Definition in file primitive_class.cpp.
#include <nel/ligo/primitive_class.h>
#include <nel/ligo/primitive.h>
#include <nel/ligo/ligo_config.h>
#include <nel/misc/i_xml.h>
#include <nel/misc/path.h>
Go to the source code of this file.
Functions | |
bool | ReadBool (const char *propName, bool &result, xmlNodePtr xmlNode, const char *filename, CLigoConfig &config) |
bool | ReadChild (CPrimitiveClass::CChild &child, xmlNodePtr childNode, const char *filename, bool _static, CLigoConfig &config) |
bool | ReadColor (CRGBA &color, xmlNodePtr node) |
bool | ReadFloat (const char *propName, float &result, xmlNodePtr xmlNode) |
bool | ReadInt (const char *propName, int &result, xmlNodePtr xmlNode) |
|
Definition at line 70 of file primitive_class.cpp. Referenced by NLLIGO::CPrimitiveClass::read().
00071 { 00072 string str; 00073 if (CIXml::getPropertyString (str, xmlNode, propName)) 00074 { 00075 if (str == "true") 00076 result = true; 00077 else if (str == "false") 00078 result = false; 00079 else 00080 { 00081 config.syntaxError (filename, xmlNode, "Unknown (%s) parameter (%s), should be false or true", propName, str.c_str ()); 00082 return false; 00083 } 00084 return true; 00085 } 00086 return false; 00087 } |
|
Definition at line 122 of file primitive_class.cpp. References NLLIGO::CPrimitiveClass::CChild::ClassName, NLLIGO::CPrimitiveClass::CInitParameters::DefaultValue, NLLIGO::CPrimitiveClass::CInitParameters::Name, NLLIGO::CPrimitiveClass::CChild::Name, NLLIGO::CPrimitiveClass::CChild::Parameters, uint, and value. Referenced by NLLIGO::CPrimitiveClass::read().
00123 { 00124 // Read the class name 00125 if (config.getPropertyString (child.ClassName, filename, childNode, "CLASS_NAME")) 00126 { 00127 // Read the name 00128 if (!_static || config.getPropertyString (child.Name, filename, childNode, "NAME")) 00129 { 00130 // Read the parameters 00131 xmlNodePtr childParamNode = CIXml::getFirstChildNode (childNode, "PARAMETER"); 00132 child.Parameters.reserve (CIXml::countChildren (childNode, "PARAMETER")); 00133 if (childParamNode) 00134 { 00135 do 00136 { 00137 // Add a static child 00138 child.Parameters.push_back (CPrimitiveClass::CInitParameters ()); 00139 00140 // Child ref 00141 CPrimitiveClass::CInitParameters &childParam = child.Parameters.back (); 00142 00143 // Read the class name 00144 if (config.getPropertyString (childParam.Name, filename, childParamNode, "NAME")) 00145 { 00146 // Read the parameters 00147 xmlNodePtr childParamValueNode = CIXml::getFirstChildNode (childParamNode, "DEFAULT_VALUE"); 00148 childParam.DefaultValue.resize (CIXml::countChildren (childParamNode, "DEFAULT_VALUE")); 00149 uint defaultId = 0; 00150 if (childParamValueNode) 00151 { 00152 do 00153 { 00154 // Gen id flag 00155 childParam.DefaultValue[defaultId].GenID = false; 00156 00157 // Read the gen id flag 00158 string value; 00159 if (CIXml::getPropertyString (value, childParamValueNode, "GEN_ID") && (value != "false")) 00160 { 00161 childParam.DefaultValue[defaultId].GenID = true; 00162 } 00163 else 00164 { 00165 if (config.getPropertyString (value, filename, childParamValueNode, "VALUE")) 00166 { 00167 childParam.DefaultValue[defaultId].Name = value; 00168 } 00169 else 00170 goto failed; 00171 } 00172 defaultId++; 00173 } 00174 while ((childParamValueNode = CIXml::getNextChildNode (childParamValueNode, "DEFAULT_VALUE"))); 00175 } 00176 } 00177 else 00178 goto failed; 00179 } 00180 while ((childParamNode = CIXml::getNextChildNode (childParamNode, "PARAMETER"))); 00181 } 00182 00183 // Ok 00184 return true; 00185 } 00186 } 00187 failed: 00188 return false; 00189 } |
|
Definition at line 91 of file primitive_class.cpp. References NLMISC::clamp(), DEFAULT_PRIMITIVE_COLOR, r, NLLIGO::ReadFloat(), and uint8. Referenced by NLLIGO::CPrimitiveClass::read(), and NLLIGO::CPrimitiveConfigurations::read().
00092 { 00093 // Read the color 00094 float r = DEFAULT_PRIMITIVE_COLOR.R; 00095 float g = DEFAULT_PRIMITIVE_COLOR.G; 00096 float b = DEFAULT_PRIMITIVE_COLOR.B; 00097 float a = DEFAULT_PRIMITIVE_COLOR.A; 00098 00099 // Read the value 00100 if (!ReadFloat ("R", r, node)) 00101 return false; 00102 if (!ReadFloat ("G", g, node)) 00103 return false; 00104 if (!ReadFloat ("B", b, node)) 00105 return false; 00106 if (!ReadFloat ("A", a, node)) 00107 a = 255; 00108 00109 // Clamp 00110 clamp (r, 0.f, 255.f); 00111 clamp (g, 0.f, 255.f); 00112 clamp (b, 0.f, 255.f); 00113 clamp (a, 0.f, 255.f); 00114 00115 // Set 00116 color.set((uint8)r, (uint8)g, (uint8)b, (uint8)a); 00117 return true; 00118 } |
|
Definition at line 44 of file primitive_class.cpp. References value.
|
|
Definition at line 57 of file primitive_class.cpp. References value. Referenced by NLLIGO::CPrimitiveClass::read().
|