v1.2.0: fixed some edge cases with selectors in inventory pane

This commit is contained in:
Evan Debenham 2022-02-02 22:03:29 -05:00
parent 58eb2242f4
commit 17e963a1fe
4 changed files with 14 additions and 7 deletions

View File

@ -104,7 +104,6 @@ public class Shopkeeper extends NPC {
} }
public static WndBag sell() { public static WndBag sell() {
//FIXME currently doesn't allow for repeated sales on new inventory pane
return GameScene.selectItem( itemSelector ); return GameScene.selectItem( itemSelector );
} }

View File

@ -89,7 +89,6 @@ public class Alchemize extends Spell {
@Override @Override
public void onSelect( Item item ) { public void onSelect( Item item ) {
if (item != null) { if (item != null) {
//FIXME currently doesn't allow for repeated alchemizes on new inventory pane
WndBag parentWnd = GameScene.selectItem( itemSelector ); WndBag parentWnd = GameScene.selectItem( itemSelector );
GameScene.show( new WndAlchemizeItem( item, parentWnd ) ); GameScene.show( new WndAlchemizeItem( item, parentWnd ) );
} }
@ -221,6 +220,9 @@ public class Alchemize extends Spell {
} }
} else { } else {
curItem.detach(Dungeon.hero.belongings.backpack); curItem.detach(Dungeon.hero.belongings.backpack);
if (owner == null){
GameScene.selectItem(itemSelector);
}
} }
} }

View File

@ -124,8 +124,9 @@ public class InventoryPane extends Component {
if (lastBag != item && !lastBag.contains(item) && !item.isEquipped(Dungeon.hero)){ if (lastBag != item && !lastBag.contains(item) && !item.isEquipped(Dungeon.hero)){
updateInventory(); updateInventory();
} else if (selector != null) { } else if (selector != null) {
selector.onSelect( item ); WndBag.ItemSelector activating = selector;
selector = null; selector = null;
activating.onSelect( item );
updateInventory(); updateInventory();
} else { } else {
GameScene.show(new WndUseItem( null, item )); GameScene.show(new WndUseItem( null, item ));
@ -163,8 +164,9 @@ public class InventoryPane extends Component {
if (lastBag != item && !lastBag.contains(item) && !item.isEquipped(Dungeon.hero)){ if (lastBag != item && !lastBag.contains(item) && !item.isEquipped(Dungeon.hero)){
updateInventory(); updateInventory();
} else if (selector != null) { } else if (selector != null) {
selector.onSelect( item ); WndBag.ItemSelector activating = selector;
selector = null; selector = null;
activating.onSelect( item );
updateInventory(); updateInventory();
} else { } else {
GameScene.show(new WndUseItem( null, item )); GameScene.show(new WndUseItem( null, item ));
@ -354,10 +356,14 @@ public class InventoryPane extends Component {
lastEnabled = (Dungeon.hero.ready || !Dungeon.hero.isAlive()); lastEnabled = (Dungeon.hero.ready || !Dungeon.hero.isAlive());
for (InventorySlot b : equipped){ for (InventorySlot b : equipped){
b.enable(lastEnabled && !(b.item() instanceof WndBag.Placeholder)); b.enable(lastEnabled
&& !(b.item() instanceof WndBag.Placeholder)
&& (selector == null || selector.itemSelectable(b.item())));
} }
for (InventorySlot b : bagItems){ for (InventorySlot b : bagItems){
b.enable(lastEnabled && b.item() != null); b.enable(lastEnabled
&& b.item() != null
&& (selector == null || selector.itemSelectable(b.item())));
} }
for (BagButton b : bags){ for (BagButton b : bags){
b.enable(lastEnabled); b.enable(lastEnabled);

View File

@ -166,8 +166,8 @@ public class WndTradeItem extends WndInfoItem {
if (owner != null) { if (owner != null) {
owner.hide(); owner.hide();
Shopkeeper.sell();
} }
Shopkeeper.sell();
} }
public static void sell( Item item ) { public static void sell( Item item ) {