Skip to content

Commit cbd1555

Browse files
committed
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
1 parent c33a1af commit cbd1555

File tree

5 files changed

+28
-6
lines changed

5 files changed

+28
-6
lines changed

src/xrEngine/Device_Initialize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ SDL_HitTestResult WindowHitTest(SDL_Window* /*window*/, const SDL_Point* area, v
107107
// Allow drag from any point except window center
108108
// For this case, 'hit' is a size of a square in the center
109109
if ((area->x > centerX + hit || area->x < centerX - hit)
110-
&& (area->y > centerY + hit || area->y < centerY - hit))
110+
|| (area->y > centerY + hit || area->y < centerY - hit))
111111
return SDL_HITTEST_DRAGGABLE;
112112

113113
return SDL_HITTEST_NORMAL;

src/xrEngine/Device_create.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ void CRenderDevice::Create()
4141
{
4242
if (b_is_Ready)
4343
return; // prevent double call
44+
4445
Statistic = new CStats();
4546
bool gpuSW = !!strstr(Core.Params, "-gpu_sw");
4647
bool gpuNonPure = !!strstr(Core.Params, "-gpu_nopure");
@@ -63,6 +64,7 @@ void CRenderDevice::Create()
6364

6465
Memory.mem_compact();
6566
b_is_Ready = TRUE;
67+
6668
_SetupStates();
6769
string_path fname;
6870
FS.update_path(fname, "$game_data$", "shaders.xr");
@@ -76,13 +78,25 @@ void CRenderDevice::UpdateWindowProps(const bool windowed)
7678
{
7779
SelectResolution(windowed);
7880

79-
SDL_SetWindowFullscreen(m_sdlWnd, windowed ? 0 : SDL_WINDOW_FULLSCREEN);
80-
81-
// Set window properties depending on what mode were in.
8281
if (windowed)
82+
{
83+
u32 width, height;
84+
sscanf(VidModesToken.back().name, "%dx%d", &width, &height);
85+
86+
const bool drawBorders = strstr(Core.Params, "-draw_borders");
87+
88+
bool desktopResolution = false;
89+
if (b_is_Ready && !drawBorders && psCurrentVidMode[0] == width && psCurrentVidMode[1] == height)
90+
desktopResolution = true;
91+
92+
SDL_SetWindowFullscreen(m_sdlWnd, desktopResolution ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
8393
SDL_SetWindowSize(m_sdlWnd, psCurrentVidMode[0], psCurrentVidMode[1]);
94+
SDL_SetWindowBordered(m_sdlWnd, drawBorders ? SDL_TRUE : SDL_FALSE);
95+
}
8496
else
8597
{
98+
SDL_SetWindowFullscreen(m_sdlWnd, SDL_WINDOW_FULLSCREEN);
99+
86100
// XXX: fix monitor selection
87101
// it appears to be buggy
88102
SDL_Rect rect;

src/xrEngine/device.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,9 @@ void CRenderDevice::message_loop()
356356
{
357357
if (!psDeviceFlags.is(rsFullscreen))
358358
{
359+
if (psCurrentVidMode[0] == event.window.data1 && psCurrentVidMode[1] == event.window.data2)
360+
break; // we don't need to reset device if resolution wasn't really changed
361+
359362
string32 buff;
360363
xr_sprintf(buff, sizeof(buff), "vid_mode %dx%d", event.window.data1, event.window.data2);
361364
Console->Execute(buff);
@@ -416,7 +419,7 @@ void CRenderDevice::Run()
416419
seqAppStart.Process();
417420
GEnv.Render->ClearTarget();
418421
splash::hide();
419-
if (GEnv.isDedicatedServer)
422+
if (GEnv.isDedicatedServer || strstr(Core.Params, "-center_screen"))
420423
SDL_SetWindowPosition(m_sdlWnd, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
421424
SDL_HideWindow(m_sdlWnd);
422425
SDL_FlushEvents(SDL_WINDOWEVENT, SDL_SYSWMEVENT);

src/xrEngine/xr_ioc_cmd.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ class ENGINE_API CCC_Token : public IConsole_Command
158158
virtual void Execute(LPCSTR args)
159159
{
160160
const xr_token* tok = GetToken();
161+
if (!tok)
162+
{
163+
Msg("! token [%s] is null", cName);
164+
return;
165+
}
161166
while (tok->name)
162167
{
163168
if (xr_stricmp(tok->name, args) == 0)

src/xrGame/ui/UITalkDialogWnd.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void CUITalkDialogWnd::AddQuestion(LPCSTR str, LPCSTR value, int number, bool b_
159159
string16 buff;
160160
xr_sprintf(buff, "%d.", (number == 10) ? 0 : number);
161161
itm->m_num_text->SetText(buff);
162-
itm->m_text->SetAccelerator(SDL_SCANCODE_ESCAPE + number, 0);
162+
itm->m_text->SetAccelerator(SDL_SCANCODE_1 - 1 + number, 0);
163163
}
164164
if (b_finalizer)
165165
{

0 commit comments

Comments
 (0)