From a5e27503fd52589703d637d1245a023233a14a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Sun, 26 Jun 2016 11:57:10 +0200 Subject: [PATCH] Homogeinize resource formats loaders/savers --- .../io/resource_format_text.cpp | 2 +- .../io/resource_format_text.h | 0 core/register_core_types.cpp | 14 ++++++++++++++ scene/register_scene_types.cpp | 18 ------------------ 4 files changed, 15 insertions(+), 19 deletions(-) rename scene/resources/scene_format_text.cpp => core/io/resource_format_text.cpp (99%) rename scene/resources/scene_format_text.h => core/io/resource_format_text.h (100%) diff --git a/scene/resources/scene_format_text.cpp b/core/io/resource_format_text.cpp similarity index 99% rename from scene/resources/scene_format_text.cpp rename to core/io/resource_format_text.cpp index 95645107d40..ed4fbdfb734 100644 --- a/scene/resources/scene_format_text.cpp +++ b/core/io/resource_format_text.cpp @@ -26,7 +26,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "scene_format_text.h" +#include "resource_format_text.h" #include "globals.h" #include "version.h" diff --git a/scene/resources/scene_format_text.h b/core/io/resource_format_text.h similarity index 100% rename from scene/resources/scene_format_text.h rename to core/io/resource_format_text.h diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 97bd5f2a327..0e73639e977 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -42,6 +42,7 @@ #include "translation.h" #include "compressed_translation.h" #include "io/translation_loader_po.h" +#include "io/resource_format_text.h" #include "io/resource_format_xml.h" #include "io/resource_format_binary.h" #include "io/stream_peer_ssl.h" @@ -53,6 +54,9 @@ #include "input_map.h" #include "undo_redo.h" + +static ResourceFormatSaverText *resource_saver_text=NULL; +static ResourceFormatLoaderText *resource_loader_text=NULL; #ifdef XML_ENABLED static ResourceFormatSaverXML *resource_saver_xml=NULL; static ResourceFormatLoaderXML *resource_loader_xml=NULL; @@ -102,6 +106,11 @@ void register_core_types() { resource_loader_binary = memnew( ResourceFormatLoaderBinary ); ResourceLoader::add_resource_format_loader(resource_loader_binary); + resource_saver_text = memnew( ResourceFormatSaverText ); + ResourceSaver::add_resource_format_saver(resource_saver_text); + resource_loader_text = memnew( ResourceFormatLoaderText ); + ResourceLoader::add_resource_format_loader(resource_loader_text); + #ifdef XML_ENABLED resource_saver_xml = memnew( ResourceFormatSaverXML ); ResourceSaver::add_resource_format_saver(resource_saver_xml); @@ -202,6 +211,11 @@ void unregister_core_types() { if (resource_loader_binary) memdelete(resource_loader_binary); + if (resource_saver_text) + memdelete(resource_saver_text); + if (resource_loader_text) + memdelete(resource_loader_text); + memdelete( resource_format_po ); diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index c83ab88c736..d848b9e5a55 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -222,8 +222,6 @@ #include "scene/3d/collision_polygon.h" #endif -#include "scene/resources/scene_format_text.h" - static ResourceFormatLoaderImage *resource_loader_image=NULL; static ResourceFormatLoaderWAV *resource_loader_wav=NULL; @@ -235,9 +233,6 @@ static ResourceFormatLoaderWAV *resource_loader_wav=NULL; static ResourceFormatLoaderTheme *resource_loader_theme=NULL; static ResourceFormatLoaderShader *resource_loader_shader=NULL; -static ResourceFormatSaverText *resource_saver_text=NULL; -static ResourceFormatLoaderText *resource_loader_text=NULL; - static ResourceFormatLoaderDynamicFont *resource_loader_dynamic_font=NULL; //static SceneStringNames *string_names; @@ -635,13 +630,6 @@ void register_scene_types() { OS::get_singleton()->yield(); //may take time to init - - resource_saver_text = memnew( ResourceFormatSaverText ); - ResourceSaver::add_resource_format_saver(resource_saver_text); - - resource_loader_text = memnew( ResourceFormatLoaderText ); - ResourceLoader::add_resource_format_loader(resource_loader_text); - } void unregister_scene_types() { @@ -661,11 +649,5 @@ void unregister_scene_types() { memdelete( resource_loader_theme ); memdelete( resource_loader_shader ); - if (resource_saver_text) { - memdelete(resource_saver_text); - } - if (resource_loader_text) { - memdelete(resource_loader_text); - } SceneStringNames::free(); }