Browse Source

Expose PackageFiles to scripting

JimMarlowe 9 years ago
parent
commit
2fff0e1b5f

+ 4 - 1
Script/Packages/Atomic/IO.json

@@ -1,11 +1,14 @@
 {
 {
 	"name" : "IO",
 	"name" : "IO",
 	"sources" : ["Source/Atomic/IO"],
 	"sources" : ["Source/Atomic/IO"],
-	"classes" : ["Log", "File", "FileSystem", "FileWatcher", "BufferQueue"],
+	"classes" : ["Log", "File", "FileSystem", "FileWatcher", "BufferQueue", "PackageFile"],
 	"interfaces" : ["Serializer", "Deserializer"],
 	"interfaces" : ["Serializer", "Deserializer"],
 	"overloads" : {
 	"overloads" : {
 		"File" : {
 		"File" : {
 			"File" : ["Context", "String", "FileMode"]
 			"File" : ["Context", "String", "FileMode"]
+		},
+		"PackageFile" : {
+			"PackageFile" : ["Context", "String", "unsigned"]
 		}
 		}
 	},
 	},
 	"typescript_decl" : {
 	"typescript_decl" : {

+ 5 - 0
Script/Packages/Atomic/Resource.json

@@ -1,11 +1,16 @@
 {
 {
 	"name" : "Resource",
 	"name" : "Resource",
 	"sources" : ["Source/Atomic/Resource"],
 	"sources" : ["Source/Atomic/Resource"],
+	"includes" : ["<Atomic/IO/PackageFile.h>"],
 	"classes" : ["Resource", "ResourceCache", "XMLFile", "PListFile", "JSONFile", "Image", "ResourceNameIterator"],
 	"classes" : ["Resource", "ResourceCache", "XMLFile", "PListFile", "JSONFile", "Image", "ResourceNameIterator"],
 	"overloads": {
 	"overloads": {
 		"Image": {
 		"Image": {
 			"GetPixel": ["int", "int"],
 			"GetPixel": ["int", "int"],
 			"SetSize": ["int", "int", "int", "unsigned"]
 			"SetSize": ["int", "int", "int", "unsigned"]
+		},
+		"ResourceCache": {
+			"AddPackageFile": ["String", "unsigned"],
+			"RemovePackageFile": ["String", "bool", "bool"]
 		}
 		}
 	},
 	},
 	"typescript_decl" : {
 	"typescript_decl" : {

+ 2 - 1
Script/Packages/Atomic/Scene.json

@@ -8,7 +8,8 @@
 	"excludes" : {
 	"excludes" : {
 		"Scene" : {
 		"Scene" : {
 			"GetComponent" : ["unsigned"],
 			"GetComponent" : ["unsigned"],
-			"MarkReplicationDirty" : ["Node"]
+			"MarkReplicationDirty" : ["Node"],
+			"GetRequiredPackageFiles" : []
 		}
 		}
 	},
 	},
 	"overloads" : {
 	"overloads" : {

+ 14 - 1
Source/Atomic/IO/PackageFile.h

@@ -86,7 +86,20 @@ public:
     const Vector<String> GetEntryNames() const { return entries_.Keys(); }
     const Vector<String> GetEntryNames() const { return entries_.Keys(); }
 
 
     // ATOMIC BEGIN
     // ATOMIC BEGIN
-    
+
+    /// Return a file name in the package, for scripting use ( GetEntryNames is not bindable? )
+    const String& GetEntryName(unsigned index) const 
+    {
+        unsigned nn = 0;  // .Begin() + index syntax not supported on HashMap
+        for (HashMap<String, PackageEntry>::ConstIterator j = entries_.Begin(); j != entries_.End(); ++j)
+        {
+            if (nn == index) return j->first_;
+            nn++;
+        }
+        return String::EMPTY; 
+    }
+
+
     /// Scan package for specified files.
     /// Scan package for specified files.
     void Scan(Vector<String>& result, const String& pathName, const String& filter, bool recursive) const;
     void Scan(Vector<String>& result, const String& pathName, const String& filter, bool recursive) const;