From 8b1dafd36151cb319e3ef77f778fcbb2f9348d60 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 21:22:02 +0800 Subject: [PATCH] feat: add DPI awareness and auto-detect screen resolution --- Minecraft.Client/Common/UI/UIController.cpp | 18 +++++++++--------- .../Windows64/Windows64_Minecraft.cpp | 11 +++++++++++ README.md | 1 + 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Minecraft.Client/Common/UI/UIController.cpp b/Minecraft.Client/Common/UI/UIController.cpp index 8045695e..241f6835 100644 --- a/Minecraft.Client/Common/UI/UIController.cpp +++ b/Minecraft.Client/Common/UI/UIController.cpp @@ -426,36 +426,36 @@ void UIController::loadSkins() #elif defined __PSVITA__ platformSkinPath = L"skinVita.swf"; #elif defined _WINDOWS64 - if(m_fScreenHeight==1080.0f) + if(m_fScreenHeight>=1080.0f) { platformSkinPath = L"skinHDWin.swf"; } else { - platformSkinPath = L"skinWin.swf"; + platformSkinPath = L"skinWin.swf"; } #elif defined _DURANGO - if(m_fScreenHeight==1080.0f) + if(m_fScreenHeight>=1080.0f) { - platformSkinPath = L"skinHDDurango.swf"; + platformSkinPath = L"skinHDDurango.swf"; } else { - platformSkinPath = L"skinDurango.swf"; + platformSkinPath = L"skinDurango.swf"; } #elif defined __ORBIS__ - if(m_fScreenHeight==1080.0f) + if(m_fScreenHeight>=1080.0f) { - platformSkinPath = L"skinHDOrbis.swf"; + platformSkinPath = L"skinHDOrbis.swf"; } else { - platformSkinPath = L"skinOrbis.swf"; + platformSkinPath = L"skinOrbis.swf"; } #endif // Every platform has one of these, so nothing shared - if(m_fScreenHeight==1080.0f) + if(m_fScreenHeight>=1080.0f) { m_iggyLibraries[eLibrary_Platform] = loadSkin(platformSkinPath, L"platformskinHD.swf"); } diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index cc589771..472d10a6 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -698,6 +698,17 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); + // Declare DPI awareness so GetSystemMetrics returns physical pixels + SetProcessDPIAware(); + g_iScreenWidth = GetSystemMetrics(SM_CXSCREEN); + g_iScreenHeight = GetSystemMetrics(SM_CYSCREEN); + + { + char buf[128]; + sprintf(buf, "Screen resolution: %dx%d\n", g_iScreenWidth, g_iScreenHeight); + OutputDebugStringA(buf); + } + if(lpCmdLine) { if(lpCmdLine[0] == '1') diff --git a/README.md b/README.md index 05b119f8..ef93ddb7 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ This project contains the source code of Minecraft Legacy Console Edition v1.3.0 - Added support for keyboard and mouse input - Added fullscreen mode support (toggle using F11) - Disabled V-Sync for better performance +- Auto-detect native monitor resolution with DPI awareness, resulting in sharper visuals on high-resolution displays ## Build & Run