update
This commit is contained in:
@@ -27,11 +27,19 @@ import haxework.gui.skin.BitmapSkin;
|
||||
import haxework.gui.skin.ButtonColorSkin;
|
||||
import haxework.gui.skin.ButtonBitmapSkin;
|
||||
import haxework.gui.skin.ProgressSkin;
|
||||
|
||||
import haxework.frame.FrameSwitcher;
|
||||
|
||||
class GuiBuilder {
|
||||
|
||||
private static var cache:Map<String, Dynamic> = new Map<String, Dynamic>();
|
||||
|
||||
private static function getResource(resource:String):Dynamic {
|
||||
if (!cache.exists(resource)) {
|
||||
cache.set(resource, Json.parse(Assets.getText(resource)));
|
||||
}
|
||||
return cache.get(resource);
|
||||
}
|
||||
|
||||
public static function build(data:Dynamic, ?links:Dynamic):Dynamic {
|
||||
return new GuiB(data, links, data._includes).build();
|
||||
}
|
||||
@@ -41,10 +49,16 @@ class GuiBuilder {
|
||||
}
|
||||
|
||||
public static function buildFromAssets(resource:String, ?key:String = null, ?links:Dynamic = null):Dynamic {
|
||||
var form:Dynamic = Json.parse(Assets.getText(resource));
|
||||
var form:Dynamic = getResource(resource);
|
||||
if (key != null) form = Reflect.field(form, key);
|
||||
return build(form, links);
|
||||
}
|
||||
|
||||
public static function fillFromAssets(object:Dynamic, resource:String, ?key:String = null, ?links:Dynamic = null):Void {
|
||||
var form:Dynamic = getResource(resource);
|
||||
if (key != null) form = Reflect.field(form, key);
|
||||
fill(object, form, links);
|
||||
}
|
||||
}
|
||||
|
||||
class GuiB {
|
||||
@@ -125,7 +139,7 @@ class GuiF {
|
||||
public function fill() {
|
||||
if (Reflect.hasField(data, "style")) {
|
||||
var style = Provider.get(IResources).styles.get(Reflect.field(data, "style"));
|
||||
for (key in Reflect.fields(style)) {
|
||||
for (key in Reflect.fields(style)) if (!Reflect.hasField(data, key)) {
|
||||
Reflect.setField(data, key, Reflect.field(style, key));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import flash.display.Graphics;
|
||||
class DrawUtil {
|
||||
|
||||
public static function draw(graphics:Graphics, image:BitmapData, rect:Rectangle, ?fillType:FillType = null, ?color:Int = -1, ?clear:Bool = true):Void {
|
||||
if (image == null) return;
|
||||
if (fillType == null) fillType = FillType.DEFAULT;
|
||||
if (clear) graphics.clear();
|
||||
if (color > -1) {
|
||||
|
||||
Reference in New Issue
Block a user