From d9eea627fb916c099e908a9178acd5093e97bfef Mon Sep 17 00:00:00 2001 From: neonloop Date: Tue, 10 Aug 2021 00:45:20 +0000 Subject: Hides state menus if states are unsupported --- core.c | 4 ++++ core.h | 1 + main.c | 4 ++-- menu.c | 9 +++++++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/core.c b/core.c index d669b64..bb37aa8 100644 --- a/core.c +++ b/core.c @@ -110,6 +110,10 @@ void sram_read(void) { fclose(sram_file); } +bool state_allowed(void) { + return current_core.retro_serialize_size() > 0; +} + void state_file_name(char *name, size_t size, int slot) { char extension[5] = {0}; diff --git a/core.h b/core.h index 67f46c9..bd4ded9 100644 --- a/core.h +++ b/core.h @@ -41,6 +41,7 @@ void config_file_name(char *buf, size_t len, int is_game); void sram_read(void); void sram_write(void); +bool state_allowed(void); void state_file_name(char *name, size_t size, int slot); int state_read(void); int state_write(void); diff --git a/main.c b/main.c index 5fabd58..d399f7a 100644 --- a/main.c +++ b/main.c @@ -207,7 +207,7 @@ void handle_emu_action(emu_action action) if (mmenu) { ShowMenu_t ShowMenu = (ShowMenu_t)dlsym(mmenu, "ShowMenu"); SDL_Surface *screen = SDL_GetVideoSurface(); - MenuReturnStatus status = ShowMenu(content_path, save_template_path, screen, kMenuEventKeyDown); + MenuReturnStatus status = ShowMenu(content_path, state_allowed() ? save_template_path : NULL, screen, kMenuEventKeyDown); if (status==kStatusExitGame) { should_quit = 1; @@ -384,7 +384,7 @@ int main(int argc, char **argv) { if (ResumeSlot) resume_slot = ResumeSlot(); } - if (resume_slot!=-1) { + if (state_allowed() && resume_slot!=-1) { state_slot = resume_slot; state_read(); resume_slot = -1; diff --git a/menu.c b/menu.c index ed10687..e691f16 100644 --- a/menu.c +++ b/menu.c @@ -392,9 +392,14 @@ void menu_loop(void) me_enable(e_menu_main, MA_MAIN_CORE_OPTS, core_options.visible_len > 0); + me_enable(e_menu_main, MA_MAIN_SAVE_STATE, state_allowed()); + me_enable(e_menu_main, MA_MAIN_LOAD_STATE, state_allowed()); + #ifdef MMENU - me_enable(e_menu_main, MA_MAIN_SAVE_STATE, mmenu == NULL); - me_enable(e_menu_main, MA_MAIN_LOAD_STATE, mmenu == NULL); + if (state_allowed()) { + me_enable(e_menu_main, MA_MAIN_SAVE_STATE, mmenu == NULL); + me_enable(e_menu_main, MA_MAIN_LOAD_STATE, mmenu == NULL); + } #endif memcpy(g_menubg_ptr, g_menuscreen_ptr, g_menuscreen_h * g_menuscreen_pp * sizeof(uint16_t)); -- cgit v1.2.3