From a39f3a25ac66b69740bafd9870be8d874fcc0cdc Mon Sep 17 00:00:00 2001 From: Recrown Date: Fri, 3 Aug 2018 21:41:18 -0500 Subject: [PATCH] added detailed display on screen (untested) --- .../ui/components/MusicSelectable.java | 7 +++- .../screens/main/MusicSelectionPage.java | 41 ++++++++++++++++--- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java b/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java index 92fb9d8..e1683a7 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java @@ -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))); } } diff --git a/desktop/src/zero1hd/rhythmbullet/desktop/screens/main/MusicSelectionPage.java b/desktop/src/zero1hd/rhythmbullet/desktop/screens/main/MusicSelectionPage.java index c7e2b0c..468f3a4 100755 --- a/desktop/src/zero1hd/rhythmbullet/desktop/screens/main/MusicSelectionPage.java +++ b/desktop/src/zero1hd/rhythmbullet/desktop/screens/main/MusicSelectionPage.java @@ -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); }