Skip to content

Add support for Godot 4.0 #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions GodotDebugSession/GodotDebugSession.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -79,7 +79,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="GodotTools.IdeMessaging" Version="1.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="MedallionShell" Version="1.6.2" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
129 changes: 99 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "C# Tools for Godot",
"description": "Debugger and utilities for working with Godot C# projects",
"icon": "icon.png",
"version": "0.2.1",
"version": "0.3.0",
"publisher": "neikeq",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -36,32 +36,34 @@
"webpack-watch": "webpack --mode development --watch"
},
"dependencies": {
"async-file": "^2.0.2",
"chokidar": "^3.4.0",
"fs-extra": "^10.0.0",
"jsonc-parser": "^3.0.0",
"lookpath": "^1.2.1",
"promise-socket": "^6.0.3",
"vscode-debugprotocol": "^1.40.0"
"async-file": "2.0.2",
"chokidar": "3.4.0",
"fs-extra": "10.0.0",
"jsonc-parser": "3.0.0",
"lookpath": "1.2.1",
"promise-socket": "6.0.3",
"semver": "^7.3.8",
"vscode-debugprotocol": "1.40.0"
},
"extensionDependencies": [
"ms-dotnettools.csharp",
"ms-vscode.mono-debug"
],
"devDependencies": {
"@types/fs-extra": "^9.0.12",
"@types/glob": "^7.1.1",
"@types/mocha": "^5.2.6",
"@types/node": "^16.4.1",
"@types/vscode": "^1.62.0",
"glob": "^7.1.4",
"mocha": "^6.1.4",
"ts-loader": "^7.0.5",
"tslint": "^5.12.1",
"typescript": "^3.3.1",
"vsce": "^1.20.0",
"webpack": "^5.70.0",
"webpack-cli": "^4.9.2"
"@types/fs-extra": "9.0.12",
"@types/glob": "7.1.1",
"@types/mocha": "5.2.6",
"@types/node": "16.4.1",
"@types/semver": "^7.3.13",
"@types/vscode": "1.62.0",
"glob": "7.1.4",
"mocha": "6.1.4",
"ts-loader": "7.0.5",
"tslint": "5.12.1",
"typescript": "3.9.10",
"vsce": "1.20.0",
"webpack": "5.70.0",
"webpack-cli": "4.9.2"
},
"breakpoints": [
{
Expand All @@ -78,7 +80,18 @@
"godot.csharp.executablePath": {
"type": "string",
"default": null,
"description": "Path to the Godot engine executable."
"description": "Path to the Godot 3 engine executable.",
"deprecationMessage": "Use godot3ExecutablePath instead."
},
"godot.csharp.godot3ExecutablePath": {
"type": "string",
"default": null,
"description": "Path to the Godot 3 engine executable."
},
"godot.csharp.godot4ExecutablePath": {
"type": "string",
"default": null,
"description": "Path to the Godot 4 engine executable."
}
}
},
Expand All @@ -105,7 +118,7 @@
"debuggers": [
{
"type": "godot-mono",
"label": "C# Godot",
"label": "C# Godot 3",
"languages": [
"csharp",
"fsharp"
Expand All @@ -122,8 +135,8 @@
},
"configurationSnippets": [
{
"label": "C# Godot: Play in Editor Configuration",
"description": "Launch a C# Godot App from the open editor with a debugger.",
"label": "C# Godot 3: Play in Editor Configuration",
"description": "Launch a C# Godot 3 App from the open editor with a debugger.",
"body": {
"name": "Play in Editor",
"type": "godot-mono",
Expand All @@ -132,8 +145,8 @@
}
},
{
"label": "C# Godot: Launch Configuration",
"description": "Launch a C# Godot App with a debugger.",
"label": "C# Godot 3: Launch Configuration",
"description": "Launch a C# Godot 3 App with a debugger.",
"body": {
"name": "Launch",
"type": "godot-mono",
Expand All @@ -148,8 +161,8 @@
}
},
{
"label": "C# Godot: Launch Configuration (Select Scene)",
"description": "Launch a C# Godot App with a debugger.",
"label": "C# Godot 3: Launch Configuration (Select Scene)",
"description": "Launch a C# Godot 3 App with a debugger.",
"body": {
"name": "Launch (Select Scene)",
"type": "godot-mono",
Expand All @@ -165,7 +178,7 @@
}
},
{
"label": "C# Godot: Attach Configuration",
"label": "C# Godot 3: Attach Configuration",
"description": "Attach a debugger to a C# Godot App.",
"body": {
"name": "Attach",
Expand Down Expand Up @@ -226,6 +239,62 @@
}
}
}
},
{
"type": "godot-dotnet",
"label": "C# Godot 4",
"languages": [
"csharp",
"fsharp"
],
"configurationSnippets": [
{
"label": "C# Godot 4: Launch Configuration",
"description": "Launch a C# Godot 4 App with a debugger.",
"body": {
"name": "Launch",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${1:<insert-godot-executable-path-here>}",
"args": [
"--path",
"${workspaceRoot}"
],
"cwd": "${workspaceRoot}",
"stopAtEntry": false,
"console": "internalConsole"
}
},
{
"label": "C# Godot 4: Launch Configuration (Select Scene)",
"description": "Launch a C# Godot 4 App with a debugger.",
"body": {
"name": "Launch (Select Scene)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${1:<insert-godot-executable-path-here>}",
"args": [
"--path",
"${workspaceRoot}",
"${command:godot.csharp.getLaunchScene}"
],
"cwd": "${workspaceRoot}",
"stopAtEntry": false,
"console": "internalConsole"
}
},
{
"label": "C# Godot 4: Attach Configuration",
"description": "Attach a debugger to a C# Godot 4 App.",
"body": {
"name": "Attach",
"type": "coreclr",
"request": "attach"
}
}
]
}
]
}
Expand Down
8 changes: 4 additions & 4 deletions src/assets-generator/assets-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ export class AssetsGenerator {
return new AssetsGenerator(vscodeFolder);
}

