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() {
|
public void loadSongInfo() {
|
||||||
doneLoading = false;
|
doneLoading = false;
|
||||||
|
for (int i = 0; i < songInfoArray.size; i++) {
|
||||||
|
songInfoArray.get(i).dispose();
|
||||||
|
}
|
||||||
songInfoArray.clear();
|
songInfoArray.clear();
|
||||||
exec.submit(() -> {
|
exec.submit(() -> {
|
||||||
for (int i = 0; i < musicList.getAmountOfMusic(); i++) {
|
for (int i = 0; i < musicList.getAmountOfMusic(); i++) {
|
||||||
@ -54,4 +57,8 @@ public class MusicInfoController implements Disposable {
|
|||||||
public synchronized boolean isDoneLoading() {
|
public synchronized boolean isDoneLoading() {
|
||||||
return doneLoading;
|
return doneLoading;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Array<MusicInfo> getSongInfoArray() {
|
||||||
|
return songInfoArray;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public class MusicSelectable extends WidgetGroup implements Disposable {
|
|||||||
table.setFillParent(true);
|
table.setFillParent(true);
|
||||||
this.msp = msp;
|
this.msp = msp;
|
||||||
setName(musicFile.nameWithoutExtension());
|
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"));
|
displayName = new ShortenedTextLabel(musicFile.nameWithoutExtension().replace('_', ' '), skin, "sub-font", skin.getColor("default"));
|
||||||
table.add(displayName);
|
table.add(displayName);
|
||||||
|
@ -63,6 +63,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
private TextButton beginButton;
|
private TextButton beginButton;
|
||||||
|
|
||||||
private int uiSongCount;
|
private int uiSongCount;
|
||||||
|
private int uiSongInfoCount;
|
||||||
private float scrollTimer, scrollDelay = 0.2f, scrollDelMod, songSelectionTimer;
|
private float scrollTimer, scrollDelay = 0.2f, scrollDelMod, songSelectionTimer;
|
||||||
|
|
||||||
public MusicSelectionPage(Skin skin, MusicListController musicListController, AssetManager assetManager, Vector3 cameraTarget, AnalysisPage ap) {
|
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;
|
this.assets = assetManager;
|
||||||
musicTable = new Table();
|
musicTable = new Table();
|
||||||
musicTableScrollPane = new ScrollPane(musicTable, skin);
|
musicTableScrollPane = new ScrollPane(musicTable, skin);
|
||||||
|
musicTable.defaults().spaceTop(5f).spaceBottom(5f);
|
||||||
musicTableScrollPane.setSize(0.45f*getWidth(), getHeight());
|
musicTableScrollPane.setSize(0.45f*getWidth(), getHeight());
|
||||||
musicTableScrollPane.setFadeScrollBars(false);
|
musicTableScrollPane.setFadeScrollBars(false);
|
||||||
musicTableScrollPane.setOverscroll(false, false);
|
musicTableScrollPane.setOverscroll(false, false);
|
||||||
@ -174,13 +176,20 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
setCurrentMusic();
|
setCurrentMusic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.act(delta);
|
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();
|
musicTable.add(selectables.get(uiSongCount)).expandX().fillX();
|
||||||
uiSongCount++;
|
uiSongCount++;
|
||||||
musicTable.row();
|
musicTable.row();
|
||||||
}
|
}
|
||||||
|
if (mic.isDoneLoading() && uiSongInfoCount < selectables.size) {
|
||||||
|
selectables.get(uiSongInfoCount).updateInfo(mic.getSongInfoArray().get(uiSongInfoCount));
|
||||||
|
uiSongInfoCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileHandle getSelectedMusic() {
|
public FileHandle getSelectedMusic() {
|
||||||
@ -192,6 +201,9 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void refreshUIList() {
|
public void refreshUIList() {
|
||||||
|
for (int i = 0; i < selectables.size; i++) {
|
||||||
|
selectables.get(i).dispose();
|
||||||
|
}
|
||||||
musicTable.clear();
|
musicTable.clear();
|
||||||
selectables.clear();
|
selectables.clear();
|
||||||
musicInfoTable.clear();
|
musicInfoTable.clear();
|
||||||
@ -199,17 +211,10 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
extraInfoDone = false;
|
extraInfoDone = false;
|
||||||
uiSongCount = 0;
|
uiSongCount = 0;
|
||||||
mic.loadSongInfo();
|
mic.loadSongInfo();
|
||||||
|
uiSongInfoCount = 0;
|
||||||
for (int i = 0; i < selectables.size; i++) {
|
|
||||||
selectables.get(i).dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
Gdx.app.debug("MusicSelectionPage", "Refreshing...");
|
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.add(songTitle).width(musicInfoTable.getWidth()*0.6f).spaceBottom(30f);
|
||||||
musicInfoTable.row();
|
musicInfoTable.row();
|
||||||
musicSubInfo.add(author);
|
musicSubInfo.add(author);
|
||||||
|
Loading…
Reference in New Issue
Block a user