Fix tab names doesn't update when filesystem changes

This commit is contained in:
yds 2024-08-08 23:30:14 -03:00
parent f14a19b947
commit 410efbe0d3
2 changed files with 20 additions and 0 deletions

View File

@ -799,6 +799,11 @@ void LimboAIEditor::_on_visibility_changed() {
task_palette->refresh(); task_palette->refresh();
} }
_update_favorite_tasks(); _update_favorite_tasks();
if (request_update_tabs && history.size() > 0) {
_update_tabs();
request_update_tabs = false;
}
} }
void LimboAIEditor::_on_header_pressed() { void LimboAIEditor::_on_header_pressed() {
@ -914,6 +919,18 @@ void LimboAIEditor::_on_resources_reload(const PackedStringArray &p_resources) {
#endif #endif
} }
void LimboAIEditor::_on_filesystem_changed() {
if (history.size() == 0) {
return;
}
if (is_visible_in_tree()) {
_update_tabs();
} else {
request_update_tabs = true;
}
}
void LimboAIEditor::_on_new_script_pressed() { 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")); SCRIPT_EDITOR()->open_script_create_dialog("BTAction", String(GLOBAL_GET("limbo_ai/behavior_tree/user_task_dir_1")).path_join("new_task"));
} }
@ -1403,6 +1420,7 @@ void LimboAIEditor::_notification(int p_what) {
version_btn->connect(LW_NAME(pressed), callable_mp(this, &LimboAIEditor::_copy_version_info)); 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("resources_reload", callable_mp(this, &LimboAIEditor::_on_resources_reload));
EDITOR_FILE_SYSTEM()->connect("filesystem_changed", callable_mp(this, &LimboAIEditor::_on_filesystem_changed));
} break; } break;
case NOTIFICATION_THEME_CHANGED: { case NOTIFICATION_THEME_CHANGED: {

View File

@ -143,6 +143,7 @@ private:
Vector<Ref<BehaviorTree>> history; Vector<Ref<BehaviorTree>> history;
int idx_history; int idx_history;
bool updating_tabs = false; bool updating_tabs = false;
bool request_update_tabs = false;
HashSet<Ref<BehaviorTree>> dirty; HashSet<Ref<BehaviorTree>> dirty;
Ref<BTTask> clipboard_task; Ref<BTTask> clipboard_task;
@ -237,6 +238,7 @@ private:
void _on_history_forward(); void _on_history_forward();
void _on_task_dragged(Ref<BTTask> p_task, Ref<BTTask> p_to_task, int p_type); 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_resources_reload(const PackedStringArray &p_resources);
void _on_filesystem_changed();
void _on_new_script_pressed(); void _on_new_script_pressed();
void _task_type_selected(const String &p_class_or_path); void _task_type_selected(const String &p_class_or_path);
void _copy_version_info(); void _copy_version_info();