Launcher: Make sure folders are always at the top of the list
Previously I was just hoping no file would start with '[' or lower, so that folders would naturally end on top. But now the lists support grouping, so that folders (or pinned items in the future) are always at the top.
This commit is contained in:
parent
376e45da32
commit
5cbca6a081
@ -3,6 +3,7 @@
|
||||
- Launcher: Added menu option to pre-compute all CRC32s (for cover art)
|
||||
- Launcher: Officially support name-based cover art (eg: `/covers/nes/game name.png`)
|
||||
- Launcher: Improved responsiveness when cover art/save preview is enabled
|
||||
- Launcher: Added network status/details in wifi dialog
|
||||
|
||||
|
||||
# Retro-Go 1.42 (2024-06-05)
|
||||
|
||||
@ -341,21 +341,22 @@ static void tab_refresh(tab_t *tab, const char *selected)
|
||||
if (file->folder != folder && strcmp(file->folder, folder) != 0)
|
||||
continue;
|
||||
|
||||
listbox_item_t *item = &tab->listbox.items[items_count++];
|
||||
|
||||
if (file->type == RETRO_TYPE_FOLDER)
|
||||
{
|
||||
listbox_item_t *item = &tab->listbox.items[items_count++];
|
||||
snprintf(item->text, sizeof(item->text), "[%.40s]", file->name);
|
||||
// snprintf(item->text, sizeof(item->text), "/[%.40s]/", file->name);
|
||||
item->group = 1;
|
||||
item->arg = file;
|
||||
}
|
||||
else
|
||||
else if (file->type == RETRO_TYPE_FILE)
|
||||
{
|
||||
listbox_item_t *item = &tab->listbox.items[items_count++];
|
||||
snprintf(item->text, sizeof(item->text), "%s", file->name);
|
||||
if ((ext = strrchr(item->text, '.')))
|
||||
*ext = 0;
|
||||
item->group = 2;
|
||||
item->arg = file;
|
||||
}
|
||||
|
||||
item->arg = file;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -236,35 +236,32 @@ listbox_item_t *gui_get_selected_item(tab_t *tab)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int list_comp_text_asc(const void *a, const void *b)
|
||||
static int list_comp_text_asc(const listbox_item_t *a, const listbox_item_t *b)
|
||||
{
|
||||
return strcasecmp(((listbox_item_t*)a)->text, ((listbox_item_t*)b)->text);
|
||||
return a->group == b->group ? strcasecmp(a->text, b->text) : ((int)a->group - b->group);
|
||||
}
|
||||
|
||||
static int list_comp_text_desc(const void *a, const void *b)
|
||||
static int list_comp_text_desc(const listbox_item_t *a, const listbox_item_t *b)
|
||||
{
|
||||
return strcasecmp(((listbox_item_t*)b)->text, ((listbox_item_t*)a)->text);
|
||||
return a->group == b->group ? strcasecmp(b->text, a->text) : ((int)a->group - b->group);
|
||||
}
|
||||
|
||||
static int list_comp_id_asc(const void *a, const void *b)
|
||||
static int list_comp_id_asc(const listbox_item_t *a, const listbox_item_t *b)
|
||||
{
|
||||
return ((listbox_item_t*)a)->order - ((listbox_item_t*)b)->order;
|
||||
return a->group == b->group ? ((int)a->order - b->order) : ((int)a->group - b->group);
|
||||
}
|
||||
|
||||
static int list_comp_id_desc(const void *a, const void *b)
|
||||
static int list_comp_id_desc(const listbox_item_t *a, const listbox_item_t *b)
|
||||
{
|
||||
return ((listbox_item_t*)b)->order - ((listbox_item_t*)a)->order;
|
||||
return a->group == b->group ? ((int)b->order - a->order) : ((int)a->group - b->group);
|
||||
}
|
||||
|
||||
void gui_sort_list(tab_t *tab)
|
||||
{
|
||||
void *comp[] = {&list_comp_id_asc, &list_comp_id_desc, &list_comp_text_asc, &list_comp_text_desc};
|
||||
int sort_mode = tab->listbox.sort_mode - 1;
|
||||
size_t sort_mode = tab->listbox.sort_mode - 1;
|
||||
|
||||
if (!tab->listbox.length)
|
||||
return;
|
||||
|
||||
if (sort_mode < 0 || sort_mode > 3)
|
||||
if (!tab->listbox.length || sort_mode > RG_COUNT(comp) - 1)
|
||||
return;
|
||||
|
||||
qsort((void*)tab->listbox.items, tab->listbox.length, sizeof(listbox_item_t), comp[sort_mode]);
|
||||
|
||||
@ -66,8 +66,8 @@ typedef struct {
|
||||
typedef struct {
|
||||
char text[92];
|
||||
int16_t order;
|
||||
uint8_t enabled;
|
||||
uint8_t unused;
|
||||
uint8_t group;
|
||||
uint8_t unused; // icon, enabled
|
||||
void *arg;
|
||||
} listbox_item_t;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user