X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmenu%2FInventoryMenu.cpp;h=de60edcf0e2289458d8e7d6e7252564b2c8e30a3;hb=63a2a96b70a18d08a2714571f79fe7d99612cb9e;hp=429fefe59da30888f73b0037c6ae493ec8495daf;hpb=24a1c72ef826bac796575dd259d43db55054482e;p=l2e.git diff --git a/src/menu/InventoryMenu.cpp b/src/menu/InventoryMenu.cpp index 429fefe..de60edc 100644 --- a/src/menu/InventoryMenu.cpp +++ b/src/menu/InventoryMenu.cpp @@ -1,14 +1,8 @@ -/* - * InventoryMenu.cpp - * - * Created on: Nov 4, 2012 - * Author: holy - */ - #include "InventoryMenu.h" #include "PartyMenu.h" #include "Resources.h" +#include "../app/Application.h" #include "../app/Input.h" #include "../common/GameConfig.h" #include "../common/GameState.h" @@ -16,13 +10,15 @@ #include "../common/Item.h" #include "../graphics/Font.h" #include "../graphics/Frame.h" +#include "../math/Vector.h" using app::Input; using common::Inventory; using common::Item; -using geometry::Vector; +using math::Vector; using graphics::Font; using graphics::Frame; +using std::swap; namespace menu { @@ -38,7 +34,9 @@ InventoryMenu::InventoryMenu(PartyMenu *parent) void InventoryMenu::OnEnterState(SDL_Surface *) { menu.SetSelected(); + menu.StartAnimation(Ctrl()); LoadInventory(); + itemMenu.StartAnimation(Ctrl()); } void InventoryMenu::LoadInventory() { @@ -99,19 +97,50 @@ void InventoryMenu::HandleEvents(const Input &input) { menu.SetSelected(); itemMenu.SetActive(); } + } else if (itemMenu.IsActive()) { + itemMenu.SetDualSelection(); + } else if (itemMenu.SelectedIndex() == itemMenu.SecondaryIndex()) { + switch (menu.Selected()) { + case CHOICE_USE: + if (itemMenu.Selected()->CanUseOnStatusScreen()) { + // TODO: implement item use + } + itemMenu.SetActive(); + break; + case CHOICE_SORT: + // invalid state, recover + menu.SetActive(); + itemMenu.SetInactive(); + break; + case CHOICE_DROP: + if (itemMenu.Selected()->CanDrop()) { + parent->Game().state->inventory.RemoveAll(itemMenu.Selected()); + itemMenu.ClearEntry(itemMenu.SelectedIndex()); + } + itemMenu.SetActive(); + break; + } + } else { + parent->Game().state->inventory.SwapEntriesAt( + itemMenu.SelectedIndex(), + itemMenu.SecondaryIndex()); + itemMenu.SwapSelected(); + itemMenu.SetActive(); } } if (input.JustPressed(Input::ACTION_B)) { if (menu.IsActive()) { Ctrl().PopState(); - } else { + } else if (itemMenu.IsActive()) { menu.SetActive(); itemMenu.SetInactive(); + } else { + itemMenu.SetActive(); } } } -void InventoryMenu::UpdateWorld(float deltaT) { +void InventoryMenu::UpdateWorld(Uint32 deltaT) { }