-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI.h
More file actions
217 lines (194 loc) · 4.94 KB
/
Copy pathGUI.h
File metadata and controls
217 lines (194 loc) · 4.94 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#pragma once
#include"include.h"
enum button_states { BTN_IDLE = 0, BTN_HOVER, BTN_ACTIVE };
namespace gui {
class Button
{
private:
short unsigned buttonState;
short unsigned id;
bool pressed;
bool hover;
sf::RectangleShape shape;
sf::Font* font;
sf::Text text;
//texture
sf::Color idleColor;
sf::Color hoverColor;
sf::Color activeColor;
sf::Color text_idle_color;
sf::Color text_hover_color;
sf::Color text_active_color;
sf::Color outlineidleColor;
sf::Color outlinehoverColor;
sf::Color outlineactiveColor;
//sound
sf::Sound BTNsound;
sf::SoundBuffer hoversound;
sf::SoundBuffer clicksound;
sf::Clock clock;
sf::Time soundDelay;
public:
Button(float x, float y, float width, float height,
sf::Font* font, std::string text, unsigned character_size,
sf::Color text_idle_color, sf::Color text_hover_color, sf::Color text_active_color,
sf::Color idleColor, sf::Color hoverColor, sf::Color activeColor,
sf::Color outlineidleColor = sf::Color::Transparent, sf::Color outlinehoverColor = sf::Color::Transparent, sf::Color outlineactiveColor = sf::Color::Transparent,
sf::Texture *texture = nullptr,
short unsigned id = 0
);
~Button();
//Accessors
const bool isPressed() const;
const std::string getText()const;
const short unsigned& getId() const;
//Modifiers
void setText(const std::string text);
void setId(const short unsigned id);
//function
void Update(sf::Vector2f mousePos);
void Render(sf::RenderTarget& target);
};
class ButtonForMainmenu
{
private:
short unsigned buttonState;
unsigned hover_size;
unsigned character_size;
bool pressed;
bool hover;
sf::RectangleShape shape;
sf::Font* font;
sf::Text text;
//texture
sf::Color text_idle_color;
sf::Texture glow;
//sound
sf::Sound BTNsound;
sf::SoundBuffer clicksound;
sf::Clock clock;
sf::Time soundDelay;
public:
ButtonForMainmenu(float x, float y, float width, float height,
sf::Font* font, std::string text, unsigned character_size,
sf::Color text_idle_color,unsigned hover_size
);
~ButtonForMainmenu();
//Accessors
const bool isPressed() const;
//function
void Update(sf::Vector2f mousePos);
void Render(sf::RenderTarget& target);
};
//============================= DROP DOWN LIST ===================================
class dropdownlist
{
private:
float keytime;
float keytimeMax;
sf::Font& font;
gui::Button* activeElement;
std::vector<gui::Button*> list;
bool showList;
public:
dropdownlist(float x, float y, float width, float height,
sf::Font& font, std::string list[],
unsigned nrOfElements, unsigned default_index = 0);
~dropdownlist();
//Accessor
const bool getkeyTime();
//function
void UpdateKeytime(const float& deltaTime);
void Update(sf::Vector2f mousePos, const float& deltaTime);
void Render(sf::RenderTarget& target);
};
//========================== BAR ===========================
class bar
{
private:
float &x;
float &y;
float percent;
float value;
float Max_value;
float width;
float height;
bool showtext;
sf::Font* font;
sf::Text text;
sf::Color value_color;
sf::Color Max_value_color;
sf::RectangleShape Max_value_shape;
sf::RectangleShape value_shape;
sf::RectangleShape texture;
public:
bar(float &x, float &y, float width, float height,
float value, float Max_value,
sf::Font* font, unsigned textsize, sf::Color text_color,
sf::Color value_color, sf::Color Max_value_color, sf::Texture *texture = nullptr,
bool showtext = false
);
~bar();
//Accessor
const float& getValue()const;
const float& getMaxValue()const;
//Modifier
void setPosition(float x, float y);
void setValue(float x);
void setMaxValue(float x);
//function
void Update();
void Render(sf::RenderTarget& target);
};
class textbox
{
private:
float x;
float y;
float width;
float height;
sf::Color box_color;
sf::Color text_color;
sf::Color Outlinecolor;
sf::Font* font;
sf::Text text;
sf::RectangleShape box;
sf::Texture* texture;
bool left;
public:
textbox(float x, float y, float width, float height,
sf::Color box_color, std::string text,
sf::Font* font, unsigned textsize, sf::Color text_color,
sf::Texture* texture = nullptr, bool left = false,
sf::Color Outlinecolor = sf::Color::Transparent, float outlineSize = 0.f
);
~textbox();
//Accessor
//Modifier
void settext(std::string text);
//function
void Update();
void Render(sf::RenderTarget& target);
};
class damageNumber
{
private:
float x, y;
float fade;
sf::Color textColor;
sf::Color OutlineTextColor;
sf::Font* font;
sf::Text text;
sf::Clock clock;
sf::Time delay;
public:
damageNumber(float x,float y,float damage,sf::Font* font,unsigned characterSize,unsigned outlineSize,
sf::Color textColor,sf::Color OutlineTextColor);
~damageNumber();
//Accessor
const bool remove();
//function
void Update(const float& deltaTime);
void Render(sf::RenderTarget& target);
};
}