24 auto sid = retrieve<dcon::state_instance_id>(
state,
parent);
25 auto content = retrieve<dcon::factory_type_id>(
state,
parent);
29 auto sid = retrieve<dcon::state_instance_id>(
state,
parent);
30 auto content = retrieve<dcon::factory_type_id>(
state,
parent);
41 auto sid = retrieve<dcon::state_instance_id>(
state,
parent);
42 auto content = retrieve<dcon::factory_type_id>(
state,
parent);
46 auto content = retrieve<dcon::factory_type_id>(
state,
parent);
48 for(
const auto s :
state.world.nation_get_state_ownership_as_nation(n)) {
49 auto sid = s.get_state();
61 auto name = fat.get_name();
66 auto content = retrieve<dcon::factory_type_id>(
state,
parent);
75 auto&
name = fat.get_construction_costs();
77 float factory_mod =
state.world.nation_get_modifier_values(
state.local_player_nation, sys::national_mod_offsets::factory_cost) + 1.0f;
78 float admin_eff =
state.world.nation_get_administrative_efficiency(
state.local_player_nation);
79 float admin_cost_factor = (2.0f - admin_eff) * factory_mod;
83 auto cid =
name.commodity_type[i];
85 total +=
state.world.commodity_get_current_price(cid) *
name.commodity_amounts[i] * admin_cost_factor;
92 auto content = retrieve<dcon::factory_type_id>(
state,
parent);
101 auto name = fat.get_construction_time();
106 auto content = retrieve<dcon::factory_type_id>(
state,
parent);
114 auto sid = retrieve<dcon::state_instance_id>(
state,
parent);
115 auto content = retrieve<dcon::factory_type_id>(
state,
parent);
125 auto content = retrieve<dcon::factory_type_id>(
state,
parent);
137 auto content = retrieve<dcon::factory_type_id>(
state,
parent);
138 auto sid = retrieve<dcon::state_instance_id>(
state,
parent);
139 auto n =
state.world.state_ownership_get_nation(
state.world.state_instance_get_state_ownership(sid));
144 auto const& cset =
state.world.factory_type_get_inputs(content);
146 if(cset.commodity_type[i] && cset.commodity_amounts[i] > 0.0f) {
147 auto amount = cset.commodity_amounts[i];
148 auto cid = cset.commodity_type[i];
149 auto cost =
state.world.commodity_get_current_price(cid);
163 if(
auto b1 =
state.world.factory_type_get_bonus_1_trigger(content); b1) {
166 sum -=
state.world.factory_type_get_bonus_1_amount(content);
170 if(
auto b2 =
state.world.factory_type_get_bonus_2_trigger(content); b2) {
173 sum -=
state.world.factory_type_get_bonus_2_amount(content);
177 if(
auto b3 =
state.world.factory_type_get_bonus_3_trigger(content); b3) {
180 sum -=
state.world.factory_type_get_bonus_3_amount(content);
189 std::vector<dcon::factory_type_id> desired_types;
193 auto ptr = make_element_by_type<factory_build_item_button>(
state,
id);
194 ptr->base_data.size.x *= 2;
195 ptr->base_data.size.x += 42;
196 ptr->base_data.size.y += 5;
199 }
else if(
name ==
"output") {
200 return make_element_by_type<commodity_image>(
state,
id);
202 }
else if(
name ==
"name") {
203 return make_element_by_type<factory_build_output_name_text>(
state,
id);
205 }
else if(
name ==
"total_build_cost") {
206 return make_element_by_type<factory_build_cost_text>(
state,
id);
208 }
else if(
name ==
"buildtime") {
209 return make_element_by_type<factory_build_time_text>(
state,
id);
217 desired_types.clear();
222 if(payload.holds_type<dcon::commodity_id>()) {
225 }
else if(payload.holds_type<
bool>()) {
226 auto sid = retrieve<dcon::state_instance_id>(
state,
parent);
227 bool is_hl = std::find(desired_types.begin(), desired_types.end(),
content) != desired_types.end();
229 payload.emplace<
bool>(is_hl);
237 std::vector<dcon::factory_type_id> desired_types;
238 bool is_highlighted(
sys::state&
state, dcon::state_instance_id sid, dcon::factory_type_id ftid) {
239 bool is_hl = std::find(desired_types.begin(), desired_types.end(), ftid) != desired_types.end();
244 return "new_factory_option";
249 auto sid = retrieve<dcon::state_instance_id>(
state,
parent);
251 desired_types.clear();
254 for(
const auto ftid : desired_types)
255 if(is_highlighted(
state, sid, ftid))
258 for(
const auto ftid :
state.world.in_factory_type) {
264 for(
const auto ftid :
state.world.in_factory_type) {
282 Cyto::Any payload = dcon::factory_type_id{};
284 auto content = any_cast<dcon::factory_type_id>(payload);
299 Cyto::Any payload = dcon::factory_type_id{};
301 auto content = any_cast<dcon::factory_type_id>(payload);
316 Cyto::Any payload = dcon::factory_type_id{};
318 auto content = any_cast<dcon::factory_type_id>(payload);
342 auto content = retrieve<dcon::factory_type_id>(
state,
parent);
362 auto& inputs =
state.world.factory_type_get_inputs(
type);
364 auto amount = inputs.commodity_amounts[
n];
377 dcon::commodity_id
c;
382 c = dcon::commodity_id{};
385 auto& inputs =
state.world.factory_type_get_inputs(
type);
387 c = inputs.commodity_type[
n];
388 frame = int32_t(
state.world.commodity_get_icon(
c));
408 dcon::factory_type_id factory_to_build{};
418 return make_element_by_type<draggable_target>(
state,
id);
419 }
else if(
name ==
"state_name") {
420 return make_element_by_type<state_name_text>(
state,
id);
421 }
else if(
name ==
"factory_type") {
422 return make_element_by_type<factory_build_list>(
state,
id);
423 }
else if(
name ==
"output") {
424 return make_element_by_type<commodity_image>(
state,
id);
425 }
else if(
name ==
"building_name") {
426 return make_element_by_type<factory_title>(
state,
id);
427 }
else if(
name ==
"output_amount") {
428 return make_element_by_type<output_amount_text>(
state,
id);
429 }
else if(
name ==
"description_text") {
430 return make_element_by_type<factory_build_description>(
state,
id);
431 }
else if(
name ==
"needed_workers") {
432 return make_element_by_type<simple_text_element_base>(
state,
id);
433 }
else if(
name ==
"needed_workers_count") {
434 return make_element_by_type<needed_workers_count_text>(
state,
id);
435 }
else if(
name ==
"available_workers") {
436 return make_element_by_type<simple_text_element_base>(
state,
id);
437 }
else if(
name ==
"current_funds_label") {
438 return make_element_by_type<factory_current_funds_text>(
state,
id);
439 }
else if(
name ==
"base_price") {
440 return make_element_by_type<simple_text_element_base>(
state,
id);
441 }
else if(
name ==
"input_price") {
442 return make_element_by_type<simple_text_element_base>(
state,
id);
443 }
else if(
name ==
"total_price") {
444 return make_element_by_type<factory_build_cost_text>(
state,
id);
445 }
else if(
name ==
"you_have") {
446 return make_element_by_type<simple_text_element_base>(
state,
id);
447 }
else if(
name ==
"prod_cost") {
448 return make_element_by_type<simple_text_element_base>(
state,
id);
449 }
else if(
name ==
"cancel") {
450 return make_element_by_type<factory_build_cancel_button>(
state,
id);
451 }
else if(
name ==
"build") {
452 return make_element_by_type<factory_build_button>(
state,
id);
454 auto ptr = make_element_by_type<input_n_image>(
state,
id);
455 std::from_chars(
name.data() + 6,
name.data() +
name.length(), ptr->n);
459 auto ptr = make_element_by_type<input_n_amout>(
state,
id);
460 std::from_chars(
name.data() + 6,
name.data() +
name.length() - 7, ptr->n);
469 factory_to_build = any_cast<element_selection_wrapper<dcon::factory_type_id>>(payload).data;
472 }
else if(payload.holds_type<dcon::factory_type_id>()) {
473 payload.emplace<dcon::factory_type_id>(factory_to_build);
475 }
else if(payload.holds_type<dcon::commodity_id>()) {
476 payload.emplace<dcon::commodity_id>(
dcon::fatten(
state.world, factory_to_build).get_output());
void impl_on_update(sys::state &state) noexcept override
message_result impl_get(sys::state &state, Cyto::Any &payload) noexcept
void set_visible(sys::state &state, bool vis)
std::string get_text(sys::state &state, dcon::factory_type_id ftid) noexcept
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) 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
void on_update(sys::state &state) noexcept override
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
std::string get_text(sys::state &state, dcon::factory_type_id ftid) noexcept
std::string get_text(sys::state &state, dcon::factory_type_id ftid) noexcept
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_create(sys::state &state) noexcept override
std::string get_text(sys::state &state) noexcept
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
std::string get_text(sys::state &state, dcon::factory_type_id fid) noexcept
void render(sys::state &state, int32_t x, int32_t y) noexcept override
std::vector< dcon::factory_type_id > row_contents
void update(sys::state &state)
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
dcon::factory_type_id content
text::layout internal_layout
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
std::string get_text(sys::state &state, dcon::factory_type_id fid) noexcept
void on_update(sys::state &state) noexcept override
std::string get_text(sys::state &state, dcon::factory_type_id fid) noexcept
void set_text(sys::state &state, std::string const &new_text)
void on_create(sys::state &state) noexcept override
void get_desired_factory_types(sys::state &state, dcon::nation_id nid, std::vector< dcon::factory_type_id > &desired_types)
bool can_begin_factory_building_construction(sys::state &state, dcon::nation_id source, dcon::state_instance_id location, dcon::factory_type_id type, bool is_upgrade)
@ begin_factory_building_construction
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
float get_treasury(sys::state &state, dcon::nation_id n)
bool is_integer(char const *start, char const *end)
uint32_t pack_color(float r, float g, float b)
void add_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, embedded_flag ico)
std::string format_money(float num)
layout_box open_layout_box(layout_base &dest, int32_t indent)
void localised_format_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, text::substitution_map const &sub)
std::string prettify(int64_t num)
endless_layout create_endless_layout(sys::state &state, layout &dest, layout_parameters const ¶ms)
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)
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)
void close_layout_box(columnar_layout &dest, layout_box &box)
int32_t to_generic(dcon::province_id v)
bool evaluate(sys::state &state, dcon::trigger_key key, int32_t primary, int32_t this_slot, int32_t from_slot)
void send(sys::state &state, element_base *parent, T value)
void trigger_description(sys::state &state, text::layout_base &layout, dcon::trigger_key k, int32_t primary_slot=-1, int32_t this_slot=-1, int32_t from_slot=-1)
static constexpr uint32_t set_size
union ui::element_data::internal_data data