put text formats for resources and scenes as priority

This commit is contained in:
Juan Linietsky 2016-07-19 21:40:05 -03:00
parent 0988970c1f
commit 79a7473cac
5 changed files with 26 additions and 8 deletions

View file

@ -360,10 +360,18 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_
}
void ResourceLoader::add_resource_format_loader(ResourceFormatLoader *p_format_loader) {
void ResourceLoader::add_resource_format_loader(ResourceFormatLoader *p_format_loader, bool p_at_front) {
ERR_FAIL_COND( loader_count >= MAX_LOADERS );
loader[loader_count++]=p_format_loader;
if (p_at_front) {
for(int i=loader_count;i>0;i--) {
loader[i]=loader[i-1];
}
loader[0]=p_format_loader;
loader_count++;
} else {
loader[loader_count++]=p_format_loader;
}
}
void ResourceLoader::get_dependencies(const String& p_path, List<String> *p_dependencies, bool p_add_types) {

View file

@ -102,7 +102,7 @@ public:
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);
static void add_resource_format_loader(ResourceFormatLoader *p_format_loader,bool p_at_front=false);
static String get_resource_type(const String &p_path);
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);

View file

@ -116,10 +116,20 @@ void ResourceSaver::get_recognized_extensions(const RES& p_resource,List<String>
}
void ResourceSaver::add_resource_format_saver(ResourceFormatSaver *p_format_saver) {
void ResourceSaver::add_resource_format_saver(ResourceFormatSaver *p_format_saver, bool p_at_front) {
ERR_FAIL_COND( saver_count >= MAX_SAVERS );
saver[saver_count++]=p_format_saver;
if (p_at_front) {
for(int i=saver_count;i>0;i--) {
saver[i]=saver[i-1];
}
saver[0]=p_format_saver;
saver_count++;
} else {
saver[saver_count++]=p_format_saver;
}
}

View file

@ -80,7 +80,7 @@ public:
static Error save(const String &p_path,const RES& p_resource,uint32_t p_flags=0);
static void get_recognized_extensions(const RES& p_resource,List<String> *p_extensions);
static void add_resource_format_saver(ResourceFormatSaver *p_format_saver);
static void add_resource_format_saver(ResourceFormatSaver *p_format_saver,bool p_at_front=false);
static void set_timestamp_on_save(bool p_timestamp) { timestamp_on_save=p_timestamp; }
static void set_save_callback(ResourceSavedCallback p_callback);

View file

@ -637,10 +637,10 @@ void register_scene_types() {
resource_saver_text = memnew( ResourceFormatSaverText );
ResourceSaver::add_resource_format_saver(resource_saver_text);
ResourceSaver::add_resource_format_saver(resource_saver_text,true);
resource_loader_text = memnew( ResourceFormatLoaderText );
ResourceLoader::add_resource_format_loader(resource_loader_text);
ResourceLoader::add_resource_format_loader(resource_loader_text,true);
}