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.
This commit is contained in:
loki5512344 2026-10-03 13:06:07 +00:00
parent 708c276787
commit 851c1a0e27
3 changed files with 15 additions and 13 deletions

View file

@ -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=Подсветка, предотвращающая полную темноту

View file

@ -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 {

View file

@ -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};
};