script_editor_debugger.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /*************************************************************************/
  2. /* script_editor_debugger.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef SCRIPT_EDITOR_DEBUGGER_H
  31. #define SCRIPT_EDITOR_DEBUGGER_H
  32. #include "core/io/packet_peer.h"
  33. #include "core/io/tcp_server.h"
  34. #include "property_editor.h"
  35. #include "scene/gui/box_container.h"
  36. #include "scene/gui/button.h"
  37. class Tree;
  38. class PropertyEditor;
  39. class EditorNode;
  40. class ScriptEditorDebuggerVariables;
  41. class LineEdit;
  42. class TabContainer;
  43. class RichTextLabel;
  44. class TextureButton;
  45. class AcceptDialog;
  46. class TreeItem;
  47. class HSplitContainer;
  48. class ItemList;
  49. class EditorProfiler;
  50. class ScriptEditorDebuggerInspectedObject;
  51. class ScriptEditorDebugger : public Control {
  52. GDCLASS(ScriptEditorDebugger, Control);
  53. AcceptDialog *msgdialog;
  54. Button *debugger_button;
  55. LineEdit *clicked_ctrl;
  56. LineEdit *clicked_ctrl_type;
  57. LineEdit *live_edit_root;
  58. Button *le_set;
  59. Button *le_clear;
  60. Tree *inspect_scene_tree;
  61. HSplitContainer *inspect_info;
  62. PropertyEditor *inspect_properties;
  63. float inspect_scene_tree_timeout;
  64. float inspect_edited_object_timeout;
  65. ObjectID inspected_object_id;
  66. ScriptEditorDebuggerInspectedObject *inspected_object;
  67. bool updating_scene_tree;
  68. Set<ObjectID> unfold_cache;
  69. HSplitContainer *error_split;
  70. ItemList *error_list;
  71. ItemList *error_stack;
  72. int error_count;
  73. int last_error_count;
  74. bool hide_on_stop;
  75. bool enable_external_editor;
  76. Ref<Script> stack_script;
  77. TabContainer *tabs;
  78. LineEdit *reason;
  79. ScriptEditorDebuggerVariables *variables;
  80. Button *step;
  81. Button *next;
  82. Button *back;
  83. Button *forward;
  84. Button *dobreak;
  85. Button *docontinue;
  86. List<Vector<float> > perf_history;
  87. Vector<float> perf_max;
  88. Vector<TreeItem *> perf_items;
  89. Map<int, String> profiler_signature;
  90. Tree *perf_monitors;
  91. Control *perf_draw;
  92. Tree *vmem_tree;
  93. Button *vmem_refresh;
  94. LineEdit *vmem_total;
  95. Tree *stack_dump;
  96. PropertyEditor *inspector;
  97. Ref<TCP_Server> server;
  98. Ref<StreamPeerTCP> connection;
  99. Ref<PacketPeerStream> ppeer;
  100. String message_type;
  101. Array message;
  102. int pending_in_queue;
  103. HashMap<NodePath, int> node_path_cache;
  104. int last_path_id;
  105. Map<String, int> res_path_cache;
  106. EditorProfiler *profiler;
  107. EditorNode *editor;
  108. bool breaked;
  109. bool live_debug;
  110. void _performance_draw();
  111. void _performance_select(Object *, int, bool);
  112. void _stack_dump_frame_selected();
  113. void _output_clear();
  114. void _scene_tree_folded(Object *obj);
  115. void _scene_tree_selected();
  116. void _scene_tree_request();
  117. void _parse_message(const String &p_msg, const Array &p_data);
  118. void _scene_tree_property_select_object(ObjectID p_object);
  119. void _scene_tree_property_value_edited(const String &p_prop, const Variant &p_value);
  120. void _video_mem_request();
  121. int _get_node_path_cache(const NodePath &p_path);
  122. int _get_res_path_cache(const String &p_path);
  123. void _live_edit_set();
  124. void _live_edit_clear();
  125. void _method_changed(Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE);
  126. void _property_changed(Object *p_base, const StringName &p_property, const Variant &p_value);
  127. static void _method_changeds(void *p_ud, Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE);
  128. static void _property_changeds(void *p_ud, Object *p_base, const StringName &p_property, const Variant &p_value);
  129. void _error_selected(int p_idx);
  130. void _error_stack_selected(int p_idx);
  131. void _profiler_activate(bool p_enable);
  132. void _profiler_seeked();
  133. void _paused();
  134. protected:
  135. void _notification(int p_what);
  136. static void _bind_methods();
  137. public:
  138. void start();
  139. void pause();
  140. void unpause();
  141. void stop();
  142. void debug_next();
  143. void debug_step();
  144. void debug_break();
  145. void debug_continue();
  146. String get_var_value(const String &p_var) const;
  147. void set_live_debugging(bool p_enable);
  148. void live_debug_create_node(const NodePath &p_parent, const String &p_type, const String &p_name);
  149. void live_debug_instance_node(const NodePath &p_parent, const String &p_path, const String &p_name);
  150. void live_debug_remove_node(const NodePath &p_at);
  151. void live_debug_remove_and_keep_node(const NodePath &p_at, ObjectID p_keep_id);
  152. void live_debug_restore_node(ObjectID p_id, const NodePath &p_at, int p_at_pos);
  153. void live_debug_duplicate_node(const NodePath &p_at, const String &p_new_name);
  154. void live_debug_reparent_node(const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos);
  155. void set_breakpoint(const String &p_path, int p_line, bool p_enabled);
  156. void update_live_edit_root();
  157. void set_hide_on_stop(bool p_hide);
  158. bool get_debug_with_external_editor() const;
  159. void set_debug_with_external_editor(bool p_enabled);
  160. Ref<Script> get_dump_stack_script() const;
  161. void set_tool_button(Button *p_tb) { debugger_button = p_tb; }
  162. void reload_scripts();
  163. virtual Size2 get_minimum_size() const;
  164. ScriptEditorDebugger(EditorNode *p_editor = NULL);
  165. ~ScriptEditorDebugger();
  166. };
  167. #endif // SCRIPT_EDITOR_DEBUGGER_H