diff --git a/core/src/zero1hd/rhythmbullet/audio/MusicListController.java b/core/src/zero1hd/rhythmbullet/audio/MusicListController.java index dea54a3..4408c0f 100755 --- a/core/src/zero1hd/rhythmbullet/audio/MusicListController.java +++ b/core/src/zero1hd/rhythmbullet/audio/MusicListController.java @@ -132,6 +132,7 @@ public class MusicListController extends Observable implements OnCompletionListe public MusicManager getCurrentMusicManager() { + if (mm == null) throw new NullPointerException("Music manager not loaded yet. try calling load music."); return mm; } diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/components/Visualizer.java b/core/src/zero1hd/rhythmbullet/graphics/ui/components/Visualizer.java index d105ddc..ee033e4 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/components/Visualizer.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/components/Visualizer.java @@ -46,9 +46,6 @@ public class Visualizer extends Widget implements Disposable { public void setMM(MusicManager mm) { - if (this.mm != null) { - this.mm.dispose(); - } this.mm = mm; mmSet = false; } diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MainPage.java b/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MainPage.java index f558953..549a89e 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MainPage.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MainPage.java @@ -25,7 +25,7 @@ import zero1hd.rhythmbullet.screens.MainMenu; public class MainPage extends Page implements Observer { private Label versionLabel; - private MusicListController sc; + private MusicListController mlc; private TitleBarVisualizer titleBar; private Table table; private TextButton playButton; @@ -33,12 +33,13 @@ public class MainPage extends Page implements Observer { private TextButton quitButton; private MusicControls musicControls; - + private MainMenu mMenu; 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")); - + this.mMenu = mm; titleBar = new TitleBarVisualizer(core.getAssetManager()); addActor(titleBar); @@ -85,7 +86,7 @@ public class MainPage extends Page implements Observer { }); 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); addActor(musicControls); @@ -113,9 +114,17 @@ public class MainPage extends Page implements Observer { @Override public void update(Observable o, Object arg) { - if (o == sc) { - MusicManager mm = (MusicManager) arg; + if (o == mlc.getMusicList()) { + mlc.shuffle(true); + MusicManager mm = mlc.getCurrentMusicManager(); updateVisualsForDifferentSong(mm); + mMenu.getMusicSelectionPage().refreshUIList(); + mMenu.getMusicSelectionPage().selectMusicUI(mm); + mlc.play(); + } else if (o == mlc) { + MusicManager mm = mlc.getCurrentMusicManager(); + updateVisualsForDifferentSong(mm); + mm.play(); } } diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java b/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java index f497d68..99f10c6 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java @@ -63,10 +63,10 @@ public class MusicSelectionPage extends Page implements Observer { private TextButton beginButton; 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")); this.skin = skin; - this.mc = musicList; + this.mc = musicListController; musicFileAnnotation = Gdx.app.getPreferences("music_file_annotation"); this.assets = assetManager; musicTable = new Table(); @@ -214,7 +214,7 @@ public class MusicSelectionPage extends Page implements Observer { } extraInfoDone = true; - musicInfoTable.add(songTitle).width(musicInfoTable.getWidth()*0.7f).spaceBottom(30f); + musicInfoTable.add(songTitle).width(musicInfoTable.getWidth()*0.6f).spaceBottom(30f); musicInfoTable.row(); musicSubInfo.add(author); musicSubInfo.row(); diff --git a/core/src/zero1hd/rhythmbullet/screens/MainMenu.java b/core/src/zero1hd/rhythmbullet/screens/MainMenu.java index efdc20a..f419943 100755 --- a/core/src/zero1hd/rhythmbullet/screens/MainMenu.java +++ b/core/src/zero1hd/rhythmbullet/screens/MainMenu.java @@ -130,10 +130,10 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter { super.clicked(event, x, y); } }); - mlc.deleteObservers(); - mlc.addObserver(mainPage); + mlc.getMusicList().deleteObservers(); mlc.addObserver(musicSelectionPage); - mlc.getMusicList().addObserver(musicSelectionPage); + mlc.addObserver(mainPage); + mlc.getMusicList().addObserver(mainPage); } public void attemptLoadShaders() { if (core.getPrefs().getBoolean("glow shader", true)) {