|
@@ -3,7 +3,7 @@ package hxd.fs;
|
|
|
@:keep @:keepSub
|
|
|
class Convert {
|
|
|
|
|
|
- public var sourceExt(default,null) : String;
|
|
|
+ public var sourceExts(default,null) : Array<String>;
|
|
|
public var destExt(default,null) : String;
|
|
|
|
|
|
/**
|
|
@@ -18,8 +18,8 @@ class Convert {
|
|
|
public var originalFilename : String;
|
|
|
public var srcBytes : haxe.io.Bytes;
|
|
|
|
|
|
- public function new( sourceExt, destExt ) {
|
|
|
- this.sourceExt = sourceExt;
|
|
|
+ public function new( sourceExts, destExt ) {
|
|
|
+ this.sourceExts = sourceExts == null ? null : sourceExts.split(",");
|
|
|
this.destExt = destExt;
|
|
|
this.version = 0;
|
|
|
}
|
|
@@ -51,18 +51,13 @@ class Convert {
|
|
|
}
|
|
|
|
|
|
static var converts = new Map<String,Array<Convert>>();
|
|
|
- public static function register( ?c : Convert, ?arr : Array<Convert> ) : Int {
|
|
|
- if( c != null ) {
|
|
|
- var dest = converts.get(c.destExt);
|
|
|
- if( dest == null ) {
|
|
|
- dest = [];
|
|
|
- converts.set(c.destExt, dest);
|
|
|
- }
|
|
|
- dest.unshift(c); // latest registered get priority ! (allow override defaults)
|
|
|
+ public static function register( c : Convert ) : Int {
|
|
|
+ var dest = converts.get(c.destExt);
|
|
|
+ if( dest == null ) {
|
|
|
+ dest = [];
|
|
|
+ converts.set(c.destExt, dest);
|
|
|
}
|
|
|
- if( arr != null )
|
|
|
- for( c in arr )
|
|
|
- register(c);
|
|
|
+ dest.unshift(c); // latest registered get priority ! (allow override defaults)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -215,11 +210,16 @@ class CompressIMG extends Convert {
|
|
|
command("CompressonatorCLI", ["-silent","-fd",getParam("format"),srcPath,dstPath]);
|
|
|
}
|
|
|
|
|
|
- static var _ = Convert.register([
|
|
|
- new CompressIMG("png","dds"),
|
|
|
- new CompressIMG("tga","dds"),
|
|
|
- new CompressIMG("jpg","dds"),
|
|
|
- new CompressIMG("jpeg","dds")
|
|
|
- ]);
|
|
|
+ static var _ = Convert.register(new CompressIMG("png,tga,jpg,jpeg","dds"));
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+class DummyConvert extends Convert {
|
|
|
+
|
|
|
+ override function convert() {
|
|
|
+ save(haxe.io.Bytes.alloc(0));
|
|
|
+ }
|
|
|
+
|
|
|
+ static var _ = Convert.register(new DummyConvert(null,"dummy"));
|
|
|
|
|
|
}
|