From 065e2670af53ae2f71b78d57f8a217b4539cbbe2 Mon Sep 17 00:00:00 2001 From: Marc Gilleron Date: Mon, 11 Jun 2018 02:59:53 +0200 Subject: Added basic support for custom resource savers and loaders --- modules/vorbis/audio_stream_ogg_vorbis.h | 1 + modules/vorbis/register_types.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'modules/vorbis') diff --git a/modules/vorbis/audio_stream_ogg_vorbis.h b/modules/vorbis/audio_stream_ogg_vorbis.h index 73c4b5f3f4..7683f38991 100644 --- a/modules/vorbis/audio_stream_ogg_vorbis.h +++ b/modules/vorbis/audio_stream_ogg_vorbis.h @@ -127,6 +127,7 @@ public: }; class ResourceFormatLoaderAudioStreamOGGVorbis : public ResourceFormatLoader { + GDCLASS(ResourceFormatLoaderAudioStreamOGGVorbis, ResourceFormatLoader) public: virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL); virtual void get_recognized_extensions(List *p_extensions) const; diff --git a/modules/vorbis/register_types.cpp b/modules/vorbis/register_types.cpp index 0ea1fbe8b2..8219e9e7ba 100644 --- a/modules/vorbis/register_types.cpp +++ b/modules/vorbis/register_types.cpp @@ -32,16 +32,17 @@ #include "audio_stream_ogg_vorbis.h" -static ResourceFormatLoaderAudioStreamOGGVorbis *vorbis_stream_loader = NULL; +static Ref vorbis_stream_loader; void register_vorbis_types() { - vorbis_stream_loader = memnew(ResourceFormatLoaderAudioStreamOGGVorbis); + vorbis_stream_loader.instance(); ResourceLoader::add_resource_format_loader(vorbis_stream_loader); ClassDB::register_class(); } void unregister_vorbis_types() { - memdelete(vorbis_stream_loader); + ResourceLoader::remove_resource_format_loader(vorbis_stream_loader); + vorbis_stream_loader.unref(); } -- cgit v1.2.3