Project Alice
Loading...
Searching...
No Matches
gui_map_legend.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "dcon_generated.hpp"
5#include "gui_graphics.hpp"
6#include "text.hpp"
7
8namespace ui {
9
11 std::string get_title_from_mode(map_mode::mode v) {
12 return "mapmode_" + std::to_string(uint32_t(v));
13 }
14public:
15 void on_update(sys::state& state) noexcept override {
16 set_text(state, text::produce_simple_string(state, get_title_from_mode(state.map_state.active_map_mode)));
17 }
18};
20 int16_t get_frame_from_mode(map_mode::mode v) {
21 switch(v) {
41 return 1;
47 return 3;
48 default:
49 return 0;
50 }
51 }
52public:
53 void on_update(sys::state& state) noexcept override {
54 frame = get_frame_from_mode(state.map_state.active_map_mode);
55 }
56};
58 std::string get_gradient_max_from_mode(map_mode::mode v) {
59 return "legend_max_mapmode_" + std::to_string(uint32_t(v));
60 }
61public:
62 void on_update(sys::state& state) noexcept override {
63 set_text(state, text::produce_simple_string(state, get_gradient_max_from_mode(state.map_state.active_map_mode)));
64 }
65};
67 std::string get_gradient_min_from_mode(map_mode::mode v) {
68 return "legend_min_mapmode_" + std::to_string(uint32_t(v));
69 }
70public:
71 void on_update(sys::state& state) noexcept override {
72 set_text(state, text::produce_simple_string(state, get_gradient_min_from_mode(state.map_state.active_map_mode)));
73 }
74};
75
77public:
78 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
79 if(name == "legend_title") {
80 return make_element_by_type<map_legend_title>(state, id);
81 } else if(name == "gradient_icon") {
82 return make_element_by_type<map_legend_gradient_image>(state, id);
83 } else if(name == "gradient_min") {
84 return make_element_by_type<map_legend_gradient_min>(state, id);
85 } else if(name == "gradient_max") {
86 return make_element_by_type<map_legend_gradient_max>(state, id);
87 } else {
88 return nullptr;
89 }
90 }
91
92 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
93 auto new_position = xy_pair{ int16_t((state.ui_state.root->base_data.size.x - base_data.size.x) / 2), int16_t((state.ui_state.root->base_data.size.y - base_data.size.y) - (state.ui_state.msg_log_window->is_visible() ? state.ui_state.msg_log_window->base_data.size.y + 54 : 12)) };
94 base_data.position = new_position;
95 window_element_base::impl_render(state, new_position.x, new_position.y);
96 }
97};
98
100public:
101 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
102 if(name == "s1_ico") {
103 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(53, 196, 53));
104 } else if(name == "s5_ico") {
105 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(53, 196, 53));
106 } else if(name == "s5_ico_b") {
107 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(53, 53, 250));
108 } else if(name == "s2_ico") {
109 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(250, 5, 5));
110 } else if(name == "s3_ico") {
111 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(250, 250, 5));
112 } else if(name == "s4_ico") {
113 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(64, 64, 64));
114 } else {
115 return nullptr;
116 }
117 }
118
119 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
120 auto new_position = xy_pair{ int16_t((state.ui_state.root->base_data.size.x - base_data.size.x) / 2), int16_t((state.ui_state.root->base_data.size.y - base_data.size.y) - (state.ui_state.msg_log_window->is_visible() ? state.ui_state.msg_log_window->base_data.size.y + 54 : 12)) };
121 base_data.position = new_position;
122 window_element_base::impl_render(state, new_position.x, new_position.y);
123 }
124};
125
127public:
128 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
129 if(name == "s1_ico") {
130 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(46, 247, 15));
131 } else if(name == "s2_ico") {
132 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(247, 15, 15));
133 } else if(name == "s3_ico") {
134 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(140, 247, 15));
135 } else if(name == "s4_ico") {
136 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(250, 250, 5));
137 } else {
138 return nullptr;
139 }
140 }
141
142 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
143 auto new_position = xy_pair{ int16_t((state.ui_state.root->base_data.size.x - base_data.size.x) / 2), int16_t((state.ui_state.root->base_data.size.y - base_data.size.y) - (state.ui_state.msg_log_window->is_visible() ? state.ui_state.msg_log_window->base_data.size.y + 54 : 12)) };
144 base_data.position = new_position;
145 window_element_base::impl_render(state, new_position.x, new_position.y);
146 }
147};
148
150public:
151 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
152 if(name == "s1_ico") { // Viewpoint
153 return make_element_by_type<tinted_image_element_base>(state, id, uint32_t(0x00FF00));
154 } else if(name == "s2_ico") { // Ally
155 return make_element_by_type<tinted_image_element_base>(state, id, uint32_t(0xFFAA00));
156 } else if(name == "s3_ico") { // Enemy
157 return make_element_by_type<tinted_image_element_base>(state, id, uint32_t(0x0000FF));
158 } else if(name == "s4_ico") { // Puppet
159 return make_element_by_type<tinted_image_element_base>(state, id, uint32_t(0x009900));
160 } else if(name == "s5_ico") { // Sphere
161 return make_element_by_type<tinted_image_element_base>(state, id, uint32_t(0x55AA55));
162 } else if(name == "s6_ico") { // Other
163 return make_element_by_type<tinted_image_element_base>(state, id, uint32_t(0x222222));
164 } else if(name == "s7_ico") { // Core
165 return make_element_by_type<tinted_image_element_base>(state, id, uint32_t(0x222222));
166 } else if(name == "s8_ico") { // Non Core
167 return make_element_by_type<tinted_image_element_base>(state, id, uint32_t(0x00FF00));
168 } else if(name == "s9_ico") { // Union Core
169 return make_element_by_type<tinted_image_element_base>(state, id, uint32_t(0x222222));
170 } else if(name == "s7_ico_b") { // Core
171 return make_element_by_type<tinted_image_element_base>(state, id, uint32_t(0x00FF00));
172 } else if(name == "s8_ico_b") { // Non Core
173 return make_element_by_type<tinted_image_element_base>(state, id, uint32_t(0xFFFFFF));
174 } else if(name == "s9_ico_b") { // Union Core
175 return make_element_by_type<tinted_image_element_base>(state, id, uint32_t(0x00FFFF));
176 } else {
177 return nullptr;
178 }
179 }
180
181 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
182 auto new_position = xy_pair{ int16_t((state.ui_state.root->base_data.size.x - base_data.size.x) / 2), int16_t((state.ui_state.root->base_data.size.y - base_data.size.y) - (state.ui_state.msg_log_window->is_visible() ? state.ui_state.msg_log_window->base_data.size.y + 54 : 12)) };
183 base_data.position = new_position;
184 window_element_base::impl_render(state, new_position.x, new_position.y);
185 }
186};
187
189public:
190 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
191 if(name == "s1_ico") { // Level 0
192 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(41, 5, 245));
193 } else if(name == "s2_ico") { // Level 5
194 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(14, 240, 44));
195 } else if(name == "s3_ico") { // Upgrading
196 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(222, 7, 46));
197 } else if(name == "s3_ico_b") { // Upgrading
198 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(232, 228, 111));
199 } else if(name == "s4_ico") { // Max level
200 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(232, 228, 111));
201 } else if(name == "s5_ico") { // Blocked
202 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(222, 7, 46));
203 } else {
204 return nullptr;
205 }
206 }
207
208 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
209 auto new_position = xy_pair{ int16_t((state.ui_state.root->base_data.size.x - base_data.size.x) / 2), int16_t((state.ui_state.root->base_data.size.y - base_data.size.y) - (state.ui_state.msg_log_window->is_visible() ? state.ui_state.msg_log_window->base_data.size.y + 54 : 12)) };
210 base_data.position = new_position;
211 window_element_base::impl_render(state, new_position.x, new_position.y);
212 }
213};
214
216public:
217 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
218 if(name == "s1_ico") { // No base
219 return make_element_by_type<tinted_image_element_base>(state, id, uint32_t(0x222222));
220 } else if(name == "s2_ico") { // Max level
221 return make_element_by_type<tinted_image_element_base>(state, id, uint32_t(0x005500));
222 } else if(name == "s3_ico") { // Upgrading
223 return make_element_by_type<tinted_image_element_base>(state, id, uint32_t(0x005500));
224 } else if(name == "s3_ico_b") { // Upgrading
225 return make_element_by_type<tinted_image_element_base>(state, id, uint32_t(0x00FF00));
226 } else if(name == "s4_ico") { // Upgradeable
227 return make_element_by_type<tinted_image_element_base>(state, id, uint32_t(0x00FF00));
228 } else if(name == "s5_ico") { // Constructible
229 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(50, 150, 200));
230 } else {
231 return nullptr;
232 }
233 }
234
235 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
236 auto new_position = xy_pair{ int16_t((state.ui_state.root->base_data.size.x - base_data.size.x) / 2), int16_t((state.ui_state.root->base_data.size.y - base_data.size.y) - (state.ui_state.msg_log_window->is_visible() ? state.ui_state.msg_log_window->base_data.size.y + 54 : 12)) };
237 base_data.position = new_position;
238 window_element_base::impl_render(state, new_position.x, new_position.y);
239 }
240};
241
243public:
244 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
245 if(name == "s1_ico") {
246 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(int32_t(48 * 0.65f), int32_t(242 * 0.65f), int32_t(51 * 0.65f)));
247 } else if(name == "s2_ico") {
248 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(int32_t(36 * 0.65f), int32_t(47 * 0.65f), int32_t(255 * 0.65f)));
249 } else if(name == "s3_ico") {
250 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(int32_t(238 * 0.65f), int32_t(252 * 0.65f), int32_t(38 * 0.65f)));
251 } else if(name == "s4_ico") {
252 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(int32_t(250 * 0.65f), int32_t(5 * 0.65f), int32_t(5 * 0.65f)));
253 } else {
254 return nullptr;
255 }
256 }
257
258 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
259 auto new_position = xy_pair{ int16_t((state.ui_state.root->base_data.size.x - base_data.size.x) / 2), int16_t((state.ui_state.root->base_data.size.y - base_data.size.y) - (state.ui_state.msg_log_window->is_visible() ? state.ui_state.msg_log_window->base_data.size.y + 54 : 12)) };
260 base_data.position = new_position;
261 window_element_base::impl_render(state, new_position.x, new_position.y);
262 }
263};
264
266public:
267 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
268 if(name == "s1_ico") {
269 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(53, 196, 53));
270 } else if(name == "s2_ico") {
271 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(212, 214, 62));
272 } else if(name == "s3_ico") {
273 return make_element_by_type<tinted_image_element_base>(state, id, sys::pack_color(155, 156, 149));
274 } else {
275 return nullptr;
276 }
277 }
278
279 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
280 auto new_position = xy_pair{ int16_t((state.ui_state.root->base_data.size.x - base_data.size.x) / 2), int16_t((state.ui_state.root->base_data.size.y - base_data.size.y) - (state.ui_state.msg_log_window->is_visible() ? state.ui_state.msg_log_window->base_data.size.y + 54 : 12)) };
281 base_data.position = new_position;
282 window_element_base::impl_render(state, new_position.x, new_position.y);
283 }
284};
285
286}
virtual void impl_render(sys::state &state, int32_t x, int32_t y) noexcept
bool is_visible() const
element_data base_data
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
void impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
void impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_update(sys::state &state) noexcept override
void set_text(sys::state &state, std::string const &new_text)
uint32_t pack_color(float r, float g, float b)
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
Definition: text.cpp:617
uint uint32_t
element_base * msg_log_window
std::unique_ptr< element_base > root