Skip to content

Commit

Permalink
engine: add pfnIsCvarReadOnly to mainui API
Browse files Browse the repository at this point in the history
  • Loading branch information
a1batross committed Oct 25, 2024
1 parent 25b2c0f commit 55bdded
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions engine/client/cl_gameui.c
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,16 @@ static gameinfo2_t *pfnGetModInfo( int gi_version, int i )
return &gameui.modsInfo[i];
}

static int pfnIsCvarReadOnly( const char *name )
{
convar_t *cv = Cvar_FindVar( name );

if( !cv )
return -1;

return FBitSet( cv->flags, FCVAR_READ_ONLY ) ? 1 : 0;
}

static ui_extendedfuncs_t gExtendedfuncs =
{
pfnEnableTextInput,
Expand All @@ -1318,6 +1328,7 @@ static ui_extendedfuncs_t gExtendedfuncs =
&gNetApi,
pfnGetGameInfo,
pfnGetModInfo,
pfnIsCvarReadOnly,
};

void UI_UnloadProgs( void )
Expand Down
4 changes: 4 additions & 0 deletions engine/menu_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ typedef struct ui_extendedfuncs_s {
// new mods info
gameinfo2_t *(*pfnGetGameInfo)( int gi_version ); // might return NULL if gi_version is unsupported
gameinfo2_t *(*pfnGetModInfo)( int gi_version, int mod_index ); // continiously call it until it returns null

// returns 1 if cvar has read-only flag
// or -1 if cvar not found
int (*pfnIsCvarReadOnly)( const char *name );
} ui_extendedfuncs_t;

// deprecated export from old engine
Expand Down

0 comments on commit 55bdded

Please sign in to comment.