X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=libpicofe.git;a=blobdiff_plain;f=menu.c;h=2e97f0640229ad96605564a76de20b1fb57871c4;hp=eb27ce6a41cf36b5af4129927508b36c0d074813;hb=ec90b021373a7f9dd02c593f656eddc2b36b5252;hpb=4db02226eb3c80f49f5c412f7718c437c5e817fc diff --git a/menu.c b/menu.c index eb27ce6..2e97f06 100644 --- a/menu.c +++ b/menu.c @@ -31,10 +31,10 @@ void *g_menuscreen_ptr; void *g_menubg_src_ptr; void *g_menubg_ptr; -#if !MSCREEN_SIZE_FIXED int g_menuscreen_w; int g_menuscreen_h; -#endif + +int g_autostateld_opt; static unsigned char *menu_font_data = NULL; static int menu_text_color = 0xfffe; // default to white @@ -898,10 +898,16 @@ static void draw_dirlist(char *curdir, struct dirent **namelist, snprintf(buff, sizeof(buff), "%s - select, %s - back", in_get_key_name(-1, -PBTN_MOK), in_get_key_name(-1, -PBTN_MBACK)); - smalltext_out16(x, g_menuscreen_h - me_sfont_h * 2 - 2, buff, 0xe78c); + smalltext_out16(x, g_menuscreen_h - me_sfont_h * 3 - 2, buff, 0xe78c); + snprintf(buff, sizeof(buff), g_menu_filter_off ? "%s - hide unknown files" : "%s - show all files", in_get_key_name(-1, -PBTN_MA3)); + smalltext_out16(x, g_menuscreen_h - me_sfont_h * 2 - 2, buff, 0xe78c); + + snprintf(buff, sizeof(buff), g_autostateld_opt ? + "%s - autoload save is ON" : "%s - autoload save is OFF", + in_get_key_name(-1, -PBTN_MA2)); smalltext_out16(x, g_menuscreen_h - me_sfont_h * 1 - 2, buff, 0xe78c); } @@ -953,9 +959,11 @@ static int dirent_seek_char(struct dirent **namelist, int len, int sel, char c) int i; sel++; - for (i = sel + 1; i != sel; i++) { + for (i = sel + 1; ; i++) { if (i >= len) i = 1; + if (i == sel) + break; if (tolower_simple(namelist[i]->d_name[0]) == c) break; @@ -983,12 +991,12 @@ static const char *menu_loop_romsel(char *curr_path, int len, // is this a dir or a full path? if (!plat_is_dir(curr_path)) { - char *p = curr_path + strlen(curr_path) - 1; - for (; p > curr_path && *p != '/'; p--) - ; - *p = 0; - curr_path_restore = p; - snprintf(sel_fname, sizeof(sel_fname), "%s", p + 1); + char *p = strrchr(curr_path, '/'); + if (p != NULL) { + *p = 0; + curr_path_restore = p; + snprintf(sel_fname, sizeof(sel_fname), "%s", p + 1); + } if (rom_fname_reload[0] == 0) show_help = 2; @@ -1051,19 +1059,19 @@ rescan: inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT | PBTN_L|PBTN_R|PBTN_MA2|PBTN_MA3|PBTN_MOK|PBTN_MBACK | PBTN_MENU|PBTN_CHAR, &cinp, 33); - if (inp & PBTN_UP ) { sel--; if (sel < 0) sel = n-2; } - if (inp & PBTN_DOWN) { sel++; if (sel > n-2) sel = 0; } - if (inp & PBTN_LEFT) { sel-=10; if (sel < 0) sel = 0; } - if (inp & PBTN_L) { sel-=24; if (sel < 0) sel = 0; } - if (inp & PBTN_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; } - if (inp & PBTN_R) { sel+=24; if (sel > n-2) sel = n-2; } - if (inp & PBTN_CHAR) sel = dirent_seek_char(namelist, n, sel, cinp); if (inp & PBTN_MA3) { g_menu_filter_off = !g_menu_filter_off; snprintf(sel_fname, sizeof(sel_fname), "%s", namelist[sel+1]->d_name); goto rescan; } + if (inp & PBTN_UP ) { sel--; if (sel < 0) sel = n-2; } + if (inp & PBTN_DOWN) { sel++; if (sel > n-2) sel = 0; } + if (inp & PBTN_LEFT) { sel-=10; if (sel < 0) sel = 0; } + if (inp & PBTN_L) { sel-=24; if (sel < 0) sel = 0; } + if (inp & PBTN_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; } + if (inp & PBTN_R) { sel+=24; if (sel > n-2) sel = n-2; } + if ((inp & PBTN_MOK) || (inp & (PBTN_MENU|PBTN_MA2)) == (PBTN_MENU|PBTN_MA2)) { again: @@ -1123,6 +1131,15 @@ rescan: } } } + else if (inp & PBTN_MA2) { + g_autostateld_opt = !g_autostateld_opt; + show_help = 3; + } + else if (inp & PBTN_CHAR) { + // must be last + sel = dirent_seek_char(namelist, n, sel, cinp); + } + if (inp & PBTN_MBACK) break;