浏览代码

allow startup Hide as either CDB/HIDE mode

Nicolas Cannasse 6 年之前
父节点
当前提交
28422f6ea3
共有 5 个文件被更改,包括 25 次插入9 次删除
  1. 11 2
      .vscode/launch.json
  2. 二进制
      bin/res/cdb.ico
  3. 二进制
      bin/res/cdb.png
  4. 13 6
      hide/Ide.hx
  5. 1 1
      hide/ui/View.hx

+ 11 - 2
.vscode/launch.json

@@ -7,15 +7,24 @@
         {
             "type": "nwjs",
             "request": "launch",
-            "name": "Launch NWjs",
+            "name": "Launch HIDE",
             "nwjsVersion": "any",
             "webRoot": "${workspaceFolder}/bin",
             "preLaunchTask": "Build"
         },
+        {
+            "type": "nwjs",
+            "request": "launch",
+            "name": "Launch CDB",
+            "nwjsVersion": "any",
+            "webRoot": "${workspaceFolder}/bin",
+            "env": {"HIDE_START_CDB":"1"},
+            "preLaunchTask": "Build"
+        },
         {
             "type": "nwjs",
             "request": "attach",
-            "name": "Attach to NWjs",
+            "name": "Attach to HIDE",
             "port": 9222,
             "webRoot": "${workspaceFolder}/bin",
             "preLaunchTask": "Build"

二进制
bin/res/cdb.ico


二进制
bin/res/cdb.png


+ 13 - 6
hide/Ide.hx

@@ -21,6 +21,7 @@ class Ide {
 	public var shaderLoader : hide.tools.ShaderLoader;
 	public var fileWatcher : hide.tools.FileWatcher;
 	public var typesCache : hide.tools.TypesCache;
+	public var isCDB = false;
 
 	var databaseFile : String;
 
@@ -51,6 +52,7 @@ class Ide {
 	static var firstInit = true;
 
 	function new() {
+		isCDB = Sys.getEnv("HIDE_START_CDB") == "1";
 		function wait() {
 			if( monaco.Editor == null ) {
 				haxe.Timer.delay(wait, 10);
@@ -261,15 +263,16 @@ class Ide {
 		}
 
 		defaultLayout = null;
+		var layoutName = isCDB ? "CDB" : "Default";
 		var emptyLayout : Config.LayoutState = { content : [], fullScreen : null };
 		for( p in config.current.current.hide.layouts )
-			if( p.name == "Default" ) {
+			if( p.name == layoutName ) {
 				if( p.state.content == null ) continue; // old version
 				defaultLayout = p;
 				break;
 			}
 		if( defaultLayout == null ) {
-			defaultLayout = { name : "Default", state : emptyLayout };
+			defaultLayout = { name : layoutName, state : emptyLayout };
 			ideConfig.layouts.push(defaultLayout);
 			config.current.sync();
 			config.global.save();
@@ -336,8 +339,12 @@ class Ide {
 				}
 			}
 			initializing = false;
-			if( subView == null && views.length == 0 )
-				open("hide.view.FileTree",{path:""});
+			if( subView == null && views.length == 0 ) {
+				if( isCDB )
+					open("hide.view.CdbTable",{path:null}, function(v) v.fullScreen = true);
+				else
+					open("hide.view.FileTree",{path:""});
+			}
 			if( firstInit ) {
 				firstInit = false;
 				for( file in nw.App.argv ) {
@@ -379,7 +386,7 @@ class Ide {
 	}
 
 	function onLayoutChanged() {
-		if( initializing || !ideConfig.autoSaveLayout )
+		if( initializing || !ideConfig.autoSaveLayout || isCDB )
 			return;
 		defaultLayout.state = saveLayout();
 		if( subView == null ) this.config.global.save();
@@ -469,7 +476,7 @@ class Ide {
 			if( ideConfig.recentProjects.length > 10 ) ideConfig.recentProjects.pop();
 			config.global.save();
 		}
-		window.title = "HIDE - " + dir;
+		window.title = (isCDB ? "CastleDB" : "HIDE") + " - " + dir;
 		config = Config.loadForProject(projectDir, resourceDir);
 		shaderLoader = new hide.tools.ShaderLoader();
 		typesCache = new hide.tools.TypesCache();

+ 1 - 1
hide/ui/View.hx

@@ -234,7 +234,7 @@ class View<T> extends hide.comp.Component {
 			new Element("body").toggleClass("fullScreenMode",v);
 		}
 		@:privateAccess if( v ) ide.currentFullScreen = this else ide.currentFullScreen = null;
-		ide.setFullscreen(v);
+		if( !ide.isCDB ) ide.setFullscreen(v);
 		return v;
 	}