Compare commits
No commits in common. "fa3034d1906f2c602642f4dba22d9bc0c87b6d9d" and "127fa678f4d43b50a7b66f39ec346a61da5bc106" have entirely different histories.
fa3034d190
...
127fa678f4
|
@ -171,6 +171,29 @@ void LimboAIEditor::_remove_task(const Ref<BTTask> &p_task) {
|
|||
undo_redo->commit_action();
|
||||
}
|
||||
|
||||
void LimboAIEditor::_update_header() const {
|
||||
if (task_tree->get_bt().is_null()) {
|
||||
header->set_text("");
|
||||
BUTTON_SET_ICON(header, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
String text = task_tree->get_bt()->get_path();
|
||||
if (text.is_empty()) {
|
||||
text = TTR("New Behavior Tree");
|
||||
} else if (dirty.has(task_tree->get_bt())) {
|
||||
text += "(*)";
|
||||
}
|
||||
|
||||
header->set_text(text);
|
||||
BUTTON_SET_ICON(header, theme_cache.behavior_tree_icon);
|
||||
}
|
||||
|
||||
void LimboAIEditor::_update_history_buttons() {
|
||||
history_back->set_disabled(idx_history == 0);
|
||||
history_forward->set_disabled(idx_history >= (history.size() - 1));
|
||||
}
|
||||
|
||||
void LimboAIEditor::_new_bt() {
|
||||
Ref<BehaviorTree> bt = memnew(BehaviorTree);
|
||||
bt->set_root_task(memnew(BTSelector));
|
||||
|
@ -187,6 +210,7 @@ void LimboAIEditor::_save_bt(String p_path) {
|
|||
task_tree->get_bt()->take_over_path(p_path);
|
||||
#endif
|
||||
RESOURCE_SAVE(task_tree->get_bt(), p_path, ResourceSaver::FLAG_CHANGE_PATH);
|
||||
_update_header();
|
||||
_update_tabs();
|
||||
_mark_as_dirty(false);
|
||||
}
|
||||
|
@ -246,6 +270,8 @@ void LimboAIEditor::edit_bt(Ref<BehaviorTree> p_behavior_tree, bool p_force_refr
|
|||
task_tree->show();
|
||||
task_palette->show();
|
||||
|
||||
_update_history_buttons();
|
||||
_update_header();
|
||||
_update_tabs();
|
||||
}
|
||||
|
||||
|
@ -263,8 +289,10 @@ void LimboAIEditor::_mark_as_dirty(bool p_dirty) {
|
|||
Ref<BehaviorTree> bt = task_tree->get_bt();
|
||||
if (p_dirty && !dirty.has(bt)) {
|
||||
dirty.insert(bt);
|
||||
_update_header();
|
||||
} else if (p_dirty == false && dirty.has(bt)) {
|
||||
dirty.erase(bt);
|
||||
_update_header();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -750,6 +778,7 @@ void LimboAIEditor::_on_visibility_changed() {
|
|||
}
|
||||
|
||||
void LimboAIEditor::_on_header_pressed() {
|
||||
_update_header();
|
||||
task_tree->deselect();
|
||||
#ifdef LIMBOAI_MODULE
|
||||
if (task_tree->get_bt().is_valid()) {
|
||||
|
@ -935,51 +964,28 @@ void LimboAIEditor::_tab_closed(int p_tab) {
|
|||
} else {
|
||||
EDIT_RESOURCE(history[idx_history]);
|
||||
}
|
||||
_update_history_buttons();
|
||||
_update_tabs();
|
||||
}
|
||||
|
||||
void LimboAIEditor::_update_tabs() {
|
||||
updating_tabs = true;
|
||||
tab_bar->clear_tabs();
|
||||
|
||||
Vector<String> short_names;
|
||||
// Keep track of how many times each short name is used.
|
||||
HashMap<String, int> usage_counts;
|
||||
|
||||
for (int i = 0; i < history.size(); i++) {
|
||||
String tab_name;
|
||||
if (history[i]->get_path().contains("::")) {
|
||||
if (history[i]->get_path().is_empty()) {
|
||||
tab_name = "[new]";
|
||||
} else if (history[i]->get_path().contains("::")) {
|
||||
tab_name = history[i]->get_path().get_file();
|
||||
} else {
|
||||
tab_name = history[i]->get_path().get_file().get_basename();
|
||||
}
|
||||
short_names.append(tab_name);
|
||||
if (usage_counts.has(tab_name)) {
|
||||
usage_counts[tab_name] += 1;
|
||||
} else {
|
||||
usage_counts[tab_name] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < short_names.size(); i++) {
|
||||
String tab_name = short_names[i];
|
||||
if (tab_name.is_empty()) {
|
||||
tab_name = "[new]";
|
||||
} else if (usage_counts[tab_name] > 1) {
|
||||
// Use the full name if the short name is not unique.
|
||||
tab_name = history[i]->get_path().trim_prefix("res://");
|
||||
}
|
||||
tab_bar->add_tab(tab_name, LimboUtility::get_singleton()->get_task_icon("BehaviorTree"));
|
||||
if (i == idx_history) {
|
||||
tab_bar->set_tab_button_icon(tab_bar->get_tab_count() - 1, LimboUtility::get_singleton()->get_task_icon("LimboEditBlackboard"));
|
||||
}
|
||||
}
|
||||
|
||||
if (idx_history >= 0) {
|
||||
ERR_FAIL_INDEX(idx_history, history.size());
|
||||
tab_bar->set_current_tab(idx_history);
|
||||
}
|
||||
|
||||
updating_tabs = false;
|
||||
}
|
||||
|
||||
|
@ -992,6 +998,7 @@ void LimboAIEditor::_move_active_tab(int p_to_index) {
|
|||
history.remove_at(idx_history);
|
||||
history.insert(p_to_index, bt);
|
||||
idx_history = p_to_index;
|
||||
_update_history_buttons();
|
||||
_update_tabs();
|
||||
}
|
||||
|
||||
|
@ -1042,30 +1049,26 @@ void LimboAIEditor::_tab_menu_option_selected(int p_id) {
|
|||
history.clear();
|
||||
history.append(bt);
|
||||
idx_history = 0;
|
||||
_update_history_buttons();
|
||||
_update_tabs();
|
||||
} break;
|
||||
case TAB_CLOSE_RIGHT: {
|
||||
for (int i = history.size() - 1; i > idx_history; i--) {
|
||||
history.remove_at(i);
|
||||
}
|
||||
_update_history_buttons();
|
||||
_update_tabs();
|
||||
} break;
|
||||
case TAB_CLOSE_ALL: {
|
||||
history.clear();
|
||||
idx_history = -1;
|
||||
_disable_editing();
|
||||
_update_history_buttons();
|
||||
_update_tabs();
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void LimboAIEditor::_tab_plan_edited(int p_tab) {
|
||||
ERR_FAIL_INDEX(p_tab, history.size());
|
||||
if (history[p_tab]->get_blackboard_plan().is_valid()) {
|
||||
EDIT_RESOURCE(history[p_tab]->get_blackboard_plan());
|
||||
}
|
||||
}
|
||||
|
||||
void LimboAIEditor::_reload_modified() {
|
||||
for (const String &res_path : disk_changed_files) {
|
||||
Ref<BehaviorTree> res = RESOURCE_LOAD(res_path, "BehaviorTree");
|
||||
|
@ -1120,6 +1123,7 @@ void LimboAIEditor::apply_changes() {
|
|||
RESOURCE_SAVE(bt, path, 0);
|
||||
}
|
||||
dirty.clear();
|
||||
_update_header();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1274,6 +1278,9 @@ void LimboAIEditor::_notification(int p_what) {
|
|||
save_btn->connect(LW_NAME(pressed), callable_mp(this, &LimboAIEditor::_on_save_pressed));
|
||||
misc_btn->connect(LW_NAME(pressed), callable_mp(this, &LimboAIEditor::_update_misc_menu));
|
||||
misc_btn->get_popup()->connect("id_pressed", callable_mp(this, &LimboAIEditor::_misc_option_selected));
|
||||
history_back->connect(LW_NAME(pressed), callable_mp(this, &LimboAIEditor::_on_history_back));
|
||||
history_forward->connect(LW_NAME(pressed), callable_mp(this, &LimboAIEditor::_on_history_forward));
|
||||
header->connect(LW_NAME(pressed), callable_mp(this, &LimboAIEditor::_on_header_pressed));
|
||||
task_palette->connect("task_selected", callable_mp(this, &LimboAIEditor::_add_task_by_class_or_path));
|
||||
task_palette->connect("favorite_tasks_changed", callable_mp(this, &LimboAIEditor::_update_favorite_tasks));
|
||||
change_type_palette->connect("task_selected", callable_mp(this, &LimboAIEditor::_task_type_selected));
|
||||
|
@ -1291,10 +1298,12 @@ void LimboAIEditor::_notification(int p_what) {
|
|||
tab_bar->connect("tab_close_pressed", callable_mp(this, &LimboAIEditor::_tab_closed));
|
||||
tab_bar->connect(LW_NAME(gui_input), callable_mp(this, &LimboAIEditor::_tab_input));
|
||||
tab_menu->connect(LW_NAME(id_pressed), callable_mp(this, &LimboAIEditor::_tab_menu_option_selected));
|
||||
tab_bar->connect("tab_button_pressed", callable_mp(this, &LimboAIEditor::_tab_plan_edited));
|
||||
|
||||
EDITOR_FILE_SYSTEM()->connect("resources_reload", callable_mp(this, &LimboAIEditor::_on_resources_reload));
|
||||
|
||||
_update_history_buttons();
|
||||
_update_header();
|
||||
|
||||
} break;
|
||||
case NOTIFICATION_THEME_CHANGED: {
|
||||
_do_update_theme_item_cache();
|
||||
|
@ -1305,9 +1314,12 @@ void LimboAIEditor::_notification(int p_what) {
|
|||
BUTTON_SET_ICON(load_btn, get_theme_icon(LW_NAME(Load), LW_NAME(EditorIcons)));
|
||||
BUTTON_SET_ICON(save_btn, get_theme_icon(LW_NAME(Save), LW_NAME(EditorIcons)));
|
||||
BUTTON_SET_ICON(new_script_btn, get_theme_icon(LW_NAME(ScriptCreate), LW_NAME(EditorIcons)));
|
||||
BUTTON_SET_ICON(history_back, get_theme_icon(LW_NAME(Back), LW_NAME(EditorIcons)));
|
||||
BUTTON_SET_ICON(history_forward, get_theme_icon(LW_NAME(Forward), LW_NAME(EditorIcons)));
|
||||
BUTTON_SET_ICON(misc_btn, get_theme_icon(LW_NAME(Tools), LW_NAME(EditorIcons)));
|
||||
|
||||
_update_favorite_tasks();
|
||||
_update_header();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1432,6 +1444,16 @@ LimboAIEditor::LimboAIEditor() {
|
|||
nav->set_h_size_flags(SIZE_EXPAND | SIZE_SHRINK_END);
|
||||
toolbar->add_child(nav);
|
||||
|
||||
history_back = memnew(Button);
|
||||
history_back->set_flat(true);
|
||||
history_back->set_focus_mode(FOCUS_NONE);
|
||||
nav->add_child(history_back);
|
||||
|
||||
history_forward = memnew(Button);
|
||||
history_forward->set_flat(true);
|
||||
history_forward->set_focus_mode(FOCUS_NONE);
|
||||
nav->add_child(history_forward);
|
||||
|
||||
tab_bar_panel = memnew(PanelContainer);
|
||||
vbox->add_child(tab_bar_panel);
|
||||
tab_bar_container = memnew(HBoxContainer);
|
||||
|
@ -1450,6 +1472,12 @@ LimboAIEditor::LimboAIEditor() {
|
|||
tab_menu = memnew(PopupMenu);
|
||||
add_child(tab_menu);
|
||||
|
||||
header = memnew(Button);
|
||||
header->set_text_alignment(HORIZONTAL_ALIGNMENT_LEFT);
|
||||
header->add_theme_constant_override("hseparation", 8);
|
||||
vbox->add_child(header);
|
||||
header->hide();
|
||||
|
||||
hsc = memnew(HSplitContainer);
|
||||
hsc->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
hsc->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
|
|
|
@ -139,6 +139,7 @@ private:
|
|||
HBoxContainer *tab_bar_container;
|
||||
TabBar *tab_bar;
|
||||
PopupMenu *tab_menu;
|
||||
Button *header;
|
||||
HSplitContainer *hsc;
|
||||
TaskTree *task_tree;
|
||||
VBoxContainer *banners;
|
||||
|
@ -158,6 +159,8 @@ private:
|
|||
FileDialog *save_dialog;
|
||||
FileDialog *load_dialog;
|
||||
FileDialog *extract_dialog;
|
||||
Button *history_back;
|
||||
Button *history_forward;
|
||||
|
||||
Button *new_btn;
|
||||
Button *load_btn;
|
||||
|
@ -179,6 +182,8 @@ private:
|
|||
Ref<BTTask> _create_task_by_class_or_path(const String &p_class_or_path) const;
|
||||
void _add_task_by_class_or_path(const String &p_class_or_path);
|
||||
void _remove_task(const Ref<BTTask> &p_task);
|
||||
void _update_header() const;
|
||||
void _update_history_buttons();
|
||||
void _update_favorite_tasks();
|
||||
void _update_misc_menu();
|
||||
void _update_banners();
|
||||
|
@ -199,7 +204,6 @@ private:
|
|||
void _tab_input(const Ref<InputEvent> &p_input);
|
||||
void _show_tab_context_menu();
|
||||
void _tab_menu_option_selected(int p_id);
|
||||
void _tab_plan_edited(int p_tab);
|
||||
|
||||
void _reload_modified();
|
||||
void _resave_modified(String _str = "");
|
||||
|
|
|
@ -431,7 +431,6 @@ TaskTree::TaskTree() {
|
|||
tree->set_anchor(SIDE_RIGHT, ANCHOR_END);
|
||||
tree->set_anchor(SIDE_BOTTOM, ANCHOR_END);
|
||||
tree->set_allow_rmb_select(true);
|
||||
tree->set_allow_reselect(true);
|
||||
|
||||
tree->set_drag_forwarding(callable_mp(this, &TaskTree::_get_drag_data_fw), callable_mp(this, &TaskTree::_can_drop_data_fw), callable_mp(this, &TaskTree::_drop_data_fw));
|
||||
}
|
||||
|
|
|
@ -75,7 +75,6 @@ BehaviorTreeView = "res://addons/limboai/icons/BehaviorTreeView.svg"
|
|||
BlackboardPlan = "res://addons/limboai/icons/BlackboardPlan.svg"
|
||||
LimboAI = "res://addons/limboai/icons/LimboAI.svg"
|
||||
LimboDeselectAll = "res://addons/limboai/icons/LimboDeselectAll.svg"
|
||||
LimboEditBlackboard = "res://addons/limboai/icons/LimboEditBlackboard.svg"
|
||||
LimboExtraBlackboard = "res://addons/limboai/icons/LimboExtraBlackboard.svg"
|
||||
LimboExtraClock = "res://addons/limboai/icons/LimboExtraClock.svg"
|
||||
LimboExtraVariable = "res://addons/limboai/icons/LimboExtraVariable.svg"
|
||||
|
@ -85,8 +84,6 @@ LimboPercent = "res://addons/limboai/icons/LimboPercent.svg"
|
|||
LimboSelectAll = "res://addons/limboai/icons/LimboSelectAll.svg"
|
||||
LimboState = "res://addons/limboai/icons/LimboState.svg"
|
||||
LimboVarAdd = "res://addons/limboai/icons/LimboVarAdd.svg"
|
||||
LimboVarEmpty = "res://addons/limboai/icons/LimboVarEmpty.svg"
|
||||
LimboVarError = "res://addons/limboai/icons/LimboVarError.svg"
|
||||
LimboVarExists = "res://addons/limboai/icons/LimboVarExists.svg"
|
||||
LimboVarNotFound = "res://addons/limboai/icons/LimboVarNotFound.svg"
|
||||
LimboVarPrivate = "res://addons/limboai/icons/LimboVarPrivate.svg"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
<svg clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="m0 0h16v16h-16z" fill="none"/><path d="m13 3h1.439c.861 0 1.56.699 1.56 1.56v8.88c0 .861-.699 1.56-1.56 1.56h-12.877c-.828 0-1.507-.647-1.558-1.463-.001.009-.001.017-.002.026-.001-.002 0-.049-.001-.119v-.004c0-.234.001-.591.001-.712v-8.168-1.468c0-1.295 2.999-1.483 2.999-.892v.8h3.999v1h-3.999v9.058c0-.362-1.126-.555-1.999-.35v.732c0 .309.251.56.56.56h12.877c.309 0 .56-.251.56-.56v-8.88c0-.309-.251-.56-.56-.56h-1.439zm-5 7v-6h4v6l-2 2zm2-5h-1v4h1zm-2-3.204c0-.439.896-.796 2-.796s2 .357 2 .796v1.204h-4z" fill="#e0e0e0"/></svg>
|
Before Width: | Height: | Size: 686 B |
Loading…
Reference in New Issue