summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/core_bind.cpp5
-rw-r--r--core/core_bind.h3
-rw-r--r--core/io/resource_saver.h3
-rw-r--r--doc/classes/ResourceSaver.xml7
4 files changed, 12 insertions, 6 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp
index bb4b49d9cd..590d1c12c6 100644
--- a/core/core_bind.cpp
+++ b/core/core_bind.cpp
@@ -137,7 +137,7 @@ void ResourceLoader::_bind_methods() {
////// ResourceSaver //////
-Error ResourceSaver::save(const String &p_path, const RES &p_resource, SaverFlags p_flags) {
+Error ResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
ERR_FAIL_COND_V_MSG(p_resource.is_null(), ERR_INVALID_PARAMETER, "Can't save empty resource to path '" + String(p_path) + "'.");
return ::ResourceSaver::save(p_path, p_resource, p_flags);
}
@@ -156,9 +156,10 @@ Vector<String> ResourceSaver::get_recognized_extensions(const RES &p_resource) {
ResourceSaver *ResourceSaver::singleton = nullptr;
void ResourceSaver::_bind_methods() {
- ClassDB::bind_method(D_METHOD("save", "path", "resource", "flags"), &ResourceSaver::save, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("save", "path", "resource", "flags"), &ResourceSaver::save, DEFVAL((uint32_t)FLAG_NONE));
ClassDB::bind_method(D_METHOD("get_recognized_extensions", "type"), &ResourceSaver::get_recognized_extensions);
+ BIND_ENUM_CONSTANT(FLAG_NONE);
BIND_ENUM_CONSTANT(FLAG_RELATIVE_PATHS);
BIND_ENUM_CONSTANT(FLAG_BUNDLE_RESOURCES);
BIND_ENUM_CONSTANT(FLAG_CHANGE_PATH);
diff --git a/core/core_bind.h b/core/core_bind.h
index 1ed243206b..4a7eb718f1 100644
--- a/core/core_bind.h
+++ b/core/core_bind.h
@@ -94,6 +94,7 @@ protected:
public:
enum SaverFlags {
+ FLAG_NONE = 0,
FLAG_RELATIVE_PATHS = 1,
FLAG_BUNDLE_RESOURCES = 2,
FLAG_CHANGE_PATH = 4,
@@ -105,7 +106,7 @@ public:
static ResourceSaver *get_singleton() { return singleton; }
- Error save(const String &p_path, const RES &p_resource, SaverFlags p_flags);
+ Error save(const String &p_path, const RES &p_resource, uint32_t p_flags);
Vector<String> get_recognized_extensions(const RES &p_resource);
ResourceSaver() { singleton = this; }
diff --git a/core/io/resource_saver.h b/core/io/resource_saver.h
index 2919a4cec0..ebc3be91a1 100644
--- a/core/io/resource_saver.h
+++ b/core/io/resource_saver.h
@@ -71,6 +71,7 @@ class ResourceSaver {
public:
enum SaverFlags {
+ FLAG_NONE = 0,
FLAG_RELATIVE_PATHS = 1,
FLAG_BUNDLE_RESOURCES = 2,
FLAG_CHANGE_PATH = 4,
@@ -80,7 +81,7 @@ public:
FLAG_REPLACE_SUBRESOURCE_PATHS = 64,
};
- static Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0);
+ static Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = (uint32_t)FLAG_NONE);
static void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions);
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);
diff --git a/doc/classes/ResourceSaver.xml b/doc/classes/ResourceSaver.xml
index 3872db5ea9..a029fb9acf 100644
--- a/doc/classes/ResourceSaver.xml
+++ b/doc/classes/ResourceSaver.xml
@@ -21,15 +21,18 @@
<return type="int" enum="Error" />
<argument index="0" name="path" type="String" />
<argument index="1" name="resource" type="Resource" />
- <argument index="2" name="flags" type="int" enum="ResourceSaver.SaverFlags" default="0" />
+ <argument index="2" name="flags" type="int" default="0" />
<description>
Saves a resource to disk to the given path, using a [ResourceFormatSaver] that recognizes the resource object.
- The [code]flags[/code] bitmask can be specified to customize the save behavior.
+ The [code]flags[/code] bitmask can be specified to customize the save behavior using [enum SaverFlags] flags.
Returns [constant OK] on success.
</description>
</method>
</methods>
<constants>
+ <constant name="FLAG_NONE" value="0" enum="SaverFlags">
+ No resource saving option.
+ </constant>
<constant name="FLAG_RELATIVE_PATHS" value="1" enum="SaverFlags">
Save the resource with a path relative to the scene which uses it.
</constant>