diff --git a/editor/limbo_ai_editor_plugin.cpp b/editor/limbo_ai_editor_plugin.cpp index 3e01565..bac8586 100644 --- a/editor/limbo_ai_editor_plugin.cpp +++ b/editor/limbo_ai_editor_plugin.cpp @@ -792,22 +792,26 @@ void LimboAIEditor::shortcut_input(const Ref &p_event) { accept_event(); } -void LimboAIEditor::_create_popup_menu() { +void LimboAIEditor::_on_tree_rmb(const Vector2 &p_menu_pos) { menu->clear(); + + Ref task = task_tree->get_selected(); + ERR_FAIL_COND_MSG(task.is_null(), "LimboAIEditor: get_selected() returned null"); + menu->add_icon_shortcut(get_theme_icon(SNAME("Rename"), SNAME("EditorIcons")), ED_GET_SHORTCUT("limbo_ai/rename_task"), ACTION_RENAME); + menu->add_icon_item(get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), TTR("Edit Script"), ACTION_EDIT_SCRIPT); + menu->set_item_disabled(ACTION_EDIT_SCRIPT, task->get_script().is_null()); + menu->add_separator(); menu->add_icon_shortcut(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons")), ED_GET_SHORTCUT("limbo_ai/move_task_up"), ACTION_MOVE_UP); menu->add_icon_shortcut(get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons")), ED_GET_SHORTCUT("limbo_ai/move_task_down"), ACTION_MOVE_DOWN); menu->add_icon_shortcut(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), ED_GET_SHORTCUT("limbo_ai/duplicate_task"), ACTION_DUPLICATE); menu->add_icon_item(get_theme_icon(SNAME("NewRoot"), SNAME("EditorIcons")), TTR("Make Root"), ACTION_MAKE_ROOT); + menu->add_separator(); menu->add_icon_shortcut(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ED_GET_SHORTCUT("limbo_ai/remove_task"), ACTION_REMOVE); menu->reset_size(); -} - -void LimboAIEditor::_on_tree_rmb(const Vector2 &p_menu_pos) { - _create_popup_menu(); menu->set_position(p_menu_pos); menu->popup(); } @@ -825,6 +829,10 @@ void LimboAIEditor::_action_selected(int p_id) { rename_edit->select_all(); rename_edit->grab_focus(); } break; + case ACTION_EDIT_SCRIPT: { + ERR_FAIL_COND(task_tree->get_selected().is_null()); + EditorNode::get_singleton()->edit_resource(task_tree->get_selected()->get_script()); + } break; case ACTION_MOVE_UP: { Ref sel = task_tree->get_selected(); if (sel.is_valid() && sel->get_parent().is_valid()) { @@ -1137,7 +1145,6 @@ void LimboAIEditor::_notification(int p_what) { history_back->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); history_forward->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); - _create_popup_menu(); _update_header(); } } diff --git a/editor/limbo_ai_editor_plugin.h b/editor/limbo_ai_editor_plugin.h index 3b5c27b..db2c741 100644 --- a/editor/limbo_ai_editor_plugin.h +++ b/editor/limbo_ai_editor_plugin.h @@ -134,6 +134,7 @@ class LimboAIEditor : public Control { private: enum Action { ACTION_RENAME, + ACTION_EDIT_SCRIPT, ACTION_MOVE_UP, ACTION_MOVE_DOWN, ACTION_DUPLICATE, @@ -180,7 +181,6 @@ private: void _save_bt(String p_path); void _load_bt(String p_path); void _mark_as_dirty(bool p_dirty); - void _create_popup_menu(); void _reload_modified(); void _resave_modified(String _str = "");