0.2.0-dev Download ZIP
103 lines ·4.4 KB Raw
| 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 | |
| 31 | #pragma once |
| 32 | |
| 33 | #include "editor/inspector/editor_inspector.h" |
| 34 | |
| 35 | class SceneDebuggerObject; |
| 36 | |
| 37 | template <typename K, typename V> |
| 38 | class TypedDictionary; |
| 39 | |
| 40 | class EditorDebuggerRemoteObjects : public Object { |
| 41 | GDCLASS(EditorDebuggerRemoteObjects, Object); |
| 42 | |
| 43 | private: |
| 44 | bool _set_impl(const StringName &p_name, const Variant &p_value, const String &p_field); |
| 45 | |
| 46 | protected: |
| 47 | bool _set(const StringName &p_name, const Variant &p_value); |
| 48 | bool _get(const StringName &p_name, Variant &r_ret) const; |
| 49 | void _get_property_list(List<PropertyInfo> *p_list) const; |
| 50 | static void _bind_methods(); |
| 51 | |
| 52 | public: |
| 53 | TypedArray<uint64_t> remote_object_ids; |
| 54 | String type_name; |
| 55 | String node_name; // For human-readable name. |
| 56 | List<PropertyInfo> prop_list; |
| 57 | HashMap<StringName, TypedDictionary<uint64_t, Variant>> prop_values; |
| 58 | int debugger_id = 0; |
| 59 | bool has_canvas_items = false; |
| 60 | |
| 61 | bool _hide_script_from_inspector() { return true; } |
| 62 | bool _hide_metadata_from_inspector() { return true; } |
| 63 | |
| 64 | void set_property_field(const StringName &p_property, const Variant &p_value, const String &p_field); |
| 65 | String get_title(); |
| 66 | Variant get_variant(const StringName &p_name); |
| 67 | |
| 68 | void clear(); |
| 69 | |
| 70 | void update() { notify_property_list_changed(); } |
| 71 | }; |
| 72 | |
| 73 | class EditorDebuggerInspector : public EditorInspector { |
| 74 | GDCLASS(EditorDebuggerInspector, EditorInspector); |
| 75 | |
| 76 | private: |
| 77 | LocalVector<EditorDebuggerRemoteObjects *> remote_objects_list; |
| 78 | HashSet<Ref<Resource>> remote_dependencies; |
| 79 | EditorDebuggerRemoteObjects *variables = nullptr; |
| 80 | |
| 81 | void _object_selected(ObjectID p_object); |
| 82 | void _objects_edited(const String &p_prop, const TypedDictionary<uint64_t, Variant> &p_values, const String &p_field); |
| 83 | |
| 84 | protected: |
| 85 | void _notification(int p_what); |
| 86 | static void _bind_methods(); |
| 87 | |
| 88 | public: |
| 89 | EditorDebuggerInspector(); |
| 90 | ~EditorDebuggerInspector(); |
| 91 | |
| 92 | // Remote Object cache |
| 93 | EditorDebuggerRemoteObjects *set_objects(const Array &p_array, int p_debugger_id); |
| 94 | void add_undo_redo_action(const Array &p_array); |
| 95 | void clear_remote_inspector(); |
| 96 | void clear_cache(); |
| 97 | void invalidate_selection_from_cache(const TypedArray<uint64_t> &p_ids); |
| 98 | |
| 99 | // Stack Dump variables |
| 100 | String get_stack_variable(const String &p_var); |
| 101 | void add_stack_variable(const Array &p_arr, int p_offset = -1); |
| 102 | void clear_stack_variables(); |
| 103 | }; |