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 text::add_to_layout_box(state, contents, box, name);
118 text::add_space_to_layout_box(state, contents, box);
119 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));
120 text::add_to_layout_box(state, contents, box, std::string{":"});
121 text::add_space_to_layout_box(state, contents, box);
122 auto color = mod.amount > 0.f ? text::text_color::green : text::text_color::red;
123 text::add_to_layout_box(state, contents, box, (mod.amount > 0.f ? "+" : "") + text::format_percentage(mod.amount, 1), color);
124 text::close_layout_box(contents, box);
125 }
126 };
127 commodity_mod_description(iid.get_factory_goods_output(), "tech_output", "tech_output");
128 commodity_mod_description(iid.get_rgo_goods_output(), "tech_mine_output", "tech_farm_output");
129 commodity_mod_description(iid.get_factory_goods_throughput(), "tech_throughput", "tech_throughput");
130 commodity_mod_description(iid.get_rgo_size(), "tech_mine_size", "tech_farm_size");
131
132 auto colonial_points = iid.get_colonial_points();
133 if(colonial_points != 0) {
134 auto box = text::open_layout_box(contents, 0);
135 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, "colonial_points_tech"),
137 text::add_to_layout_box(state, contents, box, std::string_view{ ":" }, text::text_color::white);
138 text::add_space_to_layout_box(state, contents, box);
139 auto color = colonial_points > 0.f ? text::text_color::green : text::text_color::red;
140 text::add_to_layout_box(state, contents, box, (colonial_points > 0.f ? "+" : "") + text::prettify(int64_t(colonial_points)),
141 color);
142 text::close_layout_box(contents, box);
143 }
144
145 auto unit_modifier_description = [&](sys::unit_modifier& mod) {
146 bool is_land = true;
147 if(mod.type == state.military_definitions.base_army_unit) {
148 text::add_line(state, contents, "armies", indent);
149 } else if(mod.type == state.military_definitions.base_naval_unit) {
150 text::add_line(state, contents, "navies", indent);
151 is_land = false;
152 } else {
153 auto box = text::open_layout_box(contents, indent);
154 text::add_to_layout_box(state, contents, box, state.military_definitions.unit_base_definitions[mod.type].name);
155 text::close_layout_box(contents, box);
156 is_land = state.military_definitions.unit_base_definitions[mod.type].is_land;
157 }
158
159 if(mod.build_time != 0) {
160 auto box = text::open_layout_box(contents, indent + 15);
161 text::localised_format_box(state, contents, box, "build_time");
162 text::add_to_layout_box(state, contents, box, std::string_view{": "});
163 if(mod.build_time < 0) {
164 text::add_to_layout_box(state, contents, box, int64_t{mod.build_time}, text::text_color::green);
165 } else {
166 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::red);
167 text::add_to_layout_box(state, contents, box, int64_t{mod.build_time}, text::text_color::red);
168 }
169 text::close_layout_box(contents, box);
170 }
171 if(mod.default_organisation != 0) {
172 auto box = text::open_layout_box(contents, indent + 15);
173 text::localised_format_box(state, contents, box, "default_org");
174 text::add_to_layout_box(state, contents, box, std::string_view{": "});
175 if(mod.default_organisation < 0) {
176 text::add_to_layout_box(state, contents, box, int64_t{mod.default_organisation}, text::text_color::red);
177 } else {
178 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
179 text::add_to_layout_box(state, contents, box, int64_t{mod.default_organisation}, text::text_color::green);
180 }
181 text::close_layout_box(contents, box);
182 }
183 if(mod.maximum_speed != 0) {
184 auto box = text::open_layout_box(contents, indent + 15);
185 text::localised_format_box(state, contents, box, "maximum_speed");
186 text::add_to_layout_box(state, contents, box, std::string_view{": "});
187 if(mod.maximum_speed < 0) {
188 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.maximum_speed}, text::text_color::red);
189 } else {
190 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
192 }
193 text::close_layout_box(contents, box);
194 }
195 if(mod.supply_consumption != 0) {
196 auto box = text::open_layout_box(contents, indent + 15);
197 text::localised_format_box(state, contents, box, "supply_consumption");
198 text::add_to_layout_box(state, contents, box, std::string_view{": "});
199 if(mod.supply_consumption < 0) {
200 text::add_to_layout_box(state, contents, box, text::fp_percentage{mod.supply_consumption}, text::text_color::green);
201 } else {
202 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::red);
203 text::add_to_layout_box(state, contents, box, text::fp_percentage{mod.supply_consumption}, text::text_color::red);
204 }
205 text::close_layout_box(contents, box);
206 }
207
208 if(is_land) {
209 if(mod.attack_or_gun_power != 0) {
210 auto box = text::open_layout_box(contents, indent + 15);
211 text::localised_format_box(state, contents, box, "attack");
212 text::add_to_layout_box(state, contents, box, std::string_view{": "});
213 if(mod.attack_or_gun_power < 0) {
214 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.attack_or_gun_power}, text::text_color::red);
215 } else {
216 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
217 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.attack_or_gun_power}, text::text_color::green);
218 }
219 text::close_layout_box(contents, box);
220 }
221 if(mod.defence_or_hull != 0) {
222 auto box = text::open_layout_box(contents, indent + 15);
223 text::localised_format_box(state, contents, box, "defence");
224 text::add_to_layout_box(state, contents, box, std::string_view{": "});
225 if(mod.defence_or_hull < 0) {
226 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.defence_or_hull}, text::text_color::red);
227 } else {
228 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
229 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.defence_or_hull}, text::text_color::green);
230 }
231 text::close_layout_box(contents, box);
232 }
233 if(mod.reconnaissance_or_fire_range != 0) {
234 auto box = text::open_layout_box(contents, indent + 15);
235 text::localised_format_box(state, contents, box, "reconaissance");
236 text::add_to_layout_box(state, contents, box, std::string_view{": "});
237 if(mod.reconnaissance_or_fire_range < 0) {
238 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.reconnaissance_or_fire_range},
240 } else {
241 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
242 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.reconnaissance_or_fire_range},
244 }
245 text::close_layout_box(contents, box);
246 }
247 if(mod.siege_or_torpedo_attack != 0) {
248 auto box = text::open_layout_box(contents, indent + 15);
249 text::localised_format_box(state, contents, box, "siege");
250 text::add_to_layout_box(state, contents, box, std::string_view{": "});
251 if(mod.siege_or_torpedo_attack < 0) {
252 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.siege_or_torpedo_attack}, text::text_color::red);
253 } else {
254 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
255 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.siege_or_torpedo_attack},
257 }
258 text::close_layout_box(contents, box);
259 }
260 if(mod.support != 0) {
261 auto box = text::open_layout_box(contents, indent + 15);
262 text::localised_format_box(state, contents, box, "support");
263 text::add_to_layout_box(state, contents, box, std::string_view{": "});
264 if(mod.support < 0) {
266 } else {
267 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
269 }
270 text::close_layout_box(contents, box);
271 }
272 if(mod.discipline_or_evasion != 0) {
273 auto box = text::open_layout_box(contents, indent + 15);
274 text::localised_format_box(state, contents, box, "discipline");
275 text::add_to_layout_box(state, contents, box, std::string_view{ ": " });
276 if(mod.discipline_or_evasion < 0) {
277 text::add_to_layout_box(state, contents, box, text::fp_two_places{ mod.discipline_or_evasion }, text::text_color::red);
278 } else {
279 text::add_to_layout_box(state, contents, box, std::string_view{ "+" }, text::text_color::green);
280 text::add_to_layout_box(state, contents, box, text::fp_two_places{ mod.discipline_or_evasion }, text::text_color::green);
281 }
282 text::close_layout_box(contents, box);
283 }
284 } else {
285 if(mod.attack_or_gun_power != 0) {
286 auto box = text::open_layout_box(contents, indent + 15);
287 text::localised_format_box(state, contents, box, "gun_power");
288 text::add_to_layout_box(state, contents, box, std::string_view{": "});
289 if(mod.attack_or_gun_power < 0) {
290 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.attack_or_gun_power}, text::text_color::red);
291 } else {
292 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
293 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.attack_or_gun_power}, text::text_color::green);
294 }
295 text::close_layout_box(contents, box);
296 }
297 if(mod.defence_or_hull != 0) {
298 auto box = text::open_layout_box(contents, indent + 15);
299 text::localised_format_box(state, contents, box, "hull");
300 text::add_to_layout_box(state, contents, box, std::string_view{": "});
301 if(mod.defence_or_hull < 0) {
302 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.defence_or_hull}, text::text_color::red);
303 } else {
304 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
305 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.defence_or_hull}, text::text_color::green);
306 }
307 text::close_layout_box(contents, box);
308 }
309 if(mod.reconnaissance_or_fire_range != 0) {
310 auto box = text::open_layout_box(contents, indent + 15);
311 text::localised_format_box(state, contents, box, "gun_range");
312 text::add_to_layout_box(state, contents, box, std::string_view{": "});
313 if(mod.reconnaissance_or_fire_range < 0) {
314 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.reconnaissance_or_fire_range},
316 } else {
317 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
318 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.reconnaissance_or_fire_range},
320 }
321 text::close_layout_box(contents, box);
322 }
323 if(mod.siege_or_torpedo_attack != 0) {
324 auto box = text::open_layout_box(contents, indent + 15);
325 text::localised_format_box(state, contents, box, "torpedo_attack");
326 text::add_to_layout_box(state, contents, box, std::string_view{": "});
327 if(mod.siege_or_torpedo_attack < 0) {
328 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.siege_or_torpedo_attack}, text::text_color::red);
329 } else {
330 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
331 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.siege_or_torpedo_attack},
333 }
334 text::close_layout_box(contents, box);
335 }
336 if(mod.discipline_or_evasion != 0) {
337 auto box = text::open_layout_box(contents, indent + 15);
338 text::localised_format_box(state, contents, box, "evasion");
339 text::add_to_layout_box(state, contents, box, std::string_view{ ": " });
340 if(mod.discipline_or_evasion < 0) {
341 text::add_to_layout_box(state, contents, box, text::fp_two_places{ mod.discipline_or_evasion }, text::text_color::red);
342 } else {
343 text::add_to_layout_box(state, contents, box, std::string_view{ "+" }, text::text_color::green);
344 text::add_to_layout_box(state, contents, box, text::fp_two_places{ mod.discipline_or_evasion }, text::text_color::green);
345 }
346 text::close_layout_box(contents, box);
347 }
348 }
349 };
350 for(auto& mod : iid.get_modified_units()) {
351 unit_modifier_description(mod);
352 }
353
354 for(auto& mod : iid.get_rebel_org()) {
355 if(!mod.type) {
356 auto box = text::open_layout_box(contents, indent);
357 text::localised_format_box(state, contents, box, "tech_rebel_org_gain");
358 text::add_to_layout_box(state, contents, box, std::string_view{": "});
359 if(mod.amount < 0) {
361 } else {
362 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::red);
364 }
365 text::close_layout_box(contents, box);
366 } else {
367 auto box = text::open_layout_box(contents, indent);
368 text::add_to_layout_box(state, contents, box, state.world.rebel_type_get_title(mod.type));
369 text::add_space_to_layout_box(state, contents, box);
370 text::localised_format_box(state, contents, box, "blank_org_gain");
371 text::add_to_layout_box(state, contents, box, std::string_view{": "});
372 if(mod.amount < 0) {
374 } else {
375 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::red);
377 }
378 text::close_layout_box(contents, box);
379 }
380 }
381}
382
383void technology_description(sys::state& state, text::layout_base& contents, dcon::technology_id tech_id) noexcept {
384 auto tech_fat_id = dcon::fatten(state.world, tech_id);
385 auto mod_id = tech_fat_id.get_modifier().id;
386 if(bool(mod_id))
387 modifier_description(state, contents, mod_id);
388
390 auto increase_building = tech_fat_id.get_increase_building(t);
391 if(increase_building) {
392 auto box = text::open_layout_box(contents, 0);
394 text::add_space_to_layout_box(state, contents, box);
396 text::add_to_layout_box(state, contents, box, std::string_view{":"}, text::text_color::white);
397 text::add_space_to_layout_box(state, contents, box);
399 text::close_layout_box(contents, box);
400 }
401 }
402 if(tech_fat_id.get_plurality() != 0) {
403 auto box = text::open_layout_box(contents, 15);
404 text::localised_format_box(state, contents, box, "tech_plurality");
405 text::add_to_layout_box(state, contents, box, std::string_view{ ": " });
406 if(tech_fat_id.get_plurality() < 0) {
407 text::add_to_layout_box(state, contents, box, text::fp_percentage{ tech_fat_id.get_plurality() }, text::text_color::red);
408 } else {
409 text::add_to_layout_box(state, contents, box, std::string_view{ "+" }, text::text_color::green);
410 text::add_to_layout_box(state, contents, box, text::fp_percentage{ tech_fat_id.get_plurality() }, text::text_color::green);
411 }
412 text::close_layout_box(contents, box);
413 }
414 auto activate_unit_description = [&](dcon::unit_type_id id) {
415 if(tech_fat_id.get_activate_unit(id)) {
416 auto unit_type_name = state.military_definitions.unit_base_definitions[id].name;
417
418 auto box = text::open_layout_box(contents, 0);
419 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, "enable_unit_tech"),
421 text::add_space_to_layout_box(state, contents, box);
423 text::close_layout_box(contents, box);
424 }
425 };
426 for(uint8_t unit_type_i = 0; unit_type_i < tech_fat_id.get_activate_unit_size(); ++unit_type_i) {
427 dcon::unit_type_id id(unit_type_i);
428 activate_unit_description(id);
429 }
430
431 auto activate_factory_description = [&](dcon::factory_type_id id) {
432 if(tech_fat_id.get_activate_building(id)) {
433 auto factory_type_fat_id = dcon::fatten(state.world, id);
434
435 auto box = text::open_layout_box(contents, 0);
436 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, "enable_building_tech"),
438 text::add_space_to_layout_box(state, contents, box);
439 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, factory_type_fat_id.get_name()),
441 text::close_layout_box(contents, box);
442
443 box = text::open_layout_box(contents, 0);
444 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, "activate_goods"),
446 text::add_space_to_layout_box(state, contents, box);
447 text::add_to_layout_box(state, contents, box,
448 text::produce_simple_string(state, factory_type_fat_id.get_output().get_name()), text::text_color::yellow);
449 text::close_layout_box(contents, box);
450 }
451 };
452 for(uint8_t building_type_i = 0; building_type_i < tech_fat_id.get_activate_building_size(); ++building_type_i) {
453 dcon::factory_type_id id(building_type_i);
454 activate_factory_description(id);
455 }
456
457 auto commodity_mod_description = [&](auto const& list, std::string_view locale_base_name,
458 std::string_view locale_farm_base_name) {
459 for(const auto mod : list) {
460 auto box = text::open_layout_box(contents, 0);
461 auto name = state.world.commodity_get_name(mod.type);
462 text::add_to_layout_box(state, contents, box, name);
463 text::add_space_to_layout_box(state, contents, box);
464 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));
465 text::add_to_layout_box(state, contents, box, std::string{":"});
466 text::add_space_to_layout_box(state, contents, box);
467 auto color = mod.amount > 0.f ? text::text_color::green : text::text_color::red;
468 text::add_to_layout_box(state, contents, box, (mod.amount > 0.f ? "+" : "") + text::format_percentage(mod.amount, 1),
469 color);
470 text::close_layout_box(contents, box);
471 }
472 };
473 commodity_mod_description(tech_fat_id.get_factory_goods_output(), "tech_output", "tech_output");
474 commodity_mod_description(tech_fat_id.get_rgo_goods_output(), "tech_mine_output", "tech_farm_output");
475 commodity_mod_description(tech_fat_id.get_rgo_size(), "tech_mine_size", "tech_farm_size");
476
477 auto colonial_points = tech_fat_id.get_colonial_points();
478 if(colonial_points != 0) {
479 auto box = text::open_layout_box(contents, 0);
480 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, "colonial_points_tech"),
482 text::add_to_layout_box(state, contents, box, std::string_view{":"}, text::text_color::white);
483 text::add_space_to_layout_box(state, contents, box);
484 auto color = colonial_points > 0.f ? text::text_color::green : text::text_color::red;
485 text::add_to_layout_box(state, contents, box, (colonial_points > 0.f ? "+" : "") + text::prettify(int64_t(colonial_points)),
486 color);
487 text::close_layout_box(contents, box);
488 }
489
490 auto unit_modifier_description = [&](sys::unit_modifier& mod) {
491 bool is_land = true;
492 if(mod.type == state.military_definitions.base_army_unit) {
493 text::add_line(state, contents, "armies");
494 } else if(mod.type == state.military_definitions.base_naval_unit) {
495 text::add_line(state, contents, "navies");
496 is_land = false;
497 } else {
498 auto box = text::open_layout_box(contents);
499 text::add_to_layout_box(state, contents, box, state.military_definitions.unit_base_definitions[mod.type].name);
500 text::close_layout_box(contents, box);
501 is_land = state.military_definitions.unit_base_definitions[mod.type].is_land;
502 }
503
504 if(mod.build_time != 0) {
505 auto box = text::open_layout_box(contents, 15);
506 text::localised_format_box(state, contents, box, "build_time");
507 text::add_to_layout_box(state, contents, box, std::string_view{": "});
508 if(mod.build_time < 0) {
509 text::add_to_layout_box(state, contents, box, int64_t{mod.build_time}, text::text_color::green);
510 } else {
511 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::red);
512 text::add_to_layout_box(state, contents, box, int64_t{mod.build_time}, text::text_color::red);
513 }
514 text::close_layout_box(contents, box);
515 }
516 if(mod.default_organisation != 0) {
517 auto box = text::open_layout_box(contents, 15);
518 text::localised_format_box(state, contents, box, "default_org");
519 text::add_to_layout_box(state, contents, box, std::string_view{": "});
520 if(mod.default_organisation < 0) {
521 text::add_to_layout_box(state, contents, box, int64_t{mod.default_organisation}, text::text_color::red);
522 } else {
523 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
524 text::add_to_layout_box(state, contents, box, int64_t{mod.default_organisation}, text::text_color::green);
525 }
526 text::close_layout_box(contents, box);
527 }
528 if(mod.maximum_speed != 0) {
529 auto box = text::open_layout_box(contents, 15);
530 text::localised_format_box(state, contents, box, "maximum_speed");
531 text::add_to_layout_box(state, contents, box, std::string_view{": "});
532 if(mod.maximum_speed < 0) {
533 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.maximum_speed}, text::text_color::red);
534 } else {
535 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
537 }
538 text::close_layout_box(contents, box);
539 }
540 if(mod.supply_consumption != 0) {
541 auto box = text::open_layout_box(contents, 15);
542 text::localised_format_box(state, contents, box, "supply_consumption");
543 text::add_to_layout_box(state, contents, box, std::string_view{": "});
544 if(mod.supply_consumption < 0) {
545 text::add_to_layout_box(state, contents, box, text::fp_percentage{mod.supply_consumption}, text::text_color::green);
546 } else {
547 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::red);
548 text::add_to_layout_box(state, contents, box, text::fp_percentage{mod.supply_consumption}, text::text_color::red);
549 }
550 text::close_layout_box(contents, box);
551 }
552
553 if(is_land) {
554 if(mod.attack_or_gun_power != 0) {
555 auto box = text::open_layout_box(contents, 15);
556 text::localised_format_box(state, contents, box, "attack");
557 text::add_to_layout_box(state, contents, box, std::string_view{": "});
558 if(mod.attack_or_gun_power < 0) {
559 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.attack_or_gun_power}, text::text_color::red);
560 } else {
561 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
562 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.attack_or_gun_power}, text::text_color::green);
563 }
564 text::close_layout_box(contents, box);
565 }
566 if(mod.defence_or_hull != 0) {
567 auto box = text::open_layout_box(contents, 15);
568 text::localised_format_box(state, contents, box, "defence");
569 text::add_to_layout_box(state, contents, box, std::string_view{": "});
570 if(mod.defence_or_hull < 0) {
571 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.defence_or_hull}, 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.defence_or_hull}, text::text_color::green);
575 }
576 text::close_layout_box(contents, box);
577 }
578 if(mod.reconnaissance_or_fire_range != 0) {
579 auto box = text::open_layout_box(contents, 15);
580 text::localised_format_box(state, contents, box, "reconaissance");
581 text::add_to_layout_box(state, contents, box, std::string_view{": "});
582 if(mod.reconnaissance_or_fire_range < 0) {
583 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.reconnaissance_or_fire_range},
585 } else {
586 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
587 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.reconnaissance_or_fire_range},
589 }
590 text::close_layout_box(contents, box);
591 }
592 if(mod.siege_or_torpedo_attack != 0) {
593 auto box = text::open_layout_box(contents, 15);
594 text::localised_format_box(state, contents, box, "siege");
595 text::add_to_layout_box(state, contents, box, std::string_view{": "});
596 if(mod.siege_or_torpedo_attack < 0) {
597 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.siege_or_torpedo_attack}, text::text_color::red);
598 } else {
599 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
600 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.siege_or_torpedo_attack},
602 }
603 text::close_layout_box(contents, box);
604 }
605 if(mod.support != 0) {
606 auto box = text::open_layout_box(contents, 15);
607 text::localised_format_box(state, contents, box, "support");
608 text::add_to_layout_box(state, contents, box, std::string_view{": "});
609 if(mod.support < 0) {
611 } else {
612 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
614 }
615 text::close_layout_box(contents, box);
616 }
617 } else {
618 if(mod.attack_or_gun_power != 0) {
619 auto box = text::open_layout_box(contents, 15);
620 text::localised_format_box(state, contents, box, "gun_power");
621 text::add_to_layout_box(state, contents, box, std::string_view{": "});
622 if(mod.attack_or_gun_power < 0) {
623 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.attack_or_gun_power}, text::text_color::red);
624 } else {
625 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
626 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.attack_or_gun_power}, text::text_color::green);
627 }
628 text::close_layout_box(contents, box);
629 }
630 if(mod.defence_or_hull != 0) {
631 auto box = text::open_layout_box(contents, 15);
632 text::localised_format_box(state, contents, box, "hull");
633 text::add_to_layout_box(state, contents, box, std::string_view{": "});
634 if(mod.defence_or_hull < 0) {
635 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.defence_or_hull}, 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.defence_or_hull}, text::text_color::green);
639 }
640 text::close_layout_box(contents, box);
641 }
642 if(mod.reconnaissance_or_fire_range != 0) {
643 auto box = text::open_layout_box(contents, 15);
644 text::localised_format_box(state, contents, box, "gun_range");
645 text::add_to_layout_box(state, contents, box, std::string_view{": "});
646 if(mod.reconnaissance_or_fire_range < 0) {
647 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.reconnaissance_or_fire_range},
649 } else {
650 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
651 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.reconnaissance_or_fire_range},
653 }
654 text::close_layout_box(contents, box);
655 }
656 if(mod.siege_or_torpedo_attack != 0) {
657 auto box = text::open_layout_box(contents, 15);
658 text::localised_format_box(state, contents, box, "torpedo_attack");
659 text::add_to_layout_box(state, contents, box, std::string_view{": "});
660 if(mod.siege_or_torpedo_attack < 0) {
661 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.siege_or_torpedo_attack},
663 } else {
664 text::add_to_layout_box(state, contents, box, std::string_view{"+"}, text::text_color::green);
665 text::add_to_layout_box(state, contents, box, text::fp_two_places{mod.siege_or_torpedo_attack},
667 }
668 text::close_layout_box(contents, box);
669 }
670 }
671 };
672 for(auto& mod : tech_fat_id.get_modified_units()) {
673 unit_modifier_description(mod);
674 }
675
676 bool an_invention = false;
677
678 state.world.for_each_invention([&](dcon::invention_id id) {
679 auto lim_trigger_k = state.world.invention_get_limit(id);
680 bool activable_by_this_tech = false;
681 trigger::recurse_over_triggers(state.trigger_data.data() + state.trigger_data_indices[lim_trigger_k.index() + 1],
682 [&](uint16_t* tval) {
683 if((tval[0] & trigger::code_mask) == trigger::technology && trigger::payload(tval[1]).tech_id == tech_id)
684 activable_by_this_tech = true;
685 });
686 if(activable_by_this_tech) {
687 if(!an_invention) {
688 auto box = text::open_layout_box(contents);
690 text::localised_format_box(state, contents, box, "be_invent");
691 text::close_layout_box(contents, box);
692
693 an_invention = true;
694 }
695 auto box = text::open_layout_box(contents);
696 text::add_to_layout_box(state, contents, box, state.world.invention_get_name(id), text::text_color::yellow);
697 text::close_layout_box(contents, box);
698 invention_description(state, contents, id, 15);
699 }
700 });
701}
702
704 return parent && parent->parent && static_cast<technology_window*>(parent->parent)->active_tab == category;
705}
706
708 if(parent) {
709 Cyto::Any payload = category;
710 parent->parent->impl_set(state, payload);
711 }
712}
713
715 if(payload.holds_type<dcon::technology_id>()) {
716 tech_id = any_cast<dcon::technology_id>(payload);
717 auto tech = dcon::fatten(state.world, tech_id);
718 category = state.culture_definitions.tech_folders[tech.get_folder_index()].category;
720 } else if(payload.holds_type<culture::tech_category>()) {
721 auto enum_val = any_cast<culture::tech_category>(payload);
722 set_visible(state, category == enum_val);
724 }
726}
727} // 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:56
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:1799
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:1880
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:1899
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:1788
void close_layout_box(columnar_layout &dest, layout_box &box)
Definition: text.cpp:1807
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