X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FSelectIkari.cpp;h=d66f8b5458dff6fccd822a38d278e6b61ea5a776;hb=2147d00bbcb43f5cb4499091f646057cb6944cb3;hp=85b61c79d24443dc02be1396e07e7c81b39e06cc;hpb=536a8c96ebfec2a2b34f680d3d0b97db8e66d599;p=l2e.git diff --git a/src/battle/states/SelectIkari.cpp b/src/battle/states/SelectIkari.cpp index 85b61c7..d66f8b5 100644 --- a/src/battle/states/SelectIkari.cpp +++ b/src/battle/states/SelectIkari.cpp @@ -8,15 +8,19 @@ #include "SelectIkari.h" #include "SelectAttackType.h" +#include "SelectTarget.h" #include "../BattleState.h" #include "../../app/Application.h" #include "../../app/Input.h" +#include "../../common/Ikari.h" +#include "../../common/Item.h" #include "../../geometry/Point.h" #include "../../geometry/operators.h" #include "../../graphics/Frame.h" using app::Application; using app::Input; +using common::Ikari; using geometry::Point; using geometry::Vector; using graphics::Frame; @@ -32,7 +36,11 @@ void SelectIkari::ExitState(Application &c, SDL_Surface *screen) { } void SelectIkari::ResumeState(Application &ctrl, SDL_Surface *screen) { - + if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) { + battle->ActiveHero().GetAttackChoice().SetType(AttackChoice::IKARI); + battle->ActiveHero().GetAttackChoice().SetItem(battle->GetIkariMenu().Selected()); + ctrl.PopState(); + } } void SelectIkari::PauseState(Application &ctrl, SDL_Surface *screen) { @@ -45,13 +53,31 @@ 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)) { - // TODO: switch to target select - if (battle->GetIkariMenu().SelectedIsEnabled()) { - battle->SetAttackType(AttackChoice::IKARI); - battle->NextHero(); - ctrl->PopState(); + if (battle->GetIkariMenu().SelectedIsEnabled() && battle->GetIkariMenu().Selected()->HasIkari()) { + AttackChoice &ac(battle->ActiveHero().GetAttackChoice()); + const Ikari *ikari(battle->GetIkariMenu().Selected()->GetIkari()); + ac.Selection().Reset(); + if (ikari->GetTargetingMode().TargetsAlly()) { + ac.Selection().SelectHeroes(); + } else { + ac.Selection().SelectEnemies(); + } + if (ikari->GetTargetingMode().TargetsAll()) { + ac.SetType(AttackChoice::MAGIC); + // TODO: remove item from inventory + ac.SetItem(battle->GetIkariMenu().Selected()); + battle->NextHero(); + ctrl->PopState(); + } else { + if (ikari->GetTargetingMode().TargetsSingle()) { + ac.Selection().SetSingle(); + } else { + ac.Selection().SetMultiple(); + } + ctrl->PushState(new SelectTarget(battle, parent, &ac.Selection(), ikari->IsMagical() ? battle->Res().magicTargetCursor : battle->Res().weaponTargetCursor)); + } } } if (input.JustPressed(Input::ACTION_B)) { @@ -86,7 +112,7 @@ void SelectIkari::Render(SDL_Surface *screen) { void SelectIkari::RenderFrame(SDL_Surface *screen, const Vector &offset) { const Frame *frame(battle->Res().selectFrame); Point 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); }