better control system; album art loading more efficient;
This commit is contained in:
parent
d7008796f4
commit
dc4db57281
@ -366,7 +366,7 @@ rect
|
|||||||
rotate: false
|
rotate: false
|
||||||
xy: 176, 35
|
xy: 176, 35
|
||||||
size: 14, 14
|
size: 14, 14
|
||||||
split: 4, 4, 4, 4
|
split: 3, 3, 3, 3
|
||||||
orig: 14, 14
|
orig: 14, 14
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
@ -374,7 +374,7 @@ rect-down
|
|||||||
rotate: false
|
rotate: false
|
||||||
xy: 191, 35
|
xy: 191, 35
|
||||||
size: 14, 14
|
size: 14, 14
|
||||||
split: 4, 4, 4, 4
|
split: 3, 3, 3, 3
|
||||||
orig: 14, 14
|
orig: 14, 14
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
@ -382,7 +382,7 @@ rect-disabled
|
|||||||
rotate: false
|
rotate: false
|
||||||
xy: 206, 35
|
xy: 206, 35
|
||||||
size: 14, 14
|
size: 14, 14
|
||||||
split: 4, 4, 4, 4
|
split: 3, 3, 3, 3
|
||||||
orig: 14, 14
|
orig: 14, 14
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
|
@ -21,6 +21,7 @@ public class MusicController extends Observable implements OnCompletionListener,
|
|||||||
public final class States {
|
public final class States {
|
||||||
public final Integer LOADED = new Integer(0), PLAYING = new Integer(1);
|
public final Integer LOADED = new Integer(0), PLAYING = new Integer(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final States states = new States();
|
public final States states = new States();
|
||||||
private MusicList musicList;
|
private MusicList musicList;
|
||||||
private MinimalAudioHeader musicHeader;
|
private MinimalAudioHeader musicHeader;
|
||||||
@ -191,6 +192,9 @@ public class MusicController extends Observable implements OnCompletionListener,
|
|||||||
@Override
|
@Override
|
||||||
public void update(Observable o, Object arg) {
|
public void update(Observable o, Object arg) {
|
||||||
if (o == musicList) {
|
if (o == musicList) {
|
||||||
|
if (arg == musicList.states.LOADING) {
|
||||||
|
pause();
|
||||||
|
} else if (arg == musicList.states.COMPLETE) {
|
||||||
if (shuffle) {
|
if (shuffle) {
|
||||||
shuffle();
|
shuffle();
|
||||||
}
|
}
|
||||||
@ -200,6 +204,7 @@ public class MusicController extends Observable implements OnCompletionListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getCurrentSongName() {
|
public String getCurrentSongName() {
|
||||||
return getCurrentMusicFileHandle().nameWithoutExtension();
|
return getCurrentMusicFileHandle().nameWithoutExtension();
|
||||||
|
@ -17,6 +17,10 @@ import zero1hd.rhythmbullet.audio.processor.WAVAudioProcessor;
|
|||||||
* @author yunya
|
* @author yunya
|
||||||
*/
|
*/
|
||||||
public class MusicList extends Observable {
|
public class MusicList extends Observable {
|
||||||
|
public final class States {
|
||||||
|
public final Integer LOADING = new Integer(0), COMPLETE = new Integer(1);
|
||||||
|
}
|
||||||
|
public States states = new States();
|
||||||
private Array<FileHandle> musicList;
|
private Array<FileHandle> musicList;
|
||||||
private RecursiveMusicSearchThread searchThread;
|
private RecursiveMusicSearchThread searchThread;
|
||||||
private AudioProcessorFactory audioProcFactory;
|
private AudioProcessorFactory audioProcFactory;
|
||||||
@ -45,7 +49,7 @@ public class MusicList extends Observable {
|
|||||||
*/
|
*/
|
||||||
public void asyncSearch(boolean refresh) {
|
public void asyncSearch(boolean refresh) {
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
|
notifyObservers(states.LOADING);
|
||||||
if (searchThread != null) {
|
if (searchThread != null) {
|
||||||
if (!searchThread.start()) {
|
if (!searchThread.start()) {
|
||||||
searchThread.stop();
|
searchThread.stop();
|
||||||
@ -57,9 +61,7 @@ public class MusicList extends Observable {
|
|||||||
searchThread.start();
|
searchThread.start();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (searched && !hasChanged()) {
|
if (!searched || hasChanged()) {
|
||||||
notifyObservers();
|
|
||||||
} else {
|
|
||||||
asyncSearch(true);
|
asyncSearch(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,7 +156,7 @@ public class MusicList extends Observable {
|
|||||||
searched = true;
|
searched = true;
|
||||||
Gdx.app.debug("MusicList", "recursive async search completed.");
|
Gdx.app.debug("MusicList", "recursive async search completed.");
|
||||||
setChanged();
|
setChanged();
|
||||||
notifyObservers();
|
notifyObservers(states.COMPLETE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ public class MP3Metadata implements AudioMetadata {
|
|||||||
private int length;
|
private int length;
|
||||||
private Texture albumCover;
|
private Texture albumCover;
|
||||||
private FileHandle fileHandle;
|
private FileHandle fileHandle;
|
||||||
private byte[] imageData;
|
private Pixmap pixmap;
|
||||||
|
|
||||||
public MP3Metadata(FileHandle fileHandle) {
|
public MP3Metadata(FileHandle fileHandle) {
|
||||||
this.fileHandle = fileHandle;
|
this.fileHandle = fileHandle;
|
||||||
@ -65,8 +65,8 @@ public class MP3Metadata implements AudioMetadata {
|
|||||||
mp3file = (MP3File) AudioFileIO.read(fileHandle.file());
|
mp3file = (MP3File) AudioFileIO.read(fileHandle.file());
|
||||||
Artwork art = mp3file.getTag().getFirstArtwork();
|
Artwork art = mp3file.getTag().getFirstArtwork();
|
||||||
if (art != null) {
|
if (art != null) {
|
||||||
imageData = art.getBinaryData();
|
byte[] imageData = art.getBinaryData();
|
||||||
|
pixmap = new Pixmap(imageData, 0, imageData.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (CannotReadException | IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) {
|
} catch (CannotReadException | IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) {
|
||||||
@ -109,11 +109,10 @@ public class MP3Metadata implements AudioMetadata {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Texture getAlbumCover() {
|
public Texture getAlbumCover() {
|
||||||
if (albumCover == null && imageData != null) {
|
if (pixmap != null && albumCover == null) {
|
||||||
Pixmap pixmap = new Pixmap(imageData, 0, imageData.length);
|
|
||||||
albumCover = new Texture(pixmap);
|
albumCover = new Texture(pixmap);
|
||||||
pixmap.dispose();
|
pixmap.dispose();
|
||||||
imageData = null;
|
pixmap = null;
|
||||||
}
|
}
|
||||||
return albumCover;
|
return albumCover;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ public class WAVMetadata implements AudioMetadata {
|
|||||||
private int length;
|
private int length;
|
||||||
private Texture albumCover;
|
private Texture albumCover;
|
||||||
private FileHandle fileHandle;
|
private FileHandle fileHandle;
|
||||||
private byte[] imageData;
|
private Pixmap pixmap;
|
||||||
|
|
||||||
public WAVMetadata(FileHandle fileHandle) {
|
public WAVMetadata(FileHandle fileHandle) {
|
||||||
this.fileHandle = fileHandle;
|
this.fileHandle = fileHandle;
|
||||||
@ -52,10 +52,11 @@ public class WAVMetadata implements AudioMetadata {
|
|||||||
try {
|
try {
|
||||||
AudioFile wav = AudioFileIO.read(fileHandle.file());
|
AudioFile wav = AudioFileIO.read(fileHandle.file());
|
||||||
Artwork art = wav.getTag().getFirstArtwork();
|
Artwork art = wav.getTag().getFirstArtwork();
|
||||||
if (art != null) {
|
|
||||||
imageData = art.getBinaryData();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (art != null) {
|
||||||
|
byte[] imageData = art.getBinaryData();
|
||||||
|
pixmap = new Pixmap(imageData, 0, imageData.length);
|
||||||
|
}
|
||||||
} catch (CannotReadException | IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) {
|
} catch (CannotReadException | IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -88,11 +89,10 @@ public class WAVMetadata implements AudioMetadata {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Texture getAlbumCover() {
|
public Texture getAlbumCover() {
|
||||||
if (albumCover == null && imageData != null) {
|
if (pixmap != null && albumCover == null) {
|
||||||
Pixmap pixmap = new Pixmap(imageData, 0, imageData.length);
|
|
||||||
albumCover = new Texture(pixmap);
|
albumCover = new Texture(pixmap);
|
||||||
pixmap.dispose();
|
pixmap.dispose();
|
||||||
imageData = null;
|
pixmap = null;
|
||||||
}
|
}
|
||||||
return albumCover;
|
return albumCover;
|
||||||
}
|
}
|
||||||
|
@ -1,149 +0,0 @@
|
|||||||
package zero1hd.rhythmbullet.controls;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
|
||||||
import com.badlogic.gdx.Input.Keys;
|
|
||||||
import com.badlogic.gdx.Preferences;
|
|
||||||
import com.badlogic.gdx.assets.AssetManager;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
|
||||||
|
|
||||||
public class KeyMap {
|
|
||||||
TextureAtlas keyTextures;
|
|
||||||
private Preferences keyBindPrefs;
|
|
||||||
|
|
||||||
public static final String UP = "up";
|
|
||||||
public static final String DOWN = "down";
|
|
||||||
public static final String LEFT = "left";
|
|
||||||
public static final String RIGHT = "right";
|
|
||||||
|
|
||||||
public static final String SHOOT = "shoot";
|
|
||||||
|
|
||||||
public static final String FIRSTTHIRDTELEPORT = "firstThirdTP";
|
|
||||||
public static final String SECONDTHIRDTELEPORT = "secondThirdTP";
|
|
||||||
public static final String THIRDTHIRDTELEPORT = "thirdThirdTP";
|
|
||||||
|
|
||||||
public static final String ACCELERATE = "accelerate";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* forward binding.
|
|
||||||
*/
|
|
||||||
public static int up;
|
|
||||||
/**
|
|
||||||
* backward binding.
|
|
||||||
*/
|
|
||||||
public static int down;
|
|
||||||
/**
|
|
||||||
* left binding.
|
|
||||||
*/
|
|
||||||
public static int left;
|
|
||||||
/**
|
|
||||||
* right binding.
|
|
||||||
*/
|
|
||||||
public static int right;
|
|
||||||
/**
|
|
||||||
* shoot binding
|
|
||||||
*/
|
|
||||||
public static int shoot;
|
|
||||||
/**
|
|
||||||
* teleport first third binding
|
|
||||||
*/
|
|
||||||
public static int firstThirdTeleport;
|
|
||||||
/**
|
|
||||||
* teleport second third binding
|
|
||||||
*/
|
|
||||||
public static int secondThirdTeleport;
|
|
||||||
/**
|
|
||||||
* teleport third third binding
|
|
||||||
*/
|
|
||||||
public static int thirdThirdTeleport;
|
|
||||||
|
|
||||||
public static int accelerate;
|
|
||||||
|
|
||||||
|
|
||||||
public KeyMap(AssetManager assets) {
|
|
||||||
keyTextures = assets.get("keyboard.atlas", TextureAtlas.class);
|
|
||||||
|
|
||||||
setKeys(Gdx.app.getPreferences("PolyJet_Controls"));
|
|
||||||
updateKeys();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Preferences getKeys() {
|
|
||||||
return keyBindPrefs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKeys(Preferences keys) {
|
|
||||||
this.keyBindPrefs = keys;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TextureRegion getIcon(int keycode) {
|
|
||||||
// Gdx.app.debug("Keycode texture name", Keys.toString(keycode));
|
|
||||||
|
|
||||||
switch (keycode) {
|
|
||||||
case Keys.ALT_LEFT:
|
|
||||||
case Keys.ALT_RIGHT:
|
|
||||||
return keyTextures.findRegion("Keyboard_Black_Alt");
|
|
||||||
case Keys.SHIFT_LEFT:
|
|
||||||
case Keys.SHIFT_RIGHT:
|
|
||||||
return keyTextures.findRegion("Keyboard_Black_Shift");
|
|
||||||
case Keys.LEFT_BRACKET:
|
|
||||||
return keyTextures.findRegion("Keyboard_Black_Bracket_Left");
|
|
||||||
case Keys.RIGHT_BRACKET:
|
|
||||||
return keyTextures.findRegion("Keyboard_Black_Bracket_Right");
|
|
||||||
case Keys.SEMICOLON:
|
|
||||||
return keyTextures.findRegion("Keyboard_Black_Semicolon");
|
|
||||||
case Keys.SLASH:
|
|
||||||
return keyTextures.findRegion("Keyboard_Black_Slash");
|
|
||||||
case Keys.NUM:
|
|
||||||
return keyTextures.findRegion("Keyboard_Black_Num_Lock");
|
|
||||||
default:
|
|
||||||
return keyTextures.findRegion("Keyboard_Black_" + Keys.toString(keycode).replace(' ', '_'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateKeys() {
|
|
||||||
up = keyBindPrefs.getInteger(KeyMap.UP, Keys.UP);
|
|
||||||
down = keyBindPrefs.getInteger(KeyMap.DOWN, Keys.DOWN);
|
|
||||||
left = keyBindPrefs.getInteger(KeyMap.LEFT, Keys.LEFT);
|
|
||||||
right = keyBindPrefs.getInteger(KeyMap.RIGHT, Keys.RIGHT);
|
|
||||||
|
|
||||||
shoot = keyBindPrefs.getInteger(KeyMap.SHOOT, Keys.SPACE);
|
|
||||||
|
|
||||||
firstThirdTeleport = keyBindPrefs.getInteger(KeyMap.FIRSTTHIRDTELEPORT, Keys.Q);
|
|
||||||
secondThirdTeleport = keyBindPrefs.getInteger(KeyMap.SECONDTHIRDTELEPORT, Keys.W);
|
|
||||||
thirdThirdTeleport = keyBindPrefs.getInteger(KeyMap.THIRDTHIRDTELEPORT, Keys.E);
|
|
||||||
|
|
||||||
accelerate = keyBindPrefs.getInteger(KeyMap.ACCELERATE, Keys.SHIFT_LEFT);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* resets all binding to default;
|
|
||||||
*/
|
|
||||||
public void resetAllBinding() {
|
|
||||||
keyBindPrefs.clear();
|
|
||||||
keyBindPrefs.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int stringToID(String control) {
|
|
||||||
if (control == KeyMap.UP) {
|
|
||||||
return KeyMap.up;
|
|
||||||
} else if (control == KeyMap.DOWN) {
|
|
||||||
return KeyMap.down;
|
|
||||||
} else if (control == KeyMap.LEFT) {
|
|
||||||
return KeyMap.left;
|
|
||||||
} else if (control == KeyMap.RIGHT) {
|
|
||||||
return KeyMap.right;
|
|
||||||
} else if (control == KeyMap.SHOOT) {
|
|
||||||
return KeyMap.shoot;
|
|
||||||
} else if (control == KeyMap.FIRSTTHIRDTELEPORT) {
|
|
||||||
return KeyMap.firstThirdTeleport;
|
|
||||||
} else if (control == KeyMap.SECONDTHIRDTELEPORT) {
|
|
||||||
return KeyMap.secondThirdTeleport;
|
|
||||||
} else if (control == KeyMap.THIRDTHIRDTELEPORT) {
|
|
||||||
return KeyMap.thirdThirdTeleport;
|
|
||||||
} else if (control == KeyMap.ACCELERATE) {
|
|
||||||
return KeyMap.accelerate;
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,148 +0,0 @@
|
|||||||
package zero1hd.rhythmbullet.game;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
|
||||||
import com.badlogic.gdx.InputProcessor;
|
|
||||||
import com.badlogic.gdx.Preferences;
|
|
||||||
import com.badlogic.gdx.assets.AssetManager;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
|
||||||
import com.badlogic.gdx.utils.Disposable;
|
|
||||||
|
|
||||||
import zero1hd.rhythmbullet.controls.KeyMap;
|
|
||||||
import zero1hd.rhythmbullet.entity.CollisionDetector;
|
|
||||||
import zero1hd.rhythmbullet.entity.EntityManager;
|
|
||||||
import zero1hd.rhythmbullet.entity.ally.Laser;
|
|
||||||
import zero1hd.rhythmbullet.entity.ally.PolyjetEntity;
|
|
||||||
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorManager;
|
|
||||||
|
|
||||||
|
|
||||||
public class GameController implements Disposable, InputProcessor {
|
|
||||||
public PolyjetEntity polyjet;
|
|
||||||
|
|
||||||
public CoordinatorManager cm;
|
|
||||||
public EntityManager em;
|
|
||||||
private CollisionDetector collisionDetector;
|
|
||||||
|
|
||||||
public ScoreManager score = new ScoreManager();
|
|
||||||
|
|
||||||
public GameController(AssetManager assetManager, Preferences prefs) {
|
|
||||||
Gdx.app.debug("Game Area", "new area created");
|
|
||||||
|
|
||||||
polyjet = new PolyjetEntity(assetManager, 25f, 25f, 100, "standard");
|
|
||||||
em = new EntityManager(assetManager, prefs);
|
|
||||||
cm = new CoordinatorManager(em);
|
|
||||||
|
|
||||||
collisionDetector = new CollisionDetector(em.activeEnemies, em.activeAllies, assetManager, prefs);
|
|
||||||
em.activeAllies.add(polyjet);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void draw(Batch batch) {
|
|
||||||
batch.begin();
|
|
||||||
for (int i = 0; i < em.activeEnemies.size; i++) {
|
|
||||||
em.activeEnemies.get(i).draw(batch);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < em.activeAllies.size; i++) {
|
|
||||||
em.activeAllies.get(i).draw(batch);
|
|
||||||
}
|
|
||||||
batch.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void prepare(float delta) {
|
|
||||||
for (int i = 0; i < em.activeEnemies.size; i++) {
|
|
||||||
em.activeEnemies.get(i).updatePosition();
|
|
||||||
}
|
|
||||||
for (int i = 0; i < em.activeAllies.size; i++) {
|
|
||||||
em.activeAllies.get(i).updatePosition();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean keyDown(int keycode) {
|
|
||||||
if (keycode == KeyMap.left) {
|
|
||||||
polyjet.moveLeft = true;
|
|
||||||
}
|
|
||||||
if (keycode == KeyMap.right) {
|
|
||||||
polyjet.moveRight = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keycode == KeyMap.up) {
|
|
||||||
polyjet.moveUp = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keycode == KeyMap.down) {
|
|
||||||
polyjet.moveDown = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keycode == KeyMap.accelerate) {
|
|
||||||
polyjet.accelerate = true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean keyUp(int keycode) {
|
|
||||||
if (keycode == KeyMap.left) {
|
|
||||||
polyjet.moveLeft = false;
|
|
||||||
}
|
|
||||||
if (keycode == KeyMap.right) {
|
|
||||||
polyjet.moveRight = false;
|
|
||||||
}
|
|
||||||
if (keycode == KeyMap.up) {
|
|
||||||
polyjet.moveUp = false;
|
|
||||||
}
|
|
||||||
if (keycode == KeyMap.down) {
|
|
||||||
polyjet.moveDown = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keycode == KeyMap.accelerate) {
|
|
||||||
polyjet.accelerate = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keycode == KeyMap.shoot) {
|
|
||||||
Laser laser = em.laser.buildEntity();
|
|
||||||
laser.init(polyjet.getX() + polyjet.getWidth()/2f, polyjet.getY() + polyjet.getHeight()+1f, 60f);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PolyjetEntity getPolyjetEntity() {
|
|
||||||
return polyjet;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public CollisionDetector getCollisionDetector() {
|
|
||||||
return collisionDetector;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean keyTyped(char character) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean touchDragged(int screenX, int screenY, int pointer) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean mouseMoved(int screenX, int screenY) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean scrolled(int amount) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package zero1hd.rhythmbullet.desktop.graphics.ui.components;
|
package zero1hd.rhythmbullet.graphics.ui.components;
|
||||||
|
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
45
desktop/src/zero1hd/rhythmbullet/desktop/Controls.java
Executable file
45
desktop/src/zero1hd/rhythmbullet/desktop/Controls.java
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
package zero1hd.rhythmbullet.desktop;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Preferences;
|
||||||
|
import com.badlogic.gdx.Input.Keys;
|
||||||
|
|
||||||
|
public enum Controls {
|
||||||
|
UP("Forward", Keys.UP), DOWN("Backwards", Keys.DOWN), LEFT("Left", Keys.LEFT), RIGHT("Right", Keys.RIGHT), SHOOT("Shoot", Keys.SPACE), ACCELERATE("Boost", Keys.SHIFT_LEFT);
|
||||||
|
private int keycode;
|
||||||
|
private final String friendly;
|
||||||
|
private final int defectKey;
|
||||||
|
|
||||||
|
private Controls(String friendly, int defectKey) {
|
||||||
|
this.friendly = friendly;
|
||||||
|
this.defectKey = defectKey;
|
||||||
|
this.keycode = defectKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Controls setKeycode(int keycode) {
|
||||||
|
Controls[] controls = Controls.values();
|
||||||
|
for (int i = 0; i < controls.length; i++) {
|
||||||
|
if (controls[i] != this && controls[i].getKeycode() == keycode) {
|
||||||
|
return controls[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.keycode = keycode;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getKeycode() {
|
||||||
|
return keycode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadKeyFromPreferences(Preferences preferences) {
|
||||||
|
setKeycode(preferences.getInteger(name(), defectKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveKeyToPreferences(Preferences preferences) {
|
||||||
|
preferences.putInteger(name(), keycode);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return friendly;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package zero1hd.rhythmbullet.desktop;
|
package zero1hd.rhythmbullet.desktop;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.Preferences;
|
||||||
import com.badlogic.gdx.assets.AssetManager;
|
import com.badlogic.gdx.assets.AssetManager;
|
||||||
import com.badlogic.gdx.audio.Sound;
|
import com.badlogic.gdx.audio.Sound;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
@ -94,13 +95,6 @@ public class DesktopAssetPack implements AssetPack {
|
|||||||
windowTextButton.font = skin.getFont("window-font");
|
windowTextButton.font = skin.getFont("window-font");
|
||||||
skin.add("window", windowTextButton);
|
skin.add("window", windowTextButton);
|
||||||
|
|
||||||
TextButtonStyle textButtonLeft = new TextButtonStyle();
|
|
||||||
textButtonLeft.up = skin.getDrawable("left-button");
|
|
||||||
textButtonLeft.down = skin.getDrawable("left-button-down");
|
|
||||||
textButtonLeft.font = skin.getFont("default-font");
|
|
||||||
textButtonLeft.fontColor = skin.getColor("default");
|
|
||||||
skin.add("left", textButtonLeft);
|
|
||||||
|
|
||||||
SliderStyle defaultSlider = new SliderStyle(skin.getDrawable("default-slider"), skin.getDrawable("default-slider-knob"));
|
SliderStyle defaultSlider = new SliderStyle(skin.getDrawable("default-slider"), skin.getDrawable("default-slider-knob"));
|
||||||
skin.add("default-horizontal", defaultSlider);
|
skin.add("default-horizontal", defaultSlider);
|
||||||
|
|
||||||
@ -172,10 +166,13 @@ public class DesktopAssetPack implements AssetPack {
|
|||||||
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();
|
ButtonStyle selectableButton = new ButtonStyle();
|
||||||
musicSelectable.checked = skin.getDrawable("holo-pane-down");
|
selectableButton.checked = skin.getDrawable("holo-pane-down");
|
||||||
musicSelectable.up = skin.getDrawable("holo-pane");
|
selectableButton.up = skin.getDrawable("holo-pane");
|
||||||
skin.add("music-selectable", musicSelectable);
|
skin.add("selectable-button", selectableButton);
|
||||||
|
|
||||||
|
ButtonStyle selectableCleanButton = new ButtonStyle();
|
||||||
|
skin.add("selectable-clean-button", selectableCleanButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -220,6 +217,14 @@ public class DesktopAssetPack implements AssetPack {
|
|||||||
@Override
|
@Override
|
||||||
public void complete(AssetManager assetManager) {
|
public void complete(AssetManager assetManager) {
|
||||||
assetManager.get("standard_thrust.p", ParticleEffect.class).flipY();
|
assetManager.get("standard_thrust.p", ParticleEffect.class).flipY();
|
||||||
|
|
||||||
|
Preferences controlsPrefs = Gdx.app.getPreferences("RhythmBullet_Controls");
|
||||||
|
Controls.UP.loadKeyFromPreferences(controlsPrefs);
|
||||||
|
Controls.DOWN.loadKeyFromPreferences(controlsPrefs);
|
||||||
|
Controls.LEFT.loadKeyFromPreferences(controlsPrefs);
|
||||||
|
Controls.RIGHT.loadKeyFromPreferences(controlsPrefs);
|
||||||
|
Controls.SHOOT.loadKeyFromPreferences(controlsPrefs);
|
||||||
|
Controls.ACCELERATE.loadKeyFromPreferences(controlsPrefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,16 +1,7 @@
|
|||||||
package zero1hd.rhythmbullet.desktop;
|
package zero1hd.rhythmbullet.desktop;
|
||||||
|
|
||||||
import java.awt.Canvas;
|
|
||||||
import java.awt.Color;
|
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
|
|
||||||
import org.lwjgl.LWJGLException;
|
|
||||||
import org.lwjgl.opengl.AWTGLCanvas;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
|
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
|
||||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
|
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
|
||||||
import com.badlogic.gdx.backends.lwjgl.LwjglGraphics;
|
|
||||||
|
|
||||||
import zero1hd.rhythmbullet.RhythmBullet;
|
import zero1hd.rhythmbullet.RhythmBullet;
|
||||||
import zero1hd.rhythmbullet.desktop.screens.SplashScreen;
|
import zero1hd.rhythmbullet.desktop.screens.SplashScreen;
|
||||||
|
@ -1,123 +0,0 @@
|
|||||||
package zero1hd.rhythmbullet.desktop.graphics.ui.components;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
|
||||||
import com.badlogic.gdx.Input.Keys;
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
|
||||||
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.ClickListener;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.FocusListener;
|
|
||||||
import com.badlogic.gdx.utils.Align;
|
|
||||||
|
|
||||||
import zero1hd.rhythmbullet.controls.KeyMap;
|
|
||||||
|
|
||||||
public class ControlOptions extends Table {
|
|
||||||
private KeyBindButton selected;
|
|
||||||
|
|
||||||
public ControlOptions(Skin skin, KeyMap keyMap) {
|
|
||||||
super(skin);
|
|
||||||
align(Align.center);
|
|
||||||
|
|
||||||
ClickListener selectedListener = new ClickListener() {
|
|
||||||
@Override
|
|
||||||
public void clicked(InputEvent event, float x, float y) {
|
|
||||||
getStage().setKeyboardFocus(event.getTarget());
|
|
||||||
event.getTarget().setColor(Color.ORANGE);
|
|
||||||
selected = (KeyBindButton) event.getTarget();
|
|
||||||
super.clicked(event, x, y);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
InputListener keyPressedListener = new InputListener() {
|
|
||||||
@Override
|
|
||||||
public boolean keyUp(InputEvent event, int keycode) {
|
|
||||||
getStage().setKeyboardFocus(null);
|
|
||||||
Gdx.app.debug("KeySetter", "input keycode received: " + keycode);
|
|
||||||
if (keycode != Keys.ESCAPE) {
|
|
||||||
Gdx.app.debug("keySetter", "input has been set to: " + Keys.toString(keycode));
|
|
||||||
if (selected.setKey(keycode)) {
|
|
||||||
keyMap.updateKeys();
|
|
||||||
selected.addAction(Actions.sequence(Actions.color(Color.GREEN, 0.2f), Actions.color(Color.WHITE, 0.2f)));
|
|
||||||
} else {
|
|
||||||
selected.addAction(Actions.sequence(Actions.color(Color.RED, 0.2f), Actions.delay(0.1f), Actions.color(Color.WHITE, 0.2f)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return super.keyUp(event, keycode);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
FocusListener deselected = new FocusListener() {
|
|
||||||
@Override
|
|
||||||
public void keyboardFocusChanged(FocusEvent event, Actor actor, boolean focused) {
|
|
||||||
if (!focused) {
|
|
||||||
unselect();
|
|
||||||
}
|
|
||||||
super.keyboardFocusChanged(event, actor, focused);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Label forwardKeyLabel = new Label("Forward: ",skin);
|
|
||||||
forwardKeyLabel.setName(KeyMap.UP);
|
|
||||||
add(forwardKeyLabel).left();
|
|
||||||
KeyBindButton forwardKeySetter = new KeyBindButton(keyMap, KeyMap.UP, selectedListener, keyPressedListener, deselected);
|
|
||||||
add(forwardKeySetter).spaceRight(45f);
|
|
||||||
Label shootKeyLabel = new Label("Shoot: ", skin);
|
|
||||||
shootKeyLabel.setName(KeyMap.SHOOT);
|
|
||||||
add(shootKeyLabel).left();
|
|
||||||
KeyBindButton shootKeySetter = new KeyBindButton(keyMap, KeyMap.SHOOT, selectedListener, keyPressedListener, deselected);
|
|
||||||
add(shootKeySetter);
|
|
||||||
|
|
||||||
row();
|
|
||||||
|
|
||||||
Label backwardKeyLabel = new Label("Backward: ", skin);
|
|
||||||
backwardKeyLabel.setName(KeyMap.DOWN);
|
|
||||||
add(backwardKeyLabel).left();
|
|
||||||
KeyBindButton backwardKeySetter = new KeyBindButton(keyMap, KeyMap.DOWN, selectedListener, keyPressedListener, deselected);
|
|
||||||
add(backwardKeySetter).spaceRight(45f);
|
|
||||||
Label sector1TPKeyLabel = new Label("Left Teleport", skin);
|
|
||||||
sector1TPKeyLabel.setName(KeyMap.FIRSTTHIRDTELEPORT);
|
|
||||||
add(sector1TPKeyLabel).left();
|
|
||||||
KeyBindButton Sector1TPKeySetter = new KeyBindButton(keyMap, KeyMap.FIRSTTHIRDTELEPORT, selectedListener, keyPressedListener, deselected);
|
|
||||||
Sector1TPKeySetter.addListener(selectedListener);
|
|
||||||
add(Sector1TPKeySetter);
|
|
||||||
|
|
||||||
row();
|
|
||||||
|
|
||||||
Label leftKeyLabel = new Label("Left: ", skin);
|
|
||||||
leftKeyLabel.setName(KeyMap.LEFT);
|
|
||||||
add(leftKeyLabel).left();
|
|
||||||
KeyBindButton leftKeySetter = new KeyBindButton(keyMap, KeyMap.LEFT, selectedListener, keyPressedListener, deselected);
|
|
||||||
add(leftKeySetter).spaceRight(45f);
|
|
||||||
Label sector2TPKeyLabel = new Label("Middle Teleport: ", skin);
|
|
||||||
sector2TPKeyLabel.setName(KeyMap.SECONDTHIRDTELEPORT);
|
|
||||||
add(sector2TPKeyLabel).left();
|
|
||||||
KeyBindButton sector2TPKeySetter = new KeyBindButton(keyMap, KeyMap.SECONDTHIRDTELEPORT, selectedListener, keyPressedListener, deselected);
|
|
||||||
sector2TPKeySetter.addListener(selectedListener);
|
|
||||||
add(sector2TPKeySetter);
|
|
||||||
|
|
||||||
row();
|
|
||||||
|
|
||||||
Label rightKeyLabel = new Label("Right: ", skin);
|
|
||||||
rightKeyLabel.setName(KeyMap.RIGHT);
|
|
||||||
add(rightKeyLabel).left();
|
|
||||||
KeyBindButton rightKeySetter = new KeyBindButton(keyMap, KeyMap.RIGHT, selectedListener, keyPressedListener, deselected);
|
|
||||||
add(rightKeySetter).spaceRight(45f);
|
|
||||||
Label sector3TPKeyLabel = new Label("Right Teleport: ", skin);
|
|
||||||
sector3TPKeyLabel.setName(KeyMap.THIRDTHIRDTELEPORT);
|
|
||||||
add(sector3TPKeyLabel).left();
|
|
||||||
KeyBindButton sector3TPKeySetter = new KeyBindButton(keyMap, KeyMap.THIRDTHIRDTELEPORT, selectedListener, keyPressedListener, deselected);
|
|
||||||
sector3TPKeySetter.addListener(selectedListener);
|
|
||||||
add(sector3TPKeySetter);
|
|
||||||
|
|
||||||
setFillParent(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void unselect() {
|
|
||||||
selected.setColor(Color.WHITE);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
package zero1hd.rhythmbullet.desktop.graphics.ui.components;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.FocusListener;
|
|
||||||
|
|
||||||
import zero1hd.rhythmbullet.controls.KeyMap;
|
|
||||||
|
|
||||||
public class KeyBindButton extends Actor {
|
|
||||||
private TextureRegion keyIcon;
|
|
||||||
private KeyMap keyMap;
|
|
||||||
private String controlKey;
|
|
||||||
|
|
||||||
public KeyBindButton(final KeyMap keyMap, final String control, ClickListener selectionListener, InputListener keyPressListener, FocusListener deselectedListener) {
|
|
||||||
this.keyMap = keyMap;
|
|
||||||
this.keyIcon = keyMap.getIcon(keyMap.stringToID(control));
|
|
||||||
this.controlKey = control;
|
|
||||||
setSize(keyIcon.getRegionWidth(), keyIcon.getRegionHeight());
|
|
||||||
|
|
||||||
addListener(selectionListener);
|
|
||||||
addListener(keyPressListener);
|
|
||||||
addListener(deselectedListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean setKey(int keycode) {
|
|
||||||
if (keyMap.getIcon(keycode) != null) {
|
|
||||||
keyMap.getKeys().putInteger(controlKey, keycode);
|
|
||||||
keyIcon = keyMap.getIcon(keycode);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(Batch batch, float parentAlpha) {
|
|
||||||
batch.setColor(getColor());
|
|
||||||
batch.draw(keyIcon, getX(), getY(), getWidth(), getHeight());
|
|
||||||
super.draw(batch, parentAlpha);
|
|
||||||
}
|
|
||||||
}
|
|
@ -13,13 +13,11 @@ import zero1hd.rhythmbullet.RhythmBullet;
|
|||||||
import zero1hd.rhythmbullet.audio.MusicController;
|
import zero1hd.rhythmbullet.audio.MusicController;
|
||||||
import zero1hd.rhythmbullet.audio.visualizer.CircularVisualizer;
|
import zero1hd.rhythmbullet.audio.visualizer.CircularVisualizer;
|
||||||
import zero1hd.rhythmbullet.desktop.audio.PCMObtainer;
|
import zero1hd.rhythmbullet.desktop.audio.PCMObtainer;
|
||||||
import zero1hd.rhythmbullet.game.GameController;
|
|
||||||
|
|
||||||
public class GameScreen extends ScreenAdapter {
|
public class GameScreen extends ScreenAdapter {
|
||||||
private AssetManager assets;
|
private AssetManager assets;
|
||||||
private SpriteBatch batch;
|
private SpriteBatch batch;
|
||||||
private ExtendViewport viewport;
|
private ExtendViewport viewport;
|
||||||
private GameController gc;
|
|
||||||
private CircularVisualizer circleVisualizer;
|
private CircularVisualizer circleVisualizer;
|
||||||
|
|
||||||
public GameScreen(AssetManager assets, Preferences prefs, MusicController musicController) {
|
public GameScreen(AssetManager assets, Preferences prefs, MusicController musicController) {
|
||||||
|
@ -1,30 +1,224 @@
|
|||||||
package zero1hd.rhythmbullet.desktop.screens.main;
|
package zero1hd.rhythmbullet.desktop.screens.main;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.Preferences;
|
||||||
|
import com.badlogic.gdx.Input.Keys;
|
||||||
import com.badlogic.gdx.assets.AssetManager;
|
import com.badlogic.gdx.assets.AssetManager;
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import com.badlogic.gdx.math.Vector3;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Touchable;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Button;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.ButtonGroup;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||||
|
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.TextButton;
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||||
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
|
||||||
import zero1hd.rhythmbullet.controls.KeyMap;
|
import zero1hd.rhythmbullet.desktop.Controls;
|
||||||
import zero1hd.rhythmbullet.desktop.graphics.ui.components.ControlOptions;
|
|
||||||
import zero1hd.rhythmbullet.graphics.ui.Page;
|
import zero1hd.rhythmbullet.graphics.ui.Page;
|
||||||
|
|
||||||
public class KeybindPage extends Page {
|
public class KeybindPage extends Page {
|
||||||
private ControlOptions controlTable;
|
private ButtonGroup<KeyChangeButton> buttonOptions;
|
||||||
private KeyMap keyMap;
|
private VerticalGroup group;
|
||||||
private TextButton backButton;
|
private ScrollPane scrollPane;
|
||||||
|
private Skin skin;
|
||||||
|
TextureAtlas keyTextures;
|
||||||
|
private Preferences keyBindPrefs;
|
||||||
|
private InputListener inputListener;
|
||||||
|
private ChangeListener checkedListener;
|
||||||
|
|
||||||
public KeybindPage(AssetManager assetManager, Skin skin, ChangeListener backButtonListener) {
|
public KeybindPage(AssetManager assetManager, Skin skin, ChangeListener backButtonListener) {
|
||||||
super(-1, -1);
|
super(-1, -1);
|
||||||
keyMap = new KeyMap(assetManager);
|
setTouchable(Touchable.enabled);
|
||||||
controlTable = new ControlOptions(skin, keyMap);
|
this.skin = skin;
|
||||||
|
keyTextures = assetManager.get("keyboard.atlas", TextureAtlas.class);
|
||||||
addActor(controlTable);
|
this.keyBindPrefs = Gdx.app.getPreferences("PolyJet_Controls");
|
||||||
|
TextButton backButton = new TextButton("Back", skin);
|
||||||
backButton = new TextButton("Back", skin);
|
backButton.setWidth(backButton.getWidth()+20f);
|
||||||
backButton.setPosition(10, getHeight() - 10 - backButton.getHeight());
|
backButton.setPosition(getWidth()-backButton.getWidth()-15f, getHeight() - backButton.getHeight() - 15f);
|
||||||
backButton.setWidth(backButton.getWidth() + 20);
|
|
||||||
backButton.addListener(backButtonListener);
|
backButton.addListener(backButtonListener);
|
||||||
|
|
||||||
addActor(backButton);
|
addActor(backButton);
|
||||||
|
|
||||||
|
inputListener = new InputListener() {
|
||||||
|
@Override
|
||||||
|
public boolean keyUp(InputEvent event, int keycode) {
|
||||||
|
KeyChangeButton button = buttonOptions.getChecked();
|
||||||
|
if (button != null) {
|
||||||
|
if (keycode != Keys.ESCAPE) {
|
||||||
|
button.attemptSetKeycode(keycode);
|
||||||
|
}
|
||||||
|
getStage().setKeyboardFocus(null);
|
||||||
|
}
|
||||||
|
return super.keyUp(event, keycode);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
checkedListener = new ChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
|
KeyChangeButton button = (KeyChangeButton) actor;
|
||||||
|
if (button.isChecked()) {
|
||||||
|
button.ready();
|
||||||
|
} else {
|
||||||
|
button.done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
buttonOptions = new ButtonGroup<>();
|
||||||
|
buttonOptions.setMinCheckCount(0);
|
||||||
|
buttonOptions.setMaxCheckCount(1);
|
||||||
|
group = new VerticalGroup();
|
||||||
|
group.setTouchable(Touchable.childrenOnly);
|
||||||
|
group.space(15f);
|
||||||
|
Controls[] controls = Controls.values();
|
||||||
|
for (int i = 0; i < controls.length; i++) {
|
||||||
|
KeyChangeButton button = new KeyChangeButton(controls[i]);
|
||||||
|
buttonOptions.add(button);
|
||||||
|
group.addActor(button);
|
||||||
|
}
|
||||||
|
scrollPane = new ScrollPane(group);
|
||||||
|
scrollPane.setHeight(Math.min(getHeight(), group.getPrefHeight()));
|
||||||
|
scrollPane.setWidth(group.getPrefWidth());
|
||||||
|
scrollPane.setPosition((getWidth()-scrollPane.getWidth())/2f, (getHeight()-scrollPane.getHeight())/2f);
|
||||||
|
scrollPane.setTouchable(Touchable.childrenOnly);
|
||||||
|
addActor(scrollPane);
|
||||||
|
addListener(new ClickListener() {
|
||||||
|
@Override
|
||||||
|
public void clicked(InputEvent event, float x, float y) {
|
||||||
|
if (hit(x, y, true) == event.getListenerActor()) {
|
||||||
|
simpleDebug("unchecking selected key change buttons.");
|
||||||
|
buttonOptions.uncheckAll();
|
||||||
|
}
|
||||||
|
super.clicked(event, x, y);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCameraPositionToPage(Vector3 cameraPosition) {
|
||||||
|
getStage().setScrollFocus(scrollPane);
|
||||||
|
super.setCameraPositionToPage(cameraPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
save();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
public void save() {
|
||||||
|
keyBindPrefs.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class KeyChangeButton extends Button {
|
||||||
|
private Image keyImage;
|
||||||
|
private Label nameLabel;
|
||||||
|
private Controls control;
|
||||||
|
private boolean error;
|
||||||
|
|
||||||
|
public KeyChangeButton(Controls control) {
|
||||||
|
super(skin, "selectable-clean-button");
|
||||||
|
this.control = control;
|
||||||
|
nameLabel = new Label(control.toString(), skin);
|
||||||
|
keyImage = new Image(getIcon(control.getKeycode()));
|
||||||
|
|
||||||
|
add(nameLabel).expandX().left().spaceRight(20f);
|
||||||
|
add(keyImage).expandX().right();
|
||||||
|
|
||||||
|
addListener(inputListener);
|
||||||
|
addListener(checkedListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void attemptSetKeycode(int keycode) {
|
||||||
|
simpleDebug("Attempting to set keycode to " + keycode);
|
||||||
|
TextureRegion textureRegion = getIcon(keycode);
|
||||||
|
if (textureRegion != null) {
|
||||||
|
setKeycode(keycode, textureRegion);
|
||||||
|
error = false;
|
||||||
|
} else {
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
|
setChecked(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKeycode(int keycode, TextureRegion texture) {
|
||||||
|
|
||||||
|
Controls conflict = control.setKeycode(keycode);
|
||||||
|
if (conflict != null) {
|
||||||
|
Array<KeyChangeButton> buttons = buttonOptions.getButtons();
|
||||||
|
for (int i = 0; i < buttons.size; i++) {
|
||||||
|
System.out.println(buttons.get(i).getControl());
|
||||||
|
if (buttons.get(i).getControl() == conflict) {
|
||||||
|
KeyChangeButton b = buttons.get(i);
|
||||||
|
scrollPane.scrollTo(b.getX(), b.getY(), b.getWidth(), b.getHeight());
|
||||||
|
b.done(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TextureRegion textureRegion = getIcon(keycode);
|
||||||
|
if (textureRegion != null) {
|
||||||
|
keyImage.setDrawable(new TextureRegionDrawable(texture));
|
||||||
|
control.saveKeyToPreferences(keyBindPrefs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ready() {
|
||||||
|
getStage().setKeyboardFocus(this);
|
||||||
|
keyImage.setColor(Color.ORANGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void done() {
|
||||||
|
done(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void done(boolean error) {
|
||||||
|
if (error) {
|
||||||
|
keyImage.addAction(Actions.repeat(3, Actions.sequence(Actions.color(Color.RED, 0.2f), Actions.color(Color.WHITE, 0.1f))));
|
||||||
|
} else {
|
||||||
|
keyImage.addAction(Actions.color(Color.WHITE, 0.2f));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Controls getControl() {
|
||||||
|
return control;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextureRegion getIcon(int keycode) {
|
||||||
|
switch (keycode) {
|
||||||
|
case Keys.ALT_LEFT:
|
||||||
|
case Keys.ALT_RIGHT:
|
||||||
|
return keyTextures.findRegion("Keyboard_Black_Alt");
|
||||||
|
case Keys.SHIFT_LEFT:
|
||||||
|
case Keys.SHIFT_RIGHT:
|
||||||
|
return keyTextures.findRegion("Keyboard_Black_Shift");
|
||||||
|
case Keys.LEFT_BRACKET:
|
||||||
|
return keyTextures.findRegion("Keyboard_Black_Bracket_Left");
|
||||||
|
case Keys.RIGHT_BRACKET:
|
||||||
|
return keyTextures.findRegion("Keyboard_Black_Bracket_Right");
|
||||||
|
case Keys.SEMICOLON:
|
||||||
|
return keyTextures.findRegion("Keyboard_Black_Semicolon");
|
||||||
|
case Keys.SLASH:
|
||||||
|
return keyTextures.findRegion("Keyboard_Black_Slash");
|
||||||
|
case Keys.NUM:
|
||||||
|
return keyTextures.findRegion("Keyboard_Black_Num_Lock");
|
||||||
|
case Keys.ESCAPE:
|
||||||
|
return null;
|
||||||
|
default:
|
||||||
|
return keyTextures.findRegion("Keyboard_Black_" + Keys.toString(keycode).replace(' ', '_'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package zero1hd.rhythmbullet.desktop.screens.main;
|
package zero1hd.rhythmbullet.desktop.screens.main;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Input.Keys;
|
|
||||||
import com.badlogic.gdx.ScreenAdapter;
|
import com.badlogic.gdx.ScreenAdapter;
|
||||||
import com.badlogic.gdx.graphics.GL20;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
@ -9,11 +8,8 @@ import com.badlogic.gdx.graphics.g2d.Batch;
|
|||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
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.InputEvent;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
|
||||||
import com.badlogic.gdx.utils.viewport.ScreenViewport;
|
import com.badlogic.gdx.utils.viewport.ScreenViewport;
|
||||||
|
|
||||||
import zero1hd.rhythmbullet.RhythmBullet;
|
import zero1hd.rhythmbullet.RhythmBullet;
|
||||||
@ -139,28 +135,6 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
|||||||
analysisPage = new AnalysisPage(rhythmBullet.getSkin(), listeners.returnToMainPageListener, listeners.confirmedSongListener);
|
analysisPage = new AnalysisPage(rhythmBullet.getSkin(), listeners.returnToMainPageListener, listeners.confirmedSongListener);
|
||||||
stage.addActor(analysisPage);
|
stage.addActor(analysisPage);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
stage.addListener(new InputListener() {
|
|
||||||
@Override
|
|
||||||
public boolean keyUp(InputEvent event, int keycode) {
|
|
||||||
if (keycode == Keys.ESCAPE) {
|
|
||||||
stage.unfocusAll();
|
|
||||||
}
|
|
||||||
return super.keyUp(event, keycode);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
stage.addListener(new ClickListener() {
|
|
||||||
@Override
|
|
||||||
public void clicked(InputEvent event, float x, float y) {
|
|
||||||
if (stage.hit(x, y, true) == null) {
|
|
||||||
stage.unfocusAll();
|
|
||||||
}
|
|
||||||
super.clicked(event, x, y);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
musicController.getMusicList().asyncSearch(false);
|
musicController.getMusicList().asyncSearch(false);
|
||||||
resizing = false;
|
resizing = false;
|
||||||
}
|
}
|
||||||
@ -221,7 +195,6 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
|||||||
@Override
|
@Override
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
setDisplayedPage(musicSelectionPage);
|
setDisplayedPage(musicSelectionPage);
|
||||||
stage.setKeyboardFocus(musicSelectionPage);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -26,8 +26,6 @@ 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.VerticalGroup;
|
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||||
import com.badlogic.gdx.utils.Align;
|
import com.badlogic.gdx.utils.Align;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
@ -57,6 +55,8 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
|
|
||||||
private boolean down, up;
|
private boolean down, up;
|
||||||
|
|
||||||
|
private boolean frameUsed;
|
||||||
|
|
||||||
private TextButton beginButton;
|
private TextButton beginButton;
|
||||||
|
|
||||||
private float scrollTimer, scrollDelay = 0.2f, scrollDelMod, songSelectionTimer;
|
private float scrollTimer, scrollDelay = 0.2f, scrollDelMod, songSelectionTimer;
|
||||||
@ -77,6 +77,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
scrollPane.setSize(0.45f*getWidth(), getHeight());
|
scrollPane.setSize(0.45f*getWidth(), getHeight());
|
||||||
scrollPane.setOverscroll(false, false);
|
scrollPane.setOverscroll(false, false);
|
||||||
scrollPane.setClamp(true);
|
scrollPane.setClamp(true);
|
||||||
|
scrollPane.setSmoothScrolling(false);
|
||||||
scrollPane.setColor(Color.BLUE);
|
scrollPane.setColor(Color.BLUE);
|
||||||
addActor(scrollPane);
|
addActor(scrollPane);
|
||||||
back = new TextButton("Back", skin);
|
back = new TextButton("Back", skin);
|
||||||
@ -121,11 +122,18 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
|
|
||||||
mmc.addObserver(this);
|
mmc.addObserver(this);
|
||||||
mc.addObserver(this);
|
mc.addObserver(this);
|
||||||
|
mc.getMusicList().addObserver(this);
|
||||||
selectionLoaderThread = new musicSelectionLoaderThread();
|
selectionLoaderThread = new musicSelectionLoaderThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
|
|
||||||
|
if (frameUsed) {
|
||||||
|
frameUsed = false;
|
||||||
|
simpleDebug("New frame.");
|
||||||
|
}
|
||||||
|
|
||||||
if (down) {
|
if (down) {
|
||||||
if (scrollDelMod > 0.25f) {
|
if (scrollDelMod > 0.25f) {
|
||||||
scrollDelMod -= delta/0.5f;
|
scrollDelMod -= delta/0.5f;
|
||||||
@ -210,24 +218,31 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
|
mc.getMusicList().deleteObserver(this);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Observable o, Object arg) {
|
public void update(Observable o, Object arg) {
|
||||||
if (o == mmc) {
|
if (o == mmc) {
|
||||||
musicInfoTable.setToDefault();
|
|
||||||
selectionLoaderThread.start();
|
selectionLoaderThread.start();
|
||||||
} else if (o == mc) {
|
} else if (o == mc) {
|
||||||
if (mc.getMusicList().getTotal() == selectables.size() && mc.getCurrentMusicFileHandle() != selectables.getChecked().getMetadata().getFileHandle()) {
|
if (mc.getMusicList().getTotal() == selectables.size() && mc.getCurrentMusicFileHandle() != selectables.getChecked().getMetadata().getFileHandle()) {
|
||||||
selectables.setChecked(mc.getCurrentMusicFileHandle());
|
selectables.setChecked(mc.getCurrentMusicFileHandle());
|
||||||
}
|
}
|
||||||
|
} else if (o == mc.getMusicList()) {
|
||||||
|
if (arg == mc.getMusicList().states.LOADING) {
|
||||||
|
vGroup.clear();
|
||||||
|
selectables.clear();
|
||||||
|
musicInfoTable.setToDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCameraPositionToPage(Vector3 cameraPosition) {
|
public void setCameraPositionToPage(Vector3 cameraPosition) {
|
||||||
getStage().setKeyboardFocus(this);
|
getStage().setKeyboardFocus(this);
|
||||||
|
getStage().setScrollFocus(scrollPane);
|
||||||
super.setCameraPositionToPage(cameraPosition);
|
super.setCameraPositionToPage(cameraPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,22 +259,14 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while (work) {
|
while (work) {
|
||||||
if (selectables.size() != mmc.size()) {
|
|
||||||
selectables.clear();
|
|
||||||
for (int mid = 0; mid < mmc.size(); mid++) {
|
|
||||||
|
|
||||||
}
|
|
||||||
selectables.uncheckAll();
|
|
||||||
} else {
|
|
||||||
synchronized (this) {
|
|
||||||
while (queueList.size != 0) {
|
while (queueList.size != 0) {
|
||||||
AudioMetadata metadata = queueList.pop();
|
AudioMetadata metadata;
|
||||||
|
synchronized (this) {
|
||||||
|
metadata = queueList.pop();
|
||||||
metadata.loadAlbumCover();
|
metadata.loadAlbumCover();
|
||||||
|
simpleDebug("Loading " + metadata.getTitle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
try {
|
try {
|
||||||
wait();
|
wait();
|
||||||
@ -283,10 +290,10 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void queue(AudioMetadata metadata) {
|
public void queue(AudioMetadata metadata) {
|
||||||
if (!queueList.contains(metadata, true)) {
|
if (!queueList.contains(metadata, true)) {
|
||||||
queueList.add(metadata);
|
queueList.add(metadata);
|
||||||
notify();
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,14 +305,15 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
private Table informationTable;
|
private Table informationTable;
|
||||||
private Label name, artist;
|
private Label name, artist;
|
||||||
private Label time;
|
private Label time;
|
||||||
private float timeSinceOnScreen;
|
private boolean offScreen;
|
||||||
|
private float timeSinceChanged;
|
||||||
private AudioMetadata metadata;
|
private AudioMetadata metadata;
|
||||||
private Texture defaultAlbumArt;
|
private Texture defaultAlbumArt;
|
||||||
private TextureRegion albumArtTexture;
|
private TextureRegion albumArtTexture;
|
||||||
private boolean albumArtUsed, albumArtAttempted;
|
private boolean albumArtDisplayed, albumArtAttempted;
|
||||||
|
|
||||||
public MusicSelectable(AudioMetadata metadata) {
|
public MusicSelectable(AudioMetadata metadata) {
|
||||||
super(skin, "music-selectable");
|
super(skin, "selectable-button");
|
||||||
|
|
||||||
this.metadata = metadata;
|
this.metadata = metadata;
|
||||||
this.defaultAlbumArt = assets.get("defaultCover.png");
|
this.defaultAlbumArt = assets.get("defaultCover.png");
|
||||||
@ -314,7 +322,6 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
albumCoverImage = new Image();
|
albumCoverImage = new Image();
|
||||||
updateAlbumArtImage(defaultAlbumArt);
|
updateAlbumArtImage(defaultAlbumArt);
|
||||||
|
|
||||||
setSize(getPrefWidth(), getPrefHeight());
|
|
||||||
informationTable = new Table();
|
informationTable = new Table();
|
||||||
informationTable.row().width(0.75f*getWidth());
|
informationTable.row().width(0.75f*getWidth());
|
||||||
name = new Label(metadata.getTitle(), skin, "default-font", skin.getColor("default"));
|
name = new Label(metadata.getTitle(), skin, "default-font", skin.getColor("default"));
|
||||||
@ -349,21 +356,27 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Batch batch, float parentAlpha) {
|
public void draw(Batch batch, float parentAlpha) {
|
||||||
synchronized (albumCoverImage) {
|
|
||||||
super.draw(batch, parentAlpha);
|
super.draw(batch, parentAlpha);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void onScreenAct(float delta) {
|
public void onScreenAct(float delta) {
|
||||||
timeSinceOnScreen = 0;
|
if (offScreen) {
|
||||||
if (metadata.getAlbumCover() != null && !albumArtUsed) {
|
offScreen = false;
|
||||||
|
timeSinceChanged = 0;
|
||||||
|
} else if (timeSinceChanged < 0.75f) {
|
||||||
|
timeSinceChanged += delta;
|
||||||
|
}
|
||||||
|
if (timeSinceChanged >= 0.75f) {
|
||||||
|
if (!frameUsed && metadata.getAlbumCover() != null && !albumArtDisplayed) {
|
||||||
updateAlbumArtImage(metadata.getAlbumCover());
|
updateAlbumArtImage(metadata.getAlbumCover());
|
||||||
albumArtUsed = true;
|
albumArtDisplayed = true;
|
||||||
|
frameUsed = true;
|
||||||
} else if (!albumArtAttempted) {
|
} else if (!albumArtAttempted) {
|
||||||
selectionLoaderThread.queue(metadata);
|
selectionLoaderThread.queue(metadata);
|
||||||
albumArtAttempted = true;
|
albumArtAttempted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateAlbumArtImage(Texture texture) {
|
private void updateAlbumArtImage(Texture texture) {
|
||||||
if (texture == null) throw new IllegalArgumentException("Texture can't be null!");
|
if (texture == null) throw new IllegalArgumentException("Texture can't be null!");
|
||||||
@ -372,12 +385,16 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void offScreenAct(float delta) {
|
public void offScreenAct(float delta) {
|
||||||
|
if (!offScreen) {
|
||||||
|
offScreen = true;
|
||||||
|
timeSinceChanged = 0;
|
||||||
|
}
|
||||||
if (metadata.getAlbumCover() != null) {
|
if (metadata.getAlbumCover() != null) {
|
||||||
timeSinceOnScreen += delta;
|
timeSinceChanged += delta;
|
||||||
if (timeSinceOnScreen >= 2) {
|
if (timeSinceChanged >= 2) {
|
||||||
updateAlbumArtImage(defaultAlbumArt);
|
updateAlbumArtImage(defaultAlbumArt);
|
||||||
metadata.unloadAlbumCover();
|
metadata.unloadAlbumCover();
|
||||||
albumArtUsed = false;
|
albumArtDisplayed = false;
|
||||||
albumArtAttempted = false;
|
albumArtAttempted = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -446,6 +463,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
protected boolean canCheck(MusicSelectable button, boolean newState) {
|
protected boolean canCheck(MusicSelectable button, boolean newState) {
|
||||||
if (newState) {
|
if (newState) {
|
||||||
musicInfoTable.setDisplayedSelectable(button);
|
musicInfoTable.setDisplayedSelectable(button);
|
||||||
|
musicSelectDelay = 0f;
|
||||||
}
|
}
|
||||||
return super.canCheck(button, newState);
|
return super.canCheck(button, newState);
|
||||||
}
|
}
|
||||||
@ -464,7 +482,6 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
private Image albumCover;
|
private Image albumCover;
|
||||||
|
|
||||||
private Table subInformation;
|
private Table subInformation;
|
||||||
private MusicSelectable displayedSelectable;
|
|
||||||
|
|
||||||
public InformationTable(float width, float height) {
|
public InformationTable(float width, float height) {
|
||||||
defaults().center();
|
defaults().center();
|
||||||
@ -481,7 +498,6 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setDisplayedSelectable(MusicSelectable displayedSelectable) {
|
public void setDisplayedSelectable(MusicSelectable displayedSelectable) {
|
||||||
this.displayedSelectable = displayedSelectable;
|
|
||||||
if (displayedSelectable != null) {
|
if (displayedSelectable != null) {
|
||||||
AudioMetadata metadata = displayedSelectable.getMetadata();
|
AudioMetadata metadata = displayedSelectable.getMetadata();
|
||||||
albumCover.setDrawable(new TextureRegionDrawable(displayedSelectable.getAlbumArtTexture()));
|
albumCover.setDrawable(new TextureRegionDrawable(displayedSelectable.getAlbumArtTexture()));
|
||||||
@ -502,6 +518,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setToDefault() {
|
public void setToDefault() {
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
subInformation.clear();
|
subInformation.clear();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user