Created
July 4, 2022 07:55
-
-
Save ark-tik/600cf91c9e9bc6a63a93701965a7e3c5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TMXMapLoader : public pugi::xml_tree_walker { | |
public: | |
// code truncated... | |
bool Load(pugi::xml_document &xmlDoc) { | |
pugi::xml_node mapNode = xmlDoc.child("map"); | |
// first load all tileset(s) in background(s) | |
bool backgroundsOk = LoadTilesets(mapNode, "background"); | |
if(!backgroundsOk) | |
return false; | |
// now load map, backgrounds are available for setting room.tile and/or room.background | |
bool roomOk = LoadMap(mapNode, "room"); | |
if(!roomOk) | |
return false; | |
return true; | |
} | |
// code truncated... | |
}; | |
std::unique_ptr<buffers::Project> TMXFileFormat::LoadProject(const fs::path& fPath) const { | |
pugi::xml_document doc; | |
if(!doc.load_file(fPath.c_str())) return nullptr; | |
// code truncated... | |
TMXMapLoader mapWalker(game->mutable_root(), fPath); | |
bool success = mapWalker.Load(doc); | |
if(!success){ | |
std::cout<<"Error occured while loading selected Tiled map"<<std::endl; | |
return NULL; | |
} | |
return proj; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment