Add an option to use current rom directory for config and saves

This commit is contained in:
Elouan Martinet 2024-10-28 09:05:17 +01:00
parent 7a7190baea
commit 6d8869d23a
4 changed files with 25 additions and 9 deletions

View File

@ -66,6 +66,9 @@ General settings.
`bool useGbaDb` - Use `gba_db.bin` to get save types
* Default: `true`
`bool useSavesFolder` - Use `/3ds/open_agb_firm/saves` for save files instead of the ROM directory
* Default: `true`
### Video
Video-related settings.

View File

@ -39,6 +39,7 @@ typedef struct
u8 backlightSteps;
bool directBoot;
bool useGbaDb;
bool useSavesFolder;
// [video]
u8 scaler; // 0 = 1:1, 1 = bilinear (GPU) x1.5, 2 = matrix (hardware) x1.5.

View File

@ -30,7 +30,8 @@
"backlight=64\n" \
"backlightSteps=5\n" \
"directBoot=false\n" \
"useGbaDb=true\n\n" \
"useGbaDb=true\n" \
"useSavesFolder=true\n\n" \
"[video]\n" \
"scaler=2\n" \
"gbaGamma=2.2\n" \
@ -55,6 +56,7 @@ OafConfig g_oafConfig =
5, // backlightSteps
false, // directBoot
true, // useGbaDb
true, // useSavesFolder
// [video]
2, // scaler
@ -143,6 +145,8 @@ static int cfgIniCallback(void* user, const char* section, const char* name, con
config->directBoot = (strcmp(value, "false") == 0 ? false : true);
else if(strcmp(name, "useGbaDb") == 0)
config->useGbaDb = (strcmp(value, "true") == 0 ? true : false);
else if(strcmp(name, "useSavesFolder") == 0)
config->useSavesFolder = (strcmp(value, "true") == 0 ? true : false);
}
else if(strcmp(section, "video") == 0)
{

View File

@ -211,15 +211,23 @@ static Result showFileBrowser(char romAndSavePath[512])
static void rom2GameCfgPath(char romPath[512])
{
// Extract the file name and change the extension.
// For cfg2SavePath() we need to reserve 2 extra bytes/chars.
char tmpIniFileName[256];
safeStrcpy(tmpIniFileName, strrchr(romPath, '/') + 1, 256 - 2);
strcpy(tmpIniFileName + strlen(tmpIniFileName) - 4, ".ini");
if (g_oafConfig.useSavesFolder)
{
// Extract the file name and change the extension.
// For cfg2SavePath() we need to reserve 2 extra bytes/chars.
char tmpIniFileName[256];
safeStrcpy(tmpIniFileName, strrchr(romPath, '/') + 1, 256 - 2);
strcpy(tmpIniFileName + strlen(tmpIniFileName) - 4, ".ini");
// Construct the new path.
strcpy(romPath, OAF_SAVE_DIR "/");
strcat(romPath, tmpIniFileName);
// Construct the new path.
strcpy(romPath, OAF_SAVE_DIR "/");
strcat(romPath, tmpIniFileName);
}
else
{
// Change the extension to .ini.
strcpy(romPath + strlen(romPath) - 4, ".ini");
}
}
static void gameCfg2SavePath(char cfgPath[512], const u8 saveSlot)