equipmentMenu.SetActive();
break;
case CHOICE_STRONGEST:
+ // TODO
break;
case CHOICE_REMOVE:
actionMenu.SetSelected();
} else if (input.JustPressed(Input::ACTION_B)) {
Ctrl().PopState();
}
+ } else if (equipmentMenu.IsActive()) {
+ if (input.JustPressed(Input::PAD_UP)) {
+ equipmentMenu.PreviousRow();
+ }
+ if (input.JustPressed(Input::PAD_DOWN)) {
+ equipmentMenu.NextRow();
+ }
+ if (input.JustPressed(Input::ACTION_B)) {
+ equipmentMenu.SetInactive();
+ actionMenu.SetActive();
+ } else if (input.JustPressed(Input::ACTION_A)) {
+ switch (actionMenu.Selected()) {
+ case CHOICE_EQUIP:
+ // TODO
+ break;
+ case CHOICE_STRONGEST:
+ case CHOICE_REMOVE_ALL:
+ // invalid state, recover
+ equipmentMenu.SetInactive();
+ actionMenu.SetActive();
+ break;
+ case CHOICE_REMOVE:
+ RemoveItem();
+ break;
+ case CHOICE_DROP:
+ DropItem();
+ break;
+ }
+ }
}
}
LoadEquipment();
}
+void EquipMenu::RemoveItem() {
+ Inventory &inv(parent->Game().state->inventory);
+ switch (equipmentMenu.SelectedIndex()) {
+ case 0:
+ if (GetHero().HasWeapon() && inv.Add(GetHero().Weapon(), 1)) {
+ GetHero().RemoveWeapon();
+ }
+ break;
+ case 1:
+ if (GetHero().HasArmor() && inv.Add(GetHero().Armor(), 1)) {
+ GetHero().RemoveArmor();
+ }
+ break;
+ case 2:
+ if (GetHero().HasShield() && inv.Add(GetHero().Shield(), 1)) {
+ GetHero().RemoveShield();
+ }
+ break;
+ case 3:
+ if (GetHero().HasHelmet() && inv.Add(GetHero().Helmet(), 1)) {
+ GetHero().RemoveHelmet();
+ }
+ break;
+ case 4:
+ if (GetHero().HasRing() && inv.Add(GetHero().Ring(), 1)) {
+ GetHero().RemoveRing();
+ }
+ break;
+ case 5:
+ if (GetHero().HasJewel() && inv.Add(GetHero().Jewel(), 1)) {
+ GetHero().RemoveJewel();
+ }
+ break;
+ }
+ LoadEquipment();
+}
+
+void EquipMenu::DropItem() {
+ switch (equipmentMenu.SelectedIndex()) {
+ case 0:
+ GetHero().RemoveWeapon();
+ break;
+ case 1:
+ GetHero().RemoveArmor();
+ break;
+ case 2:
+ GetHero().RemoveShield();
+ break;
+ case 3:
+ GetHero().RemoveHelmet();
+ break;
+ case 4:
+ GetHero().RemoveRing();
+ break;
+ case 5:
+ GetHero().RemoveJewel();
+ break;
+ }
+ LoadEquipment();
+}
+
}