1 | /**************************************************************************/ |
2 | /* editor_settings_dialog.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 | #ifndef EDITOR_SETTINGS_DIALOG_H |
32 | #define EDITOR_SETTINGS_DIALOG_H |
33 | |
34 | #include "editor/action_map_editor.h" |
35 | #include "editor/editor_inspector.h" |
36 | #include "editor/editor_sectioned_inspector.h" |
37 | #include "scene/gui/dialogs.h" |
38 | #include "scene/gui/panel_container.h" |
39 | #include "scene/gui/rich_text_label.h" |
40 | #include "scene/gui/tab_container.h" |
41 | #include "scene/gui/texture_rect.h" |
42 | |
43 | class EditorSettingsDialog : public AcceptDialog { |
44 | GDCLASS(EditorSettingsDialog, AcceptDialog); |
45 | |
46 | bool updating = false; |
47 | |
48 | TabContainer *tabs = nullptr; |
49 | Control *tab_general = nullptr; |
50 | Control *tab_shortcuts = nullptr; |
51 | |
52 | LineEdit *search_box = nullptr; |
53 | LineEdit *shortcut_search_box = nullptr; |
54 | EventListenerLineEdit *shortcut_search_by_event = nullptr; |
55 | SectionedInspector *inspector = nullptr; |
56 | |
57 | // Shortcuts |
58 | enum ShortcutButton { |
59 | SHORTCUT_ADD, |
60 | SHORTCUT_EDIT, |
61 | SHORTCUT_ERASE, |
62 | SHORTCUT_REVERT |
63 | }; |
64 | |
65 | Tree *shortcuts = nullptr; |
66 | |
67 | InputEventConfigurationDialog *shortcut_editor = nullptr; |
68 | |
69 | bool is_editing_action = false; |
70 | String current_edited_identifier; |
71 | Array current_events; |
72 | int current_event_index = -1; |
73 | |
74 | Timer *timer = nullptr; |
75 | |
76 | virtual void cancel_pressed() override; |
77 | virtual void ok_pressed() override; |
78 | |
79 | void _settings_changed(); |
80 | void _settings_property_edited(const String &p_name); |
81 | void _settings_save(); |
82 | |
83 | virtual void shortcut_input(const Ref<InputEvent> &p_event) override; |
84 | void _notification(int p_what); |
85 | void _update_icons(); |
86 | |
87 | void _event_config_confirmed(); |
88 | |
89 | 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); |
90 | Array _event_list_to_array_helper(const List<Ref<InputEvent>> &p_events); |
91 | void _update_builtin_action(const String &p_name, const Array &p_events); |
92 | void _update_shortcut_events(const String &p_path, const Array &p_events); |
93 | |
94 | Variant get_drag_data_fw(const Point2 &p_point, Control *p_from); |
95 | bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; |
96 | void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); |
97 | |
98 | void _tabs_tab_changed(int p_tab); |
99 | void _focus_current_search_box(); |
100 | |
101 | void _filter_shortcuts(const String &p_filter); |
102 | void _filter_shortcuts_by_event(const Ref<InputEvent> &p_event); |
103 | bool _should_display_shortcut(const String &p_name, const Array &p_events) const; |
104 | |
105 | void _update_shortcuts(); |
106 | void _shortcut_button_pressed(Object *p_item, int p_column, int p_idx, MouseButton p_button = MouseButton::LEFT); |
107 | void _shortcut_cell_double_clicked(); |
108 | |
109 | static void _undo_redo_callback(void *p_self, const String &p_name); |
110 | |
111 | Label *restart_label = nullptr; |
112 | TextureRect *restart_icon = nullptr; |
113 | PanelContainer *restart_container = nullptr; |
114 | Button *restart_close_button = nullptr; |
115 | |
116 | void _editor_restart_request(); |
117 | void _editor_restart(); |
118 | void _editor_restart_close(); |
119 | |
120 | protected: |
121 | static void _bind_methods(); |
122 | |
123 | public: |
124 | void (); |
125 | |
126 | EditorSettingsDialog(); |
127 | ~EditorSettingsDialog(); |
128 | }; |
129 | |
130 | #endif // EDITOR_SETTINGS_DIALOG_H |
131 | |