diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2020-03-16 09:37:43 +0100 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2020-05-12 15:09:13 +0200 |
commit | d79e28c3021a4410f41a3bbff111d56b28f155ef (patch) | |
tree | 250f03d617692ff4b0e3aaece14fc59126cd3fd0 /editor/debugger | |
parent | ed225faf31c9b3aa47154260aa1a7826d728acc8 (diff) |
Support multiple debug protocols.
Diffstat (limited to 'editor/debugger')
-rw-r--r-- | editor/debugger/editor_debugger_node.cpp | 12 | ||||
-rw-r--r-- | editor/debugger/editor_debugger_node.h | 2 | ||||
-rw-r--r-- | editor/debugger/editor_debugger_server.cpp | 27 | ||||
-rw-r--r-- | editor/debugger/editor_debugger_server.h | 12 | ||||
-rw-r--r-- | editor/debugger/script_editor_debugger.cpp | 2 |
5 files changed, 41 insertions, 14 deletions
diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index 7551214336..5bfb79806e 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -173,7 +173,7 @@ ScriptEditorDebugger *EditorDebuggerNode::get_default_debugger() const { return Object::cast_to<ScriptEditorDebugger>(tabs->get_tab_control(0)); } -Error EditorDebuggerNode::start() { +Error EditorDebuggerNode::start(const String &p_protocol) { stop(); if (EDITOR_GET("run/output/always_open_output_on_play")) { EditorNode::get_singleton()->make_bottom_panel_item_visible(EditorNode::get_log()); @@ -181,7 +181,7 @@ Error EditorDebuggerNode::start() { EditorNode::get_singleton()->make_bottom_panel_item_visible(this); } - server = Ref<EditorDebuggerServer>(EditorDebuggerServer::create_default()); + server = Ref<EditorDebuggerServer>(EditorDebuggerServer::create(p_protocol)); const Error err = server->start(); if (err != OK) { return err; @@ -213,14 +213,6 @@ void EditorDebuggerNode::stop() { void EditorDebuggerNode::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - EditorNode::get_singleton()->connect("play_pressed", callable_mp(this, &EditorDebuggerNode::start)); - EditorNode::get_singleton()->connect("stop_pressed", callable_mp(this, &EditorDebuggerNode::stop)); - } break; - case NOTIFICATION_EXIT_TREE: { - EditorNode::get_singleton()->disconnect("play_pressed", callable_mp(this, &EditorDebuggerNode::start)); - EditorNode::get_singleton()->disconnect("stop_pressed", callable_mp(this, &EditorDebuggerNode::stop)); - } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { if (tabs->get_tab_count() > 1) { add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT)); diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h index 9467442c9a..7546febd05 100644 --- a/editor/debugger/editor_debugger_node.h +++ b/editor/debugger/editor_debugger_node.h @@ -183,7 +183,7 @@ public: void set_camera_override(CameraOverride p_override) { camera_override = p_override; } CameraOverride get_camera_override() { return camera_override; } - Error start(); + Error start(const String &p_protocol = "tcp://"); void stop(); }; diff --git a/editor/debugger/editor_debugger_server.cpp b/editor/debugger/editor_debugger_server.cpp index c80988a662..33f20d9a12 100644 --- a/editor/debugger/editor_debugger_server.cpp +++ b/editor/debugger/editor_debugger_server.cpp @@ -44,6 +44,7 @@ private: Ref<TCP_Server> server; public: + static EditorDebuggerServer *create(const String &p_protocol); virtual void poll() {} virtual Error start(); virtual void stop(); @@ -54,6 +55,11 @@ public: EditorDebuggerServerTCP(); }; +EditorDebuggerServer *EditorDebuggerServerTCP::create(const String &p_protocol) { + ERR_FAIL_COND_V(p_protocol != "tcp://", nullptr); + return memnew(EditorDebuggerServerTCP); +} + EditorDebuggerServerTCP::EditorDebuggerServerTCP() { server.instance(); } @@ -85,6 +91,23 @@ Ref<RemoteDebuggerPeer> EditorDebuggerServerTCP::take_connection() { return memnew(RemoteDebuggerPeerTCP(server->take_connection())); } -EditorDebuggerServer *EditorDebuggerServer::create_default() { - return memnew(EditorDebuggerServerTCP); +/// EditorDebuggerServer +Map<StringName, EditorDebuggerServer::CreateServerFunc> EditorDebuggerServer::protocols; + +EditorDebuggerServer *EditorDebuggerServer::create(const String &p_protocol) { + ERR_FAIL_COND_V(!protocols.has(p_protocol), nullptr); + return protocols[p_protocol](p_protocol); +} + +void EditorDebuggerServer::register_protocol_handler(const String &p_protocol, CreateServerFunc p_func) { + ERR_FAIL_COND(protocols.has(p_protocol)); + protocols[p_protocol] = p_func; +} + +void EditorDebuggerServer::initialize() { + register_protocol_handler("tcp://", EditorDebuggerServerTCP::create); +} + +void EditorDebuggerServer::deinitialize() { + protocols.clear(); } diff --git a/editor/debugger/editor_debugger_server.h b/editor/debugger/editor_debugger_server.h index e9798c90b3..515ffce628 100644 --- a/editor/debugger/editor_debugger_server.h +++ b/editor/debugger/editor_debugger_server.h @@ -37,7 +37,17 @@ class EditorDebuggerServer : public Reference { public: - static EditorDebuggerServer *create_default(); + typedef EditorDebuggerServer *(*CreateServerFunc)(const String &p_uri); + +private: + static Map<StringName, CreateServerFunc> protocols; + +public: + static void initialize(); + static void deinitialize(); + + static void register_protocol_handler(const String &p_protocol, CreateServerFunc p_func); + static EditorDebuggerServer *create(const String &p_protocol); virtual void poll() = 0; virtual Error start() = 0; virtual void stop() = 0; diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index af79de2991..3ed271c7c6 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -846,6 +846,8 @@ void ScriptEditorDebugger::_notification(int p_what) { if (is_session_active()) { + peer->poll(); + if (camera_override == CameraOverride::OVERRIDE_2D) { CanvasItemEditor *editor = CanvasItemEditor::get_singleton(); |