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;
81 auto s = retrieve<dcon::state_instance_id>(
state,
parent);
85 auto cid =
name.commodity_type[i];
94 auto content = retrieve<dcon::factory_type_id>(
state,
parent);
103 auto name = fat.get_construction_time();
108 auto content = retrieve<dcon::factory_type_id>(
state,
parent);
116 auto sid = retrieve<dcon::state_instance_id>(
state,
parent);
117 auto content = retrieve<dcon::factory_type_id>(
state,
parent);
127 auto content = retrieve<dcon::factory_type_id>(
state,
parent);
139 auto content = retrieve<dcon::factory_type_id>(
state,
parent);
140 auto sid = retrieve<dcon::state_instance_id>(
state,
parent);
141 auto n =
state.world.state_ownership_get_nation(
state.world.state_instance_get_state_ownership(sid));
147 auto s = retrieve<dcon::state_instance_id>(
state,
parent);
149 auto const& cset =
state.world.factory_type_get_inputs(content);
151 if(cset.commodity_type[i] && cset.commodity_amounts[i] > 0.0f) {
152 auto amount = cset.commodity_amounts[i];
153 auto cid = cset.commodity_type[i];
168 if(
auto b1 =
state.world.factory_type_get_bonus_1_trigger(content); b1) {
171 sum -=
state.world.factory_type_get_bonus_1_amount(content);
175 if(
auto b2 =
state.world.factory_type_get_bonus_2_trigger(content); b2) {
178 sum -=
state.world.factory_type_get_bonus_2_amount(content);
182 if(
auto b3 =
state.world.factory_type_get_bonus_3_trigger(content); b3) {
185 sum -=
state.world.factory_type_get_bonus_3_amount(content);
194 std::vector<dcon::factory_type_id> desired_types;
198 auto ptr = make_element_by_type<factory_build_item_button>(
state,
id);
199 ptr->base_data.size.x *= 2;
200 ptr->base_data.size.x += 42;
201 ptr->base_data.size.y += 5;
204 }
else if(
name ==
"output") {
205 return make_element_by_type<commodity_image>(
state,
id);
207 }
else if(
name ==
"name") {
208 return make_element_by_type<factory_build_output_name_text>(
state,
id);
210 }
else if(
name ==
"total_build_cost") {
211 return make_element_by_type<factory_build_cost_text>(
state,
id);
213 }
else if(
name ==
"buildtime") {
214 return make_element_by_type<factory_build_time_text>(
state,
id);
222 desired_types.clear();
223 auto sid = retrieve<dcon::state_instance_id>(
state,
parent);
224 auto m =
state.world.state_instance_get_market_from_local_market(sid);
229 if(payload.holds_type<dcon::commodity_id>()) {
232 }
else if(payload.holds_type<
bool>()) {
233 auto sid = retrieve<dcon::state_instance_id>(
state,
parent);
234 bool is_hl = std::find(desired_types.begin(), desired_types.end(),
content) != desired_types.end();
236 payload.emplace<
bool>(is_hl);
244 std::vector<dcon::factory_type_id> desired_types;
245 bool is_highlighted(
sys::state&
state, dcon::state_instance_id sid, dcon::factory_type_id ftid) {
246 bool is_hl = std::find(desired_types.begin(), desired_types.end(), ftid) != desired_types.end();
251 return "new_factory_option";
256 auto sid = retrieve<dcon::state_instance_id>(
state,
parent);
258 desired_types.clear();
259 auto m =
state.world.state_instance_get_market_from_local_market(sid);
263 for(
const auto ftid : desired_types)
264 if(is_highlighted(
state, sid, ftid))
267 for(
const auto ftid :
state.world.in_factory_type) {
273 for(
const auto ftid :
state.world.in_factory_type) {
291 Cyto::Any payload = dcon::factory_type_id{};
293 auto content = any_cast<dcon::factory_type_id>(payload);
308 Cyto::Any payload = dcon::factory_type_id{};
310 auto content = any_cast<dcon::factory_type_id>(payload);
325 Cyto::Any payload = dcon::factory_type_id{};
327 auto content = any_cast<dcon::factory_type_id>(payload);
351 auto content = retrieve<dcon::factory_type_id>(
state,
parent);
371 auto& inputs =
state.world.factory_type_get_inputs(
type);
373 auto amount = inputs.commodity_amounts[
n];
386 dcon::commodity_id
c;
391 c = dcon::commodity_id{};
394 auto& inputs =
state.world.factory_type_get_inputs(
type);
396 c = inputs.commodity_type[
n];
397 frame = int32_t(
state.world.commodity_get_icon(
c));
417 dcon::factory_type_id factory_to_build{};
427 return make_element_by_type<draggable_target>(
state,
id);
428 }
else if(
name ==
"state_name") {
429 return make_element_by_type<state_name_text>(
state,
id);
430 }
else if(
name ==
"factory_type") {
431 return make_element_by_type<factory_build_list>(
state,
id);
432 }
else if(
name ==
"output") {
433 return make_element_by_type<commodity_image>(
state,
id);
434 }
else if(
name ==
"building_name") {
435 return make_element_by_type<factory_title>(
state,
id);
436 }
else if(
name ==
"output_amount") {
437 return make_element_by_type<output_amount_text>(
state,
id);
438 }
else if(
name ==
"description_text") {
439 return make_element_by_type<factory_build_description>(
state,
id);
440 }
else if(
name ==
"needed_workers") {
441 return make_element_by_type<simple_text_element_base>(
state,
id);
442 }
else if(
name ==
"needed_workers_count") {
443 return make_element_by_type<needed_workers_count_text>(
state,
id);
444 }
else if(
name ==
"available_workers") {
445 return make_element_by_type<simple_text_element_base>(
state,
id);
446 }
else if(
name ==
"current_funds_label") {
447 return make_element_by_type<factory_current_funds_text>(
state,
id);
448 }
else if(
name ==
"base_price") {
449 return make_element_by_type<simple_text_element_base>(
state,
id);
450 }
else if(
name ==
"input_price") {
451 return make_element_by_type<simple_text_element_base>(
state,
id);
452 }
else if(
name ==
"total_price") {
453 return make_element_by_type<factory_build_cost_text>(
state,
id);
454 }
else if(
name ==
"you_have") {
455 return make_element_by_type<simple_text_element_base>(
state,
id);
456 }
else if(
name ==
"prod_cost") {
457 return make_element_by_type<simple_text_element_base>(
state,
id);
458 }
else if(
name ==
"cancel") {
459 return make_element_by_type<factory_build_cancel_button>(
state,
id);
460 }
else if(
name ==
"build") {
461 return make_element_by_type<factory_build_button>(
state,
id);
463 auto ptr = make_element_by_type<input_n_image>(
state,
id);
464 std::from_chars(
name.data() + 6,
name.data() +
name.length(), ptr->n);
468 auto ptr = make_element_by_type<input_n_amout>(
state,
id);
469 std::from_chars(
name.data() + 6,
name.data() +
name.length() - 7, ptr->n);
478 factory_to_build = any_cast<element_selection_wrapper<dcon::factory_type_id>>(payload).data;
481 }
else if(payload.holds_type<dcon::factory_type_id>()) {
482 payload.emplace<dcon::factory_type_id>(factory_to_build);
484 }
else if(payload.holds_type<dcon::commodity_id>()) {
485 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, dcon::market_id mid, 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 price(sys::state const &state, dcon::state_instance_id s, dcon::commodity_id c)
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
Holds important data about the game world, state, and other data regarding windowing,...
union ui::element_data::internal_data data