mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08: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:
@@ -3922,7 +3922,7 @@ qboolean CL_LoadProgs( const char *name )
|
|||||||
// during LoadLibrary
|
// during LoadLibrary
|
||||||
if( !GI->internal_vgui_support && VGui_LoadProgs( NULL ))
|
if( !GI->internal_vgui_support && VGui_LoadProgs( NULL ))
|
||||||
{
|
{
|
||||||
VGui_Startup( refState.width, refState.height );
|
VGui_Startup( NULL, refState.width, refState.height );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -3938,7 +3938,8 @@ qboolean CL_LoadProgs( const char *name )
|
|||||||
// delayed vgui initialization for internal support
|
// delayed vgui initialization for internal support
|
||||||
if( GI->internal_vgui_support && VGui_LoadProgs( clgame.hInstance ))
|
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
|
// clear exports
|
||||||
@@ -4021,6 +4022,9 @@ qboolean CL_LoadProgs( const char *name )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// try to load VGUI2
|
||||||
|
VGui_Startup( clgame.hInstance, refState.width, refState.height );
|
||||||
|
|
||||||
Cvar_FullSet( "host_clientloaded", "1", FCVAR_READ_ONLY );
|
Cvar_FullSet( "host_clientloaded", "1", FCVAR_READ_ONLY );
|
||||||
|
|
||||||
clgame.maxRemapInfos = 0; // will be alloc on first call CL_InitEdicts();
|
clgame.maxRemapInfos = 0; // will be alloc on first call CL_InitEdicts();
|
||||||
|
|||||||
@@ -715,7 +715,9 @@ void SCR_VidInit( void )
|
|||||||
// notify vgui about screen size change
|
// notify vgui about screen size change
|
||||||
if( clgame.hInstance )
|
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
|
CL_ClearSpriteTextures(); // now all hud sprites are invalid
|
||||||
|
|||||||
@@ -117,6 +117,9 @@ static vgui_support_api_t gEngfuncs =
|
|||||||
Platform_GetClipboardText,
|
Platform_GetClipboardText,
|
||||||
Platform_SetClipboardText,
|
Platform_SetClipboardText,
|
||||||
Platform_GetKeyModifiers,
|
Platform_GetKeyModifiers,
|
||||||
|
COM_LoadLibrary,
|
||||||
|
COM_FreeLibrary,
|
||||||
|
COM_GetProcAddress,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void VGui_FillAPIFromRef( vgui_support_api_t *to, const ref_interface_t *from )
|
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 )
|
vgui_support_interface_t *iface, const vgui_support_api_t *api )
|
||||||
{
|
{
|
||||||
const int version = VGUI_SUPPORT_API_VERSION;
|
const int version = VGUI_SUPPORT_API_VERSION;
|
||||||
vgui_support_api_t localapi;
|
static vgui_support_api_t localapi;
|
||||||
VGUISUPPORTAPI F;
|
VGUISUPPORTAPI F;
|
||||||
|
|
||||||
F = COM_GetProcAddress( hInstance, GET_VGUI_SUPPORT_API );
|
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
|
// vgui not initialized from both support and client modules, skip
|
||||||
if( !vgui.initialized )
|
if( !vgui.initialized )
|
||||||
@@ -302,12 +305,18 @@ void VGui_Startup( int width, int height )
|
|||||||
else if( width <= 1280 ) width = 1280;
|
else if( width <= 1280 ) width = 1280;
|
||||||
else if( width <= 1600 ) width = 1600;
|
else if( width <= 1600 ) width = 1600;
|
||||||
|
|
||||||
if( vgui.dllFuncs.Startup )
|
if( !clientInstance )
|
||||||
vgui.dllFuncs.Startup( width, height );
|
{
|
||||||
|
if( vgui.dllFuncs.Startup )
|
||||||
|
vgui.dllFuncs.Startup( width, height );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( vgui.dllFuncs.ClientStartup )
|
||||||
|
vgui.dllFuncs.ClientStartup( clientInstance, width, height );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
================
|
================
|
||||||
VGui_Shutdown
|
VGui_Shutdown
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ GNU General Public License for more details.
|
|||||||
//
|
//
|
||||||
void VGui_RegisterCvars( void );
|
void VGui_RegisterCvars( void );
|
||||||
qboolean VGui_LoadProgs( HINSTANCE hInstance );
|
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_Shutdown( void );
|
||||||
void VGui_Paint( void );
|
void VGui_Paint( void );
|
||||||
void VGui_RunFrame( void );
|
void VGui_RunFrame( void );
|
||||||
|
|||||||
@@ -209,10 +209,13 @@ typedef void (*LEGACY_VGUISUPPORTAPI)( legacy_vguiapi_t * );
|
|||||||
#define LEGACY_GET_VGUI_SUPPORT_API "InitAPI"
|
#define LEGACY_GET_VGUI_SUPPORT_API "InitAPI"
|
||||||
#define LEGACY_CLIENT_GET_VGUI_SUPPORT_API "InitVGUISupportAPI"
|
#define LEGACY_CLIENT_GET_VGUI_SUPPORT_API "InitVGUISupportAPI"
|
||||||
|
|
||||||
|
#define vguiapi_t legacy_vguiapi_t
|
||||||
|
|
||||||
#endif // ENABLE_LEGACY_API_SUPPORT
|
#endif // ENABLE_LEGACY_API_SUPPORT
|
||||||
|
|
||||||
typedef struct vgui_support_api_s
|
typedef struct vgui_support_api_s
|
||||||
{
|
{
|
||||||
|
// LEGACY COMPATIBLE FUNCTIONS
|
||||||
void (*DrawInit)( void );
|
void (*DrawInit)( void );
|
||||||
void (*DrawShutdown)( void );
|
void (*DrawShutdown)( void );
|
||||||
void (*SetupDrawingText)( int *pColor );
|
void (*SetupDrawingText)( int *pColor );
|
||||||
@@ -236,10 +239,17 @@ typedef struct vgui_support_api_s
|
|||||||
int (*GetClipboardText)( char *buffer, size_t bufferSize );
|
int (*GetClipboardText)( char *buffer, size_t bufferSize );
|
||||||
void (*SetClipboardText)( const char *text );
|
void (*SetClipboardText)( const char *text );
|
||||||
key_modifier_t (*GetKeyModifiers)( void );
|
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;
|
} vgui_support_api_t;
|
||||||
|
|
||||||
typedef struct vgui_support_interface_s
|
typedef struct vgui_support_interface_s
|
||||||
{
|
{
|
||||||
|
// LEGACY COMPATIBLE FUNCTIONS
|
||||||
void (*Startup)( int width, int height );
|
void (*Startup)( int width, int height );
|
||||||
void (*Shutdown)( void );
|
void (*Shutdown)( void );
|
||||||
void *(*GetPanel)( 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 (*Key)( enum VGUI_KeyAction action, enum VGUI_KeyCode code );
|
||||||
void (*MouseMove)( int x, int y );
|
void (*MouseMove)( int x, int y );
|
||||||
void (*TextInput)( const char *text );
|
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;
|
} vgui_support_interface_t;
|
||||||
|
|
||||||
typedef int (*VGUISUPPORTAPI)( int version, vgui_support_interface_t *pFunctionTable, vgui_support_api_t *engfuncs );
|
typedef int (*VGUISUPPORTAPI)( int version, vgui_support_interface_t *pFunctionTable, vgui_support_api_t *engfuncs );
|
||||||
|
|||||||
Reference in New Issue
Block a user