]> icculus.org git repositories - divverent/nexuiz.git/blob - data/menuqc/control/data/cvar.qc
rename menu directories
[divverent/nexuiz.git] / data / menuqc / control / data / cvar.qc
1 // DP/Nex Menu
2 // control/data/cvar.qc
3
4 /*
5 ===================
6 Item_Data_Cvar
7 ===================
8 */
9
10 void() Item_Data_Cvar_Sync =
11 {
12         String_EntitySet( self, _syncValue, cvar_string( self.cvarName ) );
13         String_EntitySet( self, value, self._syncValue );
14 };
15
16 void() Item_Data_Cvar_Send =
17 {
18         cvar_set( self.cvarName, self.value );
19         Item_Data_Cvar_Sync();
20 };
21
22 void() Item_Data_Cvar_Reset =
23 {
24         if( self.defValue ) {
25                 String_EntitySet( self, value, self.defValue );
26         } else {
27                 String_EntitySet( self, value, cvar_defstring( self.cvarName ) );
28         }
29         Item_Data_Cvar_Send();
30 };
31
32 void() Item_Data_Cvar_Test_Start =
33 {
34         cvar_set( self.cvarName, self.value );
35 };
36
37 void() Item_Data_Cvar_Test_End =
38 {
39         cvar_set( self.cvarName, self._syncValue );
40 };
41
42 void() Item_Data_Cvar_Save_ExecString = {
43         Data_ExecString = String_Append( Data_ExecString, strcat( "set \"", self.cvarName, "\" \"", self.value, "\"\n" ) );
44 };
45
46 void( float pEvent ) Item_Data_Cvar_DataEvent =
47 {
48         switch( pEvent ) {
49         case ITEM_DATA_SYNC:
50                 Item_Data_Cvar_Sync();
51                 break;
52         case ITEM_DATA_SEND:
53                 Item_Data_Cvar_Send();
54                 break;
55         case ITEM_DATA_RESET:
56                 Item_Data_Cvar_Reset();
57                 break;
58         case ITEM_DATA_TEST_START:
59                 Item_Data_Cvar_Test_Start();
60                 break;
61         case ITEM_DATA_TEST_END:
62                 Item_Data_Cvar_Test_End();
63                 break;
64         case ITEM_DATA_SAVE_EXECSTRING:
65                 Item_Data_Cvar_Save_ExecString();
66                 break;
67         }
68 };
69
70 void() Item_Data_Cvar_Destroy =
71 {
72         Item_Data_Destroy();
73         String_EntityFree( self, cvarName );
74 };
75
76 void() Item_Data_Cvar_Spawn =
77 {
78         String_EntityZone( self, cvarName );
79         Item_Data_Init();
80
81         self.flag = self.flag | FLAG_HIDDEN;
82
83         self._dataEvent = Item_Data_Cvar_DataEvent;
84         self._reinit = Item_Data_Cvar_Sync;
85         self._destroy = Item_Data_Cvar_Destroy;
86 };
87
88 /*
89 ===================
90 Item_Data_CvarCreateSave
91 ===================
92 */
93
94 void() Item_Data_CvarCreateSave_Spawn =
95 {
96         Item_Data_Cvar_Spawn();
97
98         registercvar( self.cvarName, self.defValue, CVAR_SAVE );
99 };