Debian Codegraph @

modules/multiplayer/editor/replication_editor.h

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