Mercurial > repos > blastem
comparison nuklear_ui/blastem_nuklear.c @ 1481:77a401044935 nuklear_ui
Fix directory navigation in ROM file chooser in Nuklear UI
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 25 Nov 2017 13:57:38 -0800 |
parents | da1dce39e846 |
children | 2d203bf73dbd |
comparison
equal
deleted
inserted
replaced
1480:8464a3f09b94 | 1481:77a401044935 |
---|---|
26 { | 26 { |
27 static char *current_path; | 27 static char *current_path; |
28 static dir_entry *entries; | 28 static dir_entry *entries; |
29 static size_t num_entries; | 29 static size_t num_entries; |
30 static uint32_t selected_entry; | 30 static uint32_t selected_entry; |
31 get_initial_browse_path(¤t_path); | 31 if (!current_path) { |
32 get_initial_browse_path(¤t_path); | |
33 } | |
32 if (!entries) { | 34 if (!entries) { |
33 entries = get_dir_list(current_path, &num_entries); | 35 entries = get_dir_list(current_path, &num_entries); |
34 } | 36 } |
35 uint32_t width = render_width(); | 37 uint32_t width = render_width(); |
36 uint32_t height = render_height(); | 38 uint32_t height = render_height(); |
51 nk_layout_row_static(context, 52, width > 600 ? 300 : width / 2, 2); | 53 nk_layout_row_static(context, 52, width > 600 ? 300 : width / 2, 2); |
52 if (nk_button_label(context, "Back")) { | 54 if (nk_button_label(context, "Back")) { |
53 current_view = previous_view; | 55 current_view = previous_view; |
54 } | 56 } |
55 if (nk_button_label(context, "Open")) { | 57 if (nk_button_label(context, "Open")) { |
56 char const *pieces[] = {current_path, PATH_SEP, entries[selected_entry].name}; | 58 char *full_path = path_append(current_path, entries[selected_entry].name); |
57 if (entries[selected_entry].is_dir) { | 59 if (entries[selected_entry].is_dir) { |
58 char *old = current_path; | 60 free(current_path); |
59 current_path = alloc_concat_m(3, pieces); | 61 current_path = full_path; |
60 free(old); | |
61 free_dir_list(entries, num_entries); | 62 free_dir_list(entries, num_entries); |
62 entries = NULL; | 63 entries = NULL; |
63 } else { | 64 } else { |
64 current_system->next_rom = alloc_concat_m(3, pieces); | 65 current_system->next_rom = full_path; |
65 current_system->request_exit(current_system); | 66 current_system->request_exit(current_system); |
66 current_view = view_play; | 67 current_view = view_play; |
67 } | 68 } |
68 } | 69 } |
69 nk_end(context); | 70 nk_end(context); |