X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FBattleState.h;h=858b111c426283008570054b8f48030dee72901a;hb=185c6c79f8ba30981aad4e1d66f98143a344b95e;hp=9e504ed8c13b04db85168aa5bf7acd2cb672a4e4;hpb=c0860451b5fd681c3b3b8d985e8831276bbd917f;p=l2e.git diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index 9e504ed..858b111 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -8,9 +8,12 @@ #ifndef BATTLE_BATTLESTATE_H_ #define BATTLE_BATTLESTATE_H_ +#include "AttackChoice.h" #include "AttackTypeMenu.h" #include "Hero.h" +#include "HeroTag.h" #include "Monster.h" +#include "MoveMenu.h" #include "../app/State.h" #include "../geometry/Point.h" #include "../geometry/Vector.h" @@ -19,22 +22,36 @@ #include namespace app { class Input; } -namespace graphics { class Sprite; } +namespace graphics { + class Font; + class Frame; + class Gauge; + class Sprite; +} namespace battle { class PartyLayout; -// TODO: maybe split battle state into substates for each menu? class BattleState : public app::State { public: - BattleState(SDL_Surface *background, const PartyLayout &monstersLayout, const PartyLayout &heroesLayout, const graphics::Sprite *attackIcons) + 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) : background(background) , monstersLayout(&monstersLayout) , heroesLayout(&heroesLayout) - , attackTypeMenu(attackIcons) { } + , heroTagFrame(heroTagFrame) + , activeHeroTagFrame(activeHeroTagFrame) + , healthGauge(healthGauge) + , manaGauge(manaGauge) + , ikariGauge(ikariGauge) + , heroTagSprites(heroTagSprites) + , heroTagFont(heroTagFont) + , selectFrame(selectFrame) + , attackTypeMenu(attackIcons) + , moveMenu(moveIcons) + , activeHero(-1) { } public: void AddMonster(const Monster &); @@ -42,7 +59,9 @@ public: public: virtual void EnterState(app::Application &ctrl, SDL_Surface *screen); - virtual void ExitState(); + virtual void ExitState(app::Application &ctrl, SDL_Surface *screen); + virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen); + virtual void PauseState(app::Application &ctrl, SDL_Surface *screen); virtual void Resize(int width, int height); @@ -50,20 +69,56 @@ public: virtual void UpdateWorld(float deltaT); virtual void Render(SDL_Surface *); -private: +public: + 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; } + bool BeforeFirstHero() const { return activeHero < 0; } + void PreviousHero() { --activeHero; } + Hero &ActiveHero() { return heroes[activeHero]; } + const Hero &ActiveHero() const { return heroes[activeHero]; } + bool HasChosenAttackType() const { return attackChoices[activeHero].GetType() != AttackChoice::UNDECIDED; } + void SetAttackType(AttackChoice::Type t) { attackChoices[activeHero].SetType(t); } + bool AttackSelectionDone() const { return activeHero >= (int) heroes.size(); } + +public: + geometry::Vector CalculateScreenOffset(SDL_Surface *screen) const { + return geometry::Vector( + (screen->w - background->w) / 2, + (screen->h - background->h) / 2); + } + int BackgroundWidth() const { return background->w; } + int BackgroundHeight() const { return background->h; } + void RenderBackground(SDL_Surface *screen, const geometry::Vector &offset); void RenderMonsters(SDL_Surface *screen, const geometry::Vector &offset); void RenderHeroes(SDL_Surface *screen, const geometry::Vector &offset); + void RenderHeroTags(SDL_Surface *screen, const geometry::Vector &offset); 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; AttackTypeMenu attackTypeMenu; + MoveMenu moveMenu; std::vector > monsterPositions; std::vector > heroesPositions; std::vector monsters; std::vector heroes; + std::vector heroTags; + std::vector attackChoices; + int activeHero; };