]> icculus.org git repositories - btb/d2x.git/blob - main/cvar.h
needed for tolower()
[btb/d2x.git] / main / cvar.h
1 /* Console variables */
2
3 #ifndef _CVAR_H
4 #define _CVAR_H 1
5
6 #include "pstypes.h"
7 #include "cfile.h"
8
9
10 // cvar flags
11 #define CVAR_NONE           0
12 #define CVAR_ARCHIVE        1   // save to descent.cfg
13 #define CVAR_CHEAT          512 // can not be changed if cheats are disabled
14
15 // Other examples we could implement (from quake 3, see also iconvar.h from the Source sdk.)
16 //#define CVAR_USERINFO       2   // sent to server on connect or change
17 //#define CVAR_SERVERINFO     4   // sent in response to front end requests
18 //#define CVAR_SYSTEMINFO     8   // these cvars will be duplicated on all clients
19 //#define CVAR_INIT           16  // don't allow change from console at all, but can be set from the command line
20 //#define CVAR_LATCH          32  // will only change when C code next does a Cvar_Get(), so it can't be changed
21 //                                // without proper initialization.  modified will be set, even though the value hasn't changed yet
22 //#define CVAR_ROM            64  // display only, cannot be set by user at all
23 //#define CVAR_USER_CREATED   128 // created by a set command
24 //#define CVAR_TEMP           256 // can be set even when cheats are disabled, but is not archived
25 //#define CVAR_NORESTART     1024 // do not clear when a cvar_restart is issued
26
27 typedef struct cvar_s {
28         const char *name;
29         char *string;
30         ushort flags;
31         fix value;
32         int intval;
33 } cvar_t;
34
35
36 void cvar_init(void);
37
38 /* Register a CVar with the name and string and optionally archive elements set */
39 void cvar_registervariable(cvar_t *cvar);
40
41 /* Set a CVar's value */
42 void cvar_set_cvar(cvar_t *cvar, char *value);
43 void cvar_set_cvarf(cvar_t *cvar, const char *fmt, ...);
44 #define cvar_setint(cvar, x) cvar_set_cvarf((cvar), "%d", (x))
45 #define cvar_setfl(cvar, x) cvar_set_cvarf((cvar), "%f", (x))
46 #define cvar_toggle(cvar) cvar_setint((cvar), !(cvar)->intval)
47
48 /* Equivalent to typing <var_name> <value> at the console */
49 void cvar_set(const char *cvar_name, char *value);
50
51 /* Get the pointer to a cvar by name */
52 cvar_t *cvar_find(const char *cvar_name);
53
54 /* Try to autocomplete a cvar name */
55 const char *cvar_complete(char *text);
56
57 /* Write archive cvars to file */
58 void cvar_write(CFILE *file);
59
60
61 #endif /* _CVAR_H_ */