]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/states/SelectIkari.cpp
removed redundant BattleState::ActiveHeroAttackChoice()
[l2e.git] / src / battle / states / SelectIkari.cpp
index 7928888d2bb031805d703001be8733336a180e0d..d66f8b5458dff6fccd822a38d278e6b61ea5a776 100644 (file)
@@ -36,7 +36,9 @@ void SelectIkari::ExitState(Application &c, SDL_Surface *screen) {
 }
 
 void SelectIkari::ResumeState(Application &ctrl, SDL_Surface *screen) {
-       if (battle->ActiveHeroTargets().HasSelected()) {
+       if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) {
+               battle->ActiveHero().GetAttackChoice().SetType(AttackChoice::IKARI);
+               battle->ActiveHero().GetAttackChoice().SetItem(battle->GetIkariMenu().Selected());
                ctrl.PopState();
        }
 }
@@ -51,29 +53,30 @@ void SelectIkari::Resize(int width, int height) {
 }
 
 
-void SelectIkari::HandleInput(const Input &input) {
+void SelectIkari::HandleEvents(const Input &input) {
        if (input.JustPressed(Input::ACTION_A)) {
                if (battle->GetIkariMenu().SelectedIsEnabled() && battle->GetIkariMenu().Selected()->HasIkari()) {
+                       AttackChoice &ac(battle->ActiveHero().GetAttackChoice());
                        const Ikari *ikari(battle->GetIkariMenu().Selected()->GetIkari());
-                       battle->ActiveHeroTargets().Reset();
+                       ac.Selection().Reset();
                        if (ikari->GetTargetingMode().TargetsAlly()) {
-                               battle->ActiveHeroTargets().SelectHeroes();
+                               ac.Selection().SelectHeroes();
                        } else {
-                               battle->ActiveHeroTargets().SelectEnemies();
+                               ac.Selection().SelectEnemies();
                        }
                        if (ikari->GetTargetingMode().TargetsAll()) {
-                               battle->SetAttackType(AttackChoice::MAGIC);
+                               ac.SetType(AttackChoice::MAGIC);
                                // TODO: remove item from inventory
-                               battle->ActiveHeroAttackChoice().SetItem(battle->GetIkariMenu().Selected());
+                               ac.SetItem(battle->GetIkariMenu().Selected());
                                battle->NextHero();
                                ctrl->PopState();
                        } else {
                                if (ikari->GetTargetingMode().TargetsSingle()) {
-                                       battle->ActiveHeroTargets().SetSingle();
+                                       ac.Selection().SetSingle();
                                } else {
-                                       battle->ActiveHeroTargets().SetMultiple();
+                                       ac.Selection().SetMultiple();
                                }
-                               ctrl->PushState(new SelectTarget(battle, parent, &battle->ActiveHeroTargets(), ikari->IsMagical() ? battle->Res().magicTargetCursor : battle->Res().weaponTargetCursor));
+                               ctrl->PushState(new SelectTarget(battle, parent, &ac.Selection(), ikari->IsMagical() ? battle->Res().magicTargetCursor : battle->Res().weaponTargetCursor));
                        }
                }
        }
@@ -109,7 +112,7 @@ void SelectIkari::Render(SDL_Surface *screen) {
 void SelectIkari::RenderFrame(SDL_Surface *screen, const Vector<int> &offset) {
        const Frame *frame(battle->Res().selectFrame);
        Point<int> position(frame->BorderWidth(), frame->BorderHeight());
-       int width(battle->BackgroundWidth() - 2 * frame->BorderWidth());
+       int width(battle->Width() - 2 * frame->BorderWidth());
        int height(battle->Res().normalFont->CharHeight() * 13);
        frame->Draw(screen, position + offset, width, height);
 }