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 FileHandle musicFile;
|
||||||
private Preferences musicAnnotation;
|
private Preferences musicAnnotation;
|
||||||
|
|
||||||
public MusicInfo(FileHandle musicFile, Preferences musicAnnotation) {
|
public MusicInfo(FileHandle musicFile, Preferences musicAnnotation) {
|
||||||
this.musicFile = musicFile;
|
this.musicFile = musicFile;
|
||||||
this.musicAnnotation = musicAnnotation;
|
this.musicAnnotation = musicAnnotation;
|
||||||
@ -103,6 +104,7 @@ public class MusicInfo implements Disposable {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Texture loadTexture() {
|
public Texture loadTexture() {
|
||||||
|
Gdx.app.debug("MusicInfo", "Texture loading for music: " + getMusicName());
|
||||||
if (Gdx.files.external("RhythmBullet/AlbumArt/" + musicFile.name() + ".png").exists()) {
|
if (Gdx.files.external("RhythmBullet/AlbumArt/" + musicFile.name() + ".png").exists()) {
|
||||||
return new Texture(Gdx.files.external("RhythmBullet/AlbumArt/" + musicFile.name() + ".png"));
|
return new Texture(Gdx.files.external("RhythmBullet/AlbumArt/" + musicFile.name() + ".png"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -36,7 +36,7 @@ public class MusicInfoController implements Disposable {
|
|||||||
}
|
}
|
||||||
songInfoArray.clear();
|
songInfoArray.clear();
|
||||||
exec.submit(() -> {
|
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 musicInfo = new MusicInfo(musicList.getMusicList().get(i), musicAnnotation);
|
||||||
musicInfo.loadInfo();
|
musicInfo.loadInfo();
|
||||||
songInfoArray.add(musicInfo);
|
songInfoArray.add(musicInfo);
|
||||||
|
@ -102,7 +102,7 @@ public class MusicList extends Observable {
|
|||||||
return getAudioData(musicList.get(index));
|
return getAudioData(musicList.get(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAmountOfMusic() {
|
public int getTotal() {
|
||||||
return musicList.size;
|
return musicList.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,8 +65,8 @@ public class MusicListController extends Observable implements OnCompletionListe
|
|||||||
public void onCompletion(Music music) {
|
public void onCompletion(Music music) {
|
||||||
if (autoPlay) {
|
if (autoPlay) {
|
||||||
if (shuffle) {
|
if (shuffle) {
|
||||||
if (musicList.getAmountOfMusic() != 0) {
|
if (musicList.getTotal() != 0) {
|
||||||
currentPlaybackID = rand.nextInt(musicList.getAmountOfMusic());
|
currentPlaybackID = rand.nextInt(musicList.getTotal());
|
||||||
} else {
|
} else {
|
||||||
currentPlaybackID = 0;
|
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.
|
* @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) {
|
public void shuffle(boolean load) {
|
||||||
if (musicList.getAmountOfMusic() == 0) {
|
if (musicList.getTotal() == 0) {
|
||||||
currentPlaybackID = 0;
|
currentPlaybackID = 0;
|
||||||
} else {
|
} else {
|
||||||
currentPlaybackID = rand.nextInt(musicList.getAmountOfMusic());
|
currentPlaybackID = rand.nextInt(musicList.getTotal());
|
||||||
}
|
}
|
||||||
if (load) {
|
if (load) {
|
||||||
loadMusic();
|
loadMusic();
|
||||||
@ -118,9 +118,9 @@ public class MusicListController extends Observable implements OnCompletionListe
|
|||||||
mm.dispose();
|
mm.dispose();
|
||||||
}
|
}
|
||||||
if (currentPlaybackID < 0) {
|
if (currentPlaybackID < 0) {
|
||||||
currentPlaybackID = musicList.getAmountOfMusic();
|
currentPlaybackID = musicList.getTotal();
|
||||||
}
|
}
|
||||||
if (currentPlaybackID > musicList.getAmountOfMusic()) {
|
if (currentPlaybackID > musicList.getTotal()) {
|
||||||
currentPlaybackID = 0;
|
currentPlaybackID = 0;
|
||||||
}
|
}
|
||||||
this.mm = musicList.getMusicInfoFromIndex(currentPlaybackID);
|
this.mm = musicList.getMusicInfoFromIndex(currentPlaybackID);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package zero1hd.rhythmbullet.graphics.ui.components;
|
package zero1hd.rhythmbullet.graphics.ui.components;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
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.
|
* @param musicInfo the music information for this song.
|
||||||
*/
|
*/
|
||||||
public void updateInfo(MusicInfo musicInfo) {
|
public void updateInfo(MusicInfo musicInfo) {
|
||||||
|
Gdx.app.debug("MusicSelectable", "Updating info for: " + getName());
|
||||||
this.musicInfo = musicInfo;
|
this.musicInfo = musicInfo;
|
||||||
displayName.setOriginalText(musicInfo.getMusicName());
|
displayName.setOriginalText(musicInfo.getMusicName());
|
||||||
durationLabel.setText("Runtime: "
|
durationLabel.setText("Runtime: "
|
||||||
|
@ -25,11 +25,6 @@ public class ShortenedTextLabel extends Label {
|
|||||||
this.targetWidth = targetWidth;
|
this.targetWidth = targetWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void act(float delta) {
|
|
||||||
super.act(delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resize() {
|
public void resize() {
|
||||||
setToOriginalText();
|
setToOriginalText();
|
||||||
while (gl.width > targetWidth && (getText().length - 4) > 0) {
|
while (gl.width > targetWidth && (getText().length - 4) > 0) {
|
||||||
|
@ -176,15 +176,19 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
attemptRefreshUpdate();
|
||||||
super.act(delta);
|
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);
|
MusicSelectable selectable = new MusicSelectable(mc.getMusicList().getSongFileHandleFromIndex(uiSongCount), skin, this);
|
||||||
selectables.add(selectable);
|
selectables.add(selectable);
|
||||||
musicTable.add(selectables.get(uiSongCount)).expandX().fillX();
|
musicTable.add(selectables.get(uiSongCount)).expandX().fillX();
|
||||||
uiSongCount++;
|
uiSongCount++;
|
||||||
musicTable.row();
|
musicTable.row();
|
||||||
if (uiSongCount == mc.getMusicList().getAmountOfMusic()) {
|
if (uiSongCount == mc.getMusicList().getTotal()) {
|
||||||
selectMusicUI(mc.getCurrentMusicManager());
|
selectMusicUI(mc.getCurrentMusicManager());
|
||||||
}
|
}
|
||||||
} else if (uiSongInfoCount < selectables.size && mic.isDoneLoading()) {
|
} else if (uiSongInfoCount < selectables.size && mic.isDoneLoading()) {
|
||||||
@ -195,6 +199,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public FileHandle getSelectedMusic() {
|
public FileHandle getSelectedMusic() {
|
||||||
return currentlySelected.getMusicFile();
|
return currentlySelected.getMusicFile();
|
||||||
@ -255,7 +260,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
this.currentlySelected = currentlySelected;
|
this.currentlySelected = currentlySelected;
|
||||||
songSelectionTimer = 1f;
|
songSelectionTimer = 1f;
|
||||||
|
|
||||||
if (mic.isDoneLoading()) {
|
if (mic.isDoneLoading() && uiSongInfoCount == selectables.size) {
|
||||||
updateInformation();
|
updateInformation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -313,6 +318,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
private void updateInformation() {
|
private void updateInformation() {
|
||||||
Gdx.app.debug("MusicSelectionPage", "Updating song info panel...");
|
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 == 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);
|
songTitle.setText(currentlySelected.getMusicInfo().getMusicName(), null);
|
||||||
author.setText("Author: " + currentlySelected.getMusicInfo().getAuthor());
|
author.setText("Author: " + currentlySelected.getMusicInfo().getAuthor());
|
||||||
if (albumCoverTexture != null) {
|
if (albumCoverTexture != null) {
|
||||||
|
@ -84,7 +84,7 @@ public class OptionsPage extends Page {
|
|||||||
|
|
||||||
Label musicDirectoryLabel = new Label("Music Directory: ", core.getDefaultSkin());
|
Label musicDirectoryLabel = new Label("Music Directory: ", core.getDefaultSkin());
|
||||||
optionsTable.add(musicDirectoryLabel);
|
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() ) {
|
directoryField = new TextField(null, core.getDefaultSkin() ) {
|
||||||
@Override
|
@Override
|
||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
@ -93,7 +93,7 @@ public class OptionsPage extends Page {
|
|||||||
if (musicSearchTimer <= 0) {
|
if (musicSearchTimer <= 0) {
|
||||||
sc.getMusicList().setSearchPath(directoryField.getText());
|
sc.getMusicList().setSearchPath(directoryField.getText());
|
||||||
sc.getMusicList().asynchRefresh();
|
sc.getMusicList().asynchRefresh();
|
||||||
songCount.setText("Songs: " + sc.getMusicList().getAmountOfMusic());
|
songCount.setText("Songs: " + sc.getMusicList().getTotal());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.act(delta);
|
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.scenes.scene2d.ui.Skin;
|
||||||
import com.badlogic.gdx.utils.Disposable;
|
import com.badlogic.gdx.utils.Disposable;
|
||||||
|
|
||||||
import zero1hd.rhythmbullet.util.MiniSender;
|
|
||||||
|
|
||||||
public class Page extends Group implements Disposable {
|
public class Page extends Group implements Disposable {
|
||||||
private Label pageTitle;
|
private Label pageTitle;
|
||||||
private TextureRegion background;
|
private TextureRegion background;
|
||||||
public MiniSender miniSender;
|
|
||||||
|
|
||||||
public Page() {
|
public Page() {
|
||||||
setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
miniSender = new MiniSender();
|
|
||||||
setTouchable(Touchable.childrenOnly);
|
setTouchable(Touchable.childrenOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page(String titleText, Skin skin) {
|
public Page(String titleText, Skin skin) {
|
||||||
miniSender = new MiniSender();
|
|
||||||
setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
setTouchable(Touchable.childrenOnly);
|
setTouchable(Touchable.childrenOnly);
|
||||||
pageTitle = new Label(titleText, skin, "large-font", skin.getColor("default"));
|
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) {
|
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();
|
stage.getViewport().apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,9 +325,9 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
|
|||||||
|
|
||||||
private void calcLerpAlpha(int width) {
|
private void calcLerpAlpha(int width) {
|
||||||
if (width <= 3835) {
|
if (width <= 3835) {
|
||||||
lerpAlpha = 0.15f;
|
lerpAlpha = 5.0f;
|
||||||
} else {
|
} else {
|
||||||
lerpAlpha = 0.15f;
|
lerpAlpha = 5.5f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user