group_settings_editor.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /**************************************************************************/
  2. /* group_settings_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/gui/dialogs.h"
  32. class CheckBox;
  33. class EditorFileSystemDirectory;
  34. class EditorValidationPanel;
  35. class FileSystemDock;
  36. class Label;
  37. class Tree;
  38. class GroupSettingsEditor : public VBoxContainer {
  39. GDCLASS(GroupSettingsEditor, VBoxContainer);
  40. const String GLOBAL_GROUP_PREFIX = "global_group/";
  41. const StringName group_changed = "group_changed";
  42. HashMap<StringName, String> groups_cache;
  43. bool updating_groups = false;
  44. AcceptDialog *message = nullptr;
  45. Tree *tree = nullptr;
  46. LineEdit *group_name = nullptr;
  47. LineEdit *group_description = nullptr;
  48. Button *add_button = nullptr;
  49. ConfirmationDialog *remove_dialog = nullptr;
  50. CheckBox *remove_check_box = nullptr;
  51. Label *remove_label = nullptr;
  52. ConfirmationDialog *rename_group_dialog = nullptr;
  53. LineEdit *rename_group = nullptr;
  54. CheckBox *rename_check_box = nullptr;
  55. EditorValidationPanel *rename_validation_panel = nullptr;
  56. void _show_remove_dialog();
  57. void _show_rename_dialog();
  58. String _check_new_group_name(const String &p_name);
  59. void _check_rename();
  60. void _add_group();
  61. void _add_group(const String &p_name, const String &p_description);
  62. void _modify_references(const StringName &p_name, const StringName &p_new_name, bool p_is_rename);
  63. void _confirm_rename();
  64. void _confirm_delete();
  65. void _text_submitted(const String &p_text);
  66. void _group_name_text_changed(const String &p_name);
  67. void _item_edited();
  68. void _item_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
  69. protected:
  70. void _notification(int p_what);
  71. static void _bind_methods();
  72. public:
  73. LineEdit *get_name_box() const;
  74. void show_message(const String &p_message);
  75. void remove_references(const StringName &p_name);
  76. void rename_references(const StringName &p_old_name, const StringName &p_new_name);
  77. bool remove_node_references(Node *p_node, const StringName &p_name);
  78. bool rename_node_references(Node *p_node, const StringName &p_old_name, const StringName &p_new_name);
  79. void update_groups();
  80. void connect_filesystem_dock_signals(FileSystemDock *p_fs_dock);
  81. GroupSettingsEditor();
  82. };