Window and resolution resize
- determines the size of the monitor - starts the window with the resolution settings taken from the config.cpp. - sets maximum size to monitor's resolution and minimum size to 800/600 - resizes the window to 800/600 (instead of using the size from the config.cpp) - starts the game and determines the actual width/height of the game. If the game uses a resolution lower than 800/600 it upscales it, if is higher adjusts automatically - Had to add a "firstrun" value/check to fix a strange behavior/bug? (when entering/exiting fullscreen) in linux.
This commit is contained in:
parent
12b824903c
commit
a6bfcd4efe
|
@ -105,6 +105,8 @@ EventThread::EventThread()
|
|||
showCursor(false)
|
||||
{}
|
||||
|
||||
SDL_DisplayMode dm = {0};
|
||||
|
||||
void EventThread::process(RGSSThreadData &rtData)
|
||||
{
|
||||
SDL_Event event;
|
||||
|
@ -119,6 +121,16 @@ void EventThread::process(RGSSThreadData &rtData)
|
|||
#endif
|
||||
|
||||
fullscreen = rtData.config.fullscreen;
|
||||
int defScreenW, defScreenH;
|
||||
defScreenW = rtData.config.defScreenW;
|
||||
defScreenH = rtData.config.defScreenH;
|
||||
SDL_GetDesktopDisplayMode(0, &dm);
|
||||
SDL_SetWindowMaximumSize(win, dm.w, dm.h);
|
||||
SDL_SetWindowMinimumSize(win, 800, 600);
|
||||
SDL_SetWindowSize(win, 800, 600);
|
||||
int defScreenW_new, defScreenH_new;
|
||||
int firstrun;
|
||||
firstrun = 0;
|
||||
int toggleFSMod = rtData.config.anyAltToggleFS ? KMOD_ALT : KMOD_LALT;
|
||||
|
||||
fps.lastFrame = SDL_GetPerformanceCounter();
|
||||
|
@ -206,6 +218,16 @@ void EventThread::process(RGSSThreadData &rtData)
|
|||
case SDL_WINDOWEVENT_SIZE_CHANGED :
|
||||
winW = event.window.data1;
|
||||
winH = event.window.data2;
|
||||
if (firstrun == 1)
|
||||
{
|
||||
firstrun = 2;
|
||||
SDL_SetWindowPosition(win, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||
}
|
||||
if (firstrun == 0)
|
||||
{
|
||||
firstrun = 1;
|
||||
SDL_SetWindowPosition(win, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||
}
|
||||
|
||||
windowSizeMsg.post(Vec2i(winW, winH));
|
||||
resetInputStates();
|
||||
|
@ -255,12 +277,27 @@ void EventThread::process(RGSSThreadData &rtData)
|
|||
if (event.key.keysym.scancode == SDL_SCANCODE_RETURN &&
|
||||
(event.key.keysym.mod & toggleFSMod))
|
||||
{
|
||||
if (!fullscreen && firstrun < 2)
|
||||
{
|
||||
firstrun = 2;
|
||||
SDL_SetWindowPosition(win, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||
}
|
||||
setFullscreen(win, !fullscreen);
|
||||
if (!fullscreen && havePendingTitle)
|
||||
{
|
||||
SDL_SetWindowTitle(win, pendingTitle);
|
||||
pendingTitle[0] = '\0';
|
||||
havePendingTitle = false;
|
||||
SDL_SetWindowSize(win, defScreenW_new, defScreenH_new);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_SetWindowSize(win, defScreenW_new, defScreenH_new);
|
||||
}
|
||||
if (firstrun < 2)
|
||||
{
|
||||
firstrun = 2;
|
||||
SDL_SetWindowPosition(win, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -540,6 +577,7 @@ void EventThread::resetInputStates()
|
|||
|
||||
void EventThread::setFullscreen(SDL_Window *win, bool mode)
|
||||
{
|
||||
SDL_GetDesktopDisplayMode(0, &dm);
|
||||
SDL_SetWindowFullscreen
|
||||
(win, mode ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
||||
fullscreen = mode;
|
||||
|
|
Loading…
Reference in New Issue