summaryrefslogtreecommitdiff
path: root/editor/settings_config_dialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/settings_config_dialog.cpp')
-rw-r--r--editor/settings_config_dialog.cpp40
1 files changed, 20 insertions, 20 deletions
diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp
index 3852c389c7..c2c99ed17f 100644
--- a/editor/settings_config_dialog.cpp
+++ b/editor/settings_config_dialog.cpp
@@ -139,6 +139,8 @@ void EditorSettingsDialog::_notification(int p_what) {
}
void EditorSettingsDialog::_unhandled_input(const Ref<InputEvent> &p_event) {
+ ERR_FAIL_COND(p_event.is_null());
+
const Ref<InputEventKey> k = p_event;
if (k.is_valid() && k->is_pressed()) {
@@ -233,8 +235,8 @@ void EditorSettingsDialog::_update_shortcuts() {
// Before clearing the tree, take note of which categories are collapsed so that this state can be maintained when the tree is repopulated.
Map<String, bool> collapsed;
- if (shortcuts->get_root() && shortcuts->get_root()->get_children()) {
- for (TreeItem *item = shortcuts->get_root()->get_children(); item; item = item->get_next()) {
+ if (shortcuts->get_root() && shortcuts->get_root()->get_first_child()) {
+ for (TreeItem *item = shortcuts->get_root()->get_first_child(); item; item = item->get_next()) {
collapsed[item->get_text(0)] = item->is_collapsed();
}
}
@@ -259,25 +261,22 @@ void EditorSettingsDialog::_update_shortcuts() {
for (OrderedHashMap<StringName, InputMap::Action>::Element E = action_map.front(); E; E = E.next()) {
String action_name = E.key();
- if (!shortcut_filter.is_subsequence_ofi(action_name)) {
- continue;
- }
-
InputMap::Action action = E.get();
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>> defaults = InputMap::get_singleton()->get_builtins().find(action_name).value();
- // Remove all non-key events from the defaults.
- for (List<Ref<InputEvent>>::Element *I = defaults.front(); I; I = I->next()) {
+ List<Ref<InputEvent>> all_default_events = InputMap::get_singleton()->get_builtins().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()) {
Ref<InputEventKey> k = I->get();
- if (k.is_null()) {
- I->erase();
+ if (k.is_valid()) {
+ key_default_events.push_back(k);
}
}
- bool same_as_defaults = defaults.size() == action.inputs.size(); // Initially this is set to just whether the arrays are equal. Later we check the events if needed.
+ bool same_as_defaults = key_default_events.size() == action.inputs.size(); // Initially this is set to just whether the arrays are equal. Later we check the events if needed.
int count = 0;
for (List<Ref<InputEvent>>::Element *I = action.inputs.front(); I; I = I->next()) {
@@ -286,12 +285,8 @@ void EditorSettingsDialog::_update_shortcuts() {
event_strings.push_back(I->get()->as_text());
// Only check if the events have been the same so far - once one fails, we don't need to check any more.
- if (same_as_defaults) {
- Ref<InputEventKey> k = defaults[count];
- // Only check keys, since we are in the editor.
- if (k.is_valid() && !defaults[count]->shortcut_match(I->get())) {
- same_as_defaults = false;
- }
+ if (same_as_defaults && !key_default_events[count]->is_match(I->get())) {
+ same_as_defaults = false;
}
count++;
}
@@ -299,6 +294,10 @@ void EditorSettingsDialog::_update_shortcuts() {
// Join the text of the events with a delimiter so they can all be displayed in one cell.
String events_display_string = event_strings.is_empty() ? "None" : String("; ").join(event_strings);
+ if (!shortcut_filter.is_subsequence_ofi(action_name) && (events_display_string == "None" || !shortcut_filter.is_subsequence_ofi(events_display_string))) {
+ continue;
+ }
+
TreeItem *item = shortcuts->create_item(common_section);
item->set_text(0, action_name);
item->set_text(1, events_display_string);
@@ -381,7 +380,7 @@ void EditorSettingsDialog::_update_shortcuts() {
// remove sections with no shortcuts
for (Map<String, TreeItem *>::Element *E = sections.front(); E; E = E->next()) {
TreeItem *section = E->get();
- if (section->get_children() == nullptr) {
+ if (section->get_first_child() == nullptr) {
root->remove_child(section);
}
}
@@ -391,9 +390,10 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!ti);
+ button_idx = p_idx;
+
if (ti->get_metadata(0) == "Common") {
// Editing a Built-in action, which can have multiple bindings.
- button_idx = p_idx;
editing_action = true;
current_action = ti->get_text(0);