| 1655 | } |
| 1656 | |
| 1657 | Error ImportExporter::recreate_plugin_config(const String &plugin_cfg_path) { |
| 1658 | Error err; |
| 1659 | Vector<String> wildcards = { "*.gdc", "*.gde", "*.gd" }; |
| 1660 | |
| 1661 | HashSet<String> non_present_scripts; |
| 1662 | String abs_plugin_path = plugin_cfg_path.get_base_dir(); |
| 1663 | String rel_plugin_path = abs_plugin_path.trim_prefix("res://"); |
| 1664 | String plugin_dir = rel_plugin_path.trim_prefix("addons/").trim_prefix("Addons/"); |
| 1665 | String plugin_name = plugin_dir.replace("_", " ").replace(".", " ").replace("/", " "); |
| 1666 | Ref<GodotMonoDecompWrapper> decompiler; |
| 1667 | if (GDRESettings::get_singleton()->has_loaded_dotnet_assembly()) { |
| 1668 | wildcards.push_back("*.cs"); |
| 1669 | decompiler = GDRESettings::get_singleton()->get_dotnet_decompiler(); |
| 1670 | non_present_scripts = gdre::vector_to_hashset(decompiler->get_files_not_present_in_file_map()); |
| 1671 | } |
| 1672 | |
| 1673 | auto gd_scripts = gdre::get_recursive_dir_list(abs_plugin_path, wildcards, false); |
| 1674 | String main_script; |
| 1675 | |
| 1676 | if (gd_scripts.is_empty()) { |
| 1677 | return OK; |
| 1678 | } |
| 1679 | |
| 1680 | bool cant_decompile = false; |
| 1681 | |
| 1682 | for (int j = 0; j < gd_scripts.size(); j++) { |
| 1683 | auto ext = gd_scripts[j].get_extension().to_lower(); |
| 1684 | if ((ext == "gde" || ext == "gdc") && GDRESettings::get_singleton()->get_bytecode_revision() == 0) { |
| 1685 | cant_decompile = true; |
| 1686 | continue; |
| 1687 | } |
| 1688 | String gd_script_abs_path = abs_plugin_path.path_join(gd_scripts[j]); |
| 1689 | if (ext == "cs") { |
| 1690 | if (decompiler.is_null() || non_present_scripts.has(gd_script_abs_path) || decompiler->get_script_info(gd_script_abs_path).is_empty()) { |
| 1691 | continue; |
| 1692 | } |
| 1693 | } |
| 1694 | Ref<FakeScript> gd_script = ResourceCompatLoader::non_global_load(gd_script_abs_path, "", &err); |
| 1695 | if (gd_script.is_valid()) { |
| 1696 | if (gd_script->get_instance_base_type() == "EditorPlugin") { |
| 1697 | main_script = gd_scripts[j]; |
| 1698 | if (ext != "cs" && ext != "gd") { |
| 1699 | main_script = main_script.get_basename() + ".gd"; |
| 1700 | } |
| 1701 | break; |
| 1702 | } |
| 1703 | } |
| 1704 | } |
| 1705 | if (main_script == "") { |
| 1706 | if (cant_decompile) { |
| 1707 | return ERR_UNCONFIGURED; |
| 1708 | } else { |
| 1709 | return ERR_CANT_CREATE; |
| 1710 | } |
| 1711 | } |
| 1712 | String plugin_cfg_text = String("[plugin]\n\n") + |
| 1713 | "name=\"" + plugin_name + "\"\n" + |
| 1714 | "description=\"" + plugin_name + " plugin\"\n" + |
nothing calls this directly
no test coverage detected