diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-07-19 21:40:05 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-07-19 21:40:05 -0300 |
commit | 79a7473cac40049769121a3a619b0d1e08899353 (patch) | |
tree | cf39d01dd950d477c04a2f2b6a0727096c9a5847 | |
parent | 0988970c1fca780f51ba4f2dce6afebdfef7f292 (diff) |
put text formats for resources and scenes as priority
-rw-r--r-- | core/io/resource_loader.cpp | 12 | ||||
-rw-r--r-- | core/io/resource_loader.h | 2 | ||||
-rw-r--r-- | core/io/resource_saver.cpp | 14 | ||||
-rw-r--r-- | core/io/resource_saver.h | 2 | ||||
-rw-r--r-- | scene/register_scene_types.cpp | 4 |
5 files changed, 26 insertions, 8 deletions
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index f414f85df8..08b4139047 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -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) { diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index 6404e6cb13..f976a43d91 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -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); diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp index 8d78ecabbf..2ead405440 100644 --- a/core/io/resource_saver.cpp +++ b/core/io/resource_saver.cpp @@ -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; + } + } diff --git a/core/io/resource_saver.h b/core/io/resource_saver.h index 97500c46f4..b05ae23afc 100644 --- a/core/io/resource_saver.h +++ b/core/io/resource_saver.h @@ -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); diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index c83ab88c73..bc0951e436 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -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); } |