]> git.localhorst.tv Git - l2e.git/blobdiff - src/menu/CapsuleChangeMenu.cpp
stop lines in victory state from crossing the frame
[l2e.git] / src / menu / CapsuleChangeMenu.cpp
index 912f81aa513b6fde2e19d0bc2fc638256b3e0802..47c7b2eb5d57bdae5ccbd8a696a907477b75f5de 100644 (file)
 #include "../graphics/Font.h"
 #include "../graphics/Frame.h"
 #include "../graphics/Texture.h"
+#include "../math/Vector.h"
 
 using app::Input;
 using common::Capsule;
 using common::Inventory;
 using common::Item;
-using geometry::Vector;
+using math::Vector;
 using graphics::Font;
 using graphics::Frame;
 
@@ -51,7 +52,8 @@ void CapsuleChangeMenu::OnResize(int width, int height) {
 
 
 void CapsuleChangeMenu::HandleEvents(const Input &input) {
-       if (input.JustPressed(Input::ACTION_B)) {
+       if (input.JustPressed(Input::ACTION_A)
+                       || input.JustPressed(Input::ACTION_B)) {
                Ctrl().PopState();
        }
 
@@ -70,6 +72,7 @@ void CapsuleChangeMenu::HandleEvents(const Input &input) {
 }
 
 void CapsuleChangeMenu::NextCapsule() {
+       int storedClass = parent->Game().state->GetCapsule().ClassIndex();
        int &index = parent->Game().state->capsule;
        ++index;
        index %= parent->Game().state->NumCapsules();
@@ -78,9 +81,11 @@ void CapsuleChangeMenu::NextCapsule() {
                ++index;
                index %= parent->Game().state->NumCapsules();
        }
+       parent->Game().state->GetCapsule().SetClass(storedClass);
 }
 
 void CapsuleChangeMenu::PreviousCapsule() {
+       int storedClass = parent->Game().state->GetCapsule().ClassIndex();
        int &index = parent->Game().state->capsule;
        --index;
        if (index < 0) index += parent->Game().state->NumCapsules();
@@ -89,6 +94,7 @@ void CapsuleChangeMenu::PreviousCapsule() {
                --index;
                if (index < 0) index += parent->Game().state->NumCapsules();
        }
+       parent->Game().state->GetCapsule().SetClass(storedClass);
 }
 
 void CapsuleChangeMenu::NextClass() {
@@ -100,7 +106,7 @@ void CapsuleChangeMenu::PreviousClass() {
 }
 
 
-void CapsuleChangeMenu::UpdateWorld(float deltaT) {
+void CapsuleChangeMenu::UpdateWorld(Uint32 deltaT) {
 
 }
 
@@ -147,7 +153,7 @@ void CapsuleChangeMenu::RenderClasses(SDL_Surface *screen, const Vector<int> &of
        Vector<int> target(
                        cursor.X() + parent->Res().capsuleSelectTopLeft->Width(),
                        cursor.Y() + numClasses * parent->Res().capsuleSelectLadder->Height());
-       parent->Res().capsuleSelectLeftRepeat->Render(screen, cursor, target);
+       parent->Res().capsuleSelectLeftRepeat->Draw(screen, cursor, target);
        cursor.Y() = target.Y();
        parent->Res().capsuleSelectBottomLeft->Draw(screen, cursor);
        cursor.X() += parent->Res().capsuleSelectTopLeft->Width();
@@ -179,7 +185,7 @@ void CapsuleChangeMenu::RenderClasses(SDL_Surface *screen, const Vector<int> &of
        target = Vector<int>(
                        cursor.X() + parent->Res().capsuleSelectTopRight->Width(),
                        cursor.Y() + numClasses * parent->Res().capsuleSelectLadder->Height());
-       parent->Res().capsuleSelectRightRepeat->Render(screen, cursor, target);
+       parent->Res().capsuleSelectRightRepeat->Draw(screen, cursor, target);
        cursor.Y() = target.Y();
        parent->Res().capsuleSelectBottomRight->Draw(screen, cursor);
 }