v2.0.1: quickslot contents now auto-swap when equipping items
This commit is contained in:
@@ -66,6 +66,8 @@ public abstract class EquipableItem extends Item {
|
||||
}
|
||||
}
|
||||
|
||||
protected static int slotOfUnequipped = -1;
|
||||
|
||||
@Override
|
||||
public void execute( Hero hero, String action ) {
|
||||
|
||||
@@ -75,10 +77,16 @@ public abstract class EquipableItem extends Item {
|
||||
//In addition to equipping itself, item reassigns itself to the quickslot
|
||||
//This is a special case as the item is being removed from inventory, but is staying with the hero.
|
||||
int slot = Dungeon.quickslot.getSlot( this );
|
||||
slotOfUnequipped = -1;
|
||||
doEquip(hero);
|
||||
if (slot != -1) {
|
||||
Dungeon.quickslot.setSlot( slot, this );
|
||||
updateQuickslot();
|
||||
//if this item wasn't quickslotted, but the item it is replacing as equipped was
|
||||
//then also have the item occupy the unequipped item's quickslot
|
||||
} else if (slotOfUnequipped != -1 && defaultAction() != null) {
|
||||
Dungeon.quickslot.setSlot( slotOfUnequipped, this );
|
||||
updateQuickslot();
|
||||
}
|
||||
} else if (action.equals( AC_UNEQUIP )) {
|
||||
doUnequip( hero, true );
|
||||
@@ -130,6 +138,8 @@ public abstract class EquipableItem extends Item {
|
||||
hero.spend( time2equip( hero ) );
|
||||
}
|
||||
|
||||
slotOfUnequipped = Dungeon.quickslot.getSlot(this);
|
||||
|
||||
//temporarily keep this item so it can be collected
|
||||
boolean wasKept = keptThoughLostInvent;
|
||||
keptThoughLostInvent = true;
|
||||
|
||||
@@ -66,19 +66,23 @@ abstract public class KindOfWeapon extends EquipableItem {
|
||||
@Override
|
||||
protected void onSelect(int index) {
|
||||
super.onSelect(index);
|
||||
if (index == 0){
|
||||
if (index == 0 || index == 1){
|
||||
//In addition to equipping itself, item reassigns itself to the quickslot
|
||||
//This is a special case as the item is being removed from inventory, but is staying with the hero.
|
||||
int slot = Dungeon.quickslot.getSlot( KindOfWeapon.this );
|
||||
doEquip(hero);
|
||||
slotOfUnequipped = -1;
|
||||
if (index == 0) {
|
||||
doEquip(hero);
|
||||
} else {
|
||||
equipSecondary(hero);
|
||||
}
|
||||
if (slot != -1) {
|
||||
Dungeon.quickslot.setSlot( slot, KindOfWeapon.this );
|
||||
updateQuickslot();
|
||||
}
|
||||
}
|
||||
if (index == 1){
|
||||
int slot = Dungeon.quickslot.getSlot( KindOfWeapon.this );
|
||||
equipSecondary(hero);
|
||||
if (slot != -1) {
|
||||
Dungeon.quickslot.setSlot( slot, KindOfWeapon.this );
|
||||
//if this item wasn't quickslotted, but the item it is replacing as equipped was
|
||||
//then also have the item occupy the unequipped item's quickslot
|
||||
} else if (slotOfUnequipped != -1 && defaultAction() != null) {
|
||||
Dungeon.quickslot.setSlot( slotOfUnequipped, KindOfWeapon.this );
|
||||
updateQuickslot();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ public abstract class KindofMisc extends EquipableItem {
|
||||
// to unequip the equipped one, but don't want to trigger any other
|
||||
// item detaching logic
|
||||
int slot = Dungeon.quickslot.getSlot(KindofMisc.this);
|
||||
slotOfUnequipped = -1;
|
||||
Dungeon.hero.belongings.backpack.items.remove(KindofMisc.this);
|
||||
if (equipped.doUnequip(hero, true, false)) {
|
||||
//swap out equip in misc slot if needed
|
||||
@@ -115,7 +116,11 @@ public abstract class KindofMisc extends EquipableItem {
|
||||
} else {
|
||||
Dungeon.hero.belongings.backpack.items.add(KindofMisc.this);
|
||||
}
|
||||
if (slot != -1) Dungeon.quickslot.setSlot(slot, KindofMisc.this);
|
||||
if (slot != -1) {
|
||||
Dungeon.quickslot.setSlot(slot, KindofMisc.this);
|
||||
} else if (slotOfUnequipped != -1){
|
||||
Dungeon.quickslot.setSlot(slotOfUnequipped, KindofMisc.this);
|
||||
}
|
||||
updateQuickslot();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user