Add option to run the project with visible collision shapes and navigation (#312)

Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
This commit is contained in:
Anton Vakhtel
2022-04-07 10:27:13 +10:00
committed by GitHub
parent 4ac06a7691
commit 547b92ad80
4 changed files with 56 additions and 30 deletions

View File

@@ -47,6 +47,10 @@
"command": "godot-tool.run_project",
"title": "Godot Tools: Run workspace as Godot project"
},
{
"command": "godot-tool.run_project_debug",
"title": "Godot Tools: Run workspace as Godot project with visible collision shapes and navigation meshes"
},
{
"command": "godot-tool.list_native_classes",
"title": "Godot Tools: List native classes of godot"
@@ -141,6 +145,16 @@
"type": "number",
"default": 10,
"description": "How many times the client will attempt to reconnect"
},
"godot_tools.force_visible_collision_shapes": {
"type": "boolean",
"default": false,
"description": "Force the project to run with visible collision shapes"
},
"godot_tools.force_visible_nav_mesh": {
"type": "boolean",
"default": false,
"description": "Force the project to run with visible navigation meshes"
}
}
},

View File

@@ -98,7 +98,17 @@ export class ServerController {
if (launch_instance) {
let godot_path: string = utils.get_configuration("editor_path", "godot");
let executable_line = `"${godot_path}" --path "${project_path}" --remote-debug ${address}:${port}`;
const force_visible_collision_shapes = utils.get_configuration("force_visible_collision_shapes", false);
const force_visible_nav_mesh = utils.get_configuration("force_visible_nav_mesh", false);
let visible_collision_shapes_param = "";
let visible_nav_mesh_param = "";
if (force_visible_collision_shapes) {
visible_collision_shapes_param = " --debug-collisions";
}
if (force_visible_nav_mesh) {
visible_nav_mesh_param = " --debug-navigation";
}
let executable_line = `"${godot_path}" --path "${project_path}" --remote-debug ${address}:${port}""${visible_collision_shapes_param}""${visible_nav_mesh_param}`;
if (launch_scene) {
let filename = "";
if (scene_file) {
@@ -266,9 +276,8 @@ export class ServerController {
if (breakpoints.length > 0) {
output += " --breakpoints ";
breakpoints.forEach((bp, i) => {
output += `${this.breakpoint_path(project_path, bp.file)}:${bp.line}${
i < breakpoints.length - 1 ? "," : ""
}`;
output += `${this.breakpoint_path(project_path, bp.file)}:${bp.line}${i < breakpoints.length - 1 ? "," : ""
}`;
});
}

View File

@@ -11,7 +11,7 @@ export function activate(context: ExtensionContext) {
}
export function deactivate(): Thenable<void> {
return new Promise((resolve, reject) => {
return new Promise<void>((resolve, reject) => {
tools.deactivate();
resolve();
});

View File

@@ -27,11 +27,14 @@ export class GodotTools {
}
public activate() {
vscode.commands.registerCommand("godot-tool.open_editor", ()=>{
this.open_workspace_with_editor("-e").catch(err=>vscode.window.showErrorMessage(err));
vscode.commands.registerCommand("godot-tool.open_editor", () => {
this.open_workspace_with_editor("-e").catch(err => vscode.window.showErrorMessage(err));
});
vscode.commands.registerCommand("godot-tool.run_project", ()=>{
this.open_workspace_with_editor().catch(err=>vscode.window.showErrorMessage(err));
vscode.commands.registerCommand("godot-tool.run_project", () => {
this.open_workspace_with_editor().catch(err => vscode.window.showErrorMessage(err));
});
vscode.commands.registerCommand("godot-tool.run_project_debug", () => {
this.open_workspace_with_editor("--debug-collisions --debug-navigation").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));
@@ -39,7 +42,7 @@ export class GodotTools {
this.connection_status.text = "$(sync) Initializing";
this.connection_status.command = "godot-tool.check_status";
this.connection_status.show();
this.reconnection_attempts = 0;
this.client.connect_to_server();
}
@@ -57,7 +60,7 @@ export class GodotTools {
valid = (fs.existsSync(cfg) && fs.statSync(cfg).isFile());
}
if (valid) {
this.run_editor(`--path "${this.workspace_dir}" ${params}`).then(()=>resolve()).catch(err=>{
this.run_editor(`--path "${this.workspace_dir}" ${params}`).then(() => resolve()).catch(err => {
reject(err);
});
} else {
@@ -75,7 +78,7 @@ export class GodotTools {
else {
scene_config = right_clicked_scene_path
}
set_configuration("scene_file_config", scene_config);
}
@@ -86,13 +89,13 @@ export class GodotTools {
const is_powershell_path = (path?: string) => {
const POWERSHELL = "powershell.exe";
const POWERSHELL_CORE = "pwsh.exe";
return path && (path.endsWith(POWERSHELL) || path.endsWith(POWERSHELL_CORE));
return path && (path.endsWith(POWERSHELL) || path.endsWith(POWERSHELL_CORE));
};
const escape_command = (cmd: string) => {
const cmdEsc = `"${cmd}"`;
if (process.platform === "win32") {
const shell_plugin = vscode.workspace.getConfiguration("terminal.integrated.shell");
if (shell_plugin) {
const shell = shell_plugin.get<string>("windows");
if (shell) {
@@ -103,7 +106,7 @@ export class GodotTools {
}
}
}
const POWERSHELL_SOURCE = "PowerShell"
const default_profile = vscode.workspace.getConfiguration("terminal.integrated.defaultProfile");
if (default_profile) {
@@ -113,7 +116,7 @@ export class GodotTools {
return `&${cmdEsc}`;
}
const profiles = vscode.workspace.getConfiguration("terminal.integrated.profiles.windows");
const profile = profiles.get<{source?: string, path?: string}>(profile_name);
const profile = profiles.get<{ source?: string, path?: string }>(profile_name);
if (profile) {
if (POWERSHELL_SOURCE === profile.source || is_powershell_path(profile.path)) {
return `&${cmdEsc}`;
@@ -145,19 +148,19 @@ export class GodotTools {
editorPath = editorPath.replace("${workspaceRoot}", this.workspace_dir);
if (!fs.existsSync(editorPath) || !fs.statSync(editorPath).isFile()) {
vscode.window.showOpenDialog({
openLabel: "Run",
filters: process.platform === "win32" ? {"Godot Editor Binary": ["exe", "EXE"]} : undefined
}).then((uris: vscode.Uri[])=> {
if (!uris) {
return;
}
let path = uris[0].fsPath;
if (!fs.existsSync(path) || !fs.statSync(path).isFile()) {
reject("Invalid editor path to run the project");
} else {
run_godot(path, params);
set_configuration("editor_path", path);
}
openLabel: "Run",
filters: process.platform === "win32" ? { "Godot Editor Binary": ["exe", "EXE"] } : undefined
}).then((uris: vscode.Uri[]) => {
if (!uris) {
return;
}
let path = uris[0].fsPath;
if (!fs.existsSync(path) || !fs.statSync(path).isFile()) {
reject("Invalid editor path to run the project");
} else {
run_godot(path, params);
set_configuration("editor_path", path);
}
});
} else {
run_godot(editorPath, params);
@@ -244,7 +247,7 @@ export class GodotTools {
this.client.connect_to_server();
} else if (item == 'Open Godot Editor') {
this.client.status = ClientStatus.PENDING;
this.open_workspace_with_editor("-e").then(()=>{
this.open_workspace_with_editor("-e").then(() => {
setTimeout(() => {
this.reconnection_attempts = 0;
this.client.connect_to_server();