summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/bmp/image_loader_bmp.cpp20
-rw-r--r--modules/bmp/image_loader_bmp.h8
-rw-r--r--modules/csg/doc_classes/CSGBox.xml2
-rw-r--r--modules/csg/doc_classes/CSGCylinder.xml2
-rw-r--r--modules/csg/doc_classes/CSGMesh.xml4
-rw-r--r--modules/csg/doc_classes/CSGPolygon.xml2
-rw-r--r--modules/csg/doc_classes/CSGSphere.xml2
-rw-r--r--modules/csg/doc_classes/CSGTorus.xml2
-rw-r--r--modules/gdnative/doc_classes/GDNative.xml2
-rw-r--r--modules/gdnative/doc_classes/NativeScript.xml2
-rw-r--r--modules/gdnative/pluginscript/register_types.cpp2
-rw-r--r--modules/gdscript/doc_classes/@GDScript.xml71
-rw-r--r--modules/gdscript/gdscript_editor.cpp6
-rw-r--r--modules/gdscript/gdscript_function.cpp50
-rw-r--r--modules/gdscript/gdscript_functions.cpp19
-rw-r--r--modules/gdscript/gdscript_functions.h1
-rw-r--r--modules/gdscript/gdscript_parser.cpp21
-rw-r--r--modules/gridmap/doc_classes/GridMap.xml2
-rw-r--r--modules/mono/csharp_script.cpp21
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/CSharpProject.cs4
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/GodotSharpBuilds.cs131
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs110
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj1
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs3
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Internals/Globals.cs33
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs34
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/MonoBottomPanel.cs13
-rw-r--r--modules/mono/editor/editor_internal_calls.cpp44
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp504
-rw-r--r--modules/mono/mono_gd/gd_mono.h15
-rw-r--r--modules/opensimplex/doc_classes/NoiseTexture.xml2
-rw-r--r--modules/regex/doc_classes/RegExMatch.xml4
-rw-r--r--modules/visual_script/doc_classes/VisualScriptPreload.xml2
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.cpp131
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.h1
-rw-r--r--modules/visual_script/visual_script_func_nodes.cpp32
36 files changed, 516 insertions, 787 deletions
diff --git a/modules/bmp/image_loader_bmp.cpp b/modules/bmp/image_loader_bmp.cpp
index a7e8dec11e..88732dff33 100644
--- a/modules/bmp/image_loader_bmp.cpp
+++ b/modules/bmp/image_loader_bmp.cpp
@@ -47,9 +47,6 @@ Error ImageLoaderBMP::convert_to_image(Ref<Image> p_image,
size_t height = (size_t)p_header.bmp_info_header.bmp_height;
size_t bits_per_pixel = (size_t)p_header.bmp_info_header.bmp_bit_count;
- if (p_header.bmp_info_header.bmp_compression != BI_RGB) {
- err = FAILED;
- }
// Check whether we can load it
if (bits_per_pixel == 1) {
@@ -238,11 +235,16 @@ Error ImageLoaderBMP::load_image(Ref<Image> p_image, FileAccess *f,
bmp_header.bmp_info_header.bmp_colors_used = f->get_32();
bmp_header.bmp_info_header.bmp_important_colors = f->get_32();
- // Compressed bitmaps not supported, stop parsing
- if (bmp_header.bmp_info_header.bmp_compression != BI_RGB) {
- ERR_EXPLAIN("Unsupported bmp file: " + f->get_path());
- f->close();
- ERR_FAIL_V(ERR_UNAVAILABLE);
+ switch (bmp_header.bmp_info_header.bmp_compression) {
+ case BI_RLE8:
+ case BI_RLE4:
+ case BI_CMYKRLE8:
+ case BI_CMYKRLE4: {
+ // Stop parsing
+ ERR_EXPLAIN("Compressed BMP files are not supported: " + f->get_path());
+ f->close();
+ ERR_FAIL_V(ERR_UNAVAILABLE);
+ } break;
}
// Don't rely on sizeof(bmp_file_header) as structure padding
// adds 2 bytes offset leading to misaligned color table reading
@@ -257,8 +259,8 @@ Error ImageLoaderBMP::load_image(Ref<Image> p_image, FileAccess *f,
if (bmp_header.bmp_info_header.bmp_bit_count <= 8) {
// Support 256 colors max
color_table_size = 1 << bmp_header.bmp_info_header.bmp_bit_count;
+ ERR_FAIL_COND_V(color_table_size == 0, ERR_BUG);
}
- ERR_FAIL_COND_V(color_table_size == 0, ERR_BUG);
PoolVector<uint8_t> bmp_color_table;
// Color table is usually 4 bytes per color -> [B][G][R][0]
diff --git a/modules/bmp/image_loader_bmp.h b/modules/bmp/image_loader_bmp.h
index 0082cf778a..2debb19a1c 100644
--- a/modules/bmp/image_loader_bmp.h
+++ b/modules/bmp/image_loader_bmp.h
@@ -42,15 +42,15 @@ protected:
enum bmp_compression_s {
BI_RGB = 0x00,
- BI_RLE8 = 0x01,
- BI_RLE4 = 0x02,
+ BI_RLE8 = 0x01, // compressed
+ BI_RLE4 = 0x02, // compressed
BI_BITFIELDS = 0x03,
BI_JPEG = 0x04,
BI_PNG = 0x05,
BI_ALPHABITFIELDS = 0x06,
BI_CMYK = 0x0b,
- BI_CMYKRLE8 = 0x0c,
- BI_CMYKRLE4 = 0x0d
+ BI_CMYKRLE8 = 0x0c, // compressed
+ BI_CMYKRLE4 = 0x0d // compressed
};
struct bmp_header_s {
diff --git a/modules/csg/doc_classes/CSGBox.xml b/modules/csg/doc_classes/CSGBox.xml
index d100c01205..14f5a1952e 100644
--- a/modules/csg/doc_classes/CSGBox.xml
+++ b/modules/csg/doc_classes/CSGBox.xml
@@ -17,7 +17,7 @@
<member name="height" type="float" setter="set_height" getter="get_height" default="2.0">
Height of the box measured from the center of the box.
</member>
- <member name="material" type="Material" setter="set_material" getter="get_material" default="null">
+ <member name="material" type="Material" setter="set_material" getter="get_material">
The material used to render the box.
</member>
<member name="width" type="float" setter="set_width" getter="get_width" default="2.0">
diff --git a/modules/csg/doc_classes/CSGCylinder.xml b/modules/csg/doc_classes/CSGCylinder.xml
index 643eb7c7f4..9fc0281887 100644
--- a/modules/csg/doc_classes/CSGCylinder.xml
+++ b/modules/csg/doc_classes/CSGCylinder.xml
@@ -17,7 +17,7 @@
<member name="height" type="float" setter="set_height" getter="get_height" default="1.0">
The height of the cylinder.
</member>
- <member name="material" type="Material" setter="set_material" getter="get_material" default="null">
+ <member name="material" type="Material" setter="set_material" getter="get_material">
The material used to render the cylinder.
</member>
<member name="radius" type="float" setter="set_radius" getter="get_radius" default="1.0">
diff --git a/modules/csg/doc_classes/CSGMesh.xml b/modules/csg/doc_classes/CSGMesh.xml
index daa08decb6..afe0bc262d 100644
--- a/modules/csg/doc_classes/CSGMesh.xml
+++ b/modules/csg/doc_classes/CSGMesh.xml
@@ -11,9 +11,9 @@
<methods>
</methods>
<members>
- <member name="material" type="Material" setter="set_material" getter="get_material" default="null">
+ <member name="material" type="Material" setter="set_material" getter="get_material">
</member>
- <member name="mesh" type="Mesh" setter="set_mesh" getter="get_mesh" default="null">
+ <member name="mesh" type="Mesh" setter="set_mesh" getter="get_mesh">
The mesh resource to use as a CSG shape.
</member>
</members>
diff --git a/modules/csg/doc_classes/CSGPolygon.xml b/modules/csg/doc_classes/CSGPolygon.xml
index 48f5d730cc..0ecee92cd5 100644
--- a/modules/csg/doc_classes/CSGPolygon.xml
+++ b/modules/csg/doc_classes/CSGPolygon.xml
@@ -14,7 +14,7 @@
<member name="depth" type="float" setter="set_depth" getter="get_depth" default="1.0">
Extrusion depth when [member mode] is [constant MODE_DEPTH].
</member>
- <member name="material" type="Material" setter="set_material" getter="get_material" default="null">
+ <member name="material" type="Material" setter="set_material" getter="get_material">
Material to use for the resulting mesh.
</member>
<member name="mode" type="int" setter="set_mode" getter="get_mode" enum="CSGPolygon.Mode" default="0">
diff --git a/modules/csg/doc_classes/CSGSphere.xml b/modules/csg/doc_classes/CSGSphere.xml
index 0a62644179..714e725acb 100644
--- a/modules/csg/doc_classes/CSGSphere.xml
+++ b/modules/csg/doc_classes/CSGSphere.xml
@@ -11,7 +11,7 @@
<methods>
</methods>
<members>
- <member name="material" type="Material" setter="set_material" getter="get_material" default="null">
+ <member name="material" type="Material" setter="set_material" getter="get_material">
The material used to render the sphere.
</member>
<member name="radial_segments" type="int" setter="set_radial_segments" getter="get_radial_segments" default="12">
diff --git a/modules/csg/doc_classes/CSGTorus.xml b/modules/csg/doc_classes/CSGTorus.xml
index 156fb185e7..5dc6bb8380 100644
--- a/modules/csg/doc_classes/CSGTorus.xml
+++ b/modules/csg/doc_classes/CSGTorus.xml
@@ -14,7 +14,7 @@
<member name="inner_radius" type="float" setter="set_inner_radius" getter="get_inner_radius" default="2.0">
The inner radius of the torus.
</member>
- <member name="material" type="Material" setter="set_material" getter="get_material" default="null">
+ <member name="material" type="Material" setter="set_material" getter="get_material">
The material used to render the torus.
</member>
<member name="outer_radius" type="float" setter="set_outer_radius" getter="get_outer_radius" default="3.0">
diff --git a/modules/gdnative/doc_classes/GDNative.xml b/modules/gdnative/doc_classes/GDNative.xml
index 95ed1fc048..8750ddc56d 100644
--- a/modules/gdnative/doc_classes/GDNative.xml
+++ b/modules/gdnative/doc_classes/GDNative.xml
@@ -33,7 +33,7 @@
</method>
</methods>
<members>
- <member name="library" type="GDNativeLibrary" setter="set_library" getter="get_library" default="null">
+ <member name="library" type="GDNativeLibrary" setter="set_library" getter="get_library">
</member>
</members>
<constants>
diff --git a/modules/gdnative/doc_classes/NativeScript.xml b/modules/gdnative/doc_classes/NativeScript.xml
index 460471386d..e34e209374 100644
--- a/modules/gdnative/doc_classes/NativeScript.xml
+++ b/modules/gdnative/doc_classes/NativeScript.xml
@@ -53,7 +53,7 @@
<members>
<member name="class_name" type="String" setter="set_class_name" getter="get_class_name" default="&quot;&quot;">
</member>
- <member name="library" type="GDNativeLibrary" setter="set_library" getter="get_library" default="null">
+ <member name="library" type="GDNativeLibrary" setter="set_library" getter="get_library">
</member>
<member name="script_class_icon_path" type="String" setter="set_script_class_icon_path" getter="get_script_class_icon_path" default="&quot;&quot;">
</member>
diff --git a/modules/gdnative/pluginscript/register_types.cpp b/modules/gdnative/pluginscript/register_types.cpp
index b7ab887e11..3b46f33afb 100644
--- a/modules/gdnative/pluginscript/register_types.cpp
+++ b/modules/gdnative/pluginscript/register_types.cpp
@@ -114,6 +114,8 @@ void unregister_pluginscript_types() {
for (List<PluginScriptLanguage *>::Element *e = pluginscript_languages.front(); e; e = e->next()) {
PluginScriptLanguage *language = e->get();
ScriptServer::unregister_language(language);
+ ResourceLoader::remove_resource_format_loader(language->get_resource_loader());
+ ResourceSaver::remove_resource_format_saver(language->get_resource_saver());
memdelete(language);
}
}
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml
index 3870a5ea7d..a21b6a2907 100644
--- a/modules/gdscript/doc_classes/@GDScript.xml
+++ b/modules/gdscript/doc_classes/@GDScript.xml
@@ -345,45 +345,78 @@
<method name="fmod">
<return type="float">
</return>
- <argument index="0" name="x" type="float">
+ <argument index="0" name="a" type="float">
</argument>
- <argument index="1" name="y" type="float">
+ <argument index="1" name="b" type="float">
</argument>
<description>
- Returns the floating-point remainder of [code]x/y[/code].
+ Returns the floating-point remainder of [code]a/b[/code], keeping the sign of [code]a[/code].
[codeblock]
# Remainder is 1.5
var remainder = fmod(7, 5.5)
[/codeblock]
+ For the integer remainder operation, use the % operator.
</description>
</method>
<method name="fposmod">
<return type="float">
</return>
- <argument index="0" name="x" type="float">
+ <argument index="0" name="a" type="float">
</argument>
- <argument index="1" name="y" type="float">
+ <argument index="1" name="b" type="float">
+ </argument>
+ <description>
+ Returns the floating-point modulus of [code]a/b[/code] that wraps equally in positive and negative.
+ [codeblock]
+ var i = -6
+ while i &lt; 5:
+ prints(i, fposmod(i, 3))
+ i += 1
+ [/codeblock]
+ Produces:
+ [codeblock]
+ -6 0
+ -5 1
+ -4 2
+ -3 0
+ -2 1
+ -1 2
+ 0 0
+ 1 1
+ 2 2
+ 3 0
+ 4 1
+ [/codeblock]
+ </description>
+ </method>
+ <method name="posmod">
+ <return type="int">
+ </return>
+ <argument index="0" name="a" type="int">
+ </argument>
+ <argument index="1" name="b" type="int">
</argument>
<description>
- Returns the floating-point remainder of [code]x/y[/code] that wraps equally in positive and negative.
+ Returns the integer modulus of [code]a/b[/code] that wraps equally in positive and negative.
[codeblock]
- var i = -10
- while i &lt; 0:
- prints(i, fposmod(i, 10))
+ var i = -6
+ while i &lt; 5:
+ prints(i, posmod(i, 3))
i += 1
[/codeblock]
Produces:
[codeblock]
- -10 10
- -9 1
- -8 2
- -7 3
- -6 4
- -5 5
- -4 6
- -3 7
- -2 8
- -1 9
+ -6 0
+ -5 1
+ -4 2
+ -3 0
+ -2 1
+ -1 2
+ 0 0
+ 1 1
+ 2 2
+ 3 0
+ 4 1
[/codeblock]
</description>
</method>
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index f048010dea..9f65a9fff1 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -159,7 +159,11 @@ bool GDScriptLanguage::validate(const String &p_script, int &r_line_error, int &
for (int i = 0; i < cl->subclasses.size(); i++) {
for (int j = 0; j < cl->subclasses[i]->functions.size(); j++) {
- funcs[cl->subclasses[i]->functions[j]->line] = String(cl->subclasses[i]->name) + "." + String(cl->subclasses[i]->functions[j]->name);
+ funcs[cl->subclasses[i]->functions[j]->line] = String(cl->subclasses[i]->name) + "." + cl->subclasses[i]->functions[j]->name;
+ }
+ for (int j = 0; j < cl->subclasses[i]->static_functions.size(); j++) {
+
+ funcs[cl->subclasses[i]->static_functions[j]->line] = String(cl->subclasses[i]->name) + "." + cl->subclasses[i]->static_functions[j]->name;
}
}
diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp
index d5e74c07c9..42f349ffc0 100644
--- a/modules/gdscript/gdscript_function.cpp
+++ b/modules/gdscript/gdscript_function.cpp
@@ -1784,20 +1784,9 @@ GDScriptFunction::~GDScriptFunction() {
Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
- if (state.instance_id && !ObjectDB::get_instance(state.instance_id)) {
-#ifdef DEBUG_ENABLED
- ERR_EXPLAIN("Resumed function '" + String(function->get_name()) + "()' after yield, but class instance is gone. At script: " + state.script->get_path() + ":" + itos(state.line));
- ERR_FAIL_V(Variant());
-#else
- return Variant();
-#endif
- }
-
Variant arg;
r_error.error = Variant::CallError::CALL_OK;
- ERR_FAIL_COND_V(!function, Variant());
-
if (p_argcount == 0) {
r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 1;
@@ -1823,44 +1812,7 @@ Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_ar
return Variant();
}
- state.result = arg;
- Variant ret = function->call(NULL, NULL, 0, r_error, &state);
-
- bool completed = true;
-
- // If the return value is a GDScriptFunctionState reference,
- // then the function did yield again after resuming.
- if (ret.is_ref()) {
- GDScriptFunctionState *gdfs = Object::cast_to<GDScriptFunctionState>(ret);
- if (gdfs && gdfs->function == function) {
- completed = false;
- gdfs->first_state = first_state.is_valid() ? first_state : Ref<GDScriptFunctionState>(this);
- }
- }
-
- function = NULL; //cleaned up;
- state.result = Variant();
-
- if (completed) {
- if (first_state.is_valid()) {
- first_state->emit_signal("completed", ret);
- } else {
- emit_signal("completed", ret);
- }
- }
-
-#ifdef DEBUG_ENABLED
- if (ScriptDebugger::get_singleton())
- GDScriptLanguage::get_singleton()->exit_function();
- if (state.stack_size) {
- //free stack
- Variant *stack = (Variant *)state.stack.ptr();
- for (int i = 0; i < state.stack_size; i++)
- stack[i].~Variant();
- }
-#endif
-
- return ret;
+ return resume(arg);
}
bool GDScriptFunctionState::is_valid(bool p_extended_check) const {
diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp
index 0736f3d010..8c33d6613c 100644
--- a/modules/gdscript/gdscript_functions.cpp
+++ b/modules/gdscript/gdscript_functions.cpp
@@ -58,6 +58,7 @@ const char *GDScriptFunctions::get_func_name(Function p_func) {
"sqrt",
"fmod",
"fposmod",
+ "posmod",
"floor",
"ceil",
"round",
@@ -243,6 +244,12 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
VALIDATE_ARG_NUM(1);
r_ret = Math::fposmod((double)*p_args[0], (double)*p_args[1]);
} break;
+ case MATH_POSMOD: {
+ VALIDATE_ARG_COUNT(2);
+ VALIDATE_ARG_NUM(0);
+ VALIDATE_ARG_NUM(1);
+ r_ret = Math::posmod((int)*p_args[0], (int)*p_args[1]);
+ } break;
case MATH_FLOOR: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
@@ -1456,6 +1463,7 @@ bool GDScriptFunctions::is_deterministic(Function p_func) {
case MATH_SQRT:
case MATH_FMOD:
case MATH_FPOSMOD:
+ case MATH_POSMOD:
case MATH_FLOOR:
case MATH_CEIL:
case MATH_ROUND:
@@ -1568,15 +1576,20 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
return mi;
} break;
case MATH_FMOD: {
- MethodInfo mi("fmod", PropertyInfo(Variant::REAL, "x"), PropertyInfo(Variant::REAL, "y"));
+ MethodInfo mi("fmod", PropertyInfo(Variant::REAL, "a"), PropertyInfo(Variant::REAL, "b"));
mi.return_val.type = Variant::REAL;
return mi;
} break;
case MATH_FPOSMOD: {
- MethodInfo mi("fposmod", PropertyInfo(Variant::REAL, "x"), PropertyInfo(Variant::REAL, "y"));
+ MethodInfo mi("fposmod", PropertyInfo(Variant::REAL, "a"), PropertyInfo(Variant::REAL, "b"));
mi.return_val.type = Variant::REAL;
return mi;
} break;
+ case MATH_POSMOD: {
+ MethodInfo mi("posmod", PropertyInfo(Variant::INT, "a"), PropertyInfo(Variant::INT, "b"));
+ mi.return_val.type = Variant::INT;
+ return mi;
+ } break;
case MATH_FLOOR: {
MethodInfo mi("floor", PropertyInfo(Variant::REAL, "s"));
mi.return_val.type = Variant::REAL;
@@ -1603,7 +1616,7 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
return mi;
} break;
case MATH_POW: {
- MethodInfo mi("pow", PropertyInfo(Variant::REAL, "x"), PropertyInfo(Variant::REAL, "y"));
+ MethodInfo mi("pow", PropertyInfo(Variant::REAL, "base"), PropertyInfo(Variant::REAL, "exp"));
mi.return_val.type = Variant::REAL;
return mi;
} break;
diff --git a/modules/gdscript/gdscript_functions.h b/modules/gdscript/gdscript_functions.h
index 6ad70f2eb4..d52b9118d3 100644
--- a/modules/gdscript/gdscript_functions.h
+++ b/modules/gdscript/gdscript_functions.h
@@ -49,6 +49,7 @@ public:
MATH_SQRT,
MATH_FMOD,
MATH_FPOSMOD,
+ MATH_POSMOD,
MATH_FLOOR,
MATH_CEIL,
MATH_ROUND,
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index 843162dcef..f006d50a83 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -2209,6 +2209,8 @@ void GDScriptParser::_parse_pattern_block(BlockNode *p_block, Vector<PatternBran
p_block->has_return = true;
+ bool catch_all_appeared = false;
+
while (true) {
while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE && _parse_newline())
@@ -2219,7 +2221,7 @@ void GDScriptParser::_parse_pattern_block(BlockNode *p_block, Vector<PatternBran
return;
if (indent_level > tab_level.back()->get()) {
- return; // go back a level
+ break; // go back a level
}
if (pending_newline != -1) {
@@ -2234,12 +2236,20 @@ void GDScriptParser::_parse_pattern_block(BlockNode *p_block, Vector<PatternBran
branch->patterns.push_back(_parse_pattern(p_static));
if (!branch->patterns[0]) {
- return;
+ break;
}
bool has_binding = branch->patterns[0]->pt_type == PatternNode::PT_BIND;
bool catch_all = has_binding || branch->patterns[0]->pt_type == PatternNode::PT_WILDCARD;
+#ifdef DEBUG_ENABLED
+ // Branches after a wildcard or binding are unreachable
+ if (catch_all_appeared && !current_function->has_unreachable_code) {
+ _add_warning(GDScriptWarning::UNREACHABLE_CODE, -1, current_function->name.operator String());
+ current_function->has_unreachable_code = true;
+ }
+#endif
+
while (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
branch->patterns.push_back(_parse_pattern(p_static));
@@ -2257,6 +2267,8 @@ void GDScriptParser::_parse_pattern_block(BlockNode *p_block, Vector<PatternBran
catch_all = catch_all || pt == PatternNode::PT_WILDCARD;
}
+ catch_all_appeared = catch_all_appeared || catch_all;
+
if (!_enter_indent_block()) {
_set_error("Expected block in pattern branch");
return;
@@ -2272,6 +2284,11 @@ void GDScriptParser::_parse_pattern_block(BlockNode *p_block, Vector<PatternBran
p_branches.push_back(branch);
}
+
+ // Even if all branches return, there is possibility of default fallthrough
+ if (!catch_all_appeared) {
+ p_block->has_return = false;
+ }
}
void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_match, Node *&p_resulting_node, Map<StringName, Node *> &p_bindings) {
diff --git a/modules/gridmap/doc_classes/GridMap.xml b/modules/gridmap/doc_classes/GridMap.xml
index 325432579f..1bd3d72066 100644
--- a/modules/gridmap/doc_classes/GridMap.xml
+++ b/modules/gridmap/doc_classes/GridMap.xml
@@ -210,7 +210,7 @@
</member>
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
</member>
- <member name="mesh_library" type="MeshLibrary" setter="set_mesh_library" getter="get_mesh_library" default="null">
+ <member name="mesh_library" type="MeshLibrary" setter="set_mesh_library" getter="get_mesh_library">
The assigned [MeshLibrary].
</member>
<member name="theme" type="MeshLibrary" setter="set_theme" getter="get_theme">
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 1add697997..078a490b22 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -114,15 +114,20 @@ void CSharpLanguage::init() {
gdmono = memnew(GDMono);
gdmono->initialize();
-#ifndef MONO_GLUE_ENABLED
- WARN_PRINT("This binary is built with `mono_glue=no` and cannot be used for scripting");
-#endif
-
#if defined(TOOLS_ENABLED) && defined(DEBUG_METHODS_ENABLED)
+ // Generate bindings here, before loading assemblies. `initialize_load_assemblies` aborts
+ // the applications if the api assemblies or the main tools assembly is missing, but this
+ // is not a problem for BindingsGenerator as it only needs the tools project editor assembly.
List<String> cmdline_args = OS::get_singleton()->get_cmdline_args();
BindingsGenerator::handle_cmdline_args(cmdline_args);
#endif
+#ifndef MONO_GLUE_ENABLED
+ print_line("Run this binary with `--generate-mono-glue path/to/modules/mono/glue`");
+#endif
+
+ gdmono->initialize_load_assemblies();
+
#ifdef TOOLS_ENABLED
EditorNode::add_init_callback(&_editor_init_callback);
@@ -710,14 +715,6 @@ bool CSharpLanguage::is_assembly_reloading_needed() {
return false; // No assembly to load
}
-#ifdef TOOLS_ENABLED
- if (!gdmono->get_core_api_assembly() && gdmono->metadata_is_api_assembly_invalidated(APIAssembly::API_CORE))
- return false; // The core API assembly to load is invalidated
-
- if (!gdmono->get_editor_api_assembly() && gdmono->metadata_is_api_assembly_invalidated(APIAssembly::API_EDITOR))
- return false; // The editor API assembly to load is invalidated
-#endif
-
return true;
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/CSharpProject.cs b/modules/mono/editor/GodotTools/GodotTools/CSharpProject.cs
index e216d30462..4535ed7247 100644
--- a/modules/mono/editor/GodotTools/GodotTools/CSharpProject.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/CSharpProject.cs
@@ -1,9 +1,9 @@
using Godot;
using System;
-using System.Collections.Generic;
using Godot.Collections;
using GodotTools.Internals;
using GodotTools.ProjectEditor;
+using static GodotTools.Internals.Globals;
using File = GodotTools.Utils.File;
using Directory = GodotTools.Utils.Directory;
@@ -26,7 +26,7 @@ namespace GodotTools
public static void AddItem(string projectPath, string itemType, string include)
{
- if (!(bool) Internal.GlobalDef("mono/project/auto_update_project", true))
+ if (!(bool) GlobalDef("mono/project/auto_update_project", true))
return;
ProjectUtils.AddItemToProjectChecked(projectPath, itemType, include);
diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpBuilds.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpBuilds.cs
index 433a931941..a884b0ead0 100644
--- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpBuilds.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpBuilds.cs
@@ -5,6 +5,7 @@ using System.Threading.Tasks;
using GodotTools.Build;
using GodotTools.Internals;
using GodotTools.Utils;
+using static GodotTools.Internals.Globals;
using Error = Godot.Error;
using File = GodotTools.Utils.File;
using Directory = GodotTools.Utils.Directory;
@@ -192,134 +193,14 @@ namespace GodotTools
return false;
}
- private static bool CopyApiAssembly(string srcDir, string dstDir, string assemblyName, ApiAssemblyType apiType)
- {
- // Create destination directory if needed
- if (!Directory.Exists(dstDir))
- {
- try
- {
- Directory.CreateDirectory(dstDir);
- }
- catch (IOException e)
- {
- ShowBuildErrorDialog($"Failed to create destination directory for the API assemblies. Exception message: {e.Message}");
- return false;
- }
- }
-
- string assemblyFile = assemblyName + ".dll";
- string assemblySrc = Path.Combine(srcDir, assemblyFile);
- string assemblyDst = Path.Combine(dstDir, assemblyFile);
-
- if (!File.Exists(assemblyDst) || File.GetLastWriteTime(assemblySrc) > File.GetLastWriteTime(assemblyDst) ||
- Internal.MetadataIsApiAssemblyInvalidated(apiType))
- {
- string xmlFile = $"{assemblyName}.xml";
- string pdbFile = $"{assemblyName}.pdb";
-
- try
- {
- File.Copy(Path.Combine(srcDir, xmlFile), Path.Combine(dstDir, xmlFile));
- }
- catch (IOException e)
- {
- Godot.GD.PushWarning(e.ToString());
- }
-
- try
- {
- File.Copy(Path.Combine(srcDir, pdbFile), Path.Combine(dstDir, pdbFile));
- }
- catch (IOException e)
- {
- Godot.GD.PushWarning(e.ToString());
- }
-
- try
- {
- File.Copy(assemblySrc, assemblyDst);
- }
- catch (IOException e)
- {
- ShowBuildErrorDialog($"Failed to copy {assemblyFile}. Exception message: {e.Message}");
- return false;
- }
-
- Internal.MetadataSetApiAssemblyInvalidated(apiType, false);
- }
-
- return true;
- }
-
- public static bool MakeApiAssembly(ApiAssemblyType apiType, string config)
- {
- string apiName = apiType == ApiAssemblyType.Core ? ApiAssemblyNames.Core : ApiAssemblyNames.Editor;
-
- string editorPrebuiltApiDir = Path.Combine(GodotSharpDirs.DataEditorPrebuiltApiDir, config);
- string resAssembliesDir = Path.Combine(GodotSharpDirs.ResAssembliesBaseDir, config);
-
- if (File.Exists(Path.Combine(editorPrebuiltApiDir, $"{apiName}.dll")))
- {
- using (var copyProgress = new EditorProgress("mono_copy_prebuilt_api_assembly", $"Copying prebuilt {apiName} assembly...", 1))
- {
- copyProgress.Step($"Copying {apiName} assembly", 0);
- return CopyApiAssembly(editorPrebuiltApiDir, resAssembliesDir, apiName, apiType);
- }
- }
-
- const string apiSolutionName = ApiAssemblyNames.SolutionName;
-
- using (var pr = new EditorProgress($"mono_build_release_{apiSolutionName}", $"Building {apiSolutionName} solution...", 3))
- {
- pr.Step($"Generating {apiSolutionName} solution", 0);
-
- string apiSlnDir = Path.Combine(GodotSharpDirs.MonoSolutionsDir, _ApiFolderName(ApiAssemblyType.Core));
- string apiSlnFile = Path.Combine(apiSlnDir, $"{apiSolutionName}.sln");
-
- if (!Directory.Exists(apiSlnDir) || !File.Exists(apiSlnFile))
- {
- var bindingsGenerator = new BindingsGenerator();
-
- if (!Godot.OS.IsStdoutVerbose())
- bindingsGenerator.LogPrintEnabled = false;
-
- Error err = bindingsGenerator.GenerateCsApi(apiSlnDir);
- if (err != Error.Ok)
- {
- ShowBuildErrorDialog($"Failed to generate {apiSolutionName} solution. Error: {err}");
- return false;
- }
- }
-
- pr.Step($"Building {apiSolutionName} solution", 1);
-
- if (!BuildApiSolution(apiSlnDir, config))
- return false;
-
- pr.Step($"Copying {apiName} assembly", 2);
-
- // Copy the built assembly to the assemblies directory
- string apiAssemblyDir = Path.Combine(apiSlnDir, apiName, "bin", config);
- if (!CopyApiAssembly(apiAssemblyDir, resAssembliesDir, apiName, apiType))
- return false;
- }
-
- return true;
- }
-
public static bool BuildProjectBlocking(string config, IEnumerable<string> godotDefines)
{
if (!File.Exists(GodotSharpDirs.ProjectSlnPath))
return true; // No solution to build
- string apiConfig = config == "Release" ? "Release" : "Debug";
-
- if (!MakeApiAssembly(ApiAssemblyType.Core, apiConfig))
- return false;
-
- if (!MakeApiAssembly(ApiAssemblyType.Editor, apiConfig))
- return false;
+ // Make sure to update the API assemblies if they happen to be missing. Just in
+ // case the user decided to delete them at some point after they were loaded.
+ Internal.UpdateApiAssembliesFromPrebuilt();
using (var pr = new EditorProgress("mono_project_debug_build", "Building project solution...", 1))
{
@@ -376,7 +257,7 @@ namespace GodotTools
{
// Build tool settings
- Internal.EditorDef("mono/builds/build_tool", OS.IsWindows() ? BuildTool.MsBuildVs : BuildTool.MsBuildMono);
+ EditorDef("mono/builds/build_tool", OS.IsWindows() ? BuildTool.MsBuildVs : BuildTool.MsBuildMono);
var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings();
@@ -390,7 +271,7 @@ namespace GodotTools
$"{PropNameMsbuildMono},{PropNameXbuild}"
});
- Internal.EditorDef("mono/builds/print_build_output", false);
+ EditorDef("mono/builds/print_build_output", false);
}
}
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
index da439b8d6f..90dec43412 100644
--- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.IO;
using GodotTools.Internals;
using GodotTools.ProjectEditor;
+using static GodotTools.Internals.Globals;
using File = GodotTools.Utils.File;
using Path = System.IO.Path;
using OS = GodotTools.Utils.OS;
@@ -26,15 +27,15 @@ namespace GodotTools
private MonoDevelopInstance monoDevelopInstance;
private MonoDevelopInstance visualStudioForMacInstance;
- private WeakReference<GodotSharpExport> exportPluginWeak;
+ private WeakRef exportPluginWeak; // TODO Use WeakReference once we have proper serialization
public MonoBottomPanel MonoBottomPanel { get; private set; }
private bool CreateProjectSolution()
{
- using (var pr = new EditorProgress("create_csharp_solution", "Generating solution...", 2)) // TTR("Generating solution...")
+ using (var pr = new EditorProgress("create_csharp_solution", "Generating solution...".TTR(), 2))
{
- pr.Step("Generating C# project..."); // TTR("Generating C# project...")
+ pr.Step("Generating C# project...".TTR());
string resourceDir = ProjectSettings.GlobalizePath("res://");
@@ -67,96 +68,28 @@ namespace GodotTools
}
catch (IOException e)
{
- ShowErrorDialog($"Failed to save solution. Exception message: {e.Message}"); // TTR
+ ShowErrorDialog("Failed to save solution. Exception message: ".TTR() + e.Message);
return false;
}
- string apiConfig = "Debug";
+ // Make sure to update the API assemblies if they happen to be missing. Just in
+ // case the user decided to delete them at some point after they were loaded.
+ Internal.UpdateApiAssembliesFromPrebuilt();
- if (!GodotSharpBuilds.MakeApiAssembly(ApiAssemblyType.Core, apiConfig))
- return false;
-
- if (!GodotSharpBuilds.MakeApiAssembly(ApiAssemblyType.Editor, apiConfig))
- return false;
-
- pr.Step("Done"); // TTR("Done")
+ pr.Step("Done".TTR());
// Here, after all calls to progress_task_step
CallDeferred(nameof(_RemoveCreateSlnMenuOption));
}
else
{
- ShowErrorDialog("Failed to create C# project."); // TTR
+ ShowErrorDialog("Failed to create C# project.".TTR());
}
return true;
}
}
- private static int _makeApiSolutionsAttempts = 100;
- private static bool _makeApiSolutionsRecursionGuard = false;
-
- private void _MakeApiSolutionsIfNeeded()
- {
- // I'm sick entirely of ProgressDialog
-
- if (Internal.IsMessageQueueFlushing() || Engine.GetMainLoop() == null)
- {
- if (_makeApiSolutionsAttempts == 0) // This better never happen or I swear...
- throw new TimeoutException();
-
- if (Engine.GetMainLoop() != null)
- {
- if (!Engine.GetMainLoop().IsConnected("idle_frame", this, nameof(_MakeApiSolutionsIfNeeded)))
- Engine.GetMainLoop().Connect("idle_frame", this, nameof(_MakeApiSolutionsIfNeeded));
- }
- else
- {
- CallDeferred(nameof(_MakeApiSolutionsIfNeededImpl));
- }
-
- _makeApiSolutionsAttempts--;
- return;
- }
-
- // Recursion guard needed because signals don't play well with ProgressDialog either, but unlike
- // the message queue, with signals the collateral damage should be minimal in the worst case.
- if (!_makeApiSolutionsRecursionGuard)
- {
- _makeApiSolutionsRecursionGuard = true;
-
- // Oneshot signals don't play well with ProgressDialog either, so we do it this way instead
- if (Engine.GetMainLoop().IsConnected("idle_frame", this, nameof(_MakeApiSolutionsIfNeeded)))
- Engine.GetMainLoop().Disconnect("idle_frame", this, nameof(_MakeApiSolutionsIfNeeded));
-
- _MakeApiSolutionsIfNeededImpl();
-
- _makeApiSolutionsRecursionGuard = false;
- }
- }
-
- private void _MakeApiSolutionsIfNeededImpl()
- {
- // If the project has a solution and C# project make sure the API assemblies are present and up to date
-
- string api_config = "Debug";
- string resAssembliesDir = Path.Combine(GodotSharpDirs.ResAssembliesBaseDir, api_config);
-
- if (!File.Exists(Path.Combine(resAssembliesDir, $"{ApiAssemblyNames.Core}.dll")) ||
- Internal.MetadataIsApiAssemblyInvalidated(ApiAssemblyType.Core))
- {
- if (!GodotSharpBuilds.MakeApiAssembly(ApiAssemblyType.Core, api_config))
- return;
- }
-
- if (!File.Exists(Path.Combine(resAssembliesDir, $"{ApiAssemblyNames.Editor}.dll")) ||
- Internal.MetadataIsApiAssemblyInvalidated(ApiAssemblyType.Editor))
- {
- if (!GodotSharpBuilds.MakeApiAssembly(ApiAssemblyType.Editor, api_config))
- return; // Redundant? I don't think so!
- }
- }
-
private void _RemoveCreateSlnMenuOption()
{
menuPopup.RemoveItem(menuPopup.GetItemIndex((int) MenuOptions.CreateSln));
@@ -407,7 +340,7 @@ namespace GodotTools
MonoBottomPanel = new MonoBottomPanel();
- bottomPanelBtn = AddControlToBottomPanel(MonoBottomPanel, "Mono"); // TTR("Mono")
+ bottomPanelBtn = AddControlToBottomPanel(MonoBottomPanel, "Mono".TTR());
AddChild(new HotReloadAssemblyWatcher {Name = "HotReloadAssemblyWatcher"});
@@ -419,7 +352,7 @@ namespace GodotTools
// TODO: Remove or edit this info dialog once Mono support is no longer in alpha
{
- menuPopup.AddItem("About C# support", (int) MenuOptions.AboutCSharp); // TTR("About C# support")
+ menuPopup.AddItem("About C# support".TTR(), (int) MenuOptions.AboutCSharp);
aboutDialog = new AcceptDialog();
editorBaseControl.AddChild(aboutDialog);
aboutDialog.WindowTitle = "Important: C# support is not feature-complete";
@@ -441,7 +374,7 @@ namespace GodotTools
var aboutLabel = new Label();
aboutHBox.AddChild(aboutLabel);
- aboutLabel.RectMinSize = new Vector2(600, 150) * Internal.EditorScale;
+ aboutLabel.RectMinSize = new Vector2(600, 150) * EditorScale;
aboutLabel.SizeFlagsVertical = (int) Control.SizeFlags.ExpandFill;
aboutLabel.Autowrap = true;
aboutLabel.Text =
@@ -454,7 +387,7 @@ namespace GodotTools
" https://github.com/godotengine/godot/issues\n\n" +
"Your critical feedback at this stage will play a great role in shaping the C# support in future releases, so thank you!";
- Internal.EditorDef("mono/editor/show_info_on_start", true);
+ EditorDef("mono/editor/show_info_on_start", true);
// CheckBox in main container
aboutDialogCheckBox = new CheckBox {Text = "Show this warning when starting the editor"};
@@ -464,16 +397,13 @@ namespace GodotTools
if (File.Exists(GodotSharpDirs.ProjectSlnPath) && File.Exists(GodotSharpDirs.ProjectCsProjPath))
{
- // Defer this task because EditorProgress calls Main::iterarion() and the main loop is not yet initialized.
- CallDeferred(nameof(_MakeApiSolutionsIfNeeded));
-
// Make sure the existing project has Api assembly references configured correctly
CSharpProject.FixApiHintPath(GodotSharpDirs.ProjectCsProjPath);
}
else
{
bottomPanelBtn.Hide();
- menuPopup.AddItem("Create C# solution", (int) MenuOptions.CreateSln); // TTR("Create C# solution")
+ menuPopup.AddItem("Create C# solution".TTR(), (int) MenuOptions.CreateSln);
}
menuPopup.Connect("id_pressed", this, nameof(_MenuOptionPressed));
@@ -488,7 +418,7 @@ namespace GodotTools
AddControlToContainer(CustomControlContainer.Toolbar, buildButton);
// External editor settings
- Internal.EditorDef("mono/editor/external_editor", ExternalEditor.None);
+ EditorDef("mono/editor/external_editor", ExternalEditor.None);
string settingsHintStr = "Disabled";
@@ -520,7 +450,7 @@ namespace GodotTools
// Export plugin
var exportPlugin = new GodotSharpExport();
AddExportPlugin(exportPlugin);
- exportPluginWeak = new WeakReference<GodotSharpExport>(exportPlugin);
+ exportPluginWeak = WeakRef(exportPlugin);
GodotSharpBuilds.Initialize();
}
@@ -529,13 +459,15 @@ namespace GodotTools
{
base.Dispose(disposing);
- if (exportPluginWeak.TryGetTarget(out var exportPlugin))
+ if (exportPluginWeak != null)
{
// We need to dispose our export plugin before the editor destroys EditorSettings.
// Otherwise, if the GC disposes it at a later time, EditorExportPlatformAndroid
// will be freed after EditorSettings already was, and its device polling thread
// will try to access the EditorSettings singleton, resulting in null dereferencing.
- exportPlugin.Dispose();
+ (exportPluginWeak.GetRef() as GodotSharpExport)?.Dispose();
+
+ exportPluginWeak.Dispose();
}
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
index a0ff8a0df1..01e8c87d14 100644
--- a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
+++ b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
@@ -44,6 +44,7 @@
<Compile Include="Internals\GodotSharpDirs.cs" />
<Compile Include="Internals\Internal.cs" />
<Compile Include="Internals\ScriptClassParser.cs" />
+ <Compile Include="Internals\Globals.cs" />
<Compile Include="MonoDevelopInstance.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Build\BuildSystem.cs" />
diff --git a/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs b/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs
index aa52079cf4..0f6f5ffadc 100644
--- a/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs
@@ -1,5 +1,6 @@
using Godot;
using GodotTools.Internals;
+using static GodotTools.Internals.Globals;
namespace GodotTools
{
@@ -37,7 +38,7 @@ namespace GodotTools
watchTimer = new Timer
{
OneShot = false,
- WaitTime = (float) Internal.EditorDef("mono/assembly_watch_interval_sec", 0.5)
+ WaitTime = (float) EditorDef("mono/assembly_watch_interval_sec", 0.5)
};
watchTimer.Connect("timeout", this, nameof(TimerTimeout));
AddChild(watchTimer);
diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/Globals.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/Globals.cs
new file mode 100644
index 0000000000..793f84fd77
--- /dev/null
+++ b/modules/mono/editor/GodotTools/GodotTools/Internals/Globals.cs
@@ -0,0 +1,33 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.CompilerServices;
+
+namespace GodotTools.Internals
+{
+ public static class Globals
+ {
+ public static float EditorScale => internal_EditorScale();
+
+ public static object GlobalDef(string setting, object defaultValue, bool restartIfChanged = false) =>
+ internal_GlobalDef(setting, defaultValue, restartIfChanged);
+
+ public static object EditorDef(string setting, object defaultValue, bool restartIfChanged = false) =>
+ internal_EditorDef(setting, defaultValue, restartIfChanged);
+
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
+ public static string TTR(this string text) => internal_TTR(text);
+
+ // Internal Calls
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ private static extern float internal_EditorScale();
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ private static extern object internal_GlobalDef(string setting, object defaultValue, bool restartIfChanged);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ private static extern object internal_EditorDef(string setting, object defaultValue, bool restartIfChanged);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ private static extern string internal_TTR(string text);
+ }
+}
diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs
index 5c7ce832cd..9526dd3c6f 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs
@@ -10,13 +10,8 @@ namespace GodotTools.Internals
public const string CSharpLanguageType = "CSharpScript";
public const string CSharpLanguageExtension = "cs";
- public static float EditorScale => internal_EditorScale();
-
- public static object GlobalDef(string setting, object defaultValue, bool restartIfChanged = false) =>
- internal_GlobalDef(setting, defaultValue, restartIfChanged);
-
- public static object EditorDef(string setting, object defaultValue, bool restartIfChanged = false) =>
- internal_EditorDef(setting, defaultValue, restartIfChanged);
+ public static string UpdateApiAssembliesFromPrebuilt() =>
+ internal_UpdateApiAssembliesFromPrebuilt();
public static string FullTemplatesDir =>
internal_FullTemplatesDir();
@@ -25,14 +20,6 @@ namespace GodotTools.Internals
public static bool IsOsxAppBundleInstalled(string bundleId) => internal_IsOsxAppBundleInstalled(bundleId);
- public static bool MetadataIsApiAssemblyInvalidated(ApiAssemblyType apiType) =>
- internal_MetadataIsApiAssemblyInvalidated(apiType);
-
- public static void MetadataSetApiAssemblyInvalidated(ApiAssemblyType apiType, bool invalidated) =>
- internal_MetadataSetApiAssemblyInvalidated(apiType, invalidated);
-
- public static bool IsMessageQueueFlushing() => internal_IsMessageQueueFlushing();
-
public static bool GodotIs32Bits() => internal_GodotIs32Bits();
public static bool GodotIsRealTDouble() => internal_GodotIsRealTDouble();
@@ -62,13 +49,7 @@ namespace GodotTools.Internals
// Internal Calls
[MethodImpl(MethodImplOptions.InternalCall)]
- private static extern float internal_EditorScale();
-
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern object internal_GlobalDef(string setting, object defaultValue, bool restartIfChanged);
-
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern object internal_EditorDef(string setting, object defaultValue, bool restartIfChanged);
+ private static extern string internal_UpdateApiAssembliesFromPrebuilt();
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern string internal_FullTemplatesDir();
@@ -80,15 +61,6 @@ namespace GodotTools.Internals
private static extern bool internal_IsOsxAppBundleInstalled(string bundleId);
[MethodImpl(MethodImplOptions.InternalCall)]
- private static extern bool internal_MetadataIsApiAssemblyInvalidated(ApiAssemblyType apiType);
-
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void internal_MetadataSetApiAssemblyInvalidated(ApiAssemblyType apiType, bool invalidated);
-
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern bool internal_IsMessageQueueFlushing();
-
- [MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool internal_GodotIs32Bits();
[MethodImpl(MethodImplOptions.InternalCall)]
diff --git a/modules/mono/editor/GodotTools/GodotTools/MonoBottomPanel.cs b/modules/mono/editor/GodotTools/GodotTools/MonoBottomPanel.cs
index 300cf7fcb9..53ff0891d5 100644
--- a/modules/mono/editor/GodotTools/GodotTools/MonoBottomPanel.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/MonoBottomPanel.cs
@@ -3,6 +3,7 @@ using System;
using System.IO;
using Godot.Collections;
using GodotTools.Internals;
+using static GodotTools.Internals.Globals;
using File = GodotTools.Utils.File;
using Path = System.IO.Path;
@@ -254,7 +255,7 @@ namespace GodotTools
panelTabs = new TabContainer
{
TabAlign = TabContainer.TabAlignEnum.Left,
- RectMinSize = new Vector2(0, 228) * Internal.EditorScale,
+ RectMinSize = new Vector2(0, 228) * EditorScale,
SizeFlagsVertical = (int) SizeFlags.ExpandFill
};
panelTabs.AddStyleboxOverride("panel", editorBaseControl.GetStylebox("DebuggerPanel", "EditorStyles"));
@@ -266,7 +267,7 @@ namespace GodotTools
// Builds tab
panelBuildsTab = new VBoxContainer
{
- Name = "Builds", // TTR
+ Name = "Builds".TTR(),
SizeFlagsHorizontal = (int) SizeFlags.ExpandFill
};
panelTabs.AddChild(panelBuildsTab);
@@ -276,7 +277,7 @@ namespace GodotTools
var buildProjectBtn = new Button
{
- Text = "Build Project", // TTR
+ Text = "Build Project".TTR(),
FocusMode = FocusModeEnum.None
};
buildProjectBtn.Connect("pressed", this, nameof(BuildProjectPressed));
@@ -286,7 +287,7 @@ namespace GodotTools
warningsBtn = new ToolButton
{
- Text = "Warnings", // TTR
+ Text = "Warnings".TTR(),
ToggleMode = true,
Pressed = true,
Visible = false,
@@ -297,7 +298,7 @@ namespace GodotTools
errorsBtn = new ToolButton
{
- Text = "Errors", // TTR
+ Text = "Errors".TTR(),
ToggleMode = true,
Pressed = true,
Visible = false,
@@ -310,7 +311,7 @@ namespace GodotTools
viewLogBtn = new Button
{
- Text = "View log", // TTR
+ Text = "View log".TTR(),
FocusMode = FocusModeEnum.None,
Visible = false
};
diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp
index a3b5b450ef..0014aaca70 100644
--- a/modules/mono/editor/editor_internal_calls.cpp
+++ b/modules/mono/editor/editor_internal_calls.cpp
@@ -30,7 +30,6 @@
#include "editor_internal_calls.h"
-#include "core/message_queue.h"
#include "core/os/os.h"
#include "core/version.h"
#include "editor/editor_node.h"
@@ -231,24 +230,34 @@ uint32_t godot_icall_GodotSharpExport_GetExportedAssemblyDependencies(MonoString
return GodotSharpExport::get_exported_assembly_dependencies(project_dll_name, project_dll_src_path, build_config, custom_lib_dir, dependencies);
}
-float godot_icall_Internal_EditorScale() {
+float godot_icall_Globals_EditorScale() {
return EDSCALE;
}
-MonoObject *godot_icall_Internal_GlobalDef(MonoString *p_setting, MonoObject *p_default_value, MonoBoolean p_restart_if_changed) {
+MonoObject *godot_icall_Globals_GlobalDef(MonoString *p_setting, MonoObject *p_default_value, MonoBoolean p_restart_if_changed) {
String setting = GDMonoMarshal::mono_string_to_godot(p_setting);
Variant default_value = GDMonoMarshal::mono_object_to_variant(p_default_value);
Variant result = _GLOBAL_DEF(setting, default_value, (bool)p_restart_if_changed);
return GDMonoMarshal::variant_to_mono_object(result);
}
-MonoObject *godot_icall_Internal_EditorDef(MonoString *p_setting, MonoObject *p_default_value, MonoBoolean p_restart_if_changed) {
+MonoObject *godot_icall_Globals_EditorDef(MonoString *p_setting, MonoObject *p_default_value, MonoBoolean p_restart_if_changed) {
String setting = GDMonoMarshal::mono_string_to_godot(p_setting);
Variant default_value = GDMonoMarshal::mono_object_to_variant(p_default_value);
- Variant result = _GLOBAL_DEF(setting, default_value, (bool)p_restart_if_changed);
+ Variant result = _EDITOR_DEF(setting, default_value, (bool)p_restart_if_changed);
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));
+}
+
+MonoString *godot_icall_Internal_UpdateApiAssembliesFromPrebuilt() {
+ String error_str = GDMono::get_singleton()->update_api_assemblies_from_prebuilt();
+ return GDMonoMarshal::mono_string_from_godot(error_str);
+}
+
MonoString *godot_icall_Internal_FullTemplatesDir() {
String full_templates_dir = EditorSettings::get_singleton()->get_templates_dir().plus_file(VERSION_FULL_CONFIG);
return GDMonoMarshal::mono_string_from_godot(full_templates_dir);
@@ -269,18 +278,6 @@ MonoBoolean godot_icall_Internal_IsOsxAppBundleInstalled(MonoString *p_bundle_id
#endif
}
-MonoBoolean godot_icall_Internal_MetadataIsApiAssemblyInvalidated(int32_t p_api_type) {
- return GDMono::get_singleton()->metadata_is_api_assembly_invalidated((APIAssembly::Type)p_api_type);
-}
-
-void godot_icall_Internal_MetadataSetApiAssemblyInvalidated(int32_t p_api_type, MonoBoolean p_invalidated) {
- GDMono::get_singleton()->metadata_set_api_assembly_invalidated((APIAssembly::Type)p_api_type, (bool)p_invalidated);
-}
-
-MonoBoolean godot_icall_Internal_IsMessageQueueFlushing() {
- return (MonoBoolean)MessageQueue::get_singleton()->is_flushing();
-}
-
MonoBoolean godot_icall_Internal_GodotIs32Bits() {
return sizeof(void *) == 4;
}
@@ -402,15 +399,10 @@ void register_editor_internal_calls() {
mono_add_internal_call("GodotTools.GodotSharpExport::internal_GetExportedAssemblyDependencies", (void *)godot_icall_GodotSharpExport_GetExportedAssemblyDependencies);
// Internals
- mono_add_internal_call("GodotTools.Internals.Internal::internal_EditorScale", (void *)godot_icall_Internal_EditorScale);
- mono_add_internal_call("GodotTools.Internals.Internal::internal_GlobalDef", (void *)godot_icall_Internal_GlobalDef);
- mono_add_internal_call("GodotTools.Internals.Internal::internal_EditorDef", (void *)godot_icall_Internal_EditorDef);
+ mono_add_internal_call("GodotTools.Internals.Internal::internal_UpdateApiAssembliesFromPrebuilt", (void *)godot_icall_Internal_UpdateApiAssembliesFromPrebuilt);
mono_add_internal_call("GodotTools.Internals.Internal::internal_FullTemplatesDir", (void *)godot_icall_Internal_FullTemplatesDir);
mono_add_internal_call("GodotTools.Internals.Internal::internal_SimplifyGodotPath", (void *)godot_icall_Internal_SimplifyGodotPath);
mono_add_internal_call("GodotTools.Internals.Internal::internal_IsOsxAppBundleInstalled", (void *)godot_icall_Internal_IsOsxAppBundleInstalled);
- mono_add_internal_call("GodotTools.Internals.Internal::internal_MetadataIsApiAssemblyInvalidated", (void *)godot_icall_Internal_MetadataIsApiAssemblyInvalidated);
- mono_add_internal_call("GodotTools.Internals.Internal::internal_MetadataSetApiAssemblyInvalidated", (void *)godot_icall_Internal_MetadataSetApiAssemblyInvalidated);
- mono_add_internal_call("GodotTools.Internals.Internal::internal_IsMessageQueueFlushing", (void *)godot_icall_Internal_IsMessageQueueFlushing);
mono_add_internal_call("GodotTools.Internals.Internal::internal_GodotIs32Bits", (void *)godot_icall_Internal_GodotIs32Bits);
mono_add_internal_call("GodotTools.Internals.Internal::internal_GodotIsRealTDouble", (void *)godot_icall_Internal_GodotIsRealTDouble);
mono_add_internal_call("GodotTools.Internals.Internal::internal_GodotMainIteration", (void *)godot_icall_Internal_GodotMainIteration);
@@ -424,6 +416,12 @@ void register_editor_internal_calls() {
mono_add_internal_call("GodotTools.Internals.Internal::internal_GetScriptsMetadataOrNothing", (void *)godot_icall_Internal_GetScriptsMetadataOrNothing);
mono_add_internal_call("GodotTools.Internals.Internal::internal_MonoWindowsInstallRoot", (void *)godot_icall_Internal_MonoWindowsInstallRoot);
+ // Globals
+ mono_add_internal_call("GodotTools.Internals.Globals::internal_EditorScale", (void *)godot_icall_Globals_EditorScale);
+ mono_add_internal_call("GodotTools.Internals.Globals::internal_GlobalDef", (void *)godot_icall_Globals_GlobalDef);
+ mono_add_internal_call("GodotTools.Internals.Globals::internal_EditorDef", (void *)godot_icall_Globals_EditorDef);
+ mono_add_internal_call("GodotTools.Internals.Globals::internal_TTR", (void *)godot_icall_Globals_TTR);
+
// Utils.OS
mono_add_internal_call("GodotTools.Utils.OS::GetPlatformName", (void *)godot_icall_Utils_OS_GetPlatformName);
}
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index 06fbae019c..096ad0f5e3 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -59,10 +59,6 @@
#include "android_mono_config.gen.h"
#endif
-#define OUT_OF_SYNC_ERR_MESSAGE(m_assembly_name) "The assembly '" m_assembly_name "' is out of sync. " \
- "This error is expected if you just upgraded to a newer Godot version. " \
- "Building the project will update the assembly to the correct version."
-
GDMono *GDMono::singleton = NULL;
namespace {
@@ -304,26 +300,9 @@ void GDMono::initialize() {
mono_install_unhandled_exception_hook(&unhandled_exception_hook, NULL);
#ifndef TOOLS_ENABLED
- if (!DirAccess::exists("res://.mono")) {
- // 'res://.mono/' is missing so there is nothing to load. We don't need to initialize mono, but
- // we still do so unless mscorlib is missing (which is the case for projects that don't use C#).
-
- String mscorlib_fname("mscorlib.dll");
-
- Vector<String> search_dirs;
- GDMonoAssembly::fill_search_dirs(search_dirs);
-
- bool found = false;
- for (int i = 0; i < search_dirs.size(); i++) {
- if (FileAccess::exists(search_dirs[i].plus_file(mscorlib_fname))) {
- found = true;
- break;
- }
- }
-
- if (!found)
- return; // mscorlib is missing, do not initialize mono
- }
+ // Export templates only load the Mono runtime if the project uses it
+ if (!DirAccess::exists("res://.mono"))
+ return;
#endif
root_domain = mono_jit_init_version("GodotEngine.RootDomain", "v4.0.30319");
@@ -354,63 +333,48 @@ void GDMono::initialize() {
_register_internal_calls();
- // The following assemblies are not required at initialization
-#ifdef MONO_GLUE_ENABLED
- if (_load_api_assemblies()) {
- // Everything is fine with the api assemblies, load the tools and project assemblies
-
-#if defined(TOOLS_ENABLED)
- ERR_EXPLAIN("Mono: Failed to load GodotTools assemblies");
- ERR_FAIL_COND(!_load_tools_assemblies());
-#endif
+ print_verbose("Mono: INITIALIZED");
+}
- _load_project_assembly();
+void GDMono::initialize_load_assemblies() {
- } else {
- if ((core_api_assembly && (core_api_assembly_out_of_sync || !GDMonoUtils::mono_cache.godot_api_cache_updated))
-#ifdef TOOLS_ENABLED
- || (editor_api_assembly && editor_api_assembly_out_of_sync)
+#ifndef MONO_GLUE_ENABLED
+ ERR_EXPLAIN("Mono: This binary was built with `mono_glue=no`; cannot load assemblies");
+ CRASH_NOW();
#endif
- ) {
-#ifdef TOOLS_ENABLED
- // The assembly was successfully loaded, but the full api could not be cached.
- // This is most likely an outdated assembly loaded because of an invalid version in the
- // metadata, so we invalidate the version in the metadata and unload the script domain.
-
- if (core_api_assembly_out_of_sync) {
- ERR_PRINT(OUT_OF_SYNC_ERR_MESSAGE(CORE_API_ASSEMBLY_NAME));
- metadata_set_api_assembly_invalidated(APIAssembly::API_CORE, true);
- } else if (!GDMonoUtils::mono_cache.godot_api_cache_updated) {
- ERR_PRINT("The loaded assembly '" CORE_API_ASSEMBLY_NAME "' is in sync, but the cache update failed");
- metadata_set_api_assembly_invalidated(APIAssembly::API_CORE, true);
- }
- if (editor_api_assembly_out_of_sync) {
- ERR_PRINT(OUT_OF_SYNC_ERR_MESSAGE(EDITOR_API_ASSEMBLY_NAME));
- metadata_set_api_assembly_invalidated(APIAssembly::API_EDITOR, true);
- }
+ // Load assemblies. The API and tools assemblies are required,
+ // the application is aborted if these assemblies cannot be loaded.
- print_line("Mono: Proceeding to unload scripts domain because of invalid API assemblies.");
+ _load_api_assemblies();
- Error err = _unload_scripts_domain();
- if (err != OK) {
- WARN_PRINT("Mono: Failed to unload scripts domain");
- }
-#else
- ERR_PRINT("The loaded API assembly is invalid");
- CRASH_NOW();
-#endif // TOOLS_ENABLED
- }
+#if defined(TOOLS_ENABLED)
+ if (!_load_tools_assemblies()) {
+ ERR_EXPLAIN("Mono: Failed to load GodotTools assemblies");
+ CRASH_NOW();
}
-#else
- print_verbose("Mono: Glue disabled, ignoring script assemblies.");
-#endif // MONO_GLUE_ENABLED
+#endif
- print_verbose("Mono: INITIALIZED");
+ // Load the project's main assembly. This doesn't necessarily need to succeed.
+ // The game may not be using .NET at all, or if the project does use .NET and
+ // we're running in the editor, it may just happen to be it wasn't built yet.
+ if (!_load_project_assembly()) {
+ if (OS::get_singleton()->is_stdout_verbose())
+ print_error("Mono: Failed to load project assembly");
+ }
+}
+
+bool GDMono::_are_api_assemblies_out_of_sync() {
+ bool out_of_sync = core_api_assembly && (core_api_assembly_out_of_sync || !GDMonoUtils::mono_cache.godot_api_cache_updated);
+#ifdef TOOLS_ENABLED
+ if (!out_of_sync)
+ out_of_sync = editor_api_assembly && editor_api_assembly_out_of_sync;
+#endif
+ return out_of_sync;
}
-#ifdef MONO_GLUE_ENABLED
namespace GodotSharpBindings {
+#ifdef MONO_GLUE_ENABLED
uint64_t get_core_api_hash();
#ifdef TOOLS_ENABLED
@@ -419,13 +383,33 @@ uint64_t get_editor_api_hash();
uint32_t get_bindings_version();
void register_generated_icalls();
-} // namespace GodotSharpBindings
+
+#else
+
+uint64_t get_core_api_hash() {
+ CRASH_NOW();
+ GD_UNREACHABLE();
+}
+#ifdef TOOLS_ENABLED
+uint64_t get_editor_api_hash() {
+ CRASH_NOW();
+ GD_UNREACHABLE();
+}
#endif
+uint32_t get_bindings_version() {
+ CRASH_NOW();
+ GD_UNREACHABLE();
+}
+
+void register_generated_icalls() {
+ /* Fine, just do nothing */
+}
+
+#endif // MONO_GLUE_ENABLED
+} // namespace GodotSharpBindings
void GDMono::_register_internal_calls() {
-#ifdef MONO_GLUE_ENABLED
GodotSharpBindings::register_generated_icalls();
-#endif
}
void GDMono::_initialize_and_check_api_hashes() {
@@ -565,12 +549,21 @@ bool GDMono::_load_corlib_assembly() {
}
#ifdef TOOLS_ENABLED
-static bool copy_api_assembly(const String &p_src_dir, const String &p_dst_dir, const String &p_assembly_name, APIAssembly::Type p_api_type) {
+bool GDMono::copy_prebuilt_api_assembly(APIAssembly::Type p_api_type) {
+
+ bool &api_assembly_out_of_sync = (p_api_type == APIAssembly::API_CORE) ?
+ GDMono::get_singleton()->core_api_assembly_out_of_sync :
+ GDMono::get_singleton()->editor_api_assembly_out_of_sync;
+
+ String src_dir = GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file("Debug");
+ String dst_dir = GodotSharpDirs::get_res_assemblies_dir();
+
+ String assembly_name = p_api_type == APIAssembly::API_CORE ? CORE_API_ASSEMBLY_NAME : EDITOR_API_ASSEMBLY_NAME;
// Create destination directory if needed
- if (!DirAccess::exists(p_dst_dir)) {
- DirAccess *da = DirAccess::create_for_path(p_dst_dir);
- Error err = da->make_dir_recursive(p_dst_dir);
+ if (!DirAccess::exists(dst_dir)) {
+ DirAccess *da = DirAccess::create_for_path(dst_dir);
+ Error err = da->make_dir_recursive(dst_dir);
memdelete(da);
if (err != OK) {
@@ -579,21 +572,19 @@ static bool copy_api_assembly(const String &p_src_dir, const String &p_dst_dir,
}
}
- String assembly_file = p_assembly_name + ".dll";
- String assembly_src = p_src_dir.plus_file(assembly_file);
- String assembly_dst = p_dst_dir.plus_file(assembly_file);
+ String assembly_file = assembly_name + ".dll";
+ String assembly_src = src_dir.plus_file(assembly_file);
+ String assembly_dst = dst_dir.plus_file(assembly_file);
- if (!FileAccess::exists(assembly_dst) ||
- FileAccess::get_modified_time(assembly_src) > FileAccess::get_modified_time(assembly_dst) ||
- GDMono::get_singleton()->metadata_is_api_assembly_invalidated(p_api_type)) {
+ if (!FileAccess::exists(assembly_dst) || api_assembly_out_of_sync) {
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- String xml_file = p_assembly_name + ".xml";
- if (da->copy(p_src_dir.plus_file(xml_file), p_dst_dir.plus_file(xml_file)) != OK)
+ String xml_file = assembly_name + ".xml";
+ if (da->copy(src_dir.plus_file(xml_file), dst_dir.plus_file(xml_file)) != OK)
WARN_PRINTS("Failed to copy " + xml_file);
- String pdb_file = p_assembly_name + ".pdb";
- if (da->copy(p_src_dir.plus_file(pdb_file), p_dst_dir.plus_file(pdb_file)) != OK)
+ String pdb_file = assembly_name + ".pdb";
+ if (da->copy(src_dir.plus_file(pdb_file), dst_dir.plus_file(pdb_file)) != OK)
WARN_PRINTS("Failed to copy " + pdb_file);
Error err = da->copy(assembly_src, assembly_dst);
@@ -603,11 +594,46 @@ static bool copy_api_assembly(const String &p_src_dir, const String &p_dst_dir,
return false;
}
- GDMono::get_singleton()->metadata_set_api_assembly_invalidated(p_api_type, false);
+ api_assembly_out_of_sync = false;
}
return true;
}
+
+String GDMono::update_api_assemblies_from_prebuilt() {
+
+#define FAIL_REASON(m_out_of_sync, m_prebuilt_exist) \
+ ( \
+ (m_out_of_sync ? \
+ String("The assembly is invalidated") : \
+ String("The assembly was not found")) + \
+ (m_prebuilt_exist ? \
+ String(" and the prebuilt assemblies are missing") : \
+ String(" and we failed to copy the prebuilt assemblies")))
+
+ bool api_assembly_out_of_sync = core_api_assembly_out_of_sync || editor_api_assembly_out_of_sync;
+
+ String core_assembly_path = GodotSharpDirs::get_res_assemblies_dir().plus_file(CORE_API_ASSEMBLY_NAME ".dll");
+ String editor_assembly_path = GodotSharpDirs::get_res_assemblies_dir().plus_file(EDITOR_API_ASSEMBLY_NAME ".dll");
+
+ if (!api_assembly_out_of_sync && FileAccess::exists(core_assembly_path) && FileAccess::exists(editor_assembly_path))
+ return String(); // No update needed
+
+ String prebuilt_api_dir = GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file("Debug");
+ String prebuilt_core_dll_path = prebuilt_api_dir.plus_file(CORE_API_ASSEMBLY_NAME ".dll");
+ String prebuilt_editor_dll_path = prebuilt_api_dir.plus_file(EDITOR_API_ASSEMBLY_NAME ".dll");
+
+ if (!FileAccess::exists(prebuilt_core_dll_path) || !FileAccess::exists(prebuilt_editor_dll_path))
+ return FAIL_REASON(api_assembly_out_of_sync, /* prebuilt_exist: */ false);
+
+ // Copy the prebuilt Api
+ if (!copy_prebuilt_api_assembly(APIAssembly::API_CORE) || !copy_prebuilt_api_assembly(APIAssembly::API_EDITOR))
+ return FAIL_REASON(api_assembly_out_of_sync, /* prebuilt_exist: */ true);
+
+ return String(); // Updated successfully
+
+#undef FAIL_REASON
+}
#endif
bool GDMono::_load_core_api_assembly() {
@@ -616,35 +642,15 @@ bool GDMono::_load_core_api_assembly() {
return true;
#ifdef TOOLS_ENABLED
- if (metadata_is_api_assembly_invalidated(APIAssembly::API_CORE)) {
- String prebuilt_api_dir = GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file("Debug");
- String prebuilt_dll_path = prebuilt_api_dir.plus_file(CORE_API_ASSEMBLY_NAME ".dll");
- String invalidated_dll_path = get_invalidated_api_assembly_path(APIAssembly::API_CORE);
-
- if (!FileAccess::exists(prebuilt_dll_path) ||
- FileAccess::get_modified_time(invalidated_dll_path) == FileAccess::get_modified_time(prebuilt_dll_path)) {
- print_verbose("Mono: Skipping loading of Core API assembly because it was invalidated");
- return false;
- } else {
- // Copy the prebuilt Api
- String res_assemblies_dir = GodotSharpDirs::get_res_assemblies_dir();
- if (!copy_api_assembly(prebuilt_api_dir, res_assemblies_dir, CORE_API_ASSEMBLY_NAME, APIAssembly::API_CORE) ||
- !copy_api_assembly(prebuilt_api_dir, res_assemblies_dir, EDITOR_API_ASSEMBLY_NAME, APIAssembly::API_EDITOR)) {
- print_verbose("Mono: Failed to copy prebuilt API. Skipping loading of Core API assembly because it was invalidated");
- return false;
- }
- }
- }
-#endif
-
+ // For the editor and the editor player we want to load it from a specific path to make sure we can keep it up to date
String assembly_path = GodotSharpDirs::get_res_assemblies_dir().plus_file(CORE_API_ASSEMBLY_NAME ".dll");
-
- bool success = (FileAccess::exists(assembly_path) &&
- load_assembly_from(CORE_API_ASSEMBLY_NAME, assembly_path, &core_api_assembly)) ||
- load_assembly(CORE_API_ASSEMBLY_NAME, &core_api_assembly);
+ bool success = FileAccess::exists(assembly_path) &&
+ load_assembly_from(CORE_API_ASSEMBLY_NAME, assembly_path, &core_api_assembly);
+#else
+ bool success = load_assembly(CORE_API_ASSEMBLY_NAME, &core_api_assembly);
+#endif
if (success) {
-#ifdef MONO_GLUE_ENABLED
APIAssembly::Version api_assembly_ver = APIAssembly::Version::get_from_loaded_assembly(core_api_assembly, APIAssembly::API_CORE);
core_api_assembly_out_of_sync = GodotSharpBindings::get_core_api_hash() != api_assembly_ver.godot_api_hash ||
GodotSharpBindings::get_bindings_version() != api_assembly_ver.bindings_version ||
@@ -654,9 +660,8 @@ bool GDMono::_load_core_api_assembly() {
_install_trace_listener();
}
-#else
- GDMonoUtils::update_godot_api_cache();
-#endif
+ } else {
+ core_api_assembly_out_of_sync = false;
}
return success;
@@ -668,44 +673,100 @@ bool GDMono::_load_editor_api_assembly() {
if (editor_api_assembly)
return true;
- if (metadata_is_api_assembly_invalidated(APIAssembly::API_EDITOR)) {
- String prebuilt_api_dir = GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file("Debug");
- String prebuilt_dll_path = prebuilt_api_dir.plus_file(EDITOR_API_ASSEMBLY_NAME ".dll");
- String invalidated_dll_path = get_invalidated_api_assembly_path(APIAssembly::API_EDITOR);
-
- if (!FileAccess::exists(prebuilt_dll_path) ||
- FileAccess::get_modified_time(invalidated_dll_path) == FileAccess::get_modified_time(prebuilt_dll_path)) {
- print_verbose("Mono: Skipping loading of Editor API assembly because it was invalidated");
- return false;
- } else {
- // Copy the prebuilt editor Api (no need to copy the core api if we got to this point)
- String res_assemblies_dir = GodotSharpDirs::get_res_assemblies_dir();
- if (!copy_api_assembly(prebuilt_api_dir, res_assemblies_dir, EDITOR_API_ASSEMBLY_NAME, APIAssembly::API_EDITOR)) {
- print_verbose("Mono: Failed to copy prebuilt API. Skipping loading of Editor API assembly because it was invalidated");
- return false;
- }
- }
- }
-
+ // For the editor and the editor player we want to load it from a specific path to make sure we can keep it up to date
String assembly_path = GodotSharpDirs::get_res_assemblies_dir().plus_file(EDITOR_API_ASSEMBLY_NAME ".dll");
-
- bool success = (FileAccess::exists(assembly_path) &&
- load_assembly_from(EDITOR_API_ASSEMBLY_NAME, assembly_path, &editor_api_assembly)) ||
- load_assembly(EDITOR_API_ASSEMBLY_NAME, &editor_api_assembly);
+ bool success = FileAccess::exists(assembly_path) &&
+ load_assembly_from(EDITOR_API_ASSEMBLY_NAME, assembly_path, &editor_api_assembly);
if (success) {
-#ifdef MONO_GLUE_ENABLED
APIAssembly::Version api_assembly_ver = APIAssembly::Version::get_from_loaded_assembly(editor_api_assembly, APIAssembly::API_EDITOR);
editor_api_assembly_out_of_sync = GodotSharpBindings::get_editor_api_hash() != api_assembly_ver.godot_api_hash ||
GodotSharpBindings::get_bindings_version() != api_assembly_ver.bindings_version ||
CS_GLUE_VERSION != api_assembly_ver.cs_glue_version;
-#endif
+ } else {
+ editor_api_assembly_out_of_sync = false;
}
return success;
}
#endif
+bool GDMono::_try_load_api_assemblies() {
+
+ if (!_load_core_api_assembly()) {
+ if (OS::get_singleton()->is_stdout_verbose())
+ print_error("Mono: Failed to load Core API assembly");
+ return false;
+ }
+
+ if (core_api_assembly_out_of_sync || !GDMonoUtils::mono_cache.godot_api_cache_updated)
+ return false;
+
+#ifdef TOOLS_ENABLED
+ if (!_load_editor_api_assembly()) {
+ if (OS::get_singleton()->is_stdout_verbose())
+ print_error("Mono: Failed to load Editor API assembly");
+ return false;
+ }
+
+ if (editor_api_assembly_out_of_sync)
+ return false;
+#endif
+
+ return true;
+}
+
+void GDMono::_load_api_assemblies() {
+
+ if (!_try_load_api_assemblies()) {
+ // The API assemblies are out of sync. Fine, try one more time, but this time
+ // update them from the prebuilt assemblies directory before trying to load them.
+
+ // 1. Unload the scripts domain
+ if (_unload_scripts_domain() != OK) {
+ ERR_EXPLAIN("Mono: Failed to unload scripts domain");
+ CRASH_NOW();
+ }
+
+ // 2. Update the API assemblies
+ String update_error = update_api_assemblies_from_prebuilt();
+ if (!update_error.empty()) {
+ ERR_EXPLAIN(update_error);
+ CRASH_NOW();
+ }
+
+ // 3. Load the scripts domain again
+ if (_load_scripts_domain() != OK) {
+ ERR_EXPLAIN("Mono: Failed to load scripts domain");
+ CRASH_NOW();
+ }
+
+ // 4. Try loading the updated assemblies
+ if (!_try_load_api_assemblies()) {
+ // welp... too bad
+
+ if (_are_api_assemblies_out_of_sync()) {
+ if (core_api_assembly_out_of_sync) {
+ ERR_PRINT("The assembly '" CORE_API_ASSEMBLY_NAME "' is out of sync");
+ } else if (!GDMonoUtils::mono_cache.godot_api_cache_updated) {
+ ERR_PRINT("The loaded assembly '" CORE_API_ASSEMBLY_NAME "' is in sync, but the cache update failed");
+ }
+
+#ifdef TOOLS_ENABLED
+ if (editor_api_assembly_out_of_sync) {
+ ERR_PRINT("The assembly '" EDITOR_API_ASSEMBLY_NAME "' is out of sync");
+ }
+#endif
+
+ CRASH_NOW();
+ } else {
+ ERR_EXPLAIN("Failed to load one of the API assemblies");
+ CRASH_NOW();
+ }
+ }
+ }
+}
+
#ifdef TOOLS_ENABLED
bool GDMono::_load_tools_assemblies() {
@@ -734,39 +795,11 @@ bool GDMono::_load_project_assembly() {
if (success) {
mono_assembly_set_main(project_assembly->get_assembly());
- } else {
- if (OS::get_singleton()->is_stdout_verbose())
- print_error("Mono: Failed to load project assembly");
}
return success;
}
-bool GDMono::_load_api_assemblies() {
-
- if (!_load_core_api_assembly()) {
- if (OS::get_singleton()->is_stdout_verbose())
- print_error("Mono: Failed to load Core API assembly");
- return false;
- }
-
- if (core_api_assembly_out_of_sync || !GDMonoUtils::mono_cache.godot_api_cache_updated)
- return false;
-
-#ifdef TOOLS_ENABLED
- if (!_load_editor_api_assembly()) {
- if (OS::get_singleton()->is_stdout_verbose())
- print_error("Mono: Failed to load Editor API assembly");
- return false;
- }
-
- if (editor_api_assembly_out_of_sync)
- return false;
-#endif
-
- return true;
-}
-
void GDMono::_install_trace_listener() {
#ifdef DEBUG_ENABLED
@@ -784,78 +817,6 @@ void GDMono::_install_trace_listener() {
#endif
}
-#ifdef TOOLS_ENABLED
-String GDMono::_get_api_assembly_metadata_path() {
-
- return GodotSharpDirs::get_res_metadata_dir().plus_file("api_assemblies.cfg");
-}
-
-void GDMono::metadata_set_api_assembly_invalidated(APIAssembly::Type p_api_type, bool p_invalidated) {
-
- String section = APIAssembly::to_string(p_api_type);
- String path = _get_api_assembly_metadata_path();
-
- Ref<ConfigFile> metadata;
- metadata.instance();
- metadata->load(path);
-
- metadata->set_value(section, "invalidated", p_invalidated);
-
- String assembly_path = GodotSharpDirs::get_res_assemblies_dir()
- .plus_file(p_api_type == APIAssembly::API_CORE ?
- CORE_API_ASSEMBLY_NAME ".dll" :
- EDITOR_API_ASSEMBLY_NAME ".dll");
-
- ERR_FAIL_COND(!FileAccess::exists(assembly_path));
-
- uint64_t modified_time = FileAccess::get_modified_time(assembly_path);
-
- metadata->set_value(section, "invalidated_asm_modified_time", String::num_uint64(modified_time));
-
- String dir = path.get_base_dir();
- if (!DirAccess::exists(dir)) {
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- ERR_FAIL_COND(!da);
- Error err = da->make_dir_recursive(ProjectSettings::get_singleton()->globalize_path(dir));
- ERR_FAIL_COND(err != OK);
- }
-
- Error save_err = metadata->save(path);
- ERR_FAIL_COND(save_err != OK);
-}
-
-bool GDMono::metadata_is_api_assembly_invalidated(APIAssembly::Type p_api_type) {
-
- String section = APIAssembly::to_string(p_api_type);
-
- Ref<ConfigFile> metadata;
- metadata.instance();
- metadata->load(_get_api_assembly_metadata_path());
-
- String assembly_path = GodotSharpDirs::get_res_assemblies_dir()
- .plus_file(p_api_type == APIAssembly::API_CORE ?
- CORE_API_ASSEMBLY_NAME ".dll" :
- EDITOR_API_ASSEMBLY_NAME ".dll");
-
- if (!FileAccess::exists(assembly_path))
- return false;
-
- uint64_t modified_time = FileAccess::get_modified_time(assembly_path);
-
- uint64_t stored_modified_time = metadata->get_value(section, "invalidated_asm_modified_time", 0);
-
- return metadata->get_value(section, "invalidated", false) && modified_time <= stored_modified_time;
-}
-
-String GDMono::get_invalidated_api_assembly_path(APIAssembly::Type p_api_type) {
-
- return GodotSharpDirs::get_res_assemblies_dir()
- .plus_file(p_api_type == APIAssembly::API_CORE ?
- CORE_API_ASSEMBLY_NAME ".dll" :
- EDITOR_API_ASSEMBLY_NAME ".dll");
-}
-#endif
-
Error GDMono::_load_scripts_domain() {
ERR_FAIL_COND_V(scripts_domain != NULL, ERR_BUG);
@@ -903,11 +864,6 @@ Error GDMono::_unload_scripts_domain() {
tools_project_editor_assembly = NULL;
#endif
- core_api_assembly_out_of_sync = false;
-#ifdef TOOLS_ENABLED
- editor_api_assembly_out_of_sync = false;
-#endif
-
MonoDomain *domain = scripts_domain;
scripts_domain = NULL;
@@ -944,57 +900,25 @@ Error GDMono::reload_scripts_domain() {
return err;
}
-#ifdef MONO_GLUE_ENABLED
- if (!_load_api_assemblies()) {
- if ((core_api_assembly && (core_api_assembly_out_of_sync || !GDMonoUtils::mono_cache.godot_api_cache_updated))
-#ifdef TOOLS_ENABLED
- || (editor_api_assembly && editor_api_assembly_out_of_sync)
-#endif
- ) {
-#ifdef TOOLS_ENABLED
- // The assembly was successfully loaded, but the full api could not be cached.
- // This is most likely an outdated assembly loaded because of an invalid version in the
- // metadata, so we invalidate the version in the metadata and unload the script domain.
-
- if (core_api_assembly_out_of_sync) {
- ERR_PRINT(OUT_OF_SYNC_ERR_MESSAGE(CORE_API_ASSEMBLY_NAME));
- metadata_set_api_assembly_invalidated(APIAssembly::API_CORE, true);
- } else if (!GDMonoUtils::mono_cache.godot_api_cache_updated) {
- ERR_PRINT("The loaded Core API assembly is in sync, but the cache update failed");
- metadata_set_api_assembly_invalidated(APIAssembly::API_CORE, true);
- }
-
- if (editor_api_assembly_out_of_sync) {
- ERR_PRINT(OUT_OF_SYNC_ERR_MESSAGE(EDITOR_API_ASSEMBLY_NAME));
- metadata_set_api_assembly_invalidated(APIAssembly::API_EDITOR, true);
- }
+ // Load assemblies. The API and tools assemblies are required,
+ // the application is aborted if these assemblies cannot be loaded.
- err = _unload_scripts_domain();
- if (err != OK) {
- WARN_PRINT("Mono: Failed to unload scripts domain");
- }
+ _load_api_assemblies();
- return ERR_CANT_RESOLVE;
-#else
- ERR_PRINT("The loaded API assembly is invalid");
- CRASH_NOW();
-#endif
- } else {
- return ERR_CANT_OPEN;
- }
+#if defined(TOOLS_ENABLED)
+ if (!_load_tools_assemblies()) {
+ ERR_EXPLAIN("Mono: Failed to load GodotTools assemblies");
+ CRASH_NOW();
}
-
-#ifdef TOOLS_ENABLED
- ERR_EXPLAIN("Mono: Failed to load GodotTools assemblies");
- ERR_FAIL_COND_V(!_load_tools_assemblies(), ERR_CANT_OPEN);
#endif
+ // Load the project's main assembly. Here, during hot-reloading, we do
+ // consider failing to load the project's main assembly to be an error.
+ // However, unlike the API and tools assemblies, the application can continue working.
if (!_load_project_assembly()) {
+ print_error("Mono: Failed to load project assembly");
return ERR_CANT_OPEN;
}
-#else
- print_verbose("Mono: Glue disabled, ignoring script assemblies.");
-#endif // MONO_GLUE_ENABLED
return OK;
}
diff --git a/modules/mono/mono_gd/gd_mono.h b/modules/mono/mono_gd/gd_mono.h
index a926bf4126..deebe5fd50 100644
--- a/modules/mono/mono_gd/gd_mono.h
+++ b/modules/mono/mono_gd/gd_mono.h
@@ -104,6 +104,8 @@ class GDMono {
void _domain_assemblies_cleanup(uint32_t p_domain_id);
+ bool _are_api_assemblies_out_of_sync();
+
bool _load_corlib_assembly();
bool _load_core_api_assembly();
#ifdef TOOLS_ENABLED
@@ -112,11 +114,8 @@ class GDMono {
#endif
bool _load_project_assembly();
- bool _load_api_assemblies();
-
-#ifdef TOOLS_ENABLED
- String _get_api_assembly_metadata_path();
-#endif
+ bool _try_load_api_assemblies();
+ void _load_api_assemblies();
void _install_trace_listener();
@@ -157,9 +156,8 @@ public:
#endif
#ifdef TOOLS_ENABLED
- void metadata_set_api_assembly_invalidated(APIAssembly::Type p_api_type, bool p_invalidated);
- bool metadata_is_api_assembly_invalidated(APIAssembly::Type p_api_type);
- String get_invalidated_api_assembly_path(APIAssembly::Type p_api_type);
+ bool copy_prebuilt_api_assembly(APIAssembly::Type p_api_type);
+ String update_api_assemblies_from_prebuilt();
#endif
static GDMono *get_singleton() { return singleton; }
@@ -203,6 +201,7 @@ public:
Error finalize_and_unload_domain(MonoDomain *p_domain);
void initialize();
+ void initialize_load_assemblies();
GDMono();
~GDMono();
diff --git a/modules/opensimplex/doc_classes/NoiseTexture.xml b/modules/opensimplex/doc_classes/NoiseTexture.xml
index 4826b6cd2a..4b59a380f5 100644
--- a/modules/opensimplex/doc_classes/NoiseTexture.xml
+++ b/modules/opensimplex/doc_classes/NoiseTexture.xml
@@ -20,7 +20,7 @@
<member name="height" type="int" setter="set_height" getter="get_height" default="512">
Height of the generated texture.
</member>
- <member name="noise" type="OpenSimplexNoise" setter="set_noise" getter="get_noise" default="null">
+ <member name="noise" type="OpenSimplexNoise" setter="set_noise" getter="get_noise">
The [OpenSimplexNoise] instance used to generate the noise.
</member>
<member name="seamless" type="bool" setter="set_seamless" getter="get_seamless" default="false">
diff --git a/modules/regex/doc_classes/RegExMatch.xml b/modules/regex/doc_classes/RegExMatch.xml
index e279607d13..6dec9fc516 100644
--- a/modules/regex/doc_classes/RegExMatch.xml
+++ b/modules/regex/doc_classes/RegExMatch.xml
@@ -48,9 +48,7 @@
</method>
</methods>
<members>
- <member name="names" type="Dictionary" setter="" getter="get_names" default="{
-
-}">
+ <member name="names" type="Dictionary" setter="" getter="get_names" default="{}">
A dictionary of named groups and its corresponding group number. Only groups with that were matched are included. If multiple groups have the same name, that name would refer to the first matching one.
</member>
<member name="strings" type="Array" setter="" getter="get_strings" default="[ ]">
diff --git a/modules/visual_script/doc_classes/VisualScriptPreload.xml b/modules/visual_script/doc_classes/VisualScriptPreload.xml
index 05ed0ad1e5..b3b39691c9 100644
--- a/modules/visual_script/doc_classes/VisualScriptPreload.xml
+++ b/modules/visual_script/doc_classes/VisualScriptPreload.xml
@@ -15,7 +15,7 @@
<methods>
</methods>
<members>
- <member name="resource" type="Resource" setter="set_preload" getter="get_preload" default="null">
+ <member name="resource" type="Resource" setter="set_preload" getter="get_preload">
The [Resource] to load.
</member>
</members>
diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp
index 75b79f8929..6c9c6b0fc8 100644
--- a/modules/visual_script/visual_script_builtin_funcs.cpp
+++ b/modules/visual_script/visual_script_builtin_funcs.cpp
@@ -104,6 +104,7 @@ const char *VisualScriptBuiltinFunc::func_name[VisualScriptBuiltinFunc::FUNC_MAX
"bytes2var",
"color_named",
"smoothstep",
+ "posmod",
};
VisualScriptBuiltinFunc::BuiltinFunc VisualScriptBuiltinFunc::find_function(const String &p_string) {
@@ -192,6 +193,7 @@ int VisualScriptBuiltinFunc::get_func_argument_count(BuiltinFunc p_func) {
case MATH_ATAN2:
case MATH_FMOD:
case MATH_FPOSMOD:
+ case MATH_POSMOD:
case MATH_POW:
case MATH_EASE:
case MATH_STEPIFY:
@@ -261,7 +263,16 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
case MATH_ASIN:
case MATH_ACOS:
case MATH_ATAN:
- case MATH_SQRT: {
+ case MATH_SQRT:
+ case MATH_FLOOR:
+ case MATH_CEIL:
+ case MATH_ROUND:
+ case MATH_ABS:
+ case MATH_SIGN:
+ case MATH_LOG:
+ case MATH_EXP:
+ case MATH_ISNAN:
+ case MATH_ISINF: {
return PropertyInfo(Variant::REAL, "s");
} break;
case MATH_ATAN2: {
@@ -271,32 +282,25 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
return PropertyInfo(Variant::REAL, "x");
} break;
case MATH_FMOD:
- case MATH_FPOSMOD: {
+ case MATH_FPOSMOD:
+ case LOGIC_MAX:
+ case LOGIC_MIN: {
if (p_idx == 0)
- return PropertyInfo(Variant::REAL, "x");
+ return PropertyInfo(Variant::REAL, "a");
else
- return PropertyInfo(Variant::REAL, "y");
+ return PropertyInfo(Variant::REAL, "b");
} break;
- case MATH_FLOOR:
- case MATH_CEIL:
- case MATH_ROUND:
- case MATH_ABS:
- case MATH_SIGN: {
- return PropertyInfo(Variant::REAL, "s");
-
+ case MATH_POSMOD: {
+ if (p_idx == 0)
+ return PropertyInfo(Variant::INT, "a");
+ else
+ return PropertyInfo(Variant::INT, "b");
} break;
-
case MATH_POW: {
if (p_idx == 0)
- return PropertyInfo(Variant::REAL, "x");
+ return PropertyInfo(Variant::REAL, "base");
else
- return PropertyInfo(Variant::REAL, "y");
- } break;
- case MATH_LOG:
- case MATH_EXP:
- case MATH_ISNAN:
- case MATH_ISINF: {
- return PropertyInfo(Variant::REAL, "s");
+ return PropertyInfo(Variant::REAL, "exp");
} break;
case MATH_EASE: {
if (p_idx == 0)
@@ -313,14 +317,7 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
else
return PropertyInfo(Variant::REAL, "steps");
} break;
- case MATH_LERP: {
- if (p_idx == 0)
- return PropertyInfo(Variant::REAL, "from");
- else if (p_idx == 1)
- return PropertyInfo(Variant::REAL, "to");
- else
- return PropertyInfo(Variant::REAL, "weight");
- } break;
+ case MATH_LERP:
case MATH_INVERSE_LERP: {
if (p_idx == 0)
return PropertyInfo(Variant::REAL, "from");
@@ -365,12 +362,8 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
else
return PropertyInfo(Variant::REAL, "step");
} break;
- case MATH_RANDOMIZE: {
-
- } break;
- case MATH_RAND: {
-
- } break;
+ case MATH_RANDOMIZE:
+ case MATH_RAND:
case MATH_RANDF: {
} break;
@@ -380,9 +373,7 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
else
return PropertyInfo(Variant::REAL, "to");
} break;
- case MATH_SEED: {
- return PropertyInfo(Variant::INT, "seed");
- } break;
+ case MATH_SEED:
case MATH_RANDSEED: {
return PropertyInfo(Variant::INT, "seed");
} break;
@@ -418,26 +409,7 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
else
return PropertyInfo(Variant::INT, "max");
} break;
- case MATH_WRAPF: {
- if (p_idx == 0)
- return PropertyInfo(Variant::REAL, "value");
- else if (p_idx == 1)
- return PropertyInfo(Variant::REAL, "min");
- else
- return PropertyInfo(Variant::REAL, "max");
- } break;
- case LOGIC_MAX: {
- if (p_idx == 0)
- return PropertyInfo(Variant::REAL, "a");
- else
- return PropertyInfo(Variant::REAL, "b");
- } break;
- case LOGIC_MIN: {
- if (p_idx == 0)
- return PropertyInfo(Variant::REAL, "a");
- else
- return PropertyInfo(Variant::REAL, "b");
- } break;
+ case MATH_WRAPF:
case LOGIC_CLAMP: {
if (p_idx == 0)
return PropertyInfo(Variant::REAL, "value");
@@ -450,20 +422,15 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
return PropertyInfo(Variant::INT, "value");
} break;
case OBJ_WEAKREF: {
-
return PropertyInfo(Variant::OBJECT, "source");
-
} break;
case FUNC_FUNCREF: {
-
if (p_idx == 0)
return PropertyInfo(Variant::OBJECT, "instance");
else
return PropertyInfo(Variant::STRING, "funcname");
-
} break;
case TYPE_CONVERT: {
-
if (p_idx == 0)
return PropertyInfo(Variant::NIL, "what");
else
@@ -471,45 +438,24 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
} break;
case TYPE_OF: {
return PropertyInfo(Variant::NIL, "what");
-
} break;
case TYPE_EXISTS: {
-
return PropertyInfo(Variant::STRING, "type");
-
} break;
case TEXT_CHAR: {
-
return PropertyInfo(Variant::INT, "ascii");
-
- } break;
- case TEXT_STR: {
-
- return PropertyInfo(Variant::NIL, "value");
-
- } break;
- case TEXT_PRINT: {
-
- return PropertyInfo(Variant::NIL, "value");
-
- } break;
- case TEXT_PRINTERR: {
- return PropertyInfo(Variant::NIL, "value");
-
} break;
+ case TEXT_STR:
+ case TEXT_PRINT:
+ case TEXT_PRINTERR:
case TEXT_PRINTRAW: {
-
return PropertyInfo(Variant::NIL, "value");
-
- } break;
- case VAR_TO_STR: {
- return PropertyInfo(Variant::NIL, "var");
-
} break;
case STR_TO_VAR: {
return PropertyInfo(Variant::STRING, "string");
} break;
+ case VAR_TO_STR:
case VAR_TO_BYTES: {
if (p_idx == 0)
return PropertyInfo(Variant::NIL, "var");
@@ -525,12 +471,10 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
return PropertyInfo(Variant::BOOL, "allow_objects");
} break;
case COLORN: {
-
if (p_idx == 0)
return PropertyInfo(Variant::STRING, "name");
else
return PropertyInfo(Variant::REAL, "alpha");
-
} break;
case FUNC_MAX: {
}
@@ -561,6 +505,7 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons
case MATH_CEIL: {
t = Variant::REAL;
} break;
+ case MATH_POSMOD:
case MATH_ROUND: {
t = Variant::INT;
} break;
@@ -806,6 +751,12 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
VALIDATE_ARG_NUM(1);
*r_return = Math::fposmod((double)*p_inputs[0], (double)*p_inputs[1]);
} break;
+ case VisualScriptBuiltinFunc::MATH_POSMOD: {
+
+ VALIDATE_ARG_NUM(0);
+ VALIDATE_ARG_NUM(1);
+ *r_return = Math::posmod((int)*p_inputs[0], (int)*p_inputs[1]);
+ } break;
case VisualScriptBuiltinFunc::MATH_FLOOR: {
VALIDATE_ARG_NUM(0);
@@ -1365,6 +1316,7 @@ void VisualScriptBuiltinFunc::_bind_methods() {
BIND_ENUM_CONSTANT(MATH_SQRT);
BIND_ENUM_CONSTANT(MATH_FMOD);
BIND_ENUM_CONSTANT(MATH_FPOSMOD);
+ BIND_ENUM_CONSTANT(MATH_POSMOD);
BIND_ENUM_CONSTANT(MATH_FLOOR);
BIND_ENUM_CONSTANT(MATH_CEIL);
BIND_ENUM_CONSTANT(MATH_ROUND);
@@ -1454,6 +1406,7 @@ void register_visual_script_builtin_func_node() {
VisualScriptLanguage::singleton->add_register_func("functions/built_in/sqrt", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_SQRT>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/fmod", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_FMOD>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/fposmod", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_FPOSMOD>);
+ VisualScriptLanguage::singleton->add_register_func("functions/built_in/posmod", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_POSMOD>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/floor", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_FLOOR>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/ceil", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_CEIL>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/round", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ROUND>);
diff --git a/modules/visual_script/visual_script_builtin_funcs.h b/modules/visual_script/visual_script_builtin_funcs.h
index f009f49b5b..7821e0eb2d 100644
--- a/modules/visual_script/visual_script_builtin_funcs.h
+++ b/modules/visual_script/visual_script_builtin_funcs.h
@@ -104,6 +104,7 @@ public:
BYTES_TO_VAR,
COLORN,
MATH_SMOOTHSTEP,
+ MATH_POSMOD,
FUNC_MAX
};
diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp
index 0413bbf303..c330fa1bc0 100644
--- a/modules/visual_script/visual_script_func_nodes.cpp
+++ b/modules/visual_script/visual_script_func_nodes.cpp
@@ -1026,7 +1026,6 @@ void VisualScriptPropertySet::_adjust_input_index(PropertyInfo &pinfo) const {
}
PropertyInfo VisualScriptPropertySet::get_input_value_port_info(int p_idx) const {
-
if (call_mode == CALL_MODE_INSTANCE || call_mode == CALL_MODE_BASIC_TYPE) {
if (p_idx == 0) {
PropertyInfo pi;
@@ -1037,6 +1036,16 @@ PropertyInfo VisualScriptPropertySet::get_input_value_port_info(int p_idx) const
}
}
+ List<PropertyInfo> props;
+ ClassDB::get_property_list(_get_base_type(), &props, true);
+ for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
+ if (E->get().name == property) {
+ PropertyInfo pinfo = PropertyInfo(E->get().type, "value", PROPERTY_HINT_TYPE_STRING, E->get().hint_string);
+ _adjust_input_index(pinfo);
+ return pinfo;
+ }
+ }
+
PropertyInfo pinfo = type_cache;
pinfo.name = "value";
_adjust_input_index(pinfo);
@@ -1047,6 +1056,13 @@ PropertyInfo VisualScriptPropertySet::get_output_value_port_info(int p_idx) cons
if (call_mode == CALL_MODE_BASIC_TYPE) {
return PropertyInfo(basic_type, "out");
} else if (call_mode == CALL_MODE_INSTANCE) {
+ List<PropertyInfo> props;
+ ClassDB::get_property_list(_get_base_type(), &props, true);
+ for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
+ if (E->get().name == property) {
+ return PropertyInfo(E->get().type, "pass", PROPERTY_HINT_TYPE_STRING, E->get().hint_string);
+ }
+ }
return PropertyInfo(Variant::OBJECT, "pass", PROPERTY_HINT_TYPE_STRING, get_base_type());
} else {
return PropertyInfo();
@@ -1796,14 +1812,12 @@ PropertyInfo VisualScriptPropertyGet::get_input_value_port_info(int p_idx) const
}
PropertyInfo VisualScriptPropertyGet::get_output_value_port_info(int p_idx) const {
-
- if (index != StringName()) {
-
- Variant v;
- Variant::CallError ce;
- v = Variant::construct(type_cache, NULL, 0, ce);
- Variant i = v.get(index);
- return PropertyInfo(i.get_type(), "value." + String(index));
+ List<PropertyInfo> props;
+ ClassDB::get_property_list(_get_base_type(), &props, true);
+ for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
+ if (E->get().name == property) {
+ return PropertyInfo(E->get().type, "value." + String(index));
+ }
}
return PropertyInfo(type_cache, "value");