replication_editor.h 4.4 KB

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