From 7f83977f37f5f13024bee4f29ead87a992a072b6 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Fri, 23 Jul 2021 12:10:32 +0200 Subject: Expose an ImportOrder enum in ResourceImporter This avoids using magic numbers in code. --- core/io/resource_importer.cpp | 5 +++++ core/io/resource_importer.h | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp index b503655edd..f612b84404 100644 --- a/core/io/resource_importer.cpp +++ b/core/io/resource_importer.cpp @@ -445,3 +445,8 @@ ResourceFormatImporter *ResourceFormatImporter::singleton = nullptr; ResourceFormatImporter::ResourceFormatImporter() { singleton = this; } + +void ResourceImporter::_bind_methods() { + BIND_ENUM_CONSTANT(IMPORT_ORDER_DEFAULT); + BIND_ENUM_CONSTANT(IMPORT_ORDER_SCENE); +} diff --git a/core/io/resource_importer.h b/core/io/resource_importer.h index 2ceeb176e5..62cb608a42 100644 --- a/core/io/resource_importer.h +++ b/core/io/resource_importer.h @@ -96,6 +96,9 @@ public: class ResourceImporter : public RefCounted { GDCLASS(ResourceImporter, RefCounted); +protected: + static void _bind_methods(); + public: virtual String get_importer_name() const = 0; virtual String get_visible_name() const = 0; @@ -103,7 +106,7 @@ public: virtual String get_save_extension() const = 0; virtual String get_resource_type() const = 0; virtual float get_priority() const { return 1.0; } - virtual int get_import_order() const { return 0; } + virtual int get_import_order() const { return IMPORT_ORDER_DEFAULT; } virtual int get_format_version() const { return 0; } struct ImportOption { @@ -117,6 +120,11 @@ public: ImportOption() {} }; + enum ImportOrder { + IMPORT_ORDER_DEFAULT = 0, + IMPORT_ORDER_SCENE = 100, + }; + virtual bool has_advanced_options() const { return false; } virtual void show_advanced_options(const String &p_path) {} @@ -137,4 +145,6 @@ public: virtual String get_import_settings_string() const { return String(); } }; +VARIANT_ENUM_CAST(ResourceImporter::ImportOrder); + #endif // RESOURCE_IMPORTER_H -- cgit v1.2.3