summaryrefslogtreecommitdiff
path: root/editor/debugger
diff options
context:
space:
mode:
Diffstat (limited to 'editor/debugger')
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_parser.cpp9
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_parser.h4
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_protocol.cpp45
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_protocol.h6
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_server.cpp15
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_server.h4
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_types.h4
-rw-r--r--editor/debugger/editor_debugger_inspector.cpp45
-rw-r--r--editor/debugger/editor_debugger_inspector.h6
-rw-r--r--editor/debugger/editor_debugger_node.cpp241
-rw-r--r--editor/debugger/editor_debugger_node.h9
-rw-r--r--editor/debugger/editor_debugger_server.cpp52
-rw-r--r--editor/debugger/editor_debugger_server.h8
-rw-r--r--editor/debugger/editor_debugger_tree.cpp22
-rw-r--r--editor/debugger/editor_debugger_tree.h4
-rw-r--r--editor/debugger/editor_network_profiler.cpp53
-rw-r--r--editor/debugger/editor_network_profiler.h22
-rw-r--r--editor/debugger/editor_performance_profiler.cpp25
-rw-r--r--editor/debugger/editor_performance_profiler.h10
-rw-r--r--editor/debugger/editor_profiler.cpp28
-rw-r--r--editor/debugger/editor_profiler.h24
-rw-r--r--editor/debugger/editor_visual_profiler.cpp100
-rw-r--r--editor/debugger/editor_visual_profiler.h26
-rw-r--r--editor/debugger/script_editor_debugger.cpp350
-rw-r--r--editor/debugger/script_editor_debugger.h87
25 files changed, 716 insertions, 483 deletions
diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.cpp b/editor/debugger/debug_adapter/debug_adapter_parser.cpp
index 485d58f4a3..e7baeeeded 100644
--- a/editor/debugger/debug_adapter/debug_adapter_parser.cpp
+++ b/editor/debugger/debug_adapter/debug_adapter_parser.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -34,6 +34,7 @@
#include "editor/debugger/script_editor_debugger.h"
#include "editor/editor_node.h"
#include "editor/editor_run_native.h"
+#include "editor/plugins/script_editor_plugin.h"
void DebugAdapterParser::_bind_methods() {
// Requests
@@ -109,7 +110,7 @@ Dictionary DebugAdapterParser::prepare_error_response(const Dictionary &p_params
case DAP::ErrorType::UNKNOWN:
default:
error = "unknown";
- error_desc = "An unknown error has ocurred when processing the request.";
+ error_desc = "An unknown error has occurred when processing the request.";
break;
}
@@ -412,7 +413,7 @@ Dictionary DebugAdapterParser::req_scopes(const Dictionary &p_params) const {
}
Dictionary DebugAdapterParser::req_variables(const Dictionary &p_params) const {
- // If _remaining_vars > 0, the debugee is still sending a stack dump to the editor.
+ // If _remaining_vars > 0, the debuggee is still sending a stack dump to the editor.
if (DebugAdapterProtocol::get_singleton()->_remaining_vars > 0) {
return Dictionary();
}
diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.h b/editor/debugger/debug_adapter/debug_adapter_parser.h
index 4c93464e39..f458151e17 100644
--- a/editor/debugger/debug_adapter/debug_adapter_parser.h
+++ b/editor/debugger/debug_adapter/debug_adapter_parser.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp
index 2e0e6cb7c8..babe8af8bc 100644
--- a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp
+++ b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -192,10 +192,12 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) {
case Variant::VECTOR2I: {
int id = variable_id++;
Vector2 vec = p_var;
+ const String type_scalar = Variant::get_type_name(p_var.get_type() == Variant::VECTOR2 ? Variant::FLOAT : Variant::INT);
DAP::Variable x, y;
x.name = "x";
y.name = "y";
- x.type = y.type = Variant::get_type_name(p_var.get_type() == Variant::VECTOR2 ? Variant::FLOAT : Variant::INT);
+ x.type = type_scalar;
+ y.type = type_scalar;
x.value = rtos(vec.x);
y.value = rtos(vec.y);
@@ -209,12 +211,16 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) {
case Variant::RECT2I: {
int id = variable_id++;
Rect2 rect = p_var;
+ const String type_scalar = Variant::get_type_name(p_var.get_type() == Variant::RECT2 ? Variant::FLOAT : Variant::INT);
DAP::Variable x, y, w, h;
x.name = "x";
y.name = "y";
w.name = "w";
h.name = "h";
- x.type = y.type = w.type = h.type = Variant::get_type_name(p_var.get_type() == Variant::RECT2 ? Variant::FLOAT : Variant::INT);
+ x.type = type_scalar;
+ y.type = type_scalar;
+ w.type = type_scalar;
+ h.type = type_scalar;
x.value = rtos(rect.position.x);
y.value = rtos(rect.position.y);
w.value = rtos(rect.size.x);
@@ -232,11 +238,14 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) {
case Variant::VECTOR3I: {
int id = variable_id++;
Vector3 vec = p_var;
+ const String type_scalar = Variant::get_type_name(p_var.get_type() == Variant::VECTOR3 ? Variant::FLOAT : Variant::INT);
DAP::Variable x, y, z;
x.name = "x";
y.name = "y";
z.name = "z";
- x.type = y.type = z.type = Variant::get_type_name(p_var.get_type() == Variant::VECTOR3 ? Variant::FLOAT : Variant::INT);
+ x.type = type_scalar;
+ y.type = type_scalar;
+ z.type = type_scalar;
x.value = rtos(vec.x);
y.value = rtos(vec.y);
z.value = rtos(vec.z);
@@ -251,11 +260,14 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) {
case Variant::TRANSFORM2D: {
int id = variable_id++;
Transform2D transform = p_var;
+ const String type_vec2 = Variant::get_type_name(Variant::VECTOR2);
DAP::Variable x, y, origin;
x.name = "x";
y.name = "y";
origin.name = "origin";
- x.type = y.type = origin.type = Variant::get_type_name(Variant::VECTOR2);
+ x.type = type_vec2;
+ y.type = type_vec2;
+ origin.type = type_vec2;
x.value = transform.elements[0];
y.value = transform.elements[1];
origin.value = transform.elements[2];
@@ -291,12 +303,16 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) {
case Variant::QUATERNION: {
int id = variable_id++;
Quaternion quat = p_var;
+ const String type_float = Variant::get_type_name(Variant::FLOAT);
DAP::Variable x, y, z, w;
x.name = "x";
y.name = "y";
z.name = "z";
w.name = "w";
- x.type = y.type = z.type = w.type = Variant::get_type_name(Variant::FLOAT);
+ x.type = type_float;
+ y.type = type_float;
+ z.type = type_float;
+ w.type = type_float;
x.value = rtos(quat.x);
y.value = rtos(quat.y);
z.value = rtos(quat.z);
@@ -313,10 +329,12 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) {
case Variant::AABB: {
int id = variable_id++;
AABB aabb = p_var;
+ const String type_vec3 = Variant::get_type_name(Variant::VECTOR3);
DAP::Variable position, size;
position.name = "position";
size.name = "size";
- position.type = size.type = Variant::get_type_name(Variant::VECTOR3);
+ position.type = type_vec3;
+ size.type = type_vec3;
position.value = aabb.position;
size.value = aabb.size;
position.variablesReference = parse_variant(aabb.position);
@@ -331,11 +349,14 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) {
case Variant::BASIS: {
int id = variable_id++;
Basis basis = p_var;
+ const String type_vec2 = Variant::get_type_name(Variant::VECTOR2);
DAP::Variable x, y, z;
x.name = "x";
y.name = "y";
z.name = "z";
- x.type = y.type = z.type = Variant::get_type_name(Variant::VECTOR2);
+ x.type = type_vec2;
+ y.type = type_vec2;
+ z.type = type_vec2;
x.value = basis.elements[0];
y.value = basis.elements[1];
z.value = basis.elements[2];
@@ -372,12 +393,16 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) {
case Variant::COLOR: {
int id = variable_id++;
Color color = p_var;
+ const String type_float = Variant::get_type_name(Variant::FLOAT);
DAP::Variable r, g, b, a;
r.name = "r";
g.name = "g";
b.name = "b";
a.name = "a";
- r.type = g.type = b.type = a.type = Variant::get_type_name(Variant::FLOAT);
+ r.type = type_float;
+ g.type = type_float;
+ b.type = type_float;
+ a.type = type_float;
r.value = rtos(color.r);
g.value = rtos(color.g);
b.value = rtos(color.b);
diff --git a/editor/debugger/debug_adapter/debug_adapter_protocol.h b/editor/debugger/debug_adapter/debug_adapter_protocol.h
index d4291992bf..e4760bea54 100644
--- a/editor/debugger/debug_adapter/debug_adapter_protocol.h
+++ b/editor/debugger/debug_adapter/debug_adapter_protocol.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -76,7 +76,7 @@ class DebugAdapterProtocol : public Object {
private:
static DebugAdapterProtocol *singleton;
- DebugAdapterParser *parser;
+ DebugAdapterParser *parser = nullptr;
List<Ref<DAPeer>> clients;
Ref<TCPServer> server;
diff --git a/editor/debugger/debug_adapter/debug_adapter_server.cpp b/editor/debugger/debug_adapter/debug_adapter_server.cpp
index 4775e2c8b0..e9fc7ec913 100644
--- a/editor/debugger/debug_adapter/debug_adapter_server.cpp
+++ b/editor/debugger/debug_adapter/debug_adapter_server.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -42,12 +42,14 @@ DebugAdapterServer::DebugAdapterServer() {
void DebugAdapterServer::_notification(int p_what) {
switch (p_what) {
- case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_ENTER_TREE: {
start();
- break;
- case NOTIFICATION_EXIT_TREE:
+ } break;
+
+ case NOTIFICATION_EXIT_TREE: {
stop();
- break;
+ } break;
+
case NOTIFICATION_INTERNAL_PROCESS: {
// The main loop can be run again during request processing, which modifies internal state of the protocol.
// Thus, "polling" is needed to prevent it from parsing other requests while the current one isn't finished.
@@ -57,6 +59,7 @@ void DebugAdapterServer::_notification(int p_what) {
polling = false;
}
} 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");
diff --git a/editor/debugger/debug_adapter/debug_adapter_server.h b/editor/debugger/debug_adapter/debug_adapter_server.h
index c449403cc2..a2b01f92c6 100644
--- a/editor/debugger/debug_adapter/debug_adapter_server.h
+++ b/editor/debugger/debug_adapter/debug_adapter_server.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/editor/debugger/debug_adapter/debug_adapter_types.h b/editor/debugger/debug_adapter/debug_adapter_types.h
index 5156c91d14..77b70909b3 100644
--- a/editor/debugger/debug_adapter/debug_adapter_types.h
+++ b/editor/debugger/debug_adapter/debug_adapter_types.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp
index e53f66e72e..936b8ca626 100644
--- a/editor/debugger/editor_debugger_inspector.cpp
+++ b/editor/debugger/editor_debugger_inspector.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -55,9 +55,14 @@ bool EditorDebuggerRemoteObject::_get(const StringName &p_name, Variant &r_ret)
}
void EditorDebuggerRemoteObject::_get_property_list(List<PropertyInfo> *p_list) const {
- p_list->clear(); //sorry, no want category
- for (const PropertyInfo &E : prop_list) {
- p_list->push_back(E);
+ p_list->clear(); // Sorry, no want category.
+ for (const PropertyInfo &prop : prop_list) {
+ if (prop.name == "script") {
+ // Skip the script property, it's always added by the non-virtual method.
+ continue;
+ }
+
+ p_list->push_back(prop);
}
}
@@ -102,14 +107,13 @@ void EditorDebuggerInspector::_bind_methods() {
void EditorDebuggerInspector::_notification(int p_what) {
switch (p_what) {
- case NOTIFICATION_POSTINITIALIZE:
+ case NOTIFICATION_POSTINITIALIZE: {
connect("object_id_selected", callable_mp(this, &EditorDebuggerInspector::_object_selected));
- break;
- case NOTIFICATION_ENTER_TREE:
+ } break;
+
+ case NOTIFICATION_ENTER_TREE: {
edit(variables);
- break;
- default:
- break;
+ } break;
}
}
@@ -150,7 +154,7 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) {
if (pinfo.type == Variant::OBJECT) {
if (var.get_type() == Variant::STRING) {
String path = var;
- if (path.find("::") != -1) {
+ if (path.contains("::")) {
// built-in resource
String base_path = path.get_slice("::", 0);
RES dependency = ResourceLoader::load(base_path);
@@ -202,7 +206,7 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) {
void EditorDebuggerInspector::clear_cache() {
for (const KeyValue<ObjectID, EditorDebuggerRemoteObject *> &E : remote_objects) {
EditorNode *editor = EditorNode::get_singleton();
- if (editor->get_editor_history()->get_current() == E.value->get_instance_id()) {
+ if (editor->get_editor_selection_history()->get_current() == E.value->get_instance_id()) {
editor->push_item(nullptr);
}
memdelete(E.value);
@@ -257,13 +261,26 @@ void EditorDebuggerInspector::add_stack_variable(const Array &p_array) {
variables->prop_values[type + n] = v;
variables->update();
edit(variables);
+
+ // To prevent constantly resizing when using filtering.
+ int size_x = get_size().x;
+ if (size_x > get_custom_minimum_size().x) {
+ set_custom_minimum_size(Size2(size_x, 0));
+ }
}
void EditorDebuggerInspector::clear_stack_variables() {
variables->clear();
variables->update();
+ set_custom_minimum_size(Size2(0, 0));
}
String EditorDebuggerInspector::get_stack_variable(const String &p_var) {
- return variables->get_variant(p_var);
+ for (Map<StringName, Variant>::Element *E = variables->prop_values.front(); E; E = E->next()) {
+ String v = E->key().operator String();
+ if (v.get_slice("/", 1) == p_var) {
+ return variables->get_variant(v);
+ }
+ }
+ return String();
}
diff --git a/editor/debugger/editor_debugger_inspector.h b/editor/debugger/editor_debugger_inspector.h
index 6648c99c03..8f523bfbdc 100644
--- a/editor/debugger/editor_debugger_inspector.h
+++ b/editor/debugger/editor_debugger_inspector.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -70,7 +70,7 @@ private:
ObjectID inspected_object_id;
Map<ObjectID, EditorDebuggerRemoteObject *> remote_objects;
Set<RES> remote_dependencies;
- EditorDebuggerRemoteObject *variables;
+ EditorDebuggerRemoteObject *variables = nullptr;
void _object_selected(ObjectID p_object);
void _object_edited(ObjectID p_id, const String &p_prop, const Variant &p_value);
diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp
index 391839d639..c0685af572 100644
--- a/editor/debugger/editor_debugger_node.cpp
+++ b/editor/debugger/editor_debugger_node.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -36,8 +36,10 @@
#include "editor/editor_node.h"
#include "editor/plugins/editor_debugger_plugin.h"
#include "editor/plugins/script_editor_plugin.h"
+#include "editor/scene_tree_dock.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/tab_container.h"
+#include "scene/resources/packed_scene.h"
template <typename Func>
void _for_all(TabContainer *p_node, const Func &p_func) {
@@ -59,7 +61,6 @@ EditorDebuggerNode::EditorDebuggerNode() {
add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))->get_margin(SIDE_RIGHT));
tabs = memnew(TabContainer);
- tabs->set_tab_align(TabContainer::ALIGN_LEFT);
tabs->set_tabs_visible(false);
tabs->connect("tab_changed", callable_mp(this, &EditorDebuggerNode::_debugger_changed));
add_child(tabs);
@@ -75,8 +76,8 @@ 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));
- EditorNode::get_singleton()->get_scene_tree_dock()->add_remote_tree_editor(remote_scene_tree);
- EditorNode::get_singleton()->get_scene_tree_dock()->connect("remote_tree_selected", callable_mp(this, &EditorDebuggerNode::request_remote_tree));
+ SceneTreeDock::get_singleton()->add_remote_tree_editor(remote_scene_tree);
+ SceneTreeDock::get_singleton()->connect("remote_tree_selected", callable_mp(this, &EditorDebuggerNode::request_remote_tree));
remote_scene_tree_timeout = EDITOR_DEF("debugger/remote_scene_tree_refresh_interval", 1.0);
inspect_edited_object_timeout = EDITOR_DEF("debugger/remote_inspect_refresh_interval", 0.2);
@@ -88,13 +89,14 @@ EditorDebuggerNode::EditorDebuggerNode() {
}
ScriptEditorDebugger *EditorDebuggerNode::_add_debugger() {
- ScriptEditorDebugger *node = memnew(ScriptEditorDebugger(EditorNode::get_singleton()));
+ ScriptEditorDebugger *node = memnew(ScriptEditorDebugger);
int id = tabs->get_tab_count();
node->connect("stop_requested", callable_mp(this, &EditorDebuggerNode::_debugger_wants_stop), varray(id));
node->connect("stopped", callable_mp(this, &EditorDebuggerNode::_debugger_stopped), varray(id));
node->connect("stack_frame_selected", callable_mp(this, &EditorDebuggerNode::_stack_frame_selected), varray(id));
node->connect("error_selected", callable_mp(this, &EditorDebuggerNode::_error_selected), varray(id));
+ node->connect("breakpoint_selected", callable_mp(this, &EditorDebuggerNode::_error_selected), varray(id));
node->connect("clear_execution", callable_mp(this, &EditorDebuggerNode::_clear_execution));
node->connect("breaked", callable_mp(this, &EditorDebuggerNode::_breaked), varray(id));
node->connect("remote_tree_updated", callable_mp(this, &EditorDebuggerNode::_remote_tree_updated), varray(id));
@@ -139,11 +141,22 @@ void EditorDebuggerNode::_error_selected(const String &p_file, int p_line, int p
}
void EditorDebuggerNode::_text_editor_stack_goto(const ScriptEditorDebugger *p_debugger) {
- const String file = p_debugger->get_stack_script_file();
+ String file = p_debugger->get_stack_script_file();
if (file.is_empty()) {
return;
}
- stack_script = ResourceLoader::load(file);
+ if (file.is_resource_file()) {
+ stack_script = ResourceLoader::load(file);
+ } else {
+ // If the script is built-in, it can be opened only if the scene is loaded in memory.
+ int i = file.find("::");
+ int j = file.rfind("(", i);
+ if (j > -1) { // If the script is named, the string is "name (file)", so we need to extract the path.
+ file = file.substr(j + 1, file.find(")", i) - j - 1);
+ }
+ Ref<PackedScene> ps = ResourceLoader::load(file.get_slice("::", 0));
+ stack_script = ResourceLoader::load(file);
+ }
const int line = p_debugger->get_stack_script_line() - 1;
emit_signal(SNAME("goto_script_line"), stack_script, line);
emit_signal(SNAME("set_execution"), stack_script, line);
@@ -168,7 +181,7 @@ void EditorDebuggerNode::_bind_methods() {
}
EditorDebuggerRemoteObject *EditorDebuggerNode::get_inspected_remote_object() {
- return Object::cast_to<EditorDebuggerRemoteObject>(ObjectDB::get_instance(EditorNode::get_singleton()->get_editor_history()->get_current()));
+ return Object::cast_to<EditorDebuggerRemoteObject>(ObjectDB::get_instance(EditorNode::get_singleton()->get_editor_selection_history()->get_current()));
}
ScriptEditorDebugger *EditorDebuggerNode::get_debugger(int p_id) const {
@@ -183,6 +196,11 @@ ScriptEditorDebugger *EditorDebuggerNode::get_default_debugger() const {
return Object::cast_to<ScriptEditorDebugger>(tabs->get_tab_control(0));
}
+String EditorDebuggerNode::get_server_uri() const {
+ ERR_FAIL_COND_V(server.is_null(), "");
+ return server->get_uri();
+}
+
Error EditorDebuggerNode::start(const String &p_uri) {
stop();
ERR_FAIL_COND_V(p_uri.find("://") < 0, ERR_INVALID_PARAMETER);
@@ -233,112 +251,113 @@ void EditorDebuggerNode::_notification(int p_what) {
tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles")));
}
} break;
+
case NOTIFICATION_READY: {
_update_debug_options();
} break;
- default:
- break;
- }
-
- if (p_what != NOTIFICATION_PROCESS || !server.is_valid()) {
- return;
- }
-
- if (!server.is_valid() || !server->is_active()) {
- stop();
- return;
- }
- server->poll();
-
- // Errors and warnings
- int error_count = 0;
- int warning_count = 0;
- _for_all(tabs, [&](ScriptEditorDebugger *dbg) {
- error_count += dbg->get_error_count();
- warning_count += dbg->get_warning_count();
- });
- if (error_count != last_error_count || warning_count != last_warning_count) {
- _for_all(tabs, [&](ScriptEditorDebugger *dbg) {
- dbg->update_tabs();
- });
-
- if (error_count == 0 && warning_count == 0) {
- debugger_button->set_text(TTR("Debugger"));
- debugger_button->remove_theme_color_override("font_color");
- debugger_button->set_icon(Ref<Texture2D>());
- } else {
- debugger_button->set_text(TTR("Debugger") + " (" + itos(error_count + warning_count) + ")");
- if (error_count >= 1 && warning_count >= 1) {
- debugger_button->set_icon(get_theme_icon(SNAME("ErrorWarning"), SNAME("EditorIcons")));
- // Use error color to represent the highest level of severity reported.
- debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
- } else if (error_count >= 1) {
- debugger_button->set_icon(get_theme_icon(SNAME("Error"), SNAME("EditorIcons")));
- debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
- } else {
- debugger_button->set_icon(get_theme_icon(SNAME("Warning"), SNAME("EditorIcons")));
- debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+ case NOTIFICATION_PROCESS: {
+ if (!server.is_valid()) {
+ return;
}
- }
- last_error_count = error_count;
- last_warning_count = warning_count;
- }
-
- // 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");
- if (remote_scene_tree->is_visible_in_tree()) {
- get_current_debugger()->request_remote_tree();
- }
- }
-
- // 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");
- if (EditorDebuggerRemoteObject *obj = get_inspected_remote_object()) {
- get_current_debugger()->request_remote_object(obj->remote_object_id);
- }
- }
- // Take connections.
- if (server->is_connection_available()) {
- ScriptEditorDebugger *debugger = nullptr;
- _for_all(tabs, [&](ScriptEditorDebugger *dbg) {
- if (debugger || dbg->is_session_active()) {
+ if (!server->is_active()) {
+ stop();
return;
}
- debugger = dbg;
- });
- if (debugger == nullptr) {
- if (tabs->get_tab_count() <= 4) { // Max 4 debugging sessions active.
- debugger = _add_debugger();
- } else {
- // We already have too many sessions, disconnecting new clients to prevent them from hanging.
- server->take_connection()->close();
- return; // Can't add, stop here.
+ server->poll();
+
+ // Errors and warnings
+ int error_count = 0;
+ int warning_count = 0;
+ _for_all(tabs, [&](ScriptEditorDebugger *dbg) {
+ error_count += dbg->get_error_count();
+ warning_count += dbg->get_warning_count();
+ });
+
+ if (error_count != last_error_count || warning_count != last_warning_count) {
+ _for_all(tabs, [&](ScriptEditorDebugger *dbg) {
+ dbg->update_tabs();
+ });
+
+ if (error_count == 0 && warning_count == 0) {
+ debugger_button->set_text(TTR("Debugger"));
+ debugger_button->remove_theme_color_override("font_color");
+ debugger_button->set_icon(Ref<Texture2D>());
+ } else {
+ debugger_button->set_text(TTR("Debugger") + " (" + itos(error_count + warning_count) + ")");
+ if (error_count >= 1 && warning_count >= 1) {
+ debugger_button->set_icon(get_theme_icon(SNAME("ErrorWarning"), SNAME("EditorIcons")));
+ // Use error color to represent the highest level of severity reported.
+ debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ } else if (error_count >= 1) {
+ debugger_button->set_icon(get_theme_icon(SNAME("Error"), SNAME("EditorIcons")));
+ debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ } else {
+ debugger_button->set_icon(get_theme_icon(SNAME("Warning"), SNAME("EditorIcons")));
+ debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+ }
+ }
+ last_error_count = error_count;
+ last_warning_count = warning_count;
}
- }
- 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");
- if (auto_switch_remote_scene_tree) {
- EditorNode::get_singleton()->get_scene_tree_dock()->show_remote_tree();
- }
- // Good to go.
- EditorNode::get_singleton()->get_scene_tree_dock()->show_tab_buttons();
- debugger->set_editor_remote_tree(remote_scene_tree);
- debugger->start(server->take_connection());
- // Send breakpoints.
- for (const KeyValue<Breakpoint, bool> &E : breakpoints) {
- const Breakpoint &bp = E.key;
- debugger->set_breakpoint(bp.source, bp.line, E.value);
- } // Will arrive too late, how does the regular run work?
+ // 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");
+ if (remote_scene_tree->is_visible_in_tree()) {
+ get_current_debugger()->request_remote_tree();
+ }
+ }
- debugger->update_live_edit_root();
+ // 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");
+ if (EditorDebuggerRemoteObject *obj = get_inspected_remote_object()) {
+ get_current_debugger()->request_remote_object(obj->remote_object_id);
+ }
+ }
+
+ // Take connections.
+ if (server->is_connection_available()) {
+ ScriptEditorDebugger *debugger = nullptr;
+ _for_all(tabs, [&](ScriptEditorDebugger *dbg) {
+ if (debugger || dbg->is_session_active()) {
+ return;
+ }
+ debugger = dbg;
+ });
+ if (debugger == nullptr) {
+ if (tabs->get_tab_count() <= 4) { // Max 4 debugging sessions active.
+ debugger = _add_debugger();
+ } else {
+ // We already have too many sessions, disconnecting new clients to prevent them from hanging.
+ server->take_connection()->close();
+ return; // Can't add, stop here.
+ }
+ }
+
+ 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");
+ if (auto_switch_remote_scene_tree) {
+ SceneTreeDock::get_singleton()->show_remote_tree();
+ }
+ // Good to go.
+ SceneTreeDock::get_singleton()->show_tab_buttons();
+ debugger->set_editor_remote_tree(remote_scene_tree);
+ debugger->start(server->take_connection());
+ // Send breakpoints.
+ for (const KeyValue<Breakpoint, bool> &E : breakpoints) {
+ const Breakpoint &bp = E.key;
+ debugger->set_breakpoint(bp.source, bp.line, E.value);
+ } // Will arrive too late, how does the regular run work?
+
+ debugger->update_live_edit_root();
+ }
+ } break;
}
}
@@ -355,8 +374,8 @@ void EditorDebuggerNode::_debugger_stopped(int p_id) {
if (!found) {
EditorNode::get_singleton()->get_pause_button()->set_pressed(false);
EditorNode::get_singleton()->get_pause_button()->set_disabled(true);
- EditorNode::get_singleton()->get_scene_tree_dock()->hide_remote_tree();
- EditorNode::get_singleton()->get_scene_tree_dock()->hide_tab_buttons();
+ SceneTreeDock::get_singleton()->hide_remote_tree();
+ SceneTreeDock::get_singleton()->hide_tab_buttons();
EditorNode::get_singleton()->notify_all_debug_sessions_exited();
}
}
@@ -494,7 +513,7 @@ void EditorDebuggerNode::set_breakpoint(const String &p_path, int p_line, bool p
dbg->set_breakpoint(p_path, p_line, p_enabled);
});
- emit_signal("breakpoint_toggled", p_path, p_line, p_enabled);
+ emit_signal(SNAME("breakpoint_toggled"), p_path, p_line, p_enabled);
}
void EditorDebuggerNode::set_breakpoints(const String &p_path, Array p_lines) {
@@ -570,7 +589,7 @@ void EditorDebuggerNode::_remote_object_property_updated(ObjectID p_id, const St
if (obj->remote_object_id != p_id) {
return;
}
- EditorNode::get_singleton()->get_inspector()->update_property(p_property);
+ InspectorDock::get_inspector_singleton()->update_property(p_property);
}
}
@@ -590,12 +609,12 @@ void EditorDebuggerNode::_save_node_requested(ObjectID p_id, const String &p_fil
}
// Remote inspector/edit.
-void EditorDebuggerNode::_method_changeds(void *p_ud, Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE) {
+void EditorDebuggerNode::_method_changeds(void *p_ud, Object *p_base, const StringName &p_name, const Variant **p_args, int p_argcount) {
if (!singleton) {
return;
}
_for_all(singleton->tabs, [&](ScriptEditorDebugger *dbg) {
- dbg->_method_changed(p_base, p_name, VARIANT_ARG_PASS);
+ dbg->_method_changed(p_base, p_name, p_args, p_argcount);
});
}
@@ -677,7 +696,7 @@ EditorDebuggerNode::CameraOverride EditorDebuggerNode::get_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(String(p_script->get_instance_base_type()) == "", "Debugger plugin script has error.");
+ 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);
diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h
index 4d9e846834..36f99113ad 100644
--- a/editor/debugger/editor_debugger_node.h
+++ b/editor/debugger/editor_debugger_node.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -171,7 +171,7 @@ public:
// Remote inspector/edit.
void request_remote_tree();
- static void _method_changeds(void *p_ud, Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE);
+ static void _method_changeds(void *p_ud, Object *p_base, const StringName &p_name, const Variant **p_args, int p_argcount);
static void _property_changeds(void *p_ud, Object *p_base, const StringName &p_property, const Variant &p_value);
// LiveDebug
@@ -188,8 +188,9 @@ public:
void set_camera_override(CameraOverride p_override);
CameraOverride get_camera_override();
- Error start(const String &p_uri = "tcp://");
+ String get_server_uri() const;
+ Error start(const String &p_uri = "tcp://");
void stop();
void add_debugger_plugin(const Ref<Script> &p_script);
diff --git a/editor/debugger/editor_debugger_server.cpp b/editor/debugger/editor_debugger_server.cpp
index 8c3833af50..bce131a5fe 100644
--- a/editor/debugger/editor_debugger_server.cpp
+++ b/editor/debugger/editor_debugger_server.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -41,15 +41,18 @@
class EditorDebuggerServerTCP : public EditorDebuggerServer {
private:
Ref<TCPServer> server;
+ String endpoint;
public:
static EditorDebuggerServer *create(const String &p_protocol);
- virtual void poll() {}
- virtual Error start(const String &p_uri);
- virtual void stop();
- virtual bool is_active() const;
- virtual bool is_connection_available() const;
- virtual Ref<RemoteDebuggerPeer> take_connection();
+
+ virtual void poll() override {}
+ virtual String get_uri() const override;
+ virtual Error start(const String &p_uri) override;
+ virtual void stop() override;
+ virtual bool is_active() const override;
+ virtual bool is_connection_available() const override;
+ virtual Ref<RemoteDebuggerPeer> take_connection() override;
EditorDebuggerServerTCP();
};
@@ -63,21 +66,42 @@ EditorDebuggerServerTCP::EditorDebuggerServerTCP() {
server.instantiate();
}
+String EditorDebuggerServerTCP::get_uri() const {
+ return endpoint;
+}
+
Error EditorDebuggerServerTCP::start(const String &p_uri) {
- int bind_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
+ // 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");
+
+ // Optionally override
if (!p_uri.is_empty() && p_uri != "tcp://") {
String scheme, path;
Error err = p_uri.parse_url(scheme, bind_host, bind_port, path);
ERR_FAIL_COND_V(err != OK, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(!bind_host.is_valid_ip_address() && bind_host != "*", ERR_INVALID_PARAMETER);
}
- const Error err = server->listen(bind_port, bind_host);
- if (err != OK) {
- EditorNode::get_log()->add_message(String("Error listening on port ") + itos(bind_port), EditorLog::MSG_TYPE_ERROR);
- return err;
+
+ // Try listening on ports
+ const int max_attempts = 5;
+ for (int attempt = 1;; ++attempt) {
+ const Error err = server->listen(bind_port, bind_host);
+ if (err == OK) {
+ break;
+ }
+ if (attempt >= max_attempts) {
+ EditorNode::get_log()->add_message(vformat("Cannot listen on port %d, remote debugging unavailable.", bind_port), EditorLog::MSG_TYPE_ERROR);
+ return err;
+ }
+ int last_port = bind_port++;
+ EditorNode::get_log()->add_message(vformat("Cannot listen on port %d, trying %d instead.", last_port, bind_port), EditorLog::MSG_TYPE_WARNING);
}
- return err;
+
+ // Endpoint that the client should connect to
+ endpoint = vformat("tcp://%s:%d", bind_host, bind_port);
+
+ return OK;
}
void EditorDebuggerServerTCP::stop() {
diff --git a/editor/debugger/editor_debugger_server.h b/editor/debugger/editor_debugger_server.h
index 844d1a9e5a..bda4a1ce7d 100644
--- a/editor/debugger/editor_debugger_server.h
+++ b/editor/debugger/editor_debugger_server.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -47,8 +47,10 @@ public:
static void register_protocol_handler(const String &p_protocol, CreateServerFunc p_func);
static EditorDebuggerServer *create(const String &p_protocol);
+
+ virtual String get_uri() const = 0;
virtual void poll() = 0;
- virtual Error start(const String &p_uri = "") = 0;
+ virtual Error start(const String &p_uri) = 0;
virtual void stop() = 0;
virtual bool is_active() const = 0;
virtual bool is_connection_available() const = 0;
diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp
index 1feab98948..3a65d015d5 100644
--- a/editor/debugger/editor_debugger_tree.cpp
+++ b/editor/debugger/editor_debugger_tree.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -30,7 +30,9 @@
#include "editor_debugger_tree.h"
+#include "editor/editor_file_dialog.h"
#include "editor/editor_node.h"
+#include "editor/scene_tree_dock.h"
#include "scene/debugger/scene_debugger.h"
#include "scene/resources/packed_scene.h"
#include "servers/display_server.h"
@@ -51,10 +53,12 @@ EditorDebuggerTree::EditorDebuggerTree() {
}
void EditorDebuggerTree::_notification(int p_what) {
- if (p_what == NOTIFICATION_POSTINITIALIZE) {
- connect("cell_selected", callable_mp(this, &EditorDebuggerTree::_scene_tree_selected));
- connect("item_collapsed", callable_mp(this, &EditorDebuggerTree::_scene_tree_folded));
- connect("item_rmb_selected", callable_mp(this, &EditorDebuggerTree::_scene_tree_rmb_selected));
+ switch (p_what) {
+ case NOTIFICATION_POSTINITIALIZE: {
+ connect("cell_selected", callable_mp(this, &EditorDebuggerTree::_scene_tree_selected));
+ connect("item_collapsed", callable_mp(this, &EditorDebuggerTree::_scene_tree_folded));
+ connect("item_rmb_selected", callable_mp(this, &EditorDebuggerTree::_scene_tree_rmb_selected));
+ } break;
}
}
@@ -107,7 +111,7 @@ void EditorDebuggerTree::_scene_tree_rmb_selected(const Vector2 &p_position) {
item_menu->clear();
item_menu->add_icon_item(get_theme_icon(SNAME("CreateNewSceneFrom"), SNAME("EditorIcons")), TTR("Save Branch as Scene"), ITEM_MENU_SAVE_REMOTE_NODE);
item_menu->add_icon_item(get_theme_icon(SNAME("CopyNodePath"), SNAME("EditorIcons")), TTR("Copy Node Path"), ITEM_MENU_COPY_NODE_PATH);
- item_menu->set_position(get_screen_transform().xform(get_local_mouse_position()));
+ item_menu->set_position(get_screen_position() + get_local_mouse_position());
item_menu->popup();
}
@@ -128,7 +132,7 @@ void EditorDebuggerTree::_scene_tree_rmb_selected(const Vector2 &p_position) {
void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int p_debugger) {
updating_scene_tree = true;
const String last_path = get_selected_path();
- const String filter = EditorNode::get_singleton()->get_scene_tree_dock()->get_filter();
+ const String filter = SceneTreeDock::get_singleton()->get_filter();
bool filter_changed = filter != last_filter;
TreeItem *scroll_item = nullptr;
@@ -186,7 +190,7 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int
// Apply filters.
while (parent) {
const bool had_siblings = item->get_prev() || item->get_next();
- if (filter.is_subsequence_ofi(item->get_text(0))) {
+ if (filter.is_subsequence_ofn(item->get_text(0))) {
break; // Filter matches, must survive.
}
parent->remove_child(item);
diff --git a/editor/debugger/editor_debugger_tree.h b/editor/debugger/editor_debugger_tree.h
index 13193344f1..58af52b01f 100644
--- a/editor/debugger/editor_debugger_tree.h
+++ b/editor/debugger/editor_debugger_tree.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/editor/debugger/editor_network_profiler.cpp b/editor/debugger/editor_network_profiler.cpp
index d4385630be..8c18eba71d 100644
--- a/editor/debugger/editor_network_profiler.cpp
+++ b/editor/debugger/editor_network_profiler.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -39,15 +39,18 @@ void EditorNetworkProfiler::_bind_methods() {
}
void EditorNetworkProfiler::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == 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));
+ 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;
}
}
@@ -56,18 +59,16 @@ void EditorNetworkProfiler::_update_frame() {
TreeItem *root = counters_display->create_item();
- for (const KeyValue<ObjectID, DebuggerMarshalls::MultiplayerNodeInfo> &E : nodes_data) {
+ 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_align(j, j > 0 ? TreeItem::ALIGN_RIGHT : TreeItem::ALIGN_LEFT);
+ 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.incoming_rset == 0 ? "-" : itos(E.value.incoming_rset));
- node->set_text(3, E.value.outgoing_rpc == 0 ? "-" : itos(E.value.outgoing_rpc));
- node->set_text(4, E.value.outgoing_rset == 0 ? "-" : itos(E.value.outgoing_rset));
+ node->set_text(2, E.value.outgoing_rpc == 0 ? "-" : itos(E.value.outgoing_rpc));
}
}
@@ -91,14 +92,12 @@ void EditorNetworkProfiler::_clear_pressed() {
}
}
-void EditorNetworkProfiler::add_node_frame_data(const DebuggerMarshalls::MultiplayerNodeInfo p_frame) {
+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].incoming_rset += p_frame.incoming_rset;
nodes_data[p_frame.node].outgoing_rpc += p_frame.outgoing_rpc;
- nodes_data[p_frame.node].outgoing_rset += p_frame.outgoing_rset;
}
if (frame_delay->is_stopped()) {
@@ -149,7 +148,7 @@ EditorNetworkProfiler::EditorNetworkProfiler() {
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_align(LineEdit::Align::ALIGN_RIGHT);
+ incoming_bandwidth_text->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT);
hb->add_child(incoming_bandwidth_text);
Control *down_up_spacer = memnew(Control);
@@ -163,7 +162,7 @@ EditorNetworkProfiler::EditorNetworkProfiler() {
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_align(LineEdit::Align::ALIGN_RIGHT);
+ outgoing_bandwidth_text->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT);
hb->add_child(outgoing_bandwidth_text);
// Set initial texts in the incoming/outgoing bandwidth labels
@@ -174,7 +173,7 @@ EditorNetworkProfiler::EditorNetworkProfiler() {
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(5);
+ 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);
@@ -184,18 +183,10 @@ EditorNetworkProfiler::EditorNetworkProfiler() {
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("Incoming RSET"));
+ 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);
- counters_display->set_column_title(3, TTR("Outgoing RPC"));
- counters_display->set_column_expand(3, false);
- counters_display->set_column_clip_content(3, true);
- counters_display->set_column_custom_minimum_width(3, 120 * EDSCALE);
- counters_display->set_column_title(4, TTR("Outgoing RSET"));
- counters_display->set_column_expand(4, false);
- counters_display->set_column_clip_content(4, true);
- counters_display->set_column_custom_minimum_width(4, 120 * EDSCALE);
add_child(counters_display);
frame_delay = memnew(Timer);
diff --git a/editor/debugger/editor_network_profiler.h b/editor/debugger/editor_network_profiler.h
index 8c1da1cb2d..3a604f5564 100644
--- a/editor/debugger/editor_network_profiler.h
+++ b/editor/debugger/editor_network_profiler.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -31,7 +31,7 @@
#ifndef EDITORNETWORKPROFILER_H
#define EDITORNETWORKPROFILER_H
-#include "core/debugger/debugger_marshalls.h"
+#include "scene/debugger/scene_debugger.h"
#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
#include "scene/gui/label.h"
@@ -42,15 +42,15 @@ class EditorNetworkProfiler : public VBoxContainer {
GDCLASS(EditorNetworkProfiler, VBoxContainer)
private:
- Button *activate;
- Button *clear_button;
- Tree *counters_display;
- LineEdit *incoming_bandwidth_text;
- LineEdit *outgoing_bandwidth_text;
+ Button *activate = nullptr;
+ Button *clear_button = nullptr;
+ Tree *counters_display = nullptr;
+ LineEdit *incoming_bandwidth_text = nullptr;
+ LineEdit *outgoing_bandwidth_text = nullptr;
- Timer *frame_delay;
+ Timer *frame_delay = nullptr;
- Map<ObjectID, DebuggerMarshalls::MultiplayerNodeInfo> nodes_data;
+ Map<ObjectID, SceneDebugger::RPCNodeInfo> nodes_data;
void _update_frame();
@@ -62,7 +62,7 @@ protected:
static void _bind_methods();
public:
- void add_node_frame_data(const DebuggerMarshalls::MultiplayerNodeInfo p_frame);
+ void add_node_frame_data(const SceneDebugger::RPCNodeInfo p_frame);
void set_bandwidth(int p_incoming, int p_outgoing);
bool is_profiling();
diff --git a/editor/debugger/editor_performance_profiler.cpp b/editor/debugger/editor_performance_profiler.cpp
index 08ed675d16..c821561ca6 100644
--- a/editor/debugger/editor_performance_profiler.cpp
+++ b/editor/debugger/editor_performance_profiler.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -30,6 +30,7 @@
#include "editor_performance_profiler.h"
+#include "editor/editor_property_name_processor.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "main/performance.h"
@@ -132,14 +133,14 @@ void EditorPerformanceProfiler::_monitor_draw() {
rect.size -= graph_style_box->get_minimum_size();
Color draw_color = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
draw_color.set_hsv(Math::fmod(hue_shift * float(current.frame_index), 0.9f), draw_color.get_s() * 0.9f, draw_color.get_v() * value_multiplier, 0.6f);
- monitor_draw->draw_string(graph_font, rect.position + Point2(0, graph_font->get_ascent(font_size)), current.item->get_text(0), HALIGN_LEFT, rect.size.x, font_size, draw_color);
+ monitor_draw->draw_string(graph_font, rect.position + Point2(0, graph_font->get_ascent(font_size)), current.item->get_text(0), HORIZONTAL_ALIGNMENT_LEFT, rect.size.x, font_size, draw_color);
draw_color.a = 0.9f;
float value_position = rect.size.width - graph_font->get_string_size(current.item->get_text(1), font_size).width;
if (value_position < 0) {
value_position = 0;
}
- monitor_draw->draw_string(graph_font, rect.position + Point2(value_position, graph_font->get_ascent(font_size)), current.item->get_text(1), HALIGN_LEFT, rect.size.x, font_size, draw_color);
+ monitor_draw->draw_string(graph_font, rect.position + Point2(value_position, graph_font->get_ascent(font_size)), current.item->get_text(1), HORIZONTAL_ALIGNMENT_LEFT, rect.size.x, font_size, draw_color);
rect.position.y += graph_font->get_height(font_size);
rect.size.height -= graph_font->get_height(font_size);
@@ -152,12 +153,12 @@ void EditorPerformanceProfiler::_monitor_draw() {
Color horizontal_line_color;
horizontal_line_color.set_hsv(draw_color.get_h(), draw_color.get_s() * 0.5f, draw_color.get_v() * 0.5f, 0.3f);
monitor_draw->draw_line(rect.position, rect.position + Vector2(rect.size.width, 0), horizontal_line_color, Math::round(EDSCALE));
- monitor_draw->draw_string(graph_font, rect.position + Vector2(0, graph_font->get_ascent(font_size)), _create_label(current.max, current.type), HALIGN_LEFT, rect.size.width, font_size, horizontal_line_color);
+ monitor_draw->draw_string(graph_font, rect.position + Vector2(0, graph_font->get_ascent(font_size)), _create_label(current.max, current.type), HORIZONTAL_ALIGNMENT_LEFT, rect.size.width, font_size, horizontal_line_color);
for (int j = 0; j < line_count; j++) {
Vector2 y_offset = Vector2(0, rect.size.height * (1.0f - float(j) / float(line_count)));
monitor_draw->draw_line(rect.position + y_offset, rect.position + Vector2(rect.size.width, 0) + y_offset, horizontal_line_color, Math::round(EDSCALE));
- monitor_draw->draw_string(graph_font, rect.position - Vector2(0, graph_font->get_descent(font_size)) + y_offset, _create_label(current.max * float(j) / float(line_count), current.type), HALIGN_LEFT, rect.size.width, font_size, horizontal_line_color);
+ monitor_draw->draw_string(graph_font, rect.position - Vector2(0, graph_font->get_descent(font_size)) + y_offset, _create_label(current.max * float(j) / float(line_count), current.type), HORIZONTAL_ALIGNMENT_LEFT, rect.size.width, font_size, horizontal_line_color);
}
}
@@ -191,7 +192,7 @@ void EditorPerformanceProfiler::_monitor_draw() {
if (text_top_left_position.y < 0) {
text_top_left_position.y = h2 + MARKER_MARGIN;
}
- monitor_draw->draw_string(graph_font, rect.position + text_top_left_position + Point2(0, graph_font->get_ascent(font_size)), label, HALIGN_LEFT, rect.size.x, font_size, line_color);
+ monitor_draw->draw_string(graph_font, rect.position + text_top_left_position + Point2(0, graph_font->get_ascent(font_size)), label, HORIZONTAL_ALIGNMENT_LEFT, rect.size.x, font_size, line_color);
}
prev = h2;
e = e->next();
@@ -249,7 +250,7 @@ TreeItem *EditorPerformanceProfiler::_create_monitor_item(const StringName &p_mo
void EditorPerformanceProfiler::_marker_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
+ if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
Vector<StringName> active;
for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) {
if (i.value().item->is_checked(0)) {
@@ -378,16 +379,16 @@ EditorPerformanceProfiler::EditorPerformanceProfiler() {
info_message = memnew(Label);
info_message->set_text(TTR("Pick one or more items from the list to display the graph."));
- info_message->set_valign(Label::VALIGN_CENTER);
- info_message->set_align(Label::ALIGN_CENTER);
+ info_message->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
+ info_message->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
info_message->set_autowrap_mode(Label::AUTOWRAP_WORD_SMART);
info_message->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
info_message->set_anchors_and_offsets_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE);
monitor_draw->add_child(info_message);
for (int i = 0; i < Performance::MONITOR_MAX; i++) {
- String base = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)).get_slicec('/', 0).capitalize();
- String name = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)).get_slicec('/', 1).capitalize();
+ String base = EditorPropertyNameProcessor::get_singleton()->process_name(Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)).get_slicec('/', 0), EditorPropertyNameProcessor::STYLE_CAPITALIZED);
+ String name = EditorPropertyNameProcessor::get_singleton()->process_name(Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)).get_slicec('/', 1), EditorPropertyNameProcessor::STYLE_CAPITALIZED);
monitors.insert(Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)), Monitor(name, base, i, Performance::get_singleton()->get_monitor_type(Performance::Monitor(i)), nullptr));
}
diff --git a/editor/debugger/editor_performance_profiler.h b/editor/debugger/editor_performance_profiler.h
index ea3404b208..a917ddbe28 100644
--- a/editor/debugger/editor_performance_profiler.h
+++ b/editor/debugger/editor_performance_profiler.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -62,9 +62,9 @@ private:
OrderedHashMap<StringName, Monitor> monitors;
Map<StringName, TreeItem *> base_map;
- Tree *monitor_tree;
- Control *monitor_draw;
- Label *info_message;
+ Tree *monitor_tree = nullptr;
+ Control *monitor_draw = nullptr;
+ Label *info_message = nullptr;
StringName marker_key;
int marker_frame;
const int MARGIN = 4;
diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp
index 2fe7cd7886..4e2e8634e5 100644
--- a/editor/debugger/editor_profiler.cpp
+++ b/editor/debugger/editor_profiler.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -355,7 +355,7 @@ void EditorProfiler::_update_frame() {
item->set_metadata(0, it.signature);
item->set_metadata(1, it.script);
item->set_metadata(2, it.line);
- item->set_text_align(2, TreeItem::ALIGN_RIGHT);
+ item->set_text_alignment(2, HORIZONTAL_ALIGNMENT_RIGHT);
item->set_tooltip(0, it.name + "\n" + it.script + ":" + itos(it.line));
float time = dtime == DISPLAY_SELF_TIME ? it.self : it.total;
@@ -393,9 +393,14 @@ void EditorProfiler::_clear_pressed() {
}
void EditorProfiler::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) {
- activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")));
- clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")));
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
+ case NOTIFICATION_THEME_CHANGED:
+ case NOTIFICATION_TRANSLATION_CHANGED: {
+ activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")));
+ clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")));
+ } break;
}
}
@@ -438,7 +443,7 @@ void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) {
Ref<InputEventMouseMotion> mm = p_ev;
if (
- (mb.is_valid() && mb->get_button_index() == MOUSE_BUTTON_LEFT && mb->is_pressed()) ||
+ (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT && mb->is_pressed()) ||
(mm.is_valid())) {
int x = me->get_position().x - 1;
x = x * frame_metrics.size() / graph->get_size().width;
@@ -453,11 +458,12 @@ void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) {
x = frame_metrics.size() - 1;
}
- if (mb.is_valid() || mm->get_button_mask() & MOUSE_BUTTON_MASK_LEFT) {
+ if (mb.is_valid() || (mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE) {
updating_frame = true;
- if (x < total_metrics)
+ if (x < total_metrics) {
cursor_metric_edit->set_value(_get_frame_metric(x).frame_number);
+ }
updating_frame = false;
if (activate->is_pressed()) {
@@ -645,7 +651,7 @@ EditorProfiler::EditorProfiler() {
variables->connect("item_edited", callable_mp(this, &EditorProfiler::_item_edited));
graph = memnew(TextureRect);
- graph->set_expand(true);
+ graph->set_ignore_texture_size(true);
graph->set_mouse_filter(MOUSE_FILTER_STOP);
graph->connect("draw", callable_mp(this, &EditorProfiler::_graph_tex_draw));
graph->connect("gui_input", callable_mp(this, &EditorProfiler::_graph_tex_input));
@@ -654,7 +660,7 @@ EditorProfiler::EditorProfiler() {
h_split->add_child(graph);
graph->set_h_size_flags(SIZE_EXPAND_FILL);
- int metric_size = CLAMP(int(EDITOR_DEF("debugger/profiler_frame_history_size", 600)), 60, 1024);
+ int metric_size = CLAMP(int(EDITOR_GET("debugger/profiler_frame_history_size")), 60, 1024);
frame_metrics.resize(metric_size);
total_metrics = 0;
last_metric = -1;
diff --git a/editor/debugger/editor_profiler.h b/editor/debugger/editor_profiler.h
index 8880824b87..34f34be7c3 100644
--- a/editor/debugger/editor_profiler.h
+++ b/editor/debugger/editor_profiler.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -90,20 +90,20 @@ public:
};
private:
- Button *activate;
- Button *clear_button;
- TextureRect *graph;
+ Button *activate = nullptr;
+ Button *clear_button = nullptr;
+ TextureRect *graph = nullptr;
Ref<ImageTexture> graph_texture;
Vector<uint8_t> graph_image;
- Tree *variables;
- HSplitContainer *h_split;
+ Tree *variables = nullptr;
+ HSplitContainer *h_split = nullptr;
Set<StringName> plot_sigs;
- OptionButton *display_mode;
- OptionButton *display_time;
+ OptionButton *display_mode = nullptr;
+ OptionButton *display_time = nullptr;
- SpinBox *cursor_metric_edit;
+ SpinBox *cursor_metric_edit = nullptr;
Vector<Metric> frame_metrics;
int total_metrics;
@@ -119,8 +119,8 @@ private:
bool seeking;
- Timer *frame_delay;
- Timer *plot_delay;
+ Timer *frame_delay = nullptr;
+ Timer *plot_delay = nullptr;
void _update_frame();
diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp
index f25f18b7e4..2f33a0bc31 100644
--- a/editor/debugger/editor_visual_profiler.cpp
+++ b/editor/debugger/editor_visual_profiler.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -41,7 +41,6 @@ void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) {
}
frame_metrics.write[last_metric] = p_metric;
- // _make_metric_ptrs(frame_metrics.write[last_metric]);
List<String> stack;
for (int i = 0; i < frame_metrics[last_metric].areas.size(); i++) {
@@ -68,7 +67,7 @@ void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) {
updating_frame = true;
cursor_metric_edit->set_max(frame_metrics[last_metric].frame_number);
- cursor_metric_edit->set_min(MAX(frame_metrics[last_metric].frame_number - frame_metrics.size(), 0));
+ cursor_metric_edit->set_min(MAX(frame_metrics[last_metric].frame_number - frame_metrics.size(), 0u));
if (!seeking) {
cursor_metric_edit->set_value(frame_metrics[last_metric].frame_number);
@@ -144,12 +143,12 @@ void EditorVisualProfiler::_item_selected() {
}
void EditorVisualProfiler::_update_plot() {
- int w = graph->get_size().width;
- int h = graph->get_size().height;
+ const int w = graph->get_size().width;
+ const int h = graph->get_size().height;
bool reset_texture = false;
- int desired_len = w * h * 4;
+ const int desired_len = w * h * 4;
if (graph_image.size() != desired_len) {
reset_texture = true;
@@ -157,12 +156,13 @@ void EditorVisualProfiler::_update_plot() {
}
uint8_t *wr = graph_image.ptrw();
+ const Color background_color = get_theme_color("dark_color_2", "Editor");
- //clear
+ // Clear the previous frame and set the background color.
for (int i = 0; i < desired_len; i += 4) {
- wr[i + 0] = 0;
- wr[i + 1] = 0;
- wr[i + 2] = 0;
+ wr[i + 0] = Math::fast_ftoi(background_color.r * 255);
+ wr[i + 1] = Math::fast_ftoi(background_color.g * 255);
+ wr[i + 2] = Math::fast_ftoi(background_color.b * 255);
wr[i + 3] = 255;
}
@@ -260,9 +260,9 @@ void EditorVisualProfiler::_update_plot() {
uint8_t r, g, b;
if (column_cpu[j].a == 0) {
- r = 0;
- g = 0;
- b = 0;
+ r = Math::fast_ftoi(background_color.r * 255);
+ g = Math::fast_ftoi(background_color.g * 255);
+ b = Math::fast_ftoi(background_color.b * 255);
} else {
r = CLAMP((column_cpu[j].r / column_cpu[j].a) * 255.0, 0, 255);
g = CLAMP((column_cpu[j].g / column_cpu[j].a) * 255.0, 0, 255);
@@ -280,9 +280,9 @@ void EditorVisualProfiler::_update_plot() {
uint8_t r, g, b;
if (column_gpu[j].a == 0) {
- r = 0;
- g = 0;
- b = 0;
+ r = Math::fast_ftoi(background_color.r * 255);
+ g = Math::fast_ftoi(background_color.g * 255);
+ b = Math::fast_ftoi(background_color.b * 255);
} else {
r = CLAMP((column_gpu[j].r / column_gpu[j].a) * 255.0, 0, 255);
g = CLAMP((column_gpu[j].g / column_gpu[j].a) * 255.0, 0, 255);
@@ -423,13 +423,18 @@ void EditorVisualProfiler::_clear_pressed() {
}
void EditorVisualProfiler::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) {
- if (is_layout_rtl()) {
- activate->set_icon(get_theme_icon(SNAME("PlayBackwards"), SNAME("EditorIcons")));
- } else {
- activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")));
- }
- clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")));
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
+ case NOTIFICATION_THEME_CHANGED:
+ case NOTIFICATION_TRANSLATION_CHANGED: {
+ if (is_layout_rtl()) {
+ activate->set_icon(get_theme_icon(SNAME("PlayBackwards"), SNAME("EditorIcons")));
+ } else {
+ activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")));
+ }
+ clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")));
+ } break;
}
}
@@ -437,8 +442,11 @@ void EditorVisualProfiler::_graph_tex_draw() {
if (last_metric < 0) {
return;
}
+
Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label"));
+ const Color color = get_theme_color(SNAME("font_color"), SNAME("Editor"));
+
if (seeking) {
int max_frames = frame_metrics.size();
int frame = cursor_metric_edit->get_value() - (frame_metrics[last_metric].frame_number - max_frames + 1);
@@ -448,10 +456,9 @@ void EditorVisualProfiler::_graph_tex_draw() {
int half_width = graph->get_size().x / 2;
int cur_x = frame * half_width / max_frames;
- //cur_x /= 2.0;
- graph->draw_line(Vector2(cur_x, 0), Vector2(cur_x, graph->get_size().y), Color(1, 1, 1, 0.8));
- graph->draw_line(Vector2(cur_x + half_width, 0), Vector2(cur_x + half_width, graph->get_size().y), Color(1, 1, 1, 0.8));
+ graph->draw_line(Vector2(cur_x, 0), Vector2(cur_x, graph->get_size().y), color * Color(1, 1, 1));
+ graph->draw_line(Vector2(cur_x + half_width, 0), Vector2(cur_x + half_width, graph->get_size().y), color * Color(1, 1, 1));
}
if (graph_height_cpu > 0) {
@@ -459,10 +466,10 @@ void EditorVisualProfiler::_graph_tex_draw() {
int half_width = graph->get_size().x / 2;
- graph->draw_line(Vector2(0, frame_y), Vector2(half_width, frame_y), Color(1, 1, 1, 0.3));
+ graph->draw_line(Vector2(0, frame_y), Vector2(half_width, frame_y), color * Color(1, 1, 1, 0.5));
- String limit_str = String::num(graph_limit, 2);
- graph->draw_string(font, Vector2(half_width - font->get_string_size(limit_str, font_size).x - 2, frame_y - 2), limit_str, HALIGN_LEFT, -1, font_size, Color(1, 1, 1, 0.6));
+ const String limit_str = String::num(graph_limit, 2) + " ms";
+ graph->draw_string(font, Vector2(half_width - font->get_string_size(limit_str, font_size).x - 2, frame_y - 2), limit_str, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, color * Color(1, 1, 1, 0.75));
}
if (graph_height_gpu > 0) {
@@ -470,27 +477,14 @@ void EditorVisualProfiler::_graph_tex_draw() {
int half_width = graph->get_size().x / 2;
- graph->draw_line(Vector2(half_width, frame_y), Vector2(graph->get_size().x, frame_y), Color(1, 1, 1, 0.3));
+ graph->draw_line(Vector2(half_width, frame_y), Vector2(graph->get_size().x, frame_y), color * Color(1, 1, 1, 0.5));
- String limit_str = String::num(graph_limit, 2);
- graph->draw_string(font, Vector2(half_width * 2 - font->get_string_size(limit_str, font_size).x - 2, frame_y - 2), limit_str, HALIGN_LEFT, -1, font_size, Color(1, 1, 1, 0.6));
+ const String limit_str = String::num(graph_limit, 2) + " ms";
+ graph->draw_string(font, Vector2(half_width * 2 - font->get_string_size(limit_str, font_size).x - 2, frame_y - 2), limit_str, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, color * Color(1, 1, 1, 0.75));
}
- graph->draw_string(font, Vector2(font->get_string_size("X", font_size).x, font->get_ascent(font_size) + 2), "CPU:", HALIGN_LEFT, -1, font_size, Color(1, 1, 1, 0.8));
- graph->draw_string(font, Vector2(font->get_string_size("X", font_size).x + graph->get_size().width / 2, font->get_ascent(font_size) + 2), "GPU:", HALIGN_LEFT, -1, font_size, Color(1, 1, 1, 0.8));
-
- /*
- if (hover_metric != -1 && frame_metrics[hover_metric].valid) {
- int max_frames = frame_metrics.size();
- int frame = frame_metrics[hover_metric].frame_number - (frame_metrics[last_metric].frame_number - max_frames + 1);
- if (frame < 0)
- frame = 0;
-
- int cur_x = frame * graph->get_size().x / max_frames;
-
- graph->draw_line(Vector2(cur_x, 0), Vector2(cur_x, graph->get_size().y), Color(1, 1, 1, 0.4));
- }
-*/
+ graph->draw_string(font, Vector2(font->get_string_size("X", font_size).x, font->get_ascent(font_size) + 2), "CPU:", HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, color * Color(1, 1, 1));
+ graph->draw_string(font, Vector2(font->get_string_size("X", font_size).x + graph->get_size().width / 2, font->get_ascent(font_size) + 2), "GPU:", HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, color * Color(1, 1, 1));
}
void EditorVisualProfiler::_graph_tex_mouse_exit() {
@@ -517,7 +511,7 @@ void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) {
Ref<InputEventMouseMotion> mm = p_ev;
if (
- (mb.is_valid() && mb->get_button_index() == MOUSE_BUTTON_LEFT && mb->is_pressed()) ||
+ (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT && mb->is_pressed()) ||
(mm.is_valid())) {
int half_w = graph->get_size().width / 2;
int x = me->get_position().x;
@@ -549,7 +543,7 @@ void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) {
hover_metric = -1;
}
- if (mb.is_valid() || mm->get_button_mask() & MOUSE_BUTTON_MASK_LEFT) {
+ if (mb.is_valid() || (mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE) {
//cursor_metric=x;
updating_frame = true;
@@ -734,7 +728,7 @@ EditorVisualProfiler::EditorVisualProfiler() {
hb->add_child(memnew(Label(TTR("Measure:"))));
display_mode = memnew(OptionButton);
- display_mode->add_item(TTR("Frame Time (msec)"));
+ display_mode->add_item(TTR("Frame Time (ms)"));
display_mode->add_item(TTR("Frame %"));
display_mode->connect("item_selected", callable_mp(this, &EditorVisualProfiler::_combo_changed));
@@ -786,7 +780,7 @@ EditorVisualProfiler::EditorVisualProfiler() {
variables->connect("cell_selected", callable_mp(this, &EditorVisualProfiler::_item_selected));
graph = memnew(TextureRect);
- graph->set_expand(true);
+ graph->set_ignore_texture_size(true);
graph->set_mouse_filter(MOUSE_FILTER_STOP);
//graph->set_ignore_mouse(false);
graph->connect("draw", callable_mp(this, &EditorVisualProfiler::_graph_tex_draw));
@@ -796,7 +790,7 @@ EditorVisualProfiler::EditorVisualProfiler() {
h_split->add_child(graph);
graph->set_h_size_flags(SIZE_EXPAND_FILL);
- int metric_size = CLAMP(int(EDITOR_DEF("debugger/profiler_frame_history_size", 600)), 60, 1024);
+ int metric_size = CLAMP(int(EDITOR_GET("debugger/profiler_frame_history_size")), 60, 1024);
frame_metrics.resize(metric_size);
last_metric = -1;
//cursor_metric=-1;
diff --git a/editor/debugger/editor_visual_profiler.h b/editor/debugger/editor_visual_profiler.h
index 6b04fdbafc..14eacca02d 100644
--- a/editor/debugger/editor_visual_profiler.h
+++ b/editor/debugger/editor_visual_profiler.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -67,20 +67,20 @@ public:
};
private:
- Button *activate;
- Button *clear_button;
+ Button *activate = nullptr;
+ Button *clear_button = nullptr;
- TextureRect *graph;
+ TextureRect *graph = nullptr;
Ref<ImageTexture> graph_texture;
Vector<uint8_t> graph_image;
- Tree *variables;
- HSplitContainer *h_split;
- CheckBox *frame_relative;
- CheckBox *linked;
+ Tree *variables = nullptr;
+ HSplitContainer *h_split = nullptr;
+ CheckBox *frame_relative = nullptr;
+ CheckBox *linked = nullptr;
- OptionButton *display_mode;
+ OptionButton *display_mode = nullptr;
- SpinBox *cursor_metric_edit;
+ SpinBox *cursor_metric_edit = nullptr;
Vector<Metric> frame_metrics;
int last_metric;
@@ -99,8 +99,8 @@ private:
bool seeking;
- Timer *frame_delay;
- Timer *plot_delay;
+ Timer *frame_delay = nullptr;
+ Timer *plot_delay = nullptr;
void _update_frame(bool p_focus_selected = false);
diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp
index a312c161a8..3a3b35f8a5 100644
--- a/editor/debugger/script_editor_debugger.cpp
+++ b/editor/debugger/script_editor_debugger.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -36,14 +36,15 @@
#include "core/io/marshalls.h"
#include "core/string/ustring.h"
#include "core/version.h"
-#include "core/version_hash.gen.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"
+#include "editor/editor_file_dialog.h"
#include "editor/editor_log.h"
#include "editor/editor_node.h"
+#include "editor/editor_property_name_processor.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
@@ -64,6 +65,7 @@
#include "scene/gui/texture_button.h"
#include "scene/gui/tree.h"
#include "scene/resources/packed_scene.h"
+#include "servers/debugger/servers_debugger.h"
#include "servers/display_server.h"
using CameraOverride = EditorDebuggerNode::CameraOverride;
@@ -79,7 +81,7 @@ void ScriptEditorDebugger::_put_msg(String p_message, Array p_data) {
void ScriptEditorDebugger::debug_copy() {
String msg = reason->get_text();
- if (msg == "") {
+ if (msg.is_empty()) {
return;
}
DisplayServer::get_singleton()->clipboard_set(msg);
@@ -128,20 +130,21 @@ void ScriptEditorDebugger::debug_continue() {
_clear_execution();
_put_msg("continue", Array());
+ _put_msg("servers:foreground", Array());
}
void ScriptEditorDebugger::update_tabs() {
if (error_count == 0 && warning_count == 0) {
errors_tab->set_name(TTR("Errors"));
- tabs->set_tab_icon(errors_tab->get_index(), Ref<Texture2D>());
+ tabs->set_tab_icon(tabs->get_tab_idx_from_control(errors_tab), Ref<Texture2D>());
} else {
errors_tab->set_name(TTR("Errors") + " (" + itos(error_count + warning_count) + ")");
if (error_count >= 1 && warning_count >= 1) {
- tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon(SNAME("ErrorWarning"), SNAME("EditorIcons")));
+ tabs->set_tab_icon(tabs->get_tab_idx_from_control(errors_tab), get_theme_icon(SNAME("ErrorWarning"), SNAME("EditorIcons")));
} else if (error_count >= 1) {
- tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon(SNAME("Error"), SNAME("EditorIcons")));
+ tabs->set_tab_icon(tabs->get_tab_idx_from_control(errors_tab), get_theme_icon(SNAME("Error"), SNAME("EditorIcons")));
} else {
- tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon(SNAME("Warning"), SNAME("EditorIcons")));
+ tabs->set_tab_icon(tabs->get_tab_idx_from_control(errors_tab), get_theme_icon(SNAME("Warning"), SNAME("EditorIcons")));
}
}
}
@@ -161,7 +164,7 @@ void ScriptEditorDebugger::_file_selected(const String &p_file) {
switch (file_dialog_purpose) {
case SAVE_MONITORS_CSV: {
Error err;
- FileAccessRef file = FileAccess::open(p_file, FileAccess::WRITE, &err);
+ Ref<FileAccess> file = FileAccess::open(p_file, FileAccess::WRITE, &err);
if (err != OK) {
ERR_PRINT("Failed to open " + p_file);
@@ -206,7 +209,7 @@ void ScriptEditorDebugger::_file_selected(const String &p_file) {
} break;
case SAVE_VRAM_CSV: {
Error err;
- FileAccessRef file = FileAccess::open(p_file, FileAccess::WRITE, &err);
+ Ref<FileAccess> file = FileAccess::open(p_file, FileAccess::WRITE, &err);
if (err != OK) {
ERR_PRINT("Failed to open " + p_file);
@@ -278,7 +281,7 @@ void ScriptEditorDebugger::_remote_object_property_updated(ObjectID p_id, const
}
void ScriptEditorDebugger::_video_mem_request() {
- _put_msg("core:memory", Array());
+ _put_msg("servers:memory", Array());
}
void ScriptEditorDebugger::_video_mem_export() {
@@ -312,7 +315,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
if (is_move_to_foreground()) {
DisplayServer::get_singleton()->window_move_to_foreground();
}
- if (error != "") {
+ if (!error.is_empty()) {
tabs->set_current_tab(0);
}
profiler->set_enabled(false);
@@ -344,15 +347,15 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
if (id.is_valid()) {
emit_signal(SNAME("remote_object_updated"), id);
}
- } else if (p_msg == "memory:usage") {
+ } else if (p_msg == "servers:memory_usage") {
vmem_tree->clear();
TreeItem *root = vmem_tree->create_item();
- DebuggerMarshalls::ResourceUsage usage;
+ ServersDebugger::ResourceUsage usage;
usage.deserialize(p_data);
uint64_t total = 0;
- for (const DebuggerMarshalls::ResourceInfo &E : usage.infos) {
+ for (const ServersDebugger::ResourceInfo &E : usage.infos) {
TreeItem *it = vmem_tree->create_item(root);
String type = E.type;
int bytes = E.vram;
@@ -390,7 +393,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
stack_dump_info.push_back(d);
s->set_metadata(0, d);
- String line = itos(i) + " - " + String(d["file"]) + ":" + itos(d["line"]) + " - at function: " + d["function"];
+ String line = itos(i) + " - " + String(d["file"]) + ":" + itos(d["line"]) + " - at function: " + String(d["function"]);
s->set_text(0, line);
if (i == 0) {
@@ -445,7 +448,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
performance_profiler->add_profile_frame(frame_data);
} else if (p_msg == "visual:profile_frame") {
- DebuggerMarshalls::VisualProfilerFrame frame;
+ ServersDebugger::VisualProfilerFrame frame;
frame.deserialize(p_data);
EditorVisualProfiler::Metric metric;
@@ -497,9 +500,9 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
TreeItem *error = error_tree->create_item(r);
error->set_collapsed(true);
- error->set_icon(0, get_theme_icon(oe.warning ? "Warning" : "Error", "EditorIcons"));
+ error->set_icon(0, get_theme_icon(oe.warning ? SNAME("Warning") : SNAME("Error"), SNAME("EditorIcons")));
error->set_text(0, time);
- error->set_text_align(0, TreeItem::ALIGN_LEFT);
+ error->set_text_alignment(0, HORIZONTAL_ALIGNMENT_LEFT);
const Color color = get_theme_color(oe.warning ? SNAME("warning_color") : SNAME("error_color"), SNAME("Editor"));
error->set_custom_color(0, color);
@@ -524,7 +527,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
TreeItem *cpp_cond = error_tree->create_item(error);
cpp_cond->set_text(0, "<" + TTR("C++ Error") + ">");
cpp_cond->set_text(1, oe.error);
- cpp_cond->set_text_align(0, TreeItem::ALIGN_LEFT);
+ cpp_cond->set_text_alignment(0, HORIZONTAL_ALIGNMENT_LEFT);
tooltip += TTR("C++ Error:") + " " + oe.error + "\n";
if (source_is_project_file) {
cpp_cond->set_metadata(0, source_meta);
@@ -542,7 +545,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
TreeItem *cpp_source = error_tree->create_item(error);
cpp_source->set_text(0, "<" + (source_is_project_file ? TTR("Source") : TTR("C++ Source")) + ">");
cpp_source->set_text(1, source_txt);
- cpp_source->set_text_align(0, TreeItem::ALIGN_LEFT);
+ cpp_source->set_text_alignment(0, HORIZONTAL_ALIGNMENT_LEFT);
tooltip += (source_is_project_file ? TTR("Source:") : TTR("C++ Source:")) + " " + source_txt + "\n";
// Set metadata to highlight error line in scripts.
@@ -565,7 +568,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
if (i == 0) {
stack_trace->set_text(0, "<" + TTR("Stack Trace") + ">");
- stack_trace->set_text_align(0, TreeItem::ALIGN_LEFT);
+ stack_trace->set_text_alignment(0, HORIZONTAL_ALIGNMENT_LEFT);
error->set_metadata(0, meta);
tooltip += TTR("Stack Trace:") + "\n";
}
@@ -578,6 +581,12 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
error->set_tooltip(0, tooltip);
error->set_tooltip(1, tooltip);
+ if (warning_count == 0 && error_count == 0) {
+ expand_all_button->set_disabled(false);
+ collapse_all_button->set_disabled(false);
+ clear_button->set_disabled(false);
+ }
+
if (oe.warning) {
warning_count++;
} else {
@@ -586,13 +595,13 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
} else if (p_msg == "servers:function_signature") {
// Cache a profiler signature.
- DebuggerMarshalls::ScriptFunctionSignature sig;
+ ServersDebugger::ScriptFunctionSignature sig;
sig.deserialize(p_data);
profiler_signature[sig.id] = sig.name;
} else if (p_msg == "servers:profile_frame" || p_msg == "servers:profile_total") {
EditorProfiler::Metric metric;
- DebuggerMarshalls::ServersProfilerFrame frame;
+ ServersDebugger::ServersProfilerFrame frame;
frame.deserialize(p_data);
metric.valid = true;
metric.frame_number = frame.frame_number;
@@ -636,10 +645,10 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
}
for (int i = 0; i < frame.servers.size(); i++) {
- const DebuggerMarshalls::ServerInfo &srv = frame.servers[i];
+ const ServersDebugger::ServerInfo &srv = frame.servers[i];
EditorProfiler::Metric::Category c;
const String name = srv.name;
- c.name = name.capitalize();
+ c.name = EditorPropertyNameProcessor::get_singleton()->process_name(name, EditorPropertyNameProcessor::STYLE_CAPITALIZED);
c.items.resize(srv.functions.size());
c.total_time = 0;
c.signature = "categ::" + name;
@@ -651,7 +660,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
item.self = srv.functions[j].time;
item.total = item.self;
item.signature = "categ::" + name + "::" + item.name;
- item.name = item.name.capitalize();
+ item.name = EditorPropertyNameProcessor::get_singleton()->process_name(item.name, EditorPropertyNameProcessor::STYLE_CAPITALIZED);
c.total_time += item.total;
c.items.write[j] = item;
}
@@ -703,14 +712,14 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
profiler->add_frame_metric(metric, true);
}
- } else if (p_msg == "network:profile_frame") {
- DebuggerMarshalls::NetworkProfilerFrame frame;
+ } 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 == "network:bandwidth") {
+ } else if (p_msg == "multiplayer:bandwidth") {
ERR_FAIL_COND(p_data.size() < 2);
network_profiler->set_bandwidth(p_data[0], p_data[1]);
@@ -771,31 +780,33 @@ void ScriptEditorDebugger::_set_reason_text(const String &p_reason, MessageType
void ScriptEditorDebugger::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- skip_breakpoints->set_icon(get_theme_icon(SNAME("DebugSkipBreakpointsOff"), SNAME("EditorIcons")));
+ le_set->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_live_edit_set));
+ le_clear->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_live_edit_clear));
+ error_tree->connect("item_selected", callable_mp(this, &ScriptEditorDebugger::_error_selected));
+ error_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_error_activated));
+ breakpoints_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_breakpoint_tree_clicked));
+ [[fallthrough]];
+ }
+ case NOTIFICATION_THEME_CHANGED: {
+ skip_breakpoints->set_icon(get_theme_icon(skip_breakpoints_value ? SNAME("DebugSkipBreakpointsOn") : SNAME("DebugSkipBreakpointsOff"), SNAME("EditorIcons")));
copy->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")));
-
step->set_icon(get_theme_icon(SNAME("DebugStep"), SNAME("EditorIcons")));
next->set_icon(get_theme_icon(SNAME("DebugNext"), SNAME("EditorIcons")));
dobreak->set_icon(get_theme_icon(SNAME("Pause"), SNAME("EditorIcons")));
docontinue->set_icon(get_theme_icon(SNAME("DebugContinue"), SNAME("EditorIcons")));
- le_set->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_live_edit_set));
- le_clear->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_live_edit_clear));
- error_tree->connect("item_selected", callable_mp(this, &ScriptEditorDebugger::_error_selected));
- error_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_error_activated));
vmem_refresh->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")));
vmem_export->set_icon(get_theme_icon(SNAME("Save"), SNAME("EditorIcons")));
+ search->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
reason->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
-
} break;
+
case NOTIFICATION_PROCESS: {
if (is_session_active()) {
peer->poll();
if (camera_override == CameraOverride::OVERRIDE_2D) {
- CanvasItemEditor *editor = CanvasItemEditor::get_singleton();
-
- Dictionary state = editor->get_state();
+ Dictionary state = CanvasItemEditor::get_singleton()->get_state();
float zoom = state["zoom"];
Point2 offset = state["ofs"];
Transform2D transform;
@@ -825,6 +836,9 @@ void ScriptEditorDebugger::_notification(int p_what) {
msg.push_back(cam->get_far());
_put_msg("scene:override_camera_3D:transform", msg);
}
+ if (breaked) {
+ _put_msg("servers:draw", Array());
+ }
}
const uint64_t until = OS::get_singleton()->get_ticks_msec() + 20;
@@ -846,9 +860,10 @@ void ScriptEditorDebugger::_notification(int p_what) {
break;
};
} break;
+
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
if (tabs->has_theme_stylebox_override("panel")) {
- tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles")));
+ tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles")));
}
copy->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")));
@@ -858,6 +873,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
docontinue->set_icon(get_theme_icon(SNAME("DebugContinue"), SNAME("EditorIcons")));
vmem_refresh->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")));
vmem_export->set_icon(get_theme_icon(SNAME("Save"), SNAME("EditorIcons")));
+ search->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
} break;
}
}
@@ -879,12 +895,19 @@ void ScriptEditorDebugger::_clear_execution() {
void ScriptEditorDebugger::_set_breakpoint(const String &p_file, const int &p_line, const bool &p_enabled) {
Ref<Script> script = ResourceLoader::load(p_file);
- emit_signal("set_breakpoint", script, p_line - 1, p_enabled);
+ emit_signal(SNAME("set_breakpoint"), script, p_line - 1, p_enabled);
script.unref();
}
void ScriptEditorDebugger::_clear_breakpoints() {
- emit_signal("clear_breakpoints");
+ emit_signal(SNAME("clear_breakpoints"));
+}
+
+void ScriptEditorDebugger::_breakpoint_tree_clicked() {
+ TreeItem *selected = breakpoints_tree->get_selected();
+ if (selected->has_meta("line")) {
+ emit_signal(SNAME("breakpoint_selected"), selected->get_parent()->get_text(0), int(selected->get_meta("line")));
+ }
}
void ScriptEditorDebugger::start(Ref<RemoteDebuggerPeer> p_peer) {
@@ -955,7 +978,8 @@ void ScriptEditorDebugger::_profiler_activate(bool p_enable, int p_type) {
data.push_back(p_enable);
switch (p_type) {
case PROFILER_NETWORK:
- _put_msg("profiler:network", data);
+ _put_msg("profiler:multiplayer", data);
+ _put_msg("profiler:rpc", data);
break;
case PROFILER_VISUAL:
_put_msg("profiler:visual", data);
@@ -1043,32 +1067,30 @@ int ScriptEditorDebugger::_get_res_path_cache(const String &p_path) {
return last_path_id;
}
-void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE) {
- if (!p_base || !live_debug || !is_session_active() || !editor->get_edited_scene()) {
+void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_name, const Variant **p_args, int p_argcount) {
+ if (!p_base || !live_debug || !is_session_active() || !EditorNode::get_singleton()->get_edited_scene()) {
return;
}
Node *node = Object::cast_to<Node>(p_base);
- VARIANT_ARGPTRS
-
- for (int i = 0; i < VARIANT_ARG_MAX; i++) {
+ for (int i = 0; i < p_argcount; i++) {
//no pointers, sorry
- if (argptr[i] && (argptr[i]->get_type() == Variant::OBJECT || argptr[i]->get_type() == Variant::RID)) {
+ if (p_args[i]->get_type() == Variant::OBJECT || p_args[i]->get_type() == Variant::RID) {
return;
}
}
if (node) {
- NodePath path = editor->get_edited_scene()->get_path_to(node);
+ NodePath path = EditorNode::get_singleton()->get_edited_scene()->get_path_to(node);
int pathid = _get_node_path_cache(path);
Array msg;
msg.push_back(pathid);
msg.push_back(p_name);
- for (int i = 0; i < VARIANT_ARG_MAX; i++) {
+ for (int i = 0; i < p_argcount; i++) {
//no pointers, sorry
- msg.push_back(*argptr[i]);
+ msg.push_back(*p_args[i]);
}
_put_msg("scene:live_node_call", msg);
@@ -1077,16 +1099,16 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n
Resource *res = Object::cast_to<Resource>(p_base);
- if (res && res->get_path() != String()) {
+ if (res && !res->get_path().is_empty()) {
String respath = res->get_path();
int pathid = _get_res_path_cache(respath);
Array msg;
msg.push_back(pathid);
msg.push_back(p_name);
- for (int i = 0; i < VARIANT_ARG_MAX; i++) {
+ for (int i = 0; i < p_argcount; i++) {
//no pointers, sorry
- msg.push_back(*argptr[i]);
+ msg.push_back(*p_args[i]);
}
_put_msg("scene:live_res_call", msg);
@@ -1095,19 +1117,19 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n
}
void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p_property, const Variant &p_value) {
- if (!p_base || !live_debug || !editor->get_edited_scene()) {
+ if (!p_base || !live_debug || !EditorNode::get_singleton()->get_edited_scene()) {
return;
}
Node *node = Object::cast_to<Node>(p_base);
if (node) {
- NodePath path = editor->get_edited_scene()->get_path_to(node);
+ NodePath path = EditorNode::get_singleton()->get_edited_scene()->get_path_to(node);
int pathid = _get_node_path_cache(path);
- if (p_value.is_ref()) {
+ if (p_value.is_ref_counted()) {
Ref<Resource> res = p_value;
- if (res.is_valid() && res->get_path() != String()) {
+ if (res.is_valid() && !res->get_path().is_empty()) {
Array msg;
msg.push_back(pathid);
msg.push_back(p_property);
@@ -1127,13 +1149,13 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p
Resource *res = Object::cast_to<Resource>(p_base);
- if (res && res->get_path() != String()) {
+ if (res && !res->get_path().is_empty()) {
String respath = res->get_path();
int pathid = _get_res_path_cache(respath);
- if (p_value.is_ref()) {
+ if (p_value.is_ref_counted()) {
Ref<Resource> res2 = p_value;
- if (res2.is_valid() && res2->get_path() != String()) {
+ if (res2.is_valid() && !res2->get_path().is_empty()) {
Array msg;
msg.push_back(pathid);
msg.push_back(p_property);
@@ -1220,25 +1242,25 @@ void ScriptEditorDebugger::_live_edit_set() {
NodePath np = path;
- editor->get_editor_data().set_edited_scene_live_edit_root(np);
+ EditorNode::get_singleton()->get_editor_data().set_edited_scene_live_edit_root(np);
update_live_edit_root();
}
void ScriptEditorDebugger::_live_edit_clear() {
NodePath np = NodePath("/root");
- editor->get_editor_data().set_edited_scene_live_edit_root(np);
+ EditorNode::get_singleton()->get_editor_data().set_edited_scene_live_edit_root(np);
update_live_edit_root();
}
void ScriptEditorDebugger::update_live_edit_root() {
- NodePath np = editor->get_editor_data().get_edited_scene_live_edit_root();
+ NodePath np = EditorNode::get_singleton()->get_editor_data().get_edited_scene_live_edit_root();
Array msg;
msg.push_back(np);
- if (editor->get_edited_scene()) {
- msg.push_back(editor->get_edited_scene()->get_scene_file_path());
+ if (EditorNode::get_singleton()->get_edited_scene()) {
+ msg.push_back(EditorNode::get_singleton()->get_edited_scene()->get_scene_file_path());
} else {
msg.push_back("");
}
@@ -1345,6 +1367,45 @@ void ScriptEditorDebugger::set_breakpoint(const String &p_path, int p_line, bool
msg.push_back(p_line);
msg.push_back(p_enabled);
_put_msg("breakpoint", msg);
+
+ TreeItem *path_item = breakpoints_tree->search_item_text(p_path);
+ if (path_item == nullptr) {
+ if (!p_enabled) {
+ return;
+ }
+ path_item = breakpoints_tree->create_item();
+ path_item->set_text(0, p_path);
+ }
+
+ int idx = 0;
+ TreeItem *breakpoint_item;
+ for (breakpoint_item = path_item->get_first_child(); breakpoint_item; breakpoint_item = breakpoint_item->get_next()) {
+ if ((int)breakpoint_item->get_meta("line") < p_line) {
+ idx++;
+ continue;
+ }
+
+ if ((int)breakpoint_item->get_meta("line") == p_line) {
+ break;
+ }
+ }
+
+ if (breakpoint_item == nullptr) {
+ if (!p_enabled) {
+ return;
+ }
+ breakpoint_item = breakpoints_tree->create_item(path_item, idx);
+ breakpoint_item->set_meta("line", p_line);
+ breakpoint_item->set_text(0, vformat(TTR("Line %d"), p_line));
+ return;
+ }
+
+ if (!p_enabled) {
+ path_item->remove_child(breakpoint_item);
+ if (path_item->get_first_child() == nullptr) {
+ breakpoints_tree->get_root()->remove_child(path_item);
+ }
+ }
}
void ScriptEditorDebugger::reload_scripts() {
@@ -1404,12 +1465,34 @@ void ScriptEditorDebugger::_clear_errors_list() {
error_tree->clear();
error_count = 0;
warning_count = 0;
+ update_tabs();
+
+ expand_all_button->set_disabled(true);
+ collapse_all_button->set_disabled(true);
+ clear_button->set_disabled(true);
+}
+
+void ScriptEditorDebugger::_breakpoints_item_rmb_selected(const Vector2 &p_pos) {
+ breakpoints_menu->clear();
+ breakpoints_menu->set_size(Size2(1, 1));
+
+ const TreeItem *selected = breakpoints_tree->get_selected();
+ String file = selected->get_text(0);
+ if (selected->has_meta("line")) {
+ breakpoints_menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete Breakpoint"), ACTION_DELETE_BREAKPOINT);
+ file = selected->get_parent()->get_text(0);
+ }
+ breakpoints_menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete All Breakpoints in: ") + file, ACTION_DELETE_BREAKPOINTS_IN_FILE);
+ breakpoints_menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete All Breakpoints"), ACTION_DELETE_ALL_BREAKPOINTS);
+
+ breakpoints_menu->set_position(breakpoints_tree->get_global_position() + p_pos);
+ breakpoints_menu->popup();
}
// Right click on specific file(s) or folder(s).
void ScriptEditorDebugger::_error_tree_item_rmb_selected(const Vector2 &p_pos) {
item_menu->clear();
- item_menu->set_size(Size2(1, 1));
+ item_menu->reset_size();
if (error_tree->is_anything_selected()) {
item_menu->add_icon_item(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), TTR("Copy Error"), ACTION_COPY_ERROR);
@@ -1417,7 +1500,7 @@ void ScriptEditorDebugger::_error_tree_item_rmb_selected(const Vector2 &p_pos) {
}
if (item_menu->get_item_count() > 0) {
- item_menu->set_position(error_tree->get_global_position() + p_pos);
+ item_menu->set_position(error_tree->get_screen_position() + p_pos);
item_menu->popup();
}
}
@@ -1466,20 +1549,34 @@ void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) {
const int line_number = file_line_number[1].to_int();
// Construct a GitHub repository URL and open it in the user's default web browser.
- if (String(VERSION_HASH).length() >= 1) {
- // Git commit hash information available; use it for greater accuracy, including for development versions.
- OS::get_singleton()->shell_open(vformat("https://github.com/godotengine/godot/blob/%s/%s#L%d",
- VERSION_HASH,
- file,
- line_number));
- } else {
- // Git commit hash information unavailable; fall back to tagged releases.
- OS::get_singleton()->shell_open(vformat("https://github.com/godotengine/godot/blob/%s-stable/%s#L%d",
- VERSION_NUMBER,
- file,
- line_number));
+ // If the commit hash is available, use it for greater accuracy. Otherwise fall back to tagged release.
+ String git_ref = String(VERSION_HASH).is_empty() ? String(VERSION_NUMBER) + "-stable" : String(VERSION_HASH);
+ OS::get_singleton()->shell_open(vformat("https://github.com/godotengine/godot/blob/%s/%s#L%d",
+ git_ref, file, line_number));
+ } break;
+ case ACTION_DELETE_BREAKPOINT: {
+ const TreeItem *selected = breakpoints_tree->get_selected();
+ _set_breakpoint(selected->get_parent()->get_text(0), selected->get_meta("line"), false);
+ } break;
+ case ACTION_DELETE_BREAKPOINTS_IN_FILE: {
+ TreeItem *file_item = breakpoints_tree->get_selected();
+ if (file_item->has_meta("line")) {
+ file_item = file_item->get_parent();
+ }
+
+ // Store first else we will be removing as we loop.
+ List<int> lines;
+ for (TreeItem *breakpoint_item = file_item->get_first_child(); breakpoint_item; breakpoint_item = breakpoint_item->get_next()) {
+ lines.push_back(breakpoint_item->get_meta("line"));
+ }
+
+ for (const int &line : lines) {
+ _set_breakpoint(file_item->get_text(0), line, false);
}
} break;
+ case ACTION_DELETE_ALL_BREAKPOINTS: {
+ _clear_breakpoints();
+ } break;
}
}
@@ -1506,6 +1603,7 @@ void ScriptEditorDebugger::_bind_methods() {
ADD_SIGNAL(MethodInfo("stop_requested"));
ADD_SIGNAL(MethodInfo("stack_frame_selected", PropertyInfo(Variant::INT, "frame")));
ADD_SIGNAL(MethodInfo("error_selected", PropertyInfo(Variant::INT, "error")));
+ ADD_SIGNAL(MethodInfo("breakpoint_selected", PropertyInfo("script"), PropertyInfo(Variant::INT, "line")));
ADD_SIGNAL(MethodInfo("set_execution", PropertyInfo("script"), PropertyInfo(Variant::INT, "line")));
ADD_SIGNAL(MethodInfo("clear_execution", PropertyInfo("script")));
ADD_SIGNAL(MethodInfo("breaked", PropertyInfo(Variant::BOOL, "reallydid"), PropertyInfo(Variant::BOOL, "can_debug"), PropertyInfo(Variant::STRING, "reason"), PropertyInfo(Variant::BOOL, "has_stackdump")));
@@ -1559,12 +1657,9 @@ bool ScriptEditorDebugger::has_capture(const StringName &p_name) {
return captures.has(p_name);
}
-ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
- editor = p_editor;
-
+ScriptEditorDebugger::ScriptEditorDebugger() {
tabs = memnew(TabContainer);
- tabs->set_tab_align(TabContainer::ALIGN_LEFT);
- tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles")));
+ tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles")));
tabs->connect("tab_changed", callable_mp(this, &ScriptEditorDebugger::_tab_changed));
add_child(tabs);
@@ -1633,9 +1728,15 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
docontinue->set_shortcut(ED_GET_SHORTCUT("debugger/continue"));
docontinue->connect("pressed", callable_mp(this, &ScriptEditorDebugger::debug_continue));
+ HSplitContainer *parent_sc = memnew(HSplitContainer);
+ vbc->add_child(parent_sc);
+ parent_sc->set_v_size_flags(SIZE_EXPAND_FILL);
+ parent_sc->set_split_offset(500 * EDSCALE);
+
HSplitContainer *sc = memnew(HSplitContainer);
- vbc->add_child(sc);
sc->set_v_size_flags(SIZE_EXPAND_FILL);
+ sc->set_h_size_flags(SIZE_EXPAND_FILL);
+ parent_sc->add_child(sc);
stack_dump = memnew(Tree);
stack_dump->set_allow_reselect(true);
@@ -1647,43 +1748,78 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
stack_dump->connect("cell_selected", callable_mp(this, &ScriptEditorDebugger::_stack_dump_frame_selected));
sc->add_child(stack_dump);
+ VBoxContainer *inspector_vbox = memnew(VBoxContainer);
+ inspector_vbox->set_h_size_flags(SIZE_EXPAND_FILL);
+ sc->add_child(inspector_vbox);
+
+ HBoxContainer *tools_hb = memnew(HBoxContainer);
+ inspector_vbox->add_child(tools_hb);
+
+ search = memnew(LineEdit);
+ search->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ search->set_placeholder(TTR("Filter stack variables"));
+ search->set_clear_button_enabled(true);
+ tools_hb->add_child(search);
+
inspector = memnew(EditorDebuggerInspector);
inspector->set_h_size_flags(SIZE_EXPAND_FILL);
- inspector->set_enable_capitalize_paths(false);
+ inspector->set_v_size_flags(SIZE_EXPAND_FILL);
+ inspector->set_property_name_style(EditorPropertyNameProcessor::STYLE_RAW);
inspector->set_read_only(true);
inspector->connect("object_selected", callable_mp(this, &ScriptEditorDebugger::_remote_object_selected));
inspector->connect("object_edited", callable_mp(this, &ScriptEditorDebugger::_remote_object_edited));
inspector->connect("object_property_updated", callable_mp(this, &ScriptEditorDebugger::_remote_object_property_updated));
- sc->add_child(inspector);
+ inspector->register_text_enter(search);
+ inspector->set_use_filter(true);
+ inspector_vbox->add_child(inspector);
+
+ breakpoints_tree = memnew(Tree);
+ breakpoints_tree->set_h_size_flags(SIZE_EXPAND_FILL);
+ breakpoints_tree->set_column_titles_visible(true);
+ breakpoints_tree->set_column_title(0, TTR("Breakpoints"));
+ breakpoints_tree->set_allow_reselect(true);
+ breakpoints_tree->set_allow_rmb_select(true);
+ breakpoints_tree->set_hide_root(true);
+ breakpoints_tree->connect("item_rmb_selected", callable_mp(this, &ScriptEditorDebugger::_breakpoints_item_rmb_selected));
+ breakpoints_tree->create_item();
+
+ parent_sc->add_child(breakpoints_tree);
tabs->add_child(dbg);
+
+ breakpoints_menu = memnew(PopupMenu);
+ breakpoints_menu->connect("id_pressed", callable_mp(this, &ScriptEditorDebugger::_item_menu_id_pressed));
+ breakpoints_tree->add_child(breakpoints_menu);
}
{ //errors
errors_tab = memnew(VBoxContainer);
errors_tab->set_name(TTR("Errors"));
- HBoxContainer *errhb = memnew(HBoxContainer);
- errors_tab->add_child(errhb);
+ HBoxContainer *error_hbox = memnew(HBoxContainer);
+ errors_tab->add_child(error_hbox);
- Button *expand_all = memnew(Button);
- expand_all->set_text(TTR("Expand All"));
- expand_all->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_expand_errors_list));
- errhb->add_child(expand_all);
+ expand_all_button = memnew(Button);
+ expand_all_button->set_text(TTR("Expand All"));
+ expand_all_button->set_disabled(true);
+ expand_all_button->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_expand_errors_list));
+ error_hbox->add_child(expand_all_button);
- Button *collapse_all = memnew(Button);
- collapse_all->set_text(TTR("Collapse All"));
- collapse_all->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_collapse_errors_list));
- errhb->add_child(collapse_all);
+ collapse_all_button = memnew(Button);
+ collapse_all_button->set_text(TTR("Collapse All"));
+ collapse_all_button->set_disabled(true);
+ collapse_all_button->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_collapse_errors_list));
+ error_hbox->add_child(collapse_all_button);
Control *space = memnew(Control);
space->set_h_size_flags(SIZE_EXPAND_FILL);
- errhb->add_child(space);
-
- clearbutton = memnew(Button);
- clearbutton->set_text(TTR("Clear"));
- clearbutton->set_h_size_flags(0);
- clearbutton->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_clear_errors_list));
- errhb->add_child(clearbutton);
+ error_hbox->add_child(space);
+
+ clear_button = memnew(Button);
+ clear_button->set_text(TTR("Clear"));
+ clear_button->set_h_size_flags(0);
+ clear_button->set_disabled(true);
+ clear_button->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_clear_errors_list));
+ error_hbox->add_child(clear_button);
error_tree = memnew(Tree);
error_tree->set_columns(2);
diff --git a/editor/debugger/script_editor_debugger.h b/editor/debugger/script_editor_debugger.h
index 1c1c0fd3e5..ad90e63c16 100644
--- a/editor/debugger/script_editor_debugger.h
+++ b/editor/debugger/script_editor_debugger.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -35,12 +35,10 @@
#include "editor/debugger/editor_debugger_inspector.h"
#include "editor/debugger/editor_debugger_node.h"
#include "editor/debugger/editor_debugger_server.h"
-#include "editor/editor_file_dialog.h"
#include "scene/gui/button.h"
#include "scene/gui/margin_container.h"
class Tree;
-class EditorNode;
class LineEdit;
class TabContainer;
class RichTextLabel;
@@ -50,6 +48,7 @@ class TreeItem;
class HSplitContainer;
class ItemList;
class EditorProfiler;
+class EditorFileDialog;
class EditorVisualProfiler;
class EditorNetworkProfiler;
class EditorPerformanceProfiler;
@@ -81,23 +80,31 @@ private:
enum Actions {
ACTION_COPY_ERROR,
ACTION_OPEN_SOURCE,
+ ACTION_DELETE_BREAKPOINT,
+ ACTION_DELETE_BREAKPOINTS_IN_FILE,
+ ACTION_DELETE_ALL_BREAKPOINTS,
};
- AcceptDialog *msgdialog;
+ AcceptDialog *msgdialog = nullptr;
- LineEdit *clicked_ctrl;
- LineEdit *clicked_ctrl_type;
- LineEdit *live_edit_root;
- Button *le_set;
- Button *le_clear;
- Button *export_csv;
+ LineEdit *clicked_ctrl = nullptr;
+ LineEdit *clicked_ctrl_type = nullptr;
+ LineEdit *live_edit_root = nullptr;
+ Button *le_set = nullptr;
+ Button *le_clear = nullptr;
+ Button *export_csv = nullptr;
- VBoxContainer *errors_tab;
- Tree *error_tree;
- Button *clearbutton;
- PopupMenu *item_menu;
+ VBoxContainer *errors_tab = nullptr;
+ Tree *error_tree = nullptr;
+ Button *expand_all_button = nullptr;
+ Button *collapse_all_button = nullptr;
+ Button *clear_button = nullptr;
+ PopupMenu *item_menu = nullptr;
- EditorFileDialog *file_dialog;
+ Tree *breakpoints_tree = nullptr;
+ PopupMenu *breakpoints_menu = nullptr;
+
+ EditorFileDialog *file_dialog = nullptr;
enum FileDialogPurpose {
SAVE_MONITORS_CSV,
SAVE_VRAM_CSV,
@@ -110,30 +117,31 @@ private:
bool skip_breakpoints_value = false;
Ref<Script> stack_script;
- TabContainer *tabs;
+ TabContainer *tabs = nullptr;
- Label *reason;
+ Label *reason = nullptr;
- Button *skip_breakpoints;
- Button *copy;
- Button *step;
- Button *next;
- Button *dobreak;
- Button *docontinue;
+ Button *skip_breakpoints = nullptr;
+ Button *copy = nullptr;
+ Button *step = nullptr;
+ Button *next = nullptr;
+ Button *dobreak = nullptr;
+ Button *docontinue = nullptr;
// Reference to "Remote" tab in scene tree. Needed by _live_edit_set and buttons state.
// Each debugger should have it's tree in the future I guess.
const Tree *editor_remote_tree = nullptr;
Map<int, String> profiler_signature;
- Tree *vmem_tree;
- Button *vmem_refresh;
- Button *vmem_export;
- LineEdit *vmem_total;
+ Tree *vmem_tree = nullptr;
+ Button *vmem_refresh = nullptr;
+ Button *vmem_export = nullptr;
+ LineEdit *vmem_total = nullptr;
- Tree *stack_dump;
- EditorDebuggerInspector *inspector;
- SceneDebuggerTree *scene_tree;
+ Tree *stack_dump = nullptr;
+ LineEdit *search = nullptr;
+ EditorDebuggerInspector *inspector = nullptr;
+ SceneDebuggerTree *scene_tree = nullptr;
Ref<RemoteDebuggerPeer> peer;
@@ -141,12 +149,10 @@ private:
int last_path_id;
Map<String, int> res_path_cache;
- EditorProfiler *profiler;
- EditorVisualProfiler *visual_profiler;
- EditorNetworkProfiler *network_profiler;
- EditorPerformanceProfiler *performance_profiler;
-
- EditorNode *editor;
+ EditorProfiler *profiler = nullptr;
+ EditorVisualProfiler *visual_profiler = nullptr;
+ EditorNetworkProfiler *network_profiler = nullptr;
+ EditorPerformanceProfiler *performance_profiler = nullptr;
OS::ProcessID remote_pid = 0;
bool breaked = false;
@@ -181,7 +187,7 @@ private:
void _live_edit_set();
void _live_edit_clear();
- void _method_changed(Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE);
+ void _method_changed(Object *p_base, const StringName &p_name, const Variant **p_args, int p_argcount);
void _property_changed(Object *p_base, const StringName &p_property, const Variant &p_value);
void _error_activated();
@@ -195,6 +201,7 @@ private:
void _clear_errors_list();
+ void _breakpoints_item_rmb_selected(const Vector2 &p_pos);
void _error_tree_item_rmb_selected(const Vector2 &p_pos);
void _item_menu_id_pressed(int p_option);
void _tab_changed(int p_tab);
@@ -208,6 +215,8 @@ private:
void _set_breakpoint(const String &p_path, const int &p_line, const bool &p_enabled);
void _clear_breakpoints();
+ void _breakpoint_tree_clicked();
+
protected:
void _notification(int p_what);
static void _bind_methods();
@@ -286,7 +295,7 @@ public:
void unregister_message_capture(const StringName &p_name);
bool has_capture(const StringName &p_name);
- ScriptEditorDebugger(EditorNode *p_editor = nullptr);
+ ScriptEditorDebugger();
~ScriptEditorDebugger();
};