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#ifndef EDITOR_DEBUGGER_INSPECTOR_H
32#define EDITOR_DEBUGGER_INSPECTOR_H
33
34#include "editor/editor_inspector.h"
35
36class EditorDebuggerRemoteObject : public Object {
37 GDCLASS(EditorDebuggerRemoteObject, Object);
38
39protected:
40 bool _set(const StringName &p_name, const Variant &p_value);
41 bool _get(const StringName &p_name, Variant &r_ret) const;
42 void _get_property_list(List<PropertyInfo> *p_list) const;
43 static void _bind_methods();
44
45public:
46 ObjectID remote_object_id;
47 String type_name;
48 List<PropertyInfo> prop_list;
49 HashMap<StringName, Variant> prop_values;
50
51 ObjectID get_remote_object_id() { return remote_object_id; };
52 String get_title();
53
54 Variant get_variant(const StringName &p_name);
55
56 void clear() {
57 prop_list.clear();
58 prop_values.clear();
59 }
60
61 void update() { notify_property_list_changed(); }
62
63 EditorDebuggerRemoteObject() {}
64};
65
66class EditorDebuggerInspector : public EditorInspector {
67 GDCLASS(EditorDebuggerInspector, EditorInspector);
68
69private:
70 ObjectID inspected_object_id;
71 HashMap<ObjectID, EditorDebuggerRemoteObject *> remote_objects;
72 HashSet<Ref<Resource>> remote_dependencies;
73 EditorDebuggerRemoteObject *variables = nullptr;
74
75 void _object_selected(ObjectID p_object);
76 void _object_edited(ObjectID p_id, const String &p_prop, const Variant &p_value);
77
78protected:
79 void _notification(int p_what);
80 static void _bind_methods();
81
82public:
83 EditorDebuggerInspector();
84 ~EditorDebuggerInspector();
85
86 // Remote Object cache
87 ObjectID add_object(const Array &p_arr);
88 Object *get_object(ObjectID p_id);
89 void clear_cache();
90
91 // Stack Dump variables
92 String get_stack_variable(const String &p_var);
93 void add_stack_variable(const Array &p_arr);
94 void clear_stack_variables();
95};
96
97#endif // EDITOR_DEBUGGER_INSPECTOR_H
98