v2.0.0: improved cell selector cancelling logic

This commit is contained in:
Evan Debenham
2022-11-03 14:18:40 -04:00
parent 0a85d4ef41
commit 2539d8c2f6
2 changed files with 9 additions and 4 deletions
@@ -391,6 +391,10 @@ public class CellSelector extends ScrollArea {
return false; return false;
} }
if (GameScene.cancelCellSelector()){
return false;
}
int cell = Dungeon.hero.pos; int cell = Dungeon.hero.pos;
for (GameAction action : actions) { for (GameAction action : actions) {
cell += directionFromAction(action); cell += directionFromAction(action);
@@ -1167,7 +1167,7 @@ public class GameScene extends PixelScene {
public static void show( Window wnd ) { public static void show( Window wnd ) {
if (scene != null) { if (scene != null) {
cancelCellSelector(); cancel();
//If a window is already present (or was just present) //If a window is already present (or was just present)
// then inherit the offset it had // then inherit the offset it had
@@ -1353,9 +1353,9 @@ public class GameScene extends PixelScene {
} }
} }
private static boolean cancelCellSelector() { public static boolean cancelCellSelector() {
cellSelector.resetKeyHold();
if (cellSelector.listener != null && cellSelector.listener != defaultCellListener) { if (cellSelector.listener != null && cellSelector.listener != defaultCellListener) {
cellSelector.resetKeyHold();
cellSelector.cancel(); cellSelector.cancel();
return true; return true;
} else { } else {
@@ -1364,7 +1364,7 @@ public class GameScene extends PixelScene {
} }
public static WndBag selectItem( WndBag.ItemSelector listener ) { public static WndBag selectItem( WndBag.ItemSelector listener ) {
cancelCellSelector(); cancel();
if (scene != null) { if (scene != null) {
//TODO can the inventory pane work in these cases? bad to fallback to mobile window //TODO can the inventory pane work in these cases? bad to fallback to mobile window
@@ -1382,6 +1382,7 @@ public class GameScene extends PixelScene {
} }
public static boolean cancel() { public static boolean cancel() {
cellSelector.resetKeyHold();
if (Dungeon.hero != null && (Dungeon.hero.curAction != null || Dungeon.hero.resting)) { if (Dungeon.hero != null && (Dungeon.hero.curAction != null || Dungeon.hero.resting)) {
Dungeon.hero.curAction = null; Dungeon.hero.curAction = null;