Support multiple instances with separate configs

This commit is contained in:
wiidev 2023-01-01 17:00:30 +00:00
parent 15aabd4f53
commit c3a65d572c
37 changed files with 77 additions and 194 deletions

View File

@ -2337,9 +2337,6 @@ msgstr "Aktualizace"
msgid "Update Files"
msgstr "Zaktualizuj soubory"
msgid "Update Path"
msgstr "Cesta pro aktualizaci"
msgid "Update all Language Files"
msgstr "Zaktualizuj vsechny jazykové soubory"

View File

@ -2337,9 +2337,6 @@ msgstr "Opdatér"
msgid "Update Files"
msgstr "Opdatér filer"
msgid "Update Path"
msgstr "Sti til opdateringer"
msgid "Update all Language Files"
msgstr "Opdatér alle sprogfiler"

View File

@ -2337,9 +2337,6 @@ msgstr "Updaten"
msgid "Update Files"
msgstr "Bestanden Updaten"
msgid "Update Path"
msgstr "Updatelocatie"
msgid "Update all Language Files"
msgstr "Alle taalbestanden updaten"

View File

@ -2337,9 +2337,6 @@ msgstr ""
msgid "Update Files"
msgstr ""
msgid "Update Path"
msgstr ""
msgid "Update all Language Files"
msgstr ""

View File

@ -2337,9 +2337,6 @@ msgstr "Päivitä"
msgid "Update Files"
msgstr "Päivitä tiedostot"
msgid "Update Path"
msgstr "Päivityspolku"
msgid "Update all Language Files"
msgstr "Päivitä kaikki kielitiedostot"

View File

@ -2337,9 +2337,6 @@ msgstr "Mise à jour"
msgid "Update Files"
msgstr "MàJ Fichiers"
msgid "Update Path"
msgstr "Dossier de mise à jour"
msgid "Update all Language Files"
msgstr "Mise à jour des fichiers de langue"

View File

@ -2337,9 +2337,6 @@ msgstr "Update"
msgid "Update Files"
msgstr "Aktualisieren"
msgid "Update Path"
msgstr "Updates"
msgid "Update all Language Files"
msgstr "Sprachdateien aktualisieren"

View File

@ -2337,9 +2337,6 @@ msgstr "Aναβάθμιση"
msgid "Update Files"
msgstr "Αναβάθμιση αρχείων"
msgid "Update Path"
msgstr "Μονοπάτι αρχείων αναβάθμισης."
msgid "Update all Language Files"
msgstr "Αναβάθμιση όλων των μεταφράσεων"

View File

@ -2340,9 +2340,6 @@ msgstr "Frissítés"
msgid "Update Files"
msgstr "Fájlok frissítése"
msgid "Update Path"
msgstr "Frissítés Útvonala"
msgid "Update all Language Files"
msgstr "Minden nyelvi fájl frissítése"

View File

@ -2340,9 +2340,6 @@ msgstr "Aggiornamenti"
msgid "Update Files"
msgstr "Aggiorna i files"
msgid "Update Path"
msgstr "Percorso aggiornamenti"
msgid "Update all Language Files"
msgstr "Aggiorna tutte le traduzioni"

View File

@ -2340,9 +2340,6 @@ msgstr "更新"
msgid "Update Files"
msgstr "すべて更新"
msgid "Update Path"
msgstr "GXのdol"
msgid "Update all Language Files"
msgstr "全言語ファイルを更新"

View File

@ -2340,9 +2340,6 @@ msgstr "업데이트"
msgid "Update Files"
msgstr "파일 업데이트"
msgid "Update Path"
msgstr "경로 업데이트"
msgid "Update all Language Files"
msgstr "모든 언어 파일 업데이트"

View File

@ -2337,9 +2337,6 @@ msgstr "Oppdater"
msgid "Update Files"
msgstr "Oppdater filer"
msgid "Update Path"
msgstr "Oppdatering sti"
msgid "Update all Language Files"
msgstr "Oppdater alle språkfiler"

View File

@ -2337,9 +2337,6 @@ msgstr "Aktualizacja"
msgid "Update Files"
msgstr "Zaktualizuj pliki"
msgid "Update Path"
msgstr "Sciezka aktualizacji"
msgid "Update all Language Files"
msgstr "Zaktualizuj wszystkie pliki jezykowe"

