11 auto to_nation = retrieve<dcon::nation_id>(
state,
parent);
13 auto ul =
state.world.get_unilateral_relationship_by_unilateral_pair(to_nation,
state.local_player_nation);
29 auto to_nation = retrieve<dcon::nation_id>(
state,
parent);
31 if(
auto sl =
state.world.nation_get_in_sphere_of(to_nation); sl) {
33 auto ul =
state.world.get_unilateral_relationship_by_unilateral_pair(to_nation, sl);
34 auto sl_investment =
state.world.unilateral_relationship_get_foreign_investment(ul);
37 float base =
state.world.nation_get_rank(to_nation) <=
state.defines.colonial_rank
38 ?
state.defines.second_rank_base_share_factor
39 :
state.defines.civ_base_share_factor;
40 float investment_fraction = total_investment > 0.0001f ? sl_investment / total_investment : 0.0f;
41 auto share = base + (1.0f - base) * investment_fraction;
43 if(!
state.world.nation_get_is_civilized(to_nation)) {
45 int64_t(100.0f *
state.defines.unciv_base_share_factor));
46 }
else if(
state.world.nation_get_rank(to_nation) <=
state.defines.colonial_rank) {
70 auto to_nation = retrieve<dcon::nation_id>(
state,
parent);
72 auto ul =
state.world.get_unilateral_relationship_by_unilateral_pair(to_nation, nat_id);
73 auto investment =
state.world.unilateral_relationship_get_foreign_investment(ul);
89 if(
name ==
"prod_investment_bg") {
90 return make_element_by_type<image_element_base>(
state,
id);
91 }
else if(
name ==
"country_flag") {
92 return make_element_by_type<flag_button>(
state,
id);
93 }
else if(
name ==
"country_flag_overlay") {
94 return make_element_by_type<nation_flag_frame>(
state,
id);
95 }
else if(
name ==
"country_name") {
96 return make_element_by_type<generic_name_text<dcon::nation_id>>(
state, id);
97 }
else if(
name ==
"country_investment") {
98 return make_element_by_type<player_investement_text>(
state,
id);
99 }
else if(
name ==
"invest_country_browse") {
100 return make_element_by_type<close_investments>(
state,
id);
101 }
else if(
name ==
"select_all") {
102 return make_element_by_type<factory_select_all_button>(
state,
id);
103 }
else if(
name ==
"deselect_all") {
104 return make_element_by_type<factory_deselect_all_button>(
state,
id);
105 }
else if(
name ==
"show_empty_states") {
106 return make_element_by_type<factory_show_empty_states_button>(
state,
id);
107 }
else if(
name ==
"sort_by_name") {
108 return make_element_by_type<button_element_base>(
state,
id);
109 }
else if(
name ==
"sort_by_factories") {
110 return make_element_by_type<button_element_base>(
state,
id);
111 }
else if(
name ==
"sort_by_infra") {
112 return make_element_by_type<button_element_base>(
state,
id);
113 }
else if(
name ==
"filter_bounds") {
114 return make_element_by_type<commodity_filters_window>(
state,
id);
133 for(int32_t i = 0; i < 4; ++i) {
135 auto ptr = make_element_by_type<nation_gp_flag>(
state,
"flag_list_flag");
137 ptr->base_data.position.x = int16_t(134 * i + 460);
138 ptr->base_data.position.y = int16_t(15 + 55);
142 auto ptr = make_element_by_type<gp_investment_text>(
state,
"alice_investment_text");
144 ptr->base_data.position.x = int16_t(134 * i + 460 + 25);
145 ptr->base_data.position.y = int16_t(15 + 55);
149 for(int32_t i = 4; i < 8; ++i) {
151 auto ptr = make_element_by_type<nation_gp_flag>(
state,
"flag_list_flag");
153 ptr->base_data.position.x = int16_t(134 * (i - 4) + 460);
154 ptr->base_data.position.y = int16_t(15 + 50 + 55);
158 auto ptr = make_element_by_type<gp_investment_text>(
state,
"alice_investment_text");
160 ptr->base_data.position.x = int16_t(134 * (i - 4) + 460 + 25);
161 ptr->base_data.position.y = int16_t(15 + 50 + 55);
167 xy_pair base_sort_template_offset =
169 xy_pair sort_template_offset = base_sort_template_offset;
170 sort_template_offset.
y += 233;
172 auto ptr = make_element_by_type<button_element_base>(
state,
174 ptr->set_button_text(
state,
176 sort_template_offset.
x = 478 + base_sort_template_offset.
x * 0;
177 ptr->base_data.position = sort_template_offset;
180 auto ptr2 = make_element_by_type<button_element_base>(
state,
182 ptr2->set_button_text(
state,
184 sort_template_offset.
x = 478 + base_sort_template_offset.
x * 1;
185 ptr2->base_data.position = sort_template_offset;
188 auto ptr3 = make_element_by_type<button_element_base>(
state,
190 ptr3->set_button_text(
state,
192 sort_template_offset.
x = 478 + base_sort_template_offset.
x * 2;
193 ptr3->base_data.position = sort_template_offset;
201 curr_nation = any_cast<element_selection_wrapper<dcon::nation_id>>(payload).data;
203 }
else if(payload.holds_type<dcon::nation_id>()) {
void add_child_to_back(std::unique_ptr< element_base > child) noexcept final
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
text::layout internal_layout
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
dcon::nation_id curr_nation
message_result get(sys::state &state, Cyto::Any &payload) 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)
void on_create(sys::state &state) noexcept override
float get_foreign_investment(sys::state &state, dcon::nation_id n)
dcon::nation_id get_nth_great_power(sys::state const &state, uint16_t n)
std::string format_money(float num)
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)
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
void send(sys::state &state, element_base *parent, T value)
union ui::element_data::internal_data data
ankerl::unordered_dense::map< dcon::text_key, element_target, hash_text_key > defs_by_name