[develop] Settings improvements (#202)

<!--- Provide a general summary of your changes in the Title above -->

## Description
<!--- Describe your changes in detail -->
Adds settings for:
* Schema version
* First Run
* ROM loading progress bar

## Motivation and Context
<!--- What does this sample do? What problem does it solve? -->
<!--- If it fixes/closes/resolves an open issue, please link to the
issue here -->
They will be required in the near future.
Certain users want to turn the ROM loading progress bar off (for some
reason).

## How Has This Been Tested?
<!-- (if applicable) -->
<!--- Please describe in detail how you tested your sample/changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->

## Screenshots
<!-- (if appropriate): -->

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [x] Improvement (non-breaking change that adds a new feature)
- [ ] Bug fix (fixes an issue)
- [ ] Breaking change (breaking change)
- [ ] Documentation Improvement
- [ ] Config and build (change in the configuration and build system,
has no impact on code or features)

## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.

<!--- It would be nice if you could sign off your contribution by
replacing the name with your GitHub user name and GitHub email contact.
-->
Signed-off-by: GITHUB_USER <GITHUB_USER_EMAIL>
This commit is contained in:
Robin Jones 2025-01-15 00:02:32 +00:00 committed by GitHub
parent b56dfe0249
commit ae9f10cda1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 40 additions and 8 deletions

View File

@ -9,11 +9,14 @@ static char *settings_path = NULL;
static settings_t init = {
.schema_revision = 1,
.first_run = true,
.pal60_enabled = false,
.show_protected_entries = false,
.default_directory = "/",
.use_saves_folder = true,
.soundfx_enabled = false,
.loading_progress_bar_enabled = true,
.rom_autoload_enabled = false,
.rom_autoload_path = "",
.rom_autoload_filename = "",
@ -38,11 +41,14 @@ void settings_load (settings_t *settings) {
mini_t *ini = mini_try_load(settings_path);
settings->schema_revision = mini_get_int(ini, "menu", "schema_revision", init.schema_revision);
settings->first_run = mini_get_bool(ini, "menu", "first_run", init.first_run);
settings->pal60_enabled = mini_get_bool(ini, "menu", "pal60", init.pal60_enabled); // TODO: consider changing file setting name
settings->show_protected_entries = mini_get_bool(ini, "menu", "show_protected_entries", init.show_protected_entries);
settings->default_directory = strdup(mini_get_string(ini, "menu", "default_directory", init.default_directory));
settings->use_saves_folder = mini_get_bool(ini, "menu", "use_saves_folder", init.use_saves_folder);
settings->soundfx_enabled = mini_get_bool(ini, "menu", "soundfx_enabled", init.soundfx_enabled);
settings->loading_progress_bar_enabled = mini_get_bool(ini, "menu", "loading_progress_bar_enabled", init.loading_progress_bar_enabled);
settings->rom_autoload_enabled = mini_get_bool(ini, "menu", "autoload_rom_enabled", init.rom_autoload_enabled);
settings->rom_autoload_path = strdup(mini_get_string(ini, "autoload", "rom_path", init.rom_autoload_path));
@ -58,11 +64,14 @@ void settings_load (settings_t *settings) {
void settings_save (settings_t *settings) {
mini_t *ini = mini_create(settings_path);
mini_set_int(ini, "menu", "schema_revision", settings->schema_revision);
mini_set_bool(ini, "menu", "first_run", settings->first_run);
mini_set_bool(ini, "menu", "pal60", settings->pal60_enabled);
mini_set_bool(ini, "menu", "show_protected_entries", settings->show_protected_entries);
mini_set_string(ini, "menu", "default_directory", settings->default_directory);
mini_set_bool(ini, "menu", "use_saves_folder", settings->use_saves_folder);
mini_set_bool(ini, "menu", "soundfx_enabled", settings->soundfx_enabled);
mini_set_bool(ini, "menu", "loading_progress_bar_enabled", settings->loading_progress_bar_enabled);
mini_set_bool(ini, "menu", "autoload_rom_enabled", settings->rom_autoload_enabled);
mini_set_string(ini, "autoload", "rom_path", settings->rom_autoload_path);
mini_set_string(ini, "autoload", "rom_filename", settings->rom_autoload_filename);

View File

@ -10,6 +10,12 @@
/** @brief Settings Structure */
typedef struct {
/** @brief Settings version */
int schema_revision;
/** @brief First run of the menu */
bool first_run;
/** @brief Use 60 Hz refresh rate on a PAL console */
bool pal60_enabled;
@ -31,6 +37,9 @@ typedef struct {
/** @brief Enable rumble feedback */
bool rumble_enabled;
/** @brief Show progress bar when loading a ROM */
bool loading_progress_bar_enabled;
/** @brief Enable the ability to bypass the menu and instantly load a ROM */
bool rom_autoload_enabled;

View File

@ -36,14 +36,14 @@ static void draw (menu_t *menu, surface_t *d) {
"Menu version: %s\n"
"Build timestamp: %s\n"
"\n"
"Github:\n"
"Github - Website:\n"
" https://github.com/Polprzewodnikowy/N64FlashcartMenu\n"
"Authors:\n"
" Robin Jones / NetworkFusion\n"
" Mateusz Faderewski / Polprzewodnikowy\n"
"Credits:\n"
" N64Brew / libDragon contributors\n"
"\n"
"Contributors:\n"
" Thank you to ALL project contributors,\n"
" no matter how small the commit.\n"
"OSS software used:\n"
" libdragon (UNLICENSE License)\n"
" libspng (BSD 2-Clause License)\n"

View File

@ -241,7 +241,7 @@ static void draw (menu_t *menu, surface_t *d) {
ui_components_background_draw();
if (menu->boot_pending.rom_file) {
if (menu->boot_pending.rom_file && menu->settings.loading_progress_bar_enabled) {
ui_components_loader_draw(0.0f);
} else {
ui_components_layout_draw();
@ -343,7 +343,12 @@ static void draw_progress (float progress) {
}
static void load (menu_t *menu) {
cart_load_err_t err = cart_load_n64_rom_and_save(menu, draw_progress);
cart_load_err_t err;
if (!menu->settings.loading_progress_bar_enabled) {
err = cart_load_n64_rom_and_save(menu, NULL);
} else {
err = cart_load_n64_rom_and_save(menu, draw_progress);
}
if (err != CART_LOAD_OK) {
menu_show_error(menu, cart_load_convert_error_message(err));

View File

@ -136,7 +136,8 @@ static void draw (menu_t *menu, surface_t *d) {
ALIGN_LEFT, VALIGN_TOP,
"\n\n"
" Default Directory : %s\n\n"
" Autoload ROM : %s\n\n"
" Autoload ROM : %s\n"
" ROM Loading Bar : %s\n\n"
"To change the following menu settings, press 'A':\n"
" Show Hidden Files : %s\n"
" Use Saves folder : %s\n"
@ -152,6 +153,7 @@ static void draw (menu_t *menu, surface_t *d) {
,
menu->settings.default_directory,
format_switch(menu->settings.rom_autoload_enabled),
format_switch(menu->settings.loading_progress_bar_enabled),
format_switch(menu->settings.show_protected_entries),
format_switch(menu->settings.use_saves_folder),
format_switch(menu->settings.soundfx_enabled)

View File

@ -30,7 +30,14 @@ void view_startup_init (menu_t *menu) {
return;
}
menu->next_mode = MENU_MODE_BROWSER;
if (menu->settings.first_run) {
menu->settings.first_run = false;
settings_save(&menu->settings);
menu->next_mode = MENU_MODE_CREDITS;
}
else {
menu->next_mode = MENU_MODE_BROWSER;
}
}
void view_startup_display (menu_t *menu, surface_t *display) {