mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
Update Windows64_Minecraft.cpp
Observe if the Fullscreen state has changed for any reason and will write it.
This commit is contained in:
parent
59a62aaaf0
commit
407d886336
|
|
@ -96,6 +96,44 @@ wchar_t g_Win64UsernameW[17] = { 0 };
|
||||||
// Fullscreen toggle state
|
// Fullscreen toggle state
|
||||||
static bool g_isFullscreen = false;
|
static bool g_isFullscreen = false;
|
||||||
static WINDOWPLACEMENT g_wpPrev = { sizeof(g_wpPrev) };
|
static WINDOWPLACEMENT g_wpPrev = { sizeof(g_wpPrev) };
|
||||||
|
extern HWND g_hWnd;
|
||||||
|
static void SaveFullscreenOption(bool fullscreen);
|
||||||
|
|
||||||
|
static bool IsWindowBorderlessFullscreen(HWND hWnd)
|
||||||
|
{
|
||||||
|
if (hWnd == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
DWORD dwStyle = GetWindowLong(hWnd, GWL_STYLE);
|
||||||
|
if (dwStyle & WS_OVERLAPPEDWINDOW)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
RECT windowRect = {};
|
||||||
|
if (!GetWindowRect(hWnd, &windowRect))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
MONITORINFO mi = { sizeof(mi) };
|
||||||
|
if (!GetMonitorInfo(MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST), &mi))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return EqualRect(&windowRect, &mi.rcMonitor) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PersistFullscreenStateIfChanged()
|
||||||
|
{
|
||||||
|
static bool s_hasSavedState = false;
|
||||||
|
static bool s_lastSavedState = false;
|
||||||
|
|
||||||
|
const bool currentState = IsWindowBorderlessFullscreen(g_hWnd);
|
||||||
|
g_isFullscreen = currentState;
|
||||||
|
|
||||||
|
if (!s_hasSavedState || s_lastSavedState != currentState)
|
||||||
|
{
|
||||||
|
SaveFullscreenOption(currentState);
|
||||||
|
s_lastSavedState = currentState;
|
||||||
|
s_hasSavedState = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
// Update the Aspect Ratio to support Any Aspect Ratio
|
// Update the Aspect Ratio to support Any Aspect Ratio
|
||||||
|
|
@ -911,8 +949,11 @@ void Render()
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
void ToggleFullscreen()
|
void ToggleFullscreen()
|
||||||
{
|
{
|
||||||
|
const bool isFullscreenNow = IsWindowBorderlessFullscreen(g_hWnd);
|
||||||
|
g_isFullscreen = isFullscreenNow;
|
||||||
|
|
||||||
DWORD dwStyle = GetWindowLong(g_hWnd, GWL_STYLE);
|
DWORD dwStyle = GetWindowLong(g_hWnd, GWL_STYLE);
|
||||||
if (!g_isFullscreen)
|
if (!isFullscreenNow)
|
||||||
{
|
{
|
||||||
MONITORINFO mi = { sizeof(mi) };
|
MONITORINFO mi = { sizeof(mi) };
|
||||||
if (GetWindowPlacement(g_hWnd, &g_wpPrev) &&
|
if (GetWindowPlacement(g_hWnd, &g_wpPrev) &&
|
||||||
|
|
@ -933,8 +974,8 @@ void ToggleFullscreen()
|
||||||
SetWindowPos(g_hWnd, NULL, 0, 0, 0, 0,
|
SetWindowPos(g_hWnd, NULL, 0, 0, 0, 0,
|
||||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||||
}
|
}
|
||||||
g_isFullscreen = !g_isFullscreen;
|
|
||||||
SaveFullscreenOption(g_isFullscreen);
|
g_isFullscreen = IsWindowBorderlessFullscreen(g_hWnd);
|
||||||
|
|
||||||
if (g_KBMInput.IsWindowFocused())
|
if (g_KBMInput.IsWindowFocused())
|
||||||
g_KBMInput.SetWindowFocused(true);
|
g_KBMInput.SetWindowFocused(true);
|
||||||
|
|
@ -1621,6 +1662,8 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
ToggleFullscreen();
|
ToggleFullscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PersistFullscreenStateIfChanged();
|
||||||
|
|
||||||
// TAB opens game info menu. - Vvis :3 - Updated by detectiveren
|
// TAB opens game info menu. - Vvis :3 - Updated by detectiveren
|
||||||
if (g_KBMInput.IsKeyPressed(VK_TAB) && !ui.GetMenuDisplayed(0))
|
if (g_KBMInput.IsKeyPressed(VK_TAB) && !ui.GetMenuDisplayed(0))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue