mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 06:44:27 +00:00
(RMenu/Filebrowser) Refactor filebrowser
This commit is contained in:
parent
af10f3f5bc
commit
c5f5249e2a
@ -129,12 +129,6 @@ bool filebrowser_iterate(void *data, unsigned action)
|
|||||||
case FILEBROWSER_ACTION_RESET:
|
case FILEBROWSER_ACTION_RESET:
|
||||||
ret = directory_parse(filebrowser, filebrowser->current_dir.root_dir);
|
ret = directory_parse(filebrowser, filebrowser->current_dir.root_dir);
|
||||||
break;
|
break;
|
||||||
case FILEBROWSER_ACTION_RESET_CURRENT_DIR:
|
|
||||||
ret = directory_parse(filebrowser, filebrowser->current_dir.directory_path);
|
|
||||||
break;
|
|
||||||
case FILEBROWSER_ACTION_PATH_ISDIR:
|
|
||||||
ret = filebrowser->list->elems[filebrowser->current_dir.ptr].attr.b;
|
|
||||||
break;
|
|
||||||
case FILEBROWSER_ACTION_NOOP:
|
case FILEBROWSER_ACTION_NOOP:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -147,6 +141,18 @@ bool filebrowser_iterate(void *data, unsigned action)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool filebrowser_is_current_entry_dir(void *data)
|
||||||
|
{
|
||||||
|
filebrowser_t *filebrowser = (filebrowser_t*)data;
|
||||||
|
return filebrowser->list->elems[filebrowser->current_dir.ptr].attr.b;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool filebrowser_reset_current_dir(void *data)
|
||||||
|
{
|
||||||
|
filebrowser_t *filebrowser = (filebrowser_t*)data;
|
||||||
|
return directory_parse(filebrowser, filebrowser->current_dir.directory_path);
|
||||||
|
}
|
||||||
|
|
||||||
void filebrowser_update(void *data, uint64_t action_ori, const char *extensions)
|
void filebrowser_update(void *data, uint64_t action_ori, const char *extensions)
|
||||||
{
|
{
|
||||||
filebrowser_action_t action = FILEBROWSER_ACTION_NOOP;
|
filebrowser_action_t action = FILEBROWSER_ACTION_NOOP;
|
||||||
|
@ -46,8 +46,6 @@ typedef enum
|
|||||||
FILEBROWSER_ACTION_SCROLL_UP,
|
FILEBROWSER_ACTION_SCROLL_UP,
|
||||||
FILEBROWSER_ACTION_SCROLL_DOWN,
|
FILEBROWSER_ACTION_SCROLL_DOWN,
|
||||||
FILEBROWSER_ACTION_RESET,
|
FILEBROWSER_ACTION_RESET,
|
||||||
FILEBROWSER_ACTION_RESET_CURRENT_DIR,
|
|
||||||
FILEBROWSER_ACTION_PATH_ISDIR,
|
|
||||||
FILEBROWSER_ACTION_NOOP
|
FILEBROWSER_ACTION_NOOP
|
||||||
} filebrowser_action_t;
|
} filebrowser_action_t;
|
||||||
|
|
||||||
@ -55,5 +53,7 @@ void filebrowser_update(void *data, uint64_t input, const char *extensions);
|
|||||||
void filebrowser_set_root_and_ext(void *data, const char *ext, const char *root_dir);
|
void filebrowser_set_root_and_ext(void *data, const char *ext, const char *root_dir);
|
||||||
bool filebrowser_iterate(void *data, unsigned action);
|
bool filebrowser_iterate(void *data, unsigned action);
|
||||||
void filebrowser_free(void *data);
|
void filebrowser_free(void *data);
|
||||||
|
bool filebrowser_is_current_entry_dir(void *data);
|
||||||
|
bool filebrowser_reset_current_dir(void *data);
|
||||||
|
|
||||||
#endif /* FILEBROWSER_H_ */
|
#endif /* FILEBROWSER_H_ */
|
||||||
|
@ -168,7 +168,7 @@ static void menu_stack_pop(unsigned menu_type)
|
|||||||
if (rgui->browser->prev_dir.directory_path[0] != '\0')
|
if (rgui->browser->prev_dir.directory_path[0] != '\0')
|
||||||
{
|
{
|
||||||
memcpy(&rgui->browser->current_dir, &rgui->browser->prev_dir, sizeof(*(&rgui->browser->current_dir)));
|
memcpy(&rgui->browser->current_dir, &rgui->browser->prev_dir, sizeof(*(&rgui->browser->current_dir)));
|
||||||
filebrowser_iterate(rgui->browser, FILEBROWSER_ACTION_RESET_CURRENT_DIR);
|
filebrowser_reset_current_dir(rgui->browser);
|
||||||
rgui->browser->current_dir.ptr = rgui->browser->prev_dir.ptr;
|
rgui->browser->current_dir.ptr = rgui->browser->prev_dir.ptr;
|
||||||
strlcpy(rgui->browser->current_dir.path, rgui->browser->prev_dir.path,
|
strlcpy(rgui->browser->current_dir.path, rgui->browser->prev_dir.path,
|
||||||
sizeof(rgui->browser->current_dir.path));
|
sizeof(rgui->browser->current_dir.path));
|
||||||
@ -244,7 +244,7 @@ static int select_file(void *data, uint64_t action)
|
|||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case RGUI_ACTION_OK:
|
case RGUI_ACTION_OK:
|
||||||
if (filebrowser_iterate(rgui->browser, FILEBROWSER_ACTION_PATH_ISDIR))
|
if (filebrowser_is_current_entry_dir(rgui->browser))
|
||||||
{
|
{
|
||||||
if (!filebrowser_iterate(rgui->browser, FILEBROWSER_ACTION_OK))
|
if (!filebrowser_iterate(rgui->browser, FILEBROWSER_ACTION_OK))
|
||||||
{
|
{
|
||||||
@ -371,7 +371,7 @@ static int select_directory(void *data, uint64_t action)
|
|||||||
(void)path;
|
(void)path;
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
bool is_dir = filebrowser_iterate(rgui->browser, FILEBROWSER_ACTION_PATH_ISDIR);
|
bool is_dir = filebrowser_is_current_entry_dir(rgui->browser);
|
||||||
bool pop_menu_stack = false;
|
bool pop_menu_stack = false;
|
||||||
|
|
||||||
switch (action)
|
switch (action)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user