Project Alice
Loading...
Searching...
No Matches
gui_stats_window.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace ui {
6
8protected:
9 std::string get_text(sys::state& state, dcon::nation_id n) noexcept {
10 auto fat = dcon::fatten(state.world, n);
11 return (text::format_float(fat.get_war_exhaustion()) + "/" +
12 text::format_float(state.world.nation_get_modifier_values(n, sys::national_mod_offsets::max_war_exhaustion)));
13 }
14
15public:
16 void on_update(sys::state& state) noexcept override {
17 set_text(state, get_text(state, state.local_player_nation));
18 }
19
22 }
23
24 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
25 auto n = retrieve<dcon::nation_id>(state, parent);
26 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::war_exhaustion, true);
28 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::max_war_exhaustion, true);
29 }
30};
31
33protected:
34 std::string get_text(sys::state& state, dcon::nation_id n) noexcept {
36 state.world.nation_get_modifier_values(n, sys::national_mod_offsets::supply_consumption) + 1.0f);
37 }
38
39public:
40 void on_update(sys::state& state) noexcept override {
41 set_text(state, get_text(state, state.local_player_nation));
42 }
43
46 }
47
48 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
49 auto n = retrieve<dcon::nation_id>(state, parent);
50 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::supply_consumption, false);
51 }
52};
53
55protected:
56 std::string get_text(sys::state& state, dcon::nation_id n) noexcept {
57 return text::format_percentage(state.world.nation_get_modifier_values(n, sys::national_mod_offsets::org_regain) + 1.0f);
58 }
59
60public:
61 void on_update(sys::state& state) noexcept override {
62 set_text(state, get_text(state, state.local_player_nation));
63 }
64
67 }
68
69 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
70 auto n = retrieve<dcon::nation_id>(state, parent);
71 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::org_regain, false);
72 }
73};
74
76protected:
77 std::string get_text(sys::state& state, dcon::nation_id n) noexcept {
79 state.world.nation_get_modifier_values(n, sys::national_mod_offsets::land_organisation) + 1.0f);
80 }
81
82public:
83 void on_update(sys::state& state) noexcept override {
84 set_text(state, get_text(state, state.local_player_nation));
85 }
86
89 }
90
91 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
92 auto n = retrieve<dcon::nation_id>(state, parent);
93 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::land_organisation, false);
94 }
95};
96
98protected:
99 std::string get_text(sys::state& state, dcon::nation_id n) noexcept {
101 state.world.nation_get_modifier_values(n, sys::national_mod_offsets::naval_organisation) + 1.0f);
102 }
103
104public:
105 void on_update(sys::state& state) noexcept override {
106 set_text(state, get_text(state, state.local_player_nation));
107 }
108
111 }
112
113 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
114 auto n = retrieve<dcon::nation_id>(state, parent);
115 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::naval_organisation, false);
116 }
117};
118
120protected:
121 std::string get_text(sys::state& state, dcon::nation_id n) noexcept {
122 return (text::format_float(state.world.nation_get_modifier_values(n, sys::national_mod_offsets::regular_experience_level)) +
123 "/" + text::format_float(69.0f));
124 }
125
126public:
127 void on_update(sys::state& state) noexcept override {
128 set_text(state, get_text(state, state.local_player_nation));
129 }
130
133 }
134
135 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
136 auto n = retrieve<dcon::nation_id>(state, parent);
137 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::regular_experience_level, false);
138 }
139};
140
142protected:
143 std::string get_text(sys::state& state, dcon::nation_id n) noexcept {
144 return text::format_percentage(state.world.nation_get_modifier_values(n, sys::national_mod_offsets::reinforce_speed) + 1.0f);
145 }
146
147public:
148 void on_update(sys::state& state) noexcept override {
149 set_text(state, get_text(state, state.local_player_nation));
150 }
151
154 }
155
156 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
157 auto n = retrieve<dcon::nation_id>(state, parent);
158 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::reinforce_speed, false);
159 }
160};
161
163protected:
164 std::string get_text(sys::state& state, dcon::nation_id n) noexcept {
165 return std::to_string(int16_t(state.defines.base_combat_width +
166 int16_t(state.world.nation_get_modifier_values(n, sys::national_mod_offsets::combat_width))));
167 }
168
169public:
170 void on_update(sys::state& state) noexcept override {
171 set_text(state, get_text(state, state.local_player_nation));
172 }
173
176 }
177
178 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
179 auto n = retrieve<dcon::nation_id>(state, parent);
180 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::combat_width, false);
181 }
182};
183
185protected:
186 std::string get_text(sys::state& state, dcon::nation_id n) noexcept {
187 return std::to_string(int16_t(state.world.nation_get_modifier_values(n, sys::national_mod_offsets::dig_in_cap)));
188 }
189
190public:
191 void on_update(sys::state& state) noexcept override {
192 set_text(state, get_text(state, state.local_player_nation));
193 }
194
197 }
198
199 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
200 auto n = retrieve<dcon::nation_id>(state, parent);
201 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::dig_in_cap, false);
202 }
203};
204
206protected:
207 std::string get_text(sys::state& state, dcon::nation_id n) noexcept {
208 return text::format_percentage(state.world.nation_get_modifier_values(n, sys::national_mod_offsets::military_tactics) +
209 state.defines.base_military_tactics);
210 }
211
212public:
213 void on_update(sys::state& state) noexcept override {
214 set_text(state, get_text(state, state.local_player_nation));
215 }
216
219 }
220
221 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
222 auto n = retrieve<dcon::nation_id>(state, parent);
223 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::military_tactics, false);
224 }
225};
226
228public:
229 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
230 if(name == "war_exhaustion_icon") {
231 return make_element_by_type<image_element_base>(state, id);
232
233 } else if(name == "war_exhaustion_desc") {
234 return make_element_by_type<simple_text_element_base>(state, id);
235
236 } else if(name == "supply_consumption_icon") {
237 return make_element_by_type<image_element_base>(state, id);
238
239 } else if(name == "supply_consumption_desc") {
240 return make_element_by_type<simple_text_element_base>(state, id);
241
242 } else if(name == "org_regain_icon") {
243 return make_element_by_type<image_element_base>(state, id);
244
245 } else if(name == "org_regain_desc") {
246 return make_element_by_type<simple_text_element_base>(state, id);
247
248 } else if(name == "army_org_icon") {
249 return make_element_by_type<image_element_base>(state, id);
250
251 } else if(name == "army_org_desc") {
252 return make_element_by_type<simple_text_element_base>(state, id);
253
254 } else if(name == "navy_org_icon") {
255 return make_element_by_type<image_element_base>(state, id);
256
257 } else if(name == "navy_org_desc") {
258 return make_element_by_type<simple_text_element_base>(state, id);
259
260 } else if(name == "unit_experience_icon") {
261 return make_element_by_type<image_element_base>(state, id);
262
263 } else if(name == "unit_experience_desc") {
264 return make_element_by_type<simple_text_element_base>(state, id);
265
266 } else if(name == "recruit_time_icon") {
267 return make_element_by_type<image_element_base>(state, id);
268
269 } else if(name == "recruit_time_desc") {
270 return make_element_by_type<simple_text_element_base>(state, id);
271
272 } else if(name == "combat_width_icon") {
273 return make_element_by_type<image_element_base>(state, id);
274
275 } else if(name == "combat_width_desc") {
276 return make_element_by_type<simple_text_element_base>(state, id);
277
278 } else if(name == "digin_cap_icon") {
279 return make_element_by_type<image_element_base>(state, id);
280
281 } else if(name == "digin_cap_desc") {
282 return make_element_by_type<simple_text_element_base>(state, id);
283
284 } else if(name == "tactics_level_icon") {
285 return make_element_by_type<image_element_base>(state, id);
286
287 } else if(name == "tactics_level_desc") {
288 return make_element_by_type<simple_text_element_base>(state, id);
289
290 } else if(name == "war_exhaustion") {
291 return make_element_by_type<statswin_warexhaustion>(state, id);
292
293 } else if(name == "supply_consumption") {
294 return make_element_by_type<statswin_supplyconsumption>(state, id);
295
296 } else if(name == "org_regain") {
297 return make_element_by_type<statswin_orgregain>(state, id);
298
299 } else if(name == "army_org") {
300 return make_element_by_type<statswin_armyorg>(state, id);
301
302 } else if(name == "navy_org") {
303 return make_element_by_type<statswin_navyorg>(state, id);
304
305 } else if(name == "unit_experience") {
306 return make_element_by_type<statswin_unitexperience>(state, id);
307
308 } else if(name == "recruit_time") {
309 return make_element_by_type<statswin_recruittime>(state, id);
310
311 } else if(name == "combat_width") {
312 return make_element_by_type<statswin_combatwidth>(state, id);
313
314 } else if(name == "digin_cap") {
315 return make_element_by_type<statswin_digincap>(state, id);
316
317 } else if(name == "tactics_level") {
318 return make_element_by_type<statswin_tactics>(state, id);
319
320 } else {
321 return nullptr;
322 }
323 }
324};
325
326} // namespace ui
element_base * parent
void set_text(sys::state &state, std::string const &new_text)
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
std::string get_text(sys::state &state, dcon::nation_id n) noexcept
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
std::string get_text(sys::state &state, dcon::nation_id n) noexcept
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
std::string get_text(sys::state &state, dcon::nation_id n) noexcept
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_update(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
std::string get_text(sys::state &state, dcon::nation_id n) noexcept
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
std::string get_text(sys::state &state, dcon::nation_id n) noexcept
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
std::string get_text(sys::state &state, dcon::nation_id n) noexcept
tooltip_behavior has_tooltip(sys::state &state) noexcept override
std::string get_text(sys::state &state, dcon::nation_id n) noexcept
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
std::string get_text(sys::state &state, dcon::nation_id n) noexcept
tooltip_behavior has_tooltip(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
std::string get_text(sys::state &state, dcon::nation_id n) noexcept
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
std::string get_text(sys::state &state, dcon::nation_id n) noexcept
tooltip_behavior has_tooltip(sys::state &state) noexcept override
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
std::string format_float(float num, size_t digits)
Definition: text.cpp:981
void add_line_break_to_layout(sys::state &state, columnar_layout &dest)
Definition: text.cpp:1152
std::string format_percentage(float num, size_t digits)
Definition: text.cpp:977
tooltip_behavior
void active_modifiers_description(sys::state &state, text::layout_base &layout, dcon::nation_id n, int32_t identation, dcon::national_modifier_value nmid, bool header)