diff options
Diffstat (limited to 'editor/script_editor_debugger.cpp')
-rw-r--r-- | editor/script_editor_debugger.cpp | 74 |
1 files changed, 53 insertions, 21 deletions
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index e9529eb1c0..a83de1627d 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -46,6 +46,7 @@ #include "scene/gui/tab_container.h" #include "scene/gui/texture_button.h" #include "scene/gui/tree.h" +#include "scene/resources/packed_scene.h" #include "ustring.h" class ScriptEditorDebuggerVariables : public Object { @@ -286,6 +287,30 @@ void ScriptEditorDebugger::_scene_tree_selected() { ppeer->put_var(msg); } +void ScriptEditorDebugger::_scene_tree_rmb_selected(const Vector2 &p_position) { + + TreeItem *item = inspect_scene_tree->get_item_at_position(p_position); + if (!item) + return; + + item->select(0); + + item_menu->clear(); + item_menu->add_icon_item(get_icon("CreateNewSceneFrom", "EditorIcons"), TTR("Save Branch as Scene"), ITEM_MENU_SAVE_REMOTE_NODE); + item_menu->set_global_position(get_global_mouse_position()); + item_menu->popup(); +} + +void ScriptEditorDebugger::_file_selected(const String &p_file) { + if (file_dialog->get_mode() == EditorFileDialog::MODE_SAVE_FILE) { + Array msg; + msg.push_back("save_node"); + msg.push_back(inspected_object_id); + msg.push_back(p_file); + ppeer->put_var(msg); + } +} + void ScriptEditorDebugger::_scene_tree_property_value_edited(const String &p_prop, const Variant &p_value) { Array msg; @@ -710,25 +735,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da error_list->set_item_metadata(error_list->get_item_count() - 1, stack); error_count++; - /* - int count = p_data[1]; - - Array cstack; - - OutputError oe = errors.front()->get(); - - packet_peer_stream->put_var(oe.hr); - packet_peer_stream->put_var(oe.min); - packet_peer_stream->put_var(oe.sec); - packet_peer_stream->put_var(oe.msec); - packet_peer_stream->put_var(oe.source_func); - packet_peer_stream->put_var(oe.source_file); - packet_peer_stream->put_var(oe.source_line); - packet_peer_stream->put_var(oe.error); - packet_peer_stream->put_var(oe.error_descr); - packet_peer_stream->put_var(oe.warning); - packet_peer_stream->put_var(oe.callstack); - */ } else if (p_msg == "profile_sig") { //cache a signature @@ -755,6 +761,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da EditorProfiler::Metric::Category::Item item; item.calls = 1; item.line = 0; + item.name = "Physics Time"; item.total = metric.physics_time; item.self = item.total; @@ -792,8 +799,9 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da for (int i = 0; i < values.size(); i += 2) { EditorProfiler::Metric::Category::Item item; - item.name = values[i]; item.calls = 1; + item.line = 0; + item.name = values[i]; item.self = values[i + 1]; item.total = item.self; item.signature = "categ::" + name + "::" + item.name; @@ -1771,6 +1779,21 @@ void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) { OS::get_singleton()->set_clipboard(title + "\n----------\n" + desc); } break; + case ITEM_MENU_SAVE_REMOTE_NODE: { + + file_dialog->set_access(EditorFileDialog::ACCESS_RESOURCES); + file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE); + + List<String> extensions; + Ref<PackedScene> sd = memnew(PackedScene); + ResourceSaver::get_recognized_extensions(sd, &extensions); + file_dialog->clear_filters(); + for (int i = 0; i < extensions.size(); i++) { + file_dialog->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper()); + } + + file_dialog->popup_centered_ratio(); + } break; } } @@ -1805,6 +1828,8 @@ void ScriptEditorDebugger::_bind_methods() { ClassDB::bind_method(D_METHOD("_scene_tree_selected"), &ScriptEditorDebugger::_scene_tree_selected); ClassDB::bind_method(D_METHOD("_scene_tree_folded"), &ScriptEditorDebugger::_scene_tree_folded); + ClassDB::bind_method(D_METHOD("_scene_tree_rmb_selected"), &ScriptEditorDebugger::_scene_tree_rmb_selected); + ClassDB::bind_method(D_METHOD("_file_selected"), &ScriptEditorDebugger::_file_selected); ClassDB::bind_method(D_METHOD("live_debug_create_node"), &ScriptEditorDebugger::live_debug_create_node); ClassDB::bind_method(D_METHOD("live_debug_instance_node"), &ScriptEditorDebugger::live_debug_instance_node); @@ -1977,7 +2002,8 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { inspect_scene_tree->set_v_size_flags(SIZE_EXPAND_FILL); inspect_scene_tree->connect("cell_selected", this, "_scene_tree_selected"); inspect_scene_tree->connect("item_collapsed", this, "_scene_tree_folded"); - + inspect_scene_tree->set_allow_rmb_select(true); + inspect_scene_tree->connect("item_rmb_selected", this, "_scene_tree_rmb_selected"); auto_switch_remote_scene_tree = EDITOR_DEF("debugger/auto_switch_to_remote_scene_tree", false); inspect_scene_tree_timeout = EDITOR_DEF("debugger/remote_scene_tree_refresh_interval", 1.0); inspect_edited_object_timeout = EDITOR_DEF("debugger/remote_inspect_refresh_interval", 0.2); @@ -1985,6 +2011,12 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { updating_scene_tree = false; } + { // File dialog + file_dialog = memnew(EditorFileDialog); + file_dialog->connect("file_selected", this, "_file_selected"); + add_child(file_dialog); + } + { //profiler profiler = memnew(EditorProfiler); profiler->set_name(TTR("Profiler")); |