2014-02-10 02:10:30 +01: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-10 02:10:30 +01:00
/*************************************************************************/
2017-01-01 22:01:57 +01:00
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
2017-04-08 00:11:42 +02:00
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
2014-02-10 02:10:30 +01: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. */
/*************************************************************************/
2014-02-13 22:03:28 +01:00
# include "script_editor_debugger.h"
2017-01-16 08:04:19 +01:00
2014-02-13 22:03:28 +01:00
# include "editor_node.h"
2016-05-22 02:18:16 +02:00
# include "editor_profiler.h"
# include "editor_settings.h"
2017-03-05 16:44:50 +01:00
# include "main/performance.h"
2017-07-30 22:53:40 +02:00
# include "project_settings.h"
2017-03-05 16:44:50 +01:00
# include "property_editor.h"
# 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"
2014-02-13 22:03:28 +01:00
class ScriptEditorDebuggerVariables : public Object {
2017-03-05 16:44:50 +01:00
GDCLASS ( ScriptEditorDebuggerVariables , Object ) ;
2014-02-13 22:03:28 +01:00
List < PropertyInfo > props ;
2017-03-05 16:44:50 +01:00
Map < StringName , Variant > values ;
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
protected :
bool _set ( const StringName & p_name , const Variant & p_value ) {
2014-02-13 22:03:28 +01:00
return false ;
}
2017-03-05 16:44:50 +01:00
bool _get ( const StringName & p_name , Variant & r_ret ) const {
2014-02-13 22:03:28 +01:00
if ( ! values . has ( p_name ) )
return false ;
2017-03-05 16:44:50 +01:00
r_ret = values [ p_name ] ;
2014-02-13 22:03:28 +01:00
return true ;
}
2017-03-05 16:44:50 +01:00
void _get_property_list ( List < PropertyInfo > * p_list ) const {
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
for ( const List < PropertyInfo > : : Element * E = props . front ( ) ; E ; E = E - > next ( ) )
2014-02-13 22:03:28 +01:00
p_list - > push_back ( E - > get ( ) ) ;
}
public :
void clear ( ) {
props . clear ( ) ;
values . clear ( ) ;
}
2017-03-05 16:44:50 +01:00
String get_var_value ( const String & p_var ) const {
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
for ( Map < StringName , Variant > : : Element * E = values . front ( ) ; E ; E = E - > next ( ) ) {
String v = E - > key ( ) . operator String ( ) . get_slice ( " / " , 1 ) ;
if ( v = = p_var )
2014-02-13 22:03:28 +01:00
return E - > get ( ) ;
}
return " " ;
}
2017-05-01 19:27:01 +02:00
void add_property ( const String & p_name , const Variant & p_value , const PropertyHint & p_hint , const String p_hint_string ) {
2014-02-13 22:03:28 +01:00
PropertyInfo pinfo ;
2017-03-05 16:44:50 +01:00
pinfo . name = p_name ;
pinfo . type = p_value . get_type ( ) ;
2017-05-01 19:27:01 +02:00
pinfo . hint = p_hint ;
pinfo . hint_string = p_hint_string ;
2014-02-13 22:03:28 +01:00
props . push_back ( pinfo ) ;
2017-03-05 16:44:50 +01:00
values [ p_name ] = p_value ;
2014-02-13 22:03:28 +01:00
}
void update ( ) {
_change_notify ( ) ;
}
ScriptEditorDebuggerVariables ( ) {
}
} ;
2016-05-23 00:28:37 +02:00
class ScriptEditorDebuggerInspectedObject : public Object {
2017-03-05 16:44:50 +01:00
GDCLASS ( ScriptEditorDebuggerInspectedObject , Object ) ;
2016-05-23 00:28:37 +02:00
protected :
2017-03-05 16:44:50 +01:00
bool _set ( const StringName & p_name , const Variant & p_value ) {
2016-05-23 00:28:37 +02:00
if ( ! prop_values . has ( p_name ) )
return false ;
2017-03-05 16:44:50 +01:00
emit_signal ( " value_edited " , p_name , p_value ) ;
prop_values [ p_name ] = p_value ;
2016-05-23 00:28:37 +02:00
return true ;
}
2017-03-05 16:44:50 +01:00
bool _get ( const StringName & p_name , Variant & r_ret ) const {
2016-05-23 00:28:37 +02:00
if ( ! prop_values . has ( p_name ) )
return false ;
2017-03-05 16:44:50 +01:00
r_ret = prop_values [ p_name ] ;
2016-05-23 00:28:37 +02:00
return true ;
}
2017-03-05 16:44:50 +01:00
void _get_property_list ( List < PropertyInfo > * p_list ) const {
2016-05-23 00:28:37 +02:00
p_list - > clear ( ) ; //sorry, no want category
2017-03-05 16:44:50 +01:00
for ( const List < PropertyInfo > : : Element * E = prop_list . front ( ) ; E ; E = E - > next ( ) ) {
2016-05-23 00:28:37 +02:00
p_list - > push_back ( E - > get ( ) ) ;
}
}
static void _bind_methods ( ) {
ADD_SIGNAL ( MethodInfo ( " value_edited " ) ) ;
}
public :
ObjectID last_edited_id ;
List < PropertyInfo > prop_list ;
2017-03-05 16:44:50 +01:00
Map < StringName , Variant > prop_values ;
2016-05-23 00:28:37 +02:00
void update ( ) {
_change_notify ( ) ;
}
2017-03-05 16:44:50 +01:00
void update_single ( const char * p_prop ) {
2016-05-23 00:28:37 +02:00
_change_notify ( p_prop ) ;
}
2017-03-05 16:44:50 +01:00
ScriptEditorDebuggerInspectedObject ( ) { last_edited_id = 0 ; }
2016-05-23 00:28:37 +02:00
} ;
2014-02-13 22:03:28 +01:00
void ScriptEditorDebugger : : debug_next ( ) {
ERR_FAIL_COND ( ! breaked ) ;
ERR_FAIL_COND ( connection . is_null ( ) ) ;
2017-01-14 15:07:57 +01:00
ERR_FAIL_COND ( ! connection - > is_connected_to_host ( ) ) ;
2014-02-13 22:03:28 +01:00
Array msg ;
msg . push_back ( " next " ) ;
ppeer - > put_var ( msg ) ;
stack_dump - > clear ( ) ;
inspector - > edit ( NULL ) ;
}
void ScriptEditorDebugger : : debug_step ( ) {
ERR_FAIL_COND ( ! breaked ) ;
ERR_FAIL_COND ( connection . is_null ( ) ) ;
2017-01-14 15:07:57 +01:00
ERR_FAIL_COND ( ! connection - > is_connected_to_host ( ) ) ;
2014-02-13 22:03:28 +01:00
Array msg ;
msg . push_back ( " step " ) ;
ppeer - > put_var ( msg ) ;
stack_dump - > clear ( ) ;
inspector - > edit ( NULL ) ;
}
void ScriptEditorDebugger : : debug_break ( ) {
ERR_FAIL_COND ( breaked ) ;
ERR_FAIL_COND ( connection . is_null ( ) ) ;
2017-01-14 15:07:57 +01:00
ERR_FAIL_COND ( ! connection - > is_connected_to_host ( ) ) ;
2014-02-13 22:03:28 +01:00
Array msg ;
msg . push_back ( " break " ) ;
ppeer - > put_var ( msg ) ;
}
void ScriptEditorDebugger : : debug_continue ( ) {
ERR_FAIL_COND ( ! breaked ) ;
ERR_FAIL_COND ( connection . is_null ( ) ) ;
2017-01-14 15:07:57 +01:00
ERR_FAIL_COND ( ! connection - > is_connected_to_host ( ) ) ;
2014-02-13 22:03:28 +01:00
2016-09-14 04:02:18 +02:00
OS : : get_singleton ( ) - > enable_for_stealing_focus ( EditorNode : : get_singleton ( ) - > get_child_process_id ( ) ) ;
2014-02-13 22:03:28 +01:00
Array msg ;
msg . push_back ( " continue " ) ;
ppeer - > put_var ( msg ) ;
}
2017-03-05 16:44:50 +01:00
void ScriptEditorDebugger : : _scene_tree_folded ( Object * obj ) {
2016-05-23 00:28:37 +02:00
if ( updating_scene_tree ) {
return ;
}
2017-08-24 22:58:51 +02:00
TreeItem * item = Object : : cast_to < TreeItem > ( obj ) ;
2016-05-23 00:28:37 +02:00
if ( ! item )
return ;
ObjectID id = item - > get_metadata ( 0 ) ;
if ( item - > is_collapsed ( ) ) {
unfold_cache . erase ( id ) ;
} else {
unfold_cache . insert ( id ) ;
}
}
void ScriptEditorDebugger : : _scene_tree_selected ( ) {
if ( updating_scene_tree ) {
return ;
}
TreeItem * item = inspect_scene_tree - > get_selected ( ) ;
if ( ! item ) {
return ;
}
inspected_object_id = item - > get_metadata ( 0 ) ;
Array msg ;
msg . push_back ( " inspect_object " ) ;
msg . push_back ( inspected_object_id ) ;
ppeer - > put_var ( msg ) ;
}
2017-03-05 16:44:50 +01:00
void ScriptEditorDebugger : : _scene_tree_property_value_edited ( const String & p_prop , const Variant & p_value ) {
2016-05-23 00:28:37 +02:00
Array msg ;
msg . push_back ( " set_object_property " ) ;
msg . push_back ( inspected_object_id ) ;
msg . push_back ( p_prop ) ;
msg . push_back ( p_value ) ;
ppeer - > put_var ( msg ) ;
2017-03-05 16:44:50 +01:00
inspect_edited_object_timeout = 0.7 ; //avoid annoyance, don't request soon after editing
2016-05-23 00:28:37 +02:00
}
void ScriptEditorDebugger : : _scene_tree_property_select_object ( ObjectID p_object ) {
2017-03-05 16:44:50 +01:00
inspected_object_id = p_object ;
2016-05-23 00:28:37 +02:00
Array msg ;
msg . push_back ( " inspect_object " ) ;
msg . push_back ( inspected_object_id ) ;
ppeer - > put_var ( msg ) ;
}
2014-02-13 22:03:28 +01:00
void ScriptEditorDebugger : : _scene_tree_request ( ) {
ERR_FAIL_COND ( connection . is_null ( ) ) ;
2017-01-14 15:07:57 +01:00
ERR_FAIL_COND ( ! connection - > is_connected_to_host ( ) ) ;
2014-02-13 22:03:28 +01:00
Array msg ;
msg . push_back ( " request_scene_tree " ) ;
ppeer - > put_var ( msg ) ;
}
2015-10-21 14:50:44 +02:00
void ScriptEditorDebugger : : _video_mem_request ( ) {
ERR_FAIL_COND ( connection . is_null ( ) ) ;
2017-01-14 15:07:57 +01:00
ERR_FAIL_COND ( ! connection - > is_connected_to_host ( ) ) ;
2015-10-21 14:50:44 +02:00
Array msg ;
msg . push_back ( " request_video_mem " ) ;
ppeer - > put_var ( msg ) ;
}
2014-02-13 22:03:28 +01:00
Size2 ScriptEditorDebugger : : get_minimum_size ( ) const {
Size2 ms = Control : : get_minimum_size ( ) ;
2017-03-05 16:44:50 +01:00
ms . y = MAX ( ms . y , 250 ) ;
2014-02-13 22:03:28 +01:00
return ms ;
}
2017-03-05 16:44:50 +01:00
void ScriptEditorDebugger : : _parse_message ( const String & p_msg , const Array & p_data ) {
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
if ( p_msg = = " debug_enter " ) {
2014-02-13 22:03:28 +01:00
Array msg ;
msg . push_back ( " get_stack_dump " ) ;
ppeer - > put_var ( msg ) ;
2017-03-05 16:44:50 +01:00
ERR_FAIL_COND ( p_data . size ( ) ! = 2 ) ;
bool can_continue = p_data [ 0 ] ;
2014-02-13 22:03:28 +01:00
String error = p_data [ 1 ] ;
step - > set_disabled ( ! can_continue ) ;
next - > set_disabled ( ! can_continue ) ;
2017-08-22 21:16:08 +02:00
_set_reason_text ( error , MESSAGE_ERROR ) ;
2017-03-05 16:44:50 +01:00
breaked = true ;
2014-02-13 22:03:28 +01:00
dobreak - > set_disabled ( true ) ;
docontinue - > set_disabled ( false ) ;
2017-03-05 16:44:50 +01:00
emit_signal ( " breaked " , true , can_continue ) ;
2014-02-13 22:03:28 +01:00
OS : : get_singleton ( ) - > move_window_to_foreground ( ) ;
2017-03-05 16:44:50 +01:00
if ( error ! = " " ) {
2016-05-22 02:18:16 +02:00
tabs - > set_current_tab ( 0 ) ;
2016-07-17 14:17:35 +02:00
}
2016-05-22 02:18:16 +02:00
profiler - > set_enabled ( false ) ;
EditorNode : : get_singleton ( ) - > get_pause_button ( ) - > set_pressed ( true ) ;
2016-01-18 00:03:57 +01:00
EditorNode : : get_singleton ( ) - > make_bottom_panel_item_visible ( this ) ;
2017-03-05 16:44:50 +01:00
} else if ( p_msg = = " debug_exit " ) {
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
breaked = false ;
2014-02-13 22:03:28 +01:00
step - > set_disabled ( true ) ;
next - > set_disabled ( true ) ;
reason - > set_text ( " " ) ;
reason - > set_tooltip ( " " ) ;
back - > set_disabled ( true ) ;
forward - > set_disabled ( true ) ;
dobreak - > set_disabled ( false ) ;
docontinue - > set_disabled ( true ) ;
2017-03-05 16:44:50 +01:00
emit_signal ( " breaked " , false , false , Variant ( ) ) ;
2014-02-13 22:03:28 +01:00
//tabs->set_current_tab(0);
2016-05-22 02:18:16 +02:00
profiler - > set_enabled ( true ) ;
profiler - > disable_seeking ( ) ;
EditorNode : : get_singleton ( ) - > get_pause_button ( ) - > set_pressed ( false ) ;
2017-03-05 16:44:50 +01:00
} else if ( p_msg = = " message:click_ctrl " ) {
2014-02-13 22:03:28 +01:00
clicked_ctrl - > set_text ( p_data [ 0 ] ) ;
clicked_ctrl_type - > set_text ( p_data [ 1 ] ) ;
2017-03-05 16:44:50 +01:00
} else if ( p_msg = = " message:scene_tree " ) {
2014-02-13 22:03:28 +01:00
2016-05-23 00:28:37 +02:00
inspect_scene_tree - > clear ( ) ;
2017-03-05 16:44:50 +01:00
Map < int , TreeItem * > lv ;
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
updating_scene_tree = true ;
2016-05-23 00:28:37 +02:00
2017-03-05 16:44:50 +01:00
for ( int i = 0 ; i < p_data . size ( ) ; i + = 4 ) {
2014-02-13 22:03:28 +01:00
TreeItem * p ;
int level = p_data [ i ] ;
2017-03-05 16:44:50 +01:00
if ( level = = 0 ) {
2014-02-13 22:03:28 +01:00
p = NULL ;
} else {
2017-03-05 16:44:50 +01:00
ERR_CONTINUE ( ! lv . has ( level - 1 ) ) ;
p = lv [ level - 1 ] ;
2014-02-13 22:03:28 +01:00
}
2016-05-23 00:28:37 +02:00
TreeItem * it = inspect_scene_tree - > create_item ( p ) ;
2017-03-05 16:44:50 +01:00
ObjectID id = ObjectID ( p_data [ i + 3 ] ) ;
2016-05-23 00:28:37 +02:00
2017-03-05 16:44:50 +01:00
it - > set_text ( 0 , p_data [ i + 1 ] ) ;
if ( has_icon ( p_data [ i + 2 ] , " EditorIcons " ) )
it - > set_icon ( 0 , get_icon ( p_data [ i + 2 ] , " EditorIcons " ) ) ;
it - > set_metadata ( 0 , id ) ;
2017-08-18 15:59:31 +02:00
2017-03-05 16:44:50 +01:00
if ( id = = inspected_object_id ) {
2017-08-18 15:59:31 +02:00
TreeItem * cti = it - > get_parent ( ) ; //ensure selected is always uncollapsed
while ( cti ) {
cti - > set_collapsed ( false ) ;
cti = cti - > get_parent ( ) ;
}
2016-05-23 00:28:37 +02:00
it - > select ( 0 ) ;
}
if ( p ) {
if ( ! unfold_cache . has ( id ) ) {
it - > set_collapsed ( true ) ;
}
} else {
if ( unfold_cache . has ( id ) ) { //reverse for root
it - > set_collapsed ( true ) ;
}
}
2017-08-18 15:59:31 +02:00
2017-03-05 16:44:50 +01:00
lv [ level ] = it ;
2014-02-13 22:03:28 +01:00
}
2017-03-05 16:44:50 +01:00
updating_scene_tree = false ;
2014-02-13 22:03:28 +01:00
2015-08-02 17:29:37 +02:00
le_clear - > set_disabled ( false ) ;
le_set - > set_disabled ( false ) ;
2017-03-05 16:44:50 +01:00
} else if ( p_msg = = " message:inspect_object " ) {
2016-05-23 00:28:37 +02:00
ObjectID id = p_data [ 0 ] ;
String type = p_data [ 1 ] ;
Variant path = p_data [ 2 ] ; //what to do yet, i don't know
2017-03-05 16:44:50 +01:00
int prop_count = p_data [ 3 ] ;
2016-05-23 00:28:37 +02:00
2017-03-05 16:44:50 +01:00
int idx = 4 ;
2016-05-23 00:28:37 +02:00
2017-03-05 16:44:50 +01:00
if ( inspected_object - > last_edited_id ! = id ) {
2016-05-23 00:28:37 +02:00
inspected_object - > prop_list . clear ( ) ;
inspected_object - > prop_values . clear ( ) ;
}
2017-03-05 16:44:50 +01:00
for ( int i = 0 ; i < prop_count ; i + + ) {
2016-05-23 00:28:37 +02:00
PropertyInfo pinfo ;
2017-03-05 16:44:50 +01:00
pinfo . name = p_data [ idx + + ] ;
pinfo . type = Variant : : Type ( int ( p_data [ idx + + ] ) ) ;
pinfo . hint = PropertyHint ( int ( p_data [ idx + + ] ) ) ;
pinfo . hint_string = p_data [ idx + + ] ;
2016-05-23 00:28:37 +02:00
if ( pinfo . name . begins_with ( " * " ) ) {
2017-03-05 16:44:50 +01:00
pinfo . name = pinfo . name . substr ( 1 , pinfo . name . length ( ) ) ;
pinfo . usage = PROPERTY_USAGE_CATEGORY ;
2016-05-23 00:28:37 +02:00
} else {
2017-03-05 16:44:50 +01:00
pinfo . usage = PROPERTY_USAGE_EDITOR ;
2016-05-23 00:28:37 +02:00
}
2017-03-05 16:44:50 +01:00
if ( inspected_object - > last_edited_id ! = id ) {
2016-05-23 00:28:37 +02:00
//don't update.. it's the same, instead refresh
inspected_object - > prop_list . push_back ( pinfo ) ;
}
2017-03-05 16:44:50 +01:00
inspected_object - > prop_values [ pinfo . name ] = p_data [ idx + + ] ;
2016-05-23 00:28:37 +02:00
2017-03-05 16:44:50 +01:00
if ( inspected_object - > last_edited_id = = id ) {
2016-05-23 00:28:37 +02:00
//same, just update value, don't rebuild
inspected_object - > update_single ( pinfo . name . ascii ( ) . get_data ( ) ) ;
}
}
2017-03-05 16:44:50 +01:00
if ( inspected_object - > last_edited_id ! = id ) {
2016-05-23 00:28:37 +02:00
//only if different
inspected_object - > update ( ) ;
}
2017-03-05 16:44:50 +01:00
inspected_object - > last_edited_id = id ;
2016-05-23 00:28:37 +02:00
2017-08-18 15:59:31 +02:00
tabs - > set_current_tab ( inspect_info - > get_index ( ) ) ;
inspect_properties - > edit ( inspected_object ) ;
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
} else if ( p_msg = = " message:video_mem " ) {
2015-10-21 14:50:44 +02:00
vmem_tree - > clear ( ) ;
2017-03-05 16:44:50 +01:00
TreeItem * root = vmem_tree - > create_item ( ) ;
2015-10-21 14:50:44 +02:00
2017-03-05 16:44:50 +01:00
int total = 0 ;
2015-10-21 14:50:44 +02:00
2017-03-05 16:44:50 +01:00
for ( int i = 0 ; i < p_data . size ( ) ; i + = 4 ) {
2015-10-21 14:50:44 +02:00
TreeItem * it = vmem_tree - > create_item ( root ) ;
2017-03-05 16:44:50 +01:00
String type = p_data [ i + 1 ] ;
int bytes = p_data [ i + 3 ] . operator int ( ) ;
it - > set_text ( 0 , p_data [ i + 0 ] ) ; //path
it - > set_text ( 1 , type ) ; //type
it - > set_text ( 2 , p_data [ i + 2 ] ) ; //type
it - > set_text ( 3 , String : : humanize_size ( bytes ) ) ; //type
total + = bytes ;
if ( has_icon ( type , " EditorIcons " ) )
it - > set_icon ( 0 , get_icon ( type , " EditorIcons " ) ) ;
2015-10-21 14:50:44 +02:00
}
2017-03-05 16:44:50 +01:00
vmem_total - > set_tooltip ( TTR ( " Bytes: " ) + " " + itos ( total ) ) ;
2015-10-21 14:50:44 +02:00
vmem_total - > set_text ( String : : humanize_size ( total ) ) ;
2017-03-05 16:44:50 +01:00
} else if ( p_msg = = " stack_dump " ) {
2014-02-13 22:03:28 +01:00
stack_dump - > clear ( ) ;
TreeItem * r = stack_dump - > create_item ( ) ;
2017-03-05 16:44:50 +01:00
for ( int i = 0 ; i < p_data . size ( ) ; i + + ) {
2014-02-13 22:03:28 +01:00
Dictionary d = p_data [ i ] ;
ERR_CONTINUE ( ! d . has ( " function " ) ) ;
ERR_CONTINUE ( ! d . has ( " file " ) ) ;
ERR_CONTINUE ( ! d . has ( " line " ) ) ;
ERR_CONTINUE ( ! d . has ( " id " ) ) ;
TreeItem * s = stack_dump - > create_item ( r ) ;
2017-03-05 16:44:50 +01:00
d [ " frame " ] = i ;
s - > set_metadata ( 0 , d ) ;
2014-02-13 22:03:28 +01:00
2017-01-14 12:26:56 +01:00
//String line = itos(i)+" - "+String(d["file"])+":"+itos(d["line"])+" - at func: "+d["function"];
2017-03-05 16:44:50 +01:00
String line = itos ( i ) + " - " + String ( d [ " file " ] ) + " : " + itos ( d [ " line " ] ) ;
s - > set_text ( 0 , line ) ;
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
if ( i = = 0 )
2014-02-13 22:03:28 +01:00
s - > select ( 0 ) ;
}
2017-03-05 16:44:50 +01:00
} else if ( p_msg = = " stack_frame_vars " ) {
2014-02-13 22:03:28 +01:00
variables - > clear ( ) ;
2017-03-05 16:44:50 +01:00
int ofs = 0 ;
2014-02-13 22:03:28 +01:00
int mcount = p_data [ ofs ] ;
ofs + + ;
2017-03-05 16:44:50 +01:00
for ( int i = 0 ; i < mcount ; i + + ) {
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
String n = p_data [ ofs + i * 2 + 0 ] ;
Variant v = p_data [ ofs + i * 2 + 1 ] ;
2017-05-01 19:27:01 +02:00
PropertyHint h = PROPERTY_HINT_NONE ;
String hs = String ( ) ;
2014-02-13 22:03:28 +01:00
if ( n . begins_with ( " * " ) ) {
2017-03-05 16:44:50 +01:00
n = n . substr ( 1 , n . length ( ) ) ;
2017-05-01 19:27:01 +02:00
h = PROPERTY_HINT_OBJECT_ID ;
String s = v ;
s = s . replace ( " [ " , " " ) ;
hs = s . get_slice ( " : " , 0 ) ;
v = s . get_slice ( " : " , 1 ) . to_int ( ) ;
2014-02-13 22:03:28 +01:00
}
2017-05-01 19:27:01 +02:00
variables - > add_property ( " members/ " + n , v , h , hs ) ;
2014-02-13 22:03:28 +01:00
}
2017-03-05 16:44:50 +01:00
ofs + = mcount * 2 ;
2014-02-13 22:03:28 +01:00
mcount = p_data [ ofs ] ;
ofs + + ;
2017-03-05 16:44:50 +01:00
for ( int i = 0 ; i < mcount ; i + + ) {
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
String n = p_data [ ofs + i * 2 + 0 ] ;
Variant v = p_data [ ofs + i * 2 + 1 ] ;
2017-05-01 19:27:01 +02:00
PropertyHint h = PROPERTY_HINT_NONE ;
String hs = String ( ) ;
2014-02-13 22:03:28 +01:00
if ( n . begins_with ( " * " ) ) {
2017-03-05 16:44:50 +01:00
n = n . substr ( 1 , n . length ( ) ) ;
2017-05-01 19:27:01 +02:00
h = PROPERTY_HINT_OBJECT_ID ;
String s = v ;
s = s . replace ( " [ " , " " ) ;
hs = s . get_slice ( " : " , 0 ) ;
v = s . get_slice ( " : " , 1 ) . to_int ( ) ;
2014-02-13 22:03:28 +01:00
}
2017-05-01 19:27:01 +02:00
variables - > add_property ( " locals/ " + n , v , h , hs ) ;
2014-02-13 22:03:28 +01:00
}
variables - > update ( ) ;
inspector - > edit ( variables ) ;
2017-03-05 16:44:50 +01:00
} else if ( p_msg = = " output " ) {
2014-02-13 22:03:28 +01:00
//OUT
2017-03-05 16:44:50 +01:00
for ( int i = 0 ; i < p_data . size ( ) ; i + + ) {
2014-02-13 22:03:28 +01:00
String t = p_data [ i ] ;
//LOG
2017-01-13 14:45:50 +01:00
if ( ! EditorNode : : get_log ( ) - > is_visible ( ) ) {
2016-01-24 16:26:03 +01:00
if ( EditorNode : : get_singleton ( ) - > are_bottom_panels_hidden ( ) ) {
EditorNode : : get_singleton ( ) - > make_bottom_panel_item_visible ( EditorNode : : get_log ( ) ) ;
}
2014-02-13 22:03:28 +01:00
}
EditorNode : : get_log ( ) - > add_message ( t ) ;
}
2017-03-05 16:44:50 +01:00
} else if ( p_msg = = " performance " ) {
2014-02-13 22:03:28 +01:00
Array arr = p_data [ 0 ] ;
Vector < float > p ;
p . resize ( arr . size ( ) ) ;
2017-03-05 16:44:50 +01:00
for ( int i = 0 ; i < arr . size ( ) ; i + + ) {
p [ i ] = arr [ i ] ;
if ( i < perf_items . size ( ) ) {
perf_items [ i ] - > set_text ( 1 , rtos ( p [ i ] ) ) ;
if ( p [ i ] > perf_max [ i ] )
perf_max [ i ] = p [ i ] ;
2014-02-13 22:03:28 +01:00
}
}
perf_history . push_front ( p ) ;
perf_draw - > update ( ) ;
2017-03-05 16:44:50 +01:00
} else if ( p_msg = = " error " ) {
2015-08-04 14:47:32 +02:00
Array err = p_data [ 0 ] ;
Array vals ;
vals . push_back ( err [ 0 ] ) ;
vals . push_back ( err [ 1 ] ) ;
vals . push_back ( err [ 2 ] ) ;
vals . push_back ( err [ 3 ] ) ;
bool warning = err [ 9 ] ;
bool e ;
2017-03-05 16:44:50 +01:00
String time = String ( " %d:%02d:%02d:%04d " ) . sprintf ( vals , & e ) ;
String txt = time + " - " + ( err [ 8 ] . is_zero ( ) ? String ( err [ 7 ] ) : String ( err [ 8 ] ) ) ;
2015-08-04 14:47:32 +02:00
2017-03-05 16:44:50 +01:00
String tooltip = TTR ( " Type: " ) + String ( warning ? TTR ( " Warning " ) : TTR ( " Error " ) ) ;
tooltip + = " \n " + TTR ( " Description: " ) + " " + String ( err [ 8 ] ) ;
tooltip + = " \n " + TTR ( " Time: " ) + " " + time ;
tooltip + = " \n C " + TTR ( " Error: " ) + " " + String ( err [ 7 ] ) ;
tooltip + = " \n C " + TTR ( " Source: " ) + " " + String ( err [ 5 ] ) + " : " + String ( err [ 6 ] ) ;
tooltip + = " \n C " + TTR ( " Function: " ) + " " + String ( err [ 4 ] ) ;
2015-08-04 14:47:32 +02:00
2017-03-05 16:44:50 +01:00
error_list - > add_item ( txt , EditorNode : : get_singleton ( ) - > get_gui_base ( ) - > get_icon ( warning ? " Warning " : " Error " , " EditorIcons " ) ) ;
error_list - > set_item_tooltip ( error_list - > get_item_count ( ) - 1 , tooltip ) ;
2015-08-04 14:47:32 +02:00
int scc = p_data [ 1 ] ;
Array stack ;
stack . resize ( scc ) ;
2017-03-05 16:44:50 +01:00
for ( int i = 0 ; i < scc ; i + + ) {
stack [ i ] = p_data [ 2 + i ] ;
2015-08-04 14:47:32 +02:00
}
2017-03-05 16:44:50 +01:00
error_list - > set_item_metadata ( error_list - > get_item_count ( ) - 1 , stack ) ;
2015-08-04 14:47:32 +02:00
error_count + + ;
/*
int count = p_data [ 1 ] ;
Array cstack ;
OutputError oe = errors . front ( ) - > get ( ) ;
packet_peer_stream - > put_var ( oe . hr ) ;
packet_peer_stream - > put_var ( oe . min ) ;
packet_peer_stream - > put_var ( oe . sec ) ;
packet_peer_stream - > put_var ( oe . msec ) ;
packet_peer_stream - > put_var ( oe . source_func ) ;
packet_peer_stream - > put_var ( oe . source_file ) ;
packet_peer_stream - > put_var ( oe . source_line ) ;
packet_peer_stream - > put_var ( oe . error ) ;
packet_peer_stream - > put_var ( oe . error_descr ) ;
packet_peer_stream - > put_var ( oe . warning ) ;
packet_peer_stream - > put_var ( oe . callstack ) ;
*/
2016-05-22 02:18:16 +02:00
2017-03-05 16:44:50 +01:00
} else if ( p_msg = = " profile_sig " ) {
2016-05-22 02:18:16 +02:00
//cache a signature
2017-03-05 16:44:50 +01:00
profiler_signature [ p_data [ 1 ] ] = p_data [ 0 ] ;
2016-05-22 02:18:16 +02:00
2017-03-05 16:44:50 +01:00
} else if ( p_msg = = " profile_frame " | | p_msg = = " profile_total " ) {
2016-05-22 02:18:16 +02:00
EditorProfiler : : Metric metric ;
2017-03-05 16:44:50 +01:00
metric . valid = true ;
metric . frame_number = p_data [ 0 ] ;
metric . frame_time = p_data [ 1 ] ;
metric . idle_time = p_data [ 2 ] ;
metric . fixed_time = p_data [ 3 ] ;
metric . fixed_frame_time = p_data [ 4 ] ;
2016-05-22 02:18:16 +02:00
int frame_data_amount = p_data [ 6 ] ;
int frame_function_amount = p_data [ 7 ] ;
if ( frame_data_amount ) {
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-22 02:18:16 +02:00
EditorProfiler : : Metric : : Category : : Item item ;
2017-03-05 16:44:50 +01:00
item . calls = 1 ;
item . line = 0 ;
item . name = " Fixed Time " ;
item . total = metric . fixed_time ;
item . self = item . total ;
item . signature = " fixed_time " ;
2016-05-22 02:18:16 +02: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-22 02:18:16 +02:00
frame_time . items . push_back ( item ) ;
2017-03-05 16:44:50 +01:00
item . name = " Fixed Frame Time " ;
item . total = metric . fixed_frame_time ;
item . self = item . total ;
item . signature = " fixed_frame_time " ;
2016-05-22 02:18:16 +02:00
frame_time . items . push_back ( item ) ;
metric . categories . push_back ( frame_time ) ;
}
2017-03-05 16:44:50 +01:00
int idx = 8 ;
for ( int i = 0 ; i < frame_data_amount ; i + + ) {
2016-05-22 02:18:16 +02:00
EditorProfiler : : Metric : : Category c ;
2017-03-05 16:44:50 +01:00
String name = p_data [ idx + + ] ;
Array values = p_data [ idx + + ] ;
c . name = name . capitalize ( ) ;
c . items . resize ( values . size ( ) / 2 ) ;
c . total_time = 0 ;
c . signature = " categ:: " + name ;
for ( int i = 0 ; i < values . size ( ) ; i + = 2 ) {
2016-05-22 02:18:16 +02:00
EditorProfiler : : Metric : : Category : : Item item ;
2017-03-05 16:44:50 +01:00
item . name = values [ i ] ;
item . calls = 1 ;
item . self = values [ i + 1 ] ;
item . total = item . self ;
item . signature = " categ:: " + name + " :: " + item . name ;
item . name = item . name . capitalize ( ) ;
c . total_time + = item . total ;
c . items [ i / 2 ] = item ;
2016-05-22 02:18:16 +02:00
}
metric . categories . push_back ( c ) ;
}
EditorProfiler : : Metric : : Category funcs ;
2017-03-05 16:44:50 +01:00
funcs . total_time = p_data [ 5 ] ; //script time
2016-05-22 02:18:16 +02:00
funcs . items . resize ( frame_function_amount ) ;
2017-03-05 16:44:50 +01:00
funcs . name = " Script Functions " ;
funcs . signature = " script_functions " ;
for ( int i = 0 ; i < frame_function_amount ; i + + ) {
2016-05-22 02:18:16 +02:00
int signature = p_data [ idx + + ] ;
int calls = p_data [ idx + + ] ;
float total = p_data [ idx + + ] ;
float self = p_data [ idx + + ] ;
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-22 02:18:16 +02: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 ( ) ;
2016-05-22 02:18:16 +02:00
}
} else {
2017-03-05 16:44:50 +01:00
item . name = " SigErr " + itos ( signature ) ;
2016-05-22 02:18:16 +02:00
}
2017-03-05 16:44:50 +01:00
item . calls = calls ;
item . self = self ;
item . total = total ;
funcs . items [ i ] = item ;
2016-05-22 02:18:16 +02:00
}
metric . categories . push_back ( funcs ) ;
2017-03-05 16:44:50 +01:00
if ( p_msg = = " profile_frame " )
profiler - > add_frame_metric ( metric , false ) ;
2016-05-22 02:18:16 +02:00
else
2017-03-05 16:44:50 +01:00
profiler - > add_frame_metric ( metric , true ) ;
2016-05-22 02:18:16 +02:00
2017-03-05 16:44:50 +01:00
} else if ( p_msg = = " kill_me " ) {
2014-02-13 22:03:28 +01:00
editor - > call_deferred ( " stop_child_process " ) ;
}
}
2017-08-22 21:16:08 +02:00
void ScriptEditorDebugger : : _set_reason_text ( const String & p_reason , MessageType p_type ) {
switch ( p_type ) {
case MESSAGE_ERROR :
reason - > add_color_override ( " font_color " , get_color ( " error_color " , " Editor " ) ) ;
break ;
case MESSAGE_WARNING :
reason - > add_color_override ( " font_color " , get_color ( " warning_color " , " Editor " ) ) ;
break ;
default :
reason - > add_color_override ( " font_color " , get_color ( " success_color " , " Editor " ) ) ;
}
reason - > set_text ( p_reason ) ;
reason - > set_tooltip ( p_reason ) ;
}
2017-03-05 16:44:50 +01:00
void ScriptEditorDebugger : : _performance_select ( Object * , int , bool ) {
2014-02-13 22:03:28 +01: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 + + ) {
2014-02-13 22:03:28 +01:00
if ( perf_items [ i ] - > is_selected ( 0 ) )
which . push_back ( i ) ;
}
2017-08-26 18:02:52 +02:00
Ref < Font > graph_font = get_font ( " font " , " TextEdit " ) ;
if ( which . empty ( ) ) {
perf_draw - > draw_string ( graph_font , Point2 ( 0 , graph_font - > get_ascent ( ) ) , TTR ( " Pick one or more items from the list to display the graph. " ) , get_color ( " font_color " , " Label " ) , perf_draw - > get_size ( ) . x ) ;
2014-02-13 22:03:28 +01:00
return ;
2017-08-26 18:02:52 +02:00
}
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
Ref < StyleBox > graph_sb = get_stylebox ( " normal " , " TextEdit " ) ;
2014-02-13 22:03:28 +01:00
2017-01-14 21:35:39 +01:00
int cols = Math : : ceil ( Math : : sqrt ( ( float ) which . size ( ) ) ) ;
2017-08-26 18:02:52 +02:00
int rows = Math : : ceil ( ( float ) which . size ( ) / cols ) ;
2017-03-05 16:44:50 +01:00
if ( which . size ( ) = = 1 )
rows = 1 ;
int margin = 3 ;
int point_sep = 5 ;
Size2i s = Size2i ( perf_draw - > get_size ( ) ) / Size2i ( cols , rows ) ;
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 ( ) ;
int pi = which [ i ] ;
2017-08-08 04:55:24 +02:00
Color c = get_color ( " success_color " , " Editor " ) ;
2017-03-05 16:44:50 +01:00
c . set_hsv ( Math : : fmod ( c . get_h ( ) + pi * 0.7654 , 1 ) , c . get_s ( ) , c . get_v ( ) ) ;
2017-08-08 04:55:24 +02:00
//c = c.linear_interpolate(get_color("base_color", "Editor"), 0.9);
2017-03-05 16:44:50 +01:00
c . a = 0.8 ;
2017-06-04 00:25:13 +02:00
perf_draw - > draw_string ( graph_font , r . position + Point2 ( 0 , graph_font - > get_ascent ( ) ) , perf_items [ pi ] - > get_text ( 0 ) , c , r . size . x ) ;
2017-03-05 16:44:50 +01:00
c . a = 0.6 ;
2017-06-04 00:25:13 +02:00
perf_draw - > draw_string ( graph_font , r . position + Point2 ( graph_font - > get_char_size ( ' X ' ) . width , graph_font - > get_ascent ( ) + graph_font - > get_height ( ) ) , perf_items [ pi ] - > get_text ( 1 ) , c , r . size . y ) ;
2017-03-05 16:44:50 +01:00
float spacing = point_sep / float ( cols ) ;
2014-02-13 22:03:28 +01:00
float from = r . size . width ;
2017-03-05 16:44:50 +01:00
List < Vector < float > > : : Element * E = perf_history . front ( ) ;
float prev = - 1 ;
while ( from > = 0 & & E ) {
2014-02-13 22:03:28 +01:00
float m = perf_max [ pi ] ;
2017-03-05 16:44:50 +01:00
if ( m = = 0 )
m = 0.00001 ;
float h = E - > get ( ) [ pi ] / m ;
h = ( 1.0 - h ) * r . size . y ;
c . a = 0.7 ;
if ( E ! = perf_history . front ( ) )
2017-06-04 00:25:13 +02:00
perf_draw - > draw_line ( r . position + Point2 ( from , h ) , r . position + Point2 ( from + spacing , prev ) , c , 2.0 ) ;
2017-03-05 16:44:50 +01:00
prev = h ;
E = E - > next ( ) ;
from - = spacing ;
2014-02-13 22:03:28 +01:00
}
}
}
void ScriptEditorDebugger : : _notification ( int p_what ) {
2017-03-05 16:44:50 +01:00
switch ( p_what ) {
2014-02-13 22:03:28 +01:00
2014-11-06 01:20:42 +01:00
case NOTIFICATION_ENTER_TREE : {
2014-02-13 22:03:28 +01:00
2016-01-23 23:51:51 +01:00
inspector - > edit ( variables ) ;
2017-03-05 16:44:50 +01:00
step - > set_icon ( get_icon ( " DebugStep " , " EditorIcons " ) ) ;
next - > set_icon ( get_icon ( " DebugNext " , " EditorIcons " ) ) ;
back - > set_icon ( get_icon ( " Back " , " EditorIcons " ) ) ;
forward - > set_icon ( get_icon ( " Forward " , " EditorIcons " ) ) ;
dobreak - > set_icon ( get_icon ( " Pause " , " EditorIcons " ) ) ;
docontinue - > set_icon ( get_icon ( " DebugContinue " , " EditorIcons " ) ) ;
2016-05-23 00:28:37 +02:00
//scene_tree_refresh->set_icon( get_icon("Reload","EditorIcons"));
2017-03-05 16:44:50 +01:00
le_set - > connect ( " pressed " , this , " _live_edit_set " ) ;
le_clear - > connect ( " pressed " , this , " _live_edit_clear " ) ;
error_list - > connect ( " item_selected " , this , " _error_selected " ) ;
error_stack - > connect ( " item_selected " , this , " _error_stack_selected " ) ;
vmem_refresh - > set_icon ( get_icon ( " Reload " , " EditorIcons " ) ) ;
2014-02-13 22:03:28 +01:00
2017-08-08 04:55:24 +02:00
reason - > add_color_override ( " font_color " , get_color ( " error_color " , " Editor " ) ) ;
2014-02-13 22:03:28 +01:00
} break ;
case NOTIFICATION_PROCESS : {
2016-05-23 00:28:37 +02:00
if ( connection . is_valid ( ) ) {
2017-03-05 16:44:50 +01:00
inspect_scene_tree_timeout - = get_process_delta_time ( ) ;
if ( inspect_scene_tree_timeout < 0 ) {
inspect_scene_tree_timeout = EditorSettings : : get_singleton ( ) - > get ( " debugger/scene_tree_refresh_interval " ) ;
2017-01-13 14:45:50 +01:00
if ( inspect_scene_tree - > is_visible_in_tree ( ) ) {
2016-05-23 00:28:37 +02:00
_scene_tree_request ( ) ;
2017-03-05 16:44:50 +01:00
if ( inspected_object_id ! = 0 ) {
2016-05-23 00:28:37 +02:00
//take the chance and re-inspect selected object
Array msg ;
msg . push_back ( " inspect_object " ) ;
msg . push_back ( inspected_object_id ) ;
ppeer - > put_var ( msg ) ;
}
}
}
2017-03-05 16:44:50 +01:00
inspect_edited_object_timeout - = get_process_delta_time ( ) ;
if ( inspect_edited_object_timeout < 0 ) {
inspect_edited_object_timeout = EditorSettings : : get_singleton ( ) - > get ( " debugger/remote_inspect_refresh_interval " ) ;
2017-01-13 14:45:50 +01:00
if ( inspect_scene_tree - > is_visible_in_tree ( ) & & inspected_object_id ) {
2016-05-23 00:28:37 +02:00
//take the chance and re-inspect selected object
Array msg ;
msg . push_back ( " inspect_object " ) ;
msg . push_back ( inspected_object_id ) ;
ppeer - > put_var ( msg ) ;
}
}
}
2017-03-05 16:44:50 +01:00
if ( error_count ! = last_error_count ) {
2015-08-04 14:47:32 +02:00
2017-03-05 16:44:50 +01:00
if ( error_count = = 0 ) {
2016-05-04 03:25:37 +02:00
error_split - > set_name ( TTR ( " Errors " ) ) ;
debugger_button - > set_text ( TTR ( " Debugger " ) ) ;
2016-01-18 00:03:57 +01:00
debugger_button - > set_icon ( Ref < Texture > ( ) ) ;
2017-03-05 16:44:50 +01:00
tabs - > set_tab_icon ( error_split - > get_index ( ) , Ref < Texture > ( ) ) ;
2015-08-04 14:47:32 +02:00
} else {
2017-03-05 16:44:50 +01:00
error_split - > set_name ( TTR ( " Errors " ) + " ( " + itos ( error_count ) + " ) " ) ;
debugger_button - > set_text ( TTR ( " Debugger " ) + " ( " + itos ( error_count ) + " ) " ) ;
debugger_button - > set_icon ( get_icon ( " Error " , " EditorIcons " ) ) ;
tabs - > set_tab_icon ( error_split - > get_index ( ) , get_icon ( " Error " , " EditorIcons " ) ) ;
2015-08-04 14:47:32 +02:00
}
2017-03-05 16:44:50 +01:00
last_error_count = error_count ;
2015-08-04 14:47:32 +02:00
}
2016-05-23 22:10:26 +02:00
2014-02-13 22:03:28 +01:00
if ( connection . is_null ( ) ) {
if ( server - > is_connection_available ( ) ) {
connection = server - > take_connection ( ) ;
if ( connection . is_null ( ) )
break ;
EditorNode : : get_log ( ) - > add_message ( " ** Debug Process Started ** " ) ;
ppeer - > set_stream_peer ( connection ) ;
2016-01-18 00:03:57 +01:00
//EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
//emit_signal("show_debugger",true);
2015-12-12 14:00:12 +01:00
2014-02-13 22:03:28 +01:00
dobreak - > set_disabled ( false ) ;
tabs - > set_current_tab ( 0 ) ;
2017-08-22 21:16:08 +02:00
_set_reason_text ( TTR ( " Child Process Connected " ) , MESSAGE_SUCCESS ) ;
2016-05-22 02:18:16 +02:00
profiler - > clear ( ) ;
2016-05-23 00:28:37 +02:00
inspect_scene_tree - > clear ( ) ;
2015-08-02 17:29:37 +02:00
le_set - > set_disabled ( true ) ;
le_clear - > set_disabled ( false ) ;
2015-08-04 14:47:32 +02:00
error_list - > clear ( ) ;
error_stack - > clear ( ) ;
2017-03-05 16:44:50 +01:00
error_count = 0 ;
2016-05-22 02:18:16 +02:00
profiler_signature . clear ( ) ;
2015-08-02 17:29:37 +02:00
//live_edit_root->set_text("/root");
2016-05-22 02:18:16 +02:00
EditorNode : : get_singleton ( ) - > get_pause_button ( ) - > set_pressed ( false ) ;
EditorNode : : get_singleton ( ) - > get_pause_button ( ) - > set_disabled ( false ) ;
2015-08-02 17:29:37 +02:00
update_live_edit_root ( ) ;
2016-05-22 02:18:16 +02:00
if ( profiler - > is_profiling ( ) ) {
_profiler_activate ( true ) ;
}
2014-02-13 22:03:28 +01:00
} else {
break ;
}
} ;
2017-01-14 15:07:57 +01:00
if ( ! connection - > is_connected_to_host ( ) ) {
2014-02-13 22:03:28 +01:00
stop ( ) ;
editor - > notify_child_process_exited ( ) ; //somehow, exited
break ;
} ;
if ( ppeer - > get_available_packet_count ( ) < = 0 ) {
break ;
} ;
2017-03-05 16:44:50 +01:00
while ( ppeer - > get_available_packet_count ( ) > 0 ) {
2014-02-13 22:03:28 +01:00
if ( pending_in_queue ) {
2017-03-05 16:44:50 +01:00
int todo = MIN ( ppeer - > get_available_packet_count ( ) , pending_in_queue ) ;
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
for ( int i = 0 ; i < todo ; i + + ) {
2014-02-13 22:03:28 +01:00
Variant cmd ;
Error ret = ppeer - > get_var ( cmd ) ;
2017-03-05 16:44:50 +01:00
if ( ret ! = OK ) {
2014-02-13 22:03:28 +01:00
stop ( ) ;
2017-03-05 16:44:50 +01:00
ERR_FAIL_COND ( ret ! = OK ) ;
2014-02-13 22:03:28 +01:00
}
message . push_back ( cmd ) ;
pending_in_queue - - ;
}
2017-03-05 16:44:50 +01:00
if ( pending_in_queue = = 0 ) {
_parse_message ( message_type , message ) ;
2014-02-13 22:03:28 +01:00
message . clear ( ) ;
}
} else {
2017-03-05 16:44:50 +01:00
if ( ppeer - > get_available_packet_count ( ) > = 2 ) {
2014-02-13 22:03:28 +01:00
Variant cmd ;
Error ret = ppeer - > get_var ( cmd ) ;
2017-03-05 16:44:50 +01:00
if ( ret ! = OK ) {
2014-02-13 22:03:28 +01:00
stop ( ) ;
2017-03-05 16:44:50 +01:00
ERR_FAIL_COND ( ret ! = OK ) ;
2014-02-13 22:03:28 +01:00
}
2017-03-05 16:44:50 +01:00
if ( cmd . get_type ( ) ! = Variant : : STRING ) {
2014-02-13 22:03:28 +01:00
stop ( ) ;
2017-03-05 16:44:50 +01:00
ERR_FAIL_COND ( cmd . get_type ( ) ! = Variant : : STRING ) ;
2014-02-13 22:03:28 +01:00
}
2017-03-05 16:44:50 +01:00
message_type = cmd ;
2016-05-22 02:18:16 +02:00
//print_line("GOT: "+message_type);
2014-02-13 22:03:28 +01:00
ret = ppeer - > get_var ( cmd ) ;
2017-03-05 16:44:50 +01:00
if ( ret ! = OK ) {
2014-02-13 22:03:28 +01:00
stop ( ) ;
2017-03-05 16:44:50 +01:00
ERR_FAIL_COND ( ret ! = OK ) ;
2014-02-13 22:03:28 +01:00
}
2017-03-05 16:44:50 +01:00
if ( cmd . get_type ( ) ! = Variant : : INT ) {
2014-02-13 22:03:28 +01:00
stop ( ) ;
2017-03-05 16:44:50 +01:00
ERR_FAIL_COND ( cmd . get_type ( ) ! = Variant : : INT ) ;
2014-02-13 22:03:28 +01:00
}
2017-03-05 16:44:50 +01:00
pending_in_queue = cmd ;
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
if ( pending_in_queue = = 0 ) {
_parse_message ( message_type , Array ( ) ) ;
2014-02-13 22:03:28 +01:00
message . clear ( ) ;
}
} else {
break ;
}
}
}
} break ;
2017-05-02 22:13:12 +02:00
case EditorSettings : : NOTIFICATION_EDITOR_SETTINGS_CHANGED : {
tabs - > add_style_override ( " panel " , editor - > get_gui_base ( ) - > get_stylebox ( " DebuggerPanel " , " EditorStyles " ) ) ;
tabs - > add_style_override ( " tab_fg " , editor - > get_gui_base ( ) - > get_stylebox ( " DebuggerTabFG " , " EditorStyles " ) ) ;
tabs - > add_style_override ( " tab_bg " , editor - > get_gui_base ( ) - > get_stylebox ( " DebuggerTabBG " , " EditorStyles " ) ) ;
} break ;
2014-02-13 22:03:28 +01:00
}
}
void ScriptEditorDebugger : : start ( ) {
stop ( ) ;
2017-01-13 14:45:50 +01:00
if ( is_visible_in_tree ( ) ) {
2016-12-24 22:52:43 +01:00
EditorNode : : get_singleton ( ) - > make_bottom_panel_item_visible ( this ) ;
2016-09-06 01:44:33 +02:00
}
2014-02-13 22:03:28 +01:00
perf_history . clear ( ) ;
2017-03-05 16:44:50 +01:00
for ( int i = 0 ; i < Performance : : MONITOR_MAX ; i + + ) {
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
perf_max [ i ] = 0 ;
2014-02-13 22:03:28 +01:00
}
2017-06-08 21:24:36 +02:00
int remote_port = ( int ) EditorSettings : : get_singleton ( ) - > get ( " network/debug/remote_port " ) ;
if ( server - > listen ( remote_port ) ! = OK ) {
EditorNode : : get_log ( ) - > add_message ( String ( " ** Error listening on port " ) + itos ( remote_port ) + String ( " ** " ) ) ;
return ;
}
2014-02-13 22:03:28 +01:00
set_process ( true ) ;
}
2017-03-05 16:44:50 +01:00
void ScriptEditorDebugger : : pause ( ) {
2014-02-13 22:03:28 +01:00
}
2017-03-05 16:44:50 +01:00
void ScriptEditorDebugger : : unpause ( ) {
2014-02-13 22:03:28 +01:00
}
2017-03-05 16:44:50 +01:00
void ScriptEditorDebugger : : stop ( ) {
2014-02-13 22:03:28 +01:00
set_process ( false ) ;
server - > stop ( ) ;
ppeer - > set_stream_peer ( Ref < StreamPeer > ( ) ) ;
if ( connection . is_valid ( ) ) {
EditorNode : : get_log ( ) - > add_message ( " ** Debug Process Stopped ** " ) ;
connection . unref ( ) ;
}
2017-03-05 16:44:50 +01:00
pending_in_queue = 0 ;
2014-02-13 22:03:28 +01:00
message . clear ( ) ;
2015-08-02 17:29:37 +02:00
node_path_cache . clear ( ) ;
res_path_cache . clear ( ) ;
2016-05-22 02:18:16 +02:00
profiler_signature . clear ( ) ;
2015-08-02 17:29:37 +02:00
le_clear - > set_disabled ( false ) ;
le_set - > set_disabled ( true ) ;
2016-05-22 02:18:16 +02:00
profiler - > set_enabled ( true ) ;
2016-05-23 00:28:37 +02:00
inspect_properties - > edit ( NULL ) ;
inspect_scene_tree - > clear ( ) ;
2016-05-22 02:18:16 +02:00
EditorNode : : get_singleton ( ) - > get_pause_button ( ) - > set_pressed ( false ) ;
EditorNode : : get_singleton ( ) - > get_pause_button ( ) - > set_disabled ( true ) ;
2015-12-12 14:09:50 +01:00
if ( hide_on_stop ) {
2017-01-13 14:45:50 +01:00
if ( is_visible_in_tree ( ) )
2016-01-18 00:03:57 +01:00
EditorNode : : get_singleton ( ) - > hide_bottom_panel ( ) ;
2017-03-05 16:44:50 +01:00
emit_signal ( " show_debugger " , false ) ;
2015-12-12 14:09:50 +01:00
}
2014-02-13 22:03:28 +01:00
}
2016-05-22 02:18:16 +02:00
void ScriptEditorDebugger : : _profiler_activate ( bool p_enable ) {
if ( ! connection . is_valid ( ) )
return ;
if ( p_enable ) {
profiler_signature . clear ( ) ;
Array msg ;
msg . push_back ( " start_profiling " ) ;
int max_funcs = EditorSettings : : get_singleton ( ) - > get ( " debugger/profiler_frame_max_functions " ) ;
2017-03-05 16:44:50 +01:00
max_funcs = CLAMP ( max_funcs , 16 , 512 ) ;
2016-05-22 02:18:16 +02:00
msg . push_back ( max_funcs ) ;
ppeer - > put_var ( msg ) ;
print_line ( " BEGIN PROFILING! " ) ;
} else {
Array msg ;
msg . push_back ( " stop_profiling " ) ;
ppeer - > put_var ( msg ) ;
print_line ( " END PROFILING! " ) ;
}
}
void ScriptEditorDebugger : : _profiler_seeked ( ) {
2017-01-14 15:07:57 +01:00
if ( ! connection . is_valid ( ) | | ! connection - > is_connected_to_host ( ) )
2016-05-22 02:18:16 +02:00
return ;
if ( breaked )
return ;
2017-01-14 18:03:38 +01:00
debug_break ( ) ;
2016-05-22 02:18:16 +02:00
}
2014-02-13 22:03:28 +01:00
void ScriptEditorDebugger : : _stack_dump_frame_selected ( ) {
TreeItem * ti = stack_dump - > get_selected ( ) ;
if ( ! ti )
return ;
Dictionary d = ti - > get_metadata ( 0 ) ;
2017-06-25 11:20:01 +02:00
stack_script = ResourceLoader : : load ( d [ " file " ] ) ;
emit_signal ( " goto_script_line " , stack_script , int ( d [ " line " ] ) - 1 ) ;
stack_script . unref ( ) ;
2014-02-13 22:03:28 +01:00
ERR_FAIL_COND ( connection . is_null ( ) ) ;
2017-01-14 15:07:57 +01:00
ERR_FAIL_COND ( ! connection - > is_connected_to_host ( ) ) ;
2014-02-13 22:03:28 +01:00
///
Array msg ;
msg . push_back ( " get_stack_frame_vars " ) ;
msg . push_back ( d [ " frame " ] ) ;
ppeer - > put_var ( msg ) ;
}
void ScriptEditorDebugger : : _output_clear ( ) {
//output->clear();
//output->push_color(Color(0,0,0));
}
2017-03-05 16:44:50 +01:00
String ScriptEditorDebugger : : get_var_value ( const String & p_var ) const {
2014-02-13 22:03:28 +01:00
if ( ! breaked )
return String ( ) ;
return variables - > get_var_value ( p_var ) ;
}
2017-03-05 16:44:50 +01:00
int ScriptEditorDebugger : : _get_node_path_cache ( const NodePath & p_path ) {
2015-08-02 17:29:37 +02:00
const int * r = node_path_cache . getptr ( p_path ) ;
if ( r )
return * r ;
last_path_id + + ;
2017-03-05 16:44:50 +01:00
node_path_cache [ p_path ] = last_path_id ;
2015-08-02 17:29:37 +02:00
Array msg ;
msg . push_back ( " live_node_path " ) ;
msg . push_back ( p_path ) ;
msg . push_back ( last_path_id ) ;
ppeer - > put_var ( msg ) ;
return last_path_id ;
}
2017-03-05 16:44:50 +01:00
int ScriptEditorDebugger : : _get_res_path_cache ( const String & p_path ) {
2015-08-02 17:29:37 +02:00
2017-03-05 16:44:50 +01:00
Map < String , int > : : Element * E = res_path_cache . find ( p_path ) ;
2015-08-02 17:29:37 +02:00
if ( E )
return E - > get ( ) ;
last_path_id + + ;
2017-03-05 16:44:50 +01:00
res_path_cache [ p_path ] = last_path_id ;
2015-08-02 17:29:37 +02:00
Array msg ;
msg . push_back ( " live_res_path " ) ;
msg . push_back ( p_path ) ;
msg . push_back ( last_path_id ) ;
ppeer - > put_var ( msg ) ;
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 ) {
2015-08-02 17:29:37 +02:00
if ( ! p_base | | ! live_debug | | ! connection . is_valid ( ) | | ! editor - > get_edited_scene ( ) )
return ;
2017-08-24 22:58:51 +02:00
Node * node = Object : : cast_to < Node > ( p_base ) ;
2015-08-02 17:29:37 +02:00
VARIANT_ARGPTRS
2017-03-05 16:44:50 +01:00
for ( int i = 0 ; i < VARIANT_ARG_MAX ; i + + ) {
2015-08-02 17:29:37 +02:00
//no pointers, sorry
2017-03-05 16:44:50 +01:00
if ( argptr [ i ] & & ( argptr [ i ] - > get_type ( ) = = Variant : : OBJECT | | argptr [ i ] - > get_type ( ) = = Variant : : _RID ) )
2015-08-02 17:29:37 +02:00
return ;
}
if ( node ) {
NodePath path = editor - > get_edited_scene ( ) - > get_path_to ( node ) ;
int pathid = _get_node_path_cache ( path ) ;
Array msg ;
msg . push_back ( " live_node_call " ) ;
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 17:29:37 +02:00
//no pointers, sorry
msg . push_back ( * argptr [ i ] ) ;
}
ppeer - > put_var ( msg ) ;
return ;
}
2017-08-24 22:58:51 +02:00
Resource * res = Object : : cast_to < Resource > ( p_base ) ;
2015-08-02 17:29:37 +02:00
2017-03-05 16:44:50 +01:00
if ( res & & res - > get_path ( ) ! = String ( ) ) {
2015-08-02 17:29:37 +02:00
String respath = res - > get_path ( ) ;
int pathid = _get_res_path_cache ( respath ) ;
Array msg ;
msg . push_back ( " live_res_call " ) ;
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 17:29:37 +02:00
//no pointers, sorry
msg . push_back ( * argptr [ i ] ) ;
}
ppeer - > put_var ( msg ) ;
return ;
}
//print_line("method");
}
2017-03-05 16:44:50 +01:00
void ScriptEditorDebugger : : _property_changed ( Object * p_base , const StringName & p_property , const Variant & p_value ) {
2015-08-02 17:29:37 +02:00
if ( ! p_base | | ! live_debug | | ! connection . is_valid ( ) | | ! editor - > get_edited_scene ( ) )
return ;
2017-08-24 22:58:51 +02:00
Node * node = Object : : cast_to < Node > ( p_base ) ;
2015-08-02 17:29:37 +02: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 17:29:37 +02:00
Array msg ;
msg . push_back ( " live_node_prop_res " ) ;
msg . push_back ( pathid ) ;
msg . push_back ( p_property ) ;
msg . push_back ( res - > get_path ( ) ) ;
ppeer - > put_var ( msg ) ;
}
} else {
Array msg ;
msg . push_back ( " live_node_prop " ) ;
msg . push_back ( pathid ) ;
msg . push_back ( p_property ) ;
msg . push_back ( p_value ) ;
ppeer - > put_var ( msg ) ;
}
return ;
}
2017-08-24 22:58:51 +02:00
Resource * res = Object : : cast_to < Resource > ( p_base ) ;
2015-08-02 17:29:37 +02:00
2017-03-05 16:44:50 +01:00
if ( res & & res - > get_path ( ) ! = String ( ) ) {
2015-08-02 17:29:37 +02:00
String respath = res - > get_path ( ) ;
int pathid = _get_res_path_cache ( respath ) ;
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 17:29:37 +02:00
Array msg ;
msg . push_back ( " live_res_prop_res " ) ;
msg . push_back ( pathid ) ;
msg . push_back ( p_property ) ;
msg . push_back ( res - > get_path ( ) ) ;
ppeer - > put_var ( msg ) ;
}
} else {
Array msg ;
msg . push_back ( " live_res_prop " ) ;
msg . push_back ( pathid ) ;
msg . push_back ( p_property ) ;
msg . push_back ( p_value ) ;
ppeer - > put_var ( msg ) ;
}
return ;
}
//print_line("prop");
}
2017-03-05 16:44:50 +01:00
void ScriptEditorDebugger : : _method_changeds ( void * p_ud , Object * p_base , const StringName & p_name , VARIANT_ARG_DECLARE ) {
2015-08-02 17:29:37 +02:00
2017-03-05 16:44:50 +01:00
ScriptEditorDebugger * sed = ( ScriptEditorDebugger * ) p_ud ;
sed - > _method_changed ( p_base , p_name , VARIANT_ARG_PASS ) ;
2015-08-02 17:29:37 +02:00
}
2017-03-05 16:44:50 +01:00
void ScriptEditorDebugger : : _property_changeds ( void * p_ud , Object * p_base , const StringName & p_property , const Variant & p_value ) {
2015-08-02 17:29:37 +02:00
2017-03-05 16:44:50 +01:00
ScriptEditorDebugger * sed = ( ScriptEditorDebugger * ) p_ud ;
sed - > _property_changed ( p_base , p_property , p_value ) ;
2015-08-02 17:29:37 +02:00
}
void ScriptEditorDebugger : : set_live_debugging ( bool p_enable ) {
2017-03-05 16:44:50 +01:00
live_debug = p_enable ;
2015-08-02 17:29:37 +02:00
}
void ScriptEditorDebugger : : _live_edit_set ( ) {
if ( ! connection . is_valid ( ) )
return ;
2017-03-05 16:44:50 +01:00
TreeItem * ti = inspect_scene_tree - > get_selected ( ) ;
2015-08-02 17:29:37 +02:00
if ( ! ti )
return ;
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 17:29:37 +02: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 ( ) ;
if ( connection . is_valid ( ) ) {
Array msg ;
msg . push_back ( " live_set_root " ) ;
msg . push_back ( np ) ;
if ( editor - > get_edited_scene ( ) )
msg . push_back ( editor - > get_edited_scene ( ) - > get_filename ( ) ) ;
else
msg . push_back ( " " ) ;
ppeer - > put_var ( msg ) ;
}
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 ) {
2015-08-02 17:29:37 +02:00
2015-08-03 01:28:10 +02:00
if ( live_debug & & connection . is_valid ( ) ) {
2015-08-02 17:29:37 +02:00
Array msg ;
msg . push_back ( " live_create_node " ) ;
msg . push_back ( p_parent ) ;
msg . push_back ( p_type ) ;
msg . push_back ( p_name ) ;
ppeer - > put_var ( msg ) ;
}
}
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 ) {
2015-08-02 17:29:37 +02:00
2015-08-03 01:28:10 +02:00
if ( live_debug & & connection . is_valid ( ) ) {
2015-08-02 17:29:37 +02:00
Array msg ;
msg . push_back ( " live_instance_node " ) ;
msg . push_back ( p_parent ) ;
msg . push_back ( p_path ) ;
msg . push_back ( p_name ) ;
ppeer - > put_var ( msg ) ;
}
}
2017-03-05 16:44:50 +01:00
void ScriptEditorDebugger : : live_debug_remove_node ( const NodePath & p_at ) {
2015-08-02 17:29:37 +02:00
2015-08-03 01:28:10 +02:00
if ( live_debug & & connection . is_valid ( ) ) {
2015-08-02 17:29:37 +02:00
Array msg ;
msg . push_back ( " live_remove_node " ) ;
msg . push_back ( p_at ) ;
ppeer - > put_var ( msg ) ;
}
}
2017-03-05 16:44:50 +01:00
void ScriptEditorDebugger : : live_debug_remove_and_keep_node ( const NodePath & p_at , ObjectID p_keep_id ) {
2015-08-02 17:29:37 +02:00
2015-08-03 01:28:10 +02:00
if ( live_debug & & connection . is_valid ( ) ) {
2015-08-02 17:29:37 +02:00
Array msg ;
2015-08-03 01:28:10 +02:00
msg . push_back ( " live_remove_and_keep_node " ) ;
2015-08-02 17:29:37 +02:00
msg . push_back ( p_at ) ;
msg . push_back ( p_keep_id ) ;
ppeer - > put_var ( msg ) ;
}
}
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 ) {
2015-08-02 17:29:37 +02:00
2015-08-03 01:28:10 +02:00
if ( live_debug & & connection . is_valid ( ) ) {
2015-08-02 17:29:37 +02:00
Array msg ;
msg . push_back ( " live_restore_node " ) ;
msg . push_back ( p_id ) ;
msg . push_back ( p_at ) ;
msg . push_back ( p_at_pos ) ;
ppeer - > put_var ( msg ) ;
}
}
2017-03-05 16:44:50 +01:00
void ScriptEditorDebugger : : live_debug_duplicate_node ( const NodePath & p_at , const String & p_new_name ) {
2015-08-02 17:29:37 +02:00
2015-08-03 01:28:10 +02:00
if ( live_debug & & connection . is_valid ( ) ) {
2015-08-02 17:29:37 +02:00
Array msg ;
msg . push_back ( " live_duplicate_node " ) ;
msg . push_back ( p_at ) ;
msg . push_back ( p_new_name ) ;
ppeer - > put_var ( msg ) ;
}
}
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 ) {
2015-08-02 17:29:37 +02:00
2015-08-03 01:28:10 +02:00
if ( live_debug & & connection . is_valid ( ) ) {
2015-08-02 17:29:37 +02:00
Array msg ;
msg . push_back ( " live_reparent_node " ) ;
msg . push_back ( p_at ) ;
msg . push_back ( p_new_place ) ;
msg . push_back ( p_new_name ) ;
2015-08-03 01:28:10 +02:00
msg . push_back ( p_at_pos ) ;
2015-08-02 17:29:37 +02:00
ppeer - > put_var ( msg ) ;
}
}
2017-03-05 16:44:50 +01:00
void ScriptEditorDebugger : : set_breakpoint ( const String & p_path , int p_line , bool p_enabled ) {
2015-08-05 01:17:13 +02:00
if ( connection . is_valid ( ) ) {
2017-03-05 16:44:50 +01:00
Array msg ;
msg . push_back ( " breakpoint " ) ;
msg . push_back ( p_path ) ;
msg . push_back ( p_line ) ;
msg . push_back ( p_enabled ) ;
ppeer - > put_var ( msg ) ;
}
2015-08-05 01:17:13 +02:00
}
2016-06-02 01:22:02 +02:00
void ScriptEditorDebugger : : reload_scripts ( ) {
if ( connection . is_valid ( ) ) {
2017-03-05 16:44:50 +01:00
Array msg ;
msg . push_back ( " reload_scripts " ) ;
ppeer - > put_var ( msg ) ;
}
2016-06-02 01:22:02 +02:00
}
2015-08-04 14:47:32 +02:00
void ScriptEditorDebugger : : _error_selected ( int p_idx ) {
error_stack - > clear ( ) ;
2017-03-05 16:44:50 +01:00
Array st = error_list - > get_item_metadata ( p_idx ) ;
for ( int i = 0 ; i < st . size ( ) ; i + = 2 ) {
2015-08-04 14:47:32 +02:00
2017-03-05 16:44:50 +01:00
String script = st [ i ] ;
int line = st [ i + 1 ] ;
2015-08-04 14:47:32 +02:00
Array md ;
md . push_back ( st [ i ] ) ;
2017-03-05 16:44:50 +01:00
md . push_back ( st [ i + 1 ] ) ;
2015-08-04 14:47:32 +02:00
2017-03-05 16:44:50 +01:00
String str = script . get_file ( ) + " : " + itos ( line ) ;
2015-08-04 14:47:32 +02:00
error_stack - > add_item ( str ) ;
2017-03-05 16:44:50 +01:00
error_stack - > set_item_metadata ( error_stack - > get_item_count ( ) - 1 , md ) ;
error_stack - > set_item_tooltip ( error_stack - > get_item_count ( ) - 1 , TTR ( " File: " ) + " " + String ( st [ i ] ) + " \n " + TTR ( " Line: " ) + " " + itos ( line ) ) ;
2015-08-04 14:47:32 +02:00
}
}
2017-03-05 16:44:50 +01:00
void ScriptEditorDebugger : : _error_stack_selected ( int p_idx ) {
2015-08-04 14:47:32 +02:00
Array arr = error_stack - > get_item_metadata ( p_idx ) ;
2017-03-05 16:44:50 +01:00
if ( arr . size ( ) ! = 2 )
2015-08-04 14:47:32 +02:00
return ;
Ref < Script > s = ResourceLoader : : load ( arr [ 0 ] ) ;
2017-03-05 16:44:50 +01:00
emit_signal ( " goto_script_line " , s , int ( arr [ 1 ] ) - 1 ) ;
2015-08-04 14:47:32 +02:00
}
2015-12-12 14:09:50 +01:00
void ScriptEditorDebugger : : set_hide_on_stop ( bool p_hide ) {
2017-03-05 16:44:50 +01:00
hide_on_stop = p_hide ;
2015-12-12 14:09:50 +01:00
}
2015-08-02 17:29:37 +02:00
2017-06-25 11:20:01 +02:00
bool ScriptEditorDebugger : : get_debug_with_external_editor ( ) const {
return enable_external_editor ;
}
void ScriptEditorDebugger : : set_debug_with_external_editor ( bool p_enabled ) {
enable_external_editor = p_enabled ;
}
Ref < Script > ScriptEditorDebugger : : get_dump_stack_script ( ) const {
return stack_script ;
}
2016-05-22 02:18:16 +02:00
void ScriptEditorDebugger : : _paused ( ) {
ERR_FAIL_COND ( connection . is_null ( ) ) ;
2017-01-14 15:07:57 +01:00
ERR_FAIL_COND ( ! connection - > is_connected_to_host ( ) ) ;
2016-05-22 02:18:16 +02:00
if ( ! breaked & & EditorNode : : get_singleton ( ) - > get_pause_button ( ) - > is_pressed ( ) ) {
debug_break ( ) ;
}
if ( breaked & & ! EditorNode : : get_singleton ( ) - > get_pause_button ( ) - > is_pressed ( ) ) {
debug_continue ( ) ;
}
}
2014-02-13 22:03:28 +01:00
void ScriptEditorDebugger : : _bind_methods ( ) {
2017-03-05 16:44:50 +01:00
ClassDB : : bind_method ( D_METHOD ( " _stack_dump_frame_selected " ) , & ScriptEditorDebugger : : _stack_dump_frame_selected ) ;
ClassDB : : bind_method ( D_METHOD ( " debug_next " ) , & ScriptEditorDebugger : : debug_next ) ;
ClassDB : : bind_method ( D_METHOD ( " debug_step " ) , & ScriptEditorDebugger : : debug_step ) ;
ClassDB : : bind_method ( D_METHOD ( " debug_break " ) , & ScriptEditorDebugger : : debug_break ) ;
ClassDB : : bind_method ( D_METHOD ( " debug_continue " ) , & ScriptEditorDebugger : : debug_continue ) ;
ClassDB : : bind_method ( D_METHOD ( " _output_clear " ) , & ScriptEditorDebugger : : _output_clear ) ;
ClassDB : : bind_method ( D_METHOD ( " _performance_draw " ) , & ScriptEditorDebugger : : _performance_draw ) ;
ClassDB : : bind_method ( D_METHOD ( " _performance_select " ) , & ScriptEditorDebugger : : _performance_select ) ;
ClassDB : : bind_method ( D_METHOD ( " _scene_tree_request " ) , & ScriptEditorDebugger : : _scene_tree_request ) ;
ClassDB : : bind_method ( D_METHOD ( " _video_mem_request " ) , & ScriptEditorDebugger : : _video_mem_request ) ;
ClassDB : : bind_method ( D_METHOD ( " _live_edit_set " ) , & ScriptEditorDebugger : : _live_edit_set ) ;
ClassDB : : bind_method ( D_METHOD ( " _live_edit_clear " ) , & ScriptEditorDebugger : : _live_edit_clear ) ;
ClassDB : : bind_method ( D_METHOD ( " _error_selected " ) , & ScriptEditorDebugger : : _error_selected ) ;
ClassDB : : bind_method ( D_METHOD ( " _error_stack_selected " ) , & ScriptEditorDebugger : : _error_stack_selected ) ;
ClassDB : : bind_method ( D_METHOD ( " _profiler_activate " ) , & ScriptEditorDebugger : : _profiler_activate ) ;
ClassDB : : bind_method ( D_METHOD ( " _profiler_seeked " ) , & ScriptEditorDebugger : : _profiler_seeked ) ;
ClassDB : : bind_method ( D_METHOD ( " _paused " ) , & ScriptEditorDebugger : : _paused ) ;
ClassDB : : bind_method ( D_METHOD ( " _scene_tree_selected " ) , & ScriptEditorDebugger : : _scene_tree_selected ) ;
ClassDB : : bind_method ( D_METHOD ( " _scene_tree_folded " ) , & ScriptEditorDebugger : : _scene_tree_folded ) ;
ClassDB : : bind_method ( D_METHOD ( " 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 ) ;
ClassDB : : bind_method ( D_METHOD ( " _scene_tree_property_select_object " ) , & ScriptEditorDebugger : : _scene_tree_property_select_object ) ;
ClassDB : : bind_method ( D_METHOD ( " _scene_tree_property_value_edited " ) , & ScriptEditorDebugger : : _scene_tree_property_value_edited ) ;
2014-02-13 22:03:28 +01:00
ADD_SIGNAL ( MethodInfo ( " goto_script_line " ) ) ;
2017-03-05 16:44:50 +01:00
ADD_SIGNAL ( MethodInfo ( " breaked " , PropertyInfo ( Variant : : BOOL , " reallydid " ) , PropertyInfo ( Variant : : BOOL , " can_debug " ) ) ) ;
ADD_SIGNAL ( MethodInfo ( " show_debugger " , PropertyInfo ( Variant : : BOOL , " reallydid " ) ) ) ;
2014-02-13 22:03:28 +01:00
}
2017-03-05 16:44:50 +01:00
ScriptEditorDebugger : : ScriptEditorDebugger ( EditorNode * p_editor ) {
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
ppeer = Ref < PacketPeerStream > ( memnew ( PacketPeerStream ) ) ;
2017-08-09 01:55:22 +02:00
ppeer - > set_input_buffer_max_size ( 1024 * 1024 * 8 ) ; //8mb should be enough
2017-03-05 16:44:50 +01:00
editor = p_editor ;
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
tabs = memnew ( TabContainer ) ;
2017-05-02 22:13:12 +02:00
tabs - > set_tab_align ( TabContainer : : ALIGN_LEFT ) ;
tabs - > add_style_override ( " panel " , editor - > get_gui_base ( ) - > get_stylebox ( " DebuggerPanel " , " EditorStyles " ) ) ;
tabs - > add_style_override ( " tab_fg " , editor - > get_gui_base ( ) - > get_stylebox ( " DebuggerTabFG " , " EditorStyles " ) ) ;
tabs - > add_style_override ( " tab_bg " , editor - > get_gui_base ( ) - > get_stylebox ( " DebuggerTabBG " , " EditorStyles " ) ) ;
2014-02-13 22:03:28 +01:00
tabs - > set_area_as_parent_rect ( ) ;
add_child ( tabs ) ;
2016-05-23 00:28:37 +02:00
{ //debugger
2017-03-05 16:44:50 +01:00
VBoxContainer * vbc = memnew ( VBoxContainer ) ;
2016-05-23 00:28:37 +02:00
vbc - > set_name ( TTR ( " Debugger " ) ) ;
//tabs->add_child(vbc);
2017-03-05 16:44:50 +01:00
Control * dbg = vbc ;
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
HBoxContainer * hbc = memnew ( HBoxContainer ) ;
2016-05-23 00:28:37 +02:00
vbc - > add_child ( hbc ) ;
2014-02-13 22:03:28 +01:00
2017-08-08 04:55:24 +02:00
reason = memnew ( Label ) ;
2016-05-23 00:28:37 +02:00
reason - > set_text ( " " ) ;
hbc - > add_child ( reason ) ;
reason - > set_h_size_flags ( SIZE_EXPAND_FILL ) ;
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
hbc - > add_child ( memnew ( VSeparator ) ) ;
2014-02-13 22:03:28 +01:00
2017-07-18 18:03:06 +02:00
step = memnew ( ToolButton ) ;
2016-05-23 00:28:37 +02:00
hbc - > add_child ( step ) ;
step - > set_tooltip ( TTR ( " Step Into " ) ) ;
2017-03-05 16:44:50 +01:00
step - > connect ( " pressed " , this , " debug_step " ) ;
2014-02-13 22:03:28 +01:00
2017-07-18 18:03:06 +02:00
next = memnew ( ToolButton ) ;
2016-05-23 00:28:37 +02:00
hbc - > add_child ( next ) ;
next - > set_tooltip ( TTR ( " Step Over " ) ) ;
2017-03-05 16:44:50 +01:00
next - > connect ( " pressed " , this , " debug_next " ) ;
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
hbc - > add_child ( memnew ( VSeparator ) ) ;
2014-02-13 22:03:28 +01:00
2017-07-18 18:03:06 +02:00
dobreak = memnew ( ToolButton ) ;
2016-05-23 00:28:37 +02:00
hbc - > add_child ( dobreak ) ;
dobreak - > set_tooltip ( TTR ( " Break " ) ) ;
2017-03-05 16:44:50 +01:00
dobreak - > connect ( " pressed " , this , " debug_break " ) ;
2014-02-13 22:03:28 +01:00
2017-07-18 18:03:06 +02:00
docontinue = memnew ( ToolButton ) ;
2016-05-23 00:28:37 +02:00
hbc - > add_child ( docontinue ) ;
docontinue - > set_tooltip ( TTR ( " Continue " ) ) ;
2017-03-05 16:44:50 +01:00
docontinue - > connect ( " pressed " , this , " debug_continue " ) ;
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
back = memnew ( Button ) ;
2016-05-23 00:28:37 +02:00
hbc - > add_child ( back ) ;
back - > set_tooltip ( TTR ( " Inspect Previous Instance " ) ) ;
2016-06-12 02:40:51 +02:00
back - > hide ( ) ;
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
forward = memnew ( Button ) ;
2016-05-23 00:28:37 +02:00
hbc - > add_child ( forward ) ;
forward - > set_tooltip ( TTR ( " Inspect Next Instance " ) ) ;
2016-06-12 02:40:51 +02:00
forward - > hide ( ) ;
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
HSplitContainer * sc = memnew ( HSplitContainer ) ;
2016-05-23 00:28:37 +02:00
vbc - > add_child ( sc ) ;
sc - > set_v_size_flags ( SIZE_EXPAND_FILL ) ;
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
stack_dump = memnew ( Tree ) ;
2016-05-23 00:28:37 +02: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-23 00:28:37 +02:00
stack_dump - > set_h_size_flags ( SIZE_EXPAND_FILL ) ;
stack_dump - > set_hide_root ( true ) ;
2017-03-05 16:44:50 +01:00
stack_dump - > connect ( " cell_selected " , this , " _stack_dump_frame_selected " ) ;
2016-05-23 00:28:37 +02:00
sc - > add_child ( stack_dump ) ;
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
inspector = memnew ( PropertyEditor ) ;
2016-05-23 00:28:37 +02:00
inspector - > set_h_size_flags ( SIZE_EXPAND_FILL ) ;
inspector - > hide_top_label ( ) ;
2017-03-05 16:44:50 +01:00
inspector - > get_scene_tree ( ) - > set_column_title ( 0 , TTR ( " Variable " ) ) ;
2017-04-26 13:41:41 +02:00
inspector - > set_enable_capitalize_paths ( false ) ;
2016-05-23 00:28:37 +02:00
inspector - > set_read_only ( true ) ;
2017-05-01 19:27:01 +02:00
inspector - > connect ( " object_id_selected " , this , " _scene_tree_property_select_object " ) ;
2016-05-23 00:28:37 +02:00
sc - > add_child ( inspector ) ;
2014-02-13 22:03:28 +01:00
2016-05-23 00:28:37 +02:00
server = TCP_Server : : create_ref ( ) ;
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
pending_in_queue = 0 ;
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
variables = memnew ( ScriptEditorDebuggerVariables ) ;
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
breaked = false ;
2016-05-23 00:28:37 +02:00
tabs - > add_child ( dbg ) ;
}
2017-03-05 16:44:50 +01:00
{ //errors
2016-05-23 00:28:37 +02:00
2017-03-05 16:44:50 +01:00
error_split = memnew ( HSplitContainer ) ;
VBoxContainer * errvb = memnew ( VBoxContainer ) ;
2016-05-23 00:28:37 +02:00
errvb - > set_h_size_flags ( SIZE_EXPAND_FILL ) ;
2017-03-05 16:44:50 +01:00
error_list = memnew ( ItemList ) ;
errvb - > add_margin_child ( TTR ( " Errors: " ) , error_list , true ) ;
2016-05-23 00:28:37 +02:00
error_split - > add_child ( errvb ) ;
2017-03-05 16:44:50 +01:00
errvb = memnew ( VBoxContainer ) ;
2016-05-23 00:28:37 +02:00
errvb - > set_h_size_flags ( SIZE_EXPAND_FILL ) ;
2017-03-05 16:44:50 +01:00
error_stack = memnew ( ItemList ) ;
errvb - > add_margin_child ( TTR ( " Stack Trace (if applicable): " ) , error_stack , true ) ;
2016-05-23 00:28:37 +02:00
error_split - > add_child ( errvb ) ;
error_split - > set_name ( TTR ( " Errors " ) ) ;
tabs - > add_child ( error_split ) ;
}
{ // inquire
2014-02-13 22:03:28 +01:00
2017-03-05 16:44:50 +01:00
inspect_info = memnew ( HSplitContainer ) ;
2016-05-23 00:28:37 +02:00
inspect_info - > set_name ( TTR ( " Remote Inspector " ) ) ;
tabs - > add_child ( inspect_info ) ;
VBoxContainer * info_left = memnew ( VBoxContainer ) ;
info_left - > set_h_size_flags ( SIZE_EXPAND_FILL ) ;
inspect_info - > add_child ( info_left ) ;
2017-03-05 16:44:50 +01:00
inspect_scene_tree = memnew ( Tree ) ;
info_left - > add_margin_child ( TTR ( " Live Scene Tree: " ) , inspect_scene_tree , true ) ;
inspect_scene_tree - > connect ( " cell_selected " , this , " _scene_tree_selected " ) ;
inspect_scene_tree - > connect ( " item_collapsed " , this , " _scene_tree_folded " ) ;
2016-05-23 00:28:37 +02:00
//
VBoxContainer * info_right = memnew ( VBoxContainer ) ;
info_right - > set_h_size_flags ( SIZE_EXPAND_FILL ) ;
inspect_info - > add_child ( info_right ) ;
2017-03-05 16:44:50 +01:00
inspect_properties = memnew ( PropertyEditor ) ;
2016-05-23 00:28:37 +02:00
inspect_properties - > hide_top_label ( ) ;
inspect_properties - > set_show_categories ( true ) ;
2017-03-05 16:44:50 +01:00
inspect_properties - > connect ( " object_id_selected " , this , " _scene_tree_property_select_object " ) ;
2016-05-23 00:28:37 +02:00
2017-03-05 16:44:50 +01:00
info_right - > add_margin_child ( TTR ( " Remote Object Properties: " ) , inspect_properties , true ) ;
2016-05-23 00:28:37 +02:00
2017-03-05 16:44:50 +01:00
inspect_scene_tree_timeout = EDITOR_DEF ( " debugger/scene_tree_refresh_interval " , 1.0 ) ;
inspect_edited_object_timeout = EDITOR_DEF ( " debugger/remote_inspect_refresh_interval " , 0.2 ) ;
inspected_object_id = 0 ;
updating_scene_tree = false ;
2016-05-23 00:28:37 +02:00
2017-03-05 16:44:50 +01:00
inspected_object = memnew ( ScriptEditorDebuggerInspectedObject ) ;
inspected_object - > connect ( " value_edited " , this , " _scene_tree_property_value_edited " ) ;
2014-02-13 22:03:28 +01:00
}
2016-05-23 00:28:37 +02:00
{ //profiler
2017-03-05 16:44:50 +01:00
profiler = memnew ( EditorProfiler ) ;
2016-05-30 20:47:53 +02:00
profiler - > set_name ( TTR ( " Profiler " ) ) ;
2016-05-23 00:28:37 +02:00
tabs - > add_child ( profiler ) ;
2017-03-05 16:44:50 +01:00
profiler - > connect ( " enable_profiling " , this , " _profiler_activate " ) ;
profiler - > connect ( " break_request " , this , " _profiler_seeked " ) ;
2016-05-23 00:28:37 +02:00
}
{ //monitors
2017-03-05 16:44:50 +01:00
HSplitContainer * hsp = memnew ( HSplitContainer ) ;
2016-05-23 00:28:37 +02: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-23 00:28:37 +02:00
perf_monitors - > set_column_titles_visible ( true ) ;
hsp - > add_child ( perf_monitors ) ;
perf_monitors - > set_select_mode ( Tree : : SELECT_MULTI ) ;
2017-03-05 16:44:50 +01:00
perf_monitors - > connect ( " multi_selected " , this , " _performance_select " ) ;
perf_draw = memnew ( Control ) ;
perf_draw - > connect ( " draw " , this , " _performance_draw " ) ;
2016-05-23 00:28:37 +02:00
hsp - > add_child ( perf_draw ) ;
2016-05-30 20:47:53 +02:00
hsp - > set_name ( TTR ( " Monitors " ) ) ;
2016-05-23 00:28:37 +02:00
hsp - > set_split_offset ( 300 ) ;
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-23 00:28:37 +02: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-23 00:28:37 +02:00
String n = Performance : : get_singleton ( ) - > get_monitor_name ( 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-23 00:28:37 +02: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 ) ;
bases [ base ] = b ;
2016-05-23 00:28:37 +02:00
}
TreeItem * it = perf_monitors - > create_item ( bases [ base ] ) ;
2017-03-05 16:44:50 +01:00
it - > set_editable ( 0 , false ) ;
it - > set_selectable ( 0 , true ) ;
it - > set_text ( 0 , name . capitalize ( ) ) ;
2016-05-23 00:28:37 +02:00
perf_items . push_back ( it ) ;
2017-03-05 16:44:50 +01:00
perf_max [ i ] = 0 ;
2016-05-23 00:28:37 +02: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-23 00:28:37 +02: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-23 00:28:37 +02:00
vmem_total - > set_editable ( false ) ;
2017-03-05 16:44:50 +01:00
vmem_total - > set_custom_minimum_size ( Size2 ( 100 , 1 ) * EDSCALE ) ;
2016-05-23 00:28:37 +02:00
vmem_hb - > add_child ( vmem_total ) ;
2017-07-18 18:03:06 +02:00
vmem_refresh = memnew ( ToolButton ) ;
2016-05-23 00:28:37 +02:00
vmem_hb - > add_child ( vmem_refresh ) ;
vmem_vb - > add_child ( vmem_hb ) ;
2017-03-05 16:44:50 +01:00
vmem_refresh - > connect ( " pressed " , this , " _video_mem_request " ) ;
2016-05-23 00:28:37 +02:00
2017-08-08 04:55:24 +02:00
VBoxContainer * vmmc = memnew ( VBoxContainer ) ;
2017-03-05 16:44:50 +01:00
vmem_tree = memnew ( Tree ) ;
2016-05-23 00:28:37 +02: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 ) ;
vmem_vb - > set_name ( TTR ( " Video Mem " ) ) ;
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 " ) ) ;
vmem_tree - > set_column_min_width ( 1 , 100 ) ;
vmem_tree - > set_column_expand ( 2 , false ) ;
vmem_tree - > set_column_title ( 2 , TTR ( " Format " ) ) ;
vmem_tree - > set_column_min_width ( 2 , 150 ) ;
vmem_tree - > set_column_expand ( 3 , false ) ;
vmem_tree - > set_column_title ( 3 , TTR ( " Usage " ) ) ;
vmem_tree - > set_column_min_width ( 3 , 80 ) ;
2016-05-23 00:28:37 +02:00
vmem_tree - > set_hide_root ( true ) ;
tabs - > add_child ( vmem_vb ) ;
}
{ // misc
2017-07-18 08:09:19 +02:00
GridContainer * info_left = memnew ( GridContainer ) ;
info_left - > set_columns ( 2 ) ;
2017-05-02 23:02:06 +02:00
info_left - > set_name ( TTR ( " Misc " ) ) ;
tabs - > add_child ( info_left ) ;
2017-03-05 16:44:50 +01:00
clicked_ctrl = memnew ( LineEdit ) ;
2017-07-18 08:09:19 +02: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 08:09:19 +02:00
info_left - > add_child ( memnew ( Label ( TTR ( " Clicked Control Type: " ) ) ) ) ;
info_left - > add_child ( clicked_ctrl_type ) ;
2016-05-23 00:28:37 +02:00
2017-03-05 16:44:50 +01:00
live_edit_root = memnew ( LineEdit ) ;
2017-07-18 08:09:19 +02:00
live_edit_root - > set_h_size_flags ( SIZE_EXPAND_FILL ) ;
2016-05-23 00:28:37 +02:00
{
2017-03-05 16:44:50 +01:00
HBoxContainer * lehb = memnew ( HBoxContainer ) ;
2017-05-02 23:02:06 +02:00
Label * l = memnew ( Label ( TTR ( " Live Edit Root: " ) ) ) ;
2017-07-18 08:09:19 +02: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-23 00:28:37 +02:00
lehb - > add_child ( le_set ) ;
2017-03-05 16:44:50 +01:00
le_clear = memnew ( Button ( TTR ( " Clear " ) ) ) ;
2016-05-23 00:28:37 +02:00
lehb - > add_child ( le_clear ) ;
2017-05-02 23:02:06 +02:00
info_left - > add_child ( lehb ) ;
2016-05-23 00:28:37 +02:00
le_set - > set_disabled ( true ) ;
le_clear - > set_disabled ( true ) ;
}
2015-08-02 17:29:37 +02:00
}
2017-03-05 16:44:50 +01:00
msgdialog = memnew ( AcceptDialog ) ;
2014-02-13 22:03:28 +01:00
add_child ( msgdialog ) ;
2017-03-05 16:44:50 +01:00
p_editor - > get_undo_redo ( ) - > set_method_notify_callback ( _method_changeds , this ) ;
p_editor - > get_undo_redo ( ) - > set_property_notify_callback ( _property_changeds , this ) ;
live_debug = false ;
last_path_id = false ;
error_count = 0 ;
hide_on_stop = true ;
2017-06-25 11:20:01 +02:00
enable_external_editor = false ;
2017-03-05 16:44:50 +01:00
last_error_count = 0 ;
2015-08-02 17:29:37 +02:00
2017-03-05 16:44:50 +01:00
EditorNode : : get_singleton ( ) - > get_pause_button ( ) - > connect ( " pressed " , this , " _paused " ) ;
2014-02-13 22:03:28 +01:00
}
ScriptEditorDebugger : : ~ ScriptEditorDebugger ( ) {
2017-01-14 12:26:56 +01:00
//inspector->edit(NULL);
2014-02-13 22:03:28 +01:00
memdelete ( variables ) ;
ppeer - > set_stream_peer ( Ref < StreamPeer > ( ) ) ;
server - > stop ( ) ;
2016-05-23 00:28:37 +02:00
memdelete ( inspected_object ) ;
2014-02-13 22:03:28 +01:00
}