mirror of
https://github.com/godotengine/godot.git
synced 2026-01-05 06:11:29 +03:00
Added basic support for custom resource savers and loaders
This commit is contained in:
@@ -380,6 +380,7 @@ public:
|
||||
};
|
||||
|
||||
class ResourceFormatLoaderNativeScript : public ResourceFormatLoader {
|
||||
GDCLASS(ResourceFormatLoaderNativeScript, ResourceFormatLoader)
|
||||
public:
|
||||
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
|
||||
virtual void get_recognized_extensions(List<String> *p_extensions) const;
|
||||
@@ -388,6 +389,7 @@ public:
|
||||
};
|
||||
|
||||
class ResourceFormatSaverNativeScript : public ResourceFormatSaver {
|
||||
GDCLASS(ResourceFormatSaverNativeScript, ResourceFormatSaver)
|
||||
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;
|
||||
|
||||
@@ -39,8 +39,8 @@
|
||||
|
||||
NativeScriptLanguage *native_script_language;
|
||||
|
||||
ResourceFormatLoaderNativeScript *resource_loader_gdns = NULL;
|
||||
ResourceFormatSaverNativeScript *resource_saver_gdns = NULL;
|
||||
Ref<ResourceFormatLoaderNativeScript> resource_loader_gdns;
|
||||
Ref<ResourceFormatSaverNativeScript> resource_saver_gdns;
|
||||
|
||||
void register_nativescript_types() {
|
||||
native_script_language = memnew(NativeScriptLanguage);
|
||||
@@ -50,18 +50,20 @@ void register_nativescript_types() {
|
||||
native_script_language->set_language_index(ScriptServer::get_language_count());
|
||||
ScriptServer::register_language(native_script_language);
|
||||
|
||||
resource_saver_gdns = memnew(ResourceFormatSaverNativeScript);
|
||||
resource_saver_gdns.instance();
|
||||
ResourceSaver::add_resource_format_saver(resource_saver_gdns);
|
||||
|
||||
resource_loader_gdns = memnew(ResourceFormatLoaderNativeScript);
|
||||
resource_loader_gdns.instance();
|
||||
ResourceLoader::add_resource_format_loader(resource_loader_gdns);
|
||||
}
|
||||
|
||||
void unregister_nativescript_types() {
|
||||
|
||||
memdelete(resource_loader_gdns);
|
||||
ResourceLoader::remove_resource_format_loader(resource_loader_gdns);
|
||||
resource_loader_gdns.unref();
|
||||
|
||||
memdelete(resource_saver_gdns);
|
||||
ResourceSaver::remove_resource_format_saver(resource_saver_gdns);
|
||||
resource_saver_gdns.unref();
|
||||
|
||||
if (native_script_language) {
|
||||
ScriptServer::unregister_language(native_script_language);
|
||||
|
||||
Reference in New Issue
Block a user