2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-11-22 01:45:19 +01:00

engine: client: vgui: add funcs for VGUI2 support to the new API, change VGui_Startup to include VGUI2 initialization

This commit is contained in:
Alibek Omarov 2023-05-02 08:44:48 +03:00
parent 05b32e4caf
commit 41e51c530a
5 changed files with 40 additions and 10 deletions

View File

@ -3922,7 +3922,7 @@ qboolean CL_LoadProgs( const char *name )
// during LoadLibrary
if( !GI->internal_vgui_support && VGui_LoadProgs( NULL ))
{
VGui_Startup( refState.width, refState.height );
VGui_Startup( NULL, refState.width, refState.height );
}
else
{
@ -3938,7 +3938,8 @@ qboolean CL_LoadProgs( const char *name )
// delayed vgui initialization for internal support
if( GI->internal_vgui_support && VGui_LoadProgs( clgame.hInstance ))
{
VGui_Startup( refState.width, refState.height );
// do not pass client pointer yet
VGui_Startup( NULL, refState.width, refState.height );
}
// clear exports
@ -4021,6 +4022,9 @@ qboolean CL_LoadProgs( const char *name )
return false;
}
// try to load VGUI2
VGui_Startup( clgame.hInstance, refState.width, refState.height );
Cvar_FullSet( "host_clientloaded", "1", FCVAR_READ_ONLY );
clgame.maxRemapInfos = 0; // will be alloc on first call CL_InitEdicts();

View File

@ -715,7 +715,9 @@ void SCR_VidInit( void )
// notify vgui about screen size change
if( clgame.hInstance )
{
VGui_Startup( refState.width, refState.height );
// do not pass client pointer, we do not want to
// re-initialize vgui2
VGui_Startup( NULL, refState.width, refState.height );
}
CL_ClearSpriteTextures(); // now all hud sprites are invalid

View File

@ -117,6 +117,9 @@ static vgui_support_api_t gEngfuncs =
Platform_GetClipboardText,
Platform_SetClipboardText,
Platform_GetKeyModifiers,
COM_LoadLibrary,
COM_FreeLibrary,
COM_GetProcAddress,
};
static void VGui_FillAPIFromRef( vgui_support_api_t *to, const ref_interface_t *from )
@ -175,7 +178,7 @@ static qboolean VGui_ProbeNewAPI( HINSTANCE hInstance,
vgui_support_interface_t *iface, const vgui_support_api_t *api )
{
const int version = VGUI_SUPPORT_API_VERSION;
vgui_support_api_t localapi;
static vgui_support_api_t localapi;
VGUISUPPORTAPI F;
F = COM_GetProcAddress( hInstance, GET_VGUI_SUPPORT_API );
@ -287,7 +290,7 @@ VGui_Startup
================
*/
void VGui_Startup( int width, int height )
void VGui_Startup( HINSTANCE clientInstance, int width, int height )
{
// vgui not initialized from both support and client modules, skip
if( !vgui.initialized )
@ -302,12 +305,18 @@ void VGui_Startup( int width, int height )
else if( width <= 1280 ) width = 1280;
else if( width <= 1600 ) width = 1600;
if( vgui.dllFuncs.Startup )
vgui.dllFuncs.Startup( width, height );
if( !clientInstance )
{
if( vgui.dllFuncs.Startup )
vgui.dllFuncs.Startup( width, height );
}
else
{
if( vgui.dllFuncs.ClientStartup )
vgui.dllFuncs.ClientStartup( clientInstance, width, height );
}
}
/*
================
VGui_Shutdown

View File

@ -21,7 +21,7 @@ GNU General Public License for more details.
//
void VGui_RegisterCvars( void );
qboolean VGui_LoadProgs( HINSTANCE hInstance );
void VGui_Startup( int width, int height );
void VGui_Startup( HINSTANCE clientInstance, int width, int height );
void VGui_Shutdown( void );
void VGui_Paint( void );
void VGui_RunFrame( void );

View File

@ -209,10 +209,13 @@ typedef void (*LEGACY_VGUISUPPORTAPI)( legacy_vguiapi_t * );
#define LEGACY_GET_VGUI_SUPPORT_API "InitAPI"
#define LEGACY_CLIENT_GET_VGUI_SUPPORT_API "InitVGUISupportAPI"
#define vguiapi_t legacy_vguiapi_t
#endif // ENABLE_LEGACY_API_SUPPORT
typedef struct vgui_support_api_s
{
// LEGACY COMPATIBLE FUNCTIONS
void (*DrawInit)( void );
void (*DrawShutdown)( void );
void (*SetupDrawingText)( int *pColor );
@ -236,10 +239,17 @@ typedef struct vgui_support_api_s
int (*GetClipboardText)( char *buffer, size_t bufferSize );
void (*SetClipboardText)( const char *text );
key_modifier_t (*GetKeyModifiers)( void );
// END OF LEGACY COMPATIBLE FUCNTIONS
// DON'T BREAK ABI, ONLY ADD NEW FUNCTIONS TO THE END OF STRUCTURE
void *(*LoadLibrary)( const char *dllname, int build_ordinals_table, qboolean directpath );
void (*FreeLibrary)( void *hInstance );
void *(*GetProcAddress)( void *hInstance, const char *name );
} vgui_support_api_t;
typedef struct vgui_support_interface_s
{
// LEGACY COMPATIBLE FUNCTIONS
void (*Startup)( int width, int height );
void (*Shutdown)( void );
void *(*GetPanel)( void );
@ -248,6 +258,11 @@ typedef struct vgui_support_interface_s
void (*Key)( enum VGUI_KeyAction action, enum VGUI_KeyCode code );
void (*MouseMove)( int x, int y );
void (*TextInput)( const char *text );
// END OF LEGACY COMPATIBLE FUCNTIONS
// DON'T BREAK ABI, ONLY ADD NEW FUNCTIONS TO THE END OF STRUCTURE
// initialize VGUI2 after client.dll was loaded
void (*ClientStartup)( void *clientInstance, int width, int height );
} vgui_support_interface_t;
typedef int (*VGUISUPPORTAPI)( int version, vgui_support_interface_t *pFunctionTable, vgui_support_api_t *engfuncs );