for embedded scripts
| 124 | |
| 125 | // for embedded scripts |
| 126 | Ref<Resource> FakeScriptConverterCompat::convert(const Ref<MissingResource> &res, ResourceInfo::LoadType p_type, int ver_major, Error *r_error) { |
| 127 | Ref<FakeScript> fake_script; |
| 128 | auto resource_info = ResourceInfo::get_info_from_resource(res); |
| 129 | if (res->get_original_class() != "GDScript" && res->get_original_class() != "CSharpScript") { |
| 130 | fake_script.instantiate(); |
| 131 | fake_script->set_original_class(res->get_original_class()); |
| 132 | fake_script->set_load_type(p_type); |
| 133 | set_real_from_missing_resource(res, fake_script, p_type); |
| 134 | } else { |
| 135 | if (res->get_original_class() == "GDScript") { |
| 136 | Ref<FakeGDScript> fake_gd_script; |
| 137 | fake_gd_script.instantiate(); |
| 138 | fake_script = fake_gd_script; |
| 139 | } else if (res->get_original_class() == "CSharpScript") { |
| 140 | Ref<FakeCSharpScript> fake_csharp_script; |
| 141 | fake_csharp_script.instantiate(); |
| 142 | fake_script = fake_csharp_script; |
| 143 | } |
| 144 | fake_script->set_load_type(p_type); |
| 145 | String path = res->get_path(); |
| 146 | if (path.is_empty()) { |
| 147 | if (resource_info.is_valid()) { |
| 148 | path = resource_info->original_path; |
| 149 | } |
| 150 | } |
| 151 | fake_script->set_original_class(res->get_original_class()); |
| 152 | if (is_external_resource(res) && p_type != ResourceInfo::LoadType::FAKE_LOAD && p_type != ResourceInfo::LoadType::NON_GLOBAL_LOAD) { |
| 153 | fake_script->load_source_code(path); |
| 154 | } else { |
| 155 | set_real_from_missing_resource(res, fake_script, p_type); |
| 156 | } |
| 157 | } |
| 158 | // ResourceFormatGDScriptLoader::_set_resource_info(resource_info, path); |
| 159 | resource_info->set_on_resource(fake_script); |
| 160 | return fake_script; |
| 161 | } |
| 162 | |
| 163 | bool FakeScriptConverterCompat::handles_type(const String &p_type, int ver_major) const { |
| 164 | return p_type == "Script" || p_type == "GDScript" || p_type == "CSharpScript"; |
no test coverage detected