From 79a7473cac40049769121a3a619b0d1e08899353 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 19 Jul 2016 21:40:05 -0300 Subject: put text formats for resources and scenes as priority --- core/io/resource_loader.cpp | 12 ++++++++++-- core/io/resource_loader.h | 2 +- core/io/resource_saver.cpp | 14 ++++++++++++-- core/io/resource_saver.h | 2 +- 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 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 6404e6cb13..f976a43d91 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 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 } -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 *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); } -- cgit v1.2.3