summaryrefslogtreecommitdiff
path: root/editor/debugger
diff options
context:
space:
mode:
Diffstat (limited to 'editor/debugger')
-rw-r--r--editor/debugger/editor_debugger_inspector.cpp2
-rw-r--r--editor/debugger/editor_debugger_node.cpp50
-rw-r--r--editor/debugger/editor_debugger_node.h10
-rw-r--r--editor/debugger/editor_network_profiler.cpp197
-rw-r--r--editor/debugger/editor_network_profiler.h72
-rw-r--r--editor/debugger/script_editor_debugger.cpp85
-rw-r--r--editor/debugger/script_editor_debugger.h18
7 files changed, 59 insertions, 375 deletions
diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp
index 371aaf8617..c64f23aba0 100644
--- a/editor/debugger/editor_debugger_inspector.cpp
+++ b/editor/debugger/editor_debugger_inspector.cpp
@@ -230,7 +230,7 @@ void EditorDebuggerInspector::add_stack_variable(const Array &p_array) {
Variant v = var.value;
PropertyHint h = PROPERTY_HINT_NONE;
- String hs = String();
+ String hs;
if (v.get_type() == Variant::OBJECT) {
v = Object::cast_to<EncodedObjectAsID>(v)->get_object_id();
diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp
index 68aff328ed..150257a95c 100644
--- a/editor/debugger/editor_debugger_node.cpp
+++ b/editor/debugger/editor_debugger_node.cpp
@@ -119,8 +119,8 @@ ScriptEditorDebugger *EditorDebuggerNode::_add_debugger() {
}
if (!debugger_plugins.is_empty()) {
- for (const Ref<Script> &i : debugger_plugins) {
- node->add_debugger_plugin(i);
+ for (Ref<EditorDebuggerPlugin> plugin : debugger_plugins) {
+ plugin->create_session(node);
}
}
@@ -167,7 +167,7 @@ void EditorDebuggerNode::_text_editor_stack_goto(const ScriptEditorDebugger *p_d
void EditorDebuggerNode::_bind_methods() {
// LiveDebug.
ClassDB::bind_method("live_debug_create_node", &EditorDebuggerNode::live_debug_create_node);
- ClassDB::bind_method("live_debug_instance_node", &EditorDebuggerNode::live_debug_instance_node);
+ ClassDB::bind_method("live_debug_instantiate_node", &EditorDebuggerNode::live_debug_instantiate_node);
ClassDB::bind_method("live_debug_remove_node", &EditorDebuggerNode::live_debug_remove_node);
ClassDB::bind_method("live_debug_remove_and_keep_node", &EditorDebuggerNode::live_debug_remove_and_keep_node);
ClassDB::bind_method("live_debug_restore_node", &EditorDebuggerNode::live_debug_restore_node);
@@ -676,9 +676,9 @@ void EditorDebuggerNode::live_debug_create_node(const NodePath &p_parent, const
});
}
-void EditorDebuggerNode::live_debug_instance_node(const NodePath &p_parent, const String &p_path, const String &p_name) {
+void EditorDebuggerNode::live_debug_instantiate_node(const NodePath &p_parent, const String &p_path, const String &p_name) {
_for_all(tabs, [&](ScriptEditorDebugger *dbg) {
- dbg->live_debug_instance_node(p_parent, p_path, p_name);
+ dbg->live_debug_instantiate_node(p_parent, p_path, p_name);
});
}
@@ -723,22 +723,36 @@ EditorDebuggerNode::CameraOverride EditorDebuggerNode::get_camera_override() {
return camera_override;
}
-void EditorDebuggerNode::add_debugger_plugin(const Ref<Script> &p_script) {
- ERR_FAIL_COND_MSG(debugger_plugins.has(p_script), "Debugger plugin already exists.");
- ERR_FAIL_COND_MSG(p_script.is_null(), "Debugger plugin script is null");
- ERR_FAIL_COND_MSG(p_script->get_instance_base_type() == StringName(), "Debugger plugin script has error.");
- ERR_FAIL_COND_MSG(String(p_script->get_instance_base_type()) != "EditorDebuggerPlugin", "Base type of debugger plugin is not 'EditorDebuggerPlugin'.");
- ERR_FAIL_COND_MSG(!p_script->is_tool(), "Debugger plugin script is not in tool mode.");
- debugger_plugins.insert(p_script);
+void EditorDebuggerNode::add_debugger_plugin(const Ref<EditorDebuggerPlugin> &p_plugin) {
+ ERR_FAIL_COND_MSG(p_plugin.is_null(), "Debugger plugin is null.");
+ ERR_FAIL_COND_MSG(debugger_plugins.has(p_plugin), "Debugger plugin already exists.");
+ debugger_plugins.insert(p_plugin);
+
+ Ref<EditorDebuggerPlugin> plugin = p_plugin;
for (int i = 0; get_debugger(i); i++) {
- get_debugger(i)->add_debugger_plugin(p_script);
+ plugin->create_session(get_debugger(i));
}
}
-void EditorDebuggerNode::remove_debugger_plugin(const Ref<Script> &p_script) {
- ERR_FAIL_COND_MSG(!debugger_plugins.has(p_script), "Debugger plugin doesn't exists.");
- debugger_plugins.erase(p_script);
- for (int i = 0; get_debugger(i); i++) {
- get_debugger(i)->remove_debugger_plugin(p_script);
+void EditorDebuggerNode::remove_debugger_plugin(const Ref<EditorDebuggerPlugin> &p_plugin) {
+ ERR_FAIL_COND_MSG(p_plugin.is_null(), "Debugger plugin is null.");
+ ERR_FAIL_COND_MSG(!debugger_plugins.has(p_plugin), "Debugger plugin doesn't exists.");
+ debugger_plugins.erase(p_plugin);
+ Ref<EditorDebuggerPlugin>(p_plugin)->clear();
+}
+
+bool EditorDebuggerNode::plugins_capture(ScriptEditorDebugger *p_debugger, const String &p_message, const Array &p_data) {
+ int session_index = tabs->get_tab_idx_from_control(p_debugger);
+ ERR_FAIL_COND_V(session_index < 0, false);
+ int colon_index = p_message.find_char(':');
+ ERR_FAIL_COND_V_MSG(colon_index < 1, false, "Invalid message received.");
+
+ const String cap = p_message.substr(0, colon_index);
+ bool parsed = false;
+ for (Ref<EditorDebuggerPlugin> plugin : debugger_plugins) {
+ if (plugin->has_capture(cap)) {
+ parsed |= plugin->capture(p_message, p_data, session_index);
+ }
}
+ return parsed;
}
diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h
index 305f18a652..7f7279ae74 100644
--- a/editor/debugger/editor_debugger_node.h
+++ b/editor/debugger/editor_debugger_node.h
@@ -36,6 +36,7 @@
class Button;
class DebugAdapterParser;
+class EditorDebuggerPlugin;
class EditorDebuggerTree;
class EditorDebuggerRemoteObject;
class MenuButton;
@@ -113,7 +114,7 @@ private:
CameraOverride camera_override = OVERRIDE_NONE;
HashMap<Breakpoint, bool, Breakpoint> breakpoints;
- HashSet<Ref<Script>> debugger_plugins;
+ HashSet<Ref<EditorDebuggerPlugin>> debugger_plugins;
ScriptEditorDebugger *_add_debugger();
EditorDebuggerRemoteObject *get_inspected_remote_object();
@@ -190,7 +191,7 @@ public:
void set_live_debugging(bool p_enabled);
void update_live_edit_root();
void live_debug_create_node(const NodePath &p_parent, const String &p_type, const String &p_name);
- void live_debug_instance_node(const NodePath &p_parent, const String &p_path, const String &p_name);
+ void live_debug_instantiate_node(const NodePath &p_parent, const String &p_path, const String &p_name);
void live_debug_remove_node(const NodePath &p_at);
void live_debug_remove_and_keep_node(const NodePath &p_at, ObjectID p_keep_id);
void live_debug_restore_node(ObjectID p_id, const NodePath &p_at, int p_at_pos);
@@ -205,8 +206,9 @@ public:
Error start(const String &p_uri = "tcp://");
void stop();
- void add_debugger_plugin(const Ref<Script> &p_script);
- void remove_debugger_plugin(const Ref<Script> &p_script);
+ bool plugins_capture(ScriptEditorDebugger *p_debugger, const String &p_message, const Array &p_data);
+ void add_debugger_plugin(const Ref<EditorDebuggerPlugin> &p_plugin);
+ void remove_debugger_plugin(const Ref<EditorDebuggerPlugin> &p_plugin);
};
#endif // EDITOR_DEBUGGER_NODE_H
diff --git a/editor/debugger/editor_network_profiler.cpp b/editor/debugger/editor_network_profiler.cpp
deleted file mode 100644
index 8c18eba71d..0000000000
--- a/editor/debugger/editor_network_profiler.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/*************************************************************************/
-/* editor_network_profiler.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "editor_network_profiler.h"
-
-#include "core/os/os.h"
-#include "editor/editor_scale.h"
-#include "editor/editor_settings.h"
-
-void EditorNetworkProfiler::_bind_methods() {
- ADD_SIGNAL(MethodInfo("enable_profiling", PropertyInfo(Variant::BOOL, "enable")));
-}
-
-void EditorNetworkProfiler::_notification(int p_what) {
- switch (p_what) {
- case NOTIFICATION_ENTER_TREE:
- case NOTIFICATION_THEME_CHANGED: {
- activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")));
- clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")));
- incoming_bandwidth_text->set_right_icon(get_theme_icon(SNAME("ArrowDown"), SNAME("EditorIcons")));
- outgoing_bandwidth_text->set_right_icon(get_theme_icon(SNAME("ArrowUp"), SNAME("EditorIcons")));
-
- // This needs to be done here to set the faded color when the profiler is first opened
- incoming_bandwidth_text->add_theme_color_override("font_uneditable_color", get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, 0.5));
- outgoing_bandwidth_text->add_theme_color_override("font_uneditable_color", get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, 0.5));
- } break;
- }
-}
-
-void EditorNetworkProfiler::_update_frame() {
- counters_display->clear();
-
- TreeItem *root = counters_display->create_item();
-
- for (const KeyValue<ObjectID, SceneDebugger::RPCNodeInfo> &E : nodes_data) {
- TreeItem *node = counters_display->create_item(root);
-
- for (int j = 0; j < counters_display->get_columns(); ++j) {
- node->set_text_alignment(j, j > 0 ? HORIZONTAL_ALIGNMENT_RIGHT : HORIZONTAL_ALIGNMENT_LEFT);
- }
-
- node->set_text(0, E.value.node_path);
- node->set_text(1, E.value.incoming_rpc == 0 ? "-" : itos(E.value.incoming_rpc));
- node->set_text(2, E.value.outgoing_rpc == 0 ? "-" : itos(E.value.outgoing_rpc));
- }
-}
-
-void EditorNetworkProfiler::_activate_pressed() {
- if (activate->is_pressed()) {
- activate->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons")));
- activate->set_text(TTR("Stop"));
- } else {
- activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")));
- activate->set_text(TTR("Start"));
- }
- emit_signal(SNAME("enable_profiling"), activate->is_pressed());
-}
-
-void EditorNetworkProfiler::_clear_pressed() {
- nodes_data.clear();
- set_bandwidth(0, 0);
- if (frame_delay->is_stopped()) {
- frame_delay->set_wait_time(0.1);
- frame_delay->start();
- }
-}
-
-void EditorNetworkProfiler::add_node_frame_data(const SceneDebugger::RPCNodeInfo p_frame) {
- if (!nodes_data.has(p_frame.node)) {
- nodes_data.insert(p_frame.node, p_frame);
- } else {
- nodes_data[p_frame.node].incoming_rpc += p_frame.incoming_rpc;
- nodes_data[p_frame.node].outgoing_rpc += p_frame.outgoing_rpc;
- }
-
- if (frame_delay->is_stopped()) {
- frame_delay->set_wait_time(0.1);
- frame_delay->start();
- }
-}
-
-void EditorNetworkProfiler::set_bandwidth(int p_incoming, int p_outgoing) {
- incoming_bandwidth_text->set_text(vformat(TTR("%s/s"), String::humanize_size(p_incoming)));
- outgoing_bandwidth_text->set_text(vformat(TTR("%s/s"), String::humanize_size(p_outgoing)));
-
- // Make labels more prominent when the bandwidth is greater than 0 to attract user attention
- incoming_bandwidth_text->add_theme_color_override(
- "font_uneditable_color",
- get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, p_incoming > 0 ? 1 : 0.5));
- outgoing_bandwidth_text->add_theme_color_override(
- "font_uneditable_color",
- get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, p_outgoing > 0 ? 1 : 0.5));
-}
-
-bool EditorNetworkProfiler::is_profiling() {
- return activate->is_pressed();
-}
-
-EditorNetworkProfiler::EditorNetworkProfiler() {
- HBoxContainer *hb = memnew(HBoxContainer);
- hb->add_theme_constant_override("separation", 8 * EDSCALE);
- add_child(hb);
-
- activate = memnew(Button);
- activate->set_toggle_mode(true);
- activate->set_text(TTR("Start"));
- activate->connect("pressed", callable_mp(this, &EditorNetworkProfiler::_activate_pressed));
- hb->add_child(activate);
-
- clear_button = memnew(Button);
- clear_button->set_text(TTR("Clear"));
- clear_button->connect("pressed", callable_mp(this, &EditorNetworkProfiler::_clear_pressed));
- hb->add_child(clear_button);
-
- hb->add_spacer();
-
- Label *lb = memnew(Label);
- lb->set_text(TTR("Down"));
- hb->add_child(lb);
-
- incoming_bandwidth_text = memnew(LineEdit);
- incoming_bandwidth_text->set_editable(false);
- incoming_bandwidth_text->set_custom_minimum_size(Size2(120, 0) * EDSCALE);
- incoming_bandwidth_text->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT);
- hb->add_child(incoming_bandwidth_text);
-
- Control *down_up_spacer = memnew(Control);
- down_up_spacer->set_custom_minimum_size(Size2(30, 0) * EDSCALE);
- hb->add_child(down_up_spacer);
-
- lb = memnew(Label);
- lb->set_text(TTR("Up"));
- hb->add_child(lb);
-
- outgoing_bandwidth_text = memnew(LineEdit);
- outgoing_bandwidth_text->set_editable(false);
- outgoing_bandwidth_text->set_custom_minimum_size(Size2(120, 0) * EDSCALE);
- outgoing_bandwidth_text->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT);
- hb->add_child(outgoing_bandwidth_text);
-
- // Set initial texts in the incoming/outgoing bandwidth labels
- set_bandwidth(0, 0);
-
- counters_display = memnew(Tree);
- counters_display->set_custom_minimum_size(Size2(300, 0) * EDSCALE);
- counters_display->set_v_size_flags(SIZE_EXPAND_FILL);
- counters_display->set_hide_folding(true);
- counters_display->set_hide_root(true);
- counters_display->set_columns(3);
- counters_display->set_column_titles_visible(true);
- counters_display->set_column_title(0, TTR("Node"));
- counters_display->set_column_expand(0, true);
- counters_display->set_column_clip_content(0, true);
- counters_display->set_column_custom_minimum_width(0, 60 * EDSCALE);
- counters_display->set_column_title(1, TTR("Incoming RPC"));
- counters_display->set_column_expand(1, false);
- counters_display->set_column_clip_content(1, true);
- counters_display->set_column_custom_minimum_width(1, 120 * EDSCALE);
- counters_display->set_column_title(2, TTR("Outgoing RPC"));
- counters_display->set_column_expand(2, false);
- counters_display->set_column_clip_content(2, true);
- counters_display->set_column_custom_minimum_width(2, 120 * EDSCALE);
- add_child(counters_display);
-
- frame_delay = memnew(Timer);
- frame_delay->set_wait_time(0.1);
- frame_delay->set_one_shot(true);
- add_child(frame_delay);
- frame_delay->connect("timeout", callable_mp(this, &EditorNetworkProfiler::_update_frame));
-}
diff --git a/editor/debugger/editor_network_profiler.h b/editor/debugger/editor_network_profiler.h
deleted file mode 100644
index aea7ce3eec..0000000000
--- a/editor/debugger/editor_network_profiler.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*************************************************************************/
-/* editor_network_profiler.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef EDITOR_NETWORK_PROFILER_H
-#define EDITOR_NETWORK_PROFILER_H
-
-#include "scene/debugger/scene_debugger.h"
-#include "scene/gui/box_container.h"
-#include "scene/gui/button.h"
-#include "scene/gui/label.h"
-#include "scene/gui/split_container.h"
-#include "scene/gui/tree.h"
-
-class EditorNetworkProfiler : public VBoxContainer {
- GDCLASS(EditorNetworkProfiler, VBoxContainer)
-
-private:
- Button *activate = nullptr;
- Button *clear_button = nullptr;
- Tree *counters_display = nullptr;
- LineEdit *incoming_bandwidth_text = nullptr;
- LineEdit *outgoing_bandwidth_text = nullptr;
-
- Timer *frame_delay = nullptr;
-
- HashMap<ObjectID, SceneDebugger::RPCNodeInfo> nodes_data;
-
- void _update_frame();
-
- void _activate_pressed();
- void _clear_pressed();
-
-protected:
- void _notification(int p_what);
- static void _bind_methods();
-
-public:
- void add_node_frame_data(const SceneDebugger::RPCNodeInfo p_frame);
- void set_bandwidth(int p_incoming, int p_outgoing);
- bool is_profiling();
-
- EditorNetworkProfiler();
-};
-
-#endif // EDITOR_NETWORK_PROFILER_H
diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp
index f1f34b8ebb..178010d852 100644
--- a/editor/debugger/script_editor_debugger.cpp
+++ b/editor/debugger/script_editor_debugger.cpp
@@ -37,7 +37,6 @@
#include "core/string/ustring.h"
#include "core/version.h"
#include "editor/debugger/debug_adapter/debug_adapter_protocol.h"
-#include "editor/debugger/editor_network_profiler.h"
#include "editor/debugger/editor_performance_profiler.h"
#include "editor/debugger/editor_profiler.h"
#include "editor/debugger/editor_visual_profiler.h"
@@ -52,6 +51,7 @@
#include "editor/plugins/node_3d_editor_plugin.h"
#include "main/performance.h"
#include "scene/3d/camera_3d.h"
+#include "scene/debugger/scene_debugger.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/label.h"
#include "scene/gui/line_edit.h"
@@ -713,17 +713,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
profiler->add_frame_metric(metric, true);
}
- } else if (p_msg == "multiplayer:rpc") {
- SceneDebugger::RPCProfilerFrame frame;
- frame.deserialize(p_data);
- for (int i = 0; i < frame.infos.size(); i++) {
- network_profiler->add_node_frame_data(frame.infos[i]);
- }
-
- } else if (p_msg == "multiplayer:bandwidth") {
- ERR_FAIL_COND(p_data.size() < 2);
- network_profiler->set_bandwidth(p_data[0], p_data[1]);
-
} else if (p_msg == "request_quit") {
emit_signal(SNAME("stop_requested"));
_stop_and_notify();
@@ -741,22 +730,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
int colon_index = p_msg.find_char(':');
ERR_FAIL_COND_MSG(colon_index < 1, "Invalid message received");
- bool parsed = false;
- const String cap = p_msg.substr(0, colon_index);
- HashMap<StringName, Callable>::Iterator element = captures.find(cap);
- if (element) {
- Callable &c = element->value;
- ERR_FAIL_COND_MSG(c.is_null(), "Invalid callable registered: " + cap);
- Variant cmd = p_msg.substr(colon_index + 1), cmd_data = p_data;
- const Variant *args[2] = { &cmd, &cmd_data };
- Variant retval;
- Callable::CallError err;
- c.callp(args, 2, retval, err);
- ERR_FAIL_COND_MSG(err.error != Callable::CallError::CALL_OK, "Error calling 'capture' to callable: " + Variant::get_callable_error_text(c, args, 2, err));
- ERR_FAIL_COND_MSG(retval.get_type() != Variant::BOOL, "Error calling 'capture' to callable: " + String(c) + ". Return type is not bool.");
- parsed = retval;
- }
-
+ bool parsed = EditorDebuggerNode::get_singleton()->plugins_capture(this, p_msg, p_data);
if (!parsed) {
WARN_PRINT("unknown message " + p_msg);
}
@@ -982,10 +956,6 @@ void ScriptEditorDebugger::_profiler_activate(bool p_enable, int p_type) {
Array msg_data;
msg_data.push_back(p_enable);
switch (p_type) {
- case PROFILER_NETWORK:
- _put_msg("profiler:multiplayer", msg_data);
- _put_msg("profiler:rpc", msg_data);
- break;
case PROFILER_VISUAL:
_put_msg("profiler:visual", msg_data);
break;
@@ -1283,13 +1253,13 @@ void ScriptEditorDebugger::live_debug_create_node(const NodePath &p_parent, cons
}
}
-void ScriptEditorDebugger::live_debug_instance_node(const NodePath &p_parent, const String &p_path, const String &p_name) {
+void ScriptEditorDebugger::live_debug_instantiate_node(const NodePath &p_parent, const String &p_path, const String &p_name) {
if (live_debug) {
Array msg;
msg.push_back(p_parent);
msg.push_back(p_path);
msg.push_back(p_name);
- _put_msg("scene:live_instance_node", msg);
+ _put_msg("scene:live_instantiate_node", msg);
}
}
@@ -1626,7 +1596,7 @@ void ScriptEditorDebugger::_tab_changed(int p_tab) {
void ScriptEditorDebugger::_bind_methods() {
ClassDB::bind_method(D_METHOD("live_debug_create_node"), &ScriptEditorDebugger::live_debug_create_node);
- ClassDB::bind_method(D_METHOD("live_debug_instance_node"), &ScriptEditorDebugger::live_debug_instance_node);
+ ClassDB::bind_method(D_METHOD("live_debug_instantiate_node"), &ScriptEditorDebugger::live_debug_instantiate_node);
ClassDB::bind_method(D_METHOD("live_debug_remove_node"), &ScriptEditorDebugger::live_debug_remove_node);
ClassDB::bind_method(D_METHOD("live_debug_remove_and_keep_node"), &ScriptEditorDebugger::live_debug_remove_and_keep_node);
ClassDB::bind_method(D_METHOD("live_debug_restore_node"), &ScriptEditorDebugger::live_debug_restore_node);
@@ -1658,41 +1628,25 @@ void ScriptEditorDebugger::_bind_methods() {
ADD_SIGNAL(MethodInfo("errors_cleared"));
}
-void ScriptEditorDebugger::add_debugger_plugin(const Ref<Script> &p_script) {
- if (!debugger_plugins.has(p_script)) {
- EditorDebuggerPlugin *plugin = memnew(EditorDebuggerPlugin());
- plugin->attach_debugger(this);
- plugin->set_script(p_script);
- tabs->add_child(plugin);
- debugger_plugins.insert(p_script, plugin);
- }
+void ScriptEditorDebugger::add_debugger_tab(Control *p_control) {
+ tabs->add_child(p_control);
}
-void ScriptEditorDebugger::remove_debugger_plugin(const Ref<Script> &p_script) {
- if (debugger_plugins.has(p_script)) {
- tabs->remove_child(debugger_plugins[p_script]);
- debugger_plugins[p_script]->detach_debugger(false);
- memdelete(debugger_plugins[p_script]);
- debugger_plugins.erase(p_script);
- }
+void ScriptEditorDebugger::remove_debugger_tab(Control *p_control) {
+ int idx = tabs->get_tab_idx_from_control(p_control);
+ ERR_FAIL_COND(idx < 0);
+ p_control->queue_free();
}
void ScriptEditorDebugger::send_message(const String &p_message, const Array &p_args) {
_put_msg(p_message, p_args);
}
-void ScriptEditorDebugger::register_message_capture(const StringName &p_name, const Callable &p_callable) {
- ERR_FAIL_COND_MSG(has_capture(p_name), "Capture already registered: " + p_name);
- captures.insert(p_name, p_callable);
-}
-
-void ScriptEditorDebugger::unregister_message_capture(const StringName &p_name) {
- ERR_FAIL_COND_MSG(!has_capture(p_name), "Capture not registered: " + p_name);
- captures.erase(p_name);
-}
-
-bool ScriptEditorDebugger::has_capture(const StringName &p_name) {
- return captures.has(p_name);
+void ScriptEditorDebugger::toggle_profiler(const String &p_profiler, bool p_enable, const Array &p_data) {
+ Array msg_data;
+ msg_data.push_back(p_enable);
+ msg_data.append_array(p_data);
+ _put_msg("profiler:" + p_profiler, msg_data);
}
ScriptEditorDebugger::ScriptEditorDebugger() {
@@ -1904,13 +1858,6 @@ ScriptEditorDebugger::ScriptEditorDebugger() {
visual_profiler->connect("enable_profiling", callable_mp(this, &ScriptEditorDebugger::_profiler_activate).bind(PROFILER_VISUAL));
}
- { //network profiler
- network_profiler = memnew(EditorNetworkProfiler);
- network_profiler->set_name(TTR("Network Profiler"));
- tabs->add_child(network_profiler);
- network_profiler->connect("enable_profiling", callable_mp(this, &ScriptEditorDebugger::_profiler_activate).bind(PROFILER_NETWORK));
- }
-
{ //monitors
performance_profiler = memnew(EditorPerformanceProfiler);
tabs->add_child(performance_profiler);
diff --git a/editor/debugger/script_editor_debugger.h b/editor/debugger/script_editor_debugger.h
index aa0a50ff03..06bff39053 100644
--- a/editor/debugger/script_editor_debugger.h
+++ b/editor/debugger/script_editor_debugger.h
@@ -50,7 +50,6 @@ class ItemList;
class EditorProfiler;
class EditorFileDialog;
class EditorVisualProfiler;
-class EditorNetworkProfiler;
class EditorPerformanceProfiler;
class SceneDebuggerTree;
class EditorDebuggerPlugin;
@@ -72,7 +71,6 @@ private:
};
enum ProfilerType {
- PROFILER_NETWORK,
PROFILER_VISUAL,
PROFILER_SCRIPTS_SERVERS
};
@@ -151,7 +149,6 @@ private:
EditorProfiler *profiler = nullptr;
EditorVisualProfiler *visual_profiler = nullptr;
- EditorNetworkProfiler *network_profiler = nullptr;
EditorPerformanceProfiler *performance_profiler = nullptr;
OS::ProcessID remote_pid = 0;
@@ -163,10 +160,6 @@ private:
EditorDebuggerNode::CameraOverride camera_override;
- HashMap<Ref<Script>, EditorDebuggerPlugin *> debugger_plugins;
-
- HashMap<StringName, Callable> captures;
-
void _stack_dump_frame_selected();
void _file_selected(const String &p_file);
@@ -266,7 +259,7 @@ public:
void set_live_debugging(bool p_enable);
void live_debug_create_node(const NodePath &p_parent, const String &p_type, const String &p_name);
- void live_debug_instance_node(const NodePath &p_parent, const String &p_path, const String &p_name);
+ void live_debug_instantiate_node(const NodePath &p_parent, const String &p_path, const String &p_name);
void live_debug_remove_node(const NodePath &p_at);
void live_debug_remove_and_keep_node(const NodePath &p_at, ObjectID p_keep_id);
void live_debug_restore_node(ObjectID p_id, const NodePath &p_at, int p_at_pos);
@@ -286,14 +279,11 @@ public:
virtual Size2 get_minimum_size() const override;
- void add_debugger_plugin(const Ref<Script> &p_script);
- void remove_debugger_plugin(const Ref<Script> &p_script);
+ void add_debugger_tab(Control *p_control);
+ void remove_debugger_tab(Control *p_control);
void send_message(const String &p_message, const Array &p_args);
-
- void register_message_capture(const StringName &p_name, const Callable &p_callable);
- void unregister_message_capture(const StringName &p_name);
- bool has_capture(const StringName &p_name);
+ void toggle_profiler(const String &p_profiler, bool p_enable, const Array &p_data);
ScriptEditorDebugger();
~ScriptEditorDebugger();