resmap: added method merge
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
package haxework.resources;
|
package haxework.resources;
|
||||||
|
|
||||||
|
import haxework.resources.Resources.ResMap;
|
||||||
import flash.display.BitmapData;
|
import flash.display.BitmapData;
|
||||||
|
|
||||||
interface IResources {
|
interface IResources {
|
||||||
public var image(default, null):Map<String, BitmapData>;
|
public var image(default, null):ResMap<BitmapData>;
|
||||||
public var color(default, null):Map<String, Int>;
|
public var color(default, null):ResMap<Int>;
|
||||||
}
|
}
|
||||||
@@ -35,12 +35,18 @@ class ResMap<T> extends StringMap<T> {
|
|||||||
private function call(field:F, value:T):Void {
|
private function call(field:F, value:T):Void {
|
||||||
Reflect.setProperty(field.first, field.second, value);
|
Reflect.setProperty(field.first, field.second, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function merge(value:Dynamic<T>):Void {
|
||||||
|
for (field in Reflect.fields(value)) {
|
||||||
|
set(field, Reflect.field(value, field));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Resources implements IResources {
|
class Resources implements IResources {
|
||||||
|
|
||||||
public var image(default, null):Map<String, BitmapData>;
|
public var image(default, null):ResMap<BitmapData>;
|
||||||
public var color(default, null):Map<String, Int>;
|
public var color(default, null):ResMap<Int>;
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
image = new ResMap<BitmapData>();
|
image = new ResMap<BitmapData>();
|
||||||
|
|||||||
Reference in New Issue
Block a user