View File

@ -2337,9 +2337,6 @@ msgstr "Atualizações"
msgid "Update Files"
msgstr "Atualizar arquivos"
msgid "Update Path"
msgstr "Atualização"
msgid "Update all Language Files"
msgstr "Atualizar todos os arquivos de Idioma"

View File

@ -2337,9 +2337,6 @@ msgstr "Actualizações"
msgid "Update Files"
msgstr "Actualizar ficheiros"
msgid "Update Path"
msgstr "Cam. Actualização"
msgid "Update all Language Files"
msgstr "Actualizar todos os ficheiros de Idioma"

View File

@ -2337,9 +2337,6 @@ msgstr "Обновление"
msgid "Update Files"
msgstr "Обновить файлы"
msgid "Update Path"
msgstr "Путь к обновлениям"
msgid "Update all Language Files"
msgstr "Обновить все языковые файлы"

View File

@ -2337,9 +2337,6 @@ msgstr "升级"
msgid "Update Files"
msgstr "升级文件"
msgid "Update Path"
msgstr "升级文件存放路径"
msgid "Update all Language Files"
msgstr "升级全部语言文件"

View File

@ -2337,9 +2337,6 @@ msgstr "Actualizar"
msgid "Update Files"
msgstr "Archivos"
msgid "Update Path"
msgstr "Ruta Actualización"
msgid "Update all Language Files"
msgstr "Actualizar todos los archivos de Idiomas"

View File

@ -2337,9 +2337,6 @@ msgstr "Uppdatera"
msgid "Update Files"
msgstr "Uppdatera Filer"
msgid "Update Path"
msgstr "Sökväg till uppdatering"
msgid "Update all Language Files"
msgstr "Uppdatera alla språk-filer"

View File

@ -2337,9 +2337,6 @@ msgstr "更新"
msgid "Update Files"
msgstr "更新檔案"
msgid "Update Path"
msgstr "更新路徑"
msgid "Update all Language Files"
msgstr "更新所有語言檔案"

View File

@ -2337,9 +2337,6 @@ msgstr "อัพเดท"
msgid "Update Files"
msgstr "อัพเดทไฟล์"
msgid "Update Path"
msgstr "ที่อยู่ Update"
msgid "Update all Language Files"
msgstr "อัพเดทภาษาทั้งหมด"

View File

@ -2337,9 +2337,6 @@ msgstr "Güncelleme"
msgid "Update Files"
msgstr "Dosyaları Güncelle"
msgid "Update Path"
msgstr "Güncelleme Yolu"
msgid "Update all Language Files"
msgstr "Tüm Dil Dosyalarını Güncelle"

View File

