some stuff
This commit is contained in:
118
public/icvar.h
118
public/icvar.h
@@ -5,6 +5,7 @@
|
||||
#include "tier0/platform.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include "tier1/utlvector.h"
|
||||
#include "tier1/interface.h"
|
||||
|
||||
class ConVar;
|
||||
class ConCommand;
|
||||
@@ -32,12 +33,10 @@ public:
|
||||
|
||||
virtual void AddCommand( const char *psz ) = 0;
|
||||
virtual void InsertCommand( const char *psz ) = 0;
|
||||
|
||||
CUtlVector<ConVar*> m_convars;
|
||||
CUtlVector<ConCommand*> m_commands;
|
||||
};
|
||||
|
||||
IConsole *Console();
|
||||
#define CONSOLE_INTERFACE_VERSION "Console001"
|
||||
|
||||
|
||||
#define FCVAR_NONE 0
|
||||
@@ -91,6 +90,92 @@ private:
|
||||
int m_flags;
|
||||
};
|
||||
|
||||
inline ConVar::ConVar( const char *pName, const char *pDefaultValue, int flags )
|
||||
: ConVar(pName, pDefaultValue, flags, 0)
|
||||
{
|
||||
|
||||
}
|
||||
inline ConVar::ConVar( const char *pName, const char *pDefaultValue, int flags,
|
||||
const char *pHelpString )
|
||||
: ConVar(pName, pDefaultValue, flags, pHelpString, 0)
|
||||
{
|
||||
}
|
||||
inline ConVar::ConVar( const char *pName, const char *pDefaultValue, int flags,
|
||||
const char *pHelpString, ConCommandFn callback )
|
||||
{
|
||||
m_szName = pName;
|
||||
m_flags = flags;
|
||||
SetValue(pDefaultValue);
|
||||
}
|
||||
|
||||
inline bool ConVar::IsFlagSet( int flag )
|
||||
{
|
||||
return (m_flags & flag) > 0;
|
||||
}
|
||||
inline const char *ConVar::GetHelpText( void )
|
||||
{
|
||||
return m_szHelpString;
|
||||
}
|
||||
inline bool ConVar::IsRegistered( void )
|
||||
{
|
||||
|
||||
}
|
||||
inline const char *ConVar::GetName( void )
|
||||
{
|
||||
return m_szName;
|
||||
}
|
||||
inline void ConVar::AddFlags( int flags )
|
||||
{
|
||||
|
||||
}
|
||||
inline bool ConVar::IsCommand( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline void ConVar::InstallChangeCallback( ConCommandFn )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline float ConVar::GetFloat( void )
|
||||
{
|
||||
return m_fValue;
|
||||
}
|
||||
inline int ConVar::GetInt( void )
|
||||
{
|
||||
return m_nValue;
|
||||
}
|
||||
inline bool ConVar::GetBool( void )
|
||||
{
|
||||
return m_nValue;
|
||||
}
|
||||
inline const char *ConVar::GetString( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline void ConVar::SetValue( const char *szValue )
|
||||
{
|
||||
if (!szValue)
|
||||
return;
|
||||
m_szValue = szValue;
|
||||
m_fValue = V_atof(szValue);
|
||||
m_nValue = V_atoi(szValue);
|
||||
}
|
||||
inline void ConVar::SetValue( float fValue )
|
||||
{
|
||||
m_fValue = fValue;
|
||||
m_nValue = fValue;
|
||||
m_szValue = CUtlString("%f\n",fValue);
|
||||
}
|
||||
inline void ConVar::SetValue( int iValue )
|
||||
{
|
||||
m_fValue = iValue;
|
||||
m_nValue = iValue;
|
||||
m_szValue = CUtlString("%i\n",iValue);
|
||||
}
|
||||
|
||||
|
||||
class ConCommand
|
||||
{
|
||||
@@ -109,11 +194,28 @@ private:
|
||||
int m_flags;
|
||||
};
|
||||
|
||||
#undef V_printf
|
||||
#define V_printf(...) Msg(CUtlString(__VA_ARGS__).GetString())
|
||||
inline ConCommand::ConCommand(const char *pName, ConCommandFn callback,
|
||||
const char *pHelpString, int flags)
|
||||
{
|
||||
m_szName = pName;
|
||||
m_callback = callback;
|
||||
m_flags = flags;
|
||||
Console()->RegisterCommand(this);
|
||||
};
|
||||
|
||||
void Msg( const char* message );
|
||||
void Warning( const char* message );
|
||||
void Error( const char* message );
|
||||
inline const char *ConCommand::GetHelpText( void )
|
||||
{
|
||||
return m_szHelpString;
|
||||
}
|
||||
|
||||
inline const char *ConCommand::GetName( void )
|
||||
{
|
||||
return m_szName;
|
||||
}
|
||||
|
||||
inline ConCommandFn ConCommand::GetCallback( void )
|
||||
{
|
||||
return m_callback;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user