diff --git a/haxework/format/Formatter.hx b/haxework/format/Formatter.hx index 2fbf2af..d28ab94 100755 --- a/haxework/format/Formatter.hx +++ b/haxework/format/Formatter.hx @@ -24,6 +24,13 @@ class Formatter implements IFormatter { }); } + public function formatTime(time:Int):String { + time = Math.round(time / 1000); + var mm:Int = Math.floor(time / 60); + var ss:Int = time - mm * 60; + return doubleDigit(mm) + ":" + doubleDigit(ss); + } + private static function doubleDigit(num:Int):String { return ((num < 10) ? "0" : "") + num; } diff --git a/haxework/format/IFormatter.hx b/haxework/format/IFormatter.hx index 6f4a333..88ca330 100755 --- a/haxework/format/IFormatter.hx +++ b/haxework/format/IFormatter.hx @@ -3,4 +3,5 @@ package haxework.format; interface IFormatter { public function formatDate(date:Date, format:String):String; public function formatDateFloat(date:Float, format:String):String; + public function formatTime(time:Int):String; } \ No newline at end of file diff --git a/haxework/gui/GuiBuilder.hx b/haxework/gui/GuiBuilder.hx index 34b637b..6fb2183 100755 --- a/haxework/gui/GuiBuilder.hx +++ b/haxework/gui/GuiBuilder.hx @@ -55,6 +55,8 @@ class GuiB { //Reflect.deleteField(data, "type"); var object:Dynamic = instance(type); new GuiF(object, data, links).fill(); + var initMethod:Dynamic = Reflect.field(object, "init"); + if (initMethod != null) Reflect.callMethod(object, initMethod, []); return object; } else if (Std.is(data, String)) { return GuiF.convertString(data, links); diff --git a/haxework/provider/Provider.hx b/haxework/provider/Provider.hx index 6a8482c..5f9006b 100755 --- a/haxework/provider/Provider.hx +++ b/haxework/provider/Provider.hx @@ -6,10 +6,12 @@ import flash.errors.Error; class Provider { private static var factories:ObjectMap> = new ObjectMap>(); + private static var args:ObjectMap> = new ObjectMap>(); private static var instances:ObjectMap = new ObjectMap(); - public static function setFactory(i:Class, clazz:Class, ?type:Dynamic):Void { + public static function setFactory(i:Class, clazz:Class, ?type:Dynamic, ?args:Array):Void { factories.set(type == null ? i : i + type, clazz); + if (args != null) Provider.args.set(type == null ? i : i + type, args); } public static function set(i:Class, instance:T, ?type:Dynamic):Void { @@ -21,7 +23,7 @@ class Provider { if (instances.exists(key)) { return instances.get(key); } else if (factories.exists(key)) { - var instance:T = Type.createInstance(factories.get(key), []); + var instance:T = Type.createInstance(factories.get(key), args.exists(key) ? args.get(key) : []); instances.set(key, instance); return instance; } else { @@ -32,7 +34,7 @@ class Provider { public static function build(i:Class, ?type:Dynamic):T { var key:Dynamic = (type == null) ? i : type; if (factories.exists(key)) { - var instance:T = Type.createInstance(factories.get(key), []); + var instance:T = Type.createInstance(factories.get(key), args.exists(key) ? args.get(key) : []); return instance; } else { throw new Error("Factory for\"" + i + "\" not found");