minor optimizations + page reload now funtions properly
This commit is contained in:
parent
2fc434cc29
commit
8023987148
@ -109,7 +109,7 @@ public class RhythmBullet extends Game {
|
|||||||
defineSkinStyles();
|
defineSkinStyles();
|
||||||
assetManager.get("standard_thrust.p", ParticleEffect.class).flipY();
|
assetManager.get("standard_thrust.p", ParticleEffect.class).flipY();
|
||||||
if (initComplete) {
|
if (initComplete) {
|
||||||
((TransitionAdapter) getScreen()).postTransition();
|
((TransitionAdapter) getScreen()).postTransition(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,6 +125,7 @@ public class RhythmBullet extends Game {
|
|||||||
default_fontGenerator.dispose();
|
default_fontGenerator.dispose();
|
||||||
darktech_ldr_fontGenerator.dispose();
|
darktech_ldr_fontGenerator.dispose();
|
||||||
assetManager.dispose();
|
assetManager.dispose();
|
||||||
|
getScreen().dispose();
|
||||||
}
|
}
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
@ -335,4 +336,5 @@ public class RhythmBullet extends Game {
|
|||||||
public RoundingResolutionHandler getrRHandler() {
|
public RoundingResolutionHandler getrRHandler() {
|
||||||
return rRHandler;
|
return rRHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -109,19 +109,6 @@ public class Mp3Manager implements MusicManager {
|
|||||||
return sampleCount;
|
return sampleCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
playbackMusic.stop();
|
|
||||||
playbackMusic.dispose();
|
|
||||||
exec.shutdown();
|
|
||||||
try {
|
|
||||||
bitstream.close();
|
|
||||||
bitstream = null;
|
|
||||||
} catch (BitstreamException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getDuration() {
|
public float getDuration() {
|
||||||
return Float.valueOf(String.valueOf(durationInSeconds));
|
return Float.valueOf(String.valueOf(durationInSeconds));
|
||||||
@ -204,6 +191,7 @@ public class Mp3Manager implements MusicManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pause() {
|
public void pause() {
|
||||||
|
Gdx.app.debug("MP3Manager", "Pausing...");
|
||||||
playbackMusic.pause();
|
playbackMusic.pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,4 +252,18 @@ public class Mp3Manager implements MusicManager {
|
|||||||
public FileHandle getMusicFile() {
|
public FileHandle getMusicFile() {
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
Gdx.app.debug("MP3Manager", "Disposing...");
|
||||||
|
playbackMusic.stop();
|
||||||
|
playbackMusic.dispose();
|
||||||
|
exec.shutdown();
|
||||||
|
try {
|
||||||
|
bitstream.close();
|
||||||
|
bitstream = null;
|
||||||
|
} catch (BitstreamException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ public class MusicListController extends Observable implements OnCompletionListe
|
|||||||
* Loads the current selected song.
|
* Loads the current selected song.
|
||||||
*/
|
*/
|
||||||
public void loadMusic() {
|
public void loadMusic() {
|
||||||
Gdx.app.debug("MusicListController", "music is being loaded...");
|
Gdx.app.debug("MusicListController", "music is being loaded and listeners are being notified.");
|
||||||
if (mm != null) {
|
if (mm != null) {
|
||||||
mm.dispose();
|
mm.dispose();
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public class BasicVisualizer extends VisualizerCore {
|
|||||||
pixmap = new Pixmap(2, 2, Format.RGBA8888);
|
pixmap = new Pixmap(2, 2, Format.RGBA8888);
|
||||||
pixmap.setColor(Color.WHITE);
|
pixmap.setColor(Color.WHITE);
|
||||||
pixmap.fill();
|
pixmap.fill();
|
||||||
barCount = 75;
|
barCount = 70;
|
||||||
smoothRange = 2;
|
smoothRange = 2;
|
||||||
angleRot = new Vector2(MathUtils.cosDeg(rotation), MathUtils.sinDeg(rotation));
|
angleRot = new Vector2(MathUtils.cosDeg(rotation), MathUtils.sinDeg(rotation));
|
||||||
bars = new Sprite[barCount];
|
bars = new Sprite[barCount];
|
||||||
@ -116,9 +116,6 @@ public class BasicVisualizer extends VisualizerCore {
|
|||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
barTexture.dispose();
|
barTexture.dispose();
|
||||||
if (mm != null) {
|
|
||||||
mm.dispose();
|
|
||||||
}
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import javax.sound.sampled.AudioInputStream;
|
|||||||
import javax.sound.sampled.AudioSystem;
|
import javax.sound.sampled.AudioSystem;
|
||||||
import javax.sound.sampled.UnsupportedAudioFileException;
|
import javax.sound.sampled.UnsupportedAudioFileException;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
|
|
||||||
public class WavDecoder {
|
public class WavDecoder {
|
||||||
@ -22,7 +21,6 @@ public class WavDecoder {
|
|||||||
this.file = file;
|
this.file = file;
|
||||||
try {
|
try {
|
||||||
audioInputStream = AudioSystem.getAudioInputStream(file.file());
|
audioInputStream = AudioSystem.getAudioInputStream(file.file());
|
||||||
Gdx.app.debug("WAVDecoder", String.valueOf(audioInputStream.getFormat().getFrameSize()));
|
|
||||||
buffer = new byte[audioInputStream.getFormat().getFrameSize()];
|
buffer = new byte[audioInputStream.getFormat().getFrameSize()];
|
||||||
|
|
||||||
channels = audioInputStream.getFormat().getChannels();
|
channels = audioInputStream.getFormat().getChannels();
|
||||||
|
@ -29,6 +29,7 @@ public class TitleBarVisualizer extends Group implements Disposable {
|
|||||||
ParticleEffectPool beatEffectPool;
|
ParticleEffectPool beatEffectPool;
|
||||||
Array<PooledEffect> effects = new Array<>();
|
Array<PooledEffect> effects = new Array<>();
|
||||||
|
|
||||||
|
private float particleLimitTime;
|
||||||
private boolean lastEffect;
|
private boolean lastEffect;
|
||||||
public TitleBarVisualizer(AssetManager assets) {
|
public TitleBarVisualizer(AssetManager assets) {
|
||||||
if (assets == null) throw new NullPointerException("TitleBarVisualizer requires assets manager... ITS NULL YOU FOOL");
|
if (assets == null) throw new NullPointerException("TitleBarVisualizer requires assets manager... ITS NULL YOU FOOL");
|
||||||
@ -84,15 +85,16 @@ public class TitleBarVisualizer extends Group implements Disposable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
if (!lastEffect) {
|
if (particleLimitTime > 1f/60f) {
|
||||||
if (visual.getVis().getMm() != null && visual.getVis().getMm().isPlaying() && visual.getVis().getCurrentAvg() > visual.getVis().getMaxAvgHeight()*0.55f) {
|
if (visual.getVis().getMm() != null && visual.getVis().getMm().isPlaying() && visual.getVis().getCurrentAvg() > visual.getVis().getMaxAvgHeight()*0.55f) {
|
||||||
PooledEffect effect = beatEffectPool.obtain();
|
PooledEffect effect = beatEffectPool.obtain();
|
||||||
effect.setPosition(0, 0);
|
effect.setPosition(0, 0);
|
||||||
effects.add(effect);
|
effects.add(effect);
|
||||||
lastEffect = true;
|
lastEffect = true;
|
||||||
|
particleLimitTime = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
lastEffect = false;
|
particleLimitTime += delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
super.act(delta);
|
super.act(delta);
|
||||||
|
@ -36,10 +36,10 @@ public class MainPage extends Page implements Observer {
|
|||||||
private MainMenu mMenu;
|
private MainMenu mMenu;
|
||||||
private ScrollText scrollText;
|
private ScrollText scrollText;
|
||||||
|
|
||||||
public MainPage(RhythmBullet core, Vector3 targetPosition, MusicListController mlc, MainMenu mm) {
|
public MainPage(RhythmBullet core, Vector3 targetPosition, MusicListController mlc, MainMenu mainMenu) {
|
||||||
this.mlc = mlc;
|
this.mlc = mlc;
|
||||||
setTextureBackground(core.getAssetManager().get("gradients.atlas", TextureAtlas.class).findRegion("red-linear"));
|
setTextureBackground(core.getAssetManager().get("gradients.atlas", TextureAtlas.class).findRegion("red-linear"));
|
||||||
this.mMenu = mm;
|
this.mMenu = mainMenu;
|
||||||
titleBar = new TitleBarVisualizer(core.getAssetManager());
|
titleBar = new TitleBarVisualizer(core.getAssetManager());
|
||||||
addActor(titleBar);
|
addActor(titleBar);
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ public class MainPage extends Page implements Observer {
|
|||||||
@Override
|
@Override
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
targetPosition.x = Gdx.graphics.getWidth()*1.5f;
|
targetPosition.x = Gdx.graphics.getWidth()*1.5f;
|
||||||
getStage().setKeyboardFocus(mm.getMusicSelectionPage());
|
getStage().setKeyboardFocus(mainMenu.getMusicSelectionPage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
table.add(playButton).width(Gdx.graphics.getWidth()*0.2f);
|
table.add(playButton).width(Gdx.graphics.getWidth()*0.2f);
|
||||||
@ -94,6 +94,12 @@ public class MainPage extends Page implements Observer {
|
|||||||
scrollText.setWidth(0.5f*getWidth());
|
scrollText.setWidth(0.5f*getWidth());
|
||||||
scrollText.setPosition(15, getHeight() - scrollText.getHeight()-15f);
|
scrollText.setPosition(15, getHeight() - scrollText.getHeight()-15f);
|
||||||
addActor(scrollText);
|
addActor(scrollText);
|
||||||
|
|
||||||
|
if (mlc.getMusicList().isSearched() && mlc.getCurrentMusicManager() != null) {
|
||||||
|
MusicManager mManager = mlc.getCurrentMusicManager();
|
||||||
|
updateVisualsForDifferentSong(mManager);
|
||||||
|
mMenu.getMusicSelectionPage().refreshUIList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -114,12 +120,11 @@ public class MainPage extends Page implements Observer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Observable o, Object arg) {
|
public void update(Observable o, Object arg) {
|
||||||
if (o == mlc.getMusicList()) {
|
if (o == mlc.getMusicList() && mlc.getMusicList().isSearched()) {
|
||||||
mlc.shuffle(true);
|
mlc.shuffle(true);
|
||||||
MusicManager mm = mlc.getCurrentMusicManager();
|
MusicManager mm = mlc.getCurrentMusicManager();
|
||||||
updateVisualsForDifferentSong(mm);
|
updateVisualsForDifferentSong(mm);
|
||||||
mMenu.getMusicSelectionPage().refreshUIList();
|
mMenu.getMusicSelectionPage().refreshUIList();
|
||||||
mlc.play();
|
|
||||||
} else if (o == mlc) {
|
} else if (o == mlc) {
|
||||||
MusicManager mm = mlc.getCurrentMusicManager();
|
MusicManager mm = mlc.getCurrentMusicManager();
|
||||||
mlc.play();
|
mlc.play();
|
||||||
|
@ -70,11 +70,11 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
|
|||||||
mlc = new MusicListController(musicList, core.getPrefs());
|
mlc = new MusicListController(musicList, core.getPrefs());
|
||||||
mlc.setAutoPlay(true);
|
mlc.setAutoPlay(true);
|
||||||
mlc.setShuffle(true);
|
mlc.setShuffle(true);
|
||||||
postTransition();
|
postTransition(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postTransition() {
|
public void postTransition(boolean first) {
|
||||||
attemptLoadShaders();
|
attemptLoadShaders();
|
||||||
|
|
||||||
mainPage = new MainPage(core, cameraPosition, mlc, this);
|
mainPage = new MainPage(core, cameraPosition, mlc, this);
|
||||||
@ -132,10 +132,12 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
mlc.getMusicList().deleteObservers();
|
mlc.getMusicList().deleteObservers();
|
||||||
|
mlc.deleteObservers();;
|
||||||
mlc.addObserver(musicSelectionPage);
|
mlc.addObserver(musicSelectionPage);
|
||||||
mlc.addObserver(mainPage);
|
mlc.addObserver(mainPage);
|
||||||
mlc.getMusicList().addObserver(mainPage);
|
mlc.getMusicList().addObserver(mainPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attemptLoadShaders() {
|
public void attemptLoadShaders() {
|
||||||
if (core.getPrefs().getBoolean("glow shader", true)) {
|
if (core.getPrefs().getBoolean("glow shader", true)) {
|
||||||
if (core.getPrefs().getBoolean("enhanced glow", false)) {
|
if (core.getPrefs().getBoolean("enhanced glow", false)) {
|
||||||
|
@ -8,6 +8,7 @@ public interface TransitionAdapter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* called after transition completes and assets reloaded.
|
* called after transition completes and assets reloaded.
|
||||||
|
* @param first true if this is the first time load (when the game is just started or something)
|
||||||
*/
|
*/
|
||||||
public void postTransition();
|
public void postTransition(boolean first);
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,8 @@ public class DesktopLauncher {
|
|||||||
config.resizable = false;
|
config.resizable = false;
|
||||||
config.allowSoftwareMode = true;
|
config.allowSoftwareMode = true;
|
||||||
config.useHDPI = true;
|
config.useHDPI = true;
|
||||||
config.vSyncEnabled = true;
|
config.vSyncEnabled = false;
|
||||||
|
config.foregroundFPS = 0;
|
||||||
new LwjglApplication(new RhythmBullet(), config);
|
new LwjglApplication(new RhythmBullet(), config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user