예제 #1
0
//------------------------------------------------------------------------
bool CItem::ReadLayers(const IItemParamsNode *layers)
{
	if(!m_sharedparams->Valid())
	{
		m_sharedparams->layers.clear();
		int n = layers->GetChildCount();

		for(int i=0; i<n; i++)
		{
			const IItemParamsNode *layer = layers->GetChild(i);

			if(layer)
			{
				SLayer lyr;

				if(ReadLayer(layer, &lyr))
				{
					const char *name = layer->GetAttribute("name");
					m_sharedparams->layers.insert(TLayerMap::value_type(name, lyr));
				}
			}
		}
	}

	return true;
}
예제 #2
0
void XmlMapHandler::Load(std::istream& file, Map& map)
{
    wxXmlDocument doc;
    wxFInputStream fis(file);
    if (!doc.Load(dynamic_cast<wxInputStream&>(fis)))
        throw "Could not open XML file";

    wxXmlNode* child = doc.GetRoot()->GetChildren();

    if (child != NULL && child->GetName() != "Properties")
        throw "Properties must be the first node in the XML file";

    ReadProperties(child, map);
    while ((child = child->GetNext()))
    {
        std::string name = child->GetName().ToStdString();
        VerboseLog("%s Got node %s", __func__, name.c_str());

        if (name == "Layer")
            ReadLayer(child, map);
        else if (name == "Background")
            ReadBackground(child, map);
        else if (name == "Collision")
            ReadCollision(child, map);
        else if (name == "Animation")
            ReadAnimation(child, map);
        else
            throw "Unknown element found in file " + name;
    }
}