diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index b0d0cd4f..e734de71 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -48,6 +48,9 @@ namespace game WEAK symbol generateHashValue{0x343D20}; WEAK symbol CL_IsCgameInitialized{0x3CA0C0}; + WEAK symbol CL_DrawTextPhysicalWithEffects{0x3D4990}; WEAK symbol FindVariable{0x5C1D50}; WEAK symbol FindEntityId{0x5C1C50}; diff --git a/src/client/game/ui_scripting/element.cpp b/src/client/game/ui_scripting/element.cpp index 68e11d7c..fd1d6204 100644 --- a/src/client/game/ui_scripting/element.cpp +++ b/src/client/game/ui_scripting/element.cpp @@ -192,6 +192,14 @@ namespace ui_scripting this->color[3] = a; } + void element::set_glow_color(float r, float g, float b, float a) + { + this->glow_color[0] = r; + this->glow_color[1] = g; + this->glow_color[2] = b; + this->glow_color[3] = a; + } + void element::set_border_material(const std::string& _material) { this->border_material = _material; @@ -331,11 +339,16 @@ namespace ui_scripting auto _horzalign = get_align_value(this->horzalign, (float)text_width, relative(this->w)); auto _vertalign = get_align_value(this->vertalign, (float)relative(this->fontsize), relative(this->h)); - game::R_AddCmdDrawText(this->text.data(), 0x7FFFFFFF, _font, + game::CL_DrawTextPhysicalWithEffects( + this->text.data(), + 0x7FFFFFFF, + _font, relative(this->x) + relative(this->text_offset[0]) + _horzalign + relative(this->border_width[3]), relative(this->y) + relative(this->text_offset[1]) + _vertalign + relative(this->fontsize) + relative(this->border_width[0]), - 1.0f, 1.0f, 0.0f, - (float*)this->color, 0 + 1.f, 1.f, + (float*)this->color, 0, + (float*)this->glow_color, + 0, 0, 0, 0, 0, 0, 0 ); } } diff --git a/src/client/game/ui_scripting/element.hpp b/src/client/game/ui_scripting/element.hpp index 1820e432..952daf74 100644 --- a/src/client/game/ui_scripting/element.hpp +++ b/src/client/game/ui_scripting/element.hpp @@ -22,6 +22,7 @@ namespace ui_scripting void set_font(const std::string& _font); void set_font(const std::string& _font, const int _fontsize); void set_color(float r, float g, float b, float a); + void set_glow_color(float r, float g, float b, float a); void set_text_offset(float x, float y); void set_background_color(float r, float g, float b, float a); @@ -51,6 +52,7 @@ namespace ui_scripting float text_offset[2] = {0.f, 0.f}; float color[4] = {1.f, 1.f, 1.f, 1.f}; + float glow_color[4] = {0.f, 0.f, 0.f, 0.f}; float background_color[4] = {0.f, 0.f, 0.f, 0.f}; float border_color[4] = {0.f, 0.f, 0.f, 0.f}; float border_width[4] = {0.f, 0.f, 0.f, 0.f}; @@ -59,7 +61,7 @@ namespace ui_scripting alignment horzalign = alignment::start; alignment vertalign = alignment::start; - std::string font = "fonts/fira_mono_regular.ttf"; + std::string font = "default"; std::string material = "white"; std::string border_material = "white"; std::string text{}; diff --git a/src/client/game/ui_scripting/lua/context.cpp b/src/client/game/ui_scripting/lua/context.cpp index 58f513e8..a700ad6b 100644 --- a/src/client/game/ui_scripting/lua/context.cpp +++ b/src/client/game/ui_scripting/lua/context.cpp @@ -195,6 +195,7 @@ namespace ui_scripting::lua element_type["settext"] = &element::set_text; element_type["setmaterial"] = &element::set_material; element_type["setcolor"] = &element::set_color; + element_type["setglowcolor"] = &element::set_glow_color; element_type["setbackcolor"] = &element::set_background_color; element_type["setbordercolor"] = &element::set_border_color; element_type["setborderwidth"] = sol::overload( @@ -280,6 +281,25 @@ namespace ui_scripting::lua } ); + element_type["glowcolor"] = sol::property( + [](element& element, const sol::this_state s) + { + auto color = sol::table::create(s.lua_state()); + color["r"] = element.glow_color[0]; + color["g"] = element.glow_color[1]; + color["b"] = element.glow_color[2]; + color["a"] = element.glow_color[3]; + return color; + }, + [](element& element, const sol::lua_table color) + { + element.glow_color[0] = color["r"].get_type() == sol::type::number ? color["r"].get() : 0.f; + element.glow_color[1] = color["g"].get_type() == sol::type::number ? color["g"].get() : 0.f; + element.glow_color[2] = color["b"].get_type() == sol::type::number ? color["b"].get() : 0.f; + element.glow_color[3] = color["a"].get_type() == sol::type::number ? color["a"].get() : 0.f; + } + ); + element_type["backcolor"] = sol::property( [](element& element, const sol::this_state s) { diff --git a/src/client/game/ui_scripting/menu.cpp b/src/client/game/ui_scripting/menu.cpp index 844c90ef..8a7f019e 100644 --- a/src/client/game/ui_scripting/menu.cpp +++ b/src/client/game/ui_scripting/menu.cpp @@ -16,13 +16,21 @@ namespace ui_scripting void menu::open() { - *game::keyCatchers |= 0x40; + if (this->cursor) + { + *game::keyCatchers |= 0x40; + } + this->visible = true; } void menu::close() { - *game::keyCatchers &= ~0x40; + if (this->cursor) + { + *game::keyCatchers &= ~0x40; + } + this->visible = false; }