Restore icons

This commit is contained in:
Serhii Snitsaruk 2024-01-10 01:17:09 +01:00
parent 835d053c00
commit a8dc78765b
7 changed files with 34 additions and 10 deletions

View File

@ -134,9 +134,9 @@ void BehaviorTreeView::clear() {
} }
void BehaviorTreeView::_do_update_theme_item_cache() { void BehaviorTreeView::_do_update_theme_item_cache() {
theme_cache.icon_running = get_theme_icon(LW_NAME(LimboExtraClock), LW_NAME(EditorIcons)); theme_cache.icon_running = LimboUtility::get_singleton()->get_task_icon("LimboExtraClock");
theme_cache.icon_success = get_theme_icon(LW_NAME(BTAlwaysSucceed), LW_NAME(EditorIcons)); theme_cache.icon_success = LimboUtility::get_singleton()->get_task_icon("BTAlwaysSucceed");
theme_cache.icon_failure = get_theme_icon(LW_NAME(BTAlwaysFail), LW_NAME(EditorIcons)); theme_cache.icon_failure = LimboUtility::get_singleton()->get_task_icon("BTAlwaysFail");
theme_cache.font_custom_name = get_theme_font(LW_NAME(bold), LW_NAME(EditorFonts)); theme_cache.font_custom_name = get_theme_font(LW_NAME(bold), LW_NAME(EditorFonts));

View File

@ -16,6 +16,7 @@
#include "../../bt/behavior_tree.h" #include "../../bt/behavior_tree.h"
#include "../../editor/debugger/behavior_tree_data.h" #include "../../editor/debugger/behavior_tree_data.h"
#include "../../editor/debugger/behavior_tree_view.h" #include "../../editor/debugger/behavior_tree_view.h"
#include "../../util/limbo_utility.h"
#include "limbo_debugger.h" #include "limbo_debugger.h"
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
@ -183,7 +184,7 @@ void LimboDebuggerTab::_notification(int p_what) {
} break; } break;
case NOTIFICATION_THEME_CHANGED: { case NOTIFICATION_THEME_CHANGED: {
alert_icon->set_texture(get_theme_icon(LW_NAME(StatusWarning), LW_NAME(EditorIcons))); alert_icon->set_texture(get_theme_icon(LW_NAME(StatusWarning), LW_NAME(EditorIcons)));
BUTTON_SET_ICON(resource_header, get_theme_icon(LW_NAME(BehaviorTree), LW_NAME(EditorIcons))); BUTTON_SET_ICON(resource_header, LimboUtility::get_singleton()->get_task_icon("BehaviorTree"));
} break; } break;
} }
} }

View File

