]> git.localhorst.tv Git - l2e.git/commitdiff
removed redunant getters for spell and ikari menus
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 21 Aug 2012 19:39:37 +0000 (21:39 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 21 Aug 2012 19:39:37 +0000 (21:39 +0200)
src/battle/BattleState.h
src/battle/states/SelectIkari.cpp
src/battle/states/SelectSpell.cpp

index 4964efb81f788be75e23445c28f2e1e00b09805b..27a3af8ae396cd7082a3860f10484c821f13cc54 100644 (file)
@@ -84,10 +84,6 @@ public:
        AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; }
        MoveMenu &GetMoveMenu() { return moveMenu; }
 
-       graphics::Menu<const common::Spell *> &GetSpellMenu() { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero].SpellMenu(); }
-       const graphics::Menu<const common::Spell *> &GetSpellMenu() const { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero].SpellMenu(); }
-       graphics::Menu<const common::Item *> &GetIkariMenu() { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero].IkariMenu(); }
-       const graphics::Menu<const common::Item *> &GetIkariMenu() const { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero].IkariMenu(); }
        graphics::Menu<const common::Item *> &GetItemMenu() { return itemMenu; }
        const graphics::Menu<const common::Item *> &GetItemMenu() const { return itemMenu; }
 
index d66f8b5458dff6fccd822a38d278e6b61ea5a776..5c1a27a4ee76a781c4fc79ad1143495ac96bfe36 100644 (file)
@@ -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<int> &offset) {
        Point<int> 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);
 }
 
 }
index 3b4573f485f526f0ad80fcae5cf27d8b5552273e..0708196b7b0cfde37de92974785e70499e7719f6 100644 (file)
@@ -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<int> &offset) {
        Point<int> 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);
 }
 
 }