r5sdk/r5dev/public/icvar.h
Kawe Mazidjatari 33dfe63f67 Fix incorrect ICVarIteratorInternal function order
The destructor is the last function.
2023-06-26 22:42:54 +02:00

127 lines
5.3 KiB
C++

#ifndef ICVAR_H
#define ICVAR_H
#include "tier0/annotations.h"
#include "appframework/IAppSystem.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class ConCommandBase;
class ConCommand;
class ConVar;
class IAppSystem;
class Color;
//-----------------------------------------------------------------------------
// ConVars/ComCommands are marked as having a particular DLL identifier
//-----------------------------------------------------------------------------
typedef int CVarDLLIdentifier_t;
//-----------------------------------------------------------------------------
// ConVars/ComCommands are marked as having a particular DLL identifier
//-----------------------------------------------------------------------------
typedef int CVarDLLIdentifier_t;
//-----------------------------------------------------------------------------
// Used to display console messages
//-----------------------------------------------------------------------------
abstract_class IConsoleDisplayFunc
{
public:
virtual void ColorPrint(const Color & clr, const char* pMessage) = 0;
virtual void Print(const char* pMessage) = 0;
virtual void DPrint(const char* pMessage) = 0;
virtual void GetConsoleText(char* pchText, size_t bufSize) const = 0;
};
//-----------------------------------------------------------------------------
// Purpose: Applications can implement this to modify behavior in ICvar
//-----------------------------------------------------------------------------
#define CVAR_QUERY_INTERFACE_VERSION "VCvarQuery001"
abstract_class ICvarQuery : public IAppSystem
{
public:
// Can these two convars be aliased?
virtual bool AreConVarsLinkable(const ConVar * child, const ConVar * parent) = 0;
};
//-----------------------------------------------------------------------------
// Purpose: DLL interface to ConVars/ConCommands
//-----------------------------------------------------------------------------
abstract_class ICvar : public IAppSystem
{
public:
// Allocate a unique DLL identifier
virtual CVarDLLIdentifier_t AllocateDLLIdentifier() = 0;
// Register, unregister commands
virtual void RegisterConCommand( ConCommandBase *pCommandBase ) = 0;
virtual void UnregisterConCommand( ConCommandBase *pCommandBase ) = 0;
virtual void UnregisterConCommands( CVarDLLIdentifier_t id ) = 0;
// If there is a +<varname> <value> on the command line, this returns the value.
// Otherwise, it returns NULL.
virtual const char* GetCommandLineValue( const char *pVariableName ) = 0;
// Try to find the cvar pointer by name
virtual ConCommandBase *FindCommandBase( const char *name ) = 0;
virtual const ConCommandBase *FindCommandBase( const char *name ) const = 0;
virtual ConVar *FindVar ( const char *var_name ) = 0;
virtual const ConVar *FindVar ( const char *var_name ) const = 0;
virtual ConCommand *FindCommand( const char *name ) = 0;
virtual const ConCommand *FindCommand( const char *name ) const = 0;
virtual void sub_140599640() = 0;
virtual void sub_140599BA0() = 0;
// Install a global change callback (to be called when any convar changes)
virtual void InstallGlobalChangeCallback(FnChangeCallback_t callback) = 0;
virtual void RemoveGlobalChangeCallback(FnChangeCallback_t callback) = 0;
virtual void CallGlobalChangeCallbacks(ConVar* var, const char* pOldString/*, float flOldValue*/) = 0;
// Install a console printer
virtual void InstallConsoleDisplayFunc(IConsoleDisplayFunc* pDisplayFunc) = 0;
virtual void RemoveConsoleDisplayFunc(IConsoleDisplayFunc* pDisplayFunc) = 0;
virtual void ConsoleColorPrintf(const Color& clr, PRINTF_FORMAT_STRING const char* pFormat, ...) const FMTFUNCTION(3, 4) = 0;
virtual void ConsolePrintf(PRINTF_FORMAT_STRING const char* pFormat, ...) const FMTFUNCTION(2, 3) = 0;
virtual void ConsoleDPrintf(PRINTF_FORMAT_STRING const char* pFormat, ...) const FMTFUNCTION(2, 3) = 0;
virtual void sub_140598730() = 0;
// Method allowing the engine ICvarQuery interface to take over
// A little hacky, owing to the fact the engine is loaded
// well after ICVar, so we can't use the standard connect pattern
virtual void InstallCVarQuery( ICvarQuery *pQuery ) = 0;
virtual void SetMaxSplitScreenSlots(int nSlots) = 0;
virtual int GetMaxSplitScreenSlots() const = 0;
virtual int GetConsoleDisplayFuncCount() const = 0;
virtual void GetConsoleText(int nDisplayFuncIndex, char* pchText, size_t bufSize) const = 0;
// Utilities for convars accessed by the material system thread
virtual bool IsMaterialThreadSetAllowed() const = 0;
virtual void QueueMaterialThreadSetValue(ConVar* pConVar, const char* pValue) = 0;
virtual void QueueMaterialThreadSetValue(ConVar* pConVar, int nValue) = 0;
virtual void QueueMaterialThreadSetValue(ConVar* pConVar, float flValue) = 0;
virtual bool HasQueuedMaterialThreadConVarSets() const = 0;
virtual int ProcessQueuedMaterialThreadConVarSets() = 0;
protected:
class ICVarIteratorInternal
{
public:
virtual void SetFirst(void) = 0;
virtual void Next(void) = 0;
virtual bool IsValid(void) = 0;
virtual ConCommandBase* Get(void) = 0;
virtual ~ICVarIteratorInternal(void) { }
};
virtual ICVarIteratorInternal* FactoryInternalIterator(void) = 0;
};
#endif // ICVAR_H