summaryrefslogtreecommitdiffstats
path: root/editor/editor_data.cpp
diff options
context:
space:
mode:
authorYuri Sizov <yuris@humnom.net>2023-03-31 21:17:59 +0200
committerYuri Sizov <yuris@humnom.net>2023-03-31 21:39:02 +0200
commitee2cc347c6fb9dbf6ba096961b335fb8b4319553 (patch)
tree2387df3595e44ad2eb17d4c217036a9344a5ea14 /editor/editor_data.cpp
parent1522762dc986c130ad63cbf854514d730788a4cf (diff)
downloadredot-engine-ee2cc347c6fb9dbf6ba096961b335fb8b4319553.tar.gz
Add support for icons in GDExtension classes
Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
Diffstat (limited to 'editor/editor_data.cpp')
-rw-r--r--editor/editor_data.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp
index 2d095d2dc7..c381c8c322 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -31,6 +31,7 @@
#include "editor_data.h"
#include "core/config/project_settings.h"
+#include "core/extension/gdextension_manager.h"
#include "core/io/file_access.h"
#include "core/io/image_loader.h"
#include "core/io/resource_loader.h"
@@ -1030,6 +1031,17 @@ void EditorData::script_class_load_icon_paths() {
}
}
+Ref<Texture2D> EditorData::extension_class_get_icon(const String &p_class) const {
+ if (GDExtensionManager::get_singleton()->class_has_icon_path(p_class)) {
+ String icon_path = GDExtensionManager::get_singleton()->class_get_icon_path(p_class);
+ Ref<Texture2D> icon = _load_script_icon(icon_path);
+ if (icon.is_valid()) {
+ return icon;
+ }
+ }
+ return nullptr;
+}
+
Ref<Texture2D> EditorData::_load_script_icon(const String &p_path) const {
if (!p_path.is_empty() && ResourceLoader::exists(p_path)) {
Ref<Texture2D> icon = ResourceLoader::load(p_path);