Project Alice
Loading...
Searching...
No Matches
gui_console.cpp
Go to the documentation of this file.
1#include <string>
2#include <string_view>
3#include <variant>
4#include <filesystem>
5#include "gui_console.hpp"
6#include "gui_fps_counter.hpp"
7#include "nations.hpp"
8#include "fif_dcon_generated.hpp"
9#include "fif_common.hpp"
10
11#define STB_IMAGE_WRITE_IMPLEMENTATION 1
12#include "stb_image_write.h"
13
14
15void log_to_console(sys::state& state, ui::element_base* parent, std::string_view s) noexcept {
16 Cyto::Any output = std::string(s);
17 parent->impl_get(state, output);
18}
19
20void ui::console_edit::render(sys::state& state, int32_t x, int32_t y) noexcept {
22}
23
24void ui::console_edit::edit_box_update(sys::state& state, std::string_view s) noexcept {
25}
26
27void ui::console_edit::edit_box_tab(sys::state& state, std::string_view s) noexcept {
28}
29
31 std::string up = up_history();
32 if(!up.empty()) {
33 this->set_text(state, up);
34 auto index = int32_t(up.size());
35 this->edit_index_position(state, index);
36 }
37}
39 std::string down = down_history();
40 if(!down.empty()) {
41 this->set_text(state, down);
42 auto index = int32_t(down.size());
43 this->edit_index_position(state, index);
44 }
45}
46
47template<typename F>
48void write_single_component(sys::state& state, native_string_view filename, F&& func) {
50 auto buffer = std::unique_ptr<uint8_t[]>(new uint8_t[sys::sizeof_scenario_section(state).total_size]);
51 auto buffer_position = func(buffer.get(), state);
52 size_t total_size_used = reinterpret_cast<uint8_t*>(buffer_position) - buffer.get();
53 simple_fs::write_file(sdir, filename, reinterpret_cast<char*>(buffer.get()), uint32_t(total_size_used));
54}
55
56int32_t* f_clear(fif::state_stack& s, int32_t* p, fif::environment* e) {
58 return p + 2;
59
60 auto state_global = fif::get_global_var(*e, "state-ptr");
61 sys::state* state = (sys::state*)(state_global->data);
62
63 if(state->ui_state.console_window) {
64 static_cast<ui::console_window*>(state->ui_state.console_window)->clear_list(*state);
65 }
66
67 return p + 2;
68}
69
70int32_t* f_fps(fif::state_stack& s, int32_t* p, fif::environment* e) {
73 return p + 2;
74 s.pop_main();
75 return p + 2;
76 }
77
78 auto state_global = fif::get_global_var(*e, "state-ptr");
79 sys::state* state = (sys::state*)(state_global->data);
80
81 if(!state->ui_state.fps_counter) {
82 auto fps_counter = ui::make_element_by_type<ui::fps_counter_text_box>(*state, "fps_counter");
83 state->ui_state.fps_counter = fps_counter.get();
84 state->ui_state.root->add_child_to_front(std::move(fps_counter));
85 }
86
87 if(s.main_data_back(0) != 0) {
88 state->ui_state.fps_counter->set_visible(*state, true);
89 state->ui_state.root->move_child_to_front(state->ui_state.fps_counter);
90 } else {
91 state->ui_state.fps_counter->set_visible(*state, false);
92 }
93
94 s.pop_main();
95 return p + 2;
96}
97
98int32_t* f_change_tag(fif::state_stack& s, int32_t* p, fif::environment* e) {
101 return p + 2;
102 s.pop_main();
103 return p + 2;
104 }
105
106 auto state_global = fif::get_global_var(*e, "state-ptr");
107 sys::state* state = (sys::state*)(state_global->data);
108
109 dcon::nation_id to_nation;
110 to_nation.value = dcon::nation_id::value_base_t(s.main_data_back(0));
111 if(to_nation && to_nation != state->local_player_nation && to_nation != state->world.national_identity_get_nation_from_identity_holder(state->national_definitions.rebel_id)) {
112 if(state->local_player_nation)
113 state->world.nation_set_is_player_controlled(state->local_player_nation, false);
114
115 state->local_player_nation = to_nation;
116 state->world.nation_set_is_player_controlled(to_nation, true);
117 ai::remove_ai_data(*state, to_nation);
118 }
119
120 s.pop_main();
121 return p + 2;
122}
123
124int32_t* f_spectate(fif::state_stack& s, int32_t* p, fif::environment* e) {
127 return p + 2;
128 return p + 2;
129 }
130
131 auto state_global = fif::get_global_var(*e, "state-ptr");
132 sys::state* state = (sys::state*)(state_global->data);
133
134 dcon::nation_id to_nation = state->world.national_identity_get_nation_from_identity_holder(state->national_definitions.rebel_id);
135
136 if(state->local_player_nation)
137 state->world.nation_set_is_player_controlled(state->local_player_nation, false);
138
139 state->local_player_nation = to_nation;
140
141 return p + 2;
142}
143
147 return p + 2;
148 s.pop_main();
149 s.pop_main();
150 return p + 2;
151 }
152
153 auto state_global = fif::get_global_var(*e, "state-ptr");
154 sys::state* state = (sys::state*)(state_global->data);
155
156 bool westernize_status = s.main_data_back(0) != 0;
157 s.pop_main();
158
159 dcon::nation_id to_nation;
160 to_nation.value = dcon::nation_id::value_base_t(s.main_data_back(0));
161 s.pop_main();
162
163 if(westernize_status && state->world.nation_get_is_civilized(to_nation) == false)
164 nations::make_civilized(*state, to_nation);
165 else if(!westernize_status && state->world.nation_get_is_civilized(to_nation) == true)
166 nations::make_uncivilized(*state, to_nation);
167
168 return p + 2;
169}
170
171int32_t* f_make_crisis(fif::state_stack& s, int32_t* p, fif::environment* e) {
174 return p + 2;
175 return p + 2;
176 }
177
178 auto state_global = fif::get_global_var(*e, "state-ptr");
179 sys::state* state = (sys::state*)(state_global->data);
180
181 if(state->current_crisis == sys::crisis_type::none) {
182 state->last_crisis_end_date = sys::date{};
185 float max_tension = 0.0f;
186 dcon::state_instance_id max_state;
187 for(auto si : state->world.in_state_instance) {
188 if(si.get_flashpoint_tension() > max_tension && si.get_nation_from_state_ownership().get_is_at_war() == false && si.get_flashpoint_tag().get_nation_from_identity_holder().get_is_at_war() == false) {
189 max_tension = si.get_flashpoint_tension();
190 max_state = si;
191 }
192 }
193 if(!max_state) {
194 for(auto si : state->world.in_state_instance) {
195 if(si.get_flashpoint_tag() && !si.get_nation_from_state_ownership().get_is_great_power() && si.get_nation_from_state_ownership().get_is_at_war() == false && si.get_flashpoint_tag().get_nation_from_identity_holder().get_is_at_war() == false) {
196 max_state = si;
197 break;
198 }
199 }
200 }
201 assert(max_state);
202 state->world.state_instance_set_flashpoint_tension(max_state, 10000.0f / state->defines.crisis_base_chance);
204 }
205
206 return p + 2;
207}
208
209int32_t* f_set_mil(fif::state_stack& s, int32_t* p, fif::environment* e) {
212 return p + 2;
213 s.pop_main();
214 s.pop_main();
215 return p + 2;
216 }
217
218 auto state_global = fif::get_global_var(*e, "state-ptr");
219 sys::state* state = (sys::state*)(state_global->data);
220
221 float mvalue = 0.0f;
222 auto ivalue = s.main_data_back(0);
223 memcpy(&mvalue, &ivalue, 4);
224 s.pop_main();
225
226 dcon::nation_id to_nation;
227 to_nation.value = dcon::nation_id::value_base_t(s.main_data_back(0));
228 s.pop_main();
229
230 for(auto pr : state->world.nation_get_province_ownership(to_nation))
231 for(auto pop : pr.get_province().get_pop_location())
232 pop_demographics::set_militancy(*state, pop.get_pop().id, mvalue);
233
234 return p + 2;
235}
236int32_t* f_set_con(fif::state_stack& s, int32_t* p, fif::environment* e) {
239 return p + 2;
240 s.pop_main();
241 s.pop_main();
242 return p + 2;
243 }
244
245 auto state_global = fif::get_global_var(*e, "state-ptr");
246 sys::state* state = (sys::state*)(state_global->data);
247
248 float mvalue = 0.0f;
249 auto ivalue = s.main_data_back(0);
250 memcpy(&mvalue, &ivalue, 4);
251 s.pop_main();
252
253 dcon::nation_id to_nation;
254 to_nation.value = dcon::nation_id::value_base_t(s.main_data_back(0));
255 s.pop_main();
256
257 for(auto pr : state->world.nation_get_province_ownership(to_nation))
258 for(auto pop : pr.get_province().get_pop_location())
259 pop_demographics::set_consciousness(*state, pop.get_pop().id, mvalue);
260
261 return p + 2;
262}
263
264int32_t* f_make_allied(fif::state_stack& s, int32_t* p, fif::environment* e) {
267 return p + 2;
268 s.pop_main();
269 s.pop_main();
270 return p + 2;
271 }
272
273 auto state_global = fif::get_global_var(*e, "state-ptr");
274 sys::state* state = (sys::state*)(state_global->data);
275
276 dcon::nation_id to_nation;
277 to_nation.value = dcon::nation_id::value_base_t(s.main_data_back(0));
278 s.pop_main();
279
280 dcon::nation_id to_nation_b;
281 to_nation_b.value = dcon::nation_id::value_base_t(s.main_data_back(0));
282 s.pop_main();
283
284 nations::make_alliance(*state, to_nation, to_nation_b);
285
286 return p + 2;
287}
288
289int32_t* f_end_game(fif::state_stack& s, int32_t* p, fif::environment* e) {
292 return p + 2;
293 return p + 2;
294 }
295
296 auto state_global = fif::get_global_var(*e, "state-ptr");
297 sys::state* state = (sys::state*)(state_global->data);
298
300
301 return p + 2;
302}
303
304int32_t* f_dump_oos(fif::state_stack& s, int32_t* p, fif::environment* e) {
307 return p + 2;
308 return p + 2;
309 }
310
311 auto state_global = fif::get_global_var(*e, "state-ptr");
312 sys::state* stateptr = (sys::state*)(state_global->data);
313 sys::state& state = *stateptr;
314
316 state.debug_save_oos_dump();
317 state.debug_scenario_oos_dump();
318 // Extneded data NOT included in normal dumps
319 write_single_component(state, NATIVE("map_data.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
320 ptr_in = sys::memcpy_serialize(ptr_in, state.map_state.map_data.size_x);
321 ptr_in = sys::memcpy_serialize(ptr_in, state.map_state.map_data.size_y);
322 ptr_in = sys::serialize(ptr_in, state.map_state.map_data.river_vertices);
323 ptr_in = sys::serialize(ptr_in, state.map_state.map_data.river_starts);
324 ptr_in = sys::serialize(ptr_in, state.map_state.map_data.river_counts);
325 ptr_in = sys::serialize(ptr_in, state.map_state.map_data.coastal_vertices);
326 ptr_in = sys::serialize(ptr_in, state.map_state.map_data.coastal_starts);
327 ptr_in = sys::serialize(ptr_in, state.map_state.map_data.coastal_counts);
328 ptr_in = sys::serialize(ptr_in, state.map_state.map_data.border_vertices);
329 ptr_in = sys::serialize(ptr_in, state.map_state.map_data.borders);
330 ptr_in = sys::serialize(ptr_in, state.map_state.map_data.terrain_id_map);
331 ptr_in = sys::serialize(ptr_in, state.map_state.map_data.province_id_map);
332 ptr_in = sys::serialize(ptr_in, state.map_state.map_data.province_area);
333 ptr_in = sys::serialize(ptr_in, state.map_state.map_data.diagonal_borders);
334 return ptr_in;
335 });
336 write_single_component(state, NATIVE("defines.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
337 memcpy(ptr_in, &(state.defines), sizeof(parsing::defines));
338 ptr_in += sizeof(parsing::defines);
339 return ptr_in;
340 });
341 write_single_component(state, NATIVE("economy_definitions.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
342 memcpy(ptr_in, &(state.economy_definitions), sizeof(economy::global_economy_state));
343 ptr_in += sizeof(economy::global_economy_state);
344 return ptr_in;
345 });
346 write_single_component(state, NATIVE("party_issues.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
347 ptr_in = sys::serialize(ptr_in, state.culture_definitions.party_issues);
348 return ptr_in;
349 });
350 write_single_component(state, NATIVE("political_issues.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
351 ptr_in = sys::serialize(ptr_in, state.culture_definitions.political_issues);
352 return ptr_in;
353 });
354 write_single_component(state, NATIVE("social_issues.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
355 ptr_in = sys::serialize(ptr_in, state.culture_definitions.social_issues);
356 return ptr_in;
357 });
358 write_single_component(state, NATIVE("military_issues.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
359 ptr_in = sys::serialize(ptr_in, state.culture_definitions.military_issues);
360 return ptr_in;
361 });
362 write_single_component(state, NATIVE("economic_issues.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
363 ptr_in = sys::serialize(ptr_in, state.culture_definitions.economic_issues);
364 return ptr_in;
365 });
366 write_single_component(state, NATIVE("tech_folders.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
367 ptr_in = sys::serialize(ptr_in, state.culture_definitions.tech_folders);
368 return ptr_in;
369 });
370 write_single_component(state, NATIVE("crimes.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
371 ptr_in = sys::serialize(ptr_in, state.culture_definitions.crimes);
372 return ptr_in;
373 });
374 write_single_component(state, NATIVE("culture_definitions.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
375 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.artisans);
376 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.capitalists);
377 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.farmers);
378 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.laborers);
379 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.clergy);
380 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.soldiers);
381 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.officers);
382 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.slaves);
383 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.bureaucrat);
384 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.aristocrat);
385 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.primary_factory_worker);
386 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.secondary_factory_worker);
387 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.officer_leadership_points);
388 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.bureaucrat_tax_efficiency);
389 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.conservative);
390 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.jingoism);
391 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.promotion_chance);
392 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.demotion_chance);
393 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.migration_chance);
394 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.colonialmigration_chance);
395 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.emigration_chance);
396 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.assimilation_chance);
397 ptr_in = sys::memcpy_serialize(ptr_in, state.culture_definitions.conversion_chance);
398 return ptr_in;
399 });
400 write_single_component(state, NATIVE("unit_base_definitions.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
401 ptr_in = sys::serialize(ptr_in, state.military_definitions.unit_base_definitions);
402 return ptr_in;
403 });
404 write_single_component(state, NATIVE("military_definitions.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
405 ptr_in = sys::memcpy_serialize(ptr_in, state.military_definitions.first_background_trait);
406 //ptr_in = sys::serialize(ptr_in, state.military_definitions.unit_base_definitions);
407 ptr_in = sys::memcpy_serialize(ptr_in, state.military_definitions.base_army_unit);
408 ptr_in = sys::memcpy_serialize(ptr_in, state.military_definitions.base_naval_unit);
409 ptr_in = sys::memcpy_serialize(ptr_in, state.military_definitions.standard_civil_war);
410 ptr_in = sys::memcpy_serialize(ptr_in, state.military_definitions.standard_great_war);
411 ptr_in = sys::memcpy_serialize(ptr_in, state.military_definitions.standard_status_quo);
412 ptr_in = sys::memcpy_serialize(ptr_in, state.military_definitions.liberate);
413 ptr_in = sys::memcpy_serialize(ptr_in, state.military_definitions.uninstall_communist_gov);
414 ptr_in = sys::memcpy_serialize(ptr_in, state.military_definitions.crisis_colony);
415 ptr_in = sys::memcpy_serialize(ptr_in, state.military_definitions.crisis_liberate);
416 ptr_in = sys::memcpy_serialize(ptr_in, state.military_definitions.irregular);
417 ptr_in = sys::memcpy_serialize(ptr_in, state.military_definitions.infantry);
418 ptr_in = sys::memcpy_serialize(ptr_in, state.military_definitions.artillery);
419 return ptr_in;
420 });
421 write_single_component(state, NATIVE("national_definitions.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
422 ptr_in = sys::serialize(ptr_in, state.national_definitions.flag_variable_names);
423 ptr_in = sys::serialize(ptr_in, state.national_definitions.global_flag_variable_names);
424 ptr_in = sys::serialize(ptr_in, state.national_definitions.variable_names);
425 ptr_in = sys::serialize(ptr_in, state.national_definitions.triggered_modifiers);
426 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.rebel_id);
427 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.very_easy_player);
428 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.easy_player);
429 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.hard_player);
430 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.very_hard_player);
431 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.very_easy_ai);
432 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.easy_ai);
433 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.hard_ai);
434 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.very_hard_ai);
435 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.overseas);
436 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.coastal);
437 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.non_coastal);
438 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.coastal_sea);
439 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.sea_zone);
440 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.land_province);
441 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.blockaded);
442 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.no_adjacent_controlled);
443 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.core);
444 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.has_siege);
445 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.occupied);
446 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.nationalism);
447 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.infrastructure);
448 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.base_values);
449 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.war);
450 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.peace);
451 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.disarming);
452 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.war_exhaustion);
453 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.badboy);
454 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.debt_default_to);
455 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.bad_debter);
456 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.great_power);
457 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.second_power);
458 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.civ_nation);
459 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.unciv_nation);
460 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.average_literacy);
461 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.plurality);
462 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.generalised_debt_default);
463 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.total_occupation);
464 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.total_blockaded);
465 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.in_bankrupcy);
466 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.num_allocated_national_variables);
467 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.num_allocated_national_flags);
468 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.num_allocated_global_flags);
469 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.flashpoint_focus);
470 ptr_in = sys::memcpy_serialize(ptr_in, state.national_definitions.flashpoint_amount);
471 ptr_in = sys::serialize(ptr_in, state.national_definitions.on_yearly_pulse);
472 ptr_in = sys::serialize(ptr_in, state.national_definitions.on_quarterly_pulse);
473 ptr_in = sys::serialize(ptr_in, state.national_definitions.on_battle_won);
474 ptr_in = sys::serialize(ptr_in, state.national_definitions.on_battle_lost);
475 ptr_in = sys::serialize(ptr_in, state.national_definitions.on_surrender);
476 ptr_in = sys::serialize(ptr_in, state.national_definitions.on_new_great_nation);
477 ptr_in = sys::serialize(ptr_in, state.national_definitions.on_lost_great_nation);
478 ptr_in = sys::serialize(ptr_in, state.national_definitions.on_election_tick);
479 ptr_in = sys::serialize(ptr_in, state.national_definitions.on_colony_to_state);
480 ptr_in = sys::serialize(ptr_in, state.national_definitions.on_state_conquest);
481 ptr_in = sys::serialize(ptr_in, state.national_definitions.on_colony_to_state_free_slaves);
482 ptr_in = sys::serialize(ptr_in, state.national_definitions.on_debtor_default);
483 ptr_in = sys::serialize(ptr_in, state.national_definitions.on_debtor_default_small);
484 ptr_in = sys::serialize(ptr_in, state.national_definitions.on_debtor_default_second);
485 ptr_in = sys::serialize(ptr_in, state.national_definitions.on_civilize);
486 ptr_in = sys::serialize(ptr_in, state.national_definitions.on_my_factories_nationalized);
487 ptr_in = sys::serialize(ptr_in, state.national_definitions.on_crisis_declare_interest);
488 return ptr_in;
489 });
490 write_single_component(state, NATIVE("province_definitions.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
491 ptr_in = sys::serialize(ptr_in, state.province_definitions.canals);
492 ptr_in = sys::serialize(ptr_in, state.province_definitions.terrain_to_gfx_map);
493 ptr_in = sys::memcpy_serialize(ptr_in, state.province_definitions.first_sea_province);
494 ptr_in = sys::memcpy_serialize(ptr_in, state.province_definitions.europe);
495 ptr_in = sys::memcpy_serialize(ptr_in, state.province_definitions.asia);
496 ptr_in = sys::memcpy_serialize(ptr_in, state.province_definitions.africa);
497 ptr_in = sys::memcpy_serialize(ptr_in, state.province_definitions.north_america);
498 ptr_in = sys::memcpy_serialize(ptr_in, state.province_definitions.south_america);
499 ptr_in = sys::memcpy_serialize(ptr_in, state.province_definitions.oceania);
500 return ptr_in;
501 });
502 write_single_component(state, NATIVE("dates.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
503 ptr_in = sys::memcpy_serialize(ptr_in, state.start_date);
504 ptr_in = sys::memcpy_serialize(ptr_in, state.end_date);
505 return ptr_in;
506 });
507 write_single_component(state, NATIVE("trigger_data.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
508 ptr_in = sys::serialize(ptr_in, state.trigger_data);
509 return ptr_in;
510 });
511 write_single_component(state, NATIVE("trigger_data_indices.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
512 ptr_in = sys::serialize(ptr_in, state.trigger_data_indices);
513 return ptr_in;
514 });
515 write_single_component(state, NATIVE("effect_data.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
516 ptr_in = sys::serialize(ptr_in, state.effect_data);
517 return ptr_in;
518 });
519 write_single_component(state, NATIVE("effect_data_indices.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
520 ptr_in = sys::serialize(ptr_in, state.effect_data_indices);
521 return ptr_in;
522 });
523 write_single_component(state, NATIVE("value_modifier_segments.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
524 ptr_in = sys::serialize(ptr_in, state.value_modifier_segments);
525 return ptr_in;
526 });
527 write_single_component(state, NATIVE("value_modifiers.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
528 ptr_in = sys::serialize(ptr_in, state.value_modifiers);
529 return ptr_in;
530 });
531 write_single_component(state, NATIVE("ui_defs_gfx.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
532 ptr_in = sys::serialize(ptr_in, state.ui_defs.gfx);
533 return ptr_in;
534 });
535 write_single_component(state, NATIVE("ui_defs_textures.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
536 ptr_in = sys::serialize(ptr_in, state.ui_defs.textures);
537 return ptr_in;
538 });
539 write_single_component(state, NATIVE("ui_defs_textures.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
540 ptr_in = sys::serialize(ptr_in, state.ui_defs.textures);
541 return ptr_in;
542 });
543 write_single_component(state, NATIVE("ui_defs_gui.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
544 ptr_in = sys::serialize(ptr_in, state.ui_defs.gui);
545 return ptr_in;
546 });
547 write_single_component(state, NATIVE("font_collection_font_names.bin"), [&](uint8_t* ptr_in, sys::state& state) -> uint8_t* {
548 ptr_in = sys::serialize(ptr_in, state.font_collection.font_names);
549 return ptr_in;
550 });
551 log_to_console(state, state.ui_state.console_window, "Check \"My Documents\\Project Alice\\oos\" for the OOS dump");
553
554 return p + 2;
555}
556
560 return p + 2;
561 s.pop_main();
562 return p + 2;
563 }
564
565 auto state_global = fif::get_global_var(*e, "state-ptr");
566 sys::state* state = (sys::state*)(state_global->data);
567
568 bool toggle_state = s.main_data_back(0) != 0;
569 s.pop_main();
570
571 state->cheat_data.always_allow_wargoals = toggle_state;
572 return p + 2;
573}
577 return p + 2;
578 s.pop_main();
579 return p + 2;
580 }
581
582 auto state_global = fif::get_global_var(*e, "state-ptr");
583 sys::state* state = (sys::state*)(state_global->data);
584
585 bool toggle_state = s.main_data_back(0) != 0;
586 s.pop_main();
587
588 state->cheat_data.always_allow_reforms = toggle_state;
589 return p + 2;
590}
591int32_t* f_cheat_deals(fif::state_stack& s, int32_t* p, fif::environment* e) {
594 return p + 2;
595 s.pop_main();
596 return p + 2;
597 }
598
599 auto state_global = fif::get_global_var(*e, "state-ptr");
600 sys::state* state = (sys::state*)(state_global->data);
601
602 bool toggle_state = s.main_data_back(0) != 0;
603 s.pop_main();
604
605 state->cheat_data.always_accept_deals = toggle_state;
606 return p + 2;
607}
611 return p + 2;
612 s.pop_main();
613 return p + 2;
614 }
615
616 auto state_global = fif::get_global_var(*e, "state-ptr");
617 sys::state* state = (sys::state*)(state_global->data);
618
619 bool toggle_state = s.main_data_back(0) != 0;
620 s.pop_main();
621
622 state->cheat_data.always_allow_decisions = toggle_state;
623 return p + 2;
624}
625int32_t* f_daily_oos(fif::state_stack& s, int32_t* p, fif::environment* e) {
628 return p + 2;
629 s.pop_main();
630 return p + 2;
631 }
632
633 auto state_global = fif::get_global_var(*e, "state-ptr");
634 sys::state* state = (sys::state*)(state_global->data);
635
636 bool toggle_state = s.main_data_back(0) != 0;
637 s.pop_main();
638
639 state->cheat_data.daily_oos_check = toggle_state;
640 return p + 2;
641}
645 return p + 2;
646 s.pop_main();
647 return p + 2;
648 }
649
650 auto state_global = fif::get_global_var(*e, "state-ptr");
651 sys::state* state = (sys::state*)(state_global->data);
652
653 bool toggle_state = s.main_data_back(0) != 0;
654 s.pop_main();
655
656 state->cheat_data.always_potential_decisions = toggle_state;
657 return p + 2;
658}
660 if(fif::typechecking_mode(env->mode)) {
662 return p + 2;
663 s.pop_main();
664 return p + 2;
665 }
666
667 auto state_global = fif::get_global_var(*env, "state-ptr");
668 sys::state* state = (sys::state*)(state_global->data);
669
670 bool toggle_state = s.main_data_back(0) != 0;
671 s.pop_main();
672
673 if(toggle_state) {
674 for(const auto e : state->world.in_national_event) {
675 e.set_auto_choice(1);
676 }
677 for(const auto e : state->world.in_free_national_event) {
678 e.set_auto_choice(1);
679 }
680 for(const auto e : state->world.in_provincial_event) {
681 e.set_auto_choice(1);
682 }
683 for(const auto e : state->world.in_free_provincial_event) {
684 e.set_auto_choice(1);
685 }
686 } else {
687 for(const auto e : state->world.in_national_event) {
688 e.set_auto_choice(0);
689 }
690 for(const auto e : state->world.in_free_national_event) {
691 e.set_auto_choice(0);
692 }
693 for(const auto e : state->world.in_provincial_event) {
694 e.set_auto_choice(0);
695 }
696 for(const auto e : state->world.in_free_provincial_event) {
697 e.set_auto_choice(0);
698 }
699 }
700 return p + 2;
701}
705 return p + 2;
706 s.pop_main();
707 return p + 2;
708 }
709
710 auto state_global = fif::get_global_var(*e, "state-ptr");
711 sys::state* state = (sys::state*)(state_global->data);
712
713 dcon::nation_id to_nation;
714 to_nation.value = dcon::nation_id::value_base_t(s.main_data_back(0));
715 s.pop_main();
716
717 for(uint32_t i = state->world.province_building_construction_size(); i-- > 0;) {
718 dcon::province_building_construction_id c{ dcon::province_building_construction_id::value_base_t(i) };
719
720 if(state->world.province_building_construction_get_nation(c) != to_nation)
721 continue;
722
723 auto t = economy::province_building_type(state->world.province_building_construction_get_type(c));
724 auto const& base_cost = state->economy_definitions.building_definitions[int32_t(t)].cost;
725 auto& current_purchased = state->world.province_building_construction_get_purchased_goods(c);
726 for(uint32_t j = 0; j < economy::commodity_set::set_size; ++j)
727 current_purchased.commodity_amounts[j] = base_cost.commodity_amounts[j] * 2.f;
728 }
729
730 return p + 2;
731}
735 return p + 2;
736 s.pop_main();
737 s.pop_main();
738 return p + 2;
739 }
740
741 auto state_global = fif::get_global_var(*e, "state-ptr");
742 sys::state* state = (sys::state*)(state_global->data);
743
744 bool toggle_state = s.main_data_back(0) != 0;
745 s.pop_main();
746
747 dcon::nation_id to_nation;
748 to_nation.value = dcon::nation_id::value_base_t(s.main_data_back(0));
749 s.pop_main();
750
751 auto pos = std::find(
752 state->cheat_data.instant_research_nations.begin(),
753 state->cheat_data.instant_research_nations.end(),
754 to_nation
755 );
756 if(toggle_state && pos == state->cheat_data.instant_research_nations.end()) {
757 state->cheat_data.instant_research_nations.push_back(to_nation);
758 } else if(!toggle_state && pos != state->cheat_data.instant_research_nations.end()) {
759 state->cheat_data.instant_research_nations.erase(pos);
760 }
761
762 return p + 2;
763}
764
765int32_t* f_conquer(fif::state_stack& s, int32_t* p, fif::environment* e) {
768 return p + 2;
769 s.pop_main();
770 s.pop_main();
771 return p + 2;
772 }
773
774 auto state_global = fif::get_global_var(*e, "state-ptr");
775 sys::state* state = (sys::state*)(state_global->data);
776
777 dcon::nation_id to_nation;
778 to_nation.value = dcon::nation_id::value_base_t(s.main_data_back(0));
779 s.pop_main();
780
781 dcon::nation_id to_nation_b;
782 to_nation_b.value = dcon::nation_id::value_base_t(s.main_data_back(0));
783 s.pop_main();
784
785 auto target_owns = state->world.nation_get_province_ownership(to_nation);
786
787 while(target_owns.begin() != target_owns.end()) {
788 auto prov = (*target_owns.begin()).get_province();
789 province::conquer_province(*state, prov, to_nation_b);
790 }
791
792 return p + 2;
793}
794
795int32_t* f_make_core(fif::state_stack& s, int32_t* p, fif::environment* e) {
798 return p + 2;
799 s.pop_main();
800 s.pop_main();
801 return p + 2;
802 }
803
804 auto state_global = fif::get_global_var(*e, "state-ptr");
805 sys::state* state = (sys::state*)(state_global->data);
806
807 dcon::nation_id to_nation;
808 to_nation.value = dcon::nation_id::value_base_t(s.main_data_back(0));
809 s.pop_main();
810
811 dcon::province_id prov;
812 prov.value = dcon::province_id::value_base_t(s.main_data_back(0));
813 s.pop_main();
814
815 province::add_core(*state, prov, state->world.nation_get_identity_from_identity_holder(to_nation));
816
817 return p + 2;
818}
819int32_t* f_remove_core(fif::state_stack& s, int32_t* p, fif::environment* e) {
822 return p + 2;
823 s.pop_main();
824 s.pop_main();
825 return p + 2;
826 }
827
828 auto state_global = fif::get_global_var(*e, "state-ptr");
829 sys::state* state = (sys::state*)(state_global->data);
830
831 dcon::nation_id to_nation;
832 to_nation.value = dcon::nation_id::value_base_t(s.main_data_back(0));
833 s.pop_main();
834
835 dcon::province_id prov;
836 prov.value = dcon::province_id::value_base_t(s.main_data_back(0));
837 s.pop_main();
838
839 province::remove_core(*state, prov, state->world.nation_get_identity_from_identity_holder(to_nation));
840
841 return p + 2;
842}
843int32_t* f_set_owner(fif::state_stack& s, int32_t* p, fif::environment* e) {
846 return p + 2;
847 s.pop_main();
848 s.pop_main();
849 return p + 2;
850 }
851
852 auto state_global = fif::get_global_var(*e, "state-ptr");
853 sys::state* state = (sys::state*)(state_global->data);
854
855 dcon::nation_id to_nation;
856 to_nation.value = dcon::nation_id::value_base_t(s.main_data_back(0));
857 s.pop_main();
858
859 dcon::province_id prov;
860 prov.value = dcon::province_id::value_base_t(s.main_data_back(0));
861 s.pop_main();
862
863 province::conquer_province(*state, prov, to_nation);
864
865 return p + 2;
866}
870 return p + 2;
871 s.pop_main();
872 s.pop_main();
873 return p + 2;
874 }
875
876 auto state_global = fif::get_global_var(*e, "state-ptr");
877 sys::state* state = (sys::state*)(state_global->data);
878
879 dcon::nation_id to_nation;
880 to_nation.value = dcon::nation_id::value_base_t(s.main_data_back(0));
881 s.pop_main();
882
883 dcon::province_id prov;
884 prov.value = dcon::province_id::value_base_t(s.main_data_back(0));
885 s.pop_main();
886
887 province::set_province_controller(*state, prov, to_nation);
888
889 return p + 2;
890}
891int32_t* f_cheat_army(fif::state_stack& s, int32_t* p, fif::environment* e) {
894 return p + 2;
895 s.pop_main();
896 return p + 2;
897 }
898
899 auto state_global = fif::get_global_var(*e, "state-ptr");
900 sys::state* state = (sys::state*)(state_global->data);
901
902 bool toggle_state = s.main_data_back(0) != 0;
903 s.pop_main();
904
905 state->cheat_data.instant_army = toggle_state;
906 return p + 2;
907}
908int32_t* f_cheat_navy(fif::state_stack& s, int32_t* p, fif::environment* e) {
911 return p + 2;
912 s.pop_main();
913 return p + 2;
914 }
915
916 auto state_global = fif::get_global_var(*e, "state-ptr");
917 sys::state* state = (sys::state*)(state_global->data);
918
919 bool toggle_state = s.main_data_back(0) != 0;
920 s.pop_main();
921
922 state->cheat_data.instant_navy = toggle_state;
923 return p + 2;
924}
928 return p + 2;
929 s.pop_main();
930 return p + 2;
931 }
932
933 auto state_global = fif::get_global_var(*e, "state-ptr");
934 sys::state* state = (sys::state*)(state_global->data);
935
936 bool toggle_state = s.main_data_back(0) != 0;
937 s.pop_main();
938
939 state->cheat_data.instant_industry = toggle_state;
940 return p + 2;
941}
942int32_t* f_add_days(fif::state_stack& s, int32_t* p, fif::environment* e) {
945 return p + 2;
946 s.pop_main();
947 return p + 2;
948 }
949
950 auto state_global = fif::get_global_var(*e, "state-ptr");
951 sys::state* state = (sys::state*)(state_global->data);
952
953 auto days = s.main_data_back(0);
954 s.pop_main();
955
956 state->current_date += int32_t(days);
957 return p + 2;
958}
959int32_t* f_save_map(fif::state_stack& s, int32_t* ptr, fif::environment* e) {
962 return ptr + 2;
963 s.pop_main();
964 return ptr + 2;
965 }
966
967 auto state_global = fif::get_global_var(*e, "state-ptr");
968 sys::state* state = (sys::state*)(state_global->data);
969
970 auto type = s.main_data_back(0);
971 s.pop_main();
972
973 bool opt_sea_lines = true;
974 bool opt_province_lines = true;
975 bool opt_blend = true;
976
977 if(type == 0) {
978 opt_sea_lines = false;
979 opt_province_lines = false;
980 } else if(type ==1) {
981 opt_blend = false;
982 } else if(type == 2) {
983 opt_sea_lines = false;
984 } else if(type == 3) {
985 opt_sea_lines = false;
986 opt_blend = false;
987 } else if(type == 4) {
988 opt_sea_lines = false;
989 opt_province_lines = false;
990 opt_blend = false;
991 }
992
993 auto total_px = state->map_state.map_data.size_x * state->map_state.map_data.size_y;
994 auto buffer = std::unique_ptr<uint8_t[]>(new uint8_t[total_px * 3]);
995 auto blend_fn = [&](uint32_t idx, bool sea_a, bool sea_b, dcon::province_id pa, dcon::province_id pb) {
996 if(sea_a != sea_b) {
997 buffer[idx * 3 + 0] = 0;
998 buffer[idx * 3 + 1] = 0;
999 buffer[idx * 3 + 2] = 0;
1000 }
1001 if(pa != pb) {
1002 if(((sea_a || sea_b) && opt_sea_lines)
1003 || sea_a != sea_b
1004 || (opt_province_lines && !sea_a && !sea_b)) {
1005 if(opt_blend) {
1006 buffer[idx * 3 + 0] &= 0x7f;
1007 buffer[idx * 3 + 1] &= 0x7f;
1008 buffer[idx * 3 + 2] &= 0x7f;
1009 } else {
1010 buffer[idx * 3 + 0] = 0;
1011 buffer[idx * 3 + 1] = 0;
1012 buffer[idx * 3 + 2] = 0;
1013 }
1014 }
1015 }
1016 };
1017 for(uint32_t y = 0; y < uint32_t(state->map_state.map_data.size_y); y++) {
1018 for(uint32_t x = 0; x < uint32_t(state->map_state.map_data.size_x); x++) {
1019 auto idx = y * uint32_t(state->map_state.map_data.size_x) + x;
1020 auto p = province::from_map_id(state->map_state.map_data.province_id_map[idx]);
1021 bool p_is_sea = state->map_state.map_data.province_id_map[idx] >= province::to_map_id(state->province_definitions.first_sea_province);
1022 if(p_is_sea) {
1023 buffer[idx * 3 + 0] = 128;
1024 buffer[idx * 3 + 1] = 128;
1025 buffer[idx * 3 + 2] = 255;
1026 } else {
1027 auto owner = state->world.province_get_nation_from_province_ownership(p);
1028 if(owner) {
1029 auto owner_color = state->world.nation_get_color(owner);
1030 buffer[idx * 3 + 0] = uint8_t(owner_color & 0xff);
1031 buffer[idx * 3 + 1] = uint8_t((owner_color >> 8) & 0xff) & 0xff;
1032 buffer[idx * 3 + 2] = uint8_t((owner_color >> 16) & 0xff) & 0xff;
1033 } else {
1034 buffer[idx * 3 + 0] = 170;
1035 buffer[idx * 3 + 1] = 170;
1036 buffer[idx * 3 + 2] = 170;
1037 }
1038 }
1039 if(x < uint32_t(state->map_state.map_data.size_x - 1)) {
1040 auto br_idx = idx + uint32_t(state->map_state.map_data.size_x);
1041 if(br_idx < total_px) {
1042 auto br_p = province::from_map_id(state->map_state.map_data.province_id_map[br_idx]);
1043 bool br_is_sea = state->map_state.map_data.province_id_map[br_idx] >= province::to_map_id(state->province_definitions.first_sea_province);
1044 blend_fn(idx, br_is_sea, p_is_sea, br_p, p);
1045 }
1046 auto rs_idx = idx + 1;
1047 if(rs_idx < total_px) {
1048 auto br_p = province::from_map_id(state->map_state.map_data.province_id_map[rs_idx]);
1049 bool br_is_sea = state->map_state.map_data.province_id_map[rs_idx] >= province::to_map_id(state->province_definitions.first_sea_province);
1050 blend_fn(idx, br_is_sea, p_is_sea, br_p, p);
1051 }
1052 }
1053 }
1054 }
1055 stbi_flip_vertically_on_write(true);
1056 auto func = [](void*, void* ptr_in, int size) -> void {
1058 simple_fs::write_file(sdir, NATIVE("map.png"), static_cast<const char*>(ptr_in), uint32_t(size));
1059 };
1060 stbi_write_png_to_func(func, nullptr, int(state->map_state.map_data.size_x), int(state->map_state.map_data.size_y), 3, buffer.get(), 0);
1061
1062 return ptr + 2;
1063}
1064int32_t* f_dump_econ(fif::state_stack& s, int32_t* p, fif::environment* e) {
1067 return p + 2;
1068 return p + 2;
1069 }
1070
1071 auto state_global = fif::get_global_var(*e, "state-ptr");
1072 sys::state* state = (sys::state*)(state_global->data);
1073
1074 if(state->cheat_data.ecodump) {
1075 state->cheat_data.ecodump = false;
1076 } else {
1077 state->cheat_data.ecodump = true;
1078
1079 state->world.for_each_commodity([&](dcon::commodity_id c) {
1080 state->cheat_data.prices_dump_buffer += text::produce_simple_string(*state, state->world.commodity_get_name(c)) + ",";
1081 state->cheat_data.demand_dump_buffer += text::produce_simple_string(*state, state->world.commodity_get_name(c)) + ",";
1082 state->cheat_data.supply_dump_buffer += text::produce_simple_string(*state, state->world.commodity_get_name(c)) + ",";
1083 });
1084
1085 state->cheat_data.prices_dump_buffer += "\n";
1086 state->cheat_data.demand_dump_buffer += "\n";
1087 state->cheat_data.supply_dump_buffer += "\n";
1088 }
1089 log_to_console(*state, state->ui_state.console_window, state->cheat_data.ecodump ? "✔" : "✘");
1090
1091 return p + 2;
1092}
1093int32_t* f_fire_event(fif::state_stack& s, int32_t* p, fif::environment* e) {
1096 return p + 2;
1097 s.pop_main();
1098 s.pop_main();
1099 return p + 2;
1100 }
1101
1102 auto state_global = fif::get_global_var(*e, "state-ptr");
1103 sys::state* state = (sys::state*)(state_global->data);
1104
1105 auto id = int32_t(s.main_data_back(0));
1106 s.pop_main();
1107
1108 dcon::nation_id to_nation_b;
1109 to_nation_b.value = dcon::nation_id::value_base_t(s.main_data_back(0));
1110 s.pop_main();
1111
1112 dcon::free_national_event_id ev;
1113 for(auto v : state->world.in_free_national_event) {
1114 if(v.get_legacy_id() == uint32_t(id)) {
1115 ev = v;
1116 break;
1117 }
1118 }
1119 if(!ev) {
1120 e->report_error("no free national event found with that id");
1122 } else {
1123 event::trigger_national_event(*state, ev, to_nation_b, state->current_date.value, id ^ to_nation_b.index());
1124 }
1125
1126 return p + 2;
1127}
1129 auto state_global = fif::get_global_var(*e, "state-ptr");
1130 sys::state* state = (sys::state*)(state_global->data);
1131
1134 return p + 2;
1135 s.pop_main();
1136 s.push_back_main(state->type_text_key, 0, nullptr);
1137 return p + 2;
1138 }
1139
1140
1141
1142 dcon::nation_id to_nation_b;
1143 to_nation_b.value = dcon::nation_id::value_base_t(s.main_data_back(0));
1144 s.pop_main();
1145
1146 auto name = text::get_name(*state, to_nation_b);
1147
1148 s.push_back_main(state->type_text_key, int64_t(name.value), nullptr);
1149
1150 return p + 2;
1151}
1152
1153
1154inline int32_t* compile_modifier(fif::state_stack& s, int32_t* p, fif::environment* e) {
1157 s.pop_main();
1158 }
1159 return p + 2;
1160 }
1162 e->report_error("attempted to compile a definition inside a definition");
1164 return p + 2;
1165 }
1166
1167 auto state_global = fif::get_global_var(*e, "state-ptr");
1168 sys::state* state = (sys::state*)(state_global->data);
1169
1170 auto index = s.main_data_back(0);
1171 s.pop_main();
1172
1173 dcon::value_modifier_key mkey{ dcon::value_modifier_key::value_base_t(index) };
1174 std::string body = "" + fif_trigger::multiplicative_modifier(*state, mkey) + " drop drop r> ";
1175 std::string name_str = "ttest";
1176
1177 e->dict.words.insert_or_assign(name_str, int32_t(e->dict.word_array.size()));
1178 e->dict.word_array.emplace_back();
1179 e->dict.word_array.back().source = body;
1180
1181 return p + 2;
1182}
1183
1184inline int32_t* load_file(fif::state_stack& s, int32_t* p, fif::environment* e) {
1187 s.pop_main();
1188 }
1189 return p + 2;
1190 }
1192 e->report_error("attempted to load a file inside a definition");
1194 return p + 2;
1195 }
1196
1197 auto name_token = fif::read_token(e->source_stack.back(), *e);
1198
1200 auto file = simple_fs::open_file(dir, simple_fs::utf8_to_native(name_token.content));
1201 if(file) {
1202 auto content = simple_fs::view_contents(*file);
1203 fif::interpreter_stack values{ };
1204 fif::run_fif_interpreter(*e, std::string_view{content.data, content.file_size}, values);
1205
1206 } else {
1208 e->report_error("could not open file");
1209 return p + 2;
1210 }
1211 return p + 2;
1212}
1213
1214
1216 if(state.fif_environment)
1217 return;
1218
1219 std::lock_guard lg{ state.lock_console_strings };
1220
1221 state.fif_environment = std::make_unique<fif::environment>();
1222
1223 int32_t error_count = 0;
1224 std::string error_list;
1225 state.fif_environment->report_error = [&](std::string_view s) {
1226 state.console_command_error += std::string("?R ERROR: ") + std::string(s) + "?W\\n";
1227 };
1228
1229 fif::common_fif_environment(state, *state.fif_environment);
1230
1231 fif::interpreter_stack values{ };
1232
1233 fif::run_fif_interpreter(*state.fif_environment,
1234 " :struct localized i32 value ; "
1235 " :s localize text_key s: >index make localized .value! ; ",
1236 values);
1237
1238
1239 state.type_text_key = state.fif_environment->dict.types.find("text_key")->second;
1240 state.type_localized_key = state.fif_environment->dict.types.find("localized")->second;
1241
1242 //
1243 // Add predefined names and tags
1244 //
1245 auto return_to_string = [&](dcon::text_key k) {
1246 std::string rvalue{state.to_string_view(k) };
1247 for(auto& c : rvalue) {
1248 if(uint8_t(c) == 127)
1249 c = '_';
1250 }
1251 return rvalue;
1252 };
1253 for(auto n : state.world.in_national_identity) {
1254 auto tag_str = nations::int_to_tag(n.get_identifying_int());
1255 fif::run_fif_interpreter(*state.fif_environment,
1256 std::string(" : ") + tag_str + " " + std::to_string(n.id.index()) + " >national_identity_id identity_holder-identity nation @ ; ",
1257 values);
1258 state.fif_environment->mode = fif::fif_mode::interpreting;
1259 }
1260 for(auto r : state.world.in_religion) {
1261 fif::run_fif_interpreter(*state.fif_environment,
1262 std::string(" : ") + return_to_string(r.get_name()) + " " + std::to_string(r.id.index()) + " >religion_id ; ",
1263 values);
1264 state.fif_environment->mode = fif::fif_mode::interpreting;
1265 }
1266 for(auto r : state.world.in_culture) {
1267 fif::run_fif_interpreter(*state.fif_environment,
1268 std::string(" : ") + return_to_string(r.get_name()) + " " + std::to_string(r.id.index()) + " >culture_id ; ",
1269 values);
1270 state.fif_environment->mode = fif::fif_mode::interpreting;
1271 }
1272 for(auto r : state.world.in_commodity) {
1273 fif::run_fif_interpreter(*state.fif_environment,
1274 std::string(" : ") + return_to_string(r.get_name()) + " " + std::to_string(r.id.index()) + " >commodity_id ; ",
1275 values);
1276 state.fif_environment->mode = fif::fif_mode::interpreting;
1277 }
1278 for(auto r : state.world.in_ideology) {
1279 fif::run_fif_interpreter(*state.fif_environment,
1280 std::string(" : ") + return_to_string(r.get_name()) + " " + std::to_string(r.id.index()) + " >ideology_id ; ",
1281 values);
1282 state.fif_environment->mode = fif::fif_mode::interpreting;
1283 }
1284 for(auto r : state.world.in_issue) {
1285 fif::run_fif_interpreter(*state.fif_environment,
1286 std::string(" : ") + return_to_string(r.get_name()) + " " + std::to_string(r.id.index()) + " >issue_id ; ",
1287 values);
1288 state.fif_environment->mode = fif::fif_mode::interpreting;
1289 }
1290 for(auto r : state.world.in_issue_option) {
1291 fif::run_fif_interpreter(*state.fif_environment,
1292 std::string(" : ") + return_to_string(r.get_name()) + " " + std::to_string(r.id.index()) + " >issue_option_id ; ",
1293 values);
1294 state.fif_environment->mode = fif::fif_mode::interpreting;
1295 }
1296 for(auto r : state.world.in_reform) {
1297 fif::run_fif_interpreter(*state.fif_environment,
1298 std::string(" : ") + return_to_string(r.get_name()) + " " + std::to_string(r.id.index()) + " >reform_id ; ",
1299 values);
1300 state.fif_environment->mode = fif::fif_mode::interpreting;
1301 }
1302 for(auto r : state.world.in_reform_option) {
1303 fif::run_fif_interpreter(*state.fif_environment,
1304 std::string(" : ") + return_to_string(r.get_name()) + " " + std::to_string(r.id.index()) + " >reform_option_id ; ",
1305 values);
1306 state.fif_environment->mode = fif::fif_mode::interpreting;
1307 }
1308 for(auto r : state.world.in_cb_type) {
1309 fif::run_fif_interpreter(*state.fif_environment,
1310 std::string(" : ") + return_to_string(r.get_name()) + " " + std::to_string(r.id.index()) + " >cb_type_id ; ",
1311 values);
1312 state.fif_environment->mode = fif::fif_mode::interpreting;
1313 }
1314 for(auto r : state.world.in_pop_type) {
1315 fif::run_fif_interpreter(*state.fif_environment,
1316 std::string(" : ") + return_to_string(r.get_name()) + " " + std::to_string(r.id.index()) + " >pop_type_id ; ",
1317 values);
1318 state.fif_environment->mode = fif::fif_mode::interpreting;
1319 }
1320 for(auto r : state.world.in_rebel_type) {
1321 fif::run_fif_interpreter(*state.fif_environment,
1322 std::string(" : ") + return_to_string(r.get_name()) + " " + std::to_string(r.id.index()) + " >rebel_type_id ; ",
1323 values);
1324 state.fif_environment->mode = fif::fif_mode::interpreting;
1325 }
1326 for(auto r : state.world.in_government_type) {
1327 fif::run_fif_interpreter(*state.fif_environment,
1328 std::string(" : ") + return_to_string(r.get_name()) + " " + std::to_string(r.id.index()) + " >government_type_id ; ",
1329 values);
1330 state.fif_environment->mode = fif::fif_mode::interpreting;
1331 }
1332 for(auto r : state.world.in_province) {
1333 fif::run_fif_interpreter(*state.fif_environment,
1334 std::string(" : ") + return_to_string(r.get_name()) + " " + std::to_string(r.id.index()) + " >province_id ; ",
1335 values);
1336 state.fif_environment->mode = fif::fif_mode::interpreting;
1337 }
1338 for(auto r : state.world.in_state_definition) {
1339 fif::run_fif_interpreter(*state.fif_environment,
1340 std::string(" : ") + return_to_string(r.get_name()) + " " + std::to_string(r.id.index()) + " >state_definition_id ; ",
1341 values);
1342 state.fif_environment->mode = fif::fif_mode::interpreting;
1343 }
1344 for(auto r : state.world.in_technology) {
1345 fif::run_fif_interpreter(*state.fif_environment,
1346 std::string(" : ") + return_to_string(r.get_name()) + " " + std::to_string(r.id.index()) + " >technology_id ; ",
1347 values);
1348 state.fif_environment->mode = fif::fif_mode::interpreting;
1349 }
1350 for(auto r : state.world.in_invention) {
1351 fif::run_fif_interpreter(*state.fif_environment,
1352 std::string(" : ") + return_to_string(r.get_name()) + " " + std::to_string(r.id.index()) + " >invention_id ; ",
1353 values);
1354 state.fif_environment->mode = fif::fif_mode::interpreting;
1355 }
1356
1357 //
1358 // Add console commands here
1359 //
1360
1361 auto nation_id_type = state.fif_environment->dict.types.find("nation_id")->second;
1362 auto prov_id_type = state.fif_environment->dict.types.find("province_id")->second;
1363
1364 fif::add_import("clear", nullptr, f_clear, {}, {}, * state.fif_environment);
1365 fif::add_import("fps", nullptr, f_fps, { fif::fif_bool }, {}, * state.fif_environment);
1366 fif::add_import("change-tag", nullptr, f_change_tag, { nation_id_type }, {}, *state.fif_environment);
1367 fif::add_import("set-westernized", nullptr, f_set_westernized, { nation_id_type, fif::fif_bool }, {}, * state.fif_environment);
1368 fif::add_import("make-crisis", nullptr, f_make_crisis, { }, {}, * state.fif_environment);
1369 fif::add_import("end-game", nullptr, f_end_game, { }, {}, * state.fif_environment);
1370 fif::add_import("set-mil", nullptr, f_set_mil, { nation_id_type, fif::fif_f32 }, {}, * state.fif_environment);
1371 fif::add_import("set-con", nullptr, f_set_con, { nation_id_type, fif::fif_f32 }, {}, * state.fif_environment);
1372 fif::add_import("make-allied", nullptr, f_make_allied, { nation_id_type, nation_id_type }, {}, * state.fif_environment);
1373 fif::add_import("dump-oos", nullptr, f_dump_oos, { }, {}, * state.fif_environment);
1374 fif::add_import("cheat-wargoals", nullptr, f_cheat_wargoals, { fif::fif_bool }, {}, *state.fif_environment);
1375 fif::add_import("cheat-reforms", nullptr, f_cheat_reforms, { fif::fif_bool }, {}, * state.fif_environment);
1376 fif::add_import("cheat-diplomacy", nullptr, f_cheat_deals, { fif::fif_bool }, {}, * state.fif_environment);
1377 fif::add_import("cheat-decisions", nullptr, f_cheat_decisions, { fif::fif_bool }, {}, * state.fif_environment);
1378 fif::add_import("cheat-decision-potential", nullptr, f_cheat_decision_potential, { fif::fif_bool }, {}, * state.fif_environment);
1379 fif::add_import("cheat-army", nullptr, f_cheat_army, { fif::fif_bool }, {}, * state.fif_environment);
1380 fif::add_import("cheat-navy", nullptr, f_cheat_navy, { fif::fif_bool }, {}, * state.fif_environment);
1381 fif::add_import("cheat-factories", nullptr, f_cheat_factories, { fif::fif_bool }, {}, * state.fif_environment);
1382 fif::add_import("daily-oos-check", nullptr, f_daily_oos, { fif::fif_bool }, {}, * state.fif_environment);
1383 fif::add_import("set-auto-choice", nullptr, f_set_auto_choice, { fif::fif_bool }, {}, *state.fif_environment);
1384 fif::add_import("complete-construction", nullptr, f_complete_construction, { nation_id_type }, {}, * state.fif_environment);
1385 fif::add_import("instant-research", nullptr, f_instant_research, { nation_id_type, fif::fif_bool }, {}, * state.fif_environment);
1386 fif::add_import("spectate", nullptr, f_spectate, { }, {}, *state.fif_environment);
1387 fif::add_import("conquer", nullptr, f_conquer, { nation_id_type , nation_id_type }, {}, * state.fif_environment);
1388 fif::add_import("make-core", nullptr, f_make_core, { prov_id_type , nation_id_type }, {}, * state.fif_environment);
1389 fif::add_import("remove-core", nullptr, f_remove_core, { prov_id_type , nation_id_type }, {}, * state.fif_environment);
1390 fif::add_import("set-owner", nullptr, f_set_owner, { prov_id_type , nation_id_type }, {}, * state.fif_environment);
1391 fif::add_import("set-controller", nullptr, f_set_controller, { prov_id_type , nation_id_type }, {}, * state.fif_environment);
1392 fif::add_import("add-days", nullptr, f_add_days, { fif::fif_i32 }, {}, * state.fif_environment);
1393 fif::add_import("save-map", nullptr, f_save_map, { fif::fif_i32 }, {}, * state.fif_environment);
1394 fif::add_import("dump-econ", nullptr, f_dump_econ, { }, {}, * state.fif_environment);
1395 fif::add_import("fire-event", nullptr, f_fire_event, { nation_id_type, fif::fif_i32 }, {}, * state.fif_environment);
1396 fif::add_import("nation-name", nullptr, f_nation_name, { nation_id_type }, { state.type_text_key }, *state.fif_environment);
1397 fif::add_import("load-file", nullptr, load_file, {}, {}, * state.fif_environment);
1398
1399 fif::add_import("compile-mod", nullptr, compile_modifier, { fif::fif_i32 }, { }, * state.fif_environment);
1400
1401 fif::run_fif_interpreter(*state.fif_environment,
1402 " : no-sea-line 0 ; : no-blend 1 ; : no-sea-line-2 2 ; : blend-no-sea 3 ; : vanilla 4 ; ",
1403 values);
1404 fif::run_fif_interpreter(*state.fif_environment,
1405 " :s name nation_id s: nation-name ; ",
1406 values);
1407
1408 fif::run_fif_interpreter(*state.fif_environment,
1409 " : player " + std::to_string(offsetof(sys::state, local_player_nation)) + " state-ptr @ buf-add ptr-cast ptr(nation_id) ; ",
1410 values);
1411
1412 assert(state.fif_environment->mode != fif::fif_mode::error);
1413}
1414
1415std::string ui::format_fif_value(sys::state& state, int64_t data, int32_t type) {
1416 if(type == fif::fif_i8 || type == fif::fif_i16 || type == fif::fif_i32 || type == fif::fif_i64) {
1417 return std::to_string(data);
1418 } else if(type == fif::fif_u8 || type == fif::fif_u16 || type == fif::fif_u32 || type == fif::fif_u64) {
1419 return std::to_string(uint64_t(data));
1420 } else if(type == fif::fif_f32) {
1421 float v = 0;
1422 memcpy(&v, &data, 4);
1423 return std::to_string(v);
1424 } else if(type == fif::fif_f64) {
1425 double v = 0;
1426 memcpy(&v, &data, 8);
1427 return std::to_string(v);
1428 } else if(type == fif::fif_bool) {
1429 if(data != 0)
1430 return "true";
1431 return "false";
1432 } else if(type == fif::fif_opaque_ptr) {
1433 return "#ptr(nil)";
1434 } else if(type == state.type_text_key) {
1435 dcon::text_key k;
1436 k.value = dcon::text_key::value_base_t(data);
1437 return std::string("\"") + std::string(state.to_string_view(k)) + "\"";
1438 } else if(type == state.type_localized_key) {
1439 uint32_t localized_index = uint32_t(data);
1440 dcon::text_key k{ localized_index };
1441 if(!k)
1442 return "\"\"";
1443
1444 std::string_view sv;
1445 if(auto it = state.locale_key_to_text_sequence.find(k); it != state.locale_key_to_text_sequence.end()) {
1446 return std::string("\"") + std::string{ state.locale_string_view(it->second) } + "\"";
1447 } else {
1448 return std::string("\"") + std::string{ state.to_string_view(k) } + "\"";
1449 }
1450 } else if(type == -1) {
1451 return "#nil";
1452 } else if(type == fif::fif_type) {
1453 return "#type";
1454 } else {
1455 if(state.fif_environment->dict.type_array[type].decomposed_types_count >= 2) {
1456 auto main_type = state.fif_environment->dict.all_stack_types[state.fif_environment->dict.type_array[type].decomposed_types_start];
1457 if(main_type == fif::fif_ptr) {
1458 return std::string("#ptr");
1459 } else {
1460 return std::string("#struct");
1461 }
1462 } else {
1463 return "#unknown";
1464 }
1465 }
1466}
1467
1468void ui::console_edit::edit_box_enter(sys::state& state, std::string_view s) noexcept {
1469 if(s.empty()) {
1470 edit_box_update(state, s);
1471 return;
1472 }
1473
1474 if(state.ui_state.shift_held_down) {
1475 log_to_console(state, parent, s);
1476
1477 std::lock_guard lg{ state.lock_console_strings };
1478 state.console_command_pending += s;
1479 state.console_command_pending += " ";
1480 } else {
1481 log_to_console(state, parent, s);
1482
1483 std::lock_guard lg{ state.lock_console_strings };
1484 state.console_command_pending += s;
1485 add_to_history(state, state.console_command_pending);
1487 }
1488 edit_box_update(state, s);
1489 return;
1490}
1491
1494}
1497}
1500}
1501
1503 assert(state.ui_state.console_window);
1504 if(state.ui_state.console_window->is_visible()) { //close
1505 sound::play_interface_sound(state, sound::get_console_close_sound(state), state.user_settings.master_volume * state.user_settings.interface_volume);
1506 } else { //open
1507 sound::play_interface_sound(state, sound::get_console_open_sound(state), state.user_settings.master_volume * state.user_settings.interface_volume);
1508 }
1509
1511 if(state.ui_state.console_window->is_visible())
1512 state.ui_state.root->move_child_to_front(state.ui_state.console_window);
1513}
std::vector< word > word_array
Definition: fif.hpp:506
ankerl::unordered_dense::map< std::string, int32_t > words
Definition: fif.hpp:504
std::function< void(std::string_view)> report_error
Definition: fif.hpp:768
std::vector< std::string_view > source_stack
Definition: fif.hpp:765
fif_mode mode
Definition: fif.hpp:767
dictionary dict
Definition: fif.hpp:762
virtual int64_t main_data_back(size_t index) const =0
virtual void pop_main()=0
virtual void push_back_main(int32_t type, int64_t data, LLVMValueRef expr)=0
void edit_box_update(sys::state &state, std::string_view s) noexcept override
Definition: gui_console.cpp:24
void edit_box_tab(sys::state &state, std::string_view s) noexcept override
Definition: gui_console.cpp:27
void edit_box_enter(sys::state &state, std::string_view s) noexcept override
void edit_box_down(sys::state &state) noexcept override
Definition: gui_console.cpp:38
void edit_box_up(sys::state &state) noexcept override
Definition: gui_console.cpp:30
void edit_box_back_slash(sys::state &state) noexcept override
void edit_box_esc(sys::state &state) noexcept override
void edit_box_backtick(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
Definition: gui_console.cpp:20
static void show_toggle(sys::state &state)
void render(sys::state &state, int32_t x, int32_t y) noexcept override
bool is_visible() const
void set_visible(sys::state &state, bool vis)
#define assert(condition)
Definition: debug.h:74
int32_t * f_cheat_factories(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_cheat_deals(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_set_controller(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * load_file(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_end_game(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_conquer(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_clear(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: gui_console.cpp:56
int32_t * f_spectate(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_fire_event(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_add_days(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_make_allied(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_change_tag(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: gui_console.cpp:98
int32_t * f_set_owner(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_dump_oos(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_cheat_navy(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_cheat_decisions(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_dump_econ(fif::state_stack &s, int32_t *p, fif::environment *e)
void write_single_component(sys::state &state, native_string_view filename, F &&func)
Definition: gui_console.cpp:48
int32_t * f_set_westernized(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_make_core(fif::state_stack &s, int32_t *p, fif::environment *e)
void log_to_console(sys::state &state, ui::element_base *parent, std::string_view s) noexcept
Definition: gui_console.cpp:15
int32_t * f_set_mil(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_nation_name(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_cheat_reforms(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * compile_modifier(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_cheat_army(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_save_map(fif::state_stack &s, int32_t *ptr, fif::environment *e)
int32_t * f_set_auto_choice(fif::state_stack &s, int32_t *p, fif::environment *env)
int32_t * f_fps(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: gui_console.cpp:70
int32_t * f_daily_oos(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_complete_construction(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_cheat_wargoals(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_instant_research(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_cheat_decision_potential(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_set_con(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_remove_core(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_make_crisis(fif::state_stack &s, int32_t *p, fif::environment *e)
void remove_ai_data(sys::state &state, dcon::nation_id n)
Definition: ai.cpp:3303
void notify_console_command(sys::state &state)
Definition: commands.cpp:3816
province_building_type
Definition: constants.hpp:578
void trigger_national_event(sys::state &state, dcon::national_event_id e, dcon::nation_id n, uint32_t r_lo, uint32_t r_hi, int32_t primary_slot, slot_type pt, int32_t from_slot, slot_type ft)
Definition: events.cpp:109
std::string multiplicative_modifier(sys::state &state, dcon::value_modifier_key modifier)
void run_fif_interpreter(environment &env, std::string_view on_text)
Definition: fif.hpp:5096
constexpr int32_t fif_ptr
Definition: fif.hpp:496
constexpr int32_t fif_i32
Definition: fif.hpp:483
constexpr int32_t fif_u16
Definition: fif.hpp:492
parse_result read_token(std::string_view &source, environment &env)
Definition: fif.hpp:4253
constexpr int32_t fif_i8
Definition: fif.hpp:493
constexpr int32_t fif_u32
Definition: fif.hpp:489
constexpr int32_t fif_bool
Definition: fif.hpp:485
void common_fif_environment(sys::state &state, fif::environment &env)
bool typechecking_mode(fif_mode m)
Definition: fif.hpp:719
void add_import(std::string_view name, void *ptr, fif_call interpreter_implementation, std::vector< int32_t > const &params, std::vector< int32_t > const &returns, environment &env)
Definition: fif.hpp:5154
var_data * get_global_var(environment &env, std::string const &name)
Definition: fif.hpp:4571
constexpr int32_t fif_u8
Definition: fif.hpp:494
constexpr int32_t fif_type
Definition: fif.hpp:486
bool typechecking_failed(fif_mode m)
Definition: fif.hpp:723
constexpr int32_t fif_f32
Definition: fif.hpp:484
constexpr int32_t fif_opaque_ptr
Definition: fif.hpp:497
constexpr int32_t fif_i16
Definition: fif.hpp:491
constexpr int32_t fif_u64
Definition: fif.hpp:490
constexpr int32_t fif_i64
Definition: fif.hpp:487
constexpr int32_t fif_f64
Definition: fif.hpp:488
void switch_scene(sys::state &state, scene_id ui_scene)
Definition: game_scene.cpp:13
void make_uncivilized(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:2865
std::string int_to_tag(uint32_t v)
Definition: nations.hpp:10
void daily_update_flashpoint_tension(sys::state &state)
Definition: nations.cpp:1773
void monthly_flashpoint_update(sys::state &state)
Definition: nations.cpp:1696
void make_alliance(sys::state &state, dcon::nation_id a, dcon::nation_id b)
Definition: nations.cpp:1467
void make_civilized(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:2758
void update_crisis(sys::state &state)
Definition: nations.cpp:2025
void set_militancy(sys::state &state, dcon::pop_id p, float v)
void set_consciousness(sys::state &state, dcon::pop_id p, float v)
void add_core(sys::state &state, dcon::province_id prov, dcon::national_identity_id tag)
Definition: province.cpp:1504
void remove_core(sys::state &state, dcon::province_id prov, dcon::national_identity_id tag)
Definition: province.cpp:1514
constexpr dcon::province_id from_map_id(uint16_t id)
Definition: province.hpp:13
void set_province_controller(sys::state &state, dcon::province_id p, dcon::nation_id n)
Definition: province.cpp:107
void conquer_province(sys::state &state, dcon::province_id id, dcon::nation_id new_owner)
Definition: province.cpp:907
constexpr uint16_t to_map_id(dcon::province_id id)
Definition: province.hpp:10
native_string utf8_to_native(std::string_view data_in)
void write_file(directory const &dir, native_string_view file_name, char const *file_data, uint32_t file_size)
directory get_or_create_oos_directory()
std::optional< file > open_file(directory const &dir, native_string_view file_name)
directory get_or_create_root_documents()
file_contents view_contents(file const &f)
audio_instance & get_console_open_sound(sys::state &state)
Definition: sound_nix.cpp:377
audio_instance & get_console_close_sound(sys::state &state)
Definition: sound_nix.cpp:380
void play_interface_sound(sys::state &state, audio_instance &s, float volume)
Definition: sound_nix.cpp:203
scenario_size sizeof_scenario_section(sys::state &state)
uint8_t * memcpy_serialize(uint8_t *ptr_in, T const &obj)
uint8_t * serialize(uint8_t *ptr_in, std::vector< T > const &vec)
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
Definition: text.cpp:617
dcon::text_key get_name(sys::state &state, dcon::nation_id id)
Definition: text.cpp:880
std::string format_fif_value(sys::state &state, int64_t data, int32_t type)
void initialize_console_fif_environment(sys::state &state)
void change_cursor(sys::state &state, cursor_type type)
Definition: window_nix.cpp:351
#define NATIVE(X)
std::string_view native_string_view
uint uint32_t
ulong uint64_t
uchar uint8_t
static constexpr uint32_t set_size
bool shift_held_down
std::unique_ptr< element_base > root
element_base * console_window