]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/states/SelectAttackType.cpp
tagged some TODOs
[l2e.git] / src / battle / states / SelectAttackType.cpp
index c0548132b536c115d5cee98265ce4afd43856ace..b3b3e0b0a6290195e56f63a2b47f543fee7f4619 100644 (file)
@@ -9,25 +9,35 @@
 
 #include "../AttackChoice.h"
 #include "../BattleState.h"
+#include "../../app/Application.h"
 #include "../../app/Input.h"
 #include "../../geometry/operators.h"
 
 #include <stdexcept>
 
+using app::Application;
 using app::Input;
 using geometry::Point;
 using geometry::Vector;
 
 namespace battle {
 
-void SelectAttackType::EnterState(app::Application &c, SDL_Surface *screen) {
+void SelectAttackType::EnterState(Application &c, SDL_Surface *screen) {
        ctrl = &c;
 }
 
-void SelectAttackType::ExitState() {
+void SelectAttackType::ExitState(Application &c, SDL_Surface *screen) {
        ctrl = 0;
 }
 
+void SelectAttackType::ResumeState(Application &ctrl, SDL_Surface *screen) {
+
+}
+
+void SelectAttackType::PauseState(Application &ctrl, SDL_Surface *screen) {
+
+}
+
 
 void SelectAttackType::Resize(int width, int height) {
 
@@ -48,26 +58,36 @@ void SelectAttackType::HandleInput(const Input &input) {
        }
 
        if (input.JustPressed(Input::ACTION_A)) {
+               battle->SetAttackType(battle->GetAttackTypeMenu().Selected());
                switch (battle->GetAttackTypeMenu().Selected()) {
                        case AttackChoice::SWORD:
-                               // TODO: switch to next character
+                               // TODO: switch to target select
+                               battle->NextHero();
                                break;
                        case AttackChoice::MAGIC:
                                // TODO: switch to spell select
+                               battle->NextHero();
                                break;
                        case AttackChoice::DEFEND:
-                               // TODO: switch to next character
+                               battle->NextHero();
                                break;
                        case AttackChoice::IKARI:
                                // TODO: switch to ikari attack select
+                               battle->NextHero();
                                break;
                        case AttackChoice::ITEM:
                                // TODO: switch to item select
+                               battle->NextHero();
                                break;
                        default:
                                throw std::logic_error("selected invalid attack type");
                }
        }
+
+       if (battle->AttackSelectionDone()) {
+               // TODO: switch to battle animation instead
+               ctrl->PopState();
+       }
 }
 
 void SelectAttackType::UpdateWorld(float deltaT) {
@@ -85,7 +105,7 @@ void SelectAttackType::Render(SDL_Surface *screen) {
 void SelectAttackType::RenderMenu(SDL_Surface *screen, const Vector<int> &offset) {
        Point<int> position(
                        (battle->BackgroundWidth() - battle->GetAttackTypeMenu().Width()) / 2,
-                       (battle->BackgroundHeight() * 3 / 4) - (battle->GetAttackTypeMenu().Height() / 2));
+                       battle->BackgroundHeight() - battle->GetAttackTypeMenu().Height() - battle->GetAttackTypeMenu().Height() / 2);
        battle->GetAttackTypeMenu().Render(screen, position + offset);
 }