From 8a98bdd7cb17fc0407a27d702440624815e7aa67 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sun, 12 Jan 2025 11:19:05 +0000 Subject: [PATCH] Settings: Use the full height and up to 720 width This makes it easier to navigate sections, such as gameplay and keymapping. --- Source/DiabloUI/diabloui.cpp | 4 ++-- Source/DiabloUI/diabloui.h | 2 +- Source/DiabloUI/settingsmenu.cpp | 28 ++++++++++++++++++++-------- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Source/DiabloUI/diabloui.cpp b/Source/DiabloUI/diabloui.cpp index f5d0873bc6d..4733d346036 100644 --- a/Source/DiabloUI/diabloui.cpp +++ b/Source/DiabloUI/diabloui.cpp @@ -686,10 +686,10 @@ void UiAddBackground(std::vector> *vecDialog) } } -void UiAddLogo(std::vector> *vecDialog) +void UiAddLogo(std::vector> *vecDialog, int y) { vecDialog->push_back(std::make_unique( - *ArtLogo, MakeSdlRect(0, GetUIRectangle().position.y, 0, 0), UiFlags::AlignCenter)); + *ArtLogo, MakeSdlRect(0, y, 0, 0), UiFlags::AlignCenter)); } void UiFadeIn() diff --git a/Source/DiabloUI/diabloui.h b/Source/DiabloUI/diabloui.h index a14ef3a74b0..2ec0753f1c7 100644 --- a/Source/DiabloUI/diabloui.h +++ b/Source/DiabloUI/diabloui.h @@ -103,7 +103,7 @@ void UiLoadDefaultPalette(); bool UiLoadBlackBackground(); void LoadBackgroundArt(const char *pszFile, int frames = 1); void UiAddBackground(std::vector> *vecDialog); -void UiAddLogo(std::vector> *vecDialog); +void UiAddLogo(std::vector> *vecDialog, int y = GetUIRectangle().position.y); void UiFocusNavigationSelect(); void UiFocusNavigationEsc(); void UiFocusNavigationYesNo(); diff --git a/Source/DiabloUI/settingsmenu.cpp b/Source/DiabloUI/settingsmenu.cpp index 81f008749bb..c983732d244 100644 --- a/Source/DiabloUI/settingsmenu.cpp +++ b/Source/DiabloUI/settingsmenu.cpp @@ -16,6 +16,7 @@ #include "engine/render/text_render.hpp" #include "hwcursor.hpp" #include "options.h" +#include "utils/display.h" #include "utils/is_of.hpp" #include "utils/language.h" #include "utils/utf8.hpp" @@ -348,17 +349,20 @@ void UiSettingsMenu() do { endMenu = false; + // For the settings menu, we use the full height and allow some more width. + const int uiWidth = std::clamp(gnScreenWidth, 640, 720); + const Rectangle uiRectangle = { + { (gnScreenWidth - uiWidth) / 2, 0 }, + { uiWidth, gnScreenHeight } + }; + UiLoadBlackBackground(); LoadScrollBar(); UiAddBackground(&vecDialog); - UiAddLogo(&vecDialog); - - const Rectangle &uiRectangle = GetUIRectangle(); + UiAddLogo(&vecDialog, uiRectangle.position.y); const int descriptionLineHeight = IsSmallFontTall() ? 20 : 18; const int descriptionMarginTop = IsSmallFontTall() ? 10 : 16; - rectList = { uiRectangle.position + Displacement { 50, 204 }, Size { 540, 208 } }; - rectDescription = { rectList.position + Displacement { -26, rectList.size.height + descriptionMarginTop }, Size { 590, 80 - descriptionMarginTop } }; optionDescription[0] = '\0'; @@ -375,8 +379,6 @@ void UiSettingsMenu() break; } vecDialog.push_back(std::make_unique(titleText.data(), MakeSdlRect(uiRectangle.position.x, uiRectangle.position.y + 161, uiRectangle.size.width, 35), UiFlags::FontSize30 | UiFlags::ColorUiSilver | UiFlags::AlignCenter, 8)); - vecDialog.push_back(std::make_unique((*ArtScrollBarBackground)[0], (*ArtScrollBarThumb)[0], *ArtScrollBarArrow, MakeSdlRect(rectList.position.x + rectList.size.width + 5, rectList.position.y, 25, rectList.size.height))); - vecDialog.push_back(std::make_unique(optionDescription, MakeSdlRect(rectDescription), UiFlags::FontSize12 | UiFlags::ColorUiSilverDark | UiFlags::AlignCenter, 1, descriptionLineHeight)); size_t itemToSelect = 0; std::optional> eventHandler; @@ -532,7 +534,17 @@ void UiSettingsMenu() vecDialogItems.push_back(std::make_unique("", static_cast(SpecialMenuEntry::None), UiFlags::ElementDisabled)); vecDialogItems.push_back(std::make_unique(_("Previous Menu"), static_cast(SpecialMenuEntry::PreviousMenu), UiFlags::ColorUiGold)); - vecDialog.push_back(std::make_unique(vecDialogItems, rectList.size.height / 26, rectList.position.x, rectList.position.y, rectList.size.width, 26, UiFlags::FontSize24 | UiFlags::AlignCenter)); + constexpr int ListItemHeight = 26; + rectList = { uiRectangle.position + Displacement { 50, 204 }, + Size { uiRectangle.size.width - 100, std::min(vecDialogItems.size() * ListItemHeight, uiRectangle.size.height - 272) } }; + rectDescription = { rectList.position + Displacement { -26, rectList.size.height + descriptionMarginTop }, + Size { uiRectangle.size.width - 50, 80 - descriptionMarginTop } }; + vecDialog.push_back(std::make_unique((*ArtScrollBarBackground)[0], (*ArtScrollBarThumb)[0], + *ArtScrollBarArrow, MakeSdlRect(rectList.position.x + rectList.size.width + 5, rectList.position.y, 25, rectList.size.height))); + vecDialog.push_back(std::make_unique(optionDescription, MakeSdlRect(rectDescription), + UiFlags::FontSize12 | UiFlags::ColorUiSilverDark | UiFlags::AlignCenter, 1, descriptionLineHeight)); + vecDialog.push_back(std::make_unique(vecDialogItems, rectList.size.height / ListItemHeight, + rectList.position.x, rectList.position.y, rectList.size.width, ListItemHeight, UiFlags::FontSize24 | UiFlags::AlignCenter)); UiInitList(ItemFocused, ItemSelected, EscPressed, vecDialog, true, FullscreenChanged, nullptr, itemToSelect);