14 for(
auto pt :
state.world.in_pop_type) {
27 for(
auto c :
state.world.in_culture) {
40 for(
auto c :
state.world.in_ideology) {
49 int16_t piechart_offset = 0;
54 if(
name ==
"player_shield") {
55 return make_element_by_type<flag_button>(
state,
id);
56 }
else if(
name ==
"flag_overlay") {
57 return make_element_by_type<nation_flag_frame>(
state,
id);
58 }
else if(
name ==
"selected_nation_totalrank") {
59 return make_element_by_type<nation_rank_text>(
state,
id);
60 }
else if(
name ==
"selected_nation_label") {
61 return make_element_by_type<generic_name_text<dcon::nation_id>>(
state, id);
62 }
else if(
name ==
"selected_countrystatus") {
63 return make_element_by_type<nation_status_text>(
state,
id);
64 }
else if(
name ==
"selected_fog") {
65 return make_element_by_type<nation_government_type_text>(
state,
id);
66 }
else if(
name ==
"selected_prestige_rank") {
67 return make_element_by_type<nation_prestige_rank_text>(
state,
id);
68 }
else if(
name ==
"selected_industry_rank") {
69 return make_element_by_type<nation_industry_rank_text>(
state,
id);
70 }
else if(
name ==
"selected_military_rank") {
71 return make_element_by_type<nation_military_rank_text>(
state,
id);
72 }
else if(
name ==
"selected_population_amount") {
73 return make_element_by_type<nation_population_text>(
state,
id);
74 }
else if(
name ==
"selected_population_chart") {
76 auto aptr = make_element_by_type<nation_picker_cultures_chart>(
state,
id);
77 if(piechart_offset == 0)
78 piechart_offset = aptr->base_data.size.x + 4;
79 aptr->base_data.position.x -= piechart_offset;
82 auto bptr = make_element_by_type<nation_picker_ideologies_chart>(
state,
id);
85 auto cptr = make_element_by_type<nation_picker_poptypes_chart>(
state,
id);
86 cptr->base_data.position.x += piechart_offset;
93 }
else if(
name ==
"selected_population_chart_overlay") {
95 auto aptr = make_element_by_type<image_element_base>(
state,
id);
96 if(piechart_offset == 0)
97 piechart_offset = aptr->base_data.size.x + 4;
98 aptr->base_data.position.x -= piechart_offset;
99 overlay1 = aptr.
get();
102 auto bptr = make_element_by_type<image_element_base>(
state,
id);
103 overlay2 = bptr.
get();
106 auto cptr = make_element_by_type<image_element_base>(
state,
id);
107 cptr->base_data.position.x += piechart_offset;
109 }
else if(
name ==
"wars_overlappingbox") {
110 auto ptr = make_element_by_type<overlapping_enemy_flags>(
state,
id);
111 ptr->base_data.position.y -= 8 - 1;
113 }
else if(
name ==
"allies_overlappingbox") {
114 auto ptr = make_element_by_type<overlapping_ally_flags>(
state,
id);
115 ptr->base_data.position.y -= 8 - 1;
117 }
else if(
name ==
"puppets_overlappingbox") {
118 auto ptr = make_element_by_type<overlapping_puppet_flags>(
state,
id);
119 ptr->base_data.position.y -= 8 - 1;
120 ptr->base_data.position.x += 20;
122 }
else if(
name ==
"puppets_label") {
123 auto ptr = make_element_by_type<nation_puppet_list_label>(
state,
id);
139 std::string
name =
"fe_new_game";
149 return !(*
this == o);
177 win->set_visible(
state,
false);
180 state.network_state.save_slock.store(
true, std::memory_order::release);
181 std::vector<dcon::nation_id> players;
182 for(
const auto n :
state.world.in_nation)
183 if(
state.world.nation_get_is_player_controlled(n))
184 players.push_back(n);
185 dcon::nation_id old_local_player_nation =
state.local_player_nation;
199 state.save_list_updated.store(
true, std::memory_order::release);
215 state.network_state.is_new_game =
false;
218 state.local_player_nation = dcon::nation_id{ };
220 state.fill_unsaved_data();
221 for(
const auto n : players)
222 state.world.nation_set_is_player_controlled(n,
true);
223 state.local_player_nation = old_local_player_nation;
224 assert(
state.world.nation_get_is_player_controlled(
state.local_player_nation));
234 state.fill_unsaved_data();
239 state.map_state.set_selected_province(dcon::province_id{});
240 state.map_state.unhandled_province_selection =
true;
241 state.railroad_built.store(
true, std::memory_order::release);
242 state.network_state.save_slock.store(
false, std::memory_order::release);
243 state.game_state_updated.store(
true, std::memory_order_release);
270 tag =
state.national_definitions.rebel_id;
274 auto id =
state.world.national_identity_get_government_flag_type(tag, gov);
287 dcon::gfx_object_id gid;
294 auto& gfx_def =
state.ui_defs.gfx[gid];
295 if(gfx_def.type_dependent) {
297 auto& mask_tex =
state.open_gl.asset_textures[dcon::texture_id(gfx_def.type_dependent - 1)];
301 float(mask_tex.size_x),
302 float(mask_tex.size_y),
308 gfx_def.is_vertically_flipped(),
326 if(
auto gov_name =
state.world.national_identity_get_government_name(i->
save_flag, i->
as_gov);
state.key_is_localized(gov_name)) {
351 if(
name ==
"save_game") {
352 return make_element_by_type<select_save_game>(
state,
id);
353 }
else if(
name ==
"shield") {
354 return make_element_by_type<save_flag>(
state,
id);
355 }
else if(
name ==
"title") {
356 return make_element_by_type<save_name>(
state,
id);
357 }
else if(
name ==
"date") {
358 return make_element_by_type<save_date>(
state,
id);
375 return "alice_savegameentry";
380 row_contents.push_back(std::make_shared<save_item>(
save_item{
NATIVE(
""), 0,
sys::date(0), dcon::national_identity_id{ }, dcon::government_type_id{ },
true, std::string(
"") }));
396 std::sort(
row_contents.begin() + 1,
row_contents.end(), [](std::shared_ptr<save_item>
const& a, std::shared_ptr<save_item>
const& b) {
397 if(a->is_bookmark() != b->is_bookmark())
398 return a->is_bookmark();
399 return a->timestamp > b->timestamp;
415 if(
state.save_list_updated.load(std::memory_order::acquire) ==
true) {
416 state.save_list_updated.store(
false, std::memory_order::release);
425 if(
name ==
"save_games_list") {
426 return make_element_by_type<saves_listbox>(
state,
id);
447 state.local_player_nation = n;
448 state.world.nation_set_is_player_controlled(n,
true);
459 if(
name ==
"playable_countries_button") {
460 auto ptr = make_element_by_type<pick_nation_button>(
state,
id);
461 ptr->base_data.position.x += 9;
462 ptr->base_data.position.y = 0;
464 }
else if(
name ==
"playable_countries_flag") {
465 auto ptr = make_element_by_type<flag_button>(
state,
id);
466 ptr->base_data.position.x += 9;
467 ptr->base_data.position.y = 1;
469 }
else if(
name ==
"country_name") {
470 auto ptr = make_element_by_type<generic_name_text<dcon::nation_id>>(
state, id);
471 ptr->base_data.position.x += 9;
472 ptr->base_data.position.y = 5;
474 }
else if(
name ==
"prestige_rank") {
475 auto ptr = make_element_by_type<nation_prestige_rank_text>(
state,
id);
476 ptr->base_data.position.x += 9;
477 ptr->base_data.position.y = 5;
479 }
else if(
name ==
"industry_rank") {
480 auto ptr = make_element_by_type<nation_industry_rank_text>(
state,
id);
481 ptr->base_data.position.x += 9;
482 ptr->base_data.position.y = 5;
484 }
else if(
name ==
"military_rank") {
485 auto ptr = make_element_by_type<nation_military_rank_text>(
state,
id);
486 ptr->base_data.position.x += 9;
487 ptr->base_data.position.y = 5;
501 return "playable_countries_list_item";
507 for(
auto n :
state.world.in_nation) {
508 if(n.get_owned_province_count() > 0)
515 return text::get_name_as_string(state, fatten(state.world, a)) < text::get_name_as_string(state, fatten(state.world, b));
520 return state.world.nation_get_military_rank(a) < state.world.nation_get_military_rank(b);
525 return state.world.nation_get_industrial_rank(a) < state.world.nation_get_industrial_rank(b);
530 return state.world.nation_get_prestige_rank(a) < state.world.nation_get_prestige_rank(b);
540template< picker_sort stype>
549 std::unique_ptr<element_base> make_child(
sys::state&
state, std::string_view
name, dcon::gui_def_id
id)
noexcept override {
550 if(
name ==
"lobby_sort_countryname") {
551 auto ptr = make_element_by_type<playable_nations_sort_button<picker_sort::name>>(
state, id);
552 ptr->base_data.position.y += 1;
554 }
else if(
name ==
"lobby_sort_prestige") {
555 return make_element_by_type<playable_nations_sort_button<picker_sort::p_rank>>(
state, id);
556 }
else if(
name ==
"lobby_sort_industry") {
557 return make_element_by_type<playable_nations_sort_button<picker_sort::indust_rank>>(
state, id);
558 }
else if(
name ==
"lobby_sort_military") {
559 return make_element_by_type<playable_nations_sort_button<picker_sort::mil_rank>>(
state, id);
560 }
else if(
name ==
"playable_countries_list") {
561 return make_element_by_type<playable_nations_lb>(
state,
id);
571 auto v = any_cast<element_selection_wrapper<picker_sort>>(payload);
584 auto myd =
state.current_date.to_ymd(
state.start_date);
597 if(
auto cap =
state.world.nation_get_capital(
state.local_player_nation); cap) {
600 state.map_state.center_map_on_province(
state, cap);
609 if(
state.network_state.save_stream) {
612 if(!
state.session_host_checksum.is_equal(
state.get_save_checksum())) {
622 for(
auto const& client :
state.network_state.clients) {
623 if(client.is_active()) {
630 if(
state.network_state.save_stream) {
648 if(
state.network_state.save_stream) {
650 }
else if(!
state.session_host_checksum.is_equal(
state.get_save_checksum())) {
653 for(
auto const& client :
state.network_state.clients) {
654 if(client.is_active()) {
655 if(!client.send_buffer.empty()) {
688 if(
state.network_state.is_new_game ==
false) {
689 for(
auto const& c :
state.network_state.clients) {
690 if(c.is_active() && c.playing_as == n) {
691 auto completed = c.total_sent_bytes - c.save_stream_offset;
692 auto total = c.save_stream_size;
694 float progress = float(completed) / float(total);
717 state.world.for_each_nation([&](dcon::nation_id n) {
718 if(
state.world.nation_get_is_player_controlled(n))
732 if(
name ==
"player_shield") {
733 auto ptr = make_element_by_type<flag_button>(
state,
id);
734 ptr->base_data.position.x += 10;
735 ptr->base_data.position.y += 7;
737 }
else if(
name ==
"name") {
738 auto ptr = make_element_by_type<player_name_text>(
state,
id);
739 ptr->base_data.position.x += 10;
740 ptr->base_data.position.y += 7;
742 }
else if(
name ==
"save_progress") {
743 auto ptr = make_element_by_type<multiplayer_status_text>(
state,
id);
744 ptr->base_data.position.x += 10;
745 ptr->base_data.position.y += 7;
747 }
else if(
name ==
"button_kick") {
748 auto ptr = make_element_by_type<player_kick_button>(
state,
id);
749 ptr->base_data.position.x += 10;
750 ptr->base_data.position.y += 7;
752 }
else if(
name ==
"button_ban") {
753 auto ptr = make_element_by_type<player_ban_button>(
state,
id);
754 ptr->base_data.position.x += 10;
755 ptr->base_data.position.y += 7;
757 }
else if(
name ==
"frontend_player_entry") {
758 auto ptr = make_element_by_type<image_element_base>(
state,
id);
759 ptr->base_data.position.x += 10;
760 ptr->base_data.position.y += 7;
771 return "multiplayer_entry_server";
779 state.world.for_each_nation([&](dcon::nation_id n) {
780 if(
state.world.nation_get_is_player_controlled(n))
791 if(
name ==
"multiplayer_list") {
792 return make_element_by_type<nation_picker_multiplayer_listbox>(
state,
id);
793 }
else if(
name ==
"checksum") {
794 return make_element_by_type<simple_text_element_base>(
state,
id);
795 }
else if(
name ==
"num_players") {
796 return make_element_by_type<number_of_players_text>(
state,
id);
812 base_data.data.text.font_handle, 0, text::alignment::left,
813 text::is_black_from_font_id(base_data.data.text.font_handle) ? text::text_color::black : text::text_color::white,
815 populate_layout(
state, container);
827 if(
name ==
"frontend_chat_bg") {
828 return make_element_by_type<image_element_base>(
state,
id);
829 }
else if(
name ==
"lobby_chat_edit") {
830 return make_element_by_type<invisible_element>(
state,
id);
831 }
else if(
name ==
"newgame_tab") {
832 return make_element_by_type<invisible_element>(
state,
id);
833 }
else if(
name ==
"savedgame_tab") {
834 return make_element_by_type<invisible_element>(
state,
id);
835 }
else if(
name ==
"year_label") {
836 return make_element_by_type<date_label>(
state,
id);
837 }
else if(
name ==
"multiplayer") {
838 return make_element_by_type<nation_picker_multiplayer_window>(
state,
id);
839 }
else if(
name ==
"singleplayer") {
840 return make_element_by_type<nation_details_window>(
state,
id);
841 }
else if(
name ==
"save_games") {
842 return make_element_by_type<saves_window>(
state,
id);
843 }
else if(
name ==
"bookmarks") {
844 return make_element_by_type<invisible_element>(
state,
id);
845 }
else if(
name ==
"playable_countries_window") {
846 return make_element_by_type<playable_nations_window>(
state,
id);
847 }
else if(
name ==
"back_button") {
848 return make_element_by_type<quit_game_button>(
state,
id);
849 }
else if(
name ==
"play_button") {
850 return make_element_by_type<start_game_button>(
state,
id);
851 }
else if(
name ==
"chatlog") {
852 auto ptr = make_element_by_type<nation_alice_readme_text>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"alice_readme_text"))->second.definition);
854 return make_element_by_type<invisible_element>(
state,
id);
860 if(payload.holds_type<dcon::nation_id>()) {
861 payload.emplace<dcon::nation_id>(
state.local_player_nation);
ANY_ALWAYS_INLINE bool holds_type() const noexcept
T & emplace(Args &&... args)
void add_child_to_front(std::unique_ptr< element_base > child) noexcept final
void move_child_to_front(element_base *child) noexcept final
void impl_on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
void set_visible(sys::state &state, bool vis)
void render(sys::state &state, int32_t x, int32_t y) noexcept override
static std::vector< std::unique_ptr< ui::land_combat_end_popup > > land_reports_pool
std::vector< std::shared_ptr< save_item > > row_contents
void update(sys::state &state)
std::shared_ptr< save_item > content
text::layout internal_layout
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_reset_text(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void update_chart(sys::state &state)
std::vector< entry > distribution
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_update(sys::state &state) noexcept override
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
GLuint flag_texture_handle
void button_action(sys::state &state) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
std::string_view get_row_element_name() override
void update_save_list(sys::state &state) noexcept
void on_create(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void calibrate_scrollbar(sys::state &state) noexcept
void on_create(sys::state &state) noexcept override
multiline_text_element_base * delegate
void on_create(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void set_text(sys::state &state, std::string const &new_text)
#define assert(condition)
@ notify_player_picks_nation
bool can_notify_player_picks_nation(sys::state &state, dcon::nation_id source, dcon::nation_id target)
dcon::demographics_key to_key(sys::state const &state, dcon::pop_type_id v)
constexpr float zoom_very_close
void broadcast_save_to_clients(sys::state &state, command::payload &c, uint8_t const *buffer, uint32_t length, sys::checksum_key const &k)
void write_network_save(sys::state &state)
void render_masked_rect(sys::state const &state, color_modification enabled, float x, float y, float width, float height, GLuint texture_handle, GLuint mask_texture_handle, ui::rotation r, bool flipped, bool rtl)
void render_textured_rect(sys::state const &state, color_modification enabled, float x, float y, float width, float height, GLuint texture_handle, ui::rotation r, bool flipped, bool rtl)
GLuint get_texture_handle(sys::state &state, dcon::texture_id id, bool keep_data)
GLuint get_flag_handle(sys::state &state, dcon::national_identity_id nat_id, culture::flag_type type)
std::vector< unopened_file > list_files(directory const &dir, native_char const *extension)
directory get_or_create_save_game_directory()
std::optional< file > open_file(directory const &dir, native_string_view file_name)
std::string native_to_utf8(native_string_view data_in)
file_contents view_contents(file const &f)
native_string get_file_name(unopened_file const &f)
bool try_read_scenario_as_save_file(sys::state &state, native_string_view name)
uint8_t const * read_save_header(uint8_t const *ptr_in, save_header &header_out)
size_t sizeof_save_header(save_header const &header_in)
bool try_read_save_file(sys::state &state, native_string_view name)
std::string resolve_string_substitution(sys::state &state, dcon::text_key source_text, substitution_map const &mp)
layout_box open_layout_box(layout_base &dest, int32_t indent)
std::string date_to_string(sys::state &state, sys::date date)
void localised_format_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, text::substitution_map const &sub)
endless_layout create_endless_layout(sys::state &state, layout &dest, layout_parameters const ¶ms)
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
void add_line_break_to_layout(sys::state &state, columnar_layout &dest)
void add_to_substitution_map(substitution_map &mp, variable_type key, substitution value)
ankerl::unordered_dense::map< uint32_t, substitution > substitution_map
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
dcon::text_key get_name(sys::state &state, dcon::nation_id id)
std::string format_percentage(float num, size_t digits)
void close_layout_box(columnar_layout &dest, layout_box &box)
void popup_error_window(sys::state &state, std::string_view title, std::string_view body)
void send(sys::state &state, element_base *parent, T value)
void clear_event_windows(sys::state &state)
ogl::color_modification get_color_modification(bool is_under_mouse, bool is_disabled, bool is_interactable)
void close_window(sys::state &game_state)
void change_cursor(sys::state &state, cursor_type type)
std::string native_string
union command::payload::dtype data
bool is_equal(const checksum_key &a) noexcept
element_type get_element_type() const
rotation get_rotation() const
union ui::element_data::internal_data data
dcon::gfx_object_id gfx_object
dcon::government_type_id as_gov
bool operator!=(save_item const &o) const
dcon::national_identity_id save_flag
bool operator==(save_item const &o) const
element_base * msg_log_window
std::unique_ptr< element_base > nation_picker
ankerl::unordered_dense::map< dcon::text_key, element_target, hash_text_key > defs_by_name
element_base * request_window
element_base * request_topbar_listbox
element_base * under_mouse
element_base * msg_window
notify_save_loaded_data notify_save_loaded