diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdscript/doc_classes/@GDScript.xml | 42 | ||||
-rw-r--r-- | modules/gdscript/gdscript_functions.cpp | 2 | ||||
-rw-r--r-- | modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs | 2 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/StringExtensions.cs | 38 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono.cpp | 14 | ||||
-rw-r--r-- | modules/visual_script/visual_script_editor.cpp | 8 |
6 files changed, 67 insertions, 39 deletions
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 502a68cd61..c4b7e4887e 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -168,14 +168,16 @@ <method name="char"> <return type="String"> </return> - <argument index="0" name="ascii" type="int"> + <argument index="0" name="code" type="int"> </argument> <description> - Returns a character as a String of the given ASCII code. + Returns a character as a String of the given Unicode code point (which is compatible with ASCII code). [codeblock] a = char(65) # a is "A" a = char(65 + 32) # a is "a" + a = char(8364) # a is "€" [/codeblock] + This is the inverse of [method ord]. </description> </method> <method name="clamp"> @@ -702,6 +704,13 @@ <argument index="0" name="char" type="String"> </argument> <description> + Returns an integer representing the Unicode code point of the given Unicode character [code]char[/code]. + [codeblock] + a = ord("A") # a is 65 + a = ord("a") # a is 97 + a = ord("€") # a is 8364 + [/codeblock] + This is the inverse of [method char]. </description> </method> <method name="parse_json"> @@ -937,7 +946,7 @@ <return type="int"> </return> <description> - Returns a random unsigned 32 bit integer. Use remainder to obtain a random value in the interval [code][0, N][/code] (where N is smaller than 2^32 -1). + Returns a random unsigned 32 bit integer. Use remainder to obtain a random value in the interval [code][0, N - 1][/code] (where N is smaller than 2^32). [codeblock] randi() # Returns random integer between 0 and 2^32 - 1 randi() % 20 # Returns random integer between 0 and 19 @@ -1368,23 +1377,26 @@ You can also use [code]yield[/code] to wait for a function to finish: [codeblock] func _ready(): - yield(do_something(), "completed") - yield(do_something_else(), "completed") - print("All functions are done!") - - func do_something(): - print("Something is done!") + yield(countdown(), "completed") # waiting for the countdown() function to complete + print('Ready') - func do_something_else(): - print("Something else is done!") + func countdown(): + yield(get_tree(), "idle_frame") # returns a GDScriptFunctionState object to _ready() + print(3) + yield(get_tree().create_timer(1.0), "timeout") + print(2) + yield(get_tree().create_timer(1.0), "timeout") + print(1) + yield(get_tree().create_timer(1.0), "timeout") # prints: - # Something is done! - # Something else is done! - # All functions are done! + # 3 + # 2 + # 1 + # Ready [/codeblock] When yielding on a function, the [code]completed[/code] signal will be emitted automatically when the function returns. It can, therefore, be used as the [code]signal[/code] parameter of the [code]yield[/code] method to resume. - If you are planning on calling the same function within a loop, you should consider using [code]yield(get_tree(), "idle_frame")[/code] also. + In order to yield on a function, the resulting function should also return a [code]GDScriptFunctionState[/code]. Notice [code]yield(get_tree(), "idle_frame")[/code] from the above example. </description> </method> </methods> diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp index 9e05c7b574..5c0573be3f 100644 --- a/modules/gdscript/gdscript_functions.cpp +++ b/modules/gdscript/gdscript_functions.cpp @@ -1855,7 +1855,7 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) { } break; case TEXT_CHAR: { - MethodInfo mi("char", PropertyInfo(Variant::INT, "ascii")); + MethodInfo mi("char", PropertyInfo(Variant::INT, "code")); mi.return_val.type = Variant::STRING; return mi; diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs index b17a3f4491..dd1b58b34b 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs @@ -39,7 +39,7 @@ namespace GodotTools.Export private void AddFile(string srcPath, string dstPath, bool remap = false) { - AddFile(dstPath, File.ReadAllBytes(srcPath), remap); + AddFile(dstPath.Replace("\\", "/"), File.ReadAllBytes(srcPath), remap); } public override void _ExportFile(string path, string type, string[] features) diff --git a/modules/mono/glue/Managed/Files/StringExtensions.cs b/modules/mono/glue/Managed/Files/StringExtensions.cs index 079e9912d6..b926037e5a 100644 --- a/modules/mono/glue/Managed/Files/StringExtensions.cs +++ b/modules/mono/glue/Managed/Files/StringExtensions.cs @@ -18,7 +18,7 @@ namespace Godot int pos = 0; int slices = 1; - while ((pos = instance.Find(splitter, true, pos)) >= 0) + while ((pos = instance.Find(splitter, pos, caseSensitive: true)) >= 0) { slices++; pos += splitter.Length; @@ -229,7 +229,7 @@ namespace Godot // </summary> public static int CasecmpTo(this string instance, string to) { - return instance.CompareTo(to, true); + return instance.CompareTo(to, caseSensitive: true); } // <summary> @@ -322,25 +322,29 @@ namespace Godot return instance.Substring(pos + 1); } - // <summary> - // Find the first occurrence of a substring, return the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed. - // </summary> - public static int Find(this string instance, string what, bool caseSensitive = true, int from = 0) + /// <summary>Find the first occurrence of a substring. Optionally, the search starting position can be passed.</summary> + /// <returns>The starting position of the substring, or -1 if not found.</returns> + public static int Find(this string instance, string what, int from = 0, bool caseSensitive = true) { return instance.IndexOf(what, from, caseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase); } - // <summary> - // Find the last occurrence of a substring, return the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed. - // </summary> - public static int FindLast(this string instance, string what, bool caseSensitive = true, int from = 0) + /// <summary>Find the last occurrence of a substring.</summary> + /// <returns>The starting position of the substring, or -1 if not found.</returns> + public static int FindLast(this string instance, string what, bool caseSensitive = true) + { + return instance.FindLast(what, instance.Length - 1, caseSensitive); + } + + /// <summary>Find the last occurrence of a substring specifying the search starting position.</summary> + /// <returns>The starting position of the substring, or -1 if not found.</returns> + public static int FindLast(this string instance, string what, int from, bool caseSensitive = true) { return instance.LastIndexOf(what, from, caseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase); } - // <summary> - // Find the first occurrence of a substring but search as case-insensitive, return the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed. - // </summary> + /// <summary>Find the first occurrence of a substring but search as case-insensitive. Optionally, the search starting position can be passed.</summary> + /// <returns>The starting position of the substring, or -1 if not found.</returns> public static int FindN(this string instance, string what, int from = 0) { return instance.IndexOf(what, from, StringComparison.OrdinalIgnoreCase); @@ -502,7 +506,7 @@ namespace Godot // </summary> public static bool IsSubsequenceOfI(this string instance, string text) { - return instance.IsSubsequenceOf(text, false); + return instance.IsSubsequenceOf(text, caseSensitive: false); } // <summary> @@ -662,7 +666,7 @@ namespace Godot // </summary> public static bool MatchN(this string instance, string expr) { - return instance.ExprMatch(expr, false); + return instance.ExprMatch(expr, caseSensitive: false); } // <summary> @@ -692,7 +696,7 @@ namespace Godot // </summary> public static int NocasecmpTo(this string instance, string to) { - return instance.CompareTo(to, false); + return instance.CompareTo(to, caseSensitive: false); } // <summary> @@ -928,7 +932,7 @@ namespace Godot while (true) { - int end = instance.Find(divisor, true, from); + int end = instance.Find(divisor, from, caseSensitive: true); if (end < 0) end = len; if (allowEmpty || end > from) diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index 33ba877352..29274be559 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -102,6 +102,18 @@ void gd_mono_profiler_init() { bool profiler_enabled = GLOBAL_DEF("mono/profiler/enabled", false); if (profiler_enabled) { mono_profiler_load(profiler_args.utf8()); + return; + } + + const String env_var_name = "MONO_ENV_OPTIONS"; + if (OS::get_singleton()->has_environment(env_var_name)) { + const auto mono_env_ops = OS::get_singleton()->get_environment(env_var_name); + // Usually MONO_ENV_OPTIONS looks like: --profile=jb:prof=timeline,ctl=remote,host=127.0.0.1:55467 + const String prefix = "--profile="; + if (mono_env_ops.begins_with(prefix)) { + const auto ops = mono_env_ops.substr(prefix.length(), mono_env_ops.length()); + mono_profiler_load(ops.utf8()); + } } } @@ -356,7 +368,7 @@ void GDMono::initialize() { } #endif -#if !defined(WINDOWS_ENABLED) && !defined(NO_MONO_THREADS_SUSPEND_WORKAROUND) +#if !defined(NO_MONO_THREADS_SUSPEND_WORKAROUND) // FIXME: Temporary workaround. See: https://github.com/godotengine/godot/issues/29812 if (!OS::get_singleton()->has_environment("MONO_THREADS_SUSPEND")) { OS::get_singleton()->set_environment("MONO_THREADS_SUSPEND", "preemptive"); diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index bf353d287f..70f421a80a 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -4756,7 +4756,7 @@ VisualScriptEditor::VisualScriptEditor() { HBoxContainer *graph_hbc = graph->get_zoom_hbox(); Label *base_lbl = memnew(Label); - base_lbl->set_text("Change Base Type: "); + base_lbl->set_text(TTR("Change Base Type:") + " "); graph_hbc->add_child(base_lbl); base_type_select = memnew(Button); @@ -4764,18 +4764,19 @@ VisualScriptEditor::VisualScriptEditor() { graph_hbc->add_child(base_type_select); Button *add_nds = memnew(Button); - add_nds->set_text("Add Nodes..."); + add_nds->set_text(TTR("Add Nodes...")); graph_hbc->add_child(add_nds); add_nds->connect("pressed", this, "_add_node_dialog"); Button *fn_btn = memnew(Button); - fn_btn->set_text("Add Function..."); + fn_btn->set_text(TTR("Add Function...")); graph_hbc->add_child(fn_btn); fn_btn->connect("pressed", this, "_create_function_dialog"); // Add Function Dialog. VBoxContainer *function_vb = memnew(VBoxContainer); function_vb->set_v_size_flags(SIZE_EXPAND_FILL); + function_vb->set_custom_minimum_size(Size2(450, 300) * EDSCALE); HBoxContainer *func_name_hbox = memnew(HBoxContainer); function_vb->add_child(func_name_hbox); @@ -4810,7 +4811,6 @@ VisualScriptEditor::VisualScriptEditor() { func_input_scroll->add_child(func_input_vbox); function_create_dialog = memnew(ConfirmationDialog); - function_create_dialog->set_custom_minimum_size(Size2(450, 300) * EDSCALE); function_create_dialog->set_v_size_flags(SIZE_EXPAND_FILL); function_create_dialog->set_title(TTR("Create Function")); function_create_dialog->add_child(function_vb); |