Project Alice
Loading...
Searching...
No Matches
gui_technology_window.cpp
Go to the documentation of this file.
2
3namespace ui {
4
5void invention_description(sys::state& state, text::layout_base& contents, dcon::invention_id inv_id, int32_t indent) noexcept {
6 auto iid = fatten(state.world, inv_id);
7
8 if(iid.get_modifier())
9 modifier_description(state, contents, iid.get_modifier(), indent);
10
11 if(iid.get_enable_gas_attack()) {
12 text::add_line(state, contents, "may_gas_attack", indent);
13 }
14 if(iid.get_enable_gas_defense()) {
15 text::add_line(state, contents, "may_gas_defend", indent);
16 }
17
19 auto increase_building = iid.get_increase_building(t);
20 if(increase_building) {
21 auto box = text::open_layout_box(contents, 0);
25 text::add_to_layout_box(state, contents, box, std::string_view{ ":" }, text::text_color::white);
28 text::close_layout_box(contents, box);
29 }
30 }
31
32 if(auto p = iid.get_shared_prestige(); p > 0) {
33 int32_t total = 1;
34 for(auto n : state.world.in_nation) {
35 if(n.get_active_inventions(iid)) {
36 ++total;
37 }
38 }
39 auto box = text::open_layout_box(contents, indent);
40 text::localised_format_box(state, contents, box, "shared_prestige_tech");
41 text::add_to_layout_box(state, contents, box, std::string_view{": "});
42 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
43 text::add_to_layout_box( state, contents, box, text::fp_one_place { p / float(total) }, text::text_color::green);
44
45 text::close_layout_box(contents, box);
46
47 }
48 if(iid.get_plurality() != 0) {
49 auto box = text::open_layout_box(contents, 15);
50 text::localised_format_box(state, contents, box, "tech_plurality");
51 text::add_to_layout_box(state, contents, box, std::string_view{": "});
52 if(iid.get_plurality() < 0) {
53 text::add_to_layout_box(state, contents, box, text::fp_percentage{iid.get_plurality()}, text::text_color::red);
54 } else {
55 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
56 text::add_to_layout_box(state, contents, box, text::fp_percentage{iid.get_plurality()}, text::text_color::green);
57 }
58 text::close_layout_box(contents, box);
59 }
60
61 auto activate_unit_description = [&](dcon::unit_type_id id) {
62 if(iid.get_activate_unit(id)) {
63 auto unit_type_name = state.military_definitions.unit_base_definitions[id].name;
64
65 auto box = text::open_layout_box(contents, indent);
66 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, "enable_unit_tech"),
70 text::close_layout_box(contents, box);
71 }
72 };
73 for(uint8_t unit_type_i = 0; unit_type_i < iid.get_activate_unit_size(); ++unit_type_i) {
74 dcon::unit_type_id id(unit_type_i);
75 activate_unit_description(id);
76 }
77
78 auto activate_factory_description = [&](dcon::factory_type_id id) {
79 if(iid.get_activate_building(id)) {
80 auto factory_type_fat_id = dcon::fatten(state.world, id);
81
82 auto box = text::open_layout_box(contents, indent);
83 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, "enable_building_tech"),
86 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, factory_type_fat_id.get_name()),
88 text::close_layout_box(contents, box);
89
90 box = text::open_layout_box(contents, indent);
91 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, "activate_goods"),
94 text::add_to_layout_box(state, contents, box,
95 text::produce_simple_string(state, factory_type_fat_id.get_output().get_name()), text::text_color::yellow);
96 text::close_layout_box(contents, box);
97 }
98 };
99 for(uint8_t building_type_i = 0; building_type_i < iid.get_activate_building_size(); ++building_type_i) {
100 dcon::factory_type_id id(building_type_i);
101 activate_factory_description(id);
102 }
103
104 for(auto i = state.culture_definitions.crimes.size(); i-- > 0;) {
105 dcon::crime_id c{dcon::crime_id::value_base_t(i)};
106 if(iid.get_activate_crime(c)) {
107 auto box = text::open_layout_box(contents, indent);
109 text::add_to_layout_box(state, contents, box, state.culture_definitions.crimes[c].name, text::text_color::yellow);
110 text::close_layout_box(contents, box);
111 }
112 }
113 auto commodity_mod_description = [&](auto const& list, std::string_view locale_base_name, std::string_view locale_farm_base_name) {
114 for(const auto mod : list) {
115 auto box = text::open_layout_box(contents, indent);
116 auto name = state.world.commodity_get_name(mod.type);
117
118 auto cid = mod.type;
119 std::string padding = cid.index() < 10 ? "0" : "";
120 std::string description = "@$" + padding + std::to_string(cid.index());
121 text::add_unparsed_text_to_layout_box(state, contents, box, description);
122
123 text::add_to_layout_box(state, contents, box, name);
124 text::add_space_to_layout_box(state, contents, box);
125 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, state.world.commodity_get_is_mine(mod.type) ? locale_base_name : locale_farm_base_name));
126 text::add_to_layout_box(state, contents, box, std::string{":"});
127 text::add_space_to_layout_box(state, contents, box);
128 auto color = mod.amount > 0.f ? text::text_color::green : text::text_color::red;
129 text::add_to_layout_box(state, contents, box, (mod.amount > 0.f ? "+" : "") + text::format_percentage(mod.amount, 1), color);
130 text::close_layout_box(contents, box);
131 }
132 };
133 commodity_mod_description(iid.get_factory_goods_output(), "tech_output", "tech_output");
134 commodity_mod_description(iid.get_rgo_goods_output(), "tech_mine_output", "tech_farm_output");
135 commodity_mod_description(iid.get_factory_goods_throughput(), "tech_throughput", "tech_throughput");
136 commodity_mod_description(iid.get_rgo_size(), "tech_mine_size", "tech_farm_size");
137
138 auto colonial_points = iid.get_colonial_points();
139 if(colonial_points != 0) {
140 auto box = text::open_layout_box(contents, 0);
141 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, "colonial_points_tech"),
143 text::add_to_layout_box(state, contents, box, std::string_view{ ":" }, text::text_color::white);
144 text::add_space_to_layout_box(state, contents, box);
145 auto color = colonial_points > 0.f ? text::text_color::green : text::text_color::red;
146 text::add_to_layout_box(state, contents, box, (colonial_points > 0.f ? "+" : "") + text::prettify(int64_t(colonial_points)),
147 color);
148 text::close_layout_box(contents, box);
149 }
150
151 auto unit_modifier_description = [&](sys::unit_modifier& mod) {
152 bool is_land = true;
153 if(mod.type == state.military_definitions.base_army_unit) {
154 text::add_line(state, contents, "armies", indent);
155 } else if(mod.type == state.military_definitions.base_naval_unit) {
156 text::add_line(state, contents, "navies", indent);
157 is_land = false;
158 } else {
159 auto box = text::open_layout_box(contents, indent);
160 text::add_to_layout_box(state, contents, box, state.military_definitions.unit_base_definitions[mod.type].name);
161 text::close_layout_box(contents, box);
162 is_land = state.military_definitions.unit_base_definitions[mod.type].is_land;
163 }
164
165 if(mod.build_time != 0) {
166 auto box = text::open_layout_box(contents, indent + 15);
167 text::localised_format_box(state, contents, box, "build_time");
168 text::add_to_layout_box(state, contents, box, std::string_view{": "});
169 if(mod.build_time < 0) {
170 text::add_to_layout_box(state, contents, box, int64_t{mod.build_time}, text::text_color::green);
171 } else {
172 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::red);
173 text::add_to_layout_box(state, contents, box, int64_t{mod.build_time}, text::text_color::red);
174 }
175 text::close_layout_box(contents, box);
176 }
177 if(mod.default_organisation != 0) {
178 auto box = text::open_layout_box(contents, indent + 15);
179 text::localised_format_box(state, contents, box, "default_org");
180 text::add_to_layout_box(state, contents, box, std::string_view{": "});
181 if(mod.default_organisation < 0) {
182 text::add_to_layout_box(state, contents, box, int64_t{mod.default_organisation}, text::text_color::red);
183 } else {
184 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
185 text::add_to_layout_box(state, contents, box, int64_t{mod.default_organisation}, text::text_color::green);
186 }
187 text::close_layout_box(contents, box);
188 }
189 if(mod.maximum_speed != 0) {
190 auto box = text::open_layout_box(contents, indent + 15);
191 text::localised_format_box(state, contents, box, "maximum_speed");
192 text::add_to_layout_box(state, contents, box, std::string_view{": "});
193 if(mod.maximum_speed < 0) {
194 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.maximum_speed}, text::text_color::red);
195 } else {
196 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
198 }
199 text::close_layout_box(contents, box);
200 }
201 if(mod.supply_consumption != 0) {
202 auto box = text::open_layout_box(contents, indent + 15);
203 text::localised_format_box(state, contents, box, "supply_consumption");
204 text::add_to_layout_box(state, contents, box, std::string_view{": "});
205 if(mod.supply_consumption < 0) {
206 text::add_to_layout_box(state, contents, box, text::fp_percentage{mod.supply_consumption}, text::text_color::green);
207 } else {
208 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::red);
209 text::add_to_layout_box(state, contents, box, text::fp_percentage{mod.supply_consumption}, text::text_color::red);
210 }
211 text::close_layout_box(contents, box);
212 }
213
214 if(is_land) {
215 if(mod.attack_or_gun_power != 0) {
216 auto box = text::open_layout_box(contents, indent + 15);
217 text::localised_format_box(state, contents, box, "attack");
218 text::add_to_layout_box(state, contents, box, std::string_view{": "});
219 if(mod.attack_or_gun_power < 0) {
220 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.attack_or_gun_power}, text::text_color::red);
221 } else {
222 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
223 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.attack_or_gun_power}, text::text_color::green);
224 }
225 text::close_layout_box(contents, box);
226 }
227 if(mod.defence_or_hull != 0) {
228 auto box = text::open_layout_box(contents, indent + 15);
229 text::localised_format_box(state, contents, box, "defence");
230 text::add_to_layout_box(state, contents, box, std::string_view{": "});
231 if(mod.defence_or_hull < 0) {
232 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.defence_or_hull}, text::text_color::red);
233 } else {
234 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
235 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.defence_or_hull}, text::text_color::green);
236 }
237 text::close_layout_box(contents, box);
238 }
239 if(mod.reconnaissance_or_fire_range != 0) {
240 auto box = text::open_layout_box(contents, indent + 15);
241 text::localised_format_box(state, contents, box, "reconaissance");
242 text::add_to_layout_box(state, contents, box, std::string_view{": "});
243 if(mod.reconnaissance_or_fire_range < 0) {
244 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.reconnaissance_or_fire_range},
246 } else {
247 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
248 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.reconnaissance_or_fire_range},
250 }
251 text::close_layout_box(contents, box);
252 }
253 if(mod.siege_or_torpedo_attack != 0) {
254 auto box = text::open_layout_box(contents, indent + 15);
255 text::localised_format_box(state, contents, box, "siege");
256 text::add_to_layout_box(state, contents, box, std::string_view{": "});
257 if(mod.siege_or_torpedo_attack < 0) {
258 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.siege_or_torpedo_attack}, text::text_color::red);
259 } else {
260 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
261 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.siege_or_torpedo_attack},
263 }
264 text::close_layout_box(contents, box);
265 }
266 if(mod.support != 0) {
267 auto box = text::open_layout_box(contents, indent + 15);
268 text::localised_format_box(state, contents, box, "support");
269 text::add_to_layout_box(state, contents, box, std::string_view{": "});
270 if(mod.support < 0) {
272 } else {
273 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
275 }
276 text::close_layout_box(contents, box);
277 }
278 if(mod.discipline_or_evasion != 0) {
279 auto box = text::open_layout_box(contents, indent + 15);
280 text::localised_format_box(state, contents, box, "discipline");
281 text::add_to_layout_box(state, contents, box, std::string_view{ ": " });
282 if(mod.discipline_or_evasion < 0) {
283 text::add_to_layout_box(state, contents, box, text::fp_two_places{ mod.discipline_or_evasion }, text::text_color::red);
284 } else {
285 text::add_to_layout_box(state, contents, box, std::string_view{ "+" }, text::text_color::green);
286 text::add_to_layout_box(state, contents, box, text::fp_two_places{ mod.discipline_or_evasion }, text::text_color::green);
287 }
288 text::close_layout_box(contents, box);
289 }
290 } else {
291 if(mod.attack_or_gun_power != 0) {
292 auto box = text::open_layout_box(contents, indent + 15);
293 text::localised_format_box(state, contents, box, "gun_power");
294 text::add_to_layout_box(state, contents, box, std::string_view{": "});
295 if(mod.attack_or_gun_power < 0) {
296 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.attack_or_gun_power}, text::text_color::red);
297 } else {
298 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
299 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.attack_or_gun_power}, text::text_color::green);
300 }
301 text::close_layout_box(contents, box);
302 }
303 if(mod.defence_or_hull != 0) {
304 auto box = text::open_layout_box(contents, indent + 15);
305 text::localised_format_box(state, contents, box, "hull");
306 text::add_to_layout_box(state, contents, box, std::string_view{": "});
307 if(mod.defence_or_hull < 0) {
308 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.defence_or_hull}, text::text_color::red);
309 } else {
310 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
311 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.defence_or_hull}, text::text_color::green);
312 }
313 text::close_layout_box(contents, box);
314 }
315 if(mod.reconnaissance_or_fire_range != 0) {
316 auto box = text::open_layout_box(contents, indent + 15);
317 text::localised_format_box(state, contents, box, "gun_range");
318 text::add_to_layout_box(state, contents, box, std::string_view{": "});
319 if(mod.reconnaissance_or_fire_range < 0) {
320 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.reconnaissance_or_fire_range},
322 } else {
323 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
324 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.reconnaissance_or_fire_range},
326 }
327 text::close_layout_box(contents, box);
328 }
329 if(mod.siege_or_torpedo_attack != 0) {
330 auto box = text::open_layout_box(contents, indent + 15);
331 text::localised_format_box(state, contents, box, "torpedo_attack");
332 text::add_to_layout_box(state, contents, box, std::string_view{": "});
333 if(mod.siege_or_torpedo_attack < 0) {
334 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.siege_or_torpedo_attack}, text::text_color::red);
335 } else {
336 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
337 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.siege_or_torpedo_attack},
339 }
340 text::close_layout_box(contents, box);
341 }
342 if(mod.discipline_or_evasion != 0) {
343 auto box = text::open_layout_box(contents, indent + 15);
344 text::localised_format_box(state, contents, box, "evasion");
345 text::add_to_layout_box(state, contents, box, std::string_view{ ": " });
346 if(mod.discipline_or_evasion < 0) {
347 text::add_to_layout_box(state, contents, box, text::fp_two_places{ mod.discipline_or_evasion }, text::text_color::red);
348 } else {
349 text::add_to_layout_box(state, contents, box, std::string_view{ "+" }, text::text_color::green);
350 text::add_to_layout_box(state, contents, box, text::fp_two_places{ mod.discipline_or_evasion }, text::text_color::green);
351 }
352 text::close_layout_box(contents, box);
353 }
354 }
355 };
356 for(auto& mod : iid.get_modified_units()) {
357 unit_modifier_description(mod);
358 }
359
360 for(auto& mod : iid.get_rebel_org()) {
361 if(!mod.type) {
362 auto box = text::open_layout_box(contents, indent);
363 text::localised_format_box(state, contents, box, "tech_rebel_org_gain");
364 text::add_to_layout_box(state, contents, box, std::string_view{": "});
365 if(mod.amount < 0) {
367 } else {
368 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::red);
370 }
371 text::close_layout_box(contents, box);
372 } else {
373 auto box = text::open_layout_box(contents, indent);
374 text::add_to_layout_box(state, contents, box, state.world.rebel_type_get_title(mod.type));
375 text::add_space_to_layout_box(state, contents, box);
376 text::localised_format_box(state, contents, box, "blank_org_gain");
377 text::add_to_layout_box(state, contents, box, std::string_view{": "});
378 if(mod.amount < 0) {
380 } else {
381 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::red);
383 }
384 text::close_layout_box(contents, box);
385 }
386 }
387}
388
389void technology_description(sys::state& state, text::layout_base& contents, dcon::technology_id tech_id) noexcept {
390 auto tech_fat_id = dcon::fatten(state.world, tech_id);
391 auto mod_id = tech_fat_id.get_modifier().id;
392 if(bool(mod_id))
393 modifier_description(state, contents, mod_id);
394
396 auto increase_building = tech_fat_id.get_increase_building(t);
397 if(increase_building) {
398 auto box = text::open_layout_box(contents, 0);
400 text::add_space_to_layout_box(state, contents, box);
402 text::add_to_layout_box(state, contents, box, std::string_view{":"}, text::text_color::white);
403 text::add_space_to_layout_box(state, contents, box);
405 text::close_layout_box(contents, box);
406 }
407 }
408 if(tech_fat_id.get_plurality() != 0) {
409 auto box = text::open_layout_box(contents, 15);
410 text::localised_format_box(state, contents, box, "tech_plurality");
411 text::add_to_layout_box(state, contents, box, std::string_view{ ": " });
412 if(tech_fat_id.get_plurality() < 0) {
413 text::add_to_layout_box(state, contents, box, text::fp_percentage{ tech_fat_id.get_plurality() }, text::text_color::red);
414 } else {
415 text::add_to_layout_box(state, contents, box, std::string_view{ "+" }, text::text_color::green);
416 text::add_to_layout_box(state, contents, box, text::fp_percentage{ tech_fat_id.get_plurality() }, text::text_color::green);
417 }
418 text::close_layout_box(contents, box);
419 }
420 auto activate_unit_description = [&](dcon::unit_type_id id) {
421 if(tech_fat_id.get_activate_unit(id)) {
422 auto unit_type_name = state.military_definitions.unit_base_definitions[id].name;
423
424 auto box = text::open_layout_box(contents, 0);
425 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, "enable_unit_tech"),
427 text::add_space_to_layout_box(state, contents, box);
429 text::close_layout_box(contents, box);
430 }
431 };
432 for(uint8_t unit_type_i = 0; unit_type_i < tech_fat_id.get_activate_unit_size(); ++unit_type_i) {
433 dcon::unit_type_id id(unit_type_i);
434 activate_unit_description(id);
435 }
436
437 auto activate_factory_description = [&](dcon::factory_type_id id) {
438 if(tech_fat_id.get_activate_building(id)) {
439 auto factory_type_fat_id = dcon::fatten(state.world, id);
440
441 auto box = text::open_layout_box(contents, 0);
442 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, "enable_building_tech"),
444 text::add_space_to_layout_box(state, contents, box);
445 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, factory_type_fat_id.get_name()),
447 text::close_layout_box(contents, box);
448
449 box = text::open_layout_box(contents, 0);
450 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, "activate_goods"),
452 text::add_space_to_layout_box(state, contents, box);
453 text::add_to_layout_box(state, contents, box,
454 text::produce_simple_string(state, factory_type_fat_id.get_output().get_name()), text::text_color::yellow);
455 text::close_layout_box(contents, box);
456 }
457 };
458 for(uint8_t building_type_i = 0; building_type_i < tech_fat_id.get_activate_building_size(); ++building_type_i) {
459 dcon::factory_type_id id(building_type_i);
460 activate_factory_description(id);
461 }
462
463 auto commodity_mod_description = [&](auto const& list, std::string_view locale_base_name,
464 std::string_view locale_farm_base_name) {
465 for(const auto mod : list) {
466 auto box = text::open_layout_box(contents, 0);
467 auto name = state.world.commodity_get_name(mod.type);
468
469 auto cid = mod.type;
470 std::string padding = cid.index() < 10 ? "0" : "";
471 std::string description = "@$" + padding + std::to_string(cid.index());
472 text::add_unparsed_text_to_layout_box(state, contents, box, description);
473
474 text::add_to_layout_box(state, contents, box, name);
475 text::add_space_to_layout_box(state, contents, box);
476 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, state.world.commodity_get_is_mine(mod.type) ? locale_base_name : locale_farm_base_name));
477 text::add_to_layout_box(state, contents, box, std::string{":"});
478 text::add_space_to_layout_box(state, contents, box);
479 auto color = mod.amount > 0.f ? text::text_color::green : text::text_color::red;
480 text::add_to_layout_box(state, contents, box, (mod.amount > 0.f ? "+" : "") + text::format_percentage(mod.amount, 1),
481 color);
482 text::close_layout_box(contents, box);
483 }
484 };
485 commodity_mod_description(tech_fat_id.get_factory_goods_output(), "tech_output", "tech_output");
486 commodity_mod_description(tech_fat_id.get_rgo_goods_output(), "tech_mine_output", "tech_farm_output");
487 commodity_mod_description(tech_fat_id.get_rgo_size(), "tech_mine_size", "tech_farm_size");
488
489 auto colonial_points = tech_fat_id.get_colonial_points();
490 if(colonial_points != 0) {
491 auto box = text::open_layout_box(contents, 0);
492 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, "colonial_points_tech"),
494 text::add_to_layout_box(state, contents, box, std::string_view{":"}, text::text_color::white);
495 text::add_space_to_layout_box(state, contents, box);
496 auto color = colonial_points > 0.f ? text::text_color::green : text::text_color::red;
497 text::add_to_layout_box(state, contents, box, (colonial_points > 0.f ? "+" : "") + text::prettify(int64_t(colonial_points)),
498 color);
499 text::close_layout_box(contents, box);
500 }
501
502 auto unit_modifier_description = [&](sys::unit_modifier& mod) {
503 bool is_land = true;
504 if(mod.type == state.military_definitions.base_army_unit) {
505 text::add_line(state, contents, "armies");
506 } else if(mod.type == state.military_definitions.base_naval_unit) {
507 text::add_line(state, contents, "navies");
508 is_land = false;
509 } else {
510 auto box = text::open_layout_box(contents);
511 text::add_to_layout_box(state, contents, box, state.military_definitions.unit_base_definitions[mod.type].name);
512 text::close_layout_box(contents, box);
513 is_land = state.military_definitions.unit_base_definitions[mod.type].is_land;
514 }
515
516 if(mod.build_time != 0) {
517 auto box = text::open_layout_box(contents, 15);
518 text::localised_format_box(state, contents, box, "build_time");
519 text::add_to_layout_box(state, contents, box, std::string_view{": "});
520 if(mod.build_time < 0) {
521 text::add_to_layout_box(state, contents, box, int64_t{mod.build_time}, text::text_color::green);
522 } else {
523 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::red);
524 text::add_to_layout_box(state, contents, box, int64_t{mod.build_time}, text::text_color::red);
525 }
526 text::close_layout_box(contents, box);
527 }
528 if(mod.default_organisation != 0) {
529 auto box = text::open_layout_box(contents, 15);
530 text::localised_format_box(state, contents, box, "default_org");
531 text::add_to_layout_box(state, contents, box, std::string_view{": "});
532 if(mod.default_organisation < 0) {
533 text::add_to_layout_box(state, contents, box, int64_t{mod.default_organisation}, text::text_color::red);
534 } else {
535 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
536 text::add_to_layout_box(state, contents, box, int64_t{mod.default_organisation}, text::text_color::green);
537 }
538 text::close_layout_box(contents, box);
539 }
540 if(mod.maximum_speed != 0) {
541 auto box = text::open_layout_box(contents, 15);
542 text::localised_format_box(state, contents, box, "maximum_speed");
543 text::add_to_layout_box(state, contents, box, std::string_view{": "});
544 if(mod.maximum_speed < 0) {
545 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.maximum_speed}, text::text_color::red);
546 } else {
547 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
549 }
550 text::close_layout_box(contents, box);
551 }
552 if(mod.supply_consumption != 0) {
553 auto box = text::open_layout_box(contents, 15);
554 text::localised_format_box(state, contents, box, "supply_consumption");
555 text::add_to_layout_box(state, contents, box, std::string_view{": "});
556 if(mod.supply_consumption < 0) {
557 text::add_to_layout_box(state, contents, box, text::fp_percentage{mod.supply_consumption}, text::text_color::green);
558 } else {
559 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::red);
560 text::add_to_layout_box(state, contents, box, text::fp_percentage{mod.supply_consumption}, text::text_color::red);
561 }
562 text::close_layout_box(contents, box);
563 }
564
565 if(is_land) {
566 if(mod.attack_or_gun_power != 0) {
567 auto box = text::open_layout_box(contents, 15);
568 text::localised_format_box(state, contents, box, "attack");
569 text::add_to_layout_box(state, contents, box, std::string_view{": "});
570 if(mod.attack_or_gun_power < 0) {
571 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.attack_or_gun_power}, text::text_color::red);
572 } else {
573 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
574 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.attack_or_gun_power}, text::text_color::green);
575 }
576 text::close_layout_box(contents, box);
577 }
578 if(mod.defence_or_hull != 0) {
579 auto box = text::open_layout_box(contents, 15);
580 text::localised_format_box(state, contents, box, "defence");
581 text::add_to_layout_box(state, contents, box, std::string_view{": "});
582 if(mod.defence_or_hull < 0) {
583 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.defence_or_hull}, text::text_color::red);
584 } else {
585 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
586 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.defence_or_hull}, text::text_color::green);
587 }
588 text::close_layout_box(contents, box);
589 }
590 if(mod.reconnaissance_or_fire_range != 0) {
591 auto box = text::open_layout_box(contents, 15);
592 text::localised_format_box(state, contents, box, "reconaissance");
593 text::add_to_layout_box(state, contents, box, std::string_view{": "});
594 if(mod.reconnaissance_or_fire_range < 0) {
595 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.reconnaissance_or_fire_range},
597 } else {
598 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
599 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.reconnaissance_or_fire_range},
601 }
602 text::close_layout_box(contents, box);
603 }
604 if(mod.siege_or_torpedo_attack != 0) {
605 auto box = text::open_layout_box(contents, 15);
606 text::localised_format_box(state, contents, box, "siege");
607 text::add_to_layout_box(state, contents, box, std::string_view{": "});
608 if(mod.siege_or_torpedo_attack < 0) {
609 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.siege_or_torpedo_attack}, text::text_color::red);
610 } else {
611 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
612 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.siege_or_torpedo_attack},
614 }
615 text::close_layout_box(contents, box);
616 }
617 if(mod.support != 0) {
618 auto box = text::open_layout_box(contents, 15);
619 text::localised_format_box(state, contents, box, "support");
620 text::add_to_layout_box(state, contents, box, std::string_view{": "});
621 if(mod.support < 0) {
623 } else {
624 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
626 }
627 text::close_layout_box(contents, box);
628 }
629 } else {
630 if(mod.attack_or_gun_power != 0) {
631 auto box = text::open_layout_box(contents, 15);
632 text::localised_format_box(state, contents, box, "gun_power");
633 text::add_to_layout_box(state, contents, box, std::string_view{": "});
634 if(mod.attack_or_gun_power < 0) {
635 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.attack_or_gun_power}, text::text_color::red);
636 } else {
637 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
638 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.attack_or_gun_power}, text::text_color::green);
639 }
640 text::close_layout_box(contents, box);
641 }
642 if(mod.defence_or_hull != 0) {
643 auto box = text::open_layout_box(contents, 15);
644 text::localised_format_box(state, contents, box, "hull");
645 text::add_to_layout_box(state, contents, box, std::string_view{": "});
646 if(mod.defence_or_hull < 0) {
647 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.defence_or_hull}, text::text_color::red);
648 } else {
649 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
650 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.defence_or_hull}, text::text_color::green);
651 }
652 text::close_layout_box(contents, box);
653 }
654 if(mod.reconnaissance_or_fire_range != 0) {
655 auto box = text::open_layout_box(contents, 15);
656 text::localised_format_box(state, contents, box, "gun_range");
657 text::add_to_layout_box(state, contents, box, std::string_view{": "});
658 if(mod.reconnaissance_or_fire_range < 0) {
659 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.reconnaissance_or_fire_range},
661 } else {
662 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
663 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.reconnaissance_or_fire_range},
665 }
666 text::close_layout_box(contents, box);
667 }
668 if(mod.siege_or_torpedo_attack != 0) {
669 auto box = text::open_layout_box(contents, 15);
670 text::localised_format_box(state, contents, box, "torpedo_attack");
671 text::add_to_layout_box(state, contents, box, std::string_view{": "});
672 if(mod.siege_or_torpedo_attack < 0) {
673 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.siege_or_torpedo_attack},
675 } else {
676 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
677 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.siege_or_torpedo_attack},
679 }
680 text::close_layout_box(contents, box);
681 }
682 }
683 };
684 for(auto& mod : tech_fat_id.get_modified_units()) {
685 unit_modifier_description(mod);
686 }
687
688 bool an_invention = false;
689
690 state.world.for_each_invention([&](dcon::invention_id id) {
691 auto lim_trigger_k = state.world.invention_get_limit(id);
692 bool activable_by_this_tech = false;
693 trigger::recurse_over_triggers(state.trigger_data.data() + state.trigger_data_indices[lim_trigger_k.index() + 1],
694 [&](uint16_t* tval) {
695 if((tval[0] & trigger::code_mask) == trigger::technology && trigger::payload(tval[1]).tech_id == tech_id)
696 activable_by_this_tech = true;
697 });
698 if(activable_by_this_tech) {
699 if(!an_invention) {
700 auto box = text::open_layout_box(contents);
702 text::localised_format_box(state, contents, box, "be_invent");
703 text::close_layout_box(contents, box);
704
705 an_invention = true;
706 }
707 auto box = text::open_layout_box(contents);
708 text::add_to_layout_box(state, contents, box, state.world.invention_get_name(id), text::text_color::yellow);
709 text::close_layout_box(contents, box);
710 invention_description(state, contents, id, 15);
711 }
712 });
713}
714
716 return parent && parent->parent && static_cast<technology_window*>(parent->parent)->active_tab == category;
717}
718
720 if(parent) {
721 Cyto::Any payload = category;
722 parent->parent->impl_set(state, payload);
723 }
724}
725
727 if(payload.holds_type<dcon::technology_id>()) {
728 tech_id = any_cast<dcon::technology_id>(payload);
729 auto tech = dcon::fatten(state.world, tech_id);
730 category = state.culture_definitions.tech_folders[tech.get_folder_index()].category;
732 } else if(payload.holds_type<culture::tech_category>()) {
733 auto enum_val = any_cast<culture::tech_category>(payload);
734 set_visible(state, category == enum_val);
736 }
738}
739} // namespace ui
void button_action(sys::state &state) noexcept final
bool is_active(sys::state &state) noexcept final
message_result set(sys::state &state, Cyto::Any &payload) noexcept override
tech_category
Definition: culture.hpp:106
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
std::string_view province_building_type_get_name(economy::province_building_type v)
Definition: economy.hpp:57
province_building_type
Definition: constants.hpp:578
void add_line_break_to_layout_box(sys::state &state, layout_base &dest, layout_box &box)
Definition: text.cpp:1147
void add_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, embedded_flag ico)
Definition: text.cpp:1165
layout_box open_layout_box(layout_base &dest, int32_t indent)
Definition: text.cpp:1823
void add_unparsed_text_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view sv, substitution_map const &mp)
Definition: text.cpp:1612
void localised_format_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, text::substitution_map const &sub)
Definition: text.cpp:1904
std::string prettify(int64_t num)
Definition: text.cpp:762
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
Definition: text.cpp:1923
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
Definition: text.cpp:617
std::string format_percentage(float num, size_t digits)
Definition: text.cpp:977
void add_space_to_layout_box(sys::state &state, layout_base &dest, layout_box &box)
Definition: text.cpp:1812
void close_layout_box(columnar_layout &dest, layout_box &box)
Definition: text.cpp:1831
uint16_t * recurse_over_triggers(uint16_t *source, T const &f)
void modifier_description(sys::state &state, text::layout_base &layout, dcon::modifier_id mid, int32_t indentation=0)
void technology_description(sys::state &state, text::layout_base &contents, dcon::technology_id tech_id) noexcept
message_result
void invention_description(sys::state &state, text::layout_base &contents, dcon::invention_id inv_id, int32_t indent) noexcept
uchar uint8_t
Holds important data about the game world, state, and other data regarding windowing,...