2011-06-18 09:00:42 +02:00
/****************************************************************************
* Copyright ( C ) 2011
* 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 .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2015-01-04 21:22:06 +01:00
# include <gccore.h>
# include <ogc/machine/processor.h>
2011-06-18 09:00:42 +02:00
# include <unistd.h>
2020-12-12 22:33:31 +01:00
2011-06-18 09:00:42 +02:00
# include "FeatureSettingsMenu.hpp"
2012-01-01 18:58:10 +01:00
# include "Channels/channels.h"
2011-06-18 09:00:42 +02:00
# include "settings/CGameCategories.hpp"
# include "settings/GameTitles.h"
# include "settings/CSettings.h"
# include "settings/SettingsPrompts.h"
# include "network/Wiinnertag.h"
# include "network/networkops.h"
# include "FileOperations/fileops.h"
2016-01-02 17:23:01 +01:00
# include "FileOperations/DirList.h"
# include "utils/StringTools.h"
2011-06-18 09:00:42 +02:00
# include "prompts/PromptWindows.h"
2011-09-24 01:49:18 +02:00
# include "prompts/ProgressWindow.h"
2012-01-01 18:58:10 +01:00
# include "prompts/filebrowser.h"
2011-06-26 23:38:05 +02:00
# include "usbloader/GameList.h"
2015-07-05 16:44:24 +02:00
# include "usbloader/neek.hpp"
2011-06-18 09:00:42 +02:00
# include "language/gettext.h"
2012-01-01 18:58:10 +01:00
# include "wad/nandtitle.h"
# include "wad/wad.h"
2015-02-14 16:41:20 +01:00
# include "sys.h"
2020-12-12 22:33:31 +01:00
# include "cache/cache.hpp"
2011-06-18 09:00:42 +02:00
static const char * OnOffText [ ] =
{
2011-07-26 00:28:22 +02:00
trNOOP ( " OFF " ) ,
trNOOP ( " ON " )
2011-06-18 09:00:42 +02:00
} ;
2011-06-22 19:57:37 +02:00
static const char * WiilightText [ WIILIGHT_MAX ] =
{
2011-07-26 00:28:22 +02:00
trNOOP ( " OFF " ) ,
trNOOP ( " ON " ) ,
trNOOP ( " Only for Install " )
2011-06-22 19:57:37 +02:00
} ;
2011-06-18 09:00:42 +02:00
FeatureSettingsMenu : : FeatureSettingsMenu ( )
2011-07-26 00:28:22 +02:00
: SettingsMenu ( tr ( " Features Settings " ) , & GuiOptions , MENU_NONE )
2011-06-18 09:00:42 +02:00
{
2011-07-26 00:28:22 +02:00
int Idx = 0 ;
2011-10-21 20:48:10 +02:00
Options - > SetName ( Idx + + , " %s " , tr ( " Titles from GameTDB " ) ) ;
2011-07-26 00:28:22 +02:00
Options - > SetName ( Idx + + , " %s " , tr ( " Cache Titles " ) ) ;
2020-12-12 22:33:31 +01:00
Options - > SetName ( Idx + + , " %s " , tr ( " Use Game Header Cache " ) ) ;
2012-02-29 20:52:36 +01:00
Options - > SetName ( Idx + + , " %s " , tr ( " Force Titles from Disc " ) ) ;
2011-07-26 00:28:22 +02:00
Options - > SetName ( Idx + + , " %s " , tr ( " Wiilight " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Rumble " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " AutoInit Network " ) ) ;
2020-11-08 22:29:44 +01:00
Options - > SetName ( Idx + + , " %s " , tr ( " System Proxy Settings " ) ) ;
2011-07-26 00:28:22 +02:00
Options - > SetName ( Idx + + , " %s " , tr ( " Messageboard Update " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Wiinnertag " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Import Categories " ) ) ;
2011-09-24 01:49:18 +02:00
Options - > SetName ( Idx + + , " %s " , tr ( " Export All Saves to EmuNand " ) ) ;
2012-05-06 12:59:58 +02:00
Options - > SetName ( Idx + + , " %s " , tr ( " Export Miis to EmuNand " ) ) ;
Options - > SetName ( Idx + + , " %s " , tr ( " Export SYSCONF to EmuNand " ) ) ;
2011-10-01 12:41:00 +02:00
Options - > SetName ( Idx + + , " %s " , tr ( " Dump NAND to EmuNand " ) ) ;
2016-01-02 17:23:01 +01:00
Options - > SetName ( Idx + + , " %s " , tr ( " EmuNAND Wad Manager " ) ) ;
// Options->SetName(Idx++, "%s", tr( "Update Nintendont" ));
2015-01-04 21:22:06 +01:00
Options - > SetName ( Idx + + , " %s " , tr ( " WiiU Widescreen " ) ) ;
2015-07-05 16:44:24 +02:00
Options - > SetName ( Idx + + , " %s " , tr ( " Boot Neek System Menu " ) ) ;
2020-12-12 22:33:31 +01:00
Options - > SetName ( Idx + + , " %s " , tr ( " Reset Game Header Cache " ) ) ;
2011-07-26 00:28:22 +02:00
OldTitlesOverride = Settings . titlesOverride ;
2012-01-08 19:24:46 +01:00
OldCacheTitles = Settings . CacheTitles ;
2012-02-29 20:52:36 +01:00
OldForceDiscTitles = Settings . ForceDiscTitles ;
2011-07-26 00:28:22 +02:00
SetOptionValues ( ) ;
2011-06-18 09:00:42 +02:00
}
2011-06-26 23:38:05 +02:00
FeatureSettingsMenu : : ~ FeatureSettingsMenu ( )
{
2012-01-08 19:24:46 +01:00
if ( Settings . titlesOverride ! = OldTitlesOverride
2012-02-29 20:52:36 +01:00
| | Settings . CacheTitles ! = OldCacheTitles
| | Settings . ForceDiscTitles ! = OldForceDiscTitles )
2011-07-26 00:28:22 +02:00
{
2012-02-29 20:52:36 +01:00
if ( Settings . ForceDiscTitles )
Settings . titlesOverride = OFF ;
2012-01-08 19:24:46 +01:00
//! Remove cached titles and reload new titles
GameTitles . SetDefault ( ) ;
if ( Settings . titlesOverride ) {
GameTitles . LoadTitlesFromGameTDB ( Settings . titlestxt_path ) ;
}
else
2011-12-22 23:44:48 +01:00
{
2012-01-08 19:24:46 +01:00
//! Don't override titles, in other words read them from disc header or directory names
2011-07-26 00:28:22 +02:00
gameList . ReadGameList ( ) ;
2011-12-22 23:44:48 +01:00
gameList . LoadUnfiltered ( ) ;
}
2011-07-26 00:28:22 +02:00
}
2011-06-26 23:38:05 +02:00
}
2011-06-18 09:00:42 +02:00
void FeatureSettingsMenu : : SetOptionValues ( )
{
2011-07-26 00:28:22 +02:00
int Idx = 0 ;
2011-06-18 09:00:42 +02:00
2011-10-21 20:48:10 +02:00
//! Settings: Titles from GameTDB
2011-07-26 00:28:22 +02:00
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ Settings . titlesOverride ] ) ) ;
2011-06-18 09:00:42 +02:00
2011-07-26 00:28:22 +02:00
//! Settings: Cache Titles
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ Settings . CacheTitles ] ) ) ;
2011-06-18 09:00:42 +02:00
2020-12-12 22:33:31 +01:00
//! Settings: Use Game Header Cache
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ Settings . UseGameHeaderCache ] ) ) ;
2012-02-29 20:52:36 +01:00
//! Settings: Force Titles from Disc
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ Settings . ForceDiscTitles ] ) ) ;
2011-07-26 00:28:22 +02:00
//! Settings: Wiilight
Options - > SetValue ( Idx + + , " %s " , tr ( WiilightText [ Settings . wiilight ] ) ) ;
2011-06-22 19:57:37 +02:00
2011-07-26 00:28:22 +02:00
//! Settings: Rumble
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ Settings . rumble ] ) ) ;
2011-06-22 19:57:37 +02:00
2011-07-26 00:28:22 +02:00
//! Settings: AutoInit Network
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ Settings . autonetwork ] ) ) ;
2011-06-22 19:57:37 +02:00
2020-11-08 22:29:44 +01:00
//! Settings: System Proxy Settings
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ Settings . ProxyUseSystem ] ) ) ;
2011-07-26 00:28:22 +02:00
//! Settings: Messageboard Update
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ Settings . PlaylogUpdate ] ) ) ;
2011-06-22 19:57:37 +02:00
2011-07-26 00:28:22 +02:00
//! Settings: Wiinnertag
Options - > SetValue ( Idx + + , " %s " , tr ( OnOffText [ Settings . Wiinnertag ] ) ) ;
2011-06-18 09:00:42 +02:00
2011-10-21 20:48:10 +02:00
//! Settings: Import categories from GameTDB
2011-07-26 00:28:22 +02:00
Options - > SetValue ( Idx + + , " " ) ;
2011-09-24 01:49:18 +02:00
//! Settings: Export Savegames to EmuNand
Options - > SetValue ( Idx + + , " " ) ;
2011-10-01 12:41:00 +02:00
2012-05-06 12:59:58 +02:00
//! Settings: Export Miis to EmuNand
Options - > SetValue ( Idx + + , " " ) ;
//! Settings: Export SYSCONF to EmuNand
Options - > SetValue ( Idx + + , " " ) ;
2011-10-01 12:41:00 +02:00
//! Settings: Dump NAND to EmuNand
Options - > SetValue ( Idx + + , " " ) ;
2012-01-01 18:58:10 +01:00
2016-01-02 17:23:01 +01:00
//! Settings: EmuNand Wad Manager
2012-01-01 18:58:10 +01:00
Options - > SetValue ( Idx + + , " " ) ;
2014-07-14 18:31:52 +02:00
//! Settings: Update Nintendont
2016-01-02 17:23:01 +01:00
//Options->SetValue(Idx++, " ");
2015-07-05 16:44:24 +02:00
2015-01-04 21:22:06 +01:00
//! Settings: WiiU Widescreen
Options - > SetValue ( Idx + + , " " ) ;
2015-07-05 16:44:24 +02:00
//! Settings: Neek boot
Options - > SetValue ( Idx + + , " " ) ;
2011-06-18 09:00:42 +02:00
}
int FeatureSettingsMenu : : GetMenuInternal ( )
{
2011-07-26 00:28:22 +02:00
int ret = optionBrowser - > GetClickedOption ( ) ;
if ( ret < 0 )
return MENU_NONE ;
int Idx = - 1 ;
2011-10-21 20:48:10 +02:00
//! Settings: Titles from GameTDB
2011-07-26 00:28:22 +02:00
if ( ret = = + + Idx )
{
if ( + + Settings . titlesOverride > = MAX_ON_OFF ) Settings . titlesOverride = 0 ;
}
//! Settings: Cache Titles
else if ( ret = = + + Idx )
{
if ( + + Settings . CacheTitles > = MAX_ON_OFF ) Settings . CacheTitles = 0 ;
}
2020-12-12 22:33:31 +01:00
//! Settings: Use Game Header Cache
else if ( ret = = + + Idx )
{
if ( + + Settings . UseGameHeaderCache > = MAX_ON_OFF ) Settings . UseGameHeaderCache = 0 ;
}
2012-02-29 20:52:36 +01:00
//! Settings: Force Titles from Disc
else if ( ret = = + + Idx )
{
if ( + + Settings . ForceDiscTitles > = MAX_ON_OFF ) Settings . ForceDiscTitles = 0 ;
}
2011-07-26 00:28:22 +02:00
//! Settings: Wiilight
else if ( ret = = + + Idx )
{
if ( + + Settings . wiilight > = WIILIGHT_MAX ) Settings . wiilight = 0 ;
}
//! Settings: Rumble
else if ( ret = = + + Idx )
{
if ( + + Settings . rumble > = MAX_ON_OFF ) Settings . rumble = 0 ; //RUMBLE
}
//! Settings: AutoInit Network
else if ( ret = = + + Idx )
{
if ( + + Settings . autonetwork > = MAX_ON_OFF ) Settings . autonetwork = 0 ;
}
2020-11-08 22:29:44 +01:00
//! Settings: System Proxy Settings
else if ( ret = = + + Idx )
{
if ( + + Settings . ProxyUseSystem > = MAX_ON_OFF ) Settings . ProxyUseSystem = 0 ;
}
2011-07-26 00:28:22 +02:00
//! Settings: Messageboard Update
else if ( ret = = + + Idx )
{
if ( + + Settings . PlaylogUpdate > = MAX_ON_OFF ) Settings . PlaylogUpdate = 0 ;
}
//! Settings: Winnertag
else if ( ret = = + + Idx )
{
if ( + + Settings . Wiinnertag > = MAX_ON_OFF ) Settings . Wiinnertag = 0 ;
if ( Settings . Wiinnertag = = ON & & ! Settings . autonetwork )
{
int choice = WindowPrompt ( tr ( " Warning " ) , tr ( " Wiinnertag requires you to enable automatic network connect on application start. Do you want to enable it now? " ) , tr ( " Yes " ) , tr ( " Cancel " ) ) ;
if ( choice )
{
Settings . autonetwork = ON ;
if ( ! IsNetworkInit ( ) )
Initialize_Network ( ) ;
}
}
char filepath [ 200 ] ;
snprintf ( filepath , sizeof ( filepath ) , " %sWiinnertag.xml " , Settings . WiinnertagPath ) ;
if ( Settings . Wiinnertag = = ON & & ! CheckFile ( filepath ) )
{
int choice = WindowPrompt ( tr ( " Warning " ) , tr ( " No Wiinnertag.xml found in the config path. Do you want an example file created? " ) , tr ( " Yes " ) , tr ( " No " ) ) ;
if ( choice )
{
if ( Wiinnertag : : CreateExample ( Settings . WiinnertagPath ) )
{
2020-12-12 22:35:12 +01:00
char text [ 300 ] ;
2011-07-26 00:28:22 +02:00
snprintf ( text , sizeof ( text ) , " %s %s " , tr ( " An example file was created here: " ) , filepath ) ;
WindowPrompt ( tr ( " Success " ) , text , tr ( " OK " ) ) ;
}
else
{
2020-12-12 22:35:12 +01:00
char text [ 300 ] ;
2011-07-26 00:28:22 +02:00
snprintf ( text , sizeof ( text ) , " %s %s " , tr ( " Could not write to: " ) , filepath ) ;
WindowPrompt ( tr ( " Failed " ) , text , tr ( " OK " ) ) ;
}
}
}
}
2011-10-21 20:48:10 +02:00
//! Settings: Import categories from GameTDB
2011-07-26 00:28:22 +02:00
else if ( ret = = + + Idx )
{
2011-10-21 20:48:10 +02:00
int choice = WindowPrompt ( tr ( " Import Categories " ) , tr ( " Are you sure you want to import game categories from GameTDB? " ) , tr ( " Yes " ) , tr ( " Cancel " ) ) ;
2011-07-26 00:28:22 +02:00
if ( choice )
{
char xmlpath [ 300 ] ;
snprintf ( xmlpath , sizeof ( xmlpath ) , " %swiitdb.xml " , Settings . titlestxt_path ) ;
2011-10-21 20:48:10 +02:00
if ( ! GameCategories . ImportFromGameTDB ( xmlpath ) )
2011-07-26 00:28:22 +02:00
{
WindowPrompt ( tr ( " Error " ) , tr ( " Could not open the WiiTDB.xml file. " ) , tr ( " OK " ) ) ;
}
else
{
GameCategories . Save ( ) ;
GameCategories . CategoryList . goToFirst ( ) ;
WindowPrompt ( tr ( " Import Categories " ) , tr ( " Import operation successfully completed. " ) , tr ( " OK " ) ) ;
}
}
}
2011-09-24 01:49:18 +02:00
//! Settings: Export Savegames to EmuNand
else if ( ret = = + + Idx )
{
2012-05-06 12:59:58 +02:00
int choice = WindowPrompt ( tr ( " Do you want to extract all the save games? " ) , tr ( " The save games will be extracted to your emu nand save and channel path. Attention: All existing files will be overwritten. " ) , tr ( " Yes " ) , tr ( " Cancel " ) ) ;
2011-09-24 15:42:32 +02:00
if ( choice = = 1 )
2011-09-24 01:49:18 +02:00
{
2011-10-01 12:41:00 +02:00
ProgressCancelEnable ( true ) ;
2011-09-24 15:42:32 +02:00
StartProgress ( tr ( " Extracting files: " ) , 0 , 0 , true , false ) ;
char filePath [ 512 ] ;
char nandPath [ ISFS_MAXPATH ] ;
bool noErrors = true ;
bool skipErrors = false ;
wString filter ( gameList . GetCurrentFilter ( ) ) ;
gameList . LoadUnfiltered ( ) ;
2012-05-06 12:59:58 +02:00
//! extract the Mii file
snprintf ( nandPath , sizeof ( nandPath ) , " /shared2/menu/FaceLib/RFL_DB.dat " ) ;
snprintf ( filePath , sizeof ( filePath ) , " %s%s " , Settings . NandEmuChanPath , nandPath ) ;
if ( ! CheckFile ( filePath ) )
NandTitle : : ExtractDir ( nandPath , filePath ) ;
snprintf ( filePath , sizeof ( filePath ) , " %s%s " , Settings . NandEmuPath , nandPath ) ;
if ( ! CheckFile ( filePath ) )
NandTitle : : ExtractDir ( nandPath , filePath ) ;
2011-09-24 15:42:32 +02:00
for ( int i = 0 ; i < gameList . size ( ) ; + + i )
{
2012-02-09 22:18:16 +01:00
if ( gameList [ i ] - > type ! = TYPE_GAME_WII_IMG
& & gameList [ i ] - > type ! = TYPE_GAME_NANDCHAN )
2012-01-04 21:10:38 +01:00
continue ;
2012-01-08 19:24:46 +01:00
2012-01-04 21:10:38 +01:00
if ( gameList [ i ] - > tid ! = 0 ) //! Channels
{
2017-12-14 15:26:57 +01:00
snprintf ( nandPath , sizeof ( nandPath ) , " /title/%08x/%08x/data " , ( unsigned int ) ( gameList [ i ] - > tid > > 32 ) , ( unsigned int ) gameList [ i ] - > tid ) ;
2012-01-04 21:10:38 +01:00
snprintf ( filePath , sizeof ( filePath ) , " %s%s " , Settings . NandEmuChanPath , nandPath ) ;
}
else //! Wii games
{
snprintf ( nandPath , sizeof ( nandPath ) , " /title/00010000/%02x%02x%02x%02x " , gameList [ i ] - > id [ 0 ] , gameList [ i ] - > id [ 1 ] , gameList [ i ] - > id [ 2 ] , gameList [ i ] - > id [ 3 ] ) ;
snprintf ( filePath , sizeof ( filePath ) , " %s%s " , Settings . NandEmuPath , nandPath ) ;
}
2011-09-24 01:49:18 +02:00
2011-09-24 15:42:32 +02:00
ShowProgress ( tr ( " Extracting files: " ) , GameTitles . GetTitle ( gameList [ i ] ) , 0 , 0 , - 1 , true , false ) ;
2011-09-24 01:49:18 +02:00
2011-09-24 15:42:32 +02:00
int ret = NandTitle : : ExtractDir ( nandPath , filePath ) ;
2011-10-01 12:41:00 +02:00
if ( ret = = PROGRESS_CANCELED )
{
break ;
}
else if ( ret < 0 ) //! Games with installable channels: Mario Kart, Wii Fit, etc.
2011-09-24 15:42:32 +02:00
{
snprintf ( nandPath , sizeof ( nandPath ) , " /title/00010004/%02x%02x%02x%02x " , gameList [ i ] - > id [ 0 ] , gameList [ i ] - > id [ 1 ] , gameList [ i ] - > id [ 2 ] , gameList [ i ] - > id [ 3 ] ) ;
2011-09-25 11:49:04 +02:00
snprintf ( filePath , sizeof ( filePath ) , " %s%s " , Settings . NandEmuPath , nandPath ) ;
2011-09-24 15:42:32 +02:00
ret = NandTitle : : ExtractDir ( nandPath , filePath ) ;
}
if ( ret < 0 & & ! skipErrors )
{
noErrors = false ;
char text [ 200 ] ;
snprintf ( text , sizeof ( text ) , " %s %s. %s. %s " , tr ( " Could not extract files for: " ) , GameTitles . GetTitle ( gameList [ i ] ) , tr ( " Savegame might not exist for this game. " ) , tr ( " Continue? " ) ) ;
ProgressStop ( ) ;
int ret = WindowPrompt ( tr ( " Error " ) , text , tr ( " Yes " ) , tr ( " No " ) , tr ( " Skip Errors " ) ) ;
if ( ret = = 0 )
skipErrors = true ;
else if ( ret = = 2 )
break ;
}
2011-09-24 01:49:18 +02:00
}
2011-09-24 15:42:32 +02:00
ProgressStop ( ) ;
2011-10-01 12:41:00 +02:00
ProgressCancelEnable ( false ) ;
2011-09-24 01:49:18 +02:00
2011-10-01 12:41:00 +02:00
if ( ret ! = PROGRESS_CANCELED )
{
if ( noErrors )
WindowPrompt ( tr ( " Success. " ) , tr ( " All files extracted. " ) , tr ( " OK " ) ) ;
else
WindowPrompt ( tr ( " Process finished. " ) , tr ( " Errors occured. " ) , tr ( " OK " ) ) ;
}
2011-09-24 15:42:32 +02:00
gameList . FilterList ( filter . c_str ( ) ) ;
}
2011-09-24 01:49:18 +02:00
}
2012-05-06 12:59:58 +02:00
//! Settings: Export Miis to EmuNand
else if ( ret = = + + Idx )
{
int choice = WindowPrompt ( tr ( " Extract Miis to the Emu NAND? " ) , tr ( " The Miis will be extracted to your emu nand path and emu nand channel path. Attention: All existing files will be overwritten. " ) , tr ( " Yes " ) , tr ( " Cancel " ) ) ;
if ( choice = = 1 )
{
char filePath [ 512 ] ;
char nandPath [ ISFS_MAXPATH ] ;
bool Error = false ;
ProgressCancelEnable ( true ) ;
StartProgress ( tr ( " Extracting file: " ) , 0 , 0 , true , false ) ;
//! extract the Mii file
snprintf ( nandPath , sizeof ( nandPath ) , " /shared2/menu/FaceLib/RFL_DB.dat " ) ;
snprintf ( filePath , sizeof ( filePath ) , " %s%s " , Settings . NandEmuChanPath , nandPath ) ;
if ( NandTitle : : ExtractFile ( nandPath , filePath ) < 0 )
Error = true ;
snprintf ( filePath , sizeof ( filePath ) , " %s%s " , Settings . NandEmuPath , nandPath ) ;
if ( NandTitle : : ExtractFile ( nandPath , filePath ) < 0 )
Error = true ;
ProgressStop ( ) ;
ProgressCancelEnable ( false ) ;
if ( Error )
WindowPrompt ( tr ( " Process finished. " ) , tr ( " Errors occured. " ) , tr ( " OK " ) ) ;
else
WindowPrompt ( tr ( " Success. " ) , tr ( " All files extracted. " ) , tr ( " OK " ) ) ;
}
}
//! Settings: Export SYSCONF to EmuNand
else if ( ret = = + + Idx )
{
int choice = WindowPrompt ( tr ( " Extract SYSCONF to the Emu NAND? " ) , tr ( " The SYSCONF file will be extracted to your emu nand path and emu nand channel path. Attention: All existing files will be overwritten. " ) , tr ( " Yes " ) , tr ( " Cancel " ) ) ;
if ( choice = = 1 )
{
char filePath [ 512 ] ;
char nandPath [ ISFS_MAXPATH ] ;
bool Error = false ;
ProgressCancelEnable ( true ) ;
StartProgress ( tr ( " Extracting file: " ) , 0 , 0 , true , false ) ;
//! extract the Mii file
snprintf ( nandPath , sizeof ( nandPath ) , " /shared2/sys/SYSCONF " ) ;
snprintf ( filePath , sizeof ( filePath ) , " %s%s " , Settings . NandEmuChanPath , nandPath ) ;
if ( NandTitle : : ExtractFile ( nandPath , filePath ) < 0 )
Error = true ;
snprintf ( filePath , sizeof ( filePath ) , " %s%s " , Settings . NandEmuPath , nandPath ) ;
if ( NandTitle : : ExtractFile ( nandPath , filePath ) < 0 )
Error = true ;
ProgressStop ( ) ;
ProgressCancelEnable ( false ) ;
if ( Error )
WindowPrompt ( tr ( " Process finished. " ) , tr ( " Errors occured. " ) , tr ( " OK " ) ) ;
else
WindowPrompt ( tr ( " Success. " ) , tr ( " All files extracted. " ) , tr ( " OK " ) ) ;
}
}
2011-10-01 12:41:00 +02:00
//! Settings: Dump NAND to EmuNand
else if ( ret = = + + Idx )
{
2012-05-06 12:59:58 +02:00
int choice = WindowPrompt ( tr ( " What to extract from NAND? " ) , tr ( " The files will be extracted to your emu nand save and channel path. Attention: All existing files will be overwritten. " ) , tr ( " Everything " ) , tr ( " Enter Path " ) , tr ( " Cancel " ) ) ;
2011-10-01 12:41:00 +02:00
if ( choice )
{
char filePath [ 255 ] ;
char * nandPath = ( char * ) memalign ( 32 , ISFS_MAXPATH ) ;
if ( ! nandPath )
{
WindowPrompt ( tr ( " Error " ) , tr ( " Not enough memory. " ) , tr ( " OK " ) ) ;
return MENU_NONE ;
}
2015-03-08 17:49:07 +01:00
strcpy ( nandPath , " / " ) ;
2011-10-01 12:41:00 +02:00
if ( choice = = 2 )
{
choice = OnScreenKeyboard ( nandPath , ISFS_MAXPATH , 1 ) ;
if ( strlen ( nandPath ) > 1 & & nandPath [ strlen ( nandPath ) - 1 ] = = ' / ' )
nandPath [ strlen ( nandPath ) - 1 ] = 0 ;
}
2015-07-05 16:44:24 +02:00
char extractPath [ 255 ] ;
snprintf ( extractPath , sizeof ( extractPath ) , " %s " , Settings . NandEmuPath ) ;
if ( strlen ( Settings . NandEmuPath ) ! = strlen ( Settings . NandEmuChanPath ) | | strcmp ( Settings . NandEmuPath , Settings . NandEmuChanPath ) ! = 0 )
{
if ( WindowPrompt ( tr ( " Where to dump NAND? " ) , tr ( " Select the NAND Emu Path to use. " ) , tr ( " Nand Emu Path " ) , tr ( " Nand Emu Channel Path " ) ) = = 0 )
snprintf ( extractPath , sizeof ( extractPath ) , " %s " , Settings . NandEmuChanPath ) ;
}
snprintf ( filePath , sizeof ( filePath ) , " %s%s " , extractPath , nandPath ) ;
2011-10-01 12:41:00 +02:00
if ( choice )
{
u32 dummy ;
int ret = - 1 ;
ProgressCancelEnable ( true ) ;
StartProgress ( tr ( " Extracting nand files: " ) , 0 , 0 , true , false ) ;
ShowProgress ( tr ( " Extracting nand files: " ) , 0 , 0 , - 1 , true , false ) ;
if ( ISFS_ReadDir ( nandPath , NULL , & dummy ) < 0 )
2011-12-22 23:44:48 +01:00
ret = NandTitle : : ExtractFile ( nandPath , filePath ) ;
2011-10-01 12:41:00 +02:00
else
2011-12-22 23:44:48 +01:00
ret = NandTitle : : ExtractDir ( nandPath , filePath ) ;
2011-10-01 12:41:00 +02:00
ProgressStop ( ) ;
ProgressCancelEnable ( false ) ;
if ( ret ! = PROGRESS_CANCELED )
{
if ( ret < 0 )
WindowPrompt ( tr ( " Process finished. " ) , tr ( " Errors occured. " ) , tr ( " OK " ) ) ;
else
WindowPrompt ( tr ( " Success. " ) , tr ( " All files extracted. " ) , tr ( " OK " ) ) ;
}
}
free ( nandPath ) ;
}
}
2016-01-02 17:23:01 +01:00
//! Settings: EmuNand Wad Manager
2012-01-01 18:58:10 +01:00
else if ( ret = = + + Idx )
{
GuiWindow * parent = ( GuiWindow * ) parentElement ;
if ( parent ) parent - > SetState ( STATE_DISABLED ) ;
this - > SetState ( STATE_DEFAULT ) ;
this - > Remove ( optionBrowser ) ;
char wadpath [ 150 ] ;
2012-05-06 12:59:58 +02:00
snprintf ( wadpath , sizeof ( wadpath ) , " %s/wad/ " , Settings . BootDevice ) ;
2020-12-12 22:33:31 +01:00
2016-01-02 17:23:01 +01:00
int choice = WindowPrompt ( tr ( " EmuNAND Wad Manager " ) , tr ( " Which mode do you want to use? " ) , tr ( " File " ) , tr ( " Folder " ) , tr ( " Cancel " ) ) ;
if ( choice = = 1 ) // File mode
2012-01-01 18:58:10 +01:00
{
2016-01-02 17:23:01 +01:00
int result = BrowseDevice ( wadpath , sizeof ( wadpath ) , FB_DEFAULT ) ;
if ( result )
2012-01-01 18:58:10 +01:00
{
2016-01-02 17:23:01 +01:00
choice = WindowPrompt ( tr ( " EmuNAND Wad Manager " ) , tr ( " What do you want to do? " ) , tr ( " Install " ) , tr ( " Uninstall " ) , tr ( " Cancel " ) ) ;
if ( choice = = 1 ) // File install
{
Wad wadFile ( wadpath ) ;
if ( ! wadFile . Install ( Settings . NandEmuChanPath ) )
{
// install error - Try to cleanup any partially installed wad data
WindowPrompt ( tr ( " EmuNAND Wad Manager " ) , tr ( " Install error - Cleaning incomplete data. " ) , tr ( " OK " ) ) ;
//gprintf("Error : %s\n", wadpath);
wadFile . UnInstall ( Settings . NandEmuChanPath ) ;
}
}
else if ( choice = = 2 ) // File uninstall
{
Wad wadFile ( wadpath ) ;
wadFile . UnInstall ( Settings . NandEmuChanPath ) ;
}
2020-12-12 22:33:31 +01:00
2016-01-02 17:23:01 +01:00
// Refresh new EmuNAND content
2020-12-12 22:33:31 +01:00
ResetGameHeaderCache ( ) ;
2012-01-01 18:58:10 +01:00
Channels : : Instance ( ) - > GetEmuChannelList ( ) ;
GameTitles . LoadTitlesFromGameTDB ( Settings . titlestxt_path ) ;
}
2016-01-02 17:23:01 +01:00
}
else if ( choice = = 2 ) // Folder mode
{
int result = BrowseDevice ( wadpath , sizeof ( wadpath ) , FB_DEFAULT , noFILES ) ;
if ( result )
2012-01-01 18:58:10 +01:00
{
2016-01-02 17:23:01 +01:00
DirList * wadList = new DirList ( wadpath , " .wad " , DirList : : Files ) ;
if ( wadList - > GetFilecount ( ) )
{
char found [ 20 ] ;
snprintf ( found , sizeof ( found ) , fmt ( tr ( " %i wad found. " ) , wadList - > GetFilecount ( ) ) ) ;
choice = WindowPrompt ( tr ( " EmuNAND Wad Manager " ) , fmt ( " %s %s " , found , tr ( " What do you want to do? " ) ) , tr ( " Install " ) , tr ( " Uninstall " ) , tr ( " Cancel " ) ) ;
if ( choice = = 1 ) // Folder install
{
for ( int i = 0 ; i < wadList - > GetFilecount ( ) ; i + + )
{
Wad wadFile ( wadList - > GetFilepath ( i ) , false ) ;
if ( wadFile . Install ( Settings . NandEmuChanPath ) )
{
//gprintf("Success : %s\n", wadList->GetFilepath(i));
wadList - > RemoveEntrie ( i ) ;
- - i ;
}
else // install error - Try to cleanup any partially installed wad data
{
//gprintf("Error : %s\n", wadList->GetFilepath(i));
wadFile . UnInstall ( Settings . NandEmuChanPath ) ;
}
}
}
if ( choice = = 2 ) // Folder uninstall
{
if ( WindowPrompt ( tr ( " EmuNAND Wad Manager " ) , tr ( " Attention: All savegames will be deleted. " ) , tr ( " Uninstall " ) , tr ( " Cancel " ) ) )
{
for ( int i = 0 ; i < wadList - > GetFilecount ( ) ; i + + )
{
Wad wadFile ( wadList - > GetFilepath ( i ) , false ) ;
if ( wadFile . UnInstall ( Settings . NandEmuChanPath ) )
{
//gprintf("uninst. : %s\n", wadList->GetFilepath(i));
wadList - > RemoveEntrie ( i ) ;
- - i ;
}
}
}
else
choice = 0 ;
}
// check if there is any remaining unprocessed wad
if ( choice ! = 0 )
{
if ( wadList - > GetFilecount ( ) = = 0 )
WindowPrompt ( tr ( " EmuNAND Wad Manager " ) , tr ( " All wad files processed successfully. " ) , tr ( " OK " ) ) ;
else
{
if ( WindowPrompt ( tr ( " EmuNAND Wad Manager " ) , fmt ( tr ( " %i wad file(s) not processed! " ) , wadList - > GetFilecount ( ) ) , tr ( " Save List " ) , tr ( " OK " ) ) )
{
char path [ 200 ] ;
snprintf ( path , sizeof ( path ) , " %s/WadManager_errors.txt " , Settings . update_path ) ;
FILE * f = fopen ( path , " a " ) ;
if ( f )
{
time_t rawtime = time ( NULL ) ;
char theTime [ 11 ] ;
theTime [ 0 ] = 0 ;
strftime ( theTime , sizeof ( theTime ) , " %Y-%m-%d " , localtime ( & rawtime ) ) ;
fprintf ( f , " \r \n \r \n EmuNAND Wad Manager - %10s \r \n -------------------------------- \r \n " , theTime ) ;
fprintf ( f , " %s %s \r \n " , choice = = 1 ? " Error installing to " : " Error uninstalling from " , Settings . NandEmuChanPath ) ;
fprintf ( f , " %s \r \n " , choice = = 1 ? " List of user canceled installation or bad wad files. " : " Titles not on EmuNAND or weren't correctly installed. " ) ;
for ( int i = 0 ; i < wadList - > GetFilecount ( ) ; i + + )
{
fprintf ( f , " %s \r \n " , wadList - > GetFilepath ( i ) ) ;
//gprintf("%s\n", wadList->GetFilepath(i));
}
fclose ( f ) ;
}
else
WindowPrompt ( tr ( " EmuNAND Wad Manager " ) , tr ( " Error writing the data. " ) , tr ( " OK " ) ) ;
}
2020-12-12 22:33:31 +01:00
}
2016-01-02 17:23:01 +01:00
}
2020-12-12 22:33:31 +01:00
2016-01-02 17:23:01 +01:00
// Refresh new EmuNAND content
2020-12-12 22:33:31 +01:00
ResetGameHeaderCache ( ) ;
2016-01-02 17:23:01 +01:00
Channels : : Instance ( ) - > GetEmuChannelList ( ) ;
GameTitles . LoadTitlesFromGameTDB ( Settings . titlestxt_path ) ;
}
else
{
WindowPrompt ( tr ( " EmuNAND Wad Manager " ) , tr ( " No wad file found in this folder. " ) , tr ( " OK " ) ) ;
}
2020-12-12 22:33:31 +01:00
2016-01-02 17:23:01 +01:00
delete wadList ;
2012-01-01 18:58:10 +01:00
}
}
if ( parent ) parent - > SetState ( STATE_DEFAULT ) ;
this - > Append ( optionBrowser ) ;
}
2016-01-02 17:23:01 +01:00
/*
2014-07-14 18:31:52 +02:00
//! Settings: Update Nintendont
else if ( ret = = + + Idx )
{
char NINUpdatePath [ 100 ] ;
snprintf ( NINUpdatePath , sizeof ( NINUpdatePath ) , " %sboot.dol " , Settings . NINLoaderPath ) ;
2014-08-02 18:53:56 +02:00
char NINUpdatePathBak [ 100 ] ;
snprintf ( NINUpdatePathBak , sizeof ( NINUpdatePathBak ) , " %sboot.bak " , Settings . NINLoaderPath ) ;
2020-12-12 22:33:31 +01:00
2014-07-14 18:31:52 +02:00
int choice = WindowPrompt ( tr ( " Do you want to update this file? " ) , NINUpdatePath , tr ( " Yes " ) , tr ( " Cancel " ) ) ;
if ( choice = = 1 )
{
2014-08-02 18:53:56 +02:00
if ( ! IsNetworkInit ( ) & & ! NetworkInitPrompt ( ) )
{
2015-07-05 16:44:24 +02:00
WindowPrompt ( tr ( " Error: " ) , tr ( " Could not initialize network! " ) , tr ( " OK " ) ) ;
2014-08-02 18:53:56 +02:00
}
2014-07-14 18:31:52 +02:00
else
{
2014-08-02 18:53:56 +02:00
// Rename existing boot.dol file to boot.bak
if ( CheckFile ( NINUpdatePath ) )
RenameFile ( NINUpdatePath , NINUpdatePathBak ) ;
2020-12-12 22:33:31 +01:00
2014-08-02 18:53:56 +02:00
// Download latest loader.dol as boot.dol
2015-07-13 16:26:30 +02:00
bool success = false ;
2019-11-11 18:09:59 +01:00
struct download file = { } ;
2020-11-08 22:29:44 +01:00
file . show_progress = true ;
2019-11-11 18:09:59 +01:00
downloadfile ( " https://raw.githubusercontent.com/FIX94/Nintendont/master/loader/loader.dol " , & file ) ;
if ( file . size > 0 )
2014-08-02 18:53:56 +02:00
{
2015-07-13 16:26:30 +02:00
FILE * pfile = fopen ( NINUpdatePath , " wb " ) ;
if ( pfile )
{
fwrite ( file . data , 1 , file . size , pfile ) ;
fclose ( pfile ) ;
WindowPrompt ( tr ( " Successfully Updated " ) , 0 , tr ( " OK " ) ) ;
success = true ;
}
else
WindowPrompt ( tr ( " Update failed " ) , 0 , tr ( " OK " ) ) ;
2020-12-12 22:33:31 +01:00
2020-11-08 22:29:44 +01:00
MEM2_free ( file . data ) ;
2014-08-02 18:53:56 +02:00
}
2020-12-12 22:33:31 +01:00
2015-07-13 16:26:30 +02:00
if ( success )
2014-08-02 18:53:56 +02:00
{
//remove existing loader.dol file if found as it has priority over boot.dol, and boot.bak
snprintf ( NINUpdatePath , sizeof ( NINUpdatePath ) , " %s/loader.dol " , Settings . NINLoaderPath ) ;
RemoveFile ( NINUpdatePath ) ;
RemoveFile ( NINUpdatePathBak ) ;
2015-07-13 16:26:30 +02:00
}
else
{
// Restore backup file if found
RemoveFile ( NINUpdatePath ) ;
if ( CheckFile ( NINUpdatePathBak ) )
RenameFile ( NINUpdatePathBak , NINUpdatePath ) ;
WindowPrompt ( tr ( " Update failed " ) , 0 , tr ( " OK " ) ) ;
2014-08-02 18:53:56 +02:00
}
2014-07-14 18:31:52 +02:00
}
}
}
2016-01-02 17:23:01 +01:00
*/
2014-07-14 18:31:52 +02:00
2015-01-04 21:22:06 +01:00
// WiiU Aspect switcher (Thanks Tueidj)
else if ( ret = = + + Idx )
{
2015-02-14 16:41:20 +01:00
if ( isWiiU ( ) ) // vWii only
2015-01-04 21:22:06 +01:00
{
2015-01-19 23:51:50 +01:00
if ( read32 ( 0xd8006a0 ) = = 0x30000004 )
{
write32 ( 0xd8006a0 , 0x30000002 ) , mask32 ( 0xd8006a8 , 0 , 2 ) ; // Set 4:3
Settings . widescreen = OFF ;
}
else
{
write32 ( 0xd8006a0 , 0x30000004 ) , mask32 ( 0xd8006a8 , 0 , 2 ) ; // Set 16:9
Settings . widescreen = ON ;
}
2015-01-04 21:22:06 +01:00
}
}
2015-07-05 16:44:24 +02:00
// Neek: Boot neek system menu with current EmuNAND channel path
else if ( ret = = + + Idx )
{
if ( neek2oSetNAND ( Settings . NandEmuChanPath ) < 0 ) // set current path as default
{
WindowPrompt ( tr ( " Error: " ) , tr ( " Neek NAND path selection failed. " ) , tr ( " OK " ) ) ;
}
else
{
if ( neekLoadKernel ( Settings . NandEmuChanPath ) = = false )
{
WindowPrompt ( tr ( " Error: " ) , tr ( " Neek kernel loading failed. " ) , tr ( " OK " ) ) ;
}
else
{
ExitApp ( ) ;
NEEK_CFG * neek_config = ( NEEK_CFG * ) NEEK_CONFIG_ADDRESS ;
neek2oSetBootSettings ( neek_config , 0 /* TitleID */ , 0 /* Magic */ , 0 /* Returnto TitleID */ , Settings . NandEmuChanPath /* Full EmuNAND path */ ) ;
2020-12-12 22:33:31 +01:00
2015-07-05 16:44:24 +02:00
if ( neekBoot ( ) = = - 1 )
Sys_BackToLoader ( ) ;
return MENU_NONE ;
}
}
}
2020-12-12 22:33:31 +01:00
//! Reset Game Header Cache
else if ( ret = = + + Idx )
{
int choice = WindowPrompt ( tr ( " Are you sure you want to reset? " ) , 0 , tr ( " Yes " ) , tr ( " Cancel " ) ) ;
if ( choice = = 1 )
{
ResetGameHeaderCache ( ) ;
gameList . ReadGameList ( ) ;
}
}
2011-07-26 00:28:22 +02:00
SetOptionValues ( ) ;
return MENU_NONE ;
2011-06-18 09:00:42 +02:00
}