X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FBattleState.cpp;h=c54fecaca88dd10acdb79ff16b597fe82a6d7cf5;hb=d872d756e64b8f1f57cba64ae19f479f8eab3927;hp=ad225173fce209625a452265c0913cf5b1d9adda;hpb=3c72a71fbf6de96333a641051a20c6bf8b3a5df3;p=l2e.git diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index ad22517..c54feca 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -13,6 +13,7 @@ #include "../app/Input.h" #include "../common/Inventory.h" #include "../common/Item.h" +#include "../common/Spell.h" #include "../geometry/operators.h" #include "../graphics/Sprite.h" @@ -22,6 +23,7 @@ using app::Application; using app::Input; using common::Inventory; using common::Item; +using common::Spell; using geometry::Point; using geometry::Vector; using graphics::Menu; @@ -55,7 +57,7 @@ void BattleState::EnterState(Application &ctrl, SDL_Surface *screen) { heroesLayout->CalculatePositions(background->w, background->h, heroesPositions); for (vector::size_type i(0), end(heroes.size()); i < end; ++i) { spellMenus.push_back(res->spellMenuPrototype); - // TODO: insert spell menu entries + LoadSpellMenu(i); ikariMenus.push_back(res->ikariMenuPrototype); // TODO: insert ikari menu entries heroTags[i] = HeroTag(&heroes[i], attackChoices + i, res, HeroTag::Alignment((i + 1) % 2)); @@ -74,6 +76,15 @@ void BattleState::EnterState(Application &ctrl, SDL_Surface *screen) { LoadInventory(); } +void BattleState::LoadSpellMenu(vector::size_type index) { + spellMenus[index].Clear(); + spellMenus[index].Reserve(HeroAt(index).Spells().size()); + for (vector::const_iterator i(HeroAt(index).Spells().begin()), end(HeroAt(index).Spells().end()); i != end; ++i) { + bool enabled((*i)->CanUseInBattle() && (*i)->Cost() <= HeroAt(index).Mana()); + spellMenus[index].Add((*i)->Name(), *i, enabled, 0, (*i)->Cost()); + } +} + void BattleState::LoadInventory() { const Inventory &inv(*res->inventory); itemMenu.Clear();