diff options
Diffstat (limited to 'modules')
124 files changed, 965 insertions, 692 deletions
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index 6294790132..3932c2377f 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -1852,13 +1852,13 @@ CSGBrush *CSGPolygon3D::_build_brush() { base_xform = path->get_global_transform(); } - Vector3 current_point = curve->interpolate_baked(0); - Vector3 next_point = curve->interpolate_baked(extrusion_step); + Vector3 current_point = curve->sample_baked(0); + Vector3 next_point = curve->sample_baked(extrusion_step); Vector3 current_up = Vector3(0, 1, 0); Vector3 direction = next_point - current_point; if (path_joined) { - Vector3 last_point = curve->interpolate_baked(curve->get_baked_length()); + Vector3 last_point = curve->sample_baked(curve->get_baked_length()); direction = next_point - last_point; } @@ -1869,7 +1869,7 @@ CSGBrush *CSGPolygon3D::_build_brush() { case PATH_ROTATION_PATH: break; case PATH_ROTATION_PATH_FOLLOW: - current_up = curve->interpolate_baked_up_vector(0); + current_up = curve->sample_baked_up_vector(0); break; } @@ -1931,9 +1931,9 @@ CSGBrush *CSGPolygon3D::_build_brush() { } } - Vector3 previous_point = curve->interpolate_baked(previous_offset); - Vector3 current_point = curve->interpolate_baked(current_offset); - Vector3 next_point = curve->interpolate_baked(next_offset); + Vector3 previous_point = curve->sample_baked(previous_offset); + Vector3 current_point = curve->sample_baked(current_offset); + Vector3 next_point = curve->sample_baked(next_offset); Vector3 current_up = Vector3(0, 1, 0); Vector3 direction = next_point - previous_point; Vector3 current_dir = (current_point - previous_point).normalized(); @@ -1956,7 +1956,7 @@ CSGBrush *CSGPolygon3D::_build_brush() { case PATH_ROTATION_PATH: break; case PATH_ROTATION_PATH_FOLLOW: - current_up = curve->interpolate_baked_up_vector(current_offset); + current_up = curve->sample_baked_up_vector(current_offset); break; } diff --git a/modules/denoise/config.py b/modules/denoise/config.py index 350839651a..20a5e1da2f 100644 --- a/modules/denoise/config.py +++ b/modules/denoise/config.py @@ -2,7 +2,7 @@ def can_build(env, platform): # Thirdparty dependency OpenImage Denoise includes oneDNN library # and the version we use only supports x86_64. # It's also only relevant for tools build and desktop platforms, - # as doing lightmap generation and denoising on Android or HTML5 + # as doing lightmap generation and denoising on Android or Web # would be a bit far-fetched. desktop_platforms = ["linuxbsd", "macos", "windows"] return env["tools"] and platform in desktop_platforms and env["arch"] == "x86_64" diff --git a/modules/freetype/SCsub b/modules/freetype/SCsub index 8efcd72fb6..2680479acc 100644 --- a/modules/freetype/SCsub +++ b/modules/freetype/SCsub @@ -99,7 +99,7 @@ if env["builtin_freetype"]: sfnt = thirdparty_dir + "src/sfnt/sfnt.c" # Must be done after all CPPDEFINES are being set so we can copy them. - if env["platform"] == "javascript": + if env["platform"] == "web": # Forcibly undefine this macro so SIMD is not used in this file, # since currently unsupported in WASM tmp_env = env_freetype.Clone() diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp index 61df8cdf06..02922086f0 100644 --- a/modules/gdscript/editor/gdscript_highlighter.cpp +++ b/modules/gdscript/editor/gdscript_highlighter.cpp @@ -45,10 +45,11 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l int previous_column = 0; bool prev_is_char = false; - bool prev_is_number = false; + bool prev_is_digit = false; bool prev_is_binary_op = false; bool in_keyword = false; bool in_word = false; + bool in_number = false; bool in_function_name = false; bool in_lambda = false; bool in_variable_declaration = false; @@ -94,7 +95,7 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l color = font_color; bool is_char = !is_symbol(str[j]); bool is_a_symbol = is_symbol(str[j]); - bool is_number = is_digit(str[j]); + bool is_a_digit = is_digit(str[j]); bool is_binary_op = false; /* color regions */ @@ -233,58 +234,80 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l in_region = -1; prev_is_char = false; - prev_is_number = false; + prev_is_digit = false; + prev_is_binary_op = false; continue; } } } + // A bit of a hack, but couldn't come up with anything better. + if (j > 0 && (str[j] == '&' || str[j] == '^' || str[j] == '%' || str[j] == '+' || str[j] == '-' || str[j] == '~' || str[j] == '.')) { + if (!keywords.has(previous_text)) { + if (previous_text == "PI" || previous_text == "TAU" || previous_text == "INF" || previous_text == "NAN") { + is_binary_op = true; + } else { + int k = j - 1; + while (k > 0 && is_whitespace(str[k])) { + k--; + } + if (!is_symbol(str[k]) || str[k] == '"' || str[k] == '\'' || str[k] == ')' || str[k] == ']' || str[k] == '}') { + is_binary_op = true; + } + } + } + } + + if (!is_char) { + in_keyword = false; + } + // allow ABCDEF in hex notation - if (is_hex_notation && (is_hex_digit(str[j]) || is_number)) { - is_number = true; + if (is_hex_notation && (is_hex_digit(str[j]) || is_a_digit)) { + is_a_digit = true; } else { is_hex_notation = false; } // disallow anything not a 0 or 1 in binary notation - if (is_bin_notation && (is_binary_digit(str[j]))) { - is_number = true; - } else if (is_bin_notation) { - is_bin_notation = false; - is_number = false; - } else { + if (is_bin_notation && !is_binary_digit(str[j])) { + is_a_digit = false; is_bin_notation = false; } - // check for dot or underscore or 'x' for hex notation in floating point number or 'e' for scientific notation - if ((str[j] == '.' || str[j] == 'x' || str[j] == 'b' || str[j] == '_' || str[j] == 'e') && !in_word && prev_is_number && !is_number) { - is_number = true; - is_a_symbol = false; - is_char = false; + if (!in_number && !in_word && is_a_digit) { + in_number = true; + } - if (str[j] == 'x' && str[j - 1] == '0') { - is_hex_notation = true; - } else if (str[j] == 'b' && str[j - 1] == '0') { + // Special cases for numbers + if (in_number && !is_a_digit) { + if (str[j] == 'b' && str[j - 1] == '0') { is_bin_notation = true; + } else if (str[j] == 'x' && str[j - 1] == '0') { + is_hex_notation = true; + } else if (!((str[j] == '-' || str[j] == '+') && str[j - 1] == 'e' && !prev_is_digit) && + !(str[j] == '_' && (prev_is_digit || str[j - 1] == 'b' || str[j - 1] == 'x' || str[j - 1] == '.')) && + !((str[j] == 'e' || str[j] == '.') && (prev_is_digit || str[j - 1] == '_')) && + !((str[j] == '-' || str[j] == '+' || str[j] == '~') && !prev_is_binary_op && str[j - 1] != 'e')) { + /* 1st row of condition: '+' or '-' after scientific notation; + 2nd row of condition: '_' as a numeric separator; + 3rd row of condition: Scientific notation 'e' and floating points; + 4th row of condition: Multiple unary operators. */ + in_number = false; } + } else if ((str[j] == '-' || str[j] == '+' || str[j] == '~' || (str[j] == '.' && str[j + 1] != '.' && (j == 0 || (j > 0 && str[j - 1] != '.')))) && !is_binary_op) { + // Start a number from unary mathematical operators and floating points, except for '..' + in_number = true; } - if (!in_word && (is_ascii_char(str[j]) || is_underscore(str[j])) && !is_number) { + if (!in_word && (is_ascii_char(str[j]) || is_underscore(str[j])) && !in_number) { in_word = true; } - if ((in_keyword || in_word) && !is_hex_notation) { - is_number = false; - } - if (is_a_symbol && str[j] != '.' && in_word) { in_word = false; } - if (!is_char) { - in_keyword = false; - } - if (!in_keyword && is_char && !prev_is_char) { int to = j; while (to < line_length && !is_symbol(str[to])) { @@ -355,7 +378,7 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l } } - if (!in_function_name && !in_member_variable && !in_keyword && !is_number && in_word) { + if (!in_function_name && !in_member_variable && !in_keyword && !in_number && in_word) { int k = j; while (k > 0 && !is_symbol(str[k]) && !is_whitespace(str[k])) { k--; @@ -403,22 +426,6 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l in_member_variable = false; } - if (j > 0 && (str[j] == '&' || str[j] == '^' || str[j] == '%' || str[j] == '+' || str[j] == '-' || str[j] == '~')) { - int k = j - 1; - while (k > 0 && is_whitespace(str[k])) { - k--; - } - if (!is_symbol(str[k]) || str[k] == '"' || str[k] == '\'' || str[k] == ')' || str[k] == ']' || str[k] == '}') { - is_binary_op = true; - } - } - - // Highlight '+' and '-' like numbers when unary - if ((str[j] == '+' || str[j] == '-' || str[j] == '~') && !is_binary_op) { - is_number = true; - is_a_symbol = false; - } - // Keep symbol color for binary '&&'. In the case of '&&&' use StringName color for the last ampersand if (!in_string_name && in_region == -1 && str[j] == '&' && !is_binary_op) { if (j >= 2 && str[j - 1] == '&' && str[j - 2] != '&' && prev_is_binary_op) { @@ -479,12 +486,12 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l } else { color = function_color; } + } else if (in_number) { + next_type = NUMBER; + color = number_color; } else if (is_a_symbol) { next_type = SYMBOL; color = symbol_color; - } else if (is_number) { - next_type = NUMBER; - color = number_color; } else if (expect_type) { next_type = TYPE; color = type_color; @@ -516,7 +523,7 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l } prev_is_char = is_char; - prev_is_number = is_number; + prev_is_digit = is_a_digit; prev_is_binary_op = is_binary_op; if (color != prev_color) { diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index cf2d6ae9f8..10babad378 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -683,7 +683,7 @@ bool GDScript::_update_exports(bool *r_err, bool p_recursive_call, PlaceHolderSc if (base.is_empty() || base.is_relative_path()) { ERR_PRINT(("Could not resolve relative path for parent class: " + path).utf8().get_data()); } else { - path = base.get_base_dir().plus_file(path); + path = base.get_base_dir().path_join(path); } } } else if (c->extends.size() != 0) { @@ -2204,7 +2204,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b if (c->icon_path.is_empty() || c->icon_path.is_absolute_path()) { *r_icon_path = c->icon_path; } else if (c->icon_path.is_relative_path()) { - *r_icon_path = p_path.get_base_dir().plus_file(c->icon_path).simplify_path(); + *r_icon_path = p_path.get_base_dir().path_join(c->icon_path).simplify_path(); } } if (r_base_type) { @@ -2232,7 +2232,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b } String subpath = subclass->extends_path; if (subpath.is_relative_path()) { - subpath = path.get_base_dir().plus_file(subpath).simplify_path(); + subpath = path.get_base_dir().path_join(subpath).simplify_path(); } if (OK != subparser.parse(subsource, subpath, false)) { diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index a07d4855f3..c8c876369f 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -260,7 +260,7 @@ Error GDScriptAnalyzer::resolve_inheritance(GDScriptParser::ClassNode *p_class, if (!p_class->extends_path.is_empty()) { if (p_class->extends_path.is_relative_path()) { - p_class->extends_path = class_type.script_path.get_base_dir().plus_file(p_class->extends_path).simplify_path(); + p_class->extends_path = class_type.script_path.get_base_dir().path_join(p_class->extends_path).simplify_path(); } Ref<GDScriptParserRef> parser = get_parser_for(p_class->extends_path); if (parser.is_null()) { @@ -3185,7 +3185,7 @@ void GDScriptAnalyzer::reduce_preload(GDScriptParser::PreloadNode *p_preload) { p_preload->resolved_path = p_preload->path->reduced_value; // TODO: Save this as script dependency. if (p_preload->resolved_path.is_relative_path()) { - p_preload->resolved_path = parser->script_path.get_base_dir().plus_file(p_preload->resolved_path); + p_preload->resolved_path = parser->script_path.get_base_dir().path_join(p_preload->resolved_path); } p_preload->resolved_path = p_preload->resolved_path.simplify_path(); if (!FileAccess::exists(p_preload->resolved_path)) { diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp index 44b60369ab..fd213e7b37 100644 --- a/modules/gdscript/language_server/gdscript_workspace.cpp +++ b/modules/gdscript/language_server/gdscript_workspace.cpp @@ -228,9 +228,9 @@ void GDScriptWorkspace::list_script_files(const String &p_root_dir, List<String> String file_name = dir->get_next(); while (file_name.length()) { if (dir->current_is_dir() && file_name != "." && file_name != ".." && file_name != "./") { - list_script_files(p_root_dir.plus_file(file_name), r_files); + list_script_files(p_root_dir.path_join(file_name), r_files); } else if (file_name.ends_with(".gd")) { - String script_file = p_root_dir.plus_file(file_name); + String script_file = p_root_dir.path_join(file_name); r_files.push_back(script_file); } file_name = dir->get_next(); diff --git a/modules/gdscript/tests/gdscript_test_runner.cpp b/modules/gdscript/tests/gdscript_test_runner.cpp index e3b956369d..6c346acb7e 100644 --- a/modules/gdscript/tests/gdscript_test_runner.cpp +++ b/modules/gdscript/tests/gdscript_test_runner.cpp @@ -247,7 +247,7 @@ bool GDScriptTestRunner::make_tests_for_dir(const String &p_dir) { next = dir->get_next(); continue; } - if (!make_tests_for_dir(current_dir.plus_file(next))) { + if (!make_tests_for_dir(current_dir.path_join(next))) { return false; } } else { @@ -255,7 +255,7 @@ bool GDScriptTestRunner::make_tests_for_dir(const String &p_dir) { #ifndef DEBUG_ENABLED // On release builds, skip tests marked as debug only. Error open_err = OK; - Ref<FileAccess> script_file(FileAccess::open(current_dir.plus_file(next), FileAccess::READ, &open_err)); + Ref<FileAccess> script_file(FileAccess::open(current_dir.path_join(next), FileAccess::READ, &open_err)); if (open_err != OK) { ERR_PRINT(vformat(R"(Couldn't open test file "%s".)", next)); next = dir->get_next(); @@ -272,7 +272,7 @@ bool GDScriptTestRunner::make_tests_for_dir(const String &p_dir) { if (!is_generating && !dir->file_exists(out_file)) { ERR_FAIL_V_MSG(false, "Could not find output file for " + next); } - GDScriptTest test(current_dir.plus_file(next), current_dir.plus_file(out_file), source_dir); + GDScriptTest test(current_dir.path_join(next), current_dir.path_join(out_file), source_dir); tests.push_back(test); } } diff --git a/modules/gltf/doc_classes/GLTFCamera.xml b/modules/gltf/doc_classes/GLTFCamera.xml index b90abd105d..49efaa1564 100644 --- a/modules/gltf/doc_classes/GLTFCamera.xml +++ b/modules/gltf/doc_classes/GLTFCamera.xml @@ -10,6 +10,34 @@ <link title="GLTF camera detailed specification">https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#reference-camera</link> <link title="GLTF camera spec and example file">https://github.com/KhronosGroup/glTF-Tutorials/blob/master/gltfTutorial/gltfTutorial_015_SimpleCameras.md</link> </tutorials> + <methods> + <method name="from_dictionary" qualifiers="static"> + <return type="GLTFCamera" /> + <param index="0" name="dictionary" type="Dictionary" /> + <description> + Creates a new GLTFCamera instance by parsing the given [Dictionary]. + </description> + </method> + <method name="from_node" qualifiers="static"> + <return type="GLTFCamera" /> + <param index="0" name="camera_node" type="Camera3D" /> + <description> + Create a new GLTFCamera instance from the given Godot [Camera3D] node. + </description> + </method> + <method name="to_dictionary" qualifiers="const"> + <return type="Dictionary" /> + <description> + Serializes this GLTFCamera instance into a [Dictionary]. + </description> + </method> + <method name="to_node" qualifiers="const"> + <return type="Camera3D" /> + <description> + Converts this GLTFCamera instance into a Godot [Camera3D] node. + </description> + </method> + </methods> <members> <member name="depth_far" type="float" setter="set_depth_far" getter="get_depth_far" default="4000.0"> The distance to the far culling boundary for this camera relative to its local Z axis, in meters. This maps to GLTF's [code]zfar[/code] property. diff --git a/modules/gltf/doc_classes/GLTFLight.xml b/modules/gltf/doc_classes/GLTFLight.xml index db2dfb487a..7fd59e14bc 100644 --- a/modules/gltf/doc_classes/GLTFLight.xml +++ b/modules/gltf/doc_classes/GLTFLight.xml @@ -9,6 +9,34 @@ <tutorials> <link title="KHR_lights_punctual GLTF extension spec">https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_lights_punctual</link> </tutorials> + <methods> + <method name="from_dictionary" qualifiers="static"> + <return type="GLTFLight" /> + <param index="0" name="dictionary" type="Dictionary" /> + <description> + Creates a new GLTFLight instance by parsing the given [Dictionary]. + </description> + </method> + <method name="from_node" qualifiers="static"> + <return type="GLTFLight" /> + <param index="0" name="light_node" type="Light3D" /> + <description> + Create a new GLTFLight instance from the given Godot [Light3D] node. + </description> + </method> + <method name="to_dictionary" qualifiers="const"> + <return type="Dictionary" /> + <description> + Serializes this GLTFLight instance into a [Dictionary]. + </description> + </method> + <method name="to_node" qualifiers="const"> + <return type="Light3D" /> + <description> + Converts this GLTFLight instance into a Godot [Light3D] node. + </description> + </method> + </methods> <members> <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)"> The [Color] of the light. Defaults to white. A black color causes the light to have no effect. diff --git a/modules/gltf/editor/editor_scene_importer_blend.cpp b/modules/gltf/editor/editor_scene_importer_blend.cpp index 707769da35..ab52761e17 100644 --- a/modules/gltf/editor/editor_scene_importer_blend.cpp +++ b/modules/gltf/editor/editor_scene_importer_blend.cpp @@ -64,7 +64,7 @@ Node *EditorSceneFormatImporterBlend::import_scene(const String &p_path, uint32_ // Escape paths to be valid Python strings to embed in the script. const String source_global = ProjectSettings::get_singleton()->globalize_path(p_path).c_escape(); - const String sink = ProjectSettings::get_singleton()->get_imported_files_path().plus_file( + const String sink = ProjectSettings::get_singleton()->get_imported_files_path().path_join( vformat("%s-%s.gltf", p_path.get_file().get_basename(), p_path.md5_text())); const String sink_global = ProjectSettings::get_singleton()->globalize_path(sink).c_escape(); @@ -193,9 +193,9 @@ Node *EditorSceneFormatImporterBlend::import_scene(const String &p_path, uint32_ String blender_path = EDITOR_GET("filesystem/import/blender/blender3_path"); #ifdef WINDOWS_ENABLED - blender_path = blender_path.plus_file("blender.exe"); + blender_path = blender_path.path_join("blender.exe"); #else - blender_path = blender_path.plus_file("blender"); + blender_path = blender_path.path_join("blender"); #endif List<String> args; @@ -287,14 +287,14 @@ void EditorSceneFormatImporterBlend::get_import_options(const String &p_path, Li static bool _test_blender_path(const String &p_path, String *r_err = nullptr) { String path = p_path; #ifdef WINDOWS_ENABLED - path = path.plus_file("blender.exe"); + path = path.path_join("blender.exe"); #else - path = path.plus_file("blender"); + path = path.path_join("blender"); #endif #if defined(MACOS_ENABLED) if (!FileAccess::exists(path)) { - path = path.plus_file("Blender"); + path = path.path_join("Blender"); } #endif @@ -485,7 +485,7 @@ bool EditorFileSystemImportFormatSupportQueryBlend::query() { bool found = false; for (const String &path : mdfind_paths) { - found = _autodetect_path(path.plus_file("Contents/MacOS")); + found = _autodetect_path(path.path_join("Contents/MacOS")); if (found) { break; } diff --git a/modules/gltf/editor/editor_scene_importer_fbx.cpp b/modules/gltf/editor/editor_scene_importer_fbx.cpp index faad2d315d..017a44cccf 100644 --- a/modules/gltf/editor/editor_scene_importer_fbx.cpp +++ b/modules/gltf/editor/editor_scene_importer_fbx.cpp @@ -57,7 +57,7 @@ Node *EditorSceneFormatImporterFBX::import_scene(const String &p_path, uint32_t // enclosed in double quotes by OS::execute(), so we only need to escape those. // `c_escape_multiline()` seems to do this (escapes `\` and `"` only). const String source_global = ProjectSettings::get_singleton()->globalize_path(p_path).c_escape_multiline(); - const String sink = ProjectSettings::get_singleton()->get_imported_files_path().plus_file( + const String sink = ProjectSettings::get_singleton()->get_imported_files_path().path_join( vformat("%s-%s.glb", p_path.get_file().get_basename(), p_path.md5_text())); const String sink_global = ProjectSettings::get_singleton()->globalize_path(sink).c_escape_multiline(); diff --git a/modules/gltf/extensions/gltf_light.cpp b/modules/gltf/extensions/gltf_light.cpp index af21a4e804..ab5a15c671 100644 --- a/modules/gltf/extensions/gltf_light.cpp +++ b/modules/gltf/extensions/gltf_light.cpp @@ -31,6 +31,12 @@ #include "gltf_light.h" void GLTFLight::_bind_methods() { + ClassDB::bind_static_method("GLTFLight", D_METHOD("from_node", "light_node"), &GLTFLight::from_node); + ClassDB::bind_method(D_METHOD("to_node"), &GLTFLight::to_node); + + ClassDB::bind_static_method("GLTFLight", D_METHOD("from_dictionary", "dictionary"), &GLTFLight::from_dictionary); + ClassDB::bind_method(D_METHOD("to_dictionary"), &GLTFLight::to_dictionary); + ClassDB::bind_method(D_METHOD("get_color"), &GLTFLight::get_color); ClassDB::bind_method(D_METHOD("set_color", "color"), &GLTFLight::set_color); ClassDB::bind_method(D_METHOD("get_intensity"), &GLTFLight::get_intensity); @@ -99,3 +105,116 @@ float GLTFLight::get_outer_cone_angle() { void GLTFLight::set_outer_cone_angle(float p_outer_cone_angle) { outer_cone_angle = p_outer_cone_angle; } + +Ref<GLTFLight> GLTFLight::from_node(const Light3D *p_light) { + Ref<GLTFLight> l; + l.instantiate(); + l->color = p_light->get_color(); + if (cast_to<DirectionalLight3D>(p_light)) { + l->light_type = "directional"; + const DirectionalLight3D *light = cast_to<const DirectionalLight3D>(p_light); + l->intensity = light->get_param(DirectionalLight3D::PARAM_ENERGY); + l->range = FLT_MAX; // Range for directional lights is infinite in Godot. + } else if (cast_to<const OmniLight3D>(p_light)) { + l->light_type = "point"; + const OmniLight3D *light = cast_to<const OmniLight3D>(p_light); + l->range = light->get_param(OmniLight3D::PARAM_RANGE); + l->intensity = light->get_param(OmniLight3D::PARAM_ENERGY); + } else if (cast_to<const SpotLight3D>(p_light)) { + l->light_type = "spot"; + const SpotLight3D *light = cast_to<const SpotLight3D>(p_light); + l->range = light->get_param(SpotLight3D::PARAM_RANGE); + l->intensity = light->get_param(SpotLight3D::PARAM_ENERGY); + l->outer_cone_angle = Math::deg_to_rad(light->get_param(SpotLight3D::PARAM_SPOT_ANGLE)); + // This equation is the inverse of the import equation (which has a desmos link). + float angle_ratio = 1 - (0.2 / (0.1 + light->get_param(SpotLight3D::PARAM_SPOT_ATTENUATION))); + angle_ratio = MAX(0, angle_ratio); + l->inner_cone_angle = l->outer_cone_angle * angle_ratio; + } + return l; +} + +Light3D *GLTFLight::to_node() const { + if (light_type == "directional") { + DirectionalLight3D *light = memnew(DirectionalLight3D); + light->set_param(Light3D::PARAM_ENERGY, intensity); + light->set_color(color); + return light; + } + const float range = CLAMP(this->range, 0, 4096); + if (light_type == "point") { + OmniLight3D *light = memnew(OmniLight3D); + light->set_param(OmniLight3D::PARAM_ENERGY, intensity); + light->set_param(OmniLight3D::PARAM_RANGE, range); + light->set_color(color); + return light; + } + if (light_type == "spot") { + SpotLight3D *light = memnew(SpotLight3D); + light->set_param(SpotLight3D::PARAM_ENERGY, intensity); + light->set_param(SpotLight3D::PARAM_RANGE, range); + light->set_param(SpotLight3D::PARAM_SPOT_ANGLE, Math::rad_to_deg(outer_cone_angle)); + light->set_color(color); + // Line of best fit derived from guessing, see https://www.desmos.com/calculator/biiflubp8b + // The points in desmos are not exact, except for (1, infinity). + float angle_ratio = inner_cone_angle / outer_cone_angle; + float angle_attenuation = 0.2 / (1 - angle_ratio) - 0.1; + light->set_param(SpotLight3D::PARAM_SPOT_ATTENUATION, angle_attenuation); + return light; + } + return memnew(Light3D); +} + +Ref<GLTFLight> GLTFLight::from_dictionary(const Dictionary p_dictionary) { + ERR_FAIL_COND_V_MSG(!p_dictionary.has("type"), Ref<GLTFLight>(), "Failed to parse GLTF light, missing required field 'type'."); + Ref<GLTFLight> light; + light.instantiate(); + const String &type = p_dictionary["type"]; + light->light_type = type; + + if (p_dictionary.has("color")) { + const Array &arr = p_dictionary["color"]; + if (arr.size() == 3) { + light->color = Color(arr[0], arr[1], arr[2]).linear_to_srgb(); + } else { + ERR_PRINT("Error parsing GLTF light: The color must have exactly 3 numbers."); + } + } + if (p_dictionary.has("intensity")) { + light->intensity = p_dictionary["intensity"]; + } + if (p_dictionary.has("range")) { + light->range = p_dictionary["range"]; + } + if (type == "spot") { + const Dictionary &spot = p_dictionary["spot"]; + light->inner_cone_angle = spot["innerConeAngle"]; + light->outer_cone_angle = spot["outerConeAngle"]; + if (light->inner_cone_angle >= light->outer_cone_angle) { + ERR_PRINT("Error parsing GLTF light: The inner angle must be smaller than the outer angle."); + } + } else if (type != "point" && type != "directional") { + ERR_PRINT("Error parsing GLTF light: Light type '" + type + "' is unknown."); + } + return light; +} + +Dictionary GLTFLight::to_dictionary() const { + Dictionary d; + Array color_array; + color_array.resize(3); + color_array[0] = color.r; + color_array[1] = color.g; + color_array[2] = color.b; + d["color"] = color_array; + d["type"] = light_type; + if (light_type == "spot") { + Dictionary spot_dict; + spot_dict["innerConeAngle"] = inner_cone_angle; + spot_dict["outerConeAngle"] = outer_cone_angle; + d["spot"] = spot_dict; + } + d["intensity"] = intensity; + d["range"] = range; + return d; +} diff --git a/modules/gltf/extensions/gltf_light.h b/modules/gltf/extensions/gltf_light.h index f0765a1bbc..04980e144c 100644 --- a/modules/gltf/extensions/gltf_light.h +++ b/modules/gltf/extensions/gltf_light.h @@ -70,6 +70,12 @@ public: float get_outer_cone_angle(); void set_outer_cone_angle(float p_outer_cone_angle); + + static Ref<GLTFLight> from_node(const Light3D *p_light); + Light3D *to_node() const; + + static Ref<GLTFLight> from_dictionary(const Dictionary p_dictionary); + Dictionary to_dictionary() const; }; #endif // GLTF_LIGHT_H diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 87ba1d9869..0ed212e21f 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -786,7 +786,7 @@ Error GLTFDocument::_parse_buffers(Ref<GLTFState> state, const String &p_base_pa } else { // Relative path to an external image file. ERR_FAIL_COND_V(p_base_path.is_empty(), ERR_INVALID_PARAMETER); uri = uri.uri_decode(); - uri = p_base_path.plus_file(uri).replace("\\", "/"); // Fix for Windows. + uri = p_base_path.path_join(uri).replace("\\", "/"); // Fix for Windows. buffer_data = FileAccess::get_file_as_array(uri); ERR_FAIL_COND_V_MSG(buffer.size() == 0, ERR_PARSE_ERROR, "glTF: Couldn't load binary file as an array: " + uri); } @@ -3039,8 +3039,8 @@ Error GLTFDocument::_serialize_images(Ref<GLTFState> state, const String &p_path if (!da->dir_exists(new_texture_dir)) { da->make_dir(new_texture_dir); } - image->save_png(new_texture_dir.plus_file(name)); - d["uri"] = texture_dir.plus_file(name).uri_encode(); + image->save_png(new_texture_dir.path_join(name)); + d["uri"] = texture_dir.path_join(name).uri_encode(); } images.push_back(d); } @@ -3118,7 +3118,7 @@ Error GLTFDocument::_parse_images(Ref<GLTFState> state, const String &p_base_pat } else { // Relative path to an external image file. ERR_FAIL_COND_V(p_base_path.is_empty(), ERR_INVALID_PARAMETER); uri = uri.uri_decode(); - uri = p_base_path.plus_file(uri).replace("\\", "/"); // Fix for Windows. + uri = p_base_path.path_join(uri).replace("\\", "/"); // Fix for Windows. // ResourceLoader will rely on the file extension to use the relevant loader. // The spec says that if mimeType is defined, it should take precedence (e.g. // there could be a `.png` image which is actually JPEG), but there's no easy @@ -4534,28 +4534,7 @@ Error GLTFDocument::_serialize_lights(Ref<GLTFState> state) { } Array lights; for (GLTFLightIndex i = 0; i < state->lights.size(); i++) { - Dictionary d; - Ref<GLTFLight> light = state->lights[i]; - Array color; - color.resize(3); - color[0] = light->color.r; - color[1] = light->color.g; - color[2] = light->color.b; - d["color"] = color; - d["type"] = light->light_type; - if (light->light_type == "spot") { - Dictionary s; - float inner_cone_angle = light->inner_cone_angle; - s["innerConeAngle"] = inner_cone_angle; - float outer_cone_angle = light->outer_cone_angle; - s["outerConeAngle"] = outer_cone_angle; - d["spot"] = s; - } - float intensity = light->intensity; - d["intensity"] = intensity; - float range = light->range; - d["range"] = range; - lights.push_back(d); + lights.push_back(state->lights[i]->to_dictionary()); } Dictionary extensions; @@ -4577,27 +4556,7 @@ Error GLTFDocument::_serialize_cameras(Ref<GLTFState> state) { Array cameras; cameras.resize(state->cameras.size()); for (GLTFCameraIndex i = 0; i < state->cameras.size(); i++) { - Dictionary d; - - Ref<GLTFCamera> camera = state->cameras[i]; - - if (camera->get_perspective()) { - Dictionary persp; - persp["yfov"] = camera->get_fov(); - persp["zfar"] = camera->get_depth_far(); - persp["znear"] = camera->get_depth_near(); - d["perspective"] = persp; - d["type"] = "perspective"; - } else { - Dictionary ortho; - ortho["ymag"] = camera->get_size_mag(); - ortho["xmag"] = camera->get_size_mag(); - ortho["zfar"] = camera->get_depth_far(); - ortho["znear"] = camera->get_depth_near(); - d["orthographic"] = ortho; - d["type"] = "orthographic"; - } - cameras[i] = d; + cameras[i] = state->cameras[i]->to_dictionary(); } if (!state->cameras.size()) { @@ -4627,35 +4586,10 @@ Error GLTFDocument::_parse_lights(Ref<GLTFState> state) { const Array &lights = lights_punctual["lights"]; for (GLTFLightIndex light_i = 0; light_i < lights.size(); light_i++) { - const Dictionary &d = lights[light_i]; - - Ref<GLTFLight> light; - light.instantiate(); - ERR_FAIL_COND_V(!d.has("type"), ERR_PARSE_ERROR); - const String &type = d["type"]; - light->light_type = type; - - if (d.has("color")) { - const Array &arr = d["color"]; - ERR_FAIL_COND_V(arr.size() != 3, ERR_PARSE_ERROR); - const Color c = Color(arr[0], arr[1], arr[2]).linear_to_srgb(); - light->color = c; - } - if (d.has("intensity")) { - light->intensity = d["intensity"]; + Ref<GLTFLight> light = GLTFLight::from_dictionary(lights[light_i]); + if (light.is_null()) { + return Error::ERR_PARSE_ERROR; } - if (d.has("range")) { - light->range = d["range"]; - } - if (type == "spot") { - const Dictionary &spot = d["spot"]; - light->inner_cone_angle = spot["innerConeAngle"]; - light->outer_cone_angle = spot["outerConeAngle"]; - ERR_CONTINUE_MSG(light->inner_cone_angle >= light->outer_cone_angle, "The inner angle must be smaller than the outer angle."); - } else if (type != "point" && type != "directional") { - ERR_CONTINUE_MSG(true, "Light type is unknown."); - } - state->lights.push_back(light); } @@ -4672,35 +4606,7 @@ Error GLTFDocument::_parse_cameras(Ref<GLTFState> state) { const Array cameras = state->json["cameras"]; for (GLTFCameraIndex i = 0; i < cameras.size(); i++) { - const Dictionary &d = cameras[i]; - - Ref<GLTFCamera> camera; - camera.instantiate(); - ERR_FAIL_COND_V(!d.has("type"), ERR_PARSE_ERROR); - const String &type = d["type"]; - if (type == "perspective") { - camera->set_perspective(true); - if (d.has("perspective")) { - const Dictionary &persp = d["perspective"]; - camera->set_fov(persp["yfov"]); - if (persp.has("zfar")) { - camera->set_depth_far(persp["zfar"]); - } - camera->set_depth_near(persp["znear"]); - } - } else if (type == "orthographic") { - camera->set_perspective(false); - if (d.has("orthographic")) { - const Dictionary &ortho = d["orthographic"]; - camera->set_size_mag(ortho["ymag"]); - camera->set_depth_far(ortho["zfar"]); - camera->set_depth_near(ortho["znear"]); - } - } else { - ERR_FAIL_V_MSG(ERR_PARSE_ERROR, "Camera3D should be in 'orthographic' or 'perspective'"); - } - - state->cameras.push_back(camera); + state->cameras.push_back(GLTFCamera::from_dictionary(cameras[i])); } print_verbose("glTF: Total cameras: " + itos(state->cameras.size())); @@ -5148,45 +5054,7 @@ Node3D *GLTFDocument::_generate_light(Ref<GLTFState> state, const GLTFNodeIndex print_verbose("glTF: Creating light for: " + gltf_node->get_name()); Ref<GLTFLight> l = state->lights[gltf_node->light]; - - float intensity = l->intensity; - if (intensity > 10) { - // GLTF spec has the default around 1, but Blender defaults lights to 100. - // The only sane way to handle this is to check where it came from and - // handle it accordingly. If it's over 10, it probably came from Blender. - intensity /= 100; - } - - if (l->light_type == "directional") { - DirectionalLight3D *light = memnew(DirectionalLight3D); - light->set_param(Light3D::PARAM_ENERGY, intensity); - light->set_color(l->color); - return light; - } - - const float range = CLAMP(l->range, 0, 4096); - if (l->light_type == "point") { - OmniLight3D *light = memnew(OmniLight3D); - light->set_param(OmniLight3D::PARAM_ENERGY, intensity); - light->set_param(OmniLight3D::PARAM_RANGE, range); - light->set_color(l->color); - return light; - } - if (l->light_type == "spot") { - SpotLight3D *light = memnew(SpotLight3D); - light->set_param(SpotLight3D::PARAM_ENERGY, intensity); - light->set_param(SpotLight3D::PARAM_RANGE, range); - light->set_param(SpotLight3D::PARAM_SPOT_ANGLE, Math::rad_to_deg(l->outer_cone_angle)); - light->set_color(l->color); - - // Line of best fit derived from guessing, see https://www.desmos.com/calculator/biiflubp8b - // The points in desmos are not exact, except for (1, infinity). - float angle_ratio = l->inner_cone_angle / l->outer_cone_angle; - float angle_attenuation = 0.2 / (1 - angle_ratio) - 0.1; - light->set_param(SpotLight3D::PARAM_SPOT_ATTENUATION, angle_attenuation); - return light; - } - return memnew(Node3D); + return l->to_node(); } Camera3D *GLTFDocument::_generate_camera(Ref<GLTFState> state, const GLTFNodeIndex node_index) { @@ -5194,32 +5062,16 @@ Camera3D *GLTFDocument::_generate_camera(Ref<GLTFState> state, const GLTFNodeInd ERR_FAIL_INDEX_V(gltf_node->camera, state->cameras.size(), nullptr); - Camera3D *camera = memnew(Camera3D); print_verbose("glTF: Creating camera for: " + gltf_node->get_name()); Ref<GLTFCamera> c = state->cameras[gltf_node->camera]; - camera->set_projection(c->get_perspective() ? Camera3D::PROJECTION_PERSPECTIVE : Camera3D::PROJECTION_ORTHOGONAL); - // GLTF spec (yfov) is in radians, Godot's camera (fov) is in degrees. - camera->set_fov(Math::rad_to_deg(c->get_fov())); - // GLTF spec (xmag and ymag) is a radius in meters, Godot's camera (size) is a diameter in meters. - camera->set_size(c->get_size_mag() * 2.0f); - camera->set_near(c->get_depth_near()); - camera->set_far(c->get_depth_far()); - return camera; + return c->to_node(); } GLTFCameraIndex GLTFDocument::_convert_camera(Ref<GLTFState> state, Camera3D *p_camera) { print_verbose("glTF: Converting camera: " + p_camera->get_name()); - Ref<GLTFCamera> c; - c.instantiate(); - c->set_perspective(p_camera->get_projection() == Camera3D::ProjectionType::PROJECTION_PERSPECTIVE); - // GLTF spec (yfov) is in radians, Godot's camera (fov) is in degrees. - c->set_fov(Math::deg_to_rad(p_camera->get_fov())); - // GLTF spec (xmag and ymag) is a radius in meters, Godot's camera (size) is a diameter in meters. - c->set_size_mag(p_camera->get_size() * 0.5f); - c->set_depth_far(p_camera->get_far()); - c->set_depth_near(p_camera->get_near()); + Ref<GLTFCamera> c = GLTFCamera::from_node(p_camera); GLTFCameraIndex camera_index = state->cameras.size(); state->cameras.push_back(c); return camera_index; @@ -5228,31 +5080,7 @@ GLTFCameraIndex GLTFDocument::_convert_camera(Ref<GLTFState> state, Camera3D *p_ GLTFLightIndex GLTFDocument::_convert_light(Ref<GLTFState> state, Light3D *p_light) { print_verbose("glTF: Converting light: " + p_light->get_name()); - Ref<GLTFLight> l; - l.instantiate(); - l->color = p_light->get_color(); - if (cast_to<DirectionalLight3D>(p_light)) { - l->light_type = "directional"; - DirectionalLight3D *light = cast_to<DirectionalLight3D>(p_light); - l->intensity = light->get_param(DirectionalLight3D::PARAM_ENERGY); - l->range = FLT_MAX; // Range for directional lights is infinite in Godot. - } else if (cast_to<OmniLight3D>(p_light)) { - l->light_type = "point"; - OmniLight3D *light = cast_to<OmniLight3D>(p_light); - l->range = light->get_param(OmniLight3D::PARAM_RANGE); - l->intensity = light->get_param(OmniLight3D::PARAM_ENERGY); - } else if (cast_to<SpotLight3D>(p_light)) { - l->light_type = "spot"; - SpotLight3D *light = cast_to<SpotLight3D>(p_light); - l->range = light->get_param(SpotLight3D::PARAM_RANGE); - l->intensity = light->get_param(SpotLight3D::PARAM_ENERGY); - l->outer_cone_angle = Math::deg_to_rad(light->get_param(SpotLight3D::PARAM_SPOT_ANGLE)); - - // This equation is the inverse of the import equation (which has a desmos link). - float angle_ratio = 1 - (0.2 / (0.1 + light->get_param(SpotLight3D::PARAM_SPOT_ATTENUATION))); - angle_ratio = MAX(0, angle_ratio); - l->inner_cone_angle = l->outer_cone_angle * angle_ratio; - } + Ref<GLTFLight> l = GLTFLight::from_node(p_light); GLTFLightIndex light_index = state->lights.size(); state->lights.push_back(l); diff --git a/modules/gltf/structures/gltf_camera.cpp b/modules/gltf/structures/gltf_camera.cpp index c492913ea7..5069f39c4b 100644 --- a/modules/gltf/structures/gltf_camera.cpp +++ b/modules/gltf/structures/gltf_camera.cpp @@ -31,6 +31,12 @@ #include "gltf_camera.h" void GLTFCamera::_bind_methods() { + ClassDB::bind_static_method("GLTFCamera", D_METHOD("from_node", "camera_node"), &GLTFCamera::from_node); + ClassDB::bind_method(D_METHOD("to_node"), &GLTFCamera::to_node); + + ClassDB::bind_static_method("GLTFCamera", D_METHOD("from_dictionary", "dictionary"), &GLTFCamera::from_dictionary); + ClassDB::bind_method(D_METHOD("to_dictionary"), &GLTFCamera::to_dictionary); + ClassDB::bind_method(D_METHOD("get_perspective"), &GLTFCamera::get_perspective); ClassDB::bind_method(D_METHOD("set_perspective", "perspective"), &GLTFCamera::set_perspective); ClassDB::bind_method(D_METHOD("get_fov"), &GLTFCamera::get_fov); @@ -48,3 +54,78 @@ void GLTFCamera::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "depth_far"), "set_depth_far", "get_depth_far"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "depth_near"), "set_depth_near", "get_depth_near"); } + +Ref<GLTFCamera> GLTFCamera::from_node(const Camera3D *p_camera) { + Ref<GLTFCamera> c; + c.instantiate(); + c->set_perspective(p_camera->get_projection() == Camera3D::ProjectionType::PROJECTION_PERSPECTIVE); + // GLTF spec (yfov) is in radians, Godot's camera (fov) is in degrees. + c->set_fov(Math::deg_to_rad(p_camera->get_fov())); + // GLTF spec (xmag and ymag) is a radius in meters, Godot's camera (size) is a diameter in meters. + c->set_size_mag(p_camera->get_size() * 0.5f); + c->set_depth_far(p_camera->get_far()); + c->set_depth_near(p_camera->get_near()); + return c; +} + +Camera3D *GLTFCamera::to_node() const { + Camera3D *camera = memnew(Camera3D); + camera->set_projection(perspective ? Camera3D::PROJECTION_PERSPECTIVE : Camera3D::PROJECTION_ORTHOGONAL); + // GLTF spec (yfov) is in radians, Godot's camera (fov) is in degrees. + camera->set_fov(Math::rad_to_deg(fov)); + // GLTF spec (xmag and ymag) is a radius in meters, Godot's camera (size) is a diameter in meters. + camera->set_size(size_mag * 2.0f); + camera->set_near(depth_near); + camera->set_far(depth_far); + return camera; +} + +Ref<GLTFCamera> GLTFCamera::from_dictionary(const Dictionary p_dictionary) { + ERR_FAIL_COND_V_MSG(!p_dictionary.has("type"), Ref<GLTFCamera>(), "Failed to parse GLTF camera, missing required field 'type'."); + Ref<GLTFCamera> camera; + camera.instantiate(); + const String &type = p_dictionary["type"]; + if (type == "perspective") { + camera->set_perspective(true); + if (p_dictionary.has("perspective")) { + const Dictionary &persp = p_dictionary["perspective"]; + camera->set_fov(persp["yfov"]); + if (persp.has("zfar")) { + camera->set_depth_far(persp["zfar"]); + } + camera->set_depth_near(persp["znear"]); + } + } else if (type == "orthographic") { + camera->set_perspective(false); + if (p_dictionary.has("orthographic")) { + const Dictionary &ortho = p_dictionary["orthographic"]; + camera->set_size_mag(ortho["ymag"]); + camera->set_depth_far(ortho["zfar"]); + camera->set_depth_near(ortho["znear"]); + } + } else { + ERR_PRINT("Error parsing GLTF camera: Camera type '" + type + "' is unknown, should be perspective or orthographic."); + } + return camera; +} + +Dictionary GLTFCamera::to_dictionary() const { + Dictionary d; + if (perspective) { + Dictionary persp; + persp["yfov"] = fov; + persp["zfar"] = depth_far; + persp["znear"] = depth_near; + d["perspective"] = persp; + d["type"] = "perspective"; + } else { + Dictionary ortho; + ortho["ymag"] = size_mag; + ortho["xmag"] = size_mag; + ortho["zfar"] = depth_far; + ortho["znear"] = depth_near; + d["orthographic"] = ortho; + d["type"] = "orthographic"; + } + return d; +} diff --git a/modules/gltf/structures/gltf_camera.h b/modules/gltf/structures/gltf_camera.h index 8e528c063f..50ae10e17a 100644 --- a/modules/gltf/structures/gltf_camera.h +++ b/modules/gltf/structures/gltf_camera.h @@ -63,6 +63,12 @@ public: void set_depth_far(real_t p_val) { depth_far = p_val; } real_t get_depth_near() const { return depth_near; } void set_depth_near(real_t p_val) { depth_near = p_val; } + + static Ref<GLTFCamera> from_node(const Camera3D *p_light); + Camera3D *to_node() const; + + static Ref<GLTFCamera> from_dictionary(const Dictionary p_dictionary); + Dictionary to_dictionary() const; }; #endif // GLTF_CAMERA_H diff --git a/modules/gridmap/editor/grid_map_editor_plugin.cpp b/modules/gridmap/editor/grid_map_editor_plugin.cpp index b0f73a98c9..17f9832096 100644 --- a/modules/gridmap/editor/grid_map_editor_plugin.cpp +++ b/modules/gridmap/editor/grid_map_editor_plugin.cpp @@ -1011,6 +1011,13 @@ void GridMapEditor::_draw_grids(const Vector3 &cell_size) { } } +void GridMapEditor::_update_theme() { + options->set_icon(get_theme_icon(SNAME("GridMap"), SNAME("EditorIcons"))); + search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + mode_thumbnail->set_icon(get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons"))); + mode_list->set_icon(get_theme_icon(SNAME("FileList"), SNAME("EditorIcons"))); +} + void GridMapEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { @@ -1031,6 +1038,7 @@ void GridMapEditor::_notification(int p_what) { _update_selection_transform(); _update_paste_indicator(); + _update_theme(); } break; case NOTIFICATION_EXIT_TREE: { @@ -1071,10 +1079,7 @@ void GridMapEditor::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - options->set_icon(get_theme_icon(SNAME("GridMap"), SNAME("EditorIcons"))); - search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - mode_thumbnail->set_icon(get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons"))); - mode_list->set_icon(get_theme_icon(SNAME("FileList"), SNAME("EditorIcons"))); + _update_theme(); } break; case NOTIFICATION_APPLICATION_FOCUS_OUT: { diff --git a/modules/gridmap/editor/grid_map_editor_plugin.h b/modules/gridmap/editor/grid_map_editor_plugin.h index 773bf4b6a4..a64dc4a80b 100644 --- a/modules/gridmap/editor/grid_map_editor_plugin.h +++ b/modules/gridmap/editor/grid_map_editor_plugin.h @@ -193,6 +193,7 @@ class GridMapEditor : public VBoxContainer { void _item_selected_cbk(int idx); void _update_cursor_transform(); void _update_cursor_instance(); + void _update_theme(); void _text_changed(const String &p_text); void _sbox_input(const Ref<InputEvent> &p_ie); diff --git a/modules/mono/build_scripts/mono_configure.py b/modules/mono/build_scripts/mono_configure.py index ef7dbabf66..c2d5452837 100644 --- a/modules/mono/build_scripts/mono_configure.py +++ b/modules/mono/build_scripts/mono_configure.py @@ -16,7 +16,7 @@ def module_supports_tools_on(platform): def configure(env, env_mono): # is_android = env["platform"] == "android" - # is_javascript = env["platform"] == "javascript" + # is_web = env["platform"] == "web" # is_ios = env["platform"] == "ios" # is_ios_sim = is_ios and env["arch"] in ["x86_32", "x86_64"] diff --git a/modules/mono/config.py b/modules/mono/config.py index b599414a2c..ad78c8c898 100644 --- a/modules/mono/config.py +++ b/modules/mono/config.py @@ -1,4 +1,4 @@ -# Prior to .NET Core, we supported these: ["windows", "macos", "linuxbsd", "android", "haiku", "javascript", "ios"] +# Prior to .NET Core, we supported these: ["windows", "macos", "linuxbsd", "android", "haiku", "web", "ios"] # Eventually support for each them should be added back (except Haiku if not supported by .NET Core) supported_platforms = ["windows", "macos", "linuxbsd"] @@ -10,8 +10,8 @@ def can_build(env, platform): def get_opts(platform): from SCons.Variables import BoolVariable, PathVariable - default_mono_static = platform in ["ios", "javascript"] - default_mono_bundles_zlib = platform in ["javascript"] + default_mono_static = platform in ["ios", "web"] + default_mono_bundles_zlib = platform in ["web"] return [ PathVariable( diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 8b135051c5..2e59987fe6 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -694,7 +694,7 @@ bool CSharpLanguage::is_assembly_reloading_needed() { } assembly_path = GodotSharpDirs::get_res_temp_assemblies_dir() - .plus_file(assembly_name + ".dll"); + .path_join(assembly_name + ".dll"); assembly_path = ProjectSettings::get_singleton()->globalize_path(assembly_path); if (!FileAccess::exists(assembly_path)) { @@ -1085,7 +1085,7 @@ void CSharpLanguage::_editor_init_callback() { const void **interop_funcs = godotsharp::get_editor_interop_funcs(interop_funcs_size); Object *editor_plugin_obj = GDMono::get_singleton()->get_plugin_callbacks().LoadToolsAssemblyCallback( - GodotSharpDirs::get_data_editor_tools_dir().plus_file("GodotTools.dll").utf16(), + GodotSharpDirs::get_data_editor_tools_dir().path_join("GodotTools.dll").utf16(), interop_funcs, interop_funcs_size); CRASH_COND(editor_plugin_obj == nullptr); diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.props b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.props index ad41ab04d5..59ce1da17b 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.props +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.props @@ -81,7 +81,7 @@ <GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'haiku' ">GODOT_HAIKU;GODOT_PC</GodotPlatformConstants> <GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'android' ">GODOT_ANDROID;GODOT_MOBILE</GodotPlatformConstants> <GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'ios' ">GODOT_IPHONE;GODOT_IOS;GODOT_MOBILE</GodotPlatformConstants> - <GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'javascript' ">GODOT_JAVASCRIPT;GODOT_HTML5;GODOT_WASM;GODOT_WEB</GodotPlatformConstants> + <GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'web' ">GODOT_JAVASCRIPT;GODOT_HTML5;GODOT_WASM;GODOT_WEB</GodotPlatformConstants> <GodotDefineConstants>$(GodotDefineConstants);$(GodotPlatformConstants)</GodotDefineConstants> </PropertyGroup> diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/ExportedFields.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/ExportedFields.cs index ac9f59aa99..ac8d6473a6 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/ExportedFields.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/ExportedFields.cs @@ -94,16 +94,20 @@ namespace Godot.SourceGenerators.Sample [Export] private NodePath field_NodePath = new NodePath("foo"); [Export] private RID field_RID; - [Export] private Godot.Collections.Dictionary field_GodotDictionary = + [Export] + private Godot.Collections.Dictionary field_GodotDictionary = new() { { "foo", 10 }, { Vector2.Up, Colors.Chocolate } }; - [Export] private Godot.Collections.Array field_GodotArray = + [Export] + private Godot.Collections.Array field_GodotArray = new() { "foo", 10, Vector2.Up, Colors.Chocolate }; - [Export] private Godot.Collections.Dictionary<string, bool> field_GodotGenericDictionary = + [Export] + private Godot.Collections.Dictionary<string, bool> field_GodotGenericDictionary = new() { { "foo", true }, { "bar", false } }; - [Export] private Godot.Collections.Array<int> field_GodotGenericArray = + [Export] + private Godot.Collections.Array<int> field_GodotGenericArray = new() { 0, 1, 2, 3, 4, 5, 6 }; } } diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/ExportedProperties.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/ExportedProperties.cs index 4a0e8075f0..3020cfbc50 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/ExportedProperties.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/ExportedProperties.cs @@ -94,16 +94,20 @@ namespace Godot.SourceGenerators.Sample [Export] private NodePath property_NodePath { get; set; } = new NodePath("foo"); [Export] private RID property_RID { get; set; } - [Export] private Godot.Collections.Dictionary property_GodotDictionary { get; set; } = + [Export] + private Godot.Collections.Dictionary property_GodotDictionary { get; set; } = new() { { "foo", 10 }, { Vector2.Up, Colors.Chocolate } }; - [Export] private Godot.Collections.Array property_GodotArray { get; set; } = + [Export] + private Godot.Collections.Array property_GodotArray { get; set; } = new() { "foo", 10, Vector2.Up, Colors.Chocolate }; - [Export] private Godot.Collections.Dictionary<string, bool> property_GodotGenericDictionary { get; set; } = + [Export] + private Godot.Collections.Dictionary<string, bool> property_GodotGenericDictionary { get; set; } = new() { { "foo", true }, { "bar", false } }; - [Export] private Godot.Collections.Array<int> property_GodotGenericArray { get; set; } = + [Export] + private Godot.Collections.Array<int> property_GodotGenericArray { get; set; } = new() { 0, 1, 2, 3, 4, 5, 6 }; } } diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs index 3dfa8000ba..e28788ec0b 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs @@ -168,6 +168,32 @@ namespace Godot.SourceGenerators location?.SourceTree?.FilePath)); } + public static void ReportExportedMemberIsIndexer( + GeneratorExecutionContext context, + ISymbol exportedMemberSymbol + ) + { + var locations = exportedMemberSymbol.Locations; + var location = locations.FirstOrDefault(l => l.SourceTree != null) ?? locations.FirstOrDefault(); + + string message = $"Attempted to export indexer property: " + + $"'{exportedMemberSymbol.ToDisplayString()}'"; + + string description = $"{message}. Indexer properties can't be exported." + + " Remove the '[Export]' attribute."; + + context.ReportDiagnostic(Diagnostic.Create( + new DiagnosticDescriptor(id: "GD0105", + title: message, + messageFormat: message, + category: "Usage", + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description), + location, + location?.SourceTree?.FilePath)); + } + public static void ReportSignalDelegateMissingSuffix( GeneratorExecutionContext context, INamedTypeSymbol delegateSymbol) diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotPluginsInitializerGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotPluginsInitializerGenerator.cs index 54da6218f3..7ec3f88e5d 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotPluginsInitializerGenerator.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotPluginsInitializerGenerator.cs @@ -27,7 +27,8 @@ namespace GodotPlugins.Game internal static partial class Main { [UnmanagedCallersOnly(EntryPoint = ""godotsharp_game_main_init"")] - private static godot_bool InitializeFromGameProject(IntPtr godotDllHandle, IntPtr outManagedCallbacks) + private static godot_bool InitializeFromGameProject(IntPtr godotDllHandle, IntPtr outManagedCallbacks, + IntPtr unmanagedCallbacks, int unmanagedCallbacksSize) { try { @@ -37,6 +38,8 @@ namespace GodotPlugins.Game NativeLibrary.SetDllImportResolver(coreApiAssembly, dllImportResolver); + NativeFuncs.Initialize(unmanagedCallbacks, unmanagedCallbacksSize); + ManagedCallbacks.Create(outManagedCallbacks); ScriptManagerBridge.LookupScriptsInAssembly(typeof(GodotPlugins.Game.Main).Assembly); diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalUtils.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalUtils.cs index 831ac3bdeb..efdd50098e 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalUtils.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalUtils.cs @@ -16,7 +16,7 @@ namespace Godot.SourceGenerators INamedTypeSymbol GetTypeByMetadataNameOrThrow(string fullyQualifiedMetadataName) { return compilation.GetTypeByMetadataName(fullyQualifiedMetadataName) ?? - throw new InvalidOperationException("Type not found: " + fullyQualifiedMetadataName); + throw new InvalidOperationException($"Type not found: '{fullyQualifiedMetadataName}'."); } GodotObjectType = GetTypeByMetadataNameOrThrow("Godot.Object"); diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs index 7629595b3a..fc46d82dff 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs @@ -112,7 +112,8 @@ namespace Godot.SourceGenerators var propertySymbols = members .Where(s => !s.IsStatic && s.Kind == SymbolKind.Property) - .Cast<IPropertySymbol>(); + .Cast<IPropertySymbol>() + .Where(s => !s.IsIndexer); var fieldSymbols = members .Where(s => !s.IsStatic && s.Kind == SymbolKind.Field && !s.IsImplicitlyDeclared) diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertyDefValGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertyDefValGenerator.cs index 85fadaa52e..c7745391d0 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertyDefValGenerator.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertyDefValGenerator.cs @@ -134,6 +134,12 @@ namespace Godot.SourceGenerators continue; } + if (property.IsIndexer) + { + Common.ReportExportedMemberIsIndexer(context, property); + continue; + } + // TODO: We should still restore read-only properties after reloading assembly. Two possible ways: reflection or turn RestoreGodotObjectData into a constructor overload. // Ignore properties without a getter or without a setter. Godot properties must be both readable and writable. if (property.IsWriteOnly) @@ -148,7 +154,6 @@ namespace Godot.SourceGenerators continue; } - var propertyType = property.Type; var marshalType = MarshalUtils.ConvertManagedTypeToMarshalType(propertyType, typeCache); diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSerializationGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSerializationGenerator.cs index 5a84122c4c..39a99ff8ba 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSerializationGenerator.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSerializationGenerator.cs @@ -112,7 +112,8 @@ namespace Godot.SourceGenerators var propertySymbols = members .Where(s => !s.IsStatic && s.Kind == SymbolKind.Property) - .Cast<IPropertySymbol>(); + .Cast<IPropertySymbol>() + .Where(s => !s.IsIndexer); var fieldSymbols = members .Where(s => !s.IsStatic && s.Kind == SymbolKind.Field && !s.IsImplicitlyDeclared) diff --git a/modules/mono/editor/GodotTools/GodotTools.Core/StringExtensions.cs b/modules/mono/editor/GodotTools/GodotTools.Core/StringExtensions.cs index 60a4f297c9..7c5502814f 100644 --- a/modules/mono/editor/GodotTools/GodotTools.Core/StringExtensions.cs +++ b/modules/mono/editor/GodotTools/GodotTools.Core/StringExtensions.cs @@ -34,7 +34,7 @@ namespace GodotTools.Core path = path.Replace('\\', '/'); path = path[path.Length - 1] == '/' ? path.Substring(0, path.Length - 1) : path; - string[] parts = path.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries); + string[] parts = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); path = string.Join(Path.DirectorySeparatorChar.ToString(), parts).Trim(); @@ -60,7 +60,7 @@ namespace GodotTools.Core public static string ToSafeDirName(this string dirName, bool allowDirSeparator = false) { - var invalidChars = new List<string> {":", "*", "?", "\"", "<", ">", "|"}; + var invalidChars = new List<string> { ":", "*", "?", "\"", "<", ">", "|" }; if (allowDirSeparator) { diff --git a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Client.cs b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Client.cs index bc09e1ebf9..72e2a1fc0d 100644 --- a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Client.cs +++ b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Client.cs @@ -123,12 +123,16 @@ namespace GodotTools.IdeMessaging string projectMetadataDir = Path.Combine(godotProjectDir, ".godot", "mono", "metadata"); // FileSystemWatcher requires an existing directory - if (!Directory.Exists(projectMetadataDir)) { + if (!Directory.Exists(projectMetadataDir)) + { // Check if the non hidden version exists string nonHiddenProjectMetadataDir = Path.Combine(godotProjectDir, "godot", "mono", "metadata"); - if (Directory.Exists(nonHiddenProjectMetadataDir)) { + if (Directory.Exists(nonHiddenProjectMetadataDir)) + { projectMetadataDir = nonHiddenProjectMetadataDir; - } else { + } + else + { Directory.CreateDirectory(projectMetadataDir); } } diff --git a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Peer.cs b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Peer.cs index 10d7e1898e..dd3913b4f3 100644 --- a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Peer.cs +++ b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Peer.cs @@ -78,7 +78,7 @@ namespace GodotTools.IdeMessaging clientStream.WriteTimeout = ClientWriteTimeout; clientReader = new StreamReader(clientStream, Encoding.UTF8); - clientWriter = new StreamWriter(clientStream, Encoding.UTF8) {NewLine = "\n"}; + clientWriter = new StreamWriter(clientStream, Encoding.UTF8) { NewLine = "\n" }; } public async Task Process() diff --git a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/ResponseAwaiter.cs b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/ResponseAwaiter.cs index 548e7f06ee..a57c82b608 100644 --- a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/ResponseAwaiter.cs +++ b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/ResponseAwaiter.cs @@ -17,7 +17,7 @@ namespace GodotTools.IdeMessaging if (content.Status == MessageStatus.Ok) SetResult(JsonConvert.DeserializeObject<T>(content.Body)); else - SetResult(new T {Status = content.Status}); + SetResult(new T { Status = content.Status }); } } } diff --git a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Utils/NotifyAwaiter.cs b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Utils/NotifyAwaiter.cs index d84a63c83c..a285d5fa97 100644 --- a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Utils/NotifyAwaiter.cs +++ b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Utils/NotifyAwaiter.cs @@ -21,14 +21,14 @@ namespace GodotTools.IdeMessaging.Utils public void OnCompleted(Action continuation) { if (this.continuation != null) - throw new InvalidOperationException("This awaiter has already been listened"); + throw new InvalidOperationException("This awaiter already has a continuation."); this.continuation = continuation; } public void SetResult(T result) { if (IsCompleted) - throw new InvalidOperationException("This awaiter is already completed"); + throw new InvalidOperationException("This awaiter is already completed."); IsCompleted = true; this.result = result; @@ -39,7 +39,7 @@ namespace GodotTools.IdeMessaging.Utils public void SetException(Exception exception) { if (IsCompleted) - throw new InvalidOperationException("This awaiter is already completed"); + throw new InvalidOperationException("This awaiter is already completed."); IsCompleted = true; this.exception = exception; diff --git a/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs b/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs index 7a4641dbbc..cc0deb6cc0 100644 --- a/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs +++ b/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs @@ -249,8 +249,8 @@ namespace GodotTools.OpenVisualStudio // Thread call was rejected, so try again. int IOleMessageFilter.RetryRejectedCall(IntPtr hTaskCallee, int dwTickCount, int dwRejectType) { + // flag = SERVERCALL_RETRYLATER if (dwRejectType == 2) - // flag = SERVERCALL_RETRYLATER { // Retry the thread call immediately if return >= 0 & < 100 return 99; diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs index fb6d2a707b..f3c8e89dff 100644 --- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs +++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs @@ -15,7 +15,7 @@ namespace GodotTools.ProjectEditor public static ProjectRootElement GenGameProject(string name) { if (name.Length == 0) - throw new ArgumentException("Project name is empty", nameof(name)); + throw new ArgumentException("Project name is empty.", nameof(name)); var root = ProjectRootElement.Create(NewProjectFileOptions.None); @@ -37,7 +37,7 @@ namespace GodotTools.ProjectEditor public static string GenAndSaveGameProject(string dir, string name) { if (name.Length == 0) - throw new ArgumentException("Project name is empty", nameof(name)); + throw new ArgumentException("Project name is empty.", nameof(name)); string path = Path.Combine(dir, name + ".csproj"); diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs index 43256953f5..993c6d9217 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs @@ -62,7 +62,7 @@ namespace GodotTools.Build private static bool Build(BuildInfo buildInfo) { if (_buildInProgress != null) - throw new InvalidOperationException("A build is already in progress"); + throw new InvalidOperationException("A build is already in progress."); _buildInProgress = buildInfo; @@ -111,7 +111,7 @@ namespace GodotTools.Build public static async Task<bool> BuildAsync(BuildInfo buildInfo) { if (_buildInProgress != null) - throw new InvalidOperationException("A build is already in progress"); + throw new InvalidOperationException("A build is already in progress."); _buildInProgress = buildInfo; @@ -157,7 +157,7 @@ namespace GodotTools.Build private static bool Publish(BuildInfo buildInfo) { if (_buildInProgress != null) - throw new InvalidOperationException("A build is already in progress"); + throw new InvalidOperationException("A build is already in progress."); _buildInProgress = buildInfo; diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs index 96d1fc28bf..180cc3cf14 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs @@ -120,13 +120,13 @@ namespace GodotTools.Build private void IssueActivated(int idx) { if (idx < 0 || idx >= _issuesList.ItemCount) - throw new IndexOutOfRangeException("Item list index out of range"); + throw new ArgumentOutOfRangeException(nameof(idx), "Item list index out of range."); // Get correct issue idx from issue list int issueIndex = (int)_issuesList.GetItemMetadata(idx); if (issueIndex < 0 || issueIndex >= _issues.Count) - throw new IndexOutOfRangeException("Issue index out of range"); + throw new InvalidOperationException("Issue index out of range."); BuildIssue issue = _issues[issueIndex]; @@ -293,7 +293,7 @@ namespace GodotTools.Build public void RestartBuild() { if (!HasBuildExited) - throw new InvalidOperationException("Build already started"); + throw new InvalidOperationException("Build already started."); BuildManager.RestartBuild(this); } @@ -301,7 +301,7 @@ namespace GodotTools.Build public void StopBuild() { if (!HasBuildExited) - throw new InvalidOperationException("Build is not in progress"); + throw new InvalidOperationException("Build is not in progress."); BuildManager.StopBuild(this); } diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs index 655be0ab5e..d0cd529d1f 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs @@ -176,8 +176,9 @@ namespace GodotTools.Build arguments.Add("--no-restore"); // Incremental or rebuild - if (buildInfo.Rebuild) - arguments.Add("--no-incremental"); + // TODO: Not supported in `dotnet publish` (https://github.com/dotnet/sdk/issues/11099) + // if (buildInfo.Rebuild) + // arguments.Add("--no-incremental"); // Configuration arguments.Add("-c"); diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/NuGetUtils.cs b/modules/mono/editor/GodotTools/GodotTools/Build/NuGetUtils.cs index fdb86c8f34..d2e0e128b5 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/NuGetUtils.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/NuGetUtils.cs @@ -49,7 +49,7 @@ namespace GodotTools.Build { // Check that the root node is the expected one if (rootNode.Name != nuGetConfigRootName) - throw new Exception("Invalid root Xml node for NuGet.Config. " + + throw new FormatException("Invalid root Xml node for NuGet.Config. " + $"Expected '{nuGetConfigRootName}' got '{rootNode.Name}'."); } diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs b/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs index fc325fc25b..2184cae6d6 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs @@ -76,13 +76,20 @@ namespace GodotTools.Export else { string arch = ""; - if (features.Contains("x86_64")) { + if (features.Contains("x86_64")) + { arch = "x86_64"; - } else if (features.Contains("x86_32")) { + } + else if (features.Contains("x86_32")) + { arch = "x86_32"; - } else if (features.Contains("arm64")) { + } + else if (features.Contains("arm64")) + { arch = "arm64"; - } else if (features.Contains("arm32")) { + } + else if (features.Contains("arm32")) + { arch = "arm32"; } CompileAssembliesForDesktop(exporter, platform, isDebug, arch, aotOpts, aotTempDir, outputDataDir, assembliesPrepared, bclDir); @@ -212,7 +219,7 @@ namespace GodotTools.Export int clangExitCode = OS.ExecuteCommand(XcodeHelper.FindXcodeTool("clang"), clangArgs); if (clangExitCode != 0) - throw new Exception($"Command 'clang' exited with code: {clangExitCode}"); + throw new InvalidOperationException($"Command 'clang' exited with code: {clangExitCode}."); objFilePathsForiOSArch[arch].Add(objFilePath); } @@ -318,7 +325,7 @@ MONO_AOT_MODE_LAST = 1000, int arExitCode = OS.ExecuteCommand(XcodeHelper.FindXcodeTool("ar"), arArgs); if (arExitCode != 0) - throw new Exception($"Command 'ar' exited with code: {arExitCode}"); + throw new InvalidOperationException($"Command 'ar' exited with code: {arExitCode}."); arFilePathsForAllArchs.Add(arOutputFilePath); } @@ -336,7 +343,7 @@ MONO_AOT_MODE_LAST = 1000, int lipoExitCode = OS.ExecuteCommand(XcodeHelper.FindXcodeTool("lipo"), lipoArgs); if (lipoExitCode != 0) - throw new Exception($"Command 'lipo' exited with code: {lipoExitCode}"); + throw new InvalidOperationException($"Command 'lipo' exited with code: {lipoExitCode}."); // TODO: Add the AOT lib and interpreter libs as device only to suppress warnings when targeting the simulator @@ -436,7 +443,7 @@ MONO_AOT_MODE_LAST = 1000, } else if (!Directory.Exists(androidToolchain)) { - throw new FileNotFoundException("Android toolchain not found: " + androidToolchain); + throw new FileNotFoundException($"Android toolchain not found: '{androidToolchain}'."); } var androidToolPrefixes = new Dictionary<string, string> @@ -533,12 +540,12 @@ MONO_AOT_MODE_LAST = 1000, Console.WriteLine($"Running: \"{process.StartInfo.FileName}\" {process.StartInfo.Arguments}"); if (!process.Start()) - throw new Exception("Failed to start process for Mono AOT compiler"); + throw new InvalidOperationException("Failed to start process for Mono AOT compiler."); process.WaitForExit(); if (process.ExitCode != 0) - throw new Exception($"Mono AOT compiler exited with code: {process.ExitCode}"); + throw new InvalidOperationException($"Mono AOT compiler exited with code: {process.ExitCode}."); } } diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs index e1b5530b93..851a8b3689 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs @@ -98,21 +98,21 @@ namespace GodotTools.Export return; if (!DeterminePlatformFromFeatures(features, out string platform)) - throw new NotSupportedException("Target platform not supported"); + throw new NotSupportedException("Target platform not supported."); if (!new[] { OS.Platforms.Windows, OS.Platforms.LinuxBSD, OS.Platforms.MacOS } .Contains(platform)) { - throw new NotImplementedException("Target platform not yet implemented"); + throw new NotImplementedException("Target platform not yet implemented."); } string outputDir = new FileInfo(path).Directory?.FullName ?? - throw new FileNotFoundException("Output base directory not found"); + throw new FileNotFoundException("Output base directory not found."); string buildConfig = isDebug ? "ExportDebug" : "ExportRelease"; // TODO: This works for now, as we only implemented support for x86 family desktop so far, but it needs to be fixed - string arch = features.Contains("64") ? "x86_64" : "x86"; + string arch = features.Contains("x86_64") ? "x86_64" : "x86"; string ridOS = DetermineRuntimeIdentifierOS(platform); string ridArch = DetermineRuntimeIdentifierArch(arch); @@ -131,7 +131,7 @@ namespace GodotTools.Export if (!BuildManager.PublishProjectBlocking(buildConfig, platform, runtimeIdentifier, publishOutputTempDir)) { - throw new Exception("Failed to build project"); + throw new InvalidOperationException("Failed to build project."); } string soExt = ridOS switch diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs b/modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs index 93ef837a83..4f5bebfb42 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs @@ -16,7 +16,7 @@ namespace GodotTools.Export _XcodePath = FindXcode(); if (_XcodePath == null) - throw new Exception("Could not find Xcode"); + throw new FileNotFoundException("Could not find Xcode."); } return _XcodePath; diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs index 2054f3f125..994c11fa72 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs +++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs @@ -342,7 +342,7 @@ namespace GodotTools DotNetSolution.MigrateFromOldConfigNames(GodotSharpDirs.ProjectSlnPath); var msbuildProject = ProjectUtils.Open(GodotSharpDirs.ProjectCsProjPath) - ?? throw new Exception("Cannot open C# project"); + ?? throw new InvalidOperationException("Cannot open C# project."); // NOTE: The order in which changes are made to the project is important diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeManager.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeManager.cs index 95b60aded1..9df90ac608 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeManager.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeManager.cs @@ -153,7 +153,7 @@ namespace GodotTools.Ides } default: - throw new ArgumentOutOfRangeException(); + throw new ArgumentOutOfRangeException(nameof(editorId)); } } @@ -180,17 +180,17 @@ namespace GodotTools.Ides public void SendOpenFile(string file) { - SendRequest<OpenFileResponse>(new OpenFileRequest {File = file}); + SendRequest<OpenFileResponse>(new OpenFileRequest { File = file }); } public void SendOpenFile(string file, int line) { - SendRequest<OpenFileResponse>(new OpenFileRequest {File = file, Line = line}); + SendRequest<OpenFileResponse>(new OpenFileRequest { File = file, Line = line }); } public void SendOpenFile(string file, int line, int column) { - SendRequest<OpenFileResponse>(new OpenFileRequest {File = file, Line = line, Column = column}); + SendRequest<OpenFileResponse>(new OpenFileRequest { File = file, Line = line, Column = column }); } } diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/MessagingServer.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/MessagingServer.cs index 6f11831b80..62db6e3af5 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Ides/MessagingServer.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Ides/MessagingServer.cs @@ -385,7 +385,7 @@ namespace GodotTools.Ides // However, it doesn't fix resource loading if the rest of the path is also case insensitive. string scriptFileLocalized = FsPathUtils.LocalizePathWithCaseChecked(request.ScriptFile); - var response = new CodeCompletionResponse {Kind = request.Kind, ScriptFile = request.ScriptFile}; + var response = new CodeCompletionResponse { Kind = request.Kind, ScriptFile = request.ScriptFile }; response.Suggestions = await Task.Run(() => Internal.CodeCompletionRequest(response.Kind, scriptFileLocalized ?? request.ScriptFile)); return response; diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs index 4caab035de..dad6e35344 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs @@ -42,7 +42,7 @@ namespace GodotTools.Ides.Rider { return CollectAllRiderPathsLinux(); } - throw new Exception("Unexpected OS."); + throw new InvalidOperationException("Unexpected OS."); } catch (Exception e) { @@ -216,7 +216,7 @@ namespace GodotTools.Ides.Rider return "../../build.txt"; if (OS.IsMacOS) return "Contents/Resources/build.txt"; - throw new Exception("Unknown OS."); + throw new InvalidOperationException("Unknown OS."); } [SupportedOSPlatform("windows")] diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs index e3fe1622d0..fd810996f7 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs @@ -74,11 +74,11 @@ namespace GodotTools.Internals internal static unsafe void Initialize(IntPtr unmanagedCallbacks, int unmanagedCallbacksSize) { if (initialized) - throw new InvalidOperationException("Already initialized"); + throw new InvalidOperationException("Already initialized."); initialized = true; if (unmanagedCallbacksSize != sizeof(InternalUnmanagedCallbacks)) - throw new ArgumentException("Unmanaged callbacks size mismatch"); + throw new ArgumentException("Unmanaged callbacks size mismatch.", nameof(unmanagedCallbacksSize)); _unmanagedCallbacks = Unsafe.AsRef<InternalUnmanagedCallbacks>((void*)unmanagedCallbacks); } diff --git a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs index 651922d019..c16f803226 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs @@ -30,7 +30,7 @@ namespace GodotTools.Utils public const string Haiku = "Haiku"; public const string Android = "Android"; public const string iOS = "iOS"; - public const string HTML5 = "HTML5"; + public const string Web = "Web"; } /// <summary> @@ -45,7 +45,7 @@ namespace GodotTools.Utils public const string Haiku = "haiku"; public const string Android = "android"; public const string iOS = "ios"; - public const string HTML5 = "javascript"; + public const string Web = "web"; } /// <summary> @@ -70,14 +70,12 @@ namespace GodotTools.Utils { ["Windows"] = Platforms.Windows, ["macOS"] = Platforms.MacOS, - ["LinuxBSD"] = Platforms.LinuxBSD, - // "X11" for compatibility, temporarily, while we are on an outdated branch - ["X11"] = Platforms.LinuxBSD, + ["Linux"] = Platforms.LinuxBSD, ["UWP"] = Platforms.UWP, ["Haiku"] = Platforms.Haiku, ["Android"] = Platforms.Android, ["iOS"] = Platforms.iOS, - ["HTML5"] = Platforms.HTML5 + ["Web"] = Platforms.Web }; public static readonly Dictionary<string, string> PlatformNameMap = new Dictionary<string, string> @@ -92,7 +90,7 @@ namespace GodotTools.Utils [Names.Haiku] = Platforms.Haiku, [Names.Android] = Platforms.Android, [Names.iOS] = Platforms.iOS, - [Names.HTML5] = Platforms.HTML5 + [Names.Web] = Platforms.Web }; public static readonly Dictionary<string, string> DotNetOSPlatformMap = new Dictionary<string, string> @@ -107,7 +105,7 @@ namespace GodotTools.Utils [Platforms.UWP] = DotNetOS.Win10, [Platforms.Android] = DotNetOS.Android, [Platforms.iOS] = DotNetOS.iOS, - [Platforms.HTML5] = DotNetOS.Browser + [Platforms.Web] = DotNetOS.Browser }; private static bool IsOS(string name) @@ -144,7 +142,7 @@ namespace GodotTools.Utils private static readonly Lazy<bool> _isHaiku = new(() => IsOS(Names.Haiku)); private static readonly Lazy<bool> _isAndroid = new(() => IsOS(Names.Android)); private static readonly Lazy<bool> _isiOS = new(() => IsOS(Names.iOS)); - private static readonly Lazy<bool> _isHTML5 = new(() => IsOS(Names.HTML5)); + private static readonly Lazy<bool> _isWeb = new(() => IsOS(Names.Web)); private static readonly Lazy<bool> _isUnixLike = new(() => IsAnyOS(UnixLikePlatforms)); [SupportedOSPlatformGuard("windows")] public static bool IsWindows => _isWindows.Value || IsUWP; @@ -161,7 +159,7 @@ namespace GodotTools.Utils [SupportedOSPlatformGuard("ios")] public static bool IsiOS => _isiOS.Value; - [SupportedOSPlatformGuard("browser")] public static bool IsHTML5 => _isHTML5.Value; + [SupportedOSPlatformGuard("browser")] public static bool IsWeb => _isWeb.Value; public static bool IsUnixLike => _isUnixLike.Value; public static char PathSep => IsWindows ? ';' : ':'; @@ -206,10 +204,10 @@ namespace GodotTools.Utils return searchDirs.Select(dir => Path.Combine(dir, name)).FirstOrDefault(File.Exists); return (from dir in searchDirs - select Path.Combine(dir, name) + select Path.Combine(dir, name) into path - from ext in windowsExts - select path + ext).FirstOrDefault(File.Exists); + from ext in windowsExts + select path + ext).FirstOrDefault(File.Exists); } [return: MaybeNull] @@ -257,7 +255,7 @@ namespace GodotTools.Utils using Process process = Process.Start(startInfo); if (process == null) - throw new Exception("No process was started"); + throw new InvalidOperationException("No process was started."); process.BeginOutputReadLine(); process.BeginErrorReadLine(); diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index d70a1e6c88..0e496454a1 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -1315,7 +1315,7 @@ Error BindingsGenerator::generate_cs_api(const String &p_output_dir) { // Generate GodotSharp source files - String core_proj_dir = output_dir.plus_file(CORE_API_ASSEMBLY_NAME); + String core_proj_dir = output_dir.path_join(CORE_API_ASSEMBLY_NAME); proj_err = generate_cs_core_project(core_proj_dir); if (proj_err != OK) { @@ -1325,7 +1325,7 @@ Error BindingsGenerator::generate_cs_api(const String &p_output_dir) { // Generate GodotSharpEditor source files - String editor_proj_dir = output_dir.plus_file(EDITOR_API_ASSEMBLY_NAME); + String editor_proj_dir = output_dir.path_join(EDITOR_API_ASSEMBLY_NAME); proj_err = generate_cs_editor_project(editor_proj_dir); if (proj_err != OK) { @@ -3880,7 +3880,7 @@ static void handle_cmdline_options(String glue_dir_path) { CRASH_COND(glue_dir_path.is_empty()); - if (bindings_generator.generate_cs_api(glue_dir_path.plus_file(API_SOLUTION_NAME)) != OK) { + if (bindings_generator.generate_cs_api(glue_dir_path.path_join(API_SOLUTION_NAME)) != OK) { ERR_PRINT(generate_all_glue_option + ": Failed to generate the C# API."); } } diff --git a/modules/mono/editor/code_completion.cpp b/modules/mono/editor/code_completion.cpp index 7bce6f2c21..40296eef10 100644 --- a/modules/mono/editor/code_completion.cpp +++ b/modules/mono/editor/code_completion.cpp @@ -35,6 +35,7 @@ #include "editor/editor_settings.h" #include "scene/gui/control.h" #include "scene/main/node.h" +#include "scene/theme/theme_db.h" namespace gdmono { @@ -162,9 +163,9 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr } if (dir_access->dir_exists(filename)) { - directories.push_back(dir_access->get_current_dir().plus_file(filename)); + directories.push_back(dir_access->get_current_dir().path_join(filename)); } else if (filename.ends_with(".tscn") || filename.ends_with(".scn")) { - suggestions.push_back(quoted(dir_access->get_current_dir().plus_file(filename))); + suggestions.push_back(quoted(dir_access->get_current_dir().path_join(filename))); } filename = dir_access->get_next(); @@ -195,7 +196,7 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr Node *base = _try_find_owner_node_in_tree(script); if (base && Object::cast_to<Control>(base)) { List<StringName> sn; - Theme::get_default()->get_color_list(base->get_class(), &sn); + ThemeDB::get_singleton()->get_default_theme()->get_color_list(base->get_class(), &sn); for (const StringName &E : sn) { suggestions.push_back(quoted(E)); @@ -207,7 +208,7 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr Node *base = _try_find_owner_node_in_tree(script); if (base && Object::cast_to<Control>(base)) { List<StringName> sn; - Theme::get_default()->get_constant_list(base->get_class(), &sn); + ThemeDB::get_singleton()->get_default_theme()->get_constant_list(base->get_class(), &sn); for (const StringName &E : sn) { suggestions.push_back(quoted(E)); @@ -219,7 +220,7 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr Node *base = _try_find_owner_node_in_tree(script); if (base && Object::cast_to<Control>(base)) { List<StringName> sn; - Theme::get_default()->get_font_list(base->get_class(), &sn); + ThemeDB::get_singleton()->get_default_theme()->get_font_list(base->get_class(), &sn); for (const StringName &E : sn) { suggestions.push_back(quoted(E)); @@ -231,7 +232,7 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr Node *base = _try_find_owner_node_in_tree(script); if (base && Object::cast_to<Control>(base)) { List<StringName> sn; - Theme::get_default()->get_font_size_list(base->get_class(), &sn); + ThemeDB::get_singleton()->get_default_theme()->get_font_size_list(base->get_class(), &sn); for (const StringName &E : sn) { suggestions.push_back(quoted(E)); @@ -243,7 +244,7 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr Node *base = _try_find_owner_node_in_tree(script); if (base && Object::cast_to<Control>(base)) { List<StringName> sn; - Theme::get_default()->get_stylebox_list(base->get_class(), &sn); + ThemeDB::get_singleton()->get_default_theme()->get_stylebox_list(base->get_class(), &sn); for (const StringName &E : sn) { suggestions.push_back(quoted(E)); diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp index 1ef78c3ac2..6f42ad6916 100644 --- a/modules/mono/editor/editor_internal_calls.cpp +++ b/modules/mono/editor/editor_internal_calls.cpp @@ -98,7 +98,7 @@ bool godot_icall_EditorProgress_Step(const godot_string *p_task, const godot_str } void godot_icall_Internal_FullExportTemplatesDir(godot_string *r_dest) { - String full_templates_dir = EditorPaths::get_singleton()->get_export_templates_dir().plus_file(VERSION_FULL_CONFIG); + String full_templates_dir = EditorPaths::get_singleton()->get_export_templates_dir().path_join(VERSION_FULL_CONFIG); memnew_placement(r_dest, String(full_templates_dir)); } diff --git a/modules/mono/glue/GodotSharp/GodotPlugins/Main.cs b/modules/mono/glue/GodotSharp/GodotPlugins/Main.cs index dad7464410..8308bada24 100644 --- a/modules/mono/glue/GodotSharp/GodotPlugins/Main.cs +++ b/modules/mono/glue/GodotSharp/GodotPlugins/Main.cs @@ -153,7 +153,7 @@ namespace GodotPlugins string assemblyPath = new(nAssemblyPath); if (_editorApiAssembly == null) - throw new InvalidOperationException("The Godot editor API assembly is not loaded"); + throw new InvalidOperationException("The Godot editor API assembly is not loaded."); var (assembly, _) = LoadPlugin(assemblyPath); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs index b3a36e8ac8..17f680361d 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs @@ -145,6 +145,9 @@ namespace Godot /// Gets the position of one of the 8 endpoints of the <see cref="AABB"/>. /// </summary> /// <param name="idx">Which endpoint to get.</param> + /// <exception cref="ArgumentOutOfRangeException"> + /// <paramref name="idx"/> is less than 0 or greater than 7. + /// </exception> /// <returns>An endpoint of the <see cref="AABB"/>.</returns> public Vector3 GetEndpoint(int idx) { diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs index f2984bd1fb..1c98dfcdf6 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs @@ -510,7 +510,7 @@ namespace Godot.Collections if (_convertToVariantCallback == null || _convertToManagedCallback == null) { throw new InvalidOperationException( - $"The array element type is not supported for conversion to Variant: '{typeof(T).FullName}'"); + $"The array element type is not supported for conversion to Variant: '{typeof(T).FullName}'."); } } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs index ed20067a92..fbd59d649f 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs @@ -148,6 +148,9 @@ namespace Godot /// Access whole columns in the form of <see cref="Vector3"/>. /// </summary> /// <param name="column">Which column vector.</param> + /// <exception cref="ArgumentOutOfRangeException"> + /// <paramref name="column"/> is not 0, 1, 2 or 3. + /// </exception> /// <value>The basis column.</value> public Vector3 this[int column] { @@ -366,8 +369,8 @@ namespace Godot /// but are more efficient for some internal calculations. /// </summary> /// <param name="index">Which row.</param> - /// <exception cref="IndexOutOfRangeException"> - /// Thrown when the <paramref name="index"/> is not 0, 1 or 2. + /// <exception cref="ArgumentOutOfRangeException"> + /// <paramref name="index"/> is not 0, 1 or 2. /// </exception> /// <returns>One of <c>Row0</c>, <c>Row1</c>, or <c>Row2</c>.</returns> public Vector3 GetRow(int index) @@ -391,8 +394,8 @@ namespace Godot /// </summary> /// <param name="index">Which row.</param> /// <param name="value">The vector to set the row to.</param> - /// <exception cref="IndexOutOfRangeException"> - /// Thrown when the <paramref name="index"/> is not 0, 1 or 2. + /// <exception cref="ArgumentOutOfRangeException"> + /// <paramref name="index"/> is not 0, 1 or 2. /// </exception> public void SetRow(int index, Vector3 value) { diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs index 0cbaef3dad..33d8aef1a9 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs @@ -595,7 +595,7 @@ namespace Godot /// </summary> /// <param name="rgba">A string for the HTML hexadecimal representation of this color.</param> /// <exception name="ArgumentOutOfRangeException"> - /// Thrown when the given <paramref name="rgba"/> color code is invalid. + /// <paramref name="rgba"/> color code is invalid. /// </exception> private static Color FromHTML(string rgba) { diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs index 95ad097192..93103d0f6b 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs @@ -171,7 +171,7 @@ namespace Godot.Collections var self = (godot_dictionary)NativeValue; if (NativeFuncs.godotsharp_dictionary_contains_key(ref self, variantKey).ToBool()) - throw new ArgumentException("An element with the same key already exists", nameof(key)); + throw new ArgumentException("An element with the same key already exists.", nameof(key)); godot_variant variantValue = (godot_variant)value.NativeVar; NativeFuncs.godotsharp_dictionary_add(ref self, variantKey, variantValue); @@ -381,13 +381,13 @@ namespace Godot.Collections if (_convertKeyToVariantCallback == null || _convertKeyToManagedCallback == null) { throw new InvalidOperationException( - $"The dictionary key type is not supported for conversion to Variant: '{typeof(TKey).FullName}'"); + $"The dictionary key type is not supported for conversion to Variant: '{typeof(TKey).FullName}'."); } if (_convertValueToVariantCallback == null || _convertValueToManagedCallback == null) { throw new InvalidOperationException( - $"The dictionary value type is not supported for conversion to Variant: '{typeof(TValue).FullName}'"); + $"The dictionary value type is not supported for conversion to Variant: '{typeof(TValue).FullName}'."); } } @@ -556,7 +556,7 @@ namespace Godot.Collections var self = (godot_dictionary)_underlyingDict.NativeValue; if (NativeFuncs.godotsharp_dictionary_contains_key(ref self, variantKey).ToBool()) - throw new ArgumentException("An element with the same key already exists", nameof(key)); + throw new ArgumentException("An element with the same key already exists.", nameof(key)); using var variantValue = _convertValueToVariantCallback(value); NativeFuncs.godotsharp_dictionary_add(ref self, variantKey, variantValue); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/DisposablesTracker.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/DisposablesTracker.cs index 75793ea446..421b588560 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/DisposablesTracker.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/DisposablesTracker.cs @@ -83,13 +83,13 @@ namespace Godot public static void UnregisterGodotObject(Object godotObject, WeakReference<Object> weakReferenceToSelf) { if (!GodotObjectInstances.TryRemove(weakReferenceToSelf, out _)) - throw new ArgumentException("Godot Object not registered", nameof(weakReferenceToSelf)); + throw new ArgumentException("Godot Object not registered.", nameof(weakReferenceToSelf)); } public static void UnregisterDisposable(WeakReference<IDisposable> weakReference) { if (!OtherInstances.TryRemove(weakReference, out _)) - throw new ArgumentException("Disposable not registered", nameof(weakReference)); + throw new ArgumentException("Disposable not registered.", nameof(weakReference)); } } } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/NodeExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/NodeExtensions.cs index df0e839866..03996bafdd 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/NodeExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/NodeExtensions.cs @@ -36,7 +36,7 @@ namespace Godot /// <seealso cref="GetNodeOrNull{T}(NodePath)"/> /// <param name="path">The path to the node to fetch.</param> /// <exception cref="InvalidCastException"> - /// Thrown when the given the fetched node can't be casted to the given type <typeparamref name="T"/>. + /// The fetched node can't be casted to the given type <typeparamref name="T"/>. /// </exception> /// <typeparam name="T">The type to cast to. Should be a descendant of <see cref="Node"/>.</typeparam> /// <returns> @@ -100,7 +100,7 @@ namespace Godot /// parameter in <see cref="AddChild(Node, bool, InternalMode)"/>). /// </param> /// <exception cref="InvalidCastException"> - /// Thrown when the given the fetched node can't be casted to the given type <typeparamref name="T"/>. + /// The fetched node can't be casted to the given type <typeparamref name="T"/>. /// </exception> /// <typeparam name="T">The type to cast to. Should be a descendant of <see cref="Node"/>.</typeparam> /// <returns> @@ -142,7 +142,7 @@ namespace Godot /// </summary> /// <seealso cref="GetOwnerOrNull{T}"/> /// <exception cref="InvalidCastException"> - /// Thrown when the given the fetched node can't be casted to the given type <typeparamref name="T"/>. + /// The fetched node can't be casted to the given type <typeparamref name="T"/>. /// </exception> /// <typeparam name="T">The type to cast to. Should be a descendant of <see cref="Node"/>.</typeparam> /// <returns> @@ -176,7 +176,7 @@ namespace Godot /// </summary> /// <seealso cref="GetParentOrNull{T}"/> /// <exception cref="InvalidCastException"> - /// Thrown when the given the fetched node can't be casted to the given type <typeparamref name="T"/>. + /// The fetched node can't be casted to the given type <typeparamref name="T"/>. /// </exception> /// <typeparam name="T">The type to cast to. Should be a descendant of <see cref="Node"/>.</typeparam> /// <returns> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/PackedSceneExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/PackedSceneExtensions.cs index 435b59d5f3..8463403096 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/PackedSceneExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/PackedSceneExtensions.cs @@ -11,7 +11,7 @@ namespace Godot /// </summary> /// <seealso cref="InstantiateOrNull{T}(GenEditState)"/> /// <exception cref="InvalidCastException"> - /// Thrown when the given the instantiated node can't be casted to the given type <typeparamref name="T"/>. + /// The instantiated node can't be casted to the given type <typeparamref name="T"/>. /// </exception> /// <typeparam name="T">The type to cast to. Should be a descendant of <see cref="Node"/>.</typeparam> /// <returns>The instantiated scene.</returns> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/ResourceLoaderExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/ResourceLoaderExtensions.cs index 25c11d5cf6..b246e56fa9 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/ResourceLoaderExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/ResourceLoaderExtensions.cs @@ -19,7 +19,7 @@ namespace Godot /// Returns an empty resource if no <see cref="ResourceFormatLoader"/> could handle the file. /// </summary> /// <exception cref="InvalidCastException"> - /// Thrown when the given the loaded resource can't be casted to the given type <typeparamref name="T"/>. + /// The loaded resource can't be casted to the given type <typeparamref name="T"/>. /// </exception> /// <typeparam name="T">The type to cast to. Should be a descendant of <see cref="Resource"/>.</typeparam> public static T Load<T>(string path, string typeHint = null, CacheMode cacheMode = CacheMode.Reuse) where T : class diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs index 48c1b48c59..e84bba1179 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs @@ -22,11 +22,11 @@ namespace Godot.NativeInterop public static void Initialize(IntPtr unmanagedCallbacks, int unmanagedCallbacksSize) { if (initialized) - throw new InvalidOperationException("Already initialized"); + throw new InvalidOperationException("Already initialized."); initialized = true; if (unmanagedCallbacksSize != sizeof(UnmanagedCallbacks)) - throw new ArgumentException("Unmanaged callbacks size mismatch"); + throw new ArgumentException("Unmanaged callbacks size mismatch.", nameof(unmanagedCallbacksSize)); _unmanagedCallbacks = Unsafe.AsRef<UnmanagedCallbacks>((void*)unmanagedCallbacks); } @@ -436,6 +436,15 @@ namespace Godot.NativeInterop public static partial void godotsharp_string_simplify_path(in godot_string p_self, out godot_string r_simplified_path); + public static partial void godotsharp_string_to_camel_case(in godot_string p_self, + out godot_string r_camel_case); + + public static partial void godotsharp_string_to_pascal_case(in godot_string p_self, + out godot_string r_pascal_case); + + public static partial void godotsharp_string_to_snake_case(in godot_string p_self, + out godot_string r_snake_case); + // NodePath public static partial void godotsharp_node_path_get_as_property_path(in godot_node_path p_self, diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.extended.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.extended.cs index 2ea3c18d26..26fffc079c 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.extended.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.extended.cs @@ -11,31 +11,31 @@ namespace Godot.NativeInterop case Variant.Type.Nil: return default; case Variant.Type.Bool: - return new godot_variant() { Bool = src.Bool }; + return new godot_variant() { Bool = src.Bool, Type = Variant.Type.Bool }; case Variant.Type.Int: - return new godot_variant() { Int = src.Int }; + return new godot_variant() { Int = src.Int, Type = Variant.Type.Int }; case Variant.Type.Float: - return new godot_variant() { Float = src.Float }; + return new godot_variant() { Float = src.Float, Type = Variant.Type.Float }; case Variant.Type.Vector2: - return new godot_variant() { Vector2 = src.Vector2 }; + return new godot_variant() { Vector2 = src.Vector2, Type = Variant.Type.Vector2 }; case Variant.Type.Vector2i: - return new godot_variant() { Vector2i = src.Vector2i }; + return new godot_variant() { Vector2i = src.Vector2i, Type = Variant.Type.Vector2i }; case Variant.Type.Rect2: - return new godot_variant() { Rect2 = src.Rect2 }; + return new godot_variant() { Rect2 = src.Rect2, Type = Variant.Type.Rect2 }; case Variant.Type.Rect2i: - return new godot_variant() { Rect2i = src.Rect2i }; + return new godot_variant() { Rect2i = src.Rect2i, Type = Variant.Type.Rect2i }; case Variant.Type.Vector3: - return new godot_variant() { Vector3 = src.Vector3 }; + return new godot_variant() { Vector3 = src.Vector3, Type = Variant.Type.Vector3 }; case Variant.Type.Vector3i: - return new godot_variant() { Vector3i = src.Vector3i }; + return new godot_variant() { Vector3i = src.Vector3i, Type = Variant.Type.Vector3i }; case Variant.Type.Plane: - return new godot_variant() { Plane = src.Plane }; + return new godot_variant() { Plane = src.Plane, Type = Variant.Type.Plane }; case Variant.Type.Quaternion: - return new godot_variant() { Quaternion = src.Quaternion }; + return new godot_variant() { Quaternion = src.Quaternion, Type = Variant.Type.Quaternion }; case Variant.Type.Color: - return new godot_variant() { Color = src.Color }; + return new godot_variant() { Color = src.Color, Type = Variant.Type.Color }; case Variant.Type.Rid: - return new godot_variant() { RID = src.RID }; + return new godot_variant() { RID = src.RID, Type = Variant.Type.Rid }; } godotsharp_variant_new_copy(out godot_variant ret, src); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantConversionCallbacks.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantConversionCallbacks.cs index 2b5bf2e142..a13fb936e8 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantConversionCallbacks.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantConversionCallbacks.cs @@ -6,7 +6,7 @@ namespace Godot.NativeInterop; internal static unsafe class VariantConversionCallbacks { [SuppressMessage("ReSharper", "RedundantNameQualifier")] - internal static delegate* <in T, godot_variant> GetToVariantCallback<T>() + internal static delegate*<in T, godot_variant> GetToVariantCallback<T>() { static godot_variant FromBool(in bool @bool) => VariantUtils.CreateFromBool(@bool); @@ -153,163 +153,163 @@ internal static unsafe class VariantConversionCallbacks if (typeOfT == typeof(bool)) { - return (delegate* <in T, godot_variant>)(delegate* <in bool, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in bool, godot_variant>) &FromBool; } if (typeOfT == typeof(char)) { - return (delegate* <in T, godot_variant>)(delegate* <in char, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in char, godot_variant>) &FromChar; } if (typeOfT == typeof(sbyte)) { - return (delegate* <in T, godot_variant>)(delegate* <in sbyte, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in sbyte, godot_variant>) &FromInt8; } if (typeOfT == typeof(short)) { - return (delegate* <in T, godot_variant>)(delegate* <in short, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in short, godot_variant>) &FromInt16; } if (typeOfT == typeof(int)) { - return (delegate* <in T, godot_variant>)(delegate* <in int, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in int, godot_variant>) &FromInt32; } if (typeOfT == typeof(long)) { - return (delegate* <in T, godot_variant>)(delegate* <in long, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in long, godot_variant>) &FromInt64; } if (typeOfT == typeof(byte)) { - return (delegate* <in T, godot_variant>)(delegate* <in byte, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in byte, godot_variant>) &FromUInt8; } if (typeOfT == typeof(ushort)) { - return (delegate* <in T, godot_variant>)(delegate* <in ushort, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in ushort, godot_variant>) &FromUInt16; } if (typeOfT == typeof(uint)) { - return (delegate* <in T, godot_variant>)(delegate* <in uint, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in uint, godot_variant>) &FromUInt32; } if (typeOfT == typeof(ulong)) { - return (delegate* <in T, godot_variant>)(delegate* <in ulong, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in ulong, godot_variant>) &FromUInt64; } if (typeOfT == typeof(float)) { - return (delegate* <in T, godot_variant>)(delegate* <in float, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in float, godot_variant>) &FromFloat; } if (typeOfT == typeof(double)) { - return (delegate* <in T, godot_variant>)(delegate* <in double, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in double, godot_variant>) &FromDouble; } if (typeOfT == typeof(Vector2)) { - return (delegate* <in T, godot_variant>)(delegate* <in Vector2, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in Vector2, godot_variant>) &FromVector2; } if (typeOfT == typeof(Vector2i)) { - return (delegate* <in T, godot_variant>)(delegate* <in Vector2i, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in Vector2i, godot_variant>) &FromVector2I; } if (typeOfT == typeof(Rect2)) { - return (delegate* <in T, godot_variant>)(delegate* <in Rect2, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in Rect2, godot_variant>) &FromRect2; } if (typeOfT == typeof(Rect2i)) { - return (delegate* <in T, godot_variant>)(delegate* <in Rect2i, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in Rect2i, godot_variant>) &FromRect2I; } if (typeOfT == typeof(Transform2D)) { - return (delegate* <in T, godot_variant>)(delegate* <in Transform2D, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in Transform2D, godot_variant>) &FromTransform2D; } if (typeOfT == typeof(Vector3)) { - return (delegate* <in T, godot_variant>)(delegate* <in Vector3, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in Vector3, godot_variant>) &FromVector3; } if (typeOfT == typeof(Vector3i)) { - return (delegate* <in T, godot_variant>)(delegate* <in Vector3i, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in Vector3i, godot_variant>) &FromVector3I; } if (typeOfT == typeof(Basis)) { - return (delegate* <in T, godot_variant>)(delegate* <in Basis, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in Basis, godot_variant>) &FromBasis; } if (typeOfT == typeof(Quaternion)) { - return (delegate* <in T, godot_variant>)(delegate* <in Quaternion, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in Quaternion, godot_variant>) &FromQuaternion; } if (typeOfT == typeof(Transform3D)) { - return (delegate* <in T, godot_variant>)(delegate* <in Transform3D, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in Transform3D, godot_variant>) &FromTransform3D; } if (typeOfT == typeof(AABB)) { - return (delegate* <in T, godot_variant>)(delegate* <in AABB, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in AABB, godot_variant>) &FromAabb; } if (typeOfT == typeof(Color)) { - return (delegate* <in T, godot_variant>)(delegate* <in Color, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in Color, godot_variant>) &FromColor; } if (typeOfT == typeof(Plane)) { - return (delegate* <in T, godot_variant>)(delegate* <in Plane, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in Plane, godot_variant>) &FromPlane; } if (typeOfT == typeof(Callable)) { - return (delegate* <in T, godot_variant>)(delegate* <in Callable, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in Callable, godot_variant>) &FromCallable; } if (typeOfT == typeof(SignalInfo)) { - return (delegate* <in T, godot_variant>)(delegate* <in SignalInfo, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in SignalInfo, godot_variant>) &FromSignalInfo; } @@ -321,42 +321,42 @@ internal static unsafe class VariantConversionCallbacks { case TypeCode.SByte: { - return (delegate* <in T, godot_variant>)(delegate* <in sbyte, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in sbyte, godot_variant>) &FromInt8; } case TypeCode.Int16: { - return (delegate* <in T, godot_variant>)(delegate* <in short, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in short, godot_variant>) &FromInt16; } case TypeCode.Int32: { - return (delegate* <in T, godot_variant>)(delegate* <in int, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in int, godot_variant>) &FromInt32; } case TypeCode.Int64: { - return (delegate* <in T, godot_variant>)(delegate* <in long, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in long, godot_variant>) &FromInt64; } case TypeCode.Byte: { - return (delegate* <in T, godot_variant>)(delegate* <in byte, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in byte, godot_variant>) &FromUInt8; } case TypeCode.UInt16: { - return (delegate* <in T, godot_variant>)(delegate* <in ushort, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in ushort, godot_variant>) &FromUInt16; } case TypeCode.UInt32: { - return (delegate* <in T, godot_variant>)(delegate* <in uint, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in uint, godot_variant>) &FromUInt32; } case TypeCode.UInt64: { - return (delegate* <in T, godot_variant>)(delegate* <in ulong, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in ulong, godot_variant>) &FromUInt64; } default: @@ -366,121 +366,121 @@ internal static unsafe class VariantConversionCallbacks if (typeOfT == typeof(string)) { - return (delegate* <in T, godot_variant>)(delegate* <in string, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in string, godot_variant>) &FromString; } if (typeOfT == typeof(byte[])) { - return (delegate* <in T, godot_variant>)(delegate* <in byte[], godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in byte[], godot_variant>) &FromByteArray; } if (typeOfT == typeof(int[])) { - return (delegate* <in T, godot_variant>)(delegate* <in int[], godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in int[], godot_variant>) &FromInt32Array; } if (typeOfT == typeof(long[])) { - return (delegate* <in T, godot_variant>)(delegate* <in long[], godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in long[], godot_variant>) &FromInt64Array; } if (typeOfT == typeof(float[])) { - return (delegate* <in T, godot_variant>)(delegate* <in float[], godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in float[], godot_variant>) &FromFloatArray; } if (typeOfT == typeof(double[])) { - return (delegate* <in T, godot_variant>)(delegate* <in double[], godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in double[], godot_variant>) &FromDoubleArray; } if (typeOfT == typeof(string[])) { - return (delegate* <in T, godot_variant>)(delegate* <in string[], godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in string[], godot_variant>) &FromStringArray; } if (typeOfT == typeof(Vector2[])) { - return (delegate* <in T, godot_variant>)(delegate* <in Vector2[], godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in Vector2[], godot_variant>) &FromVector2Array; } if (typeOfT == typeof(Vector3[])) { - return (delegate* <in T, godot_variant>)(delegate* <in Vector3[], godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in Vector3[], godot_variant>) &FromVector3Array; } if (typeOfT == typeof(Color[])) { - return (delegate* <in T, godot_variant>)(delegate* <in Color[], godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in Color[], godot_variant>) &FromColorArray; } if (typeOfT == typeof(StringName[])) { - return (delegate* <in T, godot_variant>)(delegate* <in StringName[], godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in StringName[], godot_variant>) &FromStringNameArray; } if (typeOfT == typeof(NodePath[])) { - return (delegate* <in T, godot_variant>)(delegate* <in NodePath[], godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in NodePath[], godot_variant>) &FromNodePathArray; } if (typeOfT == typeof(RID[])) { - return (delegate* <in T, godot_variant>)(delegate* <in RID[], godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in RID[], godot_variant>) &FromRidArray; } if (typeof(Godot.Object).IsAssignableFrom(typeOfT)) { - return (delegate* <in T, godot_variant>)(delegate* <in Godot.Object, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in Godot.Object, godot_variant>) &FromGodotObject; } if (typeOfT == typeof(StringName)) { - return (delegate* <in T, godot_variant>)(delegate* <in StringName, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in StringName, godot_variant>) &FromStringName; } if (typeOfT == typeof(NodePath)) { - return (delegate* <in T, godot_variant>)(delegate* <in NodePath, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in NodePath, godot_variant>) &FromNodePath; } if (typeOfT == typeof(RID)) { - return (delegate* <in T, godot_variant>)(delegate* <in RID, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in RID, godot_variant>) &FromRid; } if (typeOfT == typeof(Godot.Collections.Dictionary)) { - return (delegate* <in T, godot_variant>)(delegate* <in Godot.Collections.Dictionary, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in Godot.Collections.Dictionary, godot_variant>) &FromGodotDictionary; } if (typeOfT == typeof(Godot.Collections.Array)) { - return (delegate* <in T, godot_variant>)(delegate* <in Godot.Collections.Array, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in Godot.Collections.Array, godot_variant>) &FromGodotArray; } if (typeOfT == typeof(Variant)) { - return (delegate* <in T, godot_variant>)(delegate* <in Variant, godot_variant>) + return (delegate*<in T, godot_variant>)(delegate*<in Variant, godot_variant>) &FromVariant; } @@ -488,7 +488,7 @@ internal static unsafe class VariantConversionCallbacks } [SuppressMessage("ReSharper", "RedundantNameQualifier")] - internal static delegate* <in godot_variant, T> GetToManagedCallback<T>() + internal static delegate*<in godot_variant, T> GetToManagedCallback<T>() { static bool ToBool(in godot_variant variant) => VariantUtils.ConvertToBool(variant); @@ -638,163 +638,163 @@ internal static unsafe class VariantConversionCallbacks if (typeOfT == typeof(bool)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, bool>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, bool>) &ToBool; } if (typeOfT == typeof(char)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, char>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, char>) &ToChar; } if (typeOfT == typeof(sbyte)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, sbyte>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, sbyte>) &ToInt8; } if (typeOfT == typeof(short)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, short>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, short>) &ToInt16; } if (typeOfT == typeof(int)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, int>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, int>) &ToInt32; } if (typeOfT == typeof(long)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, long>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, long>) &ToInt64; } if (typeOfT == typeof(byte)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, byte>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, byte>) &ToUInt8; } if (typeOfT == typeof(ushort)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, ushort>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, ushort>) &ToUInt16; } if (typeOfT == typeof(uint)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, uint>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, uint>) &ToUInt32; } if (typeOfT == typeof(ulong)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, ulong>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, ulong>) &ToUInt64; } if (typeOfT == typeof(float)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, float>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, float>) &ToFloat; } if (typeOfT == typeof(double)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, double>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, double>) &ToDouble; } if (typeOfT == typeof(Vector2)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, Vector2>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, Vector2>) &ToVector2; } if (typeOfT == typeof(Vector2i)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, Vector2i>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, Vector2i>) &ToVector2I; } if (typeOfT == typeof(Rect2)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, Rect2>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, Rect2>) &ToRect2; } if (typeOfT == typeof(Rect2i)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, Rect2i>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, Rect2i>) &ToRect2I; } if (typeOfT == typeof(Transform2D)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, Transform2D>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, Transform2D>) &ToTransform2D; } if (typeOfT == typeof(Vector3)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, Vector3>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, Vector3>) &ToVector3; } if (typeOfT == typeof(Vector3i)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, Vector3i>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, Vector3i>) &ToVector3I; } if (typeOfT == typeof(Basis)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, Basis>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, Basis>) &ToBasis; } if (typeOfT == typeof(Quaternion)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, Quaternion>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, Quaternion>) &ToQuaternion; } if (typeOfT == typeof(Transform3D)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, Transform3D>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, Transform3D>) &ToTransform3D; } if (typeOfT == typeof(AABB)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, AABB>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, AABB>) &ToAabb; } if (typeOfT == typeof(Color)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, Color>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, Color>) &ToColor; } if (typeOfT == typeof(Plane)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, Plane>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, Plane>) &ToPlane; } if (typeOfT == typeof(Callable)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, Callable>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, Callable>) &ToCallable; } if (typeOfT == typeof(SignalInfo)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, SignalInfo>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, SignalInfo>) &ToSignalInfo; } @@ -806,42 +806,42 @@ internal static unsafe class VariantConversionCallbacks { case TypeCode.SByte: { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, sbyte>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, sbyte>) &ToInt8; } case TypeCode.Int16: { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, short>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, short>) &ToInt16; } case TypeCode.Int32: { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, int>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, int>) &ToInt32; } case TypeCode.Int64: { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, long>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, long>) &ToInt64; } case TypeCode.Byte: { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, byte>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, byte>) &ToUInt8; } case TypeCode.UInt16: { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, ushort>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, ushort>) &ToUInt16; } case TypeCode.UInt32: { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, uint>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, uint>) &ToUInt32; } case TypeCode.UInt64: { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, ulong>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, ulong>) &ToUInt64; } default: @@ -851,121 +851,121 @@ internal static unsafe class VariantConversionCallbacks if (typeOfT == typeof(string)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, string>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, string>) &ToString; } if (typeOfT == typeof(byte[])) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, byte[]>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, byte[]>) &ToByteArray; } if (typeOfT == typeof(int[])) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, int[]>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, int[]>) &ToInt32Array; } if (typeOfT == typeof(long[])) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, long[]>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, long[]>) &ToInt64Array; } if (typeOfT == typeof(float[])) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, float[]>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, float[]>) &ToFloatArray; } if (typeOfT == typeof(double[])) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, double[]>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, double[]>) &ToDoubleArray; } if (typeOfT == typeof(string[])) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, string[]>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, string[]>) &ToStringArray; } if (typeOfT == typeof(Vector2[])) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, Vector2[]>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, Vector2[]>) &ToVector2Array; } if (typeOfT == typeof(Vector3[])) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, Vector3[]>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, Vector3[]>) &ToVector3Array; } if (typeOfT == typeof(Color[])) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, Color[]>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, Color[]>) &ToColorArray; } if (typeOfT == typeof(StringName[])) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, StringName[]>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, StringName[]>) &ToStringNameArray; } if (typeOfT == typeof(NodePath[])) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, NodePath[]>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, NodePath[]>) &ToNodePathArray; } if (typeOfT == typeof(RID[])) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, RID[]>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, RID[]>) &ToRidArray; } if (typeof(Godot.Object).IsAssignableFrom(typeOfT)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, Godot.Object>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, Godot.Object>) &ToGodotObject; } if (typeOfT == typeof(StringName)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, StringName>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, StringName>) &ToStringName; } if (typeOfT == typeof(NodePath)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, NodePath>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, NodePath>) &ToNodePath; } if (typeOfT == typeof(RID)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, RID>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, RID>) &ToRid; } if (typeOfT == typeof(Godot.Collections.Dictionary)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, Godot.Collections.Dictionary>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, Godot.Collections.Dictionary>) &ToGodotDictionary; } if (typeOfT == typeof(Godot.Collections.Array)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, Godot.Collections.Array>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, Godot.Collections.Array>) &ToGodotArray; } if (typeOfT == typeof(Variant)) { - return (delegate* <in godot_variant, T>)(delegate* <in godot_variant, Variant>) + return (delegate*<in godot_variant, T>)(delegate*<in godot_variant, Variant>) &ToVariant; } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Object.exceptions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Object.exceptions.cs index eb2811c73d..0fcc4ee01b 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Object.exceptions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Object.exceptions.cs @@ -1,4 +1,5 @@ using System; +using System.Text; #nullable enable @@ -60,19 +61,22 @@ namespace Godot { get { - string s = base.Message; - - if (string.IsNullOrEmpty(s)) + StringBuilder sb; + if (string.IsNullOrEmpty(base.Message)) + { + sb = new(Arg_NativeConstructorNotFoundException); + } + else { - s = Arg_NativeConstructorNotFoundException; + sb = new(base.Message); } if (!string.IsNullOrEmpty(_nativeClassName)) { - s += " " + string.Format("(Class '{0}')", _nativeClassName); + sb.Append($" (Method '{_nativeClassName}')"); } - return s; + return sb.ToString(); } } } @@ -115,19 +119,22 @@ namespace Godot { get { - string s = base.Message; - - if (string.IsNullOrEmpty(s)) + StringBuilder sb; + if (string.IsNullOrEmpty(base.Message)) + { + sb = new(Arg_NativeMethodBindNotFoundException); + } + else { - s = Arg_NativeMethodBindNotFoundException; + sb = new(base.Message); } if (!string.IsNullOrEmpty(_nativeMethodName)) { - s += " " + string.Format("(Method '{0}')", _nativeMethodName); + sb.Append($" (Method '{_nativeMethodName}')"); } - return s; + return sb.ToString(); } } } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Projection.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Projection.cs index 9d08e7120a..da895fd121 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Projection.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Projection.cs @@ -649,6 +649,9 @@ namespace Godot /// Access whole columns in the form of <see cref="Vector4"/>. /// </summary> /// <param name="column">Which column vector.</param> + /// <exception cref="ArgumentOutOfRangeException"> + /// <paramref name="column"/> is not 0, 1, 2 or 3. + /// </exception> public Vector4 this[int column] { get @@ -664,7 +667,7 @@ namespace Godot case 3: return w; default: - throw new IndexOutOfRangeException(); + throw new ArgumentOutOfRangeException(nameof(column)); } } set @@ -684,7 +687,7 @@ namespace Godot w = value; return; default: - throw new IndexOutOfRangeException(); + throw new ArgumentOutOfRangeException(nameof(column)); } } } @@ -694,6 +697,9 @@ namespace Godot /// </summary> /// <param name="column">Which column vector.</param> /// <param name="row">Which row of the column.</param> + /// <exception cref="ArgumentOutOfRangeException"> + /// <paramref name="column"/> or <paramref name="row"/> are not 0, 1, 2 or 3. + /// </exception> public real_t this[int column, int row] { get @@ -709,7 +715,7 @@ namespace Godot case 3: return w[row]; default: - throw new IndexOutOfRangeException(); + throw new ArgumentOutOfRangeException(nameof(column)); } } set @@ -729,7 +735,7 @@ namespace Godot w[row] = value; return; default: - throw new IndexOutOfRangeException(); + throw new ArgumentOutOfRangeException(nameof(column)); } } } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs index 5cc478ca71..d459fe8c96 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs @@ -47,6 +47,9 @@ namespace Godot /// <summary> /// Access quaternion components using their index. /// </summary> + /// <exception cref="ArgumentOutOfRangeException"> + /// <paramref name="index"/> is not 0, 1, 2 or 3. + /// </exception> /// <value> /// <c>[0]</c> is equivalent to <see cref="x"/>, /// <c>[1]</c> is equivalent to <see cref="y"/>, @@ -314,7 +317,7 @@ namespace Godot #if DEBUG if (!IsNormalized()) { - throw new InvalidOperationException("Quaternion is not normalized"); + throw new InvalidOperationException("Quaternion is not normalized."); } #endif var basis = new Basis(this); @@ -330,7 +333,7 @@ namespace Godot #if DEBUG if (!IsNormalized()) { - throw new InvalidOperationException("Quaternion is not normalized"); + throw new InvalidOperationException("Quaternion is not normalized."); } #endif return new Quaternion(-x, -y, -z, w); @@ -374,11 +377,11 @@ namespace Godot #if DEBUG if (!IsNormalized()) { - throw new InvalidOperationException("Quaternion is not normalized"); + throw new InvalidOperationException("Quaternion is not normalized."); } if (!to.IsNormalized()) { - throw new ArgumentException("Argument is not normalized", nameof(to)); + throw new ArgumentException("Argument is not normalized.", nameof(to)); } #endif @@ -543,7 +546,7 @@ namespace Godot #if DEBUG if (!axis.IsNormalized()) { - throw new ArgumentException("Argument is not normalized", nameof(axis)); + throw new ArgumentException("Argument is not normalized.", nameof(axis)); } #endif @@ -599,7 +602,7 @@ namespace Godot #if DEBUG if (!quaternion.IsNormalized()) { - throw new InvalidOperationException("Quaternion is not normalized"); + throw new InvalidOperationException("Quaternion is not normalized."); } #endif var u = new Vector3(quaternion.x, quaternion.y, quaternion.z); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs index f0bc5949df..44f951e314 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs @@ -287,6 +287,45 @@ namespace Godot return cap; } + /// <summary> + /// Returns the string converted to <c>camelCase</c>. + /// </summary> + /// <param name="instance">The string to convert.</param> + /// <returns>The converted string.</returns> + public static string ToCamelCase(this string instance) + { + using godot_string instanceStr = Marshaling.ConvertStringToNative(instance); + NativeFuncs.godotsharp_string_to_camel_case(instanceStr, out godot_string camelCase); + using (camelCase) + return Marshaling.ConvertStringToManaged(camelCase); + } + + /// <summary> + /// Returns the string converted to <c>PascalCase</c>. + /// </summary> + /// <param name="instance">The string to convert.</param> + /// <returns>The converted string.</returns> + public static string ToPascalCase(this string instance) + { + using godot_string instanceStr = Marshaling.ConvertStringToNative(instance); + NativeFuncs.godotsharp_string_to_pascal_case(instanceStr, out godot_string pascalCase); + using (pascalCase) + return Marshaling.ConvertStringToManaged(pascalCase); + } + + /// <summary> + /// Returns the string converted to <c>snake_case</c>. + /// </summary> + /// <param name="instance">The string to convert.</param> + /// <returns>The converted string.</returns> + public static string ToSnakeCase(this string instance) + { + using godot_string instanceStr = Marshaling.ConvertStringToNative(instance); + NativeFuncs.godotsharp_string_to_snake_case(instanceStr, out godot_string snakeCase); + using (snakeCase) + return Marshaling.ConvertStringToManaged(snakeCase); + } + private static string CamelcaseToUnderscore(this string instance, bool lowerCase) { string newString = string.Empty; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs index 33b4f11f62..894667db76 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs @@ -75,6 +75,9 @@ namespace Godot /// The third column is the <see cref="origin"/> vector. /// </summary> /// <param name="column">Which column vector.</param> + /// <exception cref="ArgumentOutOfRangeException"> + /// <paramref name="column"/> is not 0, 1 or 2. + /// </exception> public Vector2 this[int column] { get diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs index 3c017ecc9f..2f7891e7ef 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs @@ -32,6 +32,9 @@ namespace Godot /// The fourth column is the <see cref="origin"/> vector. /// </summary> /// <param name="column">Which column vector.</param> + /// <exception cref="ArgumentOutOfRangeException"> + /// <paramref name="column"/> is not 0, 1, 2 or 3. + /// </exception> public Vector3 this[int column] { get diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs index b2964db8cd..87f397891e 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs @@ -39,8 +39,8 @@ namespace Godot /// <summary> /// Access vector components using their index. /// </summary> - /// <exception cref="IndexOutOfRangeException"> - /// Thrown when the given the <paramref name="index"/> is not 0 or 1. + /// <exception cref="ArgumentOutOfRangeException"> + /// <paramref name="index"/> is not 0 or 1. /// </exception> /// <value> /// <c>[0]</c> is equivalent to <see cref="x"/>, @@ -502,7 +502,7 @@ namespace Godot #if DEBUG if (!normal.IsNormalized()) { - throw new ArgumentException("Argument is not normalized", nameof(normal)); + throw new ArgumentException("Argument is not normalized.", nameof(normal)); } #endif return (2 * Dot(normal) * normal) - this; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs index 666616edec..bdadf696e3 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs @@ -39,8 +39,8 @@ namespace Godot /// <summary> /// Access vector components using their index. /// </summary> - /// <exception cref="IndexOutOfRangeException"> - /// Thrown when the given the <paramref name="index"/> is not 0 or 1. + /// <exception cref="ArgumentOutOfRangeException"> + /// <paramref name="index"/> is not 0 or 1. /// </exception> /// <value> /// <c>[0]</c> is equivalent to <see cref="x"/>, diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs index b53ca5e45a..6649f3b784 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs @@ -48,8 +48,8 @@ namespace Godot /// <summary> /// Access vector components using their index. /// </summary> - /// <exception cref="IndexOutOfRangeException"> - /// Thrown when the given the <paramref name="index"/> is not 0, 1 or 2. + /// <exception cref="ArgumentOutOfRangeException"> + /// <paramref name="index"/> is not 0, 1 or 2. /// </exception> /// <value> /// <c>[0]</c> is equivalent to <see cref="x"/>, @@ -521,7 +521,7 @@ namespace Godot #if DEBUG if (!normal.IsNormalized()) { - throw new ArgumentException("Argument is not normalized", nameof(normal)); + throw new ArgumentException("Argument is not normalized.", nameof(normal)); } #endif return (2.0f * Dot(normal) * normal) - this; @@ -539,7 +539,7 @@ namespace Godot #if DEBUG if (!axis.IsNormalized()) { - throw new ArgumentException("Argument is not normalized", nameof(axis)); + throw new ArgumentException("Argument is not normalized.", nameof(axis)); } #endif return new Basis(axis, angle) * this; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs index 2947ef94a7..e88a043cb3 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs @@ -48,8 +48,8 @@ namespace Godot /// <summary> /// Access vector components using their <paramref name="index"/>. /// </summary> - /// <exception cref="IndexOutOfRangeException"> - /// Thrown when the given the <paramref name="index"/> is not 0, 1 or 2. + /// <exception cref="ArgumentOutOfRangeException"> + /// <paramref name="index"/> is not 0, 1 or 2. /// </exception> /// <value> /// <c>[0]</c> is equivalent to <see cref="x"/>, diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs index b6f243dfb4..d1962c68cf 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs @@ -57,8 +57,8 @@ namespace Godot /// <summary> /// Access vector components using their index. /// </summary> - /// <exception cref="IndexOutOfRangeException"> - /// Thrown when the given the <paramref name="index"/> is not 0, 1, 2 or 3. + /// <exception cref="ArgumentOutOfRangeException"> + /// <paramref name="index"/> is not 0, 1, 2 or 3. /// </exception> /// <value> /// <c>[0]</c> is equivalent to <see cref="x"/>, @@ -81,7 +81,7 @@ namespace Godot case 3: return w; default: - throw new IndexOutOfRangeException(); + throw new ArgumentOutOfRangeException(nameof(index)); } } set @@ -101,7 +101,7 @@ namespace Godot w = value; return; default: - throw new IndexOutOfRangeException(); + throw new ArgumentOutOfRangeException(nameof(index)); } } } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4i.cs index 73134b0baf..4b1bb3ba19 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4i.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4i.cs @@ -57,8 +57,8 @@ namespace Godot /// <summary> /// Access vector components using their <paramref name="index"/>. /// </summary> - /// <exception cref="IndexOutOfRangeException"> - /// Thrown when the given the <paramref name="index"/> is not 0, 1, 2 or 3. + /// <exception cref="ArgumentOutOfRangeException"> + /// <paramref name="index"/> is not 0, 1, 2 or 3. /// </exception> /// <value> /// <c>[0]</c> is equivalent to <see cref="x"/>, @@ -81,7 +81,7 @@ namespace Godot case 3: return w; default: - throw new IndexOutOfRangeException(); + throw new ArgumentOutOfRangeException(nameof(index)); } } set @@ -101,7 +101,7 @@ namespace Godot w = value; return; default: - throw new IndexOutOfRangeException(); + throw new ArgumentOutOfRangeException(nameof(index)); } } } diff --git a/modules/mono/glue/runtime_interop.cpp b/modules/mono/glue/runtime_interop.cpp index 0d68cb54b9..529bda4c38 100644 --- a/modules/mono/glue/runtime_interop.cpp +++ b/modules/mono/glue/runtime_interop.cpp @@ -1096,6 +1096,18 @@ void godotsharp_string_simplify_path(const String *p_self, String *r_simplified_ memnew_placement(r_simplified_path, String(p_self->simplify_path())); } +void godotsharp_string_to_camel_case(const String *p_self, String *r_camel_case) { + memnew_placement(r_camel_case, String(p_self->to_camel_case())); +} + +void godotsharp_string_to_pascal_case(const String *p_self, String *r_pascal_case) { + memnew_placement(r_pascal_case, String(p_self->to_pascal_case())); +} + +void godotsharp_string_to_snake_case(const String *p_self, String *r_snake_case) { + memnew_placement(r_snake_case, String(p_self->to_snake_case())); +} + void godotsharp_node_path_get_as_property_path(const NodePath *p_ptr, NodePath *r_dest) { memnew_placement(r_dest, NodePath(p_ptr->get_as_property_path())); } @@ -1471,6 +1483,9 @@ static const void *unmanaged_callbacks[]{ (void *)godotsharp_string_sha256_buffer, (void *)godotsharp_string_sha256_text, (void *)godotsharp_string_simplify_path, + (void *)godotsharp_string_to_camel_case, + (void *)godotsharp_string_to_pascal_case, + (void *)godotsharp_string_to_snake_case, (void *)godotsharp_node_path_get_as_property_path, (void *)godotsharp_node_path_get_concatenated_names, (void *)godotsharp_node_path_get_concatenated_subnames, diff --git a/modules/mono/godotsharp_dirs.cpp b/modules/mono/godotsharp_dirs.cpp index 71576c2f80..c7e47d2718 100644 --- a/modules/mono/godotsharp_dirs.cpp +++ b/modules/mono/godotsharp_dirs.cpp @@ -64,7 +64,7 @@ String _get_expected_build_config() { String _get_mono_user_dir() { #ifdef TOOLS_ENABLED if (EditorPaths::get_singleton()) { - return EditorPaths::get_singleton()->get_data_dir().plus_file("mono"); + return EditorPaths::get_singleton()->get_data_dir().path_join("mono"); } else { String settings_path; @@ -72,23 +72,23 @@ String _get_mono_user_dir() { String exe_dir = OS::get_singleton()->get_executable_path().get_base_dir(); // On macOS, look outside .app bundle, since .app bundle is read-only. - if (OS::get_singleton()->has_feature("macos") && exe_dir.ends_with("MacOS") && exe_dir.plus_file("..").simplify_path().ends_with("Contents")) { - exe_dir = exe_dir.plus_file("../../..").simplify_path(); + if (OS::get_singleton()->has_feature("macos") && exe_dir.ends_with("MacOS") && exe_dir.path_join("..").simplify_path().ends_with("Contents")) { + exe_dir = exe_dir.path_join("../../..").simplify_path(); } Ref<DirAccess> d = DirAccess::create_for_path(exe_dir); if (d->file_exists("._sc_") || d->file_exists("_sc_")) { // contain yourself - settings_path = exe_dir.plus_file("editor_data"); + settings_path = exe_dir.path_join("editor_data"); } else { - settings_path = OS::get_singleton()->get_data_path().plus_file(OS::get_singleton()->get_godot_dir_name()); + settings_path = OS::get_singleton()->get_data_path().path_join(OS::get_singleton()->get_godot_dir_name()); } - return settings_path.plus_file("mono"); + return settings_path.path_join("mono"); } #else - return OS::get_singleton()->get_user_data_dir().plus_file("mono"); + return OS::get_singleton()->get_user_data_dir().path_join("mono"); #endif } @@ -126,27 +126,27 @@ public: private: _GodotSharpDirs() { - res_data_dir = ProjectSettings::get_singleton()->get_project_data_path().plus_file("mono"); - res_metadata_dir = res_data_dir.plus_file("metadata"); - res_config_dir = res_data_dir.plus_file("etc").plus_file("mono"); + res_data_dir = ProjectSettings::get_singleton()->get_project_data_path().path_join("mono"); + res_metadata_dir = res_data_dir.path_join("metadata"); + res_config_dir = res_data_dir.path_join("etc").path_join("mono"); // TODO use paths from csproj - res_temp_dir = res_data_dir.plus_file("temp"); - res_temp_assemblies_base_dir = res_temp_dir.plus_file("bin"); - res_temp_assemblies_dir = res_temp_assemblies_base_dir.plus_file(_get_expected_build_config()); + res_temp_dir = res_data_dir.path_join("temp"); + res_temp_assemblies_base_dir = res_temp_dir.path_join("bin"); + res_temp_assemblies_dir = res_temp_assemblies_base_dir.path_join(_get_expected_build_config()); - api_assemblies_base_dir = res_data_dir.plus_file("assemblies"); + api_assemblies_base_dir = res_data_dir.path_join("assemblies"); -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED mono_user_dir = "user://"; #else mono_user_dir = _get_mono_user_dir(); #endif - mono_logs_dir = mono_user_dir.plus_file("mono_logs"); + mono_logs_dir = mono_user_dir.path_join("mono_logs"); #ifdef TOOLS_ENABLED - mono_solutions_dir = mono_user_dir.plus_file("solutions"); - build_logs_dir = mono_user_dir.plus_file("build_logs"); + mono_solutions_dir = mono_user_dir.path_join("solutions"); + build_logs_dir = mono_user_dir.path_join("build_logs"); String base_path = ProjectSettings::get_singleton()->globalize_path("res://"); #endif @@ -155,35 +155,35 @@ private: #ifdef TOOLS_ENABLED - String data_dir_root = exe_dir.plus_file("GodotSharp"); - data_editor_tools_dir = data_dir_root.plus_file("Tools"); - api_assemblies_base_dir = data_dir_root.plus_file("Api"); + String data_dir_root = exe_dir.path_join("GodotSharp"); + data_editor_tools_dir = data_dir_root.path_join("Tools"); + api_assemblies_base_dir = data_dir_root.path_join("Api"); - String data_mono_root_dir = data_dir_root.plus_file("Mono"); - data_mono_etc_dir = data_mono_root_dir.plus_file("etc"); + String data_mono_root_dir = data_dir_root.path_join("Mono"); + data_mono_etc_dir = data_mono_root_dir.path_join("etc"); #ifdef ANDROID_ENABLED data_mono_lib_dir = gdmono::android::support::get_app_native_lib_dir(); #else - data_mono_lib_dir = data_mono_root_dir.plus_file("lib"); + data_mono_lib_dir = data_mono_root_dir.path_join("lib"); #endif #ifdef WINDOWS_ENABLED - data_mono_bin_dir = data_mono_root_dir.plus_file("bin"); + data_mono_bin_dir = data_mono_root_dir.path_join("bin"); #endif #ifdef MACOS_ENABLED if (!DirAccess::exists(data_editor_tools_dir)) { - data_editor_tools_dir = exe_dir.plus_file("../Resources/GodotSharp/Tools"); + data_editor_tools_dir = exe_dir.path_join("../Resources/GodotSharp/Tools"); } if (!DirAccess::exists(api_assemblies_base_dir)) { - api_assemblies_base_dir = exe_dir.plus_file("../Resources/GodotSharp/Api"); + api_assemblies_base_dir = exe_dir.path_join("../Resources/GodotSharp/Api"); } if (!DirAccess::exists(data_mono_root_dir)) { - data_mono_etc_dir = exe_dir.plus_file("../Resources/GodotSharp/Mono/etc"); - data_mono_lib_dir = exe_dir.plus_file("../Resources/GodotSharp/Mono/lib"); + data_mono_etc_dir = exe_dir.path_join("../Resources/GodotSharp/Mono/etc"); + data_mono_lib_dir = exe_dir.path_join("../Resources/GodotSharp/Mono/lib"); } #endif @@ -191,40 +191,40 @@ private: String appname = ProjectSettings::get_singleton()->get("application/config/name"); String appname_safe = OS::get_singleton()->get_safe_dir_name(appname); - String data_dir_root = exe_dir.plus_file("data_" + appname_safe); + String data_dir_root = exe_dir.path_join("data_" + appname_safe); if (!DirAccess::exists(data_dir_root)) { - data_dir_root = exe_dir.plus_file("data_Godot"); + data_dir_root = exe_dir.path_join("data_Godot"); } - String data_mono_root_dir = data_dir_root.plus_file("Mono"); - data_mono_etc_dir = data_mono_root_dir.plus_file("etc"); + String data_mono_root_dir = data_dir_root.path_join("Mono"); + data_mono_etc_dir = data_mono_root_dir.path_join("etc"); #ifdef ANDROID_ENABLED data_mono_lib_dir = gdmono::android::support::get_app_native_lib_dir(); #else - data_mono_lib_dir = data_mono_root_dir.plus_file("lib"); - data_game_assemblies_dir = data_dir_root.plus_file("Assemblies"); + data_mono_lib_dir = data_mono_root_dir.path_join("lib"); + data_game_assemblies_dir = data_dir_root.path_join("Assemblies"); #endif #ifdef WINDOWS_ENABLED - data_mono_bin_dir = data_mono_root_dir.plus_file("bin"); + data_mono_bin_dir = data_mono_root_dir.path_join("bin"); #endif #ifdef MACOS_ENABLED if (!DirAccess::exists(data_mono_root_dir)) { - data_mono_etc_dir = exe_dir.plus_file("../Resources/GodotSharp/Mono/etc"); - data_mono_lib_dir = exe_dir.plus_file("../Resources/GodotSharp/Mono/lib"); + data_mono_etc_dir = exe_dir.path_join("../Resources/GodotSharp/Mono/etc"); + data_mono_lib_dir = exe_dir.path_join("../Resources/GodotSharp/Mono/lib"); } if (!DirAccess::exists(data_game_assemblies_dir)) { - data_game_assemblies_dir = exe_dir.plus_file("../Resources/GodotSharp/Assemblies"); + data_game_assemblies_dir = exe_dir.path_join("../Resources/GodotSharp/Assemblies"); } #endif #endif #ifdef TOOLS_ENABLED - api_assemblies_dir = api_assemblies_base_dir.plus_file(GDMono::get_expected_api_build_config()); + api_assemblies_dir = api_assemblies_base_dir.path_join(GDMono::get_expected_api_build_config()); #else api_assemblies_dir = data_dir_root; #endif diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index 0532cc915b..e698e92d7a 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -103,12 +103,12 @@ const char_t *get_data(const HostFxrCharString &p_char_str) { } #ifdef TOOLS_ENABLED -String find_hostfxr(size_t p_known_buffet_size, get_hostfxr_parameters *p_get_hostfxr_params) { +String find_hostfxr(size_t p_known_buffer_size, get_hostfxr_parameters *p_get_hostfxr_params) { // Pre-allocate a large buffer for the path to hostfxr Vector<char_t> buffer; - buffer.resize(p_known_buffet_size); + buffer.resize(p_known_buffer_size); - int rc = get_hostfxr_path(buffer.ptrw(), &p_known_buffet_size, p_get_hostfxr_params); + int rc = get_hostfxr_path(buffer.ptrw(), &p_known_buffer_size, p_get_hostfxr_params); ERR_FAIL_COND_V_MSG(rc != 0, String(), "get_hostfxr_path failed with code: " + itos(rc)); @@ -173,13 +173,13 @@ String find_hostfxr() { #if defined(WINDOWS_ENABLED) String probe_path = GodotSharpDirs::get_api_assemblies_dir() - .plus_file("hostfxr.dll"); + .path_join("hostfxr.dll"); #elif defined(MACOS_ENABLED) String probe_path = GodotSharpDirs::get_api_assemblies_dir() - .plus_file("libhostfxr.dylib"); + .path_join("libhostfxr.dylib"); #elif defined(UNIX_ENABLED) String probe_path = GodotSharpDirs::get_api_assemblies_dir() - .plus_file("libhostfxr.so"); + .path_join("libhostfxr.so"); #else #error "Platform not supported (yet?)" #endif @@ -270,7 +270,7 @@ load_assembly_and_get_function_pointer_fn initialize_hostfxr_self_contained( int i = 1; for (const String &E : cmdline_args) { HostFxrCharString &stored = argv_store.push_back(str_to_hostfxr(E))->get(); - argv.write[i] = stored.ptr(); + argv.write[i] = get_data(stored); i++; } @@ -305,10 +305,10 @@ godot_plugins_initialize_fn initialize_hostfxr_and_godot_plugins(bool &r_runtime godot_plugins_initialize_fn godot_plugins_initialize = nullptr; HostFxrCharString godot_plugins_path = str_to_hostfxr( - GodotSharpDirs::get_api_assemblies_dir().plus_file("GodotPlugins.dll")); + GodotSharpDirs::get_api_assemblies_dir().path_join("GodotPlugins.dll")); HostFxrCharString config_path = str_to_hostfxr( - GodotSharpDirs::get_api_assemblies_dir().plus_file("GodotPlugins.runtimeconfig.json")); + GodotSharpDirs::get_api_assemblies_dir().path_join("GodotPlugins.runtimeconfig.json")); load_assembly_and_get_function_pointer_fn load_assembly_and_get_function_pointer = initialize_hostfxr_for_config(get_data(config_path)); @@ -345,7 +345,7 @@ godot_plugins_initialize_fn initialize_hostfxr_and_godot_plugins(bool &r_runtime String assembly_name = get_assembly_name(); HostFxrCharString assembly_path = str_to_hostfxr(GodotSharpDirs::get_api_assemblies_dir() - .plus_file(assembly_name + ".dll")); + .path_join(assembly_name + ".dll")); load_assembly_and_get_function_pointer_fn load_assembly_and_get_function_pointer = initialize_hostfxr_self_contained(get_data(assembly_path)); @@ -356,7 +356,7 @@ godot_plugins_initialize_fn initialize_hostfxr_and_godot_plugins(bool &r_runtime print_verbose(".NET: hostfxr initialized"); int rc = load_assembly_and_get_function_pointer(get_data(assembly_path), - str_to_hostfxr("GodotPlugins.Game.Main, " + assembly_name), + get_data(str_to_hostfxr("GodotPlugins.Game.Main, " + assembly_name)), HOSTFXR_STR("InitializeFromGameProject"), UNMANAGEDCALLERSONLY_METHOD, nullptr, @@ -370,11 +370,11 @@ godot_plugins_initialize_fn try_load_native_aot_library(void *&r_aot_dll_handle) String assembly_name = get_assembly_name(); #if defined(WINDOWS_ENABLED) - String native_aot_so_path = GodotSharpDirs::get_api_assemblies_dir().plus_file(assembly_name + ".dll"); + String native_aot_so_path = GodotSharpDirs::get_api_assemblies_dir().path_join(assembly_name + ".dll"); #elif defined(MACOS_ENABLED) - String native_aot_so_path = GodotSharpDirs::get_api_assemblies_dir().plus_file(assembly_name + ".dylib"); + String native_aot_so_path = GodotSharpDirs::get_api_assemblies_dir().path_join(assembly_name + ".dylib"); #elif defined(UNIX_ENABLED) - String native_aot_so_path = GodotSharpDirs::get_api_assemblies_dir().plus_file(assembly_name + ".so"); + String native_aot_so_path = GodotSharpDirs::get_api_assemblies_dir().path_join(assembly_name + ".so"); #else #error "Platform not supported (yet?)" #endif @@ -514,7 +514,7 @@ bool GDMono::_load_project_assembly() { } String assembly_path = GodotSharpDirs::get_res_temp_assemblies_dir() - .plus_file(assembly_name + ".dll"); + .path_join(assembly_name + ".dll"); assembly_path = ProjectSettings::get_singleton()->globalize_path(assembly_path); if (!FileAccess::exists(assembly_path)) { diff --git a/modules/mono/utils/path_utils.cpp b/modules/mono/utils/path_utils.cpp index 19ad59a1bc..269e41e2f4 100644 --- a/modules/mono/utils/path_utils.cpp +++ b/modules/mono/utils/path_utils.cpp @@ -205,7 +205,7 @@ String relative_to_impl(const String &p_path, const String &p_relative_to) { return p_path; } - return String("..").plus_file(relative_to_impl(p_path, base_dir)); + return String("..").path_join(relative_to_impl(p_path, base_dir)); } } diff --git a/modules/openxr/editor/openxr_action_editor.cpp b/modules/openxr/editor/openxr_action_editor.cpp index c4789d501f..52216fa483 100644 --- a/modules/openxr/editor/openxr_action_editor.cpp +++ b/modules/openxr/editor/openxr_action_editor.cpp @@ -34,10 +34,15 @@ void OpenXRActionEditor::_bind_methods() { ADD_SIGNAL(MethodInfo("remove", PropertyInfo(Variant::OBJECT, "action_editor"))); } +void OpenXRActionEditor::_theme_changed() { + rem_action->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); +} + void OpenXRActionEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - rem_action->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + _theme_changed(); } break; } } diff --git a/modules/openxr/editor/openxr_action_editor.h b/modules/openxr/editor/openxr_action_editor.h index 2667268e9a..6cf098cf08 100644 --- a/modules/openxr/editor/openxr_action_editor.h +++ b/modules/openxr/editor/openxr_action_editor.h @@ -49,6 +49,7 @@ private: OptionButton *action_type = nullptr; Button *rem_action = nullptr; + void _theme_changed(); void _on_action_name_changed(const String p_new_text); void _on_action_localized_name_changed(const String p_new_text); void _on_item_selected(int p_idx); diff --git a/modules/openxr/editor/openxr_action_map_editor.cpp b/modules/openxr/editor/openxr_action_map_editor.cpp index 6be04d8119..fcbe4d57f6 100644 --- a/modules/openxr/editor/openxr_action_map_editor.cpp +++ b/modules/openxr/editor/openxr_action_map_editor.cpp @@ -52,6 +52,7 @@ void OpenXRActionMapEditor::_bind_methods() { void OpenXRActionMapEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { for (int i = 0; i < tabs->get_child_count(); i++) { Control *tab = static_cast<Control *>(tabs->get_child(i)); diff --git a/modules/openxr/editor/openxr_action_set_editor.cpp b/modules/openxr/editor/openxr_action_set_editor.cpp index 6f70a91cfd..804808a6b9 100644 --- a/modules/openxr/editor/openxr_action_set_editor.cpp +++ b/modules/openxr/editor/openxr_action_set_editor.cpp @@ -44,12 +44,17 @@ void OpenXRActionSetEditor::_set_fold_icon() { } } +void OpenXRActionSetEditor::_theme_changed() { + _set_fold_icon(); + add_action->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + rem_action_set->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); +} + void OpenXRActionSetEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - _set_fold_icon(); - add_action->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - rem_action_set->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + _theme_changed(); panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); } break; } diff --git a/modules/openxr/editor/openxr_action_set_editor.h b/modules/openxr/editor/openxr_action_set_editor.h index 0a9e3fe7b0..d8c85d03dd 100644 --- a/modules/openxr/editor/openxr_action_set_editor.h +++ b/modules/openxr/editor/openxr_action_set_editor.h @@ -61,6 +61,7 @@ private: VBoxContainer *actions_vb = nullptr; void _set_fold_icon(); + void _theme_changed(); OpenXRActionEditor *_add_action_editor(Ref<OpenXRAction> p_action); void _update_actions(); diff --git a/modules/openxr/editor/openxr_select_action_dialog.cpp b/modules/openxr/editor/openxr_select_action_dialog.cpp index 1b7423ec73..80e58044d5 100644 --- a/modules/openxr/editor/openxr_select_action_dialog.cpp +++ b/modules/openxr/editor/openxr_select_action_dialog.cpp @@ -37,6 +37,7 @@ void OpenXRSelectActionDialog::_bind_methods() { void OpenXRSelectActionDialog::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); } break; diff --git a/modules/openxr/editor/openxr_select_interaction_profile_dialog.cpp b/modules/openxr/editor/openxr_select_interaction_profile_dialog.cpp index 8c88e268e9..23b025db08 100644 --- a/modules/openxr/editor/openxr_select_interaction_profile_dialog.cpp +++ b/modules/openxr/editor/openxr_select_interaction_profile_dialog.cpp @@ -36,6 +36,7 @@ void OpenXRSelectInteractionProfileDialog::_bind_methods() { void OpenXRSelectInteractionProfileDialog::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); } break; diff --git a/modules/text_server_adv/SCsub b/modules/text_server_adv/SCsub index c6678307af..8d0245f0f6 100644 --- a/modules/text_server_adv/SCsub +++ b/modules/text_server_adv/SCsub @@ -140,15 +140,9 @@ if env["builtin_harfbuzz"]: env_harfbuzz.Prepend(CPPPATH=["#thirdparty/graphite/include"]) env_harfbuzz.Append(CCFLAGS=["-DGRAPHITE2_STATIC"]) - if env["platform"] == "android" or env["platform"] == "linuxbsd": + if env["platform"] in ["android", "linuxbsd", "web"]: env_harfbuzz.Append(CCFLAGS=["-DHAVE_PTHREAD"]) - if env["platform"] == "javascript": - if env["threads_enabled"]: - env_harfbuzz.Append(CCFLAGS=["-DHAVE_PTHREAD"]) - else: - env_harfbuzz.Append(CCFLAGS=["-DHB_NO_MT"]) - env_text_server_adv.Prepend(CPPPATH=["#thirdparty/harfbuzz/src"]) lib = env_harfbuzz.add_library("harfbuzz_builtin", thirdparty_sources) diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index 366e1ba604..8f2abda00f 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -3229,7 +3229,7 @@ void TextServerAdvanced::font_draw_glyph(const RID &p_font_rid, const RID &p_can if (gl.texture_idx != -1) { Color modulate = p_color; #ifdef MODULE_FREETYPE_ENABLED - if (fd->cache[size]->face && (fd->cache[size]->textures[gl.texture_idx].format == Image::FORMAT_RGBA8) && !lcd_aa) { + if (fd->cache[size]->face && (fd->cache[size]->textures[gl.texture_idx].format == Image::FORMAT_RGBA8) && !lcd_aa && !fd->msdf) { modulate.r = modulate.g = modulate.b = 1.0; } #endif @@ -3321,7 +3321,7 @@ void TextServerAdvanced::font_draw_glyph_outline(const RID &p_font_rid, const RI if (gl.texture_idx != -1) { Color modulate = p_color; #ifdef MODULE_FREETYPE_ENABLED - if (fd->cache[size]->face && FT_HAS_COLOR(fd->cache[size]->face)) { + if (fd->cache[size]->face && (fd->cache[size]->textures[gl.texture_idx].format == Image::FORMAT_RGBA8) && !lcd_aa && !fd->msdf) { modulate.r = modulate.g = modulate.b = 1.0; } #endif diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp index 53b303cb20..8e4a4ff424 100644 --- a/modules/text_server_fb/text_server_fb.cpp +++ b/modules/text_server_fb/text_server_fb.cpp @@ -2286,7 +2286,7 @@ void TextServerFallback::font_draw_glyph(const RID &p_font_rid, const RID &p_can if (gl.texture_idx != -1) { Color modulate = p_color; #ifdef MODULE_FREETYPE_ENABLED - if (fd->cache[size]->face && (fd->cache[size]->textures[gl.texture_idx].format == Image::FORMAT_RGBA8) && !lcd_aa) { + if (fd->cache[size]->face && (fd->cache[size]->textures[gl.texture_idx].format == Image::FORMAT_RGBA8) && !lcd_aa && !fd->msdf) { modulate.r = modulate.g = modulate.b = 1.0; } #endif @@ -2378,7 +2378,7 @@ void TextServerFallback::font_draw_glyph_outline(const RID &p_font_rid, const RI if (gl.texture_idx != -1) { Color modulate = p_color; #ifdef MODULE_FREETYPE_ENABLED - if (fd->cache[size]->face && FT_HAS_COLOR(fd->cache[size]->face)) { + if (fd->cache[size]->face && (fd->cache[size]->textures[gl.texture_idx].format == Image::FORMAT_RGBA8) && !lcd_aa && !fd->msdf) { modulate.r = modulate.g = modulate.b = 1.0; } #endif diff --git a/modules/upnp/doc_classes/UPNP.xml b/modules/upnp/doc_classes/UPNP.xml index 847110abd4..4888dca822 100644 --- a/modules/upnp/doc_classes/UPNP.xml +++ b/modules/upnp/doc_classes/UPNP.xml @@ -1,16 +1,15 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="UPNP" inherits="RefCounted" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> <brief_description> - UPNP network functions. + Universal Plug and Play (UPnP) functions for network device discovery, querying and port forwarding. </brief_description> <description> - Provides UPNP functionality to discover [UPNPDevice]s on the local network and execute commands on them, like managing port mappings (port forwarding) and querying the local and remote network IP address. Note that methods on this class are synchronous and block the calling thread. - To forward a specific port: + This class can be used to discover compatible [UPNPDevice]s on the local network and execute commands on them, like managing port mappings (for port forwarding/NAT traversal) and querying the local and remote network IP address. Note that methods on this class are synchronous and block the calling thread. + To forward a specific port (here [code]7777[/code], note both [method discover] and [method add_port_mapping] can return errors that should be checked): [codeblock] - const PORT = 7777 var upnp = UPNP.new() - upnp.discover(2000, 2, "InternetGatewayDevice") - upnp.add_port_mapping(port) + upnp.discover() + upnp.add_port_mapping(7777) [/codeblock] To close a specific port (e.g. after you have finished using it): [codeblock] @@ -21,7 +20,7 @@ # Emitted when UPnP port mapping setup is completed (regardless of success or failure). signal upnp_completed(error) - # Replace this with your own server port number between 1025 and 65535. + # Replace this with your own server port number between 1024 and 65535. const SERVER_PORT = 3928 var thread = null @@ -48,6 +47,14 @@ # Wait for thread finish here to handle game exit while the thread is running. thread.wait_to_finish() [/codeblock] + [b]Terminology:[/b] In the context of UPnP networking, "gateway" (or "internet gateway device", short IGD) refers to network devices that allow computers in the local network to access the internet ("wide area network", WAN). These gateways are often also called "routers". + [b]Pitfalls:[/b] + - As explained above, these calls are blocking and shouldn't be run on the main thread, especially as they can block for multiple seconds at a time. Use threading! + - Networking is physical and messy. Packets get lost in transit or get filtered, addresses, free ports and assigned mappings change, and devices may leave or join the network at any time. Be mindful of this, be diligent when checking and handling errors, and handle these gracefully if you can: add clear error UI, timeouts and re-try handling. + - Port mappings may change (and be removed) at any time, and the remote/external IP address of the gateway can change likewise. You should consider re-querying the external IP and try to update/refresh the port mapping periodically (for example, every 5 minutes and on networking failures). + - Not all devices support UPnP, and some users disable UPnP support. You need to handle this (e.g. documenting and requiring the user to manually forward ports, or adding alternative methods of NAT traversal, like a relay/mirror server, or NAT hole punching, STUN/TURN, etc.). + - Consider what happens on mapping conflicts. Maybe multiple users on the same network would like to play your game at the same time, or maybe another application uses the same port. Make the port configurable, and optimally choose a port automatically (re-trying with a different port on failure). + [b]Further reading:[/b] If you want to know more about UPnP (and the Internet Gateway Device (IGD) and Port Control Protocol (PCP) specifically), [url=https://en.wikipedia.org/wiki/Universal_Plug_and_Play]Wikipedia[/url] is a good first stop, the specification can be found at the [url=https://openconnectivity.org/developer/specifications/upnp-resources/upnp/]Open Connectivity Foundation[/url] and Godot's implementation is based on the [url=https://github.com/miniupnp/miniupnp]MiniUPnP client[/url]. </description> <tutorials> </tutorials> @@ -67,9 +74,11 @@ <param index="3" name="proto" type="String" default=""UDP"" /> <param index="4" name="duration" type="int" default="0" /> <description> - Adds a mapping to forward the external [code]port[/code] (between 1 and 65535) on the default gateway (see [method get_gateway]) to the [code]internal_port[/code] on the local machine for the given protocol [code]proto[/code] (either [code]TCP[/code] or [code]UDP[/code], with UDP being the default). If a port mapping for the given port and protocol combination already exists on that gateway device, this method tries to overwrite it. If that is not desired, you can retrieve the gateway manually with [method get_gateway] and call [method add_port_mapping] on it, if any. + Adds a mapping to forward the external [code]port[/code] (between 1 and 65535, although recommended to use port 1024 or above) on the default gateway (see [method get_gateway]) to the [code]internal_port[/code] on the local machine for the given protocol [code]proto[/code] (either [code]TCP[/code] or [code]UDP[/code], with UDP being the default). If a port mapping for the given port and protocol combination already exists on that gateway device, this method tries to overwrite it. If that is not desired, you can retrieve the gateway manually with [method get_gateway] and call [method add_port_mapping] on it, if any. Note that forwarding a well-known port (below 1024) with UPnP may fail depending on the device. + Depending on the gateway device, if a mapping for that port already exists, it will either be updated or it will refuse this command due to that conflict, especially if the existing mapping for that port wasn't created via UPnP or points to a different network address (or device) than this one. If [code]internal_port[/code] is [code]0[/code] (the default), the same port number is used for both the external and the internal port (the [code]port[/code] value). - The description ([code]desc[/code]) is shown in some router UIs and can be used to point out which application added the mapping. The mapping's lease duration can be limited by specifying a [code]duration[/code] (in seconds). However, some routers are incompatible with one or both of these, so use with caution and add fallback logic in case of errors to retry without them if in doubt. + The description ([code]desc[/code]) is shown in some routers management UIs and can be used to point out which application added the mapping. + The mapping's lease [code]duration[/code] can be limited by specifying a duration in seconds. The default of [code]0[/code] means no duration, i.e. a permanent lease and notably some devices only support these permanent leases. Note that whether permanent or not, this is only a request and the gateway may still decide at any point to remove the mapping (which usually happens on a reboot of the gateway, when its external IP address changes, or on some models when it detects a port mapping has become inactive, i.e. had no traffic for multiple minutes). If not [code]0[/code] (permanent), the allowed range according to spec is between [code]120[/code] (2 minutes) and [code]86400[/code] seconds (24 hours). See [enum UPNPResult] for possible return values. </description> </method> @@ -84,7 +93,7 @@ <param index="0" name="port" type="int" /> <param index="1" name="proto" type="String" default=""UDP"" /> <description> - Deletes the port mapping for the given port and protocol combination on the default gateway (see [method get_gateway]) if one exists. [code]port[/code] must be a valid port between 1 and 65535, [code]proto[/code] can be either [code]TCP[/code] or [code]UDP[/code]. See [enum UPNPResult] for possible return values. + Deletes the port mapping for the given port and protocol combination on the default gateway (see [method get_gateway]) if one exists. [code]port[/code] must be a valid port between 1 and 65535, [code]proto[/code] can be either [code]TCP[/code] or [code]UDP[/code]. May be refused for mappings pointing to addresses other than this one, for well-known ports (below 1024), or for mappings not added via UPnP. See [enum UPNPResult] for possible return values. </description> </method> <method name="discover"> diff --git a/modules/upnp/doc_classes/UPNPDevice.xml b/modules/upnp/doc_classes/UPNPDevice.xml index b599acaba2..538ca72391 100644 --- a/modules/upnp/doc_classes/UPNPDevice.xml +++ b/modules/upnp/doc_classes/UPNPDevice.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="UPNPDevice" inherits="RefCounted" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> <brief_description> - UPNP device. + Universal Plug and Play (UPnP) device. </brief_description> <description> - UPNP device. See [UPNP] for UPNP discovery and utility functions. Provides low-level access to UPNP control commands. Allows to manage port mappings (port forwarding) and to query network information of the device (like local and external IP address and status). Note that methods on this class are synchronous and block the calling thread. + Universal Plug and Play (UPnP) device. See [UPNP] for UPnP discovery and utility functions. Provides low-level access to UPNP control commands. Allows to manage port mappings (port forwarding) and to query network information of the device (like local and external IP address and status). Note that methods on this class are synchronous and block the calling thread. </description> <tutorials> </tutorials> diff --git a/modules/webrtc/SCsub b/modules/webrtc/SCsub index e6b9959840..e315633f55 100644 --- a/modules/webrtc/SCsub +++ b/modules/webrtc/SCsub @@ -5,7 +5,7 @@ Import("env_modules") env_webrtc = env_modules.Clone() -if env["platform"] == "javascript": +if env["platform"] == "web": # Our JavaScript/C++ interface. env.AddJSLibraries(["library_godot_webrtc.js"]) diff --git a/modules/webrtc/webrtc_data_channel_js.cpp b/modules/webrtc/webrtc_data_channel_js.cpp index 0fb074b0c2..232f6998d3 100644 --- a/modules/webrtc/webrtc_data_channel_js.cpp +++ b/modules/webrtc/webrtc_data_channel_js.cpp @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED #include "webrtc_data_channel_js.h" diff --git a/modules/webrtc/webrtc_data_channel_js.h b/modules/webrtc/webrtc_data_channel_js.h index d059ec31ed..0caa76885a 100644 --- a/modules/webrtc/webrtc_data_channel_js.h +++ b/modules/webrtc/webrtc_data_channel_js.h @@ -31,7 +31,7 @@ #ifndef WEBRTC_DATA_CHANNEL_JS_H #define WEBRTC_DATA_CHANNEL_JS_H -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED #include "webrtc_data_channel.h" @@ -89,6 +89,6 @@ public: ~WebRTCDataChannelJS(); }; -#endif // JAVASCRIPT_ENABLED +#endif // WEB_ENABLED #endif // WEBRTC_DATA_CHANNEL_JS_H diff --git a/modules/webrtc/webrtc_peer_connection.cpp b/modules/webrtc/webrtc_peer_connection.cpp index 75716017d7..d885b9262b 100644 --- a/modules/webrtc/webrtc_peer_connection.cpp +++ b/modules/webrtc/webrtc_peer_connection.cpp @@ -30,7 +30,7 @@ #include "webrtc_peer_connection.h" -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED #include "webrtc_peer_connection_js.h" #endif @@ -44,7 +44,7 @@ void WebRTCPeerConnection::set_default_extension(const StringName &p_extension) } WebRTCPeerConnection *WebRTCPeerConnection::create() { -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED return memnew(WebRTCPeerConnectionJS); #else if (default_extension == String()) { diff --git a/modules/webrtc/webrtc_peer_connection_js.cpp b/modules/webrtc/webrtc_peer_connection_js.cpp index ee3a302fa2..f48705253b 100644 --- a/modules/webrtc/webrtc_peer_connection_js.cpp +++ b/modules/webrtc/webrtc_peer_connection_js.cpp @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED #include "webrtc_peer_connection_js.h" diff --git a/modules/webrtc/webrtc_peer_connection_js.h b/modules/webrtc/webrtc_peer_connection_js.h index 76b8c7fff8..50266129e4 100644 --- a/modules/webrtc/webrtc_peer_connection_js.h +++ b/modules/webrtc/webrtc_peer_connection_js.h @@ -31,7 +31,7 @@ #ifndef WEBRTC_PEER_CONNECTION_JS_H #define WEBRTC_PEER_CONNECTION_JS_H -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED #include "webrtc_peer_connection.h" diff --git a/modules/websocket/SCsub b/modules/websocket/SCsub index dc0661995f..890fb71592 100644 --- a/modules/websocket/SCsub +++ b/modules/websocket/SCsub @@ -7,7 +7,7 @@ env_ws = env_modules.Clone() thirdparty_obj = [] -if env["platform"] == "javascript": +if env["platform"] == "web": # Our JavaScript/C++ interface. env.AddJSLibraries(["library_godot_websocket.js"]) diff --git a/modules/websocket/doc_classes/WebSocketClient.xml b/modules/websocket/doc_classes/WebSocketClient.xml index f586c58302..7d73194ea9 100644 --- a/modules/websocket/doc_classes/WebSocketClient.xml +++ b/modules/websocket/doc_classes/WebSocketClient.xml @@ -24,8 +24,8 @@ If [code]true[/code] is passed as [code]gd_mp_api[/code], the client will behave like a multiplayer peer for the [MultiplayerAPI], connections to non-Godot servers will not work, and [signal data_received] will not be emitted. If [code]false[/code] is passed instead (default), you must call [PacketPeer] functions ([code]put_packet[/code], [code]get_packet[/code], etc.) on the [WebSocketPeer] returned via [code]get_peer(1)[/code] and not on this object directly (e.g. [code]get_peer(1).put_packet(data)[/code]). You can optionally pass a list of [code]custom_headers[/code] to be added to the handshake HTTP request. - [b]Note:[/b] To avoid mixed content warnings or errors in HTML5, you may have to use a [code]url[/code] that starts with [code]wss://[/code] (secure) instead of [code]ws://[/code]. When doing so, make sure to use the fully qualified domain name that matches the one defined in the server's SSL certificate. Do not connect directly via the IP address for [code]wss://[/code] connections, as it won't match with the SSL certificate. - [b]Note:[/b] Specifying [code]custom_headers[/code] is not supported in HTML5 exports due to browsers restrictions. + [b]Note:[/b] To avoid mixed content warnings or errors in Web, you may have to use a [code]url[/code] that starts with [code]wss://[/code] (secure) instead of [code]ws://[/code]. When doing so, make sure to use the fully qualified domain name that matches the one defined in the server's SSL certificate. Do not connect directly via the IP address for [code]wss://[/code] connections, as it won't match with the SSL certificate. + [b]Note:[/b] Specifying [code]custom_headers[/code] is not supported in Web exports due to browsers restrictions. </description> </method> <method name="disconnect_from_host"> @@ -52,7 +52,7 @@ <members> <member name="trusted_ssl_certificate" type="X509Certificate" setter="set_trusted_ssl_certificate" getter="get_trusted_ssl_certificate"> If specified, this [X509Certificate] will be the only one accepted when connecting to an SSL host. Any other certificate provided by the server will be regarded as invalid. - [b]Note:[/b] Specifying a custom [code]trusted_ssl_certificate[/code] is not supported in HTML5 exports due to browsers restrictions. + [b]Note:[/b] Specifying a custom [code]trusted_ssl_certificate[/code] is not supported in Web exports due to browsers restrictions. </member> <member name="verify_ssl" type="bool" setter="set_verify_ssl_enabled" getter="is_verify_ssl_enabled"> If [code]true[/code], SSL certificate verification is enabled. diff --git a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml index 23aa6ba3db..4cc4d515e7 100644 --- a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml +++ b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml @@ -27,7 +27,7 @@ Configures the buffer sizes for this WebSocket peer. Default values can be specified in the Project Settings under [code]network/limits[/code]. For server, values are meant per connected peer. The first two parameters define the size and queued packets limits of the input buffer, the last two of the output buffer. Buffer sizes are expressed in KiB, so [code]4 = 2^12 = 4096 bytes[/code]. All parameters will be rounded up to the nearest power of two. - [b]Note:[/b] HTML5 exports only use the input buffer since the output one is managed by browsers. + [b]Note:[/b] Web exports only use the input buffer since the output one is managed by browsers. </description> </method> </methods> diff --git a/modules/websocket/doc_classes/WebSocketPeer.xml b/modules/websocket/doc_classes/WebSocketPeer.xml index 43b765d2fe..627b9c607c 100644 --- a/modules/websocket/doc_classes/WebSocketPeer.xml +++ b/modules/websocket/doc_classes/WebSocketPeer.xml @@ -17,27 +17,27 @@ <description> Closes this WebSocket connection. [code]code[/code] is the status code for the closure (see RFC 6455 section 7.4 for a list of valid status codes). [code]reason[/code] is the human readable reason for closing the connection (can be any UTF-8 string that's smaller than 123 bytes). [b]Note:[/b] To achieve a clean close, you will need to keep polling until either [signal WebSocketClient.connection_closed] or [signal WebSocketServer.client_disconnected] is received. - [b]Note:[/b] The HTML5 export might not support all status codes. Please refer to browser-specific documentation for more details. + [b]Note:[/b] The Web export might not support all status codes. Please refer to browser-specific documentation for more details. </description> </method> <method name="get_connected_host" qualifiers="const"> <return type="String" /> <description> Returns the IP address of the connected peer. - [b]Note:[/b] Not available in the HTML5 export. + [b]Note:[/b] Not available in the Web export. </description> </method> <method name="get_connected_port" qualifiers="const"> <return type="int" /> <description> Returns the remote port of the connected peer. - [b]Note:[/b] Not available in the HTML5 export. + [b]Note:[/b] Not available in the Web export. </description> </method> <method name="get_current_outbound_buffered_amount" qualifiers="const"> <return type="int" /> <description> - Returns the current amount of data in the outbound websocket buffer. [b]Note:[/b] HTML5 exports use WebSocket.bufferedAmount, while other platforms use an internal buffer. + Returns the current amount of data in the outbound websocket buffer. [b]Note:[/b] Web exports use WebSocket.bufferedAmount, while other platforms use an internal buffer. </description> </method> <method name="get_write_mode" qualifiers="const"> @@ -57,7 +57,7 @@ <param index="0" name="enabled" type="bool" /> <description> Disable Nagle's algorithm on the underling TCP socket (default). See [method StreamPeerTCP.set_no_delay] for more information. - [b]Note:[/b] Not available in the HTML5 export. + [b]Note:[/b] Not available in the Web export. </description> </method> <method name="set_write_mode"> diff --git a/modules/websocket/doc_classes/WebSocketServer.xml b/modules/websocket/doc_classes/WebSocketServer.xml index 6a7bf8075c..19c36700e6 100644 --- a/modules/websocket/doc_classes/WebSocketServer.xml +++ b/modules/websocket/doc_classes/WebSocketServer.xml @@ -6,7 +6,7 @@ <description> This class implements a WebSocket server that can also support the high-level multiplayer API. After starting the server ([method listen]), you will need to [method MultiplayerPeer.poll] it at regular intervals (e.g. inside [method Node._process]). When clients connect, disconnect, or send data, you will receive the appropriate signal. - [b]Note:[/b] Not available in HTML5 exports. + [b]Note:[/b] Not available in Web exports. [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android. </description> <tutorials> diff --git a/modules/websocket/emws_client.cpp b/modules/websocket/emws_client.cpp index e051a3b564..65e0703c00 100644 --- a/modules/websocket/emws_client.cpp +++ b/modules/websocket/emws_client.cpp @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED #include "emws_client.h" @@ -82,12 +82,12 @@ Error EMWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port, String str = "ws://"; if (p_custom_headers.size()) { - WARN_PRINT_ONCE("Custom headers are not supported in HTML5 platform."); + WARN_PRINT_ONCE("Custom headers are not supported in Web platform."); } if (p_ssl) { str = "wss://"; if (ssl_cert.is_valid()) { - WARN_PRINT_ONCE("Custom SSL certificate is not supported in HTML5 platform."); + WARN_PRINT_ONCE("Custom SSL certificate is not supported in Web platform."); } } str += p_host + ":" + itos(p_port) + p_path; @@ -126,11 +126,11 @@ void EMWSClient::disconnect_from_host(int p_code, String p_reason) { } IPAddress EMWSClient::get_connected_host() const { - ERR_FAIL_V_MSG(IPAddress(), "Not supported in HTML5 export."); + ERR_FAIL_V_MSG(IPAddress(), "Not supported in Web export."); } uint16_t EMWSClient::get_connected_port() const { - ERR_FAIL_V_MSG(0, "Not supported in HTML5 export."); + ERR_FAIL_V_MSG(0, "Not supported in Web export."); } int EMWSClient::get_max_packet_size() const { @@ -156,4 +156,4 @@ EMWSClient::~EMWSClient() { } } -#endif // JAVASCRIPT_ENABLED +#endif // WEB_ENABLED diff --git a/modules/websocket/emws_client.h b/modules/websocket/emws_client.h index b71fd78124..ff63a76753 100644 --- a/modules/websocket/emws_client.h +++ b/modules/websocket/emws_client.h @@ -31,7 +31,7 @@ #ifndef EMWS_CLIENT_H #define EMWS_CLIENT_H -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED #include "core/error/error_list.h" #include "emws_peer.h" @@ -66,6 +66,6 @@ public: ~EMWSClient(); }; -#endif // JAVASCRIPT_ENABLED +#endif // WEB_ENABLED #endif // EMWS_CLIENT_H diff --git a/modules/websocket/emws_peer.cpp b/modules/websocket/emws_peer.cpp index 86169f88e9..859c92b457 100644 --- a/modules/websocket/emws_peer.cpp +++ b/modules/websocket/emws_peer.cpp @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED #include "emws_peer.h" @@ -110,15 +110,15 @@ void EMWSPeer::close(int p_code, String p_reason) { } IPAddress EMWSPeer::get_connected_host() const { - ERR_FAIL_V_MSG(IPAddress(), "Not supported in HTML5 export."); + ERR_FAIL_V_MSG(IPAddress(), "Not supported in Web export."); } uint16_t EMWSPeer::get_connected_port() const { - ERR_FAIL_V_MSG(0, "Not supported in HTML5 export."); + ERR_FAIL_V_MSG(0, "Not supported in Web export."); } void EMWSPeer::set_no_delay(bool p_enabled) { - ERR_FAIL_MSG("'set_no_delay' is not supported in HTML5 export."); + ERR_FAIL_MSG("'set_no_delay' is not supported in Web export."); } EMWSPeer::EMWSPeer() { @@ -129,4 +129,4 @@ EMWSPeer::~EMWSPeer() { close(); } -#endif // JAVASCRIPT_ENABLED +#endif // WEB_ENABLED diff --git a/modules/websocket/emws_peer.h b/modules/websocket/emws_peer.h index f52f615c35..cdbc9212a5 100644 --- a/modules/websocket/emws_peer.h +++ b/modules/websocket/emws_peer.h @@ -31,7 +31,7 @@ #ifndef EMWS_PEER_H #define EMWS_PEER_H -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED #include "core/error/error_list.h" #include "core/io/packet_peer.h" @@ -88,6 +88,6 @@ public: ~EMWSPeer(); }; -#endif // JAVASCRIPT_ENABLED +#endif // WEB_ENABLED #endif // EMWS_PEER_H diff --git a/modules/websocket/register_types.cpp b/modules/websocket/register_types.cpp index 056111ec92..faa7021b2f 100644 --- a/modules/websocket/register_types.cpp +++ b/modules/websocket/register_types.cpp @@ -36,7 +36,7 @@ #include "websocket_client.h" #include "websocket_server.h" -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED #include "emscripten.h" #include "emws_client.h" #include "emws_peer.h" @@ -59,7 +59,7 @@ static void _editor_init_callback() { void initialize_websocket_module(ModuleInitializationLevel p_level) { if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) { -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED EMWSPeer::make_default(); EMWSClient::make_default(); #else diff --git a/modules/websocket/remote_debugger_peer_websocket.cpp b/modules/websocket/remote_debugger_peer_websocket.cpp index 6319c3c664..f703873cbf 100644 --- a/modules/websocket/remote_debugger_peer_websocket.cpp +++ b/modules/websocket/remote_debugger_peer_websocket.cpp @@ -103,7 +103,7 @@ void RemoteDebuggerPeerWebSocket::close() { } bool RemoteDebuggerPeerWebSocket::can_block() const { -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED return false; #else return true; @@ -111,7 +111,7 @@ bool RemoteDebuggerPeerWebSocket::can_block() const { } RemoteDebuggerPeerWebSocket::RemoteDebuggerPeerWebSocket(Ref<WebSocketPeer> p_peer) { -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED ws_client = Ref<WebSocketClient>(memnew(EMWSClient)); #else ws_client = Ref<WebSocketClient>(memnew(WSLClient)); diff --git a/modules/websocket/remote_debugger_peer_websocket.h b/modules/websocket/remote_debugger_peer_websocket.h index 3227065ded..a37a789cbe 100644 --- a/modules/websocket/remote_debugger_peer_websocket.h +++ b/modules/websocket/remote_debugger_peer_websocket.h @@ -33,7 +33,7 @@ #include "core/debugger/remote_debugger_peer.h" -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED #include "emws_client.h" #else #include "wsl_client.h" diff --git a/modules/websocket/wsl_client.cpp b/modules/websocket/wsl_client.cpp index 478dbb9d47..2bb57226ea 100644 --- a/modules/websocket/wsl_client.cpp +++ b/modules/websocket/wsl_client.cpp @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef JAVASCRIPT_ENABLED +#ifndef WEB_ENABLED #include "wsl_client.h" #include "core/config/project_settings.h" @@ -404,4 +404,4 @@ WSLClient::~WSLClient() { disconnect_from_host(); } -#endif // JAVASCRIPT_ENABLED +#endif // WEB_ENABLED diff --git a/modules/websocket/wsl_client.h b/modules/websocket/wsl_client.h index 58b867fbe4..5d90bc4034 100644 --- a/modules/websocket/wsl_client.h +++ b/modules/websocket/wsl_client.h @@ -31,7 +31,7 @@ #ifndef WSL_CLIENT_H #define WSL_CLIENT_H -#ifndef JAVASCRIPT_ENABLED +#ifndef WEB_ENABLED #include "core/error/error_list.h" #include "core/io/stream_peer_ssl.h" @@ -86,6 +86,6 @@ public: ~WSLClient(); }; -#endif // JAVASCRIPT_ENABLED +#endif // WEB_ENABLED #endif // WSL_CLIENT_H diff --git a/modules/websocket/wsl_peer.cpp b/modules/websocket/wsl_peer.cpp index 15df4d039c..97bd87a526 100644 --- a/modules/websocket/wsl_peer.cpp +++ b/modules/websocket/wsl_peer.cpp @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef JAVASCRIPT_ENABLED +#ifndef WEB_ENABLED #include "wsl_peer.h" @@ -348,4 +348,4 @@ WSLPeer::~WSLPeer() { _data = nullptr; } -#endif // JAVASCRIPT_ENABLED +#endif // WEB_ENABLED diff --git a/modules/websocket/wsl_peer.h b/modules/websocket/wsl_peer.h index aabd3fd43e..92672eb2c4 100644 --- a/modules/websocket/wsl_peer.h +++ b/modules/websocket/wsl_peer.h @@ -31,7 +31,7 @@ #ifndef WSL_PEER_H #define WSL_PEER_H -#ifndef JAVASCRIPT_ENABLED +#ifndef WEB_ENABLED #include "core/error/error_list.h" #include "core/io/packet_peer.h" @@ -110,6 +110,6 @@ public: ~WSLPeer(); }; -#endif // JAVASCRIPT_ENABLED +#endif // WEB_ENABLED #endif // WSL_PEER_H diff --git a/modules/websocket/wsl_server.cpp b/modules/websocket/wsl_server.cpp index 517b9643f8..7457ac7087 100644 --- a/modules/websocket/wsl_server.cpp +++ b/modules/websocket/wsl_server.cpp @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef JAVASCRIPT_ENABLED +#ifndef WEB_ENABLED #include "wsl_server.h" #include "core/config/project_settings.h" @@ -326,4 +326,4 @@ WSLServer::~WSLServer() { stop(); } -#endif // JAVASCRIPT_ENABLED +#endif // WEB_ENABLED diff --git a/modules/websocket/wsl_server.h b/modules/websocket/wsl_server.h index ec7567c732..b0b7a6a5c9 100644 --- a/modules/websocket/wsl_server.h +++ b/modules/websocket/wsl_server.h @@ -31,7 +31,7 @@ #ifndef WSL_SERVER_H #define WSL_SERVER_H -#ifndef JAVASCRIPT_ENABLED +#ifndef WEB_ENABLED #include "websocket_server.h" #include "wsl_peer.h" @@ -93,6 +93,6 @@ public: ~WSLServer(); }; -#endif // JAVASCRIPT_ENABLED +#endif // WEB_ENABLED #endif // WSL_SERVER_H diff --git a/modules/webxr/SCsub b/modules/webxr/SCsub index 0a96af0811..81caa4a279 100644 --- a/modules/webxr/SCsub +++ b/modules/webxr/SCsub @@ -3,7 +3,7 @@ Import("env") Import("env_modules") -if env["platform"] == "javascript": +if env["platform"] == "web": env.AddJSLibraries(["native/library_godot_webxr.js"]) env.AddJSExterns(["native/webxr.externs.js"]) diff --git a/modules/webxr/doc_classes/WebXRInterface.xml b/modules/webxr/doc_classes/WebXRInterface.xml index 01ad962b20..49ff454f07 100644 --- a/modules/webxr/doc_classes/WebXRInterface.xml +++ b/modules/webxr/doc_classes/WebXRInterface.xml @@ -5,9 +5,9 @@ </brief_description> <description> WebXR is an open standard that allows creating VR and AR applications that run in the web browser. - As such, this interface is only available when running in an HTML5 export. + As such, this interface is only available when running in Web exports. WebXR supports a wide range of devices, from the very capable (like Valve Index, HTC Vive, Oculus Rift and Quest) down to the much less capable (like Google Cardboard, Oculus Go, GearVR, or plain smartphones). - Since WebXR is based on Javascript, it makes extensive use of callbacks, which means that [WebXRInterface] is forced to use signals, where other AR/VR interfaces would instead use functions that return a result immediately. This makes [WebXRInterface] quite a bit more complicated to initialize than other AR/VR interfaces. + Since WebXR is based on JavaScript, it makes extensive use of callbacks, which means that [WebXRInterface] is forced to use signals, where other AR/VR interfaces would instead use functions that return a result immediately. This makes [WebXRInterface] quite a bit more complicated to initialize than other AR/VR interfaces. Here's the minimum code required to start an immersive VR session: [codeblock] extends Node3D diff --git a/modules/webxr/register_types.cpp b/modules/webxr/register_types.cpp index cd403a4996..f4959c482f 100644 --- a/modules/webxr/register_types.cpp +++ b/modules/webxr/register_types.cpp @@ -33,7 +33,7 @@ #include "webxr_interface.h" #include "webxr_interface_js.h" -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED Ref<WebXRInterfaceJS> webxr; #endif @@ -44,7 +44,7 @@ void initialize_webxr_module(ModuleInitializationLevel p_level) { GDREGISTER_ABSTRACT_CLASS(WebXRInterface); -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED webxr.instantiate(); XRServer::get_singleton()->add_interface(webxr); #endif @@ -55,7 +55,7 @@ void uninitialize_webxr_module(ModuleInitializationLevel p_level) { return; } -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED if (webxr.is_valid()) { // uninitialise our interface if it is initialised if (webxr->is_initialized()) { diff --git a/modules/webxr/webxr_interface_js.cpp b/modules/webxr/webxr_interface_js.cpp index 07e6760555..7d97dbfa0b 100644 --- a/modules/webxr/webxr_interface_js.cpp +++ b/modules/webxr/webxr_interface_js.cpp @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED #include "webxr_interface_js.h" @@ -518,4 +518,4 @@ WebXRInterfaceJS::~WebXRInterfaceJS() { }; }; -#endif // JAVASCRIPT_ENABLED +#endif // WEB_ENABLED diff --git a/modules/webxr/webxr_interface_js.h b/modules/webxr/webxr_interface_js.h index f1ffedba46..dbe89dad83 100644 --- a/modules/webxr/webxr_interface_js.h +++ b/modules/webxr/webxr_interface_js.h @@ -31,7 +31,7 @@ #ifndef WEBXR_INTERFACE_JS_H #define WEBXR_INTERFACE_JS_H -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED #include "webxr_interface.h" @@ -98,6 +98,6 @@ public: ~WebXRInterfaceJS(); }; -#endif // JAVASCRIPT_ENABLED +#endif // WEB_ENABLED #endif // WEBXR_INTERFACE_JS_H |