Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup of action map dialogs #97392

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/openxr/editor/openxr_select_action_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ void OpenXRSelectActionDialog::_on_select_action(const String p_action) {
void OpenXRSelectActionDialog::open() {
ERR_FAIL_COND(action_map.is_null());

// out with the old...
// Out with the old.
while (main_vb->get_child_count() > 0) {
memdelete(main_vb->get_child(0));
}

selected_action = "";
action_buttons.clear();

// In with the new.
Array action_sets = action_map->get_action_sets();
for (int i = 0; i < action_sets.size(); i++) {
Ref<OpenXRActionSet> action_set = action_sets[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,23 @@ void OpenXRSelectInteractionProfileDialog::_on_select_interaction_profile(const
void OpenXRSelectInteractionProfileDialog::open(PackedStringArray p_do_not_include) {
int available_count = 0;

// out with the old...
while (main_vb->get_child_count() > 0) {
memdelete(main_vb->get_child(0));
// Out with the old.
while (main_vb->get_child_count() > 1) {
memdelete(main_vb->get_child(1));
}

selected_interaction_profile = "";
ip_buttons.clear();

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

Expand All @@ -90,23 +91,16 @@ void OpenXRSelectInteractionProfileDialog::open(PackedStringArray p_do_not_inclu
}
}

if (available_count == 0) {
// give warning that we have all profiles selected

} else {
// TODO maybe if we only have one, auto select it?

popup_centered();
}
all_selected->set_visible(available_count == 0);
get_cancel_button()->set_visible(available_count > 0);
popup_centered();
}

void OpenXRSelectInteractionProfileDialog::ok_pressed() {
if (selected_interaction_profile == "") {
return;
if (selected_interaction_profile != "") {
emit_signal("interaction_profile_selected", selected_interaction_profile);
}

emit_signal("interaction_profile_selected", selected_interaction_profile);

hide();
}

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

main_vb = memnew(VBoxContainer);
// main_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
main_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
scroll->add_child(main_vb);

all_selected = memnew(Label);
all_selected->set_text(TTR("All interaction profiles have been added to the action map."));
main_vb->add_child(all_selected);
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class OpenXRSelectInteractionProfileDialog : public ConfirmationDialog {

VBoxContainer *main_vb = nullptr;
ScrollContainer *scroll = nullptr;
Label *all_selected = nullptr;

protected:
static void _bind_methods();
Expand Down
Loading