gameState.heroes[0].AddSpell(valorSpell);
gameState.heroes[1].AddSpell(valorSpell);
+ gameState.inventory.Add(caster.GetItem("zirconPlateItem"));
gameState.inventory.Add(caster.GetItem("antidoteItem"), 9);
+ gameState.inventory.Add(caster.GetItem("powerRingItem"));
gameState.inventory.Add(caster.GetItem("magicJarItem"), 4);
+ gameState.inventory.Add(caster.GetItem("sProRingItem"));
gameState.inventory.Add(caster.GetItem("hiPotionItem"), 4);
+ gameState.inventory.Add(caster.GetItem("powerRingItem"));
gameState.inventory.Add(caster.GetItem("powerPotionItem"), 4);
+ gameState.inventory.Add(caster.GetItem("zircoSwordItem"));
gameState.inventory.Add(caster.GetItem("escapeItem"), 2);
+ gameState.inventory.Add(caster.GetItem("zircoHelmetItem"));
gameState.inventory.Add(caster.GetItem("sleepBallItem"), 1);
+ gameState.inventory.Add(caster.GetItem("zirconPlateItem"));
gameState.heroes[0].SetWeapon(caster.GetItem("zircoSwordItem"));
gameState.heroes[0].SetArmor(caster.GetItem("zirconArmorItem"));
: parent(parent)
, menu(*parent->Res().itemMenuProperties)
, itemMenu(*parent->Res().inventoryMenuProperties) {
- menu.Add(parent->Res().itemMenuUseText, 0);
- menu.Add(parent->Res().itemMenuSortText, 1);
- menu.Add(parent->Res().itemMenuDropText, 2);
+ menu.Add(parent->Res().itemMenuUseText, CHOICE_USE);
+ menu.Add(parent->Res().itemMenuSortText, CHOICE_SORT);
+ menu.Add(parent->Res().itemMenuDropText, CHOICE_DROP);
}
void InventoryMenu::OnEnterState(SDL_Surface *) {
menu.SetSelected();
+ LoadInventory();
+}
+
+void InventoryMenu::LoadInventory() {
const Inventory &inv(parent->Game().state->inventory);
itemMenu.Clear();
itemMenu.Reserve(inv.MaxItems());
if (input.JustPressed(Input::ACTION_A)) {
if (menu.IsActive()) {
- menu.SetSelected();
- itemMenu.SetActive();
+ if (menu.Selected() == CHOICE_SORT) {
+ parent->Game().state->inventory.Sort();
+ LoadInventory();
+ } else {
+ menu.SetSelected();
+ itemMenu.SetActive();
+ }
}
}
if (input.JustPressed(Input::ACTION_B)) {
virtual void OnResize(int width, int height);
+ void LoadInventory();
+
void RenderMenu(SDL_Surface *screen, const geometry::Vector<int> &offset) const;
void RenderInventory(SDL_Surface *screen, const geometry::Vector<int> &offset) const;
private:
PartyMenu *parent;
- graphics::Menu<int> menu;
+ enum Choice {
+ CHOICE_USE,
+ CHOICE_SORT,
+ CHOICE_DROP,
+ };
+ graphics::Menu<Choice> menu;
graphics::Menu<const common::Item *> itemMenu;
};