X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FSelectItem.cpp;h=045f3cc6f09e6fc7561b0efa5c8cc7d613cd7284;hb=2147d00bbcb43f5cb4499091f646057cb6944cb3;hp=22369f304252d6cf7ff82cae5e86bc738ebe2621;hpb=e27fcf693589ede18b753d5f64f9dfecfe6344bd;p=l2e.git diff --git a/src/battle/states/SelectItem.cpp b/src/battle/states/SelectItem.cpp index 22369f3..045f3cc 100644 --- a/src/battle/states/SelectItem.cpp +++ b/src/battle/states/SelectItem.cpp @@ -35,9 +35,9 @@ void SelectItem::ExitState(Application &c, SDL_Surface *screen) { } void SelectItem::ResumeState(Application &ctrl, SDL_Surface *screen) { - if (battle->ActiveHeroAttackChoice().Selection().HasSelected()) { - battle->ActiveHeroAttackChoice().SetType(AttackChoice::ITEM); - battle->ActiveHeroAttackChoice().SetItem(battle->GetItemMenu().Selected()); + if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) { + battle->ActiveHero().GetAttackChoice().SetType(AttackChoice::ITEM); + battle->ActiveHero().GetAttackChoice().SetItem(battle->GetItemMenu().Selected()); ctrl.PopState(); } } @@ -55,26 +55,27 @@ void SelectItem::Resize(int width, int height) { void SelectItem::HandleEvents(const Input &input) { if (input.JustPressed(Input::ACTION_A)) { if (battle->GetItemMenu().SelectedIsEnabled()) { + AttackChoice &ac(battle->ActiveHero().GetAttackChoice()); const Item *item(battle->GetItemMenu().Selected()); - battle->ActiveHeroAttackChoice().Selection().Reset(); + ac.Selection().Reset(); if (item->GetTargetingMode().TargetsAlly()) { - battle->ActiveHeroAttackChoice().Selection().SelectHeroes(); + ac.Selection().SelectHeroes(); } else { - battle->ActiveHeroAttackChoice().Selection().SelectEnemies(); + ac.Selection().SelectEnemies(); } if (item->GetTargetingMode().TargetsAll()) { - battle->ActiveHeroAttackChoice().SetType(AttackChoice::ITEM); + ac.SetType(AttackChoice::ITEM); // TODO: remove item from inventory - battle->ActiveHeroAttackChoice().SetItem(item); + ac.SetItem(item); battle->NextHero(); ctrl->PopState(); } else { if (item->GetTargetingMode().TargetsSingle()) { - battle->ActiveHeroAttackChoice().Selection().SetSingle(); + ac.Selection().SetSingle(); } else { - battle->ActiveHeroAttackChoice().Selection().SetMultiple(); + ac.Selection().SetMultiple(); } - ctrl->PushState(new SelectTarget(battle, parent, &battle->ActiveHeroAttackChoice().Selection(), battle->Res().itemTargetCursor)); + ctrl->PushState(new SelectTarget(battle, parent, &ac.Selection(), battle->Res().itemTargetCursor)); } } } @@ -110,7 +111,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); }