*Fixed crash on start i made in last rev by mistake

*Changed boot process to wait for USB in GUI mode.
*Changed headless ID stuff (actually was in last rev)
*Added a GameTitles class for WiiTDB titles and fixed parental control (probably crashed before)
*Removed cfg.c completely now. Nothing left in it.
*Moved per game lock feature from game statistics to the individual game settings. It is not a game statistic ;).
This commit is contained in:
dimok321 2010-10-28 09:00:52 +00:00
parent 6baa46b1e6
commit 2570d6dae8
29 changed files with 233 additions and 516 deletions

View File

@ -2,8 +2,8 @@
<app version="1">
<name> USB Loader GX</name>
<coder>USB Loader GX Team</coder>
<version>1.0 r992</version>
<release_date>201010271735</release_date>
<version>1.0 r993</version>
<release_date>201010280642</release_date>
<short_description>Loads games from USB-devices</short_description>
<long_description>USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times.
The interactive GUI is completely controllable with WiiMote, Classic Controller or GC Controller.

File diff suppressed because one or more lines are too long

View File

@ -26,7 +26,6 @@
#include "filelist.h"
#include "sys.h"
#include "network/http.h"
#include "settings/cfg.h"
#include "utils/minizip/miniunz.h"
#include "usbloader/utils.h"

View File

