diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index f414f85df85..08b41390470 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -360,10 +360,18 @@ Ref 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 *p_dependencies, bool p_add_types) { diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index 6404e6cb132..f976a43d91a 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -102,7 +102,7 @@ public: static Ref load_import_metadata(const String &p_path); static void get_recognized_extensions_for_type(const String& p_type,List *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 *p_dependencies,bool p_add_types=false); static Error rename_dependencies(const String &p_path,const Map& p_map); diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp index 8d78ecabbf8..2ead4054403 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 } -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 97500c46f43..b05ae23afc6 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 *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 c83ab88c736..bc0951e4368 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); }