From 851c1a0e2770dd31c983b5ecaf87fed7d64a04d8 Mon Sep 17 00:00:00 2001 From: loki5512344 Date: Sat, 3 Oct 2026 13:06:07 +0000 Subject: [PATCH] Limit GUI scale by window size, fix tooltip dash glyph Manual GUI scale is now limited so that UI is never smaller than 640x480 units (as in other games), otherwise menus did not fit the window at scale 3-4 in small windows. The unsupported en dash in the setting tooltip is replaced with a hyphen. --- res/texts/ru_RU.txt | 2 +- src/graphics/ui/GUI.cpp | 24 +++++++++++++----------- src/settings.hpp | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/res/texts/ru_RU.txt b/res/texts/ru_RU.txt index 316307c69..39060c1d7 100644 --- a/res/texts/ru_RU.txt +++ b/res/texts/ru_RU.txt @@ -42,7 +42,7 @@ pack.remove-confirm=Удалить весь поставляемый паком/ audio.acoustic-effects.tooltip=Акустические эффекты могут не поддерживаться системой audio.volume-contrast.tooltip=Меньше - громкие звуки приглушаются до уровня тихих (ночной режим) audio.recording-enabled.tooltip=Включает функции записи звука -display.gui-scale.tooltip=Размер интерфейса: Авто, 1–4 +display.gui-scale.tooltip=Размер интерфейса: Авто или 1-4. Слишком большой масштаб уменьшается под размер окна graphics.enable-fog.tooltip=Отображать туман / дымку graphics.gamma.tooltip=Кривая яркости освещения graphics.backlight.tooltip=Подсветка, предотвращающая полную темноту diff --git a/src/graphics/ui/GUI.cpp b/src/graphics/ui/GUI.cpp index 620be1b77..b4bb4a9aa 100644 --- a/src/graphics/ui/GUI.cpp +++ b/src/graphics/ui/GUI.cpp @@ -88,21 +88,23 @@ void GUI::onAssetsLoad(Assets* assets) { assets->store(rootDocument, "core:root"); } -/// @brief Minimal virtual window size used to choose the automatic scale -static constexpr glm::uvec2 AUTO_SCALE_MIN_SIZE {640, 480}; +/// @brief Minimal UI size (in UI units) that GUI scale must keep, so +/// menus always fit the window. Larger scale values are limited to it +static constexpr glm::uvec2 MIN_UI_SIZE {640, 480}; +static constexpr int MAX_SCALE = 4; int GUI::calcScale(const glm::uvec2& viewport) const { + int maxFit = 1; + while (maxFit < MAX_SCALE && + viewport.x / (maxFit + 1) >= MIN_UI_SIZE.x && + viewport.y / (maxFit + 1) >= MIN_UI_SIZE.y) { + maxFit++; + } int value = engine.getSettings().display.guiScale.get(); - if (value > 0) { - return value; + if (value <= 0) { + return maxFit; // auto } - int result = 1; - while (result < 4 && - viewport.x / (result + 1) >= AUTO_SCALE_MIN_SIZE.x && - viewport.y / (result + 1) >= AUTO_SCALE_MIN_SIZE.y) { - result++; - } - return result; + return std::min(value, maxFit); } int GUI::getScale() const { diff --git a/src/settings.hpp b/src/settings.hpp index faef856d1..478395ecb 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -41,7 +41,7 @@ struct DisplaySettings { FlagSetting limitFpsIconified {false}; /// @brief Adaptive framerate in menu (experimental) FlagSetting adaptiveFpsInMenu {false}; - /// @brief GUI scale factor (0 - auto, 1..4 - fixed integer scale) + /// @brief GUI scale factor (0 - auto, 1..4 - integer scale limited by window size) IntegerSetting guiScale {0, 0, 4}; };