diff --git a/menu/drivers/nuklear/nk_wnd_file_picker.c b/menu/drivers/nuklear/nk_wnd_file_picker.c index ca4e58bbf5..fa9e8b4767 100644 --- a/menu/drivers/nuklear/nk_wnd_file_picker.c +++ b/menu/drivers/nuklear/nk_wnd_file_picker.c @@ -25,15 +25,17 @@ #include #include #include +#include #include "../../menu_driver.h" #include "../../menu_hash.h" #include "../../frontend/frontend_driver.h" static bool assets_loaded; +static char path[PATH_MAX_LENGTH]; -static file_list_t *drives; -static file_list_t *files; +static file_list_t *drives = NULL; +struct string_list *files = NULL; struct icon_list { struct nk_image disk; @@ -48,27 +50,32 @@ void load_icons(nk_menu_handle_t *nk) fill_pathname_join(buf, nk->assets_directory, "harddisk.png", sizeof(buf)); icons.disk = nk_common_image_load(buf); + fill_pathname_join(buf, nk->assets_directory, + "folder.png", sizeof(buf)); + icons.folder = nk_common_image_load(buf); + fill_pathname_join(buf, nk->assets_directory, + "file.png", sizeof(buf)); + icons.file = nk_common_image_load(buf); assets_loaded = true; } void nk_wnd_file_picker(nk_menu_handle_t *nk) { - unsigned i; - video_shader_ctx_t shader_info; struct nk_panel layout; struct nk_context *ctx = &nk->ctx; const int id = NK_WND_FILE_PICKER; settings_t *settings = config_get_ptr(); + int i = 0; + char buf[PATH_MAX_LENGTH]; + if (!drives) { drives = (file_list_t*)calloc(1, sizeof(file_list_t)); frontend_driver_parse_drive_list(drives); /* RARCH_LOG ("Drives: %s\n",drives->list[0].path); */ } - if (!files) - files = (file_list_t*)calloc(1, sizeof(file_list_t)); if (!assets_loaded) load_icons(nk); @@ -78,10 +85,35 @@ void nk_wnd_file_picker(nk_menu_handle_t *nk) NK_WINDOW_BORDER)) { nk_layout_row_dynamic(ctx, 30, 3); - for (int i = 0; i < drives->size; i++ ) + for (i = 0; i < drives->size; i++) { - nk_button_image_label(ctx, icons.disk, drives->list[i].path, NK_TEXT_CENTERED, NK_BUTTON_DEFAULT); + if(nk_button_image_label(ctx, icons.disk, drives->list[i].path, + NK_TEXT_CENTERED, NK_BUTTON_DEFAULT)) + { + fill_pathname_join(path, drives->list[i].path, + "", sizeof(path)); + /* RARCH_LOG("Current Path: %s\n", path); */ + files = dir_list_new(path, NULL, true, true); + } } + nk_layout_row_dynamic(ctx, 30, 1); + if (files) + for (i = 0; i < files->size; i++) + { + /* RARCH_LOG ("Drives: %s\n",files->elems[i].data); */ + if (nk_button_image_label(ctx, path_is_directory(files->elems[i].data) ? + icons.folder : icons.file, path_basename(files->elems[i].data), + NK_TEXT_RIGHT, NK_BUTTON_DEFAULT)) + { + fill_pathname_join(path, files->elems[i].data, + "", sizeof(path)); + if (path_is_directory (path)) + files = dir_list_new(path, NULL, true, true); + else + RARCH_LOG ("File: %s selected\n", path); + } + } + } /* save position and size to restore after context reset */ nk_wnd_set_state(nk, id, nk_window_get_position(ctx), nk_window_get_size(ctx));