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

This commit is contained in:
Ram Yerrappa
2020-09-08 19:48:32 +05:30
committed by GitHub
parent bb712533e6
commit b84013719c
3 changed files with 34 additions and 2 deletions

View File

@@ -74,6 +74,10 @@
"light": "resources/light/icon_edit.svg",
"dark": "resources/dark/icon_edit.svg"
}
},
{
"command": "godot-tool.set_scene_file",
"title": "Set as Scene File"
}
],
"configuration": {
@@ -105,7 +109,12 @@
"default": "",
"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",
"default": "",
"description": "Check the gdscript language server connection status"
@@ -274,6 +283,12 @@
"when": "view == inspect-node && viewItem == editable_value",
"group": "inline"
}
],
"explorer/context": [
{
"command": "godot-tool.set_scene_file",
"group": "2_workspace"
}
]
}
},

View File

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

View File

@@ -30,6 +30,7 @@ export class GodotTools {
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.set_scene_file", this.set_scene_file.bind(this));
this.connection_status.text = "$(sync) Initializing";
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 = "") {
return new Promise((resolve, reject) => {