From bef014c0471f2ddf93225f337797a54e17883830 Mon Sep 17 00:00:00 2001 From: Recrown Date: Wed, 18 Oct 2017 21:27:07 -0500 Subject: [PATCH] more progress on play music selection page --- android/assets/gradients.png | Bin 555 -> 545 bytes .../zero1hd/rhythmbullet/audio/SongList.java | 1 - .../ui/components/MusicSelectable.java | 24 +++++++++++++----- .../graphics/ui/components/ScrollText.java | 2 +- .../graphics/ui/pages/MusicSelectionPage.java | 24 +++++++++++++----- .../rhythmbullet/screens/MainMenu.java | 1 - 6 files changed, 36 insertions(+), 16 deletions(-) diff --git a/android/assets/gradients.png b/android/assets/gradients.png index fc05e3755f0d0bc7621589bd3e415993039f54de..2ed51fc8c549084875dc60815b6db53b93ad780a 100755 GIT binary patch literal 545 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSEa{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C|TkfQ4*Y=R#Ki=l*&+$n3-3imzP?iV4`QBXJ~GmH$RzyfpMOv zi(^Pd+}kS`a}OJc91UQPT(vu;!EeIPyB;f=4kZ{joaq0|^5MIb-MP;_H*Dh9KYtZ` z-tL*?VY|NHx21l)|8V-n&Eq!7Hw^!L{vPYRzV5HVrvA!*(p7uzAAh@+Kf(TUPvZJ8 s`TEw>uWy)>Z48c$62ynWBbz#gUm{=Uwn(*Q0Hc$^)78&qol`;+0FMX2h5!Hn literal 555 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucLCF%=h?3y^w370~qEv>0#LT=By}Z;C1rt33 zJwtQjy!pvMQ)hd+IEGZjy}fcU^N520YhdH#BE7!DA5XtKn0zEChatGM!ZzS~f63kN zvKve7>gR{QuR6E!9MA94+CR6Q?c47!doJ_(%m(8>-|z2kujAYAd*1Te%*2=cA98Mg znUg&Cx%fWc`SyoazqDjOR*}#%N)R6gM{EBwv{in+9H#n=2N;(Op00i_>zopr0K4qw A(f|Me diff --git a/core/src/zero1hd/rhythmbullet/audio/SongList.java b/core/src/zero1hd/rhythmbullet/audio/SongList.java index 72cf0d4..bf92e83 100755 --- a/core/src/zero1hd/rhythmbullet/audio/SongList.java +++ b/core/src/zero1hd/rhythmbullet/audio/SongList.java @@ -34,7 +34,6 @@ public class SongList extends Observable { public void setSearchPath(String searchPath) { this.searchPath = searchPath; setChanged(); - notifyObservers(); } public MusicManager getAudioData(FileHandle file) { diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java b/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java index 5f2cf6c..15b5e9c 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java @@ -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.Skin; 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 zero1hd.rhythmbullet.audio.SongInfo; -public class MusicSelectable extends Widget implements Disposable { +public class MusicSelectable extends WidgetGroup implements Disposable { private Table table; private Image imageIcon; @@ -30,7 +30,6 @@ public class MusicSelectable extends Widget implements Disposable { public MusicSelectable(FileHandle musicFile, Preferences musicAnnotation, Skin skin, Texture defaultAlbumC) { table = new Table(skin); table.setBackground("holo-pane"); - table.setFillParent(true); setName(musicFile.name()); @@ -39,10 +38,10 @@ public class MusicSelectable extends Widget implements Disposable { songInfo = new SongInfo(musicFile, musicAnnotation); imageIcon = new Image(albumCover); - table.add(imageIcon); + table.add(imageIcon).size(128f); - displayName = new ScrollText(musicFile.name(), null, skin, true, false); - table.add(displayName); + displayName = new ScrollText(musicFile.nameWithoutExtension().replace('_', ' '), null, skin, true, false); + table.add(displayName).expandX().fillX(); table.row(); @@ -50,8 +49,11 @@ public class MusicSelectable extends Widget implements Disposable { table.add(durationLabel); authorLabel = new Label("Loading...", skin, "sub-font", skin.getColor("default")); + table.add(authorLabel); table.defaults().pad(10f); + + addActor(table); } /** @@ -65,8 +67,16 @@ public class MusicSelectable extends Widget implements Disposable { ? "0" + (songInfo.getDurationInSeconds() - (songInfo.getDurationInSeconds() / 60) * 60) : (songInfo.getDurationInSeconds() - (songInfo.getDurationInSeconds() / 60) * 60))); authorLabel.setText("Author: " + songInfo.getAuthor()); + + albumCover = songInfo.getAlbumCover(); } - + + @Override + public void act(float delta) { + table.setSize(getWidth(), getHeight()); + super.act(delta); + } + public FileHandle getMusicFile() { return musicFile; } diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/components/ScrollText.java b/core/src/zero1hd/rhythmbullet/graphics/ui/components/ScrollText.java index 26cf674..7e71c64 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/components/ScrollText.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/components/ScrollText.java @@ -102,7 +102,7 @@ public class ScrollText extends Widget { validate(); if (text1Width + text2Width > clipBounds.getWidth()) { if (scrollOnHover) { - if (scroll) { + if (scroll || text1Offset < 0 || text1Offset > 5) { scroll(delta); } } else { diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java b/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java index 31fecae..e742fa9 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java @@ -2,6 +2,8 @@ package zero1hd.rhythmbullet.graphics.ui.pages; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.logging.Level; +import java.util.logging.Logger; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Preferences; @@ -37,15 +39,16 @@ public class MusicSelectionPage extends Page { private AssetManager assets; public MusicSelectionPage(Skin skin, SongList songList, AssetManager assetManager, Vector3 cameraTarget) { super("Select music", skin); + this.skin = skin; this.songList = songList; musicFileAnnotation = Gdx.app.getPreferences("music_file_annotation"); this.assets = assetManager; - songTable = new Table(skin); + songTable = new Table(); + songTable.defaults().spaceBottom(10f); scrollbar = new ScrollPane(songTable, skin); scrollbar.setSize(0.4f*getWidth(), getHeightBelowTitle()); addActor(scrollbar); selectables = new Array<>(); - this.skin = skin; back = new TextButton("Back", skin); back.setPosition(getWidth()-back.getWidth()-15f, getHeightBelowTitle()); back.addListener(new ChangeListener() { @@ -57,11 +60,12 @@ public class MusicSelectionPage extends Page { addActor(back); back.toFront(); - + refresh(); } @Override public void act(float delta) { + Gdx.gl.glLineWidth(2); super.act(delta); } @@ -74,14 +78,22 @@ public class MusicSelectionPage extends Page { } 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..."); for (int i = 0; i < songList.getAmountOfSongs(); i++) { + MusicSelectable selectable = new MusicSelectable(songList.getSongFileHandleFromIndex(i), musicFileAnnotation, skin, assets.get("defaultCover.png", Texture.class)); selectables.add(selectable); - songTable.add(selectable); + + songTable.add(selectable).expandX().fillX().minHeight(200f); songTable.row(); } - songTable.pack(); ExecutorService exec = Executors.newSingleThreadExecutor(); exec.submit(() -> { @@ -93,7 +105,7 @@ public class MusicSelectionPage extends Page { info.updateInfo(); }); } - Gdx.app.debug("MusicSelectionPage", "Refresh complete."); + Gdx.app.debug("MusicSelectionPage", "Refresh complete. " + selectables.size + " songs loaded."); }); } } diff --git a/core/src/zero1hd/rhythmbullet/screens/MainMenu.java b/core/src/zero1hd/rhythmbullet/screens/MainMenu.java index 9d081f1..e9da482 100755 --- a/core/src/zero1hd/rhythmbullet/screens/MainMenu.java +++ b/core/src/zero1hd/rhythmbullet/screens/MainMenu.java @@ -136,7 +136,6 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter, Observ mainPage.updateVisualsForDifferentSong(sc.getCurrentSong()); sc.getSongList().addObserver(this); - sc.getSongList().refresh(); Gdx.app.debug("Post Transition", "Beginning screen setup for Main menu."); }