From c9b253c58788376865cc8768ba342a67b4758bcf Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Sun, 26 Nov 2017 18:33:36 -0800 Subject: Filter file list in Nuklear UI --HG-- branch : nuklear_ui --- nuklear_ui/blastem_nuklear.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'nuklear_ui/blastem_nuklear.c') diff --git a/nuklear_ui/blastem_nuklear.c b/nuklear_ui/blastem_nuklear.c index 44861d9..850f70e 100644 --- a/nuklear_ui/blastem_nuklear.c +++ b/nuklear_ui/blastem_nuklear.c @@ -10,6 +10,7 @@ #include "../paths.h" #include "../saves.h" #include "../blastem.h" +#include "../config.h" static struct nk_context *context; @@ -28,6 +29,9 @@ void view_load(struct nk_context *context) static dir_entry *entries; static size_t num_entries; static uint32_t selected_entry; + static char **ext_list; + static uint32_t num_exts; + static uint8_t got_ext_list; if (!current_path) { get_initial_browse_path(¤t_path); } @@ -37,6 +41,10 @@ void view_load(struct nk_context *context) sort_dir_list(entries, num_entries); } } + if (!got_ext_list) { + ext_list = get_extension_list(config, &num_exts); + got_ext_list = 1; + } uint32_t width = render_width(); uint32_t height = render_height(); if (nk_begin(context, "Load ROM", nk_rect(0, 0, width, height), 0)) { @@ -45,6 +53,12 @@ void view_load(struct nk_context *context) nk_layout_row_static(context, 28, width-100, 1); for (uint32_t i = 0; i < num_entries; i++) { + if (entries[i].name[0] == '.' && entries[i].name[1] != '.') { + continue; + } + if (num_exts && !entries[i].is_dir && !path_matches_extensions(entries[i].name, ext_list, num_exts)) { + continue; + } int selected = i == selected_entry; nk_selectable_label(context, entries[i].name, NK_TEXT_ALIGN_LEFT, &selected); if (selected) { -- cgit v1.2.3