mirror of
https://github.com/RaySollium99/libpicofe.git
synced 2025-09-04 22:47:44 -04:00
fix list seeking, add autoload option
This commit is contained in:
parent
7ceadd9993
commit
9089665ca1
3 changed files with 31 additions and 9 deletions
5
input.c
5
input.c
|
@ -428,6 +428,7 @@ finish:
|
|||
int in_menu_wait_any(char *charcode, int timeout_ms)
|
||||
{
|
||||
int keys_old = menu_key_state;
|
||||
int ret;
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
@ -443,7 +444,9 @@ int in_menu_wait_any(char *charcode, int timeout_ms)
|
|||
}
|
||||
}
|
||||
|
||||
return menu_key_state;
|
||||
ret = menu_key_state;
|
||||
menu_key_state &= ~PBTN_CHAR;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* wait for menu input, do autorepeat */
|
||||
|
|
33
menu.c
33
menu.c
|
@ -34,6 +34,8 @@ void *g_menubg_ptr;
|
|||
int g_menuscreen_w;
|
||||
int g_menuscreen_h;
|
||||
|
||||
int g_autostateld_opt;
|
||||
|
||||
static unsigned char *menu_font_data = NULL;
|
||||
static int menu_text_color = 0xfffe; // default to white
|
||||
static int menu_sel_color = -1; // disabled
|
||||
|
@ -896,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);
|
||||
}
|
||||
|
||||
|
@ -1049,19 +1057,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:
|
||||
|
@ -1121,6 +1129,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;
|
||||
|
||||
|
|
2
menu.h
2
menu.h
|
@ -118,6 +118,8 @@ extern void *g_menuscreen_ptr;
|
|||
extern int g_menuscreen_w;
|
||||
extern int g_menuscreen_h;
|
||||
|
||||
extern int g_autostateld_opt;
|
||||
|
||||
void menu_init_base(void);
|
||||
void menu_update_msg(const char *msg);
|
||||
void text_out16(int x, int y, const char *texto, ...);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue