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.cpp82
1 files changed, 68 insertions, 14 deletions
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index b7a904c255..9dce48937c 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -89,11 +90,13 @@ public:
return "";
}
- void add_property(const String &p_name, const Variant &p_value) {
+ void add_property(const String &p_name, const Variant &p_value, const PropertyHint &p_hint, const String p_hint_string) {
PropertyInfo pinfo;
pinfo.name = p_name;
pinfo.type = p_value.get_type();
+ pinfo.hint = p_hint;
+ pinfo.hint_string = p_hint_string;
props.push_back(pinfo);
values[p_name] = p_value;
}
@@ -436,7 +439,11 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
inspected_object->last_edited_id = id;
- inspect_properties->edit(inspected_object);
+ if (tabs->get_current_tab() == 2) {
+ inspect_properties->edit(inspected_object);
+ } else {
+ editor->push_item(inspected_object);
+ }
} else if (p_msg == "message:video_mem") {
@@ -498,13 +505,20 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
String n = p_data[ofs + i * 2 + 0];
Variant v = p_data[ofs + i * 2 + 1];
+ PropertyHint h = PROPERTY_HINT_NONE;
+ String hs = String();
if (n.begins_with("*")) {
n = n.substr(1, n.length());
+ h = PROPERTY_HINT_OBJECT_ID;
+ String s = v;
+ s = s.replace("[", "");
+ hs = s.get_slice(":", 0);
+ v = s.get_slice(":", 1).to_int();
}
- variables->add_property("members/" + n, v);
+ variables->add_property("members/" + n, v, h, hs);
}
ofs += mcount * 2;
@@ -515,13 +529,20 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
String n = p_data[ofs + i * 2 + 0];
Variant v = p_data[ofs + i * 2 + 1];
+ PropertyHint h = PROPERTY_HINT_NONE;
+ String hs = String();
if (n.begins_with("*")) {
n = n.substr(1, n.length());
+ h = PROPERTY_HINT_OBJECT_ID;
+ String s = v;
+ s = s.replace("[", "");
+ hs = s.get_slice(":", 0);
+ v = s.get_slice(":", 1).to_int();
}
- variables->add_property("locals/" + n, v);
+ variables->add_property("locals/" + n, v, h, hs);
}
variables->update();
@@ -769,19 +790,19 @@ void ScriptEditorDebugger::_performance_draw() {
Point2i p(i % cols, i / cols);
Rect2i r(p * s, s);
- r.pos += Point2(margin, margin);
+ r.position += Point2(margin, margin);
r.size -= Point2(margin, margin) * 2.0;
perf_draw->draw_style_box(graph_sb, r);
- r.pos += graph_sb->get_offset();
+ r.position += graph_sb->get_offset();
r.size -= graph_sb->get_minimum_size();
int pi = which[i];
Color c = Color(0.7, 0.9, 0.5);
c.set_hsv(Math::fmod(c.get_h() + pi * 0.7654, 1), c.get_s(), c.get_v());
c.a = 0.8;
- perf_draw->draw_string(graph_font, r.pos + Point2(0, graph_font->get_ascent()), perf_items[pi]->get_text(0), c, r.size.x);
+ perf_draw->draw_string(graph_font, r.position + Point2(0, graph_font->get_ascent()), perf_items[pi]->get_text(0), c, r.size.x);
c.a = 0.6;
- perf_draw->draw_string(graph_font, r.pos + Point2(graph_font->get_char_size('X').width, graph_font->get_ascent() + graph_font->get_height()), perf_items[pi]->get_text(1), c, r.size.y);
+ perf_draw->draw_string(graph_font, r.position + Point2(graph_font->get_char_size('X').width, graph_font->get_ascent() + graph_font->get_height()), perf_items[pi]->get_text(1), c, r.size.y);
float spacing = point_sep / float(cols);
float from = r.size.width;
@@ -798,7 +819,7 @@ void ScriptEditorDebugger::_performance_draw() {
c.a = 0.7;
if (E != perf_history.front())
- perf_draw->draw_line(r.pos + Point2(from, h), r.pos + Point2(from + spacing, prev), c, 2.0);
+ perf_draw->draw_line(r.position + Point2(from, h), r.position + Point2(from + spacing, prev), c, 2.0);
prev = h;
E = E->next();
from -= spacing;
@@ -998,6 +1019,11 @@ void ScriptEditorDebugger::_notification(int p_what) {
}
} break;
+ case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+ tabs->add_style_override("panel", editor->get_gui_base()->get_stylebox("DebuggerPanel", "EditorStyles"));
+ tabs->add_style_override("tab_fg", editor->get_gui_base()->get_stylebox("DebuggerTabFG", "EditorStyles"));
+ tabs->add_style_override("tab_bg", editor->get_gui_base()->get_stylebox("DebuggerTabBG", "EditorStyles"));
+ } break;
}
}
@@ -1009,14 +1035,17 @@ void ScriptEditorDebugger::start() {
EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
}
- uint16_t port = GLOBAL_GET("network/debug/remote_port");
perf_history.clear();
for (int i = 0; i < Performance::MONITOR_MAX; i++) {
perf_max[i] = 0;
}
- server->listen(port);
+ int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
+ if (server->listen(remote_port) != OK) {
+ EditorNode::get_log()->add_message(String("** Error listening on port ") + itos(remote_port) + String(" **"));
+ return;
+ }
set_process(true);
}
@@ -1055,6 +1084,9 @@ void ScriptEditorDebugger::stop() {
EditorNode::get_singleton()->get_pause_button()->set_pressed(false);
EditorNode::get_singleton()->get_pause_button()->set_disabled(true);
+ //avoid confusion when stopped debugging but an object is still edited
+ EditorNode::get_singleton()->push_item(NULL);
+
if (hide_on_stop) {
if (is_visible_in_tree())
EditorNode::get_singleton()->hide_bottom_panel();
@@ -1105,8 +1137,9 @@ void ScriptEditorDebugger::_stack_dump_frame_selected() {
Dictionary d = ti->get_metadata(0);
- Ref<Script> s = ResourceLoader::load(d["file"]);
- emit_signal("goto_script_line", s, int(d["line"]) - 1);
+ stack_script = ResourceLoader::load(d["file"]);
+ emit_signal("goto_script_line", stack_script, int(d["line"]) - 1);
+ stack_script.unref();
ERR_FAIL_COND(connection.is_null());
ERR_FAIL_COND(!connection->is_connected_to_host());
@@ -1490,6 +1523,21 @@ void ScriptEditorDebugger::set_hide_on_stop(bool p_hide) {
hide_on_stop = p_hide;
}
+bool ScriptEditorDebugger::get_debug_with_external_editor() const {
+
+ return enable_external_editor;
+}
+
+void ScriptEditorDebugger::set_debug_with_external_editor(bool p_enabled) {
+
+ enable_external_editor = p_enabled;
+}
+
+Ref<Script> ScriptEditorDebugger::get_dump_stack_script() const {
+
+ return stack_script;
+}
+
void ScriptEditorDebugger::_paused() {
ERR_FAIL_COND(connection.is_null());
@@ -1550,6 +1598,10 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
editor = p_editor;
tabs = memnew(TabContainer);
+ tabs->set_tab_align(TabContainer::ALIGN_LEFT);
+ tabs->add_style_override("panel", editor->get_gui_base()->get_stylebox("DebuggerPanel", "EditorStyles"));
+ tabs->add_style_override("tab_fg", editor->get_gui_base()->get_stylebox("DebuggerTabFG", "EditorStyles"));
+ tabs->add_style_override("tab_bg", editor->get_gui_base()->get_stylebox("DebuggerTabBG", "EditorStyles"));
tabs->set_v_size_flags(SIZE_EXPAND_FILL);
tabs->set_area_as_parent_rect();
add_child(tabs);
@@ -1624,8 +1676,9 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
inspector->set_h_size_flags(SIZE_EXPAND_FILL);
inspector->hide_top_label();
inspector->get_scene_tree()->set_column_title(0, TTR("Variable"));
- inspector->set_capitalize_paths(false);
+ inspector->set_enable_capitalize_paths(false);
inspector->set_read_only(true);
+ inspector->connect("object_id_selected", this, "_scene_tree_property_select_object");
sc->add_child(inspector);
server = TCP_Server::create_ref();
@@ -1834,6 +1887,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
last_path_id = false;
error_count = 0;
hide_on_stop = true;
+ enable_external_editor = false;
last_error_count = 0;
EditorNode::get_singleton()->get_pause_button()->connect("pressed", this, "_paused");