v0.8.0: added all other key actions from old desktop build, no remapping yet
This commit is contained in:
+31
-17
@@ -21,7 +21,6 @@
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.scenes;
|
||||
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
@@ -30,6 +29,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
|
||||
import com.watabou.input.KeyAction;
|
||||
import com.watabou.input.KeyBindings;
|
||||
import com.watabou.input.KeyEvent;
|
||||
import com.watabou.input.PointerEvent;
|
||||
@@ -55,7 +55,7 @@ public class CellSelector extends ScrollArea {
|
||||
dragThreshold = PixelScene.defaultZoom * DungeonTilemap.SIZE / 2;
|
||||
|
||||
mouseZoom = camera.zoom;
|
||||
KeyEvent.addKeyListener(movementListener);
|
||||
KeyEvent.addKeyListener( keyListener );
|
||||
}
|
||||
|
||||
private float mouseZoom;
|
||||
@@ -208,19 +208,33 @@ public class CellSelector extends ScrollArea {
|
||||
|
||||
}
|
||||
|
||||
private KeyEvent heldKey = null;
|
||||
private int heldKeyTurns = 0;
|
||||
private KeyAction heldAction = null;
|
||||
private int heldTurns = 0;
|
||||
|
||||
private Signal.Listener<KeyEvent> movementListener = new Signal.Listener<KeyEvent>() {
|
||||
private Signal.Listener<KeyEvent> keyListener = new Signal.Listener<KeyEvent>() {
|
||||
@Override
|
||||
public boolean onSignal(KeyEvent event) {
|
||||
KeyAction action = KeyBindings.getBinding( event );
|
||||
if (!event.pressed){
|
||||
if (heldKey != null && heldKey.code == event.code) {
|
||||
|
||||
if (heldAction != null && heldAction == action) {
|
||||
resetKeyHold();
|
||||
return true;
|
||||
} else {
|
||||
switch (action){
|
||||
case ZOOM_IN:
|
||||
zoom( camera.zoom+1 );
|
||||
return true;
|
||||
case ZOOM_OUT:
|
||||
zoom( camera.zoom-1 );
|
||||
return true;
|
||||
case ZOOM_DEFAULT:
|
||||
zoom( PixelScene.defaultZoom );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (moveFromKey(event)) {
|
||||
heldKey = event;
|
||||
} else if (moveFromKey(action)) {
|
||||
heldAction = action;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -228,11 +242,11 @@ public class CellSelector extends ScrollArea {
|
||||
}
|
||||
};
|
||||
|
||||
private boolean moveFromKey(KeyEvent event){
|
||||
private boolean moveFromKey(KeyAction event){
|
||||
boolean moved = true;
|
||||
int cell = Dungeon.hero.pos;
|
||||
//TODO implement game actions, instead of using keys directly
|
||||
switch (KeyBindings.getBinding( event )){
|
||||
switch (event){
|
||||
case N:
|
||||
cell += -Dungeon.level.width();
|
||||
break;
|
||||
@@ -265,7 +279,7 @@ public class CellSelector extends ScrollArea {
|
||||
//each step when keyboard moving takes 0.15s, 0.125s, 0.1s, 0.1s, ...
|
||||
// this is to make it easier to move 1 or 2 steps without overshooting
|
||||
CharSprite.setMoveInterval( CharSprite.DEFAULT_MOVE_INTERVAL +
|
||||
Math.max(0, 0.05f - heldKeyTurns*0.025f));
|
||||
Math.max(0, 0.05f - heldTurns *0.025f));
|
||||
select(cell);
|
||||
}
|
||||
|
||||
@@ -273,16 +287,16 @@ public class CellSelector extends ScrollArea {
|
||||
}
|
||||
|
||||
public void processKeyHold(){
|
||||
if (heldKey != null){
|
||||
if (heldAction != null){
|
||||
enabled = true;
|
||||
heldKeyTurns++;
|
||||
moveFromKey(heldKey);
|
||||
heldTurns++;
|
||||
moveFromKey(heldAction);
|
||||
}
|
||||
}
|
||||
|
||||
public void resetKeyHold(){
|
||||
heldKey = null;
|
||||
heldKeyTurns = 0;
|
||||
heldAction = null;
|
||||
heldTurns = 0;
|
||||
CharSprite.setMoveInterval( CharSprite.DEFAULT_MOVE_INTERVAL );
|
||||
}
|
||||
|
||||
@@ -315,7 +329,7 @@ public class CellSelector extends ScrollArea {
|
||||
@Override
|
||||
public void destroy() {
|
||||
super.destroy();
|
||||
KeyEvent.removeKeyListener(movementListener);
|
||||
KeyEvent.removeKeyListener( keyListener );
|
||||
}
|
||||
|
||||
public interface Listener {
|
||||
|
||||
@@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.watabou.input.KeyAction;
|
||||
import com.watabou.noosa.Image;
|
||||
|
||||
public class ActionIndicator extends Tag {
|
||||
@@ -40,7 +41,12 @@ public class ActionIndicator extends Tag {
|
||||
setSize( 24, 24 );
|
||||
visible = false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public KeyAction keyAction() {
|
||||
return KeyAction.TAG_ACTION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
super.destroy();
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
||||
import com.watabou.input.KeyAction;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.utils.Random;
|
||||
import com.watabou.utils.Reflection;
|
||||
@@ -57,6 +58,11 @@ public class AttackIndicator extends Tag {
|
||||
enable( false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyAction keyAction() {
|
||||
return KeyAction.TAG_ATTACK;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createChildren() {
|
||||
super.createChildren();
|
||||
|
||||
@@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.watabou.input.KeyAction;
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.Image;
|
||||
@@ -47,6 +48,11 @@ public class DangerIndicator extends Tag {
|
||||
visible = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyAction keyAction() {
|
||||
return KeyAction.TAG_DANGER;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createChildren() {
|
||||
super.createChildren();
|
||||
|
||||
@@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.watabou.input.KeyAction;
|
||||
|
||||
public class LootIndicator extends Tag {
|
||||
|
||||
@@ -40,6 +41,11 @@ public class LootIndicator extends Tag {
|
||||
visible = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyAction keyAction() {
|
||||
return KeyAction.TAG_LOOT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createChildren() {
|
||||
super.createChildren();
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.BArray;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
||||
import com.watabou.input.KeyAction;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
import com.watabou.utils.PathFinder;
|
||||
@@ -92,6 +93,11 @@ public class QuickSlotButton extends Button implements WndBag.Listener {
|
||||
item.execute( Dungeon.hero );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyAction keyAction() {
|
||||
return QuickSlotButton.this.keyAction();
|
||||
}
|
||||
@Override
|
||||
protected boolean onLongClick() {
|
||||
return QuickSlotButton.this.onLongClick();
|
||||
@@ -127,6 +133,22 @@ public class QuickSlotButton extends Button implements WndBag.Listener {
|
||||
PixelScene.align(crossB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyAction keyAction() {
|
||||
switch (slotNum){
|
||||
case 0:
|
||||
return KeyAction.QUICKSLOT_1;
|
||||
case 1:
|
||||
return KeyAction.QUICKSLOT_2;
|
||||
case 2:
|
||||
return KeyAction.QUICKSLOT_3;
|
||||
case 3:
|
||||
return KeyAction.QUICKSLOT_4;
|
||||
default:
|
||||
return super.keyAction();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
GameScene.selectItem( this, WndBag.Mode.QUICKSLOT, Messages.get(this, "select_item") );
|
||||
|
||||
@@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.watabou.input.KeyAction;
|
||||
import com.watabou.noosa.Image;
|
||||
|
||||
public class ResumeIndicator extends Tag {
|
||||
@@ -37,6 +38,11 @@ public class ResumeIndicator extends Tag {
|
||||
visible = false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyAction keyAction() {
|
||||
return KeyAction.TAG_RESUME;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createChildren() {
|
||||
|
||||
@@ -32,7 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndGame;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndHero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndJournal;
|
||||
import com.watabou.input.PointerEvent;
|
||||
import com.watabou.input.KeyAction;
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.Game;
|
||||
@@ -82,14 +82,18 @@ public class StatusPane extends Component {
|
||||
bg = new NinePatch( Assets.STATUS, 0, 0, 128, 36, 85, 0, 45, 0 );
|
||||
add( bg );
|
||||
|
||||
add( new PointerArea( 0, 1, 31, 31 ) {
|
||||
add( new Button(){
|
||||
@Override
|
||||
protected void onClick( PointerEvent event ) {
|
||||
Image sprite = Dungeon.hero.sprite;
|
||||
Camera.main.panTo( sprite.center(), 5f );
|
||||
protected void onClick () {
|
||||
Camera.main.panTo( Dungeon.hero.sprite.center(), 5f );
|
||||
GameScene.show( new WndHero() );
|
||||
}
|
||||
} );
|
||||
|
||||
@Override
|
||||
public KeyAction keyAction() {
|
||||
return KeyAction.HERO_INFO;
|
||||
}
|
||||
}.setRect( 0, 1, 30, 30 ));
|
||||
|
||||
btnJournal = new JournalButton();
|
||||
add( btnJournal );
|
||||
@@ -259,7 +263,12 @@ public class StatusPane extends Component {
|
||||
width = bg.width + 13; //includes the depth display to the left
|
||||
height = bg.height + 4;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public KeyAction keyAction() {
|
||||
return KeyAction.JOURNAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createChildren() {
|
||||
super.createChildren();
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTerrainTilemap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndJournal;
|
||||
import com.watabou.input.KeyAction;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.Gizmo;
|
||||
@@ -78,7 +79,12 @@ public class Toolbar extends Component {
|
||||
examining = false;
|
||||
Dungeon.hero.rest(false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public KeyAction keyAction() {
|
||||
return KeyAction.WAIT;
|
||||
}
|
||||
|
||||
protected boolean onLongClick() {
|
||||
examining = false;
|
||||
Dungeon.hero.rest(true);
|
||||
@@ -97,7 +103,12 @@ public class Toolbar extends Component {
|
||||
Dungeon.hero.search(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public KeyAction keyAction() {
|
||||
return KeyAction.SEARCH;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onLongClick() {
|
||||
Dungeon.hero.search(true);
|
||||
@@ -123,6 +134,11 @@ public class Toolbar extends Component {
|
||||
GameScene.show(new WndBag(Dungeon.hero.belongings.backpack, null, WndBag.Mode.ALL, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyAction keyAction() {
|
||||
return KeyAction.INVENTORY;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onLongClick() {
|
||||
WndJournal.last_index = 3; //catalog page
|
||||
|
||||
Reference in New Issue
Block a user