Compare commits
No commits in common. "e6e1addbcb719fa1cacfcb593a760fe637ad3823" and "20be87904a50ab13f91bd4c5f3ca72ff3084f527" have entirely different histories.
e6e1addbcb
...
20be87904a
|
@ -261,10 +261,6 @@ void LimboAIEditor::edit_bt(const Ref<BehaviorTree> &p_behavior_tree, bool p_for
|
|||
p_behavior_tree->editor_set_section_unfold("blackboard_plan", true);
|
||||
p_behavior_tree->notify_property_list_changed();
|
||||
#endif // LIMBOAI_MODULE
|
||||
// Remember current search info.
|
||||
if (idx_history >= 0 && idx_history < history.size()) {
|
||||
tab_search_context.insert(history[idx_history], task_tree->tree_search_get_search_info());
|
||||
}
|
||||
|
||||
task_tree->load_bt(p_behavior_tree);
|
||||
|
||||
|
@ -284,18 +280,6 @@ void LimboAIEditor::edit_bt(const Ref<BehaviorTree> &p_behavior_tree, bool p_for
|
|||
task_tree->show();
|
||||
task_palette->show();
|
||||
|
||||
// Restore search info from [tab_search_context].
|
||||
if (idx_history >= 0 && idx_history < history.size()) {
|
||||
// info for BehaviorTree available. Restore!
|
||||
if (tab_search_context.has(history[idx_history])) {
|
||||
task_tree->tree_search_set_search_info(tab_search_context[history[idx_history]]);
|
||||
}
|
||||
// new SearchContext.
|
||||
else {
|
||||
task_tree->tree_search_set_search_info(TreeSearch::SearchInfo());
|
||||
}
|
||||
}
|
||||
|
||||
_update_tabs();
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@
|
|||
|
||||
#ifdef LIMBOAI_GDEXTENSION
|
||||
#include "godot_cpp/classes/accept_dialog.hpp"
|
||||
#include <godot_cpp/classes/config_file.hpp>
|
||||
#include <godot_cpp/classes/control.hpp>
|
||||
#include <godot_cpp/classes/editor_plugin.hpp>
|
||||
#include <godot_cpp/classes/editor_spin_slider.hpp>
|
||||
|
@ -65,6 +64,7 @@
|
|||
#include <godot_cpp/classes/texture2d.hpp>
|
||||
#include <godot_cpp/variant/packed_string_array.hpp>
|
||||
#include <godot_cpp/variant/variant.hpp>
|
||||
#include <godot_cpp/classes/config_file.hpp>
|
||||
|
||||
using namespace godot;
|
||||
|
||||
|
@ -143,7 +143,6 @@ private:
|
|||
EditorLayout editor_layout;
|
||||
Vector<Ref<BehaviorTree>> history;
|
||||
int idx_history;
|
||||
HashMap<Ref<BehaviorTree>, TreeSearch::SearchInfo> tab_search_context;
|
||||
bool updating_tabs = false;
|
||||
bool request_update_tabs = false;
|
||||
HashSet<Ref<BehaviorTree>> dirty;
|
||||
|
|
|
@ -49,7 +49,7 @@ TreeItem *TaskTree::_create_tree(const Ref<BTTask> &p_task, TreeItem *p_parent,
|
|||
_update_item(item);
|
||||
|
||||
// update TreeSearch if root task was created
|
||||
if (tree->get_root() == item) {
|
||||
if (tree->get_root() == item){
|
||||
tree_search->update_search(tree);
|
||||
}
|
||||
|
||||
|
@ -546,6 +546,7 @@ void TaskTree::_notification(int p_what) {
|
|||
_update_tree();
|
||||
} break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TaskTree::_bind_methods() {
|
||||
|
@ -572,27 +573,11 @@ void TaskTree::_bind_methods() {
|
|||
PropertyInfo(Variant::INT, "type")));
|
||||
}
|
||||
|
||||
// TreeSearch API
|
||||
void TaskTree::tree_search_show_and_focus() {
|
||||
ERR_FAIL_NULL(tree_search);
|
||||
tree_search_panel->set_visible(true);
|
||||
tree_search_panel->focus_editor();
|
||||
tree_search_panel->show_and_focus();
|
||||
}
|
||||
|
||||
TreeSearch::SearchInfo TaskTree::tree_search_get_search_info() const {
|
||||
if (!tree_search.is_valid()) {
|
||||
return TreeSearch::SearchInfo();
|
||||
}
|
||||
return tree_search_panel->get_search_info();
|
||||
}
|
||||
|
||||
void TaskTree::tree_search_set_search_info(const TreeSearch::SearchInfo &p_search_info) {
|
||||
ERR_FAIL_NULL(tree_search);
|
||||
tree_search_panel->set_search_info(p_search_info);
|
||||
}
|
||||
|
||||
// TreeSearch Api ^
|
||||
|
||||
TaskTree::TaskTree() {
|
||||
editable = true;
|
||||
updating_tree = false;
|
||||
|
|
|
@ -103,16 +103,13 @@ public:
|
|||
Ref<BTTask> get_selected() const;
|
||||
Vector<Ref<BTTask>> get_selected_tasks() const;
|
||||
void clear_selection();
|
||||
void tree_search_show_and_focus();
|
||||
|
||||
Rect2 get_selected_probability_rect() const;
|
||||
double get_selected_probability_weight() const;
|
||||
double get_selected_probability_percent() const;
|
||||
bool selected_has_probability() const;
|
||||
|
||||
// TreeSearch API
|
||||
void tree_search_show_and_focus();
|
||||
TreeSearch::SearchInfo tree_search_get_search_info() const;
|
||||
void tree_search_set_search_info(const TreeSearch::SearchInfo &p_search_info);
|
||||
|
||||
virtual bool editor_can_reload_from_file() { return false; }
|
||||
|
||||
TaskTree();
|
||||
|
|
|
@ -68,16 +68,10 @@ void TreeSearch::_filter_tree(const String &p_search_mask) {
|
|||
}
|
||||
|
||||
TreeItem *first_counting_ancestor = cur_item;
|
||||
bool parents_visible = true;
|
||||
while (first_counting_ancestor && !number_matches.has(first_counting_ancestor)) {
|
||||
// Performance: we only need to check the first visible ancestor. This is already optimal because of the ordering in ordered_tree_items.
|
||||
if (!first_counting_ancestor->is_visible()){
|
||||
parents_visible = false;
|
||||
break;
|
||||
}
|
||||
first_counting_ancestor = first_counting_ancestor->get_parent();
|
||||
}
|
||||
if (!parents_visible || !first_counting_ancestor || !_vector_has_bsearch(matching_entries, first_counting_ancestor)) {
|
||||
if (!first_counting_ancestor || !_vector_has_bsearch(matching_entries, first_counting_ancestor)) {
|
||||
cur_item->set_visible(false);
|
||||
}
|
||||
}
|
||||
|
@ -389,11 +383,10 @@ void TreeSearch::_select_next_match() {
|
|||
_select_first_match();
|
||||
}
|
||||
|
||||
void TreeSearch::_on_search_panel_closed() {
|
||||
if (!tree_reference) {
|
||||
return;
|
||||
}
|
||||
void TreeSearch::_on_search_panel_visibility_changed() {
|
||||
if (tree_reference && !search_panel->is_visible()) {
|
||||
tree_reference->grab_focus();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@ -451,8 +444,8 @@ void TreeSearch::update_search(Tree *p_tree) {
|
|||
|
||||
TreeSearch::TreeSearch(TreeSearchPanel *p_search_panel) {
|
||||
search_panel = p_search_panel;
|
||||
search_panel->connect(LW_NAME(text_submitted), callable_mp(this, &TreeSearch::_select_next_match));
|
||||
search_panel->connect(LW_NAME(Close), callable_mp(this, &TreeSearch::_on_search_panel_closed));
|
||||
search_panel->connect("text_submitted", callable_mp(this, &TreeSearch::_select_next_match));
|
||||
search_panel->connect("visibility_changed", callable_mp(this, &TreeSearch::_on_search_panel_visibility_changed));
|
||||
}
|
||||
|
||||
/* !TreeSearch */
|
||||
|
@ -497,16 +490,16 @@ void TreeSearchPanel::_notification(int p_what) {
|
|||
switch (p_what) {
|
||||
case NOTIFICATION_READY: {
|
||||
// close callbacks
|
||||
close_button->connect(LW_NAME(pressed), Callable(this, LW_NAME(set_visible)).bind(false));
|
||||
close_button->connect(LW_NAME(pressed), Callable(this, LW_NAME(emit_signal)).bind(LW_NAME(Close)));
|
||||
close_button->connect("pressed", Callable(this, "set_visible").bind(false));
|
||||
close_button->set_shortcut(LW_GET_SHORTCUT("limbo_ai/hide_tree_search"));
|
||||
// search callbacks
|
||||
Callable c_update_requested = Callable(this, LW_NAME(emit_signal)).bind("update_requested");
|
||||
Callable c_text_submitted = Callable((Object *)this, LW_NAME(emit_signal)).bind(LW_NAME(text_submitted));
|
||||
|
||||
line_edit_search->connect(LW_NAME(text_changed), c_update_requested.unbind(1));
|
||||
check_button_filter_highlight->connect(LW_NAME(pressed), c_update_requested);
|
||||
line_edit_search->connect(LW_NAME(text_submitted), c_text_submitted.unbind(1));
|
||||
// search callbacks
|
||||
Callable c_update_requested = Callable(this, "emit_signal").bind("update_requested");
|
||||
Callable c_text_submitted = Callable((Object *)this, "emit_signal").bind("text_submitted");
|
||||
|
||||
line_edit_search->connect("text_changed", c_update_requested.unbind(1));
|
||||
check_button_filter_highlight->connect("pressed", c_update_requested);
|
||||
line_edit_search->connect("text_submitted", c_text_submitted.unbind(1));
|
||||
break;
|
||||
}
|
||||
case NOTIFICATION_THEME_CHANGED: {
|
||||
|
@ -519,8 +512,7 @@ void TreeSearchPanel::_notification(int p_what) {
|
|||
|
||||
void TreeSearchPanel::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("update_requested"));
|
||||
ADD_SIGNAL(MethodInfo(LW_NAME(text_submitted)));
|
||||
ADD_SIGNAL(MethodInfo(LW_NAME(Close)));
|
||||
ADD_SIGNAL(MethodInfo("text_submitted"));
|
||||
}
|
||||
|
||||
TreeSearchPanel::TreeSearchPanel() {
|
||||
|
@ -542,22 +534,8 @@ String TreeSearchPanel::get_text() const {
|
|||
return line_edit_search->get_text();
|
||||
}
|
||||
|
||||
TreeSearch::SearchInfo TreeSearchPanel::get_search_info() const {
|
||||
TreeSearch::SearchInfo result;
|
||||
result.search_mask = get_text();
|
||||
result.search_mode = get_search_mode();
|
||||
result.visible = is_visible();
|
||||
return result;
|
||||
}
|
||||
|
||||
void TreeSearchPanel::set_search_info(const TreeSearch::SearchInfo &p_search_info) {
|
||||
line_edit_search->set_text(p_search_info.search_mask);
|
||||
check_button_filter_highlight->set_pressed(p_search_info.search_mode == TreeSearch::TreeSearchMode::FILTER);
|
||||
set_visible(p_search_info.visible);
|
||||
emit_signal("update_requested");
|
||||
}
|
||||
|
||||
void TreeSearchPanel::focus_editor() {
|
||||
void TreeSearchPanel::show_and_focus() {
|
||||
set_visible(true);
|
||||
line_edit_search->grab_focus();
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ private:
|
|||
void _select_first_match();
|
||||
void _select_next_match();
|
||||
|
||||
void _on_search_panel_closed();
|
||||
void _on_search_panel_visibility_changed();
|
||||
|
||||
// TODO: make p_vec ref `const` once Vector::bsearch is const. See: https://github.com/godotengine/godot/pull/90341
|
||||
template <typename T>
|
||||
|
@ -105,12 +105,6 @@ public:
|
|||
FILTER = 1
|
||||
};
|
||||
|
||||
struct SearchInfo {
|
||||
String search_mask;
|
||||
TreeSearchMode search_mode;
|
||||
bool visible;
|
||||
};
|
||||
|
||||
void update_search(Tree *p_tree);
|
||||
void notify_item_edited(TreeItem *p_item);
|
||||
|
||||
|
@ -138,11 +132,9 @@ protected:
|
|||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
String get_text() const;
|
||||
TreeSearch::TreeSearchMode get_search_mode() const;
|
||||
TreeSearch::SearchInfo get_search_info() const;
|
||||
void set_search_info(const TreeSearch::SearchInfo &p_search_info);
|
||||
void focus_editor();
|
||||
String get_text() const;
|
||||
void show_and_focus();
|
||||
TreeSearchPanel();
|
||||
};
|
||||
|
||||
|
|
|
@ -59,7 +59,6 @@ LimboStringNames::LimboStringNames() {
|
|||
EditorFonts = SN("EditorFonts");
|
||||
EditorIcons = SN("EditorIcons");
|
||||
EditorStyles = SN("EditorStyles");
|
||||
emit_signal = SN("emit_signal");
|
||||
entered = SN("entered");
|
||||
error_value = SN("error_value");
|
||||
EVENT_FAILURE = SN("failure");
|
||||
|
@ -125,7 +124,6 @@ LimboStringNames::LimboStringNames() {
|
|||
separation = SN("separation");
|
||||
set_custom_name = SN("set_custom_name");
|
||||
set_root_task = SN("set_root_task");
|
||||
set_visible = SN("set_visible");
|
||||
set_v_scroll = SN("set_v_scroll");
|
||||
setup = SN("setup");
|
||||
started = SN("started");
|
||||
|
|
|
@ -75,7 +75,6 @@ public:
|
|||
StringName EditorFonts;
|
||||
StringName EditorIcons;
|
||||
StringName EditorStyles;
|
||||
StringName emit_signal;
|
||||
StringName entered;
|
||||
StringName error_value;
|
||||
StringName EVENT_FAILURE;
|
||||
|
@ -141,7 +140,6 @@ public:
|
|||
StringName separation;
|
||||
StringName set_custom_name;
|
||||
StringName set_root_task;
|
||||
StringName set_visible;
|
||||
StringName set_v_scroll;
|
||||
StringName setup;
|
||||
StringName started;
|
||||
|
|
Loading…
Reference in New Issue