|
|
|
@ -47,10 +47,27 @@ struct LayerTag{ |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
struct SpawnerTag{ |
|
|
|
|
XMLTag ObjectData; |
|
|
|
|
std::vector<XMLTag>properties; |
|
|
|
|
std::string str() { |
|
|
|
|
std::string displayStr=ObjectData.tag+"\n"+ObjectData.FormatTagData(ObjectData.data); |
|
|
|
|
for(XMLTag tag:properties){ |
|
|
|
|
displayStr+=" ("+tag.FormatTagData(tag.data)+")\n"; |
|
|
|
|
} |
|
|
|
|
return displayStr; |
|
|
|
|
} |
|
|
|
|
friend std::ostream& operator << (std::ostream& os, SpawnerTag& rhs) {
|
|
|
|
|
os << rhs.str()<<"\n"; |
|
|
|
|
|
|
|
|
|
return os; } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
struct Map{ |
|
|
|
|
XMLTag MapData; |
|
|
|
|
XMLTag TilesetData; |
|
|
|
|
std::vector<LayerTag> LayerData; |
|
|
|
|
std::vector<SpawnerTag> SpawnerData; |
|
|
|
|
std::string FormatLayerData(std::ostream& os, std::vector<LayerTag>tiles) { |
|
|
|
|
std::string displayStr; |
|
|
|
|
for (int i=0;i<LayerData.size();i++) { |
|
|
|
@ -58,11 +75,19 @@ struct Map{ |
|
|
|
|
} |
|
|
|
|
return displayStr; |
|
|
|
|
} |
|
|
|
|
std::string FormatSpawnerData(std::ostream& os, std::vector<SpawnerTag>tiles) { |
|
|
|
|
std::string displayStr; |
|
|
|
|
for (int i=0;i<SpawnerData.size();i++) { |
|
|
|
|
displayStr+=SpawnerData[i].str(); |
|
|
|
|
} |
|
|
|
|
return displayStr; |
|
|
|
|
} |
|
|
|
|
friend std::ostream& operator << (std::ostream& os, Map& rhs) {
|
|
|
|
|
os <<
|
|
|
|
|
rhs.MapData <<"\n"<<
|
|
|
|
|
rhs.TilesetData <<"\n"<<
|
|
|
|
|
rhs.FormatLayerData(os,rhs.LayerData) <<"\n"; |
|
|
|
|
rhs.FormatLayerData(os,rhs.LayerData) <<"\n"<< |
|
|
|
|
rhs.FormatSpawnerData(os,rhs.SpawnerData)<<"\n"; |
|
|
|
|
|
|
|
|
|
return os; } |
|
|
|
|
}; |
|
|
|
@ -78,6 +103,8 @@ public: |
|
|
|
|
private: |
|
|
|
|
|
|
|
|
|
Map parsedMapInfo; |
|
|
|
|
bool buildingSpawner=false; |
|
|
|
|
SpawnerTag obj; |
|
|
|
|
|
|
|
|
|
void ParseTag(std::string tag) { |
|
|
|
|
XMLTag newTag; |
|
|
|
@ -135,9 +162,28 @@ private: |
|
|
|
|
if (newTag.tag=="layer") { |
|
|
|
|
LayerTag l = {newTag}; |
|
|
|
|
parsedMapInfo.LayerData.push_back(l); |
|
|
|
|
} else
|
|
|
|
|
if (newTag.tag=="object") { |
|
|
|
|
if(buildingSpawner){ |
|
|
|
|
parsedMapInfo.SpawnerData.push_back(obj); |
|
|
|
|
} |
|
|
|
|
buildingSpawner=true; |
|
|
|
|
obj={newTag}; |
|
|
|
|
goto spawnerResetSkip; |
|
|
|
|
} else
|
|
|
|
|
if (newTag.tag=="property"&&buildingSpawner) { |
|
|
|
|
if(newTag.data["propertytype"]=="MonsterName"){ |
|
|
|
|
obj.properties.push_back(newTag); |
|
|
|
|
} |
|
|
|
|
goto spawnerResetSkip; |
|
|
|
|
} else { |
|
|
|
|
std::cout<<"Unsupported tag format! Ignoring."<<"\n"; |
|
|
|
|
} |
|
|
|
|
if(buildingSpawner){ |
|
|
|
|
parsedMapInfo.SpawnerData.push_back(obj); |
|
|
|
|
} |
|
|
|
|
buildingSpawner=false; |
|
|
|
|
spawnerResetSkip: |
|
|
|
|
std::cout<<"\n"<<"=============\n"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -184,6 +230,10 @@ public: |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(buildingSpawner){ |
|
|
|
|
parsedMapInfo.SpawnerData.push_back(obj); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::cout<<"Parsed Map Data:\n"<<parsedMapInfo<<"\n"; |
|
|
|
|
} |
|
|
|
|
}; |