Skip to content

Commit

Permalink
- Added support for borderless mode, with taskbar vis, and fullscreen…
Browse files Browse the repository at this point in the history
…, and a resizable mode. ms_borderless set to 1, 2 or 3 respectively. This also fixes bloom issues, bloom works in these windowed modes.
  • Loading branch information
BerntA committed May 31, 2021
1 parent 06779d1 commit cd33b5a
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 11 deletions.
Binary file modified bin/client.dll
Binary file not shown.
Binary file modified bin/ms.dll
Binary file not shown.
81 changes: 72 additions & 9 deletions cl_dll/cdll_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
#include "netadr.h"
#include "vgui_schememanager.h"
#include "logfile.h"
#include <windows.h>

//#define LOG_ALLEXPORTS //more exports in entity.cpp


#ifdef LOG_ALLEXPORTS
#define logfileopt logfile
#else
Expand Down Expand Up @@ -54,9 +54,66 @@ TeamFortressViewport *gViewPort = NULL;
extern void InitScreenGlow(void);
extern void RenderScreenGlow(void);

void InitInput (void);
void EV_HookEvents( void );
void IN_Commands( void );
void InitInput(void);
void EV_HookEvents(void);
void IN_Commands(void);

static cvar_s *g_pVarBorderless = NULL;
static int g_iBorderlessMode = 0;

enum BORDERLESS_WINDOW_TYPES
{
BORDERLESS_SHOWTASKBAR = 1,
BORDERLESS_FULLSCREEN,
BORDERLESS_RESIZABLE,
};

static void SetBorderlessWindow() // Bernt; fixing bloom by making fullscreen windowed a thing *shrugs*!
{
int iCurrentMode = (g_pVarBorderless ? ((int)g_pVarBorderless->value) : 0);
if ((g_iBorderlessMode == iCurrentMode) || (iCurrentMode <= 0))
return;

HWND handle = GetActiveWindow();
if (!handle)
return;

RECT area;
const int w = GetSystemMetrics(SM_CXSCREEN);
const int h = GetSystemMetrics(SM_CYSCREEN);
SystemParametersInfoA(SPI_GETWORKAREA, 0, &area, 0);

switch (iCurrentMode)
{

case BORDERLESS_SHOWTASKBAR:
{
SetWindowLongPtr(handle, GWL_STYLE, WS_VISIBLE | WS_POPUP);
SetWindowPos(handle, HWND_TOP, 0, 0, w, area.bottom, SWP_FRAMECHANGED);
break;
}

case BORDERLESS_FULLSCREEN:
{
SetWindowLongPtr(handle, GWL_STYLE, WS_VISIBLE | WS_POPUP);
SetWindowPos(handle, HWND_TOP, 0, 0, w, h, SWP_FRAMECHANGED);
break;
}

case BORDERLESS_RESIZABLE:
{
DWORD new_style = (WS_POPUP | WS_THICKFRAME | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX);
::SetWindowLongPtrW(handle, GWL_STYLE, static_cast<LONG>(new_style));
::SetWindowPos(handle, nullptr, 0, 0, w, area.bottom, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE);
::ShowWindow(handle, SW_SHOW);
break;
}

}

g_iBorderlessMode = iCurrentMode;
}

