-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.h
136 lines (110 loc) · 3.49 KB
/
gui.h
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
#pragma once
#include "stdafx.h"
#ifndef IGEEK_RPG_TOOLKIT_GUI
#define IGEEK_RPG_TOOLKIT_GUI
enum button_states {
kButtonIdle = 0, //<
kButtonHover, //<
kButtonActive //<
};
namespace gui {
const float p2pX(const float perc, const sf::VideoMode& vm);
const float p2pY(const float perc, const sf::VideoMode& vm);
const unsigned CalcCharSize(const sf::VideoMode& vm,
const unsigned modifier = 60);
class Button {
private:
short unsigned buttonState;
short unsigned id;
sf::RectangleShape shape;
sf::Font* font;
sf::Text text;
sf::Color textIdleColor;
sf::Color textHoverColor;
sf::Color textActiveColor;
sf::Color idleColor;
sf::Color hoverColor;
sf::Color activeColor;
sf::Color outlineIdleColor;
sf::Color outlineHoverColor;
sf::Color outlineActiveColor;
public:
Button(float x, float y, float width, float height, sf::Font* font,
_::AString text, unsigned character_size, sf::Color text_idle_color,
sf::Color text_hover_color, sf::Color text_active_color,
sf::Color idle_color, sf::Color hover_color, sf::Color active_color,
sf::Color outline_idle_color = sf::Color::Transparent,
sf::Color outline_hover_color = sf::Color::Transparent,
sf::Color outline_active_color = sf::Color::Transparent,
short unsigned id = 0);
~Button();
const bool IsPressed() const;
const _::AString Text() const;
const short unsigned& Id() const;
// Modifiers
void setText(const _::AString text);
void setId(const short unsigned id);
void Update(const sf::Vector2i& mouse_pos_window);
void Render(sf::RenderTarget& target);
};
class DropDownList {
private:
float keytime_;
float keytime_max_;
sf::Font& font_;
gui::Button* active_element_;
_::Array<gui::Button*> list_;
bool show_list_;
public:
DropDownList(float x, float y, float width, float height, sf::Font& font,
_::AString list[], unsigned nr_of_elements,
unsigned default_index = 0);
~DropDownList();
const unsigned short& GetActiveElementId() const;
const bool KeyTime();
void UpdateKeyTime(const float& dt);
void Update(const sf::Vector2i& mouse_pos_window, const float& dt);
void Render(sf::RenderTarget& target);
};
class TextureSelector {
float key_press_time_;
const float key_press_time_max_;
float grid_size_;
bool active_ //<
hidden_;
gui::Button* hide_button_;
sf::RectangleShape bounds_;
sf::Sprite sheet_;
sf::RectangleShape selector_;
sf::Vector2u mouse_pos_grid_;
sf::IntRect texture_rect_;
public:
TextureSelector(float x, float y, float width, float height, float grid_size,
const sf::Texture* texture_sheet, sf::Font& font,
_::AString text);
~TextureSelector();
const bool& getActive() const;
const sf::IntRect& getTextureRect() const;
const bool KeyTime();
void UpdateKeyTime(const float& dt);
void Update(const sf::Vector2i& mouse_pos_window, const float& dt);
void Render(sf::RenderTarget& target);
};
class ProgressBar {
private:
_::AString barString;
sf::Text text;
float maxWidth;
int maxValue;
sf::RectangleShape back;
sf::RectangleShape inner;
public:
ProgressBar(float x, float y, float width, float height, int max_value,
sf::Color inner_color, unsigned character_size, sf::VideoMode& vm,
sf::Font* font = nullptr);
~ProgressBar();
void Update(const int current_value);
void Render(sf::RenderTarget& target);
};
} // namespace gui
#endif