Improve settings handling

This commit is contained in:
Robin Jones 2023-02-25 02:24:19 +00:00
parent 3e1dc34369
commit abcff3feaf

View File

@ -44,12 +44,13 @@ void settings_load_from_file (settings_t *settings) {
assertf(!fclose(fp), "Couldn't close toml config file"); // TODO: work out why and handle appropriately.
fp = NULL;
// Handle last_rom
toml_table_t *last_rom = toml_table_in(conf, "last_rom");
if (!last_rom) {
printf("Missing '[last_rom]' header in config\n");
wait_ms(10000);
}
else {
toml_datum_t rom_path = toml_string_in(last_rom, "rom_path");
if (!rom_path.ok) {
printf("Couldn't read 'rom_path' value in config\n");
@ -80,13 +81,16 @@ void settings_load_from_file (settings_t *settings) {
printf("Found save type: %d\n", (int)tmp_save_type.u.i );
settings->last_rom.save_type = (int)tmp_save_type.u.i;
}
}
// Handle last_state
toml_table_t* last_state = toml_table_in(conf, "last_state");
if (!last_state) {
printf("Missing '[last_state]' header in config\n");
wait_ms(10000);
}
else {
// toml_datum_t current_directory = toml_string_in(last_state, "current_directory");
// if (!current_directory.ok) {
@ -111,6 +115,17 @@ void settings_load_from_file (settings_t *settings) {
// printf("Found autoload: %s\n", tmp_auto_load_last_rom.u.b ? "true" : "false");
// settings->last_state.auto_load_last_rom = tmp_auto_load_last_rom.u.b;
// }
}
// Handle boot_params
toml_table_t* boot_params = toml_table_in(conf, "boot_params");
if (!boot_params) {
printf("Missing '[boot_params]' header in config\n");
wait_ms(10000);
}
else {
}
toml_free(conf);