editor_debugger_inspector.h 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**************************************************************************/
  2. /* editor_debugger_inspector.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  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 EDITOR_DEBUGGER_INSPECTOR_H
  31. #define EDITOR_DEBUGGER_INSPECTOR_H
  32. #include "editor/editor_inspector.h"
  33. class EditorDebuggerRemoteObject : public Object {
  34. GDCLASS(EditorDebuggerRemoteObject, Object);
  35. protected:
  36. bool _set(const StringName &p_name, const Variant &p_value);
  37. bool _get(const StringName &p_name, Variant &r_ret) const;
  38. void _get_property_list(List<PropertyInfo> *p_list) const;
  39. static void _bind_methods();
  40. public:
  41. ObjectID remote_object_id;
  42. String type_name;
  43. List<PropertyInfo> prop_list;
  44. HashMap<StringName, Variant> prop_values;
  45. ObjectID get_remote_object_id() { return remote_object_id; };
  46. String get_title();
  47. Variant get_variant(const StringName &p_name);
  48. void clear() {
  49. prop_list.clear();
  50. prop_values.clear();
  51. }
  52. void update() { notify_property_list_changed(); }
  53. EditorDebuggerRemoteObject() {}
  54. };
  55. class EditorDebuggerInspector : public EditorInspector {
  56. GDCLASS(EditorDebuggerInspector, EditorInspector);
  57. private:
  58. ObjectID inspected_object_id;
  59. HashMap<ObjectID, EditorDebuggerRemoteObject *> remote_objects;
  60. HashSet<Ref<Resource>> remote_dependencies;
  61. EditorDebuggerRemoteObject *variables = nullptr;
  62. void _object_selected(ObjectID p_object);
  63. void _object_edited(ObjectID p_id, const String &p_prop, const Variant &p_value);
  64. protected:
  65. void _notification(int p_what);
  66. static void _bind_methods();
  67. public:
  68. EditorDebuggerInspector();
  69. ~EditorDebuggerInspector();
  70. // Remote Object cache
  71. ObjectID add_object(const Array &p_arr);
  72. Object *get_object(ObjectID p_id);
  73. void clear_cache();
  74. // Stack Dump variables
  75. String get_stack_variable(const String &p_var);
  76. void add_stack_variable(const Array &p_arr);
  77. void clear_stack_variables();
  78. };
  79. #endif // EDITOR_DEBUGGER_INSPECTOR_H