added detailed display on screen (untested)

This commit is contained in:
Harrison Deng 2018-08-03 21:41:18 -05:00
parent b857ffe4bd
commit a39f3a25ac
2 changed files with 42 additions and 6 deletions

View File

@ -10,6 +10,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Array;
@ -89,8 +90,12 @@ public class MusicSelectable extends Button {
public void loadAlbumCover() {
metadata.loadAlbumCover();
Texture texture = defaultAlbumArt;
if (metadata.getAlbumCover() != null) {
texture = metadata.getAlbumCover();
}
synchronized (album) {
album.setDrawable(new TextureRegionDrawable(new TextureRegion(metadata.getAlbumCover())));
album.setDrawable(new TextureRegionDrawable(new TextureRegion(texture)));
}
}

View File

@ -10,6 +10,7 @@ import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
@ -21,6 +22,8 @@ import com.badlogic.gdx.scenes.scene2d.ui.Stack;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Array;
import zero1hd.rhythmbullet.audio.MusicMetadataController;
@ -38,9 +41,9 @@ public class MusicSelectionPage extends Page implements Observer {
private MusicSelectableButtonGroup selectables;
private Stack stackSelectables;
private TextButton back;
private Table musicTable;
private ScrollPane musicTableScrollPane;
private ClickListener selectionListener;
private musicSelectionLoaderThread thread;
private Table musicInfoTable;
@ -71,9 +74,7 @@ public class MusicSelectionPage extends Page implements Observer {
selectables = new MusicSelectableButtonGroup();
musicFileAnnotation = Gdx.app.getPreferences("music_file_annotation");
musicTable = new Table();
musicTableScrollPane = new ScrollPane(musicTable, skin);
musicTable.defaults().spaceTop(5f).spaceBottom(5f);
musicTableScrollPane = new ScrollPane(stackSelectables, skin);
musicTableScrollPane.setSize(0.45f*getWidth(), getHeight());
musicTableScrollPane.setFadeScrollBars(false);
musicTableScrollPane.setOverscroll(false, false);
@ -133,6 +134,31 @@ public class MusicSelectionPage extends Page implements Observer {
mmc.addObserver(this);
thread = new musicSelectionLoaderThread();
selectionListener = new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
MusicSelectable selectable = (MusicSelectable) event.getListenerActor();
if (selectable.getMetadata().getTitle() != null) {
songTitle.setText(selectable.getMetadata().getTitle(), null);
} else {
songTitle.setText(selectable.getFileHandle().nameWithoutExtension(), null);
}
author.setText(selectable.getMetadata().getAuthor());
songLength.setText(selectable.getMetadata().getDuration());
previousTop.setText("...");
ratedDifficulty.setText("...");
if (selectable.getMetadata().getAlbumCover() != null) {
albumCover.setDrawable(new TextureRegionDrawable(new TextureRegion(selectable.getMetadata().getAlbumCover())));
} else {
albumCover.setDrawable(new TextureRegionDrawable(new TextureRegion(assets.get("defaultCover.png", Texture.class))));
}
}
};
}
@Override
@ -206,7 +232,6 @@ public class MusicSelectionPage extends Page implements Observer {
selectables.clear();
mmc.loadAudioMetadata();
musicTable.clear();
selectables.clear();
musicInfoTable.clear();
musicSubInfo.clear();
@ -216,16 +241,21 @@ public class MusicSelectionPage extends Page implements Observer {
songTitle.setText("loading...", null);
musicInfoTable.add(songTitle).width(musicInfoTable.getWidth()*0.6f).spaceBottom(30f);
musicInfoTable.row();
author.setText("...");
musicSubInfo.add(author);
musicSubInfo.row();
songLength.setText("...");
musicSubInfo.add(songLength);
musicSubInfo.row();
previousTop.setText("...");
musicSubInfo.add(previousTop);
musicSubInfo.row();
ratedDifficulty.setText("...");
musicSubInfo.add(ratedDifficulty);
musicSubInfo.pack();
musicInfoTable.add(musicSubInfo).spaceBottom(20f);
musicInfoTable.row();
albumCover.setDrawable(new TextureRegionDrawable(new TextureRegion(assets.get("defaultCover.png", Texture.class))));
musicInfoTable.add(albumCover).size(musicInfoTable.getWidth()/2f);
musicInfoTable.row();
musicInfoTable.add(beginButton).spaceTop(20f).fillX();
@ -268,6 +298,7 @@ public class MusicSelectionPage extends Page implements Observer {
while (work) {
while (selectables.getButtons().size != mc.getMusicList().getTotal()) {
MusicSelectable selectable = new MusicSelectable(skin, assets.get("defaultCover.png"), mmc.getMetadata(selectables.getButtons().size), queueList);
selectable.addListener(selectionListener);
selectables.add(selectable);
}