X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FSelectAttackType.cpp;h=4bac0bbe50cf1d8ebf7a827f042e14588bd304cb;hb=2147d00bbcb43f5cb4499091f646057cb6944cb3;hp=5e687b670622ec25f4b870cacfe00fa15a34e3cb;hpb=b782e097508340f375a06f0f293775eb86c3df9c;p=l2e.git diff --git a/src/battle/states/SelectAttackType.cpp b/src/battle/states/SelectAttackType.cpp index 5e687b6..4bac0bb 100644 --- a/src/battle/states/SelectAttackType.cpp +++ b/src/battle/states/SelectAttackType.cpp @@ -11,6 +11,7 @@ #include "SelectItem.h" #include "SelectMoveAction.h" #include "SelectSpell.h" +#include "SelectTarget.h" #include "../AttackChoice.h" #include "../BattleState.h" #include "../../app/Application.h" @@ -35,6 +36,10 @@ void SelectAttackType::ExitState(Application &c, SDL_Surface *screen) { } void SelectAttackType::ResumeState(Application &ctrl, SDL_Surface *screen) { + if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) { + battle->ActiveHero().GetAttackChoice().SetType(battle->GetAttackTypeMenu().Selected()); + battle->NextHero(); + } if (battle->AttackSelectionDone()) { // pass through ctrl.PopState(); @@ -51,7 +56,7 @@ void SelectAttackType::Resize(int width, int height) { } -void SelectAttackType::HandleInput(const Input &input) { +void SelectAttackType::HandleEvents(const Input &input) { if (input.IsDown(Input::PAD_UP)) { battle->GetAttackTypeMenu().Select(AttackChoice::MAGIC); } else if (input.IsDown(Input::PAD_RIGHT)) { @@ -65,11 +70,12 @@ 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 target select - battle->NextHero(); + // TODO: detect single/multiple/all attack mode + battle->ActiveHero().GetAttackChoice().Selection().SetSingle(); + battle->ActiveHero().GetAttackChoice().Selection().Reset(); + ctrl->PushState(new SelectTarget(battle, this, &battle->ActiveHero().GetAttackChoice().Selection(), battle->Res().weaponTargetCursor)); break; case AttackChoice::MAGIC: if (battle->ActiveHero().CanUseMagic()) { @@ -77,6 +83,7 @@ void SelectAttackType::HandleInput(const Input &input) { } break; case AttackChoice::DEFEND: + battle->ActiveHero().GetAttackChoice().SetType(AttackChoice::DEFEND); battle->NextHero(); break; case AttackChoice::IKARI: @@ -89,15 +96,16 @@ void SelectAttackType::HandleInput(const Input &input) { throw std::logic_error("selected invalid attack type"); } } else if (input.JustPressed(Input::ACTION_B)) { - battle->SetAttackType(AttackChoice::UNDECIDED); + battle->ActiveHero().GetAttackChoice().Reset(); battle->PreviousHero(); if (battle->BeforeFirstHero()) { ctrl->ChangeState(new SelectMoveAction(battle)); + } else { + battle->ActiveHero().GetAttackChoice().Reset(); } } if (battle->AttackSelectionDone()) { - // TODO: switch to battle animation instead ctrl->PopState(); } } @@ -116,8 +124,8 @@ void SelectAttackType::Render(SDL_Surface *screen) { void SelectAttackType::RenderMenu(SDL_Surface *screen, const Vector &offset) { Point position( - (battle->BackgroundWidth() - battle->GetAttackTypeMenu().Width()) / 2, - battle->BackgroundHeight() - battle->GetAttackTypeMenu().Height() - battle->GetAttackTypeMenu().Height() / 2); + (battle->Width() - battle->GetAttackTypeMenu().Width()) / 2, + battle->Height() - battle->GetAttackTypeMenu().Height() - battle->GetAttackTypeMenu().Height() / 2); battle->GetAttackTypeMenu().Render(screen, position + offset); }