X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FBattleState.h;h=3b293546382c1668a732eb80dff6eff64a26c500;hb=3c72a71fbf6de96333a641051a20c6bf8b3a5df3;hp=858b111c426283008570054b8f48030dee72901a;hpb=185c6c79f8ba30981aad4e1d66f98143a344b95e;p=l2e.git diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index 858b111..3b29354 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -14,14 +14,20 @@ #include "HeroTag.h" #include "Monster.h" #include "MoveMenu.h" +#include "Resources.h" #include "../app/State.h" #include "../geometry/Point.h" #include "../geometry/Vector.h" +#include "../graphics/Menu.h" #include #include namespace app { class Input; } +namespace common { + class Inventory; + class Item; +} namespace graphics { class Font; class Frame; @@ -37,20 +43,13 @@ class BattleState : public app::State { public: - BattleState(SDL_Surface *background, const PartyLayout &monstersLayout, const PartyLayout &heroesLayout, const graphics::Sprite *attackIcons, const graphics::Sprite *moveIcons, const graphics::Frame *heroTagFrame, const graphics::Frame *activeHeroTagFrame, const graphics::Gauge *healthGauge, const graphics::Gauge *manaGauge, const graphics::Gauge *ikariGauge, const graphics::Sprite *heroTagSprites, const graphics::Font *heroTagFont, const graphics::Frame *selectFrame) + BattleState(SDL_Surface *background, const PartyLayout &monstersLayout, const PartyLayout &heroesLayout, const Resources *res) : background(background) , monstersLayout(&monstersLayout) , heroesLayout(&heroesLayout) - , heroTagFrame(heroTagFrame) - , activeHeroTagFrame(activeHeroTagFrame) - , healthGauge(healthGauge) - , manaGauge(manaGauge) - , ikariGauge(ikariGauge) - , heroTagSprites(heroTagSprites) - , heroTagFont(heroTagFont) - , selectFrame(selectFrame) - , attackTypeMenu(attackIcons) - , moveMenu(moveIcons) + , res(res) + , attackTypeMenu(res->attackIcons) + , moveMenu(res->moveIcons) , activeHero(-1) { } public: @@ -70,9 +69,9 @@ public: virtual void Render(SDL_Surface *); public: + const Resources &Res() const { return *res; } AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; } MoveMenu &GetMoveMenu() { return moveMenu; } - const graphics::Frame &GetSelectFrame() const { return *selectFrame; } bool HasMoreHeroes() const { return activeHero < (int) heroes.size(); } void NextHero() { ++activeHero; } @@ -80,10 +79,31 @@ public: void PreviousHero() { --activeHero; } Hero &ActiveHero() { return heroes[activeHero]; } const Hero &ActiveHero() const { return heroes[activeHero]; } + Hero &HeroAt(std::vector::size_type index) { return heroes[index]; } + const Hero &HeroAt(std::vector::size_type index) const { return heroes[index]; } + const HeroTag &ActiveHeroTag() const { return heroTags[activeHero]; } + const HeroTag &HeroTagAt(std::vector::size_type index) const { return heroTags[index]; } + const geometry::Point &HeroTagPositionAt(std::vector::size_type index) const { return heroTagPositions[index]; } bool HasChosenAttackType() const { return attackChoices[activeHero].GetType() != AttackChoice::UNDECIDED; } void SetAttackType(AttackChoice::Type t) { attackChoices[activeHero].SetType(t); } + TargetSelection &ActiveHeroTargets() { return attackChoices[activeHero].Selection(); } + const TargetSelection &ActiveHeroTargets() const { return attackChoices[activeHero].Selection(); } bool AttackSelectionDone() const { return activeHero >= (int) heroes.size(); } + graphics::Menu &GetSpellMenu() { return spellMenus[activeHero]; } + const graphics::Menu &GetSpellMenu() const { return spellMenus[activeHero]; } + graphics::Menu &GetIkariMenu() { return ikariMenus[activeHero]; } + const graphics::Menu &GetIkariMenu() const { return ikariMenus[activeHero]; } + graphics::Menu &GetItemMenu() { return itemMenu; } + const graphics::Menu &GetItemMenu() const { return itemMenu; } + + const std::vector > &MonsterPositions() const { return monsterPositions; } + bool MonsterPositionOccupied(int index) { return index >= 0 && index < int(monsters.size()) && monsters[index].Health() > 0; } + const std::vector > &HeroesPositions() const { return heroesPositions; } + bool HeroPositionOccupied(int index) { return index >= 0 && index < int(heroes.size()); } + std::vector &Heroes() { return heroes; } + const std::vector &Heroes() const { return heroes; } + public: geometry::Vector CalculateScreenOffset(SDL_Surface *screen) const { return geometry::Vector( @@ -98,26 +118,27 @@ public: void RenderHeroes(SDL_Surface *screen, const geometry::Vector &offset); void RenderHeroTags(SDL_Surface *screen, const geometry::Vector &offset); +private: + void LoadInventory(); + private: SDL_Surface *background; const PartyLayout *monstersLayout; const PartyLayout *heroesLayout; - const graphics::Frame *heroTagFrame; - const graphics::Frame *activeHeroTagFrame; - const graphics::Gauge *healthGauge; - const graphics::Gauge *manaGauge; - const graphics::Gauge *ikariGauge; - const graphics::Sprite *heroTagSprites; - const graphics::Font *heroTagFont; - const graphics::Frame *selectFrame; + const Resources *res; AttackTypeMenu attackTypeMenu; MoveMenu moveMenu; + // TODO: combine all data about heros or monsters std::vector > monsterPositions; std::vector > heroesPositions; std::vector monsters; std::vector heroes; - std::vector heroTags; - std::vector attackChoices; + std::vector > spellMenus; + graphics::Menu itemMenu; + std::vector > ikariMenus; + HeroTag heroTags[4]; + geometry::Point heroTagPositions[4]; + AttackChoice attackChoices[4]; int activeHero; };