Merge pull request #46 from limbonaut/fix-task-icons-in-demo

Fix icons not shown for scripted tasks in demo with the module version
This commit is contained in:
Serhii Snitsaruk 2024-02-18 15:52:43 +01:00 committed by GitHub
commit 8176d5c83c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 8 deletions

View File

@ -78,8 +78,8 @@ String LimboUtility::get_status_name(int p_status) const {
Ref<Texture2D> LimboUtility::get_task_icon(String p_class_or_script_path) const { Ref<Texture2D> LimboUtility::get_task_icon(String p_class_or_script_path) const {
ERR_FAIL_COND_V_MSG(p_class_or_script_path.is_empty(), Variant(), "BTTask: script path or class cannot be empty."); ERR_FAIL_COND_V_MSG(p_class_or_script_path.is_empty(), Variant(), "BTTask: script path or class cannot be empty.");
// * Using editor theme
#if defined(TOOLS_ENABLED) && defined(LIMBOAI_MODULE) #if defined(TOOLS_ENABLED) && defined(LIMBOAI_MODULE)
// * Using editor theme
if (Engine::get_singleton()->is_editor_hint()) { if (Engine::get_singleton()->is_editor_hint()) {
Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme(); Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme();
ERR_FAIL_COND_V(theme.is_null(), nullptr); ERR_FAIL_COND_V(theme.is_null(), nullptr);
@ -122,7 +122,6 @@ Ref<Texture2D> LimboUtility::get_task_icon(String p_class_or_script_path) const
String path; String path;
#ifdef LIMBOAI_GDEXTENSION
if (p_class_or_script_path.begins_with("res://")) { if (p_class_or_script_path.begins_with("res://")) {
TypedArray<Dictionary> classes = ProjectSettings::get_singleton()->get_global_class_list(); TypedArray<Dictionary> classes = ProjectSettings::get_singleton()->get_global_class_list();
for (int i = 0; i < classes.size(); i++) { for (int i = 0; i < classes.size(); i++) {
@ -137,11 +136,8 @@ Ref<Texture2D> LimboUtility::get_task_icon(String p_class_or_script_path) const
path = "res://addons/limboai/icons/" + sc->get_instance_base_type() + ".svg"; path = "res://addons/limboai/icons/" + sc->get_instance_base_type() + ".svg";
} }
} }
} } else {
#endif // LIMBOAI_GDEXTENSION // Trying addon icons
if (path.is_empty() && !p_class_or_script_path.begins_with("res://")) {
// Trying addons/limboai/icons/
path = "res://addons/limboai/icons/" + p_class_or_script_path + ".svg"; path = "res://addons/limboai/icons/" + p_class_or_script_path + ".svg";
} }
@ -150,7 +146,6 @@ Ref<Texture2D> LimboUtility::get_task_icon(String p_class_or_script_path) const
return icon; return icon;
} }
// * Class icons are not available at runtime as they are part of the editor theme.
return nullptr; return nullptr;
} }