3#include "dcon_generated.hpp"
13#include <unordered_map>
19template<
typename T,
typename ...Params>
23 auto res = std::make_unique<T>(std::forward<Params>(params)...);
24 std::memcpy(&(res->base_data), &(
state.ui_defs.gui[it->second.definition]),
sizeof(
ui::element_data));
26 res->on_create(
state);
29 return std::unique_ptr<element_base>{};
31template<
typename T,
typename ...Params>
33 auto res = std::make_unique<T>(std::forward<Params>(params)...);
36 res->on_create(
state);
45 std::vector<std::unique_ptr<element_base>>
children;
72 return state.world.locale_get_native_rtl(
state.font_collection.get_current_locale());
117 dcon::texture_id texture_id;
121 auto& texhandle =
state.open_gl.asset_textures[texture_id];
122 uint8_t* texture = texhandle.data;
123 int32_t size_x = texhandle.size_x;
124 int32_t size_y = texhandle.size_y;
125 int32_t channels = texhandle.channels;
126 size_t size_m = (texhandle.size_x * texhandle.size_y) * 4;
127 if(texture && channels == 4) {
129 size_t index = (x + (y * size_x)) * 4 + 3;
130 if(index < size_m && texture[index] == 0x00) {
141 dcon::gfx_object_id gid;
148 texture_id =
state.ui_defs.gfx[gid].primary_texture_handle;
154 auto res = std::make_unique<partially_transparent_image>();
157 dcon::gfx_object_id gfx_handle;
160 gfx_handle = res->base_data.data.image.gfx_object;
162 gfx_handle = res->base_data.data.button.button_image;
165 auto tex_handle =
state.ui_defs.gfx[gfx_handle].primary_texture_handle;
172 res->on_create(
state);
243 if(!
state.user_settings.left_mouse_click_hold_and_release && !
disabled) {
267 if(
state.user_settings.left_mouse_click_hold_and_release && !
disabled && under_mouse) {
492template<
class RowConT>
504template<
class ItemWinT,
class ItemConT>
507 int16_t subwindow_width = 0;
513 return std::string_view{};
518 subwindow.impl_on_update(
state);
584 dcon::national_identity_id stored_identity{};
588 return stored_identity;
591 stored_identity = identity;
652 return state.world.nation_get_identity_from_identity_holder(
n);
740 float dx = float(x) -
radius;
741 float dy = float(y) -
radius;
742 auto dist = sqrt(dx * dx + dy * dy);
753template<
class SrcT,
class DemoT>
764 state.world.for_each_culture(fun);
772 state.world.for_each_pop_type(fun);
780 state.world.for_each_ideology(fun);
974template<
class RowWinT,
class RowConT>
980template<
class RowConT>
989template<
class RowConT>
999template<
class RowWinT,
class RowConT>
1005 return std::string_view{};
1041template<
typename contents_type>
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void move_child_to_back(element_base *child) noexcept final
void impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
message_result impl_set(sys::state &state, Cyto::Any &payload) noexcept final
void add_child_to_back(std::unique_ptr< element_base > child) noexcept final
std::unique_ptr< element_base > remove_child(element_base *child) noexcept final
void impl_on_reset_text(sys::state &state) noexcept override
void add_child_to_front(std::unique_ptr< element_base > child) noexcept final
mouse_probe impl_probe_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void move_child_to_front(element_base *child) noexcept final
element_base * get_child_by_name(sys::state const &state, std::string_view name) noexcept final
message_result impl_on_key_down(sys::state &state, sys::virtual_key key, sys::key_modifiers mods) noexcept final
std::vector< std::unique_ptr< element_base > > children
void impl_on_update(sys::state &state) noexcept override
element_base * get_child_by_index(sys::state const &state, int32_t index) noexcept final
void for_each_demo(sys::state &state, std::function< void(dcon::culture_id)> fun) override
void on_update(sys::state &state) noexcept override
virtual void for_each_demo(sys::state &state, std::function< void(DemoT)> fun)
message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
virtual void edit_box_backtick(sys::state &state) noexcept
virtual void edit_box_enter(sys::state &state, std::string_view s) noexcept
void on_create(sys::state &state) noexcept override
virtual void edit_box_tab(sys::state &state, std::string_view s) noexcept
message_result on_key_down(sys::state &state, sys::virtual_key key, sys::key_modifiers mods) noexcept override
void on_reset_text(sys::state &state) noexcept override
virtual void edit_index_position(sys::state &state, int32_t index) noexcept
message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
virtual void edit_box_update(sys::state &state, std::string_view s) noexcept
virtual void edit_box_down(sys::state &state) noexcept
virtual void edit_box_esc(sys::state &state) noexcept
virtual void edit_box_back_slash(sys::state &state) noexcept
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
virtual void edit_box_up(sys::state &state) noexcept
void render(sys::state &state, int32_t x, int32_t y) noexcept override
virtual tooltip_behavior has_tooltip(sys::state &state) noexcept
virtual message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept
virtual void on_create(sys::state &state) noexcept
void set_visible(sys::state &state, bool vis)
virtual message_result on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept
friend void sys::state::on_text(char32_t c)
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void for_each_demo(sys::state &state, std::function< void(dcon::ideology_id)> fun) override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
virtual bool get_horizontal_flip(sys::state &state) noexcept
void on_create(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void set_data_points(sys::state &state, std::vector< float > const &datapoints) noexcept
void on_create(sys::state &state) noexcept override
bool scrollbar_is_internal
listbox2_scrollbar * list_scrollbar
virtual std::unique_ptr< element_base > make_row(sys::state &state) noexcept=0
message_result on_scroll(sys::state &state, int32_t x, int32_t y, float amount, sys::key_modifiers mods) noexcept override
int32_t visible_row_count
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
std::vector< ui::element_base * > row_windows
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void resize(sys::state &state, int32_t height)
void render(sys::state &state, int32_t x, int32_t y) noexcept override
listbox2_base(bool scrollbar_is_internal)
std::vector< contents_type > row_contents
void on_update(sys::state &state) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
std::vector< RowConT > row_contents
virtual bool is_reversed()
message_result on_scroll(sys::state &state, int32_t x, int32_t y, float amount, sys::key_modifiers mods) noexcept override
std::vector< RowWinT * > row_windows
standard_listbox_scrollbar< RowWinT, RowConT > * list_scrollbar
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void scroll_to_bottom(sys::state &state)
virtual std::string_view get_row_element_name()
void update(sys::state &state)
void on_create(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
text::layout internal_layout
message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
message_result on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
void on_create(sys::state &state) noexcept override
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_reset_text(sys::state &state) noexcept override
void on_value_change(sys::state &state, int32_t v) noexcept override
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
message_result on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
void populate_flags(sys::state &state) override
void populate_flags(sys::state &state) override
void populate_flags(sys::state &state) override
void on_update(sys::state &state) noexcept override
std::string_view get_row_element_name() override
dcon::nation_id current_nation
void update_subwindow(sys::state &state, overlapping_flags_flag_button &subwindow, dcon::national_identity_id content) override
virtual void populate_flags(sys::state &state)
void populate_flags(sys::state &state) override
std::vector< ItemConT > row_contents
void update(sys::state &state)
std::vector< ItemWinT * > windows
virtual std::string_view get_row_element_name()
virtual void update_subwindow(sys::state &state, ItemWinT &subwindow, ItemConT content)
void populate_flags(sys::state &state) override
void populate_flags(sys::state &state) override
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
dcon::nation_id current_nation
void update_subwindow(sys::state &state, overlapping_truce_flag_button &subwindow, truce_pair content) override
static std::unique_ptr< partially_transparent_image > make_element_by_type_alias(sys::state &state, dcon::gui_def_id id)
void on_create(sys::state &state) noexcept override
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
ogl::data_texture data_texture
virtual void populate_tooltip(sys::state &state, T t, float percentage, text::columnar_layout &contents) noexcept
void update_chart(sys::state &state)
std::vector< entry > distribution
void render(sys::state &state, int32_t x, int32_t y) noexcept override
message_result on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void on_create(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
static constexpr int32_t resolution
message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
static constexpr size_t channels
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
message_result on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void calibrate_scrollbar(sys::state &state) noexcept
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
message_result on_scroll(sys::state &state, int32_t x, int32_t y, float amount, sys::key_modifiers mods) noexcept override
void on_create(sys::state &state) noexcept override
multiline_text_element_base * delegate
multiline_text_scrollbar * text_scrollbar
void on_create(sys::state &state) noexcept override
void on_reset_text(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void set_text(sys::state &state, std::string const &new_text)
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_create(sys::state &state) noexcept override
void set_text(sys::state &state, std::string const &new_text)
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
std::string_view get_text(sys::state &state) const
void on_reset_text(sys::state &state) noexcept override
text::layout internal_layout
void format_text(sys::state &state)
void on_update(sys::state &state) noexcept override
tinted_image_element_base()
tinted_image_element_base(uint32_t c)
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_create(sys::state &state) noexcept override
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void on_create(sys::state &state) noexcept override
void on_drag(sys::state &state, int32_t oldx, int32_t oldy, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
virtual std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept
void for_each_demo(sys::state &state, std::function< void(dcon::pop_type_id)> fun) override
wrapped_listbox_row_content()
wrapped_listbox_row_content(RowConT con)
audio_instance & get_click_left_sound(sys::state &state)
audio_instance & get_click_right_sound(sys::state &state)
audio_instance & get_checkbox_sound(sys::state &state)
void play_interface_sound(sys::state &state, audio_instance &s, float volume)
audio_instance & get_click_sound(sys::state &state)
audio_instance & get_subtab_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)
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_to_substitution_map(substitution_map &mp, variable_type key, substitution value)
ankerl::unordered_dense::map< uint32_t, substitution > substitution_map
void close_layout_box(columnar_layout &dest, layout_box &box)
void make_size_from_graphics(sys::state &state, ui::element_data &dat)
std::unique_ptr< element_base > make_element_by_type(sys::state &state, std::string_view name, Params &&... params)
void populate_shortcut_tooltip(sys::state &state, ui::element_base &elm, text::columnar_layout &contents) noexcept
@ position_sensitive_tooltip
void send(sys::state &state, element_base *parent, T value)
ogl::color3f get_text_color(sys::state &state, text::text_color text_color)
ogl::color_modification get_color_modification(bool is_under_mouse, bool is_disabled, bool is_interactable)
element_type get_element_type() const
union ui::element_data::internal_data data
static constexpr uint8_t do_transparency_check
dcon::gfx_object_id gfx_object
listbox2_row_element * row
entry(T key, float value)
ankerl::unordered_dense::map< dcon::text_key, element_target, hash_text_key > defs_by_name