From add56ce6223e24e0c8b1352f68bcf9b2fa859631 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 7 Jan 2022 23:14:22 +1100 Subject: [PATCH] Quick fix for UI elements being scaled too large on desktop with high DPI (thanks FizzWhiz) --- src/Gui.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Gui.c b/src/Gui.c index 90e4a288a..953de534a 100644 --- a/src/Gui.c +++ b/src/Gui.c @@ -26,8 +26,16 @@ static cc_uint8 priorities[GUI_MAX_SCREENS]; *----------------------------------------------------------Gui------------------------------------------------------------* *#########################################################################################################################*/ static CC_NOINLINE int GetWindowScale(void) { - float windowScale = min(WindowInfo.Width / 640.0f, WindowInfo.Height / 480.0f); - return 1 + (int)windowScale; + float widthScale = WindowInfo.Width / 640.0f; + float heightScale = WindowInfo.Height / 480.0f; + + /* Use larger UI scaling on mobile */ + /* TODO move this DPI scaling elsewhere.,. */ + if (!Input_TouchMode) { + widthScale /= DisplayInfo.ScaleX; + heightScale /= DisplayInfo.ScaleY; + } + return 1 + (int)(min(widthScale, heightScale)); } float Gui_Scale(float value) {