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.cpp4
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_protocol.cpp41
-rw-r--r--editor/debugger/editor_debugger_inspector.cpp17
-rw-r--r--editor/debugger/editor_debugger_node.cpp22
-rw-r--r--editor/debugger/editor_debugger_node.h3
-rw-r--r--editor/debugger/editor_debugger_server.cpp48
-rw-r--r--editor/debugger/editor_debugger_server.h4
-rw-r--r--editor/debugger/editor_debugger_tree.cpp2
-rw-r--r--editor/debugger/editor_network_profiler.cpp18
-rw-r--r--editor/debugger/editor_performance_profiler.cpp16
-rw-r--r--editor/debugger/editor_profiler.cpp22
-rw-r--r--editor/debugger/editor_visual_profiler.cpp16
-rw-r--r--editor/debugger/script_editor_debugger.cpp82
-rw-r--r--editor/debugger/script_editor_debugger.h4
14 files changed, 193 insertions, 106 deletions
diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.cpp b/editor/debugger/debug_adapter/debug_adapter_parser.cpp
index fbd3aaa409..485d58f4a3 100644
--- a/editor/debugger/debug_adapter/debug_adapter_parser.cpp
+++ b/editor/debugger/debug_adapter/debug_adapter_parser.cpp
@@ -306,8 +306,8 @@ Dictionary DebugAdapterParser::req_stackTrace(const Dictionary &p_params) const
Array arr;
DebugAdapterProtocol *dap = DebugAdapterProtocol::get_singleton();
- for (Map<DAP::StackFrame, List<int>>::Element *E = dap->stackframe_list.front(); E; E = E->next()) {
- DAP::StackFrame sf = E->key();
+ for (const KeyValue<DAP::StackFrame, List<int>> &E : dap->stackframe_list) {
+ DAP::StackFrame sf = E.key;
if (!lines_at_one) {
sf.line--;
}
diff --git a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp
index 2e0e6cb7c8..36fbf8adf1 100644
--- a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp
+++ b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp
@@ -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/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp
index a1eb71235c..9346b8f1af 100644
--- a/editor/debugger/editor_debugger_inspector.cpp
+++ b/editor/debugger/editor_debugger_inspector.cpp
@@ -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);
}
}
@@ -200,12 +205,12 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) {
}
void EditorDebuggerInspector::clear_cache() {
- for (Map<ObjectID, EditorDebuggerRemoteObject *>::Element *E = remote_objects.front(); E; E = E->next()) {
+ 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_history()->get_current() == E.value->get_instance_id()) {
editor->push_item(nullptr);
}
- memdelete(E->value());
+ memdelete(E.value);
}
remote_objects.clear();
remote_dependencies.clear();
diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp
index be84e8dec5..8ea028a7de 100644
--- a/editor/debugger/editor_debugger_node.cpp
+++ b/editor/debugger/editor_debugger_node.cpp
@@ -59,7 +59,7 @@ 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_tab_alignment(TabContainer::ALIGNMENT_LEFT);
tabs->set_tabs_visible(false);
tabs->connect("tab_changed", callable_mp(this, &EditorDebuggerNode::_debugger_changed));
add_child(tabs);
@@ -183,6 +183,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);
@@ -265,15 +270,20 @@ void EditorDebuggerNode::_notification(int p_what) {
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;
@@ -328,9 +338,9 @@ void EditorDebuggerNode::_notification(int p_what) {
debugger->set_editor_remote_tree(remote_scene_tree);
debugger->start(server->take_connection());
// Send breakpoints.
- for (Map<Breakpoint, bool>::Element *E = breakpoints.front(); E; E = E->next()) {
- const Breakpoint &bp = E->key();
- debugger->set_breakpoint(bp.source, bp.line, E->get());
+ 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();
@@ -497,8 +507,8 @@ void EditorDebuggerNode::set_breakpoints(const String &p_path, Array p_lines) {
set_breakpoint(p_path, p_lines[i], true);
}
- for (Map<Breakpoint, bool>::Element *E = breakpoints.front(); E; E = E->next()) {
- Breakpoint b = E->key();
+ for (const KeyValue<Breakpoint, bool> &E : breakpoints) {
+ Breakpoint b = E.key;
if (b.source == p_path && !p_lines.has(b.line)) {
set_breakpoint(p_path, b.line, false);
}
diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h
index 4d9e846834..135122db68 100644
--- a/editor/debugger/editor_debugger_node.h
+++ b/editor/debugger/editor_debugger_node.h
@@ -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..34904d55aa 100644
--- a/editor/debugger/editor_debugger_server.cpp
+++ b/editor/debugger/editor_debugger_server.cpp
@@ -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..6a4ca895d1 100644
--- a/editor/debugger/editor_debugger_server.h
+++ b/editor/debugger/editor_debugger_server.h
@@ -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..be369aa0ca 100644
--- a/editor/debugger/editor_debugger_tree.cpp
+++ b/editor/debugger/editor_debugger_tree.cpp
@@ -107,7 +107,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();
}
diff --git a/editor/debugger/editor_network_profiler.cpp b/editor/debugger/editor_network_profiler.cpp
index 9479fbd5d4..8b1f0085d5 100644
--- a/editor/debugger/editor_network_profiler.cpp
+++ b/editor/debugger/editor_network_profiler.cpp
@@ -56,18 +56,18 @@ void EditorNetworkProfiler::_update_frame() {
TreeItem *root = counters_display->create_item();
- for (Map<ObjectID, DebuggerMarshalls::MultiplayerNodeInfo>::Element *E = nodes_data.front(); E; E = E->next()) {
+ for (const KeyValue<ObjectID, DebuggerMarshalls::MultiplayerNodeInfo> &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->get().node_path);
- node->set_text(1, E->get().incoming_rpc == 0 ? "-" : itos(E->get().incoming_rpc));
- node->set_text(2, E->get().incoming_rset == 0 ? "-" : itos(E->get().incoming_rset));
- node->set_text(3, E->get().outgoing_rpc == 0 ? "-" : itos(E->get().outgoing_rpc));
- node->set_text(4, E->get().outgoing_rset == 0 ? "-" : itos(E->get().outgoing_rset));
+ 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));
}
}
@@ -149,7 +149,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 +163,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
diff --git a/editor/debugger/editor_performance_profiler.cpp b/editor/debugger/editor_performance_profiler.cpp
index 08ed675d16..6106f1755d 100644
--- a/editor/debugger/editor_performance_profiler.cpp
+++ b/editor/debugger/editor_performance_profiler.cpp
@@ -132,14 +132,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 +152,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 +191,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 +249,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,8 +378,8 @@ 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);
diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp
index fa9c9f61f5..2bdacb51b8 100644
--- a/editor/debugger/editor_profiler.cpp
+++ b/editor/debugger/editor_profiler.cpp
@@ -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;
@@ -438,7 +438,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,7 +453,7 @@ 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)
@@ -515,11 +515,11 @@ Vector<Vector<String>> EditorProfiler::get_data_as_csv() const {
if (!m.valid) {
continue;
}
- for (Map<StringName, Metric::Category *>::Element *E = m.category_ptrs.front(); E; E = E->next()) {
- possible_signatures.insert(E->key());
+ for (const KeyValue<StringName, Metric::Category *> &E : m.category_ptrs) {
+ possible_signatures.insert(E.key);
}
- for (Map<StringName, Metric::Category::Item *>::Element *E = m.item_ptrs.front(); E; E = E->next()) {
- possible_signatures.insert(E->key());
+ for (const KeyValue<StringName, Metric::Category::Item *> &E : m.item_ptrs) {
+ possible_signatures.insert(E.key);
}
}
@@ -557,11 +557,11 @@ Vector<Vector<String>> EditorProfiler::get_data_as_csv() const {
values.clear();
values.resize(possible_signatures.size());
- for (Map<StringName, Metric::Category *>::Element *E = m.category_ptrs.front(); E; E = E->next()) {
- values.write[sig_map[E->key()]] = String::num_real(E->value()->total_time);
+ for (const KeyValue<StringName, Metric::Category *> &E : m.category_ptrs) {
+ values.write[sig_map[E.key]] = String::num_real(E.value->total_time);
}
- for (Map<StringName, Metric::Category::Item *>::Element *E = m.item_ptrs.front(); E; E = E->next()) {
- values.write[sig_map[E->key()]] = String::num_real(E->value()->total);
+ for (const KeyValue<StringName, Metric::Category::Item *> &E : m.item_ptrs) {
+ values.write[sig_map[E.key]] = String::num_real(E.value->total);
}
res.push_back(values);
diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp
index f17ad0d36c..a4e4ed4020 100644
--- a/editor/debugger/editor_visual_profiler.cpp
+++ b/editor/debugger/editor_visual_profiler.cpp
@@ -370,8 +370,8 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) {
float total_gpu = E->get_metadata(2);
total_cpu += cpu_time;
total_gpu += gpu_time;
- E->set_metadata(1, cpu_time);
- E->set_metadata(2, gpu_time);
+ E->set_metadata(1, total_cpu);
+ E->set_metadata(2, total_gpu);
}
category->set_icon(0, track_icon);
@@ -462,7 +462,7 @@ void EditorVisualProfiler::_graph_tex_draw() {
graph->draw_line(Vector2(0, frame_y), Vector2(half_width, frame_y), Color(1, 1, 1, 0.3));
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));
+ 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(1, 1, 1, 0.6));
}
if (graph_height_gpu > 0) {
@@ -473,11 +473,11 @@ void EditorVisualProfiler::_graph_tex_draw() {
graph->draw_line(Vector2(half_width, frame_y), Vector2(graph->get_size().x, frame_y), Color(1, 1, 1, 0.3));
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));
+ 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(1, 1, 1, 0.6));
}
- 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));
+ 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(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:", HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(1, 1, 1, 0.8));
/*
if (hover_metric != -1 && frame_metrics[hover_metric].valid) {
@@ -517,7 +517,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 +549,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;
diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp
index 5fda1c76ef..4f7dc78017 100644
--- a/editor/debugger/script_editor_debugger.cpp
+++ b/editor/debugger/script_editor_debugger.cpp
@@ -79,7 +79,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);
@@ -147,7 +147,7 @@ void ScriptEditorDebugger::update_tabs() {
}
void ScriptEditorDebugger::clear_style() {
- tabs->add_theme_style_override("panel", nullptr);
+ tabs->remove_theme_style_override("panel");
}
void ScriptEditorDebugger::save_node(ObjectID p_id, const String &p_file) {
@@ -312,7 +312,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);
@@ -499,7 +499,11 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
error->set_icon(0, get_theme_icon(oe.warning ? "Warning" : "Error", "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);
+ error->set_custom_color(1, color);
String error_title;
if (oe.callstack.size() > 0) {
@@ -520,7 +524,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);
@@ -538,7 +542,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.
@@ -561,7 +565,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";
}
@@ -574,6 +578,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 {
@@ -1073,7 +1083,7 @@ 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);
@@ -1103,7 +1113,7 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p
if (p_value.is_ref()) {
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);
@@ -1123,13 +1133,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()) {
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);
@@ -1234,7 +1244,7 @@ void ScriptEditorDebugger::update_live_edit_root() {
Array msg;
msg.push_back(np);
if (editor->get_edited_scene()) {
- msg.push_back(editor->get_edited_scene()->get_filename());
+ msg.push_back(editor->get_edited_scene()->get_scene_file_path());
} else {
msg.push_back("");
}
@@ -1400,12 +1410,17 @@ 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);
}
// 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);
@@ -1413,7 +1428,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();
}
}
@@ -1559,7 +1574,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
editor = p_editor;
tabs = memnew(TabContainer);
- tabs->set_tab_align(TabContainer::ALIGN_LEFT);
+ tabs->set_tab_alignment(TabContainer::ALIGNMENT_LEFT);
tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles")));
tabs->connect("tab_changed", callable_mp(this, &ScriptEditorDebugger::_tab_changed));
@@ -1658,28 +1673,31 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
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..76209aef46 100644
--- a/editor/debugger/script_editor_debugger.h
+++ b/editor/debugger/script_editor_debugger.h
@@ -94,7 +94,9 @@ private:
VBoxContainer *errors_tab;
Tree *error_tree;
- Button *clearbutton;
+ Button *expand_all_button;
+ Button *collapse_all_button;
+ Button *clear_button;
PopupMenu *item_menu;
EditorFileDialog *file_dialog;