Skip to content

Commit

Permalink
xrEngine/Device_Initialize.cpp: fixed 'normal' window hit test result…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
Xottab-DUTY committed Jul 23, 2018
1 parent c33a1af commit cbd1555
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/xrEngine/Device_Initialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 17 additions & 3 deletions src/xrEngine/Device_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand All @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/xrEngine/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/xrEngine/xr_ioc_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/ui/UITalkDialogWnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit cbd1555

Please sign in to comment.