]> icculus.org git repositories - divverent/nexuiz.git/blob - scmenu/source/control/data/cvar.qc
Adding my current version of the scmenu to the nexuiz cvs.
[divverent/nexuiz.git] / scmenu / source / control / data / cvar.qc
1 // DP/Nex Menu
2 // control/data/cvar.qc
3
4 /*
5 ===================
6 Item_Data_CvarCreateSave
7 ===================
8 */
9
10 void() Item_Data_Cvar_Sync =
11 {
12         String_EntitySet( self, _syncValue, str_cvar( 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         String_EntitySet( self, value, self.defValue );
25         Item_Data_Cvar_Send();
26 };
27
28 void() Item_Data_Cvar_Test_Start =
29 {
30         cvar_set( self.cvarName, self.value );
31 };
32
33 void() Item_Data_Cvar_Test_End =
34 {
35         cvar_set( self.cvarName, self._syncValue );
36 };
37
38 void( float pEvent ) Item_Data_Cvar_DataEvent =
39 {
40         switch( pEvent ) {
41         case ITEM_DATA_SYNC:
42                 Item_Data_Cvar_Sync();
43                 break;
44         case ITEM_DATA_SEND:
45                 Item_Data_Cvar_Send();
46                 break;
47         case ITEM_DATA_RESET:
48                 Item_Data_Cvar_Reset();
49                 break;
50         case ITEM_DATA_TEST_START:
51                 Item_Data_Cvar_Test_Start();
52                 break;
53         case ITEM_DATA_TEST_END:
54                 Item_Data_Cvar_Test_End();
55                 break;
56         }
57 };
58
59 void() Item_Data_Cvar_Destroy =
60 {
61         Item_Data_Destroy();
62         String_EntityFree( self, cvarName );
63 };
64
65 void() Item_Data_Cvar_Spawn =
66 {
67         String_EntityZone( self, cvarName );
68         Item_Data_Init();
69
70         self.flag = self.flag | FLAG_HIDDEN;
71
72         self._dataEvent = Item_Data_Cvar_DataEvent;
73         self._reinit = Item_Data_Cvar_Sync;
74         self._destroy = Item_Data_Cvar_Destroy;
75 };
76
77 /*
78 ===================
79 Item_Data_CvarCreateSave
80 ===================
81 */
82
83 void() Item_Data_CvarCreateSave_Spawn =
84 {
85         Item_Data_Cvar_Spawn();
86
87         registercvar( self.cvarName, self.defValue, CVAR_SAVE );
88 };