Skip to content

Commit 5d5cdc0

Browse files
committed
Merge pull request #97392 from BastiaanOlij/xr_cleanup_action_map_dialogs
Cleanup of action map dialogs
2 parents 4c5e879 + 660ba05 commit 5d5cdc0

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

modules/openxr/editor/openxr_select_action_dialog.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,15 @@ void OpenXRSelectActionDialog::_on_select_action(const String p_action) {
6666
void OpenXRSelectActionDialog::open() {
6767
ERR_FAIL_COND(action_map.is_null());
6868

69-
// out with the old...
69+
// Out with the old.
7070
while (main_vb->get_child_count() > 0) {
7171
memdelete(main_vb->get_child(0));
7272
}
7373

7474
selected_action = "";
7575
action_buttons.clear();
7676

77+
// In with the new.
7778
Array action_sets = action_map->get_action_sets();
7879
for (int i = 0; i < action_sets.size(); i++) {
7980
Ref<OpenXRActionSet> action_set = action_sets[i];

modules/openxr/editor/openxr_select_interaction_profile_dialog.cpp

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,23 @@ void OpenXRSelectInteractionProfileDialog::_on_select_interaction_profile(const
6666
void OpenXRSelectInteractionProfileDialog::open(PackedStringArray p_do_not_include) {
6767
int available_count = 0;
6868

69-
// out with the old...
70-
while (main_vb->get_child_count() > 0) {
71-
memdelete(main_vb->get_child(0));
69+
// Out with the old.
70+
while (main_vb->get_child_count() > 1) {
71+
memdelete(main_vb->get_child(1));
7272
}
7373

7474
selected_interaction_profile = "";
7575
ip_buttons.clear();
7676

77-
// in with the new
77+
// In with the new.
7878
PackedStringArray interaction_profiles = OpenXRInteractionProfileMetadata::get_singleton()->get_interaction_profile_paths();
7979
for (int i = 0; i < interaction_profiles.size(); i++) {
8080
const String &path = interaction_profiles[i];
8181
if (!p_do_not_include.has(path)) {
8282
Button *ip_button = memnew(Button);
8383
ip_button->set_flat(true);
8484
ip_button->set_text(OpenXRInteractionProfileMetadata::get_singleton()->get_profile(path)->display_name);
85+
ip_button->set_text_alignment(HORIZONTAL_ALIGNMENT_LEFT);
8586
ip_button->connect(SceneStringName(pressed), callable_mp(this, &OpenXRSelectInteractionProfileDialog::_on_select_interaction_profile).bind(path));
8687
main_vb->add_child(ip_button);
8788

@@ -90,23 +91,16 @@ void OpenXRSelectInteractionProfileDialog::open(PackedStringArray p_do_not_inclu
9091
}
9192
}
9293

93-
if (available_count == 0) {
94-
// give warning that we have all profiles selected
95-
96-
} else {
97-
// TODO maybe if we only have one, auto select it?
98-
99-
popup_centered();
100-
}
94+
all_selected->set_visible(available_count == 0);
95+
get_cancel_button()->set_visible(available_count > 0);
96+
popup_centered();
10197
}
10298

10399
void OpenXRSelectInteractionProfileDialog::ok_pressed() {
104-
if (selected_interaction_profile == "") {
105-
return;
100+
if (selected_interaction_profile != "") {
101+
emit_signal("interaction_profile_selected", selected_interaction_profile);
106102
}
107103

108-
emit_signal("interaction_profile_selected", selected_interaction_profile);
109-
110104
hide();
111105
}
112106

@@ -118,6 +112,10 @@ OpenXRSelectInteractionProfileDialog::OpenXRSelectInteractionProfileDialog() {
118112
add_child(scroll);
119113

120114
main_vb = memnew(VBoxContainer);
121-
// main_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
115+
main_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
122116
scroll->add_child(main_vb);
117+
118+
all_selected = memnew(Label);
119+
all_selected->set_text(TTR("All interaction profiles have been added to the action map."));
120+
main_vb->add_child(all_selected);
123121
}

modules/openxr/editor/openxr_select_interaction_profile_dialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class OpenXRSelectInteractionProfileDialog : public ConfirmationDialog {
5151

5252
VBoxContainer *main_vb = nullptr;
5353
ScrollContainer *scroll = nullptr;
54+
Label *all_selected = nullptr;
5455

5556
protected:
5657
static void _bind_methods();

0 commit comments

Comments
 (0)