diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 21:05:16 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 21:05:16 +0800 |
| commit | 4c81c7960c0970408d08928e9376ecdf7d7f00bb (patch) | |
| tree | ee1a063ad45744f491ba40ef791f0b83a441d5aa /Minecraft.Client | |
| parent | 52a256562f3ff1ff8c2302e816cbb5f601dd53cb (diff) | |
feat: fullscreen mode
Diffstat (limited to 'Minecraft.Client')
| -rw-r--r-- | Minecraft.Client/Windows64/Windows64_Minecraft.cpp | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index 4cd10fa2..cc589771 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -79,6 +79,10 @@ BOOL g_bWidescreen = TRUE; int g_iScreenWidth = 1920; int g_iScreenHeight = 1080; +// Fullscreen toggle state +static bool g_isFullscreen = false; +static WINDOWPLACEMENT g_wpPrev = { sizeof(g_wpPrev) }; + void DefineActions(void) { // The app needs to define the actions required, and the possible mappings for these @@ -642,6 +646,36 @@ void Render() } //-------------------------------------------------------------------------------------- +// Toggle borderless fullscreen +//-------------------------------------------------------------------------------------- +void ToggleFullscreen() +{ + DWORD dwStyle = GetWindowLong(g_hWnd, GWL_STYLE); + if (!g_isFullscreen) + { + MONITORINFO mi = { sizeof(mi) }; + if (GetWindowPlacement(g_hWnd, &g_wpPrev) && + GetMonitorInfo(MonitorFromWindow(g_hWnd, MONITOR_DEFAULTTOPRIMARY), &mi)) + { + SetWindowLong(g_hWnd, GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW); + SetWindowPos(g_hWnd, HWND_TOP, + mi.rcMonitor.left, mi.rcMonitor.top, + mi.rcMonitor.right - mi.rcMonitor.left, + mi.rcMonitor.bottom - mi.rcMonitor.top, + SWP_NOOWNERZORDER | SWP_FRAMECHANGED); + } + } + else + { + SetWindowLong(g_hWnd, GWL_STYLE, dwStyle | WS_OVERLAPPEDWINDOW); + SetWindowPlacement(g_hWnd, &g_wpPrev); + SetWindowPos(g_hWnd, NULL, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED); + } + g_isFullscreen = !g_isFullscreen; +} + +//-------------------------------------------------------------------------------------- // Clean up the objects we've created //-------------------------------------------------------------------------------------- void CleanupDevice() @@ -1149,8 +1183,14 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, KMInput.SetCapture(true); } } + + // F11 toggles fullscreen + if (KMInput.IsKeyPressed(VK_F11)) + { + ToggleFullscreen(); + } + #if 0 - PIXBeginNamedEvent(0,"Profile load check"); // has the game defined profile data been changed (by a profile load) if(app.uiGameDefinedDataChangedBitmask!=0) { |
