2006-02-24 04:48:15 +00:00
|
|
|
/*
|
|
|
|
** c_cvars.h
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
2006-06-11 01:37:00 +00:00
|
|
|
** Copyright 1998-2006 Randy Heit
|
2006-02-24 04:48:15 +00:00
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __C_CVARS_H__
|
|
|
|
#define __C_CVARS_H__
|
|
|
|
|
|
|
|
#include "doomtype.h"
|
|
|
|
#include "tarray.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
==========================================================
|
|
|
|
|
|
|
|
CVARS (console variables)
|
|
|
|
|
|
|
|
==========================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
CVAR_ARCHIVE = 1, // set to cause it to be saved to config
|
|
|
|
CVAR_USERINFO = 2, // added to userinfo when changed
|
|
|
|
CVAR_SERVERINFO = 4, // added to serverinfo when changed
|
|
|
|
CVAR_NOSET = 8, // don't allow change from console at all,
|
|
|
|
// but can be set from the command line
|
|
|
|
CVAR_LATCH = 16, // save changes until server restart
|
|
|
|
CVAR_UNSETTABLE = 32, // can unset this var from console
|
|
|
|
CVAR_DEMOSAVE = 64, // save the value of this cvar in a demo
|
|
|
|
CVAR_ISDEFAULT = 128, // is cvar unchanged since creation?
|
|
|
|
CVAR_AUTO = 256, // allocated; needs to be freed when destroyed
|
|
|
|
CVAR_NOINITCALL = 512, // don't call callback at game start
|
|
|
|
CVAR_GLOBALCONFIG = 1024, // cvar is saved to global config section
|
|
|
|
CVAR_VIDEOCONFIG = 2048, // cvar is saved to video config section (not implemented)
|
|
|
|
CVAR_NOSAVE = 4096, // when used with CVAR_SERVERINFO, do not save var to savegame
|
2013-05-25 17:08:59 +00:00
|
|
|
CVAR_MOD = 8192, // cvar was defined by a mod
|
|
|
|
CVAR_IGNORE = 16384,// do not send cvar across the network/inaccesible from ACS (dummy mod cvar)
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
union UCVarValue
|
|
|
|
{
|
|
|
|
bool Bool;
|
|
|
|
int Int;
|
|
|
|
float Float;
|
2013-05-27 02:20:32 +00:00
|
|
|
const char *String;
|
2006-02-24 04:48:15 +00:00
|
|
|
const GUID *pGUID;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ECVarType
|
|
|
|
{
|
|
|
|
CVAR_Bool,
|
|
|
|
CVAR_Int,
|
|
|
|
CVAR_Float,
|
|
|
|
CVAR_String,
|
|
|
|
CVAR_Color, // stored as CVAR_Int
|
|
|
|
CVAR_Dummy, // just redirects to another cvar
|
|
|
|
CVAR_GUID
|
|
|
|
};
|
|
|
|
|
|
|
|
class FConfigFile;
|
|
|
|
class AActor;
|
|
|
|
|
|
|
|
class FBaseCVar
|
|
|
|
{
|
|
|
|
public:
|
2006-09-14 00:02:31 +00:00
|
|
|
FBaseCVar (const char *name, uint32 flags, void (*callback)(FBaseCVar &));
|
2006-02-24 04:48:15 +00:00
|
|
|
virtual ~FBaseCVar ();
|
|
|
|
|
|
|
|
inline void Callback () { if (m_Callback) m_Callback (*this); }
|
|
|
|
|
|
|
|
inline const char *GetName () const { return Name; }
|
2006-09-14 00:02:31 +00:00
|
|
|
inline uint32 GetFlags () const { return Flags; }
|
2013-05-12 18:27:03 +00:00
|
|
|
inline FBaseCVar *GetNext() const { return m_Next; }
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
void CmdSet (const char *newval);
|
- Added three new ACS functions:
* int GetUserCVar(int playernum, "cvarname")
* bool SetCVar("cvarname", newvalue)
* bool SetUserCVar(int playernum, "cvarname", newvalue)
GetUserCVar is analogous to GetCVar, except it returns the value of a user cvar for a
specific player. (All user cvars can be examined using the playerinfo console command.)
SetCVar sets a cvar to a new value. If the cvar is floating point, then newvalue is treated
as a fixed point number, otherwise it's treated as an integer. SetUserCVar is the same, but
for a specific player's user cvar.
SetCVar and SetUserCVar can only change cvars created via CVARINFO. They cannot alter built-in cvars.
If you use GetCVar or SetCVar with a user cvar, they will act on the copy of the user cvar
for the player who activated the script. e.g.
GetCVar("gender")
is the same as
GetUserCVar(PlayerNumber(), "gender")
If you get the value of a floating point cvar, it will be returned as a fixed point number.
Otherwise, it will be returned as an integer.
SVN r4283 (trunk)
2013-05-25 19:08:05 +00:00
|
|
|
void ForceSet (UCVarValue value, ECVarType type, bool nouserinfosend=false);
|
2006-02-24 04:48:15 +00:00
|
|
|
void SetGenericRep (UCVarValue value, ECVarType type);
|
|
|
|
void ResetToDefault ();
|
|
|
|
void SetArchiveBit () { Flags |= CVAR_ARCHIVE; }
|
|
|
|
|
|
|
|
virtual ECVarType GetRealType () const = 0;
|
|
|
|
|
|
|
|
virtual UCVarValue GetGenericRep (ECVarType type) const = 0;
|
|
|
|
virtual UCVarValue GetFavoriteRep (ECVarType *type) const = 0;
|
|
|
|
|
|
|
|
virtual UCVarValue GetGenericRepDefault (ECVarType type) const = 0;
|
|
|
|
virtual UCVarValue GetFavoriteRepDefault (ECVarType *type) const = 0;
|
|
|
|
virtual void SetGenericRepDefault (UCVarValue value, ECVarType type) = 0;
|
|
|
|
|
|
|
|
FBaseCVar &operator= (const FBaseCVar &var)
|
|
|
|
{ UCVarValue val; ECVarType type; val = var.GetFavoriteRep (&type); SetGenericRep (val, type); return *this; }
|
|
|
|
|
|
|
|
static void EnableNoSet (); // enable the honoring of CVAR_NOSET
|
|
|
|
static void EnableCallbacks ();
|
2010-12-15 11:45:39 +00:00
|
|
|
static void DisableCallbacks ();
|
2006-02-24 04:48:15 +00:00
|
|
|
static void ResetColors (); // recalc color cvars' indices after screen change
|
|
|
|
|
|
|
|
static void ListVars (const char *filter, bool plain);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
FBaseCVar () {}
|
|
|
|
virtual void DoSet (UCVarValue value, ECVarType type) = 0;
|
|
|
|
|
|
|
|
static bool ToBool (UCVarValue value, ECVarType type);
|
|
|
|
static int ToInt (UCVarValue value, ECVarType type);
|
|
|
|
static float ToFloat (UCVarValue value, ECVarType type);
|
2013-05-27 02:20:32 +00:00
|
|
|
static const char *ToString (UCVarValue value, ECVarType type);
|
2006-02-24 04:48:15 +00:00
|
|
|
static const GUID *ToGUID (UCVarValue value, ECVarType type);
|
|
|
|
static UCVarValue FromBool (bool value, ECVarType type);
|
|
|
|
static UCVarValue FromInt (int value, ECVarType type);
|
|
|
|
static UCVarValue FromFloat (float value, ECVarType type);
|
|
|
|
static UCVarValue FromString (const char *value, ECVarType type);
|
|
|
|
static UCVarValue FromGUID (const GUID &value, ECVarType type);
|
|
|
|
|
|
|
|
char *Name;
|
2006-09-14 00:02:31 +00:00
|
|
|
uint32 Flags;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
FBaseCVar (const FBaseCVar &var);
|
2006-09-14 00:02:31 +00:00
|
|
|
FBaseCVar (const char *name, uint32 flags);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
void (*m_Callback)(FBaseCVar &);
|
|
|
|
FBaseCVar *m_Next;
|
|
|
|
|
|
|
|
static bool m_UseCallback;
|
|
|
|
static bool m_DoNoSet;
|
|
|
|
|
2013-03-17 03:04:17 +00:00
|
|
|
friend FString C_GetMassCVarString (uint32 filter, bool compact);
|
2006-09-14 00:02:31 +00:00
|
|
|
friend void C_ReadCVars (BYTE **demo_p);
|
2006-02-24 04:48:15 +00:00
|
|
|
friend void C_BackupCVars (void);
|
|
|
|
friend FBaseCVar *FindCVar (const char *var_name, FBaseCVar **prev);
|
|
|
|
friend FBaseCVar *FindCVarSub (const char *var_name, int namelen);
|
|
|
|
friend void UnlatchCVars (void);
|
2014-12-02 03:04:50 +00:00
|
|
|
friend void DestroyCVarsFlagged (DWORD flags);
|
2013-05-25 03:23:44 +00:00
|
|
|
friend void C_ArchiveCVars (FConfigFile *f, uint32 filter);
|
2006-02-24 04:48:15 +00:00
|
|
|
friend void C_SetCVarsToDefaults (void);
|
2006-09-14 00:02:31 +00:00
|
|
|
friend void FilterCompactCVars (TArray<FBaseCVar *> &cvars, uint32 filter);
|
2006-05-12 03:14:40 +00:00
|
|
|
friend void C_DeinitConsole();
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
2013-03-17 03:04:17 +00:00
|
|
|
// Returns a string with all cvars whose flags match filter. In compact mode,
|
|
|
|
// the cvar names are omitted to save space.
|
|
|
|
FString C_GetMassCVarString (uint32 filter, bool compact=false);
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
// Writes all cvars that could effect demo sync to *demo_p. These are
|
|
|
|
// cvars that have either CVAR_SERVERINFO or CVAR_DEMOSAVE set.
|
2006-09-14 00:02:31 +00:00
|
|
|
void C_WriteCVars (BYTE **demo_p, uint32 filter, bool compact=false);
|
2006-05-25 04:32:20 +00:00
|
|
|
|
|
|
|
// Read all cvars from *demo_p and set them appropriately.
|
2006-09-14 00:02:31 +00:00
|
|
|
void C_ReadCVars (BYTE **demo_p);
|
2006-05-25 04:32:20 +00:00
|
|
|
|
|
|
|
// Backup demo cvars. Called before a demo starts playing to save all
|
|
|
|
// cvars the demo might change.
|
|
|
|
void C_BackupCVars (void);
|
|
|
|
|
|
|
|
// Finds a named cvar
|
|
|
|
FBaseCVar *FindCVar (const char *var_name, FBaseCVar **prev);
|
|
|
|
FBaseCVar *FindCVarSub (const char *var_name, int namelen);
|
|
|
|
|
2013-05-12 18:27:03 +00:00
|
|
|
// Create a new cvar with the specified name and type
|
|
|
|
FBaseCVar *C_CreateCVar(const char *var_name, ECVarType var_type, DWORD flags);
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
// Called from G_InitNew()
|
|
|
|
void UnlatchCVars (void);
|
|
|
|
|
2014-12-02 03:04:50 +00:00
|
|
|
// Destroy CVars with the matching flags; called from CCMD(restart)
|
|
|
|
void DestroyCVarsFlagged (DWORD flags);
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
// archive cvars to FILE f
|
2013-05-25 03:23:44 +00:00
|
|
|
void C_ArchiveCVars (FConfigFile *f, uint32 filter);
|
2006-05-25 04:32:20 +00:00
|
|
|
|
|
|
|
// initialize cvars to default values after they are created
|
|
|
|
void C_SetCVarsToDefaults (void);
|
|
|
|
|
2006-09-14 00:02:31 +00:00
|
|
|
void FilterCompactCVars (TArray<FBaseCVar *> &cvars, uint32 filter);
|
2006-05-25 04:32:20 +00:00
|
|
|
|
|
|
|
void C_DeinitConsole();
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
class FBoolCVar : public FBaseCVar
|
|
|
|
{
|
|
|
|
public:
|
2006-09-14 00:02:31 +00:00
|
|
|
FBoolCVar (const char *name, bool def, uint32 flags, void (*callback)(FBoolCVar &)=NULL);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
virtual ECVarType GetRealType () const;
|
|
|
|
|
|
|
|
virtual UCVarValue GetGenericRep (ECVarType type) const;
|
|
|
|
virtual UCVarValue GetFavoriteRep (ECVarType *type) const;
|
|
|
|
virtual UCVarValue GetGenericRepDefault (ECVarType type) const;
|
|
|
|
virtual UCVarValue GetFavoriteRepDefault (ECVarType *type) const;
|
|
|
|
virtual void SetGenericRepDefault (UCVarValue value, ECVarType type);
|
|
|
|
|
|
|
|
inline bool operator= (bool boolval)
|
|
|
|
{ UCVarValue val; val.Bool = boolval; SetGenericRep (val, CVAR_Bool); return boolval; }
|
|
|
|
inline operator bool () const { return Value; }
|
|
|
|
inline bool operator *() const { return Value; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void DoSet (UCVarValue value, ECVarType type);
|
|
|
|
|
|
|
|
bool Value;
|
|
|
|
bool DefaultValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FIntCVar : public FBaseCVar
|
|
|
|
{
|
|
|
|
public:
|
2006-09-14 00:02:31 +00:00
|
|
|
FIntCVar (const char *name, int def, uint32 flags, void (*callback)(FIntCVar &)=NULL);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
virtual ECVarType GetRealType () const;
|
|
|
|
|
|
|
|
virtual UCVarValue GetGenericRep (ECVarType type) const;
|
|
|
|
virtual UCVarValue GetFavoriteRep (ECVarType *type) const;
|
|
|
|
virtual UCVarValue GetGenericRepDefault (ECVarType type) const;
|
|
|
|
virtual UCVarValue GetFavoriteRepDefault (ECVarType *type) const;
|
|
|
|
virtual void SetGenericRepDefault (UCVarValue value, ECVarType type);
|
|
|
|
|
|
|
|
int operator= (int intval)
|
|
|
|
{ UCVarValue val; val.Int = intval; SetGenericRep (val, CVAR_Int); return intval; }
|
|
|
|
inline operator int () const { return Value; }
|
|
|
|
inline int operator *() const { return Value; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void DoSet (UCVarValue value, ECVarType type);
|
|
|
|
|
|
|
|
int Value;
|
|
|
|
int DefaultValue;
|
|
|
|
|
|
|
|
friend class FFlagCVar;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FFloatCVar : public FBaseCVar
|
|
|
|
{
|
|
|
|
public:
|
2006-09-14 00:02:31 +00:00
|
|
|
FFloatCVar (const char *name, float def, uint32 flags, void (*callback)(FFloatCVar &)=NULL);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
virtual ECVarType GetRealType () const;
|
|
|
|
|
|
|
|
virtual UCVarValue GetGenericRep (ECVarType type) const;
|
|
|
|
virtual UCVarValue GetFavoriteRep (ECVarType *type) const;
|
|
|
|
virtual UCVarValue GetGenericRepDefault (ECVarType type) const;
|
|
|
|
virtual UCVarValue GetFavoriteRepDefault (ECVarType *type) const;
|
|
|
|
virtual void SetGenericRepDefault (UCVarValue value, ECVarType type);
|
|
|
|
|
|
|
|
float operator= (float floatval)
|
|
|
|
{ UCVarValue val; val.Float = floatval; SetGenericRep (val, CVAR_Float); return floatval; }
|
|
|
|
inline operator float () const { return Value; }
|
|
|
|
inline float operator *() const { return Value; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void DoSet (UCVarValue value, ECVarType type);
|
|
|
|
|
|
|
|
float Value;
|
|
|
|
float DefaultValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FStringCVar : public FBaseCVar
|
|
|
|
{
|
|
|
|
public:
|
2006-09-14 00:02:31 +00:00
|
|
|
FStringCVar (const char *name, const char *def, uint32 flags, void (*callback)(FStringCVar &)=NULL);
|
2006-05-04 03:49:46 +00:00
|
|
|
~FStringCVar ();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
virtual ECVarType GetRealType () const;
|
|
|
|
|
|
|
|
virtual UCVarValue GetGenericRep (ECVarType type) const;
|
|
|
|
virtual UCVarValue GetFavoriteRep (ECVarType *type) const;
|
|
|
|
virtual UCVarValue GetGenericRepDefault (ECVarType type) const;
|
|
|
|
virtual UCVarValue GetFavoriteRepDefault (ECVarType *type) const;
|
|
|
|
virtual void SetGenericRepDefault (UCVarValue value, ECVarType type);
|
|
|
|
|
|
|
|
const char *operator= (const char *stringrep)
|
|
|
|
{ UCVarValue val; val.String = const_cast<char *>(stringrep); SetGenericRep (val, CVAR_String); return stringrep; }
|
|
|
|
inline operator const char * () const { return Value; }
|
|
|
|
inline const char *operator *() const { return Value; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void DoSet (UCVarValue value, ECVarType type);
|
|
|
|
|
|
|
|
char *Value;
|
|
|
|
char *DefaultValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FColorCVar : public FIntCVar
|
|
|
|
{
|
|
|
|
public:
|
2006-09-14 00:02:31 +00:00
|
|
|
FColorCVar (const char *name, int def, uint32 flags, void (*callback)(FColorCVar &)=NULL);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
virtual ECVarType GetRealType () const;
|
|
|
|
|
|
|
|
virtual UCVarValue GetGenericRep (ECVarType type) const;
|
|
|
|
virtual UCVarValue GetGenericRepDefault (ECVarType type) const;
|
|
|
|
virtual void SetGenericRepDefault (UCVarValue value, ECVarType type);
|
|
|
|
|
2006-09-14 00:02:31 +00:00
|
|
|
inline operator uint32 () const { return Value; }
|
|
|
|
inline uint32 operator *() const { return Value; }
|
2006-02-24 04:48:15 +00:00
|
|
|
inline int GetIndex () const { return Index; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void DoSet (UCVarValue value, ECVarType type);
|
|
|
|
|
|
|
|
static UCVarValue FromInt2 (int value, ECVarType type);
|
|
|
|
static int ToInt2 (UCVarValue value, ECVarType type);
|
|
|
|
|
|
|
|
int Index;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FFlagCVar : public FBaseCVar
|
|
|
|
{
|
|
|
|
public:
|
2006-09-14 00:02:31 +00:00
|
|
|
FFlagCVar (const char *name, FIntCVar &realvar, uint32 bitval);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
virtual ECVarType GetRealType () const;
|
|
|
|
|
|
|
|
virtual UCVarValue GetGenericRep (ECVarType type) const;
|
|
|
|
virtual UCVarValue GetFavoriteRep (ECVarType *type) const;
|
|
|
|
virtual UCVarValue GetGenericRepDefault (ECVarType type) const;
|
|
|
|
virtual UCVarValue GetFavoriteRepDefault (ECVarType *type) const;
|
|
|
|
virtual void SetGenericRepDefault (UCVarValue value, ECVarType type);
|
|
|
|
|
|
|
|
bool operator= (bool boolval)
|
|
|
|
{ UCVarValue val; val.Bool = boolval; SetGenericRep (val, CVAR_Bool); return boolval; }
|
2006-12-21 04:34:43 +00:00
|
|
|
bool operator= (FFlagCVar &flag)
|
|
|
|
{ UCVarValue val; val.Bool = !!flag; SetGenericRep (val, CVAR_Bool); return val.Bool; }
|
2006-02-24 04:48:15 +00:00
|
|
|
inline operator int () const { return (ValueVar & BitVal); }
|
|
|
|
inline int operator *() const { return (ValueVar & BitVal); }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void DoSet (UCVarValue value, ECVarType type);
|
|
|
|
|
|
|
|
FIntCVar &ValueVar;
|
2006-09-14 00:02:31 +00:00
|
|
|
uint32 BitVal;
|
2006-02-24 04:48:15 +00:00
|
|
|
int BitNum;
|
|
|
|
};
|
2010-09-14 17:28:18 +00:00
|
|
|
|
|
|
|
class FMaskCVar : public FBaseCVar
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FMaskCVar (const char *name, FIntCVar &realvar, uint32 bitval);
|
|
|
|
|
|
|
|
virtual ECVarType GetRealType () const;
|
|
|
|
|
|
|
|
virtual UCVarValue GetGenericRep (ECVarType type) const;
|
|
|
|
virtual UCVarValue GetFavoriteRep (ECVarType *type) const;
|
|
|
|
virtual UCVarValue GetGenericRepDefault (ECVarType type) const;
|
|
|
|
virtual UCVarValue GetFavoriteRepDefault (ECVarType *type) const;
|
|
|
|
virtual void SetGenericRepDefault (UCVarValue value, ECVarType type);
|
|
|
|
|
|
|
|
inline operator int () const { return (ValueVar & BitVal) >> BitNum; }
|
|
|
|
inline int operator *() const { return (ValueVar & BitVal) >> BitNum; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void DoSet (UCVarValue value, ECVarType type);
|
|
|
|
|
|
|
|
FIntCVar &ValueVar;
|
|
|
|
uint32 BitVal;
|
|
|
|
int BitNum;
|
|
|
|
};
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
class FGUIDCVar : public FBaseCVar
|
|
|
|
{
|
|
|
|
public:
|
2006-09-14 00:02:31 +00:00
|
|
|
FGUIDCVar (const char *name, const GUID *defguid, uint32 flags, void (*callback)(FGUIDCVar &)=NULL);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
virtual ECVarType GetRealType () const;
|
|
|
|
|
|
|
|
virtual UCVarValue GetGenericRep (ECVarType type) const;
|
|
|
|
virtual UCVarValue GetFavoriteRep (ECVarType *type) const;
|
|
|
|
virtual UCVarValue GetGenericRepDefault (ECVarType type) const;
|
|
|
|
virtual UCVarValue GetFavoriteRepDefault (ECVarType *type) const;
|
|
|
|
virtual void SetGenericRepDefault (UCVarValue value, ECVarType type);
|
|
|
|
|
|
|
|
const GUID &operator= (const GUID &guidval)
|
|
|
|
{ UCVarValue val; val.pGUID = &guidval; SetGenericRep (val, CVAR_GUID); return guidval; }
|
|
|
|
inline operator const GUID & () const { return Value; }
|
|
|
|
inline const GUID &operator *() const { return Value; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void DoSet (UCVarValue value, ECVarType type);
|
|
|
|
|
|
|
|
GUID Value;
|
|
|
|
GUID DefaultValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern int cvar_defflags;
|
|
|
|
|
|
|
|
FBaseCVar *cvar_set (const char *var_name, const char *value);
|
|
|
|
FBaseCVar *cvar_forceset (const char *var_name, const char *value);
|
|
|
|
|
2006-09-14 00:02:31 +00:00
|
|
|
inline FBaseCVar *cvar_set (const char *var_name, const BYTE *value) { return cvar_set (var_name, (const char *)value); }
|
|
|
|
inline FBaseCVar *cvar_forceset (const char *var_name, const BYTE *value) { return cvar_forceset (var_name, (const char *)value); }
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Restore demo cvars. Called after demo playback to restore all cvars
|
|
|
|
// that might possibly have been changed during the course of demo playback.
|
|
|
|
void C_RestoreCVars (void);
|
|
|
|
|
2009-03-04 23:19:46 +00:00
|
|
|
void C_ForgetCVars (void);
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
#define CUSTOM_CVAR(type,name,def,flags) \
|
|
|
|
static void cvarfunc_##name(F##type##CVar &); \
|
|
|
|
F##type##CVar name (#name, def, flags, cvarfunc_##name); \
|
|
|
|
static void cvarfunc_##name(F##type##CVar &self)
|
|
|
|
|
|
|
|
#define CVAR(type,name,def,flags) \
|
|
|
|
F##type##CVar name (#name, def, flags);
|
|
|
|
|
|
|
|
#define EXTERN_CVAR(type,name) extern F##type##CVar name;
|
|
|
|
|
2013-05-12 18:27:03 +00:00
|
|
|
extern FBaseCVar *CVars;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
#endif //__C_CVARS_H__
|