summaryrefslogtreecommitdiff
path: root/modules/mono
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mono')
-rw-r--r--modules/mono/build_scripts/mono_reg_utils.py8
-rw-r--r--modules/mono/csharp_script.cpp4
-rw-r--r--modules/mono/csharp_script.h2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs25
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs6
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs2
-rw-r--r--modules/mono/editor/bindings_generator.cpp4
-rw-r--r--modules/mono/editor_templates/CharacterBody2D/basic_movement.cs4
-rw-r--r--modules/mono/editor_templates/CharacterBody3D/basic_movement.cs4
-rw-r--r--modules/mono/editor_templates/VisualShaderNodeCustom/basic.cs5
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs4
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs24
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs25
13 files changed, 64 insertions, 53 deletions
diff --git a/modules/mono/build_scripts/mono_reg_utils.py b/modules/mono/build_scripts/mono_reg_utils.py
index 93a66ebf6f..43c1ec8f8a 100644
--- a/modules/mono/build_scripts/mono_reg_utils.py
+++ b/modules/mono/build_scripts/mono_reg_utils.py
@@ -96,10 +96,10 @@ def find_msbuild_tools_path_reg():
raise ValueError("Cannot find `installationPath` entry")
except ValueError as e:
print("Error reading output from vswhere: " + e.message)
- except OSError:
- pass # Fine, vswhere not found
- except (subprocess.CalledProcessError, OSError):
- pass
+ except subprocess.CalledProcessError as e:
+ print(e.output)
+ except OSError as e:
+ print(e)
# Try to find 14.0 in the Registry
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 26436e3ec0..085ab9a467 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -3245,6 +3245,8 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) {
CRASH_COND(!valid);
#endif
+ GD_MONO_SCOPE_THREAD_ATTACH;
+
if (native) {
StringName native_name = NATIVE_GDMONOCLASS_NAME(native);
if (!ClassDB::is_parent_class(p_this->get_class_name(), native_name)) {
@@ -3257,8 +3259,6 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) {
}
}
- GD_MONO_SCOPE_THREAD_ATTACH;
-
Callable::CallError unchecked_error;
return _create_instance(nullptr, 0, p_this, Object::cast_to<RefCounted>(p_this) != nullptr, unchecked_error);
}
diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h
index 2be588cac4..2de923c125 100644
--- a/modules/mono/csharp_script.h
+++ b/modules/mono/csharp_script.h
@@ -103,8 +103,6 @@ private:
bool valid = false;
bool reload_invalidated = false;
- bool builtin;
-
GDMonoClass *base = nullptr;
GDMonoClass *native = nullptr;
GDMonoClass *script_class = nullptr;
diff --git a/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs b/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs
index ce2b378623..7a4641dbbc 100644
--- a/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs
+++ b/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs
@@ -47,9 +47,13 @@ namespace GodotTools.OpenVisualStudio
if (dte == null)
{
// Open a new instance
+ dte = TryVisualStudioLaunch("VisualStudio.DTE.17.0");
- var visualStudioDteType = Type.GetTypeFromProgID("VisualStudio.DTE.16.0", throwOnError: true);
- dte = (DTE)Activator.CreateInstance(visualStudioDteType);
+ if (dte == null)
+ {
+ // Launch of VS 2022 failed, fallback to 2019
+ dte = TryVisualStudioLaunch("VisualStudio.DTE.16.0");
+ }
dte.UserControl = true;
@@ -133,6 +137,21 @@ namespace GodotTools.OpenVisualStudio
return 0;
}
+ private static DTE TryVisualStudioLaunch(string version)
+ {
+ try
+ {
+ var visualStudioDteType = Type.GetTypeFromProgID(version, throwOnError: true);
+ var dte = (DTE)Activator.CreateInstance(visualStudioDteType);
+
+ return dte;
+ }
+ catch (COMException)
+ {
+ return null;
+ }
+ }
+
private static DTE FindInstanceEditingSolution(string solutionPath)
{
if (GetRunningObjectTable(0, out IRunningObjectTable pprot) != 0)
@@ -164,7 +183,7 @@ namespace GodotTools.OpenVisualStudio
continue;
// The digits after the colon are the process ID
- if (!Regex.IsMatch(ppszDisplayName, "!VisualStudio.DTE.16.0:[0-9]"))
+ if (!Regex.IsMatch(ppszDisplayName, "!VisualStudio.DTE.1[6-7].0:[0-9]"))
continue;
if (pprot.GetObject(moniker[0], out object ppunkObject) == 0)
diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs b/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs
index e9cf7911be..2dbc78ab77 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs
@@ -147,7 +147,7 @@ namespace GodotTools.Build
Icon = GetThemeIcon("StatusError", "EditorIcons"),
ExpandIcon = false,
ToggleMode = true,
- Pressed = true,
+ ButtonPressed = true,
FocusMode = FocusModeEnum.None
};
_errorsBtn.Toggled += ErrorsToggled;
@@ -159,7 +159,7 @@ namespace GodotTools.Build
Icon = GetThemeIcon("NodeWarning", "EditorIcons"),
ExpandIcon = false,
ToggleMode = true,
- Pressed = true,
+ ButtonPressed = true,
FocusMode = FocusModeEnum.None
};
_warningsBtn.Toggled += WarningsToggled;
@@ -169,7 +169,7 @@ namespace GodotTools.Build
{
Text = "Show Output".TTR(),
ToggleMode = true,
- Pressed = true,
+ ButtonPressed = true,
FocusMode = FocusModeEnum.None
};
_viewLogBtn.Toggled += ViewLogToggled;
diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
index 98c6881166..69960bdbeb 100644
--- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
@@ -428,7 +428,7 @@ namespace GodotTools
Shortcut = buildSolutionShortcut,
ShortcutInTooltip = true
};
- _toolBarBuildButton.PressedSignal += BuildSolutionPressed;
+ _toolBarBuildButton.Pressed += BuildSolutionPressed;
AddControlToContainer(CustomControlContainer.Toolbar, _toolBarBuildButton);
if (File.Exists(GodotSharpDirs.ProjectSlnPath) && File.Exists(GodotSharpDirs.ProjectCsProjPath))
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index 1b4ab0ef4b..1de41821f9 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -690,11 +690,11 @@ void BindingsGenerator::_apply_prefix_to_enum_constants(BindingsGenerator::EnumI
continue;
}
- if (parts[curr_prefix_length][0] >= '0' && parts[curr_prefix_length][0] <= '9') {
+ if (is_digit(parts[curr_prefix_length][0])) {
// The name of enum constants may begin with a numeric digit when strip from the enum prefix,
// so we make the prefix for this constant one word shorter in those cases.
for (curr_prefix_length = curr_prefix_length - 1; curr_prefix_length > 0; curr_prefix_length--) {
- if (parts[curr_prefix_length][0] < '0' || parts[curr_prefix_length][0] > '9') {
+ if (!is_digit(parts[curr_prefix_length][0])) {
break;
}
}
diff --git a/modules/mono/editor_templates/CharacterBody2D/basic_movement.cs b/modules/mono/editor_templates/CharacterBody2D/basic_movement.cs
index 6e9547ce9b..b0ded3133f 100644
--- a/modules/mono/editor_templates/CharacterBody2D/basic_movement.cs
+++ b/modules/mono/editor_templates/CharacterBody2D/basic_movement.cs
@@ -6,7 +6,7 @@ using System;
public partial class _CLASS_ : _BASE_
{
public const float Speed = 300.0f;
- public const float JumpForce = -400.0f;
+ public const float JumpVelocity = -400.0f;
// Get the gravity from the project settings to be synced with RigidDynamicBody nodes.
public float gravity = (float)ProjectSettings.GetSetting("physics/2d/default_gravity");
@@ -21,7 +21,7 @@ public partial class _CLASS_ : _BASE_
// Handle Jump.
if (Input.IsActionJustPressed("ui_accept") && IsOnFloor())
- motionVelocity.y = JumpForce;
+ motionVelocity.y = JumpVelocity;
// Get the input direction and handle the movement/deceleration.
// As good practice, you should replace UI actions with custom gameplay actions.
diff --git a/modules/mono/editor_templates/CharacterBody3D/basic_movement.cs b/modules/mono/editor_templates/CharacterBody3D/basic_movement.cs
index 13be4bbcb1..d8c2f67ac8 100644
--- a/modules/mono/editor_templates/CharacterBody3D/basic_movement.cs
+++ b/modules/mono/editor_templates/CharacterBody3D/basic_movement.cs
@@ -6,7 +6,7 @@ using System;
public partial class _CLASS_ : _BASE_
{
public const float Speed = 5.0f;
- public const float JumpForce = 4.5f;
+ public const float JumpVelocity = 4.5f;
// Get the gravity from the project settings to be synced with RigidDynamicBody nodes.
public float gravity = (float)ProjectSettings.GetSetting("physics/3d/default_gravity");
@@ -21,7 +21,7 @@ public partial class _CLASS_ : _BASE_
// Handle Jump.
if (Input.IsActionJustPressed("ui_accept") && IsOnFloor())
- motionVelocity.y = JumpForce;
+ motionVelocity.y = JumpVelocity;
// Get the input direction and handle the movement/deceleration.
// As good practice, you should replace UI actions with custom gameplay actions.
diff --git a/modules/mono/editor_templates/VisualShaderNodeCustom/basic.cs b/modules/mono/editor_templates/VisualShaderNodeCustom/basic.cs
index 00fdc9968e..a1b93e7daa 100644
--- a/modules/mono/editor_templates/VisualShaderNodeCustom/basic.cs
+++ b/modules/mono/editor_templates/VisualShaderNodeCustom/basic.cs
@@ -55,11 +55,6 @@ public partial class VisualShaderNode_CLASS_ : _BASE_
return 0;
}
- public override string _GetGlobalCode(Shader.Mode mode)
- {
- return "";
- }
-
public override string _GetCode(Godot.Collections.Array inputVars, Godot.Collections.Array outputVars, Shader.Mode mode, VisualShader.Type type)
{
return "";
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs
index a7ddcbb989..a1f058ffe5 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs
@@ -772,7 +772,7 @@ namespace Godot
/// <summary>
/// Check whether this string is a subsequence of the given string.
/// </summary>
- /// <seealso cref="IsSubsequenceOfI(string, string)"/>
+ /// <seealso cref="IsSubsequenceOfN(string, string)"/>
/// <param name="instance">The subsequence to search.</param>
/// <param name="text">The string that contains the subsequence.</param>
/// <param name="caseSensitive">If <see langword="true"/>, the check is case sensitive.</param>
@@ -824,7 +824,7 @@ namespace Godot
/// <param name="instance">The subsequence to search.</param>
/// <param name="text">The string that contains the subsequence.</param>
/// <returns>If the string is a subsequence of the given string.</returns>
- public static bool IsSubsequenceOfI(this string instance, string text)
+ public static bool IsSubsequenceOfN(this string instance, string text)
{
return instance.IsSubsequenceOf(text, caseSensitive: false);
}
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
index 1f5282e88f..fa7838633c 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
@@ -512,24 +512,24 @@ namespace Godot
/// Returns the result of the spherical linear interpolation between
/// this vector and <paramref name="to"/> by amount <paramref name="weight"/>.
///
- /// Note: Both vectors must be normalized.
+ /// This method also handles interpolating the lengths if the input vectors have different lengths.
+ /// For the special case of one or both input vectors having zero length, this method behaves like [method lerp].
/// </summary>
- /// <param name="to">The destination vector for interpolation. Must be normalized.</param>
+ /// <param name="to">The destination vector for interpolation.</param>
/// <param name="weight">A value on the range of 0.0 to 1.0, representing the amount of interpolation.</param>
/// <returns>The resulting vector of the interpolation.</returns>
public Vector2 Slerp(Vector2 to, real_t weight)
{
-#if DEBUG
- if (!IsNormalized())
- {
- throw new InvalidOperationException("Vector2.Slerp: From vector is not normalized.");
+ real_t startLengthSquared = LengthSquared();
+ real_t endLengthSquared = to.LengthSquared();
+ if (startLengthSquared == 0.0 || endLengthSquared == 0.0) {
+ // Zero length vectors have no angle, so the best we can do is either lerp or throw an error.
+ return Lerp(to, weight);
}
- if (!to.IsNormalized())
- {
- throw new InvalidOperationException($"Vector2.Slerp: `{nameof(to)}` is not normalized.");
- }
-#endif
- return Rotated(AngleTo(to) * weight);
+ real_t startLength = Mathf.Sqrt(startLengthSquared);
+ real_t resultLength = Mathf.Lerp(startLength, Mathf.Sqrt(endLengthSquared), weight);
+ real_t angle = AngleTo(to);
+ return Rotated(angle * weight) * (resultLength / startLength);
}
/// <summary>
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
index 433a5d9dc9..0faf13f8b7 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
@@ -549,25 +549,24 @@ namespace Godot
/// Returns the result of the spherical linear interpolation between
/// this vector and <paramref name="to"/> by amount <paramref name="weight"/>.
///
- /// Note: Both vectors must be normalized.
+ /// This method also handles interpolating the lengths if the input vectors have different lengths.
+ /// For the special case of one or both input vectors having zero length, this method behaves like [method lerp].
/// </summary>
- /// <param name="to">The destination vector for interpolation. Must be normalized.</param>
+ /// <param name="to">The destination vector for interpolation.</param>
/// <param name="weight">A value on the range of 0.0 to 1.0, representing the amount of interpolation.</param>
/// <returns>The resulting vector of the interpolation.</returns>
public Vector3 Slerp(Vector3 to, real_t weight)
{
-#if DEBUG
- if (!IsNormalized())
- {
- throw new InvalidOperationException("Vector3.Slerp: From vector is not normalized.");
+ real_t startLengthSquared = LengthSquared();
+ real_t endLengthSquared = to.LengthSquared();
+ if (startLengthSquared == 0.0 || endLengthSquared == 0.0) {
+ // Zero length vectors have no angle, so the best we can do is either lerp or throw an error.
+ return Lerp(to, weight);
}
- if (!to.IsNormalized())
- {
- throw new InvalidOperationException($"Vector3.Slerp: `{nameof(to)}` is not normalized.");
- }
-#endif
- real_t theta = AngleTo(to);
- return Rotated(Cross(to), theta * weight);
+ real_t startLength = Mathf.Sqrt(startLengthSquared);
+ real_t resultLength = Mathf.Lerp(startLength, Mathf.Sqrt(endLengthSquared), weight);
+ real_t angle = AngleTo(to);
+ return Rotated(Cross(to).Normalized(), angle * weight) * (resultLength / startLength);
}
/// <summary>