]> icculus.org git repositories - divverent/nexuiz.git/blob - scmenu/source/control/data/base.qc
-Changed some item names to fit to the global name convention.
[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 ===================
128 Item_GetOrdinal
129 ===================
130 */
131 float( entity pDataLink, float pValue ) Item_DataLink_Switch_GetOrdinal =
132 {
133         //if( !pDataLink )
134         //      crash();
135         return (pValue - pDataLink.minValue) / pDataLink.stepValue;
136 };
137
138 ////////////////////
139 // [Item_DataUser]
140 ///
141
142 /*
143 ===================
144 Item_DataUser_Update
145 ===================
146 */
147 void() Item_DataUser_Update =
148 {
149         if( self.target == "" )
150                 self._target = null_entity;
151         else if( self.target != self._target.name )
152                 self._target = Menu_GetItem( self.target );
153 };
154
155 /*
156 ===================
157 Item_DataUser_Destroy
158 ===================
159 */
160 void() Item_DataUser_Destroy =
161 {
162         String_EntityFree( self, target );
163 };
164
165 /*
166 ===================
167 Item_DataUser_Init
168 ===================
169 */
170 void() Item_DataUser_Init =
171 {
172         String_EntityZone( self, target );
173
174         Item_DataUser_Update();
175
176         self._destroy = Item_DataUser_Destroy;
177 };
178
179 /*
180 ===================
181 Item_DataContainer_DataEvent
182 ===================
183 */
184 void( float pEvent ) Item_DataContainer_DataEvent =
185 {
186         // no support for embedded stuff yet (isnt needed imho anyway)
187         local entity lItem;
188
189         for( lItem = self._child ; lItem != null_entity ; lItem = lItem._next ) {
190                 Raise_DataEvent( lItem, pEvent );
191         }
192 };
193
194 /*
195 ===================
196 Item_DataContainer_Spawn
197 ===================
198 */
199 void() Item_DataContainer_Spawn =
200 {
201         Item_Container_Spawn();
202
203         self._dataEvent = Item_DataContainer_DataEvent;
204 };