From dfdd0648de2f3938d0bc105f62e2d1c7fa5de68f Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 4 Feb 2022 14:31:08 -0500 Subject: [PATCH] v1.2.0: fixed various issues caused by new inventory pane --- .../shatteredpixeldungeon/items/Item.java | 3 +-- .../shatteredpixeldungeon/scenes/CellSelector.java | 2 +- .../shatteredpixeldungeon/scenes/GameScene.java | 14 +++++++++++++- .../shatteredpixeldungeon/ui/InventoryPane.java | 4 ++++ .../windows/WndTradeItem.java | 8 +++++++- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Item.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Item.java index 0f76291e8..7efe080ee 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Item.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Item.java @@ -490,8 +490,7 @@ public class Item implements Bundlable { } public static void updateQuickslot() { - QuickSlotButton.refresh(); - InventoryPane.refresh(); + GameScene.updateItemDisplays = true; } private static final String QUANTITY = "quantity"; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/CellSelector.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/CellSelector.java index d0e4e0bb6..7226eb224 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/CellSelector.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/CellSelector.java @@ -143,7 +143,7 @@ public class CellSelector extends ScrollArea { } public void select( int cell ) { - if (enabled && Dungeon.hero.ready && !GameScene.isShowingWindow() + if (enabled && Dungeon.hero.ready && !GameScene.InterfaceBlockingHero() && listener != null && cell != -1) { listener.onSelect( cell ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java index ce6a1a7b3..41920ad25 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java @@ -664,11 +664,19 @@ public class GameScene extends PixelScene { //the actor thread processes at a maximum of 60 times a second //this caps the speed of resting for higher refresh rate displays private float notifyDelay = 1/60f; + + public static boolean updateItemDisplays = false; @Override public synchronized void update() { lastOffset = null; + if (updateItemDisplays){ + updateItemDisplays = false; + QuickSlotButton.refresh(); + InventoryPane.refresh(); + } + if (Dungeon.hero == null || scene == null) { return; } @@ -1084,13 +1092,17 @@ public class GameScene extends PixelScene { } } - public static boolean isShowingWindow(){ + public static boolean InterfaceBlockingHero(){ if (scene == null) return false; for (Gizmo g : scene.members){ if (g instanceof Window) return true; } + if (scene.inventory != null && scene.inventory.isSelecting()){ + return true; + } + return false; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/InventoryPane.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/InventoryPane.java index 7a6b0ad0e..ba41aa275 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/InventoryPane.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/InventoryPane.java @@ -348,6 +348,10 @@ public class InventoryPane extends Component { updateInventory(); } + public boolean isSelecting(){ + return selector != null; + } + @Override public synchronized void update() { super.update(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndTradeItem.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndTradeItem.java index 173566567..74d2c914f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndTradeItem.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndTradeItem.java @@ -42,11 +42,15 @@ public class WndTradeItem extends WndInfoItem { private WndBag owner; + private boolean selling = false; + //selling public WndTradeItem( final Item item, WndBag owner ) { super(item); + selling = true; + this.owner = owner; float pos = height; @@ -102,6 +106,8 @@ public class WndTradeItem extends WndInfoItem { super(heap); + selling = false; + Item item = heap.peek(); float pos = height; @@ -167,7 +173,7 @@ public class WndTradeItem extends WndInfoItem { if (owner != null) { owner.hide(); } - Shopkeeper.sell(); + if (selling) Shopkeeper.sell(); } public static void sell( Item item ) {