From c7061c70cb3b6382197c93d9442bfbb4c9fc1def Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 16 Feb 2025 00:38:33 +0300 Subject: [PATCH] fix: console/chat open still available when menu is open & cleanup --- res/scripts/stdlib.lua | 4 ++-- src/graphics/ui/elements/TextBox.cpp | 8 +++++--- src/graphics/ui/elements/TextBox.hpp | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/res/scripts/stdlib.lua b/res/scripts/stdlib.lua index 47094bc7..6d458584 100644 --- a/res/scripts/stdlib.lua +++ b/res/scripts/stdlib.lua @@ -330,7 +330,7 @@ function __vc_on_hud_open() hud._set_debug_cheats(value) end) input.add_callback("devtools.console", function() - if hud.is_paused() then + if menu.page ~= "" then return end time.post_runnable(function() @@ -338,7 +338,7 @@ function __vc_on_hud_open() end) end) input.add_callback("hud.chat", function() - if hud.is_paused() then + if menu.page ~= "" then return end time.post_runnable(function() diff --git a/src/graphics/ui/elements/TextBox.cpp b/src/graphics/ui/elements/TextBox.cpp index 27bee570..c7933c7e 100644 --- a/src/graphics/ui/elements/TextBox.cpp +++ b/src/graphics/ui/elements/TextBox.cpp @@ -408,7 +408,9 @@ void TextBox::refresh() { Container::refresh(); label->setSize(size-glm::vec2(padding.z+padding.x, padding.w+padding.y)); label->setPos(glm::vec2( - padding.x + LINE_NUMBERS_PANE_WIDTH * showLineNumbers + textInitX - static_cast(textOffset), padding.y + padding.x + LINE_NUMBERS_PANE_WIDTH * showLineNumbers + textInitX - + static_cast(textOffset), + padding.y )); } @@ -815,8 +817,8 @@ size_t TextBox::getCaret() const { return caret; } -void TextBox::setCaret(size_t position, bool ignoreFormatting) { - const auto& labelText = ignoreFormatting ? label->getText() : input; +void TextBox::setCaret(size_t position) { + const auto& labelText = label->getText(); caret = std::min(static_cast(position), input.length()); if (font == nullptr) { return; diff --git a/src/graphics/ui/elements/TextBox.hpp b/src/graphics/ui/elements/TextBox.hpp index bc3a811d..0eff89f2 100644 --- a/src/graphics/ui/elements/TextBox.hpp +++ b/src/graphics/ui/elements/TextBox.hpp @@ -152,7 +152,7 @@ namespace gui { /// @brief Set caret position in the text /// @param position integer in range [0, text.length()] - virtual void setCaret(size_t position, bool ignoreFormatting = true); + virtual void setCaret(size_t position); /// @brief Set caret position in the text /// @param position integer in range [-text.length(), text.length()]