*Addition per Game Lock Feature (Issue 1694) - Patch supplied by pjigar

This commit is contained in:
dimok321 2010-09-28 18:58:56 +00:00
parent c5c5708e12
commit defd5f940b
8 changed files with 141 additions and 8 deletions

View File

@ -2,8 +2,8 @@
<app version="1">
<name> USB Loader GX</name>
<coder>USB Loader GX Team</coder>
<version>1.0 r979</version>
<release_date>201009260941</release_date>
<version>1.0 r980</version>
<release_date>201009281739</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.

View File

@ -539,7 +539,7 @@ int WindowPrompt(const char *title, const char *msg, const char *btn1Label, cons
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);
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"));
@ -1115,6 +1115,35 @@ 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)
{
@ -1176,6 +1205,9 @@ int GameWindowPrompt()
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
GuiImageData imgLocked(Resources::GetFile("lock.png"), Resources::GetFileSize("lock.png"));
GuiImageData imgNotLocked(Resources::GetFile("unlock.png"), Resources::GetFileSize("unlock.png"));
GuiImageData imgFavorite(Resources::GetFile("favorite.png"), Resources::GetFileSize("favorite.png"));
GuiImageData imgNotFavorite(Resources::GetFile("not_favorite.png"), Resources::GetFileSize("not_favorite.png"));
@ -1200,7 +1232,7 @@ int GameWindowPrompt()
GuiButton screenShotBtn(0, 0);
screenShotBtn.SetPosition(0, 0);
screenShotBtn.SetTrigger(&trigZ);
const char * image = "dialogue_box_startgame.png";
if (Settings.widescreen)
@ -1315,6 +1347,11 @@ 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 == yes)
{
@ -1354,6 +1391,7 @@ int GameWindowPrompt()
if (Settings.godmode == 1 && mountMethod != 2 && mountMethod != 3)
{
promptWindow.Append(&btn3);
promptWindow.Append(&btnLocked);
}
promptWindow.Append(&diskImg2);
@ -1495,6 +1533,8 @@ int GameWindowPrompt()
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
@ -1575,6 +1615,15 @@ int GameWindowPrompt()
}
btnFavorite1.ResetState();
}
else if (btnLocked.GetState() == STATE_CLICKED) //switch locked
{
if (isInserted(bootDevice))
{
SetLocked(&btnLocked, header->id, 1);
SetLockedImage(header->id, &btnLockedImg, &imgLocked, &imgNotLocked);
}
btnLocked.ResetState();
}
else if (btnFavorite2.GetState() == STATE_CLICKED) //switch favorite
{
if (isInserted(bootDevice))
@ -3754,7 +3803,7 @@ int HBCWindowPrompt(const char *name, const char *coder, const char *version, co
// 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"));
GuiImageData whiteBox(Resources::GetFile("bg_options.png"), Resources::GetFileSize("bg_options.png"));
@ -3793,7 +3842,7 @@ int HBCWindowPrompt(const char *name, const char *coder, const char *version, co
GuiImageData *iconData = NULL;
GuiImage *iconImg = NULL;
char imgPath[150];
snprintf(imgPath, sizeof(imgPath), "%s", iconPath);

View File

@ -119,6 +119,7 @@ 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");
@ -139,6 +140,14 @@ 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)
@ -242,11 +251,15 @@ 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);
}
@ -259,11 +272,36 @@ 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);
}
@ -291,3 +329,16 @@ 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,6 +11,7 @@ typedef struct _Stats
{
char id[7];
u8 FavoriteRank;
u8 LockStatus;
u8 PlayCount;
} GameStatus;
@ -49,6 +50,14 @@ 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

@ -80,6 +80,7 @@ void CSettings::SetDefault()
tooltips = TooltipsOn;
gamesound = 1;
parentalcontrol = 0;
lockedgames = 0;
cios = 249;
xflip = no;
quickboot = no;
@ -149,7 +150,7 @@ bool CSettings::Load()
snprintf(GameSetPath, sizeof(GameSetPath), ConfigPath);
char * ptr = strrchr(GameSetPath, '/');
if(ptr) ptr[1] = 0;
GameStatistics.Load(GameSetPath);
GameSettings.Load(GameSetPath);
Theme.Load(theme_path);
@ -209,6 +210,7 @@ bool CSettings::Save()
fprintf(file, "quickboot = %d\n ", quickboot);
fprintf(file, "wsprompt = %d\n ", wsprompt);
fprintf(file, "parentalcontrol = %d\n ", parentalcontrol);
fprintf(file, "lockedgames = %d\n ", lockedgames);
fprintf(file, "covers_path = %s\n ", covers_path);
fprintf(file, "covers2d_path = %s\n ", covers2d_path);
fprintf(file, "theme_path = %s\n ", theme_path);
@ -399,6 +401,11 @@ bool CSettings::SetSetting(char *name, char *value)
if (sscanf(value, "%d", &i) == 1) parentalcontrol = i;
return true;
}
else if (strcmp(name, "lockedgames") == 0)
{
if (sscanf(value, "%d", &i) == 1) lockedgames = i;
return true;
}
else if (strcmp(name, "screensaver") == 0)
{
if (sscanf(value, "%d", &i) == 1) screensaver = i;

View File

@ -82,6 +82,7 @@ class CSettings
short tooltips;
char unlockCode[20];
short parentalcontrol;
short lockedgames;
short cios;
short quickboot;
short wsprompt;

View File

@ -55,6 +55,7 @@ static const char *opts_videomode[settings_language_max][2] = { { "", trNOOP( "D
static const char *opts_language[settings_language_max] = { trNOOP( "Console Default" ), trNOOP( "Japanese" ),
trNOOP( "English" ), trNOOP( "German" ), trNOOP( "French" ), trNOOP( "Spanish" ), trNOOP( "Italian" ),
trNOOP( "Dutch" ), trNOOP( "SChinese" ), trNOOP( "TChinese" ), trNOOP( "Korean" ) };
static const char *opts_lockedgames[2] = { trNOOP( "0 (Locked and Unlocked Games)" ), trNOOP( "1 (Unlocked Games Only)" ) };
static const char *opts_parentalcontrol[5] = { trNOOP( "0 (Everyone)" ), trNOOP( "1 (Child 7+)" ),
trNOOP( "2 (Teen 12+)" ), trNOOP( "3 (Mature 16+)" ), trNOOP( "4 (Adults Only 18+)" ) };
static const char *opts_error002[3] = { trNOOP( "No" ), trNOOP( "Yes" ), trNOOP( "Anti" ) };
@ -1316,6 +1317,16 @@ int MenuSettings()
else options2.SetValue(Idx, "********");
}
if (ret == ++Idx || firstRun)
{
if (firstRun) options2.SetName(Idx, "%s", tr( "GamesLevel" ));
if (ret == Idx && Settings.godmode == 1 && ++Settings.lockedgames >= 2) Settings.lockedgames
= 0;
if (Settings.godmode == 1)
options2.SetValue(Idx, "%s", tr( opts_lockedgames[Settings.lockedgames] ));
else options2.SetValue(Idx, "********");
}
firstRun = false;
}
}

View File

@ -128,7 +128,7 @@ int GameList::FilterList(const wchar_t * gameFilter)
if (Settings.parentalcontrol && !Settings.godmode) if (get_block(header) >= Settings.parentalcontrol) continue;
/* Other parental control method */
/* 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
@ -140,6 +140,11 @@ int GameList::FilterList(const wchar_t * gameFilter)
}
}
/* 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)
continue;
wchar_t *gameName = charToWideChar(get_title(header));
if (gameName && *GameFilter.c_str())