From c6fb702fb1fadba9d04a46227757b6621c7fa516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2=20?= =?UTF-8?q?=D0=A1=D1=83=D1=85=D0=BE=D0=B2?= <22411953+Vladislav4KZ@users.noreply.github.com> Date: Wed, 13 May 2026 21:41:36 +0000 Subject: [PATCH] engine: add MenuFactory native object --- Documentation/extensions/native-object.md | 1 + engine/client/dll_int/cl_gameui.c | 8 ++++++++ engine/common/common.h | 2 ++ engine/common/system.c | 3 +++ 4 files changed, 14 insertions(+) diff --git a/Documentation/extensions/native-object.md b/Documentation/extensions/native-object.md index 91afbd24..685372c1 100644 --- a/Documentation/extensions/native-object.md +++ b/Documentation/extensions/native-object.md @@ -16,6 +16,7 @@ Only these objects are guaranteed to be available on all targets. |-------------|-----------| | `VFileSystem009` | Provides C++ interface to filesystem, binary-compatible with Valve's VFileSystem009. | | `XashFileSystemXXX` | Provides C interface to filesystem. This interface is unstable and not recommended for generic use, outside of engine internals. For more info about current version look into `filesystem.h`. | +| `MenuFactory` | Returns a `CreateInterface` function pointer (`pfnCreateInterface_t`) for the currently loaded menu library. | #### Android-specific objects diff --git a/engine/client/dll_int/cl_gameui.c b/engine/client/dll_int/cl_gameui.c index 80ad6b78..496a0585 100644 --- a/engine/client/dll_int/cl_gameui.c +++ b/engine/client/dll_int/cl_gameui.c @@ -1335,6 +1335,14 @@ void UI_UnloadProgs( void ) memset( &gameui, 0, sizeof( gameui )); } +void *UI_GetMenuFactory( void ) +{ + if( !gameui.hInstance ) + return NULL; + + return COM_GetProcAddress( gameui.hInstance, "CreateInterface" ); +} + qboolean UI_LoadProgs( void ) { static ui_enginefuncs_t gpEngfuncs; diff --git a/engine/common/common.h b/engine/common/common.h index 53a53878..7ec8b4c4 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -745,6 +745,7 @@ qboolean CL_DisableVisibility( void ); qboolean CL_IsRecordDemo( void ); qboolean CL_IsPlaybackDemo( void ); qboolean UI_CreditsActive( void ); +void *UI_GetMenuFactory( void ); int CL_GetMaxClients( void ); #else static inline qboolean CL_Initialized( void ) { return false; } @@ -755,6 +756,7 @@ static inline qboolean CL_DisableVisibility( void ) { return false; } static inline qboolean CL_IsRecordDemo( void ) { return false; } static inline qboolean CL_IsPlaybackDemo( void ) { return false; } static inline qboolean UI_CreditsActive( void ) { return false; } +static inline void *UI_GetMenuFactory( void ) { return NULL; } static inline int CL_GetMaxClients( void ) { return SV_GetMaxClients(); } #endif diff --git a/engine/common/system.c b/engine/common/system.c index c871aaa2..4cc3fd60 100644 --- a/engine/common/system.c +++ b/engine/common/system.c @@ -666,6 +666,9 @@ void *Sys_GetNativeObject( const char *obj ) if( COM_StringEmptyOrNULL( obj )) return NULL; + if( !Q_strcmp( obj, "MenuFactory" )) + return UI_GetMenuFactory(); + ptr = FS_GetNativeObject( obj ); if( ptr )