diff options
author | Chris Cranford <chris@hibernate.org> | 2024-01-02 14:07:10 -0500 |
---|---|---|
committer | Chris Cranford <chris@hibernate.org> | 2024-06-10 19:46:23 -0400 |
commit | 857734050157ec578565f9fe02720eb10e300815 (patch) | |
tree | 9921603241f1c0f49a46bbf7c3a1be05aa0b36a3 /editor | |
parent | 5833f597865c773fae3ee09fc4e31d4a243f812d (diff) | |
download | redot-engine-857734050157ec578565f9fe02720eb10e300815.tar.gz |
Expose several EngineDebugger methods and signals as plugin callbacks
Diffstat (limited to 'editor')
-rw-r--r-- | editor/plugins/editor_debugger_plugin.cpp | 27 | ||||
-rw-r--r-- | editor/plugins/editor_debugger_plugin.h | 12 |
2 files changed, 38 insertions, 1 deletions
diff --git a/editor/plugins/editor_debugger_plugin.cpp b/editor/plugins/editor_debugger_plugin.cpp index c96bec6e7f..fbb389ccb4 100644 --- a/editor/plugins/editor_debugger_plugin.cpp +++ b/editor/plugins/editor_debugger_plugin.cpp @@ -56,6 +56,7 @@ void EditorDebuggerSession::_bind_methods() { ClassDB::bind_method(D_METHOD("is_active"), &EditorDebuggerSession::is_active); ClassDB::bind_method(D_METHOD("add_session_tab", "control"), &EditorDebuggerSession::add_session_tab); ClassDB::bind_method(D_METHOD("remove_session_tab", "control"), &EditorDebuggerSession::remove_session_tab); + ClassDB::bind_method(D_METHOD("set_breakpoint", "path", "line", "enabled"), &EditorDebuggerSession::set_breakpoint); ADD_SIGNAL(MethodInfo("started")); ADD_SIGNAL(MethodInfo("stopped")); @@ -100,6 +101,11 @@ bool EditorDebuggerSession::is_active() { return debugger->is_session_active(); } +void EditorDebuggerSession::set_breakpoint(const String &p_path, int p_line, bool p_enabled) { + ERR_FAIL_NULL_MSG(debugger, "Plugin is not attached to debugger."); + debugger->set_breakpoint(p_path, p_line, p_enabled); +} + void EditorDebuggerSession::detach_debugger() { if (!debugger) { return; @@ -184,10 +190,31 @@ bool EditorDebuggerPlugin::capture(const String &p_message, const Array &p_data, return false; } +void EditorDebuggerPlugin::goto_script_line(const Ref<Script> &p_script, int p_line) { + GDVIRTUAL_CALL(_goto_script_line, p_script, p_line); +} + +void EditorDebuggerPlugin::breakpoints_cleared_in_tree() { + GDVIRTUAL_CALL(_breakpoints_cleared_in_tree); +} + +void EditorDebuggerPlugin::breakpoint_set_in_tree(const Ref<Script> &p_script, int p_line, bool p_enabled) { + GDVIRTUAL_CALL(_breakpoint_set_in_tree, p_script, p_line, p_enabled); +} + void EditorDebuggerPlugin::_bind_methods() { GDVIRTUAL_BIND(_setup_session, "session_id"); GDVIRTUAL_BIND(_has_capture, "capture"); GDVIRTUAL_BIND(_capture, "message", "data", "session_id"); + GDVIRTUAL_BIND(_goto_script_line, "script", "line"); + GDVIRTUAL_BIND(_breakpoints_cleared_in_tree); + GDVIRTUAL_BIND(_breakpoint_set_in_tree, "script", "line", "enabled"); ClassDB::bind_method(D_METHOD("get_session", "id"), &EditorDebuggerPlugin::get_session); ClassDB::bind_method(D_METHOD("get_sessions"), &EditorDebuggerPlugin::get_sessions); } + +EditorDebuggerPlugin::EditorDebuggerPlugin() { + EditorDebuggerNode::get_singleton()->connect("goto_script_line", callable_mp(this, &EditorDebuggerPlugin::goto_script_line)); + EditorDebuggerNode::get_singleton()->connect("breakpoints_cleared_in_tree", callable_mp(this, &EditorDebuggerPlugin::breakpoints_cleared_in_tree)); + EditorDebuggerNode::get_singleton()->connect("breakpoint_set_in_tree", callable_mp(this, &EditorDebuggerPlugin::breakpoint_set_in_tree)); +} diff --git a/editor/plugins/editor_debugger_plugin.h b/editor/plugins/editor_debugger_plugin.h index 41f34f67cf..4f09824d03 100644 --- a/editor/plugins/editor_debugger_plugin.h +++ b/editor/plugins/editor_debugger_plugin.h @@ -62,6 +62,8 @@ public: bool is_debuggable(); bool is_active(); + void set_breakpoint(const String &p_path, int p_line, bool p_enabled); + EditorDebuggerSession(ScriptEditorDebugger *p_debugger); ~EditorDebuggerSession(); }; @@ -90,7 +92,15 @@ public: GDVIRTUAL1RC(bool, _has_capture, const String &); GDVIRTUAL1(_setup_session, int); - EditorDebuggerPlugin() {} + virtual void goto_script_line(const Ref<Script> &p_script, int p_line); + virtual void breakpoints_cleared_in_tree(); + virtual void breakpoint_set_in_tree(const Ref<Script> &p_script, int p_line, bool p_enabled); + + GDVIRTUAL2(_goto_script_line, const Ref<Script> &, int); + GDVIRTUAL0(_breakpoints_cleared_in_tree); + GDVIRTUAL3(_breakpoint_set_in_tree, const Ref<Script> &, int, bool); + + EditorDebuggerPlugin(); ~EditorDebuggerPlugin(); }; |