]> git.localhorst.tv Git - l2e.git/blobdiff - src/menu/PartyMenu.cpp
added equipment in stats screen
[l2e.git] / src / menu / PartyMenu.cpp
index 85d19d2064456b74e44e63ce988253672b952ead..79b2be06d7dc436c27d9be5d264ef77a639fad86 100644 (file)
@@ -32,9 +32,10 @@ PartyMenu::PartyMenu(GameConfig *game)
                status[i].SetHero(game->state->party[i]);
                status[i].SetResources(game->menuResources);
        }
-       status[1].SetPosition(Vector<int>(status[0].Width() + Res().normalFont->CharWidth(), 0));
-       status[2].SetPosition(Vector<int>(0, status[0].Height() + Res().normalFont->CharHeight()));
-       status[3].SetPosition(Vector<int>(status[0].Width() + Res().normalFont->CharWidth(), status[0].Height() + Res().normalFont->CharHeight()));
+       statusPositions[0] = Vector<int>(0, 0);
+       statusPositions[1] = Vector<int>(status[0].Width(), 0);
+       statusPositions[2] = Vector<int>(0, status[0].Height());
+       statusPositions[3] = Vector<int>(status[0].Width(), status[0].Height());
 
        mainMenu.Add(Res().mainMenuItemText, 0);
        mainMenu.Add(Res().mainMenuStatusText, 4);
@@ -119,14 +120,25 @@ void PartyMenu::UpdateWorld(float deltaT) {
 }
 
 void PartyMenu::Render(SDL_Surface *screen) {
+       Vector<int> offset((screen->w - Width()) / 2, (screen->h - Height()) / 2);
+
        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));
+       RenderHeros(screen, offset);
+       RenderMenu(screen, offset + Vector<int>(8 * Res().normalFont->CharWidth(), 13 * Res().normalFont->CharHeight() + Res().normalFont->CharHeight() / 8));
+       RenderInfo(screen, offset + Vector<int>(14 * Res().normalFont->CharWidth(), 21 * Res().normalFont->CharHeight() + Res().normalFont->CharHeight() / 8));
+}
+
+int PartyMenu::Width() const {
+       return 2 * (status[0].Width() + Res().normalFont->CharWidth());
 }
 
-Vector<int> PartyMenu::StatusOffset() const {
-       return Vector<int>(Res().normalFont->CharWidth(), 2 * Res().normalFont->CharHeight());
+int PartyMenu::Height() const {
+       return 2 * Res().normalFont->CharHeight()
+                       + 2 * status[0].Height()
+                       + Res().normalFont->CharHeight()
+                       + 8 * Res().normalFont->CharHeight()
+                       + 5 * Res().normalFont->CharHeight()
+                       + 2 * Res().normalFont->CharHeight();
 }
 
 void PartyMenu::RenderBackground(SDL_Surface *screen) const {
@@ -135,10 +147,14 @@ void PartyMenu::RenderBackground(SDL_Surface *screen) const {
 
 void PartyMenu::RenderHeros(SDL_Surface *screen, const Vector<int> &offset) const {
        for (int i(0); i < 4; ++i) {
-               status[i].Render(screen, offset);
+               status[i].Render(screen, offset + StatusOffset(i));
        }
 }
 
+Vector<int> PartyMenu::StatusOffset(int index) const {
+       return statusPositions[index] + Vector<int>(Res().normalFont->CharWidth(), 2 * Res().normalFont->CharHeight());
+}
+
 void PartyMenu::RenderMenu(SDL_Surface *screen, const Vector<int> &offset) const {
        Vector<int> menuOffset(3 * Res().normalFont->CharWidth(), Res().normalFont->CharHeight() + Res().normalFont->CharHeight() / 4);
 
@@ -181,7 +197,7 @@ const Resources &PartyMenu::Res() const {
 }
 
 void PartyMenu::OnStatusSelect(PartyMenu *self, int index) {
-       self->Ctrl().ChangeState(new StatusMenu(self));
+       self->Ctrl().ChangeState(new StatusMenu(self, index));
 }
 
 }