| 40 | } |
| 41 | |
| 42 | Ref<Resource> ResourceFormatGDScriptLoader::custom_load(const String &p_path, const String &p_original_path, ResourceInfo::LoadType p_type, Error *r_error, bool use_threads, ResourceFormatLoader::CacheMode p_cache_mode) { |
| 43 | String load_path = p_original_path.is_empty() ? p_path : p_original_path; |
| 44 | Ref<FakeScript> fake_script; |
| 45 | if (p_path.get_extension().to_lower() == "cs") { |
| 46 | if (GDRESettings::get_singleton()->has_loaded_dotnet_assembly()) { |
| 47 | Ref<FakeCSharpScript> csharp_script; |
| 48 | csharp_script.instantiate(); |
| 49 | csharp_script->set_original_class("CSharpScript"); |
| 50 | fake_script = csharp_script; |
| 51 | Error err; |
| 52 | if (!r_error) { |
| 53 | r_error = &err; |
| 54 | } |
| 55 | fake_script->set_load_type(p_type); |
| 56 | *r_error = csharp_script->load_source_code(load_path); |
| 57 | ERR_FAIL_COND_V_MSG(*r_error != OK, Ref<Resource>(), "Error loading script: " + load_path + " (CSharpScript): " + csharp_script->get_error_message()); |
| 58 | } else { |
| 59 | fake_script.instantiate(); |
| 60 | fake_script->set_original_class("CSharpScript"); |
| 61 | fake_script->set_load_type(p_type); |
| 62 | } |
| 63 | } else { |
| 64 | Ref<FakeGDScript> fake_gd_script; |
| 65 | fake_gd_script.instantiate(); |
| 66 | fake_script = fake_gd_script; |
| 67 | Error err; |
| 68 | if (!r_error) { |
| 69 | r_error = &err; |
| 70 | } |
| 71 | fake_script->set_load_type(p_type); |
| 72 | *r_error = fake_gd_script->load_source_code(load_path); |
| 73 | ERR_FAIL_COND_V_MSG(*r_error != OK, Ref<Resource>(), "Error loading script: " + load_path); |
| 74 | } |
| 75 | |
| 76 | bool is_real_load = p_type == ResourceInfo::LoadType::REAL_LOAD || p_type == ResourceInfo::LoadType::GLTF_LOAD; |
| 77 | if (is_real_load && p_cache_mode != ResourceFormatLoader::CACHE_MODE_IGNORE && p_cache_mode != ResourceFormatLoader::CACHE_MODE_IGNORE_DEEP) { |
| 78 | fake_script->set_path(load_path, p_cache_mode == ResourceFormatLoader::CACHE_MODE_REPLACE || p_cache_mode == ResourceFormatLoader::CACHE_MODE_REPLACE_DEEP); |
| 79 | } else { |
| 80 | fake_script->set_path_cache(load_path); |
| 81 | } |
| 82 | return fake_script; |
| 83 | } |
| 84 | |
| 85 | Ref<ResourceInfo> ResourceFormatGDScriptLoader::get_resource_info(const String &p_path, Error *r_error) const { |
| 86 | Ref<ResourceInfo> info; |
nothing calls this directly
no test coverage detected