From: notaz Date: Fri, 22 Aug 2025 21:12:31 +0000 (+0300) Subject: frontend: reuse menu logic for config changing plugins X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df21c2fa8164a98fa3d50d30983af15bf2e062d3;p=pcsx_rearmed.git frontend: reuse menu logic for config changing plugins notaz/pcsx_rearmed#388 --- diff --git a/frontend/main.c b/frontend/main.c index 43373161..debfb11b 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -636,7 +636,8 @@ int main(int argc, char *argv[]) "\t-cdfile FILE\tRuns a CD image file\n" "\t-cfg FILE\tLoads desired configuration file (default: ~/.pcsx/pcsx.cfg)\n" "\t-psxout\t\tEnable PSX output\n" - "\t-load STATENUM\tLoads savestate STATENUM (1-5)\n" + "\t-load STATENUM\tLoads savestate STATENUM (1-9)\n" + "\t-loadf FILE\tLoads savestate from FILE\n" "\t-h -help\tDisplay this message\n" "\tfile\t\tLoads a PSX EXE file\n")); return 0; @@ -695,15 +696,8 @@ int main(int argc, char *argv[]) if (Load(file) != -1) ready_to_go = 1; } else { - if (cdfile) { - if (LoadCdrom() == -1) { - ClosePlugins(); - SysPrintf(_("Could not load CD-ROM!\n")); - return -1; - } - emu_on_new_cd(!loadst); - ready_to_go = 1; - } + if (cdfile) + ready_to_go = menu_load_cd_image(cdfile) == 0; } if (loadst_f) { @@ -714,14 +708,12 @@ int main(int argc, char *argv[]) } if (ready_to_go) { - if (menu_load_config(1) != 0) - menu_load_config(0); menu_prepare_emu(); - // If a state has been specified, then load that - if (loadst) { + // If a state slot has been specified, then load that + if (cdfile && loadst) { int ret = emu_load_state(loadst - 1); - SysPrintf("%s state %d\n", + SysPrintf("%s state slot %d\n", ret ? "failed to load" : "loaded", loadst); } } diff --git a/frontend/menu.c b/frontend/menu.c index 1b6ed583..2de38318 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -2166,7 +2166,6 @@ static int run_exe(void) SysReset(); if (Load(fname) != 0) { menu_update_msg("exe load failed, bad file?"); - printf("meh\n"); return -1; } @@ -2242,20 +2241,9 @@ static int run_cd_image(const char *fname) return 0; } -static int romsel_run(void) +int menu_load_cd_image(const char *fname) { int prev_gpu, prev_spu; - const char *fname; - - fname = menu_loop_romsel(last_selected_fname, - sizeof(last_selected_fname), filter_exts, - optional_cdimg_filter); - if (fname == NULL) - return -1; - - printf("selected file: %s\n", fname); - - ndrc_clear_full(); if (run_cd_image(fname) != 0) return -1; @@ -2268,7 +2256,7 @@ static int romsel_run(void) // check for plugin changes, have to repeat // loading if game config changed plugins to reload them if (prev_gpu != gpu_plugsel || prev_spu != spu_plugsel) { - printf("plugin change detected, reloading plugins..\n"); + printf("plugin change detected, reloading plugins...\n"); if (run_cd_image(fname) != 0) return -1; } @@ -2278,6 +2266,23 @@ static int romsel_run(void) return 0; } +static int romsel_run(void) +{ + const char *fname; + + fname = menu_loop_romsel(last_selected_fname, + sizeof(last_selected_fname), filter_exts, + optional_cdimg_filter); + if (fname == NULL) + return -1; + + printf("selected file: %s\n", fname); + + ndrc_clear_full(); + + return menu_load_cd_image(fname); +} + static int swap_cd_image(void) { const char *fname; diff --git a/frontend/menu.h b/frontend/menu.h index 26643af8..59885565 100644 --- a/frontend/menu.h +++ b/frontend/menu.h @@ -7,6 +7,7 @@ void menu_loop(void); void menu_finish(void); void menu_notify_mode_change(int w, int h, int bpp); +int menu_load_cd_image(const char *fname); int menu_load_config(int is_game); enum g_opts_opts {