X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FBattleState.h;h=65e8727906859fd442c174107ce92782d603fb1d;hb=57675025108b7ad3989737f18ebfeec8e5e44889;hp=52238ebe5d3594b964cd656aa10bd5094e793e51;hpb=4a1816af30dcfe53181a25355bd51cc7b24a83f1;p=l2e.git diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index 52238eb..65e8727 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -8,13 +8,29 @@ #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 "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 graphics { + class Font; + class Frame; + class Gauge; + class Sprite; +} + namespace battle { class PartyLayout; @@ -23,32 +39,80 @@ class BattleState : public app::State { public: - BattleState(SDL_Surface *background, const PartyLayout &monstersLayout) + BattleState(SDL_Surface *background, const PartyLayout &monstersLayout, const PartyLayout &heroesLayout, const Resources *res) : background(background) , monstersLayout(&monstersLayout) - , width(0) - , height(0) { } + , heroesLayout(&heroesLayout) + , res(res) + , attackTypeMenu(res->attackIcons) + , moveMenu(res->moveIcons) + , activeHero(-1) { } public: void AddMonster(const Monster &); + void AddHero(const Hero &); 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); - virtual void HandleEvent(const SDL_Event &); + virtual void HandleInput(const app::Input &); virtual void UpdateWorld(float deltaT); virtual void Render(SDL_Surface *); +public: + const Resources &Res() const { return *res; } + AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; } + MoveMenu &GetMoveMenu() { return moveMenu; } + + 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(); } + graphics::Menu &GetSpellMenu() { return spellMenus[activeHero]; } + const graphics::Menu &GetSpellMenu() const { return spellMenus[activeHero]; } + graphics::Menu &GetItemMenu() { return itemMenu; } + const graphics::Menu &GetItemMenu() const { return itemMenu; } + +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 Resources *res; + AttackTypeMenu attackTypeMenu; + MoveMenu moveMenu; std::vector > monsterPositions; + std::vector > heroesPositions; std::vector monsters; - int width; - int height; + std::vector heroes; + std::vector > spellMenus; + graphics::Menu itemMenu; + std::vector heroTags; + std::vector attackChoices; + int activeHero; };