]> icculus.org git repositories - divverent/nexuiz.git/blob - data/menuqc/control/data/base.qc
Revert first change in the trunk.
[divverent/nexuiz.git] / data / menuqc / 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 ===================
24 Data_ExecString_BeginUse
25 ===================
26 */
27 void() Data_ExecString_BeginUse =
28 {
29         Data_ExecString = String_Create();
30 };
31
32 /*
33 ===================
34 Data_ExecString_EndUse
35 ===================
36 */
37 void() Data_ExecString_EndUse =
38 {
39         String_Free( Data_ExecString);
40 };
41
42 /////////////////////
43 // [Item_Data]
44 ///
45
46 /*
47 ===================
48 Item_Data_Destroy
49 ===================
50 */
51 void() Item_Data_Destroy =
52 {
53         String_EntityFree( self, value );
54         String_EntityFree( self, defValue );
55         String_EntityFree( self, _syncValue );
56 };
57
58 /*
59 ===================
60 Item_Data_Init
61 ===================
62 */
63 void() Item_Data_Init =
64 {
65         String_EntityZone( self, value );
66         String_EntityZone( self, defValue );
67         String_EntityCreate( self, _syncValue );
68
69         self.flag = self.flag | FLAG_HIDDEN;
70
71         self._destroy = Item_Data_Destroy;
72 };
73
74 ////////////////////
75 // [Item_DataLink]
76 ///
77
78 /*
79 ===================
80 Item_DataLink_Update
81 ===================
82 */
83 void() Item_DataLink_Update =
84 {
85         if( self.link == "" )
86                 self._link = null_entity;
87         else if( self.link != self._link.name )
88                 self._link = Menu_GetItem( self.link );
89 };
90
91 /*
92 ===================
93 Item_DataLink_Destroy
94 ===================
95 */
96 void() Item_DataLink_Destroy =
97 {
98         String_EntityFree( self, link );
99         String_EntityFree( self, value );
100 };
101
102 /*
103 ===================
104 Item_DataLink_Init
105 ===================
106 */
107 void() Item_DataLink_Init =
108 {
109         self.flag = self.flag | FLAG_HIDDEN;
110
111         String_EntityZone( self, link );
112         String_EntityZone( self, value );
113         Item_DataLink_Update();
114
115         self._destroy = Item_DataLink_Destroy;
116 };
117
118 ////////////////////
119 // [Item_DataLink_Switch]
120 ///
121
122 /*
123 ===================
124 Item_DataLink_Switch_Destroy
125 ===================
126 */
127 void() Item_DataLink_Switch_Destroy =
128 {
129         Item_DataLink_Destroy();
130         String_EntityFree( self, descList );
131 };
132
133 /*
134 ===================
135 Item_DataLink_Switch_Init
136 ===================
137 */
138 void() Item_DataLink_Switch_Init =
139 {
140         Item_DataLink_Value_Spawn();
141         String_EntityZone( self, descList );
142
143         self._destroy = Item_DataLink_Switch_Destroy;
144 };
145
146 /*
147 ===================
148 Item_GetOrdinal
149 ===================
150 */
151 float( entity pDataLink, float pValue ) DataLink_Switch_GetOrdinal =
152 {
153         if( pDataLink.stepValue == 0.0 )
154                 return 0.0;
155         return (pValue - pDataLink.minValue) / pDataLink.stepValue;
156 };
157
158 ////////////////////
159 // [Item_DataUser]
160 ///
161
162 /*
163 ===================
164 Item_DataUser_Update
165 ===================
166 */
167 void() Item_DataUser_Update =
168 {
169         if( self.target == "" )
170                 self._target = null_entity;
171         else if( self.target != self._target.name )
172                 self._target = Menu_GetItem( self.target );
173 };
174
175 /*
176 ===================
177 Item_DataUser_Destroy
178 ===================
179 */
180 void() Item_DataUser_Destroy =
181 {
182         String_EntityFree( self, target );
183 };
184
185 /*
186 ===================
187 Item_DataUser_Init
188 ===================
189 */
190 void() Item_DataUser_Init =
191 {
192         String_EntityZone( self, target );
193
194         Item_DataUser_Update();
195
196         self._destroy = Item_DataUser_Destroy;
197 };
198
199 /*
200 ===================
201 Item_DataContainer_DataEvent
202 ===================
203 */
204 void( float pEvent ) Item_DataContainer_DataEvent =
205 {
206         // no support for embedded stuff yet (isnt needed imho anyway)
207         local entity lItem;
208
209         for( lItem = self._child ; lItem != null_entity ; lItem = lItem._next ) {
210                 Raise_DataEvent( lItem, pEvent );
211         }
212 };
213
214 /*
215 ===================
216 Item_DataContainer_Spawn
217 ===================
218 */
219 void() Item_DataContainer_Spawn =
220 {
221         Item_Container_Spawn();
222
223         self._dataEvent = Item_DataContainer_DataEvent;
224 };