diff options
Diffstat (limited to 'modules/mono')
| -rw-r--r-- | modules/mono/csharp_script.cpp | 42 | ||||
| -rw-r--r-- | modules/mono/csharp_script.h | 2 | ||||
| -rw-r--r-- | modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs | 8 | ||||
| -rw-r--r-- | modules/mono/editor/GodotTools/GodotTools/Internals/Globals.cs | 6 | ||||
| -rw-r--r-- | modules/mono/editor/bindings_generator.cpp | 2 | ||||
| -rw-r--r-- | modules/mono/editor/code_completion.cpp | 4 | ||||
| -rw-r--r-- | modules/mono/editor/editor_internal_calls.cpp | 7 | ||||
| -rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs | 2 | 
8 files changed, 62 insertions, 11 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 3437dbd194..17846eb281 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -43,8 +43,10 @@  #include "core/os/thread.h"  #ifdef TOOLS_ENABLED +#include "core/os/keyboard.h"  #include "editor/bindings_generator.h"  #include "editor/editor_node.h" +#include "editor/editor_settings.h"  #include "editor/node_dock.h"  #endif @@ -1353,6 +1355,7 @@ void CSharpLanguage::_editor_init_callback() {  	// Enable it as a plugin  	EditorNode::add_editor_plugin(godotsharp_editor); +	ED_SHORTCUT("mono/build_solution", TTR("Build Solution"), KEY_MASK_ALT | KEY_B);  	godotsharp_editor->enable_plugin();  	get_singleton()->godotsharp_editor = godotsharp_editor; @@ -1861,6 +1864,28 @@ Variant::Type CSharpInstance::get_property_type(const StringName &p_name, bool *  	return Variant::NIL;  } +void CSharpInstance::get_method_list(List<MethodInfo> *p_list) const { +	if (!script->is_valid() || !script->script_class) +		return; + +	GD_MONO_SCOPE_THREAD_ATTACH; + +	// TODO: We're filtering out constructors but there may be other methods unsuitable for explicit calls. +	GDMonoClass *top = script->script_class; + +	while (top && top != script->native) { +		const Vector<GDMonoMethod *> &methods = top->get_all_methods(); +		for (int i = 0; i < methods.size(); ++i) { +			MethodInfo minfo = methods[i]->get_method_info(); +			if (minfo.name != CACHED_STRING_NAME(dotctor)) { +				p_list->push_back(minfo); +			} +		} + +		top = top->get_parent_class(); +	} +} +  bool CSharpInstance::has_method(const StringName &p_method) const {  	if (!script.is_valid()) {  		return false; @@ -3280,10 +3305,19 @@ void CSharpScript::get_script_method_list(List<MethodInfo> *p_list) const {  	GD_MONO_SCOPE_THREAD_ATTACH; -	// TODO: Filter out things unsuitable for explicit calls, like constructors. -	const Vector<GDMonoMethod *> &methods = script_class->get_all_methods(); -	for (int i = 0; i < methods.size(); ++i) { -		p_list->push_back(methods[i]->get_method_info()); +	// TODO: We're filtering out constructors but there may be other methods unsuitable for explicit calls. +	GDMonoClass *top = script_class; + +	while (top && top != native) { +		const Vector<GDMonoMethod *> &methods = top->get_all_methods(); +		for (int i = 0; i < methods.size(); ++i) { +			MethodInfo minfo = methods[i]->get_method_info(); +			if (minfo.name != CACHED_STRING_NAME(dotctor)) { +				p_list->push_back(methods[i]->get_method_info()); +			} +		} + +		top = top->get_parent_class();  	}  } diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h index e3bbb20dec..afc17f694a 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -293,7 +293,7 @@ public:  	void get_property_list(List<PropertyInfo> *p_properties) const override;  	Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid) const override; -	/* TODO */ void get_method_list(List<MethodInfo> *p_list) const override {} +	void get_method_list(List<MethodInfo> *p_list) const override;  	bool has_method(const StringName &p_method) const override;  	Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) override; diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs index 73cabf8561..98c6881166 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs +++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs @@ -418,11 +418,15 @@ namespace GodotTools              AddToolSubmenuItem("C#", _menuPopup); +            var buildSolutionShortcut = (Shortcut)EditorShortcut("mono/build_solution"); +              _toolBarBuildButton = new Button              {                  Text = "Build", -                HintTooltip = "Build solution", -                FocusMode = Control.FocusModeEnum.None +                HintTooltip = "Build Solution".TTR(), +                FocusMode = Control.FocusModeEnum.None, +                Shortcut = buildSolutionShortcut, +                ShortcutInTooltip = true              };              _toolBarBuildButton.PressedSignal += BuildSolutionPressed;              AddControlToContainer(CustomControlContainer.Toolbar, _toolBarBuildButton); diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/Globals.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/Globals.cs index 793f84fd77..5c5ced8c29 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Internals/Globals.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Internals/Globals.cs @@ -13,6 +13,9 @@ namespace GodotTools.Internals          public static object EditorDef(string setting, object defaultValue, bool restartIfChanged = false) =>              internal_EditorDef(setting, defaultValue, restartIfChanged); +        public static object EditorShortcut(string setting) => +            internal_EditorShortcut(setting); +          [SuppressMessage("ReSharper", "InconsistentNaming")]          public static string TTR(this string text) => internal_TTR(text); @@ -28,6 +31,9 @@ namespace GodotTools.Internals          private static extern object internal_EditorDef(string setting, object defaultValue, bool restartIfChanged);          [MethodImpl(MethodImplOptions.InternalCall)] +        private static extern object internal_EditorShortcut(string setting); + +        [MethodImpl(MethodImplOptions.InternalCall)]          private static extern string internal_TTR(string text);      }  } diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 67bcb34b1c..e03c5fd248 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -2610,7 +2610,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() {  		Map<StringName, StringName> accessor_methods;  		for (const PropertyInfo &property : property_list) { -			if (property.usage & PROPERTY_USAGE_GROUP || property.usage & PROPERTY_USAGE_SUBGROUP || property.usage & PROPERTY_USAGE_CATEGORY) { +			if (property.usage & PROPERTY_USAGE_GROUP || property.usage & PROPERTY_USAGE_SUBGROUP || property.usage & PROPERTY_USAGE_CATEGORY || (property.type == Variant::NIL && property.usage & PROPERTY_USAGE_ARRAY)) {  				continue;  			} diff --git a/modules/mono/editor/code_completion.cpp b/modules/mono/editor/code_completion.cpp index d911f6461c..7433c865f5 100644 --- a/modules/mono/editor/code_completion.cpp +++ b/modules/mono/editor/code_completion.cpp @@ -123,8 +123,8 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr  				// AutoLoads  				OrderedHashMap<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list(); -				for (const KeyValue<StringName, ProjectSettings::AutoloadInfo> &E : autoloads) { -					const ProjectSettings::AutoloadInfo &info = E.value; +				for (OrderedHashMap<StringName, ProjectSettings::AutoloadInfo>::Element E = autoloads.front(); E; E = E.next()) { +					const ProjectSettings::AutoloadInfo &info = E.value();  					suggestions.push_back(quoted("/root/" + String(info.name)));  				}  			} diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp index 6692a6efec..9a61b63c12 100644 --- a/modules/mono/editor/editor_internal_calls.cpp +++ b/modules/mono/editor/editor_internal_calls.cpp @@ -306,6 +306,12 @@ MonoObject *godot_icall_Globals_EditorDef(MonoString *p_setting, MonoObject *p_d  	return GDMonoMarshal::variant_to_mono_object(result);  } +MonoObject *godot_icall_Globals_EditorShortcut(MonoString *p_setting) { +	String setting = GDMonoMarshal::mono_string_to_godot(p_setting); +	Ref<Shortcut> result = ED_GET_SHORTCUT(setting); +	return GDMonoMarshal::variant_to_mono_object(result); +} +  MonoString *godot_icall_Globals_TTR(MonoString *p_text) {  	String text = GDMonoMarshal::mono_string_to_godot(p_text);  	return GDMonoMarshal::mono_string_from_godot(TTR(text)); @@ -380,6 +386,7 @@ void register_editor_internal_calls() {  	GDMonoUtils::add_internal_call("GodotTools.Internals.Globals::internal_EditorScale", godot_icall_Globals_EditorScale);  	GDMonoUtils::add_internal_call("GodotTools.Internals.Globals::internal_GlobalDef", godot_icall_Globals_GlobalDef);  	GDMonoUtils::add_internal_call("GodotTools.Internals.Globals::internal_EditorDef", godot_icall_Globals_EditorDef); +	GDMonoUtils::add_internal_call("GodotTools.Internals.Globals::internal_EditorShortcut", godot_icall_Globals_EditorShortcut);  	GDMonoUtils::add_internal_call("GodotTools.Internals.Globals::internal_TTR", godot_icall_Globals_TTR);  	// Utils.OS diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs index 53c02feaa2..ef42374041 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs @@ -376,7 +376,7 @@ namespace Godot          /// <example>          /// <code>          /// GD.Print(GD.RandRange(0, 1)); // Prints 0 or 1 -        /// GD.Print(GD.RangeRange(-10, 1000)); // Prints any number from -10 to 1000 +        /// GD.Print(GD.RandRange(-10, 1000)); // Prints any number from -10 to 1000          /// </code>          /// </example>          /// <returns>A random <see langword="int"/> number inside the given range.</returns>  |