mirror of
https://github.com/Polprzewodnikowy/N64FlashcartMenu.git
synced 2024-12-27 02:31:50 +01:00
Settings context menu (#116)
<!--- Provide a general summary of your changes in the Title above --> ## Description <!--- Describe your changes in detail --> Adds ability to set the config.ini settings from the menu. ## 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 --> Ability to set the settings was missing from the menu. ## 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. --> Tested on an SC64. ## Screenshots <!-- (if appropriate): --> ![image](https://github.com/Polprzewodnikowy/N64FlashcartMenu/assets/11439699/6ca39679-d997-4f6c-a670-55d2334814ce) ## 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) - [ ] 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:
parent
9675745dbd
commit
bd821bf493
@ -1 +1 @@
|
||||
Subproject commit 536df10ad65614f519bea40482b6e2657b9c4c84
|
||||
Subproject commit 4d4449aac2af2ba8306cd4e61974ac682f1ea400
|
@ -36,7 +36,7 @@ static void draw (menu_t *menu, surface_t *d) {
|
||||
"\n"
|
||||
"\n"
|
||||
"To set the date and time, please use the PC terminal\n"
|
||||
"application and set via USB.\n\n"
|
||||
"application and set via USB or a game that uses it.\n\n"
|
||||
"Current date & time: %s\n",
|
||||
menu->current_time >= 0 ? ctime(&menu->current_time) : "Unknown\n"
|
||||
);
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include <stdbool.h>
|
||||
#include "../sound.h"
|
||||
#include "../settings.h"
|
||||
#include "views.h"
|
||||
|
||||
|
||||
@ -9,9 +11,108 @@ static const char *format_switch (bool state) {
|
||||
}
|
||||
}
|
||||
|
||||
static void set_pal60_type (menu_t *menu, void *arg) {
|
||||
menu->settings.pal60_enabled = (bool) (arg);
|
||||
settings_save(&menu->settings);
|
||||
}
|
||||
|
||||
static void set_protected_entries_type (menu_t *menu, void *arg) {
|
||||
menu->settings.show_protected_entries = (bool) (arg);
|
||||
settings_save(&menu->settings);
|
||||
|
||||
menu->browser.reload = true;
|
||||
}
|
||||
|
||||
static void set_use_saves_folder_type (menu_t *menu, void *arg) {
|
||||
menu->settings.use_saves_folder = (bool) (arg);
|
||||
settings_save(&menu->settings);
|
||||
}
|
||||
|
||||
static void set_sound_enabled_type (menu_t *menu, void *arg) {
|
||||
menu->settings.sound_enabled = (bool) (arg);
|
||||
settings_save(&menu->settings);
|
||||
}
|
||||
|
||||
#ifdef BETA_SETTINGS
|
||||
static void set_bgm_enabled_type (menu_t *menu, void *arg) {
|
||||
menu->settings.bgm_enabled = (bool) (arg);
|
||||
settings_save(&menu->settings);
|
||||
}
|
||||
|
||||
static void set_rumble_enabled_type (menu_t *menu, void *arg) {
|
||||
menu->settings.rumble_enabled = (bool) (arg);
|
||||
settings_save(&menu->settings);
|
||||
}
|
||||
|
||||
// static void set_use_default_settings (menu_t *menu, void *arg) {
|
||||
// // FIXME: add implementation
|
||||
// menu->browser.reload = true;
|
||||
// }
|
||||
#endif
|
||||
|
||||
|
||||
static component_context_menu_t set_pal60_type_context_menu = { .list = {
|
||||
{.text = "On", .action = set_pal60_type, .arg = (void *) (true) },
|
||||
{.text = "Off", .action = set_pal60_type, .arg = (void *) (false) },
|
||||
COMPONENT_CONTEXT_MENU_LIST_END,
|
||||
}};
|
||||
|
||||
static component_context_menu_t set_protected_entries_type_context_menu = { .list = {
|
||||
{.text = "On", .action = set_protected_entries_type, .arg = (void *) (true) },
|
||||
{.text = "Off", .action = set_protected_entries_type, .arg = (void *) (false) },
|
||||
COMPONENT_CONTEXT_MENU_LIST_END,
|
||||
}};
|
||||
|
||||
static component_context_menu_t set_sound_enabled_type_context_menu = { .list = {
|
||||
{.text = "On", .action = set_sound_enabled_type, .arg = (void *) (true) },
|
||||
{.text = "Off", .action = set_sound_enabled_type, .arg = (void *) (false) },
|
||||
COMPONENT_CONTEXT_MENU_LIST_END,
|
||||
}};
|
||||
|
||||
static component_context_menu_t set_use_saves_folder_type_context_menu = { .list = {
|
||||
{.text = "On", .action = set_use_saves_folder_type, .arg = (void *) (true) },
|
||||
{.text = "Off", .action = set_use_saves_folder_type, .arg = (void *) (false) },
|
||||
COMPONENT_CONTEXT_MENU_LIST_END,
|
||||
}};
|
||||
|
||||
#ifdef BETA_SETTINGS
|
||||
static component_context_menu_t set_bgm_enabled_type_context_menu = { .list = {
|
||||
{.text = "On", .action = set_bgm_enabled_type, .arg = (void *) (true) },
|
||||
{.text = "Off", .action = set_bgm_enabled_type, .arg = (void *) (false) },
|
||||
COMPONENT_CONTEXT_MENU_LIST_END,
|
||||
}};
|
||||
|
||||
static component_context_menu_t set_rumble_enabled_type_context_menu = { .list = {
|
||||
{.text = "On", .action = set_rumble_enabled_type, .arg = (void *) (true) },
|
||||
{.text = "Off", .action = set_rumble_enabled_type, .arg = (void *) (false) },
|
||||
COMPONENT_CONTEXT_MENU_LIST_END,
|
||||
}};
|
||||
#endif
|
||||
|
||||
static component_context_menu_t options_context_menu = { .list = {
|
||||
{ .text = "PAL60 Mode", .submenu = &set_pal60_type_context_menu },
|
||||
{ .text = "Show Hidden Files", .submenu = &set_protected_entries_type_context_menu },
|
||||
{ .text = "Sound Effects", .submenu = &set_sound_enabled_type_context_menu },
|
||||
{ .text = "Use Saves Folder", .submenu = &set_use_saves_folder_type_context_menu },
|
||||
#ifdef BETA_SETTINGS
|
||||
{ .text = "Background Music", .submenu = &set_bgm_enabled_type_context_menu },
|
||||
{ .text = "Rumble Feedback", .submenu = &set_rumble_enabled_type_context_menu },
|
||||
// { .text = "Restore Defaults", .action = set_use_default_settings },
|
||||
#endif
|
||||
|
||||
COMPONENT_CONTEXT_MENU_LIST_END,
|
||||
}};
|
||||
|
||||
|
||||
static void process (menu_t *menu) {
|
||||
if (menu->actions.back) {
|
||||
if (component_context_menu_process(menu, &options_context_menu)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (menu->actions.enter) {
|
||||
component_context_menu_show(&options_context_menu);
|
||||
sound_play_effect(SFX_SETTING);
|
||||
} else if (menu->actions.back) {
|
||||
menu->next_mode = MENU_MODE_BROWSER;
|
||||
sound_play_effect(SFX_EXIT);
|
||||
}
|
||||
@ -26,44 +127,55 @@ static void draw (menu_t *menu, surface_t *d) {
|
||||
|
||||
component_main_text_draw(
|
||||
ALIGN_CENTER, VALIGN_TOP,
|
||||
"SETTINGS EDITOR\n"
|
||||
"MENU SETTINGS EDITOR\n"
|
||||
"\n"
|
||||
);
|
||||
|
||||
component_main_text_draw(
|
||||
ALIGN_LEFT, VALIGN_TOP,
|
||||
"\n"
|
||||
"\n"
|
||||
"To change the settings, please adjust them\n"
|
||||
"directly in the 'menu/config.ini' file.\n\n"
|
||||
"pal60_enabled: %s\n"
|
||||
"show_protected_entries: %s\n"
|
||||
"default_directory: %s\n"
|
||||
"use_saves_folder: %s\n"
|
||||
"bgm_enabled: %s\n"
|
||||
"sound_enabled: %s\n"
|
||||
"rumble_enabled: %s\n",
|
||||
"\n\n"
|
||||
" Default Directory : %s\n\n"
|
||||
"To change the menu settings, press 'A'.\n\n"
|
||||
" PAL60 Mode : %s\n"
|
||||
" Show Hidden Files : %s\n"
|
||||
" Use Saves folder : %s\n"
|
||||
"* Sound Effects : %s\n"
|
||||
#ifdef BETA_SETTINGS
|
||||
" Background Music : %s\n"
|
||||
" Rumble Feedback : %s\n"
|
||||
#endif
|
||||
"\n\n"
|
||||
"Note: Certain settings have the following caveats:\n\n"
|
||||
"* Requires a flashcart reboot.\n",
|
||||
menu->settings.default_directory,
|
||||
format_switch(menu->settings.pal60_enabled),
|
||||
format_switch(menu->settings.show_protected_entries),
|
||||
menu->settings.default_directory,
|
||||
format_switch(menu->settings.use_saves_folder),
|
||||
format_switch(menu->settings.sound_enabled)
|
||||
#ifdef BETA_SETTINGS
|
||||
,
|
||||
format_switch(menu->settings.bgm_enabled),
|
||||
format_switch(menu->settings.sound_enabled),
|
||||
format_switch(menu->settings.rumble_enabled)
|
||||
#endif
|
||||
);
|
||||
|
||||
|
||||
component_actions_bar_text_draw(
|
||||
ALIGN_LEFT, VALIGN_TOP,
|
||||
"\n"
|
||||
"A: Change\n"
|
||||
"B: Back"
|
||||
);
|
||||
|
||||
component_context_menu_draw(&options_context_menu);
|
||||
|
||||
rdpq_detach_show();
|
||||
}
|
||||
|
||||
|
||||
void view_settings_init (menu_t *menu) {
|
||||
// Nothing to initialize (yet)
|
||||
|
||||
component_context_menu_init(&options_context_menu);
|
||||
|
||||
}
|
||||
|
||||
void view_settings_display (menu_t *menu, surface_t *display) {
|
||||
|
Loading…
Reference in New Issue
Block a user