progress on untested framework
This commit is contained in:
parent
590cb39902
commit
45da676d0d
@ -36,7 +36,7 @@ public class RhythmBullet extends Game {
|
|||||||
private AssetManager assetManager = new AssetManager();
|
private AssetManager assetManager = new AssetManager();
|
||||||
private Skin skin;
|
private Skin skin;
|
||||||
TextureAtlas skinAtlas;
|
TextureAtlas skinAtlas;
|
||||||
private Preferences prefs;
|
private Preferences preferences;
|
||||||
private RoundingResolutionHandler rRHandler;
|
private RoundingResolutionHandler rRHandler;
|
||||||
private Screen initialScreen;
|
private Screen initialScreen;
|
||||||
private AssetPack assetPack;
|
private AssetPack assetPack;
|
||||||
@ -58,7 +58,7 @@ public class RhythmBullet extends Game {
|
|||||||
|
|
||||||
assetPack.initiateResources();
|
assetPack.initiateResources();
|
||||||
|
|
||||||
prefs = Gdx.app.getPreferences("RhythmBullet Preferences");
|
preferences = Gdx.app.getPreferences("RhythmBullet Preferences");
|
||||||
|
|
||||||
Resolution[] resolution = {
|
Resolution[] resolution = {
|
||||||
new Resolution(1280, 720, "1280x720"),
|
new Resolution(1280, 720, "1280x720"),
|
||||||
@ -78,7 +78,7 @@ public class RhythmBullet extends Game {
|
|||||||
assetManager.setLoader(ParticleEffect.class, new ParticleEffectLoader(genericFileFinder));
|
assetManager.setLoader(ParticleEffect.class, new ParticleEffectLoader(genericFileFinder));
|
||||||
assetManager.setLoader(Sound.class, new SoundLoader(genericFileFinder));
|
assetManager.setLoader(Sound.class, new SoundLoader(genericFileFinder));
|
||||||
|
|
||||||
rRHandler.setResolution(getPrefs().getInteger("screen-width"), getPrefs().getInteger("screen-height"));
|
rRHandler.setResolution(getPreferences().getInteger("screen-width"), getPreferences().getInteger("screen-height"));
|
||||||
|
|
||||||
|
|
||||||
screenWidth = Gdx.graphics.getWidth();
|
screenWidth = Gdx.graphics.getWidth();
|
||||||
@ -86,10 +86,10 @@ public class RhythmBullet extends Game {
|
|||||||
|
|
||||||
pixels_per_unit = (int) (Float.valueOf(screenHeight)/Float.valueOf(WORLD_HEIGHT));
|
pixels_per_unit = (int) (Float.valueOf(screenHeight)/Float.valueOf(WORLD_HEIGHT));
|
||||||
|
|
||||||
if (getPrefs().getBoolean("fullscreen", true)) {
|
if (getPreferences().getBoolean("fullscreen", true)) {
|
||||||
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
|
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
|
||||||
} else {
|
} else {
|
||||||
Gdx.graphics.setWindowedMode(getPrefs().getInteger("screen-width"), getPrefs().getInteger("screen-height"));
|
Gdx.graphics.setWindowedMode(getPreferences().getInteger("screen-width"), getPreferences().getInteger("screen-height"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,9 +161,9 @@ public class RhythmBullet extends Game {
|
|||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Cannot perform window resize on a screen that isn't using a resize ready screen.");
|
throw new IllegalStateException("Cannot perform window resize on a screen that isn't using a resize ready screen.");
|
||||||
}
|
}
|
||||||
prefs.putInteger("screen-width", width);
|
preferences.putInteger("screen-width", width);
|
||||||
prefs.putInteger("screen-height", height);
|
preferences.putInteger("screen-height", height);
|
||||||
prefs.flush();
|
preferences.flush();
|
||||||
resizing = true;
|
resizing = true;
|
||||||
assetManager.clear();
|
assetManager.clear();
|
||||||
queueAssets();
|
queueAssets();
|
||||||
@ -185,8 +185,8 @@ public class RhythmBullet extends Game {
|
|||||||
return skin;
|
return skin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Preferences getPrefs() {
|
public Preferences getPreferences() {
|
||||||
return prefs;
|
return preferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,7 +31,11 @@ public class MusicList extends Observable {
|
|||||||
* Also notifies listeners that are on the main thread.
|
* Also notifies listeners that are on the main thread.
|
||||||
*/
|
*/
|
||||||
public void asyncSearch() {
|
public void asyncSearch() {
|
||||||
searchThread.start();
|
if (!searchThread.start()) {
|
||||||
|
searchThread.stop();
|
||||||
|
searchThread = new RecursiveMusicSearchThread("Music Search Thread");
|
||||||
|
searchThread.start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSearchPath(String searchPath) {
|
public void setSearchPath(String searchPath) {
|
||||||
@ -96,6 +100,7 @@ public class MusicList extends Observable {
|
|||||||
private Thread thread;
|
private Thread thread;
|
||||||
private String threadName;
|
private String threadName;
|
||||||
private FileHandle directory;
|
private FileHandle directory;
|
||||||
|
private volatile boolean work;
|
||||||
|
|
||||||
public RecursiveMusicSearchThread(String name) {
|
public RecursiveMusicSearchThread(String name) {
|
||||||
this.threadName = name;
|
this.threadName = name;
|
||||||
@ -107,23 +112,32 @@ public class MusicList extends Observable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
musicList = recursiveMusicSearch(directory);
|
Array<FileHandle> obtainedAudioFiles = recursiveMusicSearch(directory);
|
||||||
searchComplete();
|
if (work) {
|
||||||
|
musicList = obtainedAudioFiles;
|
||||||
|
searchComplete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public boolean start() {
|
||||||
if (thread == null && !thread.isAlive()) {
|
if (thread == null) {
|
||||||
|
work = true;
|
||||||
thread = new Thread(this, threadName);
|
thread = new Thread(this, threadName);
|
||||||
thread.start();
|
thread.start();
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Two " + threadName + " instances (threads) were created. This is not allowed for optimization as there is no reason to have two running.");
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void stop() {
|
||||||
|
work = false;
|
||||||
|
}
|
||||||
|
|
||||||
private Array<FileHandle> recursiveMusicSearch(FileHandle fileHandle) {
|
private Array<FileHandle> recursiveMusicSearch(FileHandle fileHandle) {
|
||||||
Array<FileHandle> musicFiles = new Array<>();
|
Array<FileHandle> musicFiles = new Array<>();
|
||||||
FileHandle[] files = fileHandle.list();
|
FileHandle[] files = fileHandle.list();
|
||||||
for (int i = 0; i < files.length; i++) {
|
for (int i = 0; i < files.length && work; i++) {
|
||||||
if (files[i].isDirectory()) {
|
if (files[i].isDirectory()) {
|
||||||
musicFiles.addAll(recursiveMusicSearch(files[i]));
|
musicFiles.addAll(recursiveMusicSearch(files[i]));
|
||||||
} else {
|
} else {
|
||||||
|
@ -11,7 +11,7 @@ import zero1hd.rhythmbullet.audio.metadata.AudioMetadata;
|
|||||||
import zero1hd.rhythmbullet.audio.metadata.MP3Metadata;
|
import zero1hd.rhythmbullet.audio.metadata.MP3Metadata;
|
||||||
import zero1hd.rhythmbullet.audio.metadata.WAVMetadata;
|
import zero1hd.rhythmbullet.audio.metadata.WAVMetadata;
|
||||||
|
|
||||||
public class MusicMetadataController implements Disposable, Observer {
|
public class MusicMetadataController extends Observable implements Disposable, Observer {
|
||||||
private MusicList musicList;
|
private MusicList musicList;
|
||||||
private Array<AudioMetadata> metadataArray;
|
private Array<AudioMetadata> metadataArray;
|
||||||
private MetadataLoadingThread loadingThread;
|
private MetadataLoadingThread loadingThread;
|
||||||
@ -20,6 +20,8 @@ public class MusicMetadataController implements Disposable, Observer {
|
|||||||
public MusicMetadataController(MusicList musicList) {
|
public MusicMetadataController(MusicList musicList) {
|
||||||
this.musicList = musicList;
|
this.musicList = musicList;
|
||||||
metadataArray = new Array<>();
|
metadataArray = new Array<>();
|
||||||
|
loadingThread = new MetadataLoadingThread();
|
||||||
|
musicList.addObserver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MusicList getMusicList() {
|
public MusicList getMusicList() {
|
||||||
@ -29,8 +31,12 @@ public class MusicMetadataController implements Disposable, Observer {
|
|||||||
/**
|
/**
|
||||||
* Non-blocking, loads on separate thread.
|
* Non-blocking, loads on separate thread.
|
||||||
*/
|
*/
|
||||||
public void loadSongInfo() {
|
public void loadAudioMetadata() {
|
||||||
loadingThread.start();
|
if (!loadingThread.start()) {
|
||||||
|
loadingThread.stop();
|
||||||
|
loadingThread = new MetadataLoadingThread();
|
||||||
|
loadingThread.start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDone() {
|
public boolean isDone() {
|
||||||
@ -66,6 +72,7 @@ public class MusicMetadataController implements Disposable, Observer {
|
|||||||
private class MetadataLoadingThread implements Runnable {
|
private class MetadataLoadingThread implements Runnable {
|
||||||
private Thread thread;
|
private Thread thread;
|
||||||
private String name = "Metadata-Load";
|
private String name = "Metadata-Load";
|
||||||
|
private volatile boolean work;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -74,7 +81,7 @@ public class MusicMetadataController implements Disposable, Observer {
|
|||||||
metadataArray.get(i).dispose();
|
metadataArray.get(i).dispose();
|
||||||
}
|
}
|
||||||
metadataArray.clear();
|
metadataArray.clear();
|
||||||
for (int i = 0; i < musicList.getTotal(); i++) {
|
for (int i = 0; i < musicList.getTotal() && work; i++) {
|
||||||
FileHandle musicFile = musicList.getMusicArray().get(i);
|
FileHandle musicFile = musicList.getMusicArray().get(i);
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
switch (SupportedFormats.valueOf(musicFile.extension().toUpperCase())) {
|
switch (SupportedFormats.valueOf(musicFile.extension().toUpperCase())) {
|
||||||
@ -90,19 +97,32 @@ public class MusicMetadataController implements Disposable, Observer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
searching = false;
|
if (work) {
|
||||||
|
searching = false;
|
||||||
|
notifyObservers();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public boolean start() {
|
||||||
if (thread != null && !thread.isAlive()) {
|
if (thread == null) {
|
||||||
thread = new Thread(this, name);
|
thread = new Thread(this, name);
|
||||||
thread.start();
|
thread.start();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void stop() {
|
||||||
|
work = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Observable o, Object arg) {
|
public void update(Observable o, Object arg) {
|
||||||
// TODO Auto-generated method stub
|
if (o == musicList) {
|
||||||
|
loadingThread.stop();
|
||||||
|
loadAudioMetadata();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,12 @@ package zero1hd.rhythmbullet.audio.analyzer;
|
|||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
import com.badlogic.gdx.utils.Disposable;
|
|
||||||
import com.badlogic.gdx.utils.FloatArray;
|
import com.badlogic.gdx.utils.FloatArray;
|
||||||
|
|
||||||
import edu.emory.mathcs.jtransforms.fft.FloatFFT_1D;
|
import edu.emory.mathcs.jtransforms.fft.FloatFFT_1D;
|
||||||
import zero1hd.rhythmbullet.audio.processor.AudioProcessor;
|
import zero1hd.rhythmbullet.audio.processor.AudioProcessor;
|
||||||
|
|
||||||
public class AudioAnalyzer implements Runnable, Disposable {
|
public class AudioAnalyzer implements Runnable {
|
||||||
private Thread thread;
|
private Thread thread;
|
||||||
private String threadName = "Audio-Analyzer";
|
private String threadName = "Audio-Analyzer";
|
||||||
|
|
||||||
@ -38,15 +37,15 @@ public class AudioAnalyzer implements Runnable, Disposable {
|
|||||||
private int PUID;
|
private int PUID;
|
||||||
private int progress;
|
private int progress;
|
||||||
|
|
||||||
public AudioAnalyzer(AudioProcessor audioProcessor) {
|
public boolean start(AudioProcessor processor) {
|
||||||
this.processor = audioProcessor;
|
if (thread == null) {
|
||||||
}
|
this.processor = processor;
|
||||||
|
|
||||||
public void start() {
|
|
||||||
if (thread == null || !thread.isAlive()) {
|
|
||||||
work = true;
|
work = true;
|
||||||
thread = new Thread(this, threadName);
|
thread = new Thread(this, threadName);
|
||||||
thread.start();
|
thread.start();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,13 +282,6 @@ public class AudioAnalyzer implements Runnable, Disposable {
|
|||||||
return progress;
|
return progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
if (thread != null) {
|
|
||||||
work = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
work = false;
|
work = false;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,13 @@ public interface AudioMetadata extends Disposable {
|
|||||||
*
|
*
|
||||||
* @return the length of the song with proper fomatting.
|
* @return the length of the song with proper fomatting.
|
||||||
*/
|
*/
|
||||||
public String getLength();
|
public String getDuration();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return the length of the song in seconds.
|
||||||
|
*/
|
||||||
|
public int getLength();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -18,7 +18,8 @@ import com.badlogic.gdx.graphics.Pixmap;
|
|||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
|
|
||||||
public class MP3Metadata implements AudioMetadata {
|
public class MP3Metadata implements AudioMetadata {
|
||||||
private String title, author, length, genre;
|
private String title, author, duration, genre;
|
||||||
|
private int length;
|
||||||
private Texture albumCover;
|
private Texture albumCover;
|
||||||
private FileHandle fileHandle;
|
private FileHandle fileHandle;
|
||||||
|
|
||||||
@ -38,9 +39,9 @@ public class MP3Metadata implements AudioMetadata {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int lenInSec = mp3file.getAudioHeader().getTrackLength();
|
length = mp3file.getAudioHeader().getTrackLength();
|
||||||
int min = (int) (lenInSec/60);
|
int min = (int) (length/60);
|
||||||
length = (lenInSec/60) + ":" + (lenInSec - (min*60));
|
duration = (length/60) + ":" + (length - (min*60));
|
||||||
|
|
||||||
author = tag.getFirst(ID3v23FieldKey.ARTIST);
|
author = tag.getFirst(ID3v23FieldKey.ARTIST);
|
||||||
genre = tag.getFirst(ID3v23FieldKey.GENRE);
|
genre = tag.getFirst(ID3v23FieldKey.GENRE);
|
||||||
@ -86,7 +87,12 @@ public class MP3Metadata implements AudioMetadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLength() {
|
public String getDuration() {
|
||||||
|
return duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLength() {
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,8 @@ import com.badlogic.gdx.graphics.Pixmap;
|
|||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
|
|
||||||
public class WAVMetadata implements AudioMetadata {
|
public class WAVMetadata implements AudioMetadata {
|
||||||
private String title, author, length, genre;
|
private String title, author, duration, genre;
|
||||||
|
private int length;
|
||||||
private Texture albumCover;
|
private Texture albumCover;
|
||||||
private FileHandle fileHandle;
|
private FileHandle fileHandle;
|
||||||
|
|
||||||
@ -26,9 +27,9 @@ public class WAVMetadata implements AudioMetadata {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
AudioFile wav = AudioFileIO.read(fileHandle.file());
|
AudioFile wav = AudioFileIO.read(fileHandle.file());
|
||||||
int lenInSec = wav.getAudioHeader().getTrackLength();
|
length = wav.getAudioHeader().getTrackLength();
|
||||||
int min = (int) (lenInSec/60);
|
int min = (int) (length/60);
|
||||||
this.length = (lenInSec/60) + ":" + (lenInSec - (min*60));
|
this.duration = (length/60) + ":" + (length - (min*60));
|
||||||
|
|
||||||
Tag tag = wav.getTag();
|
Tag tag = wav.getTag();
|
||||||
title = tag.getFirst(FieldKey.TITLE);
|
title = tag.getFirst(FieldKey.TITLE);
|
||||||
@ -70,9 +71,15 @@ public class WAVMetadata implements AudioMetadata {
|
|||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String getLength() {
|
public String getDuration() {
|
||||||
|
return duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLength() {
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Texture getAlbumCover() {
|
public Texture getAlbumCover() {
|
||||||
return albumCover;
|
return albumCover;
|
||||||
|
74
core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java
Executable file
74
core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java
Executable file
@ -0,0 +1,74 @@
|
|||||||
|
package zero1hd.rhythmbullet.graphics.ui.components;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Button;
|
||||||
|
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.TextureRegionDrawable;
|
||||||
|
|
||||||
|
import zero1hd.rhythmbullet.audio.metadata.AudioMetadata;
|
||||||
|
|
||||||
|
public class MusicSelectable extends Button {
|
||||||
|
private Vector2 actualCoords;
|
||||||
|
private Image album;
|
||||||
|
private Table informationTable;
|
||||||
|
private ShortenedLabel name, artist;
|
||||||
|
private Label time;
|
||||||
|
private float timeSinceOnScreen;
|
||||||
|
private AudioMetadata metadata;
|
||||||
|
private Texture defaultAlbumArt;
|
||||||
|
|
||||||
|
|
||||||
|
public MusicSelectable(Skin skin, Texture defaultAlbumArt, AudioMetadata metadata) {
|
||||||
|
super(skin, "music-selectable");
|
||||||
|
this.metadata = metadata;
|
||||||
|
this.defaultAlbumArt = defaultAlbumArt;
|
||||||
|
|
||||||
|
album = new Image(defaultAlbumArt);
|
||||||
|
add(album).expand().left();
|
||||||
|
|
||||||
|
informationTable = new Table();
|
||||||
|
name = new ShortenedLabel(metadata.getTitle(), skin, "default-font", skin.getColor("default"));
|
||||||
|
informationTable.add(name).colspan(2).expandX();
|
||||||
|
informationTable.row();
|
||||||
|
artist = new ShortenedLabel(metadata.getTitle(), skin, "sub-font", skin.getColor("default"));
|
||||||
|
informationTable.add(artist).expandX();
|
||||||
|
time = new Label(metadata.getDuration(), skin, "sub-font", skin.getColor("default"));
|
||||||
|
informationTable.add(time).expandX();
|
||||||
|
add(informationTable).expand().fill();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void act(float delta) {
|
||||||
|
actualCoords.x = getX() + getParent().getX();
|
||||||
|
actualCoords.y = getY() + getParent().getY();
|
||||||
|
|
||||||
|
if (actualCoords.y < 0-getHeight() || actualCoords.y > getStage().getHeight() || actualCoords.x < 0-getWidth() || actualCoords.x > getStage().getWidth()) {
|
||||||
|
offScreenAct(delta);
|
||||||
|
} else {
|
||||||
|
onScreenAct(delta);
|
||||||
|
}
|
||||||
|
super.act(delta);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onScreenAct(float delta) {
|
||||||
|
timeSinceOnScreen = 0;
|
||||||
|
if (metadata.getAlbumCover() == null) {
|
||||||
|
metadata.loadAlbumCover();
|
||||||
|
album.setDrawable(new TextureRegionDrawable(new TextureRegion(metadata.getAlbumCover())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void offScreenAct(float delta) {
|
||||||
|
if (metadata.getAlbumCover() != null) {
|
||||||
|
timeSinceOnScreen += delta;
|
||||||
|
if (timeSinceOnScreen >= 2) {
|
||||||
|
metadata.unloadAlbumCover();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -89,6 +89,8 @@ public class ScrollText extends Widget {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void layout() {
|
public void layout() {
|
||||||
|
super.layout();
|
||||||
|
|
||||||
if (getHeight() < (textHeight+4)) {
|
if (getHeight() < (textHeight+4)) {
|
||||||
setHeight(textHeight + 4);
|
setHeight(textHeight + 4);
|
||||||
}
|
}
|
||||||
@ -98,7 +100,6 @@ public class ScrollText extends Widget {
|
|||||||
if (text1Width < clipBounds.getWidth()) {
|
if (text1Width < clipBounds.getWidth()) {
|
||||||
text1Offset = (clipBounds.getWidth()-text1Width)/2f;
|
text1Offset = (clipBounds.getWidth()-text1Width)/2f;
|
||||||
}
|
}
|
||||||
super.layout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,34 +3,37 @@ package zero1hd.rhythmbullet.graphics.ui.components;
|
|||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
||||||
|
import com.badlogic.gdx.math.Vector2;
|
||||||
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;
|
||||||
|
|
||||||
public class ShortenedTextLabel extends Label {
|
public class ShortenedLabel extends Label {
|
||||||
private String originalText;
|
private String originalText;
|
||||||
private int targetWidth;
|
private int targetWidth;
|
||||||
private GlyphLayout gl;
|
private GlyphLayout gl;
|
||||||
private BitmapFont font;
|
private BitmapFont font;
|
||||||
|
private Vector2 size;
|
||||||
|
|
||||||
public ShortenedTextLabel(CharSequence text, Skin skin, String fontName, Color color) {
|
public ShortenedLabel(CharSequence text, Skin skin, String fontName, Color color) {
|
||||||
super(text, skin, fontName, color);
|
super(null, skin, fontName, color);
|
||||||
originalText = text.toString();
|
originalText = text.toString();
|
||||||
font = skin.getFont(fontName);
|
font = skin.getFont(fontName);
|
||||||
if (text != null) {
|
if (text != null) {
|
||||||
gl = new GlyphLayout(skin.getFont(fontName), text);
|
gl = new GlyphLayout(skin.getFont(fontName), text);
|
||||||
}
|
}
|
||||||
}
|
size = new Vector2();
|
||||||
|
|
||||||
public void setTargetWidth(int targetWidth) {
|
setWrap(true);
|
||||||
this.targetWidth = targetWidth;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resize() {
|
public void resize() {
|
||||||
setToOriginalText();
|
setToOriginalText();
|
||||||
while (gl.width > targetWidth && (getText().length - 4) > 0) {
|
String text = getText().toString();
|
||||||
setText(getText().substring(0, getText().length - 4).concat("..."));
|
while (gl.width > targetWidth && (text.length() - 4) > 0) {
|
||||||
gl.setText(font, getText());
|
text = text.substring(0, text.length() - 4).concat("...");
|
||||||
|
gl.setText(font, text);
|
||||||
}
|
}
|
||||||
|
setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setToOriginalText() {
|
public void setToOriginalText() {
|
||||||
@ -41,6 +44,10 @@ public class ShortenedTextLabel extends Label {
|
|||||||
@Override
|
@Override
|
||||||
public void layout() {
|
public void layout() {
|
||||||
super.layout();
|
super.layout();
|
||||||
|
size.x = getWidth();
|
||||||
|
size.y = getHeight();
|
||||||
|
targetWidth = (int) getStage().stageToScreenCoordinates(size).x;
|
||||||
|
resize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOriginalText(String originalText) {
|
public void setOriginalText(String originalText) {
|
@ -11,6 +11,7 @@ import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
|||||||
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter;
|
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter;
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Button.ButtonStyle;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox.CheckBoxStyle;
|
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox.CheckBoxStyle;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton.ImageButtonStyle;
|
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton.ImageButtonStyle;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
|
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
|
||||||
@ -170,6 +171,11 @@ public class DesktopAssetPack implements AssetPack {
|
|||||||
shuffleButtonStyle.checkboxOff = skin.getDrawable("shuffle");
|
shuffleButtonStyle.checkboxOff = skin.getDrawable("shuffle");
|
||||||
shuffleButtonStyle.checkboxOn = skin.getDrawable("shuffle-down");
|
shuffleButtonStyle.checkboxOn = skin.getDrawable("shuffle-down");
|
||||||
skin.add("shuffle-button", shuffleButtonStyle);
|
skin.add("shuffle-button", shuffleButtonStyle);
|
||||||
|
|
||||||
|
ButtonStyle musicSelectable = new ButtonStyle();
|
||||||
|
musicSelectable.checked = skin.getDrawable("holo-pane-down");
|
||||||
|
musicSelectable.up = skin.getDrawable("holo-pane");
|
||||||
|
skin.add("music-selectable", musicSelectable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,7 +26,7 @@ public class GraphicsOptions extends Table {
|
|||||||
_1366x768;
|
_1366x768;
|
||||||
|
|
||||||
|
|
||||||
public GraphicsOptions(Skin skin, final Preferences prefs) {
|
public GraphicsOptions(Skin skin, final Preferences prefs, ChangeListener bloomLevelSliderListener) {
|
||||||
align(Align.center);
|
align(Align.center);
|
||||||
defaults().space(10f);
|
defaults().space(10f);
|
||||||
this.prefs = prefs;
|
this.prefs = prefs;
|
||||||
@ -35,8 +35,9 @@ public class GraphicsOptions extends Table {
|
|||||||
row();
|
row();
|
||||||
|
|
||||||
glowShaderLevel = new Slider(0, 4, 1, false, skin);
|
glowShaderLevel = new Slider(0, 4, 1, false, skin);
|
||||||
glowShaderLevel.setValue(prefs.getInteger("glow shader"));
|
|
||||||
add(glowShaderLevel).fillX();
|
add(glowShaderLevel).fillX();
|
||||||
|
glowShaderLevel.addListener(bloomLevelSliderListener);
|
||||||
|
glowShaderLevel.setValue(prefs.getInteger("glow shader"));
|
||||||
|
|
||||||
row();
|
row();
|
||||||
|
|
||||||
@ -95,7 +96,8 @@ public class GraphicsOptions extends Table {
|
|||||||
prefs.putInteger("glow shader", (int) glowShaderLevel.getValue());
|
prefs.putInteger("glow shader", (int) glowShaderLevel.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Slider getGlowLevelSlider() {
|
public int getBloomShaderLevel() {
|
||||||
return glowShaderLevel;
|
return (int) glowShaderLevel.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,118 +0,0 @@
|
|||||||
package zero1hd.rhythmbullet.desktop.graphics.ui.components;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
|
||||||
import com.badlogic.gdx.utils.Disposable;
|
|
||||||
|
|
||||||
import zero1hd.rhythmbullet.audio.MusicInfo;
|
|
||||||
import zero1hd.rhythmbullet.desktop.screens.main.MusicSelectionPage;
|
|
||||||
import zero1hd.rhythmbullet.graphics.ui.components.ShortenedTextLabel;
|
|
||||||
|
|
||||||
public class MusicSelectable extends WidgetGroup implements Disposable {
|
|
||||||
private Table table;
|
|
||||||
|
|
||||||
private ShortenedTextLabel displayName;
|
|
||||||
|
|
||||||
private boolean selected;
|
|
||||||
|
|
||||||
private MusicSelectionPage msp;
|
|
||||||
private MusicInfo musicInfo;
|
|
||||||
|
|
||||||
private FileHandle musicFile;
|
|
||||||
|
|
||||||
public MusicSelectable(FileHandle musicFile, Skin skin, MusicSelectionPage msp) {
|
|
||||||
this.musicFile = musicFile;
|
|
||||||
table = new Table(skin);
|
|
||||||
table.setBackground("holo-pane");
|
|
||||||
table.setFillParent(true);
|
|
||||||
this.msp = msp;
|
|
||||||
setName(musicFile.nameWithoutExtension());
|
|
||||||
table.defaults().pad(5f).space(15f).expandX();
|
|
||||||
|
|
||||||
displayName = new ShortenedTextLabel(musicFile.nameWithoutExtension().replace('_', ' '), skin, "sub-font", skin.getColor("default"));
|
|
||||||
table.add(displayName);
|
|
||||||
|
|
||||||
table.pack();
|
|
||||||
addActor(table);
|
|
||||||
addListener(new ClickListener() {
|
|
||||||
@Override
|
|
||||||
public void clicked(InputEvent event, float x, float y) {
|
|
||||||
select();
|
|
||||||
super.clicked(event, x, y);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* updates the UI side of information.
|
|
||||||
* needs to be called in thread with gl context.
|
|
||||||
* @param musicInfo the music information for this song.
|
|
||||||
*/
|
|
||||||
public void updateInfo(MusicInfo musicInfo) {
|
|
||||||
this.musicInfo = musicInfo;
|
|
||||||
displayName.setOriginalText(musicInfo.getMusicName());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void layout() {
|
|
||||||
displayName.setTargetWidth((int) (getWidth()*0.8f));
|
|
||||||
displayName.resize();
|
|
||||||
super.layout();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(Batch batch, float parentAlpha) {
|
|
||||||
super.draw(batch, parentAlpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void act(float delta) {
|
|
||||||
super.act(delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMusicInvalid() {
|
|
||||||
return musicInfo.isInvalidMusic();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Selects this panel
|
|
||||||
*/
|
|
||||||
public void select() {
|
|
||||||
msp.deselectAll();
|
|
||||||
table.setBackground("holo-pane-down");
|
|
||||||
selected = true;
|
|
||||||
msp.setCurrentlySelected(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deselect() {
|
|
||||||
table.setBackground("holo-pane");
|
|
||||||
selected = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSelected() {
|
|
||||||
return selected;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getPrefHeight() {
|
|
||||||
return table.getMinHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileHandle getMusicFile() {
|
|
||||||
return musicFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MusicInfo getMusicInfo() {
|
|
||||||
return musicInfo;
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,7 +12,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
|||||||
|
|
||||||
public class ResolutionButton extends TextButton {
|
public class ResolutionButton extends TextButton {
|
||||||
|
|
||||||
public ResolutionButton(final int width, final int height, Skin skin, final Preferences prefs) {
|
public ResolutionButton(int width, int height, Skin skin, Preferences prefs) {
|
||||||
super(width + "x" + height, skin);
|
super(width + "x" + height, skin);
|
||||||
|
|
||||||
Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
|
Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package zero1hd.rhythmbullet.desktop.screens.main;
|
package zero1hd.rhythmbullet.desktop.screens.main;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
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;
|
||||||
@ -12,15 +11,14 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||||
|
|
||||||
import zero1hd.rhythmbullet.RhythmBullet;
|
|
||||||
import zero1hd.rhythmbullet.audio.analyzer.AudioAnalyzer;
|
import zero1hd.rhythmbullet.audio.analyzer.AudioAnalyzer;
|
||||||
|
import zero1hd.rhythmbullet.audio.metadata.AudioMetadata;
|
||||||
|
import zero1hd.rhythmbullet.audio.processor.AudioProcessor;
|
||||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.Page;
|
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.Page;
|
||||||
import zero1hd.rhythmbullet.desktop.screens.GameScreen;
|
|
||||||
|
|
||||||
public class AnalysisPage extends Page {
|
public class AnalysisPage extends Page {
|
||||||
private boolean confirmed;
|
|
||||||
private TextButton backButton;
|
private TextButton backButton;
|
||||||
private AudioAnalyzer aa;
|
private AudioAnalyzer audioAnalyzer;
|
||||||
private Table table;
|
private Table table;
|
||||||
private Table adjustment;
|
private Table adjustment;
|
||||||
private Label difficultyModLabel, healthModLabel, speedModLabel;
|
private Label difficultyModLabel, healthModLabel, speedModLabel;
|
||||||
@ -29,17 +27,14 @@ public class AnalysisPage extends Page {
|
|||||||
private Label progressLabel;
|
private Label progressLabel;
|
||||||
private TextButton confirmButton;
|
private TextButton confirmButton;
|
||||||
private Image albumArt;
|
private Image albumArt;
|
||||||
private RhythmBullet core;
|
|
||||||
|
|
||||||
public AnalysisPage(MainScreen mainScreen) {
|
public AnalysisPage(Skin skin, ChangeListener backButtonListener, ChangeListener confirmedButtonListener) {
|
||||||
super(2, 0);
|
super(2, 0);
|
||||||
table = new Table();
|
table = new Table();
|
||||||
table.setFillParent(true);
|
table.setFillParent(true);
|
||||||
table.defaults().space(10f);
|
table.defaults().space(10f);
|
||||||
addActor(table);
|
addActor(table);
|
||||||
this.core = mainScreen.rhythmBullet;
|
|
||||||
adjustment = new Table();
|
adjustment = new Table();
|
||||||
Skin skin = core.getSkin();
|
|
||||||
|
|
||||||
difficultyModLabel = new Label("Difficulty Modifier: ", skin, "sub-font", skin.getColor("default"));
|
difficultyModLabel = new Label("Difficulty Modifier: ", skin, "sub-font", skin.getColor("default"));
|
||||||
difficultyModifierSlider = new Slider(1, 3, 0.5f, false, skin);
|
difficultyModifierSlider = new Slider(1, 3, 0.5f, false, skin);
|
||||||
@ -85,7 +80,6 @@ public class AnalysisPage extends Page {
|
|||||||
confirmButton.addListener(new ChangeListener() {
|
confirmButton.addListener(new ChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
confirmed = true;
|
|
||||||
confirmButton.setDisabled(true);
|
confirmButton.setDisabled(true);
|
||||||
speedModifierSlider.setDisabled(true);
|
speedModifierSlider.setDisabled(true);
|
||||||
healthModifierSlider.setDisabled(true);
|
healthModifierSlider.setDisabled(true);
|
||||||
@ -94,6 +88,7 @@ public class AnalysisPage extends Page {
|
|||||||
progressLabel.setText("Loading...");
|
progressLabel.setText("Loading...");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
confirmButton.addListener(confirmedButtonListener);
|
||||||
|
|
||||||
adjustment.add(confirmButton).colspan(3).fillX();
|
adjustment.add(confirmButton).colspan(3).fillX();
|
||||||
adjustment.row();
|
adjustment.row();
|
||||||
@ -101,49 +96,40 @@ public class AnalysisPage extends Page {
|
|||||||
adjustment.add(progressLabel).colspan(2).left().spaceTop(20f);
|
adjustment.add(progressLabel).colspan(2).left().spaceTop(20f);
|
||||||
|
|
||||||
backButton = new TextButton("Cancel", skin);
|
backButton = new TextButton("Cancel", skin);
|
||||||
backButton.addListener(new ChangeListener() {
|
backButton.addListener(backButtonListener);
|
||||||
@Override
|
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
|
||||||
mainScreen.setDisplayedPage(mainScreen.musicSelectionPage);
|
|
||||||
aa.dispose();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
backButton.setPosition(15, getHeight()-backButton.getHeight()-25);
|
backButton.setPosition(15, getHeight()-backButton.getHeight()-25);
|
||||||
addActor(backButton);
|
addActor(backButton);
|
||||||
|
|
||||||
|
audioAnalyzer = new AudioAnalyzer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processSong(MusicManager mm, Texture albumCover, MusicInfo mi) {
|
public void processSong(AudioProcessor mm, Texture albumCover, AudioMetadata metadata) {
|
||||||
this.albumArt = new Image(albumCover);
|
this.albumArt = new Image(albumCover);
|
||||||
confirmButton.setDisabled(false);
|
|
||||||
speedModifierSlider.setDisabled(false);
|
|
||||||
healthModifierSlider.setDisabled(false);
|
|
||||||
difficultyModifierSlider.setDisabled(false);
|
|
||||||
|
|
||||||
table.clear();
|
table.clear();
|
||||||
table.add(this.albumArt).size(adjustment.getMinHeight());
|
table.add(this.albumArt).size(adjustment.getMinHeight());
|
||||||
table.row();
|
table.row();
|
||||||
table.add(adjustment);
|
table.add(adjustment);
|
||||||
if (aa != null) {
|
|
||||||
aa.dispose();
|
if (!audioAnalyzer.start(mm)) {
|
||||||
|
audioAnalyzer.stop();
|
||||||
|
audioAnalyzer = new AudioAnalyzer();
|
||||||
|
audioAnalyzer.start(mm);
|
||||||
}
|
}
|
||||||
|
|
||||||
aa = new AudioAnalyzer(mm);
|
|
||||||
aa.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void act(float delta) {
|
|
||||||
if (aa != null && aa.isDone()) {
|
|
||||||
if (confirmed) {
|
|
||||||
core.setScreen(new GameScreen(core.getAssetManager(), core.getPrefs()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
super.act(delta);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
aa.dispose();
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCameraPositionToPage(Vector3 cameraPosition) {
|
||||||
|
confirmButton.setDisabled(false);
|
||||||
|
speedModifierSlider.setDisabled(false);
|
||||||
|
healthModifierSlider.setDisabled(false);
|
||||||
|
difficultyModifierSlider.setDisabled(false);
|
||||||
|
|
||||||
|
super.setCameraPositionToPage(cameraPosition);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,37 +1,32 @@
|
|||||||
package zero1hd.rhythmbullet.desktop.screens.main;
|
package zero1hd.rhythmbullet.desktop.screens.main;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Preferences;
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
|
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Slider;
|
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||||
|
|
||||||
import zero1hd.rhythmbullet.desktop.graphics.ui.components.GraphicsOptions;
|
import zero1hd.rhythmbullet.desktop.graphics.ui.components.GraphicsOptions;
|
||||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.Page;
|
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.Page;
|
||||||
|
|
||||||
public class GraphicsOptionsPage extends Page {
|
public class GraphicsPage extends Page {
|
||||||
private ScrollPane scrollPane;
|
private ScrollPane scrollPane;
|
||||||
private GraphicsOptions graphicsTable;
|
private GraphicsOptions graphicsTable;
|
||||||
private TextButton backButton;
|
private TextButton backButton;
|
||||||
|
|
||||||
public GraphicsOptionsPage(MainScreen mainScreen) {
|
public GraphicsPage(Skin skin, Preferences preferences, ChangeListener backButtonListener, ChangeListener bloomLevelSliderListener) {
|
||||||
super(-1, 1);
|
super(-1, 1);
|
||||||
graphicsTable = new GraphicsOptions(mainScreen.rhythmBullet.getSkin(), mainScreen.rhythmBullet.getPrefs());
|
graphicsTable = new GraphicsOptions(skin, preferences, bloomLevelSliderListener);
|
||||||
scrollPane = new ScrollPane(graphicsTable, mainScreen.rhythmBullet.getSkin());
|
scrollPane = new ScrollPane(graphicsTable, skin);
|
||||||
scrollPane.setFadeScrollBars(false);
|
scrollPane.setFadeScrollBars(false);
|
||||||
scrollPane.setFillParent(true);
|
scrollPane.setFillParent(true);
|
||||||
addActor(scrollPane);
|
addActor(scrollPane);
|
||||||
|
|
||||||
backButton = new TextButton("Back", mainScreen.rhythmBullet.getSkin());
|
backButton = new TextButton("Back", skin);
|
||||||
backButton.setPosition(10, getHeight() - 10 - backButton.getHeight());
|
backButton.setPosition(10, getHeight() - 10 - backButton.getHeight());
|
||||||
backButton.setWidth(backButton.getWidth() + 20);
|
backButton.setWidth(backButton.getWidth() + 20);
|
||||||
backButton.addListener(new ChangeListener() {
|
backButton.addListener(backButtonListener);
|
||||||
@Override
|
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
|
||||||
mainScreen.setDisplayedPage(mainScreen.optionsPage);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
addActor(backButton);
|
addActor(backButton);
|
||||||
}
|
}
|
||||||
@ -50,7 +45,7 @@ public class GraphicsOptionsPage extends Page {
|
|||||||
graphicsTable.save();
|
graphicsTable.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Slider getGlowLevelSlider() {
|
public int getBloomLevel() {
|
||||||
return graphicsTable.getGlowLevelSlider();
|
return graphicsTable.getBloomShaderLevel();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package zero1hd.rhythmbullet.desktop.screens.main;
|
package zero1hd.rhythmbullet.desktop.screens.main;
|
||||||
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
import com.badlogic.gdx.assets.AssetManager;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||||
|
|
||||||
@ -8,27 +9,21 @@ import zero1hd.rhythmbullet.controls.KeyMap;
|
|||||||
import zero1hd.rhythmbullet.desktop.graphics.ui.components.ControlOptions;
|
import zero1hd.rhythmbullet.desktop.graphics.ui.components.ControlOptions;
|
||||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.Page;
|
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.Page;
|
||||||
|
|
||||||
public class KeybindOptionsPage extends Page {
|
public class KeybindPage extends Page {
|
||||||
private ControlOptions controlTable;
|
private ControlOptions controlTable;
|
||||||
private KeyMap keyMap;
|
private KeyMap keyMap;
|
||||||
private TextButton backButton;
|
private TextButton backButton;
|
||||||
public KeybindOptionsPage(MainScreen mainScreen) {
|
public KeybindPage(AssetManager assetManager, Skin skin, ChangeListener backButtonListener) {
|
||||||
super(-1, -1);
|
super(-1, -1);
|
||||||
keyMap = new KeyMap(mainScreen.rhythmBullet.getAssetManager());
|
keyMap = new KeyMap(assetManager);
|
||||||
controlTable = new ControlOptions(mainScreen.rhythmBullet.getSkin(), keyMap);
|
controlTable = new ControlOptions(skin, keyMap);
|
||||||
|
|
||||||
addActor(controlTable);
|
addActor(controlTable);
|
||||||
|
|
||||||
backButton = new TextButton("Back", mainScreen.rhythmBullet.getSkin());
|
backButton = new TextButton("Back", skin);
|
||||||
backButton.setPosition(10, getHeight() - 10 - backButton.getHeight());
|
backButton.setPosition(10, getHeight() - 10 - backButton.getHeight());
|
||||||
backButton.setWidth(backButton.getWidth() + 20);
|
backButton.setWidth(backButton.getWidth() + 20);
|
||||||
backButton.addListener(new ChangeListener() {
|
backButton.addListener(backButtonListener);
|
||||||
|
|
||||||
@Override
|
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
|
||||||
mainScreen.setDisplayedPage(mainScreen.optionsPage);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
addActor(backButton);
|
addActor(backButton);
|
||||||
}
|
}
|
@ -4,11 +4,13 @@ import java.util.Observable;
|
|||||||
import java.util.Observer;
|
import java.util.Observer;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.assets.AssetManager;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||||
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.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.Table;
|
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||||
@ -37,22 +39,19 @@ public class MainPage extends Page implements Observer {
|
|||||||
|
|
||||||
private DoubleHorizontalVisualizer dhv;
|
private DoubleHorizontalVisualizer dhv;
|
||||||
|
|
||||||
private RhythmBullet rhythmBullet;
|
public MainPage(MusicController musicController, AssetManager assetManager, Skin skin, ChangeListener playButtonListener, ChangeListener optionsButtonListener) {
|
||||||
public MainPage(MainScreen mainScreen) {
|
|
||||||
super(0, 0);
|
super(0, 0);
|
||||||
this.mc = mainScreen.musicController;
|
this.mc = musicController;
|
||||||
this.rhythmBullet = mainScreen.rhythmBullet;
|
|
||||||
|
|
||||||
dhv = new DoubleHorizontalVisualizer(70, (int) getWidth(), (int) (getHeight()*0.3), 0.3f, mc);
|
dhv = new DoubleHorizontalVisualizer(70, (int) getWidth(), (int) (getHeight()*0.3), 0.3f, mc);
|
||||||
dhv.setPosition(0, (int) ((getHeight() - dhv.getHeight())/2f));
|
dhv.setPosition(0, (int) ((getHeight() - dhv.getHeight())/2f));
|
||||||
|
|
||||||
title = new Image(rhythmBullet.getAssetManager().get("title.png", Texture.class));
|
title = new Image(assetManager.get("title.png", Texture.class));
|
||||||
title.setScale(dhv.getHeight()/title.getHeight());
|
title.setScale(dhv.getHeight()/title.getHeight());
|
||||||
title.setPosition((getWidth()-title.getWidth())/2f, (getHeight()-title.getHeight())/2f);
|
title.setPosition((getWidth()-title.getWidth())/2f, (getHeight()-title.getHeight())/2f);
|
||||||
addActor(title);
|
addActor(title);
|
||||||
|
|
||||||
versionLabel = new Label("Version: " + RhythmBullet.VERSION, rhythmBullet.getSkin(), "sub-font",
|
versionLabel = new Label("Version: " + RhythmBullet.VERSION, skin, "sub-font");
|
||||||
rhythmBullet.getSkin().getColor("default"));
|
|
||||||
versionLabel.setPosition(3, 3);
|
versionLabel.setPosition(3, 3);
|
||||||
addActor(versionLabel);
|
addActor(versionLabel);
|
||||||
|
|
||||||
@ -61,30 +60,19 @@ public class MainPage extends Page implements Observer {
|
|||||||
menuTable.align(Align.center);
|
menuTable.align(Align.center);
|
||||||
menuTable.defaults().space(10f);
|
menuTable.defaults().space(10f);
|
||||||
addActor(menuTable);
|
addActor(menuTable);
|
||||||
playButton = new TextButton("Start!", rhythmBullet.getSkin());
|
playButton = new TextButton("Start!", skin);
|
||||||
playButton.addListener(new ChangeListener() {
|
playButton.addListener(playButtonListener);
|
||||||
@Override
|
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
|
||||||
mainScreen.setDisplayedPage(mainScreen.musicSelectionPage);
|
|
||||||
getStage().setKeyboardFocus(mainScreen.musicSelectionPage);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
menuTable.add(playButton).width(Gdx.graphics.getWidth()*0.2f);
|
menuTable.add(playButton).width(Gdx.graphics.getWidth()*0.2f);
|
||||||
|
|
||||||
menuTable.row();
|
menuTable.row();
|
||||||
|
|
||||||
optionsButton = new TextButton("Options", rhythmBullet.getSkin(), "sub");
|
optionsButton = new TextButton("Options", skin, "sub");
|
||||||
optionsButton.addListener(new ChangeListener() {
|
optionsButton.addListener(optionsButtonListener);
|
||||||
@Override
|
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
|
||||||
mainScreen.setDisplayedPage(mainScreen.optionsPage);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
menuTable.add(optionsButton).fillX();
|
menuTable.add(optionsButton).fillX();
|
||||||
|
|
||||||
menuTable.row();
|
menuTable.row();
|
||||||
|
|
||||||
quitButton = new TextButton("Quit", rhythmBullet.getSkin(), "sub");
|
quitButton = new TextButton("Quit", skin, "sub");
|
||||||
quitButton.addListener(new ChangeListener() {
|
quitButton.addListener(new ChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
@ -93,11 +81,11 @@ public class MainPage extends Page implements Observer {
|
|||||||
});
|
});
|
||||||
menuTable.add(quitButton).fillX();
|
menuTable.add(quitButton).fillX();
|
||||||
|
|
||||||
musicControls = new MusicControls(rhythmBullet.getSkin(), mc);
|
musicControls = new MusicControls(skin, mc);
|
||||||
musicControls.setPosition((getWidth()-musicControls.getMinWidth() - 20f), getHeight()-musicControls.getMinHeight()-20f);
|
musicControls.setPosition((getWidth()-musicControls.getMinWidth() - 20f), getHeight()-musicControls.getMinHeight()-20f);
|
||||||
addActor(musicControls);
|
addActor(musicControls);
|
||||||
|
|
||||||
scrollText = new ScrollText("...", "...", rhythmBullet.getSkin(), false, true);
|
scrollText = new ScrollText("...", "...", skin, false, true);
|
||||||
scrollText.setWidth(0.5f*getWidth());
|
scrollText.setWidth(0.5f*getWidth());
|
||||||
scrollText.setPosition(15, getHeight() - scrollText.getHeight()-25f);
|
scrollText.setPosition(15, getHeight() - scrollText.getHeight()-25f);
|
||||||
addActor(scrollText);
|
addActor(scrollText);
|
||||||
|
@ -28,19 +28,20 @@ import zero1hd.rhythmbullet.util.ResizeReadyScreen;
|
|||||||
public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
||||||
private Stage stage;
|
private Stage stage;
|
||||||
private Vector3 cameraPosition;
|
private Vector3 cameraPosition;
|
||||||
|
private Listeners listeners;
|
||||||
|
|
||||||
protected MainPage mainPage;
|
private MainPage mainPage;
|
||||||
protected OptionsPage optionsPage;
|
private OptionsPage optionsPage;
|
||||||
protected CreditsPage creditsPage;
|
private KeybindPage keybindPage;
|
||||||
protected KeybindOptionsPage keybindPage;
|
private GraphicsPage graphicsPage;
|
||||||
protected GraphicsOptionsPage graphicsPage;
|
private CreditsPage creditsPage;
|
||||||
protected MusicSelectionPage musicSelectionPage;
|
private MusicSelectionPage musicSelectionPage;
|
||||||
protected AnalysisPage analysisPage;
|
private AnalysisPage analysisPage;
|
||||||
|
|
||||||
protected MusicController musicController;
|
private MusicController musicController;
|
||||||
protected MusicMetadataController musicMetadataController;
|
private MusicMetadataController musicMetadataController;
|
||||||
|
|
||||||
protected RhythmBullet rhythmBullet;
|
private RhythmBullet rhythmBullet;
|
||||||
|
|
||||||
private BloomShader bloomShader;
|
private BloomShader bloomShader;
|
||||||
|
|
||||||
@ -56,12 +57,14 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
|||||||
cameraPosition = new Vector3(stage.getCamera().position);
|
cameraPosition = new Vector3(stage.getCamera().position);
|
||||||
|
|
||||||
MusicList musicList = new MusicList(new DesktopAudioProcessorFactory());
|
MusicList musicList = new MusicList(new DesktopAudioProcessorFactory());
|
||||||
musicList.setSearchPath(core.getPrefs().getString("music dir"));
|
musicList.setSearchPath(core.getPreferences().getString("music dir"));
|
||||||
musicController = new MusicController(musicList, core.getPrefs());
|
musicController = new MusicController(musicList, core.getPreferences());
|
||||||
musicController.setAutoPlay(true);
|
musicController.setAutoPlay(true);
|
||||||
musicController.setShuffle(true);
|
musicController.setShuffle(true);
|
||||||
|
|
||||||
musicMetadataController = new MusicMetadataController(musicList);
|
musicMetadataController = new MusicMetadataController(musicList);
|
||||||
|
|
||||||
|
listeners = new Listeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -114,47 +117,32 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
|||||||
background = rhythmBullet.getAssetManager().get("backgrounds/mainBG.png", Texture.class);
|
background = rhythmBullet.getAssetManager().get("backgrounds/mainBG.png", Texture.class);
|
||||||
screenBatch = new SpriteBatch();
|
screenBatch = new SpriteBatch();
|
||||||
|
|
||||||
mainPage = new MainPage(this);
|
|
||||||
|
|
||||||
|
mainPage = new MainPage(musicController, rhythmBullet.getAssetManager(), rhythmBullet.getSkin(), listeners.musicSelectionPageButtonListener, listeners.optionsPageButtonListener);
|
||||||
stage.addActor(mainPage);
|
stage.addActor(mainPage);
|
||||||
//End main menu
|
//End main menu
|
||||||
|
|
||||||
optionsPage = new OptionsPage(this);
|
optionsPage = new OptionsPage(musicController, rhythmBullet.getSkin(), rhythmBullet.getPreferences(), listeners.returnToMainPageListener, listeners.graphicsPageButtonListener, listeners.keybindPageButtonListener);
|
||||||
stage.addActor(optionsPage);
|
stage.addActor(optionsPage);
|
||||||
|
|
||||||
analysisPage = new AnalysisPage(this);
|
keybindPage = new KeybindPage(rhythmBullet.getAssetManager(), rhythmBullet.getSkin(), listeners.returnToMainPageListener);
|
||||||
stage.addActor(analysisPage);
|
|
||||||
|
|
||||||
musicSelectionPage = new MusicSelectionPage(this);
|
|
||||||
stage.addActor(musicSelectionPage);
|
|
||||||
|
|
||||||
|
|
||||||
keybindPage = new KeybindOptionsPage(this);
|
|
||||||
stage.addActor(keybindPage);
|
stage.addActor(keybindPage);
|
||||||
|
|
||||||
graphicsPage = new GraphicsOptionsPage(this);
|
graphicsPage = new GraphicsPage(rhythmBullet.getSkin(), rhythmBullet.getPreferences(), listeners.returnToMainPageListener, listeners.bloomLevelShaderListener);
|
||||||
if (graphicsPage.getGlowLevelSlider().getValue() > 0) {
|
|
||||||
if (bloomShader == null) bloomShader = new BloomShader(screenBatch);
|
|
||||||
bloomShader.setBloomLevel((int) graphicsPage.getGlowLevelSlider().getValue());
|
|
||||||
}
|
|
||||||
graphicsPage.getGlowLevelSlider().addListener(new ChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
|
||||||
if (graphicsPage.getGlowLevelSlider().getValue() > 0) {
|
|
||||||
if (bloomShader == null) bloomShader = new BloomShader(screenBatch);
|
|
||||||
bloomShader.setBloomLevel((int) graphicsPage.getGlowLevelSlider().getValue());
|
|
||||||
} else if (bloomShader != null) {
|
|
||||||
bloomShader.dispose();
|
|
||||||
bloomShader = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
stage.addActor(graphicsPage);
|
stage.addActor(graphicsPage);
|
||||||
|
|
||||||
|
|
||||||
creditsPage = new CreditsPage(rhythmBullet.getSkin());
|
creditsPage = new CreditsPage(rhythmBullet.getSkin());
|
||||||
creditsPage.setPosition(0, Gdx.graphics.getHeight());
|
|
||||||
stage.addActor(creditsPage);
|
stage.addActor(creditsPage);
|
||||||
|
|
||||||
|
musicSelectionPage = new MusicSelectionPage(rhythmBullet.getAssetManager(), rhythmBullet.getSkin(), musicController, musicMetadataController, listeners.returnToMainPageListener, listeners.analysisPageButtonListener);
|
||||||
|
stage.addActor(musicSelectionPage);
|
||||||
|
|
||||||
|
analysisPage = new AnalysisPage(rhythmBullet.getSkin(), listeners.returnToMainPageListener, listeners.confirmedSongListener);
|
||||||
|
stage.addActor(analysisPage);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
stage.addListener(new InputListener() {
|
stage.addListener(new InputListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean keyUp(InputEvent event, int keycode) {
|
public boolean keyUp(InputEvent event, int keycode) {
|
||||||
@ -199,8 +187,8 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
|||||||
|
|
||||||
public void saveAll() {
|
public void saveAll() {
|
||||||
if (optionsPage != null) {
|
if (optionsPage != null) {
|
||||||
optionsPage.saveOptions(rhythmBullet.getPrefs());
|
optionsPage.saveOptions(rhythmBullet.getPreferences());
|
||||||
rhythmBullet.getPrefs().flush();
|
rhythmBullet.getPreferences().flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,4 +221,76 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
|||||||
page.setCameraPositionToPage(cameraPosition);
|
page.setCameraPositionToPage(cameraPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class Listeners {
|
||||||
|
ChangeListener musicSelectionPageButtonListener = new ChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
|
setDisplayedPage(musicSelectionPage);
|
||||||
|
stage.setKeyboardFocus(musicSelectionPage);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ChangeListener analysisPageButtonListener = new ChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
|
musicSelectionPage.getSelectedMusic();
|
||||||
|
setDisplayedPage(analysisPage);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ChangeListener returnToMainPageListener = new ChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
|
setDisplayedPage(mainPage);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ChangeListener optionsPageButtonListener = new ChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
|
setDisplayedPage(optionsPage);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ChangeListener graphicsPageButtonListener = new ChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
|
setDisplayedPage(graphicsPage);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ChangeListener keybindPageButtonListener = new ChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
|
setDisplayedPage(keybindPage);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ChangeListener creditPageButtonListener = new ChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
|
setDisplayedPage(creditsPage);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ChangeListener bloomLevelShaderListener = new ChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
|
if (graphicsPage.getBloomLevel() > 0) {
|
||||||
|
if (bloomShader == null) bloomShader = new BloomShader(screenBatch);
|
||||||
|
bloomShader.setBloomLevel((int) graphicsPage.getBloomLevel());
|
||||||
|
} else if (bloomShader != null) {
|
||||||
|
bloomShader.dispose();
|
||||||
|
bloomShader = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ChangeListener confirmedSongListener = new ChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package zero1hd.rhythmbullet.desktop.screens.main;
|
package zero1hd.rhythmbullet.desktop.screens.main;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Observable;
|
import java.util.Observable;
|
||||||
import java.util.Observer;
|
import java.util.Observer;
|
||||||
|
|
||||||
@ -7,6 +8,7 @@ import com.badlogic.gdx.Gdx;
|
|||||||
import com.badlogic.gdx.Input.Keys;
|
import com.badlogic.gdx.Input.Keys;
|
||||||
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.audio.Music;
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
@ -27,8 +29,8 @@ import com.badlogic.gdx.utils.Array;
|
|||||||
|
|
||||||
import zero1hd.rhythmbullet.audio.MusicMetadataController;
|
import zero1hd.rhythmbullet.audio.MusicMetadataController;
|
||||||
import zero1hd.rhythmbullet.audio.MusicController;
|
import zero1hd.rhythmbullet.audio.MusicController;
|
||||||
import zero1hd.rhythmbullet.desktop.graphics.ui.components.MusicSelectable;
|
|
||||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.Page;
|
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.Page;
|
||||||
|
import zero1hd.rhythmbullet.graphics.ui.components.MusicSelectable;
|
||||||
import zero1hd.rhythmbullet.graphics.ui.components.ScrollText;
|
import zero1hd.rhythmbullet.graphics.ui.components.ScrollText;
|
||||||
|
|
||||||
public class MusicSelectionPage extends Page implements Observer {
|
public class MusicSelectionPage extends Page implements Observer {
|
||||||
@ -36,10 +38,11 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
|
|
||||||
private MusicController mc;
|
private MusicController mc;
|
||||||
private MusicMetadataController mmc;
|
private MusicMetadataController mmc;
|
||||||
|
|
||||||
private Array<MusicSelectable> selectables;
|
private Array<MusicSelectable> selectables;
|
||||||
|
private TextButton back;
|
||||||
private Table musicTable;
|
private Table musicTable;
|
||||||
private ScrollPane musicTableScrollPane;
|
private ScrollPane musicTableScrollPane;
|
||||||
private TextButton back;
|
|
||||||
|
|
||||||
private Table musicInfoTable;
|
private Table musicInfoTable;
|
||||||
private Table musicSubInfo;
|
private Table musicSubInfo;
|
||||||
@ -48,29 +51,24 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
private Label songLength;
|
private Label songLength;
|
||||||
private Label previousTop;
|
private Label previousTop;
|
||||||
private Label ratedDifficulty;
|
private Label ratedDifficulty;
|
||||||
private Texture albumCoverTexture;
|
|
||||||
private Image albumCover;
|
private Image albumCover;
|
||||||
|
|
||||||
private AssetManager assets;
|
private AssetManager assets;
|
||||||
private MusicSelectable currentlySelected;
|
|
||||||
|
|
||||||
private Skin skin;
|
|
||||||
private boolean down, up;
|
private boolean down, up;
|
||||||
private int musicSelectableIndex;
|
private int musicSelectableIndex;
|
||||||
|
|
||||||
private TextButton beginButton;
|
private TextButton beginButton;
|
||||||
|
|
||||||
private int uiSongCount;
|
|
||||||
private int uiSongInfoCount;
|
|
||||||
private float scrollTimer, scrollDelay = 0.2f, scrollDelMod, songSelectionTimer;
|
private float scrollTimer, scrollDelay = 0.2f, scrollDelMod, songSelectionTimer;
|
||||||
|
|
||||||
public MusicSelectionPage(MainScreen mainScreen) {
|
public MusicSelectionPage(AssetManager assetManager, Skin skin, MusicController musicController, MusicMetadataController musicMetadataController, ChangeListener backButtonListener, ChangeListener beginButtonListener) {
|
||||||
super(1, 0);
|
super(1, 0);
|
||||||
this.assets = mainScreen.rhythmBullet.getAssetManager();
|
this.assets = assetManager;
|
||||||
this.skin = mainScreen.rhythmBullet.getSkin();
|
this.mc = musicController;
|
||||||
this.mc = mainScreen.musicController;
|
this.mmc = musicMetadataController;
|
||||||
this.mmc = mainScreen.musicMetadataController;
|
|
||||||
musicFileAnnotation = Gdx.app.getPreferences("music_file_annotation");
|
musicFileAnnotation = Gdx.app.getPreferences("music_file_annotation");
|
||||||
|
|
||||||
musicTable = new Table();
|
musicTable = new Table();
|
||||||
musicTableScrollPane = new ScrollPane(musicTable, skin);
|
musicTableScrollPane = new ScrollPane(musicTable, skin);
|
||||||
musicTable.defaults().spaceTop(5f).spaceBottom(5f);
|
musicTable.defaults().spaceTop(5f).spaceBottom(5f);
|
||||||
@ -79,16 +77,10 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
musicTableScrollPane.setOverscroll(false, false);
|
musicTableScrollPane.setOverscroll(false, false);
|
||||||
musicTableScrollPane.setColor(Color.BLUE);
|
musicTableScrollPane.setColor(Color.BLUE);
|
||||||
addActor(musicTableScrollPane);
|
addActor(musicTableScrollPane);
|
||||||
selectables = new Array<>();
|
|
||||||
back = new TextButton("Back", skin);
|
back = new TextButton("Back", skin);
|
||||||
back.setWidth(back.getWidth()+20f);
|
back.setWidth(back.getWidth()+20f);
|
||||||
back.setPosition(getWidth()-back.getWidth()-15f, getHeight() - back.getHeight() - 15f);
|
back.setPosition(getWidth()-back.getWidth()-15f, getHeight() - back.getHeight() - 15f);
|
||||||
back.addListener(new ChangeListener() {
|
back.addListener(backButtonListener);
|
||||||
@Override
|
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
|
||||||
mainScreen.setDisplayedPage(mainScreen.mainPage);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
addActor(back);
|
addActor(back);
|
||||||
back.toFront();
|
back.toFront();
|
||||||
|
|
||||||
@ -134,15 +126,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
albumCover = new Image(assets.get("defaultCover.png", Texture.class));
|
albumCover = new Image(assets.get("defaultCover.png", Texture.class));
|
||||||
|
|
||||||
beginButton = new TextButton("Begin", skin);
|
beginButton = new TextButton("Begin", skin);
|
||||||
beginButton.addListener(new ChangeListener() {
|
beginButton.addListener(beginButtonListener);
|
||||||
@Override
|
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
|
||||||
if (getSelectedMusic() != null) {
|
|
||||||
mainScreen.setDisplayedPage(mainScreen.analysisPage);
|
|
||||||
ap.processSong(mc.getMusicList().newAudioProcessor(getSelectedMusic()), (albumCoverTexture != null ? albumCoverTexture : assets.get("defaultCover.png", Texture.class)), mmc.getInfo(getSelectedMusic()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -178,30 +162,23 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
setCurrentMusic();
|
setCurrentMusic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
attemptRefreshUpdate();
|
|
||||||
super.act(delta);
|
super.act(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void attemptRefreshUpdate() {
|
private void scrollDown() {
|
||||||
if (mc.getMusicList().isSearched() && uiSongInfoCount != mc.getMusicList().getTotal()) {
|
if ((musicSelectableIndex = (musicTable.getChildren().indexOf(currentlySelected, true) + 1)) == musicTable.getChildren().size) {
|
||||||
if (uiSongCount < mc.getMusicList().getTotal()) {
|
musicSelectableIndex = 0;
|
||||||
MusicSelectable selectable = new MusicSelectable(mc.getMusicList().getSongFileHandleFromIndex(uiSongCount), skin, this);
|
|
||||||
selectables.add(selectable);
|
|
||||||
musicTable.add(selectables.get(uiSongCount)).expandX().fillX();
|
|
||||||
uiSongCount++;
|
|
||||||
musicTable.row();
|
|
||||||
if (uiSongCount == mc.getMusicList().getTotal()) {
|
|
||||||
selectMusicUI(mc.getCurrentMusicManager());
|
|
||||||
}
|
|
||||||
} else if (uiSongInfoCount < selectables.size && mmc.isDone()) {
|
|
||||||
selectables.get(uiSongInfoCount).updateInfo(mmc.getMetadataArray().get(uiSongInfoCount));
|
|
||||||
uiSongInfoCount++;
|
|
||||||
if (uiSongInfoCount == selectables.size) {
|
|
||||||
updateInformation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
((MusicSelectable)musicTable.getChildren().get(musicSelectableIndex)).select();
|
||||||
|
musicTableScrollPane.scrollTo(currentlySelected.getX(), currentlySelected.getY(), currentlySelected.getWidth(), currentlySelected.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void scrollUp() {
|
||||||
|
if ((musicSelectableIndex = (musicTable.getChildren().indexOf(currentlySelected, true) - 1)) < 0) {
|
||||||
|
musicSelectableIndex = musicTable.getChildren().size-1;
|
||||||
|
}
|
||||||
|
((MusicSelectable)musicTable.getChildren().get(musicSelectableIndex)).select();
|
||||||
|
musicTableScrollPane.scrollTo(currentlySelected.getX(), currentlySelected.getY(), currentlySelected.getWidth(), currentlySelected.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileHandle getSelectedMusic() {
|
public FileHandle getSelectedMusic() {
|
||||||
@ -212,15 +189,11 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MusicInfo getSelectedMusicInfo() {
|
|
||||||
return currentlySelected.getMusicInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refreshUIList() {
|
public void refreshUIList() {
|
||||||
for (int i = 0; i < selectables.size; i++) {
|
for (int i = 0; i < selectables.size; i++) {
|
||||||
selectables.get(i).dispose();
|
selectables.get(i).dispose();
|
||||||
}
|
}
|
||||||
mmc.loadSongInfo();
|
mmc.loadAudioMetadata();
|
||||||
musicTable.clear();
|
musicTable.clear();
|
||||||
selectables.clear();
|
selectables.clear();
|
||||||
musicInfoTable.clear();
|
musicInfoTable.clear();
|
||||||
@ -253,98 +226,30 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deselectAll() {
|
|
||||||
if (currentlySelected != null) {
|
|
||||||
currentlySelected.deselect();
|
|
||||||
} else {
|
|
||||||
for (int i = 0; i < selectables.size; i++) {
|
|
||||||
selectables.get(i).deselect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCurrentlySelected(MusicSelectable currentlySelected) {
|
|
||||||
this.currentlySelected = currentlySelected;
|
|
||||||
songSelectionTimer = 1f;
|
|
||||||
|
|
||||||
if (mmc.isDone() && uiSongInfoCount == selectables.size) {
|
|
||||||
updateInformation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void scrollDown() {
|
|
||||||
if ((musicSelectableIndex = (musicTable.getChildren().indexOf(currentlySelected, true) + 1)) == musicTable.getChildren().size) {
|
|
||||||
musicSelectableIndex = 0;
|
|
||||||
}
|
|
||||||
((MusicSelectable)musicTable.getChildren().get(musicSelectableIndex)).select();
|
|
||||||
musicTableScrollPane.scrollTo(currentlySelected.getX(), currentlySelected.getY(), currentlySelected.getWidth(), currentlySelected.getHeight());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void scrollUp() {
|
|
||||||
if ((musicSelectableIndex = (musicTable.getChildren().indexOf(currentlySelected, true) - 1)) < 0) {
|
|
||||||
musicSelectableIndex = musicTable.getChildren().size-1;
|
|
||||||
}
|
|
||||||
((MusicSelectable)musicTable.getChildren().get(musicSelectableIndex)).select();
|
|
||||||
musicTableScrollPane.scrollTo(currentlySelected.getX(), currentlySelected.getY(), currentlySelected.getWidth(), currentlySelected.getHeight());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Observable o, Object arg) {
|
public void update(Observable o, Object arg) {
|
||||||
if (o == mc && arg == MusicController.States.Loaded) {
|
if (o == mc && arg == MusicController.States.Loaded) {
|
||||||
selectMusicUI(mc.getCurrentMusic());
|
selectMusicUI(mc.getCurrentMusicFileHandle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectMusicUI(MusicManager mm) {
|
public void selectMusicUI(FileHandle fileHandle) {
|
||||||
if (currentlySelected == null || mm.getMusicFile() != currentlySelected.getMusicFile()) {
|
selectables.get(mc.getMusicList().getMusicArray().indexOf(fileHandle, true)).select();
|
||||||
for (int i = 0; i < selectables.size; i++) {
|
|
||||||
if (selectables.get(i).getMusicFile() == mm.getMusicFile()) {
|
|
||||||
selectables.get(i).select();
|
|
||||||
musicSelectableIndex = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCurrentMusic() {
|
@Override
|
||||||
playSelectedMusic();
|
public void setCameraPositionToPage(Vector3 cameraPosition) {
|
||||||
|
getStage().setKeyboardFocus(this);
|
||||||
|
super.setCameraPositionToPage(cameraPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void playSelectedMusic() {
|
private class musicSelectionLoaderThread implements Runnable {
|
||||||
if (currentlySelected.getMusicFile() != mc.getCurrentMusicManager().getMusicFile()) {
|
|
||||||
int index = mc.getMusicList().getMusicArray().indexOf(currentlySelected.getMusicFile(), true);
|
|
||||||
mc.setMusicByIndex(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* This should only be called when everything is loaded.
|
public void run() {
|
||||||
*/
|
// TODO Auto-generated method stub
|
||||||
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...");
|
|
||||||
if (currentlySelected.getMusicInfo() == null) throw new NullPointerException("K, ur music info is null.");
|
|
||||||
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));
|
|
||||||
songLength.setText("Length: " + min + ":" + (sec > 9 ? sec : "0" + sec));
|
|
||||||
|
|
||||||
previousTop.setText("Highscore: " + currentlySelected.getMusicInfo().getPreviousTop());
|
|
||||||
|
|
||||||
String difficulty = (getSelectedMusicInfo().getRatedDifficulty() == -1 ? "N/A" : String.valueOf(getSelectedMusicInfo().getRatedDifficulty()));
|
|
||||||
ratedDifficulty.setText("Rated Difficulty: " + difficulty);
|
|
||||||
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)))));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,14 @@ import com.badlogic.gdx.math.MathUtils;
|
|||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.ProgressBar;
|
import com.badlogic.gdx.scenes.scene2d.ui.ProgressBar;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Slider;
|
import com.badlogic.gdx.scenes.scene2d.ui.Slider;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
|
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||||
|
|
||||||
|
import zero1hd.rhythmbullet.audio.MusicController;
|
||||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.Page;
|
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.Page;
|
||||||
|
|
||||||
public class OptionsPage extends Page {
|
public class OptionsPage extends Page {
|
||||||
@ -21,17 +23,12 @@ public class OptionsPage extends Page {
|
|||||||
private TextField directoryField;
|
private TextField directoryField;
|
||||||
private float musicSearchTimer;
|
private float musicSearchTimer;
|
||||||
|
|
||||||
public OptionsPage(MainScreen mainScreen) {
|
public OptionsPage(MusicController musicController, Skin skin, Preferences preferences, ChangeListener backButtonListener, ChangeListener graphicsButtonListener, ChangeListener controlsButtonListener) {
|
||||||
super(-1, 0, "General", mainScreen.rhythmBullet.getSkin());
|
super(-1, 0, "General", skin);
|
||||||
|
|
||||||
//Back button
|
//Back button
|
||||||
TextButton backButton = new TextButton("Back", mainScreen.rhythmBullet.getSkin());
|
TextButton backButton = new TextButton("Back", skin);
|
||||||
backButton.addListener(new ChangeListener() {
|
backButton.addListener(backButtonListener);
|
||||||
@Override
|
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
|
||||||
mainScreen.setDisplayedPage(mainScreen.mainPage);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
backButton.setWidth(backButton.getWidth() + 20);
|
backButton.setWidth(backButton.getWidth() + 20);
|
||||||
backButton.setPosition(getWidth() - backButton.getWidth() - 10, getHeightBelowTitle() + 5);
|
backButton.setPosition(getWidth() - backButton.getWidth() - 10, getHeightBelowTitle() + 5);
|
||||||
addActor(backButton);
|
addActor(backButton);
|
||||||
@ -41,36 +38,36 @@ public class OptionsPage extends Page {
|
|||||||
optionsTable.setSize(getWidth(), getHeight());
|
optionsTable.setSize(getWidth(), getHeight());
|
||||||
addActor(optionsTable);
|
addActor(optionsTable);
|
||||||
|
|
||||||
Label musicVolSliderLabel = new Label("Music Volume: ", mainScreen.rhythmBullet.getSkin());
|
Label musicVolSliderLabel = new Label("Music Volume: ", skin);
|
||||||
optionsTable.add(musicVolSliderLabel);
|
optionsTable.add(musicVolSliderLabel);
|
||||||
musicVolSlider = new Slider(0, 100, 0.1f, false, mainScreen.rhythmBullet.getSkin());
|
musicVolSlider = new Slider(0, 100, 0.1f, false, skin);
|
||||||
musicVolSlider.setValue(mainScreen.rhythmBullet.getPrefs().getFloat("music vol", 100f)*100f);
|
musicVolSlider.setValue(preferences.getFloat("music vol", 100f)*100f);
|
||||||
optionsTable.add(musicVolSlider).minWidth(0.3f*getWidth());
|
optionsTable.add(musicVolSlider).minWidth(0.3f*getWidth());
|
||||||
final Label musicVolPercentage = new Label(MathUtils.round(musicVolSlider.getValue()) + "%", mainScreen.rhythmBullet.getSkin());
|
final Label musicVolPercentage = new Label(MathUtils.round(musicVolSlider.getValue()) + "%", skin);
|
||||||
musicVolSlider.addListener(new ChangeListener() {
|
musicVolSlider.addListener(new ChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
musicVolPercentage.setText(MathUtils.round(musicVolSlider.getValue()) + "%");
|
musicVolPercentage.setText(MathUtils.round(musicVolSlider.getValue()) + "%");
|
||||||
mainScreen.musicController.getCurrentMusic().setVolume(musicVolSlider.getPercent());
|
musicController.getCurrentMusic().setVolume(musicVolSlider.getPercent());
|
||||||
|
|
||||||
mainScreen.rhythmBullet.getPrefs().putFloat("music vol", musicVolSlider.getPercent());
|
preferences.putFloat("music vol", musicVolSlider.getPercent());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
optionsTable.add(musicVolPercentage);
|
optionsTable.add(musicVolPercentage);
|
||||||
|
|
||||||
optionsTable.row();
|
optionsTable.row();
|
||||||
|
|
||||||
Label fxVolSliderLabel = new Label("FX Volume: ", mainScreen.rhythmBullet.getSkin());
|
Label fxVolSliderLabel = new Label("FX Volume: ", skin);
|
||||||
optionsTable.add(fxVolSliderLabel);
|
optionsTable.add(fxVolSliderLabel);
|
||||||
fxVolSlider = new Slider(0, 100, 0.1f, false, mainScreen.rhythmBullet.getSkin());
|
fxVolSlider = new Slider(0, 100, 0.1f, false, skin);
|
||||||
fxVolSlider.setValue(mainScreen.rhythmBullet.getPrefs().getFloat("fx vol", 100f)*100f);
|
fxVolSlider.setValue(preferences.getFloat("fx vol", 100f)*100f);
|
||||||
optionsTable.add(fxVolSlider).fillX();
|
optionsTable.add(fxVolSlider).fillX();
|
||||||
final Label fxVolPercentage = new Label(MathUtils.round(fxVolSlider.getValue()) + "%", mainScreen.rhythmBullet.getSkin());
|
final Label fxVolPercentage = new Label(MathUtils.round(fxVolSlider.getValue()) + "%", skin);
|
||||||
fxVolSlider.addListener(new ChangeListener() {
|
fxVolSlider.addListener(new ChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
fxVolPercentage.setText(MathUtils.round(fxVolSlider.getValue()) + "%");
|
fxVolPercentage.setText(MathUtils.round(fxVolSlider.getValue()) + "%");
|
||||||
mainScreen.rhythmBullet.getPrefs().putFloat("fx vol", fxVolSlider.getPercent());
|
preferences.putFloat("fx vol", fxVolSlider.getPercent());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -78,22 +75,22 @@ public class OptionsPage extends Page {
|
|||||||
|
|
||||||
optionsTable.row();
|
optionsTable.row();
|
||||||
|
|
||||||
Label musicDirectoryLabel = new Label("Music Directory: ", mainScreen.rhythmBullet.getSkin());
|
Label musicDirectoryLabel = new Label("Music Directory: ", skin);
|
||||||
optionsTable.add(musicDirectoryLabel);
|
optionsTable.add(musicDirectoryLabel);
|
||||||
directoryField = new TextField(null, mainScreen.rhythmBullet.getSkin() ) {
|
directoryField = new TextField(null, skin ) {
|
||||||
@Override
|
@Override
|
||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
if (musicSearchTimer > 0) {
|
if (musicSearchTimer > 0) {
|
||||||
musicSearchTimer -= delta;
|
musicSearchTimer -= delta;
|
||||||
if (musicSearchTimer <= 0) {
|
if (musicSearchTimer <= 0) {
|
||||||
mainScreen.musicController.getMusicList().setSearchPath(directoryField.getText());
|
musicController.getMusicList().setSearchPath(directoryField.getText());
|
||||||
mainScreen.musicController.getMusicList().asyncSearch();
|
musicController.getMusicList().asyncSearch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.act(delta);
|
super.act(delta);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
directoryField.setText(mainScreen.rhythmBullet.getPrefs().getString("music dir", System.getProperty("user.home")+System.getProperty("file.separator")+"Music"));
|
directoryField.setText(preferences.getString("music dir", System.getProperty("user.home")+System.getProperty("file.separator")+"Music"));
|
||||||
directoryField.addListener(new ChangeListener() {
|
directoryField.addListener(new ChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
@ -104,29 +101,19 @@ public class OptionsPage extends Page {
|
|||||||
|
|
||||||
optionsTable.row();
|
optionsTable.row();
|
||||||
|
|
||||||
TextButton keybindSettings = new TextButton("Set Controls", mainScreen.rhythmBullet.getSkin());
|
TextButton keybindSettings = new TextButton("Set Controls", skin);
|
||||||
keybindSettings.addListener(new ChangeListener() {
|
keybindSettings.addListener(controlsButtonListener);
|
||||||
@Override
|
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
|
||||||
mainScreen.setDisplayedPage(mainScreen.keybindPage);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
optionsTable.add(keybindSettings).colspan(2).fillX();
|
optionsTable.add(keybindSettings).colspan(2).fillX();
|
||||||
|
|
||||||
optionsTable.row();
|
optionsTable.row();
|
||||||
|
|
||||||
TextButton graphicsSettings = new TextButton("Graphics", mainScreen.rhythmBullet.getSkin());
|
TextButton graphicsSettings = new TextButton("Graphics", skin);
|
||||||
graphicsSettings.addListener(new ChangeListener() {
|
graphicsSettings.addListener(graphicsButtonListener);
|
||||||
@Override
|
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
|
||||||
mainScreen.setDisplayedPage(mainScreen.graphicsPage);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
optionsTable.add(graphicsSettings).colspan(2).fillX();
|
optionsTable.add(graphicsSettings).colspan(2).fillX();
|
||||||
|
|
||||||
optionsTable.row();
|
optionsTable.row();
|
||||||
|
|
||||||
Label fpsLabel = new Label("", mainScreen.rhythmBullet.getSkin()) {
|
Label fpsLabel = new Label("", skin) {
|
||||||
@Override
|
@Override
|
||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
setText("Current FPS: " + Gdx.graphics.getFramesPerSecond());
|
setText("Current FPS: " + Gdx.graphics.getFramesPerSecond());
|
||||||
@ -137,7 +124,7 @@ public class OptionsPage extends Page {
|
|||||||
|
|
||||||
optionsTable.row();
|
optionsTable.row();
|
||||||
|
|
||||||
Label usageLabel = new Label("Current usage (lower the better): " + 100f*((float)(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())/(float)Runtime.getRuntime().totalMemory()) + "%", mainScreen.rhythmBullet.getSkin()) {
|
Label usageLabel = new Label("Current usage (lower the better): " + 100f*((float)(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())/(float)Runtime.getRuntime().totalMemory()) + "%", skin) {
|
||||||
float refreshTime = 60;
|
float refreshTime = 60;
|
||||||
@Override
|
@Override
|
||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user