Skip to content

Commit

Permalink
Merge pull request #86280 from Calinou/editor-input-map-editor-action…
Browse files Browse the repository at this point in the history
…-edit-title

Add input action name to window title in input map editor
  • Loading branch information
YuriSizov committed Dec 18, 2023
2 parents 8d9c11b + 8e2f319 commit bf8dd73
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions editor/action_map_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<InputEvent>(), current_action_name);
} break;
case ActionMapEditor::BUTTON_EDIT_EVENT: {
// Action and Action name is located on the parent of the event.
Expand All @@ -179,7 +179,7 @@ void ActionMapEditor::_tree_button_pressed(Object *p_item, int p_column, int p_i

Ref<InputEvent> 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: {
Expand Down
9 changes: 7 additions & 2 deletions editor/input_event_configuration_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ void InputEventConfigurationDialog::_notification(int p_what) {
}
}

void InputEventConfigurationDialog::popup_and_configure(const Ref<InputEvent> &p_event) {
void InputEventConfigurationDialog::popup_and_configure(const Ref<InputEvent> &p_event, const String &p_current_action_name) {
if (p_event.is_valid()) {
_set_event(p_event->duplicate(), p_event);
} else {
Expand All @@ -596,6 +596,12 @@ void InputEventConfigurationDialog::popup_and_configure(const Ref<InputEvent> &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);
}

Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion editor/input_event_configuration_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ class InputEventConfigurationDialog : public ConfirmationDialog {

public:
// Pass an existing event to configure it. Alternatively, pass no event to start with a blank configuration.
void popup_and_configure(const Ref<InputEvent> &p_event = Ref<InputEvent>());
// An action name can be passed for descriptive purposes.
void popup_and_configure(const Ref<InputEvent> &p_event = Ref<InputEvent>(), const String &p_current_action_name = "");
Ref<InputEvent> get_event() const;

void set_allowed_input_types(int p_type_masks);
Expand Down

0 comments on commit bf8dd73

Please sign in to comment.