You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
Merge pull request #10891 from GodotExplorer/pr-debugger-2.1.4
[2.1] Some improvements for debugger
This commit is contained in:
@@ -86,6 +86,20 @@ void EditorHistory::_add_object(ObjectID p_object, const String &p_property, int
|
|||||||
bool has_prev = current >= 0 && current < history.size();
|
bool has_prev = current >= 0 && current < history.size();
|
||||||
|
|
||||||
if (has_prev) {
|
if (has_prev) {
|
||||||
|
|
||||||
|
if (obj->is_type("ScriptEditorDebuggerInspectedObject")) {
|
||||||
|
for (int i = current; i >= 0; i--) {
|
||||||
|
Object *pre_obj = ObjectDB::get_instance(get_history_obj(i));
|
||||||
|
if (pre_obj->is_type("ScriptEditorDebuggerInspectedObject")) {
|
||||||
|
if (pre_obj->call("get_remote_object_id") == obj->call("get_remote_object_id")) {
|
||||||
|
History &pr = history[i];
|
||||||
|
pr.path[pr.path.size() - 1] = o;
|
||||||
|
current = i;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
history.resize(current + 1); //clip history to next
|
history.resize(current + 1); //clip history to next
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,12 +43,14 @@
|
|||||||
#include "os/input.h"
|
#include "os/input.h"
|
||||||
#include "os/keyboard.h"
|
#include "os/keyboard.h"
|
||||||
#include "pair.h"
|
#include "pair.h"
|
||||||
|
#include "plugins/script_editor_plugin.h"
|
||||||
#include "print_string.h"
|
#include "print_string.h"
|
||||||
#include "scene/gui/label.h"
|
#include "scene/gui/label.h"
|
||||||
#include "scene/main/viewport.h"
|
#include "scene/main/viewport.h"
|
||||||
#include "scene/resources/font.h"
|
#include "scene/resources/font.h"
|
||||||
#include "scene/resources/packed_scene.h"
|
#include "scene/resources/packed_scene.h"
|
||||||
#include "scene/scene_string_names.h"
|
#include "scene/scene_string_names.h"
|
||||||
|
#include "script_editor_debugger.h"
|
||||||
|
|
||||||
void CustomPropertyEditor::_notification(int p_what) {
|
void CustomPropertyEditor::_notification(int p_what) {
|
||||||
|
|
||||||
@@ -3616,10 +3618,19 @@ void PropertyEditor::edit(Object *p_object) {
|
|||||||
|
|
||||||
if (obj) {
|
if (obj) {
|
||||||
|
|
||||||
|
set_enable_capitalize_paths(true);
|
||||||
obj->remove_change_receptor(this);
|
obj->remove_change_receptor(this);
|
||||||
|
|
||||||
if (obj->is_type("ScriptEditorDebuggerInspectedObject"))
|
if (obj->is_type("ScriptEditorDebuggerInspectedObject")) {
|
||||||
|
ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
|
||||||
|
if (sed->is_connected()) {
|
||||||
set_enable_capitalize_paths(false);
|
set_enable_capitalize_paths(false);
|
||||||
|
emit_signal("object_id_selected", obj->call("get_remote_object_id"));
|
||||||
|
} else {
|
||||||
|
obj = NULL;
|
||||||
|
p_object = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
evaluator->edit(p_object);
|
evaluator->edit(p_object);
|
||||||
|
|||||||
@@ -213,6 +213,7 @@ class PropertyEditor : public Control {
|
|||||||
void _node_removed(Node *p_node);
|
void _node_removed(Node *p_node);
|
||||||
|
|
||||||
friend class ProjectExportDialog;
|
friend class ProjectExportDialog;
|
||||||
|
friend class ScriptEditorDebugger;
|
||||||
void _edit_set(const String &p_name, const Variant &p_value, const String &p_changed_field = "");
|
void _edit_set(const String &p_name, const Variant &p_value, const String &p_changed_field = "");
|
||||||
void _draw_flags(Object *ti, const Rect2 &p_rect);
|
void _draw_flags(Object *ti, const Rect2 &p_rect);
|
||||||
|
|
||||||
|
|||||||
@@ -250,6 +250,10 @@ void ScriptEditorDebugger::debug_continue() {
|
|||||||
ppeer->put_var(msg);
|
ppeer->put_var(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ScriptEditorDebugger::is_connected() const {
|
||||||
|
return connection.is_valid() && connection->is_connected();
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptEditorDebugger::_scene_tree_folded(Object *obj) {
|
void ScriptEditorDebugger::_scene_tree_folded(Object *obj) {
|
||||||
|
|
||||||
if (updating_scene_tree) {
|
if (updating_scene_tree) {
|
||||||
@@ -312,6 +316,9 @@ void ScriptEditorDebugger::_scene_tree_variable_value_edited(const String &p_pro
|
|||||||
|
|
||||||
void ScriptEditorDebugger::_scene_tree_property_select_object(ObjectID p_object) {
|
void ScriptEditorDebugger::_scene_tree_property_select_object(ObjectID p_object) {
|
||||||
|
|
||||||
|
if (p_object == inspected_object_id)
|
||||||
|
return;
|
||||||
|
|
||||||
inspected_object_id = p_object;
|
inspected_object_id = p_object;
|
||||||
Array msg;
|
Array msg;
|
||||||
msg.push_back("inspect_object");
|
msg.push_back("inspect_object");
|
||||||
@@ -489,7 +496,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
|
|||||||
debugObj->update_single(pinfo.name.ascii().get_data());
|
debugObj->update_single(pinfo.name.ascii().get_data());
|
||||||
}
|
}
|
||||||
|
|
||||||
debugObj->update();
|
inspected_object_id = id;
|
||||||
editor->push_item(debugObj, "");
|
editor->push_item(debugObj, "");
|
||||||
|
|
||||||
} else if (p_msg == "message:video_mem") {
|
} else if (p_msg == "message:video_mem") {
|
||||||
@@ -985,33 +992,18 @@ void ScriptEditorDebugger::_notification(int p_what) {
|
|||||||
case NOTIFICATION_PROCESS: {
|
case NOTIFICATION_PROCESS: {
|
||||||
|
|
||||||
if (connection.is_valid()) {
|
if (connection.is_valid()) {
|
||||||
inspect_scene_tree_timeout -= get_process_delta_time();
|
|
||||||
if (inspect_scene_tree_timeout < 0) {
|
|
||||||
inspect_scene_tree_timeout = EditorSettings::get_singleton()->get("debugger/scene_tree_refresh_interval");
|
|
||||||
if (inspect_scene_tree->is_visible()) {
|
|
||||||
_scene_tree_request();
|
|
||||||
|
|
||||||
if (inspected_object_id != 0) {
|
|
||||||
//take the chance and re-inspect selected object
|
|
||||||
Array msg;
|
|
||||||
msg.push_back("inspect_object");
|
|
||||||
msg.push_back(inspected_object_id);
|
|
||||||
ppeer->put_var(msg);
|
|
||||||
inspected_object_id = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inspect_edited_object_timeout -= get_process_delta_time();
|
inspect_edited_object_timeout -= get_process_delta_time();
|
||||||
if (inspect_edited_object_timeout < 0) {
|
if (inspect_edited_object_timeout < 0) {
|
||||||
inspect_edited_object_timeout = EditorSettings::get_singleton()->get("debugger/remote_inspect_refresh_interval");
|
inspect_edited_object_timeout = EditorSettings::get_singleton()->get("debugger/remote_inspect_refresh_interval");
|
||||||
if (inspect_scene_tree->is_visible() && inspected_object_id) {
|
|
||||||
//take the chance and re-inspect selected object
|
if (inspect_scene_tree->is_visible())
|
||||||
|
_scene_tree_request();
|
||||||
|
|
||||||
|
if (inspected_object_id != 0 && editor->get_property_editor()->is_visible() && (editor->get_property_editor()->obj != NULL) && editor->get_property_editor()->obj->is_type("ScriptEditorDebuggerInspectedObject") && ((ObjectID)editor->get_property_editor()->obj->call("get_remote_object_id") != 0)) {
|
||||||
Array msg;
|
Array msg;
|
||||||
msg.push_back("inspect_object");
|
msg.push_back("inspect_object");
|
||||||
msg.push_back(inspected_object_id);
|
msg.push_back(inspected_object_id);
|
||||||
ppeer->put_var(msg);
|
ppeer->put_var(msg);
|
||||||
inspected_object_id = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1210,7 +1202,6 @@ void ScriptEditorDebugger::stop() {
|
|||||||
le_set->set_disabled(true);
|
le_set->set_disabled(true);
|
||||||
profiler->set_enabled(true);
|
profiler->set_enabled(true);
|
||||||
|
|
||||||
inspect_properties->edit(NULL);
|
|
||||||
inspect_scene_tree->clear();
|
inspect_scene_tree->clear();
|
||||||
|
|
||||||
EditorNode::get_singleton()->get_pause_button()->set_pressed(false);
|
EditorNode::get_singleton()->get_pause_button()->set_pressed(false);
|
||||||
@@ -1677,9 +1668,6 @@ void ScriptEditorDebugger::_clear_remote_objects() {
|
|||||||
if (inspector)
|
if (inspector)
|
||||||
inspector->edit(NULL);
|
inspector->edit(NULL);
|
||||||
|
|
||||||
if (inspect_properties)
|
|
||||||
inspect_properties->edit(NULL);
|
|
||||||
|
|
||||||
for (Map<ObjectID, ScriptEditorDebuggerInspectedObject *>::Element *E = remote_objects.front(); E; E = E->next()) {
|
for (Map<ObjectID, ScriptEditorDebuggerInspectedObject *>::Element *E = remote_objects.front(); E; E = E->next()) {
|
||||||
memdelete(E->value());
|
memdelete(E->value());
|
||||||
}
|
}
|
||||||
@@ -1814,6 +1802,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
|
|||||||
inspector->set_read_only(true);
|
inspector->set_read_only(true);
|
||||||
inspector->connect("object_id_selected", this, "_scene_tree_property_select_object");
|
inspector->connect("object_id_selected", this, "_scene_tree_property_select_object");
|
||||||
sc->add_child(inspector);
|
sc->add_child(inspector);
|
||||||
|
editor->get_property_editor()->connect("object_id_selected", this, "_scene_tree_property_select_object");
|
||||||
|
|
||||||
server = TCP_Server::create_ref();
|
server = TCP_Server::create_ref();
|
||||||
|
|
||||||
@@ -1852,29 +1841,12 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
|
|||||||
|
|
||||||
{ // inquire
|
{ // inquire
|
||||||
|
|
||||||
inspect_info = memnew(HSplitContainer);
|
|
||||||
inspect_info->set_name(TTR("Remote Inspector"));
|
|
||||||
tabs->add_child(inspect_info);
|
|
||||||
|
|
||||||
VBoxContainer *info_left = memnew(VBoxContainer);
|
|
||||||
info_left->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
||||||
inspect_info->add_child(info_left);
|
|
||||||
|
|
||||||
inspect_scene_tree = memnew(Tree);
|
inspect_scene_tree = memnew(Tree);
|
||||||
info_left->add_margin_child(TTR("Live Scene Tree:"), inspect_scene_tree, true);
|
inspect_scene_tree->set_name(TTR("Live Scene Tree"));
|
||||||
inspect_scene_tree->connect("cell_selected", this, "_scene_tree_selected");
|
inspect_scene_tree->connect("cell_selected", this, "_scene_tree_selected");
|
||||||
inspect_scene_tree->connect("item_collapsed", this, "_scene_tree_folded");
|
inspect_scene_tree->connect("item_collapsed", this, "_scene_tree_folded");
|
||||||
|
|
||||||
VBoxContainer *info_right = memnew(VBoxContainer);
|
tabs->add_child(inspect_scene_tree);
|
||||||
info_right->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
||||||
inspect_info->add_child(info_right);
|
|
||||||
|
|
||||||
inspect_properties = memnew(PropertyEditor);
|
|
||||||
//inspect_properties->hide_top_label();
|
|
||||||
inspect_properties->set_show_categories(true);
|
|
||||||
inspect_properties->connect("object_id_selected", this, "_scene_tree_property_select_object");
|
|
||||||
|
|
||||||
info_right->add_margin_child(TTR("Remote Object Properties: "), inspect_properties, true);
|
|
||||||
|
|
||||||
inspect_scene_tree_timeout = EDITOR_DEF("debugger/scene_tree_refresh_interval", 1.0);
|
inspect_scene_tree_timeout = EDITOR_DEF("debugger/scene_tree_refresh_interval", 1.0);
|
||||||
inspect_edited_object_timeout = EDITOR_DEF("debugger/remote_inspect_refresh_interval", 0.2);
|
inspect_edited_object_timeout = EDITOR_DEF("debugger/remote_inspect_refresh_interval", 0.2);
|
||||||
@@ -2029,7 +2001,6 @@ ScriptEditorDebugger::~ScriptEditorDebugger() {
|
|||||||
ppeer->set_stream_peer(Ref<StreamPeer>());
|
ppeer->set_stream_peer(Ref<StreamPeer>());
|
||||||
|
|
||||||
inspector = NULL;
|
inspector = NULL;
|
||||||
inspect_properties = NULL;
|
|
||||||
|
|
||||||
server->stop();
|
server->stop();
|
||||||
_clear_remote_objects();
|
_clear_remote_objects();
|
||||||
|
|||||||
@@ -67,8 +67,6 @@ class ScriptEditorDebugger : public Control {
|
|||||||
Button *le_clear;
|
Button *le_clear;
|
||||||
|
|
||||||
Tree *inspect_scene_tree;
|
Tree *inspect_scene_tree;
|
||||||
HSplitContainer *inspect_info;
|
|
||||||
PropertyEditor *inspect_properties;
|
|
||||||
float inspect_scene_tree_timeout;
|
float inspect_scene_tree_timeout;
|
||||||
float inspect_edited_object_timeout;
|
float inspect_edited_object_timeout;
|
||||||
ObjectID inspected_object_id;
|
ObjectID inspected_object_id;
|
||||||
@@ -187,6 +185,8 @@ public:
|
|||||||
void debug_break();
|
void debug_break();
|
||||||
void debug_continue();
|
void debug_continue();
|
||||||
|
|
||||||
|
bool is_connected() const;
|
||||||
|
|
||||||
String get_var_value(const String &p_var) const;
|
String get_var_value(const String &p_var) const;
|
||||||
|
|
||||||
void set_live_debugging(bool p_enable);
|
void set_live_debugging(bool p_enable);
|
||||||
|
|||||||
Reference in New Issue
Block a user