diff 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
line wrap: on
line diff
--- a/nuklear_ui/blastem_nuklear.c	Sat Nov 25 11:31:08 2017 -0800
+++ b/nuklear_ui/blastem_nuklear.c	Sat Nov 25 13:57:38 2017 -0800
@@ -28,7 +28,9 @@
 	static dir_entry *entries;
 	static size_t num_entries;
 	static uint32_t selected_entry;
-	get_initial_browse_path(&current_path);
+	if (!current_path) {
+		get_initial_browse_path(&current_path);
+	}
 	if (!entries) {
 		entries = get_dir_list(current_path, &num_entries);
 	}
@@ -53,15 +55,14 @@
 			current_view = previous_view;
 		}
 		if (nk_button_label(context, "Open")) {
-			char const *pieces[] = {current_path, PATH_SEP, entries[selected_entry].name};
+			char *full_path = path_append(current_path, entries[selected_entry].name);
 			if (entries[selected_entry].is_dir) {
-				char *old = current_path;
-				current_path = alloc_concat_m(3, pieces);
-				free(old);
+				free(current_path);
+				current_path = full_path;
 				free_dir_list(entries, num_entries);
 				entries = NULL;
 			} else {
-				current_system->next_rom =  alloc_concat_m(3, pieces);
+				current_system->next_rom = full_path;
 				current_system->request_exit(current_system);
 				current_view = view_play;
 			}