2013-04-18 03:43:35 +00:00
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
2008-12-08 05:30:24 +00:00
2011-01-30 14:20:20 +00:00
# ifdef __APPLE__
# import <Cocoa / Cocoa.h>
# endif
2013-10-26 09:55:41 +00:00
# include <cinttypes>
2014-02-22 22:36:30 +00:00
# include <cstddef>
# include <cstdio>
# include <cstring>
# include <fstream>
# include <set>
# include <string>
2014-02-17 10:18:15 +00:00
# include <type_traits>
2014-02-22 22:36:30 +00:00
# include <vector>
2014-04-12 10:50:12 +00:00
# include <polarssl/md5.h>
2014-02-22 22:36:30 +00:00
# include <wx/arrstr.h>
# include <wx/bitmap.h>
# include <wx/button.h>
# include <wx/chartype.h>
# include <wx/checkbox.h>
# include <wx/checklst.h>
# include <wx/choice.h>
# include <wx/defs.h>
# include <wx/dialog.h>
# include <wx/dirdlg.h>
# include <wx/dynarray.h>
# include <wx/event.h>
# include <wx/filedlg.h>
# include <wx/gbsizer.h>
# include <wx/gdicmn.h>
# include <wx/image.h>
# include <wx/imaglist.h>
# include <wx/itemid.h>
# include <wx/menu.h>
# include <wx/mimetype.h>
# include <wx/msgdlg.h>
# include <wx/notebook.h>
# include <wx/panel.h>
# include <wx/progdlg.h>
# include <wx/sizer.h>
# include <wx/statbmp.h>
# include <wx/stattext.h>
# include <wx/string.h>
# include <wx/textctrl.h>
# include <wx/thread.h>
# include <wx/translation.h>
# include <wx/treebase.h>
# include <wx/treectrl.h>
# include <wx/utils.h>
# include <wx/validate.h>
# include <wx/windowid.h>
2013-09-07 21:02:49 +00:00
2014-02-17 10:18:15 +00:00
# include "Common/Common.h"
# include "Common/CommonPaths.h"
2014-02-22 22:36:30 +00:00
# include "Common/FileUtil.h"
# include "Common/IniFile.h"
2014-02-17 10:18:15 +00:00
# include "Common/StringUtil.h"
2014-02-22 22:36:30 +00:00
# include "Common/SysConf.h"
# include "Core/ActionReplay.h"
2014-02-17 10:18:15 +00:00
# include "Core/ConfigManager.h"
2014-02-22 22:36:30 +00:00
# include "Core/CoreParameter.h"
# include "Core/GeckoCodeConfig.h"
# include "Core/PatchEngine.h"
# include "Core/Boot/Boot.h"
2014-02-17 10:18:15 +00:00
# include "DiscIO/Filesystem.h"
2014-02-22 22:36:30 +00:00
# include "DiscIO/Volume.h"
2014-02-17 10:18:15 +00:00
# include "DiscIO/VolumeCreator.h"
# include "DolphinWX/ARCodeAddEdit.h"
# include "DolphinWX/GeckoCodeDiag.h"
2014-02-22 22:36:30 +00:00
# include "DolphinWX/ISOFile.h"
2014-02-17 10:18:15 +00:00
# include "DolphinWX/ISOProperties.h"
# include "DolphinWX/PatchAddEdit.h"
# include "DolphinWX/WxUtils.h"
2014-02-19 01:56:29 +00:00
# include "DolphinWX/resources/isoprop_disc.xpm"
2014-02-17 10:18:15 +00:00
# include "DolphinWX/resources/isoprop_file.xpm"
# include "DolphinWX/resources/isoprop_folder.xpm"
2009-09-13 22:03:18 +00:00
2014-02-22 22:36:30 +00:00
class wxWindow ;
2009-03-10 17:19:30 +00:00
struct WiiPartition
{
DiscIO : : IVolume * Partition ;
DiscIO : : IFileSystem * FileSystem ;
std : : vector < const DiscIO : : SFileInfo * > Files ;
} ;
2014-07-08 13:58:25 +00:00
static std : : vector < WiiPartition > WiiDisc ;
2008-12-08 05:30:24 +00:00
2014-07-08 13:58:25 +00:00
static DiscIO : : IVolume * OpenISO = nullptr ;
static DiscIO : : IFileSystem * pFileSystem = nullptr ;
2008-12-08 05:30:24 +00:00
std : : vector < PatchEngine : : Patch > onFrame ;
2008-12-17 04:14:24 +00:00
std : : vector < ActionReplay : : ARCode > arCodes ;
2011-02-03 17:51:12 +00:00
PHackData PHack_Data ;
2008-12-08 05:30:24 +00:00
BEGIN_EVENT_TABLE ( CISOProperties , wxDialog )
EVT_CLOSE ( CISOProperties : : OnClose )
2011-03-15 21:57:00 +00:00
EVT_BUTTON ( wxID_OK , CISOProperties : : OnCloseClick )
2008-12-08 05:30:24 +00:00
EVT_BUTTON ( ID_EDITCONFIG , CISOProperties : : OnEditConfig )
2014-04-12 10:50:12 +00:00
EVT_BUTTON ( ID_MD5SUMCOMPUTE , CISOProperties : : OnComputeMD5Sum )
2013-09-07 21:02:49 +00:00
EVT_BUTTON ( ID_SHOWDEFAULTCONFIG , CISOProperties : : OnShowDefaultConfig )
2008-12-08 05:30:24 +00:00
EVT_CHOICE ( ID_EMUSTATE , CISOProperties : : SetRefresh )
2009-02-21 14:40:34 +00:00
EVT_CHOICE ( ID_EMU_ISSUES , CISOProperties : : SetRefresh )
2008-12-08 05:30:24 +00:00
EVT_LISTBOX ( ID_PATCHES_LIST , CISOProperties : : ListSelectionChanged )
EVT_BUTTON ( ID_EDITPATCH , CISOProperties : : PatchButtonClicked )
EVT_BUTTON ( ID_ADDPATCH , CISOProperties : : PatchButtonClicked )
EVT_BUTTON ( ID_REMOVEPATCH , CISOProperties : : PatchButtonClicked )
EVT_LISTBOX ( ID_CHEATS_LIST , CISOProperties : : ListSelectionChanged )
EVT_BUTTON ( ID_EDITCHEAT , CISOProperties : : ActionReplayButtonClicked )
EVT_BUTTON ( ID_ADDCHEAT , CISOProperties : : ActionReplayButtonClicked )
EVT_BUTTON ( ID_REMOVECHEAT , CISOProperties : : ActionReplayButtonClicked )
EVT_MENU ( IDM_BNRSAVEAS , CISOProperties : : OnBannerImageSave )
EVT_TREE_ITEM_RIGHT_CLICK ( ID_TREECTRL , CISOProperties : : OnRightClickOnTree )
EVT_MENU ( IDM_EXTRACTFILE , CISOProperties : : OnExtractFile )
EVT_MENU ( IDM_EXTRACTDIR , CISOProperties : : OnExtractDir )
2009-09-13 22:03:18 +00:00
EVT_MENU ( IDM_EXTRACTALL , CISOProperties : : OnExtractDir )
2009-12-29 13:59:38 +00:00
EVT_MENU ( IDM_EXTRACTAPPLOADER , CISOProperties : : OnExtractDataFromHeader )
EVT_MENU ( IDM_EXTRACTDOL , CISOProperties : : OnExtractDataFromHeader )
2012-05-04 10:49:10 +00:00
EVT_MENU ( IDM_CHECKINTEGRITY , CISOProperties : : CheckPartitionIntegrity )
2009-02-14 17:32:03 +00:00
EVT_CHOICE ( ID_LANG , CISOProperties : : OnChangeBannerLang )
2008-12-08 05:30:24 +00:00
END_EVENT_TABLE ( )
CISOProperties : : CISOProperties ( const std : : string fileName , wxWindow * parent , wxWindowID id , const wxString & title , const wxPoint & position , const wxSize & size , long style )
: wxDialog ( parent , id , title , position , size , style )
{
2013-09-07 21:02:49 +00:00
// Load ISO data
2009-03-10 17:19:30 +00:00
OpenISO = DiscIO : : CreateVolumeFromFilename ( fileName ) ;
2013-09-14 22:07:53 +00:00
bool IsWad = DiscIO : : IsVolumeWadFile ( OpenISO ) ;
bool IsWiiDisc = DiscIO : : IsVolumeWiiDisc ( OpenISO ) ;
if ( IsWiiDisc )
2009-03-10 17:19:30 +00:00
{
2009-12-28 19:34:19 +00:00
for ( u32 i = 0 ; i < 0xFFFFFFFF ; i + + ) // yes, technically there can be OVER NINE THOUSAND partitions...
2009-03-10 17:19:30 +00:00
{
WiiPartition temp ;
2014-03-09 20:14:26 +00:00
if ( ( temp . Partition = DiscIO : : CreateVolumeFromFilename ( fileName , 0 , i ) ) ! = nullptr )
2009-03-10 17:19:30 +00:00
{
2014-03-09 20:14:26 +00:00
if ( ( temp . FileSystem = DiscIO : : CreateFileSystem ( temp . Partition ) ) ! = nullptr )
2009-04-27 23:27:56 +00:00
{
temp . FileSystem - > GetFileList ( temp . Files ) ;
WiiDisc . push_back ( temp ) ;
}
2009-03-10 17:19:30 +00:00
}
else
2013-04-08 05:16:50 +00:00
{
2009-03-10 17:19:30 +00:00
break ;
2013-04-08 05:16:50 +00:00
}
2009-03-10 17:19:30 +00:00
}
}
else
{
2009-06-07 02:54:07 +00:00
// TODO : Should we add a way to browse the wad file ?
2013-09-14 22:07:53 +00:00
if ( ! IsWad )
2009-06-07 02:54:07 +00:00
{
2009-09-04 06:52:34 +00:00
GCFiles . clear ( ) ;
2009-06-07 02:54:07 +00:00
pFileSystem = DiscIO : : CreateFileSystem ( OpenISO ) ;
2010-01-11 05:07:56 +00:00
if ( pFileSystem )
pFileSystem - > GetFileList ( GCFiles ) ;
2009-06-07 02:54:07 +00:00
}
2009-03-10 17:19:30 +00:00
}
2008-12-08 05:30:24 +00:00
2013-09-07 21:02:49 +00:00
// Load game ini
2011-02-03 17:51:12 +00:00
std : : string _iniFilename = OpenISO - > GetUniqueID ( ) ;
2013-09-23 06:39:14 +00:00
std : : string _iniFilenameRevisionSpecific = OpenISO - > GetRevisionSpecificUniqueID ( ) ;
2011-01-31 20:30:25 +00:00
2010-12-15 23:18:08 +00:00
if ( ! _iniFilename . length ( ) )
{
2014-09-02 01:47:19 +00:00
u8 title_id [ 8 ] ;
if ( OpenISO - > GetTitleID ( title_id ) )
2010-12-15 23:18:08 +00:00
{
2014-09-02 01:47:19 +00:00
_iniFilename = StringFromFormat ( " %016 " PRIx64 , Common : : swap64 ( title_id ) ) ;
2010-12-15 23:18:08 +00:00
}
}
2013-04-08 05:16:50 +00:00
2013-09-07 21:02:49 +00:00
GameIniFileDefault = File : : GetSysDirectory ( ) + GAMESETTINGS_DIR DIR_SEP + _iniFilename + " .ini " ;
2013-09-23 06:39:14 +00:00
std : : string GameIniFileDefaultRevisionSpecific = File : : GetSysDirectory ( ) + GAMESETTINGS_DIR DIR_SEP + _iniFilenameRevisionSpecific + " .ini " ;
2013-09-07 21:02:49 +00:00
GameIniFileLocal = File : : GetUserPath ( D_GAMESETTINGS_IDX ) + _iniFilename + " .ini " ;
2013-04-08 05:16:50 +00:00
2013-09-07 21:02:49 +00:00
GameIniDefault . Load ( GameIniFileDefault ) ;
2013-09-23 06:39:14 +00:00
if ( _iniFilenameRevisionSpecific ! = " " )
2014-03-05 22:05:36 +00:00
GameIniDefault . Load ( GameIniFileDefaultRevisionSpecific , true ) ;
2013-09-07 21:02:49 +00:00
GameIniLocal . Load ( GameIniFileLocal ) ;
2013-04-08 05:16:50 +00:00
2013-09-07 21:02:49 +00:00
// Setup GUI
OpenGameListItem = new GameListItem ( fileName ) ;
bRefreshList = false ;
2013-09-14 22:07:53 +00:00
CreateGUIControls ( IsWad ) ;
2013-09-07 21:02:49 +00:00
LoadGameConfig ( ) ;
2008-12-08 05:30:24 +00:00
// Disk header and apploader
2011-12-19 06:01:46 +00:00
2013-03-03 01:46:55 +00:00
m_Name - > SetValue ( StrToWxStr ( OpenISO - > GetName ( ) ) ) ;
m_GameID - > SetValue ( StrToWxStr ( OpenISO - > GetUniqueID ( ) ) ) ;
2008-12-08 05:30:24 +00:00
switch ( OpenISO - > GetCountry ( ) )
{
case DiscIO : : IVolume : : COUNTRY_EUROPE :
2011-01-05 04:35:46 +00:00
m_Country - > SetValue ( _ ( " EUROPE " ) ) ;
2009-07-03 22:34:51 +00:00
break ;
2008-12-08 05:30:24 +00:00
case DiscIO : : IVolume : : COUNTRY_FRANCE :
2011-01-05 04:35:46 +00:00
m_Country - > SetValue ( _ ( " FRANCE " ) ) ;
2009-07-03 22:34:51 +00:00
break ;
2009-03-07 18:03:53 +00:00
case DiscIO : : IVolume : : COUNTRY_ITALY :
2011-01-05 04:35:46 +00:00
m_Country - > SetValue ( _ ( " ITALY " ) ) ;
2008-12-08 05:30:24 +00:00
break ;
2010-10-03 06:10:14 +00:00
case DiscIO : : IVolume : : COUNTRY_RUSSIA :
2011-01-05 04:35:46 +00:00
m_Country - > SetValue ( _ ( " RUSSIA " ) ) ;
2010-10-03 06:10:14 +00:00
break ;
2008-12-08 05:30:24 +00:00
case DiscIO : : IVolume : : COUNTRY_USA :
2011-01-05 04:35:46 +00:00
m_Country - > SetValue ( _ ( " USA " ) ) ;
2013-09-14 22:07:53 +00:00
if ( ! IsWad ) // For (non wad) NTSC Games, there's no multi lang
{
m_Lang - > SetSelection ( 0 ) ;
m_Lang - > Disable ( ) ;
}
2008-12-08 05:30:24 +00:00
break ;
2009-07-03 22:34:51 +00:00
case DiscIO : : IVolume : : COUNTRY_JAPAN :
2011-01-05 04:35:46 +00:00
m_Country - > SetValue ( _ ( " JAPAN " ) ) ;
2013-09-14 22:07:53 +00:00
if ( ! IsWad ) // For (non wad) NTSC Games, there's no multi lang
{
m_Lang - > Insert ( _ ( " Japanese " ) , 0 ) ;
m_Lang - > SetSelection ( 0 ) ;
m_Lang - > Disable ( ) ;
}
2009-07-03 22:34:51 +00:00
break ;
case DiscIO : : IVolume : : COUNTRY_KOREA :
2011-01-05 04:35:46 +00:00
m_Country - > SetValue ( _ ( " KOREA " ) ) ;
2009-07-03 22:34:51 +00:00
break ;
case DiscIO : : IVolume : : COUNTRY_TAIWAN :
2011-01-05 04:35:46 +00:00
m_Country - > SetValue ( _ ( " TAIWAN " ) ) ;
2013-09-14 22:07:53 +00:00
if ( ! IsWad ) // For (non wad) NTSC Games, there's no multi lang
{
m_Lang - > Insert ( _ ( " TAIWAN " ) , 0 ) ;
m_Lang - > SetSelection ( 0 ) ;
m_Lang - > Disable ( ) ;
}
2009-07-03 22:34:51 +00:00
break ;
case DiscIO : : IVolume : : COUNTRY_SDK :
2011-01-05 04:35:46 +00:00
m_Country - > SetValue ( _ ( " No Country (SDK) " ) ) ;
2008-12-08 05:30:24 +00:00
break ;
default :
2011-01-05 04:35:46 +00:00
m_Country - > SetValue ( _ ( " UNKNOWN " ) ) ;
2008-12-08 05:30:24 +00:00
break ;
}
2013-10-29 05:23:17 +00:00
2013-09-14 22:07:53 +00:00
if ( IsWiiDisc ) // Only one language with wii banners
{
m_Lang - > SetSelection ( 0 ) ;
m_Lang - > Disable ( ) ;
}
2014-05-17 17:17:28 +00:00
wxString temp = " 0x " + StrToWxStr ( OpenISO - > GetMakerID ( ) ) ;
2008-12-08 05:30:24 +00:00
m_MakerID - > SetValue ( temp ) ;
2014-05-17 17:17:28 +00:00
m_Revision - > SetValue ( wxString : : Format ( " %u " , OpenISO - > GetRevision ( ) ) ) ;
2013-03-03 02:34:53 +00:00
m_Date - > SetValue ( StrToWxStr ( OpenISO - > GetApploaderDate ( ) ) ) ;
2014-05-17 17:17:28 +00:00
m_FST - > SetValue ( wxString : : Format ( " %u " , OpenISO - > GetFSTSize ( ) ) ) ;
2008-12-08 05:30:24 +00:00
2009-12-28 19:34:19 +00:00
// Here we set all the info to be shown (be it SJIS or Ascii) + we set the window title
2013-09-14 22:07:53 +00:00
if ( ! IsWad )
{
2014-07-08 18:31:09 +00:00
ChangeBannerDetails ( SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . SelectedLanguage ) ;
2013-09-14 22:07:53 +00:00
}
else
{
ChangeBannerDetails ( SConfig : : GetInstance ( ) . m_SYSCONF - > GetData < u8 > ( " IPL.LNG " ) ) ;
}
2013-10-29 05:23:17 +00:00
2013-09-25 07:05:36 +00:00
m_Banner - > SetBitmap ( OpenGameListItem - > GetBitmap ( ) ) ;
2013-01-13 18:07:45 +00:00
m_Banner - > Bind ( wxEVT_RIGHT_DOWN , & CISOProperties : : RightClickOnBanner , this ) ;
2008-12-08 05:30:24 +00:00
// Filesystem browser/dumper
2011-03-16 22:22:21 +00:00
// TODO : Should we add a way to browse the wad file ?
if ( ! DiscIO : : IsVolumeWadFile ( OpenISO ) )
2009-03-10 17:19:30 +00:00
{
2011-03-16 22:22:21 +00:00
if ( DiscIO : : IsVolumeWiiDisc ( OpenISO ) )
2009-06-07 02:54:07 +00:00
{
2011-03-16 22:22:21 +00:00
for ( u32 i = 0 ; i < WiiDisc . size ( ) ; i + + )
{
WiiPartition partition = WiiDisc . at ( i ) ;
wxTreeItemId PartitionRoot =
2011-04-17 21:39:58 +00:00
m_Treectrl - > AppendItem ( RootId , wxString : : Format ( _ ( " Partition %i " ) , i ) , 0 , 0 ) ;
2013-10-29 05:23:17 +00:00
CreateDirectoryTree ( PartitionRoot , partition . Files , 1 , partition . Files . at ( 0 ) - > m_FileSize ) ;
2011-03-16 22:22:21 +00:00
if ( i = = 1 )
m_Treectrl - > Expand ( PartitionRoot ) ;
}
2009-06-07 02:54:07 +00:00
}
2011-03-16 22:22:21 +00:00
else if ( ! GCFiles . empty ( ) )
2013-04-08 05:16:50 +00:00
{
2011-03-16 22:22:21 +00:00
CreateDirectoryTree ( RootId , GCFiles , 1 , GCFiles . at ( 0 ) - > m_FileSize ) ;
2013-04-08 05:16:50 +00:00
}
2011-03-16 22:22:21 +00:00
m_Treectrl - > Expand ( RootId ) ;
2009-03-10 17:19:30 +00:00
}
2008-12-08 05:30:24 +00:00
}
CISOProperties : : ~ CISOProperties ( )
{
2011-03-16 22:22:21 +00:00
if ( ! IsVolumeWiiDisc ( OpenISO ) & & ! IsVolumeWadFile ( OpenISO ) & & pFileSystem )
delete pFileSystem ;
2010-02-14 14:06:33 +00:00
// two vector's items are no longer valid after deleting filesystem
WiiDisc . clear ( ) ;
GCFiles . clear ( ) ;
2010-02-12 19:28:51 +00:00
delete OpenGameListItem ;
2009-03-24 23:58:32 +00:00
delete OpenISO ;
2008-12-08 05:30:24 +00:00
}
2009-09-13 22:03:18 +00:00
size_t CISOProperties : : CreateDirectoryTree ( wxTreeItemId & parent ,
2011-03-16 22:22:21 +00:00
std : : vector < const DiscIO : : SFileInfo * > fileInfos ,
2013-10-29 05:23:17 +00:00
const size_t _FirstIndex ,
2011-03-16 22:22:21 +00:00
const size_t _LastIndex )
2008-12-08 05:30:24 +00:00
{
2009-09-13 22:03:18 +00:00
size_t CurrentIndex = _FirstIndex ;
2008-12-08 05:30:24 +00:00
2009-09-13 22:03:18 +00:00
while ( CurrentIndex < _LastIndex )
{
2014-03-15 03:38:14 +00:00
const DiscIO : : SFileInfo * rFileInfo = fileInfos [ CurrentIndex ] ;
std : : string filePath = rFileInfo - > m_FullPath ;
2008-12-08 05:30:24 +00:00
2014-03-15 03:38:14 +00:00
// Trim the trailing '/' if it exists.
if ( filePath [ filePath . length ( ) - 1 ] = = DIR_SEP_CHR )
2013-04-08 05:16:50 +00:00
{
2014-03-15 03:38:14 +00:00
filePath . pop_back ( ) ;
2013-04-08 05:16:50 +00:00
}
2014-03-15 03:38:14 +00:00
// Cut off the path up to the actual filename or folder.
// Say we have "/music/stream/stream1.strm", the result will be "stream1.strm".
size_t dirSepIndex = filePath . find_last_of ( DIR_SEP_CHR ) ;
if ( dirSepIndex ! = std : : string : : npos )
{
filePath = filePath . substr ( dirSepIndex + 1 ) ;
}
2008-12-08 05:30:24 +00:00
2009-09-13 22:03:18 +00:00
// check next index
if ( rFileInfo - > IsDirectory ( ) )
{
2014-03-15 03:38:14 +00:00
wxTreeItemId item = m_Treectrl - > AppendItem ( parent , StrToWxStr ( filePath ) , 1 , 1 ) ;
2009-09-13 22:03:18 +00:00
CurrentIndex = CreateDirectoryTree ( item , fileInfos , CurrentIndex + 1 , ( size_t ) rFileInfo - > m_FileSize ) ;
2008-12-08 05:30:24 +00:00
}
2009-09-13 22:03:18 +00:00
else
{
2014-03-15 03:38:14 +00:00
m_Treectrl - > AppendItem ( parent , StrToWxStr ( filePath ) , 2 , 2 ) ;
2009-09-13 22:03:18 +00:00
CurrentIndex + + ;
}
}
2008-12-08 05:30:24 +00:00
2009-09-13 22:03:18 +00:00
return CurrentIndex ;
2008-12-08 05:30:24 +00:00
}
2013-09-07 21:02:49 +00:00
long CISOProperties : : GetElementStyle ( const char * section , const char * key )
{
// Disable 3rd state if default gameini overrides the setting
if ( GameIniDefault . Exists ( section , key ) )
return 0 ;
return wxCHK_3STATE | wxCHK_ALLOW_3RD_STATE_FOR_USER ;
}
2009-06-07 02:54:07 +00:00
void CISOProperties : : CreateGUIControls ( bool IsWad )
2008-12-08 05:30:24 +00:00
{
2014-03-06 04:02:34 +00:00
wxButton * const EditConfig = new wxButton ( this , ID_EDITCONFIG , _ ( " Edit Config " ) ) ;
2009-06-07 02:54:07 +00:00
EditConfig - > SetToolTip ( _ ( " This will let you Manually Edit the INI config file " ) ) ;
2008-12-08 05:30:24 +00:00
2014-03-06 04:02:34 +00:00
wxButton * const EditConfigDefault = new wxButton ( this , ID_SHOWDEFAULTCONFIG , _ ( " Show Defaults " ) ) ;
2013-09-08 19:03:24 +00:00
EditConfigDefault - > SetToolTip ( _ ( " Opens the default (read-only) configuration for this game in an external text editor. " ) ) ;
2008-12-08 05:30:24 +00:00
// Notebook
2014-03-06 04:02:34 +00:00
wxNotebook * const m_Notebook = new wxNotebook ( this , ID_NOTEBOOK ) ;
wxPanel * const m_GameConfig = new wxPanel ( m_Notebook , ID_GAMECONFIG ) ;
2008-12-08 05:30:24 +00:00
m_Notebook - > AddPage ( m_GameConfig , _ ( " GameConfig " ) ) ;
2014-03-06 04:02:34 +00:00
wxPanel * const m_PatchPage = new wxPanel ( m_Notebook , ID_PATCH_PAGE ) ;
2009-03-24 23:10:43 +00:00
m_Notebook - > AddPage ( m_PatchPage , _ ( " Patches " ) ) ;
2014-03-06 04:02:34 +00:00
wxPanel * const m_CheatPage = new wxPanel ( m_Notebook , ID_ARCODE_PAGE ) ;
2009-03-24 23:10:43 +00:00
m_Notebook - > AddPage ( m_CheatPage , _ ( " AR Codes " ) ) ;
2010-07-22 01:48:48 +00:00
m_geckocode_panel = new Gecko : : CodeConfigPanel ( m_Notebook ) ;
2011-01-05 04:35:46 +00:00
m_Notebook - > AddPage ( m_geckocode_panel , _ ( " Gecko Codes " ) ) ;
2014-03-06 04:02:34 +00:00
wxPanel * const m_Information = new wxPanel ( m_Notebook , ID_INFORMATION ) ;
2008-12-08 05:30:24 +00:00
m_Notebook - > AddPage ( m_Information , _ ( " Info " ) ) ;
2009-02-14 17:32:03 +00:00
2009-03-24 23:10:43 +00:00
// GameConfig editing - Overrides and emulation state
2014-03-06 04:02:34 +00:00
wxStaticText * const OverrideText = new wxStaticText ( m_GameConfig , wxID_ANY , _ ( " These settings override core Dolphin settings. \n Undetermined means the game uses Dolphin's setting. " ) ) ;
2013-09-07 21:02:49 +00:00
2009-03-24 23:10:43 +00:00
// Core
2014-03-06 04:02:34 +00:00
CPUThread = new wxCheckBox ( m_GameConfig , ID_USEDUALCORE , _ ( " Enable Dual Core " ) , wxDefaultPosition , wxDefaultSize , GetElementStyle ( " Core " , " CPUThread " ) ) ;
SkipIdle = new wxCheckBox ( m_GameConfig , ID_IDLESKIP , _ ( " Enable Idle Skipping " ) , wxDefaultPosition , wxDefaultSize , GetElementStyle ( " Core " , " SkipIdle " ) ) ;
MMU = new wxCheckBox ( m_GameConfig , ID_MMU , _ ( " Enable MMU " ) , wxDefaultPosition , wxDefaultSize , GetElementStyle ( " Core " , " MMU " ) ) ;
2011-01-05 04:35:46 +00:00
MMU - > SetToolTip ( _ ( " Enables the Memory Management Unit, needed for some games. (ON = Compatible, OFF = Fast) " ) ) ;
2014-03-06 04:02:34 +00:00
TLBHack = new wxCheckBox ( m_GameConfig , ID_TLBHACK , _ ( " MMU Speed Hack " ) , wxDefaultPosition , wxDefaultSize , GetElementStyle ( " Core " , " TLBHack " ) ) ;
2011-01-05 04:35:46 +00:00
TLBHack - > SetToolTip ( _ ( " Fast version of the MMU. Does not work for every game. " ) ) ;
2014-03-06 04:02:34 +00:00
DCBZOFF = new wxCheckBox ( m_GameConfig , ID_DCBZOFF , _ ( " Skip DCBZ clearing " ) , wxDefaultPosition , wxDefaultSize , GetElementStyle ( " Core " , " DCBZ " ) ) ;
2013-01-20 02:09:38 +00:00
DCBZOFF - > SetToolTip ( _ ( " Bypass the clearing of the data cache by the DCBZ instruction. Usually leave this option disabled. " ) ) ;
2014-03-06 04:02:34 +00:00
VBeam = new wxCheckBox ( m_GameConfig , ID_VBEAM , _ ( " VBeam Speed Hack " ) , wxDefaultPosition , wxDefaultSize , GetElementStyle ( " Core " , " VBeam " ) ) ;
2013-04-15 10:23:25 +00:00
VBeam - > SetToolTip ( _ ( " Doubles the emulated GPU clock rate. May speed up some games (ON = Fast, OFF = Compatible) " ) ) ;
2014-03-06 04:02:34 +00:00
SyncGPU = new wxCheckBox ( m_GameConfig , ID_SYNCGPU , _ ( " Synchronize GPU thread " ) , wxDefaultPosition , wxDefaultSize , GetElementStyle ( " Core " , " SyncGPU " ) ) ;
2013-03-29 16:05:22 +00:00
SyncGPU - > SetToolTip ( _ ( " Synchronizes the GPU and CPU threads to help prevent random freezes in Dual Core mode. (ON = Compatible, OFF = Fast) " ) ) ;
2014-03-06 04:02:34 +00:00
FastDiscSpeed = new wxCheckBox ( m_GameConfig , ID_DISCSPEED , _ ( " Speed up Disc Transfer Rate " ) , wxDefaultPosition , wxDefaultSize , GetElementStyle ( " Core " , " FastDiscSpeed " ) ) ;
2011-01-05 04:35:46 +00:00
FastDiscSpeed - > SetToolTip ( _ ( " Enable fast disc access. Needed for a few games. (ON = Fast, OFF = Compatible) " ) ) ;
2014-03-06 04:02:34 +00:00
BlockMerging = new wxCheckBox ( m_GameConfig , ID_MERGEBLOCKS , _ ( " Enable Block Merging " ) , wxDefaultPosition , wxDefaultSize , GetElementStyle ( " Core " , " BlockMerging " ) ) ;
DSPHLE = new wxCheckBox ( m_GameConfig , ID_AUDIO_DSP_HLE , _ ( " DSP HLE emulation (fast) " ) , wxDefaultPosition , wxDefaultSize , GetElementStyle ( " Core " , " DSPHLE " ) ) ;
2010-09-14 13:50:25 +00:00
2009-03-24 23:10:43 +00:00
// Wii Console
2014-03-06 04:02:34 +00:00
EnableWideScreen = new wxCheckBox ( m_GameConfig , ID_ENABLEWIDESCREEN , _ ( " Enable WideScreen " ) , wxDefaultPosition , wxDefaultSize , GetElementStyle ( " Wii " , " Widescreen " ) ) ;
2011-05-25 15:01:49 +00:00
2009-03-24 23:10:43 +00:00
// Video
2013-09-07 21:02:49 +00:00
UseBBox = new wxCheckBox ( m_GameConfig , ID_USE_BBOX , _ ( " Enable Bounding Box Calculation " ) , wxDefaultPosition , wxDefaultSize , GetElementStyle ( " Video " , " UseBBox " ) ) ;
2011-10-26 00:19:10 +00:00
UseBBox - > SetToolTip ( _ ( " If checked, the bounding box registers will be updated. Used by the Paper Mario games. " ) ) ;
2014-03-06 04:02:34 +00:00
wxBoxSizer * const sEmuState = new wxBoxSizer ( wxHORIZONTAL ) ;
wxStaticText * const EmuStateText = new wxStaticText ( m_GameConfig , wxID_ANY , _ ( " Emulation State: " ) ) ;
2008-12-08 05:30:24 +00:00
arrayStringFor_EmuState . Add ( _ ( " Not Set " ) ) ;
arrayStringFor_EmuState . Add ( _ ( " Broken " ) ) ;
arrayStringFor_EmuState . Add ( _ ( " Intro " ) ) ;
arrayStringFor_EmuState . Add ( _ ( " In Game " ) ) ;
2009-09-25 16:29:00 +00:00
arrayStringFor_EmuState . Add ( _ ( " Playable " ) ) ;
2008-12-08 05:30:24 +00:00
arrayStringFor_EmuState . Add ( _ ( " Perfect " ) ) ;
2014-03-06 04:02:34 +00:00
EmuState = new wxChoice ( m_GameConfig , ID_EMUSTATE , wxDefaultPosition , wxDefaultSize , arrayStringFor_EmuState ) ;
2011-03-16 22:22:21 +00:00
EmuIssues = new wxTextCtrl ( m_GameConfig , ID_EMU_ISSUES , wxEmptyString ) ;
2008-12-08 05:30:24 +00:00
2014-03-06 04:02:34 +00:00
wxBoxSizer * const sConfigPage = new wxBoxSizer ( wxVERTICAL ) ;
wxStaticBoxSizer * const sbCoreOverrides =
2011-03-16 22:22:21 +00:00
new wxStaticBoxSizer ( wxVERTICAL , m_GameConfig , _ ( " Core " ) ) ;
2011-02-04 23:44:11 +00:00
sbCoreOverrides - > Add ( CPUThread , 0 , wxLEFT , 5 ) ;
sbCoreOverrides - > Add ( SkipIdle , 0 , wxLEFT , 5 ) ;
sbCoreOverrides - > Add ( MMU , 0 , wxLEFT , 5 ) ;
sbCoreOverrides - > Add ( TLBHack , 0 , wxLEFT , 5 ) ;
2013-02-16 01:51:09 +00:00
sbCoreOverrides - > Add ( DCBZOFF , 0 , wxLEFT , 5 ) ;
2011-02-04 23:44:11 +00:00
sbCoreOverrides - > Add ( VBeam , 0 , wxLEFT , 5 ) ;
2013-02-16 01:51:09 +00:00
sbCoreOverrides - > Add ( SyncGPU , 0 , wxLEFT , 5 ) ;
2013-10-29 05:23:17 +00:00
sbCoreOverrides - > Add ( FastDiscSpeed , 0 , wxLEFT , 5 ) ;
2011-02-04 23:44:11 +00:00
sbCoreOverrides - > Add ( BlockMerging , 0 , wxLEFT , 5 ) ;
sbCoreOverrides - > Add ( DSPHLE , 0 , wxLEFT , 5 ) ;
2011-01-31 22:19:30 +00:00
2014-03-06 04:02:34 +00:00
wxStaticBoxSizer * const sbWiiOverrides = new wxStaticBoxSizer ( wxVERTICAL , m_GameConfig , _ ( " Wii Console " ) ) ;
2011-01-31 22:19:30 +00:00
if ( ! DiscIO : : IsVolumeWiiDisc ( OpenISO ) & & ! DiscIO : : IsVolumeWadFile ( OpenISO ) )
{
sbWiiOverrides - > ShowItems ( false ) ;
EnableWideScreen - > Hide ( ) ;
}
2011-02-04 23:44:11 +00:00
sbWiiOverrides - > Add ( EnableWideScreen , 0 , wxLEFT , 5 ) ;
2011-01-31 22:19:30 +00:00
2014-03-06 04:02:34 +00:00
wxStaticBoxSizer * const sbVideoOverrides = new wxStaticBoxSizer ( wxVERTICAL , m_GameConfig , _ ( " Video " ) ) ;
2011-10-26 00:19:10 +00:00
sbVideoOverrides - > Add ( UseBBox , 0 , wxLEFT , 5 ) ;
2010-07-18 15:47:28 +00:00
2014-03-06 04:02:34 +00:00
wxStaticBoxSizer * const sbGameConfig = new wxStaticBoxSizer ( wxVERTICAL , m_GameConfig , _ ( " Game-Specific Settings " ) ) ;
2011-01-31 22:19:30 +00:00
sbGameConfig - > Add ( OverrideText , 0 , wxEXPAND | wxALL , 5 ) ;
2009-03-24 23:10:43 +00:00
sbGameConfig - > Add ( sbCoreOverrides , 0 , wxEXPAND ) ;
sbGameConfig - > Add ( sbWiiOverrides , 0 , wxEXPAND ) ;
sbGameConfig - > Add ( sbVideoOverrides , 0 , wxEXPAND ) ;
sConfigPage - > Add ( sbGameConfig , 0 , wxEXPAND | wxALL , 5 ) ;
sEmuState - > Add ( EmuStateText , 0 , wxALIGN_CENTER_VERTICAL ) ;
sEmuState - > Add ( EmuState , 0 , wxEXPAND ) ;
2011-01-29 21:13:56 +00:00
sEmuState - > Add ( EmuIssues , 1 , wxEXPAND ) ;
2009-03-24 23:10:43 +00:00
sConfigPage - > Add ( sEmuState , 0 , wxEXPAND | wxALL , 5 ) ;
m_GameConfig - > SetSizer ( sConfigPage ) ;
2013-10-29 05:23:17 +00:00
2008-12-08 05:30:24 +00:00
// Patches
2014-03-06 04:02:34 +00:00
wxBoxSizer * const sPatches = new wxBoxSizer ( wxVERTICAL ) ;
Patches = new wxCheckListBox ( m_PatchPage , ID_PATCHES_LIST , wxDefaultPosition , wxDefaultSize , arrayStringFor_Patches , wxLB_HSCROLL ) ;
wxBoxSizer * const sPatchButtons = new wxBoxSizer ( wxHORIZONTAL ) ;
2011-03-16 22:22:21 +00:00
EditPatch = new wxButton ( m_PatchPage , ID_EDITPATCH , _ ( " Edit... " ) ) ;
2014-03-06 04:02:34 +00:00
wxButton * const AddPatch = new wxButton ( m_PatchPage , ID_ADDPATCH , _ ( " Add... " ) ) ;
2011-03-16 22:22:21 +00:00
RemovePatch = new wxButton ( m_PatchPage , ID_REMOVEPATCH , _ ( " Remove " ) ) ;
2008-12-08 05:30:24 +00:00
EditPatch - > Enable ( false ) ;
RemovePatch - > Enable ( false ) ;
2011-03-16 22:22:21 +00:00
wxBoxSizer * sPatchPage = new wxBoxSizer ( wxVERTICAL ) ;
2008-12-08 05:30:24 +00:00
sPatches - > Add ( Patches , 1 , wxEXPAND | wxALL , 0 ) ;
sPatchButtons - > Add ( EditPatch , 0 , wxEXPAND | wxALL , 0 ) ;
sPatchButtons - > AddStretchSpacer ( ) ;
sPatchButtons - > Add ( AddPatch , 0 , wxEXPAND | wxALL , 0 ) ;
sPatchButtons - > Add ( RemovePatch , 0 , wxEXPAND | wxALL , 0 ) ;
sPatches - > Add ( sPatchButtons , 0 , wxEXPAND | wxALL , 0 ) ;
2009-03-24 23:10:43 +00:00
sPatchPage - > Add ( sPatches , 1 , wxEXPAND | wxALL , 5 ) ;
2008-12-08 05:30:24 +00:00
m_PatchPage - > SetSizer ( sPatchPage ) ;
2013-10-29 05:23:17 +00:00
2009-03-24 23:10:43 +00:00
// Action Replay Cheats
2011-03-16 22:22:21 +00:00
wxBoxSizer * const sCheats = new wxBoxSizer ( wxVERTICAL ) ;
2014-03-06 04:02:34 +00:00
Cheats = new wxCheckListBox ( m_CheatPage , ID_CHEATS_LIST , wxDefaultPosition , wxDefaultSize , arrayStringFor_Cheats , wxLB_HSCROLL ) ;
2011-03-16 22:22:21 +00:00
wxBoxSizer * const sCheatButtons = new wxBoxSizer ( wxHORIZONTAL ) ;
EditCheat = new wxButton ( m_CheatPage , ID_EDITCHEAT , _ ( " Edit... " ) ) ;
wxButton * const AddCheat = new wxButton ( m_CheatPage , ID_ADDCHEAT , _ ( " Add... " ) ) ;
2014-03-06 04:02:34 +00:00
RemoveCheat = new wxButton ( m_CheatPage , ID_REMOVECHEAT , _ ( " Remove " ) ) ;
2009-03-24 23:10:43 +00:00
EditCheat - > Enable ( false ) ;
RemoveCheat - > Enable ( false ) ;
2011-03-16 22:22:21 +00:00
wxBoxSizer * sCheatPage = new wxBoxSizer ( wxVERTICAL ) ;
2008-12-08 05:30:24 +00:00
sCheats - > Add ( Cheats , 1 , wxEXPAND | wxALL , 0 ) ;
sCheatButtons - > Add ( EditCheat , 0 , wxEXPAND | wxALL , 0 ) ;
sCheatButtons - > AddStretchSpacer ( ) ;
sCheatButtons - > Add ( AddCheat , 0 , wxEXPAND | wxALL , 0 ) ;
sCheatButtons - > Add ( RemoveCheat , 0 , wxEXPAND | wxALL , 0 ) ;
sCheats - > Add ( sCheatButtons , 0 , wxEXPAND | wxALL , 0 ) ;
2009-03-24 23:10:43 +00:00
sCheatPage - > Add ( sCheats , 1 , wxEXPAND | wxALL , 5 ) ;
2008-12-08 05:30:24 +00:00
m_CheatPage - > SetSizer ( sCheatPage ) ;
2013-10-29 05:23:17 +00:00
2014-03-06 04:02:34 +00:00
wxStaticText * const m_NameText = new wxStaticText ( m_Information , wxID_ANY , _ ( " Name: " ) ) ;
m_Name = new wxTextCtrl ( m_Information , ID_NAME , wxEmptyString , wxDefaultPosition , wxDefaultSize , wxTE_READONLY ) ;
wxStaticText * const m_GameIDText = new wxStaticText ( m_Information , wxID_ANY , _ ( " Game ID: " ) ) ;
m_GameID = new wxTextCtrl ( m_Information , ID_GAMEID , wxEmptyString , wxDefaultPosition , wxDefaultSize , wxTE_READONLY ) ;
wxStaticText * const m_CountryText = new wxStaticText ( m_Information , wxID_ANY , _ ( " Country: " ) ) ;
m_Country = new wxTextCtrl ( m_Information , ID_COUNTRY , wxEmptyString , wxDefaultPosition , wxDefaultSize , wxTE_READONLY ) ;
wxStaticText * const m_MakerIDText = new wxStaticText ( m_Information , wxID_ANY , _ ( " Maker ID: " ) ) ;
m_MakerID = new wxTextCtrl ( m_Information , ID_MAKERID , wxEmptyString , wxDefaultPosition , wxDefaultSize , wxTE_READONLY ) ;
wxStaticText * const m_RevisionText = new wxStaticText ( m_Information , wxID_ANY , _ ( " Revision: " ) ) ;
m_Revision = new wxTextCtrl ( m_Information , ID_REVISION , wxEmptyString , wxDefaultPosition , wxDefaultSize , wxTE_READONLY ) ;
wxStaticText * const m_DateText = new wxStaticText ( m_Information , wxID_ANY , _ ( " Date: " ) ) ;
m_Date = new wxTextCtrl ( m_Information , ID_DATE , wxEmptyString , wxDefaultPosition , wxDefaultSize , wxTE_READONLY ) ;
wxStaticText * const m_FSTText = new wxStaticText ( m_Information , wxID_ANY , _ ( " FST Size: " ) ) ;
m_FST = new wxTextCtrl ( m_Information , ID_FST , wxEmptyString , wxDefaultPosition , wxDefaultSize , wxTE_READONLY ) ;
2014-04-12 10:50:12 +00:00
wxStaticText * const m_MD5SumText = new wxStaticText ( m_Information , wxID_ANY , _ ( " MD5 Checksum: " ) ) ;
m_MD5Sum = new wxTextCtrl ( m_Information , ID_MD5SUM , wxEmptyString , wxDefaultPosition , wxDefaultSize , wxTE_READONLY ) ;
m_MD5SumCompute = new wxButton ( m_Information , ID_MD5SUMCOMPUTE , _ ( " Compute " ) ) ;
2014-03-06 04:02:34 +00:00
wxStaticText * const m_LangText = new wxStaticText ( m_Information , wxID_ANY , _ ( " Show Language: " ) ) ;
2008-12-08 05:30:24 +00:00
arrayStringFor_Lang . Add ( _ ( " English " ) ) ;
arrayStringFor_Lang . Add ( _ ( " German " ) ) ;
arrayStringFor_Lang . Add ( _ ( " French " ) ) ;
arrayStringFor_Lang . Add ( _ ( " Spanish " ) ) ;
arrayStringFor_Lang . Add ( _ ( " Italian " ) ) ;
arrayStringFor_Lang . Add ( _ ( " Dutch " ) ) ;
2014-07-08 18:31:09 +00:00
int language = SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . SelectedLanguage ;
2013-09-14 22:07:53 +00:00
if ( IsWad )
{
arrayStringFor_Lang . Insert ( _ ( " Japanese " ) , 0 ) ;
arrayStringFor_Lang . Add ( _ ( " Simplified Chinese " ) ) ;
arrayStringFor_Lang . Add ( _ ( " Traditional Chinese " ) ) ;
arrayStringFor_Lang . Add ( _ ( " Korean " ) ) ;
2013-10-29 05:23:17 +00:00
2013-09-14 22:07:53 +00:00
language = SConfig : : GetInstance ( ) . m_SYSCONF - > GetData < u8 > ( " IPL.LNG " ) ;
}
2011-03-16 22:22:21 +00:00
m_Lang = new wxChoice ( m_Information , ID_LANG , wxDefaultPosition , wxDefaultSize , arrayStringFor_Lang ) ;
2013-09-14 22:07:53 +00:00
m_Lang - > SetSelection ( language ) ;
2013-10-29 05:23:17 +00:00
2014-03-06 04:02:34 +00:00
wxStaticText * const m_ShortText = new wxStaticText ( m_Information , wxID_ANY , _ ( " Short Name: " ) ) ;
2008-12-08 05:30:24 +00:00
m_ShortName = new wxTextCtrl ( m_Information , ID_SHORTNAME , wxEmptyString , wxDefaultPosition , wxDefaultSize , wxTE_READONLY ) ;
2014-03-06 04:02:34 +00:00
wxStaticText * const m_MakerText = new wxStaticText ( m_Information , wxID_ANY , _ ( " Maker: " ) ) ;
2008-12-08 05:30:24 +00:00
m_Maker = new wxTextCtrl ( m_Information , ID_MAKER , wxEmptyString , wxDefaultPosition , wxDefaultSize , wxTE_READONLY ) ;
2014-03-06 04:02:34 +00:00
wxStaticText * const m_CommentText = new wxStaticText ( m_Information , wxID_ANY , _ ( " Comment: " ) ) ;
2008-12-08 05:30:24 +00:00
m_Comment = new wxTextCtrl ( m_Information , ID_COMMENT , wxEmptyString , wxDefaultPosition , wxDefaultSize , wxTE_MULTILINE | wxTE_READONLY ) ;
2014-03-06 04:02:34 +00:00
wxStaticText * const m_BannerText = new wxStaticText ( m_Information , wxID_ANY , _ ( " Banner: " ) ) ;
m_Banner = new wxStaticBitmap ( m_Information , ID_BANNER , wxNullBitmap , wxDefaultPosition , wxSize ( 96 , 32 ) ) ;
2008-12-08 05:30:24 +00:00
2010-06-11 08:39:03 +00:00
// ISO Details
2014-03-06 04:02:34 +00:00
wxGridBagSizer * const sISODetails = new wxGridBagSizer ( 0 , 0 ) ;
2008-12-08 05:30:24 +00:00
sISODetails - > Add ( m_NameText , wxGBPosition ( 0 , 0 ) , wxGBSpan ( 1 , 1 ) , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
2014-04-12 10:50:12 +00:00
sISODetails - > Add ( m_Name , wxGBPosition ( 0 , 1 ) , wxGBSpan ( 1 , 2 ) , wxEXPAND | wxALL , 5 ) ;
2008-12-08 05:30:24 +00:00
sISODetails - > Add ( m_GameIDText , wxGBPosition ( 1 , 0 ) , wxGBSpan ( 1 , 1 ) , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
2014-04-12 10:50:12 +00:00
sISODetails - > Add ( m_GameID , wxGBPosition ( 1 , 1 ) , wxGBSpan ( 1 , 2 ) , wxEXPAND | wxALL , 5 ) ;
2008-12-08 05:30:24 +00:00
sISODetails - > Add ( m_CountryText , wxGBPosition ( 2 , 0 ) , wxGBSpan ( 1 , 1 ) , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
2014-04-12 10:50:12 +00:00
sISODetails - > Add ( m_Country , wxGBPosition ( 2 , 1 ) , wxGBSpan ( 1 , 2 ) , wxEXPAND | wxALL , 5 ) ;
2008-12-08 05:30:24 +00:00
sISODetails - > Add ( m_MakerIDText , wxGBPosition ( 3 , 0 ) , wxGBSpan ( 1 , 1 ) , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
2014-04-12 10:50:12 +00:00
sISODetails - > Add ( m_MakerID , wxGBPosition ( 3 , 1 ) , wxGBSpan ( 1 , 2 ) , wxEXPAND | wxALL , 5 ) ;
2013-04-17 03:29:01 +00:00
sISODetails - > Add ( m_RevisionText , wxGBPosition ( 4 , 0 ) , wxGBSpan ( 1 , 1 ) , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
2014-04-12 10:50:12 +00:00
sISODetails - > Add ( m_Revision , wxGBPosition ( 4 , 1 ) , wxGBSpan ( 1 , 2 ) , wxEXPAND | wxALL , 5 ) ;
2013-04-17 03:29:01 +00:00
sISODetails - > Add ( m_DateText , wxGBPosition ( 5 , 0 ) , wxGBSpan ( 1 , 1 ) , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
2014-04-12 10:50:12 +00:00
sISODetails - > Add ( m_Date , wxGBPosition ( 5 , 1 ) , wxGBSpan ( 1 , 2 ) , wxEXPAND | wxALL , 5 ) ;
2013-04-17 03:29:01 +00:00
sISODetails - > Add ( m_FSTText , wxGBPosition ( 6 , 0 ) , wxGBSpan ( 1 , 1 ) , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
2014-04-12 10:50:12 +00:00
sISODetails - > Add ( m_FST , wxGBPosition ( 6 , 1 ) , wxGBSpan ( 1 , 2 ) , wxEXPAND | wxALL , 5 ) ;
sISODetails - > Add ( m_MD5SumText , wxGBPosition ( 7 , 0 ) , wxGBSpan ( 1 , 1 ) , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
sISODetails - > Add ( m_MD5Sum , wxGBPosition ( 7 , 1 ) , wxGBSpan ( 1 , 1 ) , wxEXPAND | wxALL , 5 ) ;
wxSizer * sMD5SumButtonSizer = CreateButtonSizer ( wxNO_DEFAULT ) ;
sMD5SumButtonSizer - > Add ( m_MD5SumCompute ) ;
sISODetails - > Add ( sMD5SumButtonSizer , wxGBPosition ( 7 , 2 ) , wxGBSpan ( 1 , 1 ) , wxEXPAND | wxALL , 5 ) ;
2010-06-14 22:01:10 +00:00
sISODetails - > AddGrowableCol ( 1 ) ;
2014-03-06 04:02:34 +00:00
wxStaticBoxSizer * const sbISODetails =
2011-03-16 22:22:21 +00:00
new wxStaticBoxSizer ( wxVERTICAL , m_Information , _ ( " ISO Details " ) ) ;
2008-12-08 05:30:24 +00:00
sbISODetails - > Add ( sISODetails , 0 , wxEXPAND , 5 ) ;
2009-02-14 17:32:03 +00:00
2010-06-11 08:39:03 +00:00
// Banner Details
2014-03-06 04:02:34 +00:00
wxGridBagSizer * const sBannerDetails = new wxGridBagSizer ( 0 , 0 ) ;
2009-02-14 17:32:03 +00:00
sBannerDetails - > Add ( m_LangText , wxGBPosition ( 0 , 0 ) , wxGBSpan ( 1 , 1 ) , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
sBannerDetails - > Add ( m_Lang , wxGBPosition ( 0 , 1 ) , wxGBSpan ( 1 , 1 ) , wxEXPAND | wxALL , 5 ) ;
2008-12-08 05:30:24 +00:00
sBannerDetails - > Add ( m_ShortText , wxGBPosition ( 1 , 0 ) , wxGBSpan ( 1 , 1 ) , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
2009-02-14 17:32:03 +00:00
sBannerDetails - > Add ( m_ShortName , wxGBPosition ( 1 , 1 ) , wxGBSpan ( 1 , 1 ) , wxEXPAND | wxALL , 5 ) ;
sBannerDetails - > Add ( m_MakerText , wxGBPosition ( 2 , 0 ) , wxGBSpan ( 1 , 1 ) , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
sBannerDetails - > Add ( m_Maker , wxGBPosition ( 2 , 1 ) , wxGBSpan ( 1 , 1 ) , wxEXPAND | wxALL , 5 ) ;
sBannerDetails - > Add ( m_CommentText , wxGBPosition ( 3 , 0 ) , wxGBSpan ( 1 , 1 ) , wxALL , 5 ) ;
sBannerDetails - > Add ( m_Comment , wxGBPosition ( 3 , 1 ) , wxGBSpan ( 1 , 1 ) , wxEXPAND | wxALL , 5 ) ;
sBannerDetails - > Add ( m_BannerText , wxGBPosition ( 4 , 0 ) , wxGBSpan ( 1 , 1 ) , wxALL , 5 ) ;
sBannerDetails - > Add ( m_Banner , wxGBPosition ( 4 , 1 ) , wxGBSpan ( 1 , 1 ) , wxEXPAND | wxALL , 5 ) ;
2010-06-11 08:39:03 +00:00
sBannerDetails - > AddGrowableCol ( 1 ) ;
2014-03-06 04:02:34 +00:00
wxStaticBoxSizer * const sbBannerDetails =
2011-03-16 22:22:21 +00:00
new wxStaticBoxSizer ( wxVERTICAL , m_Information , _ ( " Banner Details " ) ) ;
2010-06-11 08:39:03 +00:00
sbBannerDetails - > Add ( sBannerDetails , 0 , wxEXPAND , 5 ) ;
2014-03-06 04:02:34 +00:00
wxBoxSizer * const sInfoPage = new wxBoxSizer ( wxVERTICAL ) ;
2008-12-08 05:30:24 +00:00
sInfoPage - > Add ( sbISODetails , 0 , wxEXPAND | wxALL , 5 ) ;
sInfoPage - > Add ( sbBannerDetails , 0 , wxEXPAND | wxALL , 5 ) ;
m_Information - > SetSizer ( sInfoPage ) ;
2009-03-24 23:10:43 +00:00
2011-03-16 22:22:21 +00:00
if ( ! IsWad )
{
2014-03-06 04:02:34 +00:00
wxPanel * const m_Filesystem = new wxPanel ( m_Notebook , ID_FILESYSTEM ) ;
2011-03-16 22:22:21 +00:00
m_Notebook - > AddPage ( m_Filesystem , _ ( " Filesystem " ) ) ;
// Filesystem icons
2014-03-06 04:02:34 +00:00
wxImageList * const m_iconList = new wxImageList ( 16 , 16 ) ;
2014-02-17 04:51:41 +00:00
m_iconList - > Add ( wxBitmap ( disc_xpm ) , wxNullBitmap ) ; // 0
m_iconList - > Add ( wxBitmap ( folder_xpm ) , wxNullBitmap ) ; // 1
m_iconList - > Add ( wxBitmap ( file_xpm ) , wxNullBitmap ) ; // 2
2011-03-16 22:22:21 +00:00
// Filesystem tree
2014-03-06 04:02:34 +00:00
m_Treectrl = new wxTreeCtrl ( m_Filesystem , ID_TREECTRL ) ;
2011-03-16 22:22:21 +00:00
m_Treectrl - > AssignImageList ( m_iconList ) ;
2014-03-09 20:14:26 +00:00
RootId = m_Treectrl - > AddRoot ( _ ( " Disc " ) , 0 , 0 , nullptr ) ;
2011-03-16 22:22:21 +00:00
wxBoxSizer * sTreePage = new wxBoxSizer ( wxVERTICAL ) ;
sTreePage - > Add ( m_Treectrl , 1 , wxEXPAND | wxALL , 5 ) ;
m_Filesystem - > SetSizer ( sTreePage ) ;
}
2008-12-08 05:30:24 +00:00
2011-03-16 22:22:21 +00:00
wxSizer * sButtons = CreateButtonSizer ( wxNO_DEFAULT ) ;
2013-09-08 19:03:24 +00:00
sButtons - > Prepend ( EditConfigDefault ) ;
2011-06-03 12:26:32 +00:00
sButtons - > Prepend ( EditConfig ) ;
sButtons - > Add ( new wxButton ( this , wxID_OK , _ ( " Close " ) ) ) ;
2009-06-07 02:54:07 +00:00
2013-09-07 21:02:49 +00:00
// If there is no default gameini, disable the button.
if ( ! File : : Exists ( GameIniFileDefault ) )
EditConfigDefault - > Disable ( ) ;
2009-03-24 23:10:43 +00:00
// Add notebook and buttons to the dialog
2014-03-06 04:02:34 +00:00
wxBoxSizer * sMain = new wxBoxSizer ( wxVERTICAL ) ;
2009-02-14 17:32:03 +00:00
sMain - > Add ( m_Notebook , 1 , wxEXPAND | wxALL , 5 ) ;
2011-06-03 12:26:32 +00:00
sMain - > Add ( sButtons , 0 , wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM , 5 ) ;
2011-03-16 22:22:21 +00:00
sMain - > SetMinSize ( wxSize ( 500 , - 1 ) ) ;
2010-06-14 22:01:10 +00:00
2009-02-14 17:32:03 +00:00
SetSizerAndFit ( sMain ) ;
2011-03-15 21:57:00 +00:00
Center ( ) ;
2011-03-16 22:22:21 +00:00
SetFocus ( ) ;
2008-12-08 05:30:24 +00:00
}
void CISOProperties : : OnClose ( wxCloseEvent & WXUNUSED ( event ) )
{
if ( ! SaveGameConfig ( ) )
2014-07-25 01:46:46 +00:00
WxUtils : : ShowErrorDialog ( wxString : : Format ( _ ( " Could not save %s. " ) , GameIniFileLocal . c_str ( ) ) ) ;
2008-12-08 05:30:24 +00:00
2009-01-28 10:21:18 +00:00
EndModal ( bRefreshList ? wxID_OK : wxID_CANCEL ) ;
2008-12-08 05:30:24 +00:00
}
void CISOProperties : : OnCloseClick ( wxCommandEvent & WXUNUSED ( event ) )
{
Close ( ) ;
}
void CISOProperties : : RightClickOnBanner ( wxMouseEvent & event )
{
2009-11-23 08:05:54 +00:00
wxMenu * popupMenu = new wxMenu ;
popupMenu - > Append ( IDM_BNRSAVEAS , _ ( " Save as... " ) ) ;
PopupMenu ( popupMenu ) ;
2008-12-08 05:30:24 +00:00
event . Skip ( ) ;
}
void CISOProperties : : OnBannerImageSave ( wxCommandEvent & WXUNUSED ( event ) )
{
wxString dirHome ;
2014-05-17 17:17:28 +00:00
wxFileDialog dialog ( this , _ ( " Save as... " ) , wxGetHomeDir ( & dirHome ) , wxString : : Format ( " %s.png " , m_GameID - > GetLabel ( ) . c_str ( ) ) ,
2014-03-06 04:02:34 +00:00
wxALL_FILES_PATTERN , wxFD_SAVE | wxFD_OVERWRITE_PROMPT ) ;
2008-12-08 05:30:24 +00:00
if ( dialog . ShowModal ( ) = = wxID_OK )
{
m_Banner - > GetBitmap ( ) . ConvertToImage ( ) . SaveFile ( dialog . GetPath ( ) ) ;
}
}
void CISOProperties : : OnRightClickOnTree ( wxTreeEvent & event )
{
m_Treectrl - > SelectItem ( event . GetItem ( ) ) ;
2009-11-23 08:05:54 +00:00
wxMenu * popupMenu = new wxMenu ;
2009-09-13 22:03:18 +00:00
2014-03-10 11:30:55 +00:00
if ( m_Treectrl - > GetItemImage ( m_Treectrl - > GetSelection ( ) ) = = 0 & &
m_Treectrl - > GetFirstVisibleItem ( ) ! = m_Treectrl - > GetSelection ( ) )
2013-06-17 10:51:15 +00:00
{
2009-11-23 08:05:54 +00:00
popupMenu - > Append ( IDM_EXTRACTDIR , _ ( " Extract Partition... " ) ) ;
2013-06-17 10:51:15 +00:00
}
2009-09-13 22:03:18 +00:00
else if ( m_Treectrl - > GetItemImage ( m_Treectrl - > GetSelection ( ) ) = = 1 )
2014-03-06 04:02:34 +00:00
{
2009-11-23 08:05:54 +00:00
popupMenu - > Append ( IDM_EXTRACTDIR , _ ( " Extract Directory... " ) ) ;
2014-03-06 04:02:34 +00:00
}
2009-09-13 22:03:18 +00:00
else if ( m_Treectrl - > GetItemImage ( m_Treectrl - > GetSelection ( ) ) = = 2 )
2014-03-06 04:02:34 +00:00
{
2009-11-23 08:05:54 +00:00
popupMenu - > Append ( IDM_EXTRACTFILE , _ ( " Extract File... " ) ) ;
2014-03-06 04:02:34 +00:00
}
2013-10-29 05:23:17 +00:00
2009-11-23 08:05:54 +00:00
popupMenu - > Append ( IDM_EXTRACTALL , _ ( " Extract All Files... " ) ) ;
2013-10-29 05:23:17 +00:00
2014-03-17 07:04:22 +00:00
if ( ! DiscIO : : IsVolumeWiiDisc ( OpenISO ) | |
( m_Treectrl - > GetItemImage ( m_Treectrl - > GetSelection ( ) ) = = 0 & &
m_Treectrl - > GetFirstVisibleItem ( ) ! = m_Treectrl - > GetSelection ( ) ) )
2012-05-04 10:49:10 +00:00
{
2013-06-17 10:51:15 +00:00
popupMenu - > AppendSeparator ( ) ;
popupMenu - > Append ( IDM_EXTRACTAPPLOADER , _ ( " Extract Apploader... " ) ) ;
popupMenu - > Append ( IDM_EXTRACTDOL , _ ( " Extract DOL... " ) ) ;
2014-03-17 07:04:22 +00:00
}
if ( m_Treectrl - > GetItemImage ( m_Treectrl - > GetSelection ( ) ) = = 0 & &
m_Treectrl - > GetFirstVisibleItem ( ) ! = m_Treectrl - > GetSelection ( ) )
{
2012-05-04 10:49:10 +00:00
popupMenu - > AppendSeparator ( ) ;
popupMenu - > Append ( IDM_CHECKINTEGRITY , _ ( " Check Partition Integrity " ) ) ;
}
2013-10-29 05:23:17 +00:00
2009-11-23 08:05:54 +00:00
PopupMenu ( popupMenu ) ;
2008-12-08 05:30:24 +00:00
event . Skip ( ) ;
}
void CISOProperties : : OnExtractFile ( wxCommandEvent & WXUNUSED ( event ) )
{
2014-03-06 04:02:34 +00:00
wxString File = m_Treectrl - > GetItemText ( m_Treectrl - > GetSelection ( ) ) ;
2013-10-29 05:23:17 +00:00
2014-03-06 04:02:34 +00:00
wxString Path = wxFileSelector (
2011-01-05 04:35:46 +00:00
_ ( " Export File " ) ,
2008-12-08 05:30:24 +00:00
wxEmptyString , File , wxEmptyString ,
2011-01-06 13:57:46 +00:00
wxGetTranslation ( wxALL_FILES ) ,
2008-12-08 05:30:24 +00:00
wxFD_SAVE ,
this ) ;
if ( ! Path | | ! File )
return ;
while ( m_Treectrl - > GetItemParent ( m_Treectrl - > GetSelection ( ) ) ! = m_Treectrl - > GetRootItem ( ) )
{
2014-03-06 04:02:34 +00:00
wxString temp = m_Treectrl - > GetItemText ( m_Treectrl - > GetItemParent ( m_Treectrl - > GetSelection ( ) ) ) ;
2014-05-17 17:17:28 +00:00
File = temp + DIR_SEP_CHR + File ;
2008-12-08 05:30:24 +00:00
m_Treectrl - > SelectItem ( m_Treectrl - > GetItemParent ( m_Treectrl - > GetSelection ( ) ) ) ;
}
2009-03-10 17:19:30 +00:00
if ( DiscIO : : IsVolumeWiiDisc ( OpenISO ) )
{
2014-03-14 23:09:36 +00:00
int partitionNum = wxAtoi ( File . Mid ( File . find_first_of ( " / " ) - 1 , 1 ) ) ;
2014-07-13 18:29:03 +00:00
File . erase ( 0 , File . find_first_of ( " / " ) + 1 ) ; // Remove "Partition x/"
2014-03-12 19:33:41 +00:00
WiiDisc . at ( partitionNum ) . FileSystem - > ExportFile ( WxStrToStr ( File ) , WxStrToStr ( Path ) ) ;
2009-03-10 17:19:30 +00:00
}
else
2013-04-08 05:16:50 +00:00
{
2014-03-12 19:33:41 +00:00
pFileSystem - > ExportFile ( WxStrToStr ( File ) , WxStrToStr ( Path ) ) ;
2013-04-08 05:16:50 +00:00
}
2008-12-08 05:30:24 +00:00
}
2014-06-29 19:22:06 +00:00
void CISOProperties : : ExportDir ( const std : : string & _rFullPath , const std : : string & _rExportFolder , const int partitionNum )
2008-12-08 05:30:24 +00:00
{
2014-06-29 19:22:06 +00:00
DiscIO : : IFileSystem * const fs = DiscIO : : IsVolumeWiiDisc ( OpenISO ) ? WiiDisc [ partitionNum ] . FileSystem : pFileSystem ;
2009-09-13 09:03:38 +00:00
2014-06-29 19:22:06 +00:00
std : : vector < const DiscIO : : SFileInfo * > fst ;
fs - > GetFileList ( fst ) ;
2009-09-13 22:03:18 +00:00
2014-06-29 19:22:06 +00:00
u32 index = 0 ;
u32 size = 0 ;
2009-09-13 22:03:18 +00:00
2014-06-29 19:22:06 +00:00
// Extract all
if ( _rFullPath . empty ( ) )
2009-09-13 22:03:18 +00:00
{
2014-06-29 19:22:06 +00:00
index = 0 ;
size = ( u32 ) fst . size ( ) ;
2009-09-13 22:03:18 +00:00
2014-06-29 19:22:06 +00:00
fs - > ExportApploader ( _rExportFolder ) ;
2009-10-11 16:06:02 +00:00
if ( ! DiscIO : : IsVolumeWiiDisc ( OpenISO ) )
2014-06-29 19:22:06 +00:00
fs - > ExportDOL ( _rExportFolder ) ;
2009-09-13 22:03:18 +00:00
}
2014-06-29 19:22:06 +00:00
else
2009-09-13 22:03:18 +00:00
{
2014-06-29 19:22:06 +00:00
// Look for the dir we are going to extract
for ( index = 0 ; index ! = fst . size ( ) ; + + index )
2009-09-13 22:03:18 +00:00
{
2014-06-29 19:22:06 +00:00
if ( fst [ index ] - > m_FullPath = = _rFullPath )
2009-09-13 22:03:18 +00:00
{
2014-06-29 19:22:06 +00:00
DEBUG_LOG ( DISCIO , " Found the directory at %u " , index ) ;
size = ( u32 ) fst [ index ] - > m_FileSize ;
2009-09-13 22:03:18 +00:00
break ;
}
}
2014-06-29 19:22:06 +00:00
DEBUG_LOG ( DISCIO , " Directory found from %u to %u \n extracting to: \n %s " , index , size , _rExportFolder . c_str ( ) ) ;
2009-09-13 22:03:18 +00:00
}
2014-06-29 19:22:06 +00:00
wxString dialogTitle = ( index ! = 0 ) ? _ ( " Extracting Directory " ) : _ ( " Extracting All Files " ) ;
2012-03-25 03:59:20 +00:00
wxProgressDialog dialog (
dialogTitle ,
_ ( " Extracting... " ) ,
2014-06-29 19:22:06 +00:00
size - 1 ,
2012-03-25 03:59:20 +00:00
this ,
wxPD_APP_MODAL | wxPD_AUTO_HIDE | wxPD_CAN_ABORT |
wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME |
wxPD_SMOOTH
) ;
2009-09-13 22:03:18 +00:00
// Extraction
2014-06-29 19:22:06 +00:00
for ( u32 i = index ; i < size ; i + + )
2009-09-13 22:03:18 +00:00
{
2014-05-17 17:17:28 +00:00
dialog . SetTitle ( wxString : : Format ( " %s : %d%% " , dialogTitle . c_str ( ) ,
2014-06-29 19:22:06 +00:00
( u32 ) ( ( ( float ) ( i - index ) / ( float ) ( size - index ) ) * 100 ) ) ) ;
2013-10-29 05:23:17 +00:00
2014-03-15 03:38:14 +00:00
dialog . Update ( i , wxString : : Format ( _ ( " Extracting %s " ) , StrToWxStr ( fst [ i ] - > m_FullPath ) ) ) ;
2012-03-25 03:59:20 +00:00
if ( dialog . WasCancelled ( ) )
2009-09-13 22:03:18 +00:00
break ;
if ( fst [ i ] - > IsDirectory ( ) )
{
2014-06-29 19:22:06 +00:00
const std : : string exportName = StringFromFormat ( " %s/%s/ " , _rExportFolder . c_str ( ) , fst [ i ] - > m_FullPath . c_str ( ) ) ;
2014-03-15 03:38:14 +00:00
DEBUG_LOG ( DISCIO , " %s " , exportName . c_str ( ) ) ;
2009-09-13 22:03:18 +00:00
if ( ! File : : Exists ( exportName ) & & ! File : : CreateFullPath ( exportName ) )
{
2014-03-15 03:38:14 +00:00
ERROR_LOG ( DISCIO , " Could not create the path %s " , exportName . c_str ( ) ) ;
2009-09-13 22:03:18 +00:00
}
else
{
if ( ! File : : IsDirectory ( exportName ) )
2014-03-15 03:38:14 +00:00
ERROR_LOG ( DISCIO , " %s already exists and is not a directory " , exportName . c_str ( ) ) ;
2009-09-13 22:03:18 +00:00
2014-03-15 03:38:14 +00:00
DEBUG_LOG ( DISCIO , " Folder %s already exists " , exportName . c_str ( ) ) ;
2009-09-13 22:03:18 +00:00
}
}
else
{
2014-06-29 19:22:06 +00:00
const std : : string exportName = StringFromFormat ( " %s/%s " , _rExportFolder . c_str ( ) , fst [ i ] - > m_FullPath . c_str ( ) ) ;
2014-03-15 03:38:14 +00:00
DEBUG_LOG ( DISCIO , " %s " , exportName . c_str ( ) ) ;
2009-09-13 22:03:18 +00:00
2014-06-29 19:22:06 +00:00
if ( ! File : : Exists ( exportName ) & & ! fs - > ExportFile ( fst [ i ] - > m_FullPath , exportName ) )
2009-09-13 22:03:18 +00:00
{
2014-03-15 03:38:14 +00:00
ERROR_LOG ( DISCIO , " Could not export %s " , exportName . c_str ( ) ) ;
2009-09-13 22:03:18 +00:00
}
else
{
2014-03-15 03:38:14 +00:00
DEBUG_LOG ( DISCIO , " %s already exists " , exportName . c_str ( ) ) ;
2009-09-13 22:03:18 +00:00
}
}
}
}
void CISOProperties : : OnExtractDir ( wxCommandEvent & event )
{
wxString Directory = m_Treectrl - > GetItemText ( m_Treectrl - > GetSelection ( ) ) ;
2011-01-06 13:57:46 +00:00
wxString Path = wxDirSelector ( _ ( " Choose the folder to extract to " ) ) ;
2009-09-13 09:03:38 +00:00
if ( ! Path | | ! Directory )
return ;
2009-09-13 22:03:18 +00:00
if ( event . GetId ( ) = = IDM_EXTRACTALL )
{
if ( DiscIO : : IsVolumeWiiDisc ( OpenISO ) )
for ( u32 i = 0 ; i < WiiDisc . size ( ) ; i + + )
2014-07-14 03:43:41 +00:00
ExportDir ( " " , WxStrToStr ( Path ) , i ) ;
2009-09-13 22:03:18 +00:00
else
2014-07-14 03:43:41 +00:00
ExportDir ( " " , WxStrToStr ( Path ) ) ;
2009-09-13 22:03:18 +00:00
return ;
}
2009-09-13 09:03:38 +00:00
while ( m_Treectrl - > GetItemParent ( m_Treectrl - > GetSelection ( ) ) ! = m_Treectrl - > GetRootItem ( ) )
{
2014-03-15 03:38:14 +00:00
wxString temp = m_Treectrl - > GetItemText ( m_Treectrl - > GetItemParent ( m_Treectrl - > GetSelection ( ) ) ) ;
2014-05-17 17:17:28 +00:00
Directory = temp + DIR_SEP_CHR + Directory ;
2009-09-13 09:03:38 +00:00
m_Treectrl - > SelectItem ( m_Treectrl - > GetItemParent ( m_Treectrl - > GetSelection ( ) ) ) ;
}
2014-06-29 19:22:06 +00:00
Directory + = DIR_SEP_CHR ;
2009-09-13 09:03:38 +00:00
if ( DiscIO : : IsVolumeWiiDisc ( OpenISO ) )
{
2014-03-14 23:09:36 +00:00
int partitionNum = wxAtoi ( Directory . Mid ( Directory . find_first_of ( " / " ) - 1 , 1 ) ) ;
2014-07-13 18:29:03 +00:00
Directory . erase ( 0 , Directory . find_first_of ( " / " ) + 1 ) ; // Remove "Partition x/"
2014-06-29 19:22:06 +00:00
ExportDir ( WxStrToStr ( Directory ) , WxStrToStr ( Path ) , partitionNum ) ;
2009-09-13 09:03:38 +00:00
}
else
2013-04-08 05:16:50 +00:00
{
2014-06-29 19:22:06 +00:00
ExportDir ( WxStrToStr ( Directory ) , WxStrToStr ( Path ) ) ;
2013-04-08 05:16:50 +00:00
}
2009-09-12 09:09:47 +00:00
}
2009-12-29 13:59:38 +00:00
void CISOProperties : : OnExtractDataFromHeader ( wxCommandEvent & event )
{
2014-03-09 20:14:26 +00:00
DiscIO : : IFileSystem * FS = nullptr ;
2011-01-05 04:35:46 +00:00
wxString Path = wxDirSelector ( _ ( " Choose the folder to extract to " ) ) ;
2009-12-29 13:59:38 +00:00
if ( Path . empty ( ) )
return ;
if ( DiscIO : : IsVolumeWiiDisc ( OpenISO ) )
2013-06-17 10:51:15 +00:00
{
wxString Directory = m_Treectrl - > GetItemText ( m_Treectrl - > GetSelection ( ) ) ;
2014-03-28 03:55:30 +00:00
unsigned int partitionNum = wxAtoi ( Directory . Mid ( Directory . find_first_of ( " 0123456789 " ) , 2 ) ) ;
2013-10-29 05:23:17 +00:00
2014-03-10 11:30:55 +00:00
if ( WiiDisc . size ( ) > partitionNum )
2013-06-17 07:25:55 +00:00
{
// Get the filesystem of the LAST partition
2013-06-17 10:51:15 +00:00
FS = WiiDisc . at ( partitionNum ) . FileSystem ;
2013-06-17 07:25:55 +00:00
}
else
{
2014-07-25 01:46:46 +00:00
WxUtils : : ShowErrorDialog ( wxString : : Format ( _ ( " Partition doesn't exist: %d " ) , partitionNum ) ) ;
2013-06-17 07:25:55 +00:00
return ;
}
2013-06-17 10:51:15 +00:00
}
2009-12-29 13:59:38 +00:00
else
2013-06-17 10:51:15 +00:00
{
2009-12-29 13:59:38 +00:00
FS = pFileSystem ;
2013-06-17 10:51:15 +00:00
}
2013-10-29 05:23:17 +00:00
2009-12-29 13:59:38 +00:00
bool ret = false ;
if ( event . GetId ( ) = = IDM_EXTRACTAPPLOADER )
{
2014-03-12 19:33:41 +00:00
ret = FS - > ExportApploader ( WxStrToStr ( Path ) ) ;
2009-12-29 13:59:38 +00:00
}
else if ( event . GetId ( ) = = IDM_EXTRACTDOL )
{
2014-03-12 19:33:41 +00:00
ret = FS - > ExportDOL ( WxStrToStr ( Path ) ) ;
2009-12-29 13:59:38 +00:00
}
if ( ! ret )
2014-07-25 01:46:46 +00:00
WxUtils : : ShowErrorDialog ( wxString : : Format ( _ ( " Failed to extract to %s! " ) , WxStrToStr ( Path ) . c_str ( ) ) ) ;
2009-12-29 13:59:38 +00:00
}
2012-05-04 10:49:10 +00:00
class IntegrityCheckThread : public wxThread
{
public :
IntegrityCheckThread ( const WiiPartition & Partition )
: wxThread ( wxTHREAD_JOINABLE ) , m_Partition ( Partition )
{
Create ( ) ;
}
2013-10-29 05:34:26 +00:00
virtual ExitCode Entry ( ) override
2012-05-04 10:49:10 +00:00
{
return ( ExitCode ) m_Partition . Partition - > CheckIntegrity ( ) ;
}
private :
const WiiPartition & m_Partition ;
} ;
void CISOProperties : : CheckPartitionIntegrity ( wxCommandEvent & event )
{
// Normally we can't enter this function if we aren't analyzing a Wii disc
// anyway, but let's still check to be sure.
if ( ! DiscIO : : IsVolumeWiiDisc ( OpenISO ) )
return ;
wxString PartitionName = m_Treectrl - > GetItemText ( m_Treectrl - > GetSelection ( ) ) ;
if ( ! PartitionName )
return ;
// Get the partition number from the item text ("Partition N")
2013-03-13 11:04:53 +00:00
int PartitionNum = wxAtoi ( PartitionName . Mid ( PartitionName . find_first_of ( " 0123456789 " ) , 1 ) ) ;
2012-05-04 10:49:10 +00:00
const WiiPartition & Partition = WiiDisc [ PartitionNum ] ;
2014-07-13 19:04:25 +00:00
wxProgressDialog dialog ( _ ( " Checking integrity... " ) , _ ( " Working... " ) , 1000 , this ,
2012-05-04 10:49:10 +00:00
wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_SMOOTH
) ;
IntegrityCheckThread thread ( Partition ) ;
thread . Run ( ) ;
while ( thread . IsAlive ( ) )
{
2014-07-13 19:04:25 +00:00
dialog . Pulse ( ) ;
2012-05-04 10:49:10 +00:00
wxThread : : Sleep ( 50 ) ;
}
2014-07-13 19:04:25 +00:00
dialog . Destroy ( ) ;
2012-05-04 10:49:10 +00:00
if ( ! thread . Wait ( ) )
{
wxMessageBox (
wxString : : Format ( _ ( " Integrity check for partition %d failed. "
" Your dump is most likely corrupted or has been "
" patched incorrectly. " ) , PartitionNum ) ,
_ ( " Integrity Check Error " ) , wxOK | wxICON_ERROR , this
) ;
}
else
{
wxMessageBox ( _ ( " Integrity check completed. No errors have been found. " ) ,
_ ( " Integrity check completed " ) , wxOK | wxICON_INFORMATION , this ) ;
}
}
2009-03-24 23:10:43 +00:00
void CISOProperties : : SetRefresh ( wxCommandEvent & event )
2008-12-08 05:30:24 +00:00
{
2009-03-24 23:10:43 +00:00
bRefreshList = true ;
if ( event . GetId ( ) = = ID_EMUSTATE )
2009-09-25 16:29:00 +00:00
EmuIssues - > Enable ( event . GetSelection ( ) ! = 0 ) ;
2008-12-08 05:30:24 +00:00
}
2013-09-07 21:02:49 +00:00
void CISOProperties : : SetCheckboxValueFromGameini ( const char * section , const char * key , wxCheckBox * checkbox )
2008-12-08 05:30:24 +00:00
{
2013-09-07 21:02:49 +00:00
// Prefer local gameini value over default gameini value.
bool value ;
2014-06-16 05:12:43 +00:00
if ( GameIniLocal . GetOrCreateSection ( section ) - > Get ( key , & value ) )
2013-09-07 21:02:49 +00:00
checkbox - > Set3StateValue ( ( wxCheckBoxState ) value ) ;
2014-06-16 05:12:43 +00:00
else if ( GameIniDefault . GetOrCreateSection ( section ) - > Get ( key , & value ) )
2013-09-07 21:02:49 +00:00
checkbox - > Set3StateValue ( ( wxCheckBoxState ) value ) ;
2010-06-03 18:05:08 +00:00
else
2013-09-07 21:02:49 +00:00
checkbox - > Set3StateValue ( wxCHK_UNDETERMINED ) ;
}
2011-01-29 21:13:56 +00:00
2013-09-07 21:02:49 +00:00
void CISOProperties : : LoadGameConfig ( )
{
SetCheckboxValueFromGameini ( " Core " , " CPUThread " , CPUThread ) ;
SetCheckboxValueFromGameini ( " Core " , " SkipIdle " , SkipIdle ) ;
SetCheckboxValueFromGameini ( " Core " , " MMU " , MMU ) ;
SetCheckboxValueFromGameini ( " Core " , " TLBHack " , TLBHack ) ;
SetCheckboxValueFromGameini ( " Core " , " DCBZ " , DCBZOFF ) ;
SetCheckboxValueFromGameini ( " Core " , " VBeam " , VBeam ) ;
SetCheckboxValueFromGameini ( " Core " , " SyncGPU " , SyncGPU ) ;
SetCheckboxValueFromGameini ( " Core " , " FastDiscSpeed " , FastDiscSpeed ) ;
SetCheckboxValueFromGameini ( " Core " , " BlockMerging " , BlockMerging ) ;
SetCheckboxValueFromGameini ( " Core " , " DSPHLE " , DSPHLE ) ;
SetCheckboxValueFromGameini ( " Wii " , " Widescreen " , EnableWideScreen ) ;
SetCheckboxValueFromGameini ( " Video " , " UseBBox " , UseBBox ) ;
2014-06-16 05:12:43 +00:00
IniFile : : Section * default_video = GameIniDefault . GetOrCreateSection ( " Video " ) ;
2013-09-18 10:27:50 +00:00
int iTemp ;
2014-06-16 05:12:43 +00:00
default_video - > Get ( " ProjectionHack " , & iTemp ) ;
default_video - > Get ( " PH_SZNear " , & PHack_Data . PHackSZNear ) ;
2013-09-18 10:27:50 +00:00
if ( GameIniLocal . GetIfExists ( " Video " , " PH_SZNear " , & iTemp ) )
2014-02-12 15:00:34 +00:00
PHack_Data . PHackSZNear = ! ! iTemp ;
2014-06-16 05:12:43 +00:00
default_video - > Get ( " PH_SZFar " , & PHack_Data . PHackSZFar ) ;
2013-09-18 10:27:50 +00:00
if ( GameIniLocal . GetIfExists ( " Video " , " PH_SZFar " , & iTemp ) )
2014-02-12 15:00:34 +00:00
PHack_Data . PHackSZFar = ! ! iTemp ;
2013-09-07 21:02:49 +00:00
2013-09-17 14:44:47 +00:00
std : : string sTemp ;
2014-06-16 05:12:43 +00:00
default_video - > Get ( " PH_ZNear " , & PHack_Data . PHZNear ) ;
2013-09-18 10:27:50 +00:00
if ( GameIniLocal . GetIfExists ( " Video " , " PH_ZNear " , & sTemp ) )
2013-09-17 14:44:47 +00:00
PHack_Data . PHZNear = sTemp ;
2014-06-16 05:12:43 +00:00
default_video - > Get ( " PH_ZFar " , & PHack_Data . PHZFar ) ;
2013-09-18 10:27:50 +00:00
if ( GameIniLocal . GetIfExists ( " Video " , " PH_ZFar " , & sTemp ) )
2013-09-17 14:44:47 +00:00
PHack_Data . PHZFar = sTemp ;
2009-05-10 12:33:47 +00:00
2014-06-16 05:12:43 +00:00
IniFile : : Section * default_emustate = GameIniDefault . GetOrCreateSection ( " EmuState " ) ;
default_emustate - > Get ( " EmulationStateId " , & iTemp , 0 /*Not Set*/ ) ;
2008-12-08 05:30:24 +00:00
EmuState - > SetSelection ( iTemp ) ;
2013-09-18 10:27:50 +00:00
if ( GameIniLocal . GetIfExists ( " EmuState " , " EmulationStateId " , & iTemp ) )
2013-09-07 21:02:49 +00:00
EmuState - > SetSelection ( iTemp ) ;
2008-12-08 05:30:24 +00:00
2014-06-16 05:12:43 +00:00
default_emustate - > Get ( " EmulationIssues " , & sTemp ) ;
2009-02-21 14:40:34 +00:00
if ( ! sTemp . empty ( ) )
2013-02-28 08:39:06 +00:00
EmuIssues - > SetValue ( StrToWxStr ( sTemp ) ) ;
2013-09-18 10:27:50 +00:00
if ( GameIniLocal . GetIfExists ( " EmuState " , " EmulationIssues " , & sTemp ) )
2013-09-07 21:02:49 +00:00
EmuIssues - > SetValue ( StrToWxStr ( sTemp ) ) ;
2009-09-25 16:29:00 +00:00
EmuIssues - > Enable ( EmuState - > GetSelection ( ) ! = 0 ) ;
2009-02-21 14:40:34 +00:00
2008-12-08 05:30:24 +00:00
PatchList_Load ( ) ;
ActionReplayList_Load ( ) ;
2013-09-23 06:39:14 +00:00
m_geckocode_panel - > LoadCodes ( GameIniDefault , GameIniLocal , OpenISO - > GetUniqueID ( ) ) ;
2008-12-08 05:30:24 +00:00
}
2013-09-07 21:02:49 +00:00
void CISOProperties : : SaveGameIniValueFrom3StateCheckbox ( const char * section , const char * key , wxCheckBox * checkbox )
2008-12-08 05:30:24 +00:00
{
2013-09-07 21:02:49 +00:00
// Delete any existing entries from the local gameini if checkbox is undetermined.
// Otherwise, write the current value to the local gameini if the value differs from the default gameini values.
// Delete any existing entry from the local gameini if the value does not differ from the default gameini value.
bool checkbox_val = ( checkbox - > Get3StateValue ( ) = = wxCHK_CHECKED ) ;
if ( checkbox - > Get3StateValue ( ) = = wxCHK_UNDETERMINED )
GameIniLocal . DeleteKey ( section , key ) ;
else if ( ! GameIniDefault . Exists ( section , key ) )
2014-06-16 05:12:43 +00:00
GameIniLocal . GetOrCreateSection ( section ) - > Set ( key , checkbox_val ) ;
2010-09-14 13:50:25 +00:00
else
2013-09-07 21:02:49 +00:00
{
bool default_value ;
2014-06-16 05:12:43 +00:00
GameIniDefault . GetOrCreateSection ( section ) - > Get ( key , & default_value ) ;
2013-09-07 21:02:49 +00:00
if ( default_value ! = checkbox_val )
2014-06-16 05:12:43 +00:00
GameIniLocal . GetOrCreateSection ( section ) - > Set ( key , checkbox_val ) ;
2013-09-07 21:02:49 +00:00
else
GameIniLocal . DeleteKey ( section , key ) ;
}
}
2013-01-25 18:00:53 +00:00
2013-09-07 21:02:49 +00:00
bool CISOProperties : : SaveGameConfig ( )
{
SaveGameIniValueFrom3StateCheckbox ( " Core " , " CPUThread " , CPUThread ) ;
SaveGameIniValueFrom3StateCheckbox ( " Core " , " SkipIdle " , SkipIdle ) ;
SaveGameIniValueFrom3StateCheckbox ( " Core " , " MMU " , MMU ) ;
SaveGameIniValueFrom3StateCheckbox ( " Core " , " TLBHack " , TLBHack ) ;
SaveGameIniValueFrom3StateCheckbox ( " Core " , " DCBZ " , DCBZOFF ) ;
SaveGameIniValueFrom3StateCheckbox ( " Core " , " VBeam " , VBeam ) ;
SaveGameIniValueFrom3StateCheckbox ( " Core " , " SyncGPU " , SyncGPU ) ;
SaveGameIniValueFrom3StateCheckbox ( " Core " , " FastDiscSpeed " , FastDiscSpeed ) ;
SaveGameIniValueFrom3StateCheckbox ( " Core " , " BlockMerging " , BlockMerging ) ;
SaveGameIniValueFrom3StateCheckbox ( " Core " , " DSPHLE " , DSPHLE ) ;
SaveGameIniValueFrom3StateCheckbox ( " Wii " , " Widescreen " , EnableWideScreen ) ;
SaveGameIniValueFrom3StateCheckbox ( " Video " , " UseBBox " , UseBBox ) ;
# define SAVE_IF_NOT_DEFAULT(section, key, val, def) do { \
if ( GameIniDefault . Exists ( ( section ) , ( key ) ) ) { \
std : : remove_reference < decltype ( ( val ) ) > : : type tmp__ ; \
2014-06-16 05:12:43 +00:00
GameIniDefault . GetOrCreateSection ( ( section ) ) - > Get ( ( key ) , & tmp__ ) ; \
2013-09-07 21:02:49 +00:00
if ( ( val ) ! = tmp__ ) \
2014-06-16 05:12:43 +00:00
GameIniLocal . GetOrCreateSection ( ( section ) ) - > Set ( ( key ) , ( val ) ) ; \
2013-09-07 21:02:49 +00:00
else \
GameIniLocal . DeleteKey ( ( section ) , ( key ) ) ; \
} else if ( ( val ) ! = ( def ) ) \
2014-06-16 05:12:43 +00:00
GameIniLocal . GetOrCreateSection ( ( section ) ) - > Set ( ( key ) , ( val ) ) ; \
2013-09-07 21:02:49 +00:00
else \
GameIniLocal . DeleteKey ( ( section ) , ( key ) ) ; \
} while ( 0 )
SAVE_IF_NOT_DEFAULT ( " Video " , " PH_SZNear " , ( PHack_Data . PHackSZNear ? 1 : 0 ) , 0 ) ;
SAVE_IF_NOT_DEFAULT ( " Video " , " PH_SZFar " , ( PHack_Data . PHackSZFar ? 1 : 0 ) , 0 ) ;
SAVE_IF_NOT_DEFAULT ( " Video " , " PH_ZNear " , PHack_Data . PHZNear , " " ) ;
SAVE_IF_NOT_DEFAULT ( " Video " , " PH_ZFar " , PHack_Data . PHZFar , " " ) ;
SAVE_IF_NOT_DEFAULT ( " EmuState " , " EmulationStateId " , EmuState - > GetSelection ( ) , 0 ) ;
std : : string emu_issues = EmuIssues - > GetValue ( ) . ToStdString ( ) ;
SAVE_IF_NOT_DEFAULT ( " EmuState " , " EmulationIssues " , emu_issues , " " ) ;
2008-12-08 05:30:24 +00:00
PatchList_Save ( ) ;
ActionReplayList_Save ( ) ;
2013-09-07 21:02:49 +00:00
Gecko : : SaveCodes ( GameIniLocal , m_geckocode_panel - > GetCodes ( ) ) ;
2014-03-12 19:33:41 +00:00
bool success = GameIniLocal . Save ( GameIniFileLocal ) ;
2008-12-08 05:30:24 +00:00
2013-09-07 21:02:49 +00:00
// If the resulting file is empty, delete it. Kind of a hack, but meh.
2013-09-15 02:58:32 +00:00
if ( success & & File : : GetSize ( GameIniFileLocal ) = = 0 )
File : : Delete ( GameIniFileLocal ) ;
2013-09-07 21:02:49 +00:00
return success ;
2008-12-08 05:30:24 +00:00
}
2013-09-07 21:02:49 +00:00
void CISOProperties : : LaunchExternalEditor ( const std : : string & filename )
2008-12-08 05:30:24 +00:00
{
2011-01-30 14:20:20 +00:00
# ifdef __APPLE__
2013-09-07 21:02:49 +00:00
// wxTheMimeTypesManager is not yet implemented for wxCocoa
[ [ NSWorkspace sharedWorkspace ] openFile :
[ NSString stringWithUTF8String : filename . c_str ( ) ]
withApplication : @ " TextEdit " ] ;
2011-01-30 14:20:20 +00:00
# else
2014-05-17 17:17:28 +00:00
wxFileType * filetype = wxTheMimeTypesManager - > GetFileTypeFromExtension ( " ini " ) ;
2014-03-10 11:30:55 +00:00
if ( filetype = = nullptr ) // From extension failed, trying with MIME type now
2013-09-07 21:02:49 +00:00
{
2014-05-17 17:17:28 +00:00
filetype = wxTheMimeTypesManager - > GetFileTypeFromMimeType ( " text/plain " ) ;
2014-03-10 11:30:55 +00:00
if ( filetype = = nullptr ) // MIME type failed, aborting mission
2008-12-09 23:19:44 +00:00
{
2014-07-25 01:46:46 +00:00
WxUtils : : ShowErrorDialog ( _ ( " Filetype 'ini' is unknown! Will not open! " ) ) ;
2013-09-07 21:02:49 +00:00
return ;
2008-12-09 23:19:44 +00:00
}
2013-09-07 21:02:49 +00:00
}
2014-07-25 01:46:46 +00:00
wxString OpenCommand = filetype - > GetOpenCommand ( StrToWxStr ( filename ) ) ;
2014-03-10 11:30:55 +00:00
if ( OpenCommand . IsEmpty ( ) )
2014-07-25 01:46:46 +00:00
{
WxUtils : : ShowErrorDialog ( _ ( " Couldn't find open command for extension 'ini'! " ) ) ;
}
2013-09-07 21:02:49 +00:00
else
2014-07-25 01:46:46 +00:00
{
2014-03-10 11:30:55 +00:00
if ( wxExecute ( OpenCommand , wxEXEC_SYNC ) = = - 1 )
2014-07-25 01:46:46 +00:00
WxUtils : : ShowErrorDialog ( _ ( " wxExecute returned -1 on application run! " ) ) ;
}
2011-01-30 14:20:20 +00:00
# endif
2008-12-08 05:30:24 +00:00
2013-09-07 21:02:49 +00:00
bRefreshList = true ; // Just in case
2009-06-07 02:54:07 +00:00
2013-10-29 05:23:17 +00:00
// Once we're done with the ini edit, give the focus back to Dolphin
2009-06-07 02:54:07 +00:00
SetFocus ( ) ;
2008-12-08 05:30:24 +00:00
}
2013-09-07 21:02:49 +00:00
void CISOProperties : : OnEditConfig ( wxCommandEvent & WXUNUSED ( event ) )
{
SaveGameConfig ( ) ;
2013-09-15 00:27:54 +00:00
// Create blank file to prevent editor from prompting to create it.
if ( ! File : : Exists ( GameIniFileLocal ) )
{
2013-09-15 02:58:32 +00:00
std : : fstream blankFile ( GameIniFileLocal , std : : ios : : out ) ;
2013-09-15 00:27:54 +00:00
blankFile . close ( ) ;
}
2013-09-07 21:02:49 +00:00
LaunchExternalEditor ( GameIniFileLocal ) ;
GameIniLocal . Load ( GameIniFileLocal ) ;
LoadGameConfig ( ) ;
}
2014-04-12 10:50:12 +00:00
void CISOProperties : : OnComputeMD5Sum ( wxCommandEvent & WXUNUSED ( event ) )
{
u8 output [ 16 ] ;
std : : string output_string ;
std : : vector < u8 > data ( 8 * 1024 * 1024 ) ;
2014-04-15 01:35:40 +00:00
u64 read_offset = 0 ;
2014-04-12 10:50:12 +00:00
md5_context ctx ;
File : : IOFile file ( OpenGameListItem - > GetFileName ( ) , " rb " ) ;
u64 game_size = file . GetSize ( ) ;
wxProgressDialog progressDialog (
_ ( " Computing MD5 checksum " ) ,
_ ( " Working... " ) ,
2014-04-15 01:35:40 +00:00
1000 ,
2014-04-12 10:50:12 +00:00
this ,
wxPD_APP_MODAL | wxPD_CAN_ABORT |
wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME |
wxPD_SMOOTH
) ;
md5_starts ( & ctx ) ;
while ( read_offset < game_size )
{
2014-04-15 01:35:40 +00:00
if ( ! progressDialog . Update ( ( int ) ( ( double ) read_offset / ( double ) game_size * 1000 ) , _ ( " Computing MD5 checksum " ) ) )
2014-04-12 10:50:12 +00:00
return ;
size_t read_size ;
file . ReadArray ( & data [ 0 ] , data . size ( ) , & read_size ) ;
md5_update ( & ctx , & data [ 0 ] , read_size ) ;
read_offset + = read_size ;
}
md5_finish ( & ctx , output ) ;
// Convert to hex
for ( int a = 0 ; a < 16 ; + + a )
output_string + = StringFromFormat ( " %02x " , output [ a ] ) ;
m_MD5Sum - > SetValue ( output_string ) ;
}
2013-09-07 21:02:49 +00:00
void CISOProperties : : OnShowDefaultConfig ( wxCommandEvent & WXUNUSED ( event ) )
{
LaunchExternalEditor ( GameIniFileDefault ) ;
}
2008-12-08 05:30:24 +00:00
void CISOProperties : : ListSelectionChanged ( wxCommandEvent & event )
{
switch ( event . GetId ( ) )
{
case ID_PATCHES_LIST :
2014-03-10 11:30:55 +00:00
if ( Patches - > GetSelection ( ) = = wxNOT_FOUND | |
DefaultPatches . find ( Patches - > GetString ( Patches - > GetSelection ( ) ) . ToStdString ( ) ) ! = DefaultPatches . end ( ) )
2013-09-07 21:02:49 +00:00
{
EditPatch - > Disable ( ) ;
RemovePatch - > Disable ( ) ;
}
else
2008-12-08 05:30:24 +00:00
{
EditPatch - > Enable ( ) ;
RemovePatch - > Enable ( ) ;
}
break ;
case ID_CHEATS_LIST :
2014-03-10 11:30:55 +00:00
if ( Cheats - > GetSelection ( ) = = wxNOT_FOUND | |
DefaultCheats . find ( Cheats - > GetString ( Cheats - > GetSelection ( ) ) . ToStdString ( ) ) ! = DefaultCheats . end ( ) )
2013-09-07 21:02:49 +00:00
{
EditCheat - > Disable ( ) ;
RemoveCheat - > Disable ( ) ;
}
else
2008-12-08 05:30:24 +00:00
{
EditCheat - > Enable ( ) ;
RemoveCheat - > Enable ( ) ;
}
break ;
}
}
void CISOProperties : : PatchList_Load ( )
{
onFrame . clear ( ) ;
Patches - > Clear ( ) ;
2013-09-07 21:02:49 +00:00
PatchEngine : : LoadPatchSection ( " OnFrame " , onFrame , GameIniDefault , GameIniLocal ) ;
2008-12-08 05:30:24 +00:00
u32 index = 0 ;
2013-10-29 05:09:01 +00:00
for ( PatchEngine : : Patch & p : onFrame )
2008-12-08 05:30:24 +00:00
{
2013-02-28 08:39:06 +00:00
Patches - > Append ( StrToWxStr ( p . name ) ) ;
2008-12-08 05:30:24 +00:00
Patches - > Check ( index , p . active ) ;
2013-09-07 21:02:49 +00:00
if ( ! p . user_defined )
DefaultPatches . insert ( p . name ) ;
2008-12-08 05:30:24 +00:00
+ + index ;
}
}
void CISOProperties : : PatchList_Save ( )
{
std : : vector < std : : string > lines ;
2013-09-07 21:02:49 +00:00
std : : vector < std : : string > enabledLines ;
2009-01-03 23:02:13 +00:00
u32 index = 0 ;
2013-10-29 05:09:01 +00:00
for ( PatchEngine : : Patch & p : onFrame )
2008-12-08 05:30:24 +00:00
{
2013-09-07 21:02:49 +00:00
if ( Patches - > IsChecked ( index ) )
2013-10-29 05:09:01 +00:00
enabledLines . push_back ( " $ " + p . name ) ;
2008-12-08 05:30:24 +00:00
2013-09-07 21:02:49 +00:00
// Do not save default patches.
2013-10-29 05:09:01 +00:00
if ( DefaultPatches . find ( p . name ) = = DefaultPatches . end ( ) )
2008-12-08 05:30:24 +00:00
{
2013-10-29 05:09:01 +00:00
lines . push_back ( " $ " + p . name ) ;
2014-02-12 15:00:34 +00:00
for ( const PatchEngine : : PatchEntry & entry : p . entries )
2013-09-07 21:02:49 +00:00
{
2014-02-12 15:00:34 +00:00
std : : string temp = StringFromFormat ( " 0x%08X:%s:0x%08X " , entry . address , PatchEngine : : PatchTypeStrings [ entry . type ] , entry . value ) ;
2013-09-07 21:02:49 +00:00
lines . push_back ( temp ) ;
}
2008-12-08 05:30:24 +00:00
}
2009-01-03 23:02:13 +00:00
+ + index ;
2008-12-08 05:30:24 +00:00
}
2013-09-07 21:02:49 +00:00
GameIniLocal . SetLines ( " OnFrame_Enabled " , enabledLines ) ;
GameIniLocal . SetLines ( " OnFrame " , lines ) ;
2008-12-08 05:30:24 +00:00
}
void CISOProperties : : PatchButtonClicked ( wxCommandEvent & event )
{
int selection = Patches - > GetSelection ( ) ;
2013-10-29 05:23:17 +00:00
2008-12-08 05:30:24 +00:00
switch ( event . GetId ( ) )
{
case ID_EDITPATCH :
{
CPatchAddEdit dlg ( selection , this ) ;
dlg . ShowModal ( ) ;
}
break ;
case ID_ADDPATCH :
{
2009-01-03 21:55:49 +00:00
CPatchAddEdit dlg ( - 1 , this , 1 , _ ( " Add Patch " ) ) ;
2009-01-03 23:02:13 +00:00
if ( dlg . ShowModal ( ) = = wxID_OK )
{
2013-02-28 04:37:38 +00:00
Patches - > Append ( StrToWxStr ( onFrame . back ( ) . name ) ) ;
2009-01-24 00:45:46 +00:00
Patches - > Check ( ( unsigned int ) ( onFrame . size ( ) - 1 ) , onFrame . back ( ) . active ) ;
2009-01-03 23:02:13 +00:00
}
2008-12-08 05:30:24 +00:00
}
break ;
case ID_REMOVEPATCH :
onFrame . erase ( onFrame . begin ( ) + Patches - > GetSelection ( ) ) ;
2009-12-11 00:03:56 +00:00
Patches - > Delete ( Cheats - > GetSelection ( ) ) ;
2008-12-08 05:30:24 +00:00
break ;
}
PatchList_Save ( ) ;
Patches - > Clear ( ) ;
PatchList_Load ( ) ;
EditPatch - > Enable ( false ) ;
RemovePatch - > Enable ( false ) ;
}
void CISOProperties : : ActionReplayList_Load ( )
{
2008-12-17 04:14:24 +00:00
arCodes . clear ( ) ;
2008-12-08 05:30:24 +00:00
Cheats - > Clear ( ) ;
2013-09-07 21:02:49 +00:00
ActionReplay : : LoadCodes ( arCodes , GameIniDefault , GameIniLocal ) ;
2008-12-08 05:30:24 +00:00
2008-12-17 04:14:24 +00:00
u32 index = 0 ;
2014-02-12 15:00:34 +00:00
for ( const ActionReplay : : ARCode & arCode : arCodes )
2008-12-08 05:30:24 +00:00
{
2013-02-28 04:37:38 +00:00
Cheats - > Append ( StrToWxStr ( arCode . name ) ) ;
2008-12-17 04:14:24 +00:00
Cheats - > Check ( index , arCode . active ) ;
2013-09-07 21:02:49 +00:00
if ( ! arCode . user_defined )
DefaultCheats . insert ( arCode . name ) ;
2008-12-17 04:14:24 +00:00
+ + index ;
2008-12-08 05:30:24 +00:00
}
}
void CISOProperties : : ActionReplayList_Save ( )
{
std : : vector < std : : string > lines ;
2013-09-07 21:02:49 +00:00
std : : vector < std : : string > enabledLines ;
2008-12-17 04:14:24 +00:00
u32 index = 0 ;
2014-08-06 03:07:23 +00:00
u32 cheats_chkbox_count = Cheats - > GetCount ( ) ;
2014-02-12 15:00:34 +00:00
for ( const ActionReplay : : ARCode & code : arCodes )
2008-12-08 05:30:24 +00:00
{
2014-08-06 03:45:18 +00:00
// Check the index against the count because of the hacky way codes are added from the "Cheat Search" dialog
2014-08-06 03:07:23 +00:00
if ( ( index < cheats_chkbox_count ) & & Cheats - > IsChecked ( index ) )
2013-09-07 21:02:49 +00:00
enabledLines . push_back ( " $ " + code . name ) ;
2008-12-08 05:30:24 +00:00
2013-09-07 21:02:49 +00:00
// Do not save default cheats.
if ( DefaultCheats . find ( code . name ) = = DefaultCheats . end ( ) )
2008-12-08 05:30:24 +00:00
{
2013-09-07 21:02:49 +00:00
lines . push_back ( " $ " + code . name ) ;
2014-02-12 15:00:34 +00:00
for ( const ActionReplay : : AREntry & op : code . ops )
2013-09-07 21:02:49 +00:00
{
2014-05-17 17:17:28 +00:00
lines . push_back ( WxStrToStr ( wxString : : Format ( " %08X %08X " , op . cmd_addr , op . value ) ) ) ;
2013-09-07 21:02:49 +00:00
}
2008-12-08 05:30:24 +00:00
}
2008-12-17 04:14:24 +00:00
+ + index ;
2008-12-08 05:30:24 +00:00
}
2013-09-07 21:02:49 +00:00
GameIniLocal . SetLines ( " ActionReplay_Enabled " , enabledLines ) ;
GameIniLocal . SetLines ( " ActionReplay " , lines ) ;
2008-12-08 05:30:24 +00:00
}
void CISOProperties : : ActionReplayButtonClicked ( wxCommandEvent & event )
{
2008-12-17 04:14:24 +00:00
int selection = Cheats - > GetSelection ( ) ;
2013-10-29 05:23:17 +00:00
2008-12-08 05:30:24 +00:00
switch ( event . GetId ( ) )
{
case ID_EDITCHEAT :
2008-12-17 04:14:24 +00:00
{
CARCodeAddEdit dlg ( selection , this ) ;
dlg . ShowModal ( ) ;
}
2008-12-08 05:30:24 +00:00
break ;
case ID_ADDCHEAT :
2008-12-17 04:14:24 +00:00
{
2009-04-08 16:38:41 +00:00
CARCodeAddEdit dlg ( - 1 , this , 1 , _ ( " Add ActionReplay Code " ) ) ;
2009-02-20 00:07:35 +00:00
if ( dlg . ShowModal ( ) = = wxID_OK )
{
2013-03-03 02:34:53 +00:00
Cheats - > Append ( StrToWxStr ( arCodes . back ( ) . name ) ) ;
2009-02-20 00:07:35 +00:00
Cheats - > Check ( ( unsigned int ) ( arCodes . size ( ) - 1 ) , arCodes . back ( ) . active ) ;
}
2008-12-17 04:14:24 +00:00
}
2008-12-08 05:30:24 +00:00
break ;
case ID_REMOVECHEAT :
2008-12-17 04:14:24 +00:00
arCodes . erase ( arCodes . begin ( ) + Cheats - > GetSelection ( ) ) ;
2009-11-08 23:12:35 +00:00
Cheats - > Delete ( Cheats - > GetSelection ( ) ) ;
2008-12-08 05:30:24 +00:00
break ;
}
ActionReplayList_Save ( ) ;
Cheats - > Clear ( ) ;
ActionReplayList_Load ( ) ;
EditCheat - > Enable ( false ) ;
RemoveCheat - > Enable ( false ) ;
}
2009-02-14 17:32:03 +00:00
void CISOProperties : : OnChangeBannerLang ( wxCommandEvent & event )
{
ChangeBannerDetails ( event . GetSelection ( ) ) ;
}
void CISOProperties : : ChangeBannerDetails ( int lang )
{
2013-09-14 22:07:53 +00:00
wxString const shortName = StrToWxStr ( OpenGameListItem - > GetName ( lang ) ) ;
2013-03-04 00:29:56 +00:00
wxString const comment = StrToWxStr ( OpenGameListItem - > GetDescription ( lang ) ) ;
wxString const maker = StrToWxStr ( OpenGameListItem - > GetCompany ( ) ) ;
2013-03-03 01:46:55 +00:00
2013-04-19 13:21:45 +00:00
// Updates the information shown in the window
2011-12-19 06:01:46 +00:00
m_ShortName - > SetValue ( shortName ) ;
m_Comment - > SetValue ( comment ) ;
m_Maker - > SetValue ( maker ) ; //dev too
std : : string filename , extension ;
2014-03-09 20:14:26 +00:00
SplitPath ( OpenGameListItem - > GetFileName ( ) , nullptr , & filename , & extension ) ;
2011-12-19 06:01:46 +00:00
// Also sets the window's title
2013-02-28 04:37:38 +00:00
SetTitle ( StrToWxStr ( StringFromFormat ( " %s%s: %s - " , filename . c_str ( ) ,
2013-02-28 08:39:06 +00:00
extension . c_str ( ) , OpenGameListItem - > GetUniqueID ( ) . c_str ( ) ) ) + shortName ) ;
2009-02-14 17:32:03 +00:00
}