Browse Source

Merge pull request #1549 from AtomicGameEngine/TSH-ATOMIC-TILEDFIX

Minor fixes for TMX files
JoshEngebretson 8 năm trước cách đây
mục cha
commit
4896a6fde9
2 tập tin đã thay đổi với 31 bổ sung3 xóa
  1. 25 2
      Source/Atomic/Atomic2D/TmxFile2D.cpp
  2. 6 1
      Source/Atomic/Atomic2D/TmxFile2D.h

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

@@ -387,8 +387,19 @@ bool TmxFile2D::BeginLoad(Deserializer& source)
                 if (!tsxXMLFile)
                     return false;
 
-                tsxXMLFiles_[source] = tsxXMLFile;
+                // ATOMIC BEGIN
 
+                // Look for an image indicating that this is a spritesheet with multiple tiles instead
+                // of a series of individual images which are not supported
+                if (!tsxXMLFile->GetRoot("tileset").GetChild("image"))
+                {
+                    ATOMIC_LOGERROR("Load TSX File failed: " + source + ". tsx files with individual images are not supported.");
+                    return false;
+                }
+                // ATOMIC END
+
+                tsxXMLFiles_[source] = tsxXMLFile;
+                
                 String textureFilePath =
                     GetParentPath(GetName()) + tsxXMLFile->GetRoot("tileset").GetChild("image").GetAttribute("source");
                 GetSubsystem<ResourceCache>()->BackgroundLoadResource<Texture2D>(textureFilePath, true, this);
@@ -418,7 +429,9 @@ bool TmxFile2D::EndLoad()
 
     XMLElement rootElem = loadXMLFile_->GetRoot("map");
     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");
         return false;
@@ -575,6 +588,16 @@ bool TmxFile2D::LoadTileSet(const XMLElement& element)
             if (!tsxXMLFile)
                 return false;
 
+            // ATOMIC BEGIN
+            // Look for an image indicating that this is a spritesheet with multiple tiles instead
+            // of a series of individual images which are not supported
+            if (!tsxXMLFile->GetRoot("tileset").GetChild("image"))
+            {
+                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
             tsxXMLFiles_[source] = tsxXMLFile;
 

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

@@ -171,7 +171,12 @@ class ATOMIC_API TmxFile2D : public Resource
     ATOMIC_OBJECT(TmxFile2D, Resource);
 
 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);
     /// Destruct.
     virtual ~TmxFile2D();