2020-11-06 16:56:32 +03:00
|
|
|
#include "pch.h"
|
|
|
|
#include "fullscrn.h"
|
2021-02-06 16:53:47 +03:00
|
|
|
|
2021-02-09 18:09:44 +03:00
|
|
|
|
|
|
|
#include "options.h"
|
2021-02-06 16:53:47 +03:00
|
|
|
#include "pb.h"
|
2020-11-16 17:12:31 +03:00
|
|
|
#include "render.h"
|
|
|
|
#include "winmain.h"
|
2020-11-06 16:56:32 +03:00
|
|
|
|
|
|
|
|
|
|
|
int fullscrn::screen_mode;
|
|
|
|
HWND fullscrn::hWnd;
|
2020-11-16 17:12:31 +03:00
|
|
|
tagRECT fullscrn::WindowRect1, fullscrn::WindowRect2;
|
|
|
|
rectangle_type fullscrn::WHRect;
|
2020-11-06 16:56:32 +03:00
|
|
|
int fullscrn::fullscrn_flag1;
|
|
|
|
int fullscrn::display_changed;
|
2021-02-15 18:55:54 +03:00
|
|
|
int fullscrn::ChangeDisplay, fullscrn::ignoreNextDisplayChangeFg;
|
2021-01-01 16:14:11 +03:00
|
|
|
int fullscrn::trick = 1;
|
2020-11-06 16:56:32 +03:00
|
|
|
int fullscrn::MenuEnabled;
|
|
|
|
HMENU fullscrn::MenuHandle;
|
2021-02-06 16:53:47 +03:00
|
|
|
int fullscrn::resolution = 0;
|
|
|
|
int fullscrn::maxResolution = 0;
|
|
|
|
const resolution_info fullscrn::resolution_array[3] =
|
|
|
|
{
|
|
|
|
{640, 480, 600, 416, 501},
|
|
|
|
{800, 600, 752, 520, 502},
|
|
|
|
{1024, 768, 960, 666, 503},
|
|
|
|
};
|
2021-02-09 18:09:44 +03:00
|
|
|
float fullscrn::ScaleX = 1;
|
|
|
|
float fullscrn::ScaleY = 1;
|
2021-09-07 10:09:07 +03:00
|
|
|
int fullscrn::OffsetX = 0;
|
|
|
|
int fullscrn::OffsetY = 0;
|
2020-11-16 17:12:31 +03:00
|
|
|
|
|
|
|
void fullscrn::init(int width, int height, int isFullscreen, HWND winHandle, HMENU menuHandle, int changeDisplay)
|
|
|
|
{
|
|
|
|
WHRect.XPosition = 0;
|
|
|
|
WHRect.YPosition = 0;
|
|
|
|
ChangeDisplay = changeDisplay;
|
|
|
|
hWnd = winHandle;
|
|
|
|
MenuHandle = menuHandle;
|
|
|
|
WHRect.Width = width;
|
|
|
|
WHRect.Height = height;
|
|
|
|
|
|
|
|
GetWindowRect(GetDesktopWindow(), &fullscrn::WindowRect1);
|
|
|
|
int widht2 = width + 2 * GetSystemMetrics(SM_CXBORDER);
|
|
|
|
int height2 = height + 2 * GetSystemMetrics(SM_CYBORDER);
|
|
|
|
int menuHeight = GetSystemMetrics(SM_CYMENU);
|
|
|
|
int captionHeight = GetSystemMetrics(SM_CYCAPTION);
|
|
|
|
int borderHeight = WindowRect1.bottom - WindowRect1.top - height2;
|
|
|
|
|
|
|
|
WindowRect2.bottom = borderHeight / 2 - 2 + height2 + 4;
|
|
|
|
WindowRect2.right = (WindowRect1.right - WindowRect1.left - widht2) / 2 - 2 + widht2 + 4;
|
|
|
|
WindowRect2.left = (WindowRect1.right - WindowRect1.left - widht2) / 2 - 2;
|
|
|
|
WindowRect2.top = borderHeight / 2 - (captionHeight + menuHeight) - 2;
|
2021-02-09 18:09:44 +03:00
|
|
|
|
|
|
|
/*RECT client{0,0,width,height};
|
|
|
|
AdjustWindowRect(&client, winmain::WndStyle, true);*/
|
2020-11-16 17:12:31 +03:00
|
|
|
MoveWindow(
|
|
|
|
hWnd,
|
|
|
|
(WindowRect1.right - WindowRect1.left - widht2) / 2 - 2,
|
|
|
|
WindowRect2.top,
|
2021-02-09 18:09:44 +03:00
|
|
|
WindowRect2.right - WindowRect2.left + 10,
|
2020-12-27 18:19:36 +03:00
|
|
|
WindowRect2.bottom - WindowRect2.top + 10,
|
2020-11-16 17:12:31 +03:00
|
|
|
0);
|
2020-12-27 18:19:36 +03:00
|
|
|
// Todo: WH + 10 hack: original request 640x480 window but somehow receives 650x490, even thought spyxx says it is 640x480
|
2020-11-16 17:12:31 +03:00
|
|
|
fullscrn_flag1 = 0;
|
2021-02-09 18:09:44 +03:00
|
|
|
|
|
|
|
window_size_changed();
|
|
|
|
assertm(ScaleX == 1 && ScaleY == 1, "Wrong default client size");
|
2020-11-16 17:12:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void fullscrn::shutdown()
|
|
|
|
{
|
|
|
|
if (display_changed)
|
|
|
|
set_screen_mode(0);
|
|
|
|
}
|
2020-11-06 16:56:32 +03:00
|
|
|
|
|
|
|
int fullscrn::set_screen_mode(int isFullscreen)
|
|
|
|
{
|
|
|
|
int result = isFullscreen;
|
|
|
|
if (isFullscreen == screen_mode)
|
|
|
|
return result;
|
|
|
|
screen_mode = isFullscreen;
|
|
|
|
if (isFullscreen)
|
|
|
|
{
|
|
|
|
if (IsWindowVisible(hWnd))
|
2020-11-16 17:12:31 +03:00
|
|
|
GetWindowRect(hWnd, &WindowRect2);
|
2020-11-06 16:56:32 +03:00
|
|
|
enableFullscreen();
|
|
|
|
BYTE1(fullscrn_flag1) |= 0x80u;
|
|
|
|
InvalidateRect(hWnd, nullptr, 1);
|
|
|
|
set_menu_mode(0);
|
|
|
|
result = disableWindowFlagsDisDlg();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
disableFullscreen();
|
|
|
|
BYTE1(fullscrn_flag1) |= 0x80u;
|
|
|
|
InvalidateRect(hWnd, nullptr, 1);
|
|
|
|
set_menu_mode(1);
|
|
|
|
result = RedrawWindow(nullptr, nullptr, nullptr, 0x185u);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int fullscrn::disableWindowFlagsDisDlg()
|
|
|
|
{
|
|
|
|
long style = GetWindowLongA(hWnd, -16);
|
2021-02-09 18:09:44 +03:00
|
|
|
return SetWindowLongA(hWnd, -16, style & ~(WS_CAPTION | WS_THICKFRAME));
|
2020-11-06 16:56:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int fullscrn::setWindowFlagsDisDlg()
|
|
|
|
{
|
|
|
|
int style = GetWindowLongA(hWnd, -16);
|
2021-02-09 18:09:44 +03:00
|
|
|
return SetWindowLongA(hWnd, -16, style | WS_CAPTION | WS_THICKFRAME);
|
2020-11-06 16:56:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int fullscrn::enableFullscreen()
|
|
|
|
{
|
2020-12-27 18:19:36 +03:00
|
|
|
tagRECT Rect{};
|
|
|
|
DEVMODEA DevMode{};
|
2020-11-06 16:56:32 +03:00
|
|
|
|
|
|
|
if (ChangeDisplay && !display_changed)
|
|
|
|
{
|
2021-02-15 18:55:54 +03:00
|
|
|
DevMode.dmSize = sizeof DevMode;
|
|
|
|
DevMode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
2021-02-06 16:53:47 +03:00
|
|
|
DevMode.dmPelsWidth = resolution_array[resolution].ScreenWidth;
|
|
|
|
DevMode.dmPelsHeight = resolution_array[resolution].ScreenHeight;
|
|
|
|
DevMode.dmBitsPerPel = 32;
|
2020-11-06 16:56:32 +03:00
|
|
|
disableWindowFlagsDisDlg();
|
|
|
|
if (trick)
|
|
|
|
{
|
|
|
|
GetWindowRect(GetDesktopWindow(), &Rect);
|
2021-02-15 18:55:54 +03:00
|
|
|
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, Rect.right - Rect.left + 1,
|
|
|
|
Rect.bottom - Rect.top + 1, SWP_NOREDRAW);
|
2020-11-06 16:56:32 +03:00
|
|
|
}
|
2021-02-15 18:55:54 +03:00
|
|
|
ignoreNextDisplayChangeFg = 1;
|
|
|
|
LONG changeDispResult = ChangeDisplaySettingsA(&DevMode, CDS_FULLSCREEN);
|
|
|
|
if (changeDispResult == DISP_CHANGE_RESTART)
|
2020-11-06 16:56:32 +03:00
|
|
|
{
|
2021-02-15 18:55:54 +03:00
|
|
|
DevMode.dmFields &= ~DM_BITSPERPEL;
|
|
|
|
ignoreNextDisplayChangeFg = 1;
|
|
|
|
changeDispResult = ChangeDisplaySettingsA(&DevMode, CDS_FULLSCREEN);
|
2020-11-06 16:56:32 +03:00
|
|
|
}
|
2021-02-15 18:55:54 +03:00
|
|
|
display_changed = changeDispResult == DISP_CHANGE_SUCCESSFUL;
|
|
|
|
if (display_changed)
|
2020-11-06 16:56:32 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
GetWindowRect(GetDesktopWindow(), &Rect);
|
|
|
|
disableWindowFlagsDisDlg();
|
2021-02-15 18:55:54 +03:00
|
|
|
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, Rect.right - Rect.left + 1, Rect.bottom - Rect.top + 1, SWP_NOREDRAW);
|
2020-11-06 16:56:32 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int fullscrn::disableFullscreen()
|
|
|
|
{
|
|
|
|
if (display_changed)
|
|
|
|
{
|
|
|
|
display_changed = 0;
|
2021-02-15 18:55:54 +03:00
|
|
|
ignoreNextDisplayChangeFg = 1;
|
|
|
|
ChangeDisplaySettingsA(nullptr, CDS_FULLSCREEN);
|
2020-11-06 16:56:32 +03:00
|
|
|
if (trick)
|
2021-02-15 18:55:54 +03:00
|
|
|
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
|
2020-11-06 16:56:32 +03:00
|
|
|
}
|
|
|
|
setWindowFlagsDisDlg();
|
|
|
|
SetWindowPos(
|
|
|
|
hWnd,
|
2021-02-15 18:55:54 +03:00
|
|
|
HWND_TOP,
|
2020-11-16 17:12:31 +03:00
|
|
|
WindowRect2.left,
|
|
|
|
WindowRect2.top,
|
|
|
|
WindowRect2.right - WindowRect2.left,
|
|
|
|
WindowRect2.bottom - WindowRect2.top,
|
2021-02-15 18:55:54 +03:00
|
|
|
SWP_NOZORDER | SWP_NOACTIVATE);
|
2020-11-06 16:56:32 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool fullscrn::set_menu_mode(int menuEnabled)
|
|
|
|
{
|
2020-12-27 18:19:36 +03:00
|
|
|
BOOL result;
|
2020-11-06 16:56:32 +03:00
|
|
|
|
|
|
|
MenuEnabled = menuEnabled;
|
|
|
|
GetWindowCenter();
|
|
|
|
if (MenuEnabled)
|
|
|
|
{
|
|
|
|
fullscrn_flag1 |= 2u;
|
|
|
|
InvalidateRect(hWnd, nullptr, 1);
|
|
|
|
result = SetMenu(hWnd, MenuHandle);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fullscrn_flag1 |= 1u;
|
|
|
|
InvalidateRect(hWnd, nullptr, 1);
|
|
|
|
result = SetMenu(hWnd, nullptr);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fullscrn::GetWindowCenter()
|
|
|
|
{
|
2020-12-27 18:19:36 +03:00
|
|
|
int yPos;
|
|
|
|
tagRECT Rect{};
|
2020-11-06 16:56:32 +03:00
|
|
|
|
|
|
|
if (screen_mode)
|
|
|
|
{
|
2020-11-16 17:12:31 +03:00
|
|
|
GetWindowRect(GetDesktopWindow(), &Rect);
|
|
|
|
render::vscreen.XPosition = (Rect.right - render::vscreen.Width - Rect.left) / 2;
|
|
|
|
yPos = (Rect.bottom - render::vscreen.Height - Rect.top) / 2;
|
2020-11-06 16:56:32 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-16 17:12:31 +03:00
|
|
|
render::vscreen.XPosition = 0;
|
|
|
|
yPos = GetSystemMetrics(15);
|
2020-11-06 16:56:32 +03:00
|
|
|
}
|
2020-11-16 17:12:31 +03:00
|
|
|
render::vscreen.YPosition = yPos;
|
2020-11-06 16:56:32 +03:00
|
|
|
if (MenuEnabled)
|
2020-11-16 17:12:31 +03:00
|
|
|
render::vscreen.YPosition -= GetSystemMetrics(15);
|
2020-11-06 16:56:32 +03:00
|
|
|
}
|
2020-11-07 18:41:14 +03:00
|
|
|
|
|
|
|
void fullscrn::force_redraw()
|
|
|
|
{
|
|
|
|
BYTE1(fullscrn_flag1) |= 0x80u;
|
2020-11-16 17:12:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void fullscrn::center_in(HWND parent, HWND child)
|
|
|
|
{
|
2020-12-27 18:19:36 +03:00
|
|
|
LONG right;
|
2020-11-16 17:12:31 +03:00
|
|
|
tagRECT childRect{}, parentRect{}, desktopRect{};
|
|
|
|
|
|
|
|
GetWindowRect(parent, &parentRect);
|
|
|
|
GetWindowRect(child, &childRect);
|
|
|
|
GetWindowRect(GetDesktopWindow(), &desktopRect);
|
|
|
|
if (display_changed)
|
|
|
|
{
|
|
|
|
desktopRect.bottom = 480;
|
|
|
|
desktopRect.left = 0;
|
|
|
|
desktopRect.top = 0;
|
|
|
|
right = 640;
|
|
|
|
desktopRect.right = 640;
|
|
|
|
parentRect.left = 0;
|
|
|
|
parentRect.top = 0;
|
|
|
|
parentRect.right = 640;
|
|
|
|
parentRect.bottom = 480;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
right = desktopRect.right;
|
|
|
|
}
|
|
|
|
|
|
|
|
int childHeight = childRect.bottom - childRect.top;
|
|
|
|
int smthWidth = parentRect.left + (parentRect.right + childRect.left - childRect.right - parentRect.left) / 2;
|
|
|
|
int smthHeight = parentRect.top + (parentRect.bottom + childRect.top - childRect.bottom - parentRect.top) / 2;
|
|
|
|
if (childRect.right - childRect.left + smthWidth > right)
|
|
|
|
smthWidth = right - (childRect.right - childRect.left);
|
|
|
|
if (childHeight + smthHeight > desktopRect.bottom)
|
|
|
|
smthHeight = desktopRect.bottom - childHeight;
|
|
|
|
if (smthWidth < desktopRect.left)
|
|
|
|
smthWidth = desktopRect.left;
|
|
|
|
if (smthHeight < desktopRect.top)
|
|
|
|
smthHeight = desktopRect.top;
|
|
|
|
MoveWindow(child, smthWidth, smthHeight, childRect.right - childRect.left, childRect.bottom - childRect.top, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int fullscrn::displaychange()
|
|
|
|
{
|
|
|
|
int result = 0;
|
2021-02-15 18:55:54 +03:00
|
|
|
if (ignoreNextDisplayChangeFg)
|
2020-11-16 17:12:31 +03:00
|
|
|
{
|
2021-02-15 18:55:54 +03:00
|
|
|
ignoreNextDisplayChangeFg = 0;
|
2020-11-16 17:12:31 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (screen_mode && display_changed)
|
|
|
|
{
|
|
|
|
display_changed = 0;
|
|
|
|
screen_mode = 0;
|
|
|
|
setWindowFlagsDisDlg();
|
|
|
|
BYTE1(fullscrn_flag1) |= 0x80u;
|
|
|
|
InvalidateRect(hWnd, nullptr, 1);
|
|
|
|
set_menu_mode(1);
|
|
|
|
SetWindowPos(
|
|
|
|
hWnd,
|
2021-02-15 18:55:54 +03:00
|
|
|
HWND_TOP,
|
2020-11-16 17:12:31 +03:00
|
|
|
WindowRect2.left,
|
|
|
|
WindowRect2.top,
|
|
|
|
WindowRect2.right - WindowRect2.left,
|
|
|
|
WindowRect2.bottom - WindowRect2.top,
|
2021-02-15 18:55:54 +03:00
|
|
|
SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE);
|
2020-11-16 17:12:31 +03:00
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetWindowPos(
|
|
|
|
hWnd,
|
2021-02-15 18:55:54 +03:00
|
|
|
HWND_TOP,
|
2020-11-16 17:12:31 +03:00
|
|
|
WindowRect2.left,
|
|
|
|
WindowRect2.top,
|
|
|
|
WindowRect2.right - WindowRect2.left,
|
|
|
|
WindowRect2.bottom - WindowRect2.top,
|
2021-02-15 18:55:54 +03:00
|
|
|
SWP_NOZORDER | SWP_NOACTIVATE);
|
2020-11-16 17:12:31 +03:00
|
|
|
}
|
|
|
|
center_in(GetDesktopWindow(), hWnd);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fullscrn::activate(int flag)
|
|
|
|
{
|
|
|
|
if (screen_mode)
|
|
|
|
{
|
|
|
|
if (!flag)
|
|
|
|
{
|
|
|
|
set_screen_mode(0);
|
2021-02-15 18:55:54 +03:00
|
|
|
SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
|
2020-11-16 17:12:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-16 19:03:45 +03:00
|
|
|
void fullscrn::fillRect(int right, int bottom, int left, int top)
|
2020-11-16 17:12:31 +03:00
|
|
|
{
|
|
|
|
RECT rc;
|
2021-02-16 19:03:45 +03:00
|
|
|
auto brush = CreateSolidBrush(0);
|
2020-11-16 17:12:31 +03:00
|
|
|
if (brush)
|
|
|
|
{
|
2021-02-16 19:03:45 +03:00
|
|
|
auto dc = winmain::_GetDC(hWnd);
|
2020-11-16 17:12:31 +03:00
|
|
|
if (dc)
|
|
|
|
{
|
2021-02-18 12:53:25 +03:00
|
|
|
auto prevBrush = SelectObject(dc, brush);
|
2021-02-16 19:03:45 +03:00
|
|
|
rc.right = left + right + 1;
|
|
|
|
rc.bottom = top + bottom + 1;
|
|
|
|
rc.left = left;
|
|
|
|
rc.top = top;
|
|
|
|
FillRect(dc, &rc, brush);
|
2021-02-18 12:53:25 +03:00
|
|
|
SelectObject(dc, prevBrush);
|
2020-11-16 17:12:31 +03:00
|
|
|
ReleaseDC(hWnd, dc);
|
|
|
|
}
|
|
|
|
DeleteObject(brush);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-06 17:06:13 +03:00
|
|
|
unsigned fullscrn::convert_mouse_pos(unsigned int mouseXY)
|
2020-11-16 17:12:31 +03:00
|
|
|
{
|
2021-02-16 19:03:45 +03:00
|
|
|
uint16_t x = mouseXY & 0xffFF - render::vscreen.XPosition;
|
|
|
|
uint16_t y = (mouseXY >> 16) - render::vscreen.YPosition;
|
2020-11-16 17:12:31 +03:00
|
|
|
return x | y << 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fullscrn::getminmaxinfo(MINMAXINFO* maxMin)
|
|
|
|
{
|
2021-02-09 18:09:44 +03:00
|
|
|
/*Block down-scaling lower than min resolution*/
|
|
|
|
maxMin->ptMinTrackSize = POINT
|
|
|
|
{
|
|
|
|
resolution_array[0].ScreenWidth / 2,
|
|
|
|
resolution_array[0].ScreenHeight / 2
|
|
|
|
};
|
2020-11-16 17:12:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void fullscrn::paint()
|
|
|
|
{
|
|
|
|
int menuHeight;
|
|
|
|
if (screen_mode)
|
|
|
|
{
|
|
|
|
if ((fullscrn_flag1 & 0x8000) == 0 && fullscrn_flag1)
|
|
|
|
{
|
|
|
|
if (fullscrn_flag1 & 1)
|
|
|
|
{
|
|
|
|
menuHeight = GetSystemMetrics(SM_CYMENU);
|
2021-02-16 19:03:45 +03:00
|
|
|
fillRect(WindowRect1.right - 1, menuHeight, 0, 0);
|
2020-11-16 17:12:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (MenuEnabled)
|
|
|
|
menuHeight = GetSystemMetrics(SM_CYMENU);
|
|
|
|
else
|
|
|
|
menuHeight = 0;
|
2021-02-16 19:03:45 +03:00
|
|
|
fillRect(WindowRect1.right, menuHeight + WindowRect1.bottom, 0, 0);
|
2020-11-16 17:12:31 +03:00
|
|
|
}
|
|
|
|
}
|
2021-10-30 18:25:49 +03:00
|
|
|
pb::paint();
|
2020-11-16 17:12:31 +03:00
|
|
|
fullscrn_flag1 = 0;
|
|
|
|
}
|
2021-02-06 16:53:47 +03:00
|
|
|
|
|
|
|
int fullscrn::GetResolution()
|
|
|
|
{
|
|
|
|
return resolution;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fullscrn::SetResolution(int resolution)
|
|
|
|
{
|
|
|
|
if (!pb::FullTiltMode)
|
|
|
|
resolution = 0;
|
|
|
|
assertm(resolution >= 0 && resolution <= 2, "Resolution value out of bounds");
|
|
|
|
fullscrn::resolution = resolution;
|
|
|
|
}
|
|
|
|
|
|
|
|
int fullscrn::GetMaxResolution()
|
|
|
|
{
|
|
|
|
return maxResolution;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fullscrn::SetMaxResolution(int resolution)
|
|
|
|
{
|
|
|
|
assertm(resolution >= 0 && resolution <= 2, "Resolution value out of bounds");
|
|
|
|
maxResolution = resolution;
|
|
|
|
}
|
|
|
|
|
|
|
|
int fullscrn::get_max_supported_resolution()
|
|
|
|
{
|
|
|
|
if (!pb::FullTiltMode)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
auto resolutionWH = get_screen_resolution();
|
|
|
|
auto width = LOWORD(resolutionWH);
|
|
|
|
auto height = HIWORD(resolutionWH);
|
|
|
|
auto result = 0;
|
|
|
|
|
|
|
|
for (auto index = 1; index < 3; ++index)
|
|
|
|
{
|
|
|
|
auto resPtr = &resolution_array[index];
|
|
|
|
if (resPtr->ScreenWidth <= width && resPtr->ScreenHeight <= height)
|
|
|
|
result = index;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
int fullscrn::get_screen_resolution()
|
|
|
|
{
|
2021-02-16 19:03:45 +03:00
|
|
|
auto height = static_cast<uint16_t>(GetSystemMetrics(SM_CYSCREEN));
|
|
|
|
return static_cast<uint16_t>(GetSystemMetrics(SM_CXSCREEN)) | (height << 16);
|
2021-02-06 16:53:47 +03:00
|
|
|
}
|
2021-02-09 18:09:44 +03:00
|
|
|
|
|
|
|
void fullscrn::window_size_changed()
|
|
|
|
{
|
|
|
|
/*No scaling in fullscreen mode*/
|
|
|
|
if (display_changed)
|
|
|
|
{
|
|
|
|
ScaleY = ScaleX = 1;
|
|
|
|
OffsetX = OffsetY = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RECT client{};
|
|
|
|
GetClientRect(hWnd, &client);
|
|
|
|
auto res = &resolution_array[resolution];
|
|
|
|
ScaleX = static_cast<float>(client.right) / res->TableWidth;
|
|
|
|
ScaleY = static_cast<float>(client.bottom) / res->TableHeight;
|
|
|
|
OffsetX = OffsetY = 0;
|
|
|
|
|
|
|
|
if (options::Options.UniformScaling)
|
|
|
|
{
|
|
|
|
ScaleY = ScaleX = min(ScaleX, ScaleY);
|
2021-09-07 10:09:07 +03:00
|
|
|
OffsetX = static_cast<int>(floor((client.right - res->TableWidth * ScaleX) / 2));
|
|
|
|
OffsetY = static_cast<int>(floor((client.bottom - res->TableHeight * ScaleY) / 2));
|
2021-02-09 18:09:44 +03:00
|
|
|
}
|
|
|
|
}
|