2
0
Эх сурвалжийг харах

reverts commit 42a9857b2f316bab60d6b6a6cc08ec6a92cd61b7.

ncannasse 6 жил өмнө
parent
commit
9ecebf8fa5

+ 0 - 1
hide.hxml

@@ -1,5 +1,4 @@
 common.hxml
--D isIDE
 -js bin/hide.js
 -main hide.Ide
 --macro include("h3d.shader")

+ 1 - 10
hide/Ide.hx

@@ -1,15 +1,8 @@
 package hide;
 import hxd.inspect.Group;
 
-#if !isIDE
-// forbid access to Ide.inst when not compiled with -D isIDE
-// plugins should not access directly to hide.Ide!
-abstract ShouldNotAccess(Int) {}
-class Ide { public static var inst(get,never) : ShouldNotAccess; }
-#else
-
 @:expose
-class Ide implements hide.prefab.EditContext.IdeApi {
+class Ide {
 
 	public var currentConfig(get,never) : Config;
 	public var projectDir(get,never) : String;
@@ -985,5 +978,3 @@ class CustomLoader extends hxd.res.Loader {
 	}
 
 }
-
-#end

+ 2 - 11
hide/prefab/EditContext.hx

@@ -1,14 +1,5 @@
 package hide.prefab;
 
-interface IdeApi {
-	function getPath( relPath : String ) : String;
-	function makeRelative( path : String ) : String;
-	function error( message : String ) : Void;
-	function chooseFileSave( fileName : String, callb : Null<String> -> Void ) : Void;
-	function parseJSON( jsonStr : String ) : Dynamic;
-	function toJSON( obj : Dynamic ) : String;
-}
-
 class EditContext {
 
 	public var rootContext : Context;
@@ -18,11 +9,11 @@ class EditContext {
 	var updates : Array<Float->Void> = [];
 
 	public var prefabPath : String;
-	public var ide(get,never) : IdeApi;
+	public var ide(get,never) : hide.Ide;
 	public var scene : hide.comp.Scene;
 	public var properties : hide.comp.PropsEditor;
 	public var cleanups : Array<Void->Void>;
-	function get_ide() return #if isIDE hide.Ide.inst #else throw "assert" #end;
+	function get_ide() return hide.Ide.inst;
 	public function onChange(p : Prefab, propName : String) {
 		var ctx = getContext(p);
 		if(ctx != null) {

+ 5 - 6
hide/prefab/Settings.hx

@@ -52,14 +52,13 @@ class Settings extends Prefab {
 			</dl>
 			<br/>
 		'),this);
-		var typesCache = hide.Ide.inst.typesCache; // direct reference (not in API)
 		var select = props.find("select");
-		var models = typesCache.getModels();
+		var models = ctx.ide.typesCache.getModels();
 		for( m in models )
-			new hide.Element('<option>').attr("value", m.id).text(typesCache.getModelName(m)).appendTo(select);
+			new hide.Element('<option>').attr("value", m.id).text(ctx.ide.typesCache.getModelName(m)).appendTo(select);
 		var modelDef = null;
 		if( modelType != null ) {
-			modelDef = typesCache.get(modelType, true);
+			modelDef = ctx.ide.typesCache.get(modelType, true);
 			if( modelDef == null )
 				new hide.Element('<option>').attr("value", modelType).text("?"+modelType).appendTo(select);
 			select.val(modelType);
@@ -105,8 +104,8 @@ class Settings extends Prefab {
 
 		ctx.properties.addProps(modelDef.fields, this.data);
 		var rebuild = ctx.rebuildProperties;
-		typesCache.watch(rebuild);
-		ctx.cleanups.push(typesCache.unwatch.bind(rebuild));
+		ctx.ide.typesCache.watch(rebuild);
+		ctx.cleanups.push(ctx.ide.typesCache.unwatch.bind(rebuild));
 	}
 
 	#end

+ 1 - 1
hide/prefab/Shader.hx

@@ -75,7 +75,7 @@ class Shader extends Prefab {
 	}
 
 	function fixSourcePath() {
-		#if isIDE
+		#if editor
 		var ide = hide.Ide.inst;
 		var shadersPath = ide.projectDir + "/src";  // TODO: serach in haxe.classPath?