minor optimizations; removed some deprecated things
This commit is contained in:
parent
fbbd079154
commit
2fc434cc29
@ -33,6 +33,7 @@ public class MusicInfo implements Disposable {
|
||||
|
||||
private FileHandle musicFile;
|
||||
private Preferences musicAnnotation;
|
||||
|
||||
public MusicInfo(FileHandle musicFile, Preferences musicAnnotation) {
|
||||
this.musicFile = musicFile;
|
||||
this.musicAnnotation = musicAnnotation;
|
||||
@ -103,6 +104,7 @@ public class MusicInfo implements Disposable {
|
||||
* @return
|
||||
*/
|
||||
public Texture loadTexture() {
|
||||
Gdx.app.debug("MusicInfo", "Texture loading for music: " + getMusicName());
|
||||
if (Gdx.files.external("RhythmBullet/AlbumArt/" + musicFile.name() + ".png").exists()) {
|
||||
return new Texture(Gdx.files.external("RhythmBullet/AlbumArt/" + musicFile.name() + ".png"));
|
||||
} else {
|
||||
|
@ -36,7 +36,7 @@ public class MusicInfoController implements Disposable {
|
||||
}
|
||||
songInfoArray.clear();
|
||||
exec.submit(() -> {
|
||||
for (int i = 0; i < musicList.getAmountOfMusic(); i++) {
|
||||
for (int i = 0; i < musicList.getTotal(); i++) {
|
||||
MusicInfo musicInfo = new MusicInfo(musicList.getMusicList().get(i), musicAnnotation);
|
||||
musicInfo.loadInfo();
|
||||
songInfoArray.add(musicInfo);
|
||||
|
@ -102,7 +102,7 @@ public class MusicList extends Observable {
|
||||
return getAudioData(musicList.get(index));
|
||||
}
|
||||
|
||||
public int getAmountOfMusic() {
|
||||
public int getTotal() {
|
||||
return musicList.size;
|
||||
}
|
||||
|
||||
|
@ -65,8 +65,8 @@ public class MusicListController extends Observable implements OnCompletionListe
|
||||
public void onCompletion(Music music) {
|
||||
if (autoPlay) {
|
||||
if (shuffle) {
|
||||
if (musicList.getAmountOfMusic() != 0) {
|
||||
currentPlaybackID = rand.nextInt(musicList.getAmountOfMusic());
|
||||
if (musicList.getTotal() != 0) {
|
||||
currentPlaybackID = rand.nextInt(musicList.getTotal());
|
||||
} else {
|
||||
currentPlaybackID = 0;
|
||||
}
|
||||
@ -83,10 +83,10 @@ public class MusicListController extends Observable implements OnCompletionListe
|
||||
* @param load whether this method should also make sure to load the music, dispose of the last one, etc. Normally called unless you plan to manually call it elswhere.
|
||||
*/
|
||||
public void shuffle(boolean load) {
|
||||
if (musicList.getAmountOfMusic() == 0) {
|
||||
if (musicList.getTotal() == 0) {
|
||||
currentPlaybackID = 0;
|
||||
} else {
|
||||
currentPlaybackID = rand.nextInt(musicList.getAmountOfMusic());
|
||||
currentPlaybackID = rand.nextInt(musicList.getTotal());
|
||||
}
|
||||
if (load) {
|
||||
loadMusic();
|
||||
@ -118,9 +118,9 @@ public class MusicListController extends Observable implements OnCompletionListe
|
||||
mm.dispose();
|
||||
}
|
||||
if (currentPlaybackID < 0) {
|
||||
currentPlaybackID = musicList.getAmountOfMusic();
|
||||
currentPlaybackID = musicList.getTotal();
|
||||
}
|
||||
if (currentPlaybackID > musicList.getAmountOfMusic()) {
|
||||
if (currentPlaybackID > musicList.getTotal()) {
|
||||
currentPlaybackID = 0;
|
||||
}
|
||||
this.mm = musicList.getMusicInfoFromIndex(currentPlaybackID);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package zero1hd.rhythmbullet.graphics.ui.components;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
@ -62,6 +63,7 @@ public class MusicSelectable extends WidgetGroup implements Disposable {
|
||||
* @param musicInfo the music information for this song.
|
||||
*/
|
||||
public void updateInfo(MusicInfo musicInfo) {
|
||||
Gdx.app.debug("MusicSelectable", "Updating info for: " + getName());
|
||||
this.musicInfo = musicInfo;
|
||||
displayName.setOriginalText(musicInfo.getMusicName());
|
||||
durationLabel.setText("Runtime: "
|
||||
|
@ -25,11 +25,6 @@ public class ShortenedTextLabel extends Label {
|
||||
this.targetWidth = targetWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
public void resize() {
|
||||
setToOriginalText();
|
||||
while (gl.width > targetWidth && (getText().length - 4) > 0) {
|
||||
|
@ -176,18 +176,22 @@ public class MusicSelectionPage extends Page implements Observer {
|
||||
}
|
||||
}
|
||||
|
||||
attemptRefreshUpdate();
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
if (uiSongCount < mc.getMusicList().getAmountOfMusic()) {
|
||||
private void attemptRefreshUpdate() {
|
||||
if (uiSongInfoCount != mc.getMusicList().getTotal()) {
|
||||
if (uiSongCount < mc.getMusicList().getTotal()) {
|
||||
MusicSelectable selectable = new MusicSelectable(mc.getMusicList().getSongFileHandleFromIndex(uiSongCount), skin, this);
|
||||
selectables.add(selectable);
|
||||
musicTable.add(selectables.get(uiSongCount)).expandX().fillX();
|
||||
uiSongCount++;
|
||||
musicTable.row();
|
||||
if (uiSongCount == mc.getMusicList().getAmountOfMusic()) {
|
||||
if (uiSongCount == mc.getMusicList().getTotal()) {
|
||||
selectMusicUI(mc.getCurrentMusicManager());
|
||||
}
|
||||
} else if (uiSongInfoCount < selectables.size && mic.isDoneLoading() ) {
|
||||
} else if (uiSongInfoCount < selectables.size && mic.isDoneLoading()) {
|
||||
selectables.get(uiSongInfoCount).updateInfo(mic.getSongInfoArray().get(uiSongInfoCount));
|
||||
uiSongInfoCount++;
|
||||
if (uiSongInfoCount == selectables.size) {
|
||||
@ -195,6 +199,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FileHandle getSelectedMusic() {
|
||||
return currentlySelected.getMusicFile();
|
||||
@ -255,7 +260,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
||||
this.currentlySelected = currentlySelected;
|
||||
songSelectionTimer = 1f;
|
||||
|
||||
if (mic.isDoneLoading()) {
|
||||
if (mic.isDoneLoading() && uiSongInfoCount == selectables.size) {
|
||||
updateInformation();
|
||||
}
|
||||
}
|
||||
@ -313,6 +318,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
||||
private void updateInformation() {
|
||||
Gdx.app.debug("MusicSelectionPage", "Updating song info panel...");
|
||||
if (currentlySelected == null) throw new NullPointerException("Buddy, you need to update this page to have the proper current music selected...");
|
||||
if (currentlySelected.getMusicInfo() == null) throw new NullPointerException("K, ur music info is null.");
|
||||
songTitle.setText(currentlySelected.getMusicInfo().getMusicName(), null);
|
||||
author.setText("Author: " + currentlySelected.getMusicInfo().getAuthor());
|
||||
if (albumCoverTexture != null) {
|
||||
|
@ -84,7 +84,7 @@ public class OptionsPage extends Page {
|
||||
|
||||
Label musicDirectoryLabel = new Label("Music Directory: ", core.getDefaultSkin());
|
||||
optionsTable.add(musicDirectoryLabel);
|
||||
Label songCount = new Label("Songs: " + sc.getMusicList().getAmountOfMusic(), core.getDefaultSkin(), "sub-font", core.getDefaultSkin().getColor("default"));
|
||||
Label songCount = new Label("Songs: " + sc.getMusicList().getTotal(), core.getDefaultSkin(), "sub-font", core.getDefaultSkin().getColor("default"));
|
||||
directoryField = new TextField(null, core.getDefaultSkin() ) {
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
@ -93,7 +93,7 @@ public class OptionsPage extends Page {
|
||||
if (musicSearchTimer <= 0) {
|
||||
sc.getMusicList().setSearchPath(directoryField.getText());
|
||||
sc.getMusicList().asynchRefresh();
|
||||
songCount.setText("Songs: " + sc.getMusicList().getAmountOfMusic());
|
||||
songCount.setText("Songs: " + sc.getMusicList().getTotal());
|
||||
}
|
||||
}
|
||||
super.act(delta);
|
||||
|
@ -9,21 +9,16 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
|
||||
import zero1hd.rhythmbullet.util.MiniSender;
|
||||
|
||||
public class Page extends Group implements Disposable {
|
||||
private Label pageTitle;
|
||||
private TextureRegion background;
|
||||
public MiniSender miniSender;
|
||||
|
||||
public Page() {
|
||||
setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
miniSender = new MiniSender();
|
||||
setTouchable(Touchable.childrenOnly);
|
||||
}
|
||||
|
||||
public Page(String titleText, Skin skin) {
|
||||
miniSender = new MiniSender();
|
||||
setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
setTouchable(Touchable.childrenOnly);
|
||||
pageTitle = new Label(titleText, skin, "large-font", skin.getColor("default"));
|
||||
|
@ -272,7 +272,7 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
|
||||
}
|
||||
|
||||
if (stage.getCamera().position.x != cameraPosition.x || stage.getCamera().position.y != cameraPosition.y) {
|
||||
stage.getCamera().position.lerp(cameraPosition, lerpAlpha);
|
||||
stage.getCamera().position.lerp(cameraPosition, delta*lerpAlpha);
|
||||
stage.getViewport().apply();
|
||||
}
|
||||
|
||||
@ -325,9 +325,9 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
|
||||
|
||||
private void calcLerpAlpha(int width) {
|
||||
if (width <= 3835) {
|
||||
lerpAlpha = 0.15f;
|
||||
lerpAlpha = 5.0f;
|
||||
} else {
|
||||
lerpAlpha = 0.15f;
|
||||
lerpAlpha = 5.5f;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user