Jelajahi Sumber

added -pngcrush to pak builder

ncannasse 7 tahun lalu
induk
melakukan
ad51ef6e59
2 mengubah file dengan 25 tambahan dan 1 penghapusan
  1. 7 1
      hxd/fmt/pak/Build.hx
  2. 18 0
      hxd/fs/Convert.hx

+ 7 - 1
hxd/fmt/pak/Build.hx

@@ -5,7 +5,9 @@ class Build {
 
 
 	var fs : hxd.fs.LocalFileSystem;
 	var fs : hxd.fs.LocalFileSystem;
 	var out : { bytes : Array<haxe.io.Bytes>, size : Int };
 	var out : { bytes : Array<haxe.io.Bytes>, size : Int };
-
+	
+	
+	public var converts : Array<hxd.fs.Convert> = [];
 	public var excludedExt : Array<String> = [];
 	public var excludedExt : Array<String> = [];
 	public var resPath : String = "res";
 	public var resPath : String = "res";
 	public var outPrefix : String = "res";
 	public var outPrefix : String = "res";
@@ -126,6 +128,8 @@ class Build {
 			throw "'" + resPath + "' resource directory was not found";
 			throw "'" + resPath + "' resource directory was not found";
 
 
 		fs = new hxd.fs.LocalFileSystem(resPath);
 		fs = new hxd.fs.LocalFileSystem(resPath);
+		for( c in converts )
+			fs.addConvert(c);
 		switch( soundFormat ) {
 		switch( soundFormat ) {
 		case "wav":
 		case "wav":
 			// no convert
 			// no convert
@@ -203,6 +207,8 @@ class Build {
 				b.checkJPG = true;
 				b.checkJPG = true;
 			case "-check-ogg":
 			case "-check-ogg":
 				b.checkOGG = true;
 				b.checkOGG = true;
+			case "-pngcrush":
+				b.converts.push(new hxd.fs.Convert.Command("png","crush.png","pngcrush",["-s","%SRC","%DST"]));
 			default:
 			default:
 				throw "Unknown parameter " + f;
 				throw "Unknown parameter " + f;
 			}
 			}

+ 18 - 0
hxd/fs/Convert.hx

@@ -56,6 +56,24 @@ class ConvertFBX2HMD extends Convert {
 
 
 }
 }
 
 
+class Command extends Convert {
+
+	var cmd : String;
+	var args : Array<String>;
+
+	public function new(fr,to,cmd:String,args:Array<String>) {
+		super(fr,to);
+		this.cmd = cmd;
+		this.args = args;
+	}
+	
+	override function convert() {
+		command(cmd,[for( a in args ) if( a == "%SRC" ) srcPath else if( a == "%DST" ) dstPath else a]);
+	}
+	
+}
+
+
 class ConvertWAV2MP3 extends Convert {
 class ConvertWAV2MP3 extends Convert {
 
 
 	public function new() {
 	public function new() {