v1.2.0: added keybinds for bag tabs, adjusted WASD defaults

This commit is contained in:
Evan Debenham 2022-02-15 15:38:07 -05:00
parent b2f1b74e50
commit c354dd3004
5 changed files with 72 additions and 9 deletions

View File

@ -109,6 +109,11 @@ windows.wndkeybindings.quickslot_3=Quickslot 3
windows.wndkeybindings.quickslot_4=Quickslot 4
windows.wndkeybindings.quickslot_5=Quickslot 5
windows.wndkeybindings.quickslot_6=Quickslot 6
windows.wndkeybindings.bag_1=Container 1
windows.wndkeybindings.bag_2=Container 2
windows.wndkeybindings.bag_3=Container 3
windows.wndkeybindings.bag_4=Container 4
windows.wndkeybindings.bag_5=Container 5
windows.wndkeybindings.tag_attack=Attack Enemy
windows.wndkeybindings.tag_danger=Switch Enemy
windows.wndkeybindings.tag_action=Special Action

View File

@ -59,6 +59,12 @@ public class SPDAction extends GameAction {
public static final GameAction QUICKSLOT_5 = new SPDAction("quickslot_5");
public static final GameAction QUICKSLOT_6 = new SPDAction("quickslot_6");
public static final GameAction BAG_1 = new SPDAction("bag_1");
public static final GameAction BAG_2 = new SPDAction("bag_2");
public static final GameAction BAG_3 = new SPDAction("bag_3");
public static final GameAction BAG_4 = new SPDAction("bag_4");
public static final GameAction BAG_5 = new SPDAction("bag_5");
public static final GameAction SEARCH = new SPDAction("search");
public static final GameAction REST = new SPDAction("rest");
@ -81,13 +87,13 @@ public class SPDAction extends GameAction {
defaultBindings.put( Input.Keys.W, SPDAction.N );
defaultBindings.put( Input.Keys.A, SPDAction.W );
defaultBindings.put( Input.Keys.S, SPDAction.S );
defaultBindings.put( Input.Keys.X, SPDAction.S );
defaultBindings.put( Input.Keys.D, SPDAction.E );
defaultBindings.put( Input.Keys.Q, SPDAction.NW );
defaultBindings.put( Input.Keys.E, SPDAction.NE );
defaultBindings.put( Input.Keys.Z, SPDAction.SW );
defaultBindings.put( Input.Keys.C, SPDAction.SE );
defaultBindings.put( Input.Keys.X, SPDAction.WAIT );
defaultBindings.put( Input.Keys.S, SPDAction.WAIT );
defaultBindings.put( Input.Keys.NUMPAD_8, SPDAction.N );
defaultBindings.put( Input.Keys.NUMPAD_4, SPDAction.W );
@ -113,6 +119,12 @@ public class SPDAction extends GameAction {
defaultBindings.put( Input.Keys.NUM_5, SPDAction.QUICKSLOT_5 );
defaultBindings.put( Input.Keys.NUM_6, SPDAction.QUICKSLOT_6 );
defaultBindings.put( Input.Keys.F1, SPDAction.BAG_1 );
defaultBindings.put( Input.Keys.F2, SPDAction.BAG_2 );
defaultBindings.put( Input.Keys.F3, SPDAction.BAG_3 );
defaultBindings.put( Input.Keys.F4, SPDAction.BAG_4 );
defaultBindings.put( Input.Keys.F5, SPDAction.BAG_5 );
defaultBindings.put( Input.Keys.G, SPDAction.SEARCH );
defaultBindings.put( Input.Keys.B, SPDAction.REST );

View File

@ -201,11 +201,11 @@ public class WelcomeScene extends PixelScene {
"Key Bindings",
"Shattered Pixel Dungeon's default keybindings have changed based on early demo feedback!\n\n" +
"Here's a quick summary of what's been adjusted:\n" +
"_-_ The WASD and QEZC keys are now used for movement\n" +
"_-_ The WAXD and QEZC keys are now used for movement, S is used for waiting\n" +
"_-_ Quickslots now use the number keys\n" +
"_-_ Several game action bindings have been moved to the right of WASD\n" +
"_-_ Inventory bags can now be tabbed through with F1-F5\n" +
"_-_ Other binding (including numpad and arrow keys to move) are unchanged." +
"_-_ Other bindings (including numpad and arrow keys to move) are unchanged." +
"Please let me know if these new bindings work well for you, I am open to further adjustments. All keybinds can still be customized via the settings menu.",
Messages.get(this, "continue"),
2){

View File

@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.ui;
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.SPDAction;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings;
@ -40,6 +41,8 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndUseItem;
import com.watabou.gltextures.TextureCache;
import com.watabou.input.GameAction;
import com.watabou.input.KeyBindings;
import com.watabou.input.KeyEvent;
import com.watabou.input.PointerEvent;
import com.watabou.noosa.BitmapText;
@ -136,7 +139,12 @@ public class InventoryPane extends Component {
keyBlocker = new Signal.Listener<KeyEvent>(){
@Override
public boolean onSignal(KeyEvent keyEvent) {
if (keyEvent.pressed && isSelecting()){
if (keyEvent.pressed && isSelecting()
&& KeyBindings.getActionForKey(keyEvent) != SPDAction.BAG_1
&& KeyBindings.getActionForKey(keyEvent) != SPDAction.BAG_2
&& KeyBindings.getActionForKey(keyEvent) != SPDAction.BAG_3
&& KeyBindings.getActionForKey(keyEvent) != SPDAction.BAG_4
&& KeyBindings.getActionForKey(keyEvent) != SPDAction.BAG_5){
selector = null;
updateInventory();
return true;
@ -177,7 +185,7 @@ public class InventoryPane extends Component {
bags = new ArrayList<>();
for (int i = 0; i < 5; i++){
BagButton btn = new BagButton(null);
BagButton btn = new BagButton(null, i+1);
bags.add(btn);
add(btn);
}
@ -542,10 +550,12 @@ public class InventoryPane extends Component {
private ColorBlock bgBottom;
private Bag bag;
private int index;
public BagButton( Bag bag ){
public BagButton( Bag bag, int index ){
super( bagIcon(bag) );
this.bag = bag;
this.index = index;
visible = active = bag != null;
}
@ -594,6 +604,22 @@ public class InventoryPane extends Component {
refresh();
}
@Override
public GameAction keyAction() {
switch (index){
case 1: default:
return SPDAction.BAG_1;
case 2:
return SPDAction.BAG_2;
case 3:
return SPDAction.BAG_3;
case 4:
return SPDAction.BAG_4;
case 5:
return SPDAction.BAG_5;
}
}
@Override
protected String hoverText() {
return Messages.titleCase(bag.name());

View File

@ -48,6 +48,7 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
import com.shatteredpixel.shatteredpixeldungeon.ui.RightClickMenu;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.watabou.gltextures.TextureCache;
import com.watabou.input.GameAction;
import com.watabou.input.KeyBindings;
import com.watabou.input.KeyEvent;
import com.watabou.input.PointerEvent;
@ -134,9 +135,10 @@ public class WndBag extends WndTabbed {
resize( windowWidth, windowHeight );
int i = 1;
for (Bag b : Dungeon.hero.belongings.getBags()) {
if (b != null) {
BagTab tab = new BagTab( b );
BagTab tab = new BagTab( b, i++ );
add( tab );
tab.select( b == bag );
}
@ -405,11 +407,29 @@ public class WndBag extends WndTabbed {
private class BagTab extends IconTab {
private Bag bag;
private int index;
public BagTab( Bag bag ) {
public BagTab( Bag bag, int index ) {
super( icon(bag) );
this.bag = bag;
this.index = index;
}
@Override
public GameAction keyAction() {
switch (index){
case 1: default:
return SPDAction.BAG_1;
case 2:
return SPDAction.BAG_2;
case 3:
return SPDAction.BAG_3;
case 4:
return SPDAction.BAG_4;
case 5:
return SPDAction.BAG_5;
}
}
@Override