moar optimizations! (hopefully...)
This commit is contained in:
parent
a858fa9159
commit
6f59e2f236
7
core/src/zero1hd/rhythmbullet/audio/MusicInfoController.java
Normal file → Executable file
7
core/src/zero1hd/rhythmbullet/audio/MusicInfoController.java
Normal file → Executable file
@ -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<MusicInfo> getSongInfoArray() {
|
||||
return songInfoArray;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user