Recently launched cores list.

This commit is contained in:
sorgelig
2020-01-04 07:31:40 +08:00
parent f58b497a58
commit 7d27132de9
2 changed files with 36 additions and 10 deletions

View File

@@ -1849,6 +1849,16 @@ void HandleUI(void)
};
}
if (recent && menusub == 0)
{
fs_Options = SCANO_CORES;
fs_MenuSelect = MENU_CORE_FILE_SELECTED1;
fs_MenuCancel = MENU_8BIT_SYSTEM1;
if (recent_init(-1)) menustate = MENU_RECENT1;
break;
}
if (select)
{
switch (menusub)
@@ -3435,7 +3445,7 @@ void HandleUI(void)
menustate = fs_MenuCancel;
}
if (recent && recent_init((fs_Options & SCANO_UMOUNT) ? ioctl_index + 500 : ioctl_index))
if (recent && recent_init((fs_Options & SCANO_CORES) ? -1 : (fs_Options & SCANO_UMOUNT) ? ioctl_index + 500 : ioctl_index))
{
menustate = MENU_RECENT1;
}
@@ -3527,6 +3537,13 @@ void HandleUI(void)
strcat(SelectedPath, "/");
}
strcpy(SelectedLabel, flist_SelectedItem()->altname);
if (fs_Options & SCANO_CORES)
{
int len = strlen(SelectedLabel);
if (SelectedLabel[len - 4] == '.') SelectedLabel[len - 4] = 0;
char *p = strstr(SelectedLabel, "_20");
if (p) *p = 0;
}
strcat(SelectedPath, name);
menustate = fs_MenuSelect;
}
@@ -3608,7 +3625,7 @@ void HandleUI(void)
/******************************************************************/
case MENU_RECENT1:
helptext = helptexts[HELPTEXT_NONE];
OsdSetTitle("Recent Files");
OsdSetTitle((fs_Options & SCANO_CORES) ? "Recent Cores" : "Recent Files");
recent_print();
menustate = MENU_RECENT2;
parentstate = menustate;
@@ -3620,6 +3637,7 @@ void HandleUI(void)
if (menu || recent)
{
menustate = fs_MenuCancel;
if (is_menu_core()) menustate = MENU_FILE_SELECT1;
break;
}
@@ -3655,8 +3673,9 @@ void HandleUI(void)
OsdWrite(OsdGetSize() / 2, " Clearing the recents", 0, 0);
OsdUpdate();
sleep(1);
recent_clear((fs_Options & SCANO_UMOUNT) ? ioctl_index + 500 : ioctl_index);
recent_clear((fs_Options & SCANO_CORES) ? -1 : (fs_Options & SCANO_UMOUNT) ? ioctl_index + 500 : ioctl_index);
menustate = fs_MenuCancel;
if (is_menu_core()) menustate = MENU_FILE_SELECT1;
break;
}
@@ -4744,6 +4763,7 @@ void HandleUI(void)
break;
case MENU_CORE_FILE_SELECTED1:
recent_update(SelectedDir, SelectedPath, SelectedLabel, -1);
menustate = MENU_NONE1;
strcpy(SelectedRBF, SelectedPath);
if (!getStorage(0)) // multiboot is only on SD card.

View File

@@ -37,14 +37,16 @@ static int recent_available()
static char* recent_create_config_name(int idx)
{
static char str[256];
sprintf(str, "%s_recent_%d.cfg", user_io_get_core_name(), idx);
sprintf(str, "cores_recent.cfg");
if (idx >= 0) sprintf(str, "%s_recent_%d.cfg", user_io_get_core_name(), idx);
return str;
}
static const char* recent_path(char* dir, char* name)
{
static char path[1024];
snprintf(path, sizeof(path), "%s/%s", dir, name);
if(strlen(dir)) snprintf(path, sizeof(path), "%s/%s", dir, name);
else snprintf(path, sizeof(path), "%s", name);
return path;
}
@@ -62,7 +64,7 @@ static void recent_load(int idx)
for (int i = 0; i < recent_available(); i++)
{
ena[i] = FileExists(recent_path(recents[i].dir, recents[i].name));
if (is_neogeo_core() && !ena[i]) ena[i] = PathIsDir(recent_path(recents[i].dir, recents[i].name));
if (idx >= 0 && is_neogeo_core() && !ena[i]) ena[i] = PathIsDir(recent_path(recents[i].dir, recents[i].name));
}
}
@@ -86,7 +88,7 @@ void recent_scan(int mode)
{
if (!recent_available()) return;
if (mode == SCANF_END)
if (mode == SCANF_END || (mode == SCANF_PREV && iSelectedEntry <= 0))
{
iSelectedEntry = recent_available() - 1;
iFirstEntry = iSelectedEntry - OsdGetSize() + 1;
@@ -99,6 +101,12 @@ void recent_scan(int mode)
iSelectedEntry++;
if (iSelectedEntry > iFirstEntry + OsdGetSize() - 1) iFirstEntry = iSelectedEntry - OsdGetSize() + 1;
}
else
{
// jump to first visible item
iFirstEntry = 0;
iSelectedEntry = 0;
}
}
else if (mode == SCANF_PREV)
{
@@ -225,9 +233,7 @@ int recent_select(char *dir, char *path, char *label)
if (strlen(recents[iSelectedEntry].name))
{
strcpy(dir, recents[iSelectedEntry].dir);
strcpy(path, dir);
strcat(path, "/");
strcat(path, recents[iSelectedEntry].name);
strcpy(path, recent_path(recents[iSelectedEntry].dir, recents[iSelectedEntry].name));
strcpy(label, recents[iSelectedEntry].label);
}