29 #include "../idlib/precompiled.h"
46 idInternalCVar(
const char *newName,
const char *newValue,
int newFlags );
54 void Set(
const char *newValue,
bool force,
bool fromServer );
150 for ( i = 0; strings[
i] !=
NULL; i++ ) {
154 ptr = (
const char **)
Mem_Alloc( ( i + 1 ) *
sizeof(
char * ) + totalLength );
155 str = (
char *) (((
byte *)ptr) + ( i + 1 ) *
sizeof(
char * ) );
157 for ( i = 0; strings[
i] !=
NULL; i++ ) {
159 strcpy( str, strings[i] );
223 bool clamped =
false;
372 Set( newValue,
true,
false );
381 Set( newValue,
true,
true );
390 Set(
idStr( newValue ),
true,
false );
399 Set(
idStr( newValue ),
true,
false );
408 Set(
idStr( newValue ),
true,
false );
426 virtual void Init(
void );
491 #define NUM_COLUMNS 77 // 78 - 1
492 #define NUM_NAME_CHARS 33
493 #define NUM_DESCRIPTION_CHARS ( NUM_COLUMNS - NUM_NAME_CHARS )
494 #define FORMAT_STRING "%-32s "
496 const char *
CreateColumn(
const char *text,
int columnWidth,
const char *indent,
idStr &
string ) {
500 for ( lastLine = i = 0; text[
i] !=
'\0'; i++ ) {
501 if ( i - lastLine >= columnWidth || text[i] ==
'\n' ) {
502 while( i > 0 && text[i] >
' ' && text[i] !=
'/' && text[i] !=
',' && text[i] !=
'\\' ) {
505 while( lastLine < i ) {
506 string.Append( text[lastLine++] );
508 string.Append( indent );
512 while( lastLine < i ) {
513 string.Append( text[lastLine++] );
515 return string.c_str();
526 if (
cvars[
i]->nameString.Icmp( name ) == 0 ) {
545 internal->InternalSetString( value );
547 internal->UpdateCheat();
685 return internal->GetString();
698 return internal->GetBool();
711 return internal->GetInteger();
724 return internal->GetFloat();
739 if (
internal ==
NULL ) {
743 if ( args.
Argc() == 1 ) {
746 internal->nameString.c_str(),
internal->valueString.c_str(),
internal->resetString.c_str() );
752 internal->Set( args.
Args(),
false, false );
779 if ( !
cvars[
i]->valueCompletion ) {
907 " toggle <variable> - toggles between 0 and 1\n"
908 " toggle <variable> <value> - toggles between 0 and <value>\n"
909 " toggle <variable> [string 1] [string 2]...[string n] - cycles through all strings\n");
915 if ( cvar ==
NULL ) {
923 for( i = 2; i < argc; i++ ) {
935 cvar->
Set(
va(
"%s", args.
Argv( i ) ),
false,
false );
940 set = atof( args.
Argv( 2 ) );
944 if ( current == 0.0
f ) {
950 cvar->
Set(
idStr( current ),
false,
false );
962 str = args.
Args( 2, args.
Argc() - 1 );
1042 if ( args.
Argc() != 2 ) {
1062 return idStr::Icmp( (*a)->GetName(), (*b)->GetName() );
1084 show = SHOW_DESCRIPTION;
1094 if ( args.
Argc() > argNum ) {
1095 match = args.
Args( argNum, -1 );
1101 for ( i = 0; i < localCVarSystem.
cvars.
Num(); i++ ) {
1102 cvar = localCVarSystem.
cvars[
i];
1104 if ( !( cvar->
GetFlags() & flags ) ) {
1119 for ( i = 0; i < cvarList.
Num(); i++ ) {
1125 case SHOW_DESCRIPTION: {
1127 indent.
Insert(
"\n", 0 );
1129 for ( i = 0; i < cvarList.
Num(); i++ ) {
1136 for ( i = 0; i < cvarList.
Num(); i++ ) {
1169 for ( i = 0; i < cvarList.
Num(); i++ ) {
1213 common->
Printf(
"listCvar [search string] = list cvar values\n"
1214 "listCvar -help [search string] = list cvar descriptions\n"
1215 "listCvar -type [search string] = list cvar types\n"
1216 "listCvar -flags [search string] = list cvar flags\n" );
1237 for ( i = 0; i < localCVarSystem.
cvars.
Num(); i++ ) {
1238 cvar = localCVarSystem.
cvars[
i];
virtual int GetCVarInteger(const char *name) const
GLsizei const GLfloat * value
virtual void InternalSetFloat(const float newValue)
argCompletion_t GetValueCompletion(void) const
static void Set_f(const idCmdArgs &args)
int Cmp(const char *text) const
bool IsActive(void) const
idCVarSystem * cvarSystem
void SetInternal(const char *name, const char *value, int flags)
int Next(const int index) const
float GetFloat(void) const
const idStr & GetKey(void) const
virtual void SetModifiedFlags(int flags)
static void Restart_f(const idCmdArgs &args)
static void Toggle_f(const idCmdArgs &args)
bool Filter(const char *filter, bool casesensitive) const
virtual void RemoveFlaggedAutoCompletion(int flags)
virtual void SetModifiedFlags(int flags)=0
static idAsyncClient client
#define NUM_DESCRIPTION_CHARS
virtual bool GetCVarBool(const char *name) const
const char ** GetValueStrings(void) const
const char * Args(int start=1, int end=-1, bool escapeArgs=false) const
GLenum GLsizei const GLvoid * string
const char ** valueStrings
idCVarSystemLocal localCVarSystem
virtual bool IsInitialized(void) const
virtual bool IsMultiplayer()=0
void RemoveIndex(const int key, const int index)
void Set(const char *key, const char *value)
virtual void ArgCompletion(const char *cmdString, void(*callback)(const char *s))
static void ListByFlags(const idCmdArgs &args, cvarFlags_t flags)
int Icmp(const char *text) const
virtual int GetModifiedFlags(void) const
virtual const idDict * MoveCVarsToDict(int flags) const
int First(const int key) const
void RegisterInternal(idCVar *cvar)
void Sort(cmp_t *compare=(cmp_t *)&idListSortCompare< type >)
void SetInternalVar(idCVar *cvar)
static void SetS_f(const idCmdArgs &args)
virtual void InternalSetInteger(const int newValue)
static void SetT_f(const idCmdArgs &args)
virtual void Shutdown(void)
virtual void SetCVarFloat(const char *name, const float value, int flags=0)
virtual void SetCVarsFromDict(const idDict &dict)
static void SetA_f(const idCmdArgs &args)
virtual void Register(idCVar *cvar)
virtual void InternalSetBool(const bool newValue)
virtual void SetCVarBool(const char *name, const bool value, int flags=0)
virtual void InternalServerSetString(const char *newValue)
const idStr & GetValue(void) const
void Insert(const char a, int index)
void DeleteContents(bool clear)
static idCVar * staticVars
GLubyte GLubyte GLubyte a
virtual void Printf(const char *fmt,...) id_attribute((format(printf
static void Reset_f(const idCmdArgs &args)
int GenerateKey(const char *string, bool caseSensitive=true) const
void TokenizeString(const char *text, bool keepAsStrings)
const char * GetString(void) const
virtual ~idInternalCVar(void)
bool IsNumeric(void) const
void Update(const idCVar *cvar)
virtual void CommandCompletion(void(*callback)(const char *s))
static int FindChar(const char *str, const char c, int start=0, int end=-1)
int Append(const type &obj)
virtual ~idCVarSystemLocal(void)
static void List_f(const idCmdArgs &args)
virtual float GetCVarFloat(const char *name) const
static idDict moveCVarsToDict
virtual void InternalSetString(const char *newValue)
virtual void SetCVarString(const char *name, const char *value, int flags=0)
bool RemoveIndex(int index)
virtual idCVar * Find(const char *name)
virtual bool Command(const idCmdArgs &args)
const char * CreateColumn(const char *text, int columnWidth, const char *indent, idStr &string)
const char ** CopyValueStrings(const char **strings)
void Fill(const char ch, int newlen)
const char * GetDescription(void) const
const char * c_str(void) const
virtual const char * GetCVarString(const char *name) const
virtual bool GetCVarBool(const char *name) const =0
const idKeyValue * GetKeyVal(int index) const
ID_INLINE int idListSortCompare(const idInternalCVar *const *a, const idInternalCVar *const *b)
const char * Argv(int arg) const
void Add(const int key, const int index)
void * Mem_Alloc(const int size)
argCompletion_t valueCompletion
float GetMinValue(void) const
char * va(const char *fmt,...)
idList< idInternalCVar * > cvars
void Replace(const char *old, const char *nw)
int GetNumKeyVals(void) const
virtual void virtual void Warning(const char *fmt,...) id_attribute((format(printf
void Set(const char *newValue, bool force, bool fromServer)
virtual void WriteFlaggedVariables(int flags, const char *setCmd, idFile *f) const
idInternalCVar * FindInternal(const char *name) const
virtual int Printf(const char *fmt,...) id_attribute((format(printf
virtual void SetCVarInteger(const char *name, const int value, int flags=0)
virtual void AddCommand(const char *cmdName, cmdFunction_t function, int flags, const char *description, argCompletion_t argCompletion=NULL)=0
float GetMaxValue(void) const
const char * GetName(void) const
virtual void ClearModifiedFlags(int flags)
virtual void ResetFlaggedVariables(int flags)
static void SetU_f(const idCmdArgs &args)