From 6f59e2f236c554f2f8bce6bf9b396010a34ad7dc Mon Sep 17 00:00:00 2001 From: Recrown Date: Thu, 7 Dec 2017 19:13:43 -0600 Subject: [PATCH] moar optimizations! (hopefully...) --- .../audio/MusicInfoController.java | 7 ++++++ .../ui/components/MusicSelectable.java | 2 +- .../graphics/ui/pages/MusicSelectionPage.java | 25 +++++++++++-------- 3 files changed, 23 insertions(+), 11 deletions(-) mode change 100644 => 100755 core/src/zero1hd/rhythmbullet/audio/MusicInfoController.java diff --git a/core/src/zero1hd/rhythmbullet/audio/MusicInfoController.java b/core/src/zero1hd/rhythmbullet/audio/MusicInfoController.java old mode 100644 new mode 100755 index 55ecc2d..a49bbf2 --- a/core/src/zero1hd/rhythmbullet/audio/MusicInfoController.java +++ b/core/src/zero1hd/rhythmbullet/audio/MusicInfoController.java @@ -31,6 +31,9 @@ public class MusicInfoController implements Disposable { */ public void loadSongInfo() { doneLoading = false; + for (int i = 0; i < songInfoArray.size; i++) { + songInfoArray.get(i).dispose(); + } songInfoArray.clear(); exec.submit(() -> { for (int i = 0; i < musicList.getAmountOfMusic(); i++) { @@ -54,4 +57,8 @@ public class MusicInfoController implements Disposable { public synchronized boolean isDoneLoading() { return doneLoading; } + + public Array getSongInfoArray() { + return songInfoArray; + } } diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java b/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java index cc648ad..b963ddc 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java @@ -34,7 +34,7 @@ public class MusicSelectable extends WidgetGroup implements Disposable { table.setFillParent(true); this.msp = msp; setName(musicFile.nameWithoutExtension()); - table.defaults().pad(5f).space(15f); + table.defaults().pad(5f).space(15f).expandX(); displayName = new ShortenedTextLabel(musicFile.nameWithoutExtension().replace('_', ' '), skin, "sub-font", skin.getColor("default")); table.add(displayName); diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java b/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java index 607a87a..d62c70c 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java @@ -63,6 +63,7 @@ public class MusicSelectionPage extends Page implements Observer { private TextButton beginButton; private int uiSongCount; + private int uiSongInfoCount; private float scrollTimer, scrollDelay = 0.2f, scrollDelMod, songSelectionTimer; public MusicSelectionPage(Skin skin, MusicListController musicListController, AssetManager assetManager, Vector3 cameraTarget, AnalysisPage ap) { @@ -74,6 +75,7 @@ public class MusicSelectionPage extends Page implements Observer { this.assets = assetManager; musicTable = new Table(); musicTableScrollPane = new ScrollPane(musicTable, skin); + musicTable.defaults().spaceTop(5f).spaceBottom(5f); musicTableScrollPane.setSize(0.45f*getWidth(), getHeight()); musicTableScrollPane.setFadeScrollBars(false); musicTableScrollPane.setOverscroll(false, false); @@ -174,13 +176,20 @@ public class MusicSelectionPage extends Page implements Observer { setCurrentMusic(); } } + super.act(delta); - if (uiSongCount < selectables.size) { + if (uiSongCount < mc.getMusicList().getAmountOfMusic()) { + MusicSelectable selectable = new MusicSelectable(mc.getMusicList().getSongFileHandleFromIndex(uiSongCount), skin, this); + selectables.add(selectable); musicTable.add(selectables.get(uiSongCount)).expandX().fillX(); uiSongCount++; musicTable.row(); } + if (mic.isDoneLoading() && uiSongInfoCount < selectables.size) { + selectables.get(uiSongInfoCount).updateInfo(mic.getSongInfoArray().get(uiSongInfoCount)); + uiSongInfoCount++; + } } public FileHandle getSelectedMusic() { @@ -192,6 +201,9 @@ public class MusicSelectionPage extends Page implements Observer { } public void refreshUIList() { + for (int i = 0; i < selectables.size; i++) { + selectables.get(i).dispose(); + } musicTable.clear(); selectables.clear(); musicInfoTable.clear(); @@ -199,17 +211,10 @@ public class MusicSelectionPage extends Page implements Observer { extraInfoDone = false; uiSongCount = 0; mic.loadSongInfo(); - - for (int i = 0; i < selectables.size; i++) { - selectables.get(i).dispose(); - } + uiSongInfoCount = 0; Gdx.app.debug("MusicSelectionPage", "Refreshing..."); - for (int i = 0; i < mc.getMusicList().getAmountOfMusic(); i++) { - - MusicSelectable selectable = new MusicSelectable(mc.getMusicList().getSongFileHandleFromIndex(i), skin, this); - selectables.add(selectable); - } + musicInfoTable.add(songTitle).width(musicInfoTable.getWidth()*0.6f).spaceBottom(30f); musicInfoTable.row(); musicSubInfo.add(author);