From e118e4f3cb7e87e71853a4433caa559ebd7a7432 Mon Sep 17 00:00:00 2001 From: sorgelig Date: Mon, 11 May 2020 15:40:18 +0800 Subject: [PATCH] display 2 lines for long files. --- cfg.cpp | 2 ++ cfg.h | 1 + file_io.cpp | 7 ++++++- file_io.h | 1 + menu.cpp | 52 +++++++++++++++++++++++++++++++++++++++++++--------- menu.h | 2 +- osd.cpp | 2 ++ 7 files changed, 56 insertions(+), 11 deletions(-) diff --git a/cfg.cpp b/cfg.cpp index 55cce9a..5df4653 100644 --- a/cfg.cpp +++ b/cfg.cpp @@ -69,6 +69,7 @@ static const ini_var_t ini_vars[] = { "JAMMASD_VID", (void*)(&(cfg.jammasd_vid)), UINT16, 0, 0xFFFF }, { "JAMMASD_PID", (void*)(&(cfg.jammasd_pid)), UINT16, 0, 0xFFFF }, { "SNIPER_MODE", (void*)(&(cfg.sniper_mode)), UINT8, 0, 1 }, + { "BROWSE_EXPAND", (void*)(&(cfg.browse_expand)), UINT8, 0, 1 }, }; static const int nvars = (int)(sizeof(ini_vars) / sizeof(ini_var_t)); @@ -313,5 +314,6 @@ void cfg_parse() cfg.bootscreen = 1; cfg.fb_terminal = 1; cfg.controller_info = 6; + cfg.browse_expand = 1; ini_parse(altcfg()); } diff --git a/cfg.h b/cfg.h index 4e10716..16600ea 100644 --- a/cfg.h +++ b/cfg.h @@ -43,6 +43,7 @@ typedef struct { uint16_t jammasd_vid; uint16_t jammasd_pid; uint8_t sniper_mode; + uint8_t browse_expand; char bootcore[256]; char video_conf[1024]; char video_conf_pal[1024]; diff --git a/file_io.cpp b/file_io.cpp index 5caa779..f0974c4 100644 --- a/file_io.cpp +++ b/file_io.cpp @@ -1571,7 +1571,7 @@ int ScanDirectory(char* path, int mode, const char *extension, int options, cons } else if (mode == SCANF_NEXT_PAGE) { - if (iSelectedEntry < iFirstEntry + OsdGetSize() - 1) + if (iSelectedEntry < iFirstEntry + OsdGetSize() - 2) { iSelectedEntry = iFirstEntry + OsdGetSize() - 1; if (iSelectedEntry >= flist_nDirEntries()) iSelectedEntry = flist_nDirEntries() - 1; @@ -1672,6 +1672,11 @@ int flist_iFirstEntry() return iFirstEntry; } +void flist_iFirstEntryInc() +{ + iFirstEntry++; +} + int flist_iSelectedEntry() { return iSelectedEntry; diff --git a/file_io.h b/file_io.h index 70c171f..852249b 100644 --- a/file_io.h +++ b/file_io.h @@ -34,6 +34,7 @@ struct direntext_t int flist_nDirEntries(); int flist_iFirstEntry(); +void flist_iFirstEntryInc(); int flist_iSelectedEntry(); direntext_t* flist_DirItem(int n); direntext_t* flist_SelectedItem(); diff --git a/menu.cpp b/menu.cpp index ca1ce53..22022ab 100644 --- a/menu.cpp +++ b/menu.cpp @@ -884,6 +884,9 @@ void HandleUI(void) // get user control codes uint32_t c = menu_key_get(); + int release = 0; + if (c & UPSTROKE) release = 1; + // decode and set events menu = false; select = false; @@ -3594,7 +3597,7 @@ void HandleUI(void) case MENU_FILE_SELECT1: helptext = helptexts[HELPTEXT_NONE]; OsdSetTitle((fs_Options & SCANO_CORES) ? "Cores" : "Select", 0); - PrintDirectory(); + PrintDirectory(hold_cnt<2); menustate = MENU_FILE_SELECT2; break; @@ -3734,6 +3737,7 @@ void HandleUI(void) } } + if (release) PrintDirectory(1); break; /******************************************************************/ @@ -5156,26 +5160,42 @@ void ScrollLongName(void) } // print directory contents -void PrintDirectory(void) +void PrintDirectory(int expand) { - int k; - int len; - char s[40]; ScrollReset(); - for(int i = 0; i < OsdGetSize(); i++) + if (expand && cfg.browse_expand) + { + int k = flist_iFirstEntry() + OsdGetSize() - 1; + if (flist_nDirEntries() && k == flist_iSelectedEntry() && k <= flist_nDirEntries() && + strlen(flist_DirItem(k)->altname) > 28 && !flist_DirItem(k)->datecode[0] && flist_DirItem(k)->de.d_type != DT_DIR) + { + //make room for last expanded line + flist_iFirstEntryInc(); + } + } + + int i = 0; + int k = flist_iFirstEntry(); + while(i < OsdGetSize()) { char leftchar = 0; memset(s, ' ', 32); // clear line buffer s[32] = 0; + int len2 = 0; + leftchar = 0; + int len = 0; if (i < flist_nDirEntries()) { - k = flist_iFirstEntry() + i; len = strlen(flist_DirItem(k)->altname); // get name length if (len > 28) { + len2 = len - 27; + if (len2 > 27) len2 = 27; + if (!expand) len2 = 0; + len = 27; // trim display length if longer than 30 characters s[28] = 22; } @@ -5200,6 +5220,7 @@ void PrintDirectory(void) { strcpy(&s[22], " "); } + len2 = 0; } else if (!cfg.rbf_hide_datecode && datecode[0]) { @@ -5219,10 +5240,11 @@ void PrintDirectory(void) s[19] = 22; s[28] = ' '; } + len2 = 0; } if (!i && k) leftchar = 17; - if ((i == OsdGetSize() - 1) && (k < flist_nDirEntries() - 1)) leftchar = 16; + if (i && k < flist_nDirEntries() - 1) leftchar = 16; } else { @@ -5230,7 +5252,19 @@ void PrintDirectory(void) strcpy(s, " No files!"); } - OsdWriteOffset(i, s, i == (flist_iSelectedEntry() - flist_iFirstEntry()), 0, 0, leftchar); + int sel = (i == (flist_iSelectedEntry() - flist_iFirstEntry())); + OsdWriteOffset(i, s, sel, 0, 0, leftchar); + i++; + + if (sel && len2) + { + len = strlen(flist_DirItem(k)->altname); + strcpy(s+1, flist_DirItem(k)->altname + len - len2); + OsdWriteOffset(i, s, sel, 0, 0, leftchar); + i++; + } + + k++; } } diff --git a/menu.h b/menu.h index f4df6c1..4bb25f4 100644 --- a/menu.h +++ b/menu.h @@ -5,7 +5,7 @@ void HandleUI(void); void menu_key_set(unsigned int c); -void PrintDirectory(void); +void PrintDirectory(int expand = 0); void ScrollLongName(void); void ErrorMessage(const char *message, unsigned char code); diff --git a/osd.cpp b/osd.cpp index 8111fa9..b1589f2 100644 --- a/osd.cpp +++ b/osd.cpp @@ -255,6 +255,8 @@ void OsdWriteOffset(unsigned char n, const char *s, unsigned char invert, unsign if (n == (osd_size-1) && (arrow & OSD_ARROW_RIGHT)) linelimit -= 22; + if (n && n < OsdGetSize() - 1) leftchar = 0; + if (stipple) { stipplemask = 0x55; stipple = 0xff;