Browse Source

- Updated version check for Tiled TMX files to recognize the latest 1.0 version
- Throw an error if a tmx file uses a TSX (tileset) file that references individual images instead of a spritesheet (those are not supported)

Shaddock Heath 8 years ago
parent
commit
2c51c27ba5
2 changed files with 26 additions and 3 deletions
  1. 20 2
      Source/Atomic/Atomic2D/TmxFile2D.cpp
  2. 6 1
      Source/Atomic/Atomic2D/TmxFile2D.h

+ 20 - 2
Source/Atomic/Atomic2D/TmxFile2D.cpp

@@ -387,8 +387,16 @@ bool TmxFile2D::BeginLoad(Deserializer& source)
                 if (!tsxXMLFile)
                 if (!tsxXMLFile)
                     return false;
                     return false;
 
 
-                tsxXMLFiles_[source] = tsxXMLFile;
+                // ATOMIC BEGIN
+                if (tsxXMLFile->GetRoot("tileset").GetChild("tile"))
+                {
+                    ATOMIC_LOGERROR("Load TSX File failed: " + source + ". tsx files with individual images are not supported.");
+                    return false;
+                }
+                // ATOMIC END
 
 
+                tsxXMLFiles_[source] = tsxXMLFile;
+                
                 String textureFilePath =
                 String textureFilePath =
                     GetParentPath(GetName()) + tsxXMLFile->GetRoot("tileset").GetChild("image").GetAttribute("source");
                     GetParentPath(GetName()) + tsxXMLFile->GetRoot("tileset").GetChild("image").GetAttribute("source");
                 GetSubsystem<ResourceCache>()->BackgroundLoadResource<Texture2D>(textureFilePath, true, this);
                 GetSubsystem<ResourceCache>()->BackgroundLoadResource<Texture2D>(textureFilePath, true, this);
@@ -418,7 +426,9 @@ bool TmxFile2D::EndLoad()
 
 
     XMLElement rootElem = loadXMLFile_->GetRoot("map");
     XMLElement rootElem = loadXMLFile_->GetRoot("map");
     String version = rootElem.GetAttribute("version");
     String version = rootElem.GetAttribute("version");
-    if (version != "1.0")
+    // ATOMIC BEGIN
+    if (version != "1.0" && version != "1.0.0")
+    // ATOMIC END
     {
     {
         ATOMIC_LOGERROR("Invalid version");
         ATOMIC_LOGERROR("Invalid version");
         return false;
         return false;
@@ -575,6 +585,14 @@ bool TmxFile2D::LoadTileSet(const XMLElement& element)
             if (!tsxXMLFile)
             if (!tsxXMLFile)
                 return false;
                 return false;
 
 
+            // ATOMIC BEGIN
+            if (tsxXMLFile->GetRoot("tileset").GetChild("tile"))
+            {
+                ATOMIC_LOGERROR("Load TSX File failed: " + source + ". tsx files with individual images are not supported.");
+                return false;
+            }
+            // ATOMIC END
+
             // Add to napping to avoid release
             // Add to napping to avoid release
             tsxXMLFiles_[source] = tsxXMLFile;
             tsxXMLFiles_[source] = tsxXMLFile;
 
 

+ 6 - 1
Source/Atomic/Atomic2D/TmxFile2D.h

@@ -171,7 +171,12 @@ class ATOMIC_API TmxFile2D : public Resource
     ATOMIC_OBJECT(TmxFile2D, Resource);
     ATOMIC_OBJECT(TmxFile2D, Resource);
 
 
 public:
 public:
-    /// Construct.
+    /** Construct.
+      * This will load a Tiled .tmx file for use.  Not all
+      * Tile options are supported.  Some important limitions are:
+      * - The Tile Layer Format must be XML
+      * - The tilesets used in the map must be made from sprite sheets. Individual images are not supported
+     */
     TmxFile2D(Context* context);
     TmxFile2D(Context* context);
     /// Destruct.
     /// Destruct.
     virtual ~TmxFile2D();
     virtual ~TmxFile2D();