26 auto rt = get_root(
state.common_fs);
27 auto interfc = open_directory(rt,
NATIVE(
"interface"));
28 auto assets = open_directory(rt,
NATIVE(
"assets"));
33 auto all_alice_files = list_files(assets,
NATIVE(
".gfx"));
34 for(
auto& file : all_alice_files) {
35 if(
auto ofile = open_file(file); ofile) {
36 auto content = view_contents(*ofile);
39 parsers::parse_gfx_files(gen, err, context);
43 auto all_files = list_files(interfc,
NATIVE(
".gfx"));
44 for(
auto& file : all_files) {
45 if(
auto ofile = open_file(file); ofile) {
46 auto content = view_contents(*ofile);
49 parsers::parse_gfx_files(gen, err, context);
53 auto all_sfx_files = list_files(interfc,
NATIVE(
".sfx"));
54 for(
auto& file : all_sfx_files) {
55 if(
auto ofile = open_file(file); ofile) {
56 auto content = view_contents(*ofile);
59 parsers::parse_sfx_file(gen, err, context);
67 auto all_alice_gui_files = list_files(assets,
NATIVE(
".gui"));
68 for(
auto& file : all_alice_gui_files) {
69 if(
auto ofile = open_file(file); ofile) {
70 auto content = view_contents(*ofile);
73 parsers::parse_gui_files(gen, err, context);
74 context.
gui_files.emplace_back(std::move(*ofile));
79 auto all_gui_files = list_files(interfc,
NATIVE(
".gui"));
81 for(
auto& file : all_gui_files) {
82 auto file_name = get_full_name(file);
84 NATIVE(
"confirmbuild.gui")) &&
87 NATIVE(
"brigadeview.gui"))) {
88 auto ofile = open_file(file);
90 auto content = view_contents(*ofile);
93 parsers::parse_gui_files(gen, err, context);
94 context.
gui_files.emplace_back(std::move(*ofile));
144 if(
state.world.locale_get_native_rtl(
state.font_collection.get_current_locale())) {
162uint8_t element_base::get_pixel_opacity(
sys::state& state, int32_t x, int32_t y, dcon::texture_id tid) {
163 uint8_t* pixels = state.open_gl.asset_textures[tid].data;
164 int32_t width = state.open_gl.asset_textures[tid].size_x;
165 int32_t stride = state.open_gl.asset_textures[tid].channels;
166 if(pixels && 0 <= x && x < width && 0 <= y && y < state.open_gl.asset_textures[tid].size_y)
167 return pixels[(y * width * stride) + (x * stride) + stride - 1];
175 auto elem_type = base_data.get_element_type();
177 dcon::gfx_object_id gid;
179 gid = base_data.data.button.button_image;
181 gid = base_data.data.image.gfx_object;
183 gid = base_data.data.list_box.background_image;
186 auto& gfx_def =
state.ui_defs.gfx[gid];
187 auto mask_handle = gfx_def.type_dependent;
188 if(gfx_def.is_partially_transparent() && gfx_def.primary_texture_handle && get_pixel_opacity(
state, x, y, gfx_def.primary_texture_handle) >
uint8_t(64)) {
193 auto& mask_tex =
state.open_gl.asset_textures[dcon::texture_id(gfx_def.type_dependent - 1)];
194 auto x_off = float(base_data.size.x - mask_tex.size_x) * 0.5f;
195 auto y_off = float(base_data.size.y - mask_tex.size_y) * 0.5f;
197 if(get_pixel_opacity(
state, int32_t(x - x_off), int32_t(y - y_off), dcon::texture_id(mask_handle - 1)) >
uint8_t(64) || get_pixel_opacity(
state, x, y, gfx_def.primary_texture_handle) >
uint8_t(64)) {
213 return on_lbutton_down(
state, x, y, mods);
216 return on_lbutton_up(
state, x, y, mods, under_mouse);
219 return on_rbutton_down(
state, x, y, mods);
222 return on_key_down(
state, key, mods);
226 return on_scroll(
state, x, y, amount, mods);
229 return on_mouse_move(
state, x, y, mods);
235 on_reset_text(
state);
240 return parent->impl_get(
state, payload);
246 return set(
state, payload);
289 return xy_pair{int16_t(parent_loc.x + rel_loc.x), int16_t(parent_loc.y + rel_loc.y)};
291 if(
state.world.locale_get_native_rtl(
state.font_collection.get_current_locale())) {
304 return xy_pair{ int16_t(parent_loc.x + rel_loc.x), int16_t(parent_loc.y + rel_loc.y) };
311 return int32_t(
state.x_size /
state.user_settings.ui_scale);
314 return int32_t(
state.y_size /
state.user_settings.ui_scale);
318 for(
size_t i =
state.ui_defs.gui.size(); i-- > 0;) {
319 if(
state.ui_defs.gui[dcon::gui_def_id(dcon::gui_def_id::value_base_t(i))].is_top_level()) {
320 auto value =
element_target{
nullptr, dcon::gui_def_id(dcon::gui_def_id::value_base_t(i))};
321 state.ui_state.
defs_by_name.insert_or_assign(
state.ui_defs.gui[dcon::gui_def_id(dcon::gui_def_id::value_base_t(i))].name, value);
tag_type emplace_back(T &&... ts)
static constexpr dcon::texture_id small_tiles_dialog
static constexpr dcon::texture_id tiles_dialog
tagged_vector< dcon::text_key, dcon::texture_id > textures
static constexpr dcon::texture_id transparency
virtual message_result impl_set(sys::state &state, Cyto::Any &payload) noexcept
virtual void impl_on_reset_text(sys::state &state) noexcept
virtual message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept
virtual message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept
virtual message_result on_lbutton_up(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods, bool under_mouse) noexcept
virtual message_result impl_on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
virtual message_result impl_on_scroll(sys::state &state, int32_t x, int32_t y, float amount, sys::key_modifiers mods) noexcept
virtual message_result set(sys::state &state, Cyto::Any &payload) noexcept
virtual void on_update(sys::state &state) noexcept
virtual void impl_on_update(sys::state &state) noexcept
virtual void impl_render(sys::state &state, int32_t x, int32_t y) noexcept
virtual message_result impl_on_key_down(sys::state &state, sys::virtual_key key, sys::key_modifiers mods) noexcept
virtual message_result impl_on_lbutton_up(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods, bool under_mouse) noexcept
virtual message_result on_scroll(sys::state &state, int32_t x, int32_t y, float amount, sys::key_modifiers mods) noexcept
virtual message_result impl_on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept
message_result impl_get(sys::state &state, Cyto::Any &payload) noexcept
virtual message_result on_mouse_move(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept
virtual void on_drag(sys::state &state, int32_t oldx, int32_t oldy, int32_t x, int32_t y, sys::key_modifiers mods) noexcept
virtual message_result on_key_down(sys::state &state, sys::virtual_key key, sys::key_modifiers mods) noexcept
virtual message_result impl_on_mouse_move(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept
virtual mouse_probe impl_probe_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept
virtual message_result on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept
#define assert(condition)
GLuint get_texture_handle(sys::state &state, dcon::texture_id id, bool keep_data)
bool native_has_fixed_suffix_ci(char const *start, char const *end, char const (&t)[N])
std::string remove_double_backslashes(std::string_view data_in)
std::string native_to_utf8(native_string_view data_in)
int32_t ui_height(sys::state const &state)
xy_pair child_relative_location(sys::state &state, element_base const &parent, element_base const &child)
int32_t ui_width(sys::state const &state)
xy_pair get_absolute_location(sys::state &state, element_base const &node)
int16_t child_relative_location_y_component(element_base const &parent, element_base const &child)
xy_pair child_relative_non_mirror_location(sys::state &state, element_base const &parent, element_base const &child)
void populate_definitions_map(sys::state &state)
void load_text_gui_definitions(sys::state &state, parsers::building_gfx_context &context, parsers::error_handler &err)
xy_pair get_absolute_non_mirror_location(sys::state &state, element_base const &node)
ui::definitions & ui_defs
std::vector< simple_fs::file > gui_files
ankerl::unordered_dense::map< std::string, dcon::texture_id > map_of_texture_names
dcon::text_key add_key_win1252(std::string const &text)
orientation get_orientation() const
element_base * under_mouse
ankerl::unordered_dense::map< dcon::text_key, element_target, hash_text_key > defs_by_name