replication_editor.h 4.3 KB

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