Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix renaming BehaviorTree files doesn't update tab names #191

Merged
merged 1 commit into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions editor/limbo_ai_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,11 @@ void LimboAIEditor::_on_visibility_changed() {
task_palette->refresh();
}
_update_favorite_tasks();

if (request_update_tabs && history.size() > 0) {
_update_tabs();
request_update_tabs = false;
}
}

void LimboAIEditor::_on_header_pressed() {
Expand Down Expand Up @@ -914,6 +919,18 @@ void LimboAIEditor::_on_resources_reload(const PackedStringArray &p_resources) {
#endif
}

void LimboAIEditor::_on_filesystem_changed() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like an overkill to do it when LimboAI is not used.
I suggest connecting & disconnecting the signal in make_visible, or checking is_visible_in_tree().

Copy link
Contributor Author

@ydeltastar ydeltastar Aug 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will introduce the issue that the tabs remain outdated when the editor is visible again.
I pushed a solution to update only when visible.

if (history.size() == 0) {
return;
}

if (is_visible_in_tree()) {
_update_tabs();
} else {
request_update_tabs = true;
}
}

void LimboAIEditor::_on_new_script_pressed() {
SCRIPT_EDITOR()->open_script_create_dialog("BTAction", String(GLOBAL_GET("limbo_ai/behavior_tree/user_task_dir_1")).path_join("new_task"));
}
Expand Down Expand Up @@ -1403,6 +1420,7 @@ void LimboAIEditor::_notification(int p_what) {
version_btn->connect(LW_NAME(pressed), callable_mp(this, &LimboAIEditor::_copy_version_info));

EDITOR_FILE_SYSTEM()->connect("resources_reload", callable_mp(this, &LimboAIEditor::_on_resources_reload));
EDITOR_FILE_SYSTEM()->connect("filesystem_changed", callable_mp(this, &LimboAIEditor::_on_filesystem_changed));

} break;
case NOTIFICATION_THEME_CHANGED: {
Expand Down
2 changes: 2 additions & 0 deletions editor/limbo_ai_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class LimboAIEditor : public Control {
Vector<Ref<BehaviorTree>> history;
int idx_history;
bool updating_tabs = false;
bool request_update_tabs = false;
HashSet<Ref<BehaviorTree>> dirty;
Ref<BTTask> clipboard_task;

Expand Down Expand Up @@ -237,6 +238,7 @@ class LimboAIEditor : public Control {
void _on_history_forward();
void _on_task_dragged(Ref<BTTask> p_task, Ref<BTTask> p_to_task, int p_type);
void _on_resources_reload(const PackedStringArray &p_resources);
void _on_filesystem_changed();
void _on_new_script_pressed();
void _task_type_selected(const String &p_class_or_path);
void _copy_version_info();
Expand Down
Loading