music selection page now functions with new method of loading

This commit is contained in:
Harrison Deng 2017-12-05 11:59:34 -06:00
parent c41c941338
commit 6fe280044d
5 changed files with 24 additions and 17 deletions

View File

@ -132,6 +132,7 @@ public class MusicListController extends Observable implements OnCompletionListe
public MusicManager getCurrentMusicManager() { public MusicManager getCurrentMusicManager() {
if (mm == null) throw new NullPointerException("Music manager not loaded yet. try calling load music.");
return mm; return mm;
} }

View File

@ -46,9 +46,6 @@ public class Visualizer extends Widget implements Disposable {
public void setMM(MusicManager mm) { public void setMM(MusicManager mm) {
if (this.mm != null) {
this.mm.dispose();
}
this.mm = mm; this.mm = mm;
mmSet = false; mmSet = false;
} }

View File

@ -25,7 +25,7 @@ import zero1hd.rhythmbullet.screens.MainMenu;
public class MainPage extends Page implements Observer { public class MainPage extends Page implements Observer {
private Label versionLabel; private Label versionLabel;
private MusicListController sc; private MusicListController mlc;
private TitleBarVisualizer titleBar; private TitleBarVisualizer titleBar;
private Table table; private Table table;
private TextButton playButton; private TextButton playButton;
@ -33,12 +33,13 @@ public class MainPage extends Page implements Observer {
private TextButton quitButton; private TextButton quitButton;
private MusicControls musicControls; private MusicControls musicControls;
private MainMenu mMenu;
private ScrollText scrollText; private ScrollText scrollText;
public MainPage(RhythmBullet core, Vector3 targetPosition, MusicListController sc, MainMenu mm) {
this.sc = sc; public MainPage(RhythmBullet core, Vector3 targetPosition, MusicListController mlc, MainMenu mm) {
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;
titleBar = new TitleBarVisualizer(core.getAssetManager()); titleBar = new TitleBarVisualizer(core.getAssetManager());
addActor(titleBar); addActor(titleBar);
@ -85,7 +86,7 @@ public class MainPage extends Page implements Observer {
}); });
table.add(quitButton).fillX(); table.add(quitButton).fillX();
musicControls = new MusicControls(core.getDefaultSkin(), sc); musicControls = new MusicControls(core.getDefaultSkin(), mlc);
musicControls.setPosition((getWidth()-musicControls.getMinWidth() - 20f), getHeight()-musicControls.getMinHeight()-15f); musicControls.setPosition((getWidth()-musicControls.getMinWidth() - 20f), getHeight()-musicControls.getMinHeight()-15f);
addActor(musicControls); addActor(musicControls);
@ -113,9 +114,17 @@ 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 == sc) { if (o == mlc.getMusicList()) {
MusicManager mm = (MusicManager) arg; mlc.shuffle(true);
MusicManager mm = mlc.getCurrentMusicManager();
updateVisualsForDifferentSong(mm); updateVisualsForDifferentSong(mm);
mMenu.getMusicSelectionPage().refreshUIList();
mMenu.getMusicSelectionPage().selectMusicUI(mm);
mlc.play();
} else if (o == mlc) {
MusicManager mm = mlc.getCurrentMusicManager();
updateVisualsForDifferentSong(mm);
mm.play();
} }
} }

View File

@ -63,10 +63,10 @@ public class MusicSelectionPage extends Page implements Observer {
private TextButton beginButton; private TextButton beginButton;
private float scrollTimer, scrollDelay = 0.2f, scrollDelMod, songSelectionTimer; private float scrollTimer, scrollDelay = 0.2f, scrollDelMod, songSelectionTimer;
public MusicSelectionPage(Skin skin, MusicListController musicList, AssetManager assetManager, Vector3 cameraTarget, AnalysisPage ap) { public MusicSelectionPage(Skin skin, MusicListController musicListController, AssetManager assetManager, Vector3 cameraTarget, AnalysisPage ap) {
setTextureBackground(assetManager.get("gradients.atlas", TextureAtlas.class).findRegion("red-round")); setTextureBackground(assetManager.get("gradients.atlas", TextureAtlas.class).findRegion("red-round"));
this.skin = skin; this.skin = skin;
this.mc = musicList; this.mc = musicListController;
musicFileAnnotation = Gdx.app.getPreferences("music_file_annotation"); musicFileAnnotation = Gdx.app.getPreferences("music_file_annotation");
this.assets = assetManager; this.assets = assetManager;
musicTable = new Table(); musicTable = new Table();
@ -214,7 +214,7 @@ public class MusicSelectionPage extends Page implements Observer {
} }
extraInfoDone = true; extraInfoDone = true;
musicInfoTable.add(songTitle).width(musicInfoTable.getWidth()*0.7f).spaceBottom(30f); musicInfoTable.add(songTitle).width(musicInfoTable.getWidth()*0.6f).spaceBottom(30f);
musicInfoTable.row(); musicInfoTable.row();
musicSubInfo.add(author); musicSubInfo.add(author);
musicSubInfo.row(); musicSubInfo.row();

View File

@ -130,10 +130,10 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
super.clicked(event, x, y); super.clicked(event, x, y);
} }
}); });
mlc.deleteObservers(); mlc.getMusicList().deleteObservers();
mlc.addObserver(mainPage);
mlc.addObserver(musicSelectionPage); mlc.addObserver(musicSelectionPage);
mlc.getMusicList().addObserver(musicSelectionPage); mlc.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)) {