# HG changeset patch # User Michael Pavone # Date 1525244602 25200 # Node ID 7121daaa48c293621ddf06bb0c46ae08c2a043bd # Parent ea7d5ced2415fd2047d98d8767c80a5db3b1342b Fix drag and drop when using Nuklear UI diff -r ea7d5ced2415 -r 7121daaa48c2 blastem.c --- a/blastem.c Tue May 01 23:55:48 2018 -0700 +++ b/blastem.c Wed May 02 00:03:22 2018 -0700 @@ -99,7 +99,7 @@ return readsize; } -uint32_t load_rom_zip(char *filename, void **dst) +uint32_t load_rom_zip(const char *filename, void **dst) { static const char *valid_exts[] = {"bin", "md", "gen", "sms", "rom"}; const uint32_t num_exts = sizeof(valid_exts)/sizeof(*valid_exts); @@ -132,7 +132,7 @@ return 0; } -uint32_t load_rom(char * filename, void **dst, system_type *stype) +uint32_t load_rom(const char * filename, void **dst, system_type *stype) { uint8_t header[10]; char *ext = path_extension(filename); @@ -284,22 +284,27 @@ static void on_drag_drop(const char *filename) { - if (current_system->next_rom) { - free(current_system->next_rom); - } - current_system->next_rom = strdup(filename); - current_system->request_exit(current_system); - if (menu_system && menu_system->type == SYSTEM_GENESIS) { - genesis_context *gen = (genesis_context *)menu_system; - if (gen->extra) { - menu_context *menu = gen->extra; - menu->external_game_load = 1; - } else { - puts("No extra"); + if (current_system) { + if (current_system->next_rom) { + free(current_system->next_rom); + } + current_system->next_rom = strdup(filename); + current_system->request_exit(current_system); + if (menu_system && menu_system->type == SYSTEM_GENESIS) { + genesis_context *gen = (genesis_context *)menu_system; + if (gen->extra) { + menu_context *menu = gen->extra; + menu->external_game_load = 1; + } } } else { - puts("no menu"); + init_system_with_media(filename, SYSTEM_UNKNOWN); } +#ifndef DISABLE_NUKLEAR + if (is_nuklear_active()) { + show_play_view(); + } +#endif } static system_media cart, lock_on; @@ -335,7 +340,7 @@ static uint32_t opts = 0; static uint8_t force_region = 0; -void init_system_with_media(char *path, system_type force_stype) +void init_system_with_media(const char *path, system_type force_stype) { if (game_system) { game_system->persist_save(game_system); diff -r ea7d5ced2415 -r 7121daaa48c2 blastem.h --- a/blastem.h Tue May 01 23:55:48 2018 -0700 +++ b/blastem.h Wed May 02 00:03:22 2018 -0700 @@ -17,7 +17,7 @@ extern uint8_t use_native_states; void reload_media(void); void lockon_media(char *lock_on_path); -void init_system_with_media(char *path, system_type force_stype); +void init_system_with_media(const char *path, system_type force_stype); void apply_updated_config(void); #endif //BLASTEM_H_ diff -r ea7d5ced2415 -r 7121daaa48c2 nuklear_ui/blastem_nuklear.c --- a/nuklear_ui/blastem_nuklear.c Tue May 01 23:55:48 2018 -0700 +++ b/nuklear_ui/blastem_nuklear.c Wed May 02 00:03:22 2018 -0700 @@ -1097,6 +1097,11 @@ current_system->request_exit(current_system); } +void show_play_view(void) +{ + current_view = view_play; +} + static uint8_t active; uint8_t is_nuklear_active(void) { diff -r ea7d5ced2415 -r 7121daaa48c2 nuklear_ui/blastem_nuklear.h --- a/nuklear_ui/blastem_nuklear.h Tue May 01 23:55:48 2018 -0700 +++ b/nuklear_ui/blastem_nuklear.h Wed May 02 00:03:22 2018 -0700 @@ -12,6 +12,7 @@ void blastem_nuklear_init(uint8_t file_loaded); void show_pause_menu(void); +void show_play_view(void); uint8_t is_nuklear_active(void); uint8_t is_nuklear_available(void); void ui_idle_loop(void); diff -r ea7d5ced2415 -r 7121daaa48c2 util.c --- a/util.c Tue May 01 23:55:48 2018 -0700 +++ b/util.c Wed May 02 00:03:22 2018 -0700 @@ -303,11 +303,11 @@ return is_path_sep(path[0]); } -char * basename_no_extension(char *path) +char * basename_no_extension(const char *path) { - char *lastdot = NULL; - char *lastslash = NULL; - char *cur; + const char *lastdot = NULL; + const char *lastslash = NULL; + const char *cur; for (cur = path; *cur; cur++) { if (*cur == '.') { @@ -365,10 +365,10 @@ return 0; } -char * path_dirname(char *path) +char * path_dirname(const char *path) { - char *lastslash = NULL; - char *cur; + const char *lastslash = NULL; + const char *cur; for (cur = path; *cur; cur++) { if (is_path_sep(*cur)) { diff -r ea7d5ced2415 -r 7121daaa48c2 util.h --- a/util.h Tue May 01 23:55:48 2018 -0700 +++ b/util.h Wed May 02 00:03:22 2018 -0700 @@ -43,13 +43,13 @@ //Determines whether a path is considered an absolute path on the current platform char is_absolute_path(char *path); //Returns the basename of a path with th extension (if any) stripped -char * basename_no_extension(char *path); +char * basename_no_extension(const char *path); //Returns the extension from a path or NULL if there is no extension char *path_extension(char const *path); //Returns true if the given path matches one of the extensions in the list uint8_t path_matches_extensions(char *path, char **ext_list, uint32_t num_exts); //Returns the directory portion of a path or NULL if there is no directory part -char *path_dirname(char *path); +char *path_dirname(const char *path); //Gets the smallest power of two that is >= a certain value, won't work for values > 0x80000000 uint32_t nearest_pow2(uint32_t val); //Should be called by main with the value of argv[0] for use by get_exe_dir diff -r ea7d5ced2415 -r 7121daaa48c2 zip.c --- a/zip.c Tue May 01 23:55:48 2018 -0700 +++ b/zip.c Wed May 02 00:03:22 2018 -0700 @@ -19,7 +19,7 @@ ZIP_DEFLATE = 8 }; -zip_file *zip_open(char *filename) +zip_file *zip_open(const char *filename) { FILE *f = fopen(filename, "rb"); if (!f) { diff -r ea7d5ced2415 -r 7121daaa48c2 zip.h --- a/zip.h Tue May 01 23:55:48 2018 -0700 +++ b/zip.h Wed May 02 00:03:22 2018 -0700 @@ -18,7 +18,7 @@ uint32_t num_entries; } zip_file; -zip_file *zip_open(char *filename); +zip_file *zip_open(const char *filename); uint8_t *zip_read(zip_file *f, uint32_t index, size_t *out_size); void zip_close(zip_file *f);