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";
100 if(std::holds_alternative<dcon::province_building_construction_id>(
content)) {
102 return fat_id.get_province().get_state_membership().id;
103 }
else if(std::holds_alternative<dcon::state_building_construction_id>(
content)) {
105 return fat_id.get_state();
107 return dcon::state_instance_id{};
112 if(
name ==
"state_bg") {
113 return make_element_by_type<image_element_base>(
state,
id);
114 }
else if(
name ==
"state_name") {
115 return make_element_by_type<state_name_text>(
state,
id);
116 }
else if(
name ==
"project_icon") {
117 auto ptr = make_element_by_type<image_element_base>(
state,
id);
118 factory_icon = ptr.
get();
120 }
else if(
name ==
"infra") {
121 auto ptr = make_element_by_type<image_element_base>(
state,
id);
122 building_icon = ptr.
get();
124 }
else if(
name ==
"project_name") {
125 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
126 name_text = ptr.
get();
128 }
else if(
name ==
"project_cost") {
129 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
130 cost_text = ptr.
get();
132 }
else if(
name ==
"pop_icon" ||
name ==
"pop_amount") {
133 return make_element_by_type<invisible_element>(
state,
id);
134 }
else if(
name ==
"invest_project") {
135 return make_element_by_type<production_project_invest_button>(
state,
id);
136 }
else if(
name ==
"input_goods") {
137 auto ptr = make_element_by_type<production_project_input_listbox>(
state,
id);
138 input_listbox = ptr.
get();
148 if(std::holds_alternative<dcon::province_building_construction_id>(
content)) {
152 factory_icon->
frame = uint16_t(fat_id.get_type());
156 needed_commodities =
state.economy_definitions.building_definitions[int32_t(
type)].cost;
158 satisfied_commodities = fat_id.get_purchased_goods();
159 }
else if(std::holds_alternative<dcon::state_building_construction_id>(
content)) {
163 factory_icon->
frame = uint16_t(fat_id.get_type().get_output().get_icon());
165 needed_commodities = fat_id.get_type().get_construction_costs();
166 satisfied_commodities = fat_id.get_purchased_goods();
168 float factory_mod =
state.world.nation_get_modifier_values(
state.local_player_nation, sys::national_mod_offsets::factory_cost) + 1.0f;
169 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));
170 float admin_cost_factor = pop_factory_mod * factory_mod;
173 needed_commodities.commodity_amounts[i] *= admin_cost_factor;
180 if(
bool(needed_commodities.commodity_type[i]))
182 needed_commodities.commodity_type[i],
183 satisfied_commodities.commodity_amounts[i],
184 needed_commodities.commodity_amounts[i]
189 float purchased_cost = 0.0f;
191 dcon::commodity_id cid = needed_commodities.commodity_type[i];
193 purchased_cost +=
state.world.commodity_get_current_price(cid) * satisfied_commodities.commodity_amounts[i];
195 float total_cost = get_cost(
state, needed_commodities);
200 if(payload.holds_type<dcon::state_instance_id>()) {
201 payload.emplace<dcon::state_instance_id>(get_state_instance_id(
state));
211 return "project_info";
217 state.world.nation_for_each_state_building_construction_as_nation(
state.local_player_nation,
218 [&](dcon::state_building_construction_id
id) {
219 auto fat_id = dcon::fatten(state.world, id);
220 if(fat_id.get_is_pop_project())
221 row_contents.push_back(production_project_data(id));
223 state.world.nation_for_each_province_building_construction_as_nation(
state.local_player_nation,
224 [&](dcon::province_building_construction_id
id) {
225 auto fat_id = dcon::fatten(state.world, id);
226 if(fat_id.get_is_pop_project())
227 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
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