summaryrefslogtreecommitdiff
path: root/core/io
diff options
context:
space:
mode:
Diffstat (limited to 'core/io')
-rw-r--r--core/io/config_file.cpp5
-rw-r--r--core/io/config_file.h2
-rw-r--r--core/io/resource_format_binary.cpp100
-rw-r--r--core/io/resource_format_binary.h1
-rw-r--r--core/io/resource_import.cpp238
-rw-r--r--core/io/resource_import.h76
-rw-r--r--core/io/resource_loader.cpp145
-rw-r--r--core/io/resource_loader.h9
8 files changed, 349 insertions, 227 deletions
diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp
index a9de740806..b944906e78 100644
--- a/core/io/config_file.cpp
+++ b/core/io/config_file.cpp
@@ -119,7 +119,10 @@ void ConfigFile::get_section_keys(const String& p_section,List<String> *r_keys)
}
+void ConfigFile::erase_section(const String& p_section) {
+ values.erase(p_section);
+}
Error ConfigFile::save(const String& p_path){
@@ -215,6 +218,8 @@ void ConfigFile::_bind_methods(){
ClassDB::bind_method(_MD("get_sections"),&ConfigFile::_get_sections);
ClassDB::bind_method(_MD("get_section_keys","section"),&ConfigFile::_get_section_keys);
+ ClassDB::bind_method(_MD("erase_section","section"),&ConfigFile::erase_section);
+
ClassDB::bind_method(_MD("load:Error","path"),&ConfigFile::load);
ClassDB::bind_method(_MD("save:Error","path"),&ConfigFile::save);
diff --git a/core/io/config_file.h b/core/io/config_file.h
index 397342f90f..c9c4a9fbc0 100644
--- a/core/io/config_file.h
+++ b/core/io/config_file.h
@@ -54,6 +54,8 @@ public:
void get_sections(List<String> *r_sections) const;
void get_section_keys(const String& p_section,List<String> *r_keys) const;
+ void erase_section(const String& p_section);
+
Error save(const String& p_path);
Error load(const String& p_path);
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 4af3503434..c75e476764 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -80,7 +80,8 @@ enum {
OBJECT_EXTERNAL_RESOURCE=1,
OBJECT_INTERNAL_RESOURCE=2,
OBJECT_EXTERNAL_RESOURCE_INDEX=3,
- FORMAT_VERSION=1,
+ //version 2: added 64 bits support for float and int
+ FORMAT_VERSION=2,
FORMAT_VERSION_CAN_RENAME_DEPS=1
@@ -758,30 +759,7 @@ Error ResourceInteractiveLoaderBinary::poll(){
resource_cache.push_back(res);
if (main) {
- if (importmd_ofs) {
- f->seek(importmd_ofs);
- Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata );
- imd->set_editor(get_unicode_string());
- int sc = f->get_32();
- for(int i=0;i<sc;i++) {
-
- String src = get_unicode_string();
- String md5 = get_unicode_string();
- imd->add_source(src,md5);
- }
- int pc = f->get_32();
-
- for(int i=0;i<pc;i++) {
-
- String name = get_unicode_string();
- Variant val;
- parse_variant(val);
- imd->set_option(name,val);
- }
- res->set_import_metadata(imd);
-
- }
f->close();
resource=res;
error=ERR_FILE_EOF;
@@ -848,9 +826,6 @@ void ResourceInteractiveLoaderBinary::get_dependencies(FileAccess *p_f,List<Stri
for(int i=0;i<external_resources.size();i++) {
String dep=external_resources[i].path;
- if (dep.ends_with("*")) {
- dep=ResourceLoader::guess_full_filename(dep,external_resources[i].type);
- }
if (p_add_types && external_resources[i].type!=String()) {
dep+="::"+external_resources[i].type;
@@ -1103,53 +1078,6 @@ bool ResourceFormatLoaderBinary::handles_type(const String& p_type) const{
return true; //handles all
}
-Error ResourceFormatLoaderBinary::load_import_metadata(const String &p_path, Ref<ResourceImportMetadata>& r_var) const {
-
-
- FileAccess *f = FileAccess::open(p_path,FileAccess::READ);
- if (!f) {
- return ERR_FILE_CANT_OPEN;
- }
-
- Ref<ResourceInteractiveLoaderBinary> ria = memnew( ResourceInteractiveLoaderBinary );
- ria->local_path=GlobalConfig::get_singleton()->localize_path(p_path);
- ria->res_path=ria->local_path;
- //ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
- ria->recognize(f);
- if(ria->error!=OK)
- return ERR_FILE_UNRECOGNIZED;
- f=ria->f;
- uint64_t imp_ofs = f->get_64();
-
- if (imp_ofs==0)
- return ERR_UNAVAILABLE;
-
- f->seek(imp_ofs);
- Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata );
- imd->set_editor(ria->get_unicode_string());
- int sc = f->get_32();
- for(int i=0;i<sc;i++) {
-
- String src = ria->get_unicode_string();
- String md5 = ria->get_unicode_string();
- imd->add_source(src,md5);
- }
- int pc = f->get_32();
-
- for(int i=0;i<pc;i++) {
-
- String name = ria->get_unicode_string();
- Variant val;
- ria->parse_variant(val);
- imd->set_option(name,val);
- }
-
- r_var=imd;
-
- return OK;
-
-}
-
void ResourceFormatLoaderBinary::get_dependencies(const String& p_path,List<String> *p_dependencies,bool p_add_types) {
@@ -2178,30 +2106,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_
}
f->seek_end();
- print_line("SAVING: "+p_path);
- if (p_resource->get_import_metadata().is_valid()) {
- uint64_t md_pos = f->get_pos();
- Ref<ResourceImportMetadata> imd=p_resource->get_import_metadata();
- save_unicode_string(imd->get_editor());
- f->store_32(imd->get_source_count());
- for(int i=0;i<imd->get_source_count();i++) {
- save_unicode_string(imd->get_source_path(i));
- save_unicode_string(imd->get_source_md5(i));
- print_line("SAVE PATH: "+imd->get_source_path(i));
- print_line("SAVE MD5: "+imd->get_source_md5(i));
- }
- List<String> options;
- imd->get_options(&options);
- f->store_32(options.size());
- for(List<String>::Element *E=options.front();E;E=E->next()) {
- save_unicode_string(E->get());
- write_variant(imd->get_option(E->get()));
- }
-
- f->seek(md_at);
- f->store_64(md_pos);
- f->seek_end();
- }
f->store_buffer((const uint8_t*)"RSRC",4); //magic at end
diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h
index 611029e792..1dac51cc5c 100644
--- a/core/io/resource_format_binary.h
+++ b/core/io/resource_format_binary.h
@@ -109,7 +109,6 @@ public:
virtual bool handles_type(const String& p_type) const;
virtual String get_resource_type(const String &p_path) const;
virtual void get_dependencies(const String& p_path, List<String> *p_dependencies, bool p_add_types=false);
- virtual Error load_import_metadata(const String &p_path, Ref<ResourceImportMetadata>& r_var) const;
virtual Error rename_dependencies(const String &p_path,const Map<String,String>& p_map);
diff --git a/core/io/resource_import.cpp b/core/io/resource_import.cpp
new file mode 100644
index 0000000000..d0799cdbe6
--- /dev/null
+++ b/core/io/resource_import.cpp
@@ -0,0 +1,238 @@
+#include "resource_import.h"
+#include "variant_parser.h"
+
+Error ResourceFormatImporter::_get_path_and_type(const String& p_path, PathAndType &r_path_and_type) const {
+
+ Error err;
+ FileAccess *f= FileAccess::open(p_path+".import",FileAccess::READ,&err);
+
+ if (!f)
+ return err;
+
+ VariantParser::StreamFile stream;
+ stream.f=f;
+
+ String assign;
+ Variant value;
+ VariantParser::Tag next_tag;
+
+ int lines=0;
+ String error_text;
+ while(true) {
+
+ assign=Variant();
+ next_tag.fields.clear();
+ next_tag.name=String();
+
+ err = VariantParser::parse_tag_assign_eof(&stream,lines,error_text,next_tag,assign,value,NULL,true);
+ if (err==ERR_FILE_EOF) {
+ memdelete(f);
+ return OK;
+ }
+ else if (err!=OK) {
+ ERR_PRINTS("ResourceFormatImporter::load - "+p_path+".import:"+itos(lines)+" error: "+error_text);
+ memdelete(f);
+ return err;
+ }
+
+ if (assign!=String()) {
+ if (assign=="path") {
+ r_path_and_type.path=value;
+ } else if (assign=="type") {
+ r_path_and_type.type=value;
+ }
+
+ } else if (next_tag.name!="remap") {
+ break;
+ }
+ }
+
+ memdelete(f);
+
+ if (r_path_and_type.path==String() || r_path_and_type.type==String()) {
+ return ERR_FILE_CORRUPT;
+ }
+ return OK;
+
+}
+
+
+RES ResourceFormatImporter::load(const String &p_path,const String& p_original_path,Error *r_error) {
+
+ PathAndType pat;
+ Error err = _get_path_and_type(p_path,pat);
+
+ if (err!=OK) {
+
+ if (r_error)
+ *r_error=err;
+
+ return RES();
+ }
+
+
+ RES res = ResourceLoader::load(pat.path,pat.type,false,r_error);
+
+#ifdef TOOLS_ENABLED
+ res->set_import_last_modified_time( res->get_last_modified_time() ); //pass this, if used
+ res->set_import_path(pat.path);
+#endif
+
+ return res;
+
+}
+
+void ResourceFormatImporter::get_recognized_extensions(List<String> *p_extensions) const{
+
+ print_line("getting exts from: "+itos(importers.size()));
+ Set<String> found;
+
+ for (Set< Ref<ResourceImporter> >::Element *E=importers.front();E;E=E->next()) {
+ List<String> local_exts;
+ E->get()->get_recognized_extensions(&local_exts);
+ for (List<String>::Element *F=local_exts.front();F;F=F->next()) {
+ if (!found.has(F->get())) {
+ print_line("adding ext "+String(F->get()));
+ p_extensions->push_back(F->get());
+ found.insert(F->get());
+ }
+ }
+ }
+}
+
+void ResourceFormatImporter::get_recognized_extensions_for_type(const String& p_type,List<String> *p_extensions) const{
+
+ if (p_type=="") {
+ return get_recognized_extensions(p_extensions);
+ }
+
+ Set<String> found;
+
+ for (Set< Ref<ResourceImporter> >::Element *E=importers.front();E;E=E->next()) {
+ String res_type = E->get()->get_resource_type();
+ if (res_type==String())
+ continue;
+
+ if (!ClassDB::is_parent_class(res_type,p_type))
+ continue;
+
+ List<String> local_exts;
+ E->get()->get_recognized_extensions(&local_exts);
+ for (List<String>::Element *F=local_exts.front();F;F=F->next()) {
+ if (!found.has(F->get())) {
+ p_extensions->push_back(F->get());
+ found.insert(F->get());
+ }
+ }
+ }
+}
+
+bool ResourceFormatImporter::recognize_path(const String& p_path,const String& p_for_type) const{
+
+ return FileAccess::exists(p_path+".import");
+
+}
+
+bool ResourceFormatImporter::can_be_imported(const String& p_path) const {
+
+ return ResourceFormatLoader::recognize_path(p_path);
+}
+
+
+bool ResourceFormatImporter::handles_type(const String& p_type) const {
+
+ for (Set< Ref<ResourceImporter> >::Element *E=importers.front();E;E=E->next()) {
+
+ String res_type = E->get()->get_resource_type();
+ if (res_type==String())
+ continue;
+ if (ClassDB::is_parent_class(res_type,p_type))
+ return true;
+
+ }
+
+ return true;
+}
+
+String ResourceFormatImporter::get_resource_type(const String &p_path) const {
+
+ PathAndType pat;
+ Error err = _get_path_and_type(p_path,pat);
+
+ if (err!=OK) {
+
+ return "";
+ }
+
+ return pat.type;
+}
+
+void ResourceFormatImporter::get_dependencies(const String& p_path,List<String> *p_dependencies,bool p_add_types){
+
+ PathAndType pat;
+ Error err = _get_path_and_type(p_path,pat);
+
+ if (err!=OK) {
+
+ return;
+ }
+
+ return ResourceLoader::get_dependencies(pat.path,p_dependencies,p_add_types);
+}
+
+Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_name(const String& p_name) {
+
+ for (Set< Ref<ResourceImporter> >::Element *E=importers.front();E;E=E->next()) {
+ if (E->get()->get_importer_name()==p_name) {
+ return E->get();
+ }
+ }
+
+ return Ref<ResourceImporter>();
+}
+
+
+void ResourceFormatImporter::get_importers_for_extension(const String& p_extension,List<Ref<ResourceImporter> > *r_importers) {
+
+ for (Set< Ref<ResourceImporter> >::Element *E=importers.front();E;E=E->next()) {
+ List<String> local_exts;
+ E->get()->get_recognized_extensions(&local_exts);
+ for (List<String>::Element *F=local_exts.front();F;F=F->next()) {
+ if (p_extension.to_lower()==F->get()) {
+ r_importers->push_back(E->get());
+ }
+ }
+ }
+}
+
+Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_extension(const String& p_extension) {
+
+
+ Ref<ResourceImporter> importer;
+ float priority=0;
+
+ for (Set< Ref<ResourceImporter> >::Element *E=importers.front();E;E=E->next()) {
+
+ List<String> local_exts;
+ E->get()->get_recognized_extensions(&local_exts);
+ for (List<String>::Element *F=local_exts.front();F;F=F->next()) {
+ if (p_extension.to_lower()==F->get() && E->get()->get_priority() > priority) {
+ importer=E->get();
+ priority=E->get()->get_priority();
+ }
+ }
+ }
+
+ return importer;
+}
+
+String ResourceFormatImporter::get_import_base_path(const String& p_for_file) const {
+
+ return "res://.import/"+p_for_file.get_file()+"-"+p_for_file.md5_text();
+}
+
+ResourceFormatImporter *ResourceFormatImporter::singleton=NULL;
+
+ResourceFormatImporter::ResourceFormatImporter() {
+ singleton=this;
+}
diff --git a/core/io/resource_import.h b/core/io/resource_import.h
new file mode 100644
index 0000000000..939cecfbd9
--- /dev/null
+++ b/core/io/resource_import.h
@@ -0,0 +1,76 @@
+#ifndef RESOURCE_IMPORT_H
+#define RESOURCE_IMPORT_H
+
+
+#include "io/resource_loader.h"
+class ResourceImporter;
+
+class ResourceFormatImporter : public ResourceFormatLoader {
+
+ struct PathAndType {
+ String path;
+ String type;
+ };
+
+
+ Error _get_path_and_type(const String& p_path,PathAndType & r_path_and_type) const;
+
+ static ResourceFormatImporter *singleton;
+
+ Set< Ref<ResourceImporter> > importers;
+public:
+
+ static ResourceFormatImporter *get_singleton() { return singleton; }
+ virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL);
+ virtual void get_recognized_extensions(List<String> *p_extensions) const;
+ virtual void get_recognized_extensions_for_type(const String& p_type,List<String> *p_extensions) const;
+ virtual bool recognize_path(const String& p_path,const String& p_for_type=String()) const;
+ virtual bool handles_type(const String& p_type) const;
+ virtual String get_resource_type(const String &p_path) const;
+ virtual void get_dependencies(const String& p_path,List<String> *p_dependencies,bool p_add_types=false);
+
+ virtual bool can_be_imported(const String& p_path) const;
+
+
+ void add_importer(const Ref<ResourceImporter>& p_importer) { importers.insert(p_importer); }
+ Ref<ResourceImporter> get_importer_by_name(const String& p_name);
+ Ref<ResourceImporter> get_importer_by_extension(const String& p_extension);
+ void get_importers_for_extension(const String& p_extension,List<Ref<ResourceImporter> > *r_importers);
+
+ String get_import_base_path(const String& p_for_file) const;
+ ResourceFormatImporter();
+};
+
+
+class ResourceImporter : public Reference {
+
+ GDCLASS(ResourceImporter,Reference)
+public:
+ virtual String get_importer_name() const=0;
+ virtual String get_visible_name() const=0;
+ virtual void get_recognized_extensions(List<String> *p_extensions) const=0;
+ virtual String get_save_extension() const=0;
+ virtual String get_resource_type() const=0;
+ virtual float get_priority() const { return 1.0; }
+
+ struct ImportOption {
+ PropertyInfo option;
+ Variant default_value;
+
+ ImportOption(const PropertyInfo& p_info,const Variant& p_default) { option=p_info; default_value=p_default; }
+ ImportOption() {}
+ };
+
+
+ virtual int get_preset_count() const { return 0; }
+ virtual String get_preset_name(int p_idx) const { return String(); }
+
+ virtual void get_import_options(List<ImportOption> *r_options,int p_preset=0) const=0;
+ virtual bool get_option_visibility(const String& p_option,const Map<StringName,Variant>& p_options) const=0;
+
+
+ virtual Error import(const String& p_source_file,const String& p_save_path,const Map<StringName,Variant>& p_options,List<String>* r_platform_variants,List<String>* r_gen_files=NULL)=0;
+
+};
+
+#endif // RESOURCE_IMPORT_H
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 354efaa83f..fbf6a2cea2 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -47,21 +47,29 @@ Error ResourceInteractiveLoader::wait() {
return err;
}
+bool ResourceFormatLoader::recognize_path(const String& p_path,const String& p_for_type) const {
-bool ResourceFormatLoader::recognize(const String& p_extension) const {
+ String extension = p_path.get_extension();
List<String> extensions;
- get_recognized_extensions(&extensions);
+ if (p_for_type==String()) {
+ get_recognized_extensions(&extensions);
+ } else {
+ get_recognized_extensions_for_type(p_for_type,&extensions);
+ }
+
for (List<String>::Element *E=extensions.front();E;E=E->next()) {
- if (E->get().nocasecmp_to(p_extension.get_extension())==0)
+ if (E->get().nocasecmp_to(extension)==0)
return true;
}
return false;
+
}
+
void ResourceFormatLoader::get_recognized_extensions_for_type(const String& p_type,List<String> *p_extensions) const {
if (p_type=="" || handles_type(p_type))
@@ -166,7 +174,7 @@ RES ResourceLoader::load(const String &p_path, const String& p_type_hint, bool p
else
local_path = GlobalConfig::get_singleton()->localize_path(p_path);
- local_path=find_complete_path(local_path,p_type_hint);
+
ERR_FAIL_COND_V(local_path=="",RES());
if (!p_no_cache && ResourceCache::has(local_path)) {
@@ -177,22 +185,16 @@ RES ResourceLoader::load(const String &p_path, const String& p_type_hint, bool p
return RES( ResourceCache::get(local_path ) );
}
- String remapped_path = PathRemap::get_singleton()->get_remap(local_path);
-
if (OS::get_singleton()->is_stdout_verbose())
- print_line("load resource: "+remapped_path);
-
- String extension=remapped_path.get_extension();
+ print_line("load resource: "+local_path);
bool found=false;
for (int i=0;i<loader_count;i++) {
- if (!loader[i]->recognize(extension))
- continue;
- if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
+ if (!loader[i]->recognize_path(local_path,p_type_hint))
continue;
found=true;
- RES res = loader[i]->load(remapped_path,local_path,r_error);
+ RES res = loader[i]->load(local_path,local_path,r_error);
if (res.is_null())
continue;
if (!p_no_cache)
@@ -201,7 +203,7 @@ RES ResourceLoader::load(const String &p_path, const String& p_type_hint, bool p
res->set_edited(false);
if (timestamp_on_load) {
- uint64_t mt = FileAccess::get_modified_time(remapped_path);
+ uint64_t mt = FileAccess::get_modified_time(local_path);
//printf("mt %s: %lli\n",remapped_path.utf8().get_data(),mt);
res->set_last_modified_time(mt);
}
@@ -220,82 +222,6 @@ RES ResourceLoader::load(const String &p_path, const String& p_type_hint, bool p
}
-Ref<ResourceImportMetadata> ResourceLoader::load_import_metadata(const String &p_path) {
-
-
-
- String local_path;
- if (p_path.is_rel_path())
- local_path="res://"+p_path;
- else
- local_path = GlobalConfig::get_singleton()->localize_path(p_path);
-
- String extension=p_path.get_extension();
- Ref<ResourceImportMetadata> ret;
-
- for (int i=0;i<loader_count;i++) {
-
- if (!loader[i]->recognize(extension))
- continue;
-
- Error err = loader[i]->load_import_metadata(local_path,ret);
- if (err==OK)
- break;
- }
-
-
- return ret;
-
-}
-
-
-
-String ResourceLoader::find_complete_path(const String& p_path,const String& p_type) {
- //this is an old vestige when the engine saved files without extension.
- //remains here for compatibility with old projects and only because it
- //can be sometimes nice to open files using .* from a script and have it guess
- //the right extension.
-
- String local_path = p_path;
- if (local_path.ends_with("*")) {
-
- //find the extension for resource that ends with *
- local_path = local_path.substr(0,local_path.length()-1);
- List<String> extensions;
- get_recognized_extensions_for_type(p_type,&extensions);
- List<String> candidates;
-
- for(List<String>::Element *E=extensions.front();E;E=E->next()) {
-
- String path = local_path+E->get();
-
- if (PathRemap::get_singleton()->has_remap(path) || FileAccess::exists(path)) {
- candidates.push_back(path);
- }
-
- }
-
-
- if (candidates.size()==0) {
- return "";
- } else if (candidates.size()==1 || p_type=="") {
- return candidates.front()->get();
- } else {
-
- for(List<String>::Element *E=candidates.front();E;E=E->next()) {
-
- String rt = get_resource_type(E->get());
- if (ClassDB::is_parent_class(rt,p_type)) {
- return E->get();
- }
- }
-
- return "";
- }
- }
-
- return local_path;
-}
Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_path,const String& p_type_hint,bool p_no_cache,Error *r_error) {
@@ -309,7 +235,7 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_
else
local_path = GlobalConfig::get_singleton()->localize_path(p_path);
- local_path=find_complete_path(local_path,p_type_hint);
+
ERR_FAIL_COND_V(local_path=="",Ref<ResourceInteractiveLoader>());
@@ -329,19 +255,14 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_
if (OS::get_singleton()->is_stdout_verbose())
print_line("load resource: ");
- String remapped_path = PathRemap::get_singleton()->get_remap(local_path);
-
- String extension=remapped_path.get_extension();
bool found=false;
for (int i=0;i<loader_count;i++) {
- if (!loader[i]->recognize(extension))
- continue;
- if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
+ if (!loader[i]->recognize_path(local_path,p_type_hint))
continue;
found=true;
- Ref<ResourceInteractiveLoader> ril = loader[i]->load_interactive(remapped_path,r_error);
+ Ref<ResourceInteractiveLoader> ril = loader[i]->load_interactive(local_path,r_error);
if (ril.is_null())
continue;
if (!p_no_cache)
@@ -383,20 +304,16 @@ void ResourceLoader::get_dependencies(const String& p_path, List<String> *p_depe
else
local_path = GlobalConfig::get_singleton()->localize_path(p_path);
- String remapped_path = PathRemap::get_singleton()->get_remap(local_path);
-
- String extension=remapped_path.get_extension();
-
for (int i=0;i<loader_count;i++) {
- if (!loader[i]->recognize(extension))
+ if (!loader[i]->recognize_path(local_path))
continue;
/*
if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
continue;
*/
- loader[i]->get_dependencies(remapped_path,p_dependencies,p_add_types);
+ loader[i]->get_dependencies(local_path,p_dependencies,p_add_types);
}
}
@@ -410,20 +327,17 @@ Error ResourceLoader::rename_dependencies(const String &p_path,const Map<String,
else
local_path = GlobalConfig::get_singleton()->localize_path(p_path);
- String remapped_path = PathRemap::get_singleton()->get_remap(local_path);
-
- String extension=remapped_path.get_extension();
for (int i=0;i<loader_count;i++) {
- if (!loader[i]->recognize(extension))
+ if (!loader[i]->recognize_path(local_path))
continue;
/*
if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
continue;
*/
- return loader[i]->rename_dependencies(p_path,p_map);
+ return loader[i]->rename_dependencies(local_path,p_map);
}
@@ -432,17 +346,6 @@ Error ResourceLoader::rename_dependencies(const String &p_path,const Map<String,
}
-String ResourceLoader::guess_full_filename(const String &p_path,const String& p_type) {
-
- String local_path;
- if (p_path.is_rel_path())
- local_path="res://"+p_path;
- else
- local_path = GlobalConfig::get_singleton()->localize_path(p_path);
-
- return find_complete_path(local_path,p_type);
-
-}
String ResourceLoader::get_resource_type(const String &p_path) {
@@ -452,8 +355,6 @@ String ResourceLoader::get_resource_type(const String &p_path) {
else
local_path = GlobalConfig::get_singleton()->localize_path(p_path);
- String remapped_path = PathRemap::get_singleton()->get_remap(local_path);
- String extension=remapped_path.get_extension();
for (int i=0;i<loader_count;i++) {
diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h
index 7979bd02a7..f464415e12 100644
--- a/core/io/resource_loader.h
+++ b/core/io/resource_loader.h
@@ -61,11 +61,10 @@ public:
virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const=0;
virtual void get_recognized_extensions_for_type(const String& p_type,List<String> *p_extensions) const;
- bool recognize(const String& p_extension) const;
+ virtual bool recognize_path(const String& p_path,const String& p_for_type=String()) const;
virtual bool handles_type(const String& p_type) const=0;
virtual String get_resource_type(const String &p_path) const=0;
virtual void get_dependencies(const String& p_path,List<String> *p_dependencies,bool p_add_types=false);
- virtual Error load_import_metadata(const String &p_path, Ref<ResourceImportMetadata>& r_var) const { return ERR_UNAVAILABLE; }
virtual Error rename_dependencies(const String &p_path,const Map<String,String>& p_map) { return OK; }
virtual ~ResourceFormatLoader() {}
@@ -92,14 +91,12 @@ class ResourceLoader {
static DependencyErrorNotify dep_err_notify;
static bool abort_on_missing_resource;
- static String find_complete_path(const String& p_path,const String& p_type);
public:
static Ref<ResourceInteractiveLoader> load_interactive(const String &p_path,const String& p_type_hint="",bool p_no_cache=false,Error *r_error=NULL);
static RES load(const String &p_path,const String& p_type_hint="",bool p_no_cache=false,Error *r_error=NULL);
- static Ref<ResourceImportMetadata> load_import_metadata(const String &p_path);
static void get_recognized_extensions_for_type(const String& p_type,List<String> *p_extensions);
static void add_resource_format_loader(ResourceFormatLoader *p_format_loader,bool p_at_front=false);
@@ -107,8 +104,6 @@ public:
static void get_dependencies(const String& p_path,List<String> *p_dependencies,bool p_add_types=false);
static Error rename_dependencies(const String &p_path,const Map<String,String>& p_map);
- static String guess_full_filename(const String &p_path,const String& p_type);
-
static void set_timestamp_on_load(bool p_timestamp) { timestamp_on_load=p_timestamp; }
static void notify_load_error(const String& p_err) { if (err_notify) err_notify(err_notify_ud,p_err); }
@@ -122,4 +117,6 @@ public:
static bool get_abort_on_missing_resources() { return abort_on_missing_resource; }
};
+
+
#endif