X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbattle%2Fstates%2FSelectItem.cpp;h=96def09e1bed6803972feb3521ca0ffe9af5fed4;hb=b6469d8a22e60335fd8d9304569e648310ddc399;hp=0bdd4b10c3adfba9fe4216e5a8b9e6cc1d582628;hpb=57675025108b7ad3989737f18ebfeec8e5e44889;p=l2e.git diff --git a/src/battle/states/SelectItem.cpp b/src/battle/states/SelectItem.cpp index 0bdd4b1..96def09 100644 --- a/src/battle/states/SelectItem.cpp +++ b/src/battle/states/SelectItem.cpp @@ -8,15 +8,18 @@ #include "SelectItem.h" #include "SelectAttackType.h" +#include "SelectTarget.h" #include "../BattleState.h" #include "../../app/Application.h" #include "../../app/Input.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::Item; using geometry::Point; using geometry::Vector; using graphics::Frame; @@ -32,7 +35,9 @@ void SelectItem::ExitState(Application &c, SDL_Surface *screen) { } void SelectItem::ResumeState(Application &ctrl, SDL_Surface *screen) { - + if (battle->ActiveHeroTargets().HasSelected()) { + ctrl.PopState(); + } } void SelectItem::PauseState(Application &ctrl, SDL_Surface *screen) { @@ -47,10 +52,28 @@ void SelectItem::Resize(int width, int height) { void SelectItem::HandleInput(const Input &input) { if (input.JustPressed(Input::ACTION_A)) { - // TODO: switch to target select if (battle->GetItemMenu().SelectedIsEnabled()) { - battle->NextHero(); - ctrl->PopState(); + const Item *item(battle->GetItemMenu().Selected()); + battle->ActiveHeroTargets().Reset(); + if (item->GetTargetingMode().TargetsAlly()) { + battle->ActiveHeroTargets().SelectHeroes(); + } else { + battle->ActiveHeroTargets().SelectEnemies(); + } + if (item->GetTargetingMode().TargetsAll()) { + battle->SetAttackType(AttackChoice::ITEM); + // TODO: remove item from inventory + battle->ActiveHeroAttackChoice().SetItem(item); + battle->NextHero(); + ctrl->PopState(); + } else { + if (item->GetTargetingMode().TargetsSingle()) { + battle->ActiveHeroTargets().SetSingle(); + } else { + battle->ActiveHeroTargets().SetMultiple(); + } + ctrl->PushState(new SelectTarget(battle, parent, &battle->ActiveHeroTargets(), battle->Res().itemTargetCursor)); + } } } if (input.JustPressed(Input::ACTION_B)) {