diff options
| author | Rémi Verschelde <remi@verschelde.fr> | 2022-01-12 17:42:31 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-12 17:42:31 +0100 |
| commit | 2f3a6fb55dd5331f7c26a3a09434ca019479cb20 (patch) | |
| tree | 64a4c314b604bccedee2f3e8202b94e523f4dc7a /editor/action_map_editor.cpp | |
| parent | f927fee49a0df9fa8d502597a9349d0d5c5e5b4a (diff) | |
| parent | 5737e7dd2dac03e04d1c17cb1f4afedc956b48e2 (diff) | |
Merge pull request #56302 from madmiraal/fix-54698
Diffstat (limited to 'editor/action_map_editor.cpp')
| -rw-r--r-- | editor/action_map_editor.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp index eabe0a95e2..96d9ab1064 100644 --- a/editor/action_map_editor.cpp +++ b/editor/action_map_editor.cpp @@ -760,12 +760,26 @@ void ActionMapEditor::_add_action_pressed() { _add_action(add_edit->get_text()); } +bool ActionMapEditor::_has_action(const String &p_name) const { + for (const ActionInfo &action_info : actions_cache) { + if (p_name == action_info.name) { + return true; + } + } + return false; +} + void ActionMapEditor::_add_action(const String &p_name) { if (p_name.is_empty() || !_is_action_name_valid(p_name)) { show_message(TTR("Invalid action name. It cannot be empty nor contain '/', ':', '=', '\\' or '\"'")); return; } + if (_has_action(p_name)) { + show_message(vformat(TTR("An action with the name '%s' already exists."), p_name)); + return; + } + add_edit->clear(); emit_signal(SNAME("action_added"), p_name); } @@ -791,6 +805,12 @@ void ActionMapEditor::_action_edited() { return; } + if (_has_action(new_name)) { + ti->set_text(0, old_name); + show_message(vformat(TTR("An action with the name '%s' already exists."), new_name)); + return; + } + emit_signal(SNAME("action_renamed"), old_name, new_name); } else if (action_tree->get_selected_column() == 1) { // Deadzone Edited |