- Fixed Window Size formula based on factoring value

- Fixed Aspect Ratio Maintaining to be consistent with Window Size behavior changes
This commit is contained in:
amponzi 2007-02-03 00:25:58 +00:00
parent 5db974bd5c
commit 766e4c9c66
1 changed files with 22 additions and 35 deletions

View File

@ -79,9 +79,10 @@ BOOL finished = FALSE;
BOOL romloaded = FALSE; BOOL romloaded = FALSE;
BOOL ForceRatio = FALSE; BOOL ForceRatio = FALSE;
float aspectratio; float DefaultWidth;
int DefaultWidth; float DefaultHeight;
int DefaultHeight; float widthTradeOff;
float heightTradeOff;
HMENU menu; HMENU menu;
HANDLE runthread=INVALID_HANDLE_VALUE; HANDLE runthread=INVALID_HANDLE_VALUE;
@ -203,15 +204,9 @@ void SetWindowClientSize(HWND hwnd, int cx, int cy) //found at: http://blogs.msd
void ScaleScreen(float factor) void ScaleScreen(float factor)
{ {
RECT fullSize,clientSize ;
int widthTradeOff,heightTradeOff ;
GetWindowRect(hwnd,&fullSize) ;
GetClientRect(hwnd,&clientSize) ;
widthTradeOff = (fullSize.right-fullSize.left) - (clientSize.right-fullSize.left) ;
heightTradeOff = (fullSize.bottom-fullSize.top) - (clientSize.bottom-fullSize.top) ;
SetWindowPos(hwnd, NULL, 0, 0, widthTradeOff + DefaultWidth * factor, SetWindowPos(hwnd, NULL, 0, 0, widthTradeOff + DefaultWidth * factor,
heightTradeOff + DefaultHeight * factor, SWP_NOMOVE | SWP_NOZORDER); heightTradeOff + DefaultHeight * factor, SWP_NOMOVE | SWP_NOZORDER);
return;
} }
void translateXY(s32 *x, s32*y) void translateXY(s32 *x, s32*y)
@ -555,12 +550,14 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
{ {
case WM_CREATE: case WM_CREATE:
{ {
RECT fullSize; RECT clientSize, fullSize;
ReadConfig(); ReadConfig();
GetClientRect(hwnd, &fullSize); GetClientRect(hwnd, &clientSize);
DefaultWidth = fullSize.right - fullSize.left; GetWindowRect(hwnd, &fullSize);
DefaultHeight = fullSize.bottom - fullSize.top; DefaultWidth = clientSize.right - clientSize.left;
aspectratio = ((fullSize.right - fullSize.left) * 1.0) / ((fullSize.bottom - fullSize.top) * 1.0); DefaultHeight = clientSize.bottom - clientSize.top;
widthTradeOff = (fullSize.right - fullSize.left) - (clientSize.right - clientSize.left);
heightTradeOff = (fullSize.bottom - fullSize.top) - (clientSize.bottom - clientSize.top);
return 0; return 0;
} }
case WM_DESTROY: case WM_DESTROY:
@ -585,9 +582,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
if (ForceRatio) { if (ForceRatio) {
RECT fullSize; RECT fullSize;
GetWindowRect(hwnd, &fullSize); GetWindowRect(hwnd, &fullSize);
fullSize.right = (fullSize.bottom - fullSize.top) * aspectratio + fullSize.left; ScaleScreen((fullSize.bottom - fullSize.top - heightTradeOff) / DefaultHeight);
SetWindowPos(hwnd, NULL, 0, 0, fullSize.right - fullSize.left,
fullSize.bottom - fullSize.top, SWP_NOMOVE | SWP_NOZORDER);
} }
return 0; return 0;
case WM_CLOSE: case WM_CLOSE:
@ -1343,12 +1338,6 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
CheckMenuItem(menu, IDC_ROTATE180, MF_BYCOMMAND | MF_UNCHECKED); CheckMenuItem(menu, IDC_ROTATE180, MF_BYCOMMAND | MF_UNCHECKED);
CheckMenuItem(menu, IDC_ROTATE270, MF_BYCOMMAND | MF_CHECKED); CheckMenuItem(menu, IDC_ROTATE270, MF_BYCOMMAND | MF_CHECKED);
return 0; return 0;
/*case IDC_MAGNIFY:
ScaleScreen(1.25f) ; //100 -> 125%
break ;
case IDC_DEMAGNIFY:
ScaleScreen(0.8f) ; //125 -> 100% (== 100 -> 80%)
break ; */
case IDC_WINDOW1X: case IDC_WINDOW1X:
ScaleScreen(1); ScaleScreen(1);
break; break;
@ -1369,9 +1358,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
else { else {
RECT fullSize; RECT fullSize;
GetWindowRect(hwnd, &fullSize); GetWindowRect(hwnd, &fullSize);
fullSize.right = (fullSize.bottom - fullSize.top) * aspectratio + fullSize.left; ScaleScreen((fullSize.bottom - fullSize.top - heightTradeOff) / DefaultHeight);
SetWindowPos(hwnd, NULL, 0, 0, fullSize.right - fullSize.left,
fullSize.bottom - fullSize.top, SWP_NOMOVE | SWP_NOZORDER);
CheckMenuItem(menu, IDC_FORCERATIO, MF_BYCOMMAND | MF_CHECKED); CheckMenuItem(menu, IDC_FORCERATIO, MF_BYCOMMAND | MF_CHECKED);
ForceRatio = TRUE; ForceRatio = TRUE;
} }