bool TmxObjectGroup::parseElement(void* p) { _x = 0; _y = 0; _width = 0; _height = 0; _opacity = 1.0f; _visible = true; _name = ""; _properties.clear(); _objects.clear(); auto element = static_cast<tinyxml2::XMLElement*>(p); if(!element) { return false; } if(element->Attribute("name")) { _name = element->Attribute("name"); } element->QueryIntAttribute("x", &_x); element->QueryIntAttribute("y", &_y); element->QueryIntAttribute("width", &_width); element->QueryIntAttribute("height", &_height); element->QueryFloatAttribute("opacity", &_opacity); element->QueryBoolAttribute("visible", &_visible); auto propertiesElement = element->FirstChildElement("properties"); _properties.parseElement(propertiesElement); auto objectElement = element->FirstChildElement("object"); while(objectElement) { _objects.push_back(TmxObject()); _objects.back().parseElement(objectElement); objectElement = objectElement->NextSiblingElement("object"); } return true; }
void Effect::Deserialize(View* view, tinyxml2::XMLElement* in_xmlNode) { Node::Deserialize(view, in_xmlNode); for (auto pXmlChild = in_xmlNode->FirstChildElement(); pXmlChild; pXmlChild = pXmlChild->NextSiblingElement()) { string childName = pXmlChild->Name(); if (childName != "Filter") continue; const char* szType = pXmlChild->Attribute("type"); if (!szType) continue; string typeName = szType; if (typeName == "blur") { m_blurEnabled = pXmlChild->BoolAttribute("enabled"); float amount = GetBlurAmount(); pXmlChild->QueryFloatAttribute("amount", &amount); SetBlurAmount(amount); } if (typeName == "sepia") { m_sepiaEnabled = pXmlChild->BoolAttribute("enabled"); Vector3 tone = GetSepiaTone(); pXmlChild->QueryFloatAttribute("toneR", &tone.x); pXmlChild->QueryFloatAttribute("toneG", &tone.y); pXmlChild->QueryFloatAttribute("toneB", &tone.z); SetSepiaTone(tone); float saturation = GetSepiaSaturation(); pXmlChild->QueryFloatAttribute("saturation", &saturation); SetSepiaSaturation(saturation); float amount = GetSepiaAmount(); pXmlChild->QueryFloatAttribute("amount", &amount); SetSepiaAmount(amount); } if (typeName == "crt") { m_crtEnabled = pXmlChild->BoolAttribute("enabled"); } if (typeName == "cartoon") { m_cartoonEnabled = pXmlChild->BoolAttribute("enabled"); Vector3 tone = GetCartoonTone(); pXmlChild->QueryFloatAttribute("toneR", &tone.x); pXmlChild->QueryFloatAttribute("toneG", &tone.y); pXmlChild->QueryFloatAttribute("toneB", &tone.z); SetCartoonTone(tone); } if (typeName == "vignette") { m_vignetteEnabled = pXmlChild->BoolAttribute("enabled"); float amount = GetVignetteAmount(); pXmlChild->QueryFloatAttribute("amount", &amount); SetVignetteAmount(amount); } } }