10typedef std::variant< dcon::province_building_construction_id, dcon::state_building_construction_id>
production_project_data;
13 dcon::commodity_id
cid{};
29 if(
name ==
"goods_type") {
30 auto ptr = make_element_by_type<commodity_image>(
state,
id);
31 commodity_icon = ptr.
get();
33 }
else if(
name ==
"goods_amount") {
34 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
35 amount_text = ptr.
get();
47 if(payload.holds_type<dcon::commodity_id>()) {
48 payload.emplace<dcon::commodity_id>(
content.
cid);
59 return "goods_need_template";
90 if(std::holds_alternative<dcon::province_building_construction_id>(
content)) {
92 return fat_id.get_province().get_state_membership().id;
93 }
else if(std::holds_alternative<dcon::state_building_construction_id>(
content)) {
95 return fat_id.get_state();
97 return dcon::state_instance_id{};
102 auto s = get_state_instance_id(
state);
113 if(
name ==
"state_bg") {
114 return make_element_by_type<image_element_base>(
state,
id);
115 }
else if(
name ==
"state_name") {
116 return make_element_by_type<state_name_text>(
state,
id);
117 }
else if(
name ==
"project_icon") {
118 auto ptr = make_element_by_type<image_element_base>(
state,
id);
119 factory_icon = ptr.
get();
121 }
else if(
name ==
"infra") {
122 auto ptr = make_element_by_type<image_element_base>(
state,
id);
123 building_icon = ptr.
get();
125 }
else if(
name ==
"project_name") {
126 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
127 name_text = ptr.
get();
129 }
else if(
name ==
"project_cost") {
130 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
131 cost_text = ptr.
get();
133 }
else if(
name ==
"pop_icon" ||
name ==
"pop_amount") {
134 return make_element_by_type<invisible_element>(
state,
id);
135 }
else if(
name ==
"invest_project") {
136 return make_element_by_type<production_project_invest_button>(
state,
id);
137 }
else if(
name ==
"input_goods") {
138 auto ptr = make_element_by_type<production_project_input_listbox>(
state,
id);
139 input_listbox = ptr.
get();
149 if(std::holds_alternative<dcon::province_building_construction_id>(
content)) {
153 factory_icon->
frame = uint16_t(fat_id.get_type());
157 needed_commodities =
state.economy_definitions.building_definitions[int32_t(
type)].cost;
159 satisfied_commodities = fat_id.get_purchased_goods();
160 }
else if(std::holds_alternative<dcon::state_building_construction_id>(
content)) {
164 factory_icon->
frame = uint16_t(fat_id.get_type().get_output().get_icon());
166 needed_commodities = fat_id.get_type().get_construction_costs();
167 satisfied_commodities = fat_id.get_purchased_goods();
169 float factory_mod =
state.world.nation_get_modifier_values(
state.local_player_nation, sys::national_mod_offsets::factory_cost) + 1.0f;
170 float pop_factory_mod = std::max(0.1f,
state.world.nation_get_modifier_values(
state.local_player_nation, sys::national_mod_offsets::factory_owner_cost));
171 float admin_cost_factor = pop_factory_mod * factory_mod;
174 needed_commodities.commodity_amounts[i] *= admin_cost_factor;
181 if(
bool(needed_commodities.commodity_type[i]))
183 needed_commodities.commodity_type[i],
184 satisfied_commodities.commodity_amounts[i],
185 needed_commodities.commodity_amounts[i]
190 auto s = get_state_instance_id(
state);
192 float purchased_cost = 0.0f;
194 dcon::commodity_id cid = needed_commodities.commodity_type[i];
196 purchased_cost +=
economy::price(
state, s, cid) * satisfied_commodities.commodity_amounts[i];
198 float total_cost = get_cost(
state, needed_commodities);
203 if(payload.holds_type<dcon::state_instance_id>()) {
204 payload.emplace<dcon::state_instance_id>(get_state_instance_id(
state));
214 return "project_info";
220 state.world.nation_for_each_state_building_construction_as_nation(
state.local_player_nation,
221 [&](dcon::state_building_construction_id
id) {
222 auto fat_id = dcon::fatten(state.world, id);
223 if(fat_id.get_is_pop_project())
224 row_contents.push_back(production_project_data(id));
226 state.world.nation_for_each_province_building_construction_as_nation(
state.local_player_nation,
227 [&](dcon::province_building_construction_id
id) {
228 auto fat_id = dcon::fatten(state.world, id);
229 if(fat_id.get_is_pop_project())
230 row_contents.push_back(production_project_data(id));
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
virtual void on_create(sys::state &state) noexcept
void set_visible(sys::state &state, bool vis)
std::vector< production_project_data > row_contents
void update(sys::state &state)
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
production_project_input_data content
std::vector< ItemConT > row_contents
void update(sys::state &state)
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
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void on_update(sys::state &state) noexcept override
std::string_view get_row_element_name() override
void set_text(sys::state &state, std::string const &new_text)
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
float price(sys::state const &state, dcon::state_instance_id s, dcon::commodity_id c)
std::string format_money(float num)
std::string format_float(float num, size_t digits)
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)
std::variant< dcon::province_building_construction_id, dcon::state_building_construction_id > production_project_data
float commodity_amounts[set_size]
dcon::commodity_id commodity_type[set_size]
static constexpr uint32_t set_size
Holds important data about the game world, state, and other data regarding windowing,...