@ -14,6 +14,7 @@
#include "../settings/CSettings.h"
#include "../main.h"
#include "settings/newtitles.h"
#include "settings/GameTitles.h"
#include "usbloader/GameList.h"
#include "themes/CTheme.h"
@ -120,12 +121,12 @@ GuiGameBrowser::GuiGameBrowser(int w, int h, int selected, int offset)
for (int i = 0; i < pagesize; i++)
{
gameTxt[i] = new GuiText(get_title(gameList[i]), 20, Theme.gametext);
gameTxt[i] = new GuiText(GameTitles.GetTitle(gameList[i]), 20, Theme.gametext);
gameTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
gameTxt[i]->SetPosition(24, 0);
gameTxt[i]->SetMaxWidth(maxTextWidth, DOTTED);
gameTxtOver[i] = new GuiText(get_title(gameList[i]), 20, Theme.gametext);
gameTxtOver[i] = new GuiText(GameTitles.GetTitle(gameList[i]), 20, Theme.gametext);
gameTxtOver[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
gameTxtOver[i]->SetPosition(24, 0);
gameTxtOver[i]->SetMaxWidth(maxTextWidth, SCROLL_HORIZONTAL);
@ -272,9 +273,10 @@ int GuiGameBrowser::FindMenuItem(int currentItem, int direction)
if (nextItem < 0 || nextItem >= gameList.size()) return -1;
if (strlen(get_title(gameList[nextItem])) > 0)
if (strlen(GameTitles.GetTitle(gameList[nextItem])) > 0)
return nextItem;
else return FindMenuItem(nextItem, direction);
return FindMenuItem(nextItem, direction);
}
/**
@ -321,9 +323,9 @@ void GuiGameBrowser::UpdateListEntries()
game[i]->SetVisible(true);
game[i]->SetState(STATE_DEFAULT);
}
gameTxt[i]->SetText(get_title(gameList[next]));
gameTxt[i]->SetText(GameTitles.GetTitle(gameList[next]));
gameTxt[i]->SetPosition(24, 0);
gameTxtOver[i]->SetText(get_title(gameList[next]));
gameTxtOver[i]->SetText(GameTitles.GetTitle(gameList[next]));
gameTxtOver[i]->SetPosition(24, 0);
if (Settings.marknewtitles)

View File

@ -14,6 +14,7 @@
#include "gui_image_async.h"
#include "gui_gamecarousel.h"
#include "usbloader/GameList.h"
#include "settings/GameTitles.h"
#include "../settings/CSettings.h"
#include "themes/CTheme.h"
#include "../main.h"
@ -304,8 +305,7 @@ void GuiGameCarousel::Update(GuiTrigger * t)
if (selectedItem >= 0)
{
game[selectedItem]->SetEffect(EFFECT_SCALE, 1, 130);
char *gameTitle = get_title(gameList[gameIndex[selectedItem]]);
gamename->SetText(gameTitle);
gamename->SetText(GameTitles.GetTitle(gameList[gameIndex[selectedItem]]));
}
else gamename->SetText((char*) NULL);
if (selectedItem_old >= 0) game[selectedItem_old]->SetEffect(EFFECT_SCALE, -1, 100);

View File

@ -13,6 +13,7 @@
#include "gui_gamegrid.h"
#include "gui_image_async.h"
#include "usbloader/GameList.h"
#include "settings/GameTitles.h"
#include "../settings/CSettings.h"
#include "themes/CTheme.h"
#include "../prompts/PromptWindows.h"
@ -566,7 +567,7 @@ void GuiGameGrid::Update(GuiTrigger * t)
coverImg[ii] ->SetScale(VALUE4ROWS( rows, 1.0, 0.6, 0.26 ));
coverImg[ii] ->SetPosition(0, VALUE4ROWS( rows, 0, -50, -80 ));
}
titleTT[ii] ->SetText(get_title(gameList[gameIndex[ii]]));
titleTT[ii] ->SetText(GameTitles.GetTitle(gameList[gameIndex[ii]]));
}
else
{
@ -654,7 +655,7 @@ void GuiGameGrid::Update(GuiTrigger * t)
coverImg[i] ->SetScale(VALUE4ROWS( rows, 1.0, 0.6, 0.26 ));
coverImg[i] ->SetPosition(0, VALUE4ROWS( rows, 0, -50, -80 ));
}
titleTT[i] ->SetText(get_title(gameList[gameIndex[i]]));
titleTT[i] ->SetText(GameTitles.GetTitle(gameList[gameIndex[i]]));
}
else
{
@ -786,7 +787,7 @@ void GuiGameGrid::Reload(int Rows, int ListOffset)
// Tooltip
//------------------------
if (gameIndex[i] != -1)
titleTT[i] = new GuiTooltip(get_title(gameList[gameIndex[i]]), Theme.tooltipAlpha);
titleTT[i] = new GuiTooltip(GameTitles.GetTitle(gameList[gameIndex[i]]), Theme.tooltipAlpha);
else titleTT[i] = new GuiTooltip(NULL, Theme.tooltipAlpha);
//------------------------

View File

@ -16,18 +16,11 @@
#include <unistd.h>
#include <locale.h>
#include <wiiuse/wpad.h>
//#include <debug.h>
extern "C"
{
extern void __exception_setreload(int t);
}
#include <di/di.h>
#include <sys/iosupport.h>
#include "libwiigui/gui.h"
#include "usbloader/wbfs.h"
#include "settings/cfg.h"
#include "language/gettext.h"
#include "mload/mload.h"
#include "mload/mload_modules.h"
@ -56,6 +49,11 @@ extern "C"
#include "system/IosLoader.h"
#include "GameBootProcess.h"
extern "C"
{
extern void __exception_setreload(int t);
}
extern bool geckoinit;
PartList partitions;

View File

@ -254,8 +254,6 @@ int MainMenu(int menu)
{
currentMenu = menu;
MountGamePartition();
pointer[0] = Resources::GetImageData("player1_point.png");
pointer[1] = Resources::GetImageData("player2_point.png");
pointer[2] = Resources::GetImageData("player3_point.png");
@ -275,6 +273,8 @@ int MainMenu(int menu)
bgMusic->Load(Settings.ogg_path);
bgMusic->Play();
MountGamePartition();
while (currentMenu != MENU_EXIT)
{
bgMusic->SetVolume(Settings.volume);

View File

@ -17,7 +17,7 @@ static int FindGamesPartition(PartList * partitions)
if (partitions->wbfs_n != 0)
{
WBFS_Open();
for (int p = 0; p < partitions->num; p++)
{
if (partitions->pinfo[p].fs_type == FS_TYPE_WBFS)
@ -115,8 +115,10 @@ int MountGamePartition(bool ShowGUI)
// Added for slow HDD
for (int retries = 10; retries > 0; retries--)
{
if (Partition_GetList(WBFS_DEVICE_USB, &partitions) != 0)
if (Partition_GetList(WBFS_DEVICE_USB, &partitions) == 0)
break;
sleep(1);
}
if (Settings.partition != -1 && partitions.num > Settings.partition)

View File

@ -11,6 +11,7 @@
#include "settings/Settings.h"
#include "settings/CGameSettings.h"
#include "settings/CGameStatistics.h"
#include "settings/GameTitles.h"
#include "themes/CTheme.h"
#include "wpad.h"
#include "sys.h"
@ -1402,13 +1403,13 @@ int MenuDiscList()
if (!mountMethod)//only get this stuff it we are booting a game from USB
{
WBFS_GameSize(header->id, &size);
if (strlen(get_title(header)) < (MAX_CHARACTERS + 3))
if (strlen(GameTitles.GetTitle(header)) < (MAX_CHARACTERS + 3))
{
sprintf(text, "%s", get_title(header));
sprintf(text, "%s", GameTitles.GetTitle(header));
}
else
{
strncpy(text, get_title(header), MAX_CHARACTERS);
strncpy(text, GameTitles.GetTitle(header), MAX_CHARACTERS);
text[MAX_CHARACTERS] = '\0';
strncat(text, "...", 3);
}
@ -1582,7 +1583,7 @@ int MenuDiscList()
//enter new game title
char entered[60];
snprintf(entered, sizeof(entered), "%s", get_title(header));
snprintf(entered, sizeof(entered), "%s", GameTitles.GetTitle(header));
entered[59] = '\0';
int result = OnScreenKeyboard(entered, 60, 0);
if (result == 1)
@ -1672,8 +1673,8 @@ void rockout(int f)
{
HaltGui();
if (gameSelected >= 0 && gameSelected < gameList.size() && (strcasestr(get_title(gameList[gameSelected]), "guitar")
|| strcasestr(get_title(gameList[gameSelected]), "band") || strcasestr(get_title(gameList[gameSelected]),
if (gameSelected >= 0 && gameSelected < gameList.size() && (strcasestr(GameTitles.GetTitle(gameList[gameSelected]), "guitar")
|| strcasestr(GameTitles.GetTitle(gameList[gameSelected]), "band") || strcasestr(GameTitles.GetTitle(gameList[gameSelected]),
"rock")))
{
for (int i = 0; i < 4; i++)

View File

@ -18,7 +18,7 @@
#include "libs/libwbfs/wiidisc.h"
#include "main.h"
#include "sys.h"
#include "settings/cfg.h"
#include "settings/GameTitles.h"
#include "themes/CTheme.h"
#include "memory.h"
#include "../gecko.h"
@ -115,8 +115,7 @@ int DiscBrowse(struct discHdr * header, char * alternatedname, int alternatednam
GuiTrigger trigB;
trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
GuiText titleTxt(get_title(header), 28, ( GXColor )
{ 0, 0, 0, 255});
GuiText titleTxt(GameTitles.GetTitle(header), 28, ( GXColor ) {0, 0, 0, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetPosition(12, 40);
titleTxt.SetMaxWidth(356, SCROLL_HORIZONTAL);

View File

@ -18,6 +18,7 @@
#include "libwiigui/gui_diskcover.h"
#include "libwiigui/Text.hpp"
#include "settings/CGameStatistics.h"
#include "settings/GameTitles.h"
#include "network/networkops.h"
#include "network/http.h"
#include "prompts/PromptWindows.h"
@ -1106,35 +1107,6 @@ int WindowExitPrompt()
return choice;
}
void SetupLockedButton(GuiButton *btnLocked, GuiImage *img, GuiSound *sndOver, GuiSound *sndClick,
GuiTrigger *trig)
{
btnLocked->SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
//btnLocked->SetPosition(xPos, yPos);
btnLocked->SetPosition(125, 40);
btnLocked->SetImage(img);
btnLocked->SetSoundOver(sndOver);
btnLocked->SetSoundClick(sndClick);
btnLocked->SetTrigger(trig);
btnLocked->SetEffectGrow();
}
u8 SetLocked(GuiButton *lock1, u8* gameId, u8 locked)
{
int LockStatus = (locked == GameStatistics.GetLockStatus(gameId)) ? 0 : locked; // Press the current rank to reset the rank
GameStatistics.SetLockStatus(gameId, LockStatus);
GameStatistics.Save();
return LockStatus;
}
void SetLockedImage(const u8 * gameid, GuiImage *b1, GuiImageData *on, GuiImageData *off)
{
int lockedvar = GameStatistics.GetLockStatus(gameid);
b1->SetImage(lockedvar == 1 ? on : off);
}
void SetupFavoriteButton(GuiButton *btnFavorite, int xPos, GuiImage *img, GuiSound *sndOver, GuiSound *sndClick,
GuiTrigger *trig)
{
@ -1338,11 +1310,6 @@ int GameWindowPrompt()
SetupFavoriteButton(&btnFavorite4, -117, &btnFavoriteImg4, &btnSoundOver, btnClick2, &trigA);
SetupFavoriteButton(&btnFavorite5, -90, &btnFavoriteImg5, &btnSoundOver, btnClick2, &trigA);
GuiImage btnLockedImg;
btnLockedImg.SetWidescreen(Settings.widescreen);
GuiButton btnLocked(imgLocked.GetWidth(), imgLocked.GetHeight());
SetupLockedButton(&btnLocked, &btnLockedImg, &btnSoundOver, btnClick2, &trigA);
GuiImage btnLeftImg(&imgLeft);
if (Settings.wsprompt)
{
@ -1382,7 +1349,6 @@ int GameWindowPrompt()
if (Settings.godmode == 1 && mountMethod != 2 && mountMethod != 3)
{
promptWindow.Append(&btn3);
promptWindow.Append(&btnLocked);
}
promptWindow.Append(&diskImg2);
@ -1519,13 +1485,11 @@ int GameWindowPrompt()
sizeTxt.SetTextf("%.2fGB", size); //set size text;
}
nameTxt.SetText(get_title(header));
nameTxt.SetText(GameTitles.GetTitle(header));
playcntTxt.SetTextf("%s: %i", tr( "Play Count" ), GameStatistics.GetPlayCount(header));
SetFavoriteImages(header->id, &btnFavoriteImg1, &btnFavoriteImg2, &btnFavoriteImg3, &btnFavoriteImg4, &btnFavoriteImg5,
&imgFavorite, &imgNotFavorite);
SetLockedImage(header->id, &btnLockedImg, &imgLocked, &imgNotLocked);
nameTxt.SetPosition(0, 1);
if (changed != 3 && changed != 4) // changed==3 or changed==4 --> only Resume the GUI
@ -1606,15 +1570,6 @@ int GameWindowPrompt()
}
btnFavorite1.ResetState();
}
else if (btnLocked.GetState() == STATE_CLICKED) //switch locked
{
if (isInserted(Settings.BootDevice))
{
SetLocked(&btnLocked, header->id, 1);
SetLockedImage(header->id, &btnLockedImg, &imgLocked, &imgNotLocked);
}
btnLocked.ResetState();
}
else if (btnFavorite2.GetState() == STATE_CLICKED) //switch favorite
{
if (isInserted(Settings.BootDevice))
@ -1803,9 +1758,8 @@ int DiscWait(const char *title, const char *msg, const char *btn1Label, const ch
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
promptWindow.SetPosition(0, -10);
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
GuiImageData dialogBox(Resources::GetFile("dialogue_box.png"), Resources::GetFileSize("dialogue_box.png"));
@ -1862,7 +1816,7 @@ int DiscWait(const char *title, const char *msg, const char *btn1Label, const ch
GuiButton btn2(&btn2Img, &btn2Img, 1, 4, -20, -25, &trigA, &btnSoundOver, btnClick2, 1);
btn2.SetLabel(&btn2Txt);
if ((Settings.wsprompt) && (Settings.widescreen)) /////////////adjust buttons for widescreen
if (Settings.wsprompt && Settings.widescreen) /////////////adjust buttons for widescreen
{
msgTxt.SetMaxWidth(380);
if (btn2Label)

View File

@ -6,6 +6,7 @@
***************************************************************************/
#include <dirent.h>
#include <zlib.h>
#include "language/gettext.h"
#include "libwiigui/gui.h"
@ -16,7 +17,6 @@
#include "network/http.h"
#include "filelist.h"
#include "FileOperations/fileops.h"
#include "settings/cfg.h"
#include "themes/CTheme.h"
#include "sys.h"
#include "menu.h"
@ -31,8 +31,6 @@ u32 titleCnt;
extern u32 infilesize;
extern u32 uncfilesize;
extern char wiiloadVersion[2];
#include <zlib.h>
#include "settings/cfg.h"
/*** Extern functions ***/
extern void ResumeGui();

View File

@ -19,6 +19,7 @@
#include "FileOperations/fileops.h"
#include "prompts/PromptWindows.h"
#include "themes/CTheme.h"
#include "settings/GameTitles.h"
#include "gameinfo.h"
#include "usbloader/GameList.h"
#include "../gecko.h"
@ -1117,7 +1118,7 @@ bool save_gamelist(int txt) // save gamelist
fprintf(f, "%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2], header->id[3], header->id[4],
header->id[5]);
fprintf(f, " [%.2f] ", size);
fprintf(f, " %s", get_title(header));
fprintf(f, " %s", GameTitles.GetTitle(header));
}
fprintf(f, "\n");
}
@ -1134,11 +1135,8 @@ bool save_gamelist(int txt) // save gamelist
if (i < 500)
{
fprintf(f, "\"%c%c%c%c%c%c\",\"%.2f\",\"%s\"\n", header->id[0], header->id[1], header->id[2],
header->id[3], header->id[4], header->id[5], size, get_title(header));
//fprintf(f, "\"%.2f\",", size);
//fprintf(f, "\"%s\"",get_title(header));
header->id[3], header->id[4], header->id[5], size, GameTitles.GetTitle(header));
}
//fprintf(f, "\n");
}
}
fclose(f);

View File

@ -179,7 +179,8 @@ bool CGameSettings::Save()
fprintf(f, "loadalternatedol:%d; ", GameList[i].loadalternatedol);
fprintf(f, "alternatedolstart:%d; ", GameList[i].alternatedolstart);
fprintf(f, "alternatedolname:%s; ", GameList[i].alternatedolname);
fprintf(f, "returnTo:%d;\n", GameList[i].returnTo);
fprintf(f, "returnTo:%d; ", GameList[i].returnTo);
fprintf(f, "Locked:%d;\n", GameList[i].Locked);
}
fprintf(f, "# END\n");
fclose(f);
@ -300,6 +301,14 @@ bool CGameSettings::SetSetting(GameCFG & game, char *name, char *value)
}
return true;
}
else if(strcmp(name, "Locked") == 0)
{
if (sscanf(value, "%d", &i) == 1)
{
game.Locked = i;
}
return true;
}
return false;
}
@ -385,3 +394,15 @@ void CGameSettings::TrimLine(char *dest, const char *src, int size)
dest[i] = '\0';
}
int CGameSettings::GetPartenalPEGI(int parental)
{
switch(parental)
{
case 1: return 7;
case 2: return 12;
case 3: return 16;
case 4: return 18;
default: return -1;
}
}

View File

@ -23,6 +23,7 @@ typedef struct _GameCFG
u8 patchcountrystrings;
char alternatedolname[40];
u8 returnTo;
u8 Locked;
} GameCFG;
class CGameSettings
@ -50,7 +51,8 @@ class CGameSettings
GameCFG * GetGameCFG(const u8 * id) { return GetGameCFG((const char *) id); };
//!Overload
GameCFG * GetGameCFG(const struct discHdr * game) { if(!game) return NULL; else return GetGameCFG(game->id); };
//!Quick settings to PEGI conversion
static int GetPartenalPEGI(int parentalsetting);
protected:
bool ReadGameID(const char * src, char * GameID, int size);
bool SetSetting(GameCFG & game, char *name, char *value);

View File

@ -119,7 +119,6 @@ bool CGameStatistics::Save()
{
fprintf(f, "game:%s = ", GameList[i].id);
fprintf(f, "FavoriteRank:%d; ", GameList[i].FavoriteRank);
fprintf(f, "LockStatus:%d; ", GameList[i].LockStatus);
fprintf(f, "PlayCount:%d;\n", GameList[i].PlayCount);
}
fprintf(f, "# END\n");
@ -140,14 +139,6 @@ bool CGameStatistics::SetSetting(GameStatus & game, char *name, char *value)
}
return true;
}
else if(strcmp(name, "LockStatus") == 0)
{
if (sscanf(value, "%d", &i) == 1)
{
game.LockStatus = i;
}
return true;
}
else if(strcmp(name, "PlayCount") == 0)
{
if (sscanf(value, "%d", &i) == 1)
@ -251,14 +242,12 @@ void CGameStatistics::SetPlayCount(const char * id, int count)
GameStatus NewStatus;
snprintf(NewStatus.id, sizeof(NewStatus.id), id);
NewStatus.FavoriteRank = 0;
NewStatus.LockStatus = 0;
NewStatus.PlayCount = count;
GameStatus * game = GetGameStatus(id);
if(game)
{
NewStatus.FavoriteRank = game->FavoriteRank;
NewStatus.LockStatus = game->LockStatus;
}
AddGame(NewStatus);
@ -272,35 +261,12 @@ void CGameStatistics::SetFavoriteRank(const char * id, int rank)
GameStatus NewStatus;
snprintf(NewStatus.id, sizeof(NewStatus.id), id);
NewStatus.FavoriteRank = rank;
NewStatus.LockStatus = 0;
NewStatus.PlayCount = 0;
GameStatus * game = GetGameStatus(id);
if(game)
{
NewStatus.PlayCount = game->PlayCount;
NewStatus.LockStatus = game->LockStatus;
}
AddGame(NewStatus);
}
void CGameStatistics::SetLockStatus(const char * id, int lock)
{
if(!id)
return;
GameStatus NewStatus;
snprintf(NewStatus.id, sizeof(NewStatus.id), id);
NewStatus.FavoriteRank = 0;
NewStatus.LockStatus = lock;
NewStatus.PlayCount = 0;
GameStatus * game = GetGameStatus(id);
if(game)
{
NewStatus.PlayCount = game->PlayCount;
NewStatus.FavoriteRank = game->FavoriteRank;
}
AddGame(NewStatus);
@ -329,16 +295,3 @@ int CGameStatistics::GetFavoriteRank(const char * id)
return 0;
}
int CGameStatistics::GetLockStatus(const char * id)
{
if(!id)
return 0;
GameStatus * game = GetGameStatus(id);
if(game)
return game->LockStatus;
return 0;
}

View File

@ -11,7 +11,6 @@ typedef struct _Stats
{
char id[7];
u8 FavoriteRank;
u8 LockStatus;
u8 PlayCount;
} GameStatus;
@ -50,14 +49,6 @@ class CGameStatistics
int GetFavoriteRank(const char * id);
int GetFavoriteRank(const u8 * id) { return GetFavoriteRank((const char *) id); };
int GetFavoriteRank(const struct discHdr * game) { if(!game) return 0; else return GetFavoriteRank(game->id); };
//!Overloads for set LockStatus
void SetLockStatus(const char * id, int lock);
void SetLockStatus(const u8 * id, int lock) { SetLockStatus((const char *) id, lock); };
void SetLockStatus(const struct discHdr * game, int lock) { if(!game) return; SetLockStatus(game->id, lock); };
//!Overloads for get LockStatus
int GetLockStatus(const char * id);
int GetLockStatus(const u8 * id) { return GetLockStatus((const char *) id); };
int GetLockStatus(const struct discHdr * game) { if(!game) return 0; else return GetLockStatus(game->id); };
//!Get GameStatus
GameStatus * GetGameStatus(const char * id);
//!Overload

View File

@ -28,7 +28,6 @@
#include <stdio.h>
#include <gctypes.h>
#include "SettingsEnums.h"
#include "cfg.h"
class CSettings
{

View File

@ -0,0 +1,66 @@
#include <string.h>
#include "GameTitles.h"
CGameTitles GameTitles;
void CGameTitles::SetGameTitle(const char * id, const char * title)
{
if(!id || !title)
return;
for(u32 i = 0; i < TitleList.size(); ++i)
{
if(strncasecmp(id, TitleList[i].GameID, 6) == 0)
{
TitleList[i].Title = title;
return;
}
}
GameTitle newTitle;
newTitle.Title = title;
//! Just in case a 0 termination is missing
int n;
for(n = 0; n < 6; ++n)
newTitle.GameID[n] = id[n];
newTitle.GameID[n] = '\0';
TitleList.push_back(newTitle);
}
const char * CGameTitles::GetTitle(const char * id)
{
if(!id)
return NULL;
for(u32 i = 0; i < TitleList.size(); ++i)
{
if(strncasecmp(id, TitleList[i].GameID, 6) == 0)
return TitleList[i].Title.c_str();
}
return NULL;
}
const char * CGameTitles::GetTitle(const struct discHdr *header)
{
if(!header)
return NULL;
for(u32 i = 0; i < TitleList.size(); ++i)
{
if(strncasecmp((const char *) header->id, TitleList[i].GameID, 6) == 0)
return TitleList[i].Title.c_str();
}
return header->title;
}
void CGameTitles::SetDefault()
{
TitleList.clear();
//! Free vector memory
std::vector<GameTitle>().swap(TitleList);
}

View File

@ -0,0 +1,39 @@
#ifndef WIITDB_TITLES_H_
#define WIITDB_TITLES_H_
#include <string>
#include <vector>
#include <gctypes.h>
#include "usbloader/disc.h"
typedef struct _GameTitle
{
char GameID[7];
std::string Title;
} GameTitle;
class CGameTitles
{
public:
//! Set a game title from wiitdb
void SetGameTitle(const char * id, const char * title);
//! Overload
void SetGameTitle(const u8 * id, const char * title) { SetGameTitle((const char *) id, title); };
//! Get a game title
const char * GetTitle(const char * id);
//! Overload
const char * GetTitle(const u8 * id) { return GetTitle((const char *) id); };
//! Overload
const char * GetTitle(const struct discHdr *header);
//! Set default game titles
void SetDefault();
protected:
std::vector<GameTitle> TitleList;
};
extern CGameTitles GameTitles;
#endif

View File

@ -10,6 +10,7 @@
#include "settings/SettingsPrompts.h"
#include "settings/CGameSettings.h"
#include "settings/CGameStatistics.h"
#include "settings/GameTitles.h"
#include "prompts/filebrowser.h"
#include "cheats/cheatmenu.h"
#include "themes/CTheme.h"
@ -19,7 +20,6 @@
#include "filelist.h"
#include "FileOperations/fileops.h"
#include "sys.h"
#include "cfg.h"
#include "usbloader/partition_usbloader.h"
#include "usbloader/utils.h"
#include "xml/xml.h"
@ -2238,13 +2238,13 @@ int MenuSettings()
{
reloaddatabasefile = true;
CloseXMLDatabase();
CFG_Cleanup();
GameTitles.SetDefault();
}
OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN, reloaddatabasefile,
Settings.titlesOverride == 1 ? true : false, true); // open file, reload titles, keep in memory
}
// disable titles from database if setting has changed
if (opt_override != opt_overridenew && Settings.titlesOverride == 0) titles_default();
if (opt_override != opt_overridenew && Settings.titlesOverride == 0) GameTitles.SetDefault();
HaltGui();
@ -2290,11 +2290,11 @@ int MenuGameSettings(struct discHdr * header)
char gameName[31];
if (!mountMethod)
{
if (strlen(get_title(header)) < (27 + 3))
sprintf(gameName, "%s", get_title(header));
if (strlen(GameTitles.GetTitle(header)) < (27 + 3))
sprintf(gameName, "%s", GameTitles.GetTitle(header));
else
{
strncpy(gameName, get_title(header), 27);
strncpy(gameName, GameTitles.GetTitle(header), 27);
gameName[27] = '\0';
strncat(gameName, "...", 3);
}
@ -2302,7 +2302,7 @@ int MenuGameSettings(struct discHdr * header)
else sprintf(gameName, "%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2], header->id[3], header->id[4],
header->id[5]);
GuiText titleTxt(!mountMethod ? get_title(header) : gameName, 28, ( GXColor )
GuiText titleTxt(!mountMethod ? GameTitles.GetTitle(header) : gameName, 28, ( GXColor )
{ 0, 0, 0, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetPosition(12, 40);
@ -2434,6 +2434,7 @@ int MenuGameSettings(struct discHdr * header)
game_cfg.iosreloadblock = OFF;
strcpy(game_cfg.alternatedolname, "");
game_cfg.returnTo = 1;
game_cfg.Locked = 0;
}
int pageToDisplay = 1;
@ -2791,6 +2792,13 @@ int MenuGameSettings(struct discHdr * header)
options2.SetValue(Idx, "%s", tr( opts_off_on[game_cfg.iosreloadblock] ));
}
if (ret == ++Idx || firstRun)
{
if (firstRun) options2.SetName(Idx, "%s", tr( "Game Locked" ));
if (ret == Idx && ++game_cfg.Locked >= MAX_ON_OFF) game_cfg.Locked = 0;
options2.SetValue(Idx, "%s", tr( opts_off_on[game_cfg.Locked] ));
}
firstRun = false;
}
}
@ -3015,6 +3023,7 @@ int MenuGameSettings(struct discHdr * header)
game_cfg.parentalcontrol = 0;
strcpy(game_cfg.alternatedolname, "");
game_cfg.returnTo = 1;
game_cfg.Locked = 0;
GameSettings.Remove(header->id);
GameSettings.Save();
}

