summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2018-05-02 00:03:22 -0700
committerMichael Pavone <pavone@retrodev.com>2018-05-02 00:03:22 -0700
commit7b2501bbfa7caf11303621415aab98fa4c454968 (patch)
treefbd1ed76c046e4dbe15ead0e570a8193781a5039
parentc0e175f9d588f1aa5e0049a43d5e37199c2d1a60 (diff)
Fix drag and drop when using Nuklear UI
-rw-r--r--blastem.c37
-rw-r--r--blastem.h2
-rw-r--r--nuklear_ui/blastem_nuklear.c5
-rw-r--r--nuklear_ui/blastem_nuklear.h1
-rw-r--r--util.c14
-rw-r--r--util.h4
-rw-r--r--zip.c2
-rw-r--r--zip.h2
8 files changed, 39 insertions, 28 deletions
diff --git a/blastem.c b/blastem.c
index 48172b2..6005a04 100644
--- a/blastem.c
+++ b/blastem.c
@@ -99,7 +99,7 @@ int load_smd_rom(ROMFILE f, void **buffer)
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 @@ uint32_t load_rom_zip(char *filename, void **dst)
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 @@ void apply_updated_config(void)
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 @@ void lockon_media(char *lock_on_path)
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 --git a/blastem.h b/blastem.h
index 597d2c2..f33e3aa 100644
--- a/blastem.h
+++ b/blastem.h
@@ -17,7 +17,7 @@ extern char *save_filename;
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 --git a/nuklear_ui/blastem_nuklear.c b/nuklear_ui/blastem_nuklear.c
index 18669cf..3621718 100644
--- a/nuklear_ui/blastem_nuklear.c
+++ b/nuklear_ui/blastem_nuklear.c
@@ -1097,6 +1097,11 @@ void show_pause_menu(void)
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 --git a/nuklear_ui/blastem_nuklear.h b/nuklear_ui/blastem_nuklear.h
index c179b69..b962f19 100644
--- a/nuklear_ui/blastem_nuklear.h
+++ b/nuklear_ui/blastem_nuklear.h
@@ -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 --git a/util.c b/util.c
index 03f1007..91ee262 100644
--- a/util.c
+++ b/util.c
@@ -303,11 +303,11 @@ char is_absolute_path(char *path)
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 @@ uint8_t path_matches_extensions(char *path, char **ext_list, uint32_t num_exts)
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 --git a/util.h b/util.h
index aa42c8c..34144b5 100644
--- a/util.h
+++ b/util.h
@@ -43,13 +43,13 @@ char is_path_sep(char c);
//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 --git a/zip.c b/zip.c
index c978b60..5356c44 100644
--- a/zip.c
+++ b/zip.c
@@ -19,7 +19,7 @@ enum {
ZIP_DEFLATE = 8
};
-zip_file *zip_open(char *filename)
+zip_file *zip_open(const char *filename)
{
FILE *f = fopen(filename, "rb");
if (!f) {
diff --git a/zip.h b/zip.h
index 9e56084..c4ef371 100644
--- a/zip.h
+++ b/zip.h
@@ -18,7 +18,7 @@ typedef struct {
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);