@ -218,6 +218,21 @@ bool StartUpProcess::USBSpinUp()
int StartUpProcess::Run(int argc, char *argv[])
{
// A normal launch should always have the first arg be the path
char *ptr = strrchr(argv[0], '/');
if (ptr && (argv[0][2] == ':' || argv[0][3] == ':'))
{
*ptr = 0;
// HBC doesn't specify the USB port
if (strncmp(argv[0], "usb", 3) == 0)
{
snprintf(Settings.BootDevice, sizeof(Settings.BootDevice), "usb1");
snprintf(Settings.ConfigPath, sizeof(Settings.ConfigPath), "usb1:%s/", argv[0] + 4);
}
else if (strncmp(argv[0], "sd", 2) == 0)
snprintf(Settings.ConfigPath, sizeof(Settings.ConfigPath), "%s/", argv[0]);
gprintf("Loader path: %s\n", Settings.ConfigPath);
}
int quickGameBoot = ParseArguments(argc, argv);
StartUpProcess Process;

View File

@ -931,7 +931,7 @@ int GameBrowseMenu::MainLoop()
gprintf("\tgameCntBtn clicked\n");
gamecntBtn->ResetState();
int choice = WindowPrompt(0, fmt("%s %sGameList ?", tr( "Save Game List to" ), Settings.update_path), "TXT", "CSV", tr( "Back" ));
int choice = WindowPrompt(0, fmt("%s %sGameList ?", tr( "Save Game List to" ), Settings.ConfigPath), "TXT", "CSV", tr( "Back" ));
if (choice)
{
if (save_gamelist(choice == 2))

View File

@ -412,7 +412,7 @@ void ImageDownloader::DownloadImage(const char *url, const char *gameID, const c
void ImageDownloader::CreateCSVLog()
{
char path[200];
snprintf(path, sizeof(path), "%s/MissingImages.csv", Settings.update_path);
snprintf(path, sizeof(path), "%s/MissingImages.csv", Settings.ConfigPath);
FILE *f = fopen(path, "wb");
if(!f) return;

View File

@ -145,7 +145,7 @@ static void UpdateIconPng()
downloadfile("https://raw.githubusercontent.com/wiidev/usbloadergx/updates/icon.png", &file);
if (file.size > 0)
{
snprintf(iconpath, sizeof(iconpath), "%sicon.png", Settings.update_path);
snprintf(iconpath, sizeof(iconpath), "%sicon.png", Settings.ConfigPath);
FILE *pfile = fopen(iconpath, "wb");
if (pfile)
{
@ -163,7 +163,7 @@ static void UpdateMetaXml()
downloadfile("https://raw.githubusercontent.com/wiidev/usbloadergx/updates/meta.xml", &file);
if (file.size > 0)
{
snprintf(xmlpath, sizeof(xmlpath), "%smeta.xml", Settings.update_path);
snprintf(xmlpath, sizeof(xmlpath), "%smeta.xml", Settings.ConfigPath);
FILE *pfile = fopen(xmlpath, "wb");
if (pfile)
{
@ -217,8 +217,8 @@ static int ApplicationDownload(void)
snprintf(tmppath, sizeof(tmppath), "%s/ULNR.wad", Settings.BootDevice);
#else
char realpath[250];
snprintf(realpath, sizeof(realpath), "%sboot.dol", Settings.update_path);
snprintf(tmppath, sizeof(tmppath), "%sboot.tmp", Settings.update_path);
snprintf(realpath, sizeof(realpath), "%sboot.dol", Settings.ConfigPath);
snprintf(tmppath, sizeof(tmppath), "%sboot.tmp", Settings.ConfigPath);
#endif
int ret = DownloadFileToPath(DownloadURL.c_str(), tmppath);
@ -282,12 +282,6 @@ int UpdateApp()
return -1;
}
if (!CreateSubfolder(Settings.update_path))
{
WindowPrompt(tr("Error:"), tr("Can't create directory"), tr("OK"));
return -1;
}
int choice = WindowPrompt(tr("What do you want to update?"), 0, "USB Loader GX", tr("WiiTDB.xml"), tr("Language Files"), tr("Cancel"));
if (choice == 0)
return 0;

View File

@ -1118,14 +1118,13 @@ char *readable_size(float size, char *buf)
bool save_gamelist(bool bCSV) // save gamelist
{
mainWindow->SetState(STATE_DISABLED);
CreateSubfolder(Settings.update_path);
// Save the game list
char tmp[256];
if(bCSV)
snprintf(tmp, sizeof(tmp), "%sGameList.csv", Settings.update_path);
snprintf(tmp, sizeof(tmp), "%sGameList.csv", Settings.ConfigPath);
else
snprintf(tmp, sizeof(tmp), "%sGameList.txt", Settings.update_path);
snprintf(tmp, sizeof(tmp), "%sGameList.txt", Settings.ConfigPath);
FILE *f = fopen(tmp, "w");
if (!f)

View File

@ -175,8 +175,6 @@ bool CGameSettings::Save()
if(ptr)
ptr[0] = 0;
CreateSubfolder(filepath);
FILE * f = fopen(ConfigPath.c_str(), "w");
if (!f) return false;

View File

@ -138,9 +138,6 @@ bool CGameStatistics::Save()
if(ptr)
ptr[0] = 0;
if(!CreateSubfolder(filepath))
return false;
FILE * f = fopen(ConfigPath.c_str(), "w");
if (!f) return false;

View File

@ -44,7 +44,7 @@ CSettings::CSettings()
{
CONF_Init();
strcpy(BootDevice, "sd:");
snprintf(ConfigPath, sizeof(ConfigPath), "%s/config/", BootDevice);
snprintf(ConfigPath, sizeof(ConfigPath), "%s/apps/usbloader_gx/", BootDevice);
this->SetDefault();
FirstTimeRun = true;
}
@ -61,9 +61,8 @@ void CSettings::SetDefault()
snprintf(disc_path, sizeof(disc_path), "%simages/disc/", ConfigPath);
snprintf(titlestxt_path, sizeof(titlestxt_path), "%s", ConfigPath);
snprintf(languagefiles_path, sizeof(languagefiles_path), "%slanguage/", ConfigPath);
snprintf(update_path, sizeof(update_path), "%s/apps/usbloader_gx/", BootDevice);
snprintf(BNRCachePath, sizeof(BNRCachePath), "%s/apps/usbloader_gx/cache_bnr/", BootDevice);
snprintf(GameHeaderCachePath, sizeof(GameHeaderCachePath), "%s/apps/usbloader_gx/cache/", BootDevice);
snprintf(BNRCachePath, sizeof(BNRCachePath), "%scache_bnr/", ConfigPath);
snprintf(GameHeaderCachePath, sizeof(GameHeaderCachePath), "%scache/", ConfigPath);
snprintf(homebrewapps_path, sizeof(homebrewapps_path), "%s/apps/", BootDevice);
snprintf(Cheatcodespath, sizeof(Cheatcodespath), "%s/codes/", BootDevice);
snprintf(TxtCheatcodespath, sizeof(TxtCheatcodespath), "%s/txtcodes/", BootDevice);
@ -317,8 +316,6 @@ bool CSettings::Save()
char filedest[300];
snprintf(filedest, sizeof(filedest), "%sGXGlobal.cfg", ConfigPath);
if(!CreateSubfolder(ConfigPath)) return false;
FILE * file = fopen(filedest, "w");
if (!file) return false;
@ -367,7 +364,6 @@ bool CSettings::Save()
fprintf(file, "ogg_path = %s\n", ogg_path);
fprintf(file, "wiilight = %d\n", wiilight);
fprintf(file, "gameDisplay = %d\n", gameDisplay);
fprintf(file, "update_path = %s\n", update_path);
fprintf(file, "homebrewapps_path = %s\n", homebrewapps_path);
fprintf(file, "BNRCachePath = %s\n", BNRCachePath);
fprintf(file, "GameHeaderCachePath = %s\n", GameHeaderCachePath);
@ -1271,11 +1267,6 @@ bool CSettings::SetSetting(char *name, char *value)
strlcpy(ogg_path, value, sizeof(ogg_path));
return true;
}
else if (strcmp(name, "update_path") == 0)
{
strlcpy(update_path, value, sizeof(update_path));
return true;
}
else if (strcmp(name, "homebrewapps_path") == 0)
{
strlcpy(homebrewapps_path, value, sizeof(homebrewapps_path));
@ -1497,63 +1488,42 @@ bool CSettings::SetSetting(char *name, char *value)
bool CSettings::FindConfig()
{
bool found = false;
char CheckDevice[73];
char CheckPath[300];
std::string device(ConfigPath);
char *ptr = strchr(device.c_str(), ':');
if (ptr)
{
*ptr = 0;
snprintf(BootDevice, sizeof(BootDevice), "%s:", device.c_str());
snprintf(CheckPath, sizeof(CheckPath), "%sGXGlobal.cfg", ConfigPath);
// Enumerate the devices supported by libogc.
for (int i = SD; (i < MAXDEVICES) && !found; ++i)
FILE *fp = fopen(CheckPath, "ab+");
if (fp)
{
fclose(fp);
return true;
}
}
// Enumerate the devices supported by libogc
char CheckDevice[73];
for (int i = SD; i < MAXDEVICES; ++i)
{
snprintf(CheckDevice, sizeof(CheckDevice), "%s:", DeviceName[i]);
if(!found)
{
// Check for the config file in the apps directory.
// Check for the config file in the apps directory
strlcpy(BootDevice, CheckDevice, sizeof(BootDevice));
snprintf(ConfigPath, sizeof(ConfigPath), "%s/apps/usbloader_gx/", BootDevice);
snprintf(CheckPath, sizeof(CheckPath), "%sGXGlobal.cfg", ConfigPath);
found = CheckFile(CheckPath);
}
if(!found)
FILE *fp = fopen(CheckPath, "ab+");
if (fp)
{
// Check for the config file in the config directory.
strlcpy(BootDevice, CheckDevice, sizeof(BootDevice));
snprintf(ConfigPath, sizeof(ConfigPath), "%s/config/", BootDevice);
snprintf(CheckPath, sizeof(CheckPath), "%sGXGlobal.cfg", ConfigPath);
found = CheckFile(CheckPath);
fclose(fp);
return true;
}
}
FILE * testFp = NULL;
//! No existing config so try to find a place where we can write it too
for (int i = SD; (i < MAXDEVICES) && !found; ++i)
{
sprintf(CheckDevice, "%s:", DeviceName[i]);
if (!found)
{
// Check if we can write to the apps directory.
strlcpy(BootDevice, CheckDevice, sizeof(BootDevice));
snprintf(ConfigPath, sizeof(ConfigPath), "%s/apps/usbloader_gx/", BootDevice);
snprintf(CheckPath, sizeof(CheckPath), "%sGXGlobal.cfg", ConfigPath);
testFp = fopen(CheckPath, "wb");
found = (testFp != NULL);
if(testFp) fclose(testFp);
}
if (!found)
{
// Check if we can write to the config directory.
strlcpy(BootDevice, CheckDevice, sizeof(BootDevice));
snprintf(ConfigPath, sizeof(ConfigPath), "%s/config/", BootDevice);
CreateSubfolder(ConfigPath);
snprintf(CheckPath, sizeof(CheckPath), "%sGXGlobal.cfg", ConfigPath);
testFp = fopen(CheckPath, "wb");
found = (testFp != NULL);
if(testFp) fclose(testFp);
}
}
return found;
return false;
}
void CSettings::ParseLine(char *line)

View File

@ -78,7 +78,6 @@ class CSettings
char BcaCodepath[100];
char WipCodepath[100];
char dolpath[100];
char update_path[100];
char homebrewapps_path[100];
char WDMpath[100];
char WiinnertagPath[100];

View File

@ -50,7 +50,6 @@ CustomPathsSM::CustomPathsSM()
Options->SetName(Idx++, tr("Disc Artwork Path"));
Options->SetName(Idx++, tr("Theme Path"));
Options->SetName(Idx++, tr("Titles Path"));
Options->SetName(Idx++, tr("Update Path"));
Options->SetName(Idx++, tr("GCT Cheatcodes Path"));
Options->SetName(Idx++, tr("TXT Cheatcodes Path"));
Options->SetName(Idx++, tr("DOL Path"));
@ -94,9 +93,6 @@ void CustomPathsSM::SetOptionValues()
//! Settings: Titles Path
Options->SetValue(Idx++, Settings.titlestxt_path);
//! Settings: Update Path
Options->SetValue(Idx++, Settings.update_path);
//! Settings: GCT Cheatcodes Path
Options->SetValue(Idx++, Settings.Cheatcodespath);
@ -217,13 +213,6 @@ int CustomPathsSM::GetMenuInternal()
}
}
//! Settings: Update Path
else if (ret == ++Idx)
{
titleTxt->SetText(tr( "Update Path" ));
ChangePath(Settings.update_path, sizeof(Settings.update_path));
}
//! Settings: GCT Cheatcodes Path
else if (ret == ++Idx)
{

View File

@ -600,7 +600,7 @@ int FeatureSettingsMenu::GetMenuInternal()
if(WindowPrompt(tr( "EmuNAND WAD Manager" ), fmt(tr("%i WAD file(s) not processed!"), wadList->GetFilecount()), tr("Save List"), tr( "OK" )))
{
char path[200];
snprintf(path, sizeof(path), "%s/wad_manager_errors.txt", Settings.update_path);
snprintf(path, sizeof(path), "%s/wad_manager_errors.txt", Settings.ConfigPath);
FILE *f = fopen(path, "a");
if(f)

View File

@ -25,12 +25,12 @@ distribution.
#include "settings/CSettings.h"
#include "svnrev.h"
int updateMetaXML (void)
int updateMetaXML()
{
HomebrewXML MetaXML;
char filepath[255];
snprintf(filepath, sizeof(filepath), "%s/meta.xml", Settings.update_path);
if(!MetaXML.LoadHomebrewXMLData(filepath))
snprintf(filepath, sizeof(filepath), "%smeta.xml", Settings.ConfigPath);
if (!MetaXML.LoadHomebrewXMLData(filepath))
return 0;
char line[50];
@ -47,22 +47,19 @@ int updateMetaXML (void)
return ret;
}
int editMetaArguments (void)
int editMetaArguments()
{
char metapath[255] = "";
char metatmppath[255] = "";
snprintf(metapath, sizeof(metapath), "%s/meta.xml", Settings.update_path);
snprintf(metatmppath, sizeof(metatmppath), "%s/meta.tmp", Settings.update_path);
snprintf(metapath, sizeof(metapath), "%smeta.xml", Settings.ConfigPath);
snprintf(metatmppath, sizeof(metatmppath), "%smeta.tmp", Settings.ConfigPath);
FILE *source = fopen(metapath, "rb");
if(!source)
{
if (!source)
return 0;
}
FILE *destination = fopen(metatmppath, "wb");
if(!destination)
if (!destination)
{
fclose(source);
return 0;
@ -73,20 +70,20 @@ int editMetaArguments (void)
while (fgets(line, max_line_size, source) != NULL)
{
// delete commented lines
if( strstr(line, " <!-- remove this line to enable arguments") != NULL ||
if (strstr(line, " <!-- remove this line to enable arguments") != NULL ||
strstr(line, " remove this line to enable arguments -->") != NULL)
{
strcpy(line, "");
}
// delete commented lines (old version)
if( strstr(line, "<!-- // remove this line to enable arguments") != NULL ||
if (strstr(line, "<!-- // remove this line to enable arguments") != NULL ||
strstr(line, "// remove this line to enable arguments -->") != NULL)
{
strcpy(line, "");
}
// generate argurments
if(strstr(line, "<arguments>") != NULL)
if (strstr(line, "<arguments>") != NULL)
{
fputs(line, destination);
snprintf(line, max_line_size, " <arg>--bootios=%d</arg>\n", Settings.BootIOS);
@ -96,14 +93,14 @@ int editMetaArguments (void)
snprintf(line, max_line_size, " <arg>--mountusb=%d</arg>\n", Settings.USBAutoMount);
fputs(line, destination);
while(strstr(line, "</arguments>") == NULL)
while (strstr(line, "</arguments>") == NULL)
{
fgets(line, max_line_size, source); // advance one line
if(feof(source))
if (feof(source))
{
fclose(source);
fclose(destination);
delete [] line;
delete[] line;
return 0;
}
}
@ -113,7 +110,7 @@ int editMetaArguments (void)
fclose(source);
fclose(destination);
delete [] line;
delete[] line;
if(CopyFile(metatmppath, metapath) <0)
return 0;

View File

@ -24,7 +24,7 @@
#ifndef _META_H_
#define _META_H_
int updateMetaXML(void);
int editMetaArguments(void);
int updateMetaXML();
int editMetaArguments();
#endif

View File

@ -239,7 +239,7 @@ void Sys_LoadHBC(void)
bool RebootApp(void)
{
// be sure to use current settings as arguments
// Be sure to use current settings as arguments
editMetaArguments();
#ifdef FULLCHANNEL
@ -251,12 +251,12 @@ bool RebootApp(void)
// Load meta.xml arguments
char filepath[255];
HomebrewXML MetaXML;
snprintf(filepath, sizeof(filepath), "%s/meta.xml", Settings.update_path);
snprintf(filepath, sizeof(filepath), "%smeta.xml", Settings.ConfigPath);
MetaXML.LoadHomebrewXMLData(filepath);
u8 *buffer = NULL;
u32 filesize = 0;
snprintf(filepath, sizeof(filepath), "%s/boot.dol", Settings.update_path);
snprintf(filepath, sizeof(filepath), "%sboot.dol", Settings.ConfigPath);
LoadFileToMem(filepath, &buffer, &filesize);
if(!buffer)
{
@ -299,12 +299,6 @@ void ScreenShot()
// Create the full pathname.
snprintf(fullPath, sizeof(fullPath), "%s%s", Settings.ConfigPath, filename);
if(!CreateSubfolder(Settings.ConfigPath))
{
gprintf("Can't create screenshot folder\n");
return;
}
TakeScreenshot(fullPath);
}