Skip to content

Instantly share code, notes, and snippets.

@KartikShrivastava
Created July 4, 2022 07:38
Show Gist options
  • Save KartikShrivastava/0705497a264c2e29e0c0a316f6ae7a34 to your computer and use it in GitHub Desktop.
Save KartikShrivastava/0705497a264c2e29e0c0a316f6ae7a34 to your computer and use it in GitHub Desktop.
bool TSXTilesetLoader::for_each(pugi::xml_node& xmlNode) {
// truncated code...
pugi::xml_node imgNode = xmlNode.child("image");
if(imgNode.empty()) {
pugi::xml_object_range<pugi::xml_named_node_iterator> tileChildrenItr = xmlNode.children("tile");
for(pugi::xml_node tileChild : tileChildrenItr) {
buffers::TreeNode *protoNode = backgroundFolderRef->mutable_folder()->add_children();
std::string tileId = tileChild.attribute("id").value();
std::string protoNodeName = resName+"_"+tileId;
protoNode->set_name(protoNodeName);
AddResource(protoNode, resType, tileChild);
// use_as_tileset should be false for stanalone tile converted to background
protoNode->mutable_background()->set_use_as_tileset(false);
// truncated code...
}
}
else {
buffers::TreeNode *protoNode = backgroundFolderRef->mutable_folder()->add_children();
protoNode->set_name(resName);
AddResource(protoNode, resType, xmlNode);
protoNode->mutable_background()->set_use_as_tileset(true);
// truncated code...
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment