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"
|
|
|
|
|
|
|
|
#define VALID_CONFIG_REV 1031
|
2010-09-19 22:25:12 +02:00
|
|
|
|
|
|
|
CSettings Settings;
|
|
|
|
|
|
|
|
CSettings::CSettings()
|
|
|
|
{
|
2010-09-24 19:58:56 +02:00
|
|
|
CONF_Init();
|
2010-12-31 00:49:22 +01:00
|
|
|
strcpy(BootDevice, "sd:");
|
2010-11-28 16:31:08 +01:00
|
|
|
snprintf(ConfigPath, sizeof(ConfigPath), "%s/config/", BootDevice);
|
2010-09-19 22:25:12 +02:00
|
|
|
this->SetDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
CSettings::~CSettings()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSettings::SetDefault()
|
|
|
|
{
|
2010-11-28 16:31:08 +01:00
|
|
|
snprintf(covers_path, sizeof(covers_path), "%simages/", ConfigPath);
|
|
|
|
snprintf(covers2d_path, sizeof(covers2d_path), "%simages/2D/", ConfigPath);
|
2011-01-30 17:22:16 +01:00
|
|
|
snprintf(coversFull_path, sizeof(coversFull_path), "%simages/full/", ConfigPath);
|
2010-11-28 16:31:08 +01:00
|
|
|
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);
|
2010-09-24 02:48:03 +02:00
|
|
|
snprintf(update_path, sizeof(update_path), "%s/apps/usbloader_gx/", BootDevice);
|
|
|
|
snprintf(homebrewapps_path, sizeof(homebrewapps_path), "%s/apps/", BootDevice);
|
2010-12-29 16:42:26 +01:00
|
|
|
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);
|
2011-01-16 14:12:07 +01:00
|
|
|
snprintf(WDMpath, sizeof(WDMpath), "%s/wdm/", BootDevice);
|
2011-06-25 21:50:57 +02:00
|
|
|
snprintf(WiinnertagPath, sizeof(WiinnertagPath), "%s", ConfigPath);
|
2010-11-28 16:31:08 +01:00
|
|
|
snprintf(theme_path, sizeof(theme_path), "%stheme/", ConfigPath);
|
2010-09-24 02:48:03 +02:00
|
|
|
snprintf(dolpath, sizeof(dolpath), "%s/", BootDevice);
|
2010-12-31 00:49:22 +01:00
|
|
|
strcpy(theme, "");
|
2010-11-07 21:31:45 +01:00
|
|
|
strcpy(language_path, "");
|
2010-09-19 22:25:12 +02:00
|
|
|
strcpy(ogg_path, "");
|
|
|
|
strcpy(unlockCode, "");
|
*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
|
|
|
strcpy(db_language, "");
|
|
|
|
strcpy(returnTo, "");
|
2010-09-19 22:25:12 +02:00
|
|
|
|
*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
|
|
|
godmode = 1;
|
2011-02-03 22:46:54 +01:00
|
|
|
videomode = VIDEO_MODE_DISCDEFAULT;
|
2010-10-27 16:45:27 +02:00
|
|
|
videopatch = OFF;
|
|
|
|
language = CONSOLE_DEFAULT;
|
|
|
|
ocarina = OFF;
|
|
|
|
hddinfo = CLOCK_HR12;
|
|
|
|
sinfo = ON;
|
|
|
|
rumble = ON;
|
2010-11-07 21:31:45 +01:00
|
|
|
GameSort = SORT_ABC;
|
2010-09-19 22:25:12 +02:00
|
|
|
volume = 80;
|
|
|
|
sfxvolume = 80;
|
|
|
|
gamesoundvolume = 80;
|
2010-10-27 16:45:27 +02:00
|
|
|
tooltips = ON;
|
2011-01-20 16:00:55 +01:00
|
|
|
gamesound = ON;
|
|
|
|
parentalcontrol = PARENTAL_LVL_ADULT;
|
2011-02-21 20:41:48 +01:00
|
|
|
cios = BUILD_IOS;
|
2010-09-19 22:25:12 +02:00
|
|
|
gridRows = 3;
|
|
|
|
error002 = 2;
|
|
|
|
partition = -1;
|
2011-01-23 21:13:41 +01:00
|
|
|
discart = DISCARTS_ORIGINALS_CUSTOMS;
|
2011-01-20 16:00:55 +01:00
|
|
|
xflip = XFLIP_NO;
|
|
|
|
quickboot = OFF;
|
|
|
|
wiilight = WIILIGHT_ON;
|
|
|
|
autonetwork = OFF;
|
|
|
|
patchcountrystrings = OFF;
|
|
|
|
titlesOverride = ON;
|
|
|
|
screensaver = SCREENSAVER_10_MIN;
|
|
|
|
musicloopmode = ON;
|
|
|
|
marknewtitles = ON;
|
|
|
|
ShowFreeSpace = ON;
|
|
|
|
PlaylogUpdate = ON;
|
|
|
|
ParentalBlocks = BLOCK_ALL;
|
2010-12-31 14:13:14 +01:00
|
|
|
InstallToDir = INSTALL_TO_NAME_GAMEID;
|
2010-12-29 16:42:26 +01:00
|
|
|
GameSplit = GAMESPLIT_4GB;
|
2010-10-27 16:45:27 +02:00
|
|
|
InstallPartitions = ONLY_GAME_PARTITION;
|
2010-09-24 19:58:56 +02:00
|
|
|
widescreen = (CONF_GetAspectRatio() == CONF_ASPECT_16_9);
|
2011-01-22 17:10:36 +01:00
|
|
|
HomeMenu = HOME_MENU_DEFAULT;
|
2011-02-02 19:30:15 +01:00
|
|
|
MultiplePartitions = OFF;
|
2011-06-10 14:22:19 +02:00
|
|
|
BlockIOSReload = AUTO;
|
2011-02-05 22:06:52 +01:00
|
|
|
USBPort = 0;
|
2011-02-12 10:50:35 +01:00
|
|
|
CacheTitles = ON;
|
2011-02-25 19:18:57 +01:00
|
|
|
WSFactor = 0.8f; //actually should be 0.75 for real widescreen
|
2011-07-23 21:49:51 +02:00
|
|
|
FontScaleFactor = 0.8f; //it's a work around to not have to change ALL fonts now
|
2011-06-03 22:31:09 +02:00
|
|
|
EnabledCategories.resize(1);
|
|
|
|
EnabledCategories[0] = 0;
|
2011-06-18 09:00:42 +02:00
|
|
|
Wiinnertag = OFF;
|
2011-06-24 21:11:36 +02:00
|
|
|
SelectedGame = 0;
|
|
|
|
GameListOffset = 0;
|
2011-06-25 21:50:57 +02:00
|
|
|
sneekVideoPatch = OFF;
|
2010-09-24 19:58:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CSettings::Load()
|
|
|
|
{
|
|
|
|
FindConfig();
|
2010-11-07 21:31:45 +01:00
|
|
|
//! Reset default path variables to the right device
|
|
|
|
SetDefault();
|
2010-09-24 19:58:56 +02:00
|
|
|
|
|
|
|
char filepath[300];
|
2010-11-28 16:31:08 +01:00
|
|
|
snprintf(filepath, sizeof(filepath), "%sGXGlobal.cfg", ConfigPath);
|
2010-09-24 19:58:56 +02:00
|
|
|
|
2011-01-06 19:59:45 +01:00
|
|
|
FILE * file = fopen(filepath, "r");
|
2010-09-24 19:58:56 +02:00
|
|
|
if (!file) return false;
|
|
|
|
|
2011-01-06 19:59:45 +01:00
|
|
|
if(!ValidVersion(file))
|
|
|
|
{
|
|
|
|
fclose(file);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
char line[1024];
|
|
|
|
|
2010-09-24 19:58:56 +02:00
|
|
|
while (fgets(line, sizeof(line), file))
|
|
|
|
{
|
|
|
|
if (line[0] == '#') continue;
|
|
|
|
|
|
|
|
this->ParseLine(line);
|
|
|
|
}
|
|
|
|
fclose(file);
|
|
|
|
|
|
|
|
return true;
|
2011-01-06 19:59:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CSettings::ValidVersion(FILE * file)
|
|
|
|
{
|
|
|
|
if(!file) return false;
|
|
|
|
|
|
|
|
char line[255];
|
|
|
|
int revision = 0;
|
2010-09-24 19:58:56 +02:00
|
|
|
|
2011-01-06 19:59:45 +01: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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rewind(file);
|
|
|
|
|
|
|
|
return revision >= VALID_CONFIG_REV;
|
2010-09-24 19:58:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CSettings::Reset()
|
|
|
|
{
|
|
|
|
this->SetDefault();
|
|
|
|
|
|
|
|
if (this->Save()) return true;
|
|
|
|
|
|
|
|
return false;
|
2010-09-19 22:25:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CSettings::Save()
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (!FindConfig()) return false;
|
2010-09-19 22:25:12 +02:00
|
|
|
|
2010-11-28 16:31:08 +01:00
|
|
|
char filedest[300];
|
|
|
|
snprintf(filedest, sizeof(filedest), "%sGXGlobal.cfg", ConfigPath);
|
2010-09-19 22:25:12 +02:00
|
|
|
|
2010-11-28 16:31:08 +01:00
|
|
|
if(!CreateSubfolder(ConfigPath)) return false;
|
2010-09-19 22:25:12 +02:00
|
|
|
|
2011-01-06 19:59:45 +01:00
|
|
|
FILE * file = fopen(filedest, "w");
|
2010-09-24 02:48:03 +02:00
|
|
|
if (!file) return false;
|
|
|
|
|
2011-01-06 19:59:45 +01:00
|
|
|
fprintf(file, "# USB Loader GX R%s - Main settings file\n", GetRev());
|
2011-06-18 09:00:42 +02:00
|
|
|
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);
|
*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
|
|
|
char EncryptedTxt[50];
|
|
|
|
EncryptString(unlockCode, EncryptedTxt);
|
2011-06-18 09:00:42 +02:00
|
|
|
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);
|
|
|
|
fprintf(file, "Cheatcodespath = %s\n", Cheatcodespath);
|
|
|
|
fprintf(file, "BcaCodepath = %s\n", BcaCodepath);
|
|
|
|
fprintf(file, "WipCodepath = %s\n", WipCodepath);
|
2011-01-16 14:12:07 +01:00
|
|
|
fprintf(file, "WDMpath = %s\n ", WDMpath);
|
2011-06-18 09:00:42 +02:00
|
|
|
fprintf(file, "titlesOverride = %d\n", titlesOverride);
|
|
|
|
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);
|
2011-06-03 22:31:09 +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, ",");
|
|
|
|
}
|
2011-06-18 09:00:42 +02:00
|
|
|
fprintf(file, "\n");
|
|
|
|
fprintf(file, "Wiinnertag = %d\n", Wiinnertag);
|
|
|
|
fprintf(file, "WiinnertagPath = %s\n", WiinnertagPath);
|
2011-06-24 21:11:36 +02:00
|
|
|
fprintf(file, "SelectedGame = %d\n", SelectedGame);
|
|
|
|
fprintf(file, "GameListOffset = %d\n", GameListOffset);
|
2011-06-25 21:50:57 +02:00
|
|
|
fprintf(file, "sneekVideoPatch = %d\n", sneekVideoPatch);
|
2010-09-24 02:48:03 +02:00
|
|
|
fclose(file);
|
2010-09-19 22:25:12 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
return true;
|
2010-09-19 22:25:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CSettings::SetSetting(char *name, char *value)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
2010-12-17 18:50:44 +01:00
|
|
|
if (strcmp(name, "godmode") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1)
|
|
|
|
{
|
*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
|
|
|
godmode = i;
|
2010-12-17 18:50:44 +01:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "videomode") == 0)
|
2010-09-24 02:48:03 +02:00
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1)
|
|
|
|
{
|
|
|
|
videomode = i;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "videopatch") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1)
|
|
|
|
{
|
|
|
|
videopatch = i;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "language") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1)
|
|
|
|
{
|
|
|
|
language = i;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "ocarina") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1)
|
|
|
|
{
|
|
|
|
ocarina = i;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "hddinfo") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1)
|
|
|
|
{
|
|
|
|
hddinfo = i;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "sinfo") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1)
|
|
|
|
{
|
|
|
|
sinfo = i;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "rumble") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1)
|
|
|
|
{
|
|
|
|
rumble = i;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "volume") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1)
|
|
|
|
{
|
|
|
|
volume = i;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "sfxvolume") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1)
|
|
|
|
{
|
|
|
|
sfxvolume = i;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "gamesoundvolume") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1)
|
|
|
|
{
|
|
|
|
gamesoundvolume = i;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "tooltips") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1)
|
|
|
|
{
|
|
|
|
tooltips = i;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2010-09-24 23:43:46 +02:00
|
|
|
else if (strcmp(name, "password") == 0)
|
2010-09-24 02:48:03 +02:00
|
|
|
{
|
*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
|
|
|
char EncryptedTxt[50];
|
|
|
|
strcpy(EncryptedTxt, value);
|
|
|
|
DecryptString(EncryptedTxt, unlockCode);
|
2010-09-24 02:48:03 +02:00
|
|
|
return true;
|
|
|
|
}
|
2010-10-27 16:45:27 +02:00
|
|
|
else if (strcmp(name, "GameSort") == 0)
|
2010-09-24 02:48:03 +02:00
|
|
|
{
|
2010-10-27 16:45:27 +02:00
|
|
|
if (sscanf(value, "%d", &i) == 1) GameSort = i;
|
2010-09-24 02:48:03 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "cios") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) cios = i;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "keyset") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) keyset = i;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "xflip") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) xflip = i;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "gridRows") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) gridRows = i;
|
|
|
|
return true;
|
|
|
|
}
|
2010-09-24 23:22:01 +02:00
|
|
|
else if (strcmp(name, "quickboot") == 0)
|
2010-09-24 02:48:03 +02:00
|
|
|
{
|
2010-09-24 23:22:01 +02:00
|
|
|
if (sscanf(value, "%d", &i) == 1) quickboot = i;
|
2010-09-24 02:48:03 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "partition") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) partition = i;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "wsprompt") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) wsprompt = i;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "gameDisplay") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) gameDisplay = i;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "parentalcontrol") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) parentalcontrol = i;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "screensaver") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) screensaver = i;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "titlesOverride") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) titlesOverride = i;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "musicloopmode") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) musicloopmode = i;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "gamesound") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) gamesound = i;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "wiilight") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) wiilight = i;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "marknewtitles") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) marknewtitles = i;
|
|
|
|
return true;
|
2010-12-31 14:13:14 +01:00
|
|
|
}
|
|
|
|
else if (strcmp(name, "ShowFreeSpace") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) ShowFreeSpace = i;
|
|
|
|
return true;
|
2010-09-24 02:48:03 +02:00
|
|
|
}
|
2011-01-22 17:10:36 +01:00
|
|
|
else if (strcmp(name, "HomeMenu") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) HomeMenu = i;
|
|
|
|
return true;
|
|
|
|
}
|
2011-02-02 19:30:15 +01:00
|
|
|
else if (strcmp(name, "MultiplePartitions") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) MultiplePartitions = i;
|
|
|
|
return true;
|
|
|
|
}
|
2011-06-10 14:22:19 +02:00
|
|
|
else if (strcmp(name, "BlockIOSReload") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) BlockIOSReload = i;
|
|
|
|
return true;
|
|
|
|
}
|
2011-02-05 22:06:52 +01:00
|
|
|
else if (strcmp(name, "USBPort") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) USBPort = i;
|
|
|
|
return true;
|
|
|
|
}
|
2011-02-12 19:26:18 +01:00
|
|
|
else if (strcmp(name, "CacheTitles") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) CacheTitles = i;
|
|
|
|
return true;
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (strcmp(name, "patchcountrystrings") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) patchcountrystrings = i;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "discart") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) discart = i;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "error002") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) error002 = i;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "autonetwork") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) autonetwork = i;
|
|
|
|
return true;
|
|
|
|
}
|
2010-12-29 16:42:26 +01:00
|
|
|
else if (strcmp(name, "InstallToDir") == 0)
|
2010-09-24 02:48:03 +02:00
|
|
|
{
|
2010-12-29 16:42:26 +01:00
|
|
|
if (sscanf(value, "%d", &i) == 1) InstallToDir = i;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "GameSplit") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) GameSplit = i;
|
2010-09-24 02:48:03 +02:00
|
|
|
return true;
|
|
|
|
}
|
2010-12-27 10:44:27 +01:00
|
|
|
else if (strcmp(name, "PlaylogUpdate") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) PlaylogUpdate = i;
|
|
|
|
return true;
|
|
|
|
}
|
2011-06-18 09:00:42 +02:00
|
|
|
else if(strcmp(name, "Wiinnertag") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) Wiinnertag = i;
|
2011-06-24 21:11:36 +02:00
|
|
|
}
|
|
|
|
else if(strcmp(name, "SelectedGame") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) SelectedGame = i;
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "GameListOffset") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) GameListOffset = i;
|
2011-06-25 21:50:57 +02:00
|
|
|
}
|
|
|
|
else if(strcmp(name, "sneekVideoPatch") == 0)
|
|
|
|
{
|
|
|
|
if (sscanf(value, "%d", &i) == 1) sneekVideoPatch = i;
|
2011-06-18 09:00:42 +02:00
|
|
|
}
|
2010-10-27 16:45:27 +02:00
|
|
|
else if (strcmp(name, "InstallPartitions") == 0)
|
2010-09-24 02:48:03 +02:00
|
|
|
{
|
2010-12-26 18:02:14 +01:00
|
|
|
InstallPartitions = strtoul(value, 0, 16);
|
2010-09-24 02:48:03 +02:00
|
|
|
return true;
|
|
|
|
}
|
2011-02-25 19:18:57 +01:00
|
|
|
else if (strcmp(name, "WSFactor") == 0)
|
|
|
|
{
|
|
|
|
WSFactor = atof(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "FontScaleFactor") == 0)
|
|
|
|
{
|
|
|
|
FontScaleFactor = atof(value);
|
|
|
|
return true;
|
|
|
|
}
|
2011-01-20 16:00:55 +01:00
|
|
|
else if (strcmp(name, "ParentalBlocks") == 0)
|
|
|
|
{
|
|
|
|
ParentalBlocks = strtoul(value, 0, 16);
|
|
|
|
return true;
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (strcmp(name, "covers_path") == 0)
|
|
|
|
{
|
|
|
|
strcpy(covers_path, value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "covers2d_path") == 0)
|
|
|
|
{
|
|
|
|
strcpy(covers2d_path, value);
|
|
|
|
return true;
|
|
|
|
}
|
2011-01-30 17:22:16 +01:00
|
|
|
else if (strcmp(name, "coversFull_path") == 0)
|
|
|
|
{
|
|
|
|
strcpy(coversFull_path, value);
|
|
|
|
return true;
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (strcmp(name, "theme_path") == 0)
|
|
|
|
{
|
|
|
|
strcpy(theme_path, value);
|
|
|
|
return true;
|
|
|
|
}
|
2010-12-31 00:49:22 +01:00
|
|
|
else if (strcmp(name, "theme") == 0)
|
|
|
|
{
|
|
|
|
strcpy(theme, value);
|
|
|
|
return true;
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (strcmp(name, "disc_path") == 0)
|
|
|
|
{
|
|
|
|
strcpy(disc_path, value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "language_path") == 0)
|
|
|
|
{
|
|
|
|
strcpy(language_path, value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "languagefiles_path") == 0)
|
|
|
|
{
|
|
|
|
strcpy(languagefiles_path, value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "TxtCheatcodespath") == 0)
|
|
|
|
{
|
|
|
|
strcpy(TxtCheatcodespath, value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "titlestxt_path") == 0)
|
|
|
|
{
|
|
|
|
strcpy(titlestxt_path, value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "dolpath") == 0)
|
|
|
|
{
|
|
|
|
strcpy(dolpath, value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "ogg_path") == 0)
|
|
|
|
{
|
|
|
|
strcpy(ogg_path, value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "update_path") == 0)
|
|
|
|
{
|
|
|
|
strcpy(update_path, value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "homebrewapps_path") == 0)
|
|
|
|
{
|
|
|
|
strcpy(homebrewapps_path, value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "Cheatcodespath") == 0)
|
|
|
|
{
|
|
|
|
strcpy(Cheatcodespath, value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "BcaCodepath") == 0)
|
|
|
|
{
|
|
|
|
strcpy(BcaCodepath, value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "WipCodepath") == 0)
|
|
|
|
{
|
|
|
|
strcpy(WipCodepath, value);
|
|
|
|
return true;
|
|
|
|
}
|
2011-01-16 14:12:07 +01:00
|
|
|
else if (strcmp(name, "WDMpath") == 0)
|
|
|
|
{
|
|
|
|
strcpy(WDMpath, value);
|
|
|
|
return true;
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (strcmp(name, "returnTo") == 0)
|
|
|
|
{
|
|
|
|
strcpy(returnTo, value);
|
|
|
|
return true;
|
|
|
|
}
|
2011-06-18 09:00:42 +02:00
|
|
|
else if (strcmp(name, "WiinnertagPath") == 0)
|
|
|
|
{
|
|
|
|
strcpy(WiinnertagPath, value);
|
|
|
|
return true;
|
|
|
|
}
|
2011-06-03 22:31:09 +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;
|
|
|
|
}
|
2010-09-19 22:25:12 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-09-24 19:58:56 +02:00
|
|
|
bool CSettings::FindConfig()
|
|
|
|
{
|
|
|
|
bool found = false;
|
2010-12-29 11:22:11 +01:00
|
|
|
char CheckDevice[10];
|
2010-11-28 16:31:08 +01:00
|
|
|
char CheckPath[300];
|
2010-09-24 19:58:56 +02:00
|
|
|
|
2010-12-31 00:49:22 +01:00
|
|
|
for (int i = SD; i < MAXDEVICES; ++i)
|
2010-09-24 19:58:56 +02:00
|
|
|
{
|
2010-12-31 00:49:22 +01:00
|
|
|
sprintf(CheckDevice, "%s:", DeviceName[i]);
|
2010-09-24 19:58:56 +02:00
|
|
|
|
2010-12-29 11:22:11 +01:00
|
|
|
if(!found)
|
|
|
|
{
|
|
|
|
strcpy(BootDevice, CheckDevice);
|
|
|
|
snprintf(ConfigPath, sizeof(ConfigPath), "%s/apps/usbloader_gx/", BootDevice);
|
|
|
|
snprintf(CheckPath, sizeof(CheckPath), "%sGXGlobal.cfg", ConfigPath);
|
|
|
|
found = CheckFile(CheckPath);
|
|
|
|
}
|
|
|
|
if(!found)
|
|
|
|
{
|
|
|
|
strcpy(BootDevice, CheckDevice);
|
|
|
|
snprintf(ConfigPath, sizeof(ConfigPath), "%s/config/", BootDevice);
|
|
|
|
snprintf(CheckPath, sizeof(CheckPath), "%sGXGlobal.cfg", ConfigPath);
|
|
|
|
found = CheckFile(CheckPath);
|
|
|
|
}
|
2010-09-24 19:58:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!found)
|
|
|
|
{
|
|
|
|
FILE * testFp = NULL;
|
|
|
|
//! No existing config so try to find a place where we can write it too
|
2010-12-31 00:49:22 +01:00
|
|
|
for (int i = SD; i < MAXDEVICES; ++i)
|
2010-09-24 19:58:56 +02:00
|
|
|
{
|
2010-12-31 00:49:22 +01:00
|
|
|
sprintf(CheckDevice, "%s:", DeviceName[i]);
|
|
|
|
|
2010-09-24 19:58:56 +02:00
|
|
|
if (!found)
|
|
|
|
{
|
2010-12-29 11:22:11 +01:00
|
|
|
strcpy(BootDevice, CheckDevice);
|
2010-11-06 16:30:14 +01:00
|
|
|
snprintf(ConfigPath, sizeof(ConfigPath), "%s/apps/usbloader_gx/", BootDevice);
|
2010-11-28 16:31:08 +01:00
|
|
|
snprintf(CheckPath, sizeof(CheckPath), "%sGXGlobal.cfg", ConfigPath);
|
|
|
|
testFp = fopen(CheckPath, "wb");
|
2010-09-24 19:58:56 +02:00
|
|
|
found = (testFp != NULL);
|
|
|
|
fclose(testFp);
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
{
|
2010-12-29 11:22:11 +01:00
|
|
|
strcpy(BootDevice, CheckDevice);
|
2010-11-06 16:30:14 +01:00
|
|
|
snprintf(ConfigPath, sizeof(ConfigPath), "%s/config/", BootDevice);
|
|
|
|
CreateSubfolder(ConfigPath);
|
2010-11-28 16:31:08 +01:00
|
|
|
snprintf(CheckPath, sizeof(CheckPath), "%sGXGlobal.cfg", ConfigPath);
|
|
|
|
testFp = fopen(CheckPath, "wb");
|
2010-09-24 19:58:56 +02:00
|
|
|
found = (testFp != NULL);
|
|
|
|
fclose(testFp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2010-09-19 22:25:12 +02:00
|
|
|
void CSettings::ParseLine(char *line)
|
|
|
|
{
|
|
|
|
char temp[1024], name[1024], value[1024];
|
|
|
|
|
|
|
|
strncpy(temp, line, sizeof(temp));
|
|
|
|
|
|
|
|
char * eq = strchr(temp, '=');
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (!eq) return;
|
2010-09-19 22:25:12 +02:00
|
|
|
|
|
|
|
*eq = 0;
|
|
|
|
|
|
|
|
this->TrimLine(name, temp, sizeof(name));
|
2010-09-24 02:48:03 +02:00
|
|
|
this->TrimLine(value, eq + 1, sizeof(value));
|
2010-09-19 22:25:12 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
this->SetSetting(name, value);
|
2010-09-19 22:25:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSettings::TrimLine(char *dest, char *src, int size)
|
|
|
|
{
|
2010-09-24 02:48:03 +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)
|
|
|
|
{
|
|
|
|
if(strcasestr(langpath, "japanese"))
|
|
|
|
return "JA";
|
|
|
|
|
|
|
|
else if(strcasestr(langpath, "german"))
|
|
|
|
return "DE";
|
|
|
|
|
|
|
|
else if(strcasestr(langpath, "french"))
|
|
|
|
return "FR";
|
|
|
|
|
|
|
|
else if(strcasestr(langpath, "spanish"))
|
|
|
|
return "ES";
|
|
|
|
|
|
|
|
else if(strcasestr(langpath, "italian"))
|
|
|
|
return "IT";
|
|
|
|
|
|
|
|
else if(strcasestr(langpath, "dutch"))
|
|
|
|
return "NL";
|
|
|
|
|
2010-12-26 18:02:14 +01:00
|
|
|
else if(strcasestr(langpath, "schinese"))
|
2010-11-07 21:31:45 +01:00
|
|
|
return "ZHCN";
|
|
|
|
|
2010-12-26 18:02:14 +01:00
|
|
|
else if(strcasestr(langpath, "tchinese"))
|
2010-11-07 21:31:45 +01:00
|
|
|
return "ZHTW";
|
|
|
|
|
|
|
|
else if(strcasestr(langpath, "korean"))
|
|
|
|
return "KO";
|
|
|
|
|
|
|
|
return "EN";
|
|
|
|
}
|
|
|
|
|
2010-12-29 11:22:11 +01:00
|
|
|
bool CSettings::LoadLanguage(const char *path, int lang)
|
2010-09-19 22:25:12 +02:00
|
|
|
{
|
|
|
|
bool ret = false;
|
|
|
|
|
2010-12-29 16:42:26 +01:00
|
|
|
if (path && strlen(path) > 3)
|
|
|
|
{
|
|
|
|
ret = gettextLoadLanguage(path);
|
|
|
|
if (ret)
|
|
|
|
{
|
2011-01-06 19:59:45 +01:00
|
|
|
snprintf(language_path, sizeof(language_path), path);
|
2010-12-29 16:42:26 +01:00
|
|
|
strcpy(db_language, GetLangCode(language_path));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return LoadLanguage(NULL, CONSOLE_DEFAULT);
|
|
|
|
}
|
|
|
|
else if (lang >= 0)
|
2010-09-19 22:25:12 +02:00
|
|
|
{
|
|
|
|
char filepath[150];
|
|
|
|
char langpath[150];
|
2011-01-07 23:42:03 +01:00
|
|
|
snprintf(langpath, sizeof(langpath), "%s", languagefiles_path);
|
2010-09-24 02:48:03 +02:00
|
|
|
if (langpath[strlen(langpath) - 1] != '/')
|
2010-09-19 22:25:12 +02:00
|
|
|
{
|
|
|
|
char * ptr = strrchr(langpath, '/');
|
2010-09-24 02:48:03 +02:00
|
|
|
if (ptr)
|
2010-09-19 22:25:12 +02:00
|
|
|
{
|
|
|
|
ptr++;
|
|
|
|
ptr[0] = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-29 11:22:11 +01:00
|
|
|
if (lang == CONSOLE_DEFAULT)
|
2010-09-19 22:25:12 +02:00
|
|
|
{
|
2010-12-29 11:22:11 +01:00
|
|
|
return LoadLanguage(NULL, CONF_GetLanguage());
|
2010-09-19 22:25:12 +02:00
|
|
|
}
|
2010-12-29 11:22:11 +01:00
|
|
|
else if (lang == JAPANESE)
|
2010-09-19 22:25:12 +02:00
|
|
|
{
|
|
|
|
snprintf(filepath, sizeof(filepath), "%s/japanese.lang", langpath);
|
|
|
|
}
|
2010-12-29 11:22:11 +01:00
|
|
|
else if (lang == ENGLISH)
|
2010-09-19 22:25:12 +02:00
|
|
|
{
|
|
|
|
snprintf(filepath, sizeof(filepath), "%s/english.lang", langpath);
|
|
|
|
}
|
2010-12-29 11:22:11 +01:00
|
|
|
else if (lang == GERMAN)
|
2010-09-19 22:25:12 +02:00
|
|
|
{
|
|
|
|
snprintf(filepath, sizeof(filepath), "%s/german.lang", langpath);
|
|
|
|
}
|
2010-12-29 11:22:11 +01:00
|
|
|
else if (lang == FRENCH)
|
2010-09-19 22:25:12 +02:00
|
|
|
{
|
|
|
|
snprintf(filepath, sizeof(filepath), "%s/french.lang", langpath);
|
|
|
|
}
|
2010-12-29 11:22:11 +01:00
|
|
|
else if (lang == SPANISH)
|
2010-09-19 22:25:12 +02:00
|
|
|
{
|
|
|
|
snprintf(filepath, sizeof(filepath), "%s/spanish.lang", langpath);
|
|
|
|
}
|
2010-12-29 11:22:11 +01:00
|
|
|
else if (lang == ITALIAN)
|
2010-09-19 22:25:12 +02:00
|
|
|
{
|
|
|
|
snprintf(filepath, sizeof(filepath), "%s/italian.lang", langpath);
|
|
|
|
}
|
2010-12-29 11:22:11 +01:00
|
|
|
else if (lang == DUTCH)
|
2010-09-19 22:25:12 +02:00
|
|
|
{
|
|
|
|
snprintf(filepath, sizeof(filepath), "%s/dutch.lang", langpath);
|
|
|
|
}
|
2010-12-29 11:22:11 +01:00
|
|
|
else if (lang == S_CHINESE)
|
2010-09-19 22:25:12 +02:00
|
|
|
{
|
2010-12-26 18:02:14 +01:00
|
|
|
snprintf(filepath, sizeof(filepath), "%s/schinese.lang", langpath);
|
2010-09-19 22:25:12 +02:00
|
|
|
}
|
2010-12-29 11:22:11 +01:00
|
|
|
else if (lang == T_CHINESE)
|
2010-09-19 22:25:12 +02:00
|
|
|
{
|
2010-12-26 18:02:14 +01:00
|
|
|
snprintf(filepath, sizeof(filepath), "%s/tchinese.lang", langpath);
|
2010-09-19 22:25:12 +02:00
|
|
|
}
|
2010-12-29 11:22:11 +01:00
|
|
|
else if (lang == KOREAN)
|
2010-09-19 22:25:12 +02:00
|
|
|
{
|
2010-12-29 11:22:11 +01:00
|
|
|
snprintf(filepath, sizeof(filepath), "%s/korean.lang", langpath);
|
2010-09-19 22:25:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-06 19:59:45 +01:00
|
|
|
strcpy(db_language, GetLangCode(filepath));
|
2010-09-19 22:25:12 +02:00
|
|
|
ret = gettextLoadLanguage(filepath);
|
2010-11-28 16:31:08 +01:00
|
|
|
if (ret)
|
2011-01-06 19:59:45 +01:00
|
|
|
snprintf(language_path, sizeof(language_path), filepath);
|
2010-09-19 22:25:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|