| 687 | } |
| 688 | |
| 689 | Error ResourceLoaderBinary::load() { |
| 690 | if (error != OK) { |
| 691 | return error; |
| 692 | } |
| 693 | |
| 694 | for (int i = 0; i < external_resources.size(); i++) { |
| 695 | String path = external_resources[i].path; |
| 696 | |
| 697 | if (remaps.has(path)) { |
| 698 | path = remaps[path]; |
| 699 | } |
| 700 | |
| 701 | if (!path.contains("://") && path.is_relative_path()) { |
| 702 | // path is relative to file being loaded, so convert to a resource path |
| 703 | path = ProjectSettings::get_singleton()->localize_path(path.get_base_dir().path_join(external_resources[i].path)); |
| 704 | } |
| 705 | |
| 706 | external_resources.write[i].path = path; //remap happens here, not on load because on load it can actually be used for filesystem dock resource remap |
| 707 | external_resources.write[i].load_token = ResourceLoader::_load_start(path, external_resources[i].type, use_sub_threads ? ResourceLoader::LOAD_THREAD_DISTRIBUTE : ResourceLoader::LOAD_THREAD_FROM_CURRENT, cache_mode_for_external); |
| 708 | if (external_resources[i].load_token.is_null()) { |
| 709 | if (!ResourceLoader::get_abort_on_missing_resources()) { |
| 710 | ResourceLoader::notify_dependency_error(local_path, path, external_resources[i].type); |
| 711 | } else { |
| 712 | error = ERR_FILE_MISSING_DEPENDENCIES; |
| 713 | ERR_FAIL_V_MSG(error, vformat("Can't load dependency: '%s'.", path)); |
| 714 | } |
| 715 | } |
| 716 | } |
| 717 | |
| 718 | for (int i = 0; i < internal_resources.size(); i++) { |
| 719 | bool main = i == (internal_resources.size() - 1); |
| 720 | |
| 721 | //maybe it is loaded already |
| 722 | String path; |
| 723 | String id; |
| 724 | |
| 725 | if (!main) { |
| 726 | path = internal_resources[i].path; |
| 727 | |
| 728 | if (path.begins_with("local://")) { |
| 729 | path = path.replace_first("local://", ""); |
| 730 | id = path; |
| 731 | path = res_path + "::" + path; |
| 732 | |
| 733 | internal_resources.write[i].path = path; // Update path. |
| 734 | } |
| 735 | |
| 736 | if (cache_mode == ResourceFormatLoader::CACHE_MODE_REUSE && ResourceCache::has(path)) { |
| 737 | Ref<Resource> cached = ResourceCache::get_ref(path); |
| 738 | if (cached.is_valid()) { |
| 739 | //already loaded, don't do anything |
| 740 | error = OK; |
| 741 | internal_index_cache[path] = cached; |
| 742 | continue; |
| 743 | } |
| 744 | } |
| 745 | } else { |
| 746 | if (cache_mode != ResourceFormatLoader::CACHE_MODE_IGNORE && !ResourceCache::has(res_path)) { |
no test coverage detected