Pārlūkot izejas kodu

allow multiple keys for huds

Nicolas Cannasse 4 gadi atpakaļ
vecāks
revīzija
87bbf8aee4
2 mainītis faili ar 15 papildinājumiem un 4 dzēšanām
  1. 12 1
      hide/Ide.hx
  2. 3 3
      hrt/prefab/Object3D.hx

+ 12 - 1
hide/Ide.hx

@@ -494,7 +494,18 @@ class Ide {
 		return resourceDir+"/"+relPath;
 		return resourceDir+"/"+relPath;
 	}
 	}
 
 
-	public function resolveCDBValue( path : String, obj : Dynamic ) : Dynamic {
+	public function resolveCDBValue( path : String, key : Dynamic, obj : Dynamic ) : Dynamic {
+
+		// allow Array as key (first choice)
+		if( Std.is(key,Array) ) {
+			for( v in (key:Array<Dynamic>) ) {
+				var value = resolveCDBValue(path, v, obj);
+				if( value != null ) return value;
+			}
+			return null;
+		}
+		path += "."+key;
+
 		var path = path.split(".");
 		var path = path.split(".");
 		var sheet = database.getSheet(path.shift());
 		var sheet = database.getSheet(path.shift());
 		if( sheet == null )
 		if( sheet == null )

+ 3 - 3
hrt/prefab/Object3D.hx

@@ -183,7 +183,7 @@ class Object3D extends Prefab {
 				if( ranges != null ) {
 				if( ranges != null ) {
 					for( key in Reflect.fields(ranges) ) {
 					for( key in Reflect.fields(ranges) ) {
 						var color = Std.parseInt(Reflect.field(ranges,key));
 						var color = Std.parseInt(Reflect.field(ranges,key));
-						var value : Dynamic = ide.resolveCDBValue(sheet+"."+key, props);
+						var value : Dynamic = ide.resolveCDBValue(sheet,key, props);
 						if( value != null ) {
 						if( value != null ) {
 							var mesh = new h3d.scene.Mesh(h3d.prim.Cylinder.defaultUnitCylinder(128), ctx.local3d);
 							var mesh = new h3d.scene.Mesh(h3d.prim.Cylinder.defaultUnitCylinder(128), ctx.local3d);
 							mesh.name = "$UI.RANGE";
 							mesh.name = "$UI.RANGE";
@@ -200,9 +200,9 @@ class Object3D extends Prefab {
 						}
 						}
 					}
 					}
 				}
 				}
-				var icon : String = Reflect.field(shared.scene.config.get("sceneeditor.huds"), sheet);
+				var icon = Reflect.field(shared.scene.config.get("sceneeditor.huds"), sheet);
 				if( icon != null ) {
 				if( icon != null ) {
-					var t : Dynamic = ide.resolveCDBValue(sheet+"."+icon, props);
+					var t : Dynamic = ide.resolveCDBValue(sheet,icon, props);
 					if( t != null && (t.file != null || Std.is(t,String)) ) {
 					if( t != null && (t.file != null || Std.is(t,String)) ) {
 						var obj = Std.downcast(ctx.local2d, h2d.ObjectFollower);
 						var obj = Std.downcast(ctx.local2d, h2d.ObjectFollower);
 						if( obj == null || obj.follow != ctx.local3d ) {
 						if( obj == null || obj.follow != ctx.local3d ) {