summaryrefslogtreecommitdiff
path: root/core/io/resource_loader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/io/resource_loader.cpp')
-rw-r--r--core/io/resource_loader.cpp59
1 files changed, 0 insertions, 59 deletions
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index dc44be4e0b..361f40cbc6 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -49,7 +49,6 @@ Ref<ResourceFormatLoader> ResourceLoader::loader[ResourceLoader::MAX_LOADERS];
int ResourceLoader::loader_count = 0;
bool ResourceFormatLoader::recognize_path(const String &p_path, const String &p_for_type) const {
-
String extension = p_path.get_extension();
List<String> extensions;
@@ -60,7 +59,6 @@ bool ResourceFormatLoader::recognize_path(const String &p_path, const String &p_
}
for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
-
if (E->get().nocasecmp_to(extension) == 0)
return true;
}
@@ -69,7 +67,6 @@ bool ResourceFormatLoader::recognize_path(const String &p_path, const String &p_
}
bool ResourceFormatLoader::handles_type(const String &p_type) const {
-
if (get_script_instance() && get_script_instance()->has_method("handles_type")) {
// I guess custom loaders for custom resources should use "Resource"
return get_script_instance()->call("handles_type", p_type);
@@ -79,7 +76,6 @@ bool ResourceFormatLoader::handles_type(const String &p_type) const {
}
String ResourceFormatLoader::get_resource_type(const String &p_path) const {
-
if (get_script_instance() && get_script_instance()->has_method("get_resource_type")) {
return get_script_instance()->call("get_resource_type", p_path);
}
@@ -88,13 +84,11 @@ String ResourceFormatLoader::get_resource_type(const String &p_path) const {
}
void ResourceFormatLoader::get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const {
-
if (p_type == "" || handles_type(p_type))
get_recognized_extensions(p_extensions);
}
void ResourceLoader::get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) {
-
for (int i = 0; i < loader_count; i++) {
loader[i]->get_recognized_extensions_for_type(p_type, p_extensions);
}
@@ -105,7 +99,6 @@ bool ResourceFormatLoader::exists(const String &p_path) const {
}
void ResourceFormatLoader::get_recognized_extensions(List<String> *p_extensions) const {
-
if (get_script_instance() && get_script_instance()->has_method("get_recognized_extensions")) {
PackedStringArray exts = get_script_instance()->call("get_recognized_extensions");
@@ -119,17 +112,14 @@ void ResourceFormatLoader::get_recognized_extensions(List<String> *p_extensions)
}
RES ResourceFormatLoader::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) {
-
if (get_script_instance() && get_script_instance()->has_method("load")) {
Variant res = get_script_instance()->call("load", p_path, p_original_path, p_use_sub_threads);
if (res.get_type() == Variant::INT) {
-
if (r_error)
*r_error = (Error)res.operator int64_t();
} else {
-
if (r_error)
*r_error = OK;
return res;
@@ -142,7 +132,6 @@ RES ResourceFormatLoader::load(const String &p_path, const String &p_original_pa
}
void ResourceFormatLoader::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) {
-
if (get_script_instance() && get_script_instance()->has_method("get_dependencies")) {
PackedStringArray deps = get_script_instance()->call("get_dependencies", p_path, p_add_types);
@@ -156,9 +145,7 @@ void ResourceFormatLoader::get_dependencies(const String &p_path, List<String> *
}
Error ResourceFormatLoader::rename_dependencies(const String &p_path, const Map<String, String> &p_map) {
-
if (get_script_instance() && get_script_instance()->has_method("rename_dependencies")) {
-
Dictionary deps_dict;
for (Map<String, String>::Element *E = p_map.front(); E; E = E->next()) {
deps_dict[E->key()] = E->value();
@@ -172,7 +159,6 @@ Error ResourceFormatLoader::rename_dependencies(const String &p_path, const Map<
}
void ResourceFormatLoader::_bind_methods() {
-
{
MethodInfo info = MethodInfo(Variant::NIL, "load", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::STRING, "original_path"));
info.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
@@ -189,12 +175,10 @@ void ResourceFormatLoader::_bind_methods() {
///////////////////////////////////
RES ResourceLoader::_load(const String &p_path, const String &p_original_path, const String &p_type_hint, bool p_no_cache, Error *r_error, bool p_use_sub_threads, float *r_progress) {
-
bool found = false;
// Try all loaders and pick the first match for the type hint
for (int i = 0; i < loader_count; i++) {
-
if (!loader[i]->recognize_path(p_path, p_type_hint)) {
continue;
}
@@ -218,7 +202,6 @@ RES ResourceLoader::_load(const String &p_path, const String &p_original_path, c
}
void ResourceLoader::_thread_load_function(void *p_userdata) {
-
ThreadLoadTask &load_task = *(ThreadLoadTask *)p_userdata;
load_task.loader_id = Thread::get_caller_id();
@@ -237,7 +220,6 @@ void ResourceLoader::_thread_load_function(void *p_userdata) {
load_task.status = THREAD_LOAD_LOADED;
}
if (load_task.semaphore) {
-
if (load_task.start_next && thread_waiting_count > 0) {
thread_waiting_count--;
//thread loading count remains constant, this ends but another one begins
@@ -279,7 +261,6 @@ void ResourceLoader::_thread_load_function(void *p_userdata) {
thread_load_mutex->unlock();
}
Error ResourceLoader::load_threaded_request(const String &p_path, const String &p_type_hint, bool p_use_sub_threads, const String &p_source_resource) {
-
String local_path;
if (p_path.is_rel_path())
local_path = "res://" + p_path;
@@ -387,7 +368,6 @@ Error ResourceLoader::load_threaded_request(const String &p_path, const String &
}
float ResourceLoader::_dependency_get_progress(const String &p_path) {
-
if (thread_load_tasks.has(p_path)) {
ThreadLoadTask &load_task = thread_load_tasks[p_path];
int dep_count = load_task.sub_tasks.size();
@@ -410,7 +390,6 @@ float ResourceLoader::_dependency_get_progress(const String &p_path) {
}
ResourceLoader::ThreadLoadStatus ResourceLoader::load_threaded_get_status(const String &p_path, float *r_progress) {
-
String local_path;
if (p_path.is_rel_path())
local_path = "res://" + p_path;
@@ -434,7 +413,6 @@ ResourceLoader::ThreadLoadStatus ResourceLoader::load_threaded_get_status(const
return status;
}
RES ResourceLoader::load_threaded_get(const String &p_path, Error *r_error) {
-
String local_path;
if (p_path.is_rel_path())
local_path = "res://" + p_path;
@@ -516,7 +494,6 @@ RES ResourceLoader::load_threaded_get(const String &p_path, Error *r_error) {
}
RES ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p_no_cache, Error *r_error) {
-
if (r_error)
*r_error = ERR_CANT_OPEN;
@@ -527,7 +504,6 @@ RES ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p
local_path = ProjectSettings::get_singleton()->localize_path(p_path);
if (!p_no_cache) {
-
thread_load_mutex->lock();
//Is it already being loaded? poll until done
@@ -592,7 +568,6 @@ RES ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p
return load_threaded_get(p_path, r_error);
} else {
-
bool xl_remapped = false;
String path = _path_remap(local_path, &xl_remapped);
@@ -627,7 +602,6 @@ RES ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p
}
bool ResourceLoader::exists(const String &p_path, const String &p_type_hint) {
-
String local_path;
if (p_path.is_rel_path())
local_path = "res://" + p_path;
@@ -635,7 +609,6 @@ bool ResourceLoader::exists(const String &p_path, const String &p_type_hint) {
local_path = ProjectSettings::get_singleton()->localize_path(p_path);
if (ResourceCache::has(local_path)) {
-
return true; // If cached, it probably exists
}
@@ -644,7 +617,6 @@ bool ResourceLoader::exists(const String &p_path, const String &p_type_hint) {
// Try all loaders and pick the first match for the type hint
for (int i = 0; i < loader_count; i++) {
-
if (!loader[i]->recognize_path(path, p_type_hint)) {
continue;
}
@@ -657,7 +629,6 @@ bool ResourceLoader::exists(const String &p_path, const String &p_type_hint) {
}
void ResourceLoader::add_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader, bool p_at_front) {
-
ERR_FAIL_COND(p_format_loader.is_null());
ERR_FAIL_COND(loader_count >= MAX_LOADERS);
@@ -673,7 +644,6 @@ void ResourceLoader::add_resource_format_loader(Ref<ResourceFormatLoader> p_form
}
void ResourceLoader::remove_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader) {
-
ERR_FAIL_COND(p_format_loader.is_null());
// Find loader
@@ -694,7 +664,6 @@ void ResourceLoader::remove_resource_format_loader(Ref<ResourceFormatLoader> p_f
}
int ResourceLoader::get_import_order(const String &p_path) {
-
String path = _path_remap(p_path);
String local_path;
@@ -704,7 +673,6 @@ int ResourceLoader::get_import_order(const String &p_path) {
local_path = ProjectSettings::get_singleton()->localize_path(path);
for (int i = 0; i < loader_count; i++) {
-
if (!loader[i]->recognize_path(local_path))
continue;
/*
@@ -728,7 +696,6 @@ String ResourceLoader::get_import_group_file(const String &p_path) {
local_path = ProjectSettings::get_singleton()->localize_path(path);
for (int i = 0; i < loader_count; i++) {
-
if (!loader[i]->recognize_path(local_path))
continue;
/*
@@ -743,7 +710,6 @@ String ResourceLoader::get_import_group_file(const String &p_path) {
}
bool ResourceLoader::is_import_valid(const String &p_path) {
-
String path = _path_remap(p_path);
String local_path;
@@ -753,7 +719,6 @@ bool ResourceLoader::is_import_valid(const String &p_path) {
local_path = ProjectSettings::get_singleton()->localize_path(path);
for (int i = 0; i < loader_count; i++) {
-
if (!loader[i]->recognize_path(local_path))
continue;
/*
@@ -768,7 +733,6 @@ bool ResourceLoader::is_import_valid(const String &p_path) {
}
bool ResourceLoader::is_imported(const String &p_path) {
-
String path = _path_remap(p_path);
String local_path;
@@ -778,7 +742,6 @@ bool ResourceLoader::is_imported(const String &p_path) {
local_path = ProjectSettings::get_singleton()->localize_path(path);
for (int i = 0; i < loader_count; i++) {
-
if (!loader[i]->recognize_path(local_path))
continue;
/*
@@ -793,7 +756,6 @@ bool ResourceLoader::is_imported(const String &p_path) {
}
void ResourceLoader::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) {
-
String path = _path_remap(p_path);
String local_path;
@@ -803,7 +765,6 @@ void ResourceLoader::get_dependencies(const String &p_path, List<String> *p_depe
local_path = ProjectSettings::get_singleton()->localize_path(path);
for (int i = 0; i < loader_count; i++) {
-
if (!loader[i]->recognize_path(local_path))
continue;
/*
@@ -816,7 +777,6 @@ void ResourceLoader::get_dependencies(const String &p_path, List<String> *p_depe
}
Error ResourceLoader::rename_dependencies(const String &p_path, const Map<String, String> &p_map) {
-
String path = _path_remap(p_path);
String local_path;
@@ -826,7 +786,6 @@ Error ResourceLoader::rename_dependencies(const String &p_path, const Map<String
local_path = ProjectSettings::get_singleton()->localize_path(path);
for (int i = 0; i < loader_count; i++) {
-
if (!loader[i]->recognize_path(local_path))
continue;
/*
@@ -841,7 +800,6 @@ Error ResourceLoader::rename_dependencies(const String &p_path, const Map<String
}
String ResourceLoader::get_resource_type(const String &p_path) {
-
String local_path;
if (p_path.is_rel_path())
local_path = "res://" + p_path;
@@ -849,7 +807,6 @@ String ResourceLoader::get_resource_type(const String &p_path) {
local_path = ProjectSettings::get_singleton()->localize_path(p_path);
for (int i = 0; i < loader_count; i++) {
-
String result = loader[i]->get_resource_type(local_path);
if (result != "") {
return result;
@@ -860,7 +817,6 @@ String ResourceLoader::get_resource_type(const String &p_path) {
}
String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_remapped) {
-
String new_path = p_path;
if (translation_remaps.has(p_path)) {
@@ -919,7 +875,6 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem
FileAccess *f = FileAccess::open(p_path + ".remap", FileAccess::READ, &err);
if (f) {
-
VariantParser::StreamFile stream;
stream.f = f;
@@ -930,7 +885,6 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem
int lines = 0;
String error_text;
while (true) {
-
assign = Variant();
next_tag.fields.clear();
next_tag.name = String();
@@ -959,9 +913,7 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem
}
String ResourceLoader::import_remap(const String &p_path) {
-
if (ResourceFormatImporter::get_singleton()->recognize_path(p_path)) {
-
return ResourceFormatImporter::get_singleton()->get_internal_resource_path(p_path);
}
@@ -973,7 +925,6 @@ String ResourceLoader::path_remap(const String &p_path) {
}
void ResourceLoader::reload_translation_remaps() {
-
if (ResourceCache::lock) {
ResourceCache::lock->read_lock();
}
@@ -998,7 +949,6 @@ void ResourceLoader::reload_translation_remaps() {
}
void ResourceLoader::load_translation_remaps() {
-
if (!ProjectSettings::get_singleton()->has_setting("locale/translation_remaps"))
return;
@@ -1006,7 +956,6 @@ void ResourceLoader::load_translation_remaps() {
List<Variant> keys;
remaps.get_key_list(&keys);
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
-
Array langs = remaps[E->get()];
Vector<String> lang_remaps;
lang_remaps.resize(langs.size());
@@ -1023,7 +972,6 @@ void ResourceLoader::clear_translation_remaps() {
}
void ResourceLoader::load_path_remaps() {
-
if (!ProjectSettings::get_singleton()->has_setting("path_remap/remapped_paths"))
return;
@@ -1033,13 +981,11 @@ void ResourceLoader::load_path_remaps() {
const String *r = remaps.ptr();
for (int i = 0; i < rc; i += 2) {
-
path_remaps[r[i]] = r[i + 1];
}
}
void ResourceLoader::clear_path_remaps() {
-
path_remaps.clear();
}
@@ -1059,7 +1005,6 @@ Ref<ResourceFormatLoader> ResourceLoader::_find_custom_resource_format_loader(St
}
bool ResourceLoader::add_custom_resource_format_loader(String script_path) {
-
if (_find_custom_resource_format_loader(script_path).is_valid())
return false;
@@ -1084,7 +1029,6 @@ bool ResourceLoader::add_custom_resource_format_loader(String script_path) {
}
void ResourceLoader::remove_custom_resource_format_loader(String script_path) {
-
Ref<ResourceFormatLoader> custom_loader = _find_custom_resource_format_loader(script_path);
if (custom_loader.is_valid())
remove_resource_format_loader(custom_loader);
@@ -1099,7 +1043,6 @@ void ResourceLoader::add_custom_loaders() {
ScriptServer::get_global_class_list(&global_classes);
for (List<StringName>::Element *E = global_classes.front(); E; E = E->next()) {
-
StringName class_name = E->get();
StringName base_class = ScriptServer::get_global_class_native_base(class_name);
@@ -1111,7 +1054,6 @@ void ResourceLoader::add_custom_loaders() {
}
void ResourceLoader::remove_custom_loaders() {
-
Vector<Ref<ResourceFormatLoader>> custom_loaders;
for (int i = 0; i < loader_count; ++i) {
if (loader[i]->get_script_instance()) {
@@ -1134,7 +1076,6 @@ void ResourceLoader::initialize() {
}
void ResourceLoader::finalize() {
-
memdelete(thread_load_mutex);
memdelete(thread_load_semaphore);
}