1 | /**************************************************************************/ |
2 | /* replication_editor.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 REPLICATION_EDITOR_H |
32 | #define REPLICATION_EDITOR_H |
33 | |
34 | #include "../scene_replication_config.h" |
35 | |
36 | #include "editor/editor_plugin.h" |
37 | #include "scene/gui/box_container.h" |
38 | |
39 | class ConfirmationDialog; |
40 | class MultiplayerSynchronizer; |
41 | class AcceptDialog; |
42 | class LineEdit; |
43 | class Tree; |
44 | class TreeItem; |
45 | class PropertySelector; |
46 | class SceneTreeDialog; |
47 | |
48 | class ReplicationEditor : public VBoxContainer { |
49 | GDCLASS(ReplicationEditor, VBoxContainer); |
50 | |
51 | private: |
52 | MultiplayerSynchronizer *current = nullptr; |
53 | |
54 | ConfirmationDialog *delete_dialog = nullptr; |
55 | Button *add_pick_button = nullptr; |
56 | Button *add_from_path_button = nullptr; |
57 | LineEdit *np_line_edit = nullptr; |
58 | |
59 | Label *drop_label = nullptr; |
60 | |
61 | Ref<SceneReplicationConfig> config; |
62 | NodePath deleting; |
63 | Tree *tree = nullptr; |
64 | |
65 | PropertySelector *prop_selector = nullptr; |
66 | SceneTreeDialog *pick_node = nullptr; |
67 | NodePath adding_node_path; |
68 | |
69 | Button *pin = nullptr; |
70 | |
71 | Ref<Texture2D> _get_class_icon(const Node *p_node); |
72 | |
73 | void _add_pressed(); |
74 | void _np_text_submitted(const String &p_newtext); |
75 | void _tree_item_edited(); |
76 | void _tree_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button); |
77 | void _update_value(const NodePath &p_prop, int p_column, int p_checked); |
78 | void _update_config(); |
79 | void _dialog_closed(bool p_confirmed); |
80 | void _add_property(const NodePath &p_property, bool p_spawn, SceneReplicationConfig::ReplicationMode p_mode); |
81 | |
82 | void _pick_node_filter_text_changed(const String &p_newtext); |
83 | void _pick_node_select_recursive(TreeItem *p_item, const String &p_filter, Vector<Node *> &p_select_candidates); |
84 | void _pick_node_filter_input(const Ref<InputEvent> &p_ie); |
85 | void _pick_node_selected(NodePath p_path); |
86 | |
87 | void _pick_new_property(); |
88 | void _pick_node_property_selected(String p_name); |
89 | |
90 | bool _can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; |
91 | void _drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); |
92 | |
93 | void _add_sync_property(String p_path); |
94 | |
95 | protected: |
96 | static void _bind_methods(); |
97 | |
98 | void _notification(int p_what); |
99 | |
100 | public: |
101 | void edit(MultiplayerSynchronizer *p_object); |
102 | MultiplayerSynchronizer *get_current() const { return current; } |
103 | |
104 | Button *get_pin() { return pin; } |
105 | ReplicationEditor(); |
106 | ~ReplicationEditor() {} |
107 | }; |
108 | |
109 | #endif // REPLICATION_EDITOR_H |
110 | |