From: Daniel Karbach Date: Tue, 21 Aug 2012 19:39:37 +0000 (+0200) Subject: removed redunant getters for spell and ikari menus X-Git-Url: http://git.localhorst.tv/?a=commitdiff_plain;ds=sidebyside;h=8d3de02319380b5142ac4c88bf54999d4027dba9;p=l2e.git removed redunant getters for spell and ikari menus --- diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index 4964efb..27a3af8 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -84,10 +84,6 @@ public: AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; } MoveMenu &GetMoveMenu() { return moveMenu; } - graphics::Menu &GetSpellMenu() { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero].SpellMenu(); } - const graphics::Menu &GetSpellMenu() const { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero].SpellMenu(); } - graphics::Menu &GetIkariMenu() { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero].IkariMenu(); } - const graphics::Menu &GetIkariMenu() const { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero].IkariMenu(); } graphics::Menu &GetItemMenu() { return itemMenu; } const graphics::Menu &GetItemMenu() const { return itemMenu; } diff --git a/src/battle/states/SelectIkari.cpp b/src/battle/states/SelectIkari.cpp index d66f8b5..5c1a27a 100644 --- a/src/battle/states/SelectIkari.cpp +++ b/src/battle/states/SelectIkari.cpp @@ -38,7 +38,7 @@ 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()); + battle->ActiveHero().GetAttackChoice().SetItem(battle->ActiveHero().IkariMenu().Selected()); ctrl.PopState(); } } @@ -55,9 +55,9 @@ void SelectIkari::Resize(int width, int height) { void SelectIkari::HandleEvents(const Input &input) { if (input.JustPressed(Input::ACTION_A)) { - if (battle->GetIkariMenu().SelectedIsEnabled() && battle->GetIkariMenu().Selected()->HasIkari()) { + if (battle->ActiveHero().IkariMenu().SelectedIsEnabled() && battle->ActiveHero().IkariMenu().Selected()->HasIkari()) { AttackChoice &ac(battle->ActiveHero().GetAttackChoice()); - const Ikari *ikari(battle->GetIkariMenu().Selected()->GetIkari()); + const Ikari *ikari(battle->ActiveHero().IkariMenu().Selected()->GetIkari()); ac.Selection().Reset(); if (ikari->GetTargetingMode().TargetsAlly()) { ac.Selection().SelectHeroes(); @@ -67,7 +67,7 @@ void SelectIkari::HandleEvents(const Input &input) { if (ikari->GetTargetingMode().TargetsAll()) { ac.SetType(AttackChoice::MAGIC); // TODO: remove item from inventory - ac.SetItem(battle->GetIkariMenu().Selected()); + ac.SetItem(battle->ActiveHero().IkariMenu().Selected()); battle->NextHero(); ctrl->PopState(); } else { @@ -84,16 +84,16 @@ void SelectIkari::HandleEvents(const Input &input) { ctrl->PopState(); // return control to parent } if (input.JustPressed(Input::PAD_UP)) { - battle->GetIkariMenu().PreviousRow(); + battle->ActiveHero().IkariMenu().PreviousRow(); } if (input.JustPressed(Input::PAD_RIGHT)) { - battle->GetIkariMenu().NextItem(); + battle->ActiveHero().IkariMenu().NextItem(); } if (input.JustPressed(Input::PAD_DOWN)) { - battle->GetIkariMenu().NextRow(); + battle->ActiveHero().IkariMenu().NextRow(); } if (input.JustPressed(Input::PAD_LEFT)) { - battle->GetIkariMenu().PreviousItem(); + battle->ActiveHero().IkariMenu().PreviousItem(); } } @@ -130,7 +130,7 @@ void SelectIkari::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->GetIkariMenu().Draw(screen, position + offset); + battle->ActiveHero().IkariMenu().Draw(screen, position + offset); } } diff --git a/src/battle/states/SelectSpell.cpp b/src/battle/states/SelectSpell.cpp index 3b4573f..0708196 100644 --- a/src/battle/states/SelectSpell.cpp +++ b/src/battle/states/SelectSpell.cpp @@ -38,7 +38,7 @@ void SelectSpell::ExitState(Application &c, SDL_Surface *screen) { void SelectSpell::ResumeState(Application &ctrl, SDL_Surface *screen) { if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) { battle->ActiveHero().GetAttackChoice().SetType(AttackChoice::MAGIC); - battle->ActiveHero().GetAttackChoice().SetSpell(battle->GetSpellMenu().Selected()); + battle->ActiveHero().GetAttackChoice().SetSpell(battle->ActiveHero().SpellMenu().Selected()); ctrl.PopState(); } } @@ -55,9 +55,9 @@ void SelectSpell::Resize(int width, int height) { void SelectSpell::HandleEvents(const Input &input) { if (input.JustPressed(Input::ACTION_A)) { - if (battle->GetSpellMenu().SelectedIsEnabled()) { + if (battle->ActiveHero().SpellMenu().SelectedIsEnabled()) { AttackChoice &ac(battle->ActiveHero().GetAttackChoice()); - const Spell *spell(battle->GetSpellMenu().Selected()); + const Spell *spell(battle->ActiveHero().SpellMenu().Selected()); ac.Selection().Reset(); if (spell->GetTargetingMode().TargetsAlly()) { ac.Selection().SelectHeroes(); @@ -84,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(); } } @@ -130,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); } }