3#include "dcon_generated.hpp"
101 auto reform = fatten(
state.world, ref);
107 if(
auto desc = reform.get_desc();
state.key_is_localized(desc)) {
123 auto mod_id = reform.get_modifier();
128 auto time_limit =
state.world.nation_get_last_issue_or_reform_change(
state.local_player_nation);
129 auto parent =
state.world.issue_option_get_parent_issue(ref);
134 auto allow = reform.get_allow();
142 auto ext = reform.get_on_execute_trigger();
148 auto ex = reform.get_on_execute_effect();
157 uint32_t((ref.index() << 2) ^
state.local_player_nation.index()));
161 auto current =
state.world.nation_get_issues(
state.local_player_nation, reform.get_parent_issue()).id;
166 bool some_support_shown =
false;
168 auto tag =
state.world.nation_get_identity_from_identity_holder(
state.local_player_nation);
169 auto start =
state.world.national_identity_get_political_party_first(tag).id.index();
170 auto end = start +
state.world.national_identity_get_political_party_count(tag);
171 auto count_party_issues =
state.world.political_party_get_party_issues_size();
173 for(
uint32_t icounter =
state.world.ideology_size(); icounter-- > 0;) {
174 dcon::ideology_id iid{ dcon::ideology_id::value_base_t(icounter) };
175 dcon::value_modifier_key condition;
177 condition = ref.index() > current.index() ?
state.world.ideology_get_add_political_reform(iid) :
state.world.ideology_get_remove_political_reform(iid);
179 condition = ref.index() > current.index() ?
state.world.ideology_get_add_social_reform(iid) :
state.world.ideology_get_remove_social_reform(iid);
181 auto upperhouse_weight = 0.01f *
state.world.nation_get_upper_house(
state.local_player_nation, iid);
183 float party_special_issues_support_total = 0.0f;
184 float count_found = 0.0f;
186 for(int32_t i = start; i < end; i++) {
187 auto pid = dcon::political_party_id(dcon::political_party_id::value_base_t(i));
189 && (
state.world.nation_get_government_type(
state.local_player_nation).get_ideologies_allowed() &
culture::to_bits(
state.world.political_party_get_ideology(pid))) != 0
190 &&
state.world.political_party_get_ideology(pid) == iid) {
192 if(
auto special_opt =
state.world.political_party_get_party_issues(pid, parent); special_opt) {
193 if(special_opt == ref
194 || (
state.world.issue_get_is_next_step_only(parent.id)
195 && ((special_opt.id.index() > current.index() && ref.index() > current.index())
196 || (special_opt.id.index() < current.index() && ref.index() < current.index())
200 party_special_issues_support_total = upperhouse_weight;
202 party_special_issues_support_total = 0.0f;
206 for(
uint32_t j = 0; j < count_party_issues; ++j) {
207 auto popt =
state.world.political_party_get_party_issues(pid, dcon::issue_id{ dcon::issue_id::value_base_t(j) });
208 auto opt_mod =
state.world.issue_option_get_support_modifiers(popt, ref);
221 if(count_found > 0.0f) {
222 auto result = std::clamp(party_special_issues_support_total / count_found, -1.0f, 1.0f);
223 if(abs(result) >= 0.01) {
229 some_support_shown =
true;
231 }
else if(condition && upperhouse_weight > 0.0f) {
233 if(abs(result) >= 0.01) {
239 some_support_shown =
true;
244 if(!some_support_shown) {
256 auto content = retrieve<dcon::issue_option_id>(
state,
parent);
261 auto content = retrieve<dcon::issue_option_id>(
state,
parent);
270 auto content = retrieve<dcon::issue_option_id>(
state,
parent);
280 if(
name ==
"reform_name") {
281 return make_element_by_type<generic_name_text<dcon::issue_option_id>>(
state, id);
282 }
else if(
name ==
"selected") {
283 auto ptr = make_element_by_type<image_element_base>(
state,
id);
284 selected_icon = ptr.
get();
286 }
else if(
name ==
"reform_option") {
287 return make_element_by_type<reforms_reform_button>(
state,
id);
301 return "reform_option_window";
306 if(payload.holds_type<dcon::issue_id>()) {
307 auto issue_id = any_cast<dcon::issue_id>(payload);
310 for(
auto& option : fat_id.get_options())
328 auto content = retrieve<dcon::issue_id>(
state,
parent);
341 dcon::issue_id issue_id{};
345 if(
name ==
"reform_name") {
346 return make_element_by_type<issue_name_text>(
state,
id);
354 auto reforms_box = std::make_unique<reforms_listbox>();
355 reforms_box->base_data.size.x = 130;
356 reforms_box->base_data.size.y = 100;
358 reforms_box->on_create(
state);
363 if(payload.holds_type<dcon::issue_id>()) {
364 payload.emplace<dcon::issue_id>(issue_id);
371 if(payload.holds_type<dcon::issue_id>()) {
372 issue_id = any_cast<dcon::issue_id>(payload);
388 auto ptr = make_element_by_type<reforms_reform_window>(
state,
id);
390 ptr->impl_set(
state, payload);
void add_child_to_front(std::unique_ptr< element_base > child) noexcept final
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
void set_visible(sys::state &state, bool vis)
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
std::vector< dcon::issue_option_id > row_contents
void update(sys::state &state)
dcon::issue_option_id content
text::layout internal_layout
void on_create(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void enact_issue(sys::state &state, dcon::nation_id source, dcon::issue_option_id i)
bool can_enact_issue(sys::state &state, dcon::nation_id source, dcon::issue_option_id i)
constexpr uint64_t to_bits(dcon::ideology_id id)
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
constexpr dcon::demographics_key total(0)
dcon::demographics_key to_key(sys::state const &state, dcon::pop_type_id v)
constexpr uint32_t pop_open_factory
constexpr uint32_t build_railway
constexpr uint32_t open_factory
constexpr uint32_t same_as_ruling_party
constexpr uint32_t state_vote
constexpr uint32_t build_factory
constexpr uint32_t can_subsidise
constexpr uint32_t pop_expand_factory
constexpr uint32_t delete_factory_if_no_input
constexpr uint32_t culture_voting
constexpr uint32_t destroy_factory
constexpr uint32_t slavery_allowed
constexpr uint32_t build_bank
constexpr uint32_t rich_only
constexpr uint32_t build_university
constexpr uint32_t all_voting
constexpr uint32_t allow_foreign_investment
constexpr uint32_t pop_build_factory
constexpr uint32_t largest_share
constexpr uint32_t primary_culture_voting
constexpr uint32_t factory_priority
constexpr uint32_t sainte_laque
constexpr uint32_t population_vote
constexpr uint32_t expand_factory
dcon::issue_id get_issue_by_name(sys::state &state, std::string_view name)
bool political_party_is_active(sys::state &state, dcon::nation_id n, dcon::political_party_id p)
bool issue_is_selected(sys::state &state, dcon::nation_id nation, dcon::issue_option_id issue_option)
audio_instance & get_enact_sound(sys::state &state)
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)
endless_layout create_endless_layout(sys::state &state, layout &dest, layout_parameters const ¶ms)
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
void add_line_with_condition(sys::state &state, layout_base &dest, std::string_view key, bool condition_met, 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)
dcon::text_key get_adjective(sys::state &state, dcon::nation_id id)
ankerl::unordered_dense::map< uint32_t, substitution > substitution_map
void add_space_to_layout_box(sys::state &state, layout_base &dest, layout_box &box)
void close_layout_box(columnar_layout &dest, layout_box &box)
int32_t to_generic(dcon::province_id v)
float evaluate_additive_modifier(sys::state &state, dcon::value_modifier_key modifier, int32_t primary, int32_t this_slot, int32_t from_slot)
void modifier_description(sys::state &state, text::layout_base &layout, dcon::modifier_id mid, int32_t indentation=0)
void reform_description(sys::state &state, text::columnar_layout &contents, dcon::issue_option_id ref)
void make_size_from_graphics(sys::state &state, ui::element_data &dat)
void effect_description(sys::state &state, text::layout_base &layout, dcon::effect_key k, int32_t primary_slot, int32_t this_slot, int32_t from_slot, uint32_t r_lo, uint32_t r_hi)
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)
void reform_rules_description(sys::state &state, text::columnar_layout &contents, uint32_t rules)
union ui::element_data::internal_data data