mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-09-09 00:53:19 +02:00
![dimok321](/assets/img/avatar_default.png)
*Rewrote the whole Settings.cpp into 11 classes. Each settings menu has it's own class now *Reworked the whole sound system. Supported formats AIF/MP3/OGG/BNS/WAV now with no file size limit (streaming). *Changed button click/over sounds to wav from raw pcm *Lot's of bug fixes
182 lines
5.6 KiB
C++
182 lines
5.6 KiB
C++
/****************************************************************************
|
|
* 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 <unistd.h>
|
|
#include "ParentalControlSM.hpp"
|
|
#include "settings/CSettings.h"
|
|
#include "prompts/PromptWindows.h"
|
|
#include "language/gettext.h"
|
|
|
|
static const char * LockModeText[] =
|
|
{
|
|
trNOOP( "Locked" ),
|
|
trNOOP( "Unlocked" )
|
|
};
|
|
|
|
static const char * ParentalText[5] =
|
|
{
|
|
trNOOP( "0 (Everyone)" ),
|
|
trNOOP( "1 (Child 7+)" ),
|
|
trNOOP( "2 (Teen 12+)" ),
|
|
trNOOP( "3 (Mature 16+)" ),
|
|
trNOOP( "4 (Adults Only 18+)" )
|
|
};
|
|
|
|
static const char * LockedGamesText[2] =
|
|
{
|
|
trNOOP( "0 (Locked and Unlocked Games)" ),
|
|
trNOOP( "1 (Unlocked Games Only)" )
|
|
};
|
|
|
|
ParentalControlSM::ParentalControlSM()
|
|
: SettingsMenu(tr("Parental Control"), &GuiOptions, MENU_NONE)
|
|
{
|
|
int Idx = 0;
|
|
Options->SetName(Idx++, "%s", tr( "Console" ));
|
|
Options->SetName(Idx++, "%s", tr( "Password" ));
|
|
Options->SetName(Idx++, "%s", tr( "Controllevel" ));
|
|
Options->SetName(Idx++, "%s", tr( "GamesLevel" ));
|
|
|
|
SetOptionValues();
|
|
}
|
|
|
|
void ParentalControlSM::SetOptionValues()
|
|
{
|
|
int Idx = 0;
|
|
|
|
//! Settings: Console
|
|
Options->SetValue(Idx++, "%s", tr( LockModeText[Settings.godmode] ));
|
|
|
|
//! Settings: Password
|
|
if (!Settings.godmode)
|
|
Options->SetValue(Idx++, "********");
|
|
else if (strcmp(Settings.unlockCode, "") == 0)
|
|
Options->SetValue(Idx++, "%s", tr( "not set" ));
|
|
else
|
|
Options->SetValue(Idx++, Settings.unlockCode);
|
|
|
|
//! Settings: Controllevel
|
|
if (Settings.godmode)
|
|
Options->SetValue(Idx++, "%s", tr( ParentalText[Settings.parentalcontrol] ));
|
|
else
|
|
Options->SetValue(Idx++, "********");
|
|
|
|
|
|
//! Settings: GamesLevel
|
|
if (Settings.godmode)
|
|
Options->SetValue(Idx++, "%s", tr( LockedGamesText[Settings.lockedgames] ));
|
|
else
|
|
Options->SetValue(Idx++, "********");
|
|
}
|
|
|
|
int ParentalControlSM::GetMenuInternal()
|
|
{
|
|
int ret = optionBrowser->GetClickedOption();
|
|
|
|
if (ret < 0)
|
|
return MENU_NONE;
|
|
|
|
int Idx = -1;
|
|
|
|
//! Settings: Console
|
|
if (ret == ++Idx)
|
|
{
|
|
if (strcmp(Settings.unlockCode, "") == 0 && !Settings.Parental.enabled)
|
|
{
|
|
Settings.godmode = !Settings.godmode;
|
|
}
|
|
else if (!Settings.godmode)
|
|
{
|
|
char entered[20];
|
|
memset(entered, 0, 20);
|
|
|
|
//password check to unlock Install,Delete and Format
|
|
SetState(STATE_DISABLED);
|
|
int result = Settings.Parental.enabled == 0 ? OnScreenKeyboard(entered, 20, 0) : OnScreenNumpad(entered, 5);
|
|
SetState(STATE_DEFAULT);
|
|
if (result == 1)
|
|
{
|
|
if (strcmp(entered, Settings.unlockCode) == 0 || !memcmp(entered, Settings.Parental.pin, 4)) //if password correct
|
|
{
|
|
WindowPrompt(
|
|
tr( "Correct Password" ),
|
|
tr( "All the features of USB Loader GX are unlocked." ),
|
|
tr( "OK" ));
|
|
Settings.godmode = 1;
|
|
}
|
|
else
|
|
WindowPrompt(tr( "Wrong Password" ), tr( "USB Loader GX is protected" ), tr( "OK" ));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
int choice = WindowPrompt(tr( "Lock Console" ), tr( "Are you sure?" ),
|
|
tr( "Yes" ), tr( "No" ));
|
|
if (choice == 1)
|
|
{
|
|
WindowPrompt(tr( "Console Locked" ), tr( "USB Loader GX is protected" ),
|
|
tr( "OK" ));
|
|
Settings.godmode = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
//! Settings: Password
|
|
else if (ret == ++Idx)
|
|
{
|
|
if (Settings.godmode)
|
|
{
|
|
char entered[20];
|
|
SetState(STATE_DISABLED);
|
|
snprintf(entered, sizeof(entered), Settings.unlockCode);
|
|
int result = OnScreenKeyboard(entered, 20, 0);
|
|
SetState(STATE_DEFAULT);
|
|
if (result == 1)
|
|
{
|
|
snprintf(Settings.unlockCode, sizeof(Settings.unlockCode), entered);
|
|
WindowPrompt(tr( "Password Changed" ), tr( "Password has been changed" ), tr( "OK" ));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
WindowPrompt(tr( "Password Changed" ), tr( "Console should be unlocked to modify it." ), tr( "OK" ));
|
|
}
|
|
}
|
|
|
|
//! Settings: Controllevel
|
|
else if (ret == ++Idx)
|
|
{
|
|
if (Settings.godmode && ++Settings.parentalcontrol >= 5) Settings.parentalcontrol = 0;
|
|
}
|
|
|
|
//! Settings: GamesLevel
|
|
else if (ret == ++Idx)
|
|
{
|
|
if (Settings.godmode && ++Settings.lockedgames >= 2) Settings.lockedgames = 0;
|
|
}
|
|
|
|
SetOptionValues();
|
|
|
|
return MENU_NONE;
|
|
}
|