| 1335 | } |
| 1336 | |
| 1337 | Error GDRESettings::set_custom_decryption_script(const String &p_decryptor_script_path) { |
| 1338 | ERR_FAIL_COND_V_MSG(!FileAccess::exists(p_decryptor_script_path), ERR_FILE_NOT_FOUND, "Custom encryption script file '" + p_decryptor_script_path + "' does not exist"); |
| 1339 | ERR_FAIL_COND_V_MSG(p_decryptor_script_path.get_extension().to_lower() != "gd", ERR_INVALID_PARAMETER, "Custom encryption script file must be a GDScript!"); |
| 1340 | Error err = OK; |
| 1341 | ResourceFormatLoaderGDScript loader; |
| 1342 | Ref<Script> script = loader.load(p_decryptor_script_path, p_decryptor_script_path, &err, false, nullptr, ResourceFormatLoader::CACHE_MODE_IGNORE); |
| 1343 | ERR_FAIL_COND_V_MSG(script.is_null() || err != OK, err, "Failed to load custom encryption script!"); |
| 1344 | auto base_type = script->get_instance_base_type(); |
| 1345 | ERR_FAIL_COND_V_MSG(base_type != "CustomDecryptor", ERR_INVALID_PARAMETER, "Custom encryption script does not inherit from CustomDecryptor!"); |
| 1346 | Ref<CustomDecryptor> decryptor; |
| 1347 | decryptor.instantiate(); |
| 1348 | decryptor->set_script(script); |
| 1349 | ERR_FAIL_COND_V_MSG(Ref<Script>(decryptor->get_script()).is_null(), ERR_INVALID_PARAMETER, "Failed to instantiate custom encryption script!"); |
| 1350 | ERR_FAIL_NULL_V_MSG(decryptor->get_script_instance(), ERR_INVALID_PARAMETER, "Failed to get script instance from custom encryption script!"); |
| 1351 | custom_decryption_script_path = p_decryptor_script_path; |
| 1352 | set_custom_decryptor(decryptor); |
| 1353 | return OK; |
| 1354 | } |
| 1355 | |
| 1356 | void GDRESettings::set_custom_decryptor(const Ref<CustomDecryptor> &p_decryptor) { |
| 1357 | custom_decryptor = p_decryptor; |
nothing calls this directly
no test coverage detected