more progress on play music selection page
This commit is contained in:
parent
9c2fa0f04b
commit
bef014c047
Binary file not shown.
Before Width: | Height: | Size: 555 B After Width: | Height: | Size: 545 B |
@ -34,7 +34,6 @@ public class SongList extends Observable {
|
|||||||
public void setSearchPath(String searchPath) {
|
public void setSearchPath(String searchPath) {
|
||||||
this.searchPath = searchPath;
|
this.searchPath = searchPath;
|
||||||
setChanged();
|
setChanged();
|
||||||
notifyObservers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MusicManager getAudioData(FileHandle file) {
|
public MusicManager getAudioData(FileHandle file) {
|
||||||
|
@ -7,12 +7,12 @@ import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
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.scenes.scene2d.ui.Table;
|
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Widget;
|
import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
|
||||||
import com.badlogic.gdx.utils.Disposable;
|
import com.badlogic.gdx.utils.Disposable;
|
||||||
|
|
||||||
import zero1hd.rhythmbullet.audio.SongInfo;
|
import zero1hd.rhythmbullet.audio.SongInfo;
|
||||||
|
|
||||||
public class MusicSelectable extends Widget implements Disposable {
|
public class MusicSelectable extends WidgetGroup implements Disposable {
|
||||||
private Table table;
|
private Table table;
|
||||||
|
|
||||||
private Image imageIcon;
|
private Image imageIcon;
|
||||||
@ -30,7 +30,6 @@ public class MusicSelectable extends Widget implements Disposable {
|
|||||||
public MusicSelectable(FileHandle musicFile, Preferences musicAnnotation, Skin skin, Texture defaultAlbumC) {
|
public MusicSelectable(FileHandle musicFile, Preferences musicAnnotation, Skin skin, Texture defaultAlbumC) {
|
||||||
table = new Table(skin);
|
table = new Table(skin);
|
||||||
table.setBackground("holo-pane");
|
table.setBackground("holo-pane");
|
||||||
table.setFillParent(true);
|
|
||||||
|
|
||||||
setName(musicFile.name());
|
setName(musicFile.name());
|
||||||
|
|
||||||
@ -39,10 +38,10 @@ public class MusicSelectable extends Widget implements Disposable {
|
|||||||
songInfo = new SongInfo(musicFile, musicAnnotation);
|
songInfo = new SongInfo(musicFile, musicAnnotation);
|
||||||
|
|
||||||
imageIcon = new Image(albumCover);
|
imageIcon = new Image(albumCover);
|
||||||
table.add(imageIcon);
|
table.add(imageIcon).size(128f);
|
||||||
|
|
||||||
displayName = new ScrollText(musicFile.name(), null, skin, true, false);
|
displayName = new ScrollText(musicFile.nameWithoutExtension().replace('_', ' '), null, skin, true, false);
|
||||||
table.add(displayName);
|
table.add(displayName).expandX().fillX();
|
||||||
|
|
||||||
table.row();
|
table.row();
|
||||||
|
|
||||||
@ -50,8 +49,11 @@ public class MusicSelectable extends Widget implements Disposable {
|
|||||||
table.add(durationLabel);
|
table.add(durationLabel);
|
||||||
|
|
||||||
authorLabel = new Label("Loading...", skin, "sub-font", skin.getColor("default"));
|
authorLabel = new Label("Loading...", skin, "sub-font", skin.getColor("default"));
|
||||||
|
table.add(authorLabel);
|
||||||
|
|
||||||
table.defaults().pad(10f);
|
table.defaults().pad(10f);
|
||||||
|
|
||||||
|
addActor(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,6 +67,14 @@ public class MusicSelectable extends Widget implements Disposable {
|
|||||||
? "0" + (songInfo.getDurationInSeconds() - (songInfo.getDurationInSeconds() / 60) * 60)
|
? "0" + (songInfo.getDurationInSeconds() - (songInfo.getDurationInSeconds() / 60) * 60)
|
||||||
: (songInfo.getDurationInSeconds() - (songInfo.getDurationInSeconds() / 60) * 60)));
|
: (songInfo.getDurationInSeconds() - (songInfo.getDurationInSeconds() / 60) * 60)));
|
||||||
authorLabel.setText("Author: " + songInfo.getAuthor());
|
authorLabel.setText("Author: " + songInfo.getAuthor());
|
||||||
|
|
||||||
|
albumCover = songInfo.getAlbumCover();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void act(float delta) {
|
||||||
|
table.setSize(getWidth(), getHeight());
|
||||||
|
super.act(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileHandle getMusicFile() {
|
public FileHandle getMusicFile() {
|
||||||
|
@ -102,7 +102,7 @@ public class ScrollText extends Widget {
|
|||||||
validate();
|
validate();
|
||||||
if (text1Width + text2Width > clipBounds.getWidth()) {
|
if (text1Width + text2Width > clipBounds.getWidth()) {
|
||||||
if (scrollOnHover) {
|
if (scrollOnHover) {
|
||||||
if (scroll) {
|
if (scroll || text1Offset < 0 || text1Offset > 5) {
|
||||||
scroll(delta);
|
scroll(delta);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2,6 +2,8 @@ package zero1hd.rhythmbullet.graphics.ui.pages;
|
|||||||
|
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Preferences;
|
import com.badlogic.gdx.Preferences;
|
||||||
@ -37,15 +39,16 @@ public class MusicSelectionPage extends Page {
|
|||||||
private AssetManager assets;
|
private AssetManager assets;
|
||||||
public MusicSelectionPage(Skin skin, SongList songList, AssetManager assetManager, Vector3 cameraTarget) {
|
public MusicSelectionPage(Skin skin, SongList songList, AssetManager assetManager, Vector3 cameraTarget) {
|
||||||
super("Select music", skin);
|
super("Select music", skin);
|
||||||
|
this.skin = skin;
|
||||||
this.songList = songList;
|
this.songList = songList;
|
||||||
musicFileAnnotation = Gdx.app.getPreferences("music_file_annotation");
|
musicFileAnnotation = Gdx.app.getPreferences("music_file_annotation");
|
||||||
this.assets = assetManager;
|
this.assets = assetManager;
|
||||||
songTable = new Table(skin);
|
songTable = new Table();
|
||||||
|
songTable.defaults().spaceBottom(10f);
|
||||||
scrollbar = new ScrollPane(songTable, skin);
|
scrollbar = new ScrollPane(songTable, skin);
|
||||||
scrollbar.setSize(0.4f*getWidth(), getHeightBelowTitle());
|
scrollbar.setSize(0.4f*getWidth(), getHeightBelowTitle());
|
||||||
addActor(scrollbar);
|
addActor(scrollbar);
|
||||||
selectables = new Array<>();
|
selectables = new Array<>();
|
||||||
this.skin = skin;
|
|
||||||
back = new TextButton("Back", skin);
|
back = new TextButton("Back", skin);
|
||||||
back.setPosition(getWidth()-back.getWidth()-15f, getHeightBelowTitle());
|
back.setPosition(getWidth()-back.getWidth()-15f, getHeightBelowTitle());
|
||||||
back.addListener(new ChangeListener() {
|
back.addListener(new ChangeListener() {
|
||||||
@ -57,11 +60,12 @@ public class MusicSelectionPage extends Page {
|
|||||||
addActor(back);
|
addActor(back);
|
||||||
|
|
||||||
back.toFront();
|
back.toFront();
|
||||||
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
|
Gdx.gl.glLineWidth(2);
|
||||||
super.act(delta);
|
super.act(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,14 +78,22 @@ public class MusicSelectionPage extends Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
|
Logger.getLogger("org.jaudiotagger").setLevel(Level.OFF);
|
||||||
|
songTable.clear();
|
||||||
|
selectables.clear();
|
||||||
|
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 < songList.getAmountOfSongs(); i++) {
|
for (int i = 0; i < songList.getAmountOfSongs(); i++) {
|
||||||
|
|
||||||
MusicSelectable selectable = new MusicSelectable(songList.getSongFileHandleFromIndex(i), musicFileAnnotation, skin, assets.get("defaultCover.png", Texture.class));
|
MusicSelectable selectable = new MusicSelectable(songList.getSongFileHandleFromIndex(i), musicFileAnnotation, skin, assets.get("defaultCover.png", Texture.class));
|
||||||
selectables.add(selectable);
|
selectables.add(selectable);
|
||||||
songTable.add(selectable);
|
|
||||||
|
songTable.add(selectable).expandX().fillX().minHeight(200f);
|
||||||
songTable.row();
|
songTable.row();
|
||||||
}
|
}
|
||||||
songTable.pack();
|
|
||||||
|
|
||||||
ExecutorService exec = Executors.newSingleThreadExecutor();
|
ExecutorService exec = Executors.newSingleThreadExecutor();
|
||||||
exec.submit(() -> {
|
exec.submit(() -> {
|
||||||
@ -93,7 +105,7 @@ public class MusicSelectionPage extends Page {
|
|||||||
info.updateInfo();
|
info.updateInfo();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Gdx.app.debug("MusicSelectionPage", "Refresh complete.");
|
Gdx.app.debug("MusicSelectionPage", "Refresh complete. " + selectables.size + " songs loaded.");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,6 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter, Observ
|
|||||||
mainPage.updateVisualsForDifferentSong(sc.getCurrentSong());
|
mainPage.updateVisualsForDifferentSong(sc.getCurrentSong());
|
||||||
|
|
||||||
sc.getSongList().addObserver(this);
|
sc.getSongList().addObserver(this);
|
||||||
sc.getSongList().refresh();
|
|
||||||
|
|
||||||
Gdx.app.debug("Post Transition", "Beginning screen setup for Main menu.");
|
Gdx.app.debug("Post Transition", "Beginning screen setup for Main menu.");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user