improvements on music selection screen

This commit is contained in:
Harrison Deng 2017-10-18 22:51:02 -05:00
parent bef014c047
commit 54e9a90ac4
5 changed files with 56 additions and 13 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -3,11 +3,13 @@ package zero1hd.rhythmbullet.graphics.ui.components;
import com.badlogic.gdx.Preferences; import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.ui.Image; 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.WidgetGroup; import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Disposable; import com.badlogic.gdx.utils.Disposable;
import zero1hd.rhythmbullet.audio.SongInfo; import zero1hd.rhythmbullet.audio.SongInfo;
@ -32,13 +34,14 @@ public class MusicSelectable extends WidgetGroup implements Disposable {
table.setBackground("holo-pane"); table.setBackground("holo-pane");
setName(musicFile.name()); setName(musicFile.name());
table.defaults().pad(10f);
this.albumCover = defaultAlbumC; this.albumCover = defaultAlbumC;
this.musicFile = musicFile; this.musicFile = musicFile;
songInfo = new SongInfo(musicFile, musicAnnotation); songInfo = new SongInfo(musicFile, musicAnnotation);
imageIcon = new Image(albumCover); imageIcon = new Image(albumCover);
table.add(imageIcon).size(128f); table.add(imageIcon).size(115).padTop(15).center();
displayName = new ScrollText(musicFile.nameWithoutExtension().replace('_', ' '), null, skin, true, false); displayName = new ScrollText(musicFile.nameWithoutExtension().replace('_', ' '), null, skin, true, false);
table.add(displayName).expandX().fillX(); table.add(displayName).expandX().fillX();
@ -51,7 +54,6 @@ public class MusicSelectable extends WidgetGroup implements Disposable {
authorLabel = new Label("Loading...", skin, "sub-font", skin.getColor("default")); authorLabel = new Label("Loading...", skin, "sub-font", skin.getColor("default"));
table.add(authorLabel); table.add(authorLabel);
table.defaults().pad(10f);
addActor(table); addActor(table);
} }
@ -68,7 +70,9 @@ public class MusicSelectable extends WidgetGroup implements Disposable {
: (songInfo.getDurationInSeconds() - (songInfo.getDurationInSeconds() / 60) * 60))); : (songInfo.getDurationInSeconds() - (songInfo.getDurationInSeconds() / 60) * 60)));
authorLabel.setText("Author: " + songInfo.getAuthor()); authorLabel.setText("Author: " + songInfo.getAuthor());
songInfo.setupTexture(albumCover);
albumCover = songInfo.getAlbumCover(); albumCover = songInfo.getAlbumCover();
imageIcon.setDrawable((new TextureRegionDrawable(new TextureRegion(albumCover))));
} }
@Override @Override

View File

