editor_settings_dialog.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*************************************************************************/
  2. /* editor_settings_dialog.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  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 EDITOR_SETTINGS_DIALOG_H
  31. #define EDITOR_SETTINGS_DIALOG_H
  32. #include "editor/action_map_editor.h"
  33. #include "editor/editor_inspector.h"
  34. #include "editor/editor_sectioned_inspector.h"
  35. #include "scene/gui/dialogs.h"
  36. #include "scene/gui/panel_container.h"
  37. #include "scene/gui/rich_text_label.h"
  38. #include "scene/gui/tab_container.h"
  39. #include "scene/gui/texture_rect.h"
  40. class EditorSettingsDialog : public AcceptDialog {
  41. GDCLASS(EditorSettingsDialog, AcceptDialog);
  42. bool updating = false;
  43. TabContainer *tabs = nullptr;
  44. Control *tab_general = nullptr;
  45. Control *tab_shortcuts = nullptr;
  46. LineEdit *search_box = nullptr;
  47. LineEdit *shortcut_search_box = nullptr;
  48. SectionedInspector *inspector = nullptr;
  49. // Shortcuts
  50. enum ShortcutButton {
  51. SHORTCUT_ADD,
  52. SHORTCUT_EDIT,
  53. SHORTCUT_ERASE,
  54. SHORTCUT_REVERT
  55. };
  56. Tree *shortcuts = nullptr;
  57. String shortcut_filter;
  58. InputEventConfigurationDialog *shortcut_editor = nullptr;
  59. bool is_editing_action = false;
  60. String current_edited_identifier;
  61. Array current_events;
  62. int current_event_index = -1;
  63. Timer *timer = nullptr;
  64. UndoRedo *undo_redo = nullptr;
  65. virtual void cancel_pressed() override;
  66. virtual void ok_pressed() override;
  67. void _settings_changed();
  68. void _settings_property_edited(const String &p_name);
  69. void _settings_save();
  70. virtual void unhandled_input(const Ref<InputEvent> &p_event) override;
  71. void _notification(int p_what);
  72. void _update_icons();
  73. void _event_config_confirmed();
  74. void _create_shortcut_treeitem(TreeItem *p_parent, const String &p_shortcut_identifier, const String &p_display, Array &p_events, bool p_allow_revert, bool p_is_common, bool p_is_collapsed);
  75. Array _event_list_to_array_helper(List<Ref<InputEvent>> &p_events);
  76. void _update_builtin_action(const String &p_name, const Array &p_events);
  77. void _update_shortcut_events(const String &p_path, const Array &p_events);
  78. Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
  79. bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
  80. void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
  81. void _tabs_tab_changed(int p_tab);
  82. void _focus_current_search_box();
  83. void _filter_shortcuts(const String &p_filter);
  84. void _update_shortcuts();
  85. void _shortcut_button_pressed(Object *p_item, int p_column, int p_idx);
  86. void _shortcut_cell_double_clicked();
  87. void _builtin_action_popup_index_pressed(int p_index);
  88. static void _undo_redo_callback(void *p_self, const String &p_name);
  89. Label *restart_label = nullptr;
  90. TextureRect *restart_icon = nullptr;
  91. PanelContainer *restart_container = nullptr;
  92. Button *restart_close_button = nullptr;
  93. void _editor_restart_request();
  94. void _editor_restart();
  95. void _editor_restart_close();
  96. protected:
  97. static void _bind_methods();
  98. public:
  99. void popup_edit_settings();
  100. EditorSettingsDialog();
  101. ~EditorSettingsDialog();
  102. };
  103. #endif // EDITOR_SETTINGS_DIALOG_H