summaryrefslogtreecommitdiffstats
path: root/editor
diff options
context:
space:
mode:
authorEric M <itsjusteza@gmail.com>2021-08-06 16:30:15 +1000
committerEric M <itsjusteza@gmail.com>2021-09-21 22:25:31 +1000
commit28b7c1be805872fb6b149b9b6b1f496ed234b465 (patch)
treed0ae69e8cb51cc797f56e033c8695ed74a206491 /editor
parent82c12060b26d0045a5c7d9b3a1f94b29baf062ea (diff)
downloadredot-engine-28b7c1be805872fb6b149b9b6b1f496ed234b465.tar.gz
Improve implementation of builtin action overrides
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_settings.cpp16
-rw-r--r--editor/settings_config_dialog.cpp4
2 files changed, 14 insertions, 6 deletions
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index a255847a56..cab7b8ffeb 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -1409,7 +1409,7 @@ Ref<Shortcut> EditorSettings::get_shortcut(const String &p_name) const {
// If there was no override, check the default builtins to see if it has an InputEvent for the provided name.
if (sc.is_null()) {
- const OrderedHashMap<String, List<Ref<InputEvent>>>::ConstElement builtin_default = InputMap::get_singleton()->get_builtins().find(p_name);
+ const OrderedHashMap<String, List<Ref<InputEvent>>>::ConstElement builtin_default = InputMap::get_singleton()->get_builtins_with_feature_overrides_applied().find(p_name);
if (builtin_default) {
sc.instantiate();
sc->set_event(builtin_default.get().front()->get());
@@ -1502,15 +1502,23 @@ void EditorSettings::set_builtin_action_override(const String &p_name, const Arr
// Check if the provided event array is same as built-in. If it is, it does not need to be added to the overrides.
// Note that event order must also be the same.
bool same_as_builtin = true;
- OrderedHashMap<String, List<Ref<InputEvent>>>::ConstElement builtin_default = InputMap::get_singleton()->get_builtins().find(p_name);
+ OrderedHashMap<String, List<Ref<InputEvent>>>::ConstElement builtin_default = InputMap::get_singleton()->get_builtins_with_feature_overrides_applied().find(p_name);
if (builtin_default) {
List<Ref<InputEvent>> builtin_events = builtin_default.get();
- if (p_events.size() == builtin_events.size()) {
+ // In the editor we only care about key events.
+ List<Ref<InputEventKey>> builtin_key_events;
+ for (Ref<InputEventKey> iek : builtin_events) {
+ if (iek.is_valid()) {
+ builtin_key_events.push_back(iek);
+ }
+ }
+
+ if (p_events.size() == builtin_key_events.size()) {
int event_idx = 0;
// Check equality of each event.
- for (const Ref<InputEvent> &E : builtin_events) {
+ for (const Ref<InputEventKey> &E : builtin_key_events) {
if (!E->is_match(p_events[event_idx])) {
same_as_builtin = false;
break;
diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp
index 649caf5373..f024589ef1 100644
--- a/editor/settings_config_dialog.cpp
+++ b/editor/settings_config_dialog.cpp
@@ -268,7 +268,7 @@ void EditorSettingsDialog::_update_shortcuts() {
Array events; // Need to get the list of events into an array so it can be set as metadata on the item.
Vector<String> event_strings;
- List<Ref<InputEvent>> all_default_events = InputMap::get_singleton()->get_builtins().find(action_name).value();
+ List<Ref<InputEvent>> all_default_events = InputMap::get_singleton()->get_builtins_with_feature_overrides_applied().find(action_name).value();
List<Ref<InputEventKey>> key_default_events;
// Remove all non-key events from the defaults. Only check keys, since we are in the editor.
for (List<Ref<InputEvent>>::Element *I = all_default_events.front(); I; I = I->next()) {
@@ -404,7 +404,7 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column
switch (button_idx) {
case SHORTCUT_REVERT: {
Array events;
- List<Ref<InputEvent>> defaults = InputMap::get_singleton()->get_builtins()[current_action];
+ List<Ref<InputEvent>> defaults = InputMap::get_singleton()->get_builtins_with_feature_overrides_applied()[current_action];
// Convert the list to an array, and only keep key events as this is for the editor.
for (const Ref<InputEvent> &k : defaults) {