diff --git a/src/client/game/ui_scripting/element.cpp b/src/client/game/ui_scripting/element.cpp index 826d9281..68e11d7c 100644 --- a/src/client/game/ui_scripting/element.cpp +++ b/src/client/game/ui_scripting/element.cpp @@ -262,58 +262,65 @@ namespace ui_scripting { check_resize(); - const auto background_material = game::Material_RegisterHandle(this->material.data()); - draw_image( - relative(this->x) + relative(this->border_width[3]), - relative(this->y) + relative(this->border_width[0]), - relative(this->w), - relative(this->h), - (float*)this->slice, - (float*)this->background_color, - background_material - ); + if (this->background_color[3] > 0) + { + const auto background_material = game::Material_RegisterHandle(this->material.data()); - const auto _border_material = game::Material_RegisterHandle(this->border_material.data()); + draw_image( + relative(this->x) + relative(this->border_width[3]), + relative(this->y) + relative(this->border_width[0]), + relative(this->w), + relative(this->h), + (float*)this->slice, + (float*)this->background_color, + background_material + ); + } - draw_image( - relative(this->x), - relative(this->y), - relative(this->w) + relative(this->border_width[1]) + relative(this->border_width[3]), - relative(this->border_width[0]), - (float*)this->slice, - (float*)this->border_color, - _border_material - ); + if (this->border_color[3] > 0) + { + const auto _border_material = game::Material_RegisterHandle(this->border_material.data()); - draw_image( - relative(this->x) + relative(this->border_width[3]) + relative(this->w), - relative(this->y) + relative(this->border_width[0]), - relative(this->border_width[1]), - relative(this->h), - (float*)this->slice, - (float*)this->border_color, - _border_material - ); + draw_image( + relative(this->x), + relative(this->y), + relative(this->w) + relative(this->border_width[1]) + relative(this->border_width[3]), + relative(this->border_width[0]), + (float*)this->slice, + (float*)this->border_color, + _border_material + ); - draw_image( - relative(this->x), - relative(this->y) + relative(this->h) + relative(this->border_width[0]), - relative(this->w) + relative(this->border_width[1]) + relative(this->border_width[3]), - relative(this->border_width[2]), - (float*)this->slice, - (float*)this->border_color, - _border_material - ); + draw_image( + relative(this->x) + relative(this->border_width[3]) + relative(this->w), + relative(this->y) + relative(this->border_width[0]), + relative(this->border_width[1]), + relative(this->h), + (float*)this->slice, + (float*)this->border_color, + _border_material + ); - draw_image( - relative(this->x), - relative(this->y) + relative(this->border_width[0]), - relative(this->border_width[3]), - relative(this->h), - (float*)this->slice, - (float*)this->border_color, - _border_material - ); + draw_image( + relative(this->x), + relative(this->y) + relative(this->h) + relative(this->border_width[0]), + relative(this->w) + relative(this->border_width[1]) + relative(this->border_width[3]), + relative(this->border_width[2]), + (float*)this->slice, + (float*)this->border_color, + _border_material + ); + + draw_image( + relative(this->x), + relative(this->y) + relative(this->border_width[0]), + relative(this->border_width[3]), + relative(this->h), + (float*)this->slice, + (float*)this->border_color, + _border_material + ); + } if (!this->text.empty()) { diff --git a/src/client/game/ui_scripting/lua/engine.cpp b/src/client/game/ui_scripting/lua/engine.cpp index eee59987..6f7a882a 100644 --- a/src/client/game/ui_scripting/lua/engine.cpp +++ b/src/client/game/ui_scripting/lua/engine.cpp @@ -2,6 +2,8 @@ #include "engine.hpp" #include "context.hpp" +#include "../../../component/scheduler.hpp" + #include #include @@ -216,6 +218,11 @@ namespace ui_scripting::lua::engine std::vector previous_elements; void handle_mousemove_event(const int x, const int y) { + if (mouse[0] == x && mouse[1] == y) + { + return; + } + mouse[0] = x; mouse[1] = y; @@ -371,20 +378,23 @@ namespace ui_scripting::lua::engine void ui_event(const std::string& type, const std::vector& arguments) { - if (type == "key") + ::scheduler::once([type, arguments]() { - handle_key_event(arguments[0], arguments[1]); - } + if (type == "key") + { + handle_key_event(arguments[0], arguments[1]); + } - if (type == "char") - { - handle_char_event(arguments[0]); - } + if (type == "char") + { + handle_char_event(arguments[0]); + } - if (type == "mousemove") - { - handle_mousemove_event(relative_mouse(arguments[0]), relative_mouse(arguments[1])); - } + if (type == "mousemove") + { + handle_mousemove_event(relative_mouse(arguments[0]), relative_mouse(arguments[1])); + } + }, ::scheduler::pipeline::renderer); } void notify(const event& e)