From 2570d6dae80b659d0376ffa7f1722134bd37f893 Mon Sep 17 00:00:00 2001 From: dimok321 <15055714+dimok789@users.noreply.github.com> Date: Thu, 28 Oct 2010 09:00:52 +0000 Subject: [PATCH] *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 ;). --- HBC/META.XML | 4 +- gui.pnproj | 2 +- source/homebrewboot/HomebrewBrowse.cpp | 1 - source/libwiigui/gui_gamebrowser.cpp | 14 +- source/libwiigui/gui_gamecarousel.cpp | 4 +- source/libwiigui/gui_gamegrid.cpp | 7 +- source/main.cpp | 12 +- source/menu.cpp | 4 +- source/menu/MountGamePartition.cpp | 6 +- source/menu/menu_disclist.cpp | 13 +- source/prompts/DiscBrowser.cpp | 5 +- source/prompts/PromptWindows.cpp | 54 +---- source/prompts/TitleBrowser.cpp | 4 +- source/prompts/gameinfo.cpp | 8 +- source/settings/CGameSettings.cpp | 23 +- source/settings/CGameSettings.h | 4 +- source/settings/CGameStatistics.cpp | 47 ---- source/settings/CGameStatistics.h | 9 - source/settings/CSettings.h | 1 - source/settings/GameTitles.cpp | 66 ++++++ source/settings/GameTitles.h | 39 ++++ source/settings/Settings.cpp | 23 +- source/settings/cfg.c | 307 ------------------------- source/settings/cfg.h | 26 --- source/usbloader/GameList.cpp | 31 ++- source/usbloader/apploader.c | 1 - source/usbloader/wbfs/wbfs_fat.cpp | 9 +- source/video.cpp | 2 - source/xml/xml.cpp | 23 +- 29 files changed, 233 insertions(+), 516 deletions(-) create mode 100644 source/settings/GameTitles.cpp create mode 100644 source/settings/GameTitles.h delete mode 100644 source/settings/cfg.c delete mode 100644 source/settings/cfg.h diff --git a/HBC/META.XML b/HBC/META.XML index 5a2e321a..d8fe77d0 100644 --- a/HBC/META.XML +++ b/HBC/META.XML @@ -2,8 +2,8 @@ USB Loader GX USB Loader GX Team - 1.0 r992 - 201010271735 + 1.0 r993 + 201010280642 Loads games from USB-devices 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. diff --git a/gui.pnproj b/gui.pnproj index 8e25e270..5c91f098 100644 --- a/gui.pnproj +++ b/gui.pnproj @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/source/homebrewboot/HomebrewBrowse.cpp b/source/homebrewboot/HomebrewBrowse.cpp index 4f210b95..0936bd51 100644 --- a/source/homebrewboot/HomebrewBrowse.cpp +++ b/source/homebrewboot/HomebrewBrowse.cpp @@ -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" diff --git a/source/libwiigui/gui_gamebrowser.cpp b/source/libwiigui/gui_gamebrowser.cpp index 0351b520..54cc2aa2 100644 --- a/source/libwiigui/gui_gamebrowser.cpp +++ b/source/libwiigui/gui_gamebrowser.cpp @@ -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) diff --git a/source/libwiigui/gui_gamecarousel.cpp b/source/libwiigui/gui_gamecarousel.cpp index dfe10e2f..d333fa2f 100644 --- a/source/libwiigui/gui_gamecarousel.cpp +++ b/source/libwiigui/gui_gamecarousel.cpp @@ -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); diff --git a/source/libwiigui/gui_gamegrid.cpp b/source/libwiigui/gui_gamegrid.cpp index 4d0eb59d..bf04ef8d 100644 --- a/source/libwiigui/gui_gamegrid.cpp +++ b/source/libwiigui/gui_gamegrid.cpp @@ -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); //------------------------ diff --git a/source/main.cpp b/source/main.cpp index 1d46e4dd..29a570a4 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -16,18 +16,11 @@ #include #include #include -//#include -extern "C" -{ - extern void __exception_setreload(int t); -} - #include #include #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; diff --git a/source/menu.cpp b/source/menu.cpp index 8aa0b792..ae829a41 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -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); diff --git a/source/menu/MountGamePartition.cpp b/source/menu/MountGamePartition.cpp index 1dfe6323..ad431cfc 100644 --- a/source/menu/MountGamePartition.cpp +++ b/source/menu/MountGamePartition.cpp @@ -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) diff --git a/source/menu/menu_disclist.cpp b/source/menu/menu_disclist.cpp index 19b3b6b4..a1ddfd15 100644 --- a/source/menu/menu_disclist.cpp +++ b/source/menu/menu_disclist.cpp @@ -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++) diff --git a/source/prompts/DiscBrowser.cpp b/source/prompts/DiscBrowser.cpp index 399dd154..9ea1d212 100644 --- a/source/prompts/DiscBrowser.cpp +++ b/source/prompts/DiscBrowser.cpp @@ -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); diff --git a/source/prompts/PromptWindows.cpp b/source/prompts/PromptWindows.cpp index ee658566..d81f4dd8 100644 --- a/source/prompts/PromptWindows.cpp +++ b/source/prompts/PromptWindows.cpp @@ -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) diff --git a/source/prompts/TitleBrowser.cpp b/source/prompts/TitleBrowser.cpp index 8de6a750..d0c7d7ec 100644 --- a/source/prompts/TitleBrowser.cpp +++ b/source/prompts/TitleBrowser.cpp @@ -6,6 +6,7 @@ ***************************************************************************/ #include +#include #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 -#include "settings/cfg.h" /*** Extern functions ***/ extern void ResumeGui(); diff --git a/source/prompts/gameinfo.cpp b/source/prompts/gameinfo.cpp index 15107930..aead4724 100644 --- a/source/prompts/gameinfo.cpp +++ b/source/prompts/gameinfo.cpp @@ -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); diff --git a/source/settings/CGameSettings.cpp b/source/settings/CGameSettings.cpp index 4b294dfe..7cae81d2 100644 --- a/source/settings/CGameSettings.cpp +++ b/source/settings/CGameSettings.cpp @@ -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; + } +} diff --git a/source/settings/CGameSettings.h b/source/settings/CGameSettings.h index 16cf74c4..815d5275 100644 --- a/source/settings/CGameSettings.h +++ b/source/settings/CGameSettings.h @@ -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); diff --git a/source/settings/CGameStatistics.cpp b/source/settings/CGameStatistics.cpp index 16d8b2b6..5afc6697 100644 --- a/source/settings/CGameStatistics.cpp +++ b/source/settings/CGameStatistics.cpp @@ -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; -} - diff --git a/source/settings/CGameStatistics.h b/source/settings/CGameStatistics.h index b816281b..86bd5165 100644 --- a/source/settings/CGameStatistics.h +++ b/source/settings/CGameStatistics.h @@ -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 diff --git a/source/settings/CSettings.h b/source/settings/CSettings.h index e566b90e..ab72a3b8 100644 --- a/source/settings/CSettings.h +++ b/source/settings/CSettings.h @@ -28,7 +28,6 @@ #include #include #include "SettingsEnums.h" -#include "cfg.h" class CSettings { diff --git a/source/settings/GameTitles.cpp b/source/settings/GameTitles.cpp new file mode 100644 index 00000000..934e2fdc --- /dev/null +++ b/source/settings/GameTitles.cpp @@ -0,0 +1,66 @@ +#include +#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().swap(TitleList); +} diff --git a/source/settings/GameTitles.h b/source/settings/GameTitles.h new file mode 100644 index 00000000..5c5b1adb --- /dev/null +++ b/source/settings/GameTitles.h @@ -0,0 +1,39 @@ +#ifndef WIITDB_TITLES_H_ +#define WIITDB_TITLES_H_ + +#include +#include +#include +#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 TitleList; +}; + +extern CGameTitles GameTitles; + +#endif diff --git a/source/settings/Settings.cpp b/source/settings/Settings.cpp index c7ac9d01..3ef4d05b 100644 --- a/source/settings/Settings.cpp +++ b/source/settings/Settings.cpp @@ -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(); } diff --git a/source/settings/cfg.c b/source/settings/cfg.c deleted file mode 100644 index 46028388..00000000 --- a/source/settings/cfg.c +++ /dev/null @@ -1,307 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#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; -} - diff --git a/source/settings/cfg.h b/source/settings/cfg.h deleted file mode 100644 index 7abd704d..00000000 --- a/source/settings/cfg.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef _CFG_H_ -#define _CFG_H_ - -#include - -#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 diff --git a/source/usbloader/GameList.cpp b/source/usbloader/GameList.cpp index d17efe60..aa6c6261 100644 --- a/source/usbloader/GameList.cpp +++ b/source/usbloader/GameList.cpp @@ -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) diff --git a/source/usbloader/apploader.c b/source/usbloader/apploader.c index 670816d0..24e2315c 100644 --- a/source/usbloader/apploader.c +++ b/source/usbloader/apploader.c @@ -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" diff --git a/source/usbloader/wbfs/wbfs_fat.cpp b/source/usbloader/wbfs/wbfs_fat.cpp index 3a23a611..4f33d16e 100644 --- a/source/usbloader/wbfs/wbfs_fat.cpp +++ b/source/usbloader/wbfs/wbfs_fat.cpp @@ -12,6 +12,7 @@ #include #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) diff --git a/source/video.cpp b/source/video.cpp index fccc694f..cac33301 100644 --- a/source/video.cpp +++ b/source/video.cpp @@ -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 diff --git a/source/xml/xml.cpp b/source/xml/xml.cpp index e4f1925b..0a7f409b 100644 --- a/source/xml/xml.cpp +++ b/source/xml/xml.cpp @@ -8,15 +8,24 @@ #include #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); } }