]> git.localhorst.tv Git - l2e.git/blobdiff - src/menu/PartyMenu.cpp
added hero selection state + status stub
[l2e.git] / src / menu / PartyMenu.cpp
index 5a68ca4fa5c3eac66b39055f18d28e861b29f2e6..85d19d2064456b74e44e63ce988253672b952ead 100644 (file)
@@ -8,6 +8,8 @@
 #include "PartyMenu.h"
 
 #include "Resources.h"
+#include "SelectHero.h"
+#include "StatusMenu.h"
 #include "../app/Application.h"
 #include "../app/Input.h"
 #include "../common/GameConfig.h"
@@ -86,6 +88,30 @@ void PartyMenu::HandleEvents(const Input &input) {
        } else if (input.JustPressed(Input::PAD_LEFT)) {
                mainMenu.PreviousItem();
        }
+
+       if (input.JustPressed(Input::ACTION_A)) {
+               switch (mainMenu.Selected()) {
+                       case MENU_ITEM_ITEM:
+                               break;
+                       case MENU_ITEM_SPELL:
+                               break;
+                       case MENU_ITEM_CAPSULE:
+                               break;
+                       case MENU_ITEM_EQUIP:
+                               break;
+                       case MENU_ITEM_STATUS:
+                               Ctrl().PushState(new SelectHero(this, OnStatusSelect));
+                               break;
+                       case MENU_ITEM_CHANGE:
+                               break;
+                       case MENU_ITEM_CONFIG:
+                               break;
+                       case MENU_ITEM_SCENARIO:
+                               break;
+                       default:
+                               break;
+               }
+       }
 }
 
 void PartyMenu::UpdateWorld(float deltaT) {
@@ -93,12 +119,20 @@ void PartyMenu::UpdateWorld(float deltaT) {
 }
 
 void PartyMenu::Render(SDL_Surface *screen) {
-       Res().menubg->Render(screen, Vector<int>(), Vector<int>(screen->w, screen->h));
-       RenderHeros(screen, Vector<int>(Res().normalFont->CharWidth(), 2 * Res().normalFont->CharHeight()));
+       RenderBackground(screen);
+       RenderHeros(screen, StatusOffset());
        RenderMenu(screen, Vector<int>(8 * Res().normalFont->CharWidth(), 13 * Res().normalFont->CharHeight() + Res().normalFont->CharHeight() / 8));
        RenderInfo(screen, Vector<int>(14 * Res().normalFont->CharWidth(), 21 * Res().normalFont->CharHeight() + Res().normalFont->CharHeight() / 8));
 }
 
+Vector<int> PartyMenu::StatusOffset() const {
+       return Vector<int>(Res().normalFont->CharWidth(), 2 * Res().normalFont->CharHeight());
+}
+
+void PartyMenu::RenderBackground(SDL_Surface *screen) const {
+       Res().menubg->Render(screen, Vector<int>(), Vector<int>(screen->w, screen->h));
+}
+
 void PartyMenu::RenderHeros(SDL_Surface *screen, const Vector<int> &offset) const {
        for (int i(0); i < 4; ++i) {
                status[i].Render(screen, offset);
@@ -146,4 +180,8 @@ const Resources &PartyMenu::Res() const {
        return *game->menuResources;
 }
 
+void PartyMenu::OnStatusSelect(PartyMenu *self, int index) {
+       self->Ctrl().ChangeState(new StatusMenu(self));
+}
+
 }