progress towards optimizations
This commit is contained in:
parent
6f59e2f236
commit
fbbd079154
@ -350,7 +350,7 @@ holo-pane-down
|
|||||||
rotate: false
|
rotate: false
|
||||||
xy: 133, 8
|
xy: 133, 8
|
||||||
size: 20, 20
|
size: 20, 20
|
||||||
split: 4, 4, 4, 4
|
split: 2, 2, 2, 2
|
||||||
orig: 20, 20
|
orig: 20, 20
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@ -209,6 +209,7 @@ public class Mp3Manager implements MusicManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void play() {
|
public void play() {
|
||||||
|
Gdx.app.debug("Mp3Manager", "MP3 Playing...");
|
||||||
playbackMusic.play();
|
playbackMusic.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ public class MusicInfo implements Disposable {
|
|||||||
|
|
||||||
private long durationInSeconds;
|
private long durationInSeconds;
|
||||||
private String songName;
|
private String songName;
|
||||||
private Texture albumCover;
|
|
||||||
private String author;
|
private String author;
|
||||||
private int previousTop;
|
private int previousTop;
|
||||||
private int ratedDifficulty;
|
private int ratedDifficulty;
|
||||||
@ -119,10 +118,6 @@ public class MusicInfo implements Disposable {
|
|||||||
return songName.replace('_', ' ');
|
return songName.replace('_', ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture getAlbumCover() {
|
|
||||||
return albumCover;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAuthor() {
|
public String getAuthor() {
|
||||||
return author;
|
return author;
|
||||||
}
|
}
|
||||||
@ -141,7 +136,6 @@ public class MusicInfo implements Disposable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
albumCover.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,6 +56,7 @@ public class MusicList extends Observable {
|
|||||||
setChanged();
|
setChanged();
|
||||||
Sort.instance().sort(musicList, fhac);
|
Sort.instance().sort(musicList, fhac);
|
||||||
searched = true;
|
searched = true;
|
||||||
|
|
||||||
if (notify) {
|
if (notify) {
|
||||||
notifyObservers();
|
notifyObservers();
|
||||||
}
|
}
|
||||||
@ -69,10 +70,10 @@ public class MusicList extends Observable {
|
|||||||
searched = false;
|
searched = false;
|
||||||
exec.submit(() -> {
|
exec.submit(() -> {
|
||||||
refresh(false);
|
refresh(false);
|
||||||
|
Gdx.app.debug("Asynch-MusicList", "Async refresh done. Notification has been sent.");
|
||||||
Gdx.app.postRunnable(() -> {
|
Gdx.app.postRunnable(() -> {
|
||||||
notifyObservers();
|
notifyObservers();
|
||||||
searched = true;
|
searched = true;
|
||||||
Gdx.app.debug("Asynch-MusicList", "Async refresh done. Notification has been sent.");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,12 @@ public class MusicListController extends Observable implements OnCompletionListe
|
|||||||
rand = new Random();
|
rand = new Random();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This play method automatically sets the volume.
|
||||||
|
*/
|
||||||
public void play() {
|
public void play() {
|
||||||
if (mm != null) {
|
if (mm != null) {
|
||||||
|
Gdx.app.debug("MusicListController", "Playing from MLC.");
|
||||||
mm.play();
|
mm.play();
|
||||||
mm.setVolume(prefs.getFloat("music vol", 1f));
|
mm.setVolume(prefs.getFloat("music vol", 1f));
|
||||||
} else {
|
} else {
|
||||||
|
@ -76,7 +76,7 @@ public class MusicSelectable extends WidgetGroup implements Disposable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void layout() {
|
public void layout() {
|
||||||
displayName.setTargetWidth((int) (getWidth()/3f));
|
displayName.setTargetWidth((int) (getWidth()*0.43f));
|
||||||
authorLabel.setTargetWidth((int) (getWidth()/3f));
|
authorLabel.setTargetWidth((int) (getWidth()/3f));
|
||||||
displayName.resize();
|
displayName.resize();
|
||||||
authorLabel.resize();
|
authorLabel.resize();
|
||||||
|
@ -119,12 +119,11 @@ public class MainPage extends Page implements Observer {
|
|||||||
MusicManager mm = mlc.getCurrentMusicManager();
|
MusicManager mm = mlc.getCurrentMusicManager();
|
||||||
updateVisualsForDifferentSong(mm);
|
updateVisualsForDifferentSong(mm);
|
||||||
mMenu.getMusicSelectionPage().refreshUIList();
|
mMenu.getMusicSelectionPage().refreshUIList();
|
||||||
mMenu.getMusicSelectionPage().selectMusicUI(mm);
|
|
||||||
mlc.play();
|
mlc.play();
|
||||||
} else if (o == mlc) {
|
} else if (o == mlc) {
|
||||||
MusicManager mm = mlc.getCurrentMusicManager();
|
MusicManager mm = mlc.getCurrentMusicManager();
|
||||||
|
mlc.play();
|
||||||
updateVisualsForDifferentSong(mm);
|
updateVisualsForDifferentSong(mm);
|
||||||
mm.play();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@ import zero1hd.rhythmbullet.graphics.ui.components.ScrollText;
|
|||||||
|
|
||||||
public class MusicSelectionPage extends Page implements Observer {
|
public class MusicSelectionPage extends Page implements Observer {
|
||||||
Preferences musicFileAnnotation;
|
Preferences musicFileAnnotation;
|
||||||
private boolean extraInfoDone;
|
|
||||||
|
|
||||||
private MusicListController mc;
|
private MusicListController mc;
|
||||||
private MusicInfoController mic;
|
private MusicInfoController mic;
|
||||||
@ -50,13 +49,13 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
private Label songLength;
|
private Label songLength;
|
||||||
private Label previousTop;
|
private Label previousTop;
|
||||||
private Label ratedDifficulty;
|
private Label ratedDifficulty;
|
||||||
|
private Texture albumCoverTexture;
|
||||||
private Image albumCover;
|
private Image albumCover;
|
||||||
|
|
||||||
|
private AssetManager assets;
|
||||||
private MusicSelectable currentlySelected;
|
private MusicSelectable currentlySelected;
|
||||||
|
|
||||||
private Skin skin;
|
private Skin skin;
|
||||||
private AssetManager assets;
|
|
||||||
|
|
||||||
private boolean down, up;
|
private boolean down, up;
|
||||||
private int musicSelectableIndex;
|
private int musicSelectableIndex;
|
||||||
|
|
||||||
@ -68,11 +67,11 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
|
|
||||||
public MusicSelectionPage(Skin skin, MusicListController musicListController, AssetManager assetManager, Vector3 cameraTarget, AnalysisPage ap) {
|
public MusicSelectionPage(Skin skin, MusicListController musicListController, AssetManager assetManager, Vector3 cameraTarget, AnalysisPage ap) {
|
||||||
setTextureBackground(assetManager.get("gradients.atlas", TextureAtlas.class).findRegion("red-round"));
|
setTextureBackground(assetManager.get("gradients.atlas", TextureAtlas.class).findRegion("red-round"));
|
||||||
|
this.assets = assetManager;
|
||||||
this.skin = skin;
|
this.skin = skin;
|
||||||
this.mc = musicListController;
|
this.mc = musicListController;
|
||||||
mic = new MusicInfoController(mc.getMusicList());
|
mic = new MusicInfoController(mc.getMusicList());
|
||||||
musicFileAnnotation = Gdx.app.getPreferences("music_file_annotation");
|
musicFileAnnotation = Gdx.app.getPreferences("music_file_annotation");
|
||||||
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);
|
musicTable.defaults().spaceTop(5f).spaceBottom(5f);
|
||||||
@ -185,10 +184,15 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
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()) {
|
||||||
|
selectMusicUI(mc.getCurrentMusicManager());
|
||||||
}
|
}
|
||||||
if (mic.isDoneLoading() && uiSongInfoCount < selectables.size) {
|
} else if (uiSongInfoCount < selectables.size && mic.isDoneLoading() ) {
|
||||||
selectables.get(uiSongInfoCount).updateInfo(mic.getSongInfoArray().get(uiSongInfoCount));
|
selectables.get(uiSongInfoCount).updateInfo(mic.getSongInfoArray().get(uiSongInfoCount));
|
||||||
uiSongInfoCount++;
|
uiSongInfoCount++;
|
||||||
|
if (uiSongInfoCount == selectables.size) {
|
||||||
|
updateInformation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,13 +208,12 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
for (int i = 0; i < selectables.size; i++) {
|
for (int i = 0; i < selectables.size; i++) {
|
||||||
selectables.get(i).dispose();
|
selectables.get(i).dispose();
|
||||||
}
|
}
|
||||||
|
mic.loadSongInfo();
|
||||||
musicTable.clear();
|
musicTable.clear();
|
||||||
selectables.clear();
|
selectables.clear();
|
||||||
musicInfoTable.clear();
|
musicInfoTable.clear();
|
||||||
musicSubInfo.clear();
|
musicSubInfo.clear();
|
||||||
extraInfoDone = false;
|
|
||||||
uiSongCount = 0;
|
uiSongCount = 0;
|
||||||
mic.loadSongInfo();
|
|
||||||
uiSongInfoCount = 0;
|
uiSongInfoCount = 0;
|
||||||
|
|
||||||
Gdx.app.debug("MusicSelectionPage", "Refreshing...");
|
Gdx.app.debug("MusicSelectionPage", "Refreshing...");
|
||||||
@ -252,7 +255,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
this.currentlySelected = currentlySelected;
|
this.currentlySelected = currentlySelected;
|
||||||
songSelectionTimer = 1f;
|
songSelectionTimer = 1f;
|
||||||
|
|
||||||
if (extraInfoDone) {
|
if (mic.isDoneLoading()) {
|
||||||
updateInformation();
|
updateInformation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -308,9 +311,13 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
* This should only be called when everything is loaded.
|
* This should only be called when everything is loaded.
|
||||||
*/
|
*/
|
||||||
private void updateInformation() {
|
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...");
|
||||||
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) {
|
||||||
|
albumCoverTexture.dispose();
|
||||||
|
}
|
||||||
long lengthInSeconds = currentlySelected.getMusicInfo().getDurationInSeconds();
|
long lengthInSeconds = currentlySelected.getMusicInfo().getDurationInSeconds();
|
||||||
int min = (int) (lengthInSeconds/60);
|
int min = (int) (lengthInSeconds/60);
|
||||||
int sec = (int) (lengthInSeconds - (min*60));
|
int sec = (int) (lengthInSeconds - (min*60));
|
||||||
@ -320,7 +327,11 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
|
|
||||||
String difficulty = (getSelectedMusicInfo().getRatedDifficulty() == -1 ? "N/A" : String.valueOf(getSelectedMusicInfo().getRatedDifficulty()));
|
String difficulty = (getSelectedMusicInfo().getRatedDifficulty() == -1 ? "N/A" : String.valueOf(getSelectedMusicInfo().getRatedDifficulty()));
|
||||||
ratedDifficulty.setText("Rated Difficulty: " + difficulty);
|
ratedDifficulty.setText("Rated Difficulty: " + difficulty);
|
||||||
|
albumCoverTexture = currentlySelected.getMusicInfo().loadTexture();
|
||||||
albumCover.setDrawable((new TextureRegionDrawable(new TextureRegion(currentlySelected.getMusicInfo().getAlbumCover()))));
|
if (albumCoverTexture != null) {
|
||||||
|
albumCover.setDrawable((new TextureRegionDrawable(new TextureRegion(albumCoverTexture))));
|
||||||
|
} else {
|
||||||
|
albumCover.setDrawable((new TextureRegionDrawable(new TextureRegion(assets.get("defaultCover.png", Texture.class)))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,138 +0,0 @@
|
|||||||
package zero1hd.rhythmbullet.graphics.ui.windows;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.Input.Keys;
|
|
||||||
import com.badlogic.gdx.audio.Music;
|
|
||||||
import com.badlogic.gdx.audio.Music.OnCompletionListener;
|
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Window;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
|
||||||
|
|
||||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
|
||||||
|
|
||||||
public class MusicController extends Window implements OnCompletionListener {
|
|
||||||
Skin skin;
|
|
||||||
private Image togglePlay;
|
|
||||||
private TextField info;
|
|
||||||
private MusicManager audiofile;
|
|
||||||
|
|
||||||
public MusicController(final Skin skin) {
|
|
||||||
super("Playback Controller", skin, "tinted");
|
|
||||||
|
|
||||||
defaults().space(5f);
|
|
||||||
|
|
||||||
this.skin = skin;
|
|
||||||
final ImageButton rewind = new ImageButton(skin.getDrawable("left-double-arrow"));
|
|
||||||
rewind.addListener(new ChangeListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
|
||||||
audiofile.setPosition(audiofile.getPositionInSeconds() - 2);
|
|
||||||
info.setText(String.valueOf(MathUtils.round(audiofile.getPositionInSeconds())) + " sec");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
add(rewind).center();
|
|
||||||
|
|
||||||
togglePlay = new Image(skin.getDrawable("loading")) {
|
|
||||||
@Override
|
|
||||||
public void act(float delta) {
|
|
||||||
super.act(delta);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
togglePlay.addListener(new ClickListener() {
|
|
||||||
@Override
|
|
||||||
public void clicked(InputEvent event, float x, float y) {
|
|
||||||
if (audiofile != null) {
|
|
||||||
if (audiofile.isPlaying()) {
|
|
||||||
audiofile.pause();
|
|
||||||
|
|
||||||
togglePlay.setDrawable(skin.getDrawable("arrow"));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
togglePlay.setDrawable(skin.getDrawable("pause"));
|
|
||||||
audiofile.play();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
super.clicked(event, x, y);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
add(togglePlay).minWidth(togglePlay.getDrawable().getMinWidth()).center();
|
|
||||||
|
|
||||||
final ImageButton fastForward = new ImageButton(skin.getDrawable("right-double-arrow"));
|
|
||||||
fastForward.addListener(new ChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
|
||||||
if (audiofile != null) {
|
|
||||||
audiofile.play();
|
|
||||||
audiofile.setPosition(audiofile.getPositionInSeconds() + 2);
|
|
||||||
info.setText(String.valueOf(MathUtils.round(audiofile.getPositionInSeconds())) + " sec");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
add(fastForward);
|
|
||||||
|
|
||||||
info = new TextField(null, skin, "ui") {
|
|
||||||
@Override
|
|
||||||
public void act(float delta) {
|
|
||||||
if (audiofile != null && audiofile.isPlaying()) {
|
|
||||||
setText(String.valueOf(MathUtils.round(audiofile.getPositionInSeconds())) + " sec");
|
|
||||||
}
|
|
||||||
super.act(delta);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
add(info);
|
|
||||||
|
|
||||||
|
|
||||||
addListener(new InputListener() {
|
|
||||||
@Override
|
|
||||||
public boolean keyUp(InputEvent event, int keycode) {
|
|
||||||
if (keycode == Keys.ENTER) {
|
|
||||||
if (!info.getText().replaceAll("(?![0-9])\\S+", "").trim().isEmpty()) {
|
|
||||||
audiofile.setPosition(Float.valueOf(info.getText().replaceAll("(?![0-9])\\S+", "").trim()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return super.keyUp(event, keycode);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
setSize(260, 75);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAudiofile(MusicManager audiofile) {
|
|
||||||
this.audiofile = audiofile;
|
|
||||||
if (this.audiofile != null) {
|
|
||||||
this.audiofile.dispose();
|
|
||||||
this.audiofile = null;
|
|
||||||
}
|
|
||||||
if (audiofile == null) {
|
|
||||||
togglePlay.setDrawable(skin.getDrawable("loading"));
|
|
||||||
info.setText("Analyzing...");
|
|
||||||
} else {
|
|
||||||
togglePlay.setDrawable(skin.getDrawable("arrow"));
|
|
||||||
info.setText("Ready.");
|
|
||||||
audiofile.play();
|
|
||||||
audiofile.pause();
|
|
||||||
audiofile.setOnCompletionListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public MusicManager getAudiofile() {
|
|
||||||
return audiofile;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCompletion(Music music) {
|
|
||||||
audiofile.dispose();
|
|
||||||
audiofile = null;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user