void SetWindowSize(int zoom) { AssertCurrentThreadName("Main"); RECT rc, rcOuter; // Actually, auto mode should be more granular... if (g_Config.IsPortrait()) { GetWindowRectAtResolution(272 * (int)zoom, 480 * (int)zoom, rc, rcOuter); } else { GetWindowRectAtResolution(480 * (int)zoom, 272 * (int)zoom, rc, rcOuter); } MoveWindow(hwndMain, rcOuter.left, rcOuter.top, rcOuter.right - rcOuter.left, rcOuter.bottom - rcOuter.top, TRUE); }
RECT DetermineWindowRectangle() { RECT rc; const int screenWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN); const int screenHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN); const int screenX = GetSystemMetrics(SM_XVIRTUALSCREEN); const int screenY = GetSystemMetrics(SM_YVIRTUALSCREEN); if (!g_Config.bFullScreen) { bool visibleHorizontally = ((g_Config.iWindowX + g_Config.iWindowWidth) >= screenX) && ((g_Config.iWindowX + g_Config.iWindowWidth) < (screenWidth + g_Config.iWindowWidth)); bool visibleVertically = ((g_Config.iWindowY + g_Config.iWindowHeight) >= screenY) && ((g_Config.iWindowY + g_Config.iWindowHeight) < (screenHeight + g_Config.iWindowHeight)); if (!visibleHorizontally) g_Config.iWindowX = -1; if (!visibleVertically) g_Config.iWindowY = -1; } rc.left = g_Config.iWindowX; rc.top = g_Config.iWindowY; // First, get the w/h right. if (g_Config.iWindowWidth <= 0 || g_Config.iWindowHeight <= 0) { RECT rcInner = rc, rcOuter; bool portrait = g_Config.IsPortrait(); GetWindowRectAtResolution(2 * (portrait ? 272 : 480), 2 * (portrait ? 480 : 272), rcInner, rcOuter); rc.right = rc.left + (rcOuter.right - rcOuter.left); rc.bottom = rc.top + (rcOuter.bottom - rcOuter.top); g_Config.iWindowWidth = rc.right - rc.left; g_Config.iWindowHeight = rc.bottom - rc.top; } else { rc.right = rc.left + g_Config.iWindowWidth; rc.bottom = rc.top + g_Config.iWindowHeight; } // Then center if necessary. if (g_Config.iWindowX == -1 && g_Config.iWindowY == -1) { // Center the window. const int primaryScreenWidth = GetSystemMetrics(SM_CXSCREEN); const int primaryScreenHeight = GetSystemMetrics(SM_CYSCREEN); g_Config.iWindowX = (primaryScreenWidth - g_Config.iWindowWidth) / 2; g_Config.iWindowY = (primaryScreenHeight - g_Config.iWindowHeight) / 2; rc.left = g_Config.iWindowX; rc.top = g_Config.iWindowY; rc.right = rc.left + g_Config.iWindowWidth; rc.bottom = rc.top + g_Config.iWindowHeight; } return rc; }