-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathState.h
More file actions
105 lines (76 loc) · 2.15 KB
/
State.h
File metadata and controls
105 lines (76 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#pragma once
#include "GraphicsSettings.h"
#include "Button.h"
#include "DropDownList.h"
#include "ProgressBar.h"
#include "Randomizer.h"
#include "TileMap.h"
#include "FadeScreen.h"
#include "SoundEngine.h"
class State;
class StateData
{
public:
// Variables:
float gridSize;
sf::RenderWindow* window;
GraphicsSettings* gfxSettings;
std::map<const std::string, int32_t>* supportedKeys;
std::stack<State*>* states;
};
class State
{
protected:
// Variables:
StateData* stateData;
gui::FadeScreen* fadeScreen;
sfx::SoundEngine* soundEngine;
std::stack<State*>* states;
sf::RenderWindow* window;
std::map<const std::string, int32_t>* supportedKeys;
std::map<const std::string, int32_t> keybinds;
bool quit;
bool paused;
float keyTime;
float keyTimeMax;
float gridSize;
sf::Vector2i mousePositionScreen;
sf::Vector2i mousePositionWindow;
sf::Vector2f mousePositionView;
sf::Vector2i mousePositionGrid;
sf::Font systemFont;
sf::Text mousePositionTextX;
sf::Text mousePositionTextY;
Randomizer randomizer;
sf::Text fpsCounterText;
// Resources:
std::map<const Figure, sf::Texture> figureTextures;
// protected: Functions:
void initKeybinds(const std::string file_path);
void initFont(sf::Font& font, const std::string file_path);
void initTexture(const Figure name, const std::string file_path);
void initMousePositionText();
void initFpsCounter();
public:
// Constructors and Destructor:
State(StateData* state_data, gui::FadeScreen* fade_screen, sfx::SoundEngine* sound_engine);
virtual ~State();
// Accessors:
const bool& getQuit() const;
const bool getKeyTime();
const bool getKeyTime(const float key_time_max);
// Functions:
void endState();
void pauseState();
void unpauseState();
void updateMousePositions(sf::View* view = nullptr);
void updateKeyTime(const float& dt);
void updateSound(const float& dt);
void updateMousePositionText();
void updateFpsCounter(const float& dt);
virtual void updateInput(const float& dt) = 0;
virtual void update(const float& dt) = 0;
void renderMousePositionText(sf::RenderTarget* target);
void renderFpsCounter(sf::RenderTarget* target);
virtual void render(sf::RenderTarget* target) = 0;
};