38 switch(diplomacy_request.
type) {
40 return std::string(
"???");
60 return std::string(
"???");
64 auto diplomacy_request = retrieve< diplomatic_message::message>(
state,
parent);
71 switch(diplomacy_request.
type) {
83 dcon::nation_id primary_attacker =
state.world.war_get_primary_attacker(war);
84 dcon::nation_id primary_defender =
state.world.war_get_primary_defender(war);
114 state.world.peace_offer_for_each_peace_offer_item_as_peace_offer(diplomacy_request.
data.
peace, [&
state, &contents, &is_wp](dcon::peace_offer_item_id poiid) {
115 dcon::wargoal_id wg = state.world.peace_offer_item_get_wargoal(poiid);
116 dcon::cb_type_id cbt = state.world.wargoal_get_type(wg);
118 text::substitution_map sub;
119 text::add_to_substitution_map(sub, text::variable_type::recipient, state.world.wargoal_get_target_nation(wg));
120 text::add_to_substitution_map(sub, text::variable_type::from, state.world.wargoal_get_added_by(wg));
121 text::add_to_substitution_map(sub, text::variable_type::actor, state.world.wargoal_get_added_by(wg));
122 if(state.world.wargoal_get_secondary_nation(wg))
123 text::add_to_substitution_map(sub, text::variable_type::third, state.world.wargoal_get_secondary_nation(wg));
124 else if(state.world.wargoal_get_associated_tag(wg))
125 text::add_to_substitution_map(sub, text::variable_type::third, state.world.wargoal_get_associated_tag(wg));
126 text::add_to_substitution_map(sub, text::variable_type::state, state.world.wargoal_get_associated_state(wg));
128 auto box = text::open_layout_box(contents);
129 text::add_to_layout_box(state, contents, box, state.world.cb_type_get_shortest_desc(cbt), sub);
130 text::close_layout_box(contents, box);
161 auto is_concession =
state.world.peace_offer_get_is_concession(diplomacy_request.
data.
peace);
168 state.world.peace_offer_for_each_peace_offer_item_as_peace_offer(diplomacy_request.
data.
peace, [&
state, &contents, &is_wp](dcon::peace_offer_item_id poiid) {
169 dcon::wargoal_id wg = state.world.peace_offer_item_get_wargoal(poiid);
170 dcon::cb_type_id cbt = state.world.wargoal_get_type(wg);
172 text::substitution_map sub;
173 text::add_to_substitution_map(sub, text::variable_type::recipient, state.world.wargoal_get_target_nation(wg));
174 text::add_to_substitution_map(sub, text::variable_type::from, state.world.wargoal_get_added_by(wg));
175 text::add_to_substitution_map(sub, text::variable_type::actor, state.world.wargoal_get_added_by(wg));
176 if(state.world.wargoal_get_secondary_nation(wg))
177 text::add_to_substitution_map(sub, text::variable_type::third, state.world.wargoal_get_secondary_nation(wg));
178 else if(state.world.wargoal_get_associated_tag(wg))
179 text::add_to_substitution_map(sub, text::variable_type::third, state.world.wargoal_get_associated_tag(wg));
180 text::add_to_substitution_map(sub, text::variable_type::state, state.world.wargoal_get_associated_state(wg));
182 auto box = text::open_layout_box(contents);
183 text::add_to_layout_box(state, contents, box, state.world.cb_type_get_shortest_desc(cbt), sub);
184 text::close_layout_box(contents, box);
223 auto content = retrieve<diplomatic_message::message>(
state,
parent);
230 int16_t(base_data.size.x - border.x * 2),
231 int16_t(base_data.size.y - border.y * 2),
232 base_data.data.text.font_handle,
237 populate_layout(
state, container, content);
260 dcon::gfx_object_id gid;
267 auto const& gfx_def =
state.ui_defs.gfx[gid];
269 auto& mask_tex =
state.open_gl.asset_textures[dcon::texture_id(gfx_def.type_dependent - 1)];
272 gfx_def.is_vertically_flipped(),
false);
282 return fat_id.get_identity_from_identity_holder();
297 auto ptr = make_element_by_type<diplomacy_request_lr_button<false>>(
state,
300 cur_pos.y = ptr->base_data.size.y * 1;
301 ptr->base_data.position = cur_pos;
305 auto ptr = make_element_by_type<diplomacy_request_count_text>(
state,
307 cur_pos.x -= ptr->base_data.size.x;
308 ptr->base_data.position = cur_pos;
309 count_text = ptr.
get();
313 auto ptr = make_element_by_type<diplomacy_request_lr_button<true>>(
state,
315 cur_pos.x -= ptr->base_data.size.x;
316 ptr->base_data.position = cur_pos;
323 if(
name ==
"title") {
324 return make_element_by_type<diplomacy_request_title_text>(
state,
id);
325 }
else if(
name ==
"description") {
326 return make_element_by_type<diplomacy_request_desc_text>(
state,
id);
327 }
else if(
name ==
"agreebutton") {
328 return make_element_by_type<diplomacy_request_reply_button<true>>(
state, id);
329 }
else if(
name ==
"declinebutton") {
330 return make_element_by_type<diplomacy_request_reply_button<false>>(
state, id);
331 }
else if(
name ==
"leftshield") {
332 return make_element_by_type<diplomacy_request_player_flag_button>(
state,
id);
333 }
else if(
name ==
"rightshield") {
334 return make_element_by_type<diplomacy_request_flag_button>(
state,
id);
335 }
else if(
name ==
"background") {
336 auto ptr = make_element_by_type<draggable_target>(
state,
id);
346 return m.when + diplomatic_message::expiration_in_days <= state.current_date
347 || !diplomatic_message::can_accept(state, m);
355 count_text->
set_text(
state, std::to_string(int32_t(index + 1)) +
"/" + std::to_string(int32_t(
messages.size())));
361 if(index >= int32_t(
messages.size()))
364 index = int32_t(
messages.size()) - 1;
367 if(payload.holds_type<dcon::nation_id>()) {
369 payload.emplace<dcon::nation_id>(dcon::nation_id{});
371 payload.emplace<dcon::nation_id>(
messages[index].from);
375 bool b = any_cast<element_selection_wrapper<bool>>(payload).data;
376 index += b ? -1 : +1;
void add_child_to_front(std::unique_ptr< element_base > child) noexcept final
void impl_on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
std::string get_text(sys::state &state, diplomatic_message::message const &diplomacy_request)
message_result get(sys::state &state, Cyto::Any &payload) 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_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
std::vector< diplomatic_message::message > messages
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
void set_visible(sys::state &state, bool vis)
void render(sys::state &state, int32_t x, int32_t y) noexcept override
text::layout internal_layout
void on_create(sys::state &state) noexcept override
multiline_text_element_base * delegate
void on_create(sys::state &state) noexcept override
void set_text(sys::state &state, std::string const &new_text)
void on_create(sys::state &state) noexcept override
@ respond_to_diplomatic_message
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
@ be_crisis_primary_attacker
@ be_crisis_primary_defender
void render_masked_rect(sys::state const &state, color_modification enabled, float x, float y, float width, float height, GLuint texture_handle, GLuint mask_texture_handle, ui::rotation r, bool flipped, bool rtl)
GLuint get_texture_handle(sys::state &state, dcon::texture_id id, bool keep_data)
void add_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, embedded_flag ico)
std::string resolve_string_substitution(sys::state &state, dcon::text_key source_text, substitution_map const &mp)
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)
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_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
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
void close_layout_box(columnar_layout &dest, layout_box &box)
void send(sys::state &state, element_base *parent, T value)
ogl::color_modification get_color_modification(bool is_under_mouse, bool is_disabled, bool is_interactable)
union diplomatic_message::message::dtype data
dcon::national_identity_id wargoal_tag
dcon::state_definition_id wargoal_state
dcon::nation_id wargoal_secondary_nation
dcon::cb_type_id wargoal_type
element_type get_element_type() const
rotation get_rotation() const
union ui::element_data::internal_data data
dcon::gfx_object_id gfx_object
ankerl::unordered_dense::map< dcon::text_key, element_target, hash_text_key > defs_by_name
element_base * under_mouse
alignment get_alignment() const
dcon::state_definition_id state
dcon::peace_offer_id peace
sys::crisis_join_offer crisis_offer