@ -981,12 +981,13 @@ void LimboAIEditor::_do_update_theme_item_cache() {
theme_cache.move_task_up_icon = get_theme_icon(LW_NAME(MoveUp), LW_NAME(EditorIcons)); theme_cache.move_task_up_icon = get_theme_icon(LW_NAME(MoveUp), LW_NAME(EditorIcons));
theme_cache.open_debugger_icon = get_theme_icon(LW_NAME(Debug), LW_NAME(EditorIcons)); theme_cache.open_debugger_icon = get_theme_icon(LW_NAME(Debug), LW_NAME(EditorIcons));
theme_cache.open_doc_icon = get_theme_icon(LW_NAME(Help), LW_NAME(EditorIcons)); theme_cache.open_doc_icon = get_theme_icon(LW_NAME(Help), LW_NAME(EditorIcons));
theme_cache.percent_icon = get_theme_icon(LW_NAME(LimboPercent), LW_NAME(EditorIcons));
theme_cache.remove_task_icon = get_theme_icon(LW_NAME(Remove), LW_NAME(EditorIcons)); theme_cache.remove_task_icon = get_theme_icon(LW_NAME(Remove), LW_NAME(EditorIcons));
theme_cache.rename_task_icon = get_theme_icon(LW_NAME(Rename), LW_NAME(EditorIcons)); theme_cache.rename_task_icon = get_theme_icon(LW_NAME(Rename), LW_NAME(EditorIcons));
theme_cache.change_type_icon = get_theme_icon(LW_NAME(Reload), LW_NAME(EditorIcons)); theme_cache.change_type_icon = get_theme_icon(LW_NAME(Reload), LW_NAME(EditorIcons));
theme_cache.extract_subtree_icon = get_theme_icon(LW_NAME(LimboExtractSubtree), LW_NAME(EditorIcons));
theme_cache.behavior_tree_icon = get_theme_icon(LW_NAME(BehaviorTree), LW_NAME(EditorIcons)); theme_cache.behavior_tree_icon = LimboUtility::get_singleton()->get_task_icon("BehaviorTree");
theme_cache.percent_icon = LimboUtility::get_singleton()->get_task_icon("LimboPercent");
theme_cache.extract_subtree_icon = LimboUtility::get_singleton()->get_task_icon("LimboExtractSubtree");
} }
void LimboAIEditor::_notification(int p_what) { void LimboAIEditor::_notification(int p_what) {
@ -1394,6 +1395,12 @@ bool LimboAIEditorPlugin::_handles(Object *p_object) const {
return false; return false;
} }
#ifdef LIMBOAI_GDEXTENSION
Ref<Texture2D> LimboAIEditorPlugin::_get_plugin_icon() const {
return LimboUtility::get_singleton()->get_task_icon("LimboAI");
}
#endif // LIMBOAI_GDEXTENSION
LimboAIEditorPlugin::LimboAIEditorPlugin() { LimboAIEditorPlugin::LimboAIEditorPlugin() {
limbo_ai_editor = memnew(LimboAIEditor()); limbo_ai_editor = memnew(LimboAIEditor());
limbo_ai_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); limbo_ai_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);

View File

@ -243,6 +243,7 @@ public:
virtual void _apply_changes() override; virtual void _apply_changes() override;
virtual void _edit(Object *p_object) override; virtual void _edit(Object *p_object) override;
virtual bool _handles(Object *p_object) const override; virtual bool _handles(Object *p_object) const override;
virtual Ref<Texture2D> _get_plugin_icon() const override;
#endif // LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION
LimboAIEditorPlugin(); LimboAIEditorPlugin();

View File

@ -580,11 +580,12 @@ void TaskPalette::_notification(int p_what) {
BUTTON_SET_ICON(tool_filters, get_theme_icon(LW_NAME(AnimationFilter), LW_NAME(EditorIcons))); BUTTON_SET_ICON(tool_filters, get_theme_icon(LW_NAME(AnimationFilter), LW_NAME(EditorIcons)));
BUTTON_SET_ICON(tool_refresh, get_theme_icon(LW_NAME(Reload), LW_NAME(EditorIcons))); BUTTON_SET_ICON(tool_refresh, get_theme_icon(LW_NAME(Reload), LW_NAME(EditorIcons)));
BUTTON_SET_ICON(select_all, get_theme_icon(LW_NAME(LimboSelectAll), LW_NAME(EditorIcons)));
BUTTON_SET_ICON(deselect_all, get_theme_icon(LW_NAME(LimboDeselectAll), LW_NAME(EditorIcons)));
filter_edit->set_right_icon(get_theme_icon(LW_NAME(Search), LW_NAME(EditorIcons))); filter_edit->set_right_icon(get_theme_icon(LW_NAME(Search), LW_NAME(EditorIcons)));
BUTTON_SET_ICON(select_all, LimboUtility::get_singleton()->get_task_icon("LimboSelectAll"));
BUTTON_SET_ICON(deselect_all, LimboUtility::get_singleton()->get_task_icon("LimboDeselectAll"));
category_choice->queue_redraw(); category_choice->queue_redraw();
if (is_visible_in_tree()) { if (is_visible_in_tree()) {

View File

@ -126,6 +126,7 @@ LimboStringNames::LimboStringNames() {
text_changed = SN("text_changed"); text_changed = SN("text_changed");
timeout = SN("timeout"); timeout = SN("timeout");
toggled = SN("toggled"); toggled = SN("toggled");
Tools = SN("Tools");
update_task = SN("update_task"); update_task = SN("update_task");
update_tree = SN("update_tree"); update_tree = SN("update_tree");
updated = SN("updated"); updated = SN("updated");

View File

@ -32,6 +32,7 @@
#include "godot_cpp/classes/input_event_key.hpp" #include "godot_cpp/classes/input_event_key.hpp"
#include "godot_cpp/variant/utility_functions.hpp" #include "godot_cpp/variant/utility_functions.hpp"
#include <godot_cpp/classes/resource_loader.hpp> #include <godot_cpp/classes/resource_loader.hpp>
#include <godot_cpp/classes/texture2d.hpp>
#include <godot_cpp/classes/theme.hpp> #include <godot_cpp/classes/theme.hpp>
#include <godot_cpp/core/error_macros.hpp> #include <godot_cpp/core/error_macros.hpp>
@ -106,7 +107,19 @@ Ref<Texture2D> LimboUtility::get_task_icon(String p_class_or_script_path) const
} }
// Return generic resource icon as a fallback. // Return generic resource icon as a fallback.
return theme->get_icon(SNAME("Resource"), SNAME("EditorIcons")); return theme->get_icon(SNAME("Resource"), SNAME("EditorIcons"));
#endif // TOOLS_ENABLED #endif // ! TOOLS_ENABLED && LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION
String path;
if (p_class_or_script_path.begins_with("res://")) {
path = p_class_or_script_path;
} else {
path = "res://addons/limboai/icons/" + p_class_or_script_path + ".svg";
}
Ref<Texture2D> icon = RESOURCE_LOAD(path, "Texture2D");
return icon;
#endif // LIMBOAI_GDEXTENSION
// TODO: GDExtension needs the icons too. // TODO: GDExtension needs the icons too.