| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | /*  script_editor_debugger.cpp                                           */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | /*                       This file is part of:                           */ | 
					
						
							|  |  |  | /*                           GODOT ENGINE                                */ | 
					
						
							| 
									
										
										
										
											2017-08-27 14:16:55 +02:00
										 |  |  | /*                      https://godotengine.org                          */ | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | /*************************************************************************/ | 
					
						
							| 
									
										
										
										
											2020-01-01 11:16:22 +01:00
										 |  |  | /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.                 */ | 
					
						
							|  |  |  | /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).   */ | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* Permission is hereby granted, free of charge, to any person obtaining */ | 
					
						
							|  |  |  | /* a copy of this software and associated documentation files (the       */ | 
					
						
							|  |  |  | /* "Software"), to deal in the Software without restriction, including   */ | 
					
						
							|  |  |  | /* without limitation the rights to use, copy, modify, merge, publish,   */ | 
					
						
							|  |  |  | /* distribute, sublicense, and/or sell copies of the Software, and to    */ | 
					
						
							|  |  |  | /* permit persons to whom the Software is furnished to do so, subject to */ | 
					
						
							|  |  |  | /* the following conditions:                                             */ | 
					
						
							|  |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* The above copyright notice and this permission notice shall be        */ | 
					
						
							|  |  |  | /* included in all copies or substantial portions of the Software.       */ | 
					
						
							|  |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */ | 
					
						
							|  |  |  | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */ | 
					
						
							|  |  |  | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ | 
					
						
							|  |  |  | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */ | 
					
						
							|  |  |  | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */ | 
					
						
							|  |  |  | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */ | 
					
						
							|  |  |  | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							| 
									
										
										
										
											2018-01-05 00:50:27 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | #include "script_editor_debugger.h"
 | 
					
						
							| 
									
										
										
										
											2017-01-16 08:04:19 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | #include "core/debugger/debugger_marshalls.h"
 | 
					
						
							| 
									
										
										
										
											2020-05-01 18:23:51 +02:00
										 |  |  | #include "core/debugger/remote_debugger.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-28 19:08:31 +02:00
										 |  |  | #include "core/io/marshalls.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-11 18:13:45 +02:00
										 |  |  | #include "core/project_settings.h"
 | 
					
						
							|  |  |  | #include "core/ustring.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | #include "editor/debugger/editor_network_profiler.h"
 | 
					
						
							|  |  |  | #include "editor/debugger/editor_profiler.h"
 | 
					
						
							|  |  |  | #include "editor/debugger/editor_visual_profiler.h"
 | 
					
						
							| 
									
										
										
										
											2019-09-20 17:58:06 -03:00
										 |  |  | #include "editor/editor_log.h"
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | #include "editor/editor_node.h"
 | 
					
						
							|  |  |  | #include "editor/editor_scale.h"
 | 
					
						
							|  |  |  | #include "editor/editor_settings.h"
 | 
					
						
							| 
									
										
										
										
											2020-02-11 14:01:43 +01:00
										 |  |  | #include "editor/plugins/canvas_item_editor_plugin.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-27 08:44:44 +01:00
										 |  |  | #include "editor/plugins/node_3d_editor_plugin.h"
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | #include "editor/property_editor.h"
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | #include "main/performance.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-26 18:49:16 -03:00
										 |  |  | #include "scene/3d/camera_3d.h"
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | #include "scene/debugger/scene_debugger.h"
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | #include "scene/gui/dialogs.h"
 | 
					
						
							|  |  |  | #include "scene/gui/label.h"
 | 
					
						
							|  |  |  | #include "scene/gui/line_edit.h"
 | 
					
						
							|  |  |  | #include "scene/gui/margin_container.h"
 | 
					
						
							|  |  |  | #include "scene/gui/rich_text_label.h"
 | 
					
						
							|  |  |  | #include "scene/gui/separator.h"
 | 
					
						
							|  |  |  | #include "scene/gui/split_container.h"
 | 
					
						
							|  |  |  | #include "scene/gui/tab_container.h"
 | 
					
						
							|  |  |  | #include "scene/gui/texture_button.h"
 | 
					
						
							|  |  |  | #include "scene/gui/tree.h"
 | 
					
						
							| 
									
										
										
										
											2018-02-21 23:07:49 +08:00
										 |  |  | #include "scene/resources/packed_scene.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-03 10:36:29 -03:00
										 |  |  | #include "servers/display_server.h"
 | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-24 06:21:15 +01:00
										 |  |  | using CameraOverride = EditorDebuggerNode::CameraOverride; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | void ScriptEditorDebugger::_put_msg(String p_message, Array p_data) { | 
					
						
							|  |  |  | 	if (is_session_active()) { | 
					
						
							|  |  |  | 		Array msg; | 
					
						
							|  |  |  | 		msg.push_back(p_message); | 
					
						
							|  |  |  | 		msg.push_back(p_data); | 
					
						
							| 
									
										
										
										
											2020-02-24 06:21:15 +01:00
										 |  |  | 		peer->put_message(msg); | 
					
						
							| 
									
										
										
										
											2017-10-17 22:37:25 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-13 19:46:45 +03:00
										 |  |  | void ScriptEditorDebugger::debug_copy() { | 
					
						
							|  |  |  | 	String msg = reason->get_text(); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (msg == "") { | 
					
						
							| 
									
										
										
										
											2020-05-10 12:56:01 +02:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-03-03 10:36:29 -03:00
										 |  |  | 	DisplayServer::get_singleton()->clipboard_set(msg); | 
					
						
							| 
									
										
										
										
											2018-02-13 19:46:45 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-29 20:09:22 +02:00
										 |  |  | void ScriptEditorDebugger::debug_skip_breakpoints() { | 
					
						
							|  |  |  | 	skip_breakpoints_value = !skip_breakpoints_value; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (skip_breakpoints_value) { | 
					
						
							| 
									
										
										
										
											2020-03-12 09:37:40 -03:00
										 |  |  | 		skip_breakpoints->set_icon(get_theme_icon("DebugSkipBreakpointsOn", "EditorIcons")); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2020-03-12 09:37:40 -03:00
										 |  |  | 		skip_breakpoints->set_icon(get_theme_icon("DebugSkipBreakpointsOff", "EditorIcons")); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-07-29 20:09:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	Array msg; | 
					
						
							|  |  |  | 	msg.push_back(skip_breakpoints_value); | 
					
						
							|  |  |  | 	_put_msg("set_skip_breakpoints", msg); | 
					
						
							| 
									
										
										
										
											2019-07-29 20:09:22 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | void ScriptEditorDebugger::debug_next() { | 
					
						
							|  |  |  | 	ERR_FAIL_COND(!breaked); | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	_put_msg("next", Array()); | 
					
						
							| 
									
										
										
										
											2019-04-22 17:20:27 +01:00
										 |  |  | 	_clear_execution(); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-05-14 14:29:06 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | void ScriptEditorDebugger::debug_step() { | 
					
						
							|  |  |  | 	ERR_FAIL_COND(!breaked); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	_put_msg("step", Array()); | 
					
						
							| 
									
										
										
										
											2019-04-22 17:20:27 +01:00
										 |  |  | 	_clear_execution(); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ScriptEditorDebugger::debug_break() { | 
					
						
							|  |  |  | 	ERR_FAIL_COND(breaked); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	_put_msg("break", Array()); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ScriptEditorDebugger::debug_continue() { | 
					
						
							|  |  |  | 	ERR_FAIL_COND(!breaked); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	// Allow focus stealing only if we actually run this client for security.
 | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (remote_pid && EditorNode::get_singleton()->has_child_process(remote_pid)) { | 
					
						
							| 
									
										
										
										
											2020-03-03 10:36:29 -03:00
										 |  |  | 		DisplayServer::get_singleton()->enable_for_stealing_focus(remote_pid); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-09-14 04:02:18 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-22 17:20:27 +01:00
										 |  |  | 	_clear_execution(); | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	_put_msg("continue", Array()); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | void ScriptEditorDebugger::update_tabs() { | 
					
						
							|  |  |  | 	if (error_count == 0 && warning_count == 0) { | 
					
						
							|  |  |  | 		errors_tab->set_name(TTR("Errors")); | 
					
						
							|  |  |  | 		tabs->set_tab_icon(errors_tab->get_index(), Ref<Texture2D>()); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		errors_tab->set_name(TTR("Errors") + " (" + itos(error_count + warning_count) + ")"); | 
					
						
							| 
									
										
										
										
											2020-05-09 15:29:13 +02:00
										 |  |  | 		if (error_count >= 1 && warning_count >= 1) { | 
					
						
							|  |  |  | 			tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon("ErrorWarning", "EditorIcons")); | 
					
						
							|  |  |  | 		} else if (error_count >= 1) { | 
					
						
							| 
									
										
										
										
											2020-03-12 09:37:40 -03:00
										 |  |  | 			tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon("Error", "EditorIcons")); | 
					
						
							| 
									
										
										
										
											2020-05-09 15:29:13 +02:00
										 |  |  | 		} else { | 
					
						
							|  |  |  | 			tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon("Warning", "EditorIcons")); | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-22 01:04:55 -03:00
										 |  |  | void ScriptEditorDebugger::clear_style() { | 
					
						
							| 
									
										
										
										
											2020-04-02 01:20:12 +02:00
										 |  |  | 	tabs->add_theme_style_override("panel", nullptr); | 
					
						
							| 
									
										
										
										
											2020-02-22 01:04:55 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | void ScriptEditorDebugger::save_node(ObjectID p_id, const String &p_file) { | 
					
						
							|  |  |  | 	Array msg; | 
					
						
							|  |  |  | 	msg.push_back(p_id); | 
					
						
							|  |  |  | 	msg.push_back(p_file); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 	_put_msg("scene:save_node", msg); | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | void ScriptEditorDebugger::_file_selected(const String &p_file) { | 
					
						
							| 
									
										
										
										
											2020-03-17 13:46:18 +01:00
										 |  |  | 	switch (file_dialog_purpose) { | 
					
						
							|  |  |  | 		case SAVE_MONITORS_CSV: { | 
					
						
							|  |  |  | 			Error err; | 
					
						
							|  |  |  | 			FileAccessRef file = FileAccess::open(p_file, FileAccess::WRITE, &err); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-17 13:46:18 +01:00
										 |  |  | 			if (err != OK) { | 
					
						
							|  |  |  | 				ERR_PRINT("Failed to open " + p_file); | 
					
						
							|  |  |  | 				return; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			Vector<String> line; | 
					
						
							|  |  |  | 			line.resize(Performance::MONITOR_MAX); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-17 13:46:18 +01:00
										 |  |  | 			// 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); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-17 13:46:18 +01:00
										 |  |  | 			// 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++) { | 
					
						
							|  |  |  | 					line.write[i] = String::num_real(perf_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; | 
					
						
							|  |  |  | 		case SAVE_VRAM_CSV: { | 
					
						
							|  |  |  | 			Error err; | 
					
						
							|  |  |  | 			FileAccessRef file = FileAccess::open(p_file, FileAccess::WRITE, &err); | 
					
						
							| 
									
										
										
										
											2018-02-21 23:07:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-17 13:46:18 +01:00
										 |  |  | 			if (err != OK) { | 
					
						
							|  |  |  | 				ERR_PRINT("Failed to open " + p_file); | 
					
						
							|  |  |  | 				return; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			Vector<String> headers; | 
					
						
							|  |  |  | 			headers.resize(vmem_tree->get_columns()); | 
					
						
							|  |  |  | 			for (int i = 0; i < vmem_tree->get_columns(); ++i) { | 
					
						
							|  |  |  | 				headers.write[i] = vmem_tree->get_column_title(i); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			file->store_csv_line(headers); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if (vmem_tree->get_root()) { | 
					
						
							|  |  |  | 				TreeItem *ti = vmem_tree->get_root()->get_children(); | 
					
						
							|  |  |  | 				while (ti) { | 
					
						
							|  |  |  | 					Vector<String> values; | 
					
						
							|  |  |  | 					values.resize(vmem_tree->get_columns()); | 
					
						
							|  |  |  | 					for (int i = 0; i < vmem_tree->get_columns(); ++i) { | 
					
						
							|  |  |  | 						values.write[i] = ti->get_text(i); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					file->store_csv_line(values); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					ti = ti->get_next(); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} break; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-02-21 23:07:49 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | void ScriptEditorDebugger::request_remote_tree() { | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 	_put_msg("scene:request_scene_tree", Array()); | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2019-02-18 01:25:26 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | const SceneDebuggerTree *ScriptEditorDebugger::get_remote_tree() { | 
					
						
							|  |  |  | 	return scene_tree; | 
					
						
							| 
									
										
										
										
											2018-02-21 23:07:49 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | void ScriptEditorDebugger::update_remote_object(ObjectID p_obj_id, const String &p_prop, const Variant &p_value) { | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 	Array msg; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	msg.push_back(p_obj_id); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 	msg.push_back(p_prop); | 
					
						
							|  |  |  | 	msg.push_back(p_value); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 	_put_msg("scene:set_object_property", msg); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | void ScriptEditorDebugger::request_remote_object(ObjectID p_obj_id) { | 
					
						
							|  |  |  | 	ERR_FAIL_COND(p_obj_id.is_null()); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 	Array msg; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	msg.push_back(p_obj_id); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 	_put_msg("scene:inspect_object", msg); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | Object *ScriptEditorDebugger::get_remote_object(ObjectID p_id) { | 
					
						
							|  |  |  | 	return inspector->get_object(p_id); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-07-30 15:11:13 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | void ScriptEditorDebugger::_remote_object_selected(ObjectID p_id) { | 
					
						
							|  |  |  | 	emit_signal("remote_object_requested", p_id); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-10-25 10:39:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | void ScriptEditorDebugger::_remote_object_edited(ObjectID p_id, const String &p_prop, const Variant &p_value) { | 
					
						
							|  |  |  | 	update_remote_object(p_id, p_prop, p_value); | 
					
						
							|  |  |  | 	request_remote_object(p_id); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-10-25 10:39:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | void ScriptEditorDebugger::_remote_object_property_updated(ObjectID p_id, const String &p_property) { | 
					
						
							|  |  |  | 	emit_signal("remote_object_property_updated", p_id, p_property); | 
					
						
							| 
									
										
										
										
											2018-10-25 10:39:02 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-21 09:50:44 -03:00
										 |  |  | void ScriptEditorDebugger::_video_mem_request() { | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 	_put_msg("core:memory", Array()); | 
					
						
							| 
									
										
										
										
											2015-10-21 09:50:44 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-17 13:46:18 +01:00
										 |  |  | void ScriptEditorDebugger::_video_mem_export() { | 
					
						
							|  |  |  | 	file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); | 
					
						
							|  |  |  | 	file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM); | 
					
						
							|  |  |  | 	file_dialog->clear_filters(); | 
					
						
							|  |  |  | 	file_dialog_purpose = SAVE_VRAM_CSV; | 
					
						
							|  |  |  | 	file_dialog->popup_centered_ratio(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | Size2 ScriptEditorDebugger::get_minimum_size() const { | 
					
						
							| 
									
										
										
										
											2019-11-18 09:42:28 +01:00
										 |  |  | 	Size2 ms = MarginContainer::get_minimum_size(); | 
					
						
							| 
									
										
										
										
											2018-10-20 22:05:11 +02:00
										 |  |  | 	ms.y = MAX(ms.y, 250 * EDSCALE); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 	return ms; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-05-05 03:59:10 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_data) { | 
					
						
							|  |  |  | 	if (p_msg == "debug_enter") { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		_put_msg("get_stack_dump", Array()); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		ERR_FAIL_COND(p_data.size() != 2); | 
					
						
							|  |  |  | 		bool can_continue = p_data[0]; | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 		String error = p_data[1]; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		breaked = true; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		can_debug = can_continue; | 
					
						
							|  |  |  | 		_update_buttons_state(); | 
					
						
							|  |  |  | 		_set_reason_text(error, MESSAGE_ERROR); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		emit_signal("breaked", true, can_continue); | 
					
						
							| 
									
										
										
										
											2020-03-03 10:36:29 -03:00
										 |  |  | 		DisplayServer::get_singleton()->window_move_to_foreground(); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		if (error != "") { | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 			tabs->set_current_tab(0); | 
					
						
							| 
									
										
										
										
											2016-07-17 09:17:35 -03:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 		profiler->set_enabled(false); | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		inspector->clear_cache(); // Take a chance to force remote objects update.
 | 
					
						
							| 
									
										
										
										
											2016-01-17 20:03:57 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	} else if (p_msg == "debug_exit") { | 
					
						
							|  |  |  | 		breaked = false; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		can_debug = false; | 
					
						
							| 
									
										
										
										
											2019-04-22 17:20:27 +01:00
										 |  |  | 		_clear_execution(); | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		_update_buttons_state(); | 
					
						
							|  |  |  | 		_set_reason_text(TTR("Execution resumed."), MESSAGE_SUCCESS); | 
					
						
							|  |  |  | 		emit_signal("breaked", false, false); | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 		profiler->set_enabled(true); | 
					
						
							|  |  |  | 		profiler->disable_seeking(); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 	} else if (p_msg == "set_pid") { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		ERR_FAIL_COND(p_data.size() < 1); | 
					
						
							|  |  |  | 		remote_pid = p_data[0]; | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 	} else if (p_msg == "scene:click_ctrl") { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		ERR_FAIL_COND(p_data.size() < 2); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 		clicked_ctrl->set_text(p_data[0]); | 
					
						
							|  |  |  | 		clicked_ctrl_type->set_text(p_data[1]); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 	} else if (p_msg == "scene:scene_tree") { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		scene_tree->nodes.clear(); | 
					
						
							|  |  |  | 		scene_tree->deserialize(p_data); | 
					
						
							|  |  |  | 		emit_signal("remote_tree_updated"); | 
					
						
							|  |  |  | 		_update_buttons_state(); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 	} else if (p_msg == "scene:inspect_object") { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		ObjectID id = inspector->add_object(p_data); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		if (id.is_valid()) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 			emit_signal("remote_object_updated", id); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 	} else if (p_msg == "memory:usage") { | 
					
						
							| 
									
										
										
										
											2015-10-21 09:50:44 -03:00
										 |  |  | 		vmem_tree->clear(); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		TreeItem *root = vmem_tree->create_item(); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		DebuggerMarshalls::ResourceUsage usage; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		usage.deserialize(p_data); | 
					
						
							| 
									
										
										
										
											2015-10-21 09:50:44 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		int total = 0; | 
					
						
							| 
									
										
										
										
											2015-10-21 09:50:44 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		for (List<DebuggerMarshalls::ResourceInfo>::Element *E = usage.infos.front(); E; E = E->next()) { | 
					
						
							| 
									
										
										
										
											2015-10-21 09:50:44 -03:00
										 |  |  | 			TreeItem *it = vmem_tree->create_item(root); | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 			String type = E->get().type; | 
					
						
							|  |  |  | 			int bytes = E->get().vram; | 
					
						
							|  |  |  | 			it->set_text(0, E->get().path); | 
					
						
							|  |  |  | 			it->set_text(1, type); | 
					
						
							|  |  |  | 			it->set_text(2, E->get().format); | 
					
						
							|  |  |  | 			it->set_text(3, String::humanize_size(bytes)); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			total += bytes; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 			if (has_theme_icon(type, "EditorIcons")) { | 
					
						
							| 
									
										
										
										
											2020-03-12 09:37:40 -03:00
										 |  |  | 				it->set_icon(0, get_theme_icon(type, "EditorIcons")); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2015-10-21 09:50:44 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		vmem_total->set_tooltip(TTR("Bytes:") + " " + itos(total)); | 
					
						
							| 
									
										
										
										
											2015-10-21 09:50:44 -03:00
										 |  |  | 		vmem_total->set_text(String::humanize_size(total)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	} else if (p_msg == "stack_dump") { | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		DebuggerMarshalls::ScriptStackDump stack; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		stack.deserialize(p_data); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 		stack_dump->clear(); | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		inspector->clear_stack_variables(); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 		TreeItem *r = stack_dump->create_item(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		for (int i = 0; i < stack.frames.size(); i++) { | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 			TreeItem *s = stack_dump->create_item(r); | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 			Dictionary d; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			d["frame"] = i; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 			d["file"] = stack.frames[i].file; | 
					
						
							|  |  |  | 			d["function"] = stack.frames[i].func; | 
					
						
							|  |  |  | 			d["line"] = stack.frames[i].line; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			s->set_metadata(0, d); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-10 16:39:39 -03:00
										 |  |  | 			String line = itos(i) + " - " + String(d["file"]) + ":" + itos(d["line"]) + " - at function: " + d["function"]; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			s->set_text(0, line); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 			if (i == 0) { | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 				s->select(0); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	} else if (p_msg == "stack_frame_vars") { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		inspector->clear_stack_variables(); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	} else if (p_msg == "stack_frame_var") { | 
					
						
							|  |  |  | 		inspector->add_stack_variable(p_data); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	} else if (p_msg == "output") { | 
					
						
							| 
									
										
										
										
											2020-05-01 18:23:51 +02:00
										 |  |  | 		ERR_FAIL_COND(p_data.size() != 2); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		ERR_FAIL_COND(p_data[0].get_type() != Variant::PACKED_STRING_ARRAY); | 
					
						
							| 
									
										
										
										
											2020-05-01 18:23:51 +02:00
										 |  |  | 		Vector<String> output_strings = p_data[0]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		ERR_FAIL_COND(p_data[1].get_type() != Variant::PACKED_INT32_ARRAY); | 
					
						
							|  |  |  | 		Vector<int> output_types = p_data[1]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		ERR_FAIL_COND(output_strings.size() != output_types.size()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		for (int i = 0; i < output_strings.size(); i++) { | 
					
						
							|  |  |  | 			RemoteDebugger::MessageType type = (RemoteDebugger::MessageType)(int)(output_types[i]); | 
					
						
							|  |  |  | 			EditorLog::MessageType msg_type; | 
					
						
							|  |  |  | 			switch (type) { | 
					
						
							|  |  |  | 				case RemoteDebugger::MESSAGE_TYPE_LOG: { | 
					
						
							|  |  |  | 					msg_type = EditorLog::MSG_TYPE_STD; | 
					
						
							|  |  |  | 				} break; | 
					
						
							|  |  |  | 				case RemoteDebugger::MESSAGE_TYPE_ERROR: { | 
					
						
							|  |  |  | 					msg_type = EditorLog::MSG_TYPE_ERROR; | 
					
						
							|  |  |  | 				} break; | 
					
						
							|  |  |  | 				default: { | 
					
						
							|  |  |  | 					WARN_PRINT("Unhandled script debugger message type: " + itos(type)); | 
					
						
							|  |  |  | 					msg_type = EditorLog::MSG_TYPE_STD; | 
					
						
							|  |  |  | 				} break; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			EditorNode::get_log()->add_message(output_strings[i], msg_type); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 	} else if (p_msg == "performance:profile_frame") { | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 		Vector<float> p; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		p.resize(p_data.size()); | 
					
						
							|  |  |  | 		for (int i = 0; i < p_data.size(); i++) { | 
					
						
							|  |  |  | 			p.write[i] = p_data[i]; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			if (i < perf_items.size()) { | 
					
						
							| 
									
										
										
										
											2020-01-24 12:07:38 +01:00
										 |  |  | 				const float value = p[i]; | 
					
						
							|  |  |  | 				String label = rtos(value); | 
					
						
							|  |  |  | 				String tooltip = label; | 
					
						
							| 
									
										
										
										
											2017-10-23 01:59:04 -05:00
										 |  |  | 				switch (Performance::MonitorType((int)perf_items[i]->get_metadata(1))) { | 
					
						
							|  |  |  | 					case Performance::MONITOR_TYPE_MEMORY: { | 
					
						
							| 
									
										
										
										
											2020-01-24 12:07:38 +01:00
										 |  |  | 						label = String::humanize_size(value); | 
					
						
							|  |  |  | 						tooltip = label; | 
					
						
							| 
									
										
										
										
											2017-10-23 01:59:04 -05:00
										 |  |  | 					} break; | 
					
						
							|  |  |  | 					case Performance::MONITOR_TYPE_TIME: { | 
					
						
							| 
									
										
										
										
											2020-01-24 12:07:38 +01:00
										 |  |  | 						label = rtos(value * 1000).pad_decimals(2) + " ms"; | 
					
						
							|  |  |  | 						tooltip = label; | 
					
						
							| 
									
										
										
										
											2017-10-23 01:59:04 -05:00
										 |  |  | 					} break; | 
					
						
							|  |  |  | 					default: { | 
					
						
							| 
									
										
										
										
											2020-01-24 12:07:38 +01:00
										 |  |  | 						tooltip += " " + perf_items[i]->get_text(0); | 
					
						
							| 
									
										
										
										
											2017-10-23 01:59:04 -05:00
										 |  |  | 					} break; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-24 12:07:38 +01:00
										 |  |  | 				perf_items[i]->set_text(1, label); | 
					
						
							|  |  |  | 				perf_items[i]->set_tooltip(1, tooltip); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 				if (p[i] > perf_max[i]) { | 
					
						
							| 
									
										
										
										
											2018-07-25 03:11:03 +02:00
										 |  |  | 					perf_max.write[i] = p[i]; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		perf_history.push_front(p); | 
					
						
							|  |  |  | 		perf_draw->update(); | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 	} else if (p_msg == "visual:profile_frame") { | 
					
						
							|  |  |  | 		DebuggerMarshalls::VisualProfilerFrame frame; | 
					
						
							|  |  |  | 		frame.deserialize(p_data); | 
					
						
							| 
									
										
										
										
											2019-09-20 17:58:06 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		EditorVisualProfiler::Metric metric; | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		metric.areas.resize(frame.areas.size()); | 
					
						
							|  |  |  | 		metric.frame_number = frame.frame_number; | 
					
						
							| 
									
										
										
										
											2019-09-20 17:58:06 -03:00
										 |  |  | 		metric.valid = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			EditorVisualProfiler::Metric::Area *areas_ptr = metric.areas.ptrw(); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 			for (int i = 0; i < frame.areas.size(); i++) { | 
					
						
							|  |  |  | 				areas_ptr[i].name = frame.areas[i].name; | 
					
						
							|  |  |  | 				areas_ptr[i].cpu_time = frame.areas[i].cpu_msec; | 
					
						
							|  |  |  | 				areas_ptr[i].gpu_time = frame.areas[i].gpu_msec; | 
					
						
							| 
									
										
										
										
											2019-09-20 17:58:06 -03:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		visual_profiler->add_frame_metric(metric); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	} else if (p_msg == "error") { | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		DebuggerMarshalls::OutputError oe; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		ERR_FAIL_COND_MSG(oe.deserialize(p_data) == false, "Failed to deserialize error message"); | 
					
						
							| 
									
										
										
										
											2019-09-25 10:47:41 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Format time.
 | 
					
						
							|  |  |  | 		Array time_vals; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		time_vals.push_back(oe.hr); | 
					
						
							|  |  |  | 		time_vals.push_back(oe.min); | 
					
						
							|  |  |  | 		time_vals.push_back(oe.sec); | 
					
						
							|  |  |  | 		time_vals.push_back(oe.msec); | 
					
						
							| 
									
										
										
										
											2015-08-04 09:47:32 -03:00
										 |  |  | 		bool e; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		String time = String("%d:%02d:%02d:%04d").sprintf(time_vals, &e); | 
					
						
							| 
									
										
										
										
											2015-08-04 09:47:32 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-25 10:47:41 +02:00
										 |  |  | 		// Rest of the error data.
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		bool source_is_project_file = oe.source_file.begins_with("res://"); | 
					
						
							| 
									
										
										
										
											2019-09-25 10:47:41 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Metadata to highlight error line in scripts.
 | 
					
						
							|  |  |  | 		Array source_meta; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		source_meta.push_back(oe.source_file); | 
					
						
							|  |  |  | 		source_meta.push_back(oe.source_line); | 
					
						
							| 
									
										
										
										
											2019-09-25 10:47:41 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Create error tree to display above error or warning details.
 | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | 		TreeItem *r = error_tree->get_root(); | 
					
						
							|  |  |  | 		if (!r) { | 
					
						
							|  |  |  | 			r = error_tree->create_item(); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2015-08-04 09:47:32 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-25 10:47:41 +02:00
										 |  |  | 		// Also provide the relevant details as tooltip to quickly check without
 | 
					
						
							|  |  |  | 		// uncollapsing the tree.
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		String tooltip = oe.warning ? TTR("Warning:") : TTR("Error:"); | 
					
						
							| 
									
										
										
										
											2019-09-25 10:47:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | 		TreeItem *error = error_tree->create_item(r); | 
					
						
							|  |  |  | 		error->set_collapsed(true); | 
					
						
							| 
									
										
										
										
											2015-08-04 09:47:32 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-12 09:37:40 -03:00
										 |  |  | 		error->set_icon(0, get_theme_icon(oe.warning ? "Warning" : "Error", "EditorIcons")); | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | 		error->set_text(0, time); | 
					
						
							|  |  |  | 		error->set_text_align(0, TreeItem::ALIGN_LEFT); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-25 10:47:41 +02:00
										 |  |  | 		String error_title; | 
					
						
							|  |  |  | 		// Include method name, when given, in error title.
 | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		if (!oe.source_func.empty()) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 			error_title += oe.source_func + ": "; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2019-09-25 10:47:41 +02:00
										 |  |  | 		// If we have a (custom) error message, use it as title, and add a C++ Error
 | 
					
						
							|  |  |  | 		// item with the original error condition.
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		error_title += oe.error_descr.empty() ? oe.error : oe.error_descr; | 
					
						
							| 
									
										
										
										
											2019-09-25 10:47:41 +02:00
										 |  |  | 		error->set_text(1, error_title); | 
					
						
							|  |  |  | 		tooltip += " " + error_title + "\n"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		if (!oe.error_descr.empty()) { | 
					
						
							| 
									
										
										
										
											2019-09-25 10:47:41 +02:00
										 |  |  | 			// Add item for C++ error condition.
 | 
					
						
							|  |  |  | 			TreeItem *cpp_cond = error_tree->create_item(error); | 
					
						
							|  |  |  | 			cpp_cond->set_text(0, "<" + TTR("C++ Error") + ">"); | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 			cpp_cond->set_text(1, oe.error); | 
					
						
							| 
									
										
										
										
											2019-09-25 10:47:41 +02:00
										 |  |  | 			cpp_cond->set_text_align(0, TreeItem::ALIGN_LEFT); | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 			tooltip += TTR("C++ Error:") + " " + oe.error + "\n"; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 			if (source_is_project_file) { | 
					
						
							| 
									
										
										
										
											2019-09-25 10:47:41 +02:00
										 |  |  | 				cpp_cond->set_metadata(0, source_meta); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-09-25 10:47:41 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		Vector<uint8_t> v; | 
					
						
							|  |  |  | 		v.resize(100); | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-25 10:47:41 +02:00
										 |  |  | 		// Source of the error.
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		String source_txt = (source_is_project_file ? oe.source_file.get_file() : oe.source_file) + ":" + itos(oe.source_line); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		if (!oe.source_func.empty()) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 			source_txt += " @ " + oe.source_func + "()"; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2015-08-04 09:47:32 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-25 10:47:41 +02:00
										 |  |  | 		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"; | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-25 10:47:41 +02:00
										 |  |  | 		// Set metadata to highlight error line in scripts.
 | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | 		if (source_is_project_file) { | 
					
						
							| 
									
										
										
										
											2019-09-25 10:47:41 +02:00
										 |  |  | 			error->set_metadata(0, source_meta); | 
					
						
							|  |  |  | 			cpp_source->set_metadata(0, source_meta); | 
					
						
							| 
									
										
										
										
											2015-08-04 09:47:32 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-25 10:47:41 +02:00
										 |  |  | 		error->set_tooltip(0, tooltip); | 
					
						
							|  |  |  | 		error->set_tooltip(1, tooltip); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// 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).
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		const ScriptLanguage::StackInfo *infos = oe.callstack.ptr(); | 
					
						
							|  |  |  | 		for (unsigned int i = 0; i < (unsigned int)oe.callstack.size(); i++) { | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | 			TreeItem *stack_trace = error_tree->create_item(error); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			Array meta; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 			meta.push_back(infos[i].file); | 
					
						
							|  |  |  | 			meta.push_back(infos[i].line); | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | 			stack_trace->set_metadata(0, meta); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if (i == 0) { | 
					
						
							|  |  |  | 				stack_trace->set_text(0, "<" + TTR("Stack Trace") + ">"); | 
					
						
							|  |  |  | 				stack_trace->set_text_align(0, TreeItem::ALIGN_LEFT); | 
					
						
							|  |  |  | 				error->set_metadata(0, meta); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 			stack_trace->set_text(1, infos[i].file.get_file() + ":" + itos(infos[i].line) + " @ " + infos[i].func + "()"); | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2015-08-04 09:47:32 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		if (oe.warning) { | 
					
						
							| 
									
										
										
										
											2018-08-16 08:41:03 +03:00
										 |  |  | 			warning_count++; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2018-08-16 08:41:03 +03:00
										 |  |  | 			error_count++; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 	} else if (p_msg == "servers:function_signature") { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		// Cache a profiler signature.
 | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		DebuggerMarshalls::ScriptFunctionSignature sig; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		sig.deserialize(p_data); | 
					
						
							|  |  |  | 		profiler_signature[sig.id] = sig.name; | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 	} else if (p_msg == "servers:profile_frame" || p_msg == "servers:profile_total") { | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 		EditorProfiler::Metric metric; | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		DebuggerMarshalls::ServersProfilerFrame frame; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		frame.deserialize(p_data); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		metric.valid = true; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		metric.frame_number = frame.frame_number; | 
					
						
							|  |  |  | 		metric.frame_time = frame.frame_time; | 
					
						
							|  |  |  | 		metric.idle_time = frame.idle_time; | 
					
						
							|  |  |  | 		metric.physics_time = frame.physics_time; | 
					
						
							|  |  |  | 		metric.physics_frame_time = frame.physics_frame_time; | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		if (frame.servers.size()) { | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 			EditorProfiler::Metric::Category frame_time; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			frame_time.signature = "category_frame_time"; | 
					
						
							|  |  |  | 			frame_time.name = "Frame Time"; | 
					
						
							|  |  |  | 			frame_time.total_time = metric.frame_time; | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			EditorProfiler::Metric::Category::Item item; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			item.calls = 1; | 
					
						
							|  |  |  | 			item.line = 0; | 
					
						
							| 
									
										
										
										
											2018-04-19 13:04:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-21 21:28:08 +07:00
										 |  |  | 			item.name = "Physics Time"; | 
					
						
							| 
									
										
										
										
											2017-09-30 16:19:07 +02:00
										 |  |  | 			item.total = metric.physics_time; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			item.self = item.total; | 
					
						
							| 
									
										
										
										
											2017-09-30 16:19:07 +02:00
										 |  |  | 			item.signature = "physics_time"; | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			frame_time.items.push_back(item); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			item.name = "Idle Time"; | 
					
						
							|  |  |  | 			item.total = metric.idle_time; | 
					
						
							|  |  |  | 			item.self = item.total; | 
					
						
							|  |  |  | 			item.signature = "idle_time"; | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			frame_time.items.push_back(item); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-21 21:28:08 +07:00
										 |  |  | 			item.name = "Physics Frame Time"; | 
					
						
							| 
									
										
										
										
											2017-09-30 16:19:07 +02:00
										 |  |  | 			item.total = metric.physics_frame_time; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			item.self = item.total; | 
					
						
							| 
									
										
										
										
											2017-09-30 16:19:07 +02:00
										 |  |  | 			item.signature = "physics_frame_time"; | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			frame_time.items.push_back(item); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			metric.categories.push_back(frame_time); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		for (int i = 0; i < frame.servers.size(); i++) { | 
					
						
							|  |  |  | 			const DebuggerMarshalls::ServerInfo &srv = frame.servers[i]; | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 			EditorProfiler::Metric::Category c; | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 			const String name = srv.name; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			c.name = name.capitalize(); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 			c.items.resize(srv.functions.size()); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			c.total_time = 0; | 
					
						
							|  |  |  | 			c.signature = "categ::" + name; | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 			for (int j = 0; j < srv.functions.size(); j++) { | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 				EditorProfiler::Metric::Category::Item item; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				item.calls = 1; | 
					
						
							| 
									
										
										
										
											2018-04-19 13:04:41 +02:00
										 |  |  | 				item.line = 0; | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 				item.name = srv.functions[j].name; | 
					
						
							|  |  |  | 				item.self = srv.functions[j].time; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				item.total = item.self; | 
					
						
							|  |  |  | 				item.signature = "categ::" + name + "::" + item.name; | 
					
						
							|  |  |  | 				item.name = item.name.capitalize(); | 
					
						
							|  |  |  | 				c.total_time += item.total; | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 				c.items.write[j] = item; | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			metric.categories.push_back(c); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		EditorProfiler::Metric::Category funcs; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		funcs.total_time = frame.script_time; | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		funcs.items.resize(frame.script_functions.size()); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		funcs.name = "Script Functions"; | 
					
						
							|  |  |  | 		funcs.signature = "script_functions"; | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		for (int i = 0; i < frame.script_functions.size(); i++) { | 
					
						
							|  |  |  | 			int signature = frame.script_functions[i].sig_id; | 
					
						
							|  |  |  | 			int calls = frame.script_functions[i].call_count; | 
					
						
							|  |  |  | 			float total = frame.script_functions[i].total_time; | 
					
						
							|  |  |  | 			float self = frame.script_functions[i].self_time; | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			EditorProfiler::Metric::Category::Item item; | 
					
						
							|  |  |  | 			if (profiler_signature.has(signature)) { | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				item.signature = profiler_signature[signature]; | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				String name = profiler_signature[signature]; | 
					
						
							|  |  |  | 				Vector<String> strings = name.split("::"); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				if (strings.size() == 3) { | 
					
						
							|  |  |  | 					item.name = strings[2]; | 
					
						
							|  |  |  | 					item.script = strings[0]; | 
					
						
							|  |  |  | 					item.line = strings[1].to_int(); | 
					
						
							| 
									
										
										
										
											2019-01-25 02:19:06 +01:00
										 |  |  | 				} else if (strings.size() == 4) { //Built-in scripts have an :: in their name
 | 
					
						
							|  |  |  | 					item.name = strings[3]; | 
					
						
							|  |  |  | 					item.script = strings[0] + "::" + strings[1]; | 
					
						
							|  |  |  | 					item.line = strings[2].to_int(); | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				item.name = "SigErr " + itos(signature); | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			item.calls = calls; | 
					
						
							|  |  |  | 			item.self = self; | 
					
						
							|  |  |  | 			item.total = total; | 
					
						
							| 
									
										
										
										
											2018-07-25 03:11:03 +02:00
										 |  |  | 			funcs.items.write[i] = item; | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		metric.categories.push_back(funcs); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		if (p_msg == "servers:profile_frame") { | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			profiler->add_frame_metric(metric, false); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			profiler->add_frame_metric(metric, true); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 	} else if (p_msg == "network:profile_frame") { | 
					
						
							|  |  |  | 		DebuggerMarshalls::NetworkProfilerFrame frame; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		frame.deserialize(p_data); | 
					
						
							|  |  |  | 		for (int i = 0; i < frame.infos.size(); i++) { | 
					
						
							|  |  |  | 			network_profiler->add_node_frame_data(frame.infos[i]); | 
					
						
							| 
									
										
										
										
											2019-09-01 18:38:58 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	} else if (p_msg == "network:bandwidth") { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		ERR_FAIL_COND(p_data.size() < 2); | 
					
						
							| 
									
										
										
										
											2019-09-01 18:38:58 +02:00
										 |  |  | 		network_profiler->set_bandwidth(p_data[0], p_data[1]); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 	} else if (p_msg == "request_quit") { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		emit_signal("stop_requested"); | 
					
						
							|  |  |  | 		_stop_and_notify(); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		WARN_PRINT("unknown message " + p_msg); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-22 14:16:08 -05:00
										 |  |  | void ScriptEditorDebugger::_set_reason_text(const String &p_reason, MessageType p_type) { | 
					
						
							|  |  |  | 	switch (p_type) { | 
					
						
							|  |  |  | 		case MESSAGE_ERROR: | 
					
						
							| 
									
										
										
										
											2020-03-12 09:37:40 -03:00
										 |  |  | 			reason->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); | 
					
						
							| 
									
										
										
										
											2017-08-22 14:16:08 -05:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		case MESSAGE_WARNING: | 
					
						
							| 
									
										
										
										
											2020-03-12 09:37:40 -03:00
										 |  |  | 			reason->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor")); | 
					
						
							| 
									
										
										
										
											2017-08-22 14:16:08 -05:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		default: | 
					
						
							| 
									
										
										
										
											2020-03-12 09:37:40 -03:00
										 |  |  | 			reason->add_theme_color_override("font_color", get_theme_color("success_color", "Editor")); | 
					
						
							| 
									
										
										
										
											2017-08-22 14:16:08 -05:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	reason->set_text(p_reason); | 
					
						
							| 
									
										
										
										
											2018-05-26 13:50:46 +02:00
										 |  |  | 	reason->set_tooltip(p_reason.word_wrap(80)); | 
					
						
							| 
									
										
										
										
											2017-08-22 14:16:08 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-23 15:11:46 +07:00
										 |  |  | void ScriptEditorDebugger::_performance_select() { | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 	perf_draw->update(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ScriptEditorDebugger::_performance_draw() { | 
					
						
							|  |  |  | 	Vector<int> which; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	for (int i = 0; i < perf_items.size(); i++) { | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		if (perf_items[i]->is_checked(0)) { | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 			which.push_back(i); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-26 23:02:52 +07:00
										 |  |  | 	if (which.empty()) { | 
					
						
							| 
									
										
										
										
											2019-09-04 02:20:57 -03:00
										 |  |  | 		info_message->show(); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2017-08-26 23:02:52 +07:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-04 02:20:57 -03:00
										 |  |  | 	info_message->hide(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-06 01:30:29 +02:00
										 |  |  | 	const Ref<StyleBox> graph_sb = get_theme_stylebox("normal", "TextEdit"); | 
					
						
							|  |  |  | 	const Ref<Font> graph_font = get_theme_font("font", "TextEdit"); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-06 01:30:29 +02:00
										 |  |  | 	const int cols = Math::ceil(Math::sqrt((float)which.size())); | 
					
						
							| 
									
										
										
										
											2017-08-26 23:02:52 +07:00
										 |  |  | 	int rows = Math::ceil((float)which.size() / cols); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (which.size() == 1) { | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		rows = 1; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-06 01:30:29 +02:00
										 |  |  | 	const int margin = 3; | 
					
						
							|  |  |  | 	const int point_sep = 5; | 
					
						
							|  |  |  | 	const Size2i s = Size2i(perf_draw->get_size()) / Size2i(cols, rows); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	for (int i = 0; i < which.size(); i++) { | 
					
						
							|  |  |  | 		Point2i p(i % cols, i / cols); | 
					
						
							|  |  |  | 		Rect2i r(p * s, s); | 
					
						
							| 
									
										
										
										
											2017-06-04 00:25:13 +02:00
										 |  |  | 		r.position += Point2(margin, margin); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		r.size -= Point2(margin, margin) * 2.0; | 
					
						
							|  |  |  | 		perf_draw->draw_style_box(graph_sb, r); | 
					
						
							| 
									
										
										
										
											2017-06-04 00:25:13 +02:00
										 |  |  | 		r.position += graph_sb->get_offset(); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		r.size -= graph_sb->get_minimum_size(); | 
					
						
							| 
									
										
										
										
											2020-06-06 01:30:29 +02:00
										 |  |  | 		const int pi = which[i]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Draw horizontal lines with labels.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		int nb_lines = 5; | 
					
						
							|  |  |  | 		// Draw less lines if the monitor isn't tall enough to display 5 labels.
 | 
					
						
							|  |  |  | 		if (r.size.height <= 160 * EDSCALE) { | 
					
						
							|  |  |  | 			nb_lines = 3; | 
					
						
							|  |  |  | 		} else if (r.size.height <= 240 * EDSCALE) { | 
					
						
							|  |  |  | 			nb_lines = 4; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		const float inv_nb_lines = 1.0 / nb_lines; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		for (int line = 0; line < nb_lines; line += 1) { | 
					
						
							|  |  |  | 			const int from_x = r.position.x; | 
					
						
							|  |  |  | 			const int to_x = r.position.x + r.size.width; | 
					
						
							|  |  |  | 			const int y = r.position.y + (r.size.height * inv_nb_lines + line * inv_nb_lines * r.size.height); | 
					
						
							|  |  |  | 			perf_draw->draw_line( | 
					
						
							|  |  |  | 					Point2(from_x, y), | 
					
						
							|  |  |  | 					Point2i(to_x, y), | 
					
						
							|  |  |  | 					Color(0.5, 0.5, 0.5, 0.25), | 
					
						
							|  |  |  | 					Math::round(EDSCALE)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			String label; | 
					
						
							|  |  |  | 			switch (Performance::MonitorType((int)perf_items[pi]->get_metadata(1))) { | 
					
						
							|  |  |  | 				case Performance::MONITOR_TYPE_MEMORY: { | 
					
						
							|  |  |  | 					label = String::humanize_size(Math::ceil((1 - inv_nb_lines - inv_nb_lines * line) * perf_max[pi])); | 
					
						
							|  |  |  | 				} break; | 
					
						
							|  |  |  | 				case Performance::MONITOR_TYPE_TIME: { | 
					
						
							|  |  |  | 					label = rtos((1 - inv_nb_lines - inv_nb_lines * line) * perf_max[pi] * 1000).pad_decimals(2) + " ms"; | 
					
						
							|  |  |  | 				} break; | 
					
						
							|  |  |  | 				default: { | 
					
						
							|  |  |  | 					label = itos(Math::ceil((1 - inv_nb_lines - inv_nb_lines * line) * perf_max[pi])); | 
					
						
							|  |  |  | 				} break; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			perf_draw->draw_string( | 
					
						
							|  |  |  | 					graph_font, | 
					
						
							|  |  |  | 					Point2(from_x, y - graph_font->get_ascent() * 0.25), | 
					
						
							|  |  |  | 					label, | 
					
						
							|  |  |  | 					Color(0.5, 0.5, 0.5, 1.0)); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		const float h = (float)which[i] / (float)(perf_items.size()); | 
					
						
							|  |  |  | 		// Use a darker color on light backgrounds for better visibility.
 | 
					
						
							|  |  |  | 		const float value_multiplier = EditorSettings::get_singleton()->is_dark_theme() ? 1.4 : 0.55; | 
					
						
							|  |  |  | 		Color color = get_theme_color("accent_color", "Editor"); | 
					
						
							|  |  |  | 		color.set_hsv(Math::fmod(h + 0.4, 0.9), color.get_s() * 0.9, color.get_v() * value_multiplier); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Draw the monitor name in the top-left corner.
 | 
					
						
							|  |  |  | 		color.a = 0.6; | 
					
						
							|  |  |  | 		perf_draw->draw_string( | 
					
						
							|  |  |  | 				graph_font, | 
					
						
							|  |  |  | 				r.position + Point2(0, graph_font->get_ascent()), | 
					
						
							|  |  |  | 				perf_items[pi]->get_text(0), | 
					
						
							|  |  |  | 				color, | 
					
						
							|  |  |  | 				r.size.x); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Draw the monitor value in the top-left corner, just below the name.
 | 
					
						
							|  |  |  | 		color.a = 0.9; | 
					
						
							|  |  |  | 		perf_draw->draw_string( | 
					
						
							|  |  |  | 				graph_font, | 
					
						
							|  |  |  | 				r.position + Point2(0, graph_font->get_ascent() + graph_font->get_height()), | 
					
						
							|  |  |  | 				perf_items[pi]->get_text(1), | 
					
						
							|  |  |  | 				color, | 
					
						
							|  |  |  | 				r.size.y); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		const float spacing = point_sep / float(cols); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 		float from = r.size.width; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-06 01:30:29 +02:00
										 |  |  | 		const List<Vector<float>>::Element *E = perf_history.front(); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		float prev = -1; | 
					
						
							|  |  |  | 		while (from >= 0 && E) { | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 			float m = perf_max[pi]; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 			if (m == 0) { | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				m = 0.00001; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-02-12 21:10:08 +01:00
										 |  |  | 			float h2 = E->get()[pi] / m; | 
					
						
							|  |  |  | 			h2 = (1.0 - h2) * r.size.y; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 			if (E != perf_history.front()) { | 
					
						
							| 
									
										
										
										
											2020-06-06 01:30:29 +02:00
										 |  |  | 				perf_draw->draw_line( | 
					
						
							|  |  |  | 						r.position + Point2(from, h2), | 
					
						
							|  |  |  | 						r.position + Point2(from + spacing, prev), | 
					
						
							|  |  |  | 						color, | 
					
						
							|  |  |  | 						Math::round(EDSCALE)); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-02-12 21:10:08 +01:00
										 |  |  | 			prev = h2; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			E = E->next(); | 
					
						
							|  |  |  | 			from -= spacing; | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ScriptEditorDebugger::_notification(int p_what) { | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	switch (p_what) { | 
					
						
							| 
									
										
										
										
											2014-11-05 21:20:42 -03:00
										 |  |  | 		case NOTIFICATION_ENTER_TREE: { | 
					
						
							| 
									
										
										
										
											2020-03-12 09:37:40 -03:00
										 |  |  | 			skip_breakpoints->set_icon(get_theme_icon("DebugSkipBreakpointsOff", "EditorIcons")); | 
					
						
							|  |  |  | 			copy->set_icon(get_theme_icon("ActionCopy", "EditorIcons")); | 
					
						
							| 
									
										
										
										
											2018-02-13 19:46:45 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-12 09:37:40 -03:00
										 |  |  | 			step->set_icon(get_theme_icon("DebugStep", "EditorIcons")); | 
					
						
							|  |  |  | 			next->set_icon(get_theme_icon("DebugNext", "EditorIcons")); | 
					
						
							|  |  |  | 			dobreak->set_icon(get_theme_icon("Pause", "EditorIcons")); | 
					
						
							|  |  |  | 			docontinue->set_icon(get_theme_icon("DebugContinue", "EditorIcons")); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 			le_set->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_live_edit_set)); | 
					
						
							|  |  |  | 			le_clear->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_live_edit_clear)); | 
					
						
							|  |  |  | 			error_tree->connect("item_selected", callable_mp(this, &ScriptEditorDebugger::_error_selected)); | 
					
						
							|  |  |  | 			error_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_error_activated)); | 
					
						
							| 
									
										
										
										
											2020-03-12 09:37:40 -03:00
										 |  |  | 			vmem_refresh->set_icon(get_theme_icon("Reload", "EditorIcons")); | 
					
						
							| 
									
										
										
										
											2020-03-17 13:46:18 +01:00
										 |  |  | 			vmem_export->set_icon(get_theme_icon("Save", "EditorIcons")); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-12 09:37:40 -03:00
										 |  |  | 			reason->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); | 
					
						
							| 
									
										
										
										
											2017-08-07 21:55:24 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 		} break; | 
					
						
							|  |  |  | 		case NOTIFICATION_PROCESS: { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 			if (is_session_active()) { | 
					
						
							| 
									
										
										
										
											2020-03-16 09:37:43 +01:00
										 |  |  | 				peer->poll(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-24 06:21:15 +01:00
										 |  |  | 				if (camera_override == CameraOverride::OVERRIDE_2D) { | 
					
						
							| 
									
										
										
										
											2019-04-06 22:55:01 +02:00
										 |  |  | 					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(transform); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 					_put_msg("scene:override_camera_2D:transform", msg); | 
					
						
							| 
									
										
										
										
											2019-04-06 22:55:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-24 06:21:15 +01:00
										 |  |  | 				} else if (camera_override >= CameraOverride::OVERRIDE_3D_1) { | 
					
						
							|  |  |  | 					int viewport_idx = camera_override - CameraOverride::OVERRIDE_3D_1; | 
					
						
							| 
									
										
										
										
											2020-03-26 18:49:16 -03:00
										 |  |  | 					Node3DEditorViewport *viewport = Node3DEditor::get_singleton()->get_editor_viewport(viewport_idx); | 
					
						
							|  |  |  | 					Camera3D *const cam = viewport->get_camera(); | 
					
						
							| 
									
										
										
										
											2019-04-06 22:55:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 					Array msg; | 
					
						
							|  |  |  | 					msg.push_back(cam->get_camera_transform()); | 
					
						
							| 
									
										
										
										
											2020-03-26 18:49:16 -03:00
										 |  |  | 					if (cam->get_projection() == Camera3D::PROJECTION_ORTHOGONAL) { | 
					
						
							| 
									
										
										
										
											2019-04-06 22:55:01 +02:00
										 |  |  | 						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()); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 					_put_msg("scene:override_camera_3D:transform", msg); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2019-06-04 07:37:57 +02:00
										 |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-03 15:59:10 +01:00
										 |  |  | 			const uint64_t until = OS::get_singleton()->get_ticks_msec() + 20; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-19 07:21:43 +05:30
										 |  |  | 			while (peer.is_valid() && peer->has_message()) { | 
					
						
							| 
									
										
										
										
											2020-02-24 06:21:15 +01:00
										 |  |  | 				Array arr = peer->get_message(); | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 				if (arr.size() != 2 || arr[0].get_type() != Variant::STRING || arr[1].get_type() != Variant::ARRAY) { | 
					
						
							|  |  |  | 					_stop_and_notify(); | 
					
						
							|  |  |  | 					ERR_FAIL_MSG("Invalid message format received from peer"); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				_parse_message(arr[0], arr[1]); | 
					
						
							| 
									
										
										
										
											2018-01-03 15:59:10 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 				if (OS::get_singleton()->get_ticks_msec() > until) { | 
					
						
							| 
									
										
										
										
											2018-01-03 15:59:10 +01:00
										 |  |  | 					break; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2020-02-24 06:21:15 +01:00
										 |  |  | 			if (!is_session_active()) { | 
					
						
							|  |  |  | 				_stop_and_notify(); | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			}; | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 		} break; | 
					
						
							| 
									
										
										
										
											2017-05-03 05:13:12 +09:00
										 |  |  | 		case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { | 
					
						
							| 
									
										
										
										
											2020-03-12 09:37:40 -03:00
										 |  |  | 			if (tabs->has_theme_stylebox_override("panel")) { | 
					
						
							|  |  |  | 				tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles")); | 
					
						
							| 
									
										
										
										
											2020-02-22 01:04:55 -03:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-11-21 18:20:57 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-12 09:37:40 -03:00
										 |  |  | 			copy->set_icon(get_theme_icon("ActionCopy", "EditorIcons")); | 
					
						
							|  |  |  | 			step->set_icon(get_theme_icon("DebugStep", "EditorIcons")); | 
					
						
							|  |  |  | 			next->set_icon(get_theme_icon("DebugNext", "EditorIcons")); | 
					
						
							|  |  |  | 			dobreak->set_icon(get_theme_icon("Pause", "EditorIcons")); | 
					
						
							|  |  |  | 			docontinue->set_icon(get_theme_icon("DebugContinue", "EditorIcons")); | 
					
						
							|  |  |  | 			vmem_refresh->set_icon(get_theme_icon("Reload", "EditorIcons")); | 
					
						
							| 
									
										
										
										
											2020-03-17 13:46:18 +01:00
										 |  |  | 			vmem_export->set_icon(get_theme_icon("Save", "EditorIcons")); | 
					
						
							| 
									
										
										
										
											2017-05-03 05:13:12 +09:00
										 |  |  | 		} break; | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-22 17:20:27 +01:00
										 |  |  | void ScriptEditorDebugger::_clear_execution() { | 
					
						
							|  |  |  | 	TreeItem *ti = stack_dump->get_selected(); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (!ti) { | 
					
						
							| 
									
										
										
										
											2019-04-22 17:20:27 +01:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-04-22 17:20:27 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	Dictionary d = ti->get_metadata(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	stack_script = ResourceLoader::load(d["file"]); | 
					
						
							|  |  |  | 	emit_signal("clear_execution", stack_script); | 
					
						
							|  |  |  | 	stack_script.unref(); | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	stack_dump->clear(); | 
					
						
							|  |  |  | 	inspector->clear_stack_variables(); | 
					
						
							| 
									
										
										
										
											2019-04-22 17:20:27 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | void ScriptEditorDebugger::start(Ref<RemoteDebuggerPeer> p_peer) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	error_count = 0; | 
					
						
							|  |  |  | 	warning_count = 0; | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 	stop(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-24 06:21:15 +01:00
										 |  |  | 	peer = p_peer; | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 	ERR_FAIL_COND(p_peer.is_null()); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	perf_history.clear(); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	for (int i = 0; i < Performance::MONITOR_MAX; i++) { | 
					
						
							| 
									
										
										
										
											2018-07-25 03:11:03 +02:00
										 |  |  | 		perf_max.write[i] = 0; | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	set_process(true); | 
					
						
							| 
									
										
										
										
											2018-01-07 13:00:15 +01:00
										 |  |  | 	breaked = false; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	can_debug = true; | 
					
						
							| 
									
										
										
										
											2020-02-24 06:21:15 +01:00
										 |  |  | 	camera_override = CameraOverride::OVERRIDE_NONE; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	tabs->set_current_tab(0); | 
					
						
							|  |  |  | 	_set_reason_text(TTR("Debug session started."), MESSAGE_SUCCESS); | 
					
						
							|  |  |  | 	_update_buttons_state(); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | void ScriptEditorDebugger::_update_buttons_state() { | 
					
						
							|  |  |  | 	const bool active = is_session_active(); | 
					
						
							|  |  |  | 	const bool has_editor_tree = active && editor_remote_tree && editor_remote_tree->get_selected(); | 
					
						
							|  |  |  | 	vmem_refresh->set_disabled(!active); | 
					
						
							|  |  |  | 	step->set_disabled(!active || !breaked || !can_debug); | 
					
						
							|  |  |  | 	next->set_disabled(!active || !breaked || !can_debug); | 
					
						
							|  |  |  | 	copy->set_disabled(!active || !breaked); | 
					
						
							|  |  |  | 	docontinue->set_disabled(!active || !breaked); | 
					
						
							|  |  |  | 	dobreak->set_disabled(!active || breaked); | 
					
						
							|  |  |  | 	le_clear->set_disabled(!active); | 
					
						
							|  |  |  | 	le_set->set_disabled(!has_editor_tree); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | void ScriptEditorDebugger::_stop_and_notify() { | 
					
						
							|  |  |  | 	stop(); | 
					
						
							|  |  |  | 	emit_signal("stopped"); | 
					
						
							|  |  |  | 	_set_reason_text(TTR("Debug session closed."), MESSAGE_WARNING); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | void ScriptEditorDebugger::stop() { | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 	set_process(false); | 
					
						
							| 
									
										
										
										
											2018-01-07 13:00:15 +01:00
										 |  |  | 	breaked = false; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	can_debug = false; | 
					
						
							|  |  |  | 	remote_pid = 0; | 
					
						
							| 
									
										
										
										
											2019-04-22 17:20:27 +01:00
										 |  |  | 	_clear_execution(); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	inspector->clear_cache(); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-24 06:21:15 +01:00
										 |  |  | 	if (peer.is_valid()) { | 
					
						
							|  |  |  | 		peer->close(); | 
					
						
							|  |  |  | 		peer.unref(); | 
					
						
							| 
									
										
										
										
											2018-08-20 20:46:14 +02:00
										 |  |  | 		reason->set_text(""); | 
					
						
							|  |  |  | 		reason->set_tooltip(""); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 	node_path_cache.clear(); | 
					
						
							|  |  |  | 	res_path_cache.clear(); | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 	profiler_signature.clear(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-02 01:20:12 +02:00
										 |  |  | 	inspector->edit(nullptr); | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	_update_buttons_state(); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | void ScriptEditorDebugger::_profiler_activate(bool p_enable, int p_type) { | 
					
						
							|  |  |  | 	Array data; | 
					
						
							|  |  |  | 	data.push_back(p_enable); | 
					
						
							|  |  |  | 	switch (p_type) { | 
					
						
							|  |  |  | 		case PROFILER_NETWORK: | 
					
						
							|  |  |  | 			_put_msg("profiler:network", data); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case PROFILER_VISUAL: | 
					
						
							|  |  |  | 			_put_msg("profiler:visual", data); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case PROFILER_SCRIPTS_SERVERS: | 
					
						
							|  |  |  | 			if (p_enable) { | 
					
						
							|  |  |  | 				// Clear old script signatures. (should we move all this into the profiler?)
 | 
					
						
							|  |  |  | 				profiler_signature.clear(); | 
					
						
							|  |  |  | 				// Add max funcs options to request.
 | 
					
						
							|  |  |  | 				Array opts; | 
					
						
							|  |  |  | 				int max_funcs = EditorSettings::get_singleton()->get("debugger/profiler_frame_max_functions"); | 
					
						
							|  |  |  | 				opts.push_back(CLAMP(max_funcs, 16, 512)); | 
					
						
							|  |  |  | 				data.push_back(opts); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			_put_msg("profiler:servers", data); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 			ERR_FAIL_MSG("Invalid profiler type"); | 
					
						
							| 
									
										
										
										
											2019-09-01 18:38:58 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | void ScriptEditorDebugger::_profiler_seeked() { | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (breaked) { | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-14 18:03:38 +01:00
										 |  |  | 	debug_break(); | 
					
						
							| 
									
										
										
										
											2016-05-21 21:18:16 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | void ScriptEditorDebugger::_stack_dump_frame_selected() { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	emit_signal("stack_frame_selected"); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	int frame = get_stack_script_frame(); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	if (is_session_active() && frame >= 0) { | 
					
						
							| 
									
										
										
										
											2018-02-21 19:28:26 +08:00
										 |  |  | 		Array msg; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		msg.push_back(frame); | 
					
						
							|  |  |  | 		_put_msg("get_stack_frame_vars", msg); | 
					
						
							| 
									
										
										
										
											2018-02-21 19:28:26 +08:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2020-04-02 01:20:12 +02:00
										 |  |  | 		inspector->edit(nullptr); | 
					
						
							| 
									
										
										
										
											2018-02-21 19:28:26 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-18 01:25:26 +01:00
										 |  |  | void ScriptEditorDebugger::_export_csv() { | 
					
						
							| 
									
										
										
										
											2020-03-06 14:00:16 -03:00
										 |  |  | 	file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); | 
					
						
							| 
									
										
										
										
											2020-01-24 12:18:00 +01:00
										 |  |  | 	file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM); | 
					
						
							| 
									
										
										
										
											2020-03-17 13:46:18 +01:00
										 |  |  | 	file_dialog_purpose = SAVE_MONITORS_CSV; | 
					
						
							| 
									
										
										
										
											2019-02-18 01:25:26 +01:00
										 |  |  | 	file_dialog->popup_centered_ratio(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | String ScriptEditorDebugger::get_var_value(const String &p_var) const { | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (!breaked) { | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 		return String(); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	return inspector->get_stack_variable(p_var); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | int ScriptEditorDebugger::_get_node_path_cache(const NodePath &p_path) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 	const int *r = node_path_cache.getptr(p_path); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (r) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 		return *r; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	last_path_id++; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	node_path_cache[p_path] = last_path_id; | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 	Array msg; | 
					
						
							|  |  |  | 	msg.push_back(p_path); | 
					
						
							|  |  |  | 	msg.push_back(last_path_id); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 	_put_msg("scene:live_node_path", msg); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return last_path_id; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | int ScriptEditorDebugger::_get_res_path_cache(const String &p_path) { | 
					
						
							|  |  |  | 	Map<String, int>::Element *E = res_path_cache.find(p_path); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (E) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 		return E->get(); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	last_path_id++; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	res_path_cache[p_path] = last_path_id; | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 	Array msg; | 
					
						
							|  |  |  | 	msg.push_back(p_path); | 
					
						
							|  |  |  | 	msg.push_back(last_path_id); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 	_put_msg("scene:live_res_path", msg); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return last_path_id; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE) { | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (!p_base || !live_debug || !is_session_active() || !editor->get_edited_scene()) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-24 22:58:51 +02:00
										 |  |  | 	Node *node = Object::cast_to<Node>(p_base); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	VARIANT_ARGPTRS | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	for (int i = 0; i < VARIANT_ARG_MAX; i++) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 		//no pointers, sorry
 | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		if (argptr[i] && (argptr[i]->get_type() == Variant::OBJECT || argptr[i]->get_type() == Variant::_RID)) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 			return; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (node) { | 
					
						
							|  |  |  | 		NodePath path = editor->get_edited_scene()->get_path_to(node); | 
					
						
							|  |  |  | 		int pathid = _get_node_path_cache(path); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		Array msg; | 
					
						
							|  |  |  | 		msg.push_back(pathid); | 
					
						
							|  |  |  | 		msg.push_back(p_name); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		for (int i = 0; i < VARIANT_ARG_MAX; i++) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 			//no pointers, sorry
 | 
					
						
							|  |  |  | 			msg.push_back(*argptr[i]); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		_put_msg("scene:live_node_call", msg); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-24 22:58:51 +02:00
										 |  |  | 	Resource *res = Object::cast_to<Resource>(p_base); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	if (res && res->get_path() != String()) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 		String respath = res->get_path(); | 
					
						
							|  |  |  | 		int pathid = _get_res_path_cache(respath); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		Array msg; | 
					
						
							|  |  |  | 		msg.push_back(pathid); | 
					
						
							|  |  |  | 		msg.push_back(p_name); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		for (int i = 0; i < VARIANT_ARG_MAX; i++) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 			//no pointers, sorry
 | 
					
						
							|  |  |  | 			msg.push_back(*argptr[i]); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		_put_msg("scene:live_res_call", msg); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p_property, const Variant &p_value) { | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (!p_base || !live_debug || !editor->get_edited_scene()) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-24 22:58:51 +02:00
										 |  |  | 	Node *node = Object::cast_to<Node>(p_base); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (node) { | 
					
						
							|  |  |  | 		NodePath path = editor->get_edited_scene()->get_path_to(node); | 
					
						
							|  |  |  | 		int pathid = _get_node_path_cache(path); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (p_value.is_ref()) { | 
					
						
							|  |  |  | 			Ref<Resource> res = p_value; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			if (res.is_valid() && res->get_path() != String()) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 				Array msg; | 
					
						
							|  |  |  | 				msg.push_back(pathid); | 
					
						
							|  |  |  | 				msg.push_back(p_property); | 
					
						
							|  |  |  | 				msg.push_back(res->get_path()); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 				_put_msg("scene:live_node_prop_res", msg); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			Array msg; | 
					
						
							|  |  |  | 			msg.push_back(pathid); | 
					
						
							|  |  |  | 			msg.push_back(p_property); | 
					
						
							|  |  |  | 			msg.push_back(p_value); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 			_put_msg("scene:live_node_prop", msg); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-24 22:58:51 +02:00
										 |  |  | 	Resource *res = Object::cast_to<Resource>(p_base); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	if (res && res->get_path() != String()) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 		String respath = res->get_path(); | 
					
						
							|  |  |  | 		int pathid = _get_res_path_cache(respath); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (p_value.is_ref()) { | 
					
						
							| 
									
										
										
										
											2019-02-12 21:10:08 +01:00
										 |  |  | 			Ref<Resource> res2 = p_value; | 
					
						
							|  |  |  | 			if (res2.is_valid() && res2->get_path() != String()) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 				Array msg; | 
					
						
							|  |  |  | 				msg.push_back(pathid); | 
					
						
							|  |  |  | 				msg.push_back(p_property); | 
					
						
							| 
									
										
										
										
											2019-02-12 21:10:08 +01:00
										 |  |  | 				msg.push_back(res2->get_path()); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 				_put_msg("scene:live_res_prop_res", msg); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			Array msg; | 
					
						
							|  |  |  | 			msg.push_back(pathid); | 
					
						
							|  |  |  | 			msg.push_back(p_property); | 
					
						
							|  |  |  | 			msg.push_back(p_value); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 			_put_msg("scene:live_res_prop", msg); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | String ScriptEditorDebugger::get_stack_script_file() const { | 
					
						
							|  |  |  | 	TreeItem *ti = stack_dump->get_selected(); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (!ti) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		return ""; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	Dictionary d = ti->get_metadata(0); | 
					
						
							|  |  |  | 	return d["file"]; | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | int ScriptEditorDebugger::get_stack_script_line() const { | 
					
						
							|  |  |  | 	TreeItem *ti = stack_dump->get_selected(); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (!ti) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		return -1; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	Dictionary d = ti->get_metadata(0); | 
					
						
							|  |  |  | 	return d["line"]; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | int ScriptEditorDebugger::get_stack_script_frame() const { | 
					
						
							|  |  |  | 	TreeItem *ti = stack_dump->get_selected(); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (!ti) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		return -1; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	Dictionary d = ti->get_metadata(0); | 
					
						
							|  |  |  | 	return d["frame"]; | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ScriptEditorDebugger::set_live_debugging(bool p_enable) { | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	live_debug = p_enable; | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ScriptEditorDebugger::_live_edit_set() { | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (!is_session_active() || !editor_remote_tree) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	TreeItem *ti = editor_remote_tree->get_selected(); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (!ti) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 	String path; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	while (ti) { | 
					
						
							|  |  |  | 		String lp = ti->get_text(0); | 
					
						
							|  |  |  | 		path = "/" + lp + path; | 
					
						
							|  |  |  | 		ti = ti->get_parent(); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	NodePath np = path; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	editor->get_editor_data().set_edited_scene_live_edit_root(np); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	update_live_edit_root(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ScriptEditorDebugger::_live_edit_clear() { | 
					
						
							|  |  |  | 	NodePath np = NodePath("/root"); | 
					
						
							|  |  |  | 	editor->get_editor_data().set_edited_scene_live_edit_root(np); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	update_live_edit_root(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ScriptEditorDebugger::update_live_edit_root() { | 
					
						
							|  |  |  | 	NodePath np = editor->get_editor_data().get_edited_scene_live_edit_root(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	Array msg; | 
					
						
							|  |  |  | 	msg.push_back(np); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (editor->get_edited_scene()) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		msg.push_back(editor->get_edited_scene()->get_filename()); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		msg.push_back(""); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 	_put_msg("scene:live_set_root", msg); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 	live_edit_root->set_text(np); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | void ScriptEditorDebugger::live_debug_create_node(const NodePath &p_parent, const String &p_type, const String &p_name) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	if (live_debug) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 		Array msg; | 
					
						
							|  |  |  | 		msg.push_back(p_parent); | 
					
						
							|  |  |  | 		msg.push_back(p_type); | 
					
						
							|  |  |  | 		msg.push_back(p_name); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		_put_msg("scene:live_create_node", msg); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | void ScriptEditorDebugger::live_debug_instance_node(const NodePath &p_parent, const String &p_path, const String &p_name) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	if (live_debug) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 		Array msg; | 
					
						
							|  |  |  | 		msg.push_back(p_parent); | 
					
						
							|  |  |  | 		msg.push_back(p_path); | 
					
						
							|  |  |  | 		msg.push_back(p_name); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		_put_msg("scene:live_instance_node", msg); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-05-14 14:29:06 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | void ScriptEditorDebugger::live_debug_remove_node(const NodePath &p_at) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	if (live_debug) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 		Array msg; | 
					
						
							|  |  |  | 		msg.push_back(p_at); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		_put_msg("scene:live_remove_node", msg); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-05-14 14:29:06 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | void ScriptEditorDebugger::live_debug_remove_and_keep_node(const NodePath &p_at, ObjectID p_keep_id) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	if (live_debug) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 		Array msg; | 
					
						
							|  |  |  | 		msg.push_back(p_at); | 
					
						
							|  |  |  | 		msg.push_back(p_keep_id); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		_put_msg("scene:live_remove_and_keep_node", msg); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-05-14 14:29:06 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | void ScriptEditorDebugger::live_debug_restore_node(ObjectID p_id, const NodePath &p_at, int p_at_pos) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	if (live_debug) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 		Array msg; | 
					
						
							|  |  |  | 		msg.push_back(p_id); | 
					
						
							|  |  |  | 		msg.push_back(p_at); | 
					
						
							|  |  |  | 		msg.push_back(p_at_pos); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		_put_msg("scene:live_restore_node", msg); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-05-14 14:29:06 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | void ScriptEditorDebugger::live_debug_duplicate_node(const NodePath &p_at, const String &p_new_name) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	if (live_debug) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 		Array msg; | 
					
						
							|  |  |  | 		msg.push_back(p_at); | 
					
						
							|  |  |  | 		msg.push_back(p_new_name); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		_put_msg("scene:live_duplicate_node", msg); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-05-14 14:29:06 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | void ScriptEditorDebugger::live_debug_reparent_node(const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	if (live_debug) { | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 		Array msg; | 
					
						
							|  |  |  | 		msg.push_back(p_at); | 
					
						
							|  |  |  | 		msg.push_back(p_new_place); | 
					
						
							|  |  |  | 		msg.push_back(p_new_name); | 
					
						
							| 
									
										
										
										
											2015-08-02 20:28:10 -03:00
										 |  |  | 		msg.push_back(p_at_pos); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		_put_msg("scene:live_reparent_node", msg); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-24 06:21:15 +01:00
										 |  |  | CameraOverride ScriptEditorDebugger::get_camera_override() const { | 
					
						
							| 
									
										
										
										
											2019-04-06 22:55:01 +02:00
										 |  |  | 	return camera_override; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ScriptEditorDebugger::set_camera_override(CameraOverride p_override) { | 
					
						
							| 
									
										
										
										
											2020-02-24 06:21:15 +01:00
										 |  |  | 	if (p_override == CameraOverride::OVERRIDE_2D && camera_override != CameraOverride::OVERRIDE_2D) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		Array msg; | 
					
						
							|  |  |  | 		msg.push_back(true); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		_put_msg("scene:override_camera_2D:set", msg); | 
					
						
							| 
									
										
										
										
											2020-02-24 06:21:15 +01:00
										 |  |  | 	} else if (p_override != CameraOverride::OVERRIDE_2D && camera_override == CameraOverride::OVERRIDE_2D) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		Array msg; | 
					
						
							|  |  |  | 		msg.push_back(false); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		_put_msg("scene:override_camera_2D:set", msg); | 
					
						
							| 
									
										
										
										
											2020-02-24 06:21:15 +01:00
										 |  |  | 	} else if (p_override >= CameraOverride::OVERRIDE_3D_1 && camera_override < CameraOverride::OVERRIDE_3D_1) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		Array msg; | 
					
						
							|  |  |  | 		msg.push_back(true); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		_put_msg("scene:override_camera_3D:set", msg); | 
					
						
							| 
									
										
										
										
											2020-02-24 06:21:15 +01:00
										 |  |  | 	} else if (p_override < CameraOverride::OVERRIDE_3D_1 && camera_override >= CameraOverride::OVERRIDE_3D_1) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		Array msg; | 
					
						
							|  |  |  | 		msg.push_back(false); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		_put_msg("scene:override_camera_3D:set", msg); | 
					
						
							| 
									
										
										
										
											2019-04-06 22:55:01 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	camera_override = p_override; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | void ScriptEditorDebugger::set_breakpoint(const String &p_path, int p_line, bool p_enabled) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	Array msg; | 
					
						
							|  |  |  | 	msg.push_back(p_path); | 
					
						
							|  |  |  | 	msg.push_back(p_line); | 
					
						
							|  |  |  | 	msg.push_back(p_enabled); | 
					
						
							|  |  |  | 	_put_msg("breakpoint", msg); | 
					
						
							| 
									
										
										
										
											2015-08-04 20:17:13 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-01 20:22:02 -03:00
										 |  |  | void ScriptEditorDebugger::reload_scripts() { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	_put_msg("reload_scripts", Array()); | 
					
						
							| 
									
										
										
										
											2016-06-01 20:22:02 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-29 20:09:22 +02:00
										 |  |  | bool ScriptEditorDebugger::is_skip_breakpoints() { | 
					
						
							|  |  |  | 	return skip_breakpoints_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | void ScriptEditorDebugger::_error_activated() { | 
					
						
							|  |  |  | 	TreeItem *selected = error_tree->get_selected(); | 
					
						
							| 
									
										
										
										
											2015-08-04 09:47:32 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | 	TreeItem *ci = selected->get_children(); | 
					
						
							|  |  |  | 	if (ci) { | 
					
						
							|  |  |  | 		selected->set_collapsed(!selected->is_collapsed()); | 
					
						
							| 
									
										
										
										
											2015-08-04 09:47:32 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | void ScriptEditorDebugger::_error_selected() { | 
					
						
							|  |  |  | 	TreeItem *selected = error_tree->get_selected(); | 
					
						
							|  |  |  | 	Array meta = selected->get_metadata(0); | 
					
						
							|  |  |  | 	if (meta.size() == 0) { | 
					
						
							| 
									
										
										
										
											2015-08-04 09:47:32 -03:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-08-04 09:47:32 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	emit_signal("error_selected", String(meta[0]), int(meta[1])); | 
					
						
							| 
									
										
										
										
											2015-08-04 09:47:32 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-12 23:53:10 -03:00
										 |  |  | void ScriptEditorDebugger::_expand_errors_list() { | 
					
						
							|  |  |  | 	TreeItem *root = error_tree->get_root(); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (!root) { | 
					
						
							| 
									
										
										
										
											2018-09-12 23:53:10 -03:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-09-12 23:53:10 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	TreeItem *item = root->get_children(); | 
					
						
							|  |  |  | 	while (item) { | 
					
						
							|  |  |  | 		item->set_collapsed(false); | 
					
						
							|  |  |  | 		item = item->get_next(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ScriptEditorDebugger::_collapse_errors_list() { | 
					
						
							|  |  |  | 	TreeItem *root = error_tree->get_root(); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (!root) { | 
					
						
							| 
									
										
										
										
											2018-09-12 23:53:10 -03:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-09-12 23:53:10 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	TreeItem *item = root->get_children(); | 
					
						
							|  |  |  | 	while (item) { | 
					
						
							|  |  |  | 		item->set_collapsed(true); | 
					
						
							|  |  |  | 		item = item->get_next(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-18 01:16:11 +03:00
										 |  |  | void ScriptEditorDebugger::_clear_errors_list() { | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | 	error_tree->clear(); | 
					
						
							| 
									
										
										
										
											2017-12-18 01:16:11 +03:00
										 |  |  | 	error_count = 0; | 
					
						
							| 
									
										
										
										
											2018-08-16 08:41:03 +03:00
										 |  |  | 	warning_count = 0; | 
					
						
							| 
									
										
										
										
											2017-12-18 01:16:11 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Right click on specific file(s) or folder(s).
 | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | void ScriptEditorDebugger::_error_tree_item_rmb_selected(const Vector2 &p_pos) { | 
					
						
							| 
									
										
										
										
											2017-12-18 01:16:11 +03:00
										 |  |  | 	item_menu->clear(); | 
					
						
							|  |  |  | 	item_menu->set_size(Size2(1, 1)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | 	if (error_tree->is_anything_selected()) { | 
					
						
							| 
									
										
										
										
											2020-03-12 09:37:40 -03:00
										 |  |  | 		item_menu->add_icon_item(get_theme_icon("ActionCopy", "EditorIcons"), TTR("Copy Error"), 0); | 
					
						
							| 
									
										
										
										
											2017-12-18 01:16:11 +03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (item_menu->get_item_count() > 0) { | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | 		item_menu->set_position(error_tree->get_global_position() + p_pos); | 
					
						
							| 
									
										
										
										
											2017-12-18 01:16:11 +03:00
										 |  |  | 		item_menu->popup(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	TreeItem *ti = error_tree->get_selected(); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	while (ti->get_parent() != error_tree->get_root()) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		ti = ti->get_parent(); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-12-18 01:16:11 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	String type; | 
					
						
							| 
									
										
										
										
											2018-02-21 23:07:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-12 09:37:40 -03:00
										 |  |  | 	if (ti->get_icon(0) == get_theme_icon("Warning", "EditorIcons")) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		type = "W "; | 
					
						
							| 
									
										
										
										
											2020-03-12 09:37:40 -03:00
										 |  |  | 	} else if (ti->get_icon(0) == get_theme_icon("Error", "EditorIcons")) { | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		type = "E "; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-05-05 03:59:10 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	String text = ti->get_text(0) + "   "; | 
					
						
							|  |  |  | 	int rpad_len = text.length(); | 
					
						
							| 
									
										
										
										
											2019-05-05 03:59:10 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	text = type + text + ti->get_text(1) + "\n"; | 
					
						
							|  |  |  | 	TreeItem *ci = ti->get_children(); | 
					
						
							|  |  |  | 	while (ci) { | 
					
						
							|  |  |  | 		text += "  " + ci->get_text(0).rpad(rpad_len) + ci->get_text(1) + "\n"; | 
					
						
							|  |  |  | 		ci = ci->get_next(); | 
					
						
							| 
									
										
										
										
											2017-12-18 01:16:11 +03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-03 10:36:29 -03:00
										 |  |  | 	DisplayServer::get_singleton()->clipboard_set(text); | 
					
						
							| 
									
										
										
										
											2017-12-18 01:16:11 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-28 16:37:15 +01:00
										 |  |  | void ScriptEditorDebugger::_tab_changed(int p_tab) { | 
					
						
							|  |  |  | 	if (tabs->get_tab_title(p_tab) == TTR("Video RAM")) { | 
					
						
							| 
									
										
										
										
											2020-03-11 13:59:18 -04:00
										 |  |  | 		// "Video RAM" tab was clicked, refresh the data it's displaying when entering the tab.
 | 
					
						
							| 
									
										
										
										
											2019-11-28 16:37:15 +01:00
										 |  |  | 		_video_mem_request(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | void ScriptEditorDebugger::_bind_methods() { | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	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); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("live_debug_remove_node"), &ScriptEditorDebugger::live_debug_remove_node); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("live_debug_remove_and_keep_node"), &ScriptEditorDebugger::live_debug_remove_and_keep_node); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("live_debug_restore_node"), &ScriptEditorDebugger::live_debug_restore_node); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("live_debug_duplicate_node"), &ScriptEditorDebugger::live_debug_duplicate_node); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("live_debug_reparent_node"), &ScriptEditorDebugger::live_debug_reparent_node); | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	ClassDB::bind_method(D_METHOD("request_remote_object", "id"), &ScriptEditorDebugger::request_remote_object); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("update_remote_object", "id", "property", "value"), &ScriptEditorDebugger::update_remote_object); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	ADD_SIGNAL(MethodInfo("stopped")); | 
					
						
							|  |  |  | 	ADD_SIGNAL(MethodInfo("stop_requested")); | 
					
						
							|  |  |  | 	ADD_SIGNAL(MethodInfo("stack_frame_selected", PropertyInfo(Variant::INT, "frame"))); | 
					
						
							|  |  |  | 	ADD_SIGNAL(MethodInfo("error_selected", PropertyInfo(Variant::INT, "error"))); | 
					
						
							| 
									
										
										
										
											2019-04-22 17:20:27 +01:00
										 |  |  | 	ADD_SIGNAL(MethodInfo("set_execution", PropertyInfo("script"), PropertyInfo(Variant::INT, "line"))); | 
					
						
							|  |  |  | 	ADD_SIGNAL(MethodInfo("clear_execution", PropertyInfo("script"))); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	ADD_SIGNAL(MethodInfo("breaked", PropertyInfo(Variant::BOOL, "reallydid"), PropertyInfo(Variant::BOOL, "can_debug"))); | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	ADD_SIGNAL(MethodInfo("remote_object_requested", PropertyInfo(Variant::INT, "id"))); | 
					
						
							|  |  |  | 	ADD_SIGNAL(MethodInfo("remote_object_updated", PropertyInfo(Variant::INT, "id"))); | 
					
						
							|  |  |  | 	ADD_SIGNAL(MethodInfo("remote_object_property_updated", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::STRING, "property"))); | 
					
						
							|  |  |  | 	ADD_SIGNAL(MethodInfo("remote_tree_updated")); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { | 
					
						
							|  |  |  | 	editor = p_editor; | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	tabs = memnew(TabContainer); | 
					
						
							| 
									
										
										
										
											2017-05-03 05:13:12 +09:00
										 |  |  | 	tabs->set_tab_align(TabContainer::ALIGN_LEFT); | 
					
						
							| 
									
										
										
										
											2020-03-12 09:37:40 -03:00
										 |  |  | 	tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles")); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 	tabs->connect("tab_changed", callable_mp(this, &ScriptEditorDebugger::_tab_changed)); | 
					
						
							| 
									
										
										
										
											2017-09-18 21:06:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 	add_child(tabs); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 	{ //debugger
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		VBoxContainer *vbc = memnew(VBoxContainer); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		vbc->set_name(TTR("Debugger")); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		Control *dbg = vbc; | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		HBoxContainer *hbc = memnew(HBoxContainer); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		vbc->add_child(hbc); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-07 21:55:24 -05:00
										 |  |  | 		reason = memnew(Label); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		reason->set_text(""); | 
					
						
							|  |  |  | 		hbc->add_child(reason); | 
					
						
							|  |  |  | 		reason->set_h_size_flags(SIZE_EXPAND_FILL); | 
					
						
							| 
									
										
										
										
											2018-05-26 13:50:46 +02:00
										 |  |  | 		reason->set_autowrap(true); | 
					
						
							|  |  |  | 		reason->set_max_lines_visible(3); | 
					
						
							|  |  |  | 		reason->set_mouse_filter(Control::MOUSE_FILTER_PASS); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		hbc->add_child(memnew(VSeparator)); | 
					
						
							| 
									
										
										
										
											2019-07-29 20:09:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-19 20:49:04 +02:00
										 |  |  | 		skip_breakpoints = memnew(Button); | 
					
						
							|  |  |  | 		skip_breakpoints->set_flat(true); | 
					
						
							| 
									
										
										
										
											2019-07-29 20:09:22 +02:00
										 |  |  | 		hbc->add_child(skip_breakpoints); | 
					
						
							|  |  |  | 		skip_breakpoints->set_tooltip(TTR("Skip Breakpoints")); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 		skip_breakpoints->connect("pressed", callable_mp(this, &ScriptEditorDebugger::debug_skip_breakpoints)); | 
					
						
							| 
									
										
										
										
											2019-07-29 20:09:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		hbc->add_child(memnew(VSeparator)); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-19 20:49:04 +02:00
										 |  |  | 		copy = memnew(Button); | 
					
						
							|  |  |  | 		copy->set_flat(true); | 
					
						
							| 
									
										
										
										
											2018-02-13 19:46:45 +03:00
										 |  |  | 		hbc->add_child(copy); | 
					
						
							|  |  |  | 		copy->set_tooltip(TTR("Copy Error")); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 		copy->connect("pressed", callable_mp(this, &ScriptEditorDebugger::debug_copy)); | 
					
						
							| 
									
										
										
										
											2018-02-13 19:46:45 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		hbc->add_child(memnew(VSeparator)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-19 20:49:04 +02:00
										 |  |  | 		step = memnew(Button); | 
					
						
							|  |  |  | 		step->set_flat(true); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		hbc->add_child(step); | 
					
						
							|  |  |  | 		step->set_tooltip(TTR("Step Into")); | 
					
						
							| 
									
										
										
										
											2019-09-22 19:19:53 +02:00
										 |  |  | 		step->set_shortcut(ED_GET_SHORTCUT("debugger/step_into")); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 		step->connect("pressed", callable_mp(this, &ScriptEditorDebugger::debug_step)); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-19 20:49:04 +02:00
										 |  |  | 		next = memnew(Button); | 
					
						
							|  |  |  | 		next->set_flat(true); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		hbc->add_child(next); | 
					
						
							|  |  |  | 		next->set_tooltip(TTR("Step Over")); | 
					
						
							| 
									
										
										
										
											2019-09-22 19:19:53 +02:00
										 |  |  | 		next->set_shortcut(ED_GET_SHORTCUT("debugger/step_over")); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 		next->connect("pressed", callable_mp(this, &ScriptEditorDebugger::debug_next)); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		hbc->add_child(memnew(VSeparator)); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-19 20:49:04 +02:00
										 |  |  | 		dobreak = memnew(Button); | 
					
						
							|  |  |  | 		dobreak->set_flat(true); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		hbc->add_child(dobreak); | 
					
						
							|  |  |  | 		dobreak->set_tooltip(TTR("Break")); | 
					
						
							| 
									
										
										
										
											2019-09-22 19:19:53 +02:00
										 |  |  | 		dobreak->set_shortcut(ED_GET_SHORTCUT("debugger/break")); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 		dobreak->connect("pressed", callable_mp(this, &ScriptEditorDebugger::debug_break)); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-19 20:49:04 +02:00
										 |  |  | 		docontinue = memnew(Button); | 
					
						
							|  |  |  | 		docontinue->set_flat(true); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		hbc->add_child(docontinue); | 
					
						
							|  |  |  | 		docontinue->set_tooltip(TTR("Continue")); | 
					
						
							| 
									
										
										
										
											2019-09-22 19:19:53 +02:00
										 |  |  | 		docontinue->set_shortcut(ED_GET_SHORTCUT("debugger/continue")); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 		docontinue->connect("pressed", callable_mp(this, &ScriptEditorDebugger::debug_continue)); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		HSplitContainer *sc = memnew(HSplitContainer); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		vbc->add_child(sc); | 
					
						
							|  |  |  | 		sc->set_v_size_flags(SIZE_EXPAND_FILL); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		stack_dump = memnew(Tree); | 
					
						
							| 
									
										
										
										
											2018-02-19 23:35:52 -03:00
										 |  |  | 		stack_dump->set_allow_reselect(true); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		stack_dump->set_columns(1); | 
					
						
							|  |  |  | 		stack_dump->set_column_titles_visible(true); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		stack_dump->set_column_title(0, TTR("Stack Frames")); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		stack_dump->set_h_size_flags(SIZE_EXPAND_FILL); | 
					
						
							|  |  |  | 		stack_dump->set_hide_root(true); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 		stack_dump->connect("cell_selected", callable_mp(this, &ScriptEditorDebugger::_stack_dump_frame_selected)); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		sc->add_child(stack_dump); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		inspector = memnew(EditorDebuggerInspector); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		inspector->set_h_size_flags(SIZE_EXPAND_FILL); | 
					
						
							| 
									
										
										
										
											2017-04-26 13:41:41 +02:00
										 |  |  | 		inspector->set_enable_capitalize_paths(false); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		inspector->set_read_only(true); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 		inspector->connect("object_selected", callable_mp(this, &ScriptEditorDebugger::_remote_object_selected)); | 
					
						
							|  |  |  | 		inspector->connect("object_edited", callable_mp(this, &ScriptEditorDebugger::_remote_object_edited)); | 
					
						
							|  |  |  | 		inspector->connect("object_property_updated", callable_mp(this, &ScriptEditorDebugger::_remote_object_property_updated)); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		sc->add_child(inspector); | 
					
						
							|  |  |  | 		tabs->add_child(dbg); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	{ //errors
 | 
					
						
							| 
									
										
										
										
											2019-02-28 22:12:14 +01:00
										 |  |  | 		errors_tab = memnew(VBoxContainer); | 
					
						
							|  |  |  | 		errors_tab->set_name(TTR("Errors")); | 
					
						
							| 
									
										
										
										
											2018-09-12 23:53:10 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-18 01:16:11 +03:00
										 |  |  | 		HBoxContainer *errhb = memnew(HBoxContainer); | 
					
						
							| 
									
										
										
										
											2019-02-28 22:12:14 +01:00
										 |  |  | 		errors_tab->add_child(errhb); | 
					
						
							| 
									
										
										
										
											2018-09-12 23:53:10 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		Button *expand_all = memnew(Button); | 
					
						
							|  |  |  | 		expand_all->set_text(TTR("Expand All")); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 		expand_all->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_expand_errors_list)); | 
					
						
							| 
									
										
										
										
											2018-09-12 23:53:10 -03:00
										 |  |  | 		errhb->add_child(expand_all); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		Button *collapse_all = memnew(Button); | 
					
						
							|  |  |  | 		collapse_all->set_text(TTR("Collapse All")); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 		collapse_all->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_collapse_errors_list)); | 
					
						
							| 
									
										
										
										
											2018-09-12 23:53:10 -03:00
										 |  |  | 		errhb->add_child(collapse_all); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		Control *space = memnew(Control); | 
					
						
							|  |  |  | 		space->set_h_size_flags(SIZE_EXPAND_FILL); | 
					
						
							|  |  |  | 		errhb->add_child(space); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		clearbutton = memnew(Button); | 
					
						
							|  |  |  | 		clearbutton->set_text(TTR("Clear")); | 
					
						
							|  |  |  | 		clearbutton->set_h_size_flags(0); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 		clearbutton->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_clear_errors_list)); | 
					
						
							| 
									
										
										
										
											2018-09-12 23:53:10 -03:00
										 |  |  | 		errhb->add_child(clearbutton); | 
					
						
							| 
									
										
										
										
											2017-12-18 01:16:11 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | 		error_tree = memnew(Tree); | 
					
						
							|  |  |  | 		error_tree->set_columns(2); | 
					
						
							| 
									
										
										
										
											2017-12-18 01:16:11 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | 		error_tree->set_column_expand(0, false); | 
					
						
							|  |  |  | 		error_tree->set_column_min_width(0, 140); | 
					
						
							| 
									
										
										
										
											2017-12-18 01:16:11 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | 		error_tree->set_column_expand(1, true); | 
					
						
							| 
									
										
										
										
											2017-12-18 01:16:11 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | 		error_tree->set_select_mode(Tree::SELECT_ROW); | 
					
						
							|  |  |  | 		error_tree->set_hide_root(true); | 
					
						
							| 
									
										
										
										
											2018-09-12 23:53:10 -03:00
										 |  |  | 		error_tree->set_v_size_flags(SIZE_EXPAND_FILL); | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | 		error_tree->set_allow_rmb_select(true); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 		error_tree->connect("item_rmb_selected", callable_mp(this, &ScriptEditorDebugger::_error_tree_item_rmb_selected)); | 
					
						
							| 
									
										
										
										
											2019-02-28 22:12:14 +01:00
										 |  |  | 		errors_tab->add_child(error_tree); | 
					
						
							| 
									
										
										
										
											2017-12-18 01:16:11 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | 		item_menu = memnew(PopupMenu); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 		item_menu->connect("id_pressed", callable_mp(this, &ScriptEditorDebugger::_item_menu_id_pressed)); | 
					
						
							| 
									
										
										
										
											2018-09-08 19:31:49 -04:00
										 |  |  | 		error_tree->add_child(item_menu); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-28 22:12:14 +01:00
										 |  |  | 		tabs->add_child(errors_tab); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-21 23:07:49 +08:00
										 |  |  | 	{ // File dialog
 | 
					
						
							|  |  |  | 		file_dialog = memnew(EditorFileDialog); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 		file_dialog->connect("file_selected", callable_mp(this, &ScriptEditorDebugger::_file_selected)); | 
					
						
							| 
									
										
										
										
											2018-02-21 23:07:49 +08:00
										 |  |  | 		add_child(file_dialog); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 	{ //profiler
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		profiler = memnew(EditorProfiler); | 
					
						
							| 
									
										
										
										
											2016-05-30 21:47:53 +03:00
										 |  |  | 		profiler->set_name(TTR("Profiler")); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		tabs->add_child(profiler); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		profiler->connect("enable_profiling", callable_mp(this, &ScriptEditorDebugger::_profiler_activate), varray(PROFILER_SCRIPTS_SERVERS)); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 		profiler->connect("break_request", callable_mp(this, &ScriptEditorDebugger::_profiler_seeked)); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-20 17:58:06 -03:00
										 |  |  | 	{ //frame profiler
 | 
					
						
							|  |  |  | 		visual_profiler = memnew(EditorVisualProfiler); | 
					
						
							|  |  |  | 		visual_profiler->set_name(TTR("Visual Profiler")); | 
					
						
							|  |  |  | 		tabs->add_child(visual_profiler); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		visual_profiler->connect("enable_profiling", callable_mp(this, &ScriptEditorDebugger::_profiler_activate), varray(PROFILER_VISUAL)); | 
					
						
							| 
									
										
										
										
											2019-09-20 17:58:06 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-01 18:38:58 +02:00
										 |  |  | 	{ //network profiler
 | 
					
						
							|  |  |  | 		network_profiler = memnew(EditorNetworkProfiler); | 
					
						
							|  |  |  | 		network_profiler->set_name(TTR("Network Profiler")); | 
					
						
							|  |  |  | 		tabs->add_child(network_profiler); | 
					
						
							| 
									
										
										
										
											2020-03-08 12:21:08 +01:00
										 |  |  | 		network_profiler->connect("enable_profiling", callable_mp(this, &ScriptEditorDebugger::_profiler_activate), varray(PROFILER_NETWORK)); | 
					
						
							| 
									
										
										
										
											2019-09-01 18:38:58 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 	{ //monitors
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		HSplitContainer *hsp = memnew(HSplitContainer); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		perf_monitors = memnew(Tree); | 
					
						
							|  |  |  | 		perf_monitors->set_columns(2); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		perf_monitors->set_column_title(0, TTR("Monitor")); | 
					
						
							|  |  |  | 		perf_monitors->set_column_title(1, TTR("Value")); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		perf_monitors->set_column_titles_visible(true); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 		perf_monitors->connect("item_edited", callable_mp(this, &ScriptEditorDebugger::_performance_select)); | 
					
						
							| 
									
										
										
										
											2019-09-04 02:20:57 -03:00
										 |  |  | 		hsp->add_child(perf_monitors); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		perf_draw = memnew(Control); | 
					
						
							| 
									
										
										
										
											2019-09-04 02:20:57 -03:00
										 |  |  | 		perf_draw->set_clip_contents(true); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 		perf_draw->connect("draw", callable_mp(this, &ScriptEditorDebugger::_performance_draw)); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		hsp->add_child(perf_draw); | 
					
						
							| 
									
										
										
										
											2019-09-04 02:20:57 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-30 21:47:53 +03:00
										 |  |  | 		hsp->set_name(TTR("Monitors")); | 
					
						
							| 
									
										
										
										
											2017-10-23 15:11:46 +07:00
										 |  |  | 		hsp->set_split_offset(340 * EDSCALE); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		tabs->add_child(hsp); | 
					
						
							|  |  |  | 		perf_max.resize(Performance::MONITOR_MAX); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		Map<String, TreeItem *> bases; | 
					
						
							|  |  |  | 		TreeItem *root = perf_monitors->create_item(); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		perf_monitors->set_hide_root(true); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		for (int i = 0; i < Performance::MONITOR_MAX; i++) { | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 			String n = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)); | 
					
						
							| 
									
										
										
										
											2017-10-23 01:59:04 -05:00
										 |  |  | 			Performance::MonitorType mtype = Performance::get_singleton()->get_monitor_type(Performance::Monitor(i)); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			String base = n.get_slice("/", 0); | 
					
						
							|  |  |  | 			String name = n.get_slice("/", 1); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 			if (!bases.has(base)) { | 
					
						
							|  |  |  | 				TreeItem *b = perf_monitors->create_item(root); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				b->set_text(0, base.capitalize()); | 
					
						
							|  |  |  | 				b->set_editable(0, false); | 
					
						
							|  |  |  | 				b->set_selectable(0, false); | 
					
						
							| 
									
										
										
										
											2017-10-23 15:11:46 +07:00
										 |  |  | 				b->set_expand_right(0, true); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				bases[base] = b; | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			TreeItem *it = perf_monitors->create_item(bases[base]); | 
					
						
							| 
									
										
										
										
											2017-10-23 01:59:04 -05:00
										 |  |  | 			it->set_metadata(1, mtype); | 
					
						
							| 
									
										
										
										
											2017-10-23 15:11:46 +07:00
										 |  |  | 			it->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); | 
					
						
							|  |  |  | 			it->set_editable(0, true); | 
					
						
							|  |  |  | 			it->set_selectable(0, false); | 
					
						
							|  |  |  | 			it->set_selectable(1, false); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			it->set_text(0, name.capitalize()); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 			perf_items.push_back(it); | 
					
						
							| 
									
										
										
										
											2018-07-25 03:11:03 +02:00
										 |  |  | 			perf_max.write[i] = 0; | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2019-09-04 02:20:57 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		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); | 
					
						
							| 
									
										
										
										
											2019-11-04 10:12:15 +01:00
										 |  |  | 		info_message->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); | 
					
						
							| 
									
										
										
										
											2019-09-04 02:20:57 -03:00
										 |  |  | 		info_message->set_anchors_and_margins_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE); | 
					
						
							|  |  |  | 		perf_draw->add_child(info_message); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	{ //vmem inspect
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		VBoxContainer *vmem_vb = memnew(VBoxContainer); | 
					
						
							|  |  |  | 		HBoxContainer *vmem_hb = memnew(HBoxContainer); | 
					
						
							|  |  |  | 		Label *vmlb = memnew(Label(TTR("List of Video Memory Usage by Resource:") + " ")); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		vmlb->set_h_size_flags(SIZE_EXPAND_FILL); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		vmem_hb->add_child(vmlb); | 
					
						
							|  |  |  | 		vmem_hb->add_child(memnew(Label(TTR("Total:") + " "))); | 
					
						
							|  |  |  | 		vmem_total = memnew(LineEdit); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		vmem_total->set_editable(false); | 
					
						
							| 
									
										
										
										
											2019-09-04 02:20:57 -03:00
										 |  |  | 		vmem_total->set_custom_minimum_size(Size2(100, 0) * EDSCALE); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		vmem_hb->add_child(vmem_total); | 
					
						
							| 
									
										
										
										
											2020-06-19 20:49:04 +02:00
										 |  |  | 		vmem_refresh = memnew(Button); | 
					
						
							|  |  |  | 		vmem_refresh->set_flat(true); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		vmem_hb->add_child(vmem_refresh); | 
					
						
							| 
									
										
										
										
											2020-06-19 20:49:04 +02:00
										 |  |  | 		vmem_export = memnew(Button); | 
					
						
							|  |  |  | 		vmem_export->set_flat(true); | 
					
						
							| 
									
										
										
										
											2020-03-17 13:46:18 +01:00
										 |  |  | 		vmem_export->set_tooltip(TTR("Export list to a CSV file")); | 
					
						
							|  |  |  | 		vmem_hb->add_child(vmem_export); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		vmem_vb->add_child(vmem_hb); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 		vmem_refresh->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_video_mem_request)); | 
					
						
							| 
									
										
										
										
											2020-03-17 13:46:18 +01:00
										 |  |  | 		vmem_export->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_video_mem_export)); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-07 21:55:24 -05:00
										 |  |  | 		VBoxContainer *vmmc = memnew(VBoxContainer); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		vmem_tree = memnew(Tree); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		vmem_tree->set_v_size_flags(SIZE_EXPAND_FILL); | 
					
						
							|  |  |  | 		vmem_tree->set_h_size_flags(SIZE_EXPAND_FILL); | 
					
						
							|  |  |  | 		vmmc->add_child(vmem_tree); | 
					
						
							|  |  |  | 		vmmc->set_v_size_flags(SIZE_EXPAND_FILL); | 
					
						
							|  |  |  | 		vmem_vb->add_child(vmmc); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-28 16:37:15 +01:00
										 |  |  | 		vmem_vb->set_name(TTR("Video RAM")); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		vmem_tree->set_columns(4); | 
					
						
							|  |  |  | 		vmem_tree->set_column_titles_visible(true); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		vmem_tree->set_column_title(0, TTR("Resource Path")); | 
					
						
							|  |  |  | 		vmem_tree->set_column_expand(0, true); | 
					
						
							|  |  |  | 		vmem_tree->set_column_expand(1, false); | 
					
						
							|  |  |  | 		vmem_tree->set_column_title(1, TTR("Type")); | 
					
						
							| 
									
										
										
										
											2019-11-28 16:37:15 +01:00
										 |  |  | 		vmem_tree->set_column_min_width(1, 100 * EDSCALE); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		vmem_tree->set_column_expand(2, false); | 
					
						
							|  |  |  | 		vmem_tree->set_column_title(2, TTR("Format")); | 
					
						
							| 
									
										
										
										
											2019-11-28 16:37:15 +01:00
										 |  |  | 		vmem_tree->set_column_min_width(2, 150 * EDSCALE); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		vmem_tree->set_column_expand(3, false); | 
					
						
							|  |  |  | 		vmem_tree->set_column_title(3, TTR("Usage")); | 
					
						
							| 
									
										
										
										
											2019-11-28 16:37:15 +01:00
										 |  |  | 		vmem_tree->set_column_min_width(3, 80 * EDSCALE); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		vmem_tree->set_hide_root(true); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		tabs->add_child(vmem_vb); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	{ // misc
 | 
					
						
							| 
									
										
										
										
											2019-02-18 01:25:26 +01:00
										 |  |  | 		VBoxContainer *misc = memnew(VBoxContainer); | 
					
						
							|  |  |  | 		misc->set_name(TTR("Misc")); | 
					
						
							|  |  |  | 		tabs->add_child(misc); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-18 01:09:19 -05:00
										 |  |  | 		GridContainer *info_left = memnew(GridContainer); | 
					
						
							|  |  |  | 		info_left->set_columns(2); | 
					
						
							| 
									
										
										
										
											2019-02-18 01:25:26 +01:00
										 |  |  | 		misc->add_child(info_left); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		clicked_ctrl = memnew(LineEdit); | 
					
						
							| 
									
										
										
										
											2017-07-18 01:09:19 -05:00
										 |  |  | 		clicked_ctrl->set_h_size_flags(SIZE_EXPAND_FILL); | 
					
						
							|  |  |  | 		info_left->add_child(memnew(Label(TTR("Clicked Control:")))); | 
					
						
							|  |  |  | 		info_left->add_child(clicked_ctrl); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		clicked_ctrl_type = memnew(LineEdit); | 
					
						
							| 
									
										
										
										
											2017-07-18 01:09:19 -05:00
										 |  |  | 		info_left->add_child(memnew(Label(TTR("Clicked Control Type:")))); | 
					
						
							|  |  |  | 		info_left->add_child(clicked_ctrl_type); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 		scene_tree = memnew(SceneDebuggerTree); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		live_edit_root = memnew(LineEdit); | 
					
						
							| 
									
										
										
										
											2017-07-18 01:09:19 -05:00
										 |  |  | 		live_edit_root->set_h_size_flags(SIZE_EXPAND_FILL); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			HBoxContainer *lehb = memnew(HBoxContainer); | 
					
						
							| 
									
										
										
										
											2017-05-03 06:02:06 +09:00
										 |  |  | 			Label *l = memnew(Label(TTR("Live Edit Root:"))); | 
					
						
							| 
									
										
										
										
											2017-07-18 01:09:19 -05:00
										 |  |  | 			info_left->add_child(l); | 
					
						
							|  |  |  | 			lehb->add_child(live_edit_root); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			le_set = memnew(Button(TTR("Set From Tree"))); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 			lehb->add_child(le_set); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			le_clear = memnew(Button(TTR("Clear"))); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 			lehb->add_child(le_clear); | 
					
						
							| 
									
										
										
										
											2017-05-03 06:02:06 +09:00
										 |  |  | 			info_left->add_child(lehb); | 
					
						
							| 
									
										
										
										
											2016-05-22 19:28:37 -03:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2019-02-18 01:25:26 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		misc->add_child(memnew(VSeparator)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		HBoxContainer *buttons = memnew(HBoxContainer); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		export_csv = memnew(Button(TTR("Export measures as CSV"))); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 		export_csv->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_export_csv)); | 
					
						
							| 
									
										
										
										
											2019-02-18 01:25:26 +01:00
										 |  |  | 		buttons->add_child(export_csv); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		misc->add_child(buttons); | 
					
						
							| 
									
										
										
										
											2015-08-02 12:29:37 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	msgdialog = memnew(AcceptDialog); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 	add_child(msgdialog); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-11 09:14:06 -03:00
										 |  |  | 	live_debug = true; | 
					
						
							| 
									
										
										
										
											2020-02-24 06:21:15 +01:00
										 |  |  | 	camera_override = CameraOverride::OVERRIDE_NONE; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	last_path_id = false; | 
					
						
							|  |  |  | 	error_count = 0; | 
					
						
							| 
									
										
										
										
											2018-08-16 08:41:03 +03:00
										 |  |  | 	warning_count = 0; | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	_update_buttons_state(); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ScriptEditorDebugger::~ScriptEditorDebugger() { | 
					
						
							| 
									
										
										
										
											2020-02-24 06:21:15 +01:00
										 |  |  | 	if (peer.is_valid()) { | 
					
						
							|  |  |  | 		peer->close(); | 
					
						
							|  |  |  | 		peer.unref(); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-02-07 02:52:05 +01:00
										 |  |  | 	memdelete(scene_tree); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | } |