瀏覽代碼

PAK : always load resXXX

ncannasse 10 年之前
父節點
當前提交
0d6cd1264f
共有 2 個文件被更改,包括 22 次插入1 次删除
  1. 11 0
      hxd/File.hx
  2. 11 1
      hxd/Res.hx

+ 11 - 0
hxd/File.hx

@@ -145,6 +145,17 @@ class File {
 		#end
 	}
 
+	public static function exists( path : String ) : Bool {
+		#if air3
+		return getRelPath(path).exists;
+		#elseif sys
+		return sys.FileSystem.exists(path);
+		#else
+		throw "Not supported";
+		return false;
+		#end
+	}
+
 	public static function getBytes( path : String ) : haxe.io.Bytes {
 		#if air3
 		var file = getRelPath(path);

+ 11 - 1
hxd/Res.hx

@@ -24,7 +24,17 @@ class Res {
 	public static macro function initPak() {
 		var dir = haxe.macro.Context.definedValue("resourcesPath");
 		if( dir == null ) dir = "res";
-		return macro hxd.Res.loader = new hxd.res.Loader(new hxd.fmt.pak.FileSystem($v{dir}+".pak"));
+		return macro {
+			var dir = $v{dir};
+			var pak = new hxd.fmt.pak.FileSystem(dir+".pak");
+			var i = 1;
+			while( true ) {
+				if( !hxd.File.exists(dir + i + ".pak") ) break;
+				pak.loadPak(dir + i + ".pak");
+				i++;
+			}
+			hxd.Res.loader = new hxd.res.Loader(pak);
+		}
 	}
 
 }