2011-01-20 16:00:55 +01:00
/****************************************************************************
2010-11-13 23:34:53 +01:00
* Copyright ( C ) 2010
* by Dimok
*
* This software is provided ' as - is ' , without any express or implied
* warranty . In no event will the authors be held liable for any
* damages arising from the use of this software .
*
* Permission is granted to anyone to use this software for any
* purpose , including commercial applications , and to alter it and
* redistribute it freely , subject to the following restrictions :
*
* 1. The origin of this software must not be misrepresented ; you
* must not claim that you wrote the original software . If you use
* this software in a product , an acknowledgment in the product
* documentation would be appreciated but is not required .
*
* 2. Altered source versions must be plainly marked as such , and
* must not be misrepresented as being the original software .
*
* 3. This notice may not be removed or altered from any source
* distribution .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# include <unistd.h>
2011-01-09 11:45:29 +01:00
# include <gccore.h>
2010-11-13 23:34:53 +01:00
# include "settings/CSettings.h"
2011-01-09 11:45:29 +01:00
# include "themes/CTheme.h"
2010-11-13 23:34:53 +01:00
# include "prompts/PromptWindows.h"
2011-01-09 11:45:29 +01:00
# include "prompts/DiscBrowser.h"
2011-01-21 20:43:59 +01:00
# include "usbloader/AlternateDOLOffsets.h"
2010-11-13 23:34:53 +01:00
# include "language/gettext.h"
# include "wad/nandtitle.h"
2011-05-30 21:49:12 +02:00
# include "system/IosLoader.h"
2011-01-09 11:45:29 +01:00
# include "GameLoadSM.hpp"
2010-11-13 23:34:53 +01:00
2011-05-28 21:52:00 +02:00
static const char * OnOffText [ ] =
2010-11-13 23:34:53 +01:00
{
trNOOP ( " OFF " ) ,
trNOOP ( " ON " )
} ;
2011-05-28 21:52:00 +02:00
static const char * VideoModeText [ ] =
2010-11-13 23:34:53 +01:00
{
trNOOP ( " System Default " ) ,
2010-12-29 11:22:11 +01:00
trNOOP ( " Disc Default " ) ,
2010-11-13 23:34:53 +01:00
trNOOP ( " Force PAL50 " ) ,
trNOOP ( " Force PAL60 " ) ,
2010-12-29 11:22:11 +01:00
trNOOP ( " Force NTSC " ) ,
trNOOP ( " Region Patch " ) ,
2011-05-28 21:52:00 +02:00
trNOOP ( " Force PAL480p " ) ,
trNOOP ( " Force NTSC480p " ) ,
2010-11-13 23:34:53 +01:00
} ;
2011-05-28 21:52:00 +02:00
static const char * LanguageText [ ] =
2010-11-13 23:34:53 +01:00
{
trNOOP ( " Japanese " ) ,
trNOOP ( " English " ) ,
trNOOP ( " German " ) ,
trNOOP ( " French " ) ,
trNOOP ( " Spanish " ) ,
trNOOP ( " Italian " ) ,
trNOOP ( " Dutch " ) ,
trNOOP ( " SChinese " ) ,
trNOOP ( " TChinese " ) ,
2010-12-29 11:22:11 +01:00
trNOOP ( " Korean " ) ,
2011-01-09 11:45:29 +01:00
trNOOP ( " Console Default " ) ,
2010-11-13 23:34:53 +01:00
} ;
2011-05-28 21:52:00 +02:00
static const char * Error002Text [ ] =
2010-11-13 23:34:53 +01:00
{
2011-01-09 11:45:29 +01:00
trNOOP ( " No " ) ,
trNOOP ( " Yes " ) ,
trNOOP ( " Anti " )
2010-11-13 23:34:53 +01:00
} ;
2011-05-28 21:52:00 +02:00
static const char * ParentalText [ ] =
2010-12-29 16:42:26 +01:00
{
2011-01-09 11:45:29 +01:00
trNOOP ( " 0 (Everyone) " ) ,
trNOOP ( " 1 (Child 7+) " ) ,
trNOOP ( " 2 (Teen 12+) " ) ,
trNOOP ( " 3 (Mature 16+) " ) ,
trNOOP ( " 4 (Adults Only 18+) " )
2010-12-29 16:42:26 +01:00
} ;
2011-01-09 11:45:29 +01:00
static const char * AlternateDOLText [ ] =
2010-11-13 23:34:53 +01:00
{
2011-01-09 11:45:29 +01:00
trNOOP ( " OFF " ) ,
trNOOP ( " Select a DOL from Game " ) ,
trNOOP ( " Load From SD/USB " ) ,
2011-01-16 14:12:07 +01:00
trNOOP ( " List on Gamelaunch " ) ,
2011-01-21 20:43:59 +01:00
trNOOP ( " Default " ) ,
2010-11-13 23:34:53 +01:00
} ;
2011-05-30 21:49:12 +02:00
static const char * IOSReloadBlockText [ ] =
{
trNOOP ( " OFF " ) ,
trNOOP ( " Method 1 " ) ,
trNOOP ( " Method 2 " ) ,
} ;
2011-01-09 11:45:29 +01:00
GameLoadSM : : GameLoadSM ( const char * GameID )
: SettingsMenu ( tr ( " Game Load " ) , & GuiOptions , MENU_NONE )
2010-11-13 23:34:53 +01:00
{
2011-01-21 21:59:49 +01:00
memcpy ( & GameConfig , GameSettings . GetGameCFG ( GameID ) , sizeof ( GameCFG ) ) ;
2011-01-09 11:45:29 +01:00
if ( ! btnOutline )
btnOutline = Resources : : GetImageData ( " button_dialogue_box.png " ) ;
if ( ! trigA )
trigA = new GuiTrigger ( ) ;
trigA - > SetSimpleTrigger ( - 1 , WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A , PAD_BUTTON_A ) ;
saveBtnTxt = new GuiText ( tr ( " Save " ) , 22 , thColor ( " r=0 g=0 b=0 a=255 - prompt windows text color " ) ) ;
saveBtnTxt - > SetMaxWidth ( btnOutline - > GetWidth ( ) - 30 ) ;
saveBtnImg = new GuiImage ( btnOutline ) ;
if ( Settings . wsprompt = = ON )
2010-11-13 23:34:53 +01:00
{
2011-01-09 11:45:29 +01:00
saveBtnTxt - > SetWidescreen ( Settings . widescreen ) ;
saveBtnImg - > SetWidescreen ( Settings . widescreen ) ;
2010-11-13 23:34:53 +01:00
}
2011-01-09 11:45:29 +01:00
saveBtn = new GuiButton ( saveBtnImg , saveBtnImg , 2 , 3 , 180 , 400 , trigA , btnSoundOver , btnSoundClick2 , 1 ) ;
saveBtn - > SetLabel ( saveBtnTxt ) ;
Append ( saveBtn ) ;
SetOptionNames ( ) ;
SetOptionValues ( ) ;
2010-11-13 23:34:53 +01:00
}
2011-01-09 11:45:29 +01:00
GameLoadSM : : ~ GameLoadSM ( )
{
HaltGui ( ) ;
//! The rest is destroyed in SettingsMenu.cpp
Remove ( saveBtn ) ;
delete saveBtnTxt ;
delete saveBtnImg ;
delete saveBtn ;
ResumeGui ( ) ;
}
void GameLoadSM : : SetDefaultConfig ( )
{
2011-01-21 20:43:59 +01:00
char id [ 7 ] ;
snprintf ( id , sizeof ( id ) , GameConfig . id ) ;
memcpy ( & GameConfig , GameSettings . GetDefault ( ) , sizeof ( GameCFG ) ) ;
snprintf ( GameConfig . id , sizeof ( GameConfig . id ) , id ) ;
2011-01-09 11:45:29 +01:00
}
void GameLoadSM : : SetOptionNames ( )
2010-11-13 23:34:53 +01:00
{
int Idx = 0 ;
Options - > SetName ( Idx + + , " %s " , tr ( " Video Mode " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " VIDTV Patch " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Game Language " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Patch Country Strings " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Ocarina " ) ) ;
2011-01-09 11:45:29 +01:00
Options - > SetName ( Idx + + , " %s " , tr ( " Game IOS " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Parental Control " ) ) ;
2010-11-13 23:34:53 +01:00
Options - > SetName ( Idx + + , " %s " , tr ( " Error 002 fix " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Return To " ) ) ;
2011-01-09 11:45:29 +01:00
Options - > SetName ( Idx + + , " %s " , tr ( " Alternate DOL " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Select DOL Offset " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Block IOS Reload " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Game Lock " ) ) ;
2010-11-13 23:34:53 +01:00
}
void GameLoadSM : : SetOptionValues ( )
{
int Idx = 0 ;
//! Settings: Video Mode
2011-05-30 21:49:12 +02:00
if ( GameConfig . video = = INHERIT )
2011-05-28 21:52:00 +02:00
Options - > SetValue ( Idx + + , tr ( " Use global " ) ) ;
else
Options - > SetValue ( Idx + + , " %s " , tr ( VideoModeText [ GameConfig . video ] ) ) ;
2010-11-13 23:34:53 +01:00
//! Settings: VIDTV Patch
2011-05-30 21:49:12 +02:00
if ( GameConfig . vipatch = = INHERIT )
2011-05-28 21:52:00 +02:00
Options - > SetValue ( Idx + + , tr ( " Use global " ) ) ;
else
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ GameConfig . vipatch ] ) ) ;
2010-11-13 23:34:53 +01:00
//! Settings: Game Language
2011-05-30 21:49:12 +02:00
if ( GameConfig . language = = INHERIT )
2011-05-28 21:52:00 +02:00
Options - > SetValue ( Idx + + , tr ( " Use global " ) ) ;
else
Options - > SetValue ( Idx + + , " %s " , tr ( LanguageText [ GameConfig . language ] ) ) ;
2010-11-13 23:34:53 +01:00
//! Settings: Patch Country Strings
2011-05-30 21:49:12 +02:00
if ( GameConfig . patchcountrystrings = = INHERIT )
2011-05-28 21:52:00 +02:00
Options - > SetValue ( Idx + + , tr ( " Use global " ) ) ;
else
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ GameConfig . patchcountrystrings ] ) ) ;
2010-11-13 23:34:53 +01:00
//! Settings: Ocarina
2011-05-30 21:49:12 +02:00
if ( GameConfig . ocarina = = INHERIT )
2011-05-28 21:52:00 +02:00
Options - > SetValue ( Idx + + , tr ( " Use global " ) ) ;
else
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ GameConfig . ocarina ] ) ) ;
2010-11-13 23:34:53 +01:00
2011-01-09 11:45:29 +01:00
//! Settings: Game IOS
2011-05-30 21:49:12 +02:00
if ( GameConfig . ios = = INHERIT )
2011-05-28 21:52:00 +02:00
Options - > SetValue ( Idx + + , tr ( " Use global " ) ) ;
else
Options - > SetValue ( Idx + + , " %i " , GameConfig . ios ) ;
2010-11-13 23:34:53 +01:00
2011-01-09 11:45:29 +01:00
//! Settings: Parental Control
Options - > SetValue ( Idx + + , " %s " , tr ( ParentalText [ GameConfig . parentalcontrol ] ) ) ;
2010-11-13 23:34:53 +01:00
2011-01-09 11:45:29 +01:00
//! Settings: Error 002 fix
2011-05-30 21:49:12 +02:00
if ( GameConfig . errorfix002 = = INHERIT )
2011-05-28 21:52:00 +02:00
Options - > SetValue ( Idx + + , tr ( " Use global " ) ) ;
else
Options - > SetValue ( Idx + + , " %s " , tr ( Error002Text [ GameConfig . errorfix002 ] ) ) ;
2010-12-29 16:42:26 +01:00
2011-01-09 11:45:29 +01:00
//! Settings: Return To
if ( GameConfig . returnTo )
{
const char * TitleName = NULL ;
int haveTitle = NandTitles . FindU32 ( Settings . returnTo ) ;
if ( haveTitle > = 0 )
TitleName = NandTitles . NameFromIndex ( haveTitle ) ;
Options - > SetValue ( Idx + + , " %s " , TitleName ? TitleName : strlen ( Settings . returnTo ) > 0 ?
Settings . returnTo : tr ( OnOffText [ 0 ] ) ) ;
}
else
{
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ 0 ] ) ) ;
}
2010-11-13 23:34:53 +01:00
2011-01-09 11:45:29 +01:00
//! Settings: Alternate DOL
Options - > SetValue ( Idx + + , " %s " , tr ( AlternateDOLText [ GameConfig . loadalternatedol ] ) ) ;
2010-11-13 23:34:53 +01:00
2011-01-09 11:45:29 +01:00
//! Settings: Select DOL Offset
if ( GameConfig . loadalternatedol ! = 1 )
Options - > SetValue ( Idx + + , tr ( " Not required " ) ) ;
else
{
if ( strcmp ( GameConfig . alternatedolname , " " ) ! = 0 )
Options - > SetValue ( Idx + + , " %i <%s> " , GameConfig . alternatedolstart , GameConfig . alternatedolname ) ;
else
Options - > SetValue ( Idx + + , " %i " , GameConfig . alternatedolstart ) ;
}
2010-11-13 23:34:53 +01:00
2011-01-09 11:45:29 +01:00
//! Settings: Block IOS Reload
2011-05-30 21:49:12 +02:00
if ( IosLoader : : IsHermesIOS ( GameConfig . ios = = INHERIT ? Settings . cios : GameConfig . ios ) & & GameConfig . iosreloadblock )
Options - > SetValue ( Idx + + , tr ( " ON " ) ) ;
else if ( GameConfig . iosreloadblock )
Options - > SetValue ( Idx + + , " %s " , tr ( IOSReloadBlockText [ GameConfig . iosreloadblock ] ) ) ;
else
Options - > SetValue ( Idx + + , tr ( " OFF " ) ) ;
2010-11-13 23:34:53 +01:00
2011-01-09 11:45:29 +01:00
//! Settings: Game Lock
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ GameConfig . Locked ] ) ) ;
2010-11-13 23:34:53 +01:00
}
int GameLoadSM : : GetMenuInternal ( )
{
2011-01-09 11:45:29 +01:00
if ( saveBtn - > GetState ( ) = = STATE_CLICKED )
{
if ( GameSettings . AddGame ( GameConfig ) & & GameSettings . Save ( ) )
{
WindowPrompt ( tr ( " Successfully Saved " ) , 0 , tr ( " OK " ) ) ;
}
else
WindowPrompt ( tr ( " Save Failed. No device inserted? " ) , 0 , tr ( " OK " ) ) ;
saveBtn - > ResetState ( ) ;
}
2010-11-13 23:34:53 +01:00
int ret = optionBrowser - > GetClickedOption ( ) ;
if ( ret < 0 )
return MENU_NONE ;
int Idx = - 1 ;
//! Settings: Video Mode
if ( ret = = + + Idx )
{
2011-05-28 21:52:00 +02:00
if ( + + GameConfig . video > = VIDEO_MODE_MAX ) GameConfig . video = INHERIT ;
2010-11-13 23:34:53 +01:00
}
//! Settings: VIDTV Patch
else if ( ret = = + + Idx )
{
2011-05-28 21:52:00 +02:00
if ( + + GameConfig . vipatch > = MAX_ON_OFF ) GameConfig . vipatch = INHERIT ;
2010-11-13 23:34:53 +01:00
}
//! Settings: Game Language
else if ( ret = = + + Idx )
{
2011-05-28 21:52:00 +02:00
if ( + + GameConfig . language > = MAX_LANGUAGE ) GameConfig . language = INHERIT ;
2010-11-13 23:34:53 +01:00
}
//! Settings: Patch Country Strings
else if ( ret = = + + Idx )
{
2011-05-28 21:52:00 +02:00
if ( + + GameConfig . patchcountrystrings > = MAX_ON_OFF ) GameConfig . patchcountrystrings = INHERIT ;
2010-11-13 23:34:53 +01:00
}
//! Settings: Ocarina
else if ( ret = = + + Idx )
{
2011-05-28 21:52:00 +02:00
if ( + + GameConfig . ocarina > = MAX_ON_OFF ) GameConfig . ocarina = INHERIT ;
2010-11-13 23:34:53 +01:00
}
2011-01-09 11:45:29 +01:00
//! Settings: Game IOS
2010-11-13 23:34:53 +01:00
else if ( ret = = + + Idx )
{
char entered [ 4 ] ;
2011-01-09 11:45:29 +01:00
snprintf ( entered , sizeof ( entered ) , " %i " , GameConfig . ios ) ;
2010-11-13 23:34:53 +01:00
if ( OnScreenKeyboard ( entered , sizeof ( entered ) , 0 ) )
{
2011-02-06 19:36:32 +01:00
GameConfig . ios = atoi ( entered ) & 0xFF ;
2011-01-09 11:45:29 +01:00
if ( GameConfig . ios < 200 ) GameConfig . ios = 200 ;
2010-11-13 23:34:53 +01:00
2011-01-09 11:45:29 +01:00
if ( NandTitles . IndexOf ( TITLE_ID ( 1 , GameConfig . ios ) ) < 0 )
2010-11-13 23:34:53 +01:00
{
WindowPrompt ( tr ( " Warning: " ) , tr ( " This IOS was not found on the titles list. If you are sure you have it installed than ignore this warning. " ) , tr ( " OK " ) ) ;
}
2011-01-09 11:45:29 +01:00
else if ( GameConfig . ios = = 254 )
2010-11-13 23:34:53 +01:00
{
WindowPrompt ( tr ( " Warning: " ) , tr ( " This IOS is the BootMii ios. If you are sure it is not BootMii and you have something else installed there than ignore this warning. " ) , tr ( " OK " ) ) ;
}
}
}
2011-01-09 11:45:29 +01:00
//! Settings: Parental Control
2010-11-13 23:34:53 +01:00
else if ( ret = = + + Idx )
{
2011-01-09 11:45:29 +01:00
if ( + + GameConfig . parentalcontrol > = 5 ) GameConfig . parentalcontrol = 0 ;
2010-11-13 23:34:53 +01:00
}
2011-01-09 11:45:29 +01:00
//! Settings: Error 002 fix
2010-11-13 23:34:53 +01:00
else if ( ret = = + + Idx )
{
2011-05-28 21:52:00 +02:00
if ( + + GameConfig . errorfix002 > = 3 ) GameConfig . errorfix002 = INHERIT ;
2010-12-29 16:42:26 +01:00
}
2011-01-09 11:45:29 +01:00
//! Settings: Return To
2010-12-29 16:42:26 +01:00
else if ( ret = = + + Idx )
{
2011-01-09 11:45:29 +01:00
if ( + + GameConfig . returnTo > = MAX_ON_OFF ) GameConfig . returnTo = 0 ;
2010-11-13 23:34:53 +01:00
}
2011-01-09 11:45:29 +01:00
//! Settings: Alternate DOL
2010-11-13 23:34:53 +01:00
else if ( ret = = + + Idx )
{
2011-01-23 21:13:41 +01:00
if ( + + GameConfig . loadalternatedol > = ALT_DOL_MAX_CHOICE )
2011-01-09 11:45:29 +01:00
GameConfig . loadalternatedol = 0 ;
2010-11-13 23:34:53 +01:00
}
2011-01-09 11:45:29 +01:00
//! Settings: Select DOL Offset from Game
else if ( ret = = + + Idx & & GameConfig . loadalternatedol = = 1 )
2010-11-13 23:34:53 +01:00
{
2011-01-30 17:22:16 +01:00
GuiWindow * parentWindow = ( GuiWindow * ) parentElement ;
if ( parentWindow ) parentWindow - > SetState ( STATE_DISABLED ) ;
2011-01-09 11:45:29 +01:00
//alt dol menu for games that require more than a single alt dol
2011-01-21 20:43:59 +01:00
int autodol = autoSelectDolPrompt ( ( char * ) GameConfig . id ) ;
if ( autodol = = 0 )
2011-01-30 17:22:16 +01:00
{
if ( parentWindow ) parentWindow - > SetState ( STATE_DEFAULT ) ;
2011-01-21 20:43:59 +01:00
return MENU_NONE ; //Cancel Button pressed
2011-01-30 17:22:16 +01:00
}
2011-01-09 11:45:29 +01:00
if ( autodol > 0 )
{
GameConfig . alternatedolstart = autodol ;
snprintf ( GameConfig . alternatedolname , sizeof ( GameConfig . alternatedolname ) , " %s <%i> " , tr ( " AUTO " ) , autodol ) ;
SetOptionValues ( ) ;
2011-01-30 17:22:16 +01:00
if ( parentWindow ) parentWindow - > SetState ( STATE_DEFAULT ) ;
2011-01-09 11:45:29 +01:00
return MENU_NONE ;
}
2011-01-21 20:43:59 +01:00
int res = DiscBrowse ( GameConfig . id , GameConfig . alternatedolname , sizeof ( GameConfig . alternatedolname ) ) ;
if ( res > = 0 )
2011-01-09 11:45:29 +01:00
{
2011-01-21 20:43:59 +01:00
GameConfig . alternatedolstart = res ;
char tmp [ 170 ] ;
snprintf ( tmp , sizeof ( tmp ) , " %s %.6s - %i " , tr ( " It seems that you have some information that will be helpful to us. Please pass this information along to the DEV team. " ) , ( char * ) GameConfig . id , GameConfig . alternatedolstart ) ;
WindowPrompt ( 0 , tmp , tr ( " OK " ) ) ;
2011-01-09 11:45:29 +01:00
}
if ( GameConfig . alternatedolstart = = 0 )
GameConfig . loadalternatedol = 0 ;
2011-01-30 17:22:16 +01:00
if ( parentWindow ) parentWindow - > SetState ( STATE_DEFAULT ) ;
2010-11-13 23:34:53 +01:00
}
2011-01-09 11:45:29 +01:00
//! Settings: Block IOS Reload
2010-11-13 23:34:53 +01:00
else if ( ret = = + + Idx )
{
2011-05-30 21:49:12 +02:00
+ + GameConfig . iosreloadblock ;
if ( GameConfig . iosreloadblock > = MAX_ON_OFF & & IosLoader : : IsHermesIOS ( GameConfig . ios = = INHERIT ? Settings . cios : GameConfig . ios ) )
GameConfig . iosreloadblock = 0 ;
else if ( GameConfig . iosreloadblock > = 3 )
GameConfig . iosreloadblock = 0 ;
2010-11-13 23:34:53 +01:00
}
2011-01-09 11:45:29 +01:00
//! Settings: Game Lock
else if ( ret = = + + Idx )
2010-12-27 10:44:27 +01:00
{
2011-01-09 11:45:29 +01:00
if ( + + GameConfig . Locked > = MAX_ON_OFF ) GameConfig . Locked = 0 ;
2010-12-27 10:44:27 +01:00
}
2010-11-13 23:34:53 +01:00
SetOptionValues ( ) ;
return MENU_NONE ;
}