diff options
Diffstat (limited to 'editor/debugger')
-rw-r--r-- | editor/debugger/debug_adapter/debug_adapter_server.cpp | 4 | ||||
-rw-r--r-- | editor/debugger/editor_debugger_inspector.cpp | 2 | ||||
-rw-r--r-- | editor/debugger/editor_debugger_node.cpp | 75 | ||||
-rw-r--r-- | editor/debugger/editor_debugger_node.h | 9 | ||||
-rw-r--r-- | editor/debugger/editor_debugger_server.cpp | 4 | ||||
-rw-r--r-- | editor/debugger/editor_debugger_tree.cpp | 32 | ||||
-rw-r--r-- | editor/debugger/editor_debugger_tree.h | 5 | ||||
-rw-r--r-- | editor/debugger/editor_network_profiler.cpp | 197 | ||||
-rw-r--r-- | editor/debugger/editor_network_profiler.h | 72 | ||||
-rw-r--r-- | editor/debugger/editor_performance_profiler.cpp | 1 | ||||
-rw-r--r-- | editor/debugger/editor_profiler.cpp | 2 | ||||
-rw-r--r-- | editor/debugger/editor_visual_profiler.cpp | 2 | ||||
-rw-r--r-- | editor/debugger/script_editor_debugger.cpp | 81 | ||||
-rw-r--r-- | editor/debugger/script_editor_debugger.h | 16 |
14 files changed, 123 insertions, 379 deletions
diff --git a/editor/debugger/debug_adapter/debug_adapter_server.cpp b/editor/debugger/debug_adapter/debug_adapter_server.cpp index 37da64beae..2e2361889d 100644 --- a/editor/debugger/debug_adapter/debug_adapter_server.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_server.cpp @@ -62,8 +62,8 @@ void DebugAdapterServer::_notification(int p_what) { } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - protocol._request_timeout = EditorSettings::get_singleton()->get("network/debug_adapter/request_timeout"); - protocol._sync_breakpoints = EditorSettings::get_singleton()->get("network/debug_adapter/sync_breakpoints"); + protocol._request_timeout = EDITOR_GET("network/debug_adapter/request_timeout"); + protocol._sync_breakpoints = EDITOR_GET("network/debug_adapter/sync_breakpoints"); int port = (int)_EDITOR_GET("network/debug_adapter/remote_port"); if (port != remote_port) { stop(); 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 06b73cf296..49fbaa81bc 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -77,6 +77,7 @@ EditorDebuggerNode::EditorDebuggerNode() { remote_scene_tree = memnew(EditorDebuggerTree); remote_scene_tree->connect("object_selected", callable_mp(this, &EditorDebuggerNode::_remote_object_requested)); remote_scene_tree->connect("save_node", callable_mp(this, &EditorDebuggerNode::_save_node_requested)); + remote_scene_tree->connect("button_clicked", callable_mp(this, &EditorDebuggerNode::_remote_tree_button_pressed)); SceneTreeDock::get_singleton()->add_remote_tree_editor(remote_scene_tree); SceneTreeDock::get_singleton()->connect("remote_tree_selected", callable_mp(this, &EditorDebuggerNode::request_remote_tree)); @@ -118,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); } } @@ -228,6 +229,12 @@ void EditorDebuggerNode::stop() { if (server.is_valid()) { server->stop(); EditorNode::get_log()->add_message("--- Debugging process stopped ---", EditorLog::MSG_TYPE_EDITOR); + + if (EditorNode::get_singleton()->is_movie_maker_enabled()) { + // Request attention in case the user was doing something else when movie recording is finished. + DisplayServer::get_singleton()->window_request_attention(); + } + server.unref(); } // Also close all debugging sessions. @@ -277,7 +284,7 @@ void EditorDebuggerNode::_notification(int p_what) { // Remote scene tree update remote_scene_tree_timeout -= get_process_delta_time(); if (remote_scene_tree_timeout < 0) { - remote_scene_tree_timeout = EditorSettings::get_singleton()->get("debugger/remote_scene_tree_refresh_interval"); + remote_scene_tree_timeout = EDITOR_GET("debugger/remote_scene_tree_refresh_interval"); if (remote_scene_tree->is_visible_in_tree()) { get_current_debugger()->request_remote_tree(); } @@ -286,7 +293,7 @@ void EditorDebuggerNode::_notification(int p_what) { // Remote inspector update inspect_edited_object_timeout -= get_process_delta_time(); if (inspect_edited_object_timeout < 0) { - inspect_edited_object_timeout = EditorSettings::get_singleton()->get("debugger/remote_inspect_refresh_interval"); + inspect_edited_object_timeout = EDITOR_GET("debugger/remote_inspect_refresh_interval"); if (EditorDebuggerRemoteObject *obj = get_inspected_remote_object()) { get_current_debugger()->request_remote_object(obj->remote_object_id); } @@ -313,7 +320,7 @@ void EditorDebuggerNode::_notification(int p_what) { EditorNode::get_singleton()->get_pause_button()->set_disabled(false); // Switch to remote tree view if so desired. - auto_switch_remote_scene_tree = (bool)EditorSettings::get_singleton()->get("debugger/auto_switch_to_remote_scene_tree"); + auto_switch_remote_scene_tree = (bool)EDITOR_GET("debugger/auto_switch_to_remote_scene_tree"); if (auto_switch_remote_scene_tree) { SceneTreeDock::get_singleton()->show_remote_tree(); } @@ -573,6 +580,24 @@ void EditorDebuggerNode::_remote_tree_updated(int p_debugger) { remote_scene_tree->update_scene_tree(get_current_debugger()->get_remote_tree(), p_debugger); } +void EditorDebuggerNode::_remote_tree_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button) { + if (p_button != MouseButton::LEFT) { + return; + } + + TreeItem *item = Object::cast_to<TreeItem>(p_item); + ERR_FAIL_COND(!item); + + if (p_id == EditorDebuggerTree::BUTTON_SUBSCENE) { + remote_scene_tree->emit_signal(SNAME("open"), item->get_meta("scene_file_path")); + } else if (p_id == EditorDebuggerTree::BUTTON_VISIBILITY) { + ObjectID obj_id = item->get_metadata(0); + ERR_FAIL_COND(obj_id.is_null()); + get_current_debugger()->update_remote_object(obj_id, "visible", !item->get_meta("visible")); + get_current_debugger()->request_remote_tree(); + } +} + void EditorDebuggerNode::_remote_object_updated(ObjectID p_id, int p_debugger) { if (p_debugger != tabs->get_current_tab()) { return; @@ -698,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 e79e60b180..259efeb47b 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(); @@ -129,6 +130,7 @@ protected: void _debugger_wants_stop(int p_id); void _debugger_changed(int p_tab); void _remote_tree_updated(int p_debugger); + void _remote_tree_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button); void _remote_object_updated(ObjectID p_id, int p_debugger); void _remote_object_property_updated(ObjectID p_id, const String &p_property, int p_debugger); void _remote_object_requested(ObjectID p_id, int p_debugger); @@ -204,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_debugger_server.cpp b/editor/debugger/editor_debugger_server.cpp index 63390825c6..dba0491cfc 100644 --- a/editor/debugger/editor_debugger_server.cpp +++ b/editor/debugger/editor_debugger_server.cpp @@ -72,8 +72,8 @@ String EditorDebuggerServerTCP::get_uri() const { Error EditorDebuggerServerTCP::start(const String &p_uri) { // Default host and port - String bind_host = (String)EditorSettings::get_singleton()->get("network/debug/remote_host"); - int bind_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port"); + String bind_host = (String)EDITOR_GET("network/debug/remote_host"); + int bind_port = (int)EDITOR_GET("network/debug/remote_port"); // Optionally override if (!p_uri.is_empty() && p_uri != "tcp://") { diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp index 76efcd7190..4168efda26 100644 --- a/editor/debugger/editor_debugger_tree.cpp +++ b/editor/debugger/editor_debugger_tree.cpp @@ -65,6 +65,7 @@ void EditorDebuggerTree::_notification(int p_what) { void EditorDebuggerTree::_bind_methods() { ADD_SIGNAL(MethodInfo("object_selected", PropertyInfo(Variant::INT, "object_id"), PropertyInfo(Variant::INT, "debugger"))); ADD_SIGNAL(MethodInfo("save_node", PropertyInfo(Variant::INT, "object_id"), PropertyInfo(Variant::STRING, "filename"), PropertyInfo(Variant::INT, "debugger"))); + ADD_SIGNAL(MethodInfo("open")); } void EditorDebuggerTree::_scene_tree_selected() { @@ -162,7 +163,7 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int } item->set_metadata(0, node.id); - // Set current item as collapsed if necessary (root is never collapsed) + // Set current item as collapsed if necessary (root is never collapsed). if (parent) { if (!unfold_cache.has(node.id)) { item->set_collapsed(true); @@ -178,7 +179,7 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int } } else { // Must use path if (last_path == _get_path(item)) { - updating_scene_tree = false; // Force emission of new selection + updating_scene_tree = false; // Force emission of new selection. item->select(0); if (filter_changed) { scroll_item = item; @@ -187,6 +188,33 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int } } + // Add buttons. + const Color remote_button_color = Color(1, 1, 1, 0.8); + if (!node.scene_file_path.is_empty()) { + String node_scene_file_path = node.scene_file_path; + Ref<Texture2D> button_icon = get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")); + String tooltip = vformat(TTR("This node has been instantiated from a PackedScene file:\n%s\nClick to open the original file in the Editor."), node_scene_file_path); + + item->set_meta("scene_file_path", node_scene_file_path); + item->add_button(0, button_icon, BUTTON_SUBSCENE, false, tooltip); + item->set_button_color(0, item->get_button_count(0) - 1, remote_button_color); + } + + if (node.view_flags & SceneDebuggerTree::RemoteNode::VIEW_HAS_VISIBLE_METHOD) { + bool node_visible = node.view_flags & SceneDebuggerTree::RemoteNode::VIEW_VISIBLE; + bool node_visible_in_tree = node.view_flags & SceneDebuggerTree::RemoteNode::VIEW_VISIBLE_IN_TREE; + Ref<Texture2D> button_icon = get_theme_icon(node_visible ? SNAME("GuiVisibilityVisible") : SNAME("GuiVisibilityHidden"), SNAME("EditorIcons")); + String tooltip = TTR("Toggle Visibility"); + + item->set_meta("visible", node_visible); + item->add_button(0, button_icon, BUTTON_VISIBILITY, false, tooltip); + if (ClassDB::is_parent_class(node.type_name, "CanvasItem") || ClassDB::is_parent_class(node.type_name, "Node3D")) { + item->set_button_color(0, item->get_button_count(0) - 1, node_visible_in_tree ? remote_button_color : Color(1, 1, 1, 0.6)); + } else { + item->set_button_color(0, item->get_button_count(0) - 1, remote_button_color); + } + } + // Add in front of the parents stack if children are expected. if (node.child_count) { parents.push_front(Pair<TreeItem *, int>(item, node.child_count)); diff --git a/editor/debugger/editor_debugger_tree.h b/editor/debugger/editor_debugger_tree.h index 5af3a0d84a..6d590cdb7a 100644 --- a/editor/debugger/editor_debugger_tree.h +++ b/editor/debugger/editor_debugger_tree.h @@ -65,6 +65,11 @@ protected: void _notification(int p_what); public: + enum Button { + BUTTON_SUBSCENE = 0, + BUTTON_VISIBILITY = 1, + }; + virtual Variant get_drag_data(const Point2 &p_point) override; String get_selected_path(); 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/editor_performance_profiler.cpp b/editor/debugger/editor_performance_profiler.cpp index e2fd462f3a..071eb583c0 100644 --- a/editor/debugger/editor_performance_profiler.cpp +++ b/editor/debugger/editor_performance_profiler.cpp @@ -234,6 +234,7 @@ TreeItem *EditorPerformanceProfiler::_get_monitor_base(const StringName &p_base_ base->set_editable(0, false); base->set_selectable(0, false); base->set_expand_right(0, true); + base->set_custom_font(0, get_theme_font(SNAME("bold"), SNAME("EditorFonts"))); base_map.insert(p_base_name, base); return base; } diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index dfa2b8e70f..35666a5566 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -85,7 +85,7 @@ void EditorProfiler::add_frame_metric(const Metric &p_metric, bool p_final) { } void EditorProfiler::clear() { - int metric_size = EditorSettings::get_singleton()->get("debugger/profiler_frame_history_size"); + int metric_size = EDITOR_GET("debugger/profiler_frame_history_size"); metric_size = CLAMP(metric_size, 60, 10000); frame_metrics.clear(); frame_metrics.resize(metric_size); diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index 8552c8e9ef..b8bc712ba6 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -92,7 +92,7 @@ void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) { } void EditorVisualProfiler::clear() { - int metric_size = EditorSettings::get_singleton()->get("debugger/profiler_frame_history_size"); + int metric_size = EDITOR_GET("debugger/profiler_frame_history_size"); metric_size = CLAMP(metric_size, 60, 10000); frame_metrics.clear(); frame_metrics.resize(metric_size); diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index f1fc1019b9..fd77ad784a 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; @@ -995,7 +965,7 @@ void ScriptEditorDebugger::_profiler_activate(bool p_enable, int p_type) { profiler_signature.clear(); // Add max funcs options to request. Array opts; - int max_funcs = EditorSettings::get_singleton()->get("debugger/profiler_frame_max_functions"); + int max_funcs = EDITOR_GET("debugger/profiler_frame_max_functions"); opts.push_back(CLAMP(max_funcs, 16, 512)); msg_data.push_back(opts); } @@ -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..22d6e48294 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); @@ -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(); |