]> git.localhorst.tv Git - l2e.git/blobdiff - src/menu/InventoryMenu.cpp
hook alternate cursor in inventory menu
[l2e.git] / src / menu / InventoryMenu.cpp
index 2ea7fb328eaf90dcb1ca90eb492cf7ba87626c7a..82a615b103a465c0e77ef41f78090ce0dc79f6aa 100644 (file)
@@ -37,6 +37,7 @@ InventoryMenu::InventoryMenu(PartyMenu *parent)
 
 
 void InventoryMenu::OnEnterState(SDL_Surface *) {
+       menu.SetSelected();
        const Inventory &inv(parent->Game().state->inventory);
        itemMenu.Clear();
        itemMenu.Reserve(inv.MaxItems());
@@ -69,18 +70,35 @@ void InventoryMenu::OnResize(int width, int height) {
 
 
 void InventoryMenu::HandleEvents(const Input &input) {
-       if (input.JustPressed(Input::PAD_LEFT)) {
-               menu.PreviousItem();
-       }
-       if (input.JustPressed(Input::PAD_RIGHT)) {
-               menu.NextItem();
+       if (menu.IsActive()) {
+               if (input.JustPressed(Input::PAD_LEFT)) {
+                       menu.PreviousItem();
+               }
+               if (input.JustPressed(Input::PAD_RIGHT)) {
+                       menu.NextItem();
+               }
+       } else {
+               if (input.JustPressed(Input::PAD_UP)) {
+                       itemMenu.PreviousItem();
+               }
+               if (input.JustPressed(Input::PAD_DOWN)) {
+                       itemMenu.NextItem();
+               }
        }
 
-       if (input.JustPressed(Input::PAD_UP)) {
-               itemMenu.PreviousItem();
+       if (input.JustPressed(Input::ACTION_A)) {
+               if (menu.IsActive()) {
+                       menu.SetSelected();
+                       itemMenu.SetActive();
+               }
        }
-       if (input.JustPressed(Input::PAD_DOWN)) {
-               itemMenu.NextItem();
+       if (input.JustPressed(Input::ACTION_B)) {
+               if (menu.IsActive()) {
+                       Ctrl().PopState();
+               } else {
+                       menu.SetActive();
+                       itemMenu.SetInactive();
+               }
        }
 }