diff --git a/android/assets/uiskin.atlas b/android/assets/uiskin.atlas index 977afe2..91c0a71 100755 --- a/android/assets/uiskin.atlas +++ b/android/assets/uiskin.atlas @@ -350,7 +350,7 @@ holo-pane-down rotate: false xy: 133, 8 size: 20, 20 - split: 4, 4, 4, 4 + split: 2, 2, 2, 2 orig: 20, 20 offset: 0, 0 index: -1 diff --git a/android/assets/uiskin.png b/android/assets/uiskin.png index 8c65aca..ad2946a 100755 Binary files a/android/assets/uiskin.png and b/android/assets/uiskin.png differ diff --git a/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java b/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java index 237825e..6b47901 100755 --- a/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java +++ b/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java @@ -209,6 +209,7 @@ public class Mp3Manager implements MusicManager { @Override public void play() { + Gdx.app.debug("Mp3Manager", "MP3 Playing..."); playbackMusic.play(); } diff --git a/core/src/zero1hd/rhythmbullet/audio/MusicInfo.java b/core/src/zero1hd/rhythmbullet/audio/MusicInfo.java index 746efc9..ea7d7f3 100755 --- a/core/src/zero1hd/rhythmbullet/audio/MusicInfo.java +++ b/core/src/zero1hd/rhythmbullet/audio/MusicInfo.java @@ -24,7 +24,6 @@ public class MusicInfo implements Disposable { private long durationInSeconds; private String songName; - private Texture albumCover; private String author; private int previousTop; private int ratedDifficulty; @@ -118,11 +117,7 @@ public class MusicInfo implements Disposable { public String getMusicName() { return songName.replace('_', ' '); } - - public Texture getAlbumCover() { - return albumCover; - } - + public String getAuthor() { return author; } @@ -138,10 +133,9 @@ public class MusicInfo implements Disposable { public boolean isInvalidMusic() { return invalidMusic; } - + @Override public void dispose() { - albumCover.dispose(); } /** diff --git a/core/src/zero1hd/rhythmbullet/audio/MusicList.java b/core/src/zero1hd/rhythmbullet/audio/MusicList.java index f74f58f..96214fb 100755 --- a/core/src/zero1hd/rhythmbullet/audio/MusicList.java +++ b/core/src/zero1hd/rhythmbullet/audio/MusicList.java @@ -56,6 +56,7 @@ public class MusicList extends Observable { setChanged(); Sort.instance().sort(musicList, fhac); searched = true; + if (notify) { notifyObservers(); } @@ -69,10 +70,10 @@ public class MusicList extends Observable { searched = false; exec.submit(() -> { refresh(false); + Gdx.app.debug("Asynch-MusicList", "Async refresh done. Notification has been sent."); Gdx.app.postRunnable(() -> { notifyObservers(); searched = true; - Gdx.app.debug("Asynch-MusicList", "Async refresh done. Notification has been sent."); }); }); } diff --git a/core/src/zero1hd/rhythmbullet/audio/MusicListController.java b/core/src/zero1hd/rhythmbullet/audio/MusicListController.java index dea54a3..8af3040 100755 --- a/core/src/zero1hd/rhythmbullet/audio/MusicListController.java +++ b/core/src/zero1hd/rhythmbullet/audio/MusicListController.java @@ -27,8 +27,12 @@ public class MusicListController extends Observable implements OnCompletionListe rand = new Random(); } + /** + * This play method automatically sets the volume. + */ public void play() { if (mm != null) { + Gdx.app.debug("MusicListController", "Playing from MLC."); mm.play(); mm.setVolume(prefs.getFloat("music vol", 1f)); } else { diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java b/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java index b963ddc..a5b8dfb 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java @@ -76,7 +76,7 @@ public class MusicSelectable extends WidgetGroup implements Disposable { @Override public void layout() { - displayName.setTargetWidth((int) (getWidth()/3f)); + displayName.setTargetWidth((int) (getWidth()*0.43f)); authorLabel.setTargetWidth((int) (getWidth()/3f)); displayName.resize(); authorLabel.resize(); diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MainPage.java b/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MainPage.java index 549a89e..81b8200 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MainPage.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MainPage.java @@ -119,12 +119,11 @@ public class MainPage extends Page implements Observer { MusicManager mm = mlc.getCurrentMusicManager(); updateVisualsForDifferentSong(mm); mMenu.getMusicSelectionPage().refreshUIList(); - mMenu.getMusicSelectionPage().selectMusicUI(mm); mlc.play(); } else if (o == mlc) { MusicManager mm = mlc.getCurrentMusicManager(); + mlc.play(); updateVisualsForDifferentSong(mm); - mm.play(); } } diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java b/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java index d62c70c..cfcc84c 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java @@ -34,7 +34,6 @@ import zero1hd.rhythmbullet.graphics.ui.components.ScrollText; public class MusicSelectionPage extends Page implements Observer { Preferences musicFileAnnotation; - private boolean extraInfoDone; private MusicListController mc; private MusicInfoController mic; @@ -50,13 +49,13 @@ public class MusicSelectionPage extends Page implements Observer { private Label songLength; private Label previousTop; private Label ratedDifficulty; + private Texture albumCoverTexture; private Image albumCover; + private AssetManager assets; private MusicSelectable currentlySelected; private Skin skin; - private AssetManager assets; - private boolean down, up; 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) { setTextureBackground(assetManager.get("gradients.atlas", TextureAtlas.class).findRegion("red-round")); + this.assets = assetManager; this.skin = skin; this.mc = musicListController; mic = new MusicInfoController(mc.getMusicList()); musicFileAnnotation = Gdx.app.getPreferences("music_file_annotation"); - this.assets = assetManager; musicTable = new Table(); musicTableScrollPane = new ScrollPane(musicTable, skin); musicTable.defaults().spaceTop(5f).spaceBottom(5f); @@ -185,10 +184,15 @@ public class MusicSelectionPage extends Page implements Observer { musicTable.add(selectables.get(uiSongCount)).expandX().fillX(); uiSongCount++; musicTable.row(); - } - if (mic.isDoneLoading() && uiSongInfoCount < selectables.size) { + if (uiSongCount == mc.getMusicList().getAmountOfMusic()) { + selectMusicUI(mc.getCurrentMusicManager()); + } + } else if (uiSongInfoCount < selectables.size && mic.isDoneLoading() ) { selectables.get(uiSongInfoCount).updateInfo(mic.getSongInfoArray().get(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++) { selectables.get(i).dispose(); } + mic.loadSongInfo(); musicTable.clear(); selectables.clear(); musicInfoTable.clear(); musicSubInfo.clear(); - extraInfoDone = false; uiSongCount = 0; - mic.loadSongInfo(); uiSongInfoCount = 0; Gdx.app.debug("MusicSelectionPage", "Refreshing..."); @@ -252,7 +255,7 @@ public class MusicSelectionPage extends Page implements Observer { this.currentlySelected = currentlySelected; songSelectionTimer = 1f; - if (extraInfoDone) { + if (mic.isDoneLoading()) { updateInformation(); } } @@ -308,9 +311,13 @@ public class MusicSelectionPage extends Page implements Observer { * This should only be called when everything is loaded. */ 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); author.setText("Author: " + currentlySelected.getMusicInfo().getAuthor()); - + if (albumCoverTexture != null) { + albumCoverTexture.dispose(); + } long lengthInSeconds = currentlySelected.getMusicInfo().getDurationInSeconds(); int min = (int) (lengthInSeconds/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())); ratedDifficulty.setText("Rated Difficulty: " + difficulty); - - albumCover.setDrawable((new TextureRegionDrawable(new TextureRegion(currentlySelected.getMusicInfo().getAlbumCover())))); + albumCoverTexture = currentlySelected.getMusicInfo().loadTexture(); + if (albumCoverTexture != null) { + albumCover.setDrawable((new TextureRegionDrawable(new TextureRegion(albumCoverTexture)))); + } else { + albumCover.setDrawable((new TextureRegionDrawable(new TextureRegion(assets.get("defaultCover.png", Texture.class))))); + } } } diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/windows/MusicController.java b/core/src/zero1hd/rhythmbullet/graphics/ui/windows/MusicController.java deleted file mode 100755 index d68d18a..0000000 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/windows/MusicController.java +++ /dev/null @@ -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; - } -}