diff --git a/core/src/zero1hd/rhythmbullet/audio/MinimalAudioHeader.java b/core/src/zero1hd/rhythmbullet/audio/MinimalAudioHeader.java index 97762e0..5e749a5 100755 --- a/core/src/zero1hd/rhythmbullet/audio/MinimalAudioHeader.java +++ b/core/src/zero1hd/rhythmbullet/audio/MinimalAudioHeader.java @@ -12,7 +12,6 @@ import org.jaudiotagger.audio.mp3.MP3AudioHeader; import org.jaudiotagger.audio.mp3.MP3File; import org.jaudiotagger.tag.TagException; -import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; public class MinimalAudioHeader { diff --git a/core/src/zero1hd/rhythmbullet/audio/visualizer/CircularVisualizer.java b/core/src/zero1hd/rhythmbullet/audio/visualizer/CircularVisualizer.java index d0d1c81..bba6edb 100755 --- a/core/src/zero1hd/rhythmbullet/audio/visualizer/CircularVisualizer.java +++ b/core/src/zero1hd/rhythmbullet/audio/visualizer/CircularVisualizer.java @@ -4,14 +4,12 @@ import java.util.Comparator; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Camera; -import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Mesh; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.VertexAttribute; import com.badlogic.gdx.graphics.VertexAttributes.Usage; import com.badlogic.gdx.graphics.glutils.ShaderProgram; -import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Disposable; diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java b/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java index 133ea07..1a6f878 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java @@ -10,7 +10,6 @@ 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.Drawable; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import com.badlogic.gdx.utils.Array; diff --git a/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/ControlOptions.java b/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/ControlOptions.java index e4678ba..9cf99fc 100755 --- a/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/ControlOptions.java +++ b/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/ControlOptions.java @@ -1,46 +1,77 @@ 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.utils.Align; -import com.badlogic.gdx.utils.Array; import zero1hd.rhythmbullet.controls.KeyMap; public class ControlOptions extends Table { + private KeyBindButton selected; + public ControlOptions(Skin skin, KeyMap keyMap) { super(skin); align(Align.center); - //first + 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); + } + }; + Label forwardKeyLabel = new Label("Forward: ",skin); forwardKeyLabel.setName(KeyMap.UP); add(forwardKeyLabel).left(); - KeyBindButton forwardKeySetter = new KeyBindButton(keyMap, KeyMap.UP); + KeyBindButton forwardKeySetter = new KeyBindButton(keyMap, KeyMap.UP, selectedListener, keyPressedListener); add(forwardKeySetter).spaceRight(45f); Label shootKeyLabel = new Label("Shoot: ", skin); shootKeyLabel.setName(KeyMap.SHOOT); add(shootKeyLabel).left(); - KeyBindButton shootKeySetter = new KeyBindButton(keyMap, KeyMap.SHOOT); + KeyBindButton shootKeySetter = new KeyBindButton(keyMap, KeyMap.SHOOT, selectedListener, keyPressedListener); add(shootKeySetter); row(); - //second Label backwardKeyLabel = new Label("Backward: ", skin); backwardKeyLabel.setName(KeyMap.DOWN); add(backwardKeyLabel).left(); - KeyBindButton backwardKeySetter = new KeyBindButton(keyMap, KeyMap.DOWN); + KeyBindButton backwardKeySetter = new KeyBindButton(keyMap, KeyMap.DOWN, selectedListener, keyPressedListener); 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); + KeyBindButton Sector1TPKeySetter = new KeyBindButton(keyMap, KeyMap.FIRSTTHIRDTELEPORT, selectedListener, keyPressedListener); + Sector1TPKeySetter.addListener(selectedListener); add(Sector1TPKeySetter); row(); @@ -48,12 +79,13 @@ public class ControlOptions extends Table { Label leftKeyLabel = new Label("Left: ", skin); leftKeyLabel.setName(KeyMap.LEFT); add(leftKeyLabel).left(); - KeyBindButton leftKeySetter = new KeyBindButton(keyMap, KeyMap.LEFT); + KeyBindButton leftKeySetter = new KeyBindButton(keyMap, KeyMap.LEFT, selectedListener, keyPressedListener); 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); + KeyBindButton sector2TPKeySetter = new KeyBindButton(keyMap, KeyMap.SECONDTHIRDTELEPORT, selectedListener, keyPressedListener); + sector2TPKeySetter.addListener(selectedListener); add(sector2TPKeySetter); row(); @@ -61,40 +93,19 @@ public class ControlOptions extends Table { Label rightKeyLabel = new Label("Right: ", skin); rightKeyLabel.setName(KeyMap.RIGHT); add(rightKeyLabel).left(); - KeyBindButton rightKeySetter = new KeyBindButton(keyMap, KeyMap.RIGHT); + KeyBindButton rightKeySetter = new KeyBindButton(keyMap, KeyMap.RIGHT, selectedListener, keyPressedListener); 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); + KeyBindButton sector3TPKeySetter = new KeyBindButton(keyMap, KeyMap.THIRDTHIRDTELEPORT, selectedListener, keyPressedListener); + sector3TPKeySetter.addListener(selectedListener); add(sector3TPKeySetter); - addListener(new ClickListener() { - @Override - public void clicked(InputEvent event, float x, float y) { - unselect(); - if (event.getTarget() instanceof KeyBindButton) { - getStage().setKeyboardFocus(event.getTarget()); - event.getTarget().setColor(Color.ORANGE); - } else { - unselect(); - } - super.clicked(event, x, y); - } - }); - setFillParent(true); } public void unselect() { - Array keys = getChildren(); - for (int i = 0; i < keys.size; i++) { - keys.get(i).setColor(Color.WHITE);; - } - } - - @Override - public void act(float delta) { - super.act(delta); + selected.setColor(Color.WHITE); } } diff --git a/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/KeyBindButton.java b/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/KeyBindButton.java index f9cf515..9c1c2e2 100755 --- a/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/KeyBindButton.java +++ b/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/KeyBindButton.java @@ -1,53 +1,32 @@ 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.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.TextureRegion; 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.utils.ClickListener; import zero1hd.rhythmbullet.controls.KeyMap; public class KeyBindButton extends Actor { - TextureRegion keyIcon; - KeyMap keyMap; + private TextureRegion keyIcon; + private KeyMap keyMap; + private String controlKey; - public KeyBindButton(final KeyMap keyMap, final String control) { + public KeyBindButton(final KeyMap keyMap, final String control, ClickListener selectionListener, InputListener keyPressListener) { this.keyMap = keyMap; - keyIcon = keyMap.getIcon(keyMap.stringToID(control)); + this.keyIcon = keyMap.getIcon(keyMap.stringToID(control)); + this.controlKey = control; setSize(keyIcon.getRegionWidth(), keyIcon.getRegionHeight()); - InputListener keyListener = 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 (setKey(keycode, control)) { - keyMap.updateKeys(); - addAction(Actions.sequence(Actions.color(Color.GREEN, 0.2f), Actions.color(Color.WHITE, 0.2f))); - } else { - addAction(Actions.sequence(Actions.color(Color.RED, 0.2f), Actions.delay(0.1f), Actions.color(Color.WHITE, 0.2f))); - } - } - return super.keyUp(event, keycode); - - } - }; - - addListener(keyListener); - + addListener(selectionListener); + addListener(keyPressListener); } - public boolean setKey(int keycode, String control) { + public boolean setKey(int keycode) { if (keyMap.getIcon(keycode) != null) { - keyMap.getKeys().putInteger(control, keycode); + keyMap.getKeys().putInteger(controlKey, keycode); keyIcon = keyMap.getIcon(keycode); return true; } else {