mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-12-06 18:18:23 +00:00
Update ICvar & Cvar structs
This commit is contained in:
parent
a4fc170d18
commit
3c33d8ab94
@ -121,6 +121,10 @@ public:
|
|||||||
// if copy_or_cleanup is true, if false would cleanup the buffer
|
// if copy_or_cleanup is true, if false would cleanup the buffer
|
||||||
virtual void CopyUserInfoCvarDefaults( ConVarUserInfoSet_t buffer, int from, int to, bool copy_or_cleanup ) = 0;
|
virtual void CopyUserInfoCvarDefaults( ConVarUserInfoSet_t buffer, int from, int to, bool copy_or_cleanup ) = 0;
|
||||||
|
|
||||||
|
// Calls completion callbacks on cvars and concommands if they exist, successful would be true if so
|
||||||
|
// Cvars & Concommands needs to have FCVAR_VCONSOLE_FUZZY_MATCHING for successful to be true if callbacks are available
|
||||||
|
virtual void GetCompletionResults( const CCommand &command, CUtlVector< CUtlString > &completions, bool *successful = nullptr ) = 0;
|
||||||
|
|
||||||
// Register, unregister vars
|
// Register, unregister vars
|
||||||
virtual void RegisterConVar( const ConVarCreation_t& setup, uint64 nAdditionalFlags, ConVarRef* pCvarRef, ConVarData** pCvarData ) = 0;
|
virtual void RegisterConVar( const ConVarCreation_t& setup, uint64 nAdditionalFlags, ConVarRef* pCvarRef, ConVarData** pCvarData ) = 0;
|
||||||
// Unregisters convar change callback, but leaves the convar in the lists,
|
// Unregisters convar change callback, but leaves the convar in the lists,
|
||||||
@ -218,6 +222,14 @@ public:
|
|||||||
int m_ConVarIndex;
|
int m_ConVarIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ConVarCompletionCallbackData_t
|
||||||
|
{
|
||||||
|
CompletionCallbackInfo_t m_pCallBack;
|
||||||
|
|
||||||
|
// Register index of cvar which change cb comes from
|
||||||
|
int m_ConVarIndex;
|
||||||
|
};
|
||||||
|
|
||||||
struct ConCommandCallbackInfoNode_t
|
struct ConCommandCallbackInfoNode_t
|
||||||
{
|
{
|
||||||
ConCommandCallbackInfo_t m_CB;
|
ConCommandCallbackInfo_t m_CB;
|
||||||
@ -245,6 +257,7 @@ public:
|
|||||||
CUtlHashtable<CUtlStringToken, uint16> m_ConVarHashes;
|
CUtlHashtable<CUtlStringToken, uint16> m_ConVarHashes;
|
||||||
CUtlLinkedList<ConVarChangeCallbackData_t, unsigned short, true> m_ConVarChangeCBList;
|
CUtlLinkedList<ConVarChangeCallbackData_t, unsigned short, true> m_ConVarChangeCBList;
|
||||||
CUtlLinkedList<ConVarFilterCallbackData_t, unsigned short, true> m_ConVarFilterCBList;
|
CUtlLinkedList<ConVarFilterCallbackData_t, unsigned short, true> m_ConVarFilterCBList;
|
||||||
|
CUtlLinkedList<ConVarCompletionCallbackData_t, unsigned short, true> m_ConVarCompletionCBList;
|
||||||
int m_ConVarCount;
|
int m_ConVarCount;
|
||||||
|
|
||||||
CUtlVector<IConVarListener *> m_CvarCreationListeners;
|
CUtlVector<IConVarListener *> m_CvarCreationListeners;
|
||||||
|
|||||||
@ -443,21 +443,21 @@ struct ConCommandCallbackInfo_t
|
|||||||
bool m_bIsContextLess : 1;
|
bool m_bIsContextLess : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ConCommandCompletionCallbackInfo_t
|
struct CompletionCallbackInfo_t
|
||||||
{
|
{
|
||||||
ConCommandCompletionCallbackInfo_t() :
|
CompletionCallbackInfo_t() :
|
||||||
m_fnCompletionCallback( nullptr ),
|
m_fnCompletionCallback( nullptr ),
|
||||||
m_bIsFunction( false ),
|
m_bIsFunction( false ),
|
||||||
m_bIsInterface( false )
|
m_bIsInterface( false )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ConCommandCompletionCallbackInfo_t( FnCommandCompletionCallback cb ) :
|
CompletionCallbackInfo_t( FnCommandCompletionCallback cb ) :
|
||||||
m_fnCompletionCallback( cb ),
|
m_fnCompletionCallback( cb ),
|
||||||
m_bIsFunction( cb ? true : false ),
|
m_bIsFunction( cb ? true : false ),
|
||||||
m_bIsInterface( false )
|
m_bIsInterface( false )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ConCommandCompletionCallbackInfo_t( ICommandCompletionCallback *cb ) :
|
CompletionCallbackInfo_t( ICommandCompletionCallback *cb ) :
|
||||||
m_pCommandCompletionCallback( cb ),
|
m_pCommandCompletionCallback( cb ),
|
||||||
m_bIsFunction( false ),
|
m_bIsFunction( false ),
|
||||||
m_bIsInterface( cb ? true : false )
|
m_bIsInterface( cb ? true : false )
|
||||||
@ -490,7 +490,7 @@ struct ConCommandCompletionCallbackInfo_t
|
|||||||
struct ConCommandCreation_t : CVarCreationBase_t
|
struct ConCommandCreation_t : CVarCreationBase_t
|
||||||
{
|
{
|
||||||
ConCommandCallbackInfo_t m_CBInfo;
|
ConCommandCallbackInfo_t m_CBInfo;
|
||||||
ConCommandCompletionCallbackInfo_t m_CompletionCBInfo;
|
CompletionCallbackInfo_t m_CompletionCBInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -520,7 +520,7 @@ public:
|
|||||||
const char* m_pszHelpString;
|
const char* m_pszHelpString;
|
||||||
uint64 m_nFlags;
|
uint64 m_nFlags;
|
||||||
|
|
||||||
ConCommandCompletionCallbackInfo_t m_CompletionCB;
|
CompletionCallbackInfo_t m_CompletionCB;
|
||||||
|
|
||||||
// Register index of concommand which completion cb comes from
|
// Register index of concommand which completion cb comes from
|
||||||
int m_CompletionCBCmdIndex;
|
int m_CompletionCBCmdIndex;
|
||||||
@ -591,7 +591,7 @@ public:
|
|||||||
|
|
||||||
ConCommand( const char *pName, ConCommandCallbackInfo_t callback,
|
ConCommand( const char *pName, ConCommandCallbackInfo_t callback,
|
||||||
const char *pHelpString, uint64 flags = 0,
|
const char *pHelpString, uint64 flags = 0,
|
||||||
ConCommandCompletionCallbackInfo_t completionFunc = ConCommandCompletionCallbackInfo_t() )
|
CompletionCallbackInfo_t completionFunc = CompletionCallbackInfo_t() )
|
||||||
: BaseClass()
|
: BaseClass()
|
||||||
{
|
{
|
||||||
Create( pName, callback, pHelpString, flags, completionFunc );
|
Create( pName, callback, pHelpString, flags, completionFunc );
|
||||||
@ -603,7 +603,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Create( const char *pName, const ConCommandCallbackInfo_t &cb, const char *pHelpString, uint64 flags, const ConCommandCompletionCallbackInfo_t &completion_cb );
|
void Create( const char *pName, const ConCommandCallbackInfo_t &cb, const char *pHelpString, uint64 flags, const CompletionCallbackInfo_t &completion_cb );
|
||||||
void Destroy( );
|
void Destroy( );
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -640,7 +640,8 @@ struct ConVarValueInfo_t
|
|||||||
m_fnCallBack( nullptr ),
|
m_fnCallBack( nullptr ),
|
||||||
m_fnProviderFilterCallBack( nullptr ),
|
m_fnProviderFilterCallBack( nullptr ),
|
||||||
m_fnFilterCallBack( nullptr ),
|
m_fnFilterCallBack( nullptr ),
|
||||||
m_eVarType( type )
|
m_eVarType( type ),
|
||||||
|
m_CompletionCallBack()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -690,6 +691,11 @@ struct ConVarValueInfo_t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetCompletionCallback( const CompletionCallbackInfo_t &cb )
|
||||||
|
{
|
||||||
|
m_CompletionCallBack = cb;
|
||||||
|
}
|
||||||
|
|
||||||
int32 m_Version;
|
int32 m_Version;
|
||||||
|
|
||||||
bool m_bHasDefault;
|
bool m_bHasDefault;
|
||||||
@ -710,6 +716,8 @@ public:
|
|||||||
FnGenericFilterCallback_t m_fnFilterCallBack;
|
FnGenericFilterCallback_t m_fnFilterCallBack;
|
||||||
|
|
||||||
EConVarType m_eVarType;
|
EConVarType m_eVarType;
|
||||||
|
|
||||||
|
CompletionCallbackInfo_t m_CompletionCallBack;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ConVarCreation_t : CVarCreationBase_t
|
struct ConVarCreation_t : CVarCreationBase_t
|
||||||
@ -998,6 +1006,8 @@ private:
|
|||||||
unsigned int m_iCallbackIndex;
|
unsigned int m_iCallbackIndex;
|
||||||
// Index into a linked list of cvar filter callbacks
|
// Index into a linked list of cvar filter callbacks
|
||||||
unsigned int m_iFilterCBIndex;
|
unsigned int m_iFilterCBIndex;
|
||||||
|
// Index into a linked list of cvar completion callbacks
|
||||||
|
unsigned int m_iCompletionCBIndex;
|
||||||
|
|
||||||
int m_GameInfoFlags;
|
int m_GameInfoFlags;
|
||||||
int m_UserInfoByteIndex;
|
int m_UserInfoByteIndex;
|
||||||
@ -1267,7 +1277,7 @@ class CConVar : public CConVarRef<T>
|
|||||||
public:
|
public:
|
||||||
typedef CConVarRef<T> BaseClass;
|
typedef CConVarRef<T> BaseClass;
|
||||||
|
|
||||||
CConVar( const char *name, uint64 flags, const char *help_string, const T &default_value, FnTypedChangeCallback_t<T> cb = nullptr )
|
CConVar( const char *name, uint64 flags, const char *help_string, const T &default_value, FnTypedChangeCallback_t<T> cb = nullptr, const CompletionCallbackInfo_t &completion_cb = {} )
|
||||||
: BaseClass()
|
: BaseClass()
|
||||||
{
|
{
|
||||||
Assert( name );
|
Assert( name );
|
||||||
@ -1278,10 +1288,16 @@ public:
|
|||||||
value_info.SetDefaultValue( default_value );
|
value_info.SetDefaultValue( default_value );
|
||||||
value_info.SetCallback( cb );
|
value_info.SetCallback( cb );
|
||||||
|
|
||||||
|
if(completion_cb.IsValid())
|
||||||
|
{
|
||||||
|
value_info.SetCompletionCallback( completion_cb );
|
||||||
|
flags |= FCVAR_VCONSOLE_FUZZY_MATCHING;
|
||||||
|
}
|
||||||
|
|
||||||
BaseClass::Register( name, flags, help_string, value_info );
|
BaseClass::Register( name, flags, help_string, value_info );
|
||||||
}
|
}
|
||||||
|
|
||||||
CConVar( const char *name, uint64 flags, const char *help_string, const T &default_value, bool min, const T &minValue, bool max, const T &maxValue, FnTypedChangeCallback_t<T> cb = nullptr, FnTypedFilterCallback_t<T> filter_cb = nullptr )
|
CConVar( const char *name, uint64 flags, const char *help_string, const T &default_value, bool min, const T &minValue, bool max, const T &maxValue, FnTypedChangeCallback_t<T> cb = nullptr, FnTypedFilterCallback_t<T> filter_cb = nullptr, const CompletionCallbackInfo_t &completion_cb = {} )
|
||||||
: BaseClass()
|
: BaseClass()
|
||||||
{
|
{
|
||||||
Assert( name );
|
Assert( name );
|
||||||
@ -1299,6 +1315,12 @@ public:
|
|||||||
|
|
||||||
value_info.SetCallback( cb );
|
value_info.SetCallback( cb );
|
||||||
value_info.SetFilterCallback( filter_cb );
|
value_info.SetFilterCallback( filter_cb );
|
||||||
|
|
||||||
|
if(completion_cb.IsValid())
|
||||||
|
{
|
||||||
|
value_info.SetCompletionCallback( completion_cb );
|
||||||
|
flags |= FCVAR_VCONSOLE_FUZZY_MATCHING;
|
||||||
|
}
|
||||||
|
|
||||||
BaseClass::Register( name, flags, help_string, value_info );
|
BaseClass::Register( name, flags, help_string, value_info );
|
||||||
}
|
}
|
||||||
|
|||||||
@ -461,7 +461,7 @@ void ConCommandRef::Dispatch( const CCommandContext &context, const CCommand &co
|
|||||||
g_pCVar->DispatchConCommand( *this, context, command );
|
g_pCVar->DispatchConCommand( *this, context, command );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConCommand::Create( const char* pName, const ConCommandCallbackInfo_t &cb, const char* pHelpString, uint64 flags, const ConCommandCompletionCallbackInfo_t &completion_cb )
|
void ConCommand::Create( const char* pName, const ConCommandCallbackInfo_t &cb, const char* pHelpString, uint64 flags, const CompletionCallbackInfo_t &completion_cb )
|
||||||
{
|
{
|
||||||
// Name should be static data
|
// Name should be static data
|
||||||
Assert(pName);
|
Assert(pName);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user