2010-09-24 02:48:03 +02:00
|
|
|
/****************************************************************************
|
2010-09-19 22:25:12 +02:00
|
|
|
* Copyright (C) 2010
|
|
|
|
* by Dimok
|
|
|
|
*
|
|
|
|
* This software is provided 'as-is', without any express or implied
|
|
|
|
* warranty. In no event will the authors be held liable for any
|
|
|
|
* damages arising from the use of this software.
|
|
|
|
*
|
|
|
|
* Permission is granted to anyone to use this software for any
|
|
|
|
* purpose, including commercial applications, and to alter it and
|
|
|
|
* redistribute it freely, subject to the following restrictions:
|
|
|
|
*
|
|
|
|
* 1. The origin of this software must not be misrepresented; you
|
|
|
|
* must not claim that you wrote the original software. If you use
|
|
|
|
* this software in a product, an acknowledgment in the product
|
|
|
|
* documentation would be appreciated but is not required.
|
|
|
|
*
|
|
|
|
* 2. Altered source versions must be plainly marked as such, and
|
|
|
|
* must not be misrepresented as being the original software.
|
|
|
|
*
|
|
|
|
* 3. This notice may not be removed or altered from any source
|
|
|
|
* distribution.
|
|
|
|
***************************************************************************/
|
|
|
|
#include <ogcsys.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "CSettings.h"
|
2010-09-25 08:54:27 +02:00
|
|
|
#include "CGameSettings.h"
|
2010-09-25 10:51:44 +02:00
|
|
|
#include "CGameStatistics.h"
|
2010-12-31 00:49:22 +01:00
|
|
|
#include "Controls/DeviceHandler.hpp"
|
2010-09-19 22:25:12 +02:00
|
|
|
#include "language/gettext.h"
|
2010-09-24 19:58:56 +02:00
|
|
|
#include "themes/CTheme.h"
|
2010-09-25 08:54:27 +02:00
|
|
|
#include "FileOperations/fileops.h"
|
*Completely rewrote the asynchron GuiImageData class (problems from switch Carousel<->Grid layour should be fixed now)
*Fixed bug mounting a wbfs partition which was formatted from an ext partition
*Rewrote the parental control feature. Removed loading pin or settings from the Wii Settings. Parental control is now completely managed in the loader from the settings selected and the password set.
*Saving password in config file is now encrypted
*Added loop to wait for usb when reloading the cIOS before game start
The parental control feature is filtering games like following when usb loader is locked:
level 0 (everyone 0+) > shows only games with lvl 0
level 1 (childs 7+) > shows games with lvl 0, 1
level 2 (teens 12+) > shows games with lvl 0, 1, 2
level 3 (mature 16+) > shows games with lvl 0, 1, 2, 3
level 4 (adults only 18+) > shows all games (lvl 0, 1, 2, 3, 4)
level 4 is default when creating new configs
2010-12-19 19:20:33 +01:00
|
|
|
#include "utils/encrypt.h"
|
2011-01-06 19:59:45 +01:00
|
|
|
#include "svnrev.h"
|
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
#define VALID_CONFIG_REV 1031
|
2010-09-19 22:25:12 +02:00
|
|
|
|
|
|
|
CSettings Settings;
|
|
|
|
|
|
|
|
CSettings::CSettings()
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
CONF_Init();
|
|
|
|
strcpy(BootDevice, "sd:");
|
|
|
|
snprintf(ConfigPath, sizeof(ConfigPath), "%s/config/", BootDevice);
|
|
|
|
this->SetDefault();
|
2011-12-22 23:44:48 +01:00
|
|
|
FirstTimeRun = true;
|
2010-09-19 22:25:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CSettings::~CSettings()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSettings::SetDefault()
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
snprintf(covers_path, sizeof(covers_path), "%simages/", ConfigPath);
|
|
|
|
snprintf(covers2d_path, sizeof(covers2d_path), "%simages/2D/", ConfigPath);
|
|
|
|
snprintf(coversFull_path, sizeof(coversFull_path), "%simages/full/", ConfigPath);
|
|
|
|
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);
|
2012-05-06 12:59:58 +02:00
|
|
|
snprintf(BNRCachePath, sizeof(BNRCachePath), "%s/apps/usbloader_gx/cache_bnr/", BootDevice);
|
2011-07-26 00:28:22 +02:00
|
|
|
snprintf(homebrewapps_path, sizeof(homebrewapps_path), "%s/apps/", BootDevice);
|
|
|
|
snprintf(Cheatcodespath, sizeof(Cheatcodespath), "%s/codes/", BootDevice);
|
|
|
|
snprintf(TxtCheatcodespath, sizeof(TxtCheatcodespath), "%s/txtcodes/", BootDevice);
|
|
|
|
snprintf(BcaCodepath, sizeof(BcaCodepath), "%s/bca/", BootDevice);
|
|
|
|
snprintf(WipCodepath, sizeof(WipCodepath), "%s/wip/", BootDevice);
|
|
|
|
snprintf(WDMpath, sizeof(WDMpath), "%s/wdm/", BootDevice);
|
|
|
|
snprintf(WiinnertagPath, sizeof(WiinnertagPath), "%s", ConfigPath);
|
|
|
|
snprintf(theme_path, sizeof(theme_path), "%stheme/", ConfigPath);
|
|
|
|
snprintf(dolpath, sizeof(dolpath), "%s/", BootDevice);
|
|
|
|
snprintf(NandEmuPath, sizeof(NandEmuPath), "%s/nand/", BootDevice);
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(NandEmuChanPath, NandEmuPath, sizeof(NandEmuChanPath));
|
|
|
|
strlcpy(GameCubePath, "sd:/games/", sizeof(GameCubePath));
|
|
|
|
strlcpy(GameCubeSDPath, "sd:/games/", sizeof(GameCubeSDPath));
|
2012-07-16 18:07:24 +02:00
|
|
|
strlcpy(DEVOLoaderPath, "sd:/apps/gc_devo/", sizeof(DEVOLoaderPath));
|
2012-05-06 12:59:58 +02:00
|
|
|
theme[0] = 0;
|
|
|
|
language_path[0] = 0;
|
|
|
|
ogg_path[0] = 0;
|
|
|
|
unlockCode[0] = 0;
|
|
|
|
db_language[0] = 0;
|
|
|
|
returnTo[0] = 0;
|
|
|
|
|
|
|
|
NTSC = (CONF_GetVideo() == CONF_VIDEO_NTSC);
|
|
|
|
PAL50 = (CONF_GetVideo() == CONF_VIDEO_PAL) && (CONF_GetEuRGB60() == 0);
|
|
|
|
widescreen = (CONF_GetAspectRatio() == CONF_ASPECT_16_9);
|
2011-07-26 00:28:22 +02:00
|
|
|
|
|
|
|
godmode = 1;
|
|
|
|
videomode = VIDEO_MODE_DISCDEFAULT;
|
|
|
|
videopatch = OFF;
|
|
|
|
language = CONSOLE_DEFAULT;
|
|
|
|
ocarina = OFF;
|
|
|
|
hddinfo = CLOCK_HR12;
|
|
|
|
sinfo = ON;
|
|
|
|
rumble = ON;
|
|
|
|
GameSort = SORT_ABC;
|
|
|
|
volume = 80;
|
|
|
|
sfxvolume = 80;
|
|
|
|
gamesoundvolume = 80;
|
|
|
|
tooltips = ON;
|
|
|
|
gamesound = ON;
|
|
|
|
parentalcontrol = PARENTAL_LVL_ADULT;
|
|
|
|
cios = BUILD_IOS;
|
|
|
|
gridRows = 3;
|
|
|
|
error002 = 2;
|
2011-12-22 23:44:48 +01:00
|
|
|
partition = 0;
|
2011-07-26 00:28:22 +02:00
|
|
|
discart = DISCARTS_ORIGINALS_CUSTOMS;
|
|
|
|
xflip = XFLIP_NO;
|
|
|
|
quickboot = OFF;
|
|
|
|
wiilight = WIILIGHT_ON;
|
|
|
|
autonetwork = OFF;
|
|
|
|
patchcountrystrings = OFF;
|
|
|
|
titlesOverride = ON;
|
2012-02-29 20:52:36 +01:00
|
|
|
ForceDiscTitles = OFF;
|
2011-07-26 00:28:22 +02:00
|
|
|
screensaver = SCREENSAVER_10_MIN;
|
|
|
|
musicloopmode = ON;
|
|
|
|
marknewtitles = ON;
|
|
|
|
ShowFreeSpace = ON;
|
2012-02-29 20:52:36 +01:00
|
|
|
PlaylogUpdate = OFF;
|
2011-07-26 00:28:22 +02:00
|
|
|
ParentalBlocks = BLOCK_ALL;
|
|
|
|
InstallToDir = INSTALL_TO_NAME_GAMEID;
|
|
|
|
GameSplit = GAMESPLIT_4GB;
|
|
|
|
InstallPartitions = ONLY_GAME_PARTITION;
|
|
|
|
HomeMenu = HOME_MENU_DEFAULT;
|
|
|
|
MultiplePartitions = OFF;
|
|
|
|
BlockIOSReload = AUTO;
|
|
|
|
USBPort = 0;
|
|
|
|
CacheTitles = ON;
|
|
|
|
WSFactor = 0.8f; //actually should be 0.75 for real widescreen
|
|
|
|
FontScaleFactor = 0.8f; //it's a work around to not have to change ALL fonts now
|
2012-05-19 15:40:58 +02:00
|
|
|
ClockFontScaleFactor = 1.0f; // Scale of 1 to prevent misaligned clock.
|
2011-07-26 00:28:22 +02:00
|
|
|
EnabledCategories.resize(1);
|
|
|
|
EnabledCategories[0] = 0;
|
2012-06-09 14:20:14 +02:00
|
|
|
RequiredCategories.resize(0);
|
|
|
|
ForbiddenCategories.resize(0);
|
2011-07-26 00:28:22 +02:00
|
|
|
Wiinnertag = OFF;
|
|
|
|
SelectedGame = 0;
|
|
|
|
GameListOffset = 0;
|
|
|
|
sneekVideoPatch = OFF;
|
|
|
|
NandEmuMode = OFF;
|
2012-01-08 19:24:46 +01:00
|
|
|
NandEmuChanMode = 2;
|
2011-07-26 00:28:22 +02:00
|
|
|
UseSystemFont = ON;
|
2011-07-29 22:59:31 +02:00
|
|
|
Hooktype = 0;
|
|
|
|
WiirdDebugger = OFF;
|
|
|
|
WiirdDebuggerPause = OFF;
|
2011-09-04 12:13:47 +02:00
|
|
|
ShowPlayCount = ON;
|
2011-09-10 22:08:12 +02:00
|
|
|
RememberUnlock = ON;
|
2011-12-22 23:44:48 +01:00
|
|
|
LoaderMode = MODE_WIIGAMES;
|
2011-11-12 19:14:09 +01:00
|
|
|
SearchMode = SEARCH_BEGINNING;
|
2011-12-23 16:48:20 +01:00
|
|
|
GameAspectRatio = ASPECT_SYSTEM_DEFAULT;
|
2012-01-23 22:26:41 +01:00
|
|
|
PointerSpeed = 0.18f;
|
2012-01-08 19:24:46 +01:00
|
|
|
UseChanLauncher = OFF;
|
2012-02-05 19:38:26 +01:00
|
|
|
AdjustOverscanX = 0;
|
|
|
|
AdjustOverscanY = 0;
|
2012-05-06 12:59:58 +02:00
|
|
|
TooltipDelay = 1500; // ms
|
|
|
|
GameWindowMode = GAMEWINDOW_BANNER;
|
|
|
|
CacheBNRFiles = ON;
|
|
|
|
BannerAnimStart = BANNER_START_ON_ZOOM;
|
|
|
|
BannerGridSpeed = 25.6f; // pixel/frames
|
|
|
|
BannerZoomDuration = 30; // frames
|
|
|
|
BannerProjectionOffsetX = (!widescreen || PAL50) ? 0.0f : 2.0f;
|
|
|
|
BannerProjectionOffsetY = PAL50 ? -1.0f : (NTSC ? 0.0f : -4.0f);
|
|
|
|
BannerProjectionWidth = (Settings.widescreen ? (Settings.PAL50 ? 616 : 620.0f) : 608.0f);
|
|
|
|
BannerProjectionHeight = (Settings.PAL50 ? 448.0f : (NTSC ? 470.0f : 464.0f));
|
|
|
|
GCBannerScale = 1.5f;
|
2012-07-16 18:07:24 +02:00
|
|
|
GameCubeMode = GC_MODE_MIOS;
|
2012-07-19 22:13:39 +02:00
|
|
|
DMLConfigVersion = DML_VERSION;
|
2012-07-16 18:07:24 +02:00
|
|
|
DMLProgPatch = OFF;
|
2012-05-06 12:59:58 +02:00
|
|
|
DMLNMM = OFF;
|
|
|
|
DMLActivityLED = OFF;
|
|
|
|
DMLPADHOOK = OFF;
|
|
|
|
DMLNoDisc = OFF;
|
2012-07-19 22:13:39 +02:00
|
|
|
DMLWidescreen = OFF;
|
2012-05-06 12:59:58 +02:00
|
|
|
DMLDebug = OFF;
|
2012-07-16 18:07:24 +02:00
|
|
|
DEVOMCEmulation = OFF;
|
2012-05-06 12:59:58 +02:00
|
|
|
GCInstallCompressed = OFF;
|
|
|
|
GCInstallAligned = OFF;
|
2010-09-24 19:58:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CSettings::Load()
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
FindConfig();
|
|
|
|
//! Reset default path variables to the right device
|
|
|
|
SetDefault();
|
2010-09-24 19:58:56 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
char filepath[300];
|
|
|
|
snprintf(filepath, sizeof(filepath), "%sGXGlobal.cfg", ConfigPath);
|
2010-09-24 19:58:56 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
FILE * file = fopen(filepath, "r");
|
|
|
|
if (!file) return false;
|
2010-09-24 19:58:56 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
if(!ValidVersion(file))
|
|
|
|
{
|
|
|
|
fclose(file);
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-06 19:59:45 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
char line[1024];
|
2011-01-06 19:59:45 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
while (fgets(line, sizeof(line), file))
|
|
|
|
{
|
|
|
|
if (line[0] == '#') continue;
|
2010-09-24 19:58:56 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
this->ParseLine(line);
|
|
|
|
}
|
|
|
|
fclose(file);
|
2010-09-24 19:58:56 +02:00
|
|
|
|
2011-12-22 23:44:48 +01:00
|
|
|
// A valid config file exists on the loader
|
|
|
|
// meaning it is not the first run of the loader.
|
|
|
|
FirstTimeRun = false;
|
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
2011-01-06 19:59:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CSettings::ValidVersion(FILE * file)
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
if(!file) return false;
|
2011-01-06 19:59:45 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
char line[255];
|
|
|
|
int revision = 0;
|
2010-09-24 19:58:56 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
while (fgets(line, sizeof(line), file))
|
|
|
|
{
|
|
|
|
const char * ptr = strcasestr(line, "USB Loader GX R");
|
|
|
|
if(ptr)
|
|
|
|
{
|
|
|
|
ptr += strlen("USB Loader GX R");
|
|
|
|
revision = atoi(ptr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-01-06 19:59:45 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
rewind(file);
|
2011-01-06 19:59:45 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
return revision >= VALID_CONFIG_REV;
|
2010-09-24 19:58:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CSettings::Reset()
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
this->SetDefault();
|
2010-09-24 19:58:56 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
if (this->Save()) return true;
|
2010-09-24 19:58:56 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
return false;
|
2010-09-19 22:25:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CSettings::Save()
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
if (!FindConfig()) return false;
|
|
|
|
|
|
|
|
char filedest[300];
|
|
|
|
snprintf(filedest, sizeof(filedest), "%sGXGlobal.cfg", ConfigPath);
|
|
|
|
|
|
|
|
if(!CreateSubfolder(ConfigPath)) return false;
|
|
|
|
|
|
|
|
FILE * file = fopen(filedest, "w");
|
|
|
|
if (!file) return false;
|
|
|
|
|
|
|
|
fprintf(file, "# USB Loader GX R%s - Main settings file\n", GetRev());
|
|
|
|
fprintf(file, "# Note: This file is automatically generated\n");
|
|
|
|
fprintf(file, "godmode = %d\n", godmode);
|
|
|
|
fprintf(file, "videomode = %d\n", videomode);
|
|
|
|
fprintf(file, "videopatch = %d\n", videopatch);
|
|
|
|
fprintf(file, "language = %d\n", language);
|
|
|
|
fprintf(file, "ocarina = %d\n", ocarina);
|
|
|
|
fprintf(file, "hddinfo = %d\n", hddinfo);
|
|
|
|
fprintf(file, "sinfo = %d\n", sinfo);
|
|
|
|
fprintf(file, "rumble = %d\n", rumble);
|
|
|
|
fprintf(file, "volume = %d\n", volume);
|
|
|
|
fprintf(file, "sfxvolume = %d\n", sfxvolume);
|
|
|
|
fprintf(file, "gamesoundvolume = %d\n", gamesoundvolume);
|
|
|
|
fprintf(file, "tooltips = %d\n", tooltips);
|
2011-09-10 22:08:12 +02:00
|
|
|
fprintf(file, "RememberUnlock = %d\n", RememberUnlock);
|
2011-07-26 00:28:22 +02:00
|
|
|
char EncryptedTxt[50];
|
|
|
|
EncryptString(unlockCode, EncryptedTxt);
|
|
|
|
fprintf(file, "password = %s\n", EncryptedTxt);
|
|
|
|
fprintf(file, "GameSort = %d\n", GameSort);
|
|
|
|
fprintf(file, "cios = %d\n", cios);
|
|
|
|
fprintf(file, "keyset = %d\n", keyset);
|
|
|
|
fprintf(file, "xflip = %d\n", xflip);
|
|
|
|
fprintf(file, "gridRows = %d\n", gridRows);
|
|
|
|
fprintf(file, "quickboot = %d\n", quickboot);
|
|
|
|
fprintf(file, "wsprompt = %d\n", wsprompt);
|
|
|
|
fprintf(file, "parentalcontrol = %d\n", parentalcontrol);
|
|
|
|
fprintf(file, "covers_path = %s\n", covers_path);
|
|
|
|
fprintf(file, "covers2d_path = %s\n", covers2d_path);
|
|
|
|
fprintf(file, "coversFull_path = %s\n", coversFull_path);
|
|
|
|
fprintf(file, "theme_path = %s\n", theme_path);
|
|
|
|
fprintf(file, "theme = %s\n", theme);
|
|
|
|
fprintf(file, "disc_path = %s\n", disc_path);
|
|
|
|
fprintf(file, "language_path = %s\n", language_path);
|
|
|
|
fprintf(file, "languagefiles_path = %s\n", languagefiles_path);
|
|
|
|
fprintf(file, "TxtCheatcodespath = %s\n", TxtCheatcodespath);
|
|
|
|
fprintf(file, "titlestxt_path = %s\n", titlestxt_path);
|
|
|
|
fprintf(file, "gamesound = %d\n", gamesound);
|
|
|
|
fprintf(file, "dolpath = %s\n", dolpath);
|
|
|
|
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);
|
2012-05-06 12:59:58 +02:00
|
|
|
fprintf(file, "BNRCachePath = %s\n", BNRCachePath);
|
2011-07-26 00:28:22 +02:00
|
|
|
fprintf(file, "Cheatcodespath = %s\n", Cheatcodespath);
|
|
|
|
fprintf(file, "BcaCodepath = %s\n", BcaCodepath);
|
|
|
|
fprintf(file, "WipCodepath = %s\n", WipCodepath);
|
2012-05-06 12:59:58 +02:00
|
|
|
fprintf(file, "WDMpath = %s\n", WDMpath);
|
2011-07-26 00:28:22 +02:00
|
|
|
fprintf(file, "titlesOverride = %d\n", titlesOverride);
|
2012-02-29 20:52:36 +01:00
|
|
|
fprintf(file, "ForceDiscTitles = %d\n", ForceDiscTitles);
|
2011-07-26 00:28:22 +02:00
|
|
|
fprintf(file, "patchcountrystrings = %d\n", patchcountrystrings);
|
|
|
|
fprintf(file, "screensaver = %d\n", screensaver);
|
|
|
|
fprintf(file, "musicloopmode = %d\n", musicloopmode);
|
|
|
|
fprintf(file, "error002 = %d\n", error002);
|
|
|
|
fprintf(file, "autonetwork = %d\n", autonetwork);
|
|
|
|
fprintf(file, "discart = %d\n", discart);
|
|
|
|
fprintf(file, "partition = %d\n", partition);
|
|
|
|
fprintf(file, "marknewtitles = %d\n", marknewtitles);
|
|
|
|
fprintf(file, "ShowFreeSpace = %d\n", ShowFreeSpace);
|
|
|
|
fprintf(file, "InstallToDir = %d\n", InstallToDir);
|
|
|
|
fprintf(file, "GameSplit = %d\n", GameSplit);
|
|
|
|
fprintf(file, "InstallPartitions = %08X\n", InstallPartitions);
|
|
|
|
fprintf(file, "PlaylogUpdate = %d\n", PlaylogUpdate);
|
|
|
|
fprintf(file, "ParentalBlocks = %08X\n", ParentalBlocks);
|
|
|
|
fprintf(file, "returnTo = %s\n", returnTo);
|
|
|
|
fprintf(file, "HomeMenu = %d\n", HomeMenu);
|
|
|
|
fprintf(file, "MultiplePartitions = %d\n", MultiplePartitions);
|
|
|
|
fprintf(file, "USBPort = %d\n", USBPort);
|
|
|
|
fprintf(file, "CacheTitles = %d\n", CacheTitles);
|
|
|
|
fprintf(file, "BlockIOSReload = %d\n", BlockIOSReload);
|
|
|
|
fprintf(file, "WSFactor = %0.3f\n", WSFactor);
|
|
|
|
fprintf(file, "FontScaleFactor = %0.3f\n", FontScaleFactor);
|
2012-05-19 15:40:58 +02:00
|
|
|
fprintf(file, "ClockFontScaleFactor = %0.3f\n", ClockFontScaleFactor);
|
2011-07-26 00:28:22 +02:00
|
|
|
fprintf(file, "EnabledCategories = ");
|
|
|
|
for(u32 i = 0; i < EnabledCategories.size(); ++i)
|
|
|
|
{
|
|
|
|
fprintf(file, "%i", EnabledCategories[i]);
|
|
|
|
if(i+1 < EnabledCategories.size())
|
|
|
|
fprintf(file, ",");
|
|
|
|
}
|
|
|
|
fprintf(file, "\n");
|
2012-06-09 14:20:14 +02:00
|
|
|
fprintf(file, "RequiredCategories = ");
|
|
|
|
for(u32 i = 0; i < RequiredCategories.size(); ++i)
|
|
|
|
{
|
|
|
|
fprintf(file, "%i", RequiredCategories[i]);
|
|
|
|
if(i+1 < RequiredCategories.size())
|
|
|
|
fprintf(file, ",");
|
|
|
|
}
|
|
|
|
fprintf(file, "\n");
|
|
|
|
fprintf(file, "ForbiddenCategories = ");
|
|
|
|
for(u32 i = 0; i < ForbiddenCategories.size(); ++i)
|
|
|
|
{
|
|
|
|
fprintf(file, "%i", ForbiddenCategories[i]);
|
|
|
|
if(i+1 < ForbiddenCategories.size())
|
|
|
|
fprintf(file, ",");
|
|
|
|
}
|
|
|
|
fprintf(file, "\n");
|
2011-07-26 00:28:22 +02:00
|
|
|
fprintf(file, "Wiinnertag = %d\n", Wiinnertag);
|
|
|
|
fprintf(file, "WiinnertagPath = %s\n", WiinnertagPath);
|
|
|
|
fprintf(file, "SelectedGame = %d\n", SelectedGame);
|
|
|
|
fprintf(file, "GameListOffset = %d\n", GameListOffset);
|
|
|
|
fprintf(file, "sneekVideoPatch = %d\n", sneekVideoPatch);
|
|
|
|
fprintf(file, "NandEmuMode = %d\n", NandEmuMode);
|
2012-01-08 19:24:46 +01:00
|
|
|
fprintf(file, "NandEmuChanMode = %d\n", NandEmuChanMode);
|
2011-07-26 00:28:22 +02:00
|
|
|
fprintf(file, "NandEmuPath = %s\n", NandEmuPath);
|
2011-11-12 19:14:09 +01:00
|
|
|
fprintf(file, "NandEmuChanPath = %s\n", NandEmuChanPath);
|
2011-07-26 00:28:22 +02:00
|
|
|
fprintf(file, "UseSystemFont = %d\n", UseSystemFont);
|
2011-07-29 22:59:31 +02:00
|
|
|
fprintf(file, "Hooktype = %d\n", Hooktype);
|
|
|
|
fprintf(file, "WiirdDebugger = %d\n", WiirdDebugger);
|
|
|
|
fprintf(file, "WiirdDebuggerPause = %d\n", WiirdDebuggerPause);
|
2011-09-04 12:13:47 +02:00
|
|
|
fprintf(file, "ShowPlayCount = %d\n", ShowPlayCount);
|
2011-11-12 19:14:09 +01:00
|
|
|
fprintf(file, "LoaderMode = %d\n", LoaderMode);
|
|
|
|
fprintf(file, "SearchMode = %d\n", SearchMode);
|
2011-12-23 16:48:20 +01:00
|
|
|
fprintf(file, "GameAspectRatio = %d\n", GameAspectRatio);
|
2011-12-28 17:27:30 +01:00
|
|
|
fprintf(file, "PointerSpeed = %g\n", PointerSpeed);
|
2012-01-08 19:24:46 +01:00
|
|
|
fprintf(file, "UseChanLauncher = %d\n", UseChanLauncher);
|
2012-02-05 19:38:26 +01:00
|
|
|
fprintf(file, "AdjustOverscanX = %d\n", AdjustOverscanX);
|
|
|
|
fprintf(file, "AdjustOverscanY = %d\n", AdjustOverscanY);
|
2012-05-06 12:59:58 +02:00
|
|
|
fprintf(file, "TooltipDelay = %d\n", TooltipDelay);
|
|
|
|
fprintf(file, "GameWindowMode = %d\n", GameWindowMode);
|
|
|
|
fprintf(file, "CacheBNRFiles = %d\n", CacheBNRFiles);
|
|
|
|
fprintf(file, "BannerAnimStart = %d\n", BannerAnimStart);
|
|
|
|
fprintf(file, "BannerGridSpeed = %g\n", BannerGridSpeed);
|
|
|
|
fprintf(file, "BannerZoomDuration = %d\n", BannerZoomDuration);
|
|
|
|
fprintf(file, "BannerProjectionOffsetX = %g\n", BannerProjectionOffsetX);
|
|
|
|
fprintf(file, "BannerProjectionOffsetY = %g\n", BannerProjectionOffsetY);
|
|
|
|
fprintf(file, "BannerProjectionWidth = %g\n", BannerProjectionWidth);
|
|
|
|
fprintf(file, "BannerProjectionHeight = %g\n", BannerProjectionHeight);
|
|
|
|
fprintf(file, "GCBannerScale = %g\n", GCBannerScale);
|
|
|
|
fprintf(file, "GameCubePath = %s\n", GameCubePath);
|
|
|
|
fprintf(file, "GameCubeSDPath = %s\n", GameCubeSDPath);
|
2012-07-16 18:07:24 +02:00
|
|
|
fprintf(file, "GameCubeMode = %d\n", GameCubeMode);
|
2012-07-19 22:13:39 +02:00
|
|
|
fprintf(file, "DMLConfigVersion = %d\n", DMLConfigVersion);
|
2012-07-16 18:07:24 +02:00
|
|
|
fprintf(file, "DMLProgPatch = %d\n", DMLProgPatch);
|
2012-05-06 12:59:58 +02:00
|
|
|
fprintf(file, "DMLNMM = %d\n", DMLNMM);
|
|
|
|
fprintf(file, "DMLActivityLED = %d\n", DMLActivityLED);
|
|
|
|
fprintf(file, "DMLPADHOOK = %d\n", DMLPADHOOK);
|
|
|
|
fprintf(file, "DMLNoDisc = %d\n", DMLNoDisc);
|
2012-07-19 22:13:39 +02:00
|
|
|
fprintf(file, "DMLWidescreen = %d\n", DMLWidescreen);
|
2012-05-06 12:59:58 +02:00
|
|
|
fprintf(file, "DMLDebug = %d\n", DMLDebug);
|
2012-07-16 18:07:24 +02:00
|
|
|
fprintf(file, "DEVOMCEmulation = %d\n", DEVOMCEmulation);
|
|
|
|
fprintf(file, "DEVOLoaderPath = %s\n", DEVOLoaderPath);
|
2012-05-06 12:59:58 +02:00
|
|
|
fprintf(file, "GCInstallCompressed = %d\n", GCInstallCompressed);
|
|
|
|
fprintf(file, "GCInstallAligned = %d\n", GCInstallAligned);
|
2011-07-26 00:28:22 +02:00
|
|
|
fclose(file);
|
|
|
|
|
|
|
|
return true;
|
2010-09-19 22:25:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CSettings::SetSetting(char *name, char *value)
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
if (strcmp(name, "godmode") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
godmode = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "videomode") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
videomode = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "videopatch") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
videopatch = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "language") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
language = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "ocarina") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
ocarina = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "hddinfo") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
hddinfo = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "sinfo") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
sinfo = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "rumble") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
rumble = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "volume") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
volume = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "sfxvolume") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
sfxvolume = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "gamesoundvolume") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
gamesoundvolume = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "tooltips") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
tooltips = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
2011-09-10 22:08:12 +02:00
|
|
|
else if (strcmp(name, "RememberUnlock") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
RememberUnlock = atoi(value);
|
2011-09-10 22:08:12 +02:00
|
|
|
return true;
|
|
|
|
}
|
2011-07-26 00:28:22 +02:00
|
|
|
else if (strcmp(name, "password") == 0)
|
|
|
|
{
|
|
|
|
char EncryptedTxt[50];
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(EncryptedTxt, value, sizeof(EncryptedTxt));
|
2011-07-26 00:28:22 +02:00
|
|
|
DecryptString(EncryptedTxt, unlockCode);
|
2011-09-10 22:08:12 +02:00
|
|
|
|
|
|
|
if(!RememberUnlock && strlen(unlockCode) > 0 && strcmp(unlockCode, "not set") != 0)
|
|
|
|
godmode = 0;
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "GameSort") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
GameSort = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "cios") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
cios = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "keyset") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
keyset = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "xflip") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
xflip = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "gridRows") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
gridRows = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "quickboot") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
quickboot = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "partition") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
partition = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "wsprompt") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
wsprompt = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "gameDisplay") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
gameDisplay = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "parentalcontrol") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
parentalcontrol = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "screensaver") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
screensaver = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "titlesOverride") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
titlesOverride = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
2012-02-29 20:52:36 +01:00
|
|
|
else if (strcmp(name, "ForceDiscTitles") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
ForceDiscTitles = atoi(value);
|
2012-02-29 20:52:36 +01:00
|
|
|
return true;
|
|
|
|
}
|
2011-07-26 00:28:22 +02:00
|
|
|
else if (strcmp(name, "musicloopmode") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
musicloopmode = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "gamesound") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
gamesound = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "wiilight") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
wiilight = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "marknewtitles") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
marknewtitles = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
2011-09-04 12:13:47 +02:00
|
|
|
else if (strcmp(name, "ShowPlayCount") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
ShowPlayCount = atoi(value);
|
2011-09-04 12:13:47 +02:00
|
|
|
return true;
|
|
|
|
}
|
2011-07-26 00:28:22 +02:00
|
|
|
else if (strcmp(name, "ShowFreeSpace") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
ShowFreeSpace = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "HomeMenu") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
HomeMenu = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "MultiplePartitions") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
MultiplePartitions = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "BlockIOSReload") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
BlockIOSReload = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "USBPort") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
USBPort = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "CacheTitles") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
CacheTitles = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "patchcountrystrings") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
patchcountrystrings = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "discart") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
discart = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "error002") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
error002 = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "autonetwork") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
autonetwork = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "InstallToDir") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
InstallToDir = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "GameSplit") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
GameSplit = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "PlaylogUpdate") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
PlaylogUpdate = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "Wiinnertag") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
Wiinnertag = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
|
|
|
else if(strcmp(name, "SelectedGame") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
SelectedGame = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
|
|
|
else if(strcmp(name, "GameListOffset") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
GameListOffset = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
|
|
|
else if(strcmp(name, "sneekVideoPatch") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
sneekVideoPatch = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
|
|
|
else if(strcmp(name, "UseSystemFont") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
UseSystemFont = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
2011-07-29 22:59:31 +02:00
|
|
|
else if(strcmp(name, "Hooktype") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
Hooktype = atoi(value);
|
2011-07-29 22:59:31 +02:00
|
|
|
}
|
|
|
|
else if(strcmp(name, "WiirdDebugger") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
WiirdDebugger = atoi(value);
|
2011-07-29 22:59:31 +02:00
|
|
|
}
|
|
|
|
else if(strcmp(name, "WiirdDebuggerPause") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
WiirdDebuggerPause = atoi(value);
|
2011-07-29 22:59:31 +02:00
|
|
|
}
|
2011-07-26 00:28:22 +02:00
|
|
|
else if(strcmp(name, "NandEmuMode") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
NandEmuMode = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
2012-01-08 19:24:46 +01:00
|
|
|
else if(strcmp(name, "NandEmuChanMode") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
NandEmuChanMode = atoi(value);
|
2012-01-08 19:24:46 +01:00
|
|
|
}
|
2011-11-12 19:14:09 +01:00
|
|
|
else if(strcmp(name, "LoaderMode") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
LoaderMode = atoi(value);
|
2011-11-12 19:14:09 +01:00
|
|
|
}
|
|
|
|
else if(strcmp(name, "SearchMode") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
SearchMode = atoi(value);
|
2011-11-12 19:14:09 +01:00
|
|
|
}
|
2011-12-23 16:48:20 +01:00
|
|
|
else if(strcmp(name, "GameAspectRatio") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
GameAspectRatio = atoi(value);
|
2011-12-23 16:48:20 +01:00
|
|
|
}
|
2012-01-08 19:24:46 +01:00
|
|
|
else if(strcmp(name, "UseChanLauncher") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
UseChanLauncher = atoi(value);
|
2012-01-08 19:24:46 +01:00
|
|
|
}
|
2012-02-05 19:38:26 +01:00
|
|
|
else if(strcmp(name, "AdjustOverscanX") == 0)
|
|
|
|
{
|
|
|
|
AdjustOverscanX = atoi(value);
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "AdjustOverscanY") == 0)
|
|
|
|
{
|
|
|
|
AdjustOverscanY = atoi(value);
|
|
|
|
}
|
2012-05-06 12:59:58 +02:00
|
|
|
else if(strcmp(name, "TooltipDelay") == 0)
|
|
|
|
{
|
|
|
|
TooltipDelay = atoi(value);
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "BannerZoomDuration") == 0)
|
|
|
|
{
|
|
|
|
BannerZoomDuration = atoi(value);
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "GameWindowMode") == 0)
|
|
|
|
{
|
|
|
|
GameWindowMode = atoi(value);
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "BannerAnimStart") == 0)
|
|
|
|
{
|
|
|
|
BannerAnimStart = atoi(value);
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "CacheBNRFiles") == 0)
|
|
|
|
{
|
|
|
|
CacheBNRFiles = atoi(value);
|
|
|
|
}
|
2011-07-26 00:28:22 +02:00
|
|
|
else if (strcmp(name, "InstallPartitions") == 0)
|
|
|
|
{
|
|
|
|
InstallPartitions = strtoul(value, 0, 16);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "WSFactor") == 0)
|
|
|
|
{
|
|
|
|
WSFactor = atof(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "FontScaleFactor") == 0)
|
|
|
|
{
|
|
|
|
FontScaleFactor = atof(value);
|
2012-05-19 15:40:58 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "ClockFontScaleFactor") == 0)
|
|
|
|
{
|
|
|
|
ClockFontScaleFactor = atof(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
2011-12-28 17:27:30 +01:00
|
|
|
else if (strcmp(name, "PointerSpeed") == 0)
|
|
|
|
{
|
|
|
|
PointerSpeed = atof(value);
|
|
|
|
return true;
|
|
|
|
}
|
2012-05-06 12:59:58 +02:00
|
|
|
else if (strcmp(name, "BannerGridSpeed") == 0)
|
|
|
|
{
|
|
|
|
BannerGridSpeed = atof(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "BannerProjectionOffsetX") == 0)
|
|
|
|
{
|
|
|
|
BannerProjectionOffsetX = atof(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "BannerProjectionOffsetY") == 0)
|
|
|
|
{
|
|
|
|
BannerProjectionOffsetY = atof(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "BannerProjectionWidth") == 0)
|
|
|
|
{
|
|
|
|
BannerProjectionWidth = atof(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "BannerProjectionHeight") == 0)
|
|
|
|
{
|
|
|
|
BannerProjectionHeight = atof(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "GCBannerScale") == 0)
|
|
|
|
{
|
|
|
|
GCBannerScale = atof(value);
|
|
|
|
return true;
|
|
|
|
}
|
2011-07-26 00:28:22 +02:00
|
|
|
else if (strcmp(name, "ParentalBlocks") == 0)
|
|
|
|
{
|
|
|
|
ParentalBlocks = strtoul(value, 0, 16);
|
|
|
|
return true;
|
|
|
|
}
|
2012-07-16 18:07:24 +02:00
|
|
|
else if (strcmp(name, "GameCubeMode") == 0)
|
2012-05-06 12:59:58 +02:00
|
|
|
{
|
2012-07-16 18:07:24 +02:00
|
|
|
GameCubeMode = atoi(value);
|
|
|
|
return true;
|
|
|
|
}
|
2012-07-19 22:13:39 +02:00
|
|
|
else if (strcmp(name, "DMLConfigVersion") == 0)
|
|
|
|
{
|
|
|
|
DMLConfigVersion = atoi(value);
|
|
|
|
return true;
|
|
|
|
}
|
2012-07-16 18:07:24 +02:00
|
|
|
else if (strcmp(name, "DMLProgPatch") == 0)
|
|
|
|
{
|
|
|
|
DMLProgPatch = atoi(value);
|
2012-05-06 12:59:58 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "DMLNMM") == 0)
|
|
|
|
{
|
|
|
|
DMLNMM = atoi(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "DMLActivityLED") == 0)
|
|
|
|
{
|
|
|
|
DMLActivityLED = atoi(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "DMLPADHOOK") == 0)
|
|
|
|
{
|
|
|
|
DMLPADHOOK = atoi(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "DMLNoDisc") == 0)
|
|
|
|
{
|
|
|
|
DMLNoDisc = atoi(value);
|
|
|
|
return true;
|
|
|
|
}
|
2012-07-19 22:13:39 +02:00
|
|
|
else if (strcmp(name, "DMLWidescreen") == 0)
|
|
|
|
{
|
|
|
|
DMLWidescreen = atoi(value);
|
|
|
|
return true;
|
|
|
|
}
|
2012-05-06 12:59:58 +02:00
|
|
|
else if (strcmp(name, "DMLDebug") == 0)
|
|
|
|
{
|
|
|
|
DMLDebug = atoi(value);
|
|
|
|
return true;
|
|
|
|
}
|
2012-07-16 18:07:24 +02:00
|
|
|
else if (strcmp(name, "DEVOMCEmulation") == 0)
|
|
|
|
{
|
|
|
|
DEVOMCEmulation = atoi(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "DEVOLoaderPath") == 0)
|
|
|
|
{
|
|
|
|
strlcpy(DEVOLoaderPath, value, sizeof(DEVOLoaderPath));
|
|
|
|
return true;
|
|
|
|
}
|
2012-05-06 12:59:58 +02:00
|
|
|
else if (strcmp(name, "GCInstallCompressed") == 0)
|
|
|
|
{
|
|
|
|
GCInstallCompressed = atoi(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "GCInstallAligned") == 0)
|
|
|
|
{
|
|
|
|
GCInstallAligned = atoi(value);
|
|
|
|
return true;
|
|
|
|
}
|
2011-07-26 00:28:22 +02:00
|
|
|
else if (strcmp(name, "covers_path") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(covers_path, value, sizeof(covers_path));
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "covers2d_path") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(covers2d_path, value, sizeof(covers2d_path));
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "coversFull_path") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(coversFull_path, value, sizeof(coversFull_path));
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "theme_path") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(theme_path, value, sizeof(theme_path));
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "theme") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(theme, value, sizeof(theme));
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "disc_path") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(disc_path, value, sizeof(disc_path));
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "language_path") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(language_path, value, sizeof(language_path));
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "languagefiles_path") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(languagefiles_path, value, sizeof(languagefiles_path));
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "TxtCheatcodespath") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(TxtCheatcodespath, value, sizeof(TxtCheatcodespath));
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "titlestxt_path") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(titlestxt_path, value, sizeof(titlestxt_path));
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "dolpath") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(dolpath, value, sizeof(dolpath));
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "ogg_path") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(ogg_path, value, sizeof(ogg_path));
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "update_path") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(update_path, value, sizeof(update_path));
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "homebrewapps_path") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(homebrewapps_path, value, sizeof(homebrewapps_path));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "BNRCachePath") == 0)
|
|
|
|
{
|
|
|
|
strlcpy(BNRCachePath, value, sizeof(BNRCachePath));
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "Cheatcodespath") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(Cheatcodespath, value, sizeof(Cheatcodespath));
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "BcaCodepath") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(BcaCodepath, value, sizeof(BcaCodepath));
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "WipCodepath") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(WipCodepath, value, sizeof(WipCodepath));
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "WDMpath") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(WDMpath, value, sizeof(WDMpath));
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "returnTo") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(returnTo, value, sizeof(returnTo));
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "WiinnertagPath") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(WiinnertagPath, value, sizeof(WiinnertagPath));
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "NandEmuPath") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(NandEmuPath, value, sizeof(NandEmuPath));
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
2011-11-12 19:14:09 +01:00
|
|
|
else if (strcmp(name, "NandEmuChanPath") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(NandEmuChanPath, value, sizeof(NandEmuChanPath));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "GameCubePath") == 0)
|
|
|
|
{
|
|
|
|
strlcpy(GameCubePath, value, sizeof(GameCubePath));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "GameCubeSDPath") == 0)
|
|
|
|
{
|
|
|
|
strlcpy(GameCubeSDPath, value, sizeof(GameCubeSDPath));
|
2011-11-12 19:14:09 +01:00
|
|
|
return true;
|
|
|
|
}
|
2011-07-26 00:28:22 +02:00
|
|
|
else if (strcmp(name, "EnabledCategories") == 0)
|
|
|
|
{
|
|
|
|
EnabledCategories.clear();
|
|
|
|
char * strTok = strtok(value, ",");
|
|
|
|
while (strTok != NULL)
|
|
|
|
{
|
|
|
|
u32 id = atoi(strTok);
|
|
|
|
u32 i;
|
|
|
|
for(i = 0; i < EnabledCategories.size(); ++i)
|
|
|
|
{
|
|
|
|
if(EnabledCategories[i] == id)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(i == EnabledCategories.size())
|
|
|
|
EnabledCategories.push_back(id);
|
|
|
|
strTok = strtok(NULL,",");
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2012-06-09 14:20:14 +02:00
|
|
|
else if (strcmp(name, "RequiredCategories") == 0)
|
|
|
|
{
|
|
|
|
RequiredCategories.clear();
|
|
|
|
char * strTok = strtok(value, ",");
|
|
|
|
while (strTok != NULL)
|
|
|
|
{
|
|
|
|
u32 id = atoi(strTok);
|
|
|
|
u32 i;
|
|
|
|
for(i = 0; i < RequiredCategories.size(); ++i)
|
|
|
|
{
|
|
|
|
if(RequiredCategories[i] == id)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(i == RequiredCategories.size())
|
|
|
|
RequiredCategories.push_back(id);
|
|
|
|
strTok = strtok(NULL,",");
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "ForbiddenCategories") == 0)
|
|
|
|
{
|
|
|
|
ForbiddenCategories.clear();
|
|
|
|
char * strTok = strtok(value, ",");
|
|
|
|
while (strTok != NULL)
|
|
|
|
{
|
|
|
|
u32 id = atoi(strTok);
|
|
|
|
u32 i;
|
|
|
|
for(i = 0; i < ForbiddenCategories.size(); ++i)
|
|
|
|
{
|
|
|
|
if(ForbiddenCategories[i] == id)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(i == ForbiddenCategories.size())
|
|
|
|
ForbiddenCategories.push_back(id);
|
|
|
|
strTok = strtok(NULL,",");
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2011-07-26 00:28:22 +02:00
|
|
|
|
|
|
|
return false;
|
2010-09-19 22:25:12 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 19:58:56 +02:00
|
|
|
bool CSettings::FindConfig()
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
bool found = false;
|
2012-05-06 12:59:58 +02:00
|
|
|
char CheckDevice[12];
|
2011-07-26 00:28:22 +02:00
|
|
|
char CheckPath[300];
|
|
|
|
|
2012-05-06 12:59:58 +02:00
|
|
|
// Enumerate the devices supported by libogc.
|
|
|
|
for (int i = SD; (i < MAXDEVICES) && !found; ++i)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
snprintf(CheckDevice, sizeof(CheckDevice), "%s:", DeviceName[i]);
|
2011-07-26 00:28:22 +02:00
|
|
|
|
|
|
|
if(!found)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
// Check for the config file in the apps directory.
|
|
|
|
strlcpy(BootDevice, CheckDevice, sizeof(BootDevice));
|
2011-07-26 00:28:22 +02:00
|
|
|
snprintf(ConfigPath, sizeof(ConfigPath), "%s/apps/usbloader_gx/", BootDevice);
|
|
|
|
snprintf(CheckPath, sizeof(CheckPath), "%sGXGlobal.cfg", ConfigPath);
|
|
|
|
found = CheckFile(CheckPath);
|
|
|
|
}
|
|
|
|
if(!found)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
// Check for the config file in the config directory.
|
|
|
|
strlcpy(BootDevice, CheckDevice, sizeof(BootDevice));
|
2011-07-26 00:28:22 +02:00
|
|
|
snprintf(ConfigPath, sizeof(ConfigPath), "%s/config/", BootDevice);
|
|
|
|
snprintf(CheckPath, sizeof(CheckPath), "%sGXGlobal.cfg", ConfigPath);
|
|
|
|
found = CheckFile(CheckPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 12:59:58 +02:00
|
|
|
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)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
sprintf(CheckDevice, "%s:", DeviceName[i]);
|
2011-07-26 00:28:22 +02:00
|
|
|
|
2012-05-06 12:59:58 +02:00
|
|
|
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);
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return found;
|
2010-09-24 19:58:56 +02:00
|
|
|
}
|
|
|
|
|
2010-09-19 22:25:12 +02:00
|
|
|
void CSettings::ParseLine(char *line)
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
char temp[1024], name[1024], value[1024];
|
2010-09-19 22:25:12 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
strncpy(temp, line, sizeof(temp));
|
2010-09-19 22:25:12 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
char * eq = strchr(temp, '=');
|
2010-09-19 22:25:12 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
if (!eq) return;
|
2010-09-19 22:25:12 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
*eq = 0;
|
2010-09-19 22:25:12 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
this->TrimLine(name, temp, sizeof(name));
|
|
|
|
this->TrimLine(value, eq + 1, sizeof(value));
|
2010-09-19 22:25:12 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
this->SetSetting(name, value);
|
2010-09-19 22:25:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSettings::TrimLine(char *dest, char *src, int size)
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
int len;
|
|
|
|
while (*src == ' ')
|
|
|
|
src++;
|
|
|
|
len = strlen(src);
|
|
|
|
while (len > 0 && strchr(" \r\n", src[len - 1]))
|
|
|
|
len--;
|
|
|
|
if (len >= size) len = size - 1;
|
|
|
|
strncpy(dest, src, len);
|
|
|
|
dest[len] = 0;
|
2010-09-19 22:25:12 +02:00
|
|
|
}
|
|
|
|
|
2010-11-07 21:31:45 +01:00
|
|
|
//! Get language code from the selected language file
|
|
|
|
//! eg. german.lang = DE and default to EN
|
|
|
|
static inline const char * GetLangCode(const char * langpath)
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
if(strcasestr(langpath, "japanese"))
|
|
|
|
return "JA";
|
2010-11-07 21:31:45 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
else if(strcasestr(langpath, "german"))
|
|
|
|
return "DE";
|
2010-11-07 21:31:45 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
else if(strcasestr(langpath, "french"))
|
|
|
|
return "FR";
|
2010-11-07 21:31:45 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
else if(strcasestr(langpath, "spanish"))
|
|
|
|
return "ES";
|
2010-11-07 21:31:45 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
else if(strcasestr(langpath, "italian"))
|
|
|
|
return "IT";
|
2010-11-07 21:31:45 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
else if(strcasestr(langpath, "dutch"))
|
|
|
|
return "NL";
|
2010-11-07 21:31:45 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
else if(strcasestr(langpath, "schinese"))
|
|
|
|
return "ZHCN";
|
2010-11-07 21:31:45 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
else if(strcasestr(langpath, "tchinese"))
|
|
|
|
return "ZHTW";
|
2010-11-07 21:31:45 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
else if(strcasestr(langpath, "korean"))
|
|
|
|
return "KO";
|
2010-11-07 21:31:45 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
return "EN";
|
2010-11-07 21:31:45 +01:00
|
|
|
}
|
|
|
|
|
2010-12-29 11:22:11 +01:00
|
|
|
bool CSettings::LoadLanguage(const char *path, int lang)
|
2010-09-19 22:25:12 +02:00
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
bool ret = false;
|
|
|
|
|
|
|
|
if (path && strlen(path) > 3)
|
|
|
|
{
|
|
|
|
ret = gettextLoadLanguage(path);
|
|
|
|
if (ret)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(language_path, path, sizeof(language_path));
|
|
|
|
strlcpy(db_language, GetLangCode(language_path), sizeof(db_language));
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return LoadLanguage(NULL, CONSOLE_DEFAULT);
|
|
|
|
}
|
|
|
|
else if (lang >= 0)
|
|
|
|
{
|
|
|
|
char filepath[150];
|
|
|
|
char langpath[150];
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(langpath, languagefiles_path, sizeof(langpath));
|
2011-07-26 00:28:22 +02:00
|
|
|
if (langpath[strlen(langpath) - 1] != '/')
|
|
|
|
{
|
|
|
|
char * ptr = strrchr(langpath, '/');
|
|
|
|
if (ptr)
|
|
|
|
{
|
|
|
|
ptr++;
|
|
|
|
ptr[0] = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lang == CONSOLE_DEFAULT)
|
|
|
|
{
|
|
|
|
return LoadLanguage(NULL, CONF_GetLanguage());
|
|
|
|
}
|
|
|
|
else if (lang == JAPANESE)
|
|
|
|
{
|
|
|
|
snprintf(filepath, sizeof(filepath), "%s/japanese.lang", langpath);
|
|
|
|
}
|
|
|
|
else if (lang == ENGLISH)
|
|
|
|
{
|
|
|
|
snprintf(filepath, sizeof(filepath), "%s/english.lang", langpath);
|
|
|
|
}
|
|
|
|
else if (lang == GERMAN)
|
|
|
|
{
|
|
|
|
snprintf(filepath, sizeof(filepath), "%s/german.lang", langpath);
|
|
|
|
}
|
|
|
|
else if (lang == FRENCH)
|
|
|
|
{
|
|
|
|
snprintf(filepath, sizeof(filepath), "%s/french.lang", langpath);
|
|
|
|
}
|
|
|
|
else if (lang == SPANISH)
|
|
|
|
{
|
|
|
|
snprintf(filepath, sizeof(filepath), "%s/spanish.lang", langpath);
|
|
|
|
}
|
|
|
|
else if (lang == ITALIAN)
|
|
|
|
{
|
|
|
|
snprintf(filepath, sizeof(filepath), "%s/italian.lang", langpath);
|
|
|
|
}
|
|
|
|
else if (lang == DUTCH)
|
|
|
|
{
|
|
|
|
snprintf(filepath, sizeof(filepath), "%s/dutch.lang", langpath);
|
|
|
|
}
|
|
|
|
else if (lang == S_CHINESE)
|
|
|
|
{
|
|
|
|
snprintf(filepath, sizeof(filepath), "%s/schinese.lang", langpath);
|
|
|
|
}
|
|
|
|
else if (lang == T_CHINESE)
|
|
|
|
{
|
|
|
|
snprintf(filepath, sizeof(filepath), "%s/tchinese.lang", langpath);
|
|
|
|
}
|
|
|
|
else if (lang == KOREAN)
|
|
|
|
{
|
|
|
|
snprintf(filepath, sizeof(filepath), "%s/korean.lang", langpath);
|
|
|
|
}
|
|
|
|
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(db_language, GetLangCode(filepath), sizeof(db_language));
|
2011-07-26 00:28:22 +02:00
|
|
|
ret = gettextLoadLanguage(filepath);
|
|
|
|
if (ret)
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(language_path, filepath, sizeof(language_path));
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2010-09-19 22:25:12 +02:00
|
|
|
}
|