X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FSelectAttackType.cpp;h=3603e1bb529aeb7eb587e06c691037786ddcf925;hb=1c5b28e8559e8383958307534e262a9b29f50fdf;hp=2664295929ca873055902587c0764a1f93b310a0;hpb=c8dccd84477d10dcd3ec884478a9f26c16b54ad7;p=l2e.git diff --git a/src/battle/states/SelectAttackType.cpp b/src/battle/states/SelectAttackType.cpp index 2664295..3603e1b 100644 --- a/src/battle/states/SelectAttackType.cpp +++ b/src/battle/states/SelectAttackType.cpp @@ -7,6 +7,11 @@ #include "SelectAttackType.h" +#include "SelectIkari.h" +#include "SelectItem.h" +#include "SelectMoveAction.h" +#include "SelectSpell.h" +#include "SelectTarget.h" #include "../AttackChoice.h" #include "../BattleState.h" #include "../../app/Application.h" @@ -31,7 +36,14 @@ void SelectAttackType::ExitState(Application &c, SDL_Surface *screen) { } void SelectAttackType::ResumeState(Application &ctrl, SDL_Surface *screen) { - + if (battle->ActiveHeroAttackChoice().Selection().HasSelected()) { + battle->ActiveHeroAttackChoice().SetType(battle->GetAttackTypeMenu().Selected()); + battle->NextHero(); + } + if (battle->AttackSelectionDone()) { + // pass through + ctrl.PopState(); + } } void SelectAttackType::PauseState(Application &ctrl, SDL_Surface *screen) { @@ -44,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)) { @@ -58,30 +70,42 @@ void SelectAttackType::HandleInput(const Input &input) { } if (input.JustPressed(Input::ACTION_A)) { - battle->SetAttackType(battle->GetAttackTypeMenu().Selected()); switch (battle->GetAttackTypeMenu().Selected()) { case AttackChoice::SWORD: - battle->NextHero(); + // TODO: detect single/multiple/all attack mode + battle->ActiveHeroAttackChoice().Selection().SetSingle(); + battle->ActiveHeroAttackChoice().Selection().Reset(); + ctrl->PushState(new SelectTarget(battle, this, &battle->ActiveHeroAttackChoice().Selection(), battle->Res().weaponTargetCursor)); break; case AttackChoice::MAGIC: - // TODO: switch to spell select + if (battle->ActiveHero().CanUseMagic()) { + ctrl->PushState(new SelectSpell(battle, this)); + } break; case AttackChoice::DEFEND: + battle->ActiveHeroAttackChoice().SetType(AttackChoice::DEFEND); battle->NextHero(); break; case AttackChoice::IKARI: - // TODO: switch to ikari attack select + ctrl->PushState(new SelectIkari(battle, this)); break; case AttackChoice::ITEM: - // TODO: switch to item select + ctrl->PushState(new SelectItem(battle, this)); break; default: throw std::logic_error("selected invalid attack type"); } + } else if (input.JustPressed(Input::ACTION_B)) { + battle->ActiveHeroAttackChoice().Reset(); + battle->PreviousHero(); + if (battle->BeforeFirstHero()) { + ctrl->ChangeState(new SelectMoveAction(battle)); + } else { + battle->ActiveHeroAttackChoice().Reset(); + } } if (battle->AttackSelectionDone()) { - // TODO: switch to battle animation instead ctrl->PopState(); } } @@ -100,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); }