]> icculus.org git repositories - divverent/nexuiz.git/blob - scmenu/source/control/data/base.qc
Adding my current version of the scmenu to the nexuiz cvs.
[divverent/nexuiz.git] / scmenu / source / control / data / base.qc
1 // DP/Nex Menu
2 // control/data/base.qc
3
4 /*
5 ===================
6 Raise_DataEvent
7 ===================
8 */
9 void( entity pItem, float pEvent ) Raise_DataEvent =
10 {
11         local entity lOld;
12
13         if( !pItem._dataEvent )
14                 return;
15
16         lOld = self;
17         self = pItem;
18         self._dataEvent( pEvent );
19         self = lOld;
20 };
21
22 /////////////////////
23 // [Item_Data]
24 ///
25
26 /*
27 ===================
28 Item_Data_Destroy
29 ===================
30 */
31 void() Item_Data_Destroy =
32 {
33         String_EntityFree( self, value );
34         String_EntityFree( self, defValue );
35         String_EntityFree( self, _syncValue );
36 };
37
38 /*
39 ===================
40 Item_Data_Init
41 ===================
42 */
43 void() Item_Data_Init =
44 {
45         String_EntityZone( self, value );
46         String_EntityZone( self, defValue );
47         String_EntityCreate( self, _syncValue );
48
49         self.flag = self.flag | FLAG_HIDDEN;
50
51         self._destroy = Item_Data_Destroy;
52 };
53
54 ////////////////////
55 // [Item_DataLink]
56 ///
57
58 /*
59 ===================
60 Item_DataLink_Update
61 ===================
62 */
63 void() Item_DataLink_Update =
64 {
65         if( self.link == "" )
66                 self._link = null_entity;
67         else if( self.link != self._link.name )
68                 self._link = Menu_GetItem( self.link );
69 };
70
71 /*
72 ===================
73 Item_DataLink_Destroy
74 ===================
75 */
76 void() Item_DataLink_Destroy =
77 {
78         String_EntityFree( self, link );
79         String_EntityFree( self, value );
80 };
81
82 /*
83 ===================
84 Item_DataLink_Init
85 ===================
86 */
87 void() Item_DataLink_Init =
88 {
89         self.flag = self.flag | FLAG_HIDDEN;
90
91         String_EntityZone( self, link );
92         String_EntityZone( self, value );
93         Item_DataLink_Update();
94
95         self._destroy = Item_DataLink_Destroy;
96 };
97
98 ////////////////////
99 // [Item_DataLink_Switch]
100 ///
101
102 /*
103 ===================
104 Item_DataLink_Switch_Destroy
105 ===================
106 */
107 void() Item_DataLink_Switch_Destroy =
108 {
109         Item_DataLink_Destroy();
110         String_EntityFree( self, descList );
111 };
112
113 /*
114 ===================
115 Item_DataLink_Switch_Init
116 ===================
117 */
118 void() Item_DataLink_Switch_Init =
119 {
120         Item_DataLink_Value_Spawn();
121         String_EntityZone( self, descList );
122
123         self._destroy = Item_DataLink_Switch_Destroy;
124 };
125
126 ////////////////////
127 // [Item_DataUser]
128 ///
129
130 /*
131 ===================
132 Item_DataUser_Update
133 ===================
134 */
135 void() Item_DataUser_Update =
136 {
137         if( self.target == "" )
138                 self._target = null_entity;
139         else if( self.target != self._target.name )
140                 self._target = Menu_GetItem( self.target );
141 };
142
143 /*
144 ===================
145 Item_DataUser_Destroy
146 ===================
147 */
148 void() Item_DataUser_Destroy =
149 {
150         String_EntityFree( self, target );
151 };
152
153 /*
154 ===================
155 Item_DataUser_Init
156 ===================
157 */
158 void() Item_DataUser_Init =
159 {
160         String_EntityZone( self, target );
161
162         Item_DataUser_Update();
163
164         self._destroy = Item_DataUser_Destroy;
165 };
166