]> git.localhorst.tv Git - l2e.git/blobdiff - src/menu/CapsuleChangeMenu.cpp
added capsule wheel and table
[l2e.git] / src / menu / CapsuleChangeMenu.cpp
index 3b161ad9df6ff6e0839a90c70166c52ce50a66f2..cac2056aecab713fe075f0c5fb3205010cb0b996 100644 (file)
@@ -10,6 +10,7 @@
 #include "../common/GameState.h"
 #include "../graphics/Font.h"
 #include "../graphics/Frame.h"
+#include "../graphics/Texture.h"
 
 using app::Input;
 using common::Capsule;
@@ -69,18 +70,76 @@ void CapsuleChangeMenu::Render(SDL_Surface *screen) {
                        12 * font.CharWidth(),
                        2 * font.CharHeight() - font.CharHeight() / 8);
        // TODO: wheel offset: top left, center, or center bottom?
-       const Vector<int> wheelOffset;
+       const Vector<int> wheelOffset(
+                       6 * font.CharWidth(),
+                       19 * font.CharHeight() - font.CharHeight() / 8);
+       const Vector<int> classesOffset(
+                       12 * font.CharWidth(),
+                       13 * font.CharHeight() - font.CharHeight() / 8);
        const Vector<int> menuOffset(
-                               font.CharWidth(),
-                               24 * font.CharHeight() - font.CharHeight() / 8);
+                       font.CharWidth(),
+                       24 * font.CharHeight() - font.CharHeight() / 8);
 
        parent->RenderBackground(screen);
        parent->RenderCapsule(screen, offset + capsuleOffset);
        parent->RenderInfo(screen, offset + infoOffset);
        parent->RenderWheel(screen, offset + wheelOffset);
+       RenderClasses(screen, offset + classesOffset);
        parent->RenderMenu(screen, offset + menuOffset);
 }
 
+void CapsuleChangeMenu::RenderClasses(SDL_Surface *screen, const Vector<int> &offset) const {
+       Vector<int> cursor(offset);
+
+       int numClasses = 0;
+       for (int i = 0; i < parent->Game().state->NumCapsules(); ++i) {
+               if (numClasses < parent->Game().state->capsules[i].NumClasses()) {
+                       numClasses = parent->Game().state->capsules[i].NumClasses();
+               }
+       }
+
+       parent->Res().capsuleSelectTopLeft->Draw(screen, cursor);
+       cursor.Y() += parent->Res().capsuleSelectTopLeft->Height();
+       Vector<int> target(
+                       cursor.X() + parent->Res().capsuleSelectTopLeft->Width(),
+                       cursor.Y() + numClasses * parent->Res().capsuleSelectLadder->Height());
+       parent->Res().capsuleSelectLeftRepeat->Render(screen, cursor, target);
+       cursor.Y() = target.Y();
+       parent->Res().capsuleSelectBottomLeft->Draw(screen, cursor);
+       cursor.X() += parent->Res().capsuleSelectTopLeft->Width();
+
+       for (int i = 0; i < parent->Game().state->NumCapsules(); ++i) {
+               cursor.Y() = offset.Y();
+               parent->Res().capsuleSelectTopRepeat->Draw(screen, cursor);
+               cursor.Y() += parent->Res().capsuleSelectTopRepeat->Height();
+               for (int j = numClasses - 1; j >= 0; --j) {
+                       parent->Res().capsuleSelectLadder->Draw(
+                                       screen, cursor,
+                                       j < parent->Game().state->capsules[i].MaxClass(), j);
+                       if (&parent->Game().state->capsules[i] == parent->Game().state->capsule
+                                       && parent->Game().state->capsules[i].CurrentClass() == j) {
+                               parent->Res().capsuleSelectCursor->Draw(screen, cursor);
+                       }
+                       cursor.Y() += parent->Res().capsuleSelectLadder->Height();
+               }
+               parent->Res().capsuleSelectBottomRepeat->Draw(screen, cursor);
+               if (parent->Game().state->capsules[i].AlignmentSprite()) {
+                       parent->Game().state->capsules[i].AlignmentSprite()->Draw(screen, cursor);
+               }
+               cursor.X() += parent->Res().capsuleSelectLadder->Width();
+       }
+
+       cursor.Y() = offset.Y();
+       parent->Res().capsuleSelectTopRight->Draw(screen, cursor);
+       cursor.Y() += parent->Res().capsuleSelectTopRight->Height();
+       target = Vector<int>(
+                       cursor.X() + parent->Res().capsuleSelectTopRight->Width(),
+                       cursor.Y() + numClasses * parent->Res().capsuleSelectLadder->Height());
+       parent->Res().capsuleSelectRightRepeat->Render(screen, cursor, target);
+       cursor.Y() = target.Y();
+       parent->Res().capsuleSelectBottomRight->Draw(screen, cursor);
+}
+
 
 int CapsuleChangeMenu::Width() const {
        return parent->Width();