public async addTasksJsonIfNecessary(): Promise<void> {
return addTasksJsonIfNecessary(this.tasksJsonPath);
public async addTasksJsonIfNecessary(godotVersion: string): Promise<void> {
return addTasksJsonIfNecessary(this.tasksJsonPath, godotVersion);
}

public async addLaunchJsonIfNecessary(): Promise<void> {
return addLaunchJsonIfNecessary(this.launchJsonPath);
public async addLaunchJsonIfNecessary(godotVersion: string): Promise<void> {
return addLaunchJsonIfNecessary(this.launchJsonPath, godotVersion);
}

public async hasExistingAssets(): Promise<boolean> {
Expand Down
80 changes: 61 additions & 19 deletions src/assets-generator/debug.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import * as vscode from 'vscode';
import * as jsonc from 'jsonc-parser';
import * as fs from 'fs-extra';
import * as semver from 'semver';
import {getFormattingOptions, replaceCommentPropertiesWithComments, updateJsonWithComments} from '../json-utils';
import {findGodotExecutablePath} from '../godot-utils';
import {findGodotExecutablePath, GODOT_VERSION_3, GODOT_VERSION_4} from '../godot-utils';

export function createLaunchConfiguration(godotExecutablePath: string | undefined):
export function createLaunchConfiguration(godotExecutablePath: string | undefined, godotVersion: string):
{version: string, configurations: vscode.DebugConfiguration[]}
{
return {
version: '2.0.0',
configurations: _createDebugConfigurations(godotExecutablePath),
configurations: _createDebugConfigurations(godotExecutablePath, godotVersion),
};
}

export function createDebugConfigurationsArray(godotExecutablePath: string | undefined): vscode.DebugConfiguration[]
export function createDebugConfigurationsArray(godotExecutablePath: string | undefined, godotVersion: string): vscode.DebugConfiguration[]
{
const configurations = _createDebugConfigurations(godotExecutablePath);
const configurations = _createDebugConfigurations(godotExecutablePath, godotVersion);

// Remove comments
configurations.forEach(configuration => {
Expand All @@ -34,17 +35,27 @@ export function createDebugConfigurationsArray(godotExecutablePath: string | und
return configurations;
}

function _createDebugConfigurations(godotExecutablePath: string | undefined): vscode.DebugConfiguration[]
{
return [
createPlayInEditorDebugConfiguration(),
createLaunchDebugConfiguration(godotExecutablePath),
createLaunchDebugConfiguration(godotExecutablePath, true),
createAttachDebugConfiguration(),
];
function _createDebugConfigurations(godotExecutablePath: string | undefined, godotVersion: string): vscode.DebugConfiguration[] {
if (semver.intersects(godotVersion, GODOT_VERSION_3)) {
return [
createPlayInEditorDebugConfigurationForGodot3(),
createLaunchDebugConfigurationForGodot3(godotExecutablePath),
createLaunchDebugConfigurationForGodot3(godotExecutablePath, true),
createAttachDebugConfigurationForGodot3(),
];
} else if (semver.intersects(godotVersion, GODOT_VERSION_4)) {
return [
createLaunchDebugConfigurationForGodot4(godotExecutablePath),
createLaunchDebugConfigurationForGodot4(godotExecutablePath, true),
createAttachDebugConfigurationForGodot4(),
];
} else {
vscode.window.showErrorMessage('Cannot create C# Godot debug configurations. Godot version is unknown or unsupported.');
return [];
}
}

export function createPlayInEditorDebugConfiguration(): vscode.DebugConfiguration
export function createPlayInEditorDebugConfigurationForGodot3(): vscode.DebugConfiguration
{
return {
name: 'Play in Editor',
Expand All @@ -54,7 +65,7 @@ export function createPlayInEditorDebugConfiguration(): vscode.DebugConfiguratio
};
}

export function createLaunchDebugConfiguration(godotExecutablePath: string | undefined, canSelectScene: boolean = false): vscode.DebugConfiguration
export function createLaunchDebugConfigurationForGodot3(godotExecutablePath: string | undefined, canSelectScene: boolean = false): vscode.DebugConfiguration
{
godotExecutablePath = godotExecutablePath ?? '<insert-godot-executable-path-here>';
return {
Expand All @@ -67,14 +78,36 @@ export function createLaunchDebugConfiguration(godotExecutablePath: string | und
'OS-COMMENT1': 'See which arguments are available here:',
'OS-COMMENT2': 'https://docs.godotengine.org/en/stable/getting_started/editor/command_line_tutorial.html',
executableArguments: [
'--path',
'${workspaceRoot}',
...(canSelectScene ? ['${command:godot.csharp.getLaunchScene}'] : []),
],
};
}

export function createLaunchDebugConfigurationForGodot4(godotExecutablePath: string | undefined, canSelectScene: boolean = false): vscode.DebugConfiguration
{
godotExecutablePath = godotExecutablePath ?? '<insert-godot-executable-path-here>';
return {
name: `Launch${canSelectScene ? ' (Select Scene)' : ''}`,
type: 'coreclr',
request: 'launch',
preLaunchTask: 'build',
program: godotExecutablePath,
'OS-COMMENT1': 'See which arguments are available here:',
'OS-COMMENT2': 'https://docs.godotengine.org/en/stable/getting_started/editor/command_line_tutorial.html',
args: [
'--path',
'${workspaceRoot}',
...(canSelectScene ? ['${command:SelectLaunchScene}'] : []),
],
cwd: '${workspaceRoot}',
stopAtEntry: false,
console: 'internalConsole',
};
}

export function createAttachDebugConfiguration()
export function createAttachDebugConfigurationForGodot3()
{
return {
name: 'Attach',
Expand All @@ -85,10 +118,19 @@ export function createAttachDebugConfiguration()
};
}

export async function addLaunchJsonIfNecessary(launchJsonPath: string): Promise<void>
export function createAttachDebugConfigurationForGodot4()
{
return {
name: 'Attach',
type: 'coreclr',
request: 'attach',
};
}

export async function addLaunchJsonIfNecessary(launchJsonPath: string, godotVersion: string): Promise<void>
{
const godotExecutablePath = await findGodotExecutablePath();
const launchConfiguration = createLaunchConfiguration(godotExecutablePath);
const godotExecutablePath = await findGodotExecutablePath(godotVersion);
const launchConfiguration = createLaunchConfiguration(godotExecutablePath, godotVersion);

const formattingOptions = getFormattingOptions();

Expand Down
Loading