Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings: Use the full height and up to 720 width #7645

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Source/DiabloUI/diabloui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,10 +686,10 @@ void UiAddBackground(std::vector<std::unique_ptr<UiItemBase>> *vecDialog)
}
}

void UiAddLogo(std::vector<std::unique_ptr<UiItemBase>> *vecDialog)
void UiAddLogo(std::vector<std::unique_ptr<UiItemBase>> *vecDialog, int y)
{
vecDialog->push_back(std::make_unique<UiImageAnimatedClx>(
*ArtLogo, MakeSdlRect(0, GetUIRectangle().position.y, 0, 0), UiFlags::AlignCenter));
*ArtLogo, MakeSdlRect(0, y, 0, 0), UiFlags::AlignCenter));
}

void UiFadeIn()
Expand Down
2 changes: 1 addition & 1 deletion Source/DiabloUI/diabloui.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void UiLoadDefaultPalette();
bool UiLoadBlackBackground();
void LoadBackgroundArt(const char *pszFile, int frames = 1);
void UiAddBackground(std::vector<std::unique_ptr<UiItemBase>> *vecDialog);
void UiAddLogo(std::vector<std::unique_ptr<UiItemBase>> *vecDialog);
void UiAddLogo(std::vector<std::unique_ptr<UiItemBase>> *vecDialog, int y = GetUIRectangle().position.y);
void UiFocusNavigationSelect();
void UiFocusNavigationEsc();
void UiFocusNavigationYesNo();
Expand Down
28 changes: 20 additions & 8 deletions Source/DiabloUI/settingsmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -348,17 +349,20 @@
do {
endMenu = false;

// For the settings menu, we use the full height and allow some more width.
const int uiWidth = std::clamp<int>(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';

Expand All @@ -375,8 +379,6 @@
break;
}
vecDialog.push_back(std::make_unique<UiArtText>(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<UiScrollbar>((*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<UiArtText>(optionDescription, MakeSdlRect(rectDescription), UiFlags::FontSize12 | UiFlags::ColorUiSilverDark | UiFlags::AlignCenter, 1, descriptionLineHeight));

size_t itemToSelect = 0;
std::optional<tl::function_ref<bool(SDL_Event &)>> eventHandler;
Expand Down Expand Up @@ -532,7 +534,17 @@
vecDialogItems.push_back(std::make_unique<UiListItem>("", static_cast<int>(SpecialMenuEntry::None), UiFlags::ElementDisabled));
vecDialogItems.push_back(std::make_unique<UiListItem>(_("Previous Menu"), static_cast<int>(SpecialMenuEntry::PreviousMenu), UiFlags::ColorUiGold));

vecDialog.push_back(std::make_unique<UiList>(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<int>(vecDialogItems.size() * ListItemHeight, uiRectangle.size.height - 272) } };

Check warning on line 539 in Source/DiabloUI/settingsmenu.cpp

View workflow job for this annotation

GitHub Actions / build

'argument': conversion from 'size_t' to 'const _Ty', possible loss of data
rectDescription = { rectList.position + Displacement { -26, rectList.size.height + descriptionMarginTop },
Size { uiRectangle.size.width - 50, 80 - descriptionMarginTop } };
vecDialog.push_back(std::make_unique<UiScrollbar>((*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<UiArtText>(optionDescription, MakeSdlRect(rectDescription),
UiFlags::FontSize12 | UiFlags::ColorUiSilverDark | UiFlags::AlignCenter, 1, descriptionLineHeight));
vecDialog.push_back(std::make_unique<UiList>(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);

Expand Down
Loading