mirror of
https://github.com/Polprzewodnikowy/N64FlashcartMenu.git
synced 2024-11-25 20:16:54 +01:00
add gamepak config dir
This commit is contained in:
parent
55e7663bae
commit
d69a0c64a9
@ -4,6 +4,8 @@
|
||||
|
||||
#include <mini.c/src/mini.h>
|
||||
|
||||
#include "views/views.h"
|
||||
|
||||
#include "boot/cic.h"
|
||||
#include "rom_info.h"
|
||||
#include "utils/fs.h"
|
||||
@ -18,6 +20,10 @@
|
||||
|
||||
#define CLOCK_RATE_DEFAULT (0x0000000F)
|
||||
|
||||
#ifndef GAMEPAK_CONFIG_SUBDIRECTORY
|
||||
#define GAMEPAK_CONFIG_SUBDIRECTORY "config"
|
||||
#endif
|
||||
|
||||
|
||||
/** @brief ROM File Information Structure. */
|
||||
typedef struct __attribute__((packed)) {
|
||||
@ -794,7 +800,21 @@ static void extract_rom_info (match_t *match, rom_header_t *rom_header, rom_info
|
||||
}
|
||||
}
|
||||
|
||||
static bool create_gamepak_config_subdirectory (path_t *path) {
|
||||
path_t *gamepak_config_path = path_clone(path);
|
||||
path_pop(gamepak_config_path);
|
||||
path_push(gamepak_config_path, GAMEPAK_CONFIG_SUBDIRECTORY);
|
||||
bool error = directory_create(path_get(gamepak_config_path));
|
||||
path_free(gamepak_config_path);
|
||||
return error;
|
||||
}
|
||||
|
||||
static void load_overrides (path_t *path, rom_info_t *rom_info) {
|
||||
|
||||
if ( menu->settings.use_gamepak_config_folder) {
|
||||
path_push_subdir(path, GAMEPAK_CONFIG_SUBDIRECTORY);
|
||||
}
|
||||
|
||||
path_t *overrides_path = path_clone(path);
|
||||
|
||||
path_ext_replace(overrides_path, "ini");
|
||||
@ -828,6 +848,15 @@ static void load_overrides (path_t *path, rom_info_t *rom_info) {
|
||||
}
|
||||
|
||||
static rom_err_t save_override (path_t *path, const char *id, int value, int default_value) {
|
||||
|
||||
if ( menu->settings.use_gamepak_config_folder) {
|
||||
// if the sub dir does not exist, create it
|
||||
// TODO: would it be quicker to check it exists first?
|
||||
create_gamepak_config_subdirectory(path);
|
||||
|
||||
path_push_subdir(path, GAMEPAK_CONFIG_SUBDIRECTORY);
|
||||
}
|
||||
|
||||
path_t *overrides_path = path_clone(path);
|
||||
|
||||
path_ext_replace(overrides_path, "ini");
|
||||
|
@ -13,6 +13,7 @@ static settings_t init = {
|
||||
.show_protected_entries = false,
|
||||
.default_directory = "/",
|
||||
.use_saves_folder = true,
|
||||
.use_gamepak_custom_config_folder = false,
|
||||
.sound_enabled = true,
|
||||
|
||||
/* Beta feature flags (should always init to off) */
|
||||
@ -39,6 +40,7 @@ void settings_load (settings_t *settings) {
|
||||
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->use_gamepak_custom_config_folder = mini_get_bool(ini, "menu", "use_gamepak_custom_config_folder", init.use_gamepak_custom_config_folder);
|
||||
settings->sound_enabled = mini_get_bool(ini, "menu", "sound_enabled", init.sound_enabled);
|
||||
|
||||
/* Beta feature flags, they might not be in the file */
|
||||
@ -55,6 +57,7 @@ void settings_save (settings_t *settings) {
|
||||
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", "use_gamepak_custom_config_folder", settings->use_gamepak_custom_config_folder);
|
||||
mini_set_bool(ini, "menu", "sound_enabled", settings->sound_enabled);
|
||||
|
||||
/* Beta feature flags, they should not save until production ready! */
|
||||
|
@ -22,6 +22,9 @@ typedef struct {
|
||||
/** @brief Put saves into separate directory */
|
||||
bool use_saves_folder;
|
||||
|
||||
/** @brief Put custom GamePak configs into separate directory */
|
||||
bool use_gamepak_custom_config_folder;
|
||||
|
||||
/** @brief Enable Background music */
|
||||
bool bgm_enabled;
|
||||
|
||||
|
@ -28,6 +28,11 @@ static void set_use_saves_folder_type (menu_t *menu, void *arg) {
|
||||
settings_save(&menu->settings);
|
||||
}
|
||||
|
||||
static void set_use_gamepak_custom_config_folder_type (menu_t *menu, void *arg) {
|
||||
menu->settings.use_gamepak_custom_config_folder = (bool) (arg);
|
||||
settings_save(&menu->settings);
|
||||
}
|
||||
|
||||
static void set_sound_enabled_type (menu_t *menu, void *arg) {
|
||||
menu->settings.sound_enabled = (bool) (arg);
|
||||
sound_use_sfx(menu->settings.sound_enabled);
|
||||
@ -76,6 +81,12 @@ static component_context_menu_t set_use_saves_folder_type_context_menu = { .list
|
||||
COMPONENT_CONTEXT_MENU_LIST_END,
|
||||
}};
|
||||
|
||||
static component_context_menu_t set_use_gamepak_custom_config_folder_type_context_menu = { .list = {
|
||||
{.text = "On", .action = set_use_gamepak_custom_config_folder_type, .arg = (void *) (true) },
|
||||
{.text = "Off", .action = set_use_gamepak_custom_config_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) },
|
||||
@ -95,6 +106,7 @@ static component_context_menu_t options_context_menu = { .list = {
|
||||
{ .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 },
|
||||
{ .text = "Use Game Config Folder", .submenu = &set_use_gamepak_custom_config_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 },
|
||||
@ -140,6 +152,7 @@ static void draw (menu_t *menu, surface_t *d) {
|
||||
"* PAL60 Mode : %s\n"
|
||||
" Show Hidden Files : %s\n"
|
||||
" Use Saves folder : %s\n"
|
||||
" Use config folder : %s\n"
|
||||
" Sound Effects : %s\n"
|
||||
#ifdef BETA_SETTINGS
|
||||
" Background Music : %s\n"
|
||||
@ -151,6 +164,7 @@ static void draw (menu_t *menu, surface_t *d) {
|
||||
format_switch(menu->settings.pal60_enabled),
|
||||
format_switch(menu->settings.show_protected_entries),
|
||||
format_switch(menu->settings.use_saves_folder),
|
||||
format_switch(menu->settings.use_gamepak_custom_config_folder),
|
||||
format_switch(menu->settings.sound_enabled)
|
||||
#ifdef BETA_SETTINGS
|
||||
,
|
||||
|
Loading…
Reference in New Issue
Block a user