some stuff
This commit is contained in:
119
engine/cvar.cpp
119
engine/cvar.cpp
@@ -20,7 +20,7 @@ struct ConsoleMessage_t
|
||||
|
||||
void Msg( const char* message )
|
||||
{
|
||||
printf(message);
|
||||
printf("%s\n", message);
|
||||
|
||||
}
|
||||
|
||||
@@ -57,13 +57,18 @@ public:
|
||||
|
||||
virtual void AddCommand( const char *psz ) override;
|
||||
virtual void InsertCommand( const char *psz ) override;
|
||||
|
||||
CUtlVector<ConVar*> m_convars;
|
||||
CUtlVector<ConCommand*> m_commands;
|
||||
};
|
||||
|
||||
IConsole *Console()
|
||||
{
|
||||
static CConsole s_console;
|
||||
return &s_console;
|
||||
IConsole *pConsole = &s_console;
|
||||
return pConsole;
|
||||
}
|
||||
EXPOSE_INTERFACE_FN(Console, IConsole, CONSOLE_INTERFACE_VERSION);
|
||||
|
||||
void CConsole::Init()
|
||||
{
|
||||
@@ -207,115 +212,6 @@ void CConsole::InsertCommand( const char *psz )
|
||||
g_commandBuffer.AppendHead(psz);
|
||||
};
|
||||
|
||||
ConVar::ConVar( const char *pName, const char *pDefaultValue, int flags )
|
||||
: ConVar(pName, pDefaultValue, flags, 0)
|
||||
{
|
||||
|
||||
}
|
||||
ConVar::ConVar( const char *pName, const char *pDefaultValue, int flags,
|
||||
const char *pHelpString )
|
||||
: ConVar(pName, pDefaultValue, flags, pHelpString, 0)
|
||||
{
|
||||
}
|
||||
ConVar::ConVar( const char *pName, const char *pDefaultValue, int flags,
|
||||
const char *pHelpString, ConCommandFn callback )
|
||||
{
|
||||
m_szName = pName;
|
||||
m_flags = flags;
|
||||
m_szValue = pDefaultValue;
|
||||
m_fValue = V_atof(pDefaultValue);
|
||||
m_nValue = V_atoi(pDefaultValue);
|
||||
Console()->RegisterVar(this);
|
||||
}
|
||||
|
||||
bool ConVar::IsFlagSet( int flag )
|
||||
{
|
||||
|
||||
}
|
||||
const char *ConVar::GetHelpText( void )
|
||||
{
|
||||
return m_szHelpString;
|
||||
}
|
||||
bool ConVar::IsRegistered( void )
|
||||
{
|
||||
|
||||
}
|
||||
const char *ConVar::GetName( void )
|
||||
{
|
||||
return m_szName;
|
||||
}
|
||||
void ConVar::AddFlags( int flags )
|
||||
{
|
||||
|
||||
}
|
||||
bool ConVar::IsCommand( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ConVar::InstallChangeCallback( ConCommandFn )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
float ConVar::GetFloat( void )
|
||||
{
|
||||
return m_fValue;
|
||||
}
|
||||
int ConVar::GetInt( void )
|
||||
{
|
||||
return m_nValue;
|
||||
}
|
||||
bool ConVar::GetBool( void )
|
||||
{
|
||||
return m_nValue;
|
||||
}
|
||||
const char *ConVar::GetString( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ConVar::SetValue( const char *szValue )
|
||||
{
|
||||
if (!szValue)
|
||||
return;
|
||||
m_szValue = szValue;
|
||||
m_fValue = V_atof(szValue);
|
||||
m_nValue = V_atoi(szValue);
|
||||
}
|
||||
void ConVar::SetValue( float fValue )
|
||||
{
|
||||
m_fValue = fValue;
|
||||
m_nValue = fValue;
|
||||
m_szValue = CUtlString("%f\n",fValue);
|
||||
}
|
||||
void ConVar::SetValue( int iValue )
|
||||
{
|
||||
m_fValue = iValue;
|
||||
m_nValue = iValue;
|
||||
m_szValue = CUtlString("%i\n",iValue);
|
||||
}
|
||||
|
||||
ConCommand::ConCommand(const char *pName, ConCommandFn callback,
|
||||
const char *pHelpString, int flags)
|
||||
{
|
||||
m_szName = pName;
|
||||
m_callback = callback;
|
||||
m_flags = flags;
|
||||
Console()->RegisterCommand(this);
|
||||
};
|
||||
const char *ConCommand::GetHelpText( void )
|
||||
{
|
||||
return m_szHelpString;
|
||||
}
|
||||
const char *ConCommand::GetName( void )
|
||||
{
|
||||
return m_szName;
|
||||
}
|
||||
ConCommandFn ConCommand::GetCallback( void )
|
||||
{
|
||||
return m_callback;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -330,6 +226,7 @@ void IConsole_Exec( int argc, char **argv)
|
||||
CUtlBuffer<char> b(filesystem->Size(f)+1);
|
||||
filesystem->Read(f, b, b.GetSize());
|
||||
b[b.GetSize()-1] = 0;
|
||||
|
||||
Console()->AddCommand(b);
|
||||
Console()->AddCommand(";");
|
||||
Console()->Execute();
|
||||
|
||||
Reference in New Issue
Block a user