2014-08-29 00:49:26 +02:00
# include "stdafx_gui.h"
2015-08-23 10:06:15 +02:00
# include "Ini.h"
2014-06-02 19:27:24 +02:00
# include "rpcs3.h"
2013-12-08 14:47:54 +01:00
# include "MainFrame.h"
2015-01-15 00:46:42 +01:00
# include "git-version.h"
2015-08-23 10:06:15 +02:00
# include "Emu/Memory/Memory.h"
2014-09-11 21:40:50 +02:00
# include "Emu/SysCalls/Modules/cellSysutil.h"
2015-08-23 10:06:15 +02:00
# include "Emu/System.h"
2014-07-26 07:51:45 +02:00
# include "Gui/PADManager.h"
2013-12-08 14:47:54 +01:00
# include "Gui/VHDDManager.h"
# include "Gui/VFSManager.h"
# include "Gui/AboutDialog.h"
2014-05-02 08:30:32 +02:00
# include "Gui/GameViewer.h"
2014-07-26 07:51:45 +02:00
# include "Gui/CompilerELF.h"
2014-08-14 17:22:13 +02:00
# include "Gui/AutoPauseManager.h"
2014-08-15 13:44:16 +02:00
# include "Gui/SaveDataUtility.h"
2014-07-26 07:51:45 +02:00
# include "Gui/KernelExplorer.h"
# include "Gui/MemoryViewer.h"
# include "Gui/RSXDebugger.h"
2015-08-23 10:06:15 +02:00
# include "Gui/SettingsDialog.h"
2014-12-25 05:39:57 +01:00
# include "Gui/MemoryStringSearcher.h"
2014-11-19 15:16:30 +01:00
# include "Gui/LLEModulesManager.h"
2015-02-22 15:47:12 +01:00
# include "Gui/CgDisasm.h"
2015-09-13 00:37:57 +02:00
# include "Crypto/unpkg.h"
2015-08-23 10:06:15 +02:00
# include <wx/dynlib.h>
2015-09-13 00:37:57 +02:00
# include <wx/progdlg.h>
2013-12-08 14:47:54 +01:00
2015-09-27 00:36:44 +02:00
# ifndef _WIN32
# include "frame_icon.xpm"
# endif
2013-12-08 14:47:54 +01:00
BEGIN_EVENT_TABLE ( MainFrame , FrameBase )
EVT_CLOSE ( MainFrame : : OnQuit )
END_EVENT_TABLE ( )
enum IDs
{
id_boot_elf = 0x555 ,
id_boot_game ,
2014-11-24 19:12:04 +01:00
id_boot_install_pkg ,
id_boot_exit ,
2013-12-08 14:47:54 +01:00
id_sys_pause ,
id_sys_stop ,
id_sys_send_open_menu ,
id_sys_send_exit ,
id_config_emu ,
2013-12-27 11:55:11 +01:00
id_config_pad ,
2013-12-08 14:47:54 +01:00
id_config_vfs_manager ,
id_config_vhdd_manager ,
2014-08-14 17:22:13 +02:00
id_config_autopause_manager ,
2014-08-15 13:44:16 +02:00
id_config_savedata_manager ,
2014-11-19 15:16:30 +01:00
id_config_lle_modules_manager ,
2013-12-08 14:47:54 +01:00
id_tools_compiler ,
2014-07-26 07:51:45 +02:00
id_tools_kernel_explorer ,
2013-12-08 14:47:54 +01:00
id_tools_memory_viewer ,
2013-12-30 23:59:39 +01:00
id_tools_rsx_debugger ,
2014-12-25 05:39:57 +01:00
id_tools_string_search ,
2015-02-22 15:47:12 +01:00
id_tools_cg_disasm ,
2013-12-08 14:47:54 +01:00
id_help_about ,
2015-02-22 15:47:12 +01:00
id_update_dbg
2013-12-08 14:47:54 +01:00
} ;
wxString GetPaneName ( )
{
static int pane_num = 0 ;
return wxString : : Format ( " Pane_%d " , pane_num + + ) ;
}
MainFrame : : MainFrame ( )
2014-12-14 07:48:24 +01:00
: FrameBase ( nullptr , wxID_ANY , " " , " MainFrame " , wxSize ( 900 , 600 ) )
2013-12-08 14:47:54 +01:00
, m_aui_mgr ( this )
, m_sys_menu_opened ( false )
{
2015-10-04 19:07:19 +02:00
SetLabel ( wxString : : Format ( _PRGNAME_ " v " _PRGVER_ " - " RPCS3_GIT_VERSION ) ) ;
2013-12-08 14:47:54 +01:00
2014-04-13 03:31:59 +02:00
wxMenuBar * menubar = new wxMenuBar ( ) ;
wxMenu * menu_boot = new wxMenu ( ) ;
2014-11-24 19:12:04 +01:00
menubar - > Append ( menu_boot , " &Boot " ) ;
menu_boot - > Append ( id_boot_elf , " Boot &ELF / SELF file " ) ;
menu_boot - > Append ( id_boot_game , " Boot &game " ) ;
2014-04-13 03:31:59 +02:00
menu_boot - > AppendSeparator ( ) ;
2014-11-24 19:12:04 +01:00
menu_boot - > Append ( id_boot_install_pkg , " &Install PKG " ) ;
menu_boot - > AppendSeparator ( ) ;
menu_boot - > Append ( id_boot_exit , " &Exit " ) ;
2014-04-13 03:31:59 +02:00
wxMenu * menu_sys = new wxMenu ( ) ;
2014-11-24 19:12:04 +01:00
menubar - > Append ( menu_sys , " &System " ) ;
menu_sys - > Append ( id_sys_pause , " &Pause " ) - > Enable ( false ) ;
menu_sys - > Append ( id_sys_stop , " &Stop \t Ctrl + S " ) - > Enable ( false ) ;
2014-04-13 03:31:59 +02:00
menu_sys - > AppendSeparator ( ) ;
2014-11-24 19:12:04 +01:00
menu_sys - > Append ( id_sys_send_open_menu , " Send &open system menu cmd " ) - > Enable ( false ) ;
menu_sys - > Append ( id_sys_send_exit , " Send &exit cmd " ) - > Enable ( false ) ;
2014-04-13 03:31:59 +02:00
wxMenu * menu_conf = new wxMenu ( ) ;
2014-11-24 19:12:04 +01:00
menubar - > Append ( menu_conf , " &Config " ) ;
menu_conf - > Append ( id_config_emu , " &Settings " ) ;
menu_conf - > Append ( id_config_pad , " &PAD Settings " ) ;
2014-04-13 03:31:59 +02:00
menu_conf - > AppendSeparator ( ) ;
2014-11-24 19:12:04 +01:00
menu_conf - > Append ( id_config_autopause_manager , " &Auto Pause Settings " ) ;
2014-08-14 17:22:13 +02:00
menu_conf - > AppendSeparator ( ) ;
2014-11-24 19:12:04 +01:00
menu_conf - > Append ( id_config_vfs_manager , " Virtual &File System Manager " ) ;
menu_conf - > Append ( id_config_vhdd_manager , " Virtual &HDD Manager " ) ;
menu_conf - > Append ( id_config_savedata_manager , " Save &Data Utility " ) ;
menu_conf - > Append ( id_config_lle_modules_manager , " &LLE Modules Manager " ) ;
2014-11-19 15:16:30 +01:00
2014-04-13 03:31:59 +02:00
wxMenu * menu_tools = new wxMenu ( ) ;
2014-11-24 19:12:04 +01:00
menubar - > Append ( menu_tools , " &Tools " ) ;
menu_tools - > Append ( id_tools_compiler , " &ELF Compiler " ) ;
menu_tools - > Append ( id_tools_kernel_explorer , " &Kernel Explorer " ) - > Enable ( false ) ;
menu_tools - > Append ( id_tools_memory_viewer , " &Memory Viewer " ) - > Enable ( false ) ;
menu_tools - > Append ( id_tools_rsx_debugger , " &RSX Debugger " ) - > Enable ( false ) ;
2014-12-25 05:39:57 +01:00
menu_tools - > Append ( id_tools_string_search , " &String Search " ) - > Enable ( false ) ;
2015-02-22 15:47:12 +01:00
menu_tools - > Append ( id_tools_cg_disasm , " &Cg Disasm " ) - > Enable ( ) ;
2014-04-13 03:31:59 +02:00
wxMenu * menu_help = new wxMenu ( ) ;
2014-11-24 19:12:04 +01:00
menubar - > Append ( menu_help , " &Help " ) ;
menu_help - > Append ( id_help_about , " &About... " ) ;
2014-04-13 03:31:59 +02:00
SetMenuBar ( menubar ) ;
2015-07-08 18:16:18 +02:00
SetIcon ( wxICON ( frame_icon ) ) ;
2013-12-08 14:47:54 +01:00
2014-02-19 05:33:31 +01:00
// Panels
2015-04-25 15:29:05 +02:00
m_log_frame = new LogFrame ( this ) ;
2013-12-08 14:47:54 +01:00
m_game_viewer = new GameViewer ( this ) ;
2014-02-19 05:33:31 +01:00
m_debugger_frame = new DebuggerPanel ( this ) ;
2014-06-07 09:54:02 +02:00
AddPane ( m_game_viewer , " Game List " , wxAUI_DOCK_CENTRE ) ;
2014-06-17 17:44:03 +02:00
AddPane ( m_log_frame , " Log " , wxAUI_DOCK_BOTTOM ) ;
2014-02-19 05:33:31 +01:00
AddPane ( m_debugger_frame , " Debugger " , wxAUI_DOCK_RIGHT ) ;
2013-12-08 14:47:54 +01:00
2014-02-19 05:33:31 +01:00
// Events
2014-07-23 12:38:08 +02:00
Bind ( wxEVT_MENU , & MainFrame : : BootElf , this , id_boot_elf ) ;
2014-04-13 03:31:59 +02:00
Bind ( wxEVT_MENU , & MainFrame : : BootGame , this , id_boot_game ) ;
2014-11-24 19:12:04 +01:00
Bind ( wxEVT_MENU , & MainFrame : : InstallPkg , this , id_boot_install_pkg ) ;
Bind ( wxEVT_MENU , [ ] ( wxCommandEvent & ) { wxGetApp ( ) . Exit ( ) ; } , id_boot_exit ) ;
2013-12-08 14:47:54 +01:00
2014-04-13 03:31:59 +02:00
Bind ( wxEVT_MENU , & MainFrame : : Pause , this , id_sys_pause ) ;
Bind ( wxEVT_MENU , & MainFrame : : Stop , this , id_sys_stop ) ;
Bind ( wxEVT_MENU , & MainFrame : : SendOpenCloseSysMenu , this , id_sys_send_open_menu ) ;
Bind ( wxEVT_MENU , & MainFrame : : SendExit , this , id_sys_send_exit ) ;
2013-12-08 14:47:54 +01:00
2014-04-13 03:31:59 +02:00
Bind ( wxEVT_MENU , & MainFrame : : Config , this , id_config_emu ) ;
Bind ( wxEVT_MENU , & MainFrame : : ConfigPad , this , id_config_pad ) ;
Bind ( wxEVT_MENU , & MainFrame : : ConfigVFS , this , id_config_vfs_manager ) ;
Bind ( wxEVT_MENU , & MainFrame : : ConfigVHDD , this , id_config_vhdd_manager ) ;
2014-08-14 17:22:13 +02:00
Bind ( wxEVT_MENU , & MainFrame : : ConfigAutoPause , this , id_config_autopause_manager ) ;
2014-08-15 13:44:16 +02:00
Bind ( wxEVT_MENU , & MainFrame : : ConfigSaveData , this , id_config_savedata_manager ) ;
2014-11-19 15:16:30 +01:00
Bind ( wxEVT_MENU , & MainFrame : : ConfigLLEModules , this , id_config_lle_modules_manager ) ;
2013-12-08 14:47:54 +01:00
2014-04-13 03:31:59 +02:00
Bind ( wxEVT_MENU , & MainFrame : : OpenELFCompiler , this , id_tools_compiler ) ;
2014-07-26 07:51:45 +02:00
Bind ( wxEVT_MENU , & MainFrame : : OpenKernelExplorer , this , id_tools_kernel_explorer ) ;
2014-04-13 03:31:59 +02:00
Bind ( wxEVT_MENU , & MainFrame : : OpenMemoryViewer , this , id_tools_memory_viewer ) ;
Bind ( wxEVT_MENU , & MainFrame : : OpenRSXDebugger , this , id_tools_rsx_debugger ) ;
2014-12-25 05:39:57 +01:00
Bind ( wxEVT_MENU , & MainFrame : : OpenStringSearch , this , id_tools_string_search ) ;
2015-02-22 15:47:12 +01:00
Bind ( wxEVT_MENU , & MainFrame : : OpenCgDisasm , this , id_tools_cg_disasm ) ;
2013-12-08 14:47:54 +01:00
2014-04-13 03:31:59 +02:00
Bind ( wxEVT_MENU , & MainFrame : : AboutDialogHandler , this , id_help_about ) ;
2013-12-08 14:47:54 +01:00
2014-04-13 03:31:59 +02:00
Bind ( wxEVT_MENU , & MainFrame : : UpdateUI , this , id_update_dbg ) ;
2013-12-08 14:47:54 +01:00
2014-05-10 16:00:34 +02:00
wxGetApp ( ) . Bind ( wxEVT_KEY_DOWN , & MainFrame : : OnKeyDown , this ) ;
2014-04-13 03:31:59 +02:00
wxGetApp ( ) . Bind ( wxEVT_DBG_COMMAND , & MainFrame : : UpdateUI , this ) ;
2015-09-08 12:47:00 +02:00
2015-10-04 19:07:19 +02:00
LOG_NOTICE ( GENERAL , _PRGNAME_ " v " _PRGVER_ " - " RPCS3_GIT_VERSION ) ;
2015-09-08 12:47:00 +02:00
LOG_NOTICE ( GENERAL , " " ) ;
2013-12-08 14:47:54 +01:00
}
MainFrame : : ~ MainFrame ( )
{
m_aui_mgr . UnInit ( ) ;
}
void MainFrame : : AddPane ( wxWindow * wind , const wxString & caption , int flags )
{
wind - > SetSize ( - 1 , 300 ) ;
m_aui_mgr . AddPane ( wind , wxAuiPaneInfo ( ) . Name ( GetPaneName ( ) ) . Caption ( caption ) . Direction ( flags ) . CloseButton ( false ) . MaximizeButton ( ) ) ;
}
void MainFrame : : DoSettings ( bool load )
{
2014-04-01 02:33:55 +02:00
IniEntry < std : : string > ini ;
2013-12-08 14:47:54 +01:00
ini . Init ( " Settings " , " MainFrameAui " ) ;
if ( load )
{
2014-04-01 02:33:55 +02:00
m_aui_mgr . LoadPerspective ( fmt : : FromUTF8 ( ini . LoadValue ( fmt : : ToUTF8 ( m_aui_mgr . SavePerspective ( ) ) ) ) ) ;
2013-12-08 14:47:54 +01:00
}
else
{
2014-04-01 02:33:55 +02:00
ini . SaveValue ( fmt : : ToUTF8 ( m_aui_mgr . SavePerspective ( ) ) ) ;
2013-12-08 14:47:54 +01:00
}
}
void MainFrame : : BootGame ( wxCommandEvent & WXUNUSED ( event ) )
{
bool stopped = false ;
if ( Emu . IsRunning ( ) )
{
Emu . Pause ( ) ;
stopped = true ;
}
wxDirDialog ctrl ( this , L " Select game folder " , wxEmptyString ) ;
if ( ctrl . ShowModal ( ) = = wxID_CANCEL )
{
if ( stopped ) Emu . Resume ( ) ;
return ;
}
Emu . Stop ( ) ;
2014-02-10 13:53:09 +01:00
if ( Emu . BootGame ( ctrl . GetPath ( ) . ToStdString ( ) ) )
2013-12-08 17:54:45 +01:00
{
2014-06-17 17:44:03 +02:00
LOG_SUCCESS ( HLE , " Game: boot done. " ) ;
2014-05-31 12:40:37 +02:00
2014-06-01 15:10:26 +02:00
if ( Ini . HLEAlwaysStart . GetValue ( ) & & Emu . IsReady ( ) )
2014-05-31 12:40:37 +02:00
{
Emu . Run ( ) ;
}
2013-12-08 17:54:45 +01:00
}
else
{
2015-01-12 19:12:06 +01:00
LOG_ERROR ( HLE , " PS3 executable not found in selected folder (%s) " , fmt : : ToUTF8 ( ctrl . GetPath ( ) ) ) ; // passing std::string (test)
2013-12-08 14:47:54 +01:00
}
}
2013-12-08 17:54:45 +01:00
void MainFrame : : InstallPkg ( wxCommandEvent & WXUNUSED ( event ) )
2013-12-08 14:47:54 +01:00
{
2015-09-13 00:37:57 +02:00
const bool was_running = Emu . Pause ( ) ;
2013-12-08 14:47:54 +01:00
2015-04-19 15:19:24 +02:00
wxFileDialog ctrl ( this , L " Select PKG " , wxEmptyString , wxEmptyString , " PKG files (*.pkg) | * . pkg | All files ( * . * ) | * . * " , wxFD_OPEN | wxFD_FILE_MUST_EXIST) ;
2013-12-08 14:47:54 +01:00
2015-09-13 00:37:57 +02:00
if ( ctrl . ShowModal ( ) = = wxID_CANCEL )
2013-12-08 14:47:54 +01:00
{
2015-09-13 00:37:57 +02:00
if ( was_running ) Emu . Resume ( ) ;
2013-12-08 14:47:54 +01:00
return ;
}
Emu . Stop ( ) ;
2014-02-21 02:35:33 +01:00
2015-09-13 00:37:57 +02:00
Emu . GetVFS ( ) . Init ( " / " ) ;
std : : string local_path ;
Emu . GetVFS ( ) . GetDevice ( " /dev_hdd0/game/ " , local_path ) ;
// Open PKG file
fs : : file pkg_f { ctrl . GetPath ( ) . ToStdString ( ) } ;
if ( ! pkg_f )
{
LOG_ERROR ( LOADER , " PKG: Failed to open %s " , ctrl . GetPath ( ) . ToStdString ( ) ) ;
return ;
}
// Fetch title ID from the header
char title_id [ 10 ] = " ????????? " ;
pkg_f . seek ( 55 ) ;
pkg_f . read ( title_id , 9 ) ;
pkg_f . seek ( 0 ) ;
// Append title ID to the path
local_path + = ' / ' ;
local_path + = title_id ;
if ( ! fs : : create_dir ( local_path ) )
{
if ( fs : : is_dir ( local_path ) )
{
if ( wxMessageDialog ( this , " Another installation found. Do you want to overwrite it? " , " PKG Decrypter / Installer " , wxYES_NO | wxCENTRE ) . ShowModal ( ) ! = wxID_YES )
{
LOG_ERROR ( LOADER , " PKG: Cancelled installation to existing directory %s " , local_path ) ;
return ;
}
}
else
{
LOG_ERROR ( LOADER , " PKG: Could not create the installation directory %s " , local_path ) ;
return ;
}
}
wxProgressDialog pdlg ( " PKG Decrypter / Installer " , " Please wait, unpacking... " , 1000 , this , wxPD_AUTO_HIDE | wxPD_APP_MODAL ) ;
volatile f64 progress = 0.0 ;
// Run PKG unpacking asynchronously
auto result = std : : async ( WRAP_EXPR ( UnpackPKG ( pkg_f , local_path + " / " , progress ) ) ) ;
// Wait for the completion
while ( result . wait_for ( 15 ms ) ! = std : : future_status : : ready )
{
// Update progress window
pdlg . Update ( progress * pdlg . GetRange ( ) ) ;
// Update main frame
Update ( ) ;
wxGetApp ( ) . ProcessPendingEvents ( ) ;
}
pdlg . Close ( ) ;
if ( result . get ( ) )
2014-02-06 19:34:05 +01:00
{
2015-09-13 00:37:57 +02:00
LOG_SUCCESS ( LOADER , " PKG: Package successfully installed in %s " , local_path ) ;
2014-02-21 02:35:33 +01:00
2014-08-23 09:50:34 +02:00
// Refresh game list
m_game_viewer - > Refresh ( ) ;
}
2013-12-08 14:47:54 +01:00
}
void MainFrame : : BootElf ( wxCommandEvent & WXUNUSED ( event ) )
{
bool stopped = false ;
if ( Emu . IsRunning ( ) )
{
Emu . Pause ( ) ;
stopped = true ;
}
2013-12-24 05:02:21 +01:00
wxFileDialog ctrl ( this , L " Select (S)ELF " , wxEmptyString , wxEmptyString ,
" (S)ELF files (*BOOT.BIN;*.elf;*.self)|*BOOT.BIN;*.elf;*.self "
" |ELF files (BOOT.BIN;*.elf)|BOOT.BIN;*.elf "
" |SELF files (EBOOT.BIN;*.self)|EBOOT.BIN;*.self "
" |BOOT files (*BOOT.BIN)|*BOOT.BIN "
" |BIN files (*.bin)|*.bin "
" |All files (*.*)|*.* " ,
2013-12-08 14:47:54 +01:00
wxFD_OPEN | wxFD_FILE_MUST_EXIST ) ;
if ( ctrl . ShowModal ( ) = = wxID_CANCEL )
{
if ( stopped ) Emu . Resume ( ) ;
return ;
}
2014-06-17 17:44:03 +02:00
LOG_NOTICE ( HLE , " (S)ELF: booting... " ) ;
2013-12-08 14:47:54 +01:00
Emu . Stop ( ) ;
2014-04-01 02:33:55 +02:00
Emu . SetPath ( fmt : : ToUTF8 ( ctrl . GetPath ( ) ) ) ;
2013-12-08 14:47:54 +01:00
Emu . Load ( ) ;
2014-06-17 17:44:03 +02:00
LOG_SUCCESS ( HLE , " (S)ELF: boot done. " ) ;
2014-07-18 20:07:50 +02:00
if ( Ini . HLEAlwaysStart . GetValue ( ) & & Emu . IsReady ( ) )
{
Emu . Run ( ) ;
}
2013-12-08 14:47:54 +01:00
}
void MainFrame : : Pause ( wxCommandEvent & WXUNUSED ( event ) )
{
if ( Emu . IsReady ( ) )
{
Emu . Run ( ) ;
}
else if ( Emu . IsPaused ( ) )
{
Emu . Resume ( ) ;
}
else if ( Emu . IsRunning ( ) )
{
Emu . Pause ( ) ;
}
}
void MainFrame : : Stop ( wxCommandEvent & WXUNUSED ( event ) )
{
Emu . Stop ( ) ;
}
void MainFrame : : SendExit ( wxCommandEvent & event )
{
2014-09-11 21:18:19 +02:00
sysutilSendSystemCommand ( CELL_SYSUTIL_REQUEST_EXITGAME , 0 ) ;
2013-12-08 14:47:54 +01:00
}
void MainFrame : : SendOpenCloseSysMenu ( wxCommandEvent & event )
{
2014-09-11 21:18:19 +02:00
sysutilSendSystemCommand ( m_sys_menu_opened ? CELL_SYSUTIL_SYSTEM_MENU_CLOSE : CELL_SYSUTIL_SYSTEM_MENU_OPEN , 0 ) ;
2013-12-08 14:47:54 +01:00
m_sys_menu_opened = ! m_sys_menu_opened ;
wxCommandEvent ce ;
UpdateUI ( ce ) ;
}
void MainFrame : : Config ( wxCommandEvent & WXUNUSED ( event ) )
{
2015-08-23 10:06:15 +02:00
SettingsDialog ( this ) ;
2013-12-27 11:55:11 +01:00
}
void MainFrame : : ConfigPad ( wxCommandEvent & WXUNUSED ( event ) )
{
2014-04-05 16:26:45 +02:00
PADManager ( this ) . ShowModal ( ) ;
2013-12-08 14:47:54 +01:00
}
void MainFrame : : ConfigVFS ( wxCommandEvent & WXUNUSED ( event ) )
{
VFSManagerDialog ( this ) . ShowModal ( ) ;
}
void MainFrame : : ConfigVHDD ( wxCommandEvent & WXUNUSED ( event ) )
{
VHDDManagerDialog ( this ) . ShowModal ( ) ;
}
2014-08-14 17:22:13 +02:00
void MainFrame : : ConfigAutoPause ( wxCommandEvent & WXUNUSED ( event ) )
{
AutoPauseManagerDialog ( this ) . ShowModal ( ) ;
}
2014-08-15 13:44:16 +02:00
void MainFrame : : ConfigSaveData ( wxCommandEvent & event )
{
SaveDataListDialog ( this , true ) . ShowModal ( ) ;
}
2014-11-19 15:16:30 +01:00
void MainFrame : : ConfigLLEModules ( wxCommandEvent & event )
{
( new LLEModulesManagerFrame ( this ) ) - > Show ( ) ;
}
2013-12-08 14:47:54 +01:00
void MainFrame : : OpenELFCompiler ( wxCommandEvent & WXUNUSED ( event ) )
{
2015-10-04 00:45:26 +02:00
( new CompilerELF ( this ) ) - > Show ( ) ;
2013-12-08 14:47:54 +01:00
}
2014-07-26 07:51:45 +02:00
void MainFrame : : OpenKernelExplorer ( wxCommandEvent & WXUNUSED ( event ) )
{
2015-10-04 00:45:26 +02:00
( new KernelExplorer ( this ) ) - > Show ( ) ;
2014-07-26 07:51:45 +02:00
}
2013-12-08 14:47:54 +01:00
void MainFrame : : OpenMemoryViewer ( wxCommandEvent & WXUNUSED ( event ) )
{
2015-10-04 00:45:26 +02:00
( new MemoryViewerPanel ( this ) ) - > Show ( ) ;
2013-12-08 14:47:54 +01:00
}
2013-12-30 23:59:39 +01:00
void MainFrame : : OpenRSXDebugger ( wxCommandEvent & WXUNUSED ( event ) )
{
2015-10-04 00:45:26 +02:00
( new RSXDebugger ( this ) ) - > Show ( ) ;
2013-12-30 23:59:39 +01:00
}
2014-12-25 05:39:57 +01:00
void MainFrame : : OpenStringSearch ( wxCommandEvent & WXUNUSED ( event ) )
{
2015-10-04 00:45:26 +02:00
( new MemoryStringSearcher ( this ) ) - > Show ( ) ;
2014-12-25 05:39:57 +01:00
}
2014-04-09 21:57:26 +02:00
2015-02-22 15:47:12 +01:00
void MainFrame : : OpenCgDisasm ( wxCommandEvent & WXUNUSED ( event ) )
{
( new CgDisasm ( this ) ) - > Show ( ) ;
}
2013-12-08 14:47:54 +01:00
void MainFrame : : AboutDialogHandler ( wxCommandEvent & WXUNUSED ( event ) )
{
AboutDialog ( this ) . ShowModal ( ) ;
}
void MainFrame : : UpdateUI ( wxCommandEvent & event )
{
event . Skip ( ) ;
bool is_running , is_stopped , is_ready ;
if ( event . GetEventType ( ) = = wxEVT_DBG_COMMAND )
{
switch ( event . GetId ( ) )
{
case DID_START_EMU :
case DID_STARTED_EMU :
is_running = true ;
is_stopped = false ;
is_ready = false ;
break ;
case DID_STOP_EMU :
case DID_STOPPED_EMU :
is_running = false ;
is_stopped = true ;
is_ready = false ;
m_sys_menu_opened = false ;
break ;
case DID_PAUSE_EMU :
case DID_PAUSED_EMU :
is_running = false ;
is_stopped = false ;
is_ready = false ;
break ;
case DID_RESUME_EMU :
case DID_RESUMED_EMU :
is_running = true ;
is_stopped = false ;
is_ready = false ;
break ;
case DID_READY_EMU :
is_running = false ;
is_stopped = false ;
is_ready = true ;
break ;
case DID_REGISTRED_CALLBACK :
is_running = Emu . IsRunning ( ) ;
is_stopped = Emu . IsStopped ( ) ;
is_ready = Emu . IsReady ( ) ;
break ;
default :
return ;
2014-08-24 19:42:19 +02:00
}
if ( event . GetId ( ) = = DID_STOPPED_EMU )
{
if ( Ini . HLEExitOnStop . GetValue ( ) )
{
wxGetApp ( ) . Exit ( ) ;
}
2013-12-08 14:47:54 +01:00
}
}
else
{
is_running = Emu . IsRunning ( ) ;
is_stopped = Emu . IsStopped ( ) ;
is_ready = Emu . IsReady ( ) ;
}
2014-07-06 01:30:28 +02:00
// Update menu items based on the state of the emulator
2013-12-08 14:47:54 +01:00
wxMenuBar & menubar ( * GetMenuBar ( ) ) ;
2014-07-06 01:30:28 +02:00
// Emulation
2015-07-09 19:42:39 +02:00
wxMenuItem & pause = * menubar . FindItem ( id_sys_pause ) ;
wxMenuItem & stop = * menubar . FindItem ( id_sys_stop ) ;
2014-11-24 19:12:04 +01:00
pause . SetItemLabel ( is_running ? " &Pause \t Ctrl + P " : is_ready ? " &Start \t Ctrl + E " : " &Resume \t Ctrl + E " ) ;
2013-12-08 14:47:54 +01:00
pause . Enable ( ! is_stopped ) ;
stop . Enable ( ! is_stopped ) ;
2014-07-06 01:30:28 +02:00
// PS3 Commands
2015-07-09 19:42:39 +02:00
wxMenuItem & send_exit = * menubar . FindItem ( id_sys_send_exit ) ;
wxMenuItem & send_open_menu = * menubar . FindItem ( id_sys_send_open_menu ) ;
2014-09-11 21:18:19 +02:00
bool enable_commands = ! is_stopped ;
2014-11-24 19:12:04 +01:00
send_open_menu . SetItemLabel ( wxString : : Format ( " Send &%s system menu cmd " , ( m_sys_menu_opened ? " close " : " open " ) ) ) ;
2013-12-08 14:47:54 +01:00
send_open_menu . Enable ( enable_commands ) ;
send_exit . Enable ( enable_commands ) ;
2014-07-06 01:30:28 +02:00
// Tools
2014-07-26 07:51:45 +02:00
wxMenuItem & kernel_explorer = * menubar . FindItem ( id_tools_kernel_explorer ) ;
wxMenuItem & memory_viewer = * menubar . FindItem ( id_tools_memory_viewer ) ;
wxMenuItem & rsx_debugger = * menubar . FindItem ( id_tools_rsx_debugger ) ;
2014-12-25 05:39:57 +01:00
wxMenuItem & string_search = * menubar . FindItem ( id_tools_string_search ) ;
2014-07-26 07:51:45 +02:00
kernel_explorer . Enable ( ! is_stopped ) ;
2014-07-06 01:30:28 +02:00
memory_viewer . Enable ( ! is_stopped ) ;
rsx_debugger . Enable ( ! is_stopped ) ;
2014-12-25 05:39:57 +01:00
string_search . Enable ( ! is_stopped ) ;
2013-12-08 14:47:54 +01:00
}
void MainFrame : : OnQuit ( wxCloseEvent & event )
{
DoSettings ( false ) ;
TheApp - > Exit ( ) ;
}
void MainFrame : : OnKeyDown ( wxKeyEvent & event )
{
if ( wxGetActiveWindow ( ) /*== this*/ & & event . ControlDown ( ) )
{
switch ( event . GetKeyCode ( ) )
{
2014-02-19 01:41:57 +01:00
case ' E ' : case ' e ' : if ( Emu . IsPaused ( ) ) Emu . Resume ( ) ; else if ( Emu . IsReady ( ) ) Emu . Run ( ) ; return ;
2013-12-08 14:47:54 +01:00
case ' P ' : case ' p ' : if ( Emu . IsRunning ( ) ) Emu . Pause ( ) ; return ;
case ' S ' : case ' s ' : if ( ! Emu . IsStopped ( ) ) Emu . Stop ( ) ; return ;
2015-09-18 00:41:14 +02:00
case ' R ' : case ' r ' : if ( ! Emu . GetPath ( ) . empty ( ) ) { Emu . Stop ( ) ; Emu . Run ( ) ; } return ;
2013-12-08 14:47:54 +01:00
}
}
event . Skip ( ) ;
}