diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 6b7ad8a3..855ee42e 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -70,7 +70,7 @@ GraphicsWidth=0 GraphicsHeight=0 ;Window position data. Do not modify -;Set to -1 or 0 to reset if the window position is incorrect +;Set to -1 or 0 to reset the window position to the center or top-left corner WindowData=-1 ;Uncomment the option to use a hardware shader (requires DX9 graphics mode) @@ -888,7 +888,7 @@ AlwaysFindScripts=0 Test_ForceFloats=0 ;These options control what output is saved in the debug log (sfall-log.txt) -;Prints messages duing sfall initialization +;Prints messages during sfall initialization Init=1 ;Prints messages relating to hook scripts Hook=0 @@ -909,6 +909,7 @@ Fixes=1 ConsoleWindow=0b0000 ;Console window position and size data. Do not modify +;Clear the data to reset the window position and size ConsoleWindowData= ;Set the code page for the console window (Default is your system code page) diff --git a/sfall/ConsoleWindow.cpp b/sfall/ConsoleWindow.cpp index f2bf116c..5194a0cc 100644 --- a/sfall/ConsoleWindow.cpp +++ b/sfall/ConsoleWindow.cpp @@ -53,10 +53,6 @@ BOOL WINAPI ConsoleCtrlHandler(DWORD dwCtrlType) { } void ConsoleWindow::loadPosition() { - auto windowDataStr = IniReader::GetStringDefaultConfig(IniSection, IniPositionKey, ""); - auto windowDataSplit = split(windowDataStr, ','); - if (windowDataSplit.size() < 4) return; - HWND wnd; if (!tryGetWindow(&wnd)) return; @@ -67,16 +63,17 @@ void ConsoleWindow::loadPosition() { dlog_f("Error setting console ctrl handler: 0x%x\n", DL_MAIN, GetLastError()); } + auto windowDataStr = IniReader::GetStringDefaultConfig(IniSection, IniPositionKey, ""); + auto windowDataSplit = split(windowDataStr, ','); + int windowData[5]; for (size_t i = 0; i < 5; i++) { windowData[i] = i < windowDataSplit.size() ? atoi(windowDataSplit.at(i).c_str()) : 0; } - int screenWidth = GetSystemMetrics(SM_CXSCREEN), - screenHeight = GetSystemMetrics(SM_CYSCREEN); - LONG w = min(max(windowData[2], 640), screenWidth), - h = min(max(windowData[3], 480), screenHeight), - x = min(max(windowData[0], -w/2), screenWidth - w/2), - y = min(max(windowData[1], 0), screenHeight - h/2); + LONG w = max(windowData[2], 640), + h = max(windowData[3], 480), + x = windowData[0], + y = windowData[1]; UINT showCmd = windowData[4] != 0 ? windowData[4] : SW_SHOWNORMAL; dlog_f("Setting console window position: (%d, %d), size: %dx%d, showCmd: %d\n", DL_MAIN, x, y, w, h, showCmd);