X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FSelectSpell.cpp;h=1bc195c12223e2a7d00b95f642da72ef3a15f19c;hb=fde7b27297882a7f033641df92e732abd137b532;hp=a13d8fc822e3596fecb99676f9f5b6212fd072e6;hpb=e27fcf693589ede18b753d5f64f9dfecfe6344bd;p=l2e.git diff --git a/src/battle/states/SelectSpell.cpp b/src/battle/states/SelectSpell.cpp index a13d8fc..1bc195c 100644 --- a/src/battle/states/SelectSpell.cpp +++ b/src/battle/states/SelectSpell.cpp @@ -36,9 +36,9 @@ void SelectSpell::ExitState(Application &c, SDL_Surface *screen) { } void SelectSpell::ResumeState(Application &ctrl, SDL_Surface *screen) { - if (battle->ActiveHeroAttackChoice().Selection().HasSelected()) { - battle->ActiveHeroAttackChoice().SetType(AttackChoice::MAGIC); - battle->ActiveHeroAttackChoice().SetSpell(battle->GetSpellMenu().Selected()); + if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) { + battle->ActiveHero().GetAttackChoice().SetType(AttackChoice::MAGIC); + battle->ActiveHero().GetAttackChoice().SetSpell(battle->ActiveHero().SpellMenu().Selected()); ctrl.PopState(); } } @@ -55,27 +55,28 @@ void SelectSpell::Resize(int width, int height) { void SelectSpell::HandleEvents(const Input &input) { if (input.JustPressed(Input::ACTION_A)) { - if (battle->GetSpellMenu().SelectedIsEnabled()) { - const Spell *spell(battle->GetSpellMenu().Selected()); - battle->ActiveHeroAttackChoice().Selection().Reset(); + if (battle->ActiveHero().SpellMenu().SelectedIsEnabled()) { + AttackChoice &ac(battle->ActiveHero().GetAttackChoice()); + const Spell *spell(battle->ActiveHero().SpellMenu().Selected()); + ac.Selection().Reset(); if (spell->GetTargetingMode().TargetsAlly()) { - battle->ActiveHeroAttackChoice().Selection().SelectHeroes(); + ac.Selection().SelectHeroes(); } else { - battle->ActiveHeroAttackChoice().Selection().SelectEnemies(); + ac.Selection().SelectMonsters(); } if (spell->GetTargetingMode().TargetsAll()) { - battle->ActiveHeroAttackChoice().SetType(AttackChoice::MAGIC); + ac.SetType(AttackChoice::MAGIC); // TODO: remove item from inventory - battle->ActiveHeroAttackChoice().SetSpell(spell); + ac.SetSpell(spell); battle->NextHero(); ctrl->PopState(); } else { if (spell->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().magicTargetCursor)); + ctrl->PushState(new SelectTarget(battle, parent, &ac.Selection(), battle->Res().magicTargetCursor)); } } } @@ -83,16 +84,16 @@ void SelectSpell::HandleEvents(const Input &input) { ctrl->PopState(); // return control to parent } if (input.JustPressed(Input::PAD_UP)) { - battle->GetSpellMenu().PreviousRow(); + battle->ActiveHero().SpellMenu().PreviousRow(); } if (input.JustPressed(Input::PAD_RIGHT)) { - battle->GetSpellMenu().NextItem(); + battle->ActiveHero().SpellMenu().NextItem(); } if (input.JustPressed(Input::PAD_DOWN)) { - battle->GetSpellMenu().NextRow(); + battle->ActiveHero().SpellMenu().NextRow(); } if (input.JustPressed(Input::PAD_LEFT)) { - battle->GetSpellMenu().PreviousItem(); + battle->ActiveHero().SpellMenu().PreviousItem(); } } @@ -111,7 +112,7 @@ void SelectSpell::Render(SDL_Surface *screen) { void SelectSpell::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); } @@ -129,7 +130,7 @@ void SelectSpell::RenderMenu(SDL_Surface *screen, const Vector &offset) { Point position( 2 * res.selectFrame->BorderWidth() + res.normalFont->CharWidth(), 2 * res.selectFrame->BorderHeight() + 2 * res.normalFont->CharHeight()); - battle->GetSpellMenu().Draw(screen, position + offset); + battle->ActiveHero().SpellMenu().Draw(screen, position + offset); } }