Exposes methods for adding and removing ResourceFormatLoaders and -Savers in the ClassDB
This commit is contained in:
parent
a7e589df38
commit
359f7fc51f
|
@ -83,6 +83,14 @@ Vector<String> ResourceLoader::get_recognized_extensions_for_type(const String &
|
|||
return ret;
|
||||
}
|
||||
|
||||
void ResourceLoader::add_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader, bool p_at_front) {
|
||||
::ResourceLoader::add_resource_format_loader(p_format_loader, p_at_front);
|
||||
}
|
||||
|
||||
void ResourceLoader::remove_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader) {
|
||||
::ResourceLoader::remove_resource_format_loader(p_format_loader);
|
||||
}
|
||||
|
||||
void ResourceLoader::set_abort_on_missing_resources(bool p_abort) {
|
||||
::ResourceLoader::set_abort_on_missing_resources(p_abort);
|
||||
}
|
||||
|
@ -119,6 +127,8 @@ void ResourceLoader::_bind_methods() {
|
|||
|
||||
ClassDB::bind_method(D_METHOD("load", "path", "type_hint", "cache_mode"), &ResourceLoader::load, DEFVAL(""), DEFVAL(CACHE_MODE_REUSE));
|
||||
ClassDB::bind_method(D_METHOD("get_recognized_extensions_for_type", "type"), &ResourceLoader::get_recognized_extensions_for_type);
|
||||
ClassDB::bind_method(D_METHOD("add_resource_format_loader", "format_loader", "at_front"), &ResourceLoader::add_resource_format_loader, DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("remove_resource_format_loader", "format_loader"), &ResourceLoader::remove_resource_format_loader);
|
||||
ClassDB::bind_method(D_METHOD("set_abort_on_missing_resources", "abort"), &ResourceLoader::set_abort_on_missing_resources);
|
||||
ClassDB::bind_method(D_METHOD("get_dependencies", "path"), &ResourceLoader::get_dependencies);
|
||||
ClassDB::bind_method(D_METHOD("has_cached", "path"), &ResourceLoader::has_cached);
|
||||
|
@ -153,11 +163,21 @@ Vector<String> ResourceSaver::get_recognized_extensions(const Ref<Resource> &p_r
|
|||
return ret;
|
||||
}
|
||||
|
||||
void ResourceSaver::add_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver, bool p_at_front) {
|
||||
::ResourceSaver::add_resource_format_saver(p_format_saver, p_at_front);
|
||||
}
|
||||
|
||||
void ResourceSaver::remove_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver) {
|
||||
::ResourceSaver::remove_resource_format_saver(p_format_saver);
|
||||
}
|
||||
|
||||
ResourceSaver *ResourceSaver::singleton = nullptr;
|
||||
|
||||
void ResourceSaver::_bind_methods() {
|
||||
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);
|
||||
ClassDB::bind_method(D_METHOD("add_resource_format_saver", "format_saver", "at_front"), &ResourceSaver::add_resource_format_saver, DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("remove_resource_format_saver", "format_saver"), &ResourceSaver::remove_resource_format_saver);
|
||||
|
||||
BIND_ENUM_CONSTANT(FLAG_NONE);
|
||||
BIND_ENUM_CONSTANT(FLAG_RELATIVE_PATHS);
|
||||
|
|
|
@ -77,6 +77,8 @@ public:
|
|||
|
||||
Ref<Resource> load(const String &p_path, const String &p_type_hint = "", CacheMode p_cache_mode = CACHE_MODE_REUSE);
|
||||
Vector<String> get_recognized_extensions_for_type(const String &p_type);
|
||||
void add_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader, bool p_at_front);
|
||||
void remove_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader);
|
||||
void set_abort_on_missing_resources(bool p_abort);
|
||||
PackedStringArray get_dependencies(const String &p_path);
|
||||
bool has_cached(const String &p_path);
|
||||
|
@ -109,6 +111,8 @@ public:
|
|||
|
||||
Error save(const String &p_path, const Ref<Resource> &p_resource, uint32_t p_flags);
|
||||
Vector<String> get_recognized_extensions(const Ref<Resource> &p_resource);
|
||||
void add_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver, bool p_at_front);
|
||||
void remove_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver);
|
||||
|
||||
ResourceSaver() { singleton = this; }
|
||||
};
|
||||
|
|
|
@ -11,6 +11,15 @@
|
|||
<link title="OS Test Demo">https://godotengine.org/asset-library/asset/677</link>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="add_resource_format_loader">
|
||||
<return type="void" />
|
||||
<argument index="0" name="format_loader" type="ResourceFormatLoader" />
|
||||
<argument index="1" name="at_front" type="bool" default="false" />
|
||||
<description>
|
||||
Registers a new [ResourceFormatLoader]. The ResourceLoader will use the ResourceFormatLoader as described in [method load].
|
||||
This method is performed implictly for ResourceFormatLoaders written in GDScript (see [ResourceFormatLoader] for more information).
|
||||
</description>
|
||||
</method>
|
||||
<method name="exists">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="path" type="String" />
|
||||
|
@ -89,6 +98,13 @@
|
|||
Loads the resource using threads. If [code]use_sub_threads[/code] is [code]true[/code], multiple threads will be used to load the resource, which makes loading faster, but may affect the main thread (and thus cause game slowdowns).
|
||||
</description>
|
||||
</method>
|
||||
<method name="remove_resource_format_loader">
|
||||
<return type="void" />
|
||||
<argument index="0" name="format_loader" type="ResourceFormatLoader" />
|
||||
<description>
|
||||
Unregisters the given [ResourceFormatLoader].
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_abort_on_missing_resources">
|
||||
<return type="void" />
|
||||
<argument index="0" name="abort" type="bool" />
|
||||
|
|
|
@ -10,6 +10,15 @@
|
|||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="add_resource_format_saver">
|
||||
<return type="void" />
|
||||
<argument index="0" name="format_saver" type="ResourceFormatSaver" />
|
||||
<argument index="1" name="at_front" type="bool" default="false" />
|
||||
<description>
|
||||
Registers a new [ResourceFormatSaver]. The ResourceSaver will use the ResourceFormatSaver as described in [method save].
|
||||
This method is performed implictly for ResourceFormatSavers written in GDScript (see [ResourceFormatSaver] for more information).
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_recognized_extensions">
|
||||
<return type="PackedStringArray" />
|
||||
<argument index="0" name="type" type="Resource" />
|
||||
|
@ -17,6 +26,13 @@
|
|||
Returns the list of extensions available for saving a resource of a given type.
|
||||
</description>
|
||||
</method>
|
||||
<method name="remove_resource_format_saver">
|
||||
<return type="void" />
|
||||
<argument index="0" name="format_saver" type="ResourceFormatSaver" />
|
||||
<description>
|
||||
Unregisters the given [ResourceFormatSaver].
|
||||
</description>
|
||||
</method>
|
||||
<method name="save">
|
||||
<return type="int" enum="Error" />
|
||||
<argument index="0" name="path" type="String" />
|
||||
|
|
Loading…
Reference in New Issue