| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "editor/inspector/editor_inspector.h" |
| 34 |
#include "scene/gui/dialogs.h" |
| 35 |
|
| 36 |
class CheckButton; |
| 37 |
class EditorEventSearchBar; |
| 38 |
class EventListenerLineEdit; |
| 39 |
class InputEventConfigurationDialog; |
| 40 |
class PanelContainer; |
| 41 |
class SectionedInspector; |
| 42 |
class TabContainer; |
| 43 |
class TextureRect; |
| 44 |
class Tree; |
| 45 |
class TreeItem; |
| 46 |
|
| 47 |
class EditorSettingsDialog : public AcceptDialog { |
| 48 |
GDCLASS(EditorSettingsDialog, AcceptDialog); |
| 49 |
|
| 50 |
TabContainer *tabs = nullptr; |
| 51 |
Control *tab_general = nullptr; |
| 52 |
Control *tab_shortcuts = nullptr; |
| 53 |
|
| 54 |
LineEdit *search_box = nullptr; |
| 55 |
CheckButton *advanced_switch = nullptr; |
| 56 |
SectionedInspector *inspector = nullptr; |
| 57 |
EditorEventSearchBar *shortcut_search_bar = nullptr; |
| 58 |
|
| 59 |
|
| 60 |
enum ShortcutButton { |
| 61 |
SHORTCUT_ADD, |
| 62 |
SHORTCUT_EDIT, |
| 63 |
SHORTCUT_ERASE, |
| 64 |
SHORTCUT_REVERT |
| 65 |
}; |
| 66 |
|
| 67 |
Tree *shortcuts = nullptr; |
| 68 |
|
| 69 |
InputEventConfigurationDialog *shortcut_editor = nullptr; |
| 70 |
|
| 71 |
bool is_editing_action = false; |
| 72 |
String current_edited_identifier; |
| 73 |
Array current_events; |
| 74 |
int current_event_index = -1; |
| 75 |
|
| 76 |
Timer *timer = nullptr; |
| 77 |
|
| 78 |
virtual void cancel_pressed() override; |
| 79 |
virtual void ok_pressed() override; |
| 80 |
|
| 81 |
void _settings_changed(); |
| 82 |
void _settings_property_edited(); |
| 83 |
void _settings_save(); |
| 84 |
|
| 85 |
virtual void shortcut_input(const Ref<InputEvent> &p_event) override; |
| 86 |
void _notification(int p_what); |
| 87 |
void _update_icons(); |
| 88 |
|
| 89 |
void _event_config_confirmed(); |
| 90 |
bool _is_in_project_manager() const; |
| 91 |
|
| 92 |
TreeItem *_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); |
| 93 |
Array _event_list_to_array_helper(const List<Ref<InputEvent>> &p_events); |
| 94 |
void _update_builtin_action(const String &p_name, const Array &p_events); |
| 95 |
void _update_shortcut_events(const String &p_path, const Array &p_events); |
| 96 |
|
| 97 |
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from); |
| 98 |
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; |
| 99 |
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); |
| 100 |
|
| 101 |
void _tabs_tab_changed(int p_tab); |
| 102 |
void _focus_current_search_box(); |
| 103 |
|
| 104 |
void _advanced_toggled(bool p_button_pressed); |
| 105 |
|
| 106 |
void _update_dynamic_property_hints(); |
| 107 |
PropertyInfo _create_mouse_shortcut_property_info(const String &p_property_name, const String &p_shortcut_1_name, const String &p_shortcut_2_name); |
| 108 |
String _get_shortcut_button_string(const String &p_shortcut_name); |
| 109 |
|
| 110 |
bool _should_display_shortcut(const String &p_name, const Array &p_events, bool p_match_localized_name) const; |
| 111 |
|
| 112 |
void _update_shortcuts(); |
| 113 |
void _shortcut_button_pressed(Object *p_item, int p_column, int p_idx, MouseButton p_button = MouseButton::LEFT); |
| 114 |
void _shortcut_cell_double_clicked(); |
| 115 |
static void _set_shortcut_input(const String &p_name, Ref<InputEventKey> &p_event); |
| 116 |
|
| 117 |
static void _undo_redo_callback(void *p_self, const String &p_name); |
| 118 |
|
| 119 |
Label *restart_label = nullptr; |
| 120 |
TextureRect *restart_icon = nullptr; |
| 121 |
PanelContainer *restart_container = nullptr; |
| 122 |
Button *restart_close_button = nullptr; |
| 123 |
|
| 124 |
void _editor_restart_request(); |
| 125 |
void _editor_restart(); |
| 126 |
void _editor_restart_close(); |
| 127 |
|
| 128 |
protected: |
| 129 |
static void _bind_methods(); |
| 130 |
|
| 131 |
public: |
| 132 |
void popup_edit_settings(); |
| 133 |
static void update_navigation_preset(); |
| 134 |
|
| 135 |
EditorSettingsDialog(); |
| 136 |
}; |
| 137 |
|
| 138 |
class EditorSettingsPropertyWrapper : public EditorProperty { |
| 139 |
GDCLASS(EditorSettingsPropertyWrapper, EditorProperty); |
| 140 |
|
| 141 |
String property; |
| 142 |
PropertyHint hint; |
| 143 |
String hint_text; |
| 144 |
uint32_t usage; |
| 145 |
|
| 146 |
EditorProperty *editor_property = nullptr; |
| 147 |
|
| 148 |
HBoxContainer *override_container = nullptr; |
| 149 |
TextureRect *override_icon = nullptr; |
| 150 |
EditorProperty *override_editor_property = nullptr; |
| 151 |
Button *goto_button = nullptr; |
| 152 |
Button *remove_button = nullptr; |
| 153 |
|
| 154 |
void _setup_override_info(); |
| 155 |
void _update_override(); |
| 156 |
void _create_override(); |
| 157 |
void _remove_override(); |
| 158 |
|
| 159 |
protected: |
| 160 |
void _notification(int p_what); |
| 161 |
|
| 162 |
public: |
| 163 |
static inline Callable restart_request_callback; |
| 164 |
|
| 165 |
virtual void update_property() override; |
| 166 |
void setup(const String &p_property, EditorProperty *p_editor_property, PropertyHint p_hint, const String &p_hint_text, uint32_t p_usage); |
| 167 |
}; |
| 168 |
|
| 169 |
class EditorSettingsInspectorPlugin : public EditorInspectorPlugin { |
| 170 |
GDCLASS(EditorSettingsInspectorPlugin, EditorInspectorPlugin); |
| 171 |
|
| 172 |
Object *current_object = nullptr; |
| 173 |
|
| 174 |
public: |
| 175 |
SectionedInspector *inspector = nullptr; |
| 176 |
|
| 177 |
virtual bool can_handle(Object *p_object) override; |
| 178 |
virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide = false) override; |
| 179 |
}; |