/*
==========================
Initialize
Expand Down Expand Up @@ -192,6 +249,7 @@ int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
memcpy(&gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t));

EV_HookEvents();
g_pVarBorderless = CVAR_CREATE("ms_borderless", "0", FCVAR_ARCHIVE);

logfile << "[DLLEXPORT Initialize: Complete]" << endl;

Expand Down Expand Up @@ -221,6 +279,9 @@ int DLLEXPORT HUD_VidInit( void )
dbg( "Call VGui_Startup" );
VGui_Startup();

dbg("Try Set Borderless");
SetBorderlessWindow();

dbg( "Call Glow" );
// IMAGE-SPACE GLOW - Thothie TWHL JUN2010_22 - see comments in tri.cpp
InitScreenGlow();
Expand Down Expand Up @@ -259,12 +320,15 @@ void DLLEXPORT HUD_Init( void )
dbg( "Call Scheme_Init" );
Scheme_Init();

logfile << "[HUD_Init: SetBorderlessWindow]" << endl;
dbg("Call SetBorderlessWindow");
SetBorderlessWindow();

logfile << "[HUD_Init: Complete]" << endl;

enddbg;
}


/*
==========================
HUD_Redraw
Expand Down Expand Up @@ -293,7 +357,6 @@ int DLLEXPORT HUD_Redraw( float time, int intermission )
return 1;
}


/*
==========================
HUD_UpdateClientData
Expand Down Expand Up @@ -359,9 +422,10 @@ void DLLEXPORT HUD_Frame( double time )

dbg( "Call ServersThink" );
ServersThink( time );

dbg( "Call ServersThink DONE" );

SetBorderlessWindow();

enddbg;
}

Expand Down Expand Up @@ -402,5 +466,4 @@ void DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf )

enddbg;

}

}
4 changes: 2 additions & 2 deletions dlls/server.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ if ERRORLEVEL 1 exit /b 1
<AdditionalOptions>/Zm200 /Gw /Zc:inline</AdditionalOptions>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\common;..\public;..\public\tier0;..\public\tier1;../cl_dlls;../engine;../common;../pm_shared;../game_shared;../MSShared;./Effects;./gamerules;./Global;./Half-life;./Items;./md5;./Monsters;./Player;./Stats;./Syntax;./Weapons;./</AdditionalIncludeDirectories>
<PreprocessorDefinitions>VPC;RAD_TELEMETRY_DISABLED;_HAS_ITERATOR_DEBUGGING=0;WIN32;_WIN32;_DEBUG;DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions);COMPILER_MSVC32;COMPILER_MSVC32;COMPILER_MSVC;_DLL_EXT=.dll;DLLNAME=ms;BINK_VIDEO;AVI_VIDEO;WMV_VIDEO;;FRAME_POINTER_OMISSION_DISABLED;VALVE_DLL;_EXTERNAL_DLL_EXT=.dll;VPCGAMECAPS=MSC;PROJECTDIR=E:\Cloud\GIT\MasterSwordClassic\dlls;_DLL_EXT=.dll;VPCGAME=msc;SOURCE1=1</PreprocessorDefinitions>
<PreprocessorDefinitions>VPC;RAD_TELEMETRY_DISABLED;_HAS_ITERATOR_DEBUGGING=0;WIN32;_WIN32;_DEBUG;DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions);COMPILER_MSVC32;COMPILER_MSVC32;COMPILER_MSVC;_DLL_EXT=.dll;DLLNAME=ms;BINK_VIDEO;AVI_VIDEO;WMV_VIDEO;;FRAME_POINTER_OMISSION_DISABLED;VALVE_DLL;_EXTERNAL_DLL_EXT=.dll;VPCGAMECAPS=MSC;PROJECTDIR=E:\Cloud\GIT\MasterSwordClassic\dlls;_DLL_EXT=.dll;SOURCE1=1;VPCGAME=msc</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>false</ExceptionHandling>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
Expand Down Expand Up @@ -167,7 +167,7 @@ if ERRORLEVEL 1 exit /b 1
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<AdditionalIncludeDirectories>..\common;..\public;..\public\tier0;../cl_dlls;../engine;../common;../pm_shared;../game_shared;../MSShared;./Effects;./gamerules;./Global;./Half-life;./Items;./md5;./Monsters;./Player;./Stats;./Syntax;./Weapons;./</AdditionalIncludeDirectories>
<PreprocessorDefinitions>VPC;RAD_TELEMETRY_DISABLED;WIN32;_WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions);COMPILER_MSVC32;COMPILER_MSVC32;COMPILER_MSVC;_DLL_EXT=.dll;DLLNAME=ms;BINK_VIDEO;AVI_VIDEO;WMV_VIDEO;;FRAME_POINTER_OMISSION_DISABLED;VALVE_DLL;_EXTERNAL_DLL_EXT=.dll;VPCGAMECAPS=MSC;PROJECTDIR=E:\Cloud\GIT\MasterSwordClassic\dlls;_DLL_EXT=.dll;VPCGAME=msc;SOURCE1=1</PreprocessorDefinitions>
<PreprocessorDefinitions>VPC;RAD_TELEMETRY_DISABLED;WIN32;_WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions);COMPILER_MSVC32;COMPILER_MSVC32;COMPILER_MSVC;_DLL_EXT=.dll;DLLNAME=ms;BINK_VIDEO;AVI_VIDEO;WMV_VIDEO;;FRAME_POINTER_OMISSION_DISABLED;VALVE_DLL;_EXTERNAL_DLL_EXT=.dll;VPCGAMECAPS=MSC;PROJECTDIR=E:\Cloud\GIT\MasterSwordClassic\dlls;_DLL_EXT=.dll;SOURCE1=1;VPCGAME=msc</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
Expand Down

0 comments on commit cd33b5a

Please sign in to comment.