Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
editable.h
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/***********************************************************************************************
20 *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
21 ***********************************************************************************************
22 * *
23 * Project Name : WWSaveLoad *
24 * *
25 * $Archive:: /Commando/Code/wwsaveload/editable.h $*
26 * *
27 * *
28 * Org Author:: Patrick Smith *
29 * *
30 * Author:: Kenny Mitchell *
31 * *
32 * $Modtime:: 5/29/02 11:00a $*
33 * *
34 * $Revision:: 29 $*
35 * *
36 *---------------------------------------------------------------------------------------------*
37 * Functions: *
38 * 5/27/02 KM Added named filename parameter declaration
39 * 5/29/02 KM Added specific texture filename parameter support
40 *---------------------------------------------------------------------------------------------*
41 * Functions: *
42 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
43
44
45#if defined(_MSC_VER)
46#pragma once
47#endif
48
49
50#ifndef __EDITABLE_H
51#define __EDITABLE_H
52
53
54#include "always.h"
55#include "persist.h"
56#include "parameter.h"
57#include "simpleparameter.h"
58#include "parameterlist.h"
59#include "wwdebug.h"
60
62//
63// EditableClass
64//
67{
68public:
69
71 // Public methods
72 //
73 // Note: These methods can be implemented in derived classes
74 // by the DECLARE_EDITABLE macro.
75 //
77 virtual int Get_Parameter_Count (void) const;
78 virtual ParameterClass * Lock_Parameter (int i);
79 virtual void Unlock_Parameter (int i);
80};
81
83// Get_Parameter_Count
85inline int
87{
88 return 0;
89}
90
92// Get_Parameter
94inline ParameterClass *
96{
97 WWASSERT (0);
98 return NULL;
99}
100
102// Set_Parameter
104inline void
109
110//#define PARAM_EDITING_ON
111#ifdef PARAM_EDITING_ON
112
114 //
115 // DECLARE_EDITABLE
116 //
118 #define DECLARE_EDITABLE(_class, _parent) \
119 ParameterListClass plist_##_class; \
120 virtual int _class::Get_Parameter_Count(void) const \
121 { \
122 return plist_##_class.Count () + _parent::Get_Parameter_Count (); \
123 } \
124 virtual ParameterClass *_class::Lock_Parameter(int i) \
125 { \
126 if (i < _parent::Get_Parameter_Count()) { \
127 return _parent::Lock_Parameter (i); \
128 } \
129 return plist_##_class[i - _parent::Get_Parameter_Count()]; \
130 } \
131
133 //
134 // EDITABLE_PARAM
135 //
136 // The following macros are used inside the constructor for an editable
137 // object to map member data to abstract parameter objects.
138 //
139 // Some examples:
140 //
141 // To register the player's name (a string):
142 // EDITABLE_PARAM(GameClass, ParameterClass::TYPE_STRING, Name)
143 //
144 // To register the player's name using a more descriptive display string:
145 // NAMED_EDITABLE_PARAM(GameClass, ParameterClass::TYPE_STRING, Name, "Player Name")
146 //
147 // To register a unit's maximum health
148 // INT_EDITABLE_PARAM(GameClass, MaxHeatlh, 0, 500)
149 //
150 // To register a complex variable (such as an enumerated type:
151 // #ifdef PARAM_EDITING_ON
152 // EnumParameterClass *param = new EnumParameterClass(GangID);
153 // param->Set_Name ("Gang");
154 // param->Add_Value ("GDI", ID_GDI);
155 // param->Add_Value ("NOD", ID_NOD);
156 // param->Add_Value ("Neutral", ID_NEUTRAL);
157 // GENERIC_EDITABLE_PARAM(param)
158 // #endif
159 //
161
162
163 #define EDITABLE_PARAM(_class, type, data) plist_##_class.Add (&(data), #data, type);
164 #define NAMED_EDITABLE_PARAM(_class, type, data, name) plist_##_class.Add (&(data), name, type);
165
166 #define INT_EDITABLE_PARAM(_class, data, min, max) { \
167 IntParameterClass *param = W3DNEW IntParameterClass( &data, #data); \
168 param->Set_Range (min, max); \
169 plist_##_class.Add (param); } \
170
171 #define INT_UNITS_PARAM(_class, data, min, max, unitsname) { \
172 IntParameterClass *param = W3DNEW IntParameterClass( &data, #data); \
173 param->Set_Range (min, max); \
174 param->Set_Units_Name(unitsname); \
175 plist_##_class.Add (param); } \
176
177 #define NAMED_INT_UNITS_PARAM(_class,data,min,max,unitsname,name) { \
178 IntParameterClass *param = W3DNEW IntParameterClass( &data, #data); \
179 param->Set_Range (min, max); \
180 param->Set_Units_Name(unitsname); \
181 param->Set_Name(name); \
182 plist_##_class.Add (param); } \
183
184 #define FLOAT_EDITABLE_PARAM(_class, data, min, max) { \
185 FloatParameterClass *param = W3DNEW FloatParameterClass( &data, #data); \
186 param->Set_Range (min, max); \
187 plist_##_class.Add (param); } \
188
189 #define FLOAT_UNITS_PARAM(_class, data, min, max, unitsname) { \
190 FloatParameterClass *param = W3DNEW FloatParameterClass( &data, #data); \
191 param->Set_Range (min, max); \
192 param->Set_Units_Name(unitsname); \
193 plist_##_class.Add (param); }
194
195 #define NAMED_FLOAT_UNITS_PARAM(_class, data, min, max, unitsname,name) { \
196 FloatParameterClass *param = W3DNEW FloatParameterClass( &data, #data); \
197 param->Set_Range (min, max); \
198 param->Set_Units_Name(unitsname); \
199 param->Set_Name(name); \
200 plist_##_class.Add (param); }
201
202 #define ANGLE_EDITABLE_PARAM(_class, data, min, max) { \
203 AngleParameterClass *param = W3DNEW AngleParameterClass( &data, #data); \
204 param->Set_Range (min, max); \
205 param->Set_Units_Name ("degrees"); \
206 plist_##_class.Add (param); } \
207
208 #define NAMED_ANGLE_EDITABLE_PARAM(_class, data, min, max, name) { \
209 AngleParameterClass *param = W3DNEW AngleParameterClass( &data, #data); \
210 param->Set_Range (min, max); \
211 param->Set_Units_Name ("degrees"); \
212 param->Set_Name(name); \
213 plist_##_class.Add (param); } \
214
215 #define GENERIC_EDITABLE_PARAM(_class, param) \
216 plist_##_class.Add (param); \
217
218 #define MODEL_DEF_PARAM(_class, data, name) { \
219 ModelDefParameterClass *param = W3DNEW ModelDefParameterClass (&data); \
220 param->Set_Name (#data); \
221 param->Set_Base_Class (name); \
222 GENERIC_EDITABLE_PARAM(_class, param); }
223
224 #define PHYS_DEF_PARAM(_class, data, name) { \
225 PhysDefParameterClass *param = W3DNEW PhysDefParameterClass (&data); \
226 param->Set_Name (#data); \
227 param->Set_Base_Class (name); \
228 GENERIC_EDITABLE_PARAM(_class, param); }
229
230 #define SCRIPT_PARAM(_class, name, params) { \
231 ScriptParameterClass *param = W3DNEW ScriptParameterClass (&name, &params); \
232 param->Set_Name (#name); \
233 GENERIC_EDITABLE_PARAM(_class, param); }
234
235 #define SCRIPTLIST_PARAM(_class, name, name_list, param_list) { \
236 ScriptListParameterClass *param = W3DNEW ScriptListParameterClass (&name_list, &param_list); \
237 param->Set_Name (name); \
238 GENERIC_EDITABLE_PARAM(_class, param); }
239
240 #define ENUM_PARAM(_class, data, params) { \
241 EnumParameterClass *param = W3DNEW EnumParameterClass (&data); \
242 param->Set_Name (#data); \
243 param->Add_Values params; \
244 plist_##_class.Add (param); } \
245
246 #define FILENAME_PARAM(_class, data, desc, extension) { \
247 FilenameParameterClass *param = W3DNEW FilenameParameterClass (&data); \
248 param->Set_Name (#data); \
249 param->Set_Description (desc); \
250 param->Set_Extension (extension); \
251 plist_##_class.Add (param); } \
252
253 #define NAMED_FILENAME_PARAM(_class, data, name, desc, extension) { \
254 FilenameParameterClass *param = new FilenameParameterClass (&data); \
255 param->Set_Name (name); \
256 param->Set_Description (desc); \
257 param->Set_Extension (extension); \
258 plist_##_class.Add (param); } \
259
260 #define TEXTURE_FILENAME_PARAM(_class, data, desc, extension) { \
261 TextureFilenameParameterClass *param = new TextureFilenameParameterClass (&data); \
262 param->Set_Name (#data); \
263 param->Set_Description (desc); \
264 param->Set_Extension (extension); \
265 plist_##_class.Add (param); } \
266
267 #define NAMED_TEXTURE_FILENAME_PARAM(_class, data, name, desc, extension) { \
268 TextureFilenameParameterClass *param = new TextureFilenameParameterClass (&data); \
269 param->Set_Name (name); \
270 param->Set_Description (desc); \
271 param->Set_Extension (extension); \
272 plist_##_class.Add (param); } \
273
274 #define DEFIDLIST_PARAM(_class, data, root_class_id) { \
275 DefIDListParameterClass *param = W3DNEW DefIDListParameterClass (&data); \
276 param->Set_Name (#data); \
277 param->Set_Class_ID (root_class_id); \
278 plist_##_class.Add (param); } \
279
280 #define CLASSID_DEFIDLIST_PARAM(_class, data, root_class_id, class_id, name) { \
281 DefIDListParameterClass *param = W3DNEW DefIDListParameterClass (&data); \
282 param->Set_Name (name); \
283 param->Set_Class_ID (root_class_id); \
284 param->Set_Selected_Class_ID (&class_id); \
285 plist_##_class.Add (param); }
286
287 #define ZONE_PARAM(_class, data, name) { \
288 ZoneParameterClass *param = W3DNEW ZoneParameterClass (&data); \
289 param->Set_Name (name); \
290 GENERIC_EDITABLE_PARAM(_class, param); }
291
292 #define PARAM_SEPARATOR(_class, name) { \
293 SeparatorParameterClass *param = W3DNEW SeparatorParameterClass; \
294 param->Set_Name (name); \
295 GENERIC_EDITABLE_PARAM(_class, param); }
296
297 #define GENERIC_DEFID_PARAM(_class, data, root_class_id) { \
298 GenericDefParameterClass *param = W3DNEW GenericDefParameterClass (&data); \
299 param->Set_Class_ID (root_class_id); \
300 param->Set_Name (#data); \
301 plist_##_class.Add (param); }
302
303
304#else
305
306 #define DECLARE_EDITABLE(_class, _parent)
307 #define EDITABLE_PARAM(_class, type, data)
308 #define NAMED_EDITABLE_PARAM(_class, type, data, name)
309 #define INT_EDITABLE_PARAM(_class, data, min, max)
310 #define INT_UNITS_PARAM(_class, data, min, max, unitsname)
311 #define NAMED_INT_UNITS_PARAM(_class,data,min,max,unitsname,name)
312 #define FLOAT_EDITABLE_PARAM(_class, data, min, max)
313 #define FLOAT_UNITS_PARAM(_class, data, min, max, unitsname)
314 #define NAMED_FLOAT_UNITS_PARAM(_class, data, min, max, unitsname,name)
315 #define ANGLE_EDITABLE_PARAM(_class, data, min, max)
316 #define NAMED_ANGLE_EDITABLE_PARAM(_class, data, min, max, name)
317 #define GENERIC_EDITABLE_PARAM(_class, param)
318 #define MODEL_DEF_PARAM(_class, data, name)
319 #define PHYS_DEF_PARAM(_class, data, name)
320 #define SCRIPT_PARAM(_class, name, params)
321 #define SCRIPTLIST_PARAM(_class, name, name_list, param_list)
322 #define ENUM_PARAM(_class, data, params)
323 #define FILENAME_PARAM(_class, data, desc, extension)
324 #define NAMED_FILENAME_PARAM(_class, data, name, desc, extension)
325 #define TEXTURE_FILENAME_PARAM(_class, data, desc, extension)
326 #define NAMED_TEXTURE_FILENAME_PARAM(_class, data, name, desc, extension)
327 #define DEFIDLIST_PARAM(_class, data, root_class_id)
328 #define CLASSID_DEFIDLIST_PARAM(_class, data, root_class_id, class_id, name)
329 #define ZONE_PARAM(_class, data, name)
330 #define PARAM_SEPARATOR(_class, name)
331 #define GENERIC_DEFID_PARAM(_class, data, root_class_id)
332
333#endif //PARAM_EDITING_ON
334
335
336#endif //__EDITABLE_H
337
338
339
#define NULL
Definition BaseType.h:92
#define WWASSERT
virtual void Unlock_Parameter(int i)
Definition editable.h:105
virtual int Get_Parameter_Count(void) const
Definition editable.h:86
virtual ParameterClass * Lock_Parameter(int i)
Definition editable.h:95
else return(RetVal)