- Timestamp:
- Nov 20, 2005, 9:22:11 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/gui/gl_gui/glmenu/glmenu_imagescreen.cc
r5652 r5655 123 123 void GLMenuImageScreen::setPosScale(float offsetX, float offsetY, float scaleX, float scaleY) 124 124 { 125 printf("IMG: %f %f %f %f\n", offsetX, offsetY,offsetX, offsetY);126 125 this->setPosition(offsetX, offsetY); 127 126 this->setScale(scaleX, scaleY); … … 145 144 void GLMenuImageScreen::setBarPosScale(float barX, float barY, float barW, float barH) 146 145 { 147 printf("BAR: %f %f %f %f\n", barX, barY, barW, barH);148 149 146 this->barX = barX; 150 147 this->barY = barY; -
trunk/src/util/loading/load_param.cc
r5654 r5655 24 24 25 25 #include <stdarg.h> 26 27 /**28 * @param object The object this Parameter is loaded too.29 * @param root: the XML-element to load this option from.30 * @param paramName: The name of the parameter loaded.31 * @param paramCount: how many parameters this loading-function takes32 * @param multi: if false LoadParam assumes only one occurence of this parameter in root, if true it assumes multiple occurences.33 * @param ...: the parameter information (1. Parameter, 2. Default Value for the Parameter, ...)34 */35 LoadParamBase::LoadParamBase(const TiXmlElement* root, BaseObject* object, const char* paramName,36 int paramCount, bool multi, const void* pointerToParam, ...)37 {38 this->setClassID(CL_LOAD_PARAM, "LoadParam");39 this->executor = NULL;40 41 this->loadString = NULL;42 this->pointerToParam = pointerToParam;43 44 if (paramCount == 0 || this->pointerToParam != NULL)45 this->loadString = "none";46 else47 {48 if (likely(!multi))49 this->loadString = grabParameter(root, paramName);50 else51 {52 if (!strcmp(root->Value(), paramName))53 {54 const TiXmlNode* val = root->FirstChild();55 if( val->ToText())56 this->loadString = val->Value();57 }58 }59 }60 61 this->paramDesc = NULL;62 if (LoadClassDescription::parametersDescription)63 {64 // locating the class65 this->classDesc = LoadClassDescription::addClass(object->getClassName());66 67 if ((this->paramDesc = this->classDesc->addParam(paramName)) != NULL)68 {69 70 this->paramDesc->paramCount = paramCount;71 this->paramDesc->types = new int[paramCount];72 this->paramDesc->defaultValues = new char*[paramCount];73 74 va_list types;75 va_start (types, pointerToParam);76 char defaultVal[512];77 for(int i = 0; i < paramCount; i++)78 {79 defaultVal[0] = '\0';80 // parameters parsed81 int tmpType = va_arg (types, int);82 this->paramDesc->types[i] = tmpType;83 switch (tmpType)84 {85 case MT_INT:86 sprintf(defaultVal, "%d", va_arg(types, int));87 break;88 /* case MT_LONG:89 sprintf(defaultVal, "%0.3f", va_arg(types, l_LONG_TYPE));90 break;*/91 case MT_FLOAT:92 sprintf(defaultVal, "%0.3f", va_arg(types, double));93 break;94 case MT_STRING:95 sprintf(defaultVal, "%s", va_arg(types, l_STRING_TYPE));96 break;97 case MT_EXT1:98 sprintf(defaultVal, "");99 break;100 }101 this->paramDesc->defaultValues[i] = new char[strlen(defaultVal)+1];102 strcpy(this->paramDesc->defaultValues[i], defaultVal);103 }104 va_end(types);105 106 int argCount = 0;107 }108 }109 }110 26 111 27 /** … … 116 32 * @param executor the Executor, that executes the loading procedure. 117 33 */ 118 LoadParam Base::LoadParamBase(const TiXmlElement* root, const char* paramName, BaseObject* object, const Executor& executor, bool inLoadCycle)34 LoadParam::LoadParam(const TiXmlElement* root, const char* paramName, BaseObject* object, const Executor& executor, bool inLoadCycle) 119 35 { 120 36 this->paramName = paramName; … … 147 63 * Execution-Conditions are met, they are executed here. 148 64 */ 149 LoadParam Base::~LoadParamBase()65 LoadParam::~LoadParam() 150 66 { 151 67 if (likely(this->executor != NULL)) … … 168 84 * @param ... the default values !! must be at least count parameters!! 169 85 */ 170 LoadParam Base* LoadParamBase::defaultValues(unsigned int count, ...)86 LoadParam* LoadParam::defaultValues(unsigned int count, ...) 171 87 { 172 88 if (this == NULL) … … 188 104 * @returns a pointer to itself. 189 105 */ 190 LoadParam Base* LoadParamBase::describe(const char* descriptionText)106 LoadParam* LoadParam::describe(const char* descriptionText) 191 107 { 192 108 if (LoadClassDescription::parametersDescription && this->paramDesc && !this->paramDesc->getDescription()) … … 215 131 // } 216 132 133 134 135 136 /* 137 * @param object The object this Parameter is loaded too. 138 * @param root: the XML-element to load this option from. 139 * @param paramName: The name of the parameter loaded. 140 * @param paramCount: how many parameters this loading-function takes 141 * @param multi: if false LoadParam assumes only one occurence of this parameter in root, if true it assumes multiple occurences. 142 * @param ...: the parameter information (1. Parameter, 2. Default Value for the Parameter, ...) 143 */ 144 /*LoadParam::LoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName, 145 int paramCount, bool multi, const void* pointerToParam, ...) 146 { 147 this->setClassID(CL_LOAD_PARAM, "LoadParam"); 148 this->executor = NULL; 149 150 this->loadString = NULL; 151 this->pointerToParam = pointerToParam; 152 153 if (paramCount == 0 || this->pointerToParam != NULL) 154 this->loadString = "none"; 155 else 156 { 157 if (likely(!multi)) 158 this->loadString = grabParameter(root, paramName); 159 else 160 { 161 if (!strcmp(root->Value(), paramName)) 162 { 163 const TiXmlNode* val = root->FirstChild(); 164 if( val->ToText()) 165 this->loadString = val->Value(); 166 } 167 } 168 } 169 170 this->paramDesc = NULL; 171 if (LoadClassDescription::parametersDescription) 172 { 173 // locating the class 174 this->classDesc = LoadClassDescription::addClass(object->getClassName()); 175 176 if ((this->paramDesc = this->classDesc->addParam(paramName)) != NULL) 177 { 178 179 this->paramDesc->paramCount = paramCount; 180 this->paramDesc->types = new int[paramCount]; 181 this->paramDesc->defaultValues = new char*[paramCount]; 182 183 va_list types; 184 va_start (types, pointerToParam); 185 char defaultVal[512]; 186 for(int i = 0; i < paramCount; i++) 187 { 188 defaultVal[0] = '\0'; 189 // parameters parsed 190 int tmpType = va_arg (types, int); 191 this->paramDesc->types[i] = tmpType; 192 switch (tmpType) 193 { 194 case MT_INT: 195 sprintf(defaultVal, "%d", va_arg(types, int)); 196 break; 197 // case MT_LONG: 198 // sprintf(defaultVal, "%0.3f", va_arg(types, l_LONG_TYPE)); 199 // break; 200 case MT_FLOAT: 201 sprintf(defaultVal, "%0.3f", va_arg(types, double)); 202 break; 203 case MT_STRING: 204 sprintf(defaultVal, "%s", va_arg(types, l_STRING_TYPE)); 205 break; 206 case MT_EXT1: 207 sprintf(defaultVal, ""); 208 break; 209 } 210 this->paramDesc->defaultValues[i] = new char[strlen(defaultVal)+1]; 211 strcpy(this->paramDesc->defaultValues[i], defaultVal); 212 } 213 va_end(types); 214 215 int argCount = 0; 216 } 217 } 218 }*/ 219 220 221 222 223 224 225 226 227 228 229 ////////////////////// 230 // HELPER FUNCTIONS // 231 ////////////////////// 217 232 /** 218 233 * @param root: The XML-element to grab a parameter from -
trunk/src/util/loading/load_param.h
r5654 r5655 46 46 */ 47 47 #define LoadParamNEW(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \ 48 LoadParam Base(ROOT, PARAMETER_NAME, OBJECT, ExecutorObjective<CLASS>(&CLASS::FUNCTION), false)48 LoadParam(ROOT, PARAMETER_NAME, OBJECT, ExecutorObjective<CLASS>(&CLASS::FUNCTION), false) 49 49 50 50 #define LoadParam_CYCLE(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \ 51 LoadParam Base(ROOT, PARAMETER_NAME, OBJECT, ExecutorObjective<CLASS>(&CLASS::FUNCTION), true)51 LoadParam(ROOT, PARAMETER_NAME, OBJECT, ExecutorObjective<CLASS>(&CLASS::FUNCTION), true) 52 52 53 53 #define LoadParamXML(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \ 54 LoadParam Base(ROOT, PARAMETER_NAME, OBJECT, ExecutorXML<CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), false)54 LoadParam(ROOT, PARAMETER_NAME, OBJECT, ExecutorXML<CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), false) 55 55 56 56 #define LoadParamXML_CYCLE(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \ 57 LoadParam Base(ROOT, PARAMETER_NAME, OBJECT, ExecutorXML<CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), true)57 LoadParam(ROOT, PARAMETER_NAME, OBJECT, ExecutorXML<CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), true) 58 58 59 59 … … 81 81 } 82 82 83 84 85 86 83 /************************** 87 84 **** REAL DECLARATIONS **** 88 85 **************************/ 89 86 //! abstract Base class for a Loadable parameter 90 class LoadParam Base: public BaseObject87 class LoadParam : public BaseObject 91 88 { 92 89 public: 93 LoadParam Base(const TiXmlElement* root, const char* paramName, BaseObject* object, const Executor& executor, bool inLoadCycle = false);94 ~LoadParam Base();90 LoadParam(const TiXmlElement* root, const char* paramName, BaseObject* object, const Executor& executor, bool inLoadCycle = false); 91 ~LoadParam(); 95 92 96 LoadParam Base* describe(const char* descriptionText);97 LoadParam Base* defaultValues(unsigned int count, ...);93 LoadParam* describe(const char* descriptionText); 94 LoadParam* defaultValues(unsigned int count, ...); 98 95 99 protected:100 LoadParamBase(const TiXmlElement* root, BaseObject* object, const char* paramName, int paramCount, bool multi, const void* pointerToParam, ...);101 96 102 pr otected:97 private: 103 98 bool inLoadCycle; 104 99 Executor* executor; … … 114 109 }; 115 110 116 117 118 /*****************************************119 **** MACROS DEFINITIONS OF LOADABLES *****120 *****************************************/121 // 0. TYPES122 /**123 * a Macro to easily implement many different Constructors for the LoadParam-Class with no argument124 */125 #define LoadParam0() \126 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(), bool multi = false) \127 : LoadParamBase(root, pt2Object, paramName, 0, multi, NULL) \128 { \129 if (loadString != NULL && root != NULL) \130 (*pt2Object.*function)(); \131 else \132 PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName());\133 }134 135 // 1. TYPE136 /**137 * a Macro to easily implement many different Constructors for the LoadParam-Class with 1 argument138 * @param type1 The type of the first functionParameter139 */140 #define LoadParam1(type1) \141 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE), \142 bool multi = false, type1##_TYPE default1 = type1##_DEFAULT) \143 : LoadParamBase(root, pt2Object, paramName, 1, multi, NULL, type1##_PARAM, default1) \144 { \145 if (loadString != NULL && root != NULL) \146 (*pt2Object.*function)(type1##_FUNC(loadString, default1)); \147 else \148 PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName()); \149 }150 151 // 2. TYPES152 /**153 * a Macro to easily implement many different Constructors for the LoadParam-Class with 2 arguments154 * @param type1 The type of the first functionParameter155 * @param type2 The type of the second functionParameter156 *157 * @TODO DEFAULT VALUES HACK158 */159 #define LoadParam2(type1, type2) \160 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE), \161 bool multi = false, type1##_TYPE default1 = type1##_DEFAULT, type2##_TYPE default2 = type2##_DEFAULT) \162 : LoadParamBase(root, pt2Object, paramName, 2, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2) \163 { \164 if (loadString != NULL && root != NULL) \165 { \166 SubString subLoads(loadString); \167 if (subLoads.getCount() >= 1) \168 (*pt2Object.*function)(type1##_FUNC(subLoads.getString(0), default1), type2##_FUNC(subLoads.getString(1), default2)); \169 else \170 PRINTF(2)("Not loaded Parameter %s of %s, because wrong count of arguments.\n -> Should have %d but have %d\n", \171 paramName, pt2Object->getClassName(), 2, subLoads.getCount()); \172 } \173 else \174 PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName()); \175 }176 177 178 // 3. TYPES179 /**180 * a Macro to easily implement many different Constructors for the LoadParam-Class with 3 arguments181 * @param type1 The type of the first functionParameter182 * @param type2 The type of the second functionParameter183 * @param type3 The type of the third functionParameter184 */185 #define LoadParam3(type1, type2, type3) \186 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE), \187 bool multi = false, type1##_TYPE default1 = type1##_DEFAULT, type2##_TYPE default2 = type2##_DEFAULT, type3##_TYPE default3 = type3##_DEFAULT)\188 : LoadParamBase(root, pt2Object, paramName, 3, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2, type3##_PARAM, default3) \189 { \190 if (loadString != NULL && root != NULL) \191 { \192 SubString subLoads(loadString); \193 if (subLoads.getCount() == 3) \194 (*pt2Object.*function)(type1##_FUNC(subLoads.getString(0), default1), type2##_FUNC(subLoads.getString(1), default2), type3##_FUNC(subLoads.getString(2), default3)); \195 else \196 PRINTF(2)("Not loaded Parameter %s of %s, because wrong count of arguments.\n -> Should have %d but have %d\n", \197 paramName, pt2Object->getClassName(), 3, subLoads.getCount()); \198 } \199 else \200 PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName()); \201 }202 203 204 // 4. TYPES205 /**206 * a Macro to easily implement many different Constructors for the LoadParam-Class with 4 arguments207 * @param type1 The type of the first functionParameter208 * @param type2 The type of the second functionParameter209 * @param type3 The type of the third functionParameter210 * @param type4 The type of the forth functionParameter211 */212 #define LoadParam4(type1, type2, type3, type4) \213 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE), \214 bool multi = false, type1##_TYPE default1 = type1##_DEFAULT, type2##_TYPE default2 = type2##_DEFAULT, type3##_TYPE default3 = type3##_DEFAULT, \215 type4##_TYPE default4 = type4##_DEFAULT) \216 : LoadParamBase(root, pt2Object, paramName, 4, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2, type3##_PARAM, default3, \217 type4##_PARAM, default4) \218 { \219 if (loadString != NULL && root != NULL) \220 { \221 SubString subLoads(loadString); \222 if (subLoads.getCount() == 4) \223 (*pt2Object.*function)(type1##_FUNC(subLoads.getString(0), default1), type2##_FUNC(subLoads.getString(1), default2), type3##_FUNC(subLoads.getString(2), default3), type4##_FUNC(subLoads.getString(3), default4)); \224 else \225 PRINTF(2)("Not loaded Parameter %s of %s, because wrong count of arguments.\n -> Should have %d but have %d\n", \226 paramName, pt2Object->getClassName(), 4, subLoads.getCount()); \227 } \228 else \229 PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName()); \230 }231 232 233 // 5. TYPES234 /**235 * a Macro to easily implement many different Constructors for the LoadParam-Class with 5 arguments236 * @param type1 The type of the first functionParameter237 * @param type2 The type of the second functionParameter238 * @param type3 The type of the third functionParameter239 * @param type4 The type of the forth functionParameter240 * @param type5 The type of the fifth functionParameter241 */242 #define LoadParam5(type1, type2, type3, type4, type5) \243 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, \244 void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE, type5##_TYPE), \245 bool multi = false, type1##_TYPE default1 = type1##_DEFAULT, type2##_TYPE default2 = type2##_DEFAULT, type3##_TYPE default3 = type3##_DEFAULT, \246 type4##_TYPE default4 = type4##_DEFAULT, type5##_TYPE default5 = type5##_DEFAULT ) \247 : LoadParamBase(root, pt2Object, paramName, 5, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2, type3##_PARAM, default3, \248 type4##_PARAM, default4, type5##_PARAM, default5) \249 { \250 if (loadString != NULL && root != NULL) \251 { \252 SubString subLoads(loadString); \253 if (subLoads.getCount() == 5) \254 (*pt2Object.*function)(type1##_FUNC(subLoads.getString(0), default1), type2##_FUNC(subLoads.getString(1), default2), type3##_FUNC(subLoads.getString(2), default3), type4##_FUNC(subLoads.getString(3), default4), type5##_FUNC(subLoads.getString(4), default5)); \255 else \256 PRINTF(2)("Not loaded Parameter %s of %s, because wrong count of arguments.\n -> Should have %d but have %d\n", \257 paramName, pt2Object->getClassName(), 5, subLoads.getCount()); \258 } \259 else \260 PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName()); \261 }262 263 // Pointer TYPE264 /**265 * a Macro to easily implement many different Constructors for the LoadParam-Class with one Pointer argument266 * @param type1 The type of the Pointer267 */268 #define LoadParamPT(type1) \269 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE), type1##_TYPE pointerToParam, bool multi = false) \270 : LoadParamBase(root, pt2Object, paramName, 1, multi, pointerToParam, type1##_PARAM) \271 { \272 if (pointerToParam != NULL && root != NULL) \273 (*pt2Object.*function)((type1##_TYPE) pointerToParam); \274 else \275 PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName()); \276 }277 278 //! derived template class, so all the Classes can load something.279 template<class T> class LoadParam : public LoadParamBase280 {281 public:282 283 #define FUNCTOR_LIST(x) LoadParam ## x284 #include "functor_list.h"285 #undef FUNCTOR_LIST286 };287 288 111 // helper function 289 112 -
trunk/src/util/loading/load_param_description.h
r5556 r5655 34 34 class LoadParamDescription 35 35 { 36 friend class LoadParam Base;36 friend class LoadParam; 37 37 friend class LoadClassDescription; 38 38 public: … … 56 56 class LoadClassDescription 57 57 { 58 friend class LoadParam Base;58 friend class LoadParam; 59 59 public: 60 60 LoadClassDescription(const char* className);
Note: See TracChangeset
for help on using the changeset viewer.