@@ -201,6 +201,7 @@ namespace gf {
201
201
MapLayer layer;
202
202
layer.properties_index = parse_tmx_properties (node, map);
203
203
layer.name = node.attribute (" name" ).as_string ();
204
+ layer.type = node.attribute (" class" ).as_string ();
204
205
layer.offset .x = node.attribute (" offsetx" ).as_int (0 );
205
206
layer.offset .y = node.attribute (" offsety" ).as_int (0 );
206
207
unsupported_attribute (node, " opacity" );
@@ -682,10 +683,15 @@ namespace gf {
682
683
return tile;
683
684
}
684
685
685
- void parse_tmx_tileset_from_element (MapTileset& tileset, const pugi::xml_node node, TiledMap& map, const std::filesystem::path& base_directory)
686
+ MapTileset parse_tmx_tileset_from_element (const pugi::xml_node node, TiledMap& map, const std::filesystem::path& base_directory)
686
687
{
687
688
assert (node.name () == " tileset" sv);
688
689
690
+ MapTileset tileset;
691
+ tileset.type = node.attribute (" class" ).as_string ();
692
+ tileset.properties_index = parse_tmx_properties (node, map);
693
+ tileset.first_gid = node.attribute (" firstgid" ).as_uint ();
694
+
689
695
tileset.tile_size .w = node.attribute (" tilewidth" ).as_int ();
690
696
tileset.tile_size .h = node.attribute (" tileheight" ).as_int ();
691
697
@@ -710,9 +716,11 @@ namespace gf {
710
716
std::sort (tileset.tiles .begin (), tileset.tiles .end (), MapTilesetTileComparator ());
711
717
712
718
unsupported_node (node, " wangsets" );
719
+
720
+ return tileset;
713
721
}
714
722
715
- void parse_tmx_tileset_from_file (MapTileset& tileset, const std::filesystem::path& source, TiledMap& map, const std::filesystem::path& base_directory)
723
+ MapTileset parse_tmx_tileset_from_file (const std::filesystem::path& source, TiledMap& map, const std::filesystem::path& base_directory)
716
724
{
717
725
std::filesystem::path tileset_path = base_directory / source;
718
726
std::ifstream tileset_file (tileset_path);
@@ -738,25 +746,19 @@ namespace gf {
738
746
Log::warning (" Attribute 'source' present in a TSX file: '{}'." , tileset_path);
739
747
}
740
748
741
- parse_tmx_tileset_from_element (tileset, node, map, tileset_path.parent_path ());
749
+ return parse_tmx_tileset_from_element (node, map, tileset_path.parent_path ());
742
750
}
743
751
744
752
MapTileset parse_tmx_tileset (const pugi::xml_node node, TiledMap& map, const std::filesystem::path& base_directory)
745
753
{
746
754
assert (node.name () == " tileset" sv);
747
- MapTileset tileset;
748
- tileset.properties_index = parse_tmx_properties (node, map);
749
- tileset.first_gid = node.attribute (" firstgid" ).as_uint ();
750
-
751
755
const std::filesystem::path source = node.attribute (" source" ).as_string ();
752
756
753
757
if (!source.empty ()) {
754
- parse_tmx_tileset_from_file (tileset, source, map, base_directory);
755
- } else {
756
- parse_tmx_tileset_from_element (tileset, node, map, base_directory);
758
+ return parse_tmx_tileset_from_file (source, map, base_directory);
757
759
}
758
760
759
- return tileset ;
761
+ return parse_tmx_tileset_from_element (node, map, base_directory) ;
760
762
}
761
763
762
764
/*
@@ -767,6 +769,7 @@ namespace gf {
767
769
{
768
770
assert (node.name () == " map" sv);
769
771
772
+ map.type = node.attribute (" class" ).as_string ();
770
773
map.properties_index = parse_tmx_properties (node, map);
771
774
772
775
std::string orientation = node.attribute (" orientation" ).as_string ();
0 commit comments