diff options
author | Marc Gilleron <marc.gilleron@gmail.com> | 2018-06-11 02:59:53 +0200 |
---|---|---|
committer | Marc Gilleron <marc.gilleron@gmail.com> | 2018-12-15 05:34:53 +0000 |
commit | 065e2670af53ae2f71b78d57f8a217b4539cbbe2 (patch) | |
tree | a6b802b74f6f7ebd2018b5a3d35061bdcb91eb9d /core/io/resource_saver.h | |
parent | ca28c455bfdc8408485c217c17f07011c0b43f64 (diff) | |
download | redot-engine-065e2670af53ae2f71b78d57f8a217b4539cbbe2.tar.gz |
Added basic support for custom resource savers and loaders
Diffstat (limited to 'core/io/resource_saver.h')
-rw-r--r-- | core/io/resource_saver.h | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/core/io/resource_saver.h b/core/io/resource_saver.h index 6134d9db57..38b59bdb53 100644 --- a/core/io/resource_saver.h +++ b/core/io/resource_saver.h @@ -37,11 +37,16 @@ @author Juan Linietsky <reduzio@gmail.com> */ -class ResourceFormatSaver { +class ResourceFormatSaver : public Reference { + GDCLASS(ResourceFormatSaver, Reference) + +protected: + static void _bind_methods(); + public: - virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0) = 0; - virtual bool recognize(const RES &p_resource) const = 0; - virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const = 0; + virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0); + virtual bool recognize(const RES &p_resource) const; + virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const; virtual ~ResourceFormatSaver() {} }; @@ -54,11 +59,13 @@ class ResourceSaver { MAX_SAVERS = 64 }; - static ResourceFormatSaver *saver[MAX_SAVERS]; + static Ref<ResourceFormatSaver> saver[MAX_SAVERS]; static int saver_count; static bool timestamp_on_save; static ResourceSavedCallback save_callback; + static Ref<ResourceFormatSaver> _find_custom_resource_format_saver(String path); + public: enum SaverFlags { @@ -73,10 +80,16 @@ 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, bool p_at_front = false); + static void add_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver, bool p_at_front = false); + static void remove_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver); static void set_timestamp_on_save(bool p_timestamp) { timestamp_on_save = p_timestamp; } static void set_save_callback(ResourceSavedCallback p_callback); + + static bool add_custom_resource_format_saver(String script_path); + static void remove_custom_resource_format_saver(String script_path); + static void add_custom_savers(); + static void remove_custom_savers(); }; #endif |