@ -84,16 +84,17 @@ public class MainPage extends Page implements Observer {
table.add(quitButton).fillX(); table.add(quitButton).fillX();
musicControls = new MusicControls(core.getDefaultSkin(), sc); musicControls = new MusicControls(core.getDefaultSkin(), sc);
musicControls.setPosition((getWidth()-musicControls.getMinWidth() - 20f), getHeight()-musicControls.getMinHeight()*0.8f); musicControls.setPosition((getWidth()-musicControls.getMinWidth() - 20f), getHeight()-musicControls.getMinHeight()*1.5f -15f);
musicControls.invalidate(); musicControls.invalidate();
addActor(musicControls); addActor(musicControls);
scrollText = new ScrollText("...", "...", core.getDefaultSkin(), false, true); scrollText = new ScrollText("...", "...", core.getDefaultSkin(), false, true);
scrollText.setWidth((0.4f * getWidth())); scrollText.setWidth((0.4f * getWidth()));
scrollText.setPosition(((getWidth() - scrollText.getWidth())/2f), getHeight() - scrollText.getHeight()*1.5f); scrollText.setPosition(((getWidth() - scrollText.getWidth())/2f), 0.8f*Gdx.graphics.getHeight());
if (scrollText.getX() + scrollText.getWidth() > musicControls.getX()) { if (scrollText.getX() + scrollText.getWidth() > musicControls.getX()) {
Gdx.app.debug("MainPage", "using minimal layout for scrolling text."); Gdx.app.debug("MainPage", "using minimal layout for scrolling text.");
musicControls.setX(getWidth() - musicControls.getMinWidth() - 10f); musicControls.setX(getWidth() - musicControls.getMinWidth() - 10f);
musicControls.setY(Gdx.graphics.getHeight() - 45f);
scrollText.setPosition(15, getHeight() - scrollText.getHeight() - 15f); scrollText.setPosition(15, getHeight() - scrollText.getHeight() - 15f);
musicControls.invalidate(); musicControls.invalidate();
} }

View File

@ -9,9 +9,13 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences; import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.assets.AssetManager; import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane; import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
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;
@ -37,8 +41,13 @@ public class MusicSelectionPage extends Page {
private Skin skin; private Skin skin;
private AssetManager assets; private AssetManager assets;
private Image vertSplitBar;
private Image horSplitBar;
private Texture white;
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);
setTextureBackground(assetManager.get("gradients.atlas", TextureAtlas.class).findRegion("red-round"));
this.skin = skin; this.skin = skin;
this.songList = songList; this.songList = songList;
musicFileAnnotation = Gdx.app.getPreferences("music_file_annotation"); musicFileAnnotation = Gdx.app.getPreferences("music_file_annotation");
@ -46,10 +55,13 @@ public class MusicSelectionPage extends Page {
songTable = new Table(); songTable = new Table();
songTable.defaults().spaceBottom(10f); songTable.defaults().spaceBottom(10f);
scrollbar = new ScrollPane(songTable, skin); scrollbar = new ScrollPane(songTable, skin);
scrollbar.setSize(0.4f*getWidth(), getHeightBelowTitle()); scrollbar.setSize(0.45f*getWidth(), getHeightBelowTitle());
scrollbar.setFadeScrollBars(false);
addActor(scrollbar); addActor(scrollbar);
selectables = new Array<>(); selectables = new Array<>();
back = new TextButton("Back", skin); back = new TextButton("Back", skin);
back.setWidth(back.getWidth()+20f);
back.setPosition(getWidth()-back.getWidth()-15f, getHeightBelowTitle()); back.setPosition(getWidth()-back.getWidth()-15f, getHeightBelowTitle());
back.addListener(new ChangeListener() { back.addListener(new ChangeListener() {
@Override @Override
@ -61,6 +73,22 @@ public class MusicSelectionPage extends Page {
back.toFront(); back.toFront();
refresh(); refresh();
Pixmap pixmap = new Pixmap(2, 2, Format.RGBA8888);
pixmap.setColor(skin.getColor("default"));
pixmap.fill();
white = new Texture(pixmap);
pixmap.dispose();
vertSplitBar = new Image(white);
vertSplitBar.setHeight(getHeight());
vertSplitBar.setPosition(scrollbar.getWidth() + scrollbar.getX(), 0);
addActor(vertSplitBar);
horSplitBar = new Image(white);
horSplitBar.setWidth(vertSplitBar.getX());
horSplitBar.setPosition(0, getHeightBelowTitle());
addActor(horSplitBar);
} }
@Override @Override
@ -77,7 +105,7 @@ public class MusicSelectionPage extends Page {
return selectedMusicInfo; return selectedMusicInfo;
} }
public void refresh() { public void refresh() {
Logger.getLogger("org.jaudiotagger").setLevel(Level.OFF); Logger.getLogger("org.jaudiotagger").setLevel(Level.OFF);
songTable.clear(); songTable.clear();
selectables.clear(); selectables.clear();
@ -108,4 +136,10 @@ public class MusicSelectionPage extends Page {
Gdx.app.debug("MusicSelectionPage", "Refresh complete. " + selectables.size + " songs loaded."); Gdx.app.debug("MusicSelectionPage", "Refresh complete. " + selectables.size + " songs loaded.");
}); });
} }
@Override
public void dispose() {
white.dispose();
super.dispose();
}
} }

View File

@ -336,13 +336,17 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter, Observ
} }
public void unloadShaders() { public void unloadShaders() {
brightFilterShader.dispose(); try {
combineShader.dispose(); brightFilterShader.dispose();
gaussianBlurShader.dispose(); combineShader.dispose();
normalBuffer.dispose(); gaussianBlurShader.dispose();
lightFilterBuffer.dispose(); normalBuffer.dispose();
vBlur.dispose(); lightFilterBuffer.dispose();
hBlur.dispose(); vBlur.dispose();
hBlur.dispose();
} catch (NullPointerException e) {
saveAll();
}
brightFilterShader = null; brightFilterShader = null;
combineShader = null; combineShader = null;