X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FSelectItem.cpp;h=0291b739c9c2746b5b17f6f72edf58fabb203f57;hb=1c5b28e8559e8383958307534e262a9b29f50fdf;hp=a2d178eb251f83db906d7c662ddf34c3606c6322;hpb=b7a90738b9ae701cfc86bf74a11ba59d7fcb17ba;p=l2e.git diff --git a/src/battle/states/SelectItem.cpp b/src/battle/states/SelectItem.cpp index a2d178e..0291b73 100644 --- a/src/battle/states/SelectItem.cpp +++ b/src/battle/states/SelectItem.cpp @@ -35,7 +35,9 @@ void SelectItem::ExitState(Application &c, SDL_Surface *screen) { } void SelectItem::ResumeState(Application &ctrl, SDL_Surface *screen) { - if (battle->ActiveHeroTargets().HasSelected()) { + if (battle->ActiveHeroAttackChoice().Selection().HasSelected()) { + battle->ActiveHeroAttackChoice().SetType(AttackChoice::ITEM); + battle->ActiveHeroAttackChoice().SetItem(battle->GetItemMenu().Selected()); ctrl.PopState(); } } @@ -50,33 +52,30 @@ void SelectItem::Resize(int width, int height) { } -void SelectItem::HandleInput(const Input &input) { +void SelectItem::HandleEvents(const Input &input) { if (input.JustPressed(Input::ACTION_A)) { if (battle->GetItemMenu().SelectedIsEnabled()) { const Item *item(battle->GetItemMenu().Selected()); - battle->ActiveHeroTargets().Reset(); - if (item->TargetAlly()) { - battle->ActiveHeroTargets().SelectHeroes(); + battle->ActiveHeroAttackChoice().Selection().Reset(); + if (item->GetTargetingMode().TargetsAlly()) { + battle->ActiveHeroAttackChoice().Selection().SelectHeroes(); } else { - battle->ActiveHeroTargets().SelectEnemies(); + battle->ActiveHeroAttackChoice().Selection().SelectEnemies(); } - if (item->TargetAll()) { - battle->SetAttackType(AttackChoice::ITEM); + if (item->GetTargetingMode().TargetsAll()) { + battle->ActiveHeroAttackChoice().SetType(AttackChoice::ITEM); // TODO: remove item from inventory battle->ActiveHeroAttackChoice().SetItem(item); battle->NextHero(); ctrl->PopState(); } else { - if (item->TargetOne()) { - battle->ActiveHeroTargets().SetSingle(); + if (item->GetTargetingMode().TargetsSingle()) { + battle->ActiveHeroAttackChoice().Selection().SetSingle(); } else { - battle->ActiveHeroTargets().SetMultiple(); + battle->ActiveHeroAttackChoice().Selection().SetMultiple(); } - ctrl->PushState(new SelectTarget(battle, parent, &battle->ActiveHeroTargets(), battle->Res().itemTargetCursor)); + ctrl->PushState(new SelectTarget(battle, parent, &battle->ActiveHeroAttackChoice().Selection(), battle->Res().itemTargetCursor)); } -// battle->SetAttackType(AttackChoice::ITEM); -// battle->NextHero(); -// ctrl->PopState(); } } if (input.JustPressed(Input::ACTION_B)) { @@ -111,7 +110,7 @@ void SelectItem::Render(SDL_Surface *screen) { void SelectItem::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); }