Merge pull request #92 from limbonaut/debugger-multi-session
Support multiple debugger sessions
This commit is contained in:
commit
03de485ebb
|
@ -315,40 +315,41 @@ void LimboDebuggerPlugin::_window_visibility_changed(bool p_visible) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LIMBOAI_MODULE
|
#ifdef LIMBOAI_MODULE
|
||||||
void LimboDebuggerPlugin::setup_session(int p_idx) {
|
void LimboDebuggerPlugin::setup_session(int p_session_id) {
|
||||||
#elif LIMBOAI_GDEXTENSION
|
#elif LIMBOAI_GDEXTENSION
|
||||||
void LimboDebuggerPlugin::_setup_session(int32_t p_idx) {
|
void LimboDebuggerPlugin::_setup_session(int32_t p_session_id) {
|
||||||
#endif
|
#endif
|
||||||
Ref<EditorDebuggerSession> session = get_session(p_idx);
|
Ref<EditorDebuggerSession> session = get_session(p_session_id);
|
||||||
|
ERR_FAIL_COND(session.is_null());
|
||||||
|
|
||||||
if (tab != nullptr) {
|
CompatWindowWrapper *session_window = memnew(CompatWindowWrapper);
|
||||||
tab->queue_free();
|
session_window->set_window_title(vformat(TTR("%s - Godot Engine"), TTR("LimboAI Debugger")));
|
||||||
window_wrapper->queue_free();
|
session_window->set_margins_enabled(true);
|
||||||
}
|
|
||||||
|
|
||||||
window_wrapper = memnew(CompatWindowWrapper);
|
LimboDebuggerTab *tab = memnew(LimboDebuggerTab());
|
||||||
window_wrapper->set_window_title(vformat(TTR("%s - Godot Engine"), TTR("LimboAI Debugger")));
|
tab->setup(session, session_window);
|
||||||
window_wrapper->set_margins_enabled(true);
|
|
||||||
|
|
||||||
tab = memnew(LimboDebuggerTab());
|
|
||||||
tab->setup(session, window_wrapper);
|
|
||||||
tab->set_name("LimboAI");
|
tab->set_name("LimboAI");
|
||||||
window_wrapper->set_wrapped_control(tab);
|
session_window->set_wrapped_control(tab);
|
||||||
window_wrapper->set_name("LimboAI");
|
session_window->set_name("LimboAI");
|
||||||
|
|
||||||
window_wrapper->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
session_window->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||||
window_wrapper->connect(LW_NAME(window_visibility_changed), callable_mp(this, &LimboDebuggerPlugin::_window_visibility_changed));
|
session_window->connect(LW_NAME(window_visibility_changed), callable_mp(this, &LimboDebuggerPlugin::_window_visibility_changed));
|
||||||
|
|
||||||
session->connect(LW_NAME(started), callable_mp(tab, &LimboDebuggerTab::start_session));
|
session->connect(LW_NAME(started), callable_mp(tab, &LimboDebuggerTab::start_session));
|
||||||
session->connect(LW_NAME(stopped), callable_mp(tab, &LimboDebuggerTab::stop_session));
|
session->connect(LW_NAME(stopped), callable_mp(tab, &LimboDebuggerTab::stop_session));
|
||||||
session->add_session_tab(window_wrapper);
|
session->add_session_tab(session_window);
|
||||||
|
|
||||||
|
session_windows[p_session_id] = session_window;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LIMBOAI_MODULE
|
#ifdef LIMBOAI_MODULE
|
||||||
bool LimboDebuggerPlugin::capture(const String &p_message, const Array &p_data, int p_session) {
|
bool LimboDebuggerPlugin::capture(const String &p_message, const Array &p_data, int p_session_id) {
|
||||||
#elif LIMBOAI_GDEXTENSION
|
#elif LIMBOAI_GDEXTENSION
|
||||||
bool LimboDebuggerPlugin::_capture(const String &p_message, const Array &p_data, int32_t p_session) {
|
bool LimboDebuggerPlugin::_capture(const String &p_message, const Array &p_data, int32_t p_session_id) {
|
||||||
#endif
|
#endif
|
||||||
|
ERR_FAIL_COND_V(!session_windows.has(p_session_id), false);
|
||||||
|
LimboDebuggerTab *tab = Object::cast_to<LimboDebuggerTab>(session_windows[p_session_id]->get_wrapped_control());
|
||||||
|
ERR_FAIL_NULL_V(tab, false);
|
||||||
bool captured = true;
|
bool captured = true;
|
||||||
if (p_message == "limboai:active_bt_players") {
|
if (p_message == "limboai:active_bt_players") {
|
||||||
tab->update_active_bt_players(p_data);
|
tab->update_active_bt_players(p_data);
|
||||||
|
@ -371,22 +372,23 @@ bool LimboDebuggerPlugin::_has_capture(const String &p_capture) const {
|
||||||
return p_capture == "limboai";
|
return p_capture == "limboai";
|
||||||
}
|
}
|
||||||
|
|
||||||
CompatWindowWrapper *LimboDebuggerPlugin::get_session_tab() const {
|
CompatWindowWrapper *LimboDebuggerPlugin::get_first_session_window() const {
|
||||||
return window_wrapper;
|
ERR_FAIL_COND_V(session_windows.is_empty(), nullptr);
|
||||||
|
return session_windows.begin()->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LimboDebuggerPlugin::get_session_tab_index() const {
|
int LimboDebuggerPlugin::get_first_session_tab_index() const {
|
||||||
|
ERR_FAIL_COND_V(session_windows.is_empty(), -1);
|
||||||
|
CompatWindowWrapper *window_wrapper = session_windows.begin()->value;
|
||||||
TabContainer *c = Object::cast_to<TabContainer>(window_wrapper->get_parent());
|
TabContainer *c = Object::cast_to<TabContainer>(window_wrapper->get_parent());
|
||||||
ERR_FAIL_COND_V(c == nullptr, -1);
|
ERR_FAIL_COND_V(c == nullptr, -1);
|
||||||
return c->get_tab_idx_from_control(window_wrapper);
|
return c->get_tab_idx_from_control(window_wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LimboDebuggerPlugin::_bind_methods() {
|
void LimboDebuggerPlugin::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("_window_visibility_changed"), &LimboDebuggerPlugin::_window_visibility_changed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LimboDebuggerPlugin::LimboDebuggerPlugin() {
|
LimboDebuggerPlugin::LimboDebuggerPlugin() {
|
||||||
tab = nullptr;
|
|
||||||
singleton = this;
|
singleton = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,9 +99,7 @@ class LimboDebuggerPlugin : public EditorDebuggerPlugin {
|
||||||
private:
|
private:
|
||||||
static LimboDebuggerPlugin *singleton;
|
static LimboDebuggerPlugin *singleton;
|
||||||
|
|
||||||
LimboDebuggerTab *tab = nullptr;
|
HashMap<int, CompatWindowWrapper *> session_windows;
|
||||||
|
|
||||||
CompatWindowWrapper *window_wrapper = nullptr;
|
|
||||||
|
|
||||||
void _window_visibility_changed(bool p_visible);
|
void _window_visibility_changed(bool p_visible);
|
||||||
|
|
||||||
|
@ -112,17 +110,17 @@ public:
|
||||||
static _FORCE_INLINE_ LimboDebuggerPlugin *get_singleton() { return singleton; }
|
static _FORCE_INLINE_ LimboDebuggerPlugin *get_singleton() { return singleton; }
|
||||||
|
|
||||||
#ifdef LIMBOAI_MODULE
|
#ifdef LIMBOAI_MODULE
|
||||||
void setup_session(int p_idx) override;
|
void setup_session(int p_session_id) override;
|
||||||
bool has_capture(const String &p_capture) const override;
|
bool has_capture(const String &p_capture) const override;
|
||||||
bool capture(const String &p_message, const Array &p_data, int p_session) override;
|
bool capture(const String &p_message, const Array &p_data, int p_session_id) override;
|
||||||
#elif LIMBOAI_GDEXTENSION
|
#elif LIMBOAI_GDEXTENSION
|
||||||
void _setup_session(int32_t p_idx) override;
|
void _setup_session(int32_t p_idx) override;
|
||||||
bool _has_capture(const String &p_capture) const override;
|
bool _has_capture(const String &p_capture) const override;
|
||||||
bool _capture(const String &p_message, const Array &p_data, int32_t p_session) override;
|
bool _capture(const String &p_message, const Array &p_data, int32_t p_session_id) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CompatWindowWrapper *get_session_tab() const;
|
CompatWindowWrapper *get_first_session_window() const;
|
||||||
int get_session_tab_index() const;
|
int get_first_session_tab_index() const;
|
||||||
|
|
||||||
LimboDebuggerPlugin();
|
LimboDebuggerPlugin();
|
||||||
~LimboDebuggerPlugin();
|
~LimboDebuggerPlugin();
|
||||||
|
|
|
@ -678,13 +678,13 @@ void LimboAIEditor::_misc_option_selected(int p_id) {
|
||||||
} break;
|
} break;
|
||||||
case MISC_OPEN_DEBUGGER: {
|
case MISC_OPEN_DEBUGGER: {
|
||||||
ERR_FAIL_COND(LimboDebuggerPlugin::get_singleton() == nullptr);
|
ERR_FAIL_COND(LimboDebuggerPlugin::get_singleton() == nullptr);
|
||||||
if (LimboDebuggerPlugin::get_singleton()->get_session_tab()->get_window_enabled()) {
|
if (LimboDebuggerPlugin::get_singleton()->get_first_session_window()->get_window_enabled()) {
|
||||||
LimboDebuggerPlugin::get_singleton()->get_session_tab()->set_window_enabled(true);
|
LimboDebuggerPlugin::get_singleton()->get_first_session_window()->set_window_enabled(true);
|
||||||
} else {
|
} else {
|
||||||
#ifdef LIMBOAI_MODULE
|
#ifdef LIMBOAI_MODULE
|
||||||
EditorNode::get_singleton()->make_bottom_panel_item_visible(EditorDebuggerNode::get_singleton());
|
EditorNode::get_singleton()->make_bottom_panel_item_visible(EditorDebuggerNode::get_singleton());
|
||||||
EditorDebuggerNode::get_singleton()->get_default_debugger()->switch_to_debugger(
|
EditorDebuggerNode::get_singleton()->get_default_debugger()->switch_to_debugger(
|
||||||
LimboDebuggerPlugin::get_singleton()->get_session_tab_index());
|
LimboDebuggerPlugin::get_singleton()->get_first_session_tab_index());
|
||||||
#elif LIMBOAI_GDEXTENSION
|
#elif LIMBOAI_GDEXTENSION
|
||||||
// TODO: Unsure how to switch to debugger pane with GDExtension.
|
// TODO: Unsure how to switch to debugger pane with GDExtension.
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue