Share one selection menu; drop dead variant detection and TegraExplorer filter
The variant menu in main.c and the RAM / Hekate-AMS menus in install.c were three copies of the same input loop; install_menu_select() replaces them with identical behaviour (D-pad/Vol to move, A/Power to confirm, Vol+ and Vol- to abort, Capture for screenshots).
This commit is contained in:
1 parent
664216fa11
commit
5241cccbe9
6 files changed
+99
-278
No files matched your search
+6
-80
@@ -312,16 +312,10 @@ void ipl_main(void) {
|
||||
if (num_variants == 1) {
|
||||
pack_variant = variants_present[0];
|
||||
} else {
|
||||
// Initialize joycons for menu input
|
||||
jc_init_hw();
|
||||
while (btn_read() & BTN_POWER) { msleep(50); }
|
||||
|
||||
// Selection menu (TegraExplorer-style: draw once, then only redraw changed lines)
|
||||
int selected = 0;
|
||||
int prev_selected = 0;
|
||||
bool confirmed = false;
|
||||
|
||||
// Draw menu once and remember start position of variant lines
|
||||
const char *labels[3];
|
||||
for (int i = 0; i < num_variants; i++)
|
||||
labels[i] = get_variant_name(variants_present[i]);
|
||||
|
||||
gfx_clear_grey(0x1B);
|
||||
gfx_con_setpos(0, 0);
|
||||
print_header();
|
||||
@@ -329,77 +323,9 @@ void ipl_main(void) {
|
||||
gfx_printf("Mehrere OmniNX-Pakete gefunden.\n");
|
||||
gfx_printf("Waehle die zu installierende Variante:\n\n");
|
||||
set_color(COLOR_WHITE);
|
||||
u32 menu_x, menu_variant_start_y;
|
||||
gfx_con_getpos(&menu_x, &menu_variant_start_y);
|
||||
for (int i = 0; i < num_variants; i++) {
|
||||
if (i == selected) {
|
||||
set_color(COLOR_GREEN);
|
||||
gfx_printf(" > %s\n", get_variant_name(variants_present[i]));
|
||||
set_color(COLOR_WHITE);
|
||||
} else {
|
||||
gfx_printf(" %s\n", get_variant_name(variants_present[i]));
|
||||
}
|
||||
}
|
||||
gfx_printf("\n");
|
||||
set_color(COLOR_CYAN);
|
||||
gfx_printf("D-Pad / Vol+/-: Auswahl | A oder Power: Bestaetigen\n");
|
||||
gfx_printf("Vol+ und Vol- gleichzeitig: Abbrechen (Hekate)\n");
|
||||
set_color(COLOR_WHITE);
|
||||
|
||||
// Edge detection: only move on press (not while held)
|
||||
bool prev_up = false, prev_down = false;
|
||||
bool menu_aborted = false;
|
||||
|
||||
while (!confirmed && !menu_aborted) {
|
||||
// On selection change: redraw only the two affected lines (no full clear)
|
||||
if (selected != prev_selected) {
|
||||
gfx_con_setpos(menu_x, menu_variant_start_y + (u32)prev_selected * 16);
|
||||
set_color(COLOR_WHITE);
|
||||
gfx_printf(" %s\n", get_variant_name(variants_present[prev_selected]));
|
||||
gfx_con_setpos(menu_x, menu_variant_start_y + (u32)selected * 16);
|
||||
set_color(COLOR_GREEN);
|
||||
gfx_printf(" > %s\n", get_variant_name(variants_present[selected]));
|
||||
set_color(COLOR_WHITE);
|
||||
prev_selected = selected;
|
||||
}
|
||||
|
||||
jc_gamepad_rpt_t *jc = joycon_poll();
|
||||
u8 btn = btn_read();
|
||||
|
||||
if (jc && jc->cap)
|
||||
take_screenshot();
|
||||
|
||||
if (cancel_combo_pressed(btn)) {
|
||||
menu_aborted = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// D-pad or Vol+ / Vol- for selection (Vol+ = up, Vol- = down)
|
||||
bool cur_up = false, cur_down = false;
|
||||
if (jc) {
|
||||
cur_up = (jc->up != 0) && !jc->down;
|
||||
cur_down = (jc->down != 0) && !jc->up;
|
||||
}
|
||||
if (btn & BTN_VOL_UP) cur_up = true;
|
||||
if (btn & BTN_VOL_DOWN) cur_down = true;
|
||||
|
||||
if (cur_up && !prev_up)
|
||||
selected = (selected - 1 + num_variants) % num_variants;
|
||||
else if (cur_down && !prev_down)
|
||||
selected = (selected + 1) % num_variants;
|
||||
else if (jc && jc->a)
|
||||
confirmed = true;
|
||||
prev_up = cur_up;
|
||||
prev_down = cur_down;
|
||||
|
||||
if (btn & BTN_POWER) {
|
||||
confirmed = true;
|
||||
}
|
||||
|
||||
msleep(50);
|
||||
}
|
||||
|
||||
if (menu_aborted) {
|
||||
int selected = install_menu_select(labels, num_variants);
|
||||
if (selected < 0) {
|
||||
gfx_printf("\n");
|
||||
set_color(COLOR_YELLOW);
|
||||
gfx_printf("Abgebrochen. Starte Hekate...\n");
|
||||
|
||||
Reference in new issue
Block a user