]> git.localhorst.tv Git - l2e.git/blob - src/battle/BattleState.h
added simple font implementation
[l2e.git] / src / battle / BattleState.h
1 /*
2  * BattleState.h
3  *
4  *  Created on: Aug 5, 2012
5  *      Author: holy
6  */
7
8 #ifndef BATTLE_BATTLESTATE_H_
9 #define BATTLE_BATTLESTATE_H_
10
11 #include "AttackChoice.h"
12 #include "AttackTypeMenu.h"
13 #include "Hero.h"
14 #include "HeroTag.h"
15 #include "Monster.h"
16 #include "MoveMenu.h"
17 #include "../app/State.h"
18 #include "../geometry/Point.h"
19 #include "../geometry/Vector.h"
20
21 #include <vector>
22 #include <SDL.h>
23
24 namespace app { class Input; }
25 namespace graphics {
26         class Font;
27         class Frame;
28         class Gauge;
29         class Sprite;
30 }
31
32 namespace battle {
33
34 class PartyLayout;
35
36 class BattleState
37 : public app::State {
38
39 public:
40         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)
41         : background(background)
42         , monstersLayout(&monstersLayout)
43         , heroesLayout(&heroesLayout)
44         , heroTagFrame(heroTagFrame)
45         , activeHeroTagFrame(activeHeroTagFrame)
46         , healthGauge(healthGauge)
47         , manaGauge(manaGauge)
48         , ikariGauge(ikariGauge)
49         , heroTagSprites(heroTagSprites)
50         , heroTagFont(heroTagFont)
51         , attackTypeMenu(attackIcons)
52         , moveMenu(moveIcons)
53         , activeHero(-1) { }
54
55 public:
56         void AddMonster(const Monster &);
57         void AddHero(const Hero &);
58
59 public:
60         virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
61         virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
62         virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
63         virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
64
65         virtual void Resize(int width, int height);
66
67         virtual void HandleInput(const app::Input &);
68         virtual void UpdateWorld(float deltaT);
69         virtual void Render(SDL_Surface *);
70
71 public:
72         AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; }
73         MoveMenu &GetMoveMenu() { return moveMenu; }
74
75         bool HasMoreHeroes() const { return activeHero < (int) heroes.size(); }
76         void NextHero() { ++activeHero; }
77         bool HasChosenAttackType() const { return attackChoices[activeHero].GetType() != AttackChoice::UNDECIDED; }
78         void SetAttackType(AttackChoice::Type t) { attackChoices[activeHero].SetType(t); }
79         bool AttackSelectionDone() const { return activeHero >= (int) heroes.size(); }
80
81 public:
82         geometry::Vector<int> CalculateScreenOffset(SDL_Surface *screen) const {
83                 return geometry::Vector<int>(
84                                 (screen->w - background->w) / 2,
85                                 (screen->h - background->h) / 2);
86         }
87         int BackgroundWidth() const { return background->w; }
88         int BackgroundHeight() const { return background->h; }
89
90         void RenderBackground(SDL_Surface *screen, const geometry::Vector<int> &offset);
91         void RenderMonsters(SDL_Surface *screen, const geometry::Vector<int> &offset);
92         void RenderHeroes(SDL_Surface *screen, const geometry::Vector<int> &offset);
93         void RenderHeroTags(SDL_Surface *screen, const geometry::Vector<int> &offset);
94
95 private:
96         SDL_Surface *background;
97         const PartyLayout *monstersLayout;
98         const PartyLayout *heroesLayout;
99         const graphics::Frame *heroTagFrame;
100         const graphics::Frame *activeHeroTagFrame;
101         const graphics::Gauge *healthGauge;
102         const graphics::Gauge *manaGauge;
103         const graphics::Gauge *ikariGauge;
104         const graphics::Sprite *heroTagSprites;
105         const graphics::Font *heroTagFont;
106         AttackTypeMenu attackTypeMenu;
107         MoveMenu moveMenu;
108         std::vector<geometry::Point<int> > monsterPositions;
109         std::vector<geometry::Point<int> > heroesPositions;
110         std::vector<Monster> monsters;
111         std::vector<Hero> heroes;
112         std::vector<HeroTag> heroTags;
113         std::vector<AttackChoice> attackChoices;
114         int activeHero;
115
116 };
117
118 }
119
120 #endif /* BATTLE_BATTLESTATE_H_ */