35 if constexpr(std::is_same_v<T, dcon::regiment_id>) {
68 float total_cost = 0.f;
72 auto& build_cost =
state.military_definitions.unit_base_definitions[fat_id.get_type()].build_cost;
73 auto hadheader =
false;
75 if(build_cost.commodity_type[i]) {
76 float cost =
state.world.commodity_get_cost(build_cost.commodity_type[i]);
91 float amount = build_cost.commodity_amounts[i] * (1.0f - curstr);
98 auto cid = build_cost.commodity_type[i];
99 std::string padding = cid.index() < 10 ?
"0" :
"";
100 std::string description =
"@$" + padding + std::to_string(cid.index());
105 total_cost += cost * amount;
116 auto o_sc_mod = std::max(0.01f,
state.world.nation_get_modifier_values(
state.local_player_nation, sys::national_mod_offsets::supply_consumption) + 1.0f);
117 auto& supply_cost =
state.military_definitions.unit_base_definitions[fat_id.get_type()].supply_cost;
119 if(supply_cost.commodity_type[i]) {
120 float cost =
state.world.commodity_get_cost(supply_cost.commodity_type[i]);
122 float amount = supply_cost.commodity_amounts[i] *
state.world.nation_get_unit_stats(
state.local_player_nation, fat_id.get_type()).supply_consumption * o_sc_mod * curstr;
130 auto cid = supply_cost.commodity_type[i];
131 std::string padding = cid.index() < 10 ?
"0" :
"";
132 std::string description =
"@$" + padding + std::to_string(cid.index());
137 total_cost += cost * amount;
153 auto reg_id = retrieve<dcon::regiment_id>(
state,
parent);
154 auto base_pop =
state.world.regiment_get_pop_from_regiment_source(reg_id);
156 frame =
state.world.pop_type_get_sprite(
state.culture_definitions.soldiers) - 1;
159 frame =
state.world.pop_type_get_sprite(
state.world.pop_get_poptype(base_pop)) - 1;
160 if(
state.world.pop_get_size(base_pop) <
state.defines.pop_min_size_for_regiment) {
162 }
else if(
state.world.pop_get_size(base_pop) <
state.defines.pop_size_per_regiment) {
175 auto reg_id = retrieve<dcon::regiment_id>(
state,
parent);
176 auto base_pop =
state.world.regiment_get_pop_from_regiment_source(reg_id);
185 auto reg_range =
state.world.pop_get_regiment_source(base_pop);
192 auto a =
state.world.regiment_get_army_from_army_membership(reg_id);
210 T content = any_cast<T>(payload);
213 frame =
state.military_definitions.unit_base_definitions[utid].icon - 1;
234 if constexpr(std::is_same_v<T, dcon::regiment_id>) {
235 auto army =
state.world.regiment_get_army_from_army_membership(content);
236 auto type =
state.world.regiment_get_type(content);
237 for(
auto r :
state.world.army_get_army_membership(army)) {
238 if(r.get_regiment().get_type() ==
type) {
243 auto n =
state.world.ship_get_navy_from_navy_membership(content);
244 auto type =
state.world.ship_get_type(content);
245 for(
auto r :
state.world.navy_get_navy_membership(n)) {
246 if(r.get_ship().get_type() ==
type) {
261 T content = any_cast<T>(payload);
277 dcon::regiment_id content = any_cast<dcon::regiment_id>(payload);
291 dcon::ship_id content = any_cast<dcon::ship_id>(payload);
307 T content = any_cast<T>(payload);
326 if(
name ==
"band_reorg_regiment") {
327 return make_element_by_type<reorg_unit_transfer_button<T>>(
state, id);
329 }
else if(
name ==
"band_reorg_naval") {
330 return make_element_by_type<reorg_unit_transfer_button<T>>(
state, id);
332 }
else if(
name ==
"unit_icon") {
333 return make_element_by_type<subunit_details_type_icon<T>>(
state, id);
334 }
else if(
name ==
"subunit_name") {
335 return make_element_by_type<subunit_details_name<T>>(
state, id);
336 }
else if(
name ==
"subunit_type") {
337 return make_element_by_type<subunit_details_type_text<T>>(
state, id);
338 }
else if(
name ==
"subunit_strength") {
339 return make_element_by_type<subunit_details_regiment_amount>(
state,
id);
340 }
else if(
name ==
"subunit_strength_naval") {
341 return make_element_by_type<subunit_details_ship_amount>(
state,
id);
342 }
else if(
name ==
"connected_pop") {
343 if constexpr(std::is_same_v<T, dcon::regiment_id>) {
344 return make_element_by_type<regiment_pop_icon>(
state,
id);
346 return make_element_by_type<invisible_element>(
state,
id);
348 }
else if(
name ==
"rebel_faction") {
349 return make_element_by_type<invisible_element>(
state,
id);
350 }
else if(
name ==
"org_bar") {
351 return make_element_by_type<subunit_organisation_progress_bar<T>>(
state, id);
352 }
else if(
name ==
"str_bar") {
353 return make_element_by_type<subunit_strength_progress_bar<T>>(
state, id);
354 }
else if(
name ==
"transferbutton") {
355 return make_element_by_type<reorg_unit_transfer_button<T>>(
state, id);
362template<
class T,
class T2>
367 return "reorg_entry";
377 std::vector<T2> selectedunits = any_cast<std::vector<T2>>(vpayload);
383 if constexpr(std::is_same_v<T, dcon::army_id>) {
384 for(
auto regi : fat.get_army_membership()) {
385 if(
auto result = std::find(begin(selectedunits), end(selectedunits), regi.get_regiment().id); result == std::end(selectedunits)) {
390 auto av =
state.world.regiment_get_type(a).index();
391 auto bv =
state.world.regiment_get_type(b).index();
395 return a.index() < b.index();
398 for(
auto regi : fat.get_navy_membership()) {
399 if(
auto result = std::find(begin(selectedunits), end(selectedunits), regi.get_ship().id); result == std::end(selectedunits)) {
404 auto av =
state.world.ship_get_type(a).index();
405 auto bv =
state.world.ship_get_type(b).index();
409 return a.index() < b.index();
418template<
class T,
class T2>
423 return "reorg_entry_right";
433 std::vector<T2> selectedunits = any_cast<std::vector<T2>>(vpayload);
439 if constexpr(std::is_same_v<T, dcon::army_id>) {
440 for(
auto regi : fat.get_army_membership()) {
441 if(
auto result = std::find(begin(selectedunits), end(selectedunits), regi.get_regiment().id); result != std::end(selectedunits)) {
446 auto av =
state.world.regiment_get_type(a).index();
447 auto bv =
state.world.regiment_get_type(b).index();
451 return a.index() < b.index();
454 for(
auto regi : fat.get_navy_membership()) {
455 if(
auto result = std::find(begin(selectedunits), end(selectedunits), regi.get_ship().id); result != std::end(selectedunits)) {
460 auto av =
state.world.ship_get_type(a).index();
461 auto bv =
state.world.ship_get_type(b).index();
465 return a.index() < b.index();
495template<
class T,
class T2>
498 std::vector<T2> selectedsubunits;
504 if(
name ==
"reorg_bg") {
505 return make_element_by_type<opaque_element_base>(
state,
id);
507 }
else if(
name ==
"reorg_label") {
508 return make_element_by_type<simple_text_element_base>(
state,
id);
510 }
else if(
name ==
"unitname_1") {
511 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
512 orginialunit_text = ptr.
get();
515 }
else if(
name ==
"unitname_2") {
516 return make_element_by_type<simple_text_element_base>(
state,
id);
518 }
else if(
name ==
"cell_window_left" ||
name ==
"cell_window_right") {
519 return make_element_by_type<invisible_element>(
state,
id);
521 }
else if(
name ==
"balancebutton") {
522 return make_element_by_type<unit_reorg_balance_button>(
state,
id);
524 }
else if(
name ==
"closebutton") {
525 return make_element_by_type<reorg_win_close_button>(
state,
id);
527 }
else if(
name ==
"left_list") {
528 if constexpr(std::is_same_v<T, dcon::army_id>) {
529 auto ptr = make_element_by_type<reorg_unit_listbox_left<T, T2>>(
state, id);
532 ptr->base_data.size.x += 256;
535 auto ptr = make_element_by_type<reorg_unit_listbox_left<T, T2>>(
state, id);
538 ptr->base_data.size.x += 256;
542 }
else if(
name ==
"right_list") {
543 if constexpr(std::is_same_v<T, dcon::army_id>) {
544 auto ptr = make_element_by_type<reorg_unit_listbox_right<T, T2>>(
state, id);
547 ptr->base_data.size.x += 256;
550 auto ptr = make_element_by_type<reorg_unit_listbox_right<T, T2>>(
state, id);
553 ptr->base_data.size.x += 256;
557 }
else if(
name ==
"external_scroll_slider_left" ||
name ==
"external_scroll_slider_right") {
558 return make_element_by_type<invisible_element>(
state,
id);
568 orginialunit_text->
set_text(
state, std::string(
state.to_string_view(fat.get_name())));
572 selectedsubunits.clear();
575 selectedsubunits.clear();
580 unitToReorg = any_cast<element_selection_wrapper<T>>(payload).data;
582 }
else if(payload.holds_type<T>()) {
583 payload.emplace<T>(unitToReorg);
586 auto content = any_cast<element_selection_wrapper<T2>>(payload).data;
587 if(!selectedsubunits.empty()) {
588 if(
auto result = std::find(selectedsubunits.begin(), selectedsubunits.end(), content); result != selectedsubunits.end()) {
589 selectedsubunits.erase(result);
591 selectedsubunits.push_back(content);
594 selectedsubunits.push_back(content);
598 }
else if(payload.holds_type<std::vector<T2>>()) {
599 payload.emplace<std::vector<T2>>(selectedsubunits);
602 auto content = any_cast<element_selection_wrapper<reorg_win_action>>(payload).data;
606 if constexpr(std::is_same_v<T2, dcon::regiment_id>) {
607 std::array<dcon::regiment_id, command::num_packed_units> tosplit{};
608 for(
size_t i = 0; i < selectedsubunits.size(); i++) {
609 tosplit[i] = selectedsubunits[i];
614 std::array<dcon::ship_id, command::num_packed_units> tosplit{};
615 for(
size_t i = 0; i < selectedsubunits.size(); i++) {
616 tosplit[i] = selectedsubunits[i];
622 if constexpr(std::is_same_v<T2, dcon::regiment_id>) {
623 std::array<dcon::regiment_id, command::num_packed_units> tosplit{};
625 while(selectedsubunits.size() > 0) {
626 tosplit.fill(dcon::regiment_id{});
628 tosplit[i] = selectedsubunits[i];
632 : selectedsubunits.erase(selectedsubunits.begin(), selectedsubunits.end());
636 std::array<dcon::ship_id, command::num_packed_units> tosplit{};
638 while(selectedsubunits.size() > 0) {
639 tosplit.fill(dcon::ship_id{});
641 tosplit[i] = selectedsubunits[i];
645 : selectedsubunits.erase(selectedsubunits.begin(), selectedsubunits.end());
650 if(selectedsubunits.empty()) { selectedsubunits.erase(selectedsubunits.begin(), selectedsubunits.end()); }
655 selectedsubunits.erase(selectedsubunits.begin(), selectedsubunits.end());
656 if constexpr(std::is_same_v<T, dcon::army_id>) {
658 selectedsubunits.push_back(reg.get_regiment().id);
662 selectedsubunits.push_back(reg.get_ship().id);
665 std::sort(selectedsubunits.begin(), selectedsubunits.end(), [&](
auto a,
auto b){return dcon::fatten(state.world,a).get_type().value > dcon::fatten(state.world,b).get_type().value;});
667 for(
size_t i = selectedsubunits.size(); i-->0;) {
669 selectedsubunits.erase(selectedsubunits.begin() + i);
dcon::text_key get_name() noexcept
void impl_on_update(sys::state &state) noexcept override
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
message_result impl_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< T2 > row_contents
void update(sys::state &state)
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) 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_view get_row_element_name() override
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
void set_text(sys::state &state, std::string const &new_text)
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(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_visible(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
void on_hide(sys::state &state) noexcept override
void mark_ships_to_split(sys::state &state, dcon::nation_id source, std::array< dcon::ship_id, num_packed_units > const &list)
constexpr size_t num_packed_units
void mark_regiments_to_split(sys::state &state, dcon::nation_id source, std::array< dcon::regiment_id, num_packed_units > const &list)
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
float calculate_army_combined_reinforce(sys::state &state, dcon::army_id a)
int32_t regiments_possible_from_pop(sys::state &state, dcon::pop_id p)
float unit_get_strength(sys::state &state, dcon::regiment_id regiment_id)
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)
layout_box open_layout_box(layout_base &dest, int32_t indent)
void add_unparsed_text_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view sv, substitution_map const &mp)
void localised_format_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, text::substitution_map const &sub)
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
void add_line_break_to_layout(sys::state &state, columnar_layout &dest)
void add_to_substitution_map(substitution_map &mp, variable_type key, substitution value)
std::string format_wholenum(int32_t num)
ankerl::unordered_dense::map< uint32_t, substitution > substitution_map
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
std::string format_percentage(float num, size_t digits)
void close_layout_box(columnar_layout &dest, layout_box &box)
void send(sys::state &state, element_base *parent, T value)
void active_modifiers_description(sys::state &state, text::layout_base &layout, dcon::nation_id n, int32_t identation, dcon::national_modifier_value nmid, bool header)
static constexpr uint32_t set_size
Holds important data about the game world, state, and other data regarding windowing,...