View File

@ -1,307 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <ctype.h>
#include <ogcsys.h>
#include "language/gettext.h"
#include "FileOperations/fileops.h"
#include "cfg.h"
#define isspace2(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v')
u8 ocarinaChoice = 0;
u8 videoChoice = 0;
u8 faveChoice = 0;
u8 languageChoice = 0;
u8 viChoice = 0;
u8 iosChoice = 0;
u8 parentalcontrolChoice = 0;
u8 fix002 = 0;
u8 reloadblock = 0;
u8 countrystrings = 0;
u8 alternatedol = 0;
u32 alternatedoloffset = 0;
u8 xflip = 0;
u8 sort = 0;
u8 fave = 0;
u8 qboot = 0;
u8 wsprompt = 0;
u8 keyset = 0;
u8 listDisplay = 0;
u8 partition = -1;
char alternatedname[40];
u8 returnToLoaderGV = 1; //global variable used for returnToLoaderShit. defaults to "yes, patch return to loader"
struct ID_Title
{
char id[6];
char * title;
};
struct ID_Control
{
char id[6];
u8 block;
};
// renamed titles
int num_title = 0; //number of titles
struct ID_Title *cfg_title = NULL;
int num_control = 0;
struct ID_Control *cfg_control = NULL;
char *cfg_get_title(u8 *id)
{
if (!id) return NULL;
int i;
for (i = 0; i < num_title; i++)
{
if (strncmp((char*) id, cfg_title[i].id, 6) == 0)
{
return cfg_title[i].title;
}
}
return NULL;
}
char *get_title(struct discHdr *header)
{
if (!header) return NULL;
char *title = cfg_get_title(header->id);
if (title) return title;
return header->title;
}
void title_set(char *id, char *title)
{
if (!id || !title) return;
if (!cfg_title) cfg_title = (struct ID_Title *) malloc(sizeof(struct ID_Title));
char *idt = cfg_get_title((u8*) id);
if (idt)
{
// replace
free(idt);
idt = strdup(title);
}
else
{
struct ID_Title * tmpStruct = (struct ID_Title *) realloc(cfg_title, (num_title + 1) * sizeof(struct ID_Title));
if (!tmpStruct)
{
// error
CFG_Cleanup();
num_title = 0;
return;
}
cfg_title = tmpStruct;
// add
strncpy(cfg_title[num_title].id, id, 6);
cfg_title[num_title].title = strdup(title);
num_title++;
}
}
void titles_default()
{
int i;
for (i = 0; i < num_title; i++)
{
memset(cfg_title[i].id, 0, 6);
free(cfg_title[i].title);
cfg_title[i].title = NULL;
}
}
u8 cfg_get_block(u8 *id)
{
int i;
for (i = 0; i < num_control; i++)
{
if (memcmp(id, cfg_control[i].id, 6) == 0)
{
return cfg_control[i].block;
}
}
return 0;
}
u8 get_block(struct discHdr *header)
{
return cfg_get_block(header->id);
}
s8 get_pegi_block(struct discHdr *header)
{
switch (get_block(header))
{
case 1:
return 7;
case 2:
return 12;
case 3:
return 16;
case 4:
return 18;
default:
return -1;
}
}
// trim leading and trailing whitespace
// copy at max n or at max size-1
char* trim_n_copy(char *dest, char *src, int n, int size)
{
int len;
// trim leading white space
while (isspace2( *src ))
{
src++;
n--;
}
len = strlen(src);
if (len > n) len = n;
// trim trailing white space
while (len > 0 && isspace2( src[len-1] ))
len--;
if (len >= size) len = size - 1;
strlcpy(dest, src, len + 1);
//printf("trim_copy: '%s' %d\n", dest, len); //sleep(1);
return dest;
}
char* trimcopy(char *dest, char *src, int size)
{
int len;
while (*src == ' ')
src++;
len = strlen(src);
// trim trailing " \r\n"
while (len > 0 && strchr(" \r\n", src[len - 1]))
len--;
if (len >= size) len = size - 1;
strlcpy(dest, src, len + 1);
return dest;
}
// split line to part1 delimiter part2
bool trimsplit(char *line, char *part1, char *part2, char delim, int size)
{
char *eq = strchr(line, delim);
if (!eq) return false;
trim_n_copy(part1, line, eq - line, size);
trimcopy(part2, eq + 1, size);
return true;
}
void cfg_parseline(char *line, void(*set_func)(char*, char*))
{
// split name = value
char tmp[300], name[200], val[200];
strlcpy(tmp, line, sizeof(tmp));
char *eq = strchr(tmp, '=');
if (!eq) return;
*eq = 0;
trimcopy(name, tmp, sizeof(name));
trimcopy(val, eq + 1, sizeof(val));
//printf("CFG: %s = %s\n", name, val);
set_func(name, val);
}
void cfg_parsetitleline(char *line, void(*set_func)(char*, char*, u8))
{
// split name = value
char tmp[200], name[200], val[200];
int block = 0;
strlcpy(tmp, line, sizeof(tmp));
char *eq = strchr(tmp, '=');
if (!eq) return;
*eq = 0;
trimcopy(name, tmp, sizeof(name));
char *blockpos = strrchr(eq + 1, '=');
if (!blockpos)
trimcopy(val, eq + 1, sizeof(val));
else
{
*blockpos = 0;
trimcopy(val, eq + 1, sizeof(val));
if (sscanf(blockpos + 1, "%d", &block) != 1)
{
block = 0;
}
}
set_func(name, val, block);
}
bool cfg_parsefile(char *fname, void(*set_func)(char*, char*))
{
FILE *f;
char line[300];
//printf("opening(%s)\n", fname);
f = fopen(fname, "r");
if (!f)
{
//printf("error opening(%s)\n", fname);
return false;
}
while (fgets(line, sizeof(line), f))
{
// lines starting with # are comments
if (line[0] == '#') continue;
cfg_parseline(line, set_func);
}
fclose(f);
return true;
}
bool cfg_parsetitlefile(char *fname, void(*set_func)(char*, char*, u8))
{
FILE *f;
char line[200];
//printf("opening(%s)\n", fname);
f = fopen(fname, "r");
if (!f)
{
//printf("error opening(%s)\n", fname);
return false;
}
while (fgets(line, sizeof(line), f))
{
// lines starting with # are comments
if (line[0] == '#') continue;
cfg_parsetitleline(line, set_func);
}
fclose(f);
return true;
}
void CFG_Cleanup(void)
{
int i = 0;
for (i = 0; i < num_title; i++)
{
if (cfg_title[i].title) free(cfg_title[i].title);
cfg_title[i].title = NULL;
}
if (cfg_title)
{
free(cfg_title);
cfg_title = NULL;
}
num_title = 0;
}

