summaryrefslogtreecommitdiff
path: root/editor/script_editor_debugger.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/script_editor_debugger.cpp')
-rw-r--r--editor/script_editor_debugger.cpp560
1 files changed, 411 insertions, 149 deletions
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index c3b62810f1..afbd8832f2 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -33,6 +33,9 @@
#include "core/io/marshalls.h"
#include "core/project_settings.h"
#include "core/ustring.h"
+#include "editor/plugins/canvas_item_editor_plugin.h"
+#include "editor/plugins/spatial_editor_plugin.h"
+#include "editor_network_profiler.h"
#include "editor_node.h"
#include "editor_profiler.h"
#include "editor_settings.h"
@@ -201,6 +204,21 @@ void ScriptEditorDebugger::debug_copy() {
OS::get_singleton()->set_clipboard(msg);
}
+void ScriptEditorDebugger::debug_skip_breakpoints() {
+ skip_breakpoints_value = !skip_breakpoints_value;
+ if (skip_breakpoints_value)
+ skip_breakpoints->set_icon(get_icon("DebugSkipBreakpointsOn", "EditorIcons"));
+ else
+ skip_breakpoints->set_icon(get_icon("DebugSkipBreakpointsOff", "EditorIcons"));
+
+ if (connection.is_valid()) {
+ Array msg;
+ msg.push_back("set_skip_breakpoints");
+ msg.push_back(skip_breakpoints_value);
+ ppeer->put_var(msg);
+ }
+}
+
void ScriptEditorDebugger::debug_next() {
ERR_FAIL_COND(!breaked);
@@ -305,49 +323,51 @@ void ScriptEditorDebugger::_scene_tree_rmb_selected(const Vector2 &p_position) {
}
void ScriptEditorDebugger::_file_selected(const String &p_file) {
- if (file_dialog_mode == SAVE_NODE) {
-
- Array msg;
- msg.push_back("save_node");
- msg.push_back(inspected_object_id);
- msg.push_back(p_file);
- ppeer->put_var(msg);
- } else if (file_dialog_mode == SAVE_CSV) {
+ switch (file_dialog_mode) {
+ case SAVE_NODE: {
+ Array msg;
+ msg.push_back("save_node");
+ msg.push_back(inspected_object_id);
+ msg.push_back(p_file);
+ ppeer->put_var(msg);
+ } break;
+ case SAVE_CSV: {
+ Error err;
+ FileAccessRef file = FileAccess::open(p_file, FileAccess::WRITE, &err);
- Error err;
- FileAccessRef file = FileAccess::open(p_file, FileAccess::WRITE, &err);
+ if (err != OK) {
+ ERR_PRINTS("Failed to open " + p_file);
+ return;
+ }
+ Vector<String> line;
+ line.resize(Performance::MONITOR_MAX);
- if (err != OK) {
- ERR_PRINTS("Failed to open " + p_file);
- return;
- }
- Vector<String> line;
- line.resize(Performance::MONITOR_MAX);
+ // signatures
+ for (int i = 0; i < Performance::MONITOR_MAX; i++) {
+ line.write[i] = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i));
+ }
+ file->store_csv_line(line);
- // signatures
- for (int i = 0; i < Performance::MONITOR_MAX; i++) {
- line.write[i] = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i));
- }
- file->store_csv_line(line);
+ // values
+ List<Vector<float> >::Element *E = perf_history.back();
+ while (E) {
- // values
- List<Vector<float> >::Element *E = perf_history.back();
- while (E) {
+ Vector<float> &perf_data = E->get();
+ for (int i = 0; i < perf_data.size(); i++) {
- Vector<float> &perf_data = E->get();
- for (int i = 0; i < perf_data.size(); i++) {
+ line.write[i] = String::num_real(perf_data[i]);
+ }
+ file->store_csv_line(line);
+ E = E->prev();
+ }
+ file->store_string("\n");
- line.write[i] = String::num_real(perf_data[i]);
+ Vector<Vector<String> > profiler_data = profiler->get_data_as_csv();
+ for (int i = 0; i < profiler_data.size(); i++) {
+ file->store_csv_line(profiler_data[i]);
}
- file->store_csv_line(line);
- E = E->prev();
- }
- file->store_string("\n");
- Vector<Vector<String> > profiler_data = profiler->get_data_as_csv();
- for (int i = 0; i < profiler_data.size(); i++) {
- file->store_csv_line(profiler_data[i]);
- }
+ } break;
}
}
@@ -381,6 +401,85 @@ void ScriptEditorDebugger::_scene_tree_request() {
ppeer->put_var(msg);
}
+/// Populates inspect_scene_tree recursively given data in nodes.
+/// Nodes is an array containing 4 elements for each node, it follows this pattern:
+/// nodes[i] == number of direct children of this node
+/// nodes[i + 1] == node name
+/// nodes[i + 2] == node class
+/// nodes[i + 3] == node instance id
+///
+/// Returns the number of items parsed in nodes from current_index.
+///
+/// Given a nodes array like [R,A,B,C,D,E] the following Tree will be generated, assuming
+/// filter is an empty String, R and A child count are 2, B is 1 and C, D and E are 0.
+///
+/// R
+/// |-A
+/// | |-B
+/// | | |-C
+/// | |
+/// | |-D
+/// |
+/// |-E
+///
+int ScriptEditorDebugger::_update_scene_tree(TreeItem *parent, const Array &nodes, int current_index) {
+ String filter = EditorNode::get_singleton()->get_scene_tree_dock()->get_filter();
+ String item_text = nodes[current_index + 1];
+ String item_type = nodes[current_index + 2];
+ bool keep = filter.is_subsequence_ofi(item_text);
+
+ TreeItem *item = inspect_scene_tree->create_item(parent);
+ item->set_text(0, item_text);
+ item->set_tooltip(0, TTR("Type:") + " " + item_type);
+ ObjectID id = ObjectID(nodes[current_index + 3]);
+ Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(nodes[current_index + 2], "");
+ if (icon.is_valid()) {
+ item->set_icon(0, icon);
+ }
+ item->set_metadata(0, id);
+
+ if (id == inspected_object_id) {
+ TreeItem *cti = item->get_parent();
+ while (cti) {
+ cti->set_collapsed(false);
+ cti = cti->get_parent();
+ }
+ item->select(0);
+ }
+
+ // Set current item as collapsed if necessary
+ if (parent) {
+ if (!unfold_cache.has(id)) {
+ item->set_collapsed(true);
+ }
+ }
+
+ int children_count = nodes[current_index];
+ // Tracks the total number of items parsed in nodes, this is used to skips nodes that
+ // are not direct children of the current node since we can't know in advance the total
+ // number of children, direct and not, of a node without traversing the nodes array previously.
+ // Keeping track of this allows us to build our remote scene tree by traversing the node
+ // array just once.
+ int items_count = 1;
+ for (int i = 0; i < children_count; i++) {
+ // Called for each direct child of item.
+ // Direct children of current item might not be adjacent so items_count must
+ // be incremented by the number of items parsed until now, otherwise we would not
+ // be able to access the next child of the current item.
+ // items_count is multiplied by 4 since that's the number of elements in the nodes
+ // array needed to represent a single node.
+ items_count += _update_scene_tree(item, nodes, current_index + items_count * 4);
+ }
+
+ // If item has not children and should not be kept delete it
+ if (!keep && !item->get_children() && parent) {
+ parent->remove_child(item);
+ memdelete(item);
+ }
+
+ return items_count;
+}
+
void ScriptEditorDebugger::_video_mem_request() {
ERR_FAIL_COND(connection.is_null());
@@ -453,48 +552,8 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
updating_scene_tree = true;
- for (int i = 0; i < p_data.size(); i += 4) {
-
- TreeItem *p;
- int level = p_data[i];
- if (level == 0) {
- p = NULL;
- } else {
- ERR_CONTINUE(!lv.has(level - 1));
- p = lv[level - 1];
- }
-
- TreeItem *it = inspect_scene_tree->create_item(p);
-
- ObjectID id = ObjectID(p_data[i + 3]);
-
- it->set_text(0, p_data[i + 1]);
- Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(p_data[i + 2], "");
- if (icon.is_valid())
- it->set_icon(0, icon);
- it->set_metadata(0, id);
+ _update_scene_tree(NULL, p_data, 0);
- if (id == inspected_object_id) {
- TreeItem *cti = it->get_parent(); //ensure selected is always uncollapsed
- while (cti) {
- cti->set_collapsed(false);
- cti = cti->get_parent();
- }
- it->select(0);
- }
-
- if (p) {
- if (!unfold_cache.has(id)) {
- it->set_collapsed(true);
- }
- } else {
- if (unfold_cache.has(id)) { //reverse for root
- it->set_collapsed(true);
- }
- }
-
- lv[level] = it;
- }
updating_scene_tree = false;
le_clear->set_disabled(false);
@@ -540,10 +599,30 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
if (var.is_zero()) {
var = RES();
} else if (var.get_type() == Variant::STRING) {
- var = ResourceLoader::load(var);
-
- if (pinfo.hint_string == "Script")
- debugObj->set_script(var);
+ String path = var;
+ if (path.find("::") != -1) {
+ // built-in resource
+ String base_path = path.get_slice("::", 0);
+ if (ResourceLoader::get_resource_type(base_path) == "PackedScene") {
+ if (!EditorNode::get_singleton()->is_scene_open(base_path)) {
+ EditorNode::get_singleton()->load_scene(base_path);
+ }
+ } else {
+ EditorNode::get_singleton()->load_resource(base_path);
+ }
+ }
+ var = ResourceLoader::load(path);
+
+ if (pinfo.hint_string == "Script") {
+ if (debugObj->get_script() != var) {
+ debugObj->set_script(RefPtr());
+ Ref<Script> script(var);
+ if (!script.is_null()) {
+ ScriptInstance *script_instance = script->placeholder_instance_create(debugObj);
+ debugObj->set_script_and_instance(var, script_instance);
+ }
+ }
+ }
} else if (var.get_type() == Variant::OBJECT) {
if (((Object *)var)->is_class("EncodedObjectAsID")) {
var = Object::cast_to<EncodedObjectAsID>(var)->get_object_id();
@@ -624,8 +703,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
d["frame"] = i;
s->set_metadata(0, d);
- //String line = itos(i)+" - "+String(d["file"])+":"+itos(d["line"])+" - at func: "+d["function"];
- String line = itos(i) + " - " + String(d["file"]) + ":" + itos(d["line"]);
+ String line = itos(i) + " - " + String(d["file"]) + ":" + itos(d["line"]) + " - at function: " + d["function"];
s->set_text(0, line);
if (i == 0)
@@ -672,6 +750,10 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
}
variables->add_property("Members/" + n, v, h, hs);
+
+ if (n == "self") {
+ _scene_tree_property_select_object(v);
+ }
}
ofs += mcount * 2;
@@ -727,20 +809,8 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
String tt = vs;
switch (Performance::MonitorType((int)perf_items[i]->get_metadata(1))) {
case Performance::MONITOR_TYPE_MEMORY: {
- // for the time being, going above GBs is a bad sign.
- String unit = "B";
- if ((int)v > 1073741824) {
- unit = "GB";
- v /= 1073741824.0;
- } else if ((int)v > 1048576) {
- unit = "MB";
- v /= 1048576.0;
- } else if ((int)v > 1024) {
- unit = "KB";
- v /= 1024.0;
- }
- tt += " bytes";
- vs = String::num(v, 2) + " " + unit;
+ vs = String::humanize_size(v);
+ tt = vs;
} break;
case Performance::MONITOR_TYPE_TIME: {
tt += " seconds";
@@ -762,60 +832,102 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
} else if (p_msg == "error") {
- Array err = p_data[0];
-
- Array vals;
- vals.push_back(err[0]);
- vals.push_back(err[1]);
- vals.push_back(err[2]);
- vals.push_back(err[3]);
+ // Should have at least two elements, error array and stack items count.
+ ERR_FAIL_COND_MSG(p_data.size() < 2, "Malformed error message from script debugger.");
- bool warning = err[9];
+ // Error or warning data.
+ Array err = p_data[0];
+ ERR_FAIL_COND_MSG(err.size() < 10, "Malformed error message from script debugger.");
+
+ // Format time.
+ Array time_vals;
+ time_vals.push_back(err[0]);
+ time_vals.push_back(err[1]);
+ time_vals.push_back(err[2]);
+ time_vals.push_back(err[3]);
bool e;
- String time = String("%d:%02d:%02d:%04d").sprintf(vals, &e);
- String txt = err[8].is_zero() ? String(err[7]) : String(err[8]);
+ String time = String("%d:%02d:%02d:%04d").sprintf(time_vals, &e);
+ // Rest of the error data.
+ String method = err[4];
+ String source_file = err[5];
+ String source_line = err[6];
+ String error_cond = err[7];
+ String error_msg = err[8];
+ bool is_warning = err[9];
+ bool has_method = !method.empty();
+ bool has_error_msg = !error_msg.empty();
+ bool source_is_project_file = source_file.begins_with("res://");
+
+ // Metadata to highlight error line in scripts.
+ Array source_meta;
+ source_meta.push_back(source_file);
+ source_meta.push_back(source_line);
+
+ // Create error tree to display above error or warning details.
TreeItem *r = error_tree->get_root();
if (!r) {
r = error_tree->create_item();
}
+ // Also provide the relevant details as tooltip to quickly check without
+ // uncollapsing the tree.
+ String tooltip = is_warning ? TTR("Warning:") : TTR("Error:");
+
TreeItem *error = error_tree->create_item(r);
error->set_collapsed(true);
- error->set_icon(0, get_icon(warning ? "Warning" : "Error", "EditorIcons"));
+ error->set_icon(0, get_icon(is_warning ? "Warning" : "Error", "EditorIcons"));
error->set_text(0, time);
error->set_text_align(0, TreeItem::ALIGN_LEFT);
- error->set_text(1, txt);
-
- String source(err[5]);
- bool source_is_project_file = source.begins_with("res://");
- if (source_is_project_file)
- txt = source.get_file() + ":" + String(err[6]);
- else
- txt = source + ":" + String(err[6]);
+ String error_title;
+ // Include method name, when given, in error title.
+ if (has_method)
+ error_title += method + ": ";
+ // If we have a (custom) error message, use it as title, and add a C++ Error
+ // item with the original error condition.
+ error_title += error_msg.empty() ? error_cond : error_msg;
+ error->set_text(1, error_title);
+ tooltip += " " + error_title + "\n";
+
+ if (has_error_msg) {
+ // Add item for C++ error condition.
+ TreeItem *cpp_cond = error_tree->create_item(error);
+ cpp_cond->set_text(0, "<" + TTR("C++ Error") + ">");
+ cpp_cond->set_text(1, error_cond);
+ cpp_cond->set_text_align(0, TreeItem::ALIGN_LEFT);
+ tooltip += TTR("C++ Error:") + " " + error_cond + "\n";
+ if (source_is_project_file)
+ cpp_cond->set_metadata(0, source_meta);
+ }
- String method = err[4];
- if (method.length() > 0)
- txt += " @ " + method + "()";
+ // Source of the error.
+ String source_txt = (source_is_project_file ? source_file.get_file() : source_file) + ":" + source_line;
+ if (has_method)
+ source_txt += " @ " + method + "()";
- TreeItem *c_info = error_tree->create_item(error);
- c_info->set_text(0, "<" + TTR(source_is_project_file ? "Source" : "C Source") + ">");
- c_info->set_text(1, txt);
- c_info->set_text_align(0, TreeItem::ALIGN_LEFT);
+ 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);
+ tooltip += (source_is_project_file ? TTR("Source:") : TTR("C++ Source:")) + " " + source_txt + "\n";
+ // Set metadata to highlight error line in scripts.
if (source_is_project_file) {
- Array meta;
- meta.push_back(source);
- meta.push_back(err[6]);
- error->set_metadata(0, meta);
- c_info->set_metadata(0, meta);
+ error->set_metadata(0, source_meta);
+ cpp_source->set_metadata(0, source_meta);
}
- int scc = p_data[1];
+ error->set_tooltip(0, tooltip);
+ error->set_tooltip(1, tooltip);
- for (int i = 0; i < scc; i += 3) {
+ // Format stack trace.
+ // stack_items_count is the number of elements to parse, with 3 items per frame
+ // of the stack trace (script, method, line).
+ int stack_items_count = p_data[1];
+
+ for (int i = 0; i < stack_items_count; i += 3) {
String script = p_data[2 + i];
String method2 = p_data[3 + i];
int line = p_data[4 + i];
@@ -834,7 +946,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
stack_trace->set_text(1, script.get_file() + ":" + itos(line) + " @ " + method2 + "()");
}
- if (warning)
+ if (is_warning)
warning_count++;
else
error_count++;
@@ -960,7 +1072,20 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
profiler->add_frame_metric(metric, false);
else
profiler->add_frame_metric(metric, true);
-
+ } else if (p_msg == "network_profile") {
+ int frame_size = 6;
+ for (int i = 0; i < p_data.size(); i += frame_size) {
+ MultiplayerAPI::ProfilingInfo pi;
+ pi.node = p_data[i + 0];
+ pi.node_path = p_data[i + 1];
+ pi.incoming_rpc = p_data[i + 2];
+ pi.incoming_rset = p_data[i + 3];
+ pi.outgoing_rpc = p_data[i + 4];
+ pi.outgoing_rset = p_data[i + 5];
+ network_profiler->add_node_frame_data(pi);
+ }
+ } else if (p_msg == "network_bandwidth") {
+ network_profiler->set_bandwidth(p_data[0], p_data[1]);
} else if (p_msg == "kill_me") {
editor->call_deferred("stop_child_process");
@@ -996,14 +1121,15 @@ void ScriptEditorDebugger::_performance_draw() {
which.push_back(i);
}
- Ref<Font> graph_font = get_font("font", "TextEdit");
-
if (which.empty()) {
- perf_draw->draw_string(graph_font, Point2(0, graph_font->get_ascent()), TTR("Pick one or more items from the list to display the graph."), get_color("font_color", "Label"), perf_draw->get_size().x);
+ info_message->show();
return;
}
+ info_message->hide();
+
Ref<StyleBox> graph_sb = get_stylebox("normal", "TextEdit");
+ Ref<Font> graph_font = get_font("font", "TextEdit");
int cols = Math::ceil(Math::sqrt((float)which.size()));
int rows = Math::ceil((float)which.size() / cols);
@@ -1063,7 +1189,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
inspector->edit(variables);
-
+ skip_breakpoints->set_icon(get_icon("DebugSkipBreakpointsOff", "EditorIcons"));
copy->set_icon(get_icon("ActionCopy", "EditorIcons"));
step->set_icon(get_icon("DebugStep", "EditorIcons"));
@@ -1072,7 +1198,6 @@ void ScriptEditorDebugger::_notification(int p_what) {
forward->set_icon(get_icon("Forward", "EditorIcons"));
dobreak->set_icon(get_icon("Pause", "EditorIcons"));
docontinue->set_icon(get_icon("DebugContinue", "EditorIcons"));
- //scene_tree_refresh->set_icon( get_icon("Reload","EditorIcons"));
le_set->connect("pressed", this, "_live_edit_set");
le_clear->connect("pressed", this, "_live_edit_clear");
error_tree->connect("item_selected", this, "_error_selected");
@@ -1109,6 +1234,42 @@ void ScriptEditorDebugger::_notification(int p_what) {
}
}
}
+
+ if (camera_override == OVERRIDE_2D) {
+ CanvasItemEditor *editor = CanvasItemEditor::get_singleton();
+
+ Dictionary state = editor->get_state();
+ float zoom = state["zoom"];
+ Point2 offset = state["ofs"];
+ Transform2D transform;
+
+ transform.scale_basis(Size2(zoom, zoom));
+ transform.elements[2] = -offset * zoom;
+
+ Array msg;
+ msg.push_back("override_camera_2D:transform");
+ msg.push_back(transform);
+ ppeer->put_var(msg);
+
+ } else if (camera_override >= OVERRIDE_3D_1) {
+ int viewport_idx = camera_override - OVERRIDE_3D_1;
+ SpatialEditorViewport *viewport = SpatialEditor::get_singleton()->get_editor_viewport(viewport_idx);
+ Camera *const cam = viewport->get_camera();
+
+ Array msg;
+ msg.push_back("override_camera_3D:transform");
+ msg.push_back(cam->get_camera_transform());
+ if (cam->get_projection() == Camera::PROJECTION_ORTHOGONAL) {
+ msg.push_back(false);
+ msg.push_back(cam->get_size());
+ } else {
+ msg.push_back(true);
+ msg.push_back(cam->get_fov());
+ }
+ msg.push_back(cam->get_znear());
+ msg.push_back(cam->get_zfar());
+ ppeer->put_var(msg);
+ }
}
if (error_count != last_error_count || warning_count != last_warning_count) {
@@ -1133,15 +1294,18 @@ void ScriptEditorDebugger::_notification(int p_what) {
last_warning_count = warning_count;
}
- if (connection.is_null()) {
-
- if (server->is_connection_available()) {
-
+ if (server->is_connection_available()) {
+ if (connection.is_valid()) {
+ // We already have a valid connection. Disconnecting any new connecting client to prevent it from hanging.
+ // (If we don't keep a reference to the connection it will be destroyed and disconnect_from_host will be called internally)
+ server->take_connection();
+ } else {
+ // We just got the first connection.
connection = server->take_connection();
if (connection.is_null())
break;
- EditorNode::get_log()->add_message("** Debug Process Started **");
+ EditorNode::get_log()->add_message("--- Debugging process started ---", EditorLog::MSG_TYPE_EDITOR);
ppeer->set_stream_peer(connection);
@@ -1151,7 +1315,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
dobreak->set_disabled(false);
tabs->set_current_tab(0);
- _set_reason_text(TTR("Child Process Connected"), MESSAGE_SUCCESS);
+ _set_reason_text(TTR("Child process connected."), MESSAGE_SUCCESS);
profiler->clear();
inspect_scene_tree->clear();
@@ -1171,11 +1335,14 @@ void ScriptEditorDebugger::_notification(int p_what) {
_profiler_activate(true);
}
- } else {
-
- break;
+ if (network_profiler->is_profiling()) {
+ _network_profiler_activate(true);
+ }
}
- };
+ }
+
+ if (connection.is_null())
+ break;
if (!connection->is_connected_to_host()) {
stop();
@@ -1317,6 +1484,7 @@ void ScriptEditorDebugger::start() {
set_process(true);
breaked = false;
+ camera_override = OVERRIDE_NONE;
}
void ScriptEditorDebugger::pause() {
@@ -1336,7 +1504,7 @@ void ScriptEditorDebugger::stop() {
ppeer->set_stream_peer(Ref<StreamPeer>());
if (connection.is_valid()) {
- EditorNode::get_log()->add_message("** Debug Process Stopped **");
+ EditorNode::get_log()->add_message("--- Debugging process stopped ---", EditorLog::MSG_TYPE_EDITOR);
connection.unref();
reason->set_text("");
@@ -1390,6 +1558,25 @@ void ScriptEditorDebugger::_profiler_activate(bool p_enable) {
}
}
+void ScriptEditorDebugger::_network_profiler_activate(bool p_enable) {
+
+ if (!connection.is_valid())
+ return;
+
+ if (p_enable) {
+ Array msg;
+ msg.push_back("start_network_profiling");
+ ppeer->put_var(msg);
+ print_verbose("Starting network profiling.");
+
+ } else {
+ Array msg;
+ msg.push_back("stop_network_profiling");
+ ppeer->put_var(msg);
+ print_verbose("Ending network profiling.");
+ }
+}
+
void ScriptEditorDebugger::_profiler_seeked() {
if (!connection.is_valid() || !connection->is_connected_to_host())
@@ -1742,6 +1929,45 @@ void ScriptEditorDebugger::live_debug_reparent_node(const NodePath &p_at, const
}
}
+ScriptEditorDebugger::CameraOverride ScriptEditorDebugger::get_camera_override() const {
+ return camera_override;
+}
+
+void ScriptEditorDebugger::set_camera_override(CameraOverride p_override) {
+
+ if (p_override == OVERRIDE_2D && camera_override != OVERRIDE_2D) {
+ if (connection.is_valid()) {
+ Array msg;
+ msg.push_back("override_camera_2D:set");
+ msg.push_back(true);
+ ppeer->put_var(msg);
+ }
+ } else if (p_override != OVERRIDE_2D && camera_override == OVERRIDE_2D) {
+ if (connection.is_valid()) {
+ Array msg;
+ msg.push_back("override_camera_2D:set");
+ msg.push_back(false);
+ ppeer->put_var(msg);
+ }
+ } else if (p_override >= OVERRIDE_3D_1 && camera_override < OVERRIDE_3D_1) {
+ if (connection.is_valid()) {
+ Array msg;
+ msg.push_back("override_camera_3D:set");
+ msg.push_back(true);
+ ppeer->put_var(msg);
+ }
+ } else if (p_override < OVERRIDE_3D_1 && camera_override >= OVERRIDE_3D_1) {
+ if (connection.is_valid()) {
+ Array msg;
+ msg.push_back("override_camera_3D:set");
+ msg.push_back(false);
+ ppeer->put_var(msg);
+ }
+ }
+
+ camera_override = p_override;
+}
+
void ScriptEditorDebugger::set_breakpoint(const String &p_path, int p_line, bool p_enabled) {
if (connection.is_valid()) {
@@ -1763,6 +1989,10 @@ void ScriptEditorDebugger::reload_scripts() {
}
}
+bool ScriptEditorDebugger::is_skip_breakpoints() {
+ return skip_breakpoints_value;
+}
+
void ScriptEditorDebugger::_error_activated() {
TreeItem *selected = error_tree->get_selected();
@@ -1958,6 +2188,7 @@ void ScriptEditorDebugger::_bind_methods() {
ClassDB::bind_method(D_METHOD("_stack_dump_frame_selected"), &ScriptEditorDebugger::_stack_dump_frame_selected);
+ ClassDB::bind_method(D_METHOD("debug_skip_breakpoints"), &ScriptEditorDebugger::debug_skip_breakpoints);
ClassDB::bind_method(D_METHOD("debug_copy"), &ScriptEditorDebugger::debug_copy);
ClassDB::bind_method(D_METHOD("debug_next"), &ScriptEditorDebugger::debug_next);
@@ -1978,6 +2209,7 @@ void ScriptEditorDebugger::_bind_methods() {
ClassDB::bind_method(D_METHOD("_expand_errors_list"), &ScriptEditorDebugger::_expand_errors_list);
ClassDB::bind_method(D_METHOD("_collapse_errors_list"), &ScriptEditorDebugger::_collapse_errors_list);
ClassDB::bind_method(D_METHOD("_profiler_activate"), &ScriptEditorDebugger::_profiler_activate);
+ ClassDB::bind_method(D_METHOD("_network_profiler_activate"), &ScriptEditorDebugger::_network_profiler_activate);
ClassDB::bind_method(D_METHOD("_profiler_seeked"), &ScriptEditorDebugger::_profiler_seeked);
ClassDB::bind_method(D_METHOD("_clear_errors_list"), &ScriptEditorDebugger::_clear_errors_list);
@@ -2045,6 +2277,13 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
hbc->add_child(memnew(VSeparator));
+ skip_breakpoints = memnew(ToolButton);
+ hbc->add_child(skip_breakpoints);
+ skip_breakpoints->set_tooltip(TTR("Skip Breakpoints"));
+ skip_breakpoints->connect("pressed", this, "debug_skip_breakpoints");
+
+ hbc->add_child(memnew(VSeparator));
+
copy = memnew(ToolButton);
hbc->add_child(copy);
copy->set_tooltip(TTR("Copy Error"));
@@ -2055,11 +2294,13 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
step = memnew(ToolButton);
hbc->add_child(step);
step->set_tooltip(TTR("Step Into"));
+ step->set_shortcut(ED_GET_SHORTCUT("debugger/step_into"));
step->connect("pressed", this, "debug_step");
next = memnew(ToolButton);
hbc->add_child(next);
next->set_tooltip(TTR("Step Over"));
+ next->set_shortcut(ED_GET_SHORTCUT("debugger/step_over"));
next->connect("pressed", this, "debug_next");
hbc->add_child(memnew(VSeparator));
@@ -2067,11 +2308,13 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
dobreak = memnew(ToolButton);
hbc->add_child(dobreak);
dobreak->set_tooltip(TTR("Break"));
+ dobreak->set_shortcut(ED_GET_SHORTCUT("debugger/break"));
dobreak->connect("pressed", this, "debug_break");
docontinue = memnew(ToolButton);
hbc->add_child(docontinue);
docontinue->set_tooltip(TTR("Continue"));
+ docontinue->set_shortcut(ED_GET_SHORTCUT("debugger/continue"));
docontinue->connect("pressed", this, "debug_continue");
back = memnew(Button);
@@ -2196,6 +2439,13 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
profiler->connect("break_request", this, "_profiler_seeked");
}
+ { //network profiler
+ network_profiler = memnew(EditorNetworkProfiler);
+ network_profiler->set_name(TTR("Network Profiler"));
+ tabs->add_child(network_profiler);
+ network_profiler->connect("enable_profiling", this, "_network_profiler_activate");
+ }
+
{ //monitors
HSplitContainer *hsp = memnew(HSplitContainer);
@@ -2205,11 +2455,14 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
perf_monitors->set_column_title(0, TTR("Monitor"));
perf_monitors->set_column_title(1, TTR("Value"));
perf_monitors->set_column_titles_visible(true);
- hsp->add_child(perf_monitors);
perf_monitors->connect("item_edited", this, "_performance_select");
+ hsp->add_child(perf_monitors);
+
perf_draw = memnew(Control);
+ perf_draw->set_clip_contents(true);
perf_draw->connect("draw", this, "_performance_draw");
hsp->add_child(perf_draw);
+
hsp->set_name(TTR("Monitors"));
hsp->set_split_offset(340 * EDSCALE);
tabs->add_child(hsp);
@@ -2243,6 +2496,15 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
perf_items.push_back(it);
perf_max.write[i] = 0;
}
+
+ 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_autowrap(true);
+ info_message->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
+ info_message->set_anchors_and_margins_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE);
+ perf_draw->add_child(info_message);
}
{ //vmem inspect
@@ -2254,7 +2516,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
vmem_hb->add_child(memnew(Label(TTR("Total:") + " ")));
vmem_total = memnew(LineEdit);
vmem_total->set_editable(false);
- vmem_total->set_custom_minimum_size(Size2(100, 1) * EDSCALE);
+ vmem_total->set_custom_minimum_size(Size2(100, 0) * EDSCALE);
vmem_hb->add_child(vmem_total);
vmem_refresh = memnew(ToolButton);
vmem_hb->add_child(vmem_refresh);