Debugger: Add update interval controls and keep it in the config

Also fix bug with partial update.
This commit is contained in:
Serhii Snitsaruk 2024-02-17 14:56:19 +01:00
parent b9cd31eb2b
commit ecf44e83e0
3 changed files with 45 additions and 2 deletions

View File

@ -142,6 +142,8 @@ void BehaviorTreeView::_update_tree(const Ref<BehaviorTreeData> &p_data) {
} else { } else {
// * Create new tree. // * Create new tree.
last_root_id = p_data->tasks.size() > 0 ? p_data->tasks[0].id : 0;
tree->clear(); tree->clear();
TreeItem *parent = nullptr; TreeItem *parent = nullptr;
List<Pair<TreeItem *, int>> parents; List<Pair<TreeItem *, int>> parents;
@ -201,13 +203,13 @@ void BehaviorTreeView::_update_tree(const Ref<BehaviorTreeData> &p_data) {
parents.push_front(Pair<TreeItem *, int>(item, task_data.num_children)); parents.push_front(Pair<TreeItem *, int>(item, task_data.num_children));
} }
} }
last_root_id = p_data->tasks.size() > 0 ? p_data->tasks[0].id : 0;
} }
} }
void BehaviorTreeView::clear() { void BehaviorTreeView::clear() {
tree->clear(); tree->clear();
collapsed_ids.clear(); collapsed_ids.clear();
last_root_id = 0;
} }
void BehaviorTreeView::_do_update_theme_item_cache() { void BehaviorTreeView::_do_update_theme_item_cache() {

View File

@ -16,6 +16,7 @@
#include "../../bt/behavior_tree.h" #include "../../bt/behavior_tree.h"
#include "../../editor/debugger/behavior_tree_data.h" #include "../../editor/debugger/behavior_tree_data.h"
#include "../../editor/debugger/behavior_tree_view.h" #include "../../editor/debugger/behavior_tree_view.h"
#include "../../util/limbo_compat.h"
#include "../../util/limbo_utility.h" #include "../../util/limbo_utility.h"
#include "limbo_debugger.h" #include "limbo_debugger.h"
@ -29,6 +30,7 @@
#include "core/string/ustring.h" #include "core/string/ustring.h"
#include "core/variant/array.h" #include "core/variant/array.h"
#include "editor/editor_interface.h" #include "editor/editor_interface.h"
#include "editor/editor_paths.h"
#include "editor/editor_scale.h" #include "editor/editor_scale.h"
#include "editor/filesystem_dock.h" #include "editor/filesystem_dock.h"
#include "editor/plugins/editor_debugger_plugin.h" #include "editor/plugins/editor_debugger_plugin.h"
@ -37,16 +39,20 @@
#include "scene/gui/item_list.h" #include "scene/gui/item_list.h"
#include "scene/gui/label.h" #include "scene/gui/label.h"
#include "scene/gui/line_edit.h" #include "scene/gui/line_edit.h"
#include "scene/gui/separator.h"
#include "scene/gui/split_container.h" #include "scene/gui/split_container.h"
#include "scene/gui/tab_container.h" #include "scene/gui/tab_container.h"
#include "scene/gui/texture_rect.h" #include "scene/gui/texture_rect.h"
#endif // LIMBOAI_MODULE #endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/config_file.hpp>
#include <godot_cpp/classes/editor_interface.hpp> #include <godot_cpp/classes/editor_interface.hpp>
#include <godot_cpp/classes/editor_paths.hpp>
#include <godot_cpp/classes/file_system_dock.hpp> #include <godot_cpp/classes/file_system_dock.hpp>
#include <godot_cpp/classes/resource_loader.hpp> #include <godot_cpp/classes/resource_loader.hpp>
#include <godot_cpp/classes/tab_container.hpp> #include <godot_cpp/classes/tab_container.hpp>
#include <godot_cpp/classes/v_separator.hpp>
#endif // LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION
//**** LimboDebuggerTab //**** LimboDebuggerTab
@ -180,6 +186,23 @@ void LimboDebuggerTab::_notification(int p_what) {
resource_header->connect(LW_NAME(pressed), callable_mp(this, &LimboDebuggerTab::_resource_header_pressed)); resource_header->connect(LW_NAME(pressed), callable_mp(this, &LimboDebuggerTab::_resource_header_pressed));
filter_players->connect(LW_NAME(text_changed), callable_mp(this, &LimboDebuggerTab::_filter_changed)); filter_players->connect(LW_NAME(text_changed), callable_mp(this, &LimboDebuggerTab::_filter_changed));
bt_player_list->connect(LW_NAME(item_selected), callable_mp(this, &LimboDebuggerTab::_bt_selected)); bt_player_list->connect(LW_NAME(item_selected), callable_mp(this, &LimboDebuggerTab::_bt_selected));
update_interval->connect("value_changed", callable_mp(bt_view, &BehaviorTreeView::set_update_interval_msec));
Ref<ConfigFile> cf;
cf.instantiate();
String conf_path = PROJECT_CONFIG_FILE();
if (cf->load(conf_path) == OK) {
Variant value = cf->get_value("debugger", "update_interval_msec", 0);
update_interval->set_value(value);
}
} break;
case NOTIFICATION_EXIT_TREE: {
Ref<ConfigFile> cf;
cf.instantiate();
String conf_path = PROJECT_CONFIG_FILE();
cf->load(conf_path);
cf->set_value("debugger", "update_interval_msec", update_interval->get_value());
cf->save(conf_path);
} break; } break;
case NOTIFICATION_THEME_CHANGED: { case NOTIFICATION_THEME_CHANGED: {
alert_icon->set_texture(get_theme_icon(LW_NAME(StatusWarning), LW_NAME(EditorIcons))); alert_icon->set_texture(get_theme_icon(LW_NAME(StatusWarning), LW_NAME(EditorIcons)));
@ -195,7 +218,6 @@ void LimboDebuggerTab::setup(Ref<EditorDebuggerSession> p_session, CompatWindowW
if (p_wrapper->is_window_available()) { if (p_wrapper->is_window_available()) {
make_floating = memnew(CompatScreenSelect); make_floating = memnew(CompatScreenSelect);
make_floating->set_flat(true); make_floating->set_flat(true);
make_floating->set_h_size_flags(Control::SIZE_EXPAND | Control::SIZE_SHRINK_END);
make_floating->set_tooltip_text(TTR("Make the LimboAI Debugger floating.")); make_floating->set_tooltip_text(TTR("Make the LimboAI Debugger floating."));
make_floating->connect(LW_NAME(request_open_in_screen), callable_mp(window_wrapper, &CompatWindowWrapper::enable_window_on_screen).bind(true)); make_floating->connect(LW_NAME(request_open_in_screen), callable_mp(window_wrapper, &CompatWindowWrapper::enable_window_on_screen).bind(true));
toolbar->add_child(make_floating); toolbar->add_child(make_floating);
@ -221,6 +243,22 @@ LimboDebuggerTab::LimboDebuggerTab() {
resource_header->set_tooltip_text(TTR("Debugged BehaviorTree resource.\nClick to open.")); resource_header->set_tooltip_text(TTR("Debugged BehaviorTree resource.\nClick to open."));
resource_header->set_disabled(true); resource_header->set_disabled(true);
Label *interval_label = memnew(Label);
toolbar->add_child(interval_label);
interval_label->set_text(TTR("Update Interval:"));
interval_label->set_h_size_flags(SIZE_EXPAND | SIZE_SHRINK_END);
update_interval = memnew(EditorSpinSlider);
toolbar->add_child(update_interval);
update_interval->set_min(0);
update_interval->set_max(1000);
update_interval->set_step(1.0);
update_interval->set_suffix("ms");
update_interval->set_custom_minimum_size(Vector2(100 * EDSCALE, 0));
VSeparator *sep = memnew(VSeparator);
toolbar->add_child(sep);
hsc = memnew(HSplitContainer); hsc = memnew(HSplitContainer);
hsc->set_h_size_flags(Control::SIZE_EXPAND_FILL); hsc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hsc->set_v_size_flags(Control::SIZE_EXPAND_FILL); hsc->set_v_size_flags(Control::SIZE_EXPAND_FILL);

View File

@ -22,6 +22,7 @@
#include "core/object/class_db.h" #include "core/object/class_db.h"
#include "core/object/object.h" #include "core/object/object.h"
#include "core/typedefs.h" #include "core/typedefs.h"
#include "editor/gui/editor_spin_slider.h"
#include "editor/plugins/editor_debugger_plugin.h" #include "editor/plugins/editor_debugger_plugin.h"
#include "editor/window_wrapper.h" #include "editor/window_wrapper.h"
#include "scene/gui/box_container.h" #include "scene/gui/box_container.h"
@ -35,6 +36,7 @@
#include <godot_cpp/classes/button.hpp> #include <godot_cpp/classes/button.hpp>
#include <godot_cpp/classes/editor_debugger_plugin.hpp> #include <godot_cpp/classes/editor_debugger_plugin.hpp>
#include <godot_cpp/classes/editor_debugger_session.hpp> #include <godot_cpp/classes/editor_debugger_session.hpp>
#include <godot_cpp/classes/editor_spin_slider.hpp>
#include <godot_cpp/classes/h_box_container.hpp> #include <godot_cpp/classes/h_box_container.hpp>
#include <godot_cpp/classes/h_split_container.hpp> #include <godot_cpp/classes/h_split_container.hpp>
#include <godot_cpp/classes/item_list.hpp> #include <godot_cpp/classes/item_list.hpp>
@ -64,6 +66,7 @@ private:
LineEdit *filter_players = nullptr; LineEdit *filter_players = nullptr;
Button *resource_header = nullptr; Button *resource_header = nullptr;
Button *make_floating = nullptr; Button *make_floating = nullptr;
EditorSpinSlider *update_interval = nullptr;
CompatWindowWrapper *window_wrapper = nullptr; CompatWindowWrapper *window_wrapper = nullptr;
void _reset_controls(); void _reset_controls();