View File

@ -1,26 +0,0 @@
#ifndef _CFG_H_
#define _CFG_H_
#include <gctypes.h>
#ifdef __cplusplus
extern "C"
{
#endif
#include "usbloader/disc.h"
char *get_title(struct discHdr *header);
char *cfg_get_title(u8 *id);
void title_set(char *id, char *title);
void titles_default();
u8 get_block(struct discHdr *header);
s8 get_pegi_block(struct discHdr *header);
void CFG_Cleanup(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -27,7 +27,9 @@
#include "usbloader/wbfs.h"
#include "settings/newtitles.h"
#include "settings/CSettings.h"
#include "settings/CGameSettings.h"
#include "settings/CGameStatistics.h"
#include "settings/GameTitles.h"
#include "xml/xml.h"
#include "FreeTypeGX.h"
#include "GameList.h"
@ -135,28 +137,37 @@ int GameList::FilterList(const wchar_t * gameFilter)
}
//ignore uLoader cfg "iso". i was told it is "__CFG_" but not confirmed
if (strncasecmp((char*) header->id, "__CFG_", 6) == 0) continue;
if (strncasecmp((char*) header->id, "__CFG_", 6) == 0)
continue;
if (Settings.parentalcontrol && !Settings.godmode) if (get_block(header) >= Settings.parentalcontrol) continue;
GameCFG * GameConfig = GameSettings.GetGameCFG(header);
if (Settings.parentalcontrol && !Settings.godmode)
{
if (GameConfig && GameConfig->parentalcontrol >= Settings.parentalcontrol)
continue;
}
/* Rating based parental control method */
if (Settings.parentalcontrol == 0 && Settings.godmode == 0 && Settings.Parental.enabled == 1)
{
// Check game rating in WiiTDB, since the default Wii parental control setting is enabled
s32 rating = GetRatingForGame((char *) header->id);
if ((rating != -1 && rating > Settings.Parental.rating) || (rating == -1 && get_pegi_block(header)
> Settings.Parental.rating))
if ((rating != -1 && rating > Settings.Parental.rating) ||
(GameConfig && rating == -1 &&
CGameSettings::GetPartenalPEGI(GameConfig->parentalcontrol)
> Settings.Parental.rating))
{
continue;
}
}
/* Game lock based parental control method */
// If game lock is set to "1 (Unlocked Games Only)" and the game is locked, then skip
if(Settings.lockedgames == 1 && Settings.godmode == 0 && GameStatistics.GetLockStatus(header->id) == 1)
//! Per game lock method
if(!Settings.godmode && Settings.lockedgames && GameConfig && GameConfig->Locked)
continue;
wchar_t *gameName = charToWideChar(get_title(header));
wchar_t *gameName = charToWideChar(GameTitles.GetTitle(header));
if (gameName && *GameFilter.c_str())
{
@ -203,7 +214,7 @@ int GameList::LoadUnfiltered()
/* Register game */
NewTitles::Instance()->CheckGame(header->id);
wchar_t *gameName = charToWideChar(get_title(header));
wchar_t *gameName = charToWideChar(GameTitles.GetTitle(header));
if (gameName)
{
if (wcslen(gameName) > GameFilter.size() && AvailableSearchChars.find(gameName[GameFilter.size()])
@ -249,7 +260,7 @@ void GameList::SortList()
bool GameList::NameSortCallback(const struct discHdr *a, const struct discHdr *b)
{
return (strcasecmp(get_title((struct discHdr *) a), get_title((struct discHdr *) b)) < 0);
return (strcasecmp(GameTitles.GetTitle((struct discHdr *) a), GameTitles.GetTitle((struct discHdr *) b)) < 0);
}
bool GameList::PlaycountSortCallback(const struct discHdr *a, const struct discHdr *b)

View File

@ -10,7 +10,6 @@
#include "disc.h"
#include "alternatedol.h"
#include "fstfile.h"
#include "settings/cfg.h"
#include "gecko.h"
#include "patches/wip.h"
#include "patches/dolpatcher.h"

View File

@ -12,6 +12,7 @@
#include <ctype.h>
#include "settings/CSettings.h"
#include "settings/GameTitles.h"
#include "usbloader/disc.h"
#include "fatmounter.h"
#include "wbfs_fat.h"
@ -357,7 +358,7 @@ s32 Wbfs_Fat::GetHeadersCount()
int len;
char dir_title[65];
char fname_title[TITLE_LEN];
char *title;
const char *title;
DIR_ITER *dir_iter;
//dbg_time1();
@ -467,7 +468,7 @@ s32 Wbfs_Fat::GetHeadersCount()
// size must be at least 1MB to be considered a valid wbfs file
if (st.st_size < 1024 * 1024) continue;
// if we have titles.txt entry use that
title = cfg_get_title(id);
title = GameTitles.GetTitle(id);
// if no titles.txt get title from dir or file name
if (!title && *fname_title)
{
@ -741,7 +742,7 @@ void Wbfs_Fat::mk_title_txt(struct discHdr *header, char *path)
f = fopen(fname, "wb");
if (!f) return;
fprintf(f, "%.6s = %.64s\n", header->id, get_title(header));
fprintf(f, "%.6s = %.64s\n", header->id, GameTitles.GetTitle(header));
fclose(f);
printf("Info file: %s\n", fname);
}
@ -754,7 +755,7 @@ void Wbfs_Fat::mk_gameid_title(struct discHdr *header, char *name, int re_space,
memcpy(name, header->id, 6);
name[6] = 0;
strncpy(title, get_title(header), sizeof(title));
strncpy(title, GameTitles.GetTitle(header), sizeof(title));
title_filename(title);
if (layout == 0)

View File

@ -19,8 +19,6 @@
#include "gecko.h"
#include "libwiigui/gui.h"
#include "settings/cfg.h"
#define DEFAULT_FIFO_SIZE 256 * 1024
static unsigned int *xfb[2] = { NULL, NULL }; // Double buffered
static int whichfb = 0; // Switch

View File

@ -8,15 +8,24 @@
#include <unzip/unzip.h>
#include "settings/CSettings.h"
#include "settings/CGameSettings.h"
#include "settings/GameTitles.h"
#include "xml/xml.h"
extern "C"
{
extern void title_set(char *id, char *title);
extern char* trimcopy(char *dest, char *src, int size);
extern char game_partition[6];
}
extern char game_partition[6];
static char * trimcopy(char *dest, char *src, int size)
{
int len;
while (*src == ' ')
src++;
len = strlen(src);
// trim trailing " \r\n"
while (len > 0 && strchr(" \r\n", src[len - 1]))
len--;
if (len >= size) len = size - 1;
strlcpy(dest, src, len + 1);
return dest;
}
/* config */
static bool xmldebug = false;
static char xmlcfg_filename[100] = "wiitdb";
@ -334,7 +343,7 @@ void LoadTitlesFromXML(char *langtxt, bool forcejptoen)
}
snprintf(id_text, 7, "%s", id_text);
title_set(id_text, title_text);
GameTitles.SetGameTitle(id_text, title_text);
}
}