From 2ec83d29774f0cf3e959cccd785bb1851a99ef71 Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Mon, 23 Jul 2018 13:27:41 +0500 Subject: [PATCH] xrEngine/Device_Initialize.cpp: fixed 'normal' window hit test result to be in a square, not in a cross xrEngine/Device_create.cpp: supported desktop fullscreen for windowed mode, returned support for bordered window xrEngine/device.cpp: don't reset device on event if resolution wasn't really changed; returned -center_screen key xr_ioc_cmd.h: don't crash on token execution if it's null (in other cases such as tips filling it should crash) xrGame/UITalkDialogWnd.cpp: fixed dialog accelerators --- src/xrEngine/Device_Initialize.cpp | 2 +- src/xrEngine/Device_create.cpp | 20 +++++++++++++++++--- src/xrEngine/device.cpp | 5 ++++- src/xrEngine/xr_ioc_cmd.h | 5 +++++ src/xrGame/ui/UITalkDialogWnd.cpp | 2 +- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/xrEngine/Device_Initialize.cpp b/src/xrEngine/Device_Initialize.cpp index 2f60fad85cb..936eada9d66 100644 --- a/src/xrEngine/Device_Initialize.cpp +++ b/src/xrEngine/Device_Initialize.cpp @@ -107,7 +107,7 @@ SDL_HitTestResult WindowHitTest(SDL_Window* /*window*/, const SDL_Point* area, v // Allow drag from any point except window center // For this case, 'hit' is a size of a square in the center if ((area->x > centerX + hit || area->x < centerX - hit) - && (area->y > centerY + hit || area->y < centerY - hit)) + || (area->y > centerY + hit || area->y < centerY - hit)) return SDL_HITTEST_DRAGGABLE; return SDL_HITTEST_NORMAL; diff --git a/src/xrEngine/Device_create.cpp b/src/xrEngine/Device_create.cpp index e8e3b7b681b..ba8ddb031e3 100644 --- a/src/xrEngine/Device_create.cpp +++ b/src/xrEngine/Device_create.cpp @@ -41,6 +41,7 @@ void CRenderDevice::Create() { if (b_is_Ready) return; // prevent double call + Statistic = new CStats(); bool gpuSW = !!strstr(Core.Params, "-gpu_sw"); bool gpuNonPure = !!strstr(Core.Params, "-gpu_nopure"); @@ -63,6 +64,7 @@ void CRenderDevice::Create() Memory.mem_compact(); b_is_Ready = TRUE; + _SetupStates(); string_path fname; FS.update_path(fname, "$game_data$", "shaders.xr"); @@ -76,13 +78,25 @@ void CRenderDevice::UpdateWindowProps(const bool windowed) { SelectResolution(windowed); - SDL_SetWindowFullscreen(m_sdlWnd, windowed ? 0 : SDL_WINDOW_FULLSCREEN); - - // Set window properties depending on what mode were in. if (windowed) + { + u32 width, height; + sscanf(VidModesToken.back().name, "%dx%d", &width, &height); + + const bool drawBorders = strstr(Core.Params, "-draw_borders"); + + bool desktopResolution = false; + if (b_is_Ready && !drawBorders && psCurrentVidMode[0] == width && psCurrentVidMode[1] == height) + desktopResolution = true; + + SDL_SetWindowFullscreen(m_sdlWnd, desktopResolution ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); SDL_SetWindowSize(m_sdlWnd, psCurrentVidMode[0], psCurrentVidMode[1]); + SDL_SetWindowBordered(m_sdlWnd, drawBorders ? SDL_TRUE : SDL_FALSE); + } else { + SDL_SetWindowFullscreen(m_sdlWnd, SDL_WINDOW_FULLSCREEN); + // XXX: fix monitor selection // it appears to be buggy SDL_Rect rect; diff --git a/src/xrEngine/device.cpp b/src/xrEngine/device.cpp index 118fa6a4c9e..9f2c016883a 100644 --- a/src/xrEngine/device.cpp +++ b/src/xrEngine/device.cpp @@ -356,6 +356,9 @@ void CRenderDevice::message_loop() { if (!psDeviceFlags.is(rsFullscreen)) { + if (psCurrentVidMode[0] == event.window.data1 && psCurrentVidMode[1] == event.window.data2) + break; // we don't need to reset device if resolution wasn't really changed + string32 buff; xr_sprintf(buff, sizeof(buff), "vid_mode %dx%d", event.window.data1, event.window.data2); Console->Execute(buff); @@ -416,7 +419,7 @@ void CRenderDevice::Run() seqAppStart.Process(); GEnv.Render->ClearTarget(); splash::hide(); - if (GEnv.isDedicatedServer) + if (GEnv.isDedicatedServer || strstr(Core.Params, "-center_screen")) SDL_SetWindowPosition(m_sdlWnd, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); SDL_HideWindow(m_sdlWnd); SDL_FlushEvents(SDL_WINDOWEVENT, SDL_SYSWMEVENT); diff --git a/src/xrEngine/xr_ioc_cmd.h b/src/xrEngine/xr_ioc_cmd.h index 9c4730c05b8..739ef24db58 100644 --- a/src/xrEngine/xr_ioc_cmd.h +++ b/src/xrEngine/xr_ioc_cmd.h @@ -158,6 +158,11 @@ class ENGINE_API CCC_Token : public IConsole_Command virtual void Execute(LPCSTR args) { const xr_token* tok = GetToken(); + if (!tok) + { + Msg("! token [%s] is null", cName); + return; + } while (tok->name) { if (xr_stricmp(tok->name, args) == 0) diff --git a/src/xrGame/ui/UITalkDialogWnd.cpp b/src/xrGame/ui/UITalkDialogWnd.cpp index 860036282e3..8f0936f707e 100644 --- a/src/xrGame/ui/UITalkDialogWnd.cpp +++ b/src/xrGame/ui/UITalkDialogWnd.cpp @@ -159,7 +159,7 @@ void CUITalkDialogWnd::AddQuestion(LPCSTR str, LPCSTR value, int number, bool b_ string16 buff; xr_sprintf(buff, "%d.", (number == 10) ? 0 : number); itm->m_num_text->SetText(buff); - itm->m_text->SetAccelerator(SDL_SCANCODE_ESCAPE + number, 0); + itm->m_text->SetAccelerator(SDL_SCANCODE_1 - 1 + number, 0); } if (b_finalizer) {