diff options
Diffstat (limited to 'editor/script_editor_debugger.cpp')
-rw-r--r-- | editor/script_editor_debugger.cpp | 96 |
1 files changed, 61 insertions, 35 deletions
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index cc477314e9..559ab32505 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -30,6 +30,7 @@ #include "script_editor_debugger.h" +#include "core/io/marshalls.h" #include "core/project_settings.h" #include "core/ustring.h" #include "editor_node.h" @@ -122,8 +123,8 @@ protected: if (!prop_values.has(p_name) || String(p_name).begins_with("Constants/")) return false; - emit_signal("value_edited", p_name, p_value); prop_values[p_name] = p_value; + emit_signal("value_edited", p_name, p_value); return true; } @@ -354,7 +355,7 @@ void ScriptEditorDebugger::_video_mem_request() { Size2 ScriptEditorDebugger::get_minimum_size() const { Size2 ms = Control::get_minimum_size(); - ms.y = MAX(ms.y, 250); + ms.y = MAX(ms.y, 250 * EDSCALE); return ms; } void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_data) { @@ -466,7 +467,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da String type = p_data[1]; Array properties = p_data[2]; - bool is_new_object = false; if (remote_objects.has(id)) { debugObj = remote_objects[id]; } else { @@ -474,10 +474,14 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da debugObj->remote_object_id = id; debugObj->type_name = type; remote_objects[id] = debugObj; - is_new_object = true; debugObj->connect("value_edited", this, "_scene_tree_property_value_edited"); } + int old_prop_size = debugObj->prop_list.size(); + + debugObj->prop_list.clear(); + int new_props_added = 0; + Set<String> changed; for (int i = 0; i < properties.size(); i++) { Array prop = properties[i]; @@ -492,26 +496,52 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da pinfo.usage = PropertyUsageFlags(int(prop[4])); Variant var = prop[5]; - if (is_new_object) { - //don't update.. it's the same, instead refresh - debugObj->prop_list.push_back(pinfo); + if (pinfo.type == Variant::OBJECT) { + 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); + } else if (var.get_type() == Variant::OBJECT) { + if (((Object *)var)->is_class("EncodedObjectAsID")) { + var = Object::cast_to<EncodedObjectAsID>(var)->get_object_id(); + pinfo.type = var.get_type(); + pinfo.hint = PROPERTY_HINT_OBJECT_ID; + pinfo.hint_string = "Object"; + } + } } - if (var.get_type() == Variant::STRING) { - String str = var; - var = str.substr(4, str.length()); + //always add the property, since props may have been added or removed + debugObj->prop_list.push_back(pinfo); - if (str.begins_with("PATH")) - var = ResourceLoader::load(var); - } + if (!debugObj->prop_values.has(pinfo.name)) { + new_props_added++; + debugObj->prop_values[pinfo.name] = var; + } else { - debugObj->prop_values[pinfo.name] = var; + if (bool(Variant::evaluate(Variant::OP_NOT_EQUAL, debugObj->prop_values[pinfo.name], var))) { + debugObj->prop_values[pinfo.name] = var; + changed.insert(pinfo.name); + } + } } if (editor->get_editor_history()->get_current() != debugObj->get_instance_id()) { editor->push_item(debugObj, ""); } else { - debugObj->update(); + + if (old_prop_size == debugObj->prop_list.size() && new_props_added == 0) { + //only some may have changed, if so, then update those, if exist + for (Set<String>::Element *E = changed.front(); E; E = E->next()) { + EditorNode::get_singleton()->get_inspector()->update_property(E->get()); + } + } else { + //full update, because props were added or removed + debugObj->update(); + } } } else if (p_msg == "message:video_mem") { @@ -572,15 +602,14 @@ 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 (v.get_type() == Variant::OBJECT) { + v = Object::cast_to<EncodedObjectAsID>(v)->get_object_id(); h = PROPERTY_HINT_OBJECT_ID; - String s = v; - s = s.replace("[", ""); - hs = s.get_slice(":", 0); - v = s.get_slice(":", 1).to_int(); + hs = "Object"; } variables->add_property("Locals/" + n, v, h, hs); @@ -597,11 +626,9 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da String hs = String(); if (v.get_type() == Variant::OBJECT) { + v = Object::cast_to<EncodedObjectAsID>(v)->get_object_id(); h = PROPERTY_HINT_OBJECT_ID; - String s = v; - s = s.replace("[", ""); - hs = s.get_slice(":", 0); - v = s.get_slice(":", 1).to_int(); + hs = "Object"; } variables->add_property("Members/" + n, v, h, hs); @@ -618,11 +645,9 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da String hs = String(); if (v.get_type() == Variant::OBJECT) { + v = Object::cast_to<EncodedObjectAsID>(v)->get_object_id(); h = PROPERTY_HINT_OBJECT_ID; - String s = v; - s = s.replace("[", ""); - hs = s.get_slice(":", 0); - v = s.get_slice(":", 1).to_int(); + hs = "Object"; } variables->add_property("Globals/" + n, v, h, hs); @@ -727,9 +752,10 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da String source(err[5]); bool source_is_project_file = source.begins_with("res://"); if (source_is_project_file) - source = source.get_file(); + txt = source.get_file() + ":" + String(err[6]); + else + txt = source + ":" + String(err[6]); - txt = source + ":" + String(err[6]); String method = err[4]; if (method.length() > 0) txt += " @ " + method + "()"; @@ -1016,8 +1042,11 @@ void ScriptEditorDebugger::_notification(int p_what) { if (enable_rl) { inspect_scene_tree->add_constant_override("draw_relationship_lines", 1); inspect_scene_tree->add_color_override("relationship_line_color", rl_color); - } else + inspect_scene_tree->add_constant_override("draw_guides", 0); + } else { inspect_scene_tree->add_constant_override("draw_relationship_lines", 0); + inspect_scene_tree->add_constant_override("draw_guides", 1); + } } break; case NOTIFICATION_PROCESS: { @@ -1266,7 +1295,7 @@ void ScriptEditorDebugger::stop() { breaked = false; server->stop(); - + _clear_remote_objects(); ppeer->set_stream_peer(Ref<StreamPeer>()); if (connection.is_valid()) { @@ -1294,9 +1323,6 @@ void ScriptEditorDebugger::stop() { EditorNode::get_singleton()->get_scene_tree_dock()->hide_remote_tree(); EditorNode::get_singleton()->get_scene_tree_dock()->hide_tab_buttons(); - Node *node = editor->get_scene_tree_dock()->get_tree_editor()->get_selected(); - editor->push_item(node); - if (hide_on_stop) { if (is_visible_in_tree()) EditorNode::get_singleton()->hide_bottom_panel(); @@ -2231,7 +2257,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { p_editor->get_undo_redo()->set_method_notify_callback(_method_changeds, this); p_editor->get_undo_redo()->set_property_notify_callback(_property_changeds, this); - live_debug = false; + live_debug = true; last_path_id = false; error_count = 0; warning_count = 0; |