From 8e2f3191e71eef54a958ee07d46b38e7ef263b25 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Sun, 17 Dec 2023 22:56:26 +0100 Subject: [PATCH] Add input action name to window title in input map editor --- editor/action_map_editor.cpp | 4 ++-- editor/input_event_configuration_dialog.cpp | 9 +++++++-- editor/input_event_configuration_dialog.h | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp index d47b315c407..ab923f99fe8 100644 --- a/editor/action_map_editor.cpp +++ b/editor/action_map_editor.cpp @@ -168,7 +168,7 @@ void ActionMapEditor::_tree_button_pressed(Object *p_item, int p_column, int p_i current_action_name = item->get_meta("__name"); current_action_event_index = -1; - event_config_dialog->popup_and_configure(); + event_config_dialog->popup_and_configure(Ref(), current_action_name); } break; case ActionMapEditor::BUTTON_EDIT_EVENT: { // Action and Action name is located on the parent of the event. @@ -179,7 +179,7 @@ void ActionMapEditor::_tree_button_pressed(Object *p_item, int p_column, int p_i Ref ie = item->get_meta("__event"); if (ie.is_valid()) { - event_config_dialog->popup_and_configure(ie); + event_config_dialog->popup_and_configure(ie, current_action_name); } } break; case ActionMapEditor::BUTTON_REMOVE_ACTION: { diff --git a/editor/input_event_configuration_dialog.cpp b/editor/input_event_configuration_dialog.cpp index a0d2662045d..db7922233e9 100644 --- a/editor/input_event_configuration_dialog.cpp +++ b/editor/input_event_configuration_dialog.cpp @@ -572,7 +572,7 @@ void InputEventConfigurationDialog::_notification(int p_what) { } } -void InputEventConfigurationDialog::popup_and_configure(const Ref &p_event) { +void InputEventConfigurationDialog::popup_and_configure(const Ref &p_event, const String &p_current_action_name) { if (p_event.is_valid()) { _set_event(p_event->duplicate(), p_event); } else { @@ -596,6 +596,12 @@ void InputEventConfigurationDialog::popup_and_configure(const Ref &p device_id_option->select(0); } + if (!p_current_action_name.is_empty()) { + set_title(vformat(TTR("Event Configuration for \"%s\""), p_current_action_name)); + } else { + set_title(TTR("Event Configuration")); + } + popup_centered(Size2(0, 400) * EDSCALE); } @@ -611,7 +617,6 @@ void InputEventConfigurationDialog::set_allowed_input_types(int p_type_masks) { InputEventConfigurationDialog::InputEventConfigurationDialog() { allowed_input_types = INPUT_KEY | INPUT_MOUSE_BUTTON | INPUT_JOY_BUTTON | INPUT_JOY_MOTION; - set_title(TTR("Event Configuration")); set_min_size(Size2i(550, 0) * EDSCALE); VBoxContainer *main_vbox = memnew(VBoxContainer); diff --git a/editor/input_event_configuration_dialog.h b/editor/input_event_configuration_dialog.h index e7ab0da4d68..bde0b73ade3 100644 --- a/editor/input_event_configuration_dialog.h +++ b/editor/input_event_configuration_dialog.h @@ -120,7 +120,8 @@ protected: public: // Pass an existing event to configure it. Alternatively, pass no event to start with a blank configuration. - void popup_and_configure(const Ref &p_event = Ref()); + // An action name can be passed for descriptive purposes. + void popup_and_configure(const Ref &p_event = Ref(), const String &p_current_action_name = ""); Ref get_event() const; void set_allowed_input_types(int p_type_masks);