2011-01-09 11:45:29 +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>
# include "LoaderSettings.hpp"
2011-02-05 22:06:52 +01:00
# include "usbloader/usbstorage2.h"
2011-01-09 11:45:29 +01:00
# include "settings/CSettings.h"
2011-11-12 19:14:09 +01:00
# include "settings/GameTitles.h"
2011-01-09 11:45:29 +01:00
# include "prompts/PromptWindows.h"
# include "language/gettext.h"
# include "wad/nandtitle.h"
# include "prompts/TitleBrowser.h"
2011-07-24 18:32:09 +02:00
# include "system/IosLoader.h"
2011-12-22 23:44:48 +01:00
# include "usbloader/wbfs.h"
# include "usbloader/GameList.h"
2011-01-09 11:45:29 +01:00
# include "menu.h"
2011-12-22 23:44:48 +01:00
static const char * loaderModeText [ ] =
2011-11-12 19:14:09 +01:00
{
2011-12-22 23:44:48 +01:00
trNOOP ( " None " ) ,
trNOOP ( " Wii Games " ) ,
trNOOP ( " Nand Channels " ) ,
trNOOP ( " EmuNand Channels " ) ,
trNOOP ( " All " )
2011-11-12 19:14:09 +01:00
} ;
2011-06-10 14:22:19 +02:00
static const char * OnOffText [ ] =
2011-01-09 11:45:29 +01:00
{
2011-07-26 00:28:22 +02:00
trNOOP ( " OFF " ) ,
trNOOP ( " ON " ) ,
trNOOP ( " Auto " )
2011-01-09 11:45:29 +01:00
} ;
2011-12-23 16:48:20 +01:00
static const char * AspectText [ ] =
{
trNOOP ( " Force 4:3 " ) ,
trNOOP ( " Force 16:9 " ) ,
trNOOP ( " System Default " )
} ;
2011-12-22 23:44:48 +01:00
static const char * VideoModeText [ ] =
2011-01-09 11:45:29 +01:00
{
2011-07-26 00:28:22 +02:00
trNOOP ( " System Default " ) ,
trNOOP ( " Disc Default " ) ,
trNOOP ( " Force PAL50 " ) ,
trNOOP ( " Force PAL60 " ) ,
trNOOP ( " Force NTSC " ) ,
trNOOP ( " Region Patch " ) ,
trNOOP ( " Force PAL480p " ) ,
trNOOP ( " Force NTSC480p " ) ,
2011-01-09 11:45:29 +01:00
} ;
2011-12-22 23:44:48 +01:00
static const char * LanguageText [ ] =
2011-01-09 11:45:29 +01:00
{
2011-07-26 00:28:22 +02:00
trNOOP ( " Japanese " ) ,
trNOOP ( " English " ) ,
trNOOP ( " German " ) ,
trNOOP ( " French " ) ,
trNOOP ( " Spanish " ) ,
trNOOP ( " Italian " ) ,
trNOOP ( " Dutch " ) ,
trNOOP ( " SChinese " ) ,
trNOOP ( " TChinese " ) ,
trNOOP ( " Korean " ) ,
trNOOP ( " Console Default " )
2011-01-09 11:45:29 +01:00
} ;
2011-05-28 21:52:00 +02:00
static const char * Error002Text [ ] =
2011-01-09 11:45:29 +01:00
{
2011-07-26 00:28:22 +02:00
trNOOP ( " No " ) ,
trNOOP ( " Yes " ) ,
trNOOP ( " Anti " )
2011-01-09 11:45:29 +01:00
} ;
2011-07-24 18:32:09 +02:00
static const char * NandEmuText [ ] =
{
2011-07-26 00:28:22 +02:00
trNOOP ( " OFF " ) ,
trNOOP ( " Partial " ) ,
trNOOP ( " Full " )
2011-07-24 18:32:09 +02:00
} ;
2011-07-29 22:59:31 +02:00
static const char * HooktypeText [ ] =
{
trNOOP ( " None " ) ,
trNOOP ( " VBI (Default) " ) ,
trNOOP ( " KPAD Read " ) ,
trNOOP ( " Joypad " ) ,
trNOOP ( " GXDraw " ) ,
trNOOP ( " GXFlush " ) ,
trNOOP ( " OSSleepThread " ) ,
trNOOP ( " AXNextFrame " ) ,
} ;
2011-01-09 11:45:29 +01:00
LoaderSettings : : LoaderSettings ( )
2011-07-26 00:28:22 +02:00
: SettingsMenu ( tr ( " Loader Settings " ) , & GuiOptions , MENU_NONE )
2011-01-09 11:45:29 +01:00
{
2011-07-26 00:28:22 +02:00
int Idx = 0 ;
2011-11-12 19:14:09 +01:00
Options - > SetName ( Idx + + , " %s " , tr ( " Loader Mode " ) ) ;
2011-07-26 00:28:22 +02:00
Options - > SetName ( Idx + + , " %s " , tr ( " Video Mode " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " VIDTV Patch " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Sneek Video Patch " ) ) ;
2011-12-23 16:48:20 +01:00
Options - > SetName ( Idx + + , " %s " , tr ( " Aspect Ratio " ) ) ;
2011-07-26 00:28:22 +02:00
Options - > SetName ( Idx + + , " %s " , tr ( " Game Language " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Patch Country Strings " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Ocarina " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Boot/Standard " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Quick Boot " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Error 002 fix " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Block IOS Reload " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Return To " ) ) ;
2011-11-12 19:14:09 +01:00
Options - > SetName ( Idx + + , " %s " , tr ( " Nand Saves Emulation " ) ) ;
2011-07-29 22:59:31 +02:00
Options - > SetName ( Idx + + , " %s " , tr ( " Hooktype " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Wiird Debugger " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Debugger Paused Start " ) ) ;
2011-07-26 00:28:22 +02:00
SetOptionValues ( ) ;
2011-11-12 19:14:09 +01:00
oldLoaderMode = Settings . LoaderMode ;
}
LoaderSettings : : ~ LoaderSettings ( )
{
if ( oldLoaderMode ! = Settings . LoaderMode )
2011-12-22 23:44:48 +01:00
{
if ( Settings . LoaderMode & MODE_WIIGAMES & & ( gameList . GameCount ( ) = = 0 ) )
{
WBFS_ReInit ( WBFS_DEVICE_USB ) ;
gameList . ReadGameList ( ) ;
}
gameList . LoadUnfiltered ( ) ;
GameTitles . LoadTitlesFromGameTDB ( Settings . titlestxt_path , false , false ) ;
}
2011-01-09 11:45:29 +01:00
}
void LoaderSettings : : SetOptionValues ( )
{
2011-07-26 00:28:22 +02:00
int Idx = 0 ;
2011-01-09 11:45:29 +01:00
2011-11-12 19:14:09 +01:00
//! Settings: Loader Mode
2011-12-22 23:44:48 +01:00
if ( Settings . LoaderMode = = MODE_NONE ) Options - > SetValue ( Idx + + , " %s " , tr ( loaderModeText [ 0 ] ) ) ;
else if ( Settings . LoaderMode = = MODE_ALL ) Options - > SetValue ( Idx + + , " %s " , tr ( loaderModeText [ 4 ] ) ) ;
else if ( Settings . LoaderMode & MODE_WIIGAMES ) Options - > SetValue ( Idx + + , " %s " , tr ( loaderModeText [ 1 ] ) ) ;
else if ( Settings . LoaderMode & MODE_NANDCHANNELS ) Options - > SetValue ( Idx + + , " %s " , tr ( loaderModeText [ 2 ] ) ) ;
else if ( Settings . LoaderMode & MODE_EMUCHANNELS ) Options - > SetValue ( Idx + + , " %s " , tr ( loaderModeText [ 3 ] ) ) ;
2011-11-12 19:14:09 +01:00
2011-07-26 00:28:22 +02:00
//! Settings: Video Mode
Options - > SetValue ( Idx + + , " %s " , tr ( VideoModeText [ Settings . videomode ] ) ) ;
2011-01-09 11:45:29 +01:00
2011-07-26 00:28:22 +02:00
//! Settings: VIDTV Patch
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ Settings . videopatch ] ) ) ;
2011-01-09 11:45:29 +01:00
2011-07-26 00:28:22 +02:00
//! Settings: Sneek Video Patch
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ Settings . sneekVideoPatch ] ) ) ;
2011-06-25 21:50:57 +02:00
2011-12-23 16:48:20 +01:00
//! Settings: Aspect Ratio
Options - > SetValue ( Idx + + , " %s " , tr ( AspectText [ Settings . GameAspectRatio ] ) ) ;
2011-07-26 00:28:22 +02:00
//! Settings: Game Language
Options - > SetValue ( Idx + + , " %s " , tr ( LanguageText [ Settings . language ] ) ) ;
2011-01-09 11:45:29 +01:00
2011-07-26 00:28:22 +02:00
//! Settings: Patch Country Strings
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ Settings . patchcountrystrings ] ) ) ;
2011-01-09 11:45:29 +01:00
2011-07-26 00:28:22 +02:00
//! Settings: Ocarina
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ Settings . ocarina ] ) ) ;
2011-01-09 11:45:29 +01:00
2011-07-26 00:28:22 +02:00
//! Settings: Boot/Standard
if ( Settings . godmode )
Options - > SetValue ( Idx + + , " IOS %i " , Settings . cios ) ;
else
Options - > SetValue ( Idx + + , " ******** " ) ;
2011-01-09 11:45:29 +01:00
2011-07-26 00:28:22 +02:00
//! Settings: Quick Boot
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ Settings . quickboot ] ) ) ;
2011-01-09 11:45:29 +01:00
2011-07-26 00:28:22 +02:00
//! Settings: Error 002 fix
Options - > SetValue ( Idx + + , " %s " , tr ( Error002Text [ Settings . error002 ] ) ) ;
2011-01-09 11:45:29 +01:00
2011-07-26 00:28:22 +02:00
//! Settings: Block IOS Reload
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ Settings . BlockIOSReload ] ) ) ;
2011-06-10 14:22:19 +02:00
2011-07-26 00:28:22 +02:00
//! Settings: Return To
const char * TitleName = NULL ;
u64 tid = NandTitles . FindU32 ( Settings . returnTo ) ;
if ( tid > 0 )
TitleName = NandTitles . NameOf ( tid ) ;
TitleName = TitleName ? TitleName : strlen ( Settings . returnTo ) > 0 ? Settings . returnTo : tr ( OnOffText [ 0 ] ) ;
Options - > SetValue ( Idx + + , " %s " , TitleName ) ;
2011-07-24 18:32:09 +02:00
2011-07-26 00:28:22 +02:00
//! Settings: Nand Emulation
Options - > SetValue ( Idx + + , " %s " , tr ( NandEmuText [ Settings . NandEmuMode ] ) ) ;
2011-07-29 22:59:31 +02:00
//! Settings: Hooktype
Options - > SetValue ( Idx + + , " %s " , tr ( HooktypeText [ Settings . Hooktype ] ) ) ;
//! Settings: Wiird Debugger
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ Settings . WiirdDebugger ] ) ) ;
//! Settings: Wiird Debugger Pause on Start
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ Settings . WiirdDebuggerPause ] ) ) ;
2011-01-09 11:45:29 +01:00
}
int LoaderSettings : : GetMenuInternal ( )
{
2011-07-26 00:28:22 +02:00
int ret = optionBrowser - > GetClickedOption ( ) ;
if ( ret < 0 )
return MENU_NONE ;
int Idx = - 1 ;
2011-11-12 19:14:09 +01:00
//! Settings: Loader Mode
if ( ret = = + + Idx )
{
2011-12-22 23:44:48 +01:00
if ( Settings . LoaderMode = = MODE_ALL ) Settings . LoaderMode = MODE_NONE ;
else if ( Settings . LoaderMode & MODE_WIIGAMES ) Settings . LoaderMode = MODE_NANDCHANNELS ;
else if ( Settings . LoaderMode & MODE_NANDCHANNELS ) Settings . LoaderMode = MODE_EMUCHANNELS ;
else if ( Settings . LoaderMode & MODE_EMUCHANNELS ) Settings . LoaderMode = MODE_ALL ;
else Settings . LoaderMode = MODE_WIIGAMES ;
2011-11-12 19:14:09 +01:00
}
2011-07-26 00:28:22 +02:00
//! Settings: Video Mode
if ( ret = = + + Idx )
{
if ( + + Settings . videomode > = VIDEO_MODE_MAX ) Settings . videomode = 0 ;
}
//! Settings: VIDTV Patch
else if ( ret = = + + Idx )
{
if ( + + Settings . videopatch > = MAX_ON_OFF ) Settings . videopatch = 0 ;
}
//! Settings: Sneek Video Patch
else if ( ret = = + + Idx )
{
if ( + + Settings . sneekVideoPatch > = MAX_ON_OFF ) Settings . sneekVideoPatch = 0 ;
}
2011-12-23 16:48:20 +01:00
//! Settings: Aspect Ratio
else if ( ret = = + + Idx )
{
if ( + + Settings . GameAspectRatio > = ASPECT_MAX ) Settings . GameAspectRatio = 0 ;
}
2011-07-26 00:28:22 +02:00
//! Settings: Game Language
else if ( ret = = + + Idx )
{
if ( + + Settings . language > = MAX_LANGUAGE ) Settings . language = 0 ;
}
//! Settings: Patch Country Strings
else if ( ret = = + + Idx )
{
if ( + + Settings . patchcountrystrings > = MAX_ON_OFF ) Settings . patchcountrystrings = 0 ;
}
//! Settings: Ocarina
else if ( ret = = + + Idx )
{
if ( + + Settings . ocarina > = MAX_ON_OFF ) Settings . ocarina = 0 ;
}
//! Settings: Boot/Standard
else if ( ret = = + + Idx )
{
if ( ! Settings . godmode )
return MENU_NONE ;
char entered [ 4 ] ;
snprintf ( entered , sizeof ( entered ) , " %i " , Settings . cios ) ;
if ( OnScreenKeyboard ( entered , sizeof ( entered ) , 0 ) )
{
Settings . cios = atoi ( entered ) ;
if ( Settings . cios < 200 ) Settings . cios = 200 ;
else if ( Settings . cios > 255 ) Settings . cios = 255 ;
if ( NandTitles . IndexOf ( TITLE_ID ( 1 , Settings . cios ) ) < 0 )
{
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 " ) ) ;
}
else if ( Settings . cios = = 254 )
{
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 " ) ) ;
}
}
}
//! Settings: Quick Boot
else if ( ret = = + + Idx )
{
if ( + + Settings . quickboot > = MAX_ON_OFF ) Settings . quickboot = 0 ;
}
//! Settings: Error 002 fix
else if ( ret = = + + Idx )
{
if ( + + Settings . error002 > = 3 ) Settings . error002 = 0 ;
}
//! Settings: Block IOS Reload
else if ( ret = = + + Idx )
{
if ( + + Settings . BlockIOSReload > = 3 ) Settings . BlockIOSReload = 0 ;
}
//! Settings: Return To
else if ( ret = = + + Idx )
{
char tidChar [ 10 ] ;
bool getChannel = TitleSelector ( tidChar ) ;
if ( getChannel )
snprintf ( Settings . returnTo , sizeof ( Settings . returnTo ) , " %s " , tidChar ) ;
}
//! Settings: Nand Emulation
else if ( ret = = + + Idx )
{
if ( ! IosLoader : : IsD2X ( ) )
WindowPrompt ( tr ( " Error: " ) , tr ( " Nand Emulation is only available on D2X cIOS! " ) , tr ( " OK " ) ) ;
else if ( + + Settings . NandEmuMode > = 3 ) Settings . NandEmuMode = 0 ;
}
2011-07-29 22:59:31 +02:00
//! Settings: Hooktype
else if ( ret = = + + Idx )
{
if ( + + Settings . Hooktype > = 8 ) Settings . Hooktype = 0 ;
}
//! Settings: Wiird Debugger
else if ( ret = = + + Idx )
{
if ( + + Settings . WiirdDebugger > = MAX_ON_OFF ) Settings . WiirdDebugger = 0 ;
}
//! Settings: Wiird Debugger Pause on Start
else if ( ret = = + + Idx )
{
if ( + + Settings . WiirdDebuggerPause > = MAX_ON_OFF ) Settings . WiirdDebuggerPause = 0 ;
}
2011-07-26 00:28:22 +02:00
SetOptionValues ( ) ;
return MENU_NONE ;
2011-01-09 11:45:29 +01:00
}