From: chaoskagami Date: Thu, 9 Jun 2016 22:38:44 +0000 (-0400) Subject: Make saving configuration manually done (for my sanity's sake) X-Git-Tag: v0.0.8~2 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=e9b44264473b28ebddb316089d99e53f8d7db495;p=corbenik%2Fcorbenik.git Make saving configuration manually done (for my sanity's sake) --- diff --git a/source/config.c b/source/config.c index e391c4f..32e1962 100644 --- a/source/config.c +++ b/source/config.c @@ -3,6 +3,8 @@ FILE *conf_handle; struct config_file config; +extern uint8_t *enable_list; +void list_patches_build(char *name, int desc_is_fname); void regenerate_config() @@ -74,6 +76,8 @@ load_config() } } + list_patches_build(PATH_PATCHES, 0); + if (!config.options[OPTION_SILENCE]) fprintf(BOTTOM_SCREEN, "Config file loaded.\n"); } @@ -83,6 +87,8 @@ save_config() { fprintf(stderr, "Saving config.\n"); + write_file(enable_list, PATH_TEMP "/PATCHENABLE", FCRAM_SPACING / 2); + f_unlink(PATH_CONFIG); if (!(conf_handle = fopen(PATH_CONFIG, "w"))) @@ -90,4 +96,6 @@ save_config() fwrite(&config, 1, sizeof(config), conf_handle); fclose(conf_handle); + + config.options[OPTION_RECONFIGURED] = 1; // Save caches on boot. } diff --git a/source/firm/firm.c b/source/firm/firm.c index eee914e..d275bdf 100644 --- a/source/firm/firm.c +++ b/source/firm/firm.c @@ -424,12 +424,6 @@ boot_cfw() { fprintf(BOTTOM_SCREEN, "Loading firmware...\n"); - if (config.options[OPTION_RECONFIGURED]) { - config.options[OPTION_RECONFIGURED] = 0; - save_config(); - config.options[OPTION_RECONFIGURED] = 1; - } - load_firms(); if (config.options[OPTION_RECONFIGURED]) { diff --git a/source/menu.c b/source/menu.c index fe60a22..26d0d0e 100644 --- a/source/menu.c +++ b/source/menu.c @@ -1,15 +1,16 @@ #include "common.h" #include "firm/firm.h" #include "firm/headers.h" -#define MENU_MAIN 1 +#define MENU_MAIN 1 #define MENU_OPTIONS 2 #define MENU_PATCHES 3 -#define MENU_INFO 4 -#define MENU_HELP 5 -#define MENU_RESET 6 -#define MENU_POWER 7 -#define MENU_BOOTME 8 +#define MENU_INFO 4 +#define MENU_HELP 5 +#define MENU_RESET 6 +#define MENU_POWER 7 +#define MENU_SAVECFG 8 +#define MENU_BOOTME 9 #define MAX_PATCHES ((FCRAM_SPACING / 2) / sizeof(struct options_s)) struct options_s *patches = (struct options_s *)FCRAM_MENU_LOC; @@ -189,17 +190,8 @@ int show_menu(struct options_s *options, uint8_t *toggles); int menu_patches() { - list_patches_build(PATH_PATCHES, 0); - show_menu(patches, enable_list); - // Remove old settings, save new - f_unlink(PATH_TEMP "/PATCHENABLE"); - write_file(enable_list, PATH_TEMP "/PATCHENABLE", FCRAM_SPACING / 2); - - // TODO - Determine whether it actually changed. - config.options[OPTION_RECONFIGURED] = 1; - return MENU_MAIN; } @@ -208,9 +200,6 @@ menu_options() { show_menu(options, config.options); - // TODO - Determine whether it actually changed. - config.options[OPTION_RECONFIGURED] = 1; - return MENU_MAIN; } @@ -282,10 +271,6 @@ menu_help() int menu_reset() { - write_file(enable_list, PATH_TEMP "/PATCHENABLE", FCRAM_SPACING / 2); - config.options[OPTION_RECONFIGURED] = 1; - save_config(); // Save config, including the reconfigured flag. - fumount(); // Unmount SD. // Reboot. @@ -298,10 +283,6 @@ menu_reset() int menu_poweroff() { - write_file(enable_list, PATH_TEMP "/PATCHENABLE", FCRAM_SPACING / 2); - config.options[OPTION_RECONFIGURED] = 1; - save_config(); // Save config, including the reconfigured flag. - fumount(); // Unmount SD. // Reboot. @@ -311,14 +292,20 @@ menu_poweroff() ; } +int menu_saveconfig() { + save_config(); // Save config, including the reconfigured flag. + + return MENU_MAIN; +} + int menu_main() { // TODO - Stop using different menu code here. set_cursor(TOP_SCREEN, 0, 0); - const char *list[] = { "Options", "Patches", "Info", "Help/Readme", "Reboot", "Power off", "Boot Firmware" }; - int menu_max = 7; + const char *list[] = { "Options", "Patches", "Info", "Help/Readme", "Reboot", "Power off", "Save Configuration", "Boot Firmware" }; + int menu_max = 8; header("A:Enter DPAD:Nav"); @@ -393,6 +380,9 @@ menu_handler() case MENU_HELP: to_menu = menu_help(); break; + case MENU_SAVECFG: + to_menu = menu_saveconfig(); + break; case MENU_BOOTME: return 0; case MENU_RESET: