Browse Source

Add ability for user to set scene file on right click in explorer (#182)

Ram Yerrappa 5 years ago
parent
commit
b84013719c
3 changed files with 34 additions and 2 deletions
  1. 16 1
      package.json
  2. 3 1
      src/debugger/debug_session.ts
  3. 15 0
      src/godot-tools.ts

+ 16 - 1
package.json

@@ -74,6 +74,10 @@
 					"light": "resources/light/icon_edit.svg",
 					"light": "resources/light/icon_edit.svg",
 					"dark": "resources/dark/icon_edit.svg"
 					"dark": "resources/dark/icon_edit.svg"
 				}
 				}
+			},
+			{
+				"command": "godot-tool.set_scene_file",
+				"title": "Set as Scene File"
 			}
 			}
 		],
 		],
 		"configuration": {
 		"configuration": {
@@ -105,7 +109,12 @@
 					"default": "",
 					"default": "",
 					"description": "The absolute path to the Godot editor executable"
 					"description": "The absolute path to the Godot editor executable"
 				},
 				},
-				"godot-tool.check_status": {
+				"godot_tools.scene_file_config": {
+					"type": "string",
+					"default": "",
+					"description": "The scene file to run"
+				},
+				"godot-tools.check_status": {
 					"type": "string",
 					"type": "string",
 					"default": "",
 					"default": "",
 					"description": "Check the gdscript language server connection status"
 					"description": "Check the gdscript language server connection status"
@@ -274,6 +283,12 @@
 					"when": "view == inspect-node && viewItem == editable_value",
 					"when": "view == inspect-node && viewItem == editable_value",
 					"group": "inline"
 					"group": "inline"
 				}
 				}
+			],
+			"explorer/context": [
+				{
+					"command": "godot-tool.set_scene_file",
+					"group": "2_workspace"
+				}
 			]
 			]
 		}
 		}
 	},
 	},

+ 3 - 1
src/debugger/debug_session.ts

@@ -13,6 +13,7 @@ import { ServerController } from "./server_controller";
 const { Subject } = require("await-notify");
 const { Subject } = require("await-notify");
 import fs = require("fs");
 import fs = require("fs");
 import { SceneTreeProvider } from "./scene_tree/scene_tree_provider";
 import { SceneTreeProvider } from "./scene_tree/scene_tree_provider";
+import { get_configuration } from "../utils";
 
 
 interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments {
 interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments {
 	address: string;
 	address: string;
@@ -233,8 +234,9 @@ export class GodotDebugSession extends LoggingDebugSession {
 			args.port,
 			args.port,
 			args.launch_game_instance,
 			args.launch_game_instance,
 			args.launch_scene,
 			args.launch_scene,
-			args.scene_file,
+			get_configuration("scene_file_config", "") || args.scene_file,
 		]);
 		]);
+		
 		this.sendResponse(response);
 		this.sendResponse(response);
 	}
 	}
 
 

+ 15 - 0
src/godot-tools.ts

@@ -30,6 +30,7 @@ export class GodotTools {
 			this.open_workspace_with_editor().catch(err=>vscode.window.showErrorMessage(err));
 			this.open_workspace_with_editor().catch(err=>vscode.window.showErrorMessage(err));
 		});
 		});
 		vscode.commands.registerCommand("godot-tool.check_status", this.check_client_status.bind(this));
 		vscode.commands.registerCommand("godot-tool.check_status", this.check_client_status.bind(this));
+		vscode.commands.registerCommand("godot-tool.set_scene_file", this.set_scene_file.bind(this));
 
 
 		this.connection_status.text = "$(sync) Initializing";
 		this.connection_status.text = "$(sync) Initializing";
 		this.connection_status.command = "godot-tool.check_status";
 		this.connection_status.command = "godot-tool.check_status";
@@ -62,6 +63,20 @@ export class GodotTools {
 		});
 		});
 	}
 	}
 
 
+	private set_scene_file(uri: vscode.Uri) {
+		let right_clicked_scene_path = uri.fsPath
+		let scene_config = get_configuration("scene_file_config");
+		if (scene_config == right_clicked_scene_path) {
+			scene_config = ""
+		}
+		else {
+			scene_config = right_clicked_scene_path
+		}
+		
+		set_configuration("scene_file_config", scene_config);
+	}
+
+
 	private run_editor(params = "") {
 	private run_editor(params = "") {
 
 
 		return new Promise((resolve, reject) => {
 		return new Promise((resolve, reject) => {