]> icculus.org git repositories - btb/d2x.git/blob - main/cvar.h
miscellaneous fixes
[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 typedef struct cvar_s
11 {
12         char *name;
13         char *string;
14         bool archive;
15         fix value;
16         int intval;
17         struct cvar_s *next;
18 } cvar_t;
19
20
21 void cvar_init(void);
22
23 /* Register a CVar with the name and string and optionally archive elements set */
24 void cvar_registervariable(cvar_t *cvar);
25
26 /* Set a CVar's value */
27 void cvar_set_cvar(cvar_t *cvar, char *value);
28 void cvar_set_cvarf(cvar_t *cvar, const char *fmt, ...);
29 #define cvar_setint(cvar, x) cvar_set_cvarf((cvar), "%d", (x))
30 #define cvar_setfl(cvar, x) cvar_set_cvarf((cvar), "%f", (x))
31 #define cvar_toggle(cvar) cvar_setint((cvar), !(cvar)->intval)
32
33 /* Equivalent to typing <var_name> <value> at the console */
34 void cvar_set(char *cvar_name, char *value);
35
36 /* Get the pointer to a cvar by name */
37 cvar_t *cvar_find(char *cvar_name);
38
39 /* Try to autocomplete a cvar name */
40 const char *cvar_complete(char *text);
41
42 /* Get a CVar's value */
43 fix cvar(char *cvar_name);
44
45 /* Write archive cvars to file */
46 void cvar_write(CFILE *file);
47
48
49 #endif /* _CVAR_H_ */