From: <phi...@us...> - 2007-06-09 15:31:58
|
Revision: 7292 http://armagetronad.svn.sourceforge.net/armagetronad/?rev=7292&view=rev Author: philippeqc Date: 2007-06-09 08:31:35 -0700 (Sat, 09 Jun 2007) Log Message: ----------- Quick hack to the color element to be able to use a hex code directly. Modified Paths: -------------- armagetronad/trunk/armagetronad/resource/proto/map-0.3.1-a.dtd armagetronad/trunk/armagetronad/src/tron/gParser.cpp armagetronad/trunk/armagetronad/src/tron/gParser.h Modified: armagetronad/trunk/armagetronad/resource/proto/map-0.3.1-a.dtd =================================================================== --- armagetronad/trunk/armagetronad/resource/proto/map-0.3.1-a.dtd 2007-06-09 13:29:05 UTC (rev 7291) +++ armagetronad/trunk/armagetronad/resource/proto/map-0.3.1-a.dtd 2007-06-09 15:31:35 UTC (rev 7292) @@ -97,7 +97,10 @@ <!ATTLIST Color green CDATA "0.0"> <!ATTLIST Color blue CDATA "0.0"> <!ATTLIST Color alpha CDATA "1.0"> +<!ATTLIST Color hexCode CDATA #IMPLIED> +<!ATTLIST Color name CDATA #IMPLIED> + <!ELEMENT Enter (EffectGroup+) > <!ELEMENT Inside (EffectGroup+) > <!ELEMENT Leave (EffectGroup+) > Modified: armagetronad/trunk/armagetronad/src/tron/gParser.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/tron/gParser.cpp 2007-06-09 13:29:05 UTC (rev 7291) +++ armagetronad/trunk/armagetronad/src/tron/gParser.cpp 2007-06-09 15:31:35 UTC (rev 7292) @@ -138,6 +138,32 @@ return r; } +rColor +gParser::myxmlGetPropColorFromHex(xmlNodePtr cur, const char *name) { + char *v = myxmlGetProp(cur, name); + if (v == NULL) return rColor(); + int r = strtoul(v, NULL, 0); + rColor aColor; + if (strlen(v) >= 9) { + aColor.a_ = ((REAL)(r & 255)) / 255.0; + r /= 256; + if (aColor.a_ > 0.7) + aColor.a_ = 0.7; + } + else { + aColor.a_ = 0.7; + } + aColor.b_ = ((REAL)(r & 255)) / 255.0; + r /= 256; + aColor.g_ = ((REAL)(r & 255)) / 255.0; + r /= 256; + aColor.r_ = ((REAL)(r & 255)) / 255.0; + r /= 256; + + xmlFree(v); + return aColor; +} + float gParser::myxmlGetPropFloat(xmlNodePtr cur, const char *name) { char *v = myxmlGetProp(cur, name); @@ -487,15 +513,28 @@ rColor gParser::parseColor(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword) { - rColor color; - color.r_ = myxmlGetPropFloat(cur, "red"); - color.g_ = myxmlGetPropFloat(cur, "green"); - color.b_ = myxmlGetPropFloat(cur, "blue"); - color.a_ = myxmlGetPropFloat(cur, "alpha"); + rColor color; + color.r_ = myxmlGetPropFloat(cur, "red"); + color.g_ = myxmlGetPropFloat(cur, "green"); + color.b_ = myxmlGetPropFloat(cur, "blue"); + color.a_ = myxmlGetPropFloat(cur, "alpha"); + + + if(myxmlHasProp(cur, "hexCode")) + { + color = myxmlGetPropColorFromHex(cur, "hexCode"); + } - /* + /* + if(myxmlHasProp(cur, "name") { string colorName = myxmlGetProp(cur, "name"); + } + */ + + + /* + // Blue Modified: armagetronad/trunk/armagetronad/src/tron/gParser.h =================================================================== --- armagetronad/trunk/armagetronad/src/tron/gParser.h 2007-06-09 13:29:05 UTC (rev 7291) +++ armagetronad/trunk/armagetronad/src/tron/gParser.h 2007-06-09 15:31:35 UTC (rev 7292) @@ -54,6 +54,7 @@ bool myxmlGetPropBool(xmlNodePtr cur, const char *name); Triad myxmlGetPropTriad(xmlNodePtr cur, const char *name); void myxmlGetDirection(xmlNodePtr cur, float &x, float &y); + rColor myxmlGetPropColorFromHex(xmlNodePtr cur, const char *name); // bool isElement(const xmlChar *elementName, const xmlChar *searchedElement); bool isElement(const xmlChar *elementName, const xmlChar *searchedElement, const xmlChar * keyword = NULL); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |