summaryrefslogtreecommitdiff
path: root/core/io/resource_saver.h
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-12-16 14:26:56 +0100
committerGitHub <noreply@github.com>2018-12-16 14:26:56 +0100
commit9df7ed59fb39e38db30326365adc18afb79903bb (patch)
tree59d2220e78fe5295dd6ac4aa5607da6501a96eb6 /core/io/resource_saver.h
parent3914bdb82eafa558bc1512c7cf3c4f77565d0847 (diff)
parent065e2670af53ae2f71b78d57f8a217b4539cbbe2 (diff)
Merge pull request #19501 from Zylann/custom_loaders
Added basic support for custom resource savers and loaders
Diffstat (limited to 'core/io/resource_saver.h')
-rw-r--r--core/io/resource_saver.h25
1 files changed, 19 insertions, 6 deletions
diff --git a/core/io/resource_saver.h b/core/io/resource_saver.h
index cdd43292a2..1a250e84ea 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,12 +80,18 @@ 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 bool get_timestamp_on_save() { return timestamp_on_save; }
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