Skip to content

Commit 21ffb65

Browse files
committed
Improve scaling of main menu on high-resolution displays
1 parent da48175 commit 21ffb65

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/TSMapEditor/Rendering/GameClass.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
using System.IO;
88
using System.Text;
99
using System.Threading;
10+
#if WINDOWS
11+
using System.Windows.Forms;
12+
#endif
1013
using TSMapEditor.CCEngine;
1114
using TSMapEditor.Misc;
1215
using TSMapEditor.Settings;
@@ -138,6 +141,26 @@ protected override void Initialize()
138141
menuWidth = (int)(menuWidth * dpi_ratio);
139142
menuHeight = (int)(menuHeight * dpi_ratio);
140143

144+
#if WINDOWS
145+
// If the user has a very large display, it's better to integer-upscale the main menu instead of DPI-scaling it.
146+
const int margin = 100;
147+
int scaleFactor = (int)dpi_ratio + 1;
148+
while (true)
149+
{
150+
if (Screen.PrimaryScreen.Bounds.Width > (menuRenderWidth + margin) * scaleFactor &&
151+
Screen.PrimaryScreen.Bounds.Height > (menuRenderHeight + margin) * scaleFactor)
152+
{
153+
menuWidth = menuRenderWidth * 2;
154+
menuHeight = menuRenderHeight * 2;
155+
scaleFactor++;
156+
}
157+
else
158+
{
159+
break;
160+
}
161+
}
162+
#endif
163+
141164
windowManager.InitGraphicsMode(menuWidth, menuHeight, false);
142165

143166
windowManager.SetRenderResolution(menuRenderWidth, menuRenderHeight);

0 commit comments

Comments
 (0)