Skip to content

Commit 7363d85

Browse files
committed
Improved settings window with adaptive horizontal size (vertical impl was already in 4159496 by accident), leaving more space for entries in most locales.
It will now also not cut off the left side of window, as it did on the smallest resolutions, and the vertical impl exposes previously unseen entries in locale like Arabic, for which a more extensive fix is still needed though.
1 parent b395d75 commit 7363d85

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Client/core/CSettings.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@ constexpr float kBorderlessSaturationMax = 2.0f;
4646
constexpr float kBorderlessSaturationDefault = 1.0f;
4747

4848
constexpr float kSettingsContentWidth = 680.0f;
49+
constexpr float kSettingsExtendedContentWidth = 820.0f;
4950
constexpr float kSettingsBaseContentHeight = 480.0f;
5051
constexpr float kSettingsExtendedContentHeight = 520.0f;
5152
constexpr float kSettingsWindowFrameHorizontal = 18.0f; // 9px left + 9px right
5253
constexpr float kSettingsWindowFrameVertical = 22.0f; // 20px top + 2px bottom
54+
constexpr float kSettingsBottomButtonAreaHeight = 38.0f;
5355
constexpr float kPostFxCheckboxOffset = 24.0f;
5456

5557
float NormalizeSliderValue(float value, float minValue, float maxValue)
@@ -110,14 +112,24 @@ void CSettings::CreateGUI()
110112

111113
CVector2D resolution = CCore::GetSingleton().GetGUI()->GetResolution();
112114

113-
CVector2D contentSize(kSettingsContentWidth, kSettingsBaseContentHeight);
115+
const float fBottomButtonAreaHeight = kSettingsBottomButtonAreaHeight;
116+
CVector2D contentSize(kSettingsContentWidth, kSettingsBaseContentHeight);
117+
const float availableContentWidth = resolution.fX - kSettingsWindowFrameHorizontal;
118+
if (availableContentWidth >= kSettingsContentWidth)
119+
contentSize.fX = std::min(kSettingsExtendedContentWidth, availableContentWidth);
120+
else if (availableContentWidth > 0.0f)
121+
contentSize.fX = availableContentWidth;
122+
114123
const float availableContentHeight = resolution.fY - kSettingsWindowFrameVertical;
115124
if (availableContentHeight >= kSettingsBaseContentHeight)
116125
contentSize.fY = std::min(kSettingsExtendedContentHeight, availableContentHeight);
126+
else if (availableContentHeight > 0.0f)
127+
contentSize.fY = std::max(availableContentHeight, fBottomButtonAreaHeight + 1.0f);
128+
129+
contentSize.fX = std::max(contentSize.fX, 0.0f);
130+
contentSize.fY = std::max(contentSize.fY, fBottomButtonAreaHeight + 1.0f);
117131

118-
float fBottomButtonAreaHeight = 38;
119132
CVector2D tabPanelPosition;
120-
CVector2D tabPanelSize = contentSize - CVector2D(0, fBottomButtonAreaHeight);
121133

122134
// Window size is content size plus window frame edge dims
123135
CVector2D windowSize = contentSize + CVector2D(kSettingsWindowFrameHorizontal, kSettingsWindowFrameVertical);
@@ -145,6 +157,8 @@ void CSettings::CreateGUI()
145157
pFiller->SetZOrderingEnabled(false);
146158
pFiller->SetAlwaysOnTop(true);
147159
pFiller->MoveToBack();
160+
contentSize.fX = std::min(contentSize.fX, resolution.fX);
161+
contentSize.fY = std::min(contentSize.fY, resolution.fY);
148162
pFiller->SetPosition((resolution - contentSize) / 2);
149163
pFiller->SetSize(contentSize);
150164
m_pWindow = pFiller;
@@ -154,6 +168,7 @@ void CSettings::CreateGUI()
154168
// Create the tab panel and necessary tabs
155169
m_pTabs = reinterpret_cast<CGUITabPanel*>(pManager->CreateTabPanel(m_pWindow));
156170
m_pTabs->SetPosition(tabPanelPosition);
171+
const CVector2D tabPanelSize = CVector2D(contentSize.fX, std::max(0.0f, contentSize.fY - fBottomButtonAreaHeight));
157172
m_pTabs->SetSize(tabPanelSize);
158173
m_pTabs->SetSelectionHandler(GUI_CALLBACK(&CSettings::OnTabChanged, this));
159174

0 commit comments

Comments
 (0)