X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FSelectAttackType.cpp;h=c5e0bba3b580ebcd20886fed04996f54f590b130;hb=57675025108b7ad3989737f18ebfeec8e5e44889;hp=c0548132b536c115d5cee98265ce4afd43856ace;hpb=4d0a650b178d81387caa36953ed06cc5d6c28213;p=l2e.git diff --git a/src/battle/states/SelectAttackType.cpp b/src/battle/states/SelectAttackType.cpp index c054813..c5e0bba 100644 --- a/src/battle/states/SelectAttackType.cpp +++ b/src/battle/states/SelectAttackType.cpp @@ -7,27 +7,43 @@ #include "SelectAttackType.h" +#include "SelectItem.h" +#include "SelectMoveAction.h" +#include "SelectSpell.h" #include "../AttackChoice.h" #include "../BattleState.h" +#include "../../app/Application.h" #include "../../app/Input.h" #include "../../geometry/operators.h" #include +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) { + if (battle->AttackSelectionDone()) { + // pass through + ctrl.PopState(); + } +} + +void SelectAttackType::PauseState(Application &ctrl, SDL_Surface *screen) { + +} + void SelectAttackType::Resize(int width, int height) { @@ -48,25 +64,41 @@ 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 + if (battle->ActiveHero().CanUseMagic()) { + ctrl->PushState(new SelectSpell(battle, this)); + } 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 + ctrl->PushState(new SelectItem(battle, this)); break; default: throw std::logic_error("selected invalid attack type"); } + } else if (input.JustPressed(Input::ACTION_B)) { + battle->SetAttackType(AttackChoice::UNDECIDED); + battle->PreviousHero(); + if (battle->BeforeFirstHero()) { + ctrl->ChangeState(new SelectMoveAction(battle)); + } + } + + if (battle->AttackSelectionDone()) { + // TODO: switch to battle animation instead + ctrl->PopState(); } } @@ -85,7 +117,7 @@ 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() * 3 / 4) - (battle->GetAttackTypeMenu().Height() / 2)); + battle->BackgroundHeight() - battle->GetAttackTypeMenu().Height() - battle->GetAttackTypeMenu().Height() / 2); battle->GetAttackTypeMenu().Render(screen, position + offset); }