35 if constexpr(std::is_same_v<T, dcon::regiment_id>) {
67 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);
68 auto& supply_cost =
state.military_definitions.unit_base_definitions[fat_id.get_type()].supply_cost;
69 float total_cost = 0.f;
71 if(supply_cost.commodity_type[i]) {
72 float cost =
state.world.commodity_get_cost(supply_cost.commodity_type[i]);
73 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;
82 total_cost += cost * amount;
98 auto reg_id = retrieve<dcon::regiment_id>(
state,
parent);
99 auto base_pop =
state.world.regiment_get_pop_from_regiment_source(reg_id);
101 frame =
state.world.pop_type_get_sprite(
state.culture_definitions.soldiers) - 1;
104 frame =
state.world.pop_type_get_sprite(
state.world.pop_get_poptype(base_pop)) - 1;
105 if(
state.world.pop_get_size(base_pop) <
state.defines.pop_min_size_for_regiment) {
107 }
else if(
state.world.pop_get_size(base_pop) <
state.defines.pop_size_per_regiment) {
120 auto reg_id = retrieve<dcon::regiment_id>(
state,
parent);
121 auto base_pop =
state.world.regiment_get_pop_from_regiment_source(reg_id);
130 auto reg_range =
state.world.pop_get_regiment_source(base_pop);
137 auto a =
state.world.regiment_get_army_from_army_membership(reg_id);
155 T content = any_cast<T>(payload);
158 frame =
state.military_definitions.unit_base_definitions[utid].icon - 1;
179 if constexpr(std::is_same_v<T, dcon::regiment_id>) {
180 auto army =
state.world.regiment_get_army_from_army_membership(content);
181 auto type =
state.world.regiment_get_type(content);
182 for(
auto r :
state.world.army_get_army_membership(army)) {
183 if(r.get_regiment().get_type() ==
type) {
188 auto n =
state.world.ship_get_navy_from_navy_membership(content);
189 auto type =
state.world.ship_get_type(content);
190 for(
auto r :
state.world.navy_get_navy_membership(n)) {
191 if(r.get_ship().get_type() ==
type) {
206 T content = any_cast<T>(payload);
222 dcon::regiment_id content = any_cast<dcon::regiment_id>(payload);
236 dcon::ship_id content = any_cast<dcon::ship_id>(payload);
252 T content = any_cast<T>(payload);
271 if(
name ==
"band_reorg_regiment") {
272 return make_element_by_type<reorg_unit_transfer_button<T>>(
state, id);
274 }
else if(
name ==
"band_reorg_naval") {
275 return make_element_by_type<reorg_unit_transfer_button<T>>(
state, id);
277 }
else if(
name ==
"unit_icon") {
278 return make_element_by_type<subunit_details_type_icon<T>>(
state, id);
279 }
else if(
name ==
"subunit_name") {
280 return make_element_by_type<subunit_details_name<T>>(
state, id);
281 }
else if(
name ==
"subunit_type") {
282 return make_element_by_type<subunit_details_type_text<T>>(
state, id);
283 }
else if(
name ==
"subunit_strength") {
284 return make_element_by_type<subunit_details_regiment_amount>(
state,
id);
285 }
else if(
name ==
"subunit_strength_naval") {
286 return make_element_by_type<subunit_details_ship_amount>(
state,
id);
287 }
else if(
name ==
"connected_pop") {
288 if constexpr(std::is_same_v<T, dcon::regiment_id>) {
289 return make_element_by_type<regiment_pop_icon>(
state,
id);
291 return make_element_by_type<invisible_element>(
state,
id);
293 }
else if(
name ==
"rebel_faction") {
294 return make_element_by_type<invisible_element>(
state,
id);
295 }
else if(
name ==
"org_bar") {
296 return make_element_by_type<subunit_organisation_progress_bar<T>>(
state, id);
297 }
else if(
name ==
"str_bar") {
298 return make_element_by_type<subunit_strength_progress_bar<T>>(
state, id);
299 }
else if(
name ==
"transferbutton") {
300 return make_element_by_type<reorg_unit_transfer_button<T>>(
state, id);
307template<
class T,
class T2>
312 return "reorg_entry";
322 std::vector<T2> selectedunits = any_cast<std::vector<T2>>(vpayload);
328 if constexpr(std::is_same_v<T, dcon::army_id>) {
329 for(
auto regi : fat.get_army_membership()) {
330 if(
auto result = std::find(begin(selectedunits), end(selectedunits), regi.get_regiment().id); result == std::end(selectedunits)) {
335 auto av =
state.world.regiment_get_type(a).index();
336 auto bv =
state.world.regiment_get_type(b).index();
340 return a.index() < b.index();
343 for(
auto regi : fat.get_navy_membership()) {
344 if(
auto result = std::find(begin(selectedunits), end(selectedunits), regi.get_ship().id); result == std::end(selectedunits)) {
349 auto av =
state.world.ship_get_type(a).index();
350 auto bv =
state.world.ship_get_type(b).index();
354 return a.index() < b.index();
363template<
class T,
class T2>
368 return "reorg_entry_right";
378 std::vector<T2> selectedunits = any_cast<std::vector<T2>>(vpayload);
384 if constexpr(std::is_same_v<T, dcon::army_id>) {
385 for(
auto regi : fat.get_army_membership()) {
386 if(
auto result = std::find(begin(selectedunits), end(selectedunits), regi.get_regiment().id); result != std::end(selectedunits)) {
391 auto av =
state.world.regiment_get_type(a).index();
392 auto bv =
state.world.regiment_get_type(b).index();
396 return a.index() < b.index();
399 for(
auto regi : fat.get_navy_membership()) {
400 if(
auto result = std::find(begin(selectedunits), end(selectedunits), regi.get_ship().id); result != std::end(selectedunits)) {
405 auto av =
state.world.ship_get_type(a).index();
406 auto bv =
state.world.ship_get_type(b).index();
410 return a.index() < b.index();
440template<
class T,
class T2>
443 std::vector<T2> selectedsubunits;
449 if(
name ==
"reorg_bg") {
450 return make_element_by_type<opaque_element_base>(
state,
id);
452 }
else if(
name ==
"reorg_label") {
453 return make_element_by_type<simple_text_element_base>(
state,
id);
455 }
else if(
name ==
"unitname_1") {
456 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
457 orginialunit_text = ptr.
get();
460 }
else if(
name ==
"unitname_2") {
461 return make_element_by_type<simple_text_element_base>(
state,
id);
463 }
else if(
name ==
"cell_window_left" ||
name ==
"cell_window_right") {
464 return make_element_by_type<invisible_element>(
state,
id);
466 }
else if(
name ==
"balancebutton") {
467 return make_element_by_type<unit_reorg_balance_button>(
state,
id);
469 }
else if(
name ==
"closebutton") {
470 return make_element_by_type<reorg_win_close_button>(
state,
id);
472 }
else if(
name ==
"left_list") {
473 if constexpr(std::is_same_v<T, dcon::army_id>) {
474 auto ptr = make_element_by_type<reorg_unit_listbox_left<T, T2>>(
state, id);
477 ptr->base_data.size.x += 256;
480 auto ptr = make_element_by_type<reorg_unit_listbox_left<T, T2>>(
state, id);
483 ptr->base_data.size.x += 256;
487 }
else if(
name ==
"right_list") {
488 if constexpr(std::is_same_v<T, dcon::army_id>) {
489 auto ptr = make_element_by_type<reorg_unit_listbox_right<T, T2>>(
state, id);
492 ptr->base_data.size.x += 256;
495 auto ptr = make_element_by_type<reorg_unit_listbox_right<T, T2>>(
state, id);
498 ptr->base_data.size.x += 256;
502 }
else if(
name ==
"external_scroll_slider_left" ||
name ==
"external_scroll_slider_right") {
503 return make_element_by_type<invisible_element>(
state,
id);
513 orginialunit_text->
set_text(
state, std::string(
state.to_string_view(fat.get_name())));
517 selectedsubunits.clear();
520 selectedsubunits.clear();
525 unitToReorg = any_cast<element_selection_wrapper<T>>(payload).data;
527 }
else if(payload.holds_type<T>()) {
528 payload.emplace<T>(unitToReorg);
531 auto content = any_cast<element_selection_wrapper<T2>>(payload).data;
532 if(!selectedsubunits.empty()) {
533 if(
auto result = std::find(selectedsubunits.begin(), selectedsubunits.end(), content); result != selectedsubunits.end()) {
534 selectedsubunits.erase(result);
536 selectedsubunits.push_back(content);
539 selectedsubunits.push_back(content);
543 }
else if(payload.holds_type<std::vector<T2>>()) {
544 payload.emplace<std::vector<T2>>(selectedsubunits);
547 auto content = any_cast<element_selection_wrapper<reorg_win_action>>(payload).data;
551 if constexpr(std::is_same_v<T2, dcon::regiment_id>) {
552 std::array<dcon::regiment_id, command::num_packed_units> tosplit{};
553 for(
size_t i = 0; i < selectedsubunits.size(); i++) {
554 tosplit[i] = selectedsubunits[i];
559 std::array<dcon::ship_id, command::num_packed_units> tosplit{};
560 for(
size_t i = 0; i < selectedsubunits.size(); i++) {
561 tosplit[i] = selectedsubunits[i];
567 if constexpr(std::is_same_v<T2, dcon::regiment_id>) {
568 std::array<dcon::regiment_id, command::num_packed_units> tosplit{};
570 while(selectedsubunits.size() > 0) {
571 tosplit.fill(dcon::regiment_id{});
573 tosplit[i] = selectedsubunits[i];
577 : selectedsubunits.erase(selectedsubunits.begin(), selectedsubunits.end());
581 std::array<dcon::ship_id, command::num_packed_units> tosplit{};
583 while(selectedsubunits.size() > 0) {
584 tosplit.fill(dcon::ship_id{});
586 tosplit[i] = selectedsubunits[i];
590 : selectedsubunits.erase(selectedsubunits.begin(), selectedsubunits.end());
595 if(selectedsubunits.empty()) { selectedsubunits.erase(selectedsubunits.begin(), selectedsubunits.end()); }
600 selectedsubunits.erase(selectedsubunits.begin(), selectedsubunits.end());
601 if constexpr(std::is_same_v<T, dcon::army_id>) {
603 selectedsubunits.push_back(reg.get_regiment().id);
607 selectedsubunits.push_back(reg.get_ship().id);
610 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;});
612 for(
size_t i = selectedsubunits.size(); i-->0;) {
614 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 reinforce_amount(sys::state &state, dcon::army_id a)
int32_t regiments_possible_from_pop(sys::state &state, dcon::pop_id p)
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 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