diff --git a/core/src/main/assets/messages/windows/windows.properties b/core/src/main/assets/messages/windows/windows.properties index c9325b503..4a695dd1a 100644 --- a/core/src/main/assets/messages/windows/windows.properties +++ b/core/src/main/assets/messages/windows/windows.properties @@ -136,10 +136,8 @@ windows.wndkeybindings.tag_danger=Switch Enemy windows.wndkeybindings.tag_action=Special Action windows.wndkeybindings.tag_loot=Pickup Item windows.wndkeybindings.tag_resume=Resume Motion -windows.wndkeybindings.zoom_in=Zoom In -windows.wndkeybindings.zoom_in_and_scroll=Zoom In / Scroll Up -windows.wndkeybindings.zoom_out=Zoom Out -windows.wndkeybindings.zoom_out_and_scroll=Zoom Out / Scroll Down +windows.wndkeybindings.zoom_in=Zoom In / Scroll Up +windows.wndkeybindings.zoom_out=Zoom Out / Scroll Down windows.wndkeybindings.n=Go North windows.wndkeybindings.e=Go East windows.wndkeybindings.s=Go South @@ -148,7 +146,7 @@ windows.wndkeybindings.ne=Go NE windows.wndkeybindings.se=Go SE windows.wndkeybindings.sw=Go SW windows.wndkeybindings.nw=Go NW -windows.wndkeybindings.cur=Wait / Pickup Item +windows.wndkeybindings.wait_or_pickup=Wait / Pickup Item windows.wndkeybindings$wndchangebinding.desc_first=Press a key to change the first key binding for: _%s_. windows.wndkeybindings$wndchangebinding.desc_second=Press a key to change the second key binding for: _%s_. windows.wndkeybindings$wndchangebinding.desc_third=Press a key to change the third key binding for: _%s_. diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDAction.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDAction.java index 461ed9cb8..29e2ef87a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDAction.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDAction.java @@ -54,7 +54,7 @@ public class SPDAction extends GameAction { public static final GameAction NE = new SPDAction("ne"); public static final GameAction SW = new SPDAction("sw"); public static final GameAction SE = new SPDAction("se"); - public static final GameAction WAIT = new SPDAction("wait"); + public static final GameAction WAIT_OR_PICKUP = new SPDAction("wait_or_pickup"); public static final GameAction INVENTORY = new SPDAction("inventory"); public static final GameAction QUICKSLOT_1 = new SPDAction("quickslot_1"); @@ -71,6 +71,7 @@ public class SPDAction extends GameAction { public static final GameAction BAG_5 = new SPDAction("bag_5"); public static final GameAction EXAMINE = new SPDAction("examine"); + public static final GameAction WAIT = new SPDAction("wait"); public static final GameAction REST = new SPDAction("rest"); public static final GameAction TAG_ATTACK = new SPDAction("tag_attack"); @@ -94,7 +95,7 @@ public class SPDAction extends GameAction { defaultBindings.put( Input.Keys.A, SPDAction.W ); defaultBindings.put( Input.Keys.S, SPDAction.S ); defaultBindings.put( Input.Keys.D, SPDAction.E ); - defaultBindings.put( Input.Keys.SPACE, SPDAction.WAIT ); + defaultBindings.put( Input.Keys.SPACE, SPDAction.WAIT_OR_PICKUP); defaultBindings.put( Input.Keys.UP, SPDAction.N ); defaultBindings.put( Input.Keys.LEFT, SPDAction.W ); @@ -109,7 +110,7 @@ public class SPDAction extends GameAction { defaultBindings.put( Input.Keys.NUMPAD_9, SPDAction.NE ); defaultBindings.put( Input.Keys.NUMPAD_1, SPDAction.SW ); defaultBindings.put( Input.Keys.NUMPAD_3, SPDAction.SE ); - defaultBindings.put( Input.Keys.NUMPAD_5, SPDAction.WAIT ); + defaultBindings.put( Input.Keys.NUMPAD_5, SPDAction.WAIT_OR_PICKUP ); defaultBindings.put( Input.Keys.F, SPDAction.INVENTORY ); defaultBindings.put( Input.Keys.I, SPDAction.INVENTORY ); @@ -162,7 +163,7 @@ public class SPDAction extends GameAction { defaultControllerBindings.put( Input.Keys.DPAD_DOWN+1000, SPDAction.S ); defaultControllerBindings.put( Input.Keys.DPAD_RIGHT+1000, SPDAction.E ); - defaultControllerBindings.put( Input.Keys.BUTTON_THUMBL, SPDAction.WAIT ); + defaultControllerBindings.put( Input.Keys.BUTTON_THUMBL, SPDAction.WAIT_OR_PICKUP ); defaultControllerBindings.put( Input.Keys.BUTTON_R1, SPDAction.INVENTORY ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ScrollPane.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ScrollPane.java index 8b2f2be2b..21d949b47 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ScrollPane.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ScrollPane.java @@ -21,15 +21,22 @@ package com.shatteredpixel.shatteredpixeldungeon.ui; +import com.shatteredpixel.shatteredpixeldungeon.SPDAction; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; +import com.watabou.input.GameAction; +import com.watabou.input.KeyBindings; +import com.watabou.input.KeyEvent; import com.watabou.input.PointerEvent; import com.watabou.input.ScrollEvent; import com.watabou.noosa.Camera; import com.watabou.noosa.ColorBlock; +import com.watabou.noosa.Game; import com.watabou.noosa.ScrollArea; import com.watabou.noosa.ui.Component; +import com.watabou.utils.GameMath; import com.watabou.utils.Point; import com.watabou.utils.PointF; +import com.watabou.utils.Signal; public class ScrollPane extends Component { @@ -37,9 +44,12 @@ public class ScrollPane extends Component { protected static final float THUMB_ALPHA = 0.5f; protected PointerController controller; + protected Signal.Listener keyListener; protected Component content; protected ColorBlock thumb; + private float keyScroll = 0; + public ScrollPane( Component content ) { super(); @@ -51,17 +61,64 @@ public class ScrollPane extends Component { content.camera = new Camera( 0, 0, 1, 1, PixelScene.defaultZoom ); Camera.add( content.camera ); + + KeyEvent.addKeyListener(keyListener = new Signal.Listener() { + @Override + public boolean onSignal(KeyEvent keyEvent) { + GameAction action = KeyBindings.getActionForKey(keyEvent); + if (action == SPDAction.ZOOM_IN){ + if (keyEvent.pressed){ + keyScroll += 1; + } else { + keyScroll -= 1; + } + keyScroll = GameMath.gate(-1f, keyScroll, +1f); + return true; + } else if (action == SPDAction.ZOOM_OUT){ + if (keyEvent.pressed){ + keyScroll -= 1; + } else { + keyScroll += 1; + } + keyScroll = GameMath.gate(-1f, keyScroll, +1f); + return true; + } + return false; + } + }); } @Override public void destroy() { super.destroy(); Camera.remove( content.camera ); + KeyEvent.removeKeyListener(keyListener); } public void scrollTo( float x, float y ) { - content.camera.scroll.set( x, y ); - thumb.y = this.y + height * content.camera.scroll.y / content.height(); + Camera c = content.camera; + c.scroll.set( x, y ); + if (c.scroll.x + width > content.width()) { + c.scroll.x = content.width() - width; + } + if (c.scroll.x < 0) { + c.scroll.x = 0; + } + if (c.scroll.y + height > content.height()) { + c.scroll.y = content.height() - height; + } + if (c.scroll.y < 0) { + c.scroll.y = 0; + } + thumb.y = this.y + height * c.scroll.y / content.height(); + } + + @Override + public synchronized void update() { + super.update(); + if (keyScroll != 0){ + scrollTo(content.camera.scroll.x, content.camera.scroll.y + (keyScroll * 150 * Game.elapsed)); + } } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java index 95683b3aa..328dedeed 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java @@ -134,6 +134,35 @@ public class Toolbar extends Component { else return null; } }); + + add(new Button(){ + @Override + protected void onClick() { + if (Dungeon.hero.ready && !GameScene.cancel()) { + if (Dungeon.level.heaps.get(Dungeon.hero.pos) != null + && Dungeon.hero.handle(Dungeon.hero.pos)){ + Dungeon.hero.next(); + } else { + examining = false; + Dungeon.hero.rest(false); + } + } + } + + protected boolean onLongClick() { + if (Dungeon.hero.ready && !GameScene.cancel()) { + examining = false; + Dungeon.hero.rest(true); + } + return true; + } + + @Override + public GameAction keyAction() { + if (btnWait.active) return SPDAction.WAIT_OR_PICKUP; + else return null; + } + }); add(btnSearch = new Tool(44, 0, 20, 26) { @Override