diff --git a/include/arm11/menu/menu.h b/include/arm11/menu/menu.h index cd37459..b1f8496 100644 --- a/include/arm11/menu/menu.h +++ b/include/arm11/menu/menu.h @@ -31,6 +31,8 @@ #define MENU_FLAG_SLOTS 1 #define MENU_FLAG_SLOT(x) (1<= 3) + // flags only concern descriptions right now + u32 slot = (flags & MENU_FLAG_SLOTS) ? index : + (flags & MENU_FLAG_SLOT(1)) ? 0 : + (flags & MENU_FLAG_SLOT(2)) ? 1 : + (flags & MENU_FLAG_SLOT(3)) ? 2 : (u32) -1; + + // boot mode description + if ((flags & MENU_FLAG_BOOTMODE) && (index == 3)) { + if (configDataExist(KBootMode)) + { + char* modestr = (char*) configCopyText(KBootMode); + if (!modestr) panicMsg("Config error"); + ee_snprintf(desc, 512, "%s:\n%s\n \ncurrent: %s", name_raw, desc_raw, modestr); + free (modestr); + } + else ee_snprintf(desc, 512, "%s:\n%s\n \ncurrent: - not set up -", name_raw, desc_raw); + stringWordWrap(desc, WORDWRAP_WIDTH); + return; + } + // using no slot description + else if (slot >= 3) + { + ee_snprintf(desc, 512, "%s:\n%s", name_raw, desc_raw); stringWordWrap(desc, WORDWRAP_WIDTH); return; @@ -93,18 +115,8 @@ return; // build description string - // also handle MENU_FLAG_SLOTS flag char desc_ww[512]; - u32 desc_slot = (u32) -1; - if (curr_menu->flags & 0xF) // includes all known flags - { - // flags only concern descriptions right now - desc_slot = (curr_menu->flags & MENU_FLAG_SLOTS) ? index : - (curr_menu->flags & MENU_FLAG_SLOT(1)) ? 0 : - (curr_menu->flags & MENU_FLAG_SLOT(2)) ? 1 : - (curr_menu->flags & MENU_FLAG_SLOT(3)) ? 2 : (u32) -1; - } - menuBuildDescString(desc_ww, desc_slot, name, desc); + menuBuildDescString(desc_ww, curr_menu->flags, index, name, desc); // get width, height int desc_width = stringGetWidth(desc_ww); @@ -157,9 +169,9 @@ bool is_selected = (i == index); consoleSetCursor(menu_con, menu_x, menu_y++); - if (is_selected) ee_printf("\x1b[47;30m"); + if (is_selected) ee_printf(ESC_FGCOLOR(0) ESC_BGCOLOR(7)); ee_printf("%.3s %-*.*s", ((menu_preset >> i) & 0x1) ? "[X]" : "[ ]", MENU_WIDTH-4, MENU_WIDTH-4, name); - ee_printf("\x1b[0m"); + ee_printf(ESC_RESET); } // button instructions diff --git a/source/arm11/menu/menu_fsel.c b/source/arm11/menu/menu_fsel.c index 56eae9c..3c81ec4 100644 --- a/source/arm11/menu/menu_fsel.c +++ b/source/arm11/menu/menu_fsel.c @@ -250,9 +250,8 @@ // browser title consoleSetCursor(menu_con, brws_x, brws_y++); - truncateString(temp_str, curr_path, BRWS_WIDTH, 8); - if (!*temp_str) strncpy(temp_str, "[root]", BRWS_WIDTH); - ee_printf(temp_str); + truncateString(temp_str, *curr_path ? curr_path : "root", BRWS_WIDTH, 8); + ee_printf("%-*s", BRWS_WIDTH, temp_str); brws_y++; // menu entries @@ -272,8 +271,9 @@ consoleSetCursor(menu_con, brws_x, brws_y++); truncateString(temp_str, entry->fname, BRWS_WIDTH-13, 8); - ee_printf(is_selected ? "\x1b[47;30m %-*.*s %10.10s \x1b[0m" : " %-*.*s %10.10s ", - BRWS_WIDTH-13, BRWS_WIDTH-13, temp_str, byte_str); + if (is_selected) if (is_selected) ee_printf(ESC_FGCOLOR(0) ESC_BGCOLOR(7)); + ee_printf(" %-*.*s %10.10s ", BRWS_WIDTH-13, BRWS_WIDTH-13, temp_str, byte_str); + ee_printf(ESC_RESET); } // button instructions diff --git a/source/arm11/menu/menu_func.c b/source/arm11/menu/menu_func.c index d34f599..bfb4a94 100644 --- a/source/arm11/menu/menu_func.c +++ b/source/arm11/menu/menu_func.c @@ -27,6 +27,7 @@ #include "arm11/hardware/hid.h" #include "arm11/console.h" #include "arm11/config.h" +#include "arm11/debug.h" #include "arm11/fmt.h" #include "arm11/firm.h" #include "arm11/main.h" @@ -43,7 +44,7 @@ return 0; } -u32 menuPresetBootSlot(void) +u32 menuPresetBootMenu(void) { u32 res = 0; @@ -58,6 +59,16 @@ return res; } +u32 menuPresetBootConfig(void) +{ + u32 res = 0; + + if (configDataExist(KBootMode)) + res |= 1 << 3; + + return res | menuPresetBootMenu(); +} + u32 menuSetBootMode(PrintConsole* con, u32 param) { (void) con; @@ -120,6 +131,7 @@ { char* currentSetting = (char*) configCopyText(KBootOption1Buttons + param); + if (!currentSetting) panicMsg("Config error"); ee_printf_line_center("Current: %s", currentSetting); free(currentSetting); }