diff --git a/.github/workflows/all_builds.yml b/.github/workflows/all_builds.yml index f5375932a..1f85eaed6 100644 --- a/.github/workflows/all_builds.yml +++ b/.github/workflows/all_builds.yml @@ -28,7 +28,7 @@ env: # TODO: change this back to godotengine/godot and target master when #109685 and #109475 are merged GODOT_REPOSITORY: nikitalita/godot # Change the README too - GODOT_MAIN_SYNC_REF: gdre-wb-c53c5a1f49 + GODOT_MAIN_SYNC_REF: gdre-wb-babc272d44e SCONSFLAGS: verbose=yes warnings=all werror=no module_text_server_fb_enabled=yes minizip=yes deprecated=yes SCONSFLAGS_TEMPLATE: no_editor_splash=yes module_camera_enabled=no module_mobile_vr_enabled=no module_upnp_enabled=no module_websocket_enabled=no module_csg_enabled=yes module_gridmap_enabled=yes use_static_cpp=yes builtin_freetype=yes builtin_libpng=yes builtin_zlib=yes builtin_libwebp=yes builtin_libvorbis=yes builtin_libogg=yes disable_3d=no SCONS_CACHE_MSVC_CONFIG: true diff --git a/README.md b/README.md index 9c76cdb83..8caba56a7 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ Note: Make sure to build the editor build first, and to launch the editor to edi ### Requirements -[Our fork of godot](https://github.com/nikitalita/godot) @ branch `gdre-wb-c53c5a1f49` +[Our fork of godot](https://github.com/nikitalita/godot) @ branch `gdre-wb-babc272d44e` - Support for building on 3.x has been dropped and no new features are being pushed - Godot RE Tools still retains the ability to decompile 3.x and 2.x projects, however. diff --git a/build/mono_decomp.py b/build/mono_decomp.py index 3c7a7da39..f376197fd 100644 --- a/build/mono_decomp.py +++ b/build/mono_decomp.py @@ -227,7 +227,7 @@ def build_godot_mono_decomp( else: lib_suffix = ".so" - src_suffixes = ["*.h", "*.cs", "*.csproj", "*.props", "*.targets", "*.pubxml"] + src_suffixes = ["*.h", "*.cs", "*.csproj", "*.props", "*.targets", "*.pubxml", "*.config"] def _builder_action(target, source, env): return godot_mono_builder( diff --git a/bytecode/bytecode_custom.cpp b/bytecode/bytecode_custom.cpp index 0f3799f59..514e8e1c6 100644 --- a/bytecode/bytecode_custom.cpp +++ b/bytecode/bytecode_custom.cpp @@ -166,7 +166,7 @@ GDScriptDecomp_custom::GDScriptDecomp_custom(Dictionary p_custom_def) { functions = p_custom_def.get("func_names", Vector()); } -GDScriptDecomp_custom *GDScriptDecomp_custom::_create_from_json(Dictionary p_custom_def) { +Ref GDScriptDecomp_custom::create_from_json(Dictionary p_custom_def) { if ((int)p_custom_def.get("bytecode_version", 0) == 0) { ERR_FAIL_V_MSG(nullptr, "Bytecode version is required"); } @@ -194,9 +194,5 @@ GDScriptDecomp_custom *GDScriptDecomp_custom::_create_from_json(Dictionary p_cus // if (p_custom_def.get("date", "") == "") { // return nullptr; // } - return memnew(GDScriptDecomp_custom(p_custom_def)); -} - -Ref GDScriptDecomp_custom::create_from_json(Dictionary p_custom_def) { - return Ref(_create_from_json(p_custom_def)); + return Ref(memnew(GDScriptDecomp_custom(p_custom_def))); } diff --git a/bytecode/bytecode_custom.h b/bytecode/bytecode_custom.h index 51f9d8e4c..64fb50585 100644 --- a/bytecode/bytecode_custom.h +++ b/bytecode/bytecode_custom.h @@ -39,6 +39,5 @@ class GDScriptDecomp_custom : public GDScriptDecomp { virtual bool is_custom() const override { return true; } GDScriptDecomp_custom() {} - static GDScriptDecomp_custom *_create_from_json(Dictionary p_custom_def); static Ref create_from_json(Dictionary p_custom_def); }; diff --git a/bytecode/bytecode_versions.cpp b/bytecode/bytecode_versions.cpp index 62dcba04f..229f37735 100644 --- a/bytecode/bytecode_versions.cpp +++ b/bytecode/bytecode_versions.cpp @@ -131,7 +131,7 @@ void register_decomp_versions() { ClassDB::register_class(); } -GDScriptDecomp *GDScriptDecompVersion::create_decomp_for_commit(int p_commit_hash) { +Ref GDScriptDecompVersion::create_decomp_for_commit(int p_commit_hash) { switch (p_commit_hash) { case 0xebc36a7: return memnew(GDScriptDecomp_ebc36a7); case 0x2e216b5: return memnew(GDScriptDecomp_2e216b5); @@ -297,9 +297,9 @@ Vector GDScriptDecompVersion::get_decomp_versions(bool in return versions; } -GDScriptDecomp *GDScriptDecompVersion::create_decomp() const { +Ref GDScriptDecompVersion::create_decomp() const { if (is_custom()) { - return GDScriptDecomp_custom::_create_from_json(custom); + return GDScriptDecomp_custom::create_from_json(custom); } return create_decomp_for_commit(commit); } diff --git a/bytecode/bytecode_versions.h b/bytecode/bytecode_versions.h index cbec4ec36..361be3c30 100644 --- a/bytecode/bytecode_versions.h +++ b/bytecode/bytecode_versions.h @@ -25,7 +25,7 @@ struct GDScriptDecompVersion { int get_major_version() const; - static GDScriptDecomp *create_decomp_for_commit(int p_commit_hash); + static Ref create_decomp_for_commit(int p_commit_hash); static Vector> get_decomps_for_bytecode_ver(int bytecode_version, bool include_dev = false); static Vector get_decomp_versions(bool include_dev = true, int ver_major = 0); @@ -34,5 +34,5 @@ struct GDScriptDecompVersion { static int register_decomp_version_custom(Dictionary p_custom_def); static int register_derived_decomp_version_custom(int revision, Dictionary p_custom_def); - GDScriptDecomp *create_decomp() const; + Ref create_decomp() const; }; diff --git a/compat/resource_compat_binary.cpp b/compat/resource_compat_binary.cpp index 2eebcc1b3..59b3a2222 100644 --- a/compat/resource_compat_binary.cpp +++ b/compat/resource_compat_binary.cpp @@ -797,7 +797,7 @@ Error ResourceLoaderCompatBinary::load() { Ref res; Resource *r = nullptr; - MissingResource *missing_resource = nullptr; + Ref missing_resource = nullptr; Ref converter; if (main && (is_real_load())) { @@ -810,7 +810,7 @@ Error ResourceLoaderCompatBinary::load() { auto nres = main ? CompatFormatLoader::create_missing_main_resource(path, t, uid, no_fake_script) : CompatFormatLoader::create_missing_internal_resource(path, t, id, no_fake_script); res = Ref(nres); if (res->get_class() == "MissingResource") { - missing_resource = Object::cast_to(res.ptr()); + missing_resource = res; } else { fake_script = true; } @@ -849,7 +849,7 @@ Error ResourceLoaderCompatBinary::load() { missing_resource = memnew(MissingResource); missing_resource->set_original_class(t); missing_resource->set_recording_properties(true); - obj = missing_resource; + obj = missing_resource.ptr(); } else { error = ERR_FILE_CORRUPT; ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, vformat("'%s': Resource of unrecognized type in file: '%s'.", local_path, t)); @@ -914,7 +914,7 @@ Error ResourceLoaderCompatBinary::load() { } bool set_valid = true; - if (value.get_type() == Variant::OBJECT && (!fake_script && missing_resource == nullptr) && ResourceLoader::is_creating_missing_resources_if_class_unavailable_enabled()) { + if (value.get_type() == Variant::OBJECT && (!fake_script && missing_resource.is_null()) && ResourceLoader::is_creating_missing_resources_if_class_unavailable_enabled()) { // If the property being set is a missing resource (and the parent is not), // then setting it will most likely not work. // Instead, save it as metadata. @@ -969,7 +969,7 @@ Error ResourceLoaderCompatBinary::load() { } if (set_valid) { - if (!missing_resource && ver_major <= 2 && name == "resource/name") { + if (missing_resource.is_null() && ver_major <= 2 && name == "resource/name") { name = "resource_name"; } bool valid = false; @@ -985,7 +985,7 @@ Error ResourceLoaderCompatBinary::load() { } } - if (missing_resource) { + if (missing_resource.is_valid()) { missing_resource->set_recording_properties(false); if (converter.is_valid()) { Ref compat = ResourceInfo::get_info_from_resource(missing_resource); diff --git a/compat/resource_compat_text.cpp b/compat/resource_compat_text.cpp index 4243d13dd..cfe2b4a2a 100644 --- a/compat/resource_compat_text.cpp +++ b/compat/resource_compat_text.cpp @@ -655,7 +655,7 @@ Error ResourceLoaderCompatText::load() { bool not_cached = false; bool fake_script = false; - MissingResource *missing_resource = nullptr; + Ref missing_resource = nullptr; Ref converter; auto init_missing_internal_resource([&](bool no_fake_script) { auto nres = CompatFormatLoader::create_missing_internal_resource(path, type, id, no_fake_script); @@ -690,7 +690,7 @@ Error ResourceLoaderCompatText::load() { missing_resource = memnew(MissingResource); missing_resource->set_original_class(type); missing_resource->set_recording_properties(true); - obj = missing_resource; + obj = missing_resource.ptr(); } else { error_text = vformat("Can't create sub resource of type '%s'", type); _printerr(); @@ -799,7 +799,7 @@ Error ResourceLoaderCompatText::load() { } if (set_valid) { - if (!missing_resource && ver_major <= 2 && assign == "resource/name") { + if (missing_resource.is_null() && ver_major <= 2 && assign == "resource/name") { assign = "resource_name"; } bool valid = false; @@ -826,7 +826,7 @@ Error ResourceLoaderCompatText::load() { } } - if (missing_resource) { + if (missing_resource.is_valid()) { missing_resource->set_recording_properties(false); if (converter.is_valid()) { Ref compat = ResourceInfo::get_info_from_resource(missing_resource); @@ -880,7 +880,7 @@ Error ResourceLoaderCompatText::load() { } bool fake_script = false; - MissingResource *missing_resource = nullptr; + Ref missing_resource = nullptr; Ref converter; auto init_missing_main_resource([&](bool no_fake_script) { auto res = CompatFormatLoader::create_missing_main_resource(local_path, res_type, res_uid, no_fake_script); @@ -914,10 +914,12 @@ Error ResourceLoaderCompatText::load() { } if (!resource.is_valid()) { + Ref res; Object *obj = ClassDB::class_exists(res_type) || !ClassDB::get_compatibility_class(res_type).is_empty() ? ClassDB::instantiate(res_type) : nullptr; if (!obj) { if (ResourceLoader::is_creating_missing_resources_if_class_unavailable_enabled()) { - obj = CompatFormatLoader::create_missing_main_resource(local_path, res_type, res_uid); + res = CompatFormatLoader::create_missing_main_resource(local_path, res_type, res_uid); + obj = res.ptr(); if (obj->get_class() == "MissingResource") { missing_resource = Object::cast_to(obj); missing_resource->set_original_class(res_type); @@ -1015,7 +1017,7 @@ Error ResourceLoaderCompatText::load() { } if (set_valid) { - if (!missing_resource && ver_major <= 2 && assign == "resource/name") { + if (missing_resource.is_null() && ver_major <= 2 && assign == "resource/name") { assign = "resource_name"; } bool valid = false; @@ -1046,7 +1048,7 @@ Error ResourceLoaderCompatText::load() { *progress = resource_current / float(resources_total); } - if (missing_resource) { + if (missing_resource.is_valid()) { missing_resource->set_recording_properties(false); if (converter.is_valid()) { Ref compat = ResourceInfo::get_info_from_resource(missing_resource); diff --git a/compat/resource_loader_compat.h b/compat/resource_loader_compat.h index d9c6f73a6..5286d5ae6 100644 --- a/compat/resource_loader_compat.h +++ b/compat/resource_loader_compat.h @@ -118,15 +118,15 @@ class CompatFormatLoader : public ResourceFormatLoader { } } - static Resource *make_fakescript_or_mising_resource(const String &path, const String &type, const String &scene_id = "", bool no_fake_script = false) { - Resource *ret; + static Ref make_fakescript_or_mising_resource(const String &path, const String &type, const String &scene_id = "", bool no_fake_script = false) { + Ref ret; if (!no_fake_script && (type == "Script" || type == "GDScript" || type == "CSharpScript")) { - FakeScript *res{ memnew(FakeScript) }; + Ref res{ memnew(FakeScript) }; res->set_original_class(type); res->set_instance_recording_properties(false); ret = res; } else { - MissingResource *res{ memnew(MissingResource) }; + Ref res{ memnew(MissingResource) }; res->set_original_class(type); res->set_recording_properties(true); ret = res; @@ -152,25 +152,25 @@ class CompatFormatLoader : public ResourceFormatLoader { return res; } - static Resource *create_missing_main_resource(const String &path, const String &type, const ResourceUID::ID uid, bool no_fake_script = false) { - Resource *res{ make_fakescript_or_mising_resource(path, type, "", no_fake_script) }; + static Ref create_missing_main_resource(const String &path, const String &type, const ResourceUID::ID uid, bool no_fake_script = false) { + Ref res{ make_fakescript_or_mising_resource(path, type, "", no_fake_script) }; Ref compat; compat.instantiate(); compat->uid = uid; compat->type = type; compat->topology_type = ResourceInfo::MAIN_RESOURCE; - compat->_set_on_resource(res); + compat->set_on_resource(res); return res; } - static Resource *create_missing_internal_resource(const String &path, const String &type, const String &scene_id, bool no_fake_script = false) { - Resource *res{ make_fakescript_or_mising_resource("", type, scene_id, no_fake_script) }; + static Ref create_missing_internal_resource(const String &path, const String &type, const String &scene_id, bool no_fake_script = false) { + Ref res{ make_fakescript_or_mising_resource("", type, scene_id, no_fake_script) }; Ref compat; compat.instantiate(); compat->uid = ResourceUID::INVALID_ID; compat->type = type; compat->topology_type = ResourceInfo::INTERNAL_RESOURCE; - compat->_set_on_resource(res); + compat->set_on_resource(res); return res; } diff --git a/editor/gdre_cmp_dlg.cpp b/editor/gdre_cmp_dlg.cpp index d6c764d9f..fbcf8385f 100644 --- a/editor/gdre_cmp_dlg.cpp +++ b/editor/gdre_cmp_dlg.cpp @@ -4,7 +4,6 @@ /*************************************************************************/ #ifdef TOOLS_ENABLED #include "editor/editor_node.h" -#include "editor/settings/editor_settings.h" #endif /*************************************************************************/ diff --git a/editor/gdre_editor.cpp b/editor/gdre_editor.cpp index 7d736dc20..a4c1c37ba 100644 --- a/editor/gdre_editor.cpp +++ b/editor/gdre_editor.cpp @@ -28,6 +28,7 @@ #include "scene/gui/button.h" #include "scene/gui/texture_rect.h" #include "scene/main/canvas_item.h" +#include "scene/main/scene_tree.h" #include "scene/resources/image_texture.h" #include "core/version_generated.gen.h" @@ -583,14 +584,14 @@ void GodotREEditor::_decompile_process() { print_warning("GDScriptDecomp{" + itos(script_dialog_d->get_bytecode_version()) + "}", RTR("Decompile")); String failed_files; - GDScriptDecomp *dce = GDScriptDecompVersion::create_decomp_for_commit(script_dialog_d->get_bytecode_version()); + Ref dce = GDScriptDecompVersion::create_decomp_for_commit(script_dialog_d->get_bytecode_version()); - if (!dce) { + if (dce.is_null()) { show_warning(failed_files, RTR("Decompile"), RTR("Invalid bytecode version!")); return; } - EditorProgressGDDC *pr = memnew(EditorProgressGDDC(ne_parent, "re_decompile", RTR("Decompiling files..."), files.size(), true)); + Ref pr = memnew(EditorProgressGDDC(ne_parent, "re_decompile", RTR("Decompiling files..."), files.size(), true)); for (int i = 0; i < files.size(); i++) { print_warning(RTR("decompiling") + " " + files[i].get_file(), RTR("Decompile")); @@ -620,8 +621,8 @@ void GodotREEditor::_decompile_process() { } } - memdelete(pr); - memdelete(dce); + pr.unref(); + dce.unref(); if (failed_files.length() > 0) { show_warning(failed_files, RTR("Decompile"), RTR("At least one error was detected!")); @@ -667,7 +668,7 @@ void GodotREEditor::_compile_process() { String failed_files; Ref dce = GDScriptDecomp::create_decomp_for_commit(rev); - EditorProgressGDDC *pr = memnew(EditorProgressGDDC(ne_parent, "re_compile", RTR("Compiling files..."), files.size(), true)); + Ref pr = memnew(EditorProgressGDDC(ne_parent, "re_compile", RTR("Compiling files..."), files.size(), true)); for (int i = 0; i < files.size(); i++) { print_warning(RTR("compiling") + " " + files[i].get_file(), RTR("Compile")); @@ -711,7 +712,7 @@ void GodotREEditor::_compile_process() { } } - memdelete(pr); + pr.unref(); if (failed_files.length() > 0) { show_warning(failed_files, RTR("Compile"), RTR("At least one error was detected!")); @@ -899,7 +900,7 @@ void GodotREEditor::_res_smpl_2_wav_request(const Vector &p_files) { } void GodotREEditor::_res_smpl_2_wav_process() { - EditorProgressGDDC *pr = memnew(EditorProgressGDDC(ne_parent, "re_wav2_res", RTR("Converting files..."), res_files.size(), true)); + Ref pr = memnew(EditorProgressGDDC(ne_parent, "re_wav2_res", RTR("Converting files..."), res_files.size(), true)); String failed_files; Ref rl = memnew(ResourceFormatLoaderBinary); @@ -918,7 +919,7 @@ void GodotREEditor::_res_smpl_2_wav_process() { } } - memdelete(pr); + pr.unref(); res_files = Vector(); if (failed_files.length() > 0) { @@ -949,7 +950,7 @@ void GodotREEditor::_res_ostr_2_ogg_request(const Vector &p_files) { } void GodotREEditor::_res_ostr_2_ogg_process() { - EditorProgressGDDC *pr = memnew(EditorProgressGDDC(ne_parent, "re_ogg2_res", RTR("Converting files..."), res_files.size(), true)); + Ref pr = memnew(EditorProgressGDDC(ne_parent, "re_ogg2_res", RTR("Converting files..."), res_files.size(), true)); String failed_files; Ref rl = memnew(ResourceFormatLoaderBinary); @@ -970,7 +971,7 @@ void GodotREEditor::_res_ostr_2_ogg_process() { } } - memdelete(pr); + pr.unref(); res_files = Vector(); if (failed_files.length() > 0) { @@ -1001,7 +1002,7 @@ void GodotREEditor::_res_stex_2_png_request(const Vector &p_files) { } void GodotREEditor::_res_stxt_2_png_process() { - EditorProgressGDDC *pr = memnew(EditorProgressGDDC(ne_parent, "re_st2pnh_res", RTR("Converting files..."), res_files.size(), true)); + Ref pr = memnew(EditorProgressGDDC(ne_parent, "re_st2pnh_res", RTR("Converting files..."), res_files.size(), true)); String failed_files; for (int i = 0; i < res_files.size(); i++) { @@ -1021,7 +1022,7 @@ void GodotREEditor::_res_stxt_2_png_process() { } } - memdelete(pr); + pr.unref(); res_files = Vector(); if (failed_files.length() > 0) { @@ -1064,7 +1065,7 @@ void GodotREEditor::_res_bin_2_txt_request(const Vector &p_files) { } void GodotREEditor::_res_bin_2_txt_process() { - EditorProgressGDDC *pr = memnew(EditorProgressGDDC(ne_parent, "re_b2t_res", RTR("Converting files..."), res_files.size(), true)); + Ref pr = memnew(EditorProgressGDDC(ne_parent, "re_b2t_res", RTR("Converting files..."), res_files.size(), true)); String failed_files; for (int i = 0; i < res_files.size(); i++) { @@ -1092,7 +1093,7 @@ void GodotREEditor::_res_bin_2_txt_process() { } } - memdelete(pr); + pr.unref(); res_files = Vector(); if (failed_files.length() > 0) { @@ -1124,7 +1125,7 @@ void GodotREEditor::_export_resource_output_request(const String &p_path) { } void GodotREEditor::_export_resource_process(const String &p_output_path) { - EditorProgressGDDC *pr = memnew(EditorProgressGDDC(ne_parent, "re_export_res", RTR("Exporting resources..."), res_files.size(), true)); + Ref pr = memnew(EditorProgressGDDC(ne_parent, "re_export_res", RTR("Exporting resources..."), res_files.size(), true)); String failed_files; for (int i = 0; i < res_files.size(); i++) { @@ -1141,7 +1142,7 @@ void GodotREEditor::_export_resource_process(const String &p_output_path) { } } - memdelete(pr); + pr.unref(); res_files = Vector(); if (failed_files.length() > 0) { @@ -1184,7 +1185,7 @@ void GodotREEditor::_res_txt_2_bin_request(const Vector &p_files) { } void GodotREEditor::_res_txt_2_bin_process() { - EditorProgressGDDC *pr = memnew(EditorProgressGDDC(ne_parent, "re_t2b_res", RTR("Converting files..."), res_files.size(), true)); + Ref pr = memnew(EditorProgressGDDC(ne_parent, "re_t2b_res", RTR("Converting files..."), res_files.size(), true)); String failed_files; for (int i = 0; i < res_files.size(); i++) { @@ -1208,7 +1209,7 @@ void GodotREEditor::_res_txt_2_bin_process() { } } - memdelete(pr); + pr.unref(); res_files = Vector(); if (failed_files.length() > 0) { diff --git a/exporters/scene_exporter.cpp b/exporters/scene_exporter.cpp index 593a71bf8..4a0809ee0 100644 --- a/exporters/scene_exporter.cpp +++ b/exporters/scene_exporter.cpp @@ -16,8 +16,10 @@ #include "scene/3d/navigation/navigation_region_3d.h" #include "scene/3d/occluder_instance_3d.h" #include "scene/3d/physics/area_3d.h" +#include "scene/3d/physics/collision_shape_3d.h" #include "scene/3d/physics/rigid_body_3d.h" #include "scene/3d/physics/static_body_3d.h" +#include "scene/main/scene_tree.h" #include "scene/resources/3d/box_shape_3d.h" #include "scene/resources/3d/capsule_shape_3d.h" #include "scene/resources/3d/cylinder_shape_3d.h" @@ -1759,7 +1761,7 @@ Node *GLBExporterInstance::_set_stuff_from_instanced_scene(Node *root) { // Force re-compute animation tracks. Vector> anim_libs; AnimationPlayer *player = Object::cast_to(animation_player_nodes[node_i]); - List anim_lib_names; + LocalVector anim_lib_names; player->get_animation_library_list(&anim_lib_names); for (auto &lib_name : anim_lib_names) { Ref lib = player->get_animation_library(lib_name); @@ -1772,7 +1774,7 @@ Node *GLBExporterInstance::_set_stuff_from_instanced_scene(Node *root) { auto current_pos = current_anmation.is_empty() ? 0 : player->get_current_animation_position(); int64_t max_fps = -1; for (auto &anim_lib : anim_libs) { - List anim_names; + LocalVector anim_names; anim_lib->get_animation_list(&anim_names); if (ver_major <= 3 && anim_names.size() > 0) { Ref mesh_surface_re = RegEx::create_from_string(":mesh:surface_(\\d+)"); @@ -1808,7 +1810,7 @@ Node *GLBExporterInstance::_set_stuff_from_instanced_scene(Node *root) { info->extra.set(converted_paths_from_3_x, true); } - player->set_current_animation(anim_names.front()->get()); + player->set_current_animation(*anim_names.begin()); player->advance(0); player->set_current_animation(current_anmation); if (!current_anmation.is_empty()) { diff --git a/exporters/scene_exporter.h b/exporters/scene_exporter.h index cde341187..8e6fc08a6 100644 --- a/exporters/scene_exporter.h +++ b/exporters/scene_exporter.h @@ -5,6 +5,7 @@ struct dep_info; struct BatchExportToken; +class PackedScene; #include "modules/gltf/extensions/gltf_document_extension.h" diff --git a/godot-mono-decomp/GodotMonoDecomp/GodotMonoDecomp.csproj b/godot-mono-decomp/GodotMonoDecomp/GodotMonoDecomp.csproj index 3d3a570e7..f91c0d18a 100644 --- a/godot-mono-decomp/GodotMonoDecomp/GodotMonoDecomp.csproj +++ b/godot-mono-decomp/GodotMonoDecomp/GodotMonoDecomp.csproj @@ -9,8 +9,8 @@ true - - + + diff --git a/godot-mono-decomp/GodotMonoDecomp/GodotProjectDecompiler.cs b/godot-mono-decomp/GodotMonoDecomp/GodotProjectDecompiler.cs index 3b0787d62..4917c8e99 100644 --- a/godot-mono-decomp/GodotMonoDecomp/GodotProjectDecompiler.cs +++ b/godot-mono-decomp/GodotMonoDecomp/GodotProjectDecompiler.cs @@ -306,7 +306,6 @@ public virtual CSharpDecompiler CreateDecompiler(DecompilerTypeSystem ts) decompiler.AstTransforms.Add(new EscapeInvalidIdentifiers()); decompiler.AstTransforms.Add(new RemoveCLSCompliantAttribute()); decompiler.AstTransforms.Add(new RemoveGodotScriptPathAttribute()); - decompiler.AstTransforms.Add(new RemoveAutoAccessor()); decompiler.AstTransforms.Add(new GodotMonoDecomp.RemoveEmbeddedAttributes()); decompiler.AstTransforms.Add(new RestoreGeneratedRegexMethods()); decompiler.AstTransforms.Add(new RemoveGeneratedExceptionThrows()); diff --git a/godot-mono-decomp/GodotMonoDecomp/GodotStuff.cs b/godot-mono-decomp/GodotMonoDecomp/GodotStuff.cs index 9caf98ca7..563834dcc 100644 --- a/godot-mono-decomp/GodotMonoDecomp/GodotStuff.cs +++ b/godot-mono-decomp/GodotMonoDecomp/GodotStuff.cs @@ -1065,10 +1065,6 @@ public static bool IsBannedGodotTypeMember(IEntity entity) { return true; } - if (RemoveAutoAccessor.IsCompilerGeneratedAccessorMethod(method)) - { - return true; - } // auto-generated getter methods for properties of parent classes diff --git a/godot-mono-decomp/GodotMonoDecomp/NuGetUtils.cs b/godot-mono-decomp/GodotMonoDecomp/NuGetUtils.cs index 6f5e3fb7f..b16af2e0c 100644 --- a/godot-mono-decomp/GodotMonoDecomp/NuGetUtils.cs +++ b/godot-mono-decomp/GodotMonoDecomp/NuGetUtils.cs @@ -213,7 +213,7 @@ public static bool IsPackageInLocalCache(string name, string version) public static async Task DownloadPackageToLocalCache(string name, string version, CancellationToken cancellationToken) { - string p = Path.Combine(UserPackagesPath, name, version); + string p = Path.Combine(UserPackagesPath, name.ToLower(), version.ToLower()); if (File.Exists(p)) { return p; diff --git a/godot-mono-decomp/GodotMonoDecomp/RemoveAutoAccessor.cs b/godot-mono-decomp/GodotMonoDecomp/RemoveAutoAccessor.cs deleted file mode 100644 index 5e7a00bec..000000000 --- a/godot-mono-decomp/GodotMonoDecomp/RemoveAutoAccessor.cs +++ /dev/null @@ -1,88 +0,0 @@ -using ICSharpCode.Decompiler.CSharp; -using ICSharpCode.Decompiler.CSharp.Syntax; -using ICSharpCode.Decompiler.CSharp.Transforms; -using ICSharpCode.Decompiler.TypeSystem; - -namespace GodotMonoDecomp; - -/// -/// Converts extension method calls into infix syntax. -/// -public class RemoveAutoAccessor : DepthFirstAstVisitor, IAstTransform -{ - public void Run(AstNode rootNode, TransformContext context) - { - rootNode.AcceptVisitor(this); - } - - public static bool IsCompilerGeneratedAccessorMethod(IMethod method) - { - // if it's compiler generated, it won't be marked as virtual and it won't be an actual accessor method - if (!method.Name.Contains('.') || method.IsVirtual || method.IsAccessor) - { - return false; - } - - bool isAdder = method.Name.Contains(".add_"); - bool isRemover = method.Name.Contains(".remove_"); - bool isInvoker = method.Name.Contains(".invoke_"); - bool isGetter = method.Name.Contains(".get_"); - bool isSetter = method.Name.Contains(".set_"); - if (isGetter || isSetter || isAdder || isRemover || isInvoker) - { - var lastDot = method.Name.LastIndexOf('.'); - var parentClass = method.Name.Substring(0, lastDot).Split("<")[0]; - var methodName = method.Name.Substring(lastDot + 1); - var usidx = methodName.IndexOf('_'); - if (string.IsNullOrEmpty(parentClass) || string.IsNullOrEmpty(methodName) || usidx < 0) - { - return false; - } - var memberName = methodName.Substring(usidx + 1); - var baseTypes = method.DeclaringType.GetAllBaseTypes(); - var baseType = baseTypes.FirstOrDefault(t => t.FullName == parentClass); - if (baseType == null) - { - return false; - } - IMember? member = baseType.GetMembers().FirstOrDefault(m => m.Name == memberName); - - if ((isGetter || isSetter) && member is IProperty prop) - { - var memberAccessorName = isGetter ? prop.Getter?.Name : prop.Setter?.Name; - - if (memberAccessorName == methodName) - { - return true; - } - } else if (member is IEvent ev) - { - var memberAccessorName = isInvoker ? ev.InvokeAccessor?.Name : - isAdder ? ev.AddAccessor?.Name : isRemover ? ev.RemoveAccessor?.Name : null; - if (memberAccessorName == methodName) - { - return true; - } - } - } - return false; - - } - - public override void VisitMethodDeclaration(MethodDeclaration methodDeclaration) - { - try - { - if (methodDeclaration.GetSymbol() is IMethod method && IsCompilerGeneratedAccessorMethod(method)) - { - methodDeclaration.Remove(); - return; - } - - base.VisitMethodDeclaration(methodDeclaration); - } - finally - { - } - } -} diff --git a/godot-mono-decomp/dependencies/ICSharpCode.Decompiler.10.0.0.8290-preview3.nupkg b/godot-mono-decomp/dependencies/ICSharpCode.Decompiler.10.0.0.8290-preview3.nupkg deleted file mode 100644 index 0750cab13..000000000 Binary files a/godot-mono-decomp/dependencies/ICSharpCode.Decompiler.10.0.0.8290-preview3.nupkg and /dev/null differ diff --git a/godot-mono-decomp/dependencies/ICSharpCode.ILSpyX.10.0.0.8290-preview3.nupkg b/godot-mono-decomp/dependencies/ICSharpCode.ILSpyX.10.0.0.8290-preview3.nupkg deleted file mode 100644 index 50fa0aa8a..000000000 Binary files a/godot-mono-decomp/dependencies/ICSharpCode.ILSpyX.10.0.0.8290-preview3.nupkg and /dev/null differ diff --git a/godot-mono-decomp/nuget.config b/godot-mono-decomp/nuget.config index 09eb98959..61d400f32 100644 --- a/godot-mono-decomp/nuget.config +++ b/godot-mono-decomp/nuget.config @@ -1,5 +1,5 @@ - + diff --git a/gui/find_replace_bar.cpp b/gui/find_replace_bar.cpp index ec739b4ff..5dc02abfc 100644 --- a/gui/find_replace_bar.cpp +++ b/gui/find_replace_bar.cpp @@ -25,6 +25,7 @@ void GDREFindReplaceBar::_notification(int p_what) { find_next->set_button_icon(GDREGuiIcons::get_icon(SNAME("MoveDown"), get_theme_default_base_scale())); hide_button->set_button_icon(GDREGuiIcons::get_icon(SNAME("Close"), get_theme_default_base_scale())); _update_toggle_replace_button(replace_text->is_visible_in_tree()); + _update_parent_resize_connection(); } break; case NOTIFICATION_TRANSLATION_CHANGED: { @@ -38,9 +39,27 @@ void GDREFindReplaceBar::_notification(int p_what) { } break; case NOTIFICATION_VISIBILITY_CHANGED: { + if (!is_visible_in_tree()) { + resize_handle_dragging = false; + } else { + _cache_minimum_resize_width(); + } set_process_input(is_visible_in_tree()); } break; + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_PARENTED: { + _update_parent_resize_connection(); + } break; + + case NOTIFICATION_EXIT_TREE: + case NOTIFICATION_UNPARENTED: { + if (resize_parent_control && resize_parent_control->is_connected(SceneStringName(resized), callable_mp(this, &GDREFindReplaceBar::_on_parent_control_resized))) { + resize_parent_control->disconnect(SceneStringName(resized), callable_mp(this, &GDREFindReplaceBar::_on_parent_control_resized)); + } + resize_parent_control = nullptr; + } break; + case NOTIFICATION_THEME_CHANGED: { matches_label->add_theme_color_override(SceneStringName(font_color), results_count > 0 ? get_theme_color(SceneStringName(font_color), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("Editor"))); } break; @@ -69,6 +88,132 @@ void GDREFindReplaceBar::input(const Ref &p_event) { } } +void GDREFindReplaceBar::gui_input(const Ref &p_event) { + if (p_event.is_null()) { + return; + } + + Ref mb = p_event; + if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT) { + if (mb->is_pressed()) { + if (_is_on_resize_edge(mb->get_position())) { + _cache_minimum_resize_width(); + resize_handle_dragging = true; + resize_drag_origin_x = mb->get_global_position().x; + resize_drag_start_width = (int)get_size().x; + accept_event(); + } + } else if (resize_handle_dragging) { + resize_handle_dragging = false; + accept_event(); + } + return; + } + + Ref mm = p_event; + if (mm.is_valid() && resize_handle_dragging) { + const int delta = (int)(mm->get_global_position().x - resize_drag_origin_x); + int target_width = resize_drag_start_width - delta; + if (is_layout_rtl()) { + target_width = resize_drag_start_width + delta; + } + _set_bar_width(target_width); + accept_event(); + } +} + +Control::CursorShape GDREFindReplaceBar::get_cursor_shape(const Point2 &p_pos) const { + if (resize_handle_dragging || _is_on_resize_edge(p_pos)) { + return CURSOR_HSPLIT; + } + return PanelContainer::get_cursor_shape(p_pos); +} + +bool GDREFindReplaceBar::_is_on_resize_edge(const Point2 &p_position) const { + if (!resizable) { + return false; + } + + const float edge_size = (float)MAX(6, resize_edge_size); + if (p_position.y < 0.0f || p_position.y > get_size().y) { + return false; + } + + if (is_layout_rtl()) { + return p_position.x >= get_size().x - edge_size; + } + + return p_position.x <= edge_size; +} + +void GDREFindReplaceBar::_update_parent_resize_connection() { + Control *parent_control = get_parent_control(); + if (resize_parent_control == parent_control) { + return; + } + + if (resize_parent_control && resize_parent_control->is_connected(SceneStringName(resized), callable_mp(this, &GDREFindReplaceBar::_on_parent_control_resized))) { + resize_parent_control->disconnect(SceneStringName(resized), callable_mp(this, &GDREFindReplaceBar::_on_parent_control_resized)); + } + + resize_parent_control = parent_control; + if (resize_parent_control && !resize_parent_control->is_connected(SceneStringName(resized), callable_mp(this, &GDREFindReplaceBar::_on_parent_control_resized))) { + resize_parent_control->connect(SceneStringName(resized), callable_mp(this, &GDREFindReplaceBar::_on_parent_control_resized)); + } +} + +void GDREFindReplaceBar::_on_parent_control_resized() { + if (desired_resize_width < 0) { + desired_resize_width = (int)get_size().x; + } + _set_bar_width(desired_resize_width, false); +} + +void GDREFindReplaceBar::_cache_minimum_resize_width() { + minimum_resize_width_pending = false; + if (minimum_resize_width >= 0 || !is_visible_in_tree()) { + return; + } + + const int current_width = (int)get_size().x; + if (current_width <= 0) { + if (!minimum_resize_width_pending) { + minimum_resize_width_pending = true; + callable_mp(this, &GDREFindReplaceBar::_cache_minimum_resize_width).call_deferred(); + } + return; + } + + minimum_resize_width = current_width; + if (desired_resize_width < 0) { + desired_resize_width = current_width; + } +} + +void GDREFindReplaceBar::_set_bar_width(int p_width, bool p_update_desired_width) { + int target_width = p_width; + if (minimum_resize_width >= 0 && target_width < minimum_resize_width) { + target_width = minimum_resize_width; + } + if (p_update_desired_width) { + desired_resize_width = target_width; + } + const Control *parent_control = get_parent_control(); + if (parent_control) { + const int parent_width = (int)parent_control->get_size().x; + const int right_edge_in_parent = (int)(get_position().x + get_size().x); + const int max_width_in_parent = MIN(parent_width, right_edge_in_parent); + if (max_width_in_parent > 0 && target_width > max_width_in_parent) { + target_width = max_width_in_parent; + } + } + if (target_width <= 0 || target_width == (int)get_size().x) { + return; + } + + set_offset(SIDE_LEFT, get_offset(SIDE_RIGHT) - target_width); +} + void GDREFindReplaceBar::_update_flags(bool p_direction_backwards) { flags = 0; @@ -473,6 +618,7 @@ void GDREFindReplaceBar::_update_toggle_replace_button(bool p_replace_visible) { void GDREFindReplaceBar::_show_search(bool p_with_replace, bool p_show_only) { show(); + _cache_minimum_resize_width(); if (p_show_only) { return; } @@ -742,6 +888,25 @@ bool GDREFindReplaceBar::is_showing_panel_background() const { return should_show_panel_background; } +void GDREFindReplaceBar::set_resizable(bool p_resizable) { + if (resizable == p_resizable) { + return; + } + + resizable = p_resizable; + if (!resizable) { + resize_handle_dragging = false; + } + + if (is_inside_tree()) { + get_viewport()->update_mouse_cursor_state(); + } +} + +bool GDREFindReplaceBar::is_resizable() const { + return resizable; +} + void GDREFindReplaceBar::_update_panel_background() { if (should_show_panel_background) { remove_theme_style_override(SceneStringName(panel)); @@ -785,11 +950,14 @@ void GDREFindReplaceBar::_bind_methods() { ClassDB::bind_method(D_METHOD("set_show_panel_background", "p_show"), &GDREFindReplaceBar::set_show_panel_background); ClassDB::bind_method(D_METHOD("is_showing_panel_background"), &GDREFindReplaceBar::is_showing_panel_background); + ClassDB::bind_method(D_METHOD("set_resizable", "p_resizable"), &GDREFindReplaceBar::set_resizable); + ClassDB::bind_method(D_METHOD("is_resizable"), &GDREFindReplaceBar::is_resizable); ClassDB::bind_method(D_METHOD("refresh_search"), &GDREFindReplaceBar::refresh_search); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_panel_background"), "set_show_panel_background", "is_showing_panel_background"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "replace_enabled"), "set_replace_enabled", "is_replace_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "resizable"), "set_resizable", "is_resizable"); } void GDREFindReplaceBar::_set_matches_custom_minimum_size() { @@ -808,6 +976,7 @@ GDREFindReplaceBar::GDREFindReplaceBar() { main->set_v_size_flags(SIZE_EXPAND_FILL); // main->set_anchors_preset(Control::PRESET_FULL_RECT); add_child(main); + resize_edge_size = MAX(6, (int)(6 * get_theme_default_base_scale())); toggle_replace_button = memnew(Button); main->add_child(toggle_replace_button); @@ -843,6 +1012,7 @@ GDREFindReplaceBar::GDREFindReplaceBar() { search_text = memnew(LineEdit); search_text->set_keep_editing_on_text_submit(true); vbc_lineedit->add_child(search_text); + search_text->set_h_size_flags(SIZE_EXPAND_FILL); search_text->set_placeholder(TTRC("Find")); search_text->set_tooltip_text(TTRC("Find")); search_text->set_accessibility_name(TTRC("Find")); @@ -897,14 +1067,23 @@ GDREFindReplaceBar::GDREFindReplaceBar() { whole_words->connect(SceneStringName(toggled), callable_mp(this, &GDREFindReplaceBar::_search_options_changed)); // Replace toolbar. + HBoxContainer *hbc_replace_text = memnew(HBoxContainer); + hbc_replace_text->set_h_size_flags(SIZE_EXPAND_FILL); + vbc_lineedit->add_child(hbc_replace_text); + replace_text = memnew(LineEdit); - vbc_lineedit->add_child(replace_text); + hbc_replace_text->add_child(replace_text); + replace_text->set_h_size_flags(SIZE_SHRINK_BEGIN); replace_text->set_placeholder(TTRC("Replace")); replace_text->set_tooltip_text(TTRC("Replace")); replace_text->set_accessibility_name(TTRC("Replace")); replace_text->set_custom_minimum_size(Size2(100 * GDRESettings::get_singleton()->get_auto_display_scale(), 0)); replace_text->connect(SceneStringName(text_submitted), callable_mp(this, &GDREFindReplaceBar::_replace_text_submitted)); + Control *replace_text_spacer = memnew(Control); + replace_text_spacer->set_h_size_flags(SIZE_EXPAND_FILL); + hbc_replace_text->add_child(replace_text_spacer); + replace = memnew(Button); hbc_button_replace->add_child(replace); replace->set_text(TTRC("Replace")); diff --git a/gui/find_replace_bar.h b/gui/find_replace_bar.h index 17e8673d8..1969334b9 100644 --- a/gui/find_replace_bar.h +++ b/gui/find_replace_bar.h @@ -46,10 +46,22 @@ class GDREFindReplaceBar : public PanelContainer { bool replace_all_mode = false; bool preserve_cursor = false; + bool resize_handle_dragging = false; + bool minimum_resize_width_pending = false; bool replace_enabled = true; bool should_show_panel_background = true; + bool resizable = true; + float resize_drag_origin_x = 0.0f; + int resize_drag_start_width = 0; + int minimum_resize_width = -1; + int desired_resize_width = -1; + int resize_edge_size = 0; + Control *resize_parent_control = nullptr; + + virtual void gui_input(const Ref &p_event) override; + virtual CursorShape get_cursor_shape(const Point2 &p_pos) const override; virtual void input(const Ref &p_event) override; void _get_search_from(int &r_line, int &r_col, SearchMode p_search_mode); @@ -74,6 +86,11 @@ class GDREFindReplaceBar : public PanelContainer { String get_action_description(const String &p_action_name) const; void _set_matches_custom_minimum_size(); + void _cache_minimum_resize_width(); + void _set_bar_width(int p_width, bool p_update_desired_width = true); + bool _is_on_resize_edge(const Point2 &p_position) const; + void _update_parent_resize_connection(); + void _on_parent_control_resized(); protected: void _notification(int p_what); @@ -118,6 +135,9 @@ class GDREFindReplaceBar : public PanelContainer { void set_show_panel_background(bool p_show); bool is_showing_panel_background() const; + void set_resizable(bool p_resizable); + bool is_resizable() const; + void refresh_search(); GDREFindReplaceBar(); diff --git a/gui/gdre_progress.cpp b/gui/gdre_progress.cpp index 472fa7728..bd4e196f7 100644 --- a/gui/gdre_progress.cpp +++ b/gui/gdre_progress.cpp @@ -34,6 +34,7 @@ #include "core/object/class_db.h" #include "core/os/os.h" #include "scene/gui/file_dialog.h" +#include "scene/main/scene_tree.h" #include "servers/display/display_server.h" #include "utility/gdre_logger.h" diff --git a/misc/bytecode_versions.cpp.inc b/misc/bytecode_versions.cpp.inc index 3a3aa2a9b..e070d76a1 100644 --- a/misc/bytecode_versions.cpp.inc +++ b/misc/bytecode_versions.cpp.inc @@ -1,6 +1,7 @@ //_PRELUDE_ // clang-format off +#include "core/object/class_db.h" #include "bytecode/bytecode_versions.h" #include "bytecode/bytecode_custom.h" @@ -11,7 +12,7 @@ void register_decomp_versions() { ClassDB::register_class(); } -GDScriptDecomp *GDScriptDecompVersion::create_decomp_for_commit(int p_commit_hash) { +Ref GDScriptDecompVersion::create_decomp_for_commit(int p_commit_hash) { switch (p_commit_hash) { //_BYTECODE_CASE_STATEMENTS_ default: @@ -61,9 +62,9 @@ Vector GDScriptDecompVersion::get_decomp_versions(bool in return versions; } -GDScriptDecomp *GDScriptDecompVersion::create_decomp() const { +Ref GDScriptDecompVersion::create_decomp() const { if (is_custom()) { - return GDScriptDecomp_custom::_create_from_json(custom); + return GDScriptDecomp_custom::create_from_json(custom); } return create_decomp_for_commit(commit); } diff --git a/utility/gdre_settings.cpp b/utility/gdre_settings.cpp index c12e896fc..b9b005ae8 100644 --- a/utility/gdre_settings.cpp +++ b/utility/gdre_settings.cpp @@ -10,6 +10,7 @@ #include "core/io/dir_access.h" #include "core/io/file_access.h" #include "core/object/class_db.h" +#include "core/object/message_queue.h" #include "core/string/print_string.h" #include "crypto/custom_decryptor.h" #include "exporters/translation_exporter.h" diff --git a/utility/import_exporter.cpp b/utility/import_exporter.cpp index 6a4718085..ccb8436a4 100644 --- a/utility/import_exporter.cpp +++ b/utility/import_exporter.cpp @@ -87,6 +87,7 @@ HashSet get_scene_groups(const String &p_path) { return packed_scene->get_state()->get_all_groups(); } } + return HashSet(); } // Error remove_remap(const String &src, const String &dst, const String &output_dir); diff --git a/utility/resource_info.cpp b/utility/resource_info.cpp index 71a591d28..317633383 100644 --- a/utility/resource_info.cpp +++ b/utility/resource_info.cpp @@ -62,9 +62,6 @@ Dictionary ResourceInfo::to_dict() const { void ResourceInfo::set_on_resource(Ref res) const { res->set_meta(META_COMPAT, this); } -void ResourceInfo::_set_on_resource(Resource *res) const { - res->set_meta(META_COMPAT, this); -} Ref ResourceInfo::get_info_from_resource(Ref res) { return res->get_meta(META_COMPAT, Ref()); } diff --git a/utility/task_manager.cpp b/utility/task_manager.cpp index c70fdeb46..2ce44398b 100644 --- a/utility/task_manager.cpp +++ b/utility/task_manager.cpp @@ -1,4 +1,5 @@ #include "task_manager.h" +#include "core/object/message_queue.h" #include "gui/gdre_progress.h" #include "main/main.h" #include "servers/rendering/rendering_server.h"