2009-07-28 21:32:10 +00:00
// Copyright (C) 2003 Dolphin Project.
2008-12-08 05:30:24 +00:00
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
2009-01-04 21:53:41 +00:00
2010-02-21 20:09:49 +00:00
// CFrame is the main parent window. Inside CFrame there is an m_Panel that is
// the parent for the rendering window (when we render to the main window). In
// Windows the rendering window is created by giving CreateWindow()
// m_Panel->GetHandle() as parent window and creating a new child window to
// m_Panel. The new child window handle that is returned by CreateWindow() can
2009-09-06 13:36:05 +00:00
// be accessed from Core::GetWindowHandle().
2009-01-04 21:53:41 +00:00
2009-06-20 11:05:52 +00:00
# include "Common.h" // Common
# include "FileUtil.h"
# include "Timer.h"
# include "Setup.h"
2008-12-23 08:47:37 +00:00
# include "Globals.h" // Local
2008-12-08 05:30:24 +00:00
# include "Frame.h"
2008-12-23 08:47:37 +00:00
# include "ConfigMain.h"
# include "CheatsWindow.h"
2008-12-08 05:30:24 +00:00
# include "GameListCtrl.h"
# include "BootManager.h"
2010-01-19 19:28:27 +00:00
# include "ConsoleListener.h"
2008-12-08 05:30:24 +00:00
2009-01-17 23:41:21 +00:00
# include "ConfigManager.h" // Core
2008-12-08 05:30:24 +00:00
# include "Core.h"
2008-12-23 07:34:23 +00:00
# include "HW/DVDInterface.h"
2010-06-13 09:14:40 +00:00
# include "HW/GCPad.h"
2010-01-03 23:05:52 +00:00
# include "IPC_HLE/WII_IPC_HLE_Device_usb.h"
2008-12-08 05:30:24 +00:00
# include "State.h"
2008-12-23 08:47:37 +00:00
# include "VolumeHandler.h"
2011-06-24 06:50:50 +00:00
# include "Movie.h"
2009-08-31 23:09:50 +00:00
2011-01-31 01:28:32 +00:00
# include "VideoBackendBase.h"
2009-01-04 21:53:41 +00:00
# include <wx/datetime.h> // wxWidgets
2008-12-08 05:30:24 +00:00
2009-09-01 13:06:37 +00:00
// Resources
2009-09-01 12:44:02 +00:00
2008-12-08 05:30:24 +00:00
extern " C " {
2009-01-04 21:53:41 +00:00
# include "../resources/Dolphin.c" // Dolphin icon
2008-12-08 05:30:24 +00:00
# include "../resources/toolbar_browse.c"
# include "../resources/toolbar_file_open.c"
# include "../resources/toolbar_fullscreen.c"
# include "../resources/toolbar_help.c"
# include "../resources/toolbar_pause.c"
# include "../resources/toolbar_play.c"
# include "../resources/toolbar_plugin_dsp.c"
# include "../resources/toolbar_plugin_gfx.c"
# include "../resources/toolbar_plugin_options.c"
# include "../resources/toolbar_plugin_pad.c"
# include "../resources/toolbar_refresh.c"
# include "../resources/toolbar_stop.c"
2009-01-04 21:53:41 +00:00
# include "../resources/Boomy.h" // Theme packages
# include "../resources/Vista.h"
# include "../resources/X-Plastik.h"
# include "../resources/KDE.h"
2008-12-08 05:30:24 +00:00
} ;
2008-12-23 04:35:21 +00:00
2010-02-02 08:10:23 +00:00
// Windows functions. Setting the cursor with wxSetCursor() did not work in
// this instance. Probably because it's somehow reset from the WndProc() in
// the child window
2009-01-04 23:24:13 +00:00
# ifdef _WIN32
// Declare a blank icon and one that will be the normal cursor
2009-01-04 21:53:41 +00:00
HCURSOR hCursor = NULL , hCursorBlank = NULL ;
// Create the default cursor
void CreateCursor ( )
2008-12-08 05:30:24 +00:00
{
2009-01-04 21:53:41 +00:00
hCursor = LoadCursor ( NULL , IDC_ARROW ) ;
2008-12-08 05:30:24 +00:00
}
2009-01-04 21:53:41 +00:00
void MSWSetCursor ( bool Show )
{
if ( Show )
SetCursor ( hCursor ) ;
else
{
SetCursor ( hCursorBlank ) ;
//wxSetCursor(wxCursor(wxNullCursor));
}
}
// I could not use FindItemByHWND() instead of this, it crashed on that occation I used it */
HWND MSWGetParent_ ( HWND Parent )
{
return GetParent ( Parent ) ;
}
2009-01-04 23:24:13 +00:00
# endif
2009-09-01 12:44:02 +00:00
2009-09-06 13:36:05 +00:00
// ---------------
2011-02-14 02:18:03 +00:00
// The CPanel class to receive MSWWindowProc messages from the video backend.
2009-01-04 21:53:41 +00:00
extern CFrame * main_frame ;
BEGIN_EVENT_TABLE ( CPanel , wxPanel )
END_EVENT_TABLE ( )
CPanel : : CPanel (
wxWindow * parent ,
wxWindowID id
)
2011-12-12 05:54:50 +00:00
: wxPanel ( parent , id , wxDefaultPosition , wxDefaultSize , 0 ) // disables wxTAB_TRAVERSAL because it was breaking hotkeys
2009-01-04 21:53:41 +00:00
{
}
2010-01-03 23:05:52 +00:00
2009-01-04 21:53:41 +00:00
# ifdef _WIN32
WXLRESULT CPanel : : MSWWindowProc ( WXUINT nMsg , WXWPARAM wParam , WXLPARAM lParam )
{
switch ( nMsg )
{
case WM_USER :
switch ( wParam )
{
2009-11-15 07:46:43 +00:00
case WM_USER_STOP :
2009-01-04 21:53:41 +00:00
main_frame - > DoStop ( ) ;
2010-02-08 09:57:52 +00:00
break ;
2010-07-24 02:36:22 +00:00
2010-04-12 01:33:10 +00:00
case WM_USER_SETCURSOR :
if ( SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bHideCursor & &
main_frame - > RendererHasFocus ( ) & & Core : : GetState ( ) = = Core : : CORE_RUN )
MSWSetCursor ( ! SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bHideCursor ) ;
2009-04-28 23:47:18 +00:00
else
2010-04-12 01:33:10 +00:00
MSWSetCursor ( true ) ;
2010-02-08 09:57:52 +00:00
break ;
2010-01-03 23:05:52 +00:00
case WIIMOTE_DISCONNECT :
2010-01-25 05:12:24 +00:00
if ( SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bWii )
{
2011-03-15 23:09:12 +00:00
const int wiimote_idx = lParam ;
const int wiimote_num = wiimote_idx + 1 ;
//Auto reconnect if option is turned on.
//TODO: Make this only auto reconnect wiimotes that have the option activated.
SConfig : : GetInstance ( ) . LoadSettingsWii ( ) ; //Make sure we are using the newest settings.
if ( SConfig : : GetInstance ( ) . m_WiiAutoReconnect [ wiimote_idx ] )
{
GetUsbPointer ( ) - > AccessWiiMote ( wiimote_idx | 0x100 ) - > Activate ( true ) ;
NOTICE_LOG ( WIIMOTE , " Wiimote %i has been auto-reconnected... " , wiimote_num ) ;
}
2010-01-22 23:24:43 +00:00
else
{
2011-03-15 23:09:12 +00:00
// The Wiimote has been disconnected, we offer reconnect here.
wxMessageDialog * dlg = new wxMessageDialog (
this ,
wxString : : Format ( _ ( " Wiimote %i has been disconnected by system. \n Maybe this game doesn't support multi-wiimote, \n or maybe it is due to idle time out or other reason. \n Do you want to reconnect immediately? " ) , wiimote_num ) ,
_ ( " Reconnect Wiimote Confirm " ) ,
wxYES_NO | wxSTAY_ON_TOP | wxICON_INFORMATION , //wxICON_QUESTION,
wxDefaultPosition ) ;
if ( dlg - > ShowModal ( ) = = wxID_YES )
2010-03-30 17:57:44 +00:00
GetUsbPointer ( ) - > AccessWiiMote ( wiimote_idx | 0x100 ) - > Activate ( true ) ;
2011-03-15 23:09:12 +00:00
dlg - > Destroy ( ) ;
2010-01-22 23:24:43 +00:00
}
2010-01-04 03:11:31 +00:00
}
2009-01-04 21:53:41 +00:00
}
break ;
2011-03-21 05:46:33 +00:00
2010-02-08 09:57:52 +00:00
default :
// By default let wxWidgets do what it normally does with this event
return wxPanel : : MSWWindowProc ( nMsg , wParam , lParam ) ;
2009-01-04 21:53:41 +00:00
}
2010-02-08 09:57:52 +00:00
return 0 ;
2009-01-04 21:53:41 +00:00
}
# endif
2009-09-01 12:44:02 +00:00
2010-04-15 03:25:35 +00:00
CRenderFrame : : CRenderFrame ( wxFrame * parent , wxWindowID id , const wxString & title ,
const wxPoint & pos , const wxSize & size , long style )
: wxFrame ( parent , id , title , pos , size , style )
{
2011-02-18 20:03:01 +00:00
// Give it an icon
wxIcon IconTemp ;
IconTemp . CopyFromBitmap ( wxGetBitmapFromMemory ( dolphin_ico32x32 ) ) ;
SetIcon ( IconTemp ) ;
2010-04-15 03:25:35 +00:00
}
# ifdef _WIN32
WXLRESULT CRenderFrame : : MSWWindowProc ( WXUINT nMsg , WXWPARAM wParam , WXLPARAM lParam )
{
switch ( nMsg )
{
case WM_SYSCOMMAND :
switch ( wParam )
{
case SC_SCREENSAVE :
case SC_MONITORPOWER :
2011-08-25 19:44:13 +00:00
if ( Core : : GetState ( ) = = Core : : CORE_RUN & & SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bDisableScreenSaver )
2010-04-15 03:25:35 +00:00
break ;
default :
return wxFrame : : MSWWindowProc ( nMsg , wParam , lParam ) ;
}
break ;
2010-10-04 11:09:32 +00:00
case WM_CLOSE :
// Let Core finish initializing before accepting any WM_CLOSE messages
if ( Core : : GetState ( ) = = Core : : CORE_UNINITIALIZED ) break ;
// Use default action otherwise
2010-04-15 03:25:35 +00:00
default :
// By default let wxWidgets do what it normally does with this event
return wxFrame : : MSWWindowProc ( nMsg , wParam , lParam ) ;
}
return 0 ;
}
# endif
2009-09-01 12:44:02 +00:00
// event tables
2008-12-08 05:30:24 +00:00
// Notice that wxID_HELP will be processed for the 'About' menu and the toolbar
// help button.
const wxEventType wxEVT_HOST_COMMAND = wxNewEventType ( ) ;
2010-04-15 03:25:35 +00:00
BEGIN_EVENT_TABLE ( CFrame , CRenderFrame )
2009-09-03 05:24:30 +00:00
// Menu bar
2008-12-08 05:30:24 +00:00
EVT_MENU ( wxID_OPEN , CFrame : : OnOpen )
EVT_MENU ( wxID_EXIT , CFrame : : OnQuit )
EVT_MENU ( IDM_HELPWEBSITE , CFrame : : OnHelp )
EVT_MENU ( IDM_HELPGOOGLECODE , CFrame : : OnHelp )
2010-06-01 21:03:02 +00:00
EVT_MENU ( wxID_ABOUT , CFrame : : OnHelp )
2008-12-08 05:30:24 +00:00
EVT_MENU ( wxID_REFRESH , CFrame : : OnRefresh )
EVT_MENU ( IDM_PLAY , CFrame : : OnPlay )
2009-10-06 15:49:20 +00:00
EVT_MENU ( IDM_STOP , CFrame : : OnStop )
EVT_MENU ( IDM_RESET , CFrame : : OnReset )
2009-08-21 09:26:34 +00:00
EVT_MENU ( IDM_RECORD , CFrame : : OnRecord )
2009-08-21 19:55:03 +00:00
EVT_MENU ( IDM_PLAYRECORD , CFrame : : OnPlayRecording )
2010-08-30 07:05:47 +00:00
EVT_MENU ( IDM_RECORDEXPORT , CFrame : : OnRecordExport )
2011-02-12 02:14:20 +00:00
EVT_MENU ( IDM_RECORDREADONLY , CFrame : : OnRecordReadOnly )
2011-06-24 06:50:50 +00:00
EVT_MENU ( IDM_TASINPUT , CFrame : : OnTASInput )
2009-08-22 02:05:02 +00:00
EVT_MENU ( IDM_FRAMESTEP , CFrame : : OnFrameStep )
2009-02-27 03:56:34 +00:00
EVT_MENU ( IDM_SCREENSHOT , CFrame : : OnScreenshot )
2010-06-01 21:03:02 +00:00
EVT_MENU ( wxID_PREFERENCES , CFrame : : OnConfigMain )
2011-02-14 02:18:03 +00:00
EVT_MENU ( IDM_CONFIG_GFX_BACKEND , CFrame : : OnConfigGFX )
EVT_MENU ( IDM_CONFIG_DSP_EMULATOR , CFrame : : OnConfigDSP )
2011-02-02 16:34:12 +00:00
EVT_MENU ( IDM_CONFIG_PAD_PLUGIN , CFrame : : OnConfigPAD )
EVT_MENU ( IDM_CONFIG_WIIMOTE_PLUGIN , CFrame : : OnConfigWiimote )
2011-02-12 06:46:33 +00:00
EVT_MENU ( IDM_CONFIG_HOTKEYS , CFrame : : OnConfigHotkey )
2009-01-03 01:38:44 +00:00
2009-08-30 19:44:42 +00:00
EVT_MENU ( IDM_SAVE_PERSPECTIVE , CFrame : : OnToolBar )
2009-09-01 19:47:04 +00:00
EVT_AUITOOLBAR_TOOL_DROPDOWN ( IDM_SAVE_PERSPECTIVE , CFrame : : OnDropDownToolbarItem )
2009-08-30 19:44:42 +00:00
EVT_MENU ( IDM_EDIT_PERSPECTIVES , CFrame : : OnToolBar )
2009-09-01 19:47:04 +00:00
EVT_AUITOOLBAR_TOOL_DROPDOWN ( IDM_EDIT_PERSPECTIVES , CFrame : : OnDropDownSettingsToolbar )
// Drop down
EVT_MENU ( IDM_PERSPECTIVES_ADD_PANE , CFrame : : OnToolBar )
2009-08-30 19:44:42 +00:00
EVT_MENU_RANGE ( IDM_PERSPECTIVES_0 , IDM_PERSPECTIVES_100 , CFrame : : OnSelectPerspective )
2009-09-01 19:47:04 +00:00
EVT_MENU ( IDM_ADD_PERSPECTIVE , CFrame : : OnDropDownToolbarSelect )
EVT_MENU ( IDM_TAB_SPLIT , CFrame : : OnDropDownToolbarSelect )
2009-09-02 15:23:53 +00:00
EVT_MENU ( IDM_NO_DOCKING , CFrame : : OnDropDownToolbarSelect )
2009-09-05 04:50:45 +00:00
// Drop down float
2010-07-26 03:46:14 +00:00
EVT_MENU_RANGE ( IDM_FLOAT_LOGWINDOW , IDM_FLOAT_CODEWINDOW , CFrame : : OnFloatWindow )
2009-09-05 04:50:45 +00:00
2009-05-13 21:50:24 +00:00
EVT_MENU ( IDM_NETPLAY , CFrame : : OnNetPlay )
2008-12-08 05:30:24 +00:00
EVT_MENU ( IDM_BROWSE , CFrame : : OnBrowse )
EVT_MENU ( IDM_MEMCARD , CFrame : : OnMemcard )
2010-01-05 07:34:03 +00:00
EVT_MENU ( IDM_IMPORTSAVE , CFrame : : OnImportSave )
2008-12-08 05:30:24 +00:00
EVT_MENU ( IDM_CHEATS , CFrame : : OnShow_CheatsWindow )
2008-12-23 08:47:37 +00:00
EVT_MENU ( IDM_CHANGEDISC , CFrame : : OnChangeDisc )
2011-05-08 02:56:09 +00:00
EVT_MENU ( IDM_MENU_INSTALLWAD , CFrame : : OnInstallWAD )
EVT_MENU ( IDM_LIST_INSTALLWAD , CFrame : : OnInstallWAD )
2009-02-27 23:44:15 +00:00
EVT_MENU ( IDM_LOAD_WII_MENU , CFrame : : OnLoadWiiMenu )
2011-03-27 02:55:08 +00:00
EVT_MENU ( IDM_FIFOPLAYER , CFrame : : OnFifoPlayer )
2010-01-08 21:57:31 +00:00
2008-12-08 05:30:24 +00:00
EVT_MENU ( IDM_TOGGLE_FULLSCREEN , CFrame : : OnToggleFullscreen )
EVT_MENU ( IDM_TOGGLE_DUALCORE , CFrame : : OnToggleDualCore )
EVT_MENU ( IDM_TOGGLE_SKIPIDLE , CFrame : : OnToggleSkipIdle )
EVT_MENU ( IDM_TOGGLE_TOOLBAR , CFrame : : OnToggleToolbar )
EVT_MENU ( IDM_TOGGLE_STATUSBAR , CFrame : : OnToggleStatusbar )
2010-07-26 03:46:14 +00:00
EVT_MENU_RANGE ( IDM_LOGWINDOW , IDM_VIDEOWINDOW , CFrame : : OnToggleWindow )
2009-02-27 23:44:15 +00:00
2009-06-06 07:36:22 +00:00
EVT_MENU ( IDM_PURGECACHE , CFrame : : GameListChanged )
2009-04-28 02:30:50 +00:00
2009-06-28 01:11:35 +00:00
EVT_MENU ( IDM_LOADLASTSTATE , CFrame : : OnLoadLastState )
2009-06-28 21:11:51 +00:00
EVT_MENU ( IDM_UNDOLOADSTATE , CFrame : : OnUndoLoadState )
EVT_MENU ( IDM_UNDOSAVESTATE , CFrame : : OnUndoSaveState )
2009-06-28 01:11:35 +00:00
EVT_MENU ( IDM_LOADSTATEFILE , CFrame : : OnLoadStateFromFile )
EVT_MENU ( IDM_SAVESTATEFILE , CFrame : : OnSaveStateToFile )
2009-06-28 19:47:02 +00:00
EVT_MENU_RANGE ( IDM_LOADSLOT1 , IDM_LOADSLOT8 , CFrame : : OnLoadState )
EVT_MENU_RANGE ( IDM_SAVESLOT1 , IDM_SAVESLOT8 , CFrame : : OnSaveState )
2009-08-08 01:39:56 +00:00
EVT_MENU_RANGE ( IDM_FRAMESKIP0 , IDM_FRAMESKIP9 , CFrame : : OnFrameSkip )
2009-02-21 23:44:40 +00:00
EVT_MENU_RANGE ( IDM_DRIVE1 , IDM_DRIVE24 , CFrame : : OnBootDrive )
2010-01-08 21:57:31 +00:00
EVT_MENU_RANGE ( IDM_CONNECT_WIIMOTE1 , IDM_CONNECT_WIIMOTE4 , CFrame : : OnConnectWiimote )
2010-01-11 05:07:56 +00:00
EVT_MENU_RANGE ( IDM_LISTWAD , IDM_LISTDRIVES , CFrame : : GameListChanged )
2009-01-04 21:53:41 +00:00
2009-09-03 05:24:30 +00:00
// Other
2009-12-30 09:00:43 +00:00
EVT_ACTIVATE ( CFrame : : OnActive )
2009-09-03 05:24:30 +00:00
EVT_CLOSE ( CFrame : : OnClose )
2008-12-12 03:38:50 +00:00
EVT_SIZE ( CFrame : : OnResize )
2010-01-18 18:01:03 +00:00
EVT_MOVE ( CFrame : : OnMove )
2009-01-28 16:51:05 +00:00
EVT_LIST_ITEM_ACTIVATED ( LIST_CTRL , CFrame : : OnGameListCtrl_ItemActivated )
2008-12-08 05:30:24 +00:00
EVT_HOST_COMMAND ( wxID_ANY , CFrame : : OnHostMessage )
2009-08-25 01:50:27 +00:00
2009-08-30 19:44:42 +00:00
EVT_AUI_PANE_CLOSE ( CFrame : : OnPaneClose )
2009-08-26 09:19:15 +00:00
EVT_AUINOTEBOOK_PAGE_CLOSE ( wxID_ANY , CFrame : : OnNotebookPageClose )
2009-08-26 15:23:48 +00:00
EVT_AUINOTEBOOK_ALLOW_DND ( wxID_ANY , CFrame : : OnAllowNotebookDnD )
2009-08-27 15:53:19 +00:00
EVT_AUINOTEBOOK_PAGE_CHANGED ( wxID_ANY , CFrame : : OnNotebookPageChanged )
2009-09-05 04:50:45 +00:00
EVT_AUINOTEBOOK_TAB_RIGHT_UP ( wxID_ANY , CFrame : : OnTab )
2009-08-26 09:19:15 +00:00
2009-09-03 05:24:30 +00:00
// Post events to child panels
2010-07-27 02:39:12 +00:00
EVT_MENU_RANGE ( IDM_INTERPRETER , IDM_ADDRBOX , CFrame : : PostEvent )
EVT_TEXT ( IDM_ADDRBOX , CFrame : : PostEvent )
2009-09-03 05:24:30 +00:00
2008-12-08 05:30:24 +00:00
END_EVENT_TABLE ( )
2009-01-05 04:08:18 +00:00
2009-09-03 07:56:35 +00:00
// ---------------
2009-09-01 12:44:02 +00:00
// Creation and close, quit functions
2009-09-01 13:06:37 +00:00
2009-09-01 14:33:16 +00:00
CFrame : : CFrame ( wxFrame * parent ,
2008-12-08 05:30:24 +00:00
wxWindowID id ,
const wxString & title ,
const wxPoint & pos ,
const wxSize & size ,
2009-08-25 01:50:27 +00:00
bool _UseDebugger ,
2010-07-08 23:27:51 +00:00
bool _BatchMode ,
2009-09-01 15:16:44 +00:00
bool ShowLogWindow ,
2008-12-08 05:30:24 +00:00
long style )
2010-04-15 03:25:35 +00:00
: CRenderFrame ( parent , id , title , pos , size , style )
2011-02-27 02:27:43 +00:00
, g_pCodeWindow ( NULL ) , g_NetPlaySetupDiag ( NULL ) , g_CheatsWindow ( NULL )
2009-09-08 19:54:31 +00:00
, m_ToolBar ( NULL ) , m_ToolBarDebug ( NULL ) , m_ToolBarAui ( NULL )
2010-07-30 03:51:49 +00:00
, m_GameListCtrl ( NULL ) , m_Panel ( NULL )
2010-04-12 20:41:38 +00:00
, m_RenderFrame ( NULL ) , m_RenderParent ( NULL )
2011-03-27 02:55:08 +00:00
, m_LogWindow ( NULL ) , m_LogConfigWindow ( NULL )
, m_FifoPlayerDlg ( NULL ) , UseDebugger ( _UseDebugger )
2010-07-08 23:27:51 +00:00
, m_bBatchMode ( _BatchMode ) , m_bEdit ( false ) , m_bTabSplit ( false ) , m_bNoDocking ( false )
2010-07-30 03:51:49 +00:00
, m_bGameLoading ( false )
2008-12-08 05:30:24 +00:00
{
2010-07-26 03:46:14 +00:00
for ( int i = 0 ; i < = IDM_CODEWINDOW - IDM_LOGWINDOW ; i + + )
2010-07-22 02:05:28 +00:00
bFloatWindow [ i ] = false ;
2009-09-01 15:16:44 +00:00
if ( ShowLogWindow ) SConfig : : GetInstance ( ) . m_InterfaceLogWindow = true ;
2009-09-01 14:33:16 +00:00
// Give it a console early to show potential messages from this onward
2011-04-01 07:43:02 +00:00
ConsoleListener * Console = LogManager : : GetInstance ( ) - > GetConsoleListener ( ) ;
2009-09-01 19:47:04 +00:00
if ( SConfig : : GetInstance ( ) . m_InterfaceConsole ) Console - > Open ( ) ;
2009-08-27 15:53:19 +00:00
2009-08-25 06:34:58 +00:00
// Start debugging mazimized
2009-09-06 18:54:20 +00:00
if ( UseDebugger ) this - > Maximize ( true ) ;
2009-08-25 01:50:27 +00:00
// Debugger class
if ( UseDebugger )
2009-08-30 19:44:42 +00:00
{
2009-09-07 12:40:43 +00:00
g_pCodeWindow = new CCodeWindow ( SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter , this , IDM_CODEWINDOW ) ;
2010-07-26 03:46:14 +00:00
LoadIniPerspectives ( ) ;
2010-07-28 15:22:27 +00:00
g_pCodeWindow - > Load ( ) ;
2010-07-24 02:36:22 +00:00
}
2009-08-25 01:50:27 +00:00
2010-07-24 02:36:22 +00:00
// Create toolbar bitmaps
2008-12-08 05:30:24 +00:00
InitBitmaps ( ) ;
2008-12-09 14:57:55 +00:00
// Give it a status bar
2010-07-30 03:51:49 +00:00
SetStatusBar ( CreateStatusBar ( 2 , wxST_SIZEGRIP , ID_STATUSBAR ) ) ;
2009-03-18 17:17:58 +00:00
if ( ! SConfig : : GetInstance ( ) . m_InterfaceStatusbar )
2010-07-30 03:51:49 +00:00
GetStatusBar ( ) - > Hide ( ) ;
2008-12-09 05:37:15 +00:00
2009-01-04 21:53:41 +00:00
// Give it a menu bar
2008-12-08 05:30:24 +00:00
CreateMenu ( ) ;
2009-09-01 13:06:37 +00:00
// ---------------
2009-09-01 12:44:02 +00:00
// Main panel
2009-08-27 11:08:52 +00:00
// This panel is the parent for rendering and it holds the gamelistctrl
2009-01-04 21:53:41 +00:00
m_Panel = new CPanel ( this , IDM_MPANEL ) ;
2009-03-18 17:17:58 +00:00
2008-12-08 05:30:24 +00:00
m_GameListCtrl = new CGameListCtrl ( m_Panel , LIST_CTRL ,
wxDefaultPosition , wxDefaultSize ,
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT ) ;
2010-07-24 02:36:22 +00:00
wxBoxSizer * sizerPanel = new wxBoxSizer ( wxHORIZONTAL ) ;
2009-03-07 05:32:16 +00:00
sizerPanel - > Add ( m_GameListCtrl , 1 , wxEXPAND | wxALL ) ;
2008-12-08 05:30:24 +00:00
m_Panel - > SetSizer ( sizerPanel ) ;
2009-09-01 13:06:37 +00:00
// ---------------
2008-12-08 05:30:24 +00:00
2009-09-01 19:47:04 +00:00
// Manager
2010-02-19 18:32:40 +00:00
// wxAUI_MGR_LIVE_RESIZE does not exist in the wxWidgets 2.8.9 that comes with Ubuntu 9.04
// Could just check for wxWidgets version if it becomes a problem.
2009-09-01 19:47:04 +00:00
m_Mgr = new wxAuiManager ( this , wxAUI_MGR_DEFAULT | wxAUI_MGR_LIVE_RESIZE ) ;
2009-08-27 07:33:07 +00:00
2011-03-23 02:06:40 +00:00
m_Mgr - > AddPane ( m_Panel , wxAuiPaneInfo ( )
. Name ( _T ( " Pane 0 " ) ) . Caption ( _T ( " Pane 0 " ) ) . PaneBorder ( false )
. CaptionVisible ( false ) . Layer ( 0 ) . Center ( ) . Show ( ) ) ;
if ( ! g_pCodeWindow )
2010-07-30 03:51:49 +00:00
m_Mgr - > AddPane ( CreateEmptyNotebook ( ) , wxAuiPaneInfo ( )
2011-01-06 13:57:46 +00:00
. Name ( _T ( " Pane 1 " ) ) . Caption ( _ ( " Logging " ) ) . CaptionVisible ( true )
2010-07-30 03:51:49 +00:00
. Layer ( 0 ) . FloatingSize ( wxSize ( 600 , 350 ) ) . CloseButton ( true ) . Hide ( ) ) ;
2011-03-23 02:06:40 +00:00
AuiFullscreen = m_Mgr - > SavePerspective ( ) ;
2009-08-27 07:33:07 +00:00
2009-08-27 10:46:43 +00:00
// Create toolbar
RecreateToolbar ( ) ;
if ( ! SConfig : : GetInstance ( ) . m_InterfaceToolbar ) DoToggleToolbar ( false ) ;
2010-08-02 01:52:00 +00:00
m_LogWindow = new CLogWindow ( this , IDM_LOGWINDOW ) ;
m_LogWindow - > Hide ( ) ;
m_LogWindow - > Disable ( ) ;
2011-06-24 06:50:50 +00:00
g_TASInputDlg = new TASInputDlg ( this ) ;
Movie : : SetInputManip ( TASManipFunction ) ;
2011-12-18 09:15:59 +00:00
State : : SetOnAfterLoadCallback ( OnAfterLoadCallback ) ;
2009-08-27 10:46:43 +00:00
// Setup perspectives
2009-09-07 12:40:43 +00:00
if ( g_pCodeWindow )
2010-07-24 02:36:22 +00:00
{
2009-08-27 07:33:07 +00:00
// Load perspective
2009-08-31 05:56:30 +00:00
DoLoadPerspective ( ) ;
2009-08-27 07:33:07 +00:00
}
else
2009-08-31 05:56:30 +00:00
{
2010-07-19 02:09:34 +00:00
if ( SConfig : : GetInstance ( ) . m_InterfaceLogWindow )
2010-08-01 04:09:59 +00:00
ToggleLogWindow ( true ) ;
2011-02-21 15:01:00 +00:00
if ( SConfig : : GetInstance ( ) . m_InterfaceLogConfigWindow )
ToggleLogConfigWindow ( true ) ;
2010-07-19 02:09:34 +00:00
if ( SConfig : : GetInstance ( ) . m_InterfaceConsole )
2010-08-01 04:09:59 +00:00
ToggleConsole ( true ) ;
2009-08-31 05:56:30 +00:00
}
2009-08-27 10:10:07 +00:00
2009-09-15 21:35:32 +00:00
// Show window
Show ( ) ;
2008-12-08 05:30:24 +00:00
2010-07-24 02:36:22 +00:00
// Commit
2009-08-25 01:50:27 +00:00
m_Mgr - > Update ( ) ;
2009-01-04 21:53:41 +00:00
// Create cursors
2009-01-04 23:24:13 +00:00
# ifdef _WIN32
CreateCursor ( ) ;
2011-04-27 01:10:58 +00:00
SetToolTip ( wxT ( " " ) ) ;
2011-04-20 15:25:21 +00:00
GetToolTip ( ) - > SetAutoPop ( 25000 ) ;
2009-01-04 23:24:13 +00:00
# endif
2010-04-22 04:28:34 +00:00
# if defined(HAVE_XRANDR) && HAVE_XRANDR
m_XRRConfig = new X11Utils : : XRRConfiguration ( X11Utils : : XDisplayFromHandle ( GetHandle ( ) ) ,
2010-08-01 04:09:59 +00:00
X11Utils : : XWindowFromHandle ( GetHandle ( ) ) ) ;
2010-04-22 04:28:34 +00:00
# endif
2009-09-01 12:44:02 +00:00
// -------------------------
// Connect event handlers
2009-09-03 07:56:35 +00:00
2009-08-29 06:08:14 +00:00
m_Mgr - > Connect ( wxID_ANY , wxEVT_AUI_RENDER , // Resize
wxAuiManagerEventHandler ( CFrame : : OnManagerResize ) ,
2009-09-05 04:50:45 +00:00
( wxObject * ) 0 , this ) ;
2009-09-01 12:44:02 +00:00
// ----------
2009-01-15 06:48:15 +00:00
2009-09-01 12:44:02 +00:00
// Update controls
2008-12-08 05:30:24 +00:00
UpdateGUI ( ) ;
2009-02-16 06:18:18 +00:00
// If we are rerecording create the status bar now instead of later when a game starts
# ifdef RERECORDING
ModifyStatusBar ( ) ;
2009-09-01 12:44:02 +00:00
// It's to early for the OnHostMessage(), we will update the status when Ctrl or Space is pressed
//Core::WriteStatus();
2009-02-16 06:18:18 +00:00
# endif
2008-12-08 05:30:24 +00:00
}
2009-01-04 21:53:41 +00:00
// Destructor
CFrame : : ~ CFrame ( )
2008-12-08 05:30:24 +00:00
{
2010-02-16 08:46:21 +00:00
drives . clear ( ) ;
2009-09-01 12:44:02 +00:00
2010-04-22 04:28:34 +00:00
# if defined(HAVE_XRANDR) && HAVE_XRANDR
delete m_XRRConfig ;
# endif
2009-09-01 12:44:02 +00:00
ClosePages ( ) ;
2010-02-16 04:34:41 +00:00
delete m_Mgr ;
2008-12-08 05:30:24 +00:00
}
2010-04-12 01:33:10 +00:00
bool CFrame : : RendererIsFullscreen ( )
{
if ( Core : : GetState ( ) = = Core : : CORE_RUN | | Core : : GetState ( ) = = Core : : CORE_PAUSE )
{
return m_RenderFrame - > IsFullScreen ( ) ;
}
return false ;
}
2009-01-05 04:08:18 +00:00
void CFrame : : OnQuit ( wxCommandEvent & WXUNUSED ( event ) )
{
Close ( true ) ;
}
2009-09-03 07:56:35 +00:00
// --------
2009-09-01 15:16:44 +00:00
// Events
2009-12-30 09:00:43 +00:00
void CFrame : : OnActive ( wxActivateEvent & event )
{
2010-03-15 23:25:11 +00:00
if ( Core : : GetState ( ) = = Core : : CORE_RUN | | Core : : GetState ( ) = = Core : : CORE_PAUSE )
{
2010-04-12 01:33:10 +00:00
if ( event . GetActive ( ) & & event . GetEventObject ( ) = = m_RenderFrame )
{
# ifdef _WIN32
: : SetFocus ( ( HWND ) m_RenderParent - > GetHandle ( ) ) ;
# else
m_RenderParent - > SetFocus ( ) ;
# endif
if ( SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bHideCursor & &
Core : : GetState ( ) = = Core : : CORE_RUN )
m_RenderParent - > SetCursor ( wxCURSOR_BLANK ) ;
}
2010-03-15 23:25:11 +00:00
else
2010-04-12 01:33:10 +00:00
{
if ( SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bHideCursor )
m_RenderParent - > SetCursor ( wxCURSOR_ARROW ) ;
}
2010-03-15 23:25:11 +00:00
}
2009-12-30 09:00:43 +00:00
event . Skip ( ) ;
}
2009-09-01 15:16:44 +00:00
2009-01-05 04:08:18 +00:00
void CFrame : : OnClose ( wxCloseEvent & event )
{
2010-12-17 15:23:33 +00:00
if ( Core : : GetState ( ) ! = Core : : CORE_UNINITIALIZED )
{
DoStop ( ) ;
if ( Core : : GetState ( ) ! = Core : : CORE_UNINITIALIZED )
return ;
UpdateGUI ( ) ;
}
2010-01-23 06:15:17 +00:00
//Stop Dolphin from saving the minimized Xpos and Ypos
if ( main_frame - > IsIconized ( ) )
main_frame - > Iconize ( false ) ;
2009-04-15 20:19:25 +00:00
// Don't forget the skip or the window won't be destroyed
2009-01-05 04:08:18 +00:00
event . Skip ( ) ;
2010-12-17 15:23:33 +00:00
2009-08-27 01:30:08 +00:00
// Save GUI settings
2010-07-26 03:46:14 +00:00
if ( g_pCodeWindow ) SaveIniPerspectives ( ) ;
2010-07-27 02:39:12 +00:00
// Close the log window now so that its settings are saved
2011-03-23 02:06:40 +00:00
else
{
m_LogWindow - > Close ( ) ;
m_LogWindow = NULL ;
}
2010-07-27 02:39:12 +00:00
2009-09-01 02:41:48 +00:00
// Uninit
m_Mgr - > UnInit ( ) ;
2009-01-05 04:08:18 +00:00
}
2009-08-26 09:19:15 +00:00
2009-09-01 15:16:44 +00:00
// Post events
2009-09-01 07:32:07 +00:00
2009-09-01 15:16:44 +00:00
// Warning: This may cause an endless loop if the event is propagated back to its parent
void CFrame : : PostEvent ( wxCommandEvent & event )
2009-08-27 07:33:07 +00:00
{
2010-07-27 02:39:12 +00:00
if ( g_pCodeWindow & &
event . GetId ( ) > = IDM_INTERPRETER & &
event . GetId ( ) < = IDM_ADDRBOX )
2009-09-03 05:24:30 +00:00
{
event . StopPropagation ( ) ;
2010-01-20 11:49:11 +00:00
g_pCodeWindow - > GetEventHandler ( ) - > AddPendingEvent ( event ) ;
2009-09-03 05:24:30 +00:00
}
else
event . Skip ( ) ;
2009-08-31 05:56:30 +00:00
}
2010-01-18 18:01:03 +00:00
void CFrame : : OnMove ( wxMoveEvent & event )
{
event . Skip ( ) ;
2010-04-12 01:33:10 +00:00
if ( ! IsMaximized ( ) & &
2010-10-17 12:42:04 +00:00
! ( SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bRenderToMain & & RendererIsFullscreen ( ) ) )
2010-04-12 01:33:10 +00:00
{
SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . iPosX = GetPosition ( ) . x ;
SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . iPosY = GetPosition ( ) . y ;
}
2010-01-18 18:01:03 +00:00
}
2010-03-08 23:29:16 +00:00
2009-09-07 12:40:43 +00:00
void CFrame : : OnResize ( wxSizeEvent & event )
{
event . Skip ( ) ;
2010-10-17 12:42:04 +00:00
2010-04-12 01:33:10 +00:00
if ( ! IsMaximized ( ) & &
2011-01-25 03:30:12 +00:00
! ( SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bRenderToMain & & RendererIsFullscreen ( ) ) & &
! ( Core : : GetState ( ) ! = Core : : CORE_UNINITIALIZED & &
SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bRenderToMain & &
SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bRenderWindowAutoSize ) )
2010-04-12 01:33:10 +00:00
{
SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . iWidth = GetSize ( ) . GetWidth ( ) ;
SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . iHeight = GetSize ( ) . GetHeight ( ) ;
}
2011-03-23 02:06:40 +00:00
// Make sure the logger pane is a sane size
if ( ! g_pCodeWindow & & m_LogWindow & & m_Mgr - > GetPane ( _T ( " Pane 1 " ) ) . IsShown ( ) & &
! m_Mgr - > GetPane ( _T ( " Pane 1 " ) ) . IsFloating ( ) & &
( m_LogWindow - > x > GetClientRect ( ) . GetWidth ( ) | |
m_LogWindow - > y > GetClientRect ( ) . GetHeight ( ) ) )
ShowResizePane ( ) ;
2009-09-07 12:40:43 +00:00
}
2009-08-31 05:56:30 +00:00
2009-09-01 12:44:02 +00:00
// Host messages
2009-09-01 13:06:37 +00:00
2008-12-14 17:37:59 +00:00
# ifdef _WIN32
2009-07-02 21:17:36 +00:00
WXLRESULT CFrame : : MSWWindowProc ( WXUINT nMsg , WXWPARAM wParam , WXLPARAM lParam )
{
2011-03-15 23:09:12 +00:00
if ( WM_SYSCOMMAND = = nMsg & & ( SC_SCREENSAVE = = wParam | | SC_MONITORPOWER = = wParam ) )
return 0 ;
else
2010-02-25 06:12:35 +00:00
return wxFrame : : MSWWindowProc ( nMsg , wParam , lParam ) ;
2009-07-02 21:17:36 +00:00
}
2009-01-04 21:53:41 +00:00
# endif
2008-12-08 05:30:24 +00:00
void CFrame : : OnHostMessage ( wxCommandEvent & event )
{
switch ( event . GetId ( ) )
{
2008-12-10 08:57:57 +00:00
case IDM_UPDATEGUI :
UpdateGUI ( ) ;
break ;
case IDM_UPDATESTATUSBAR :
2010-07-30 03:51:49 +00:00
if ( GetStatusBar ( ) ! = NULL )
GetStatusBar ( ) - > SetStatusText ( event . GetString ( ) , event . GetInt ( ) ) ;
2008-12-10 08:57:57 +00:00
break ;
2010-04-12 01:33:10 +00:00
2010-04-15 20:58:34 +00:00
case IDM_UPDATETITLE :
2011-01-11 04:09:11 +00:00
if ( m_RenderFrame ! = NULL )
2010-04-15 20:58:34 +00:00
m_RenderFrame - > SetTitle ( event . GetString ( ) ) ;
break ;
2010-03-15 23:25:11 +00:00
case WM_USER_CREATE :
2010-04-12 01:33:10 +00:00
if ( SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bHideCursor )
m_RenderParent - > SetCursor ( wxCURSOR_BLANK ) ;
2010-03-15 23:25:11 +00:00
break ;
2010-07-19 02:09:34 +00:00
2011-02-01 04:35:25 +00:00
case IDM_WINDOWSIZEREQUEST :
{
std : : pair < int , int > * win_size = ( std : : pair < int , int > * ) ( event . GetClientData ( ) ) ;
OnRenderWindowSizeRequest ( win_size - > first , win_size - > second ) ;
delete win_size ;
}
break ;
2010-11-11 00:55:06 +00:00
# ifdef __WXGTK__
case IDM_PANIC :
2011-07-15 14:49:34 +00:00
{
wxString caption = event . GetString ( ) . BeforeFirst ( ' : ' ) ;
wxString text = event . GetString ( ) . AfterFirst ( ' : ' ) ;
bPanicResult = ( wxYES = = wxMessageBox ( text ,
caption , event . GetInt ( ) ? wxYES_NO : wxOK , wxGetActiveWindow ( ) ) ) ;
panic_event . Set ( ) ;
}
2011-01-30 22:02:47 +00:00
break ;
2010-11-11 00:55:06 +00:00
# endif
2010-02-07 02:41:02 +00:00
case WM_USER_STOP :
2010-03-15 23:25:11 +00:00
DoStop ( ) ;
2010-02-07 06:07:56 +00:00
break ;
2009-09-07 12:40:43 +00:00
}
}
2011-01-07 04:57:59 +00:00
void CFrame : : GetRenderWindowSize ( int & x , int & y , int & width , int & height )
2010-04-12 01:33:10 +00:00
{
2011-02-20 22:56:03 +00:00
# ifdef __WXGTK__
if ( ! wxIsMainThread ( ) )
wxMutexGuiEnter ( ) ;
# endif
2011-01-25 03:30:12 +00:00
m_RenderParent - > GetClientSize ( & width , & height ) ;
2010-04-12 01:33:10 +00:00
m_RenderParent - > GetPosition ( & x , & y ) ;
2011-02-20 22:56:03 +00:00
# ifdef __WXGTK__
if ( ! wxIsMainThread ( ) )
wxMutexGuiLeave ( ) ;
# endif
2010-04-12 01:33:10 +00:00
}
2011-01-25 03:30:12 +00:00
void CFrame : : OnRenderWindowSizeRequest ( int width , int height )
2011-01-07 04:57:59 +00:00
{
2011-02-01 04:35:25 +00:00
if ( Core : : GetState ( ) = = Core : : CORE_UNINITIALIZED | |
! SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bRenderWindowAutoSize | |
2011-01-25 12:52:20 +00:00
RendererIsFullscreen ( ) | | m_RenderFrame - > IsMaximized ( ) )
2011-01-25 03:30:12 +00:00
return ;
2011-01-07 04:57:59 +00:00
2011-02-01 04:35:25 +00:00
int old_width , old_height , log_width = 0 , log_height = 0 ;
2011-01-25 03:30:12 +00:00
m_RenderFrame - > GetClientSize ( & old_width , & old_height ) ;
2011-02-01 04:35:25 +00:00
// Add space for the log/console/debugger window
2011-03-15 12:50:58 +00:00
if ( SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bRenderToMain & &
( SConfig : : GetInstance ( ) . m_InterfaceLogWindow | |
SConfig : : GetInstance ( ) . m_InterfaceConsole | |
SConfig : : GetInstance ( ) . m_InterfaceLogConfigWindow ) & &
2011-02-01 04:35:25 +00:00
! m_Mgr - > GetPane ( wxT ( " Pane 1 " ) ) . IsFloating ( ) )
2011-01-07 04:57:59 +00:00
{
2011-02-01 04:35:25 +00:00
switch ( m_Mgr - > GetPane ( wxT ( " Pane 1 " ) ) . dock_direction )
{
case wxAUI_DOCK_LEFT :
case wxAUI_DOCK_RIGHT :
log_width = m_Mgr - > GetPane ( wxT ( " Pane 1 " ) ) . rect . GetWidth ( ) ;
break ;
case wxAUI_DOCK_TOP :
case wxAUI_DOCK_BOTTOM :
log_height = m_Mgr - > GetPane ( wxT ( " Pane 1 " ) ) . rect . GetHeight ( ) ;
break ;
}
2011-01-07 04:57:59 +00:00
}
2011-02-01 04:35:25 +00:00
if ( old_width ! = width + log_width | | old_height ! = height + log_height )
m_RenderFrame - > SetClientSize ( width + log_width , height + log_height ) ;
2011-01-07 04:57:59 +00:00
}
2010-04-12 01:33:10 +00:00
bool CFrame : : RendererHasFocus ( )
{
2010-06-26 18:50:22 +00:00
if ( m_RenderParent = = NULL )
2010-06-26 13:07:33 +00:00
return false ;
2010-04-12 01:33:10 +00:00
# ifdef _WIN32
2010-06-26 13:07:33 +00:00
if ( m_RenderParent - > GetParent ( ) - > GetHWND ( ) = = GetForegroundWindow ( ) )
return true ;
2010-04-12 01:33:10 +00:00
# else
2010-06-26 18:50:22 +00:00
if ( wxWindow : : FindFocus ( ) = = NULL )
return false ;
2010-06-26 13:07:33 +00:00
// Why these different cases?
if ( m_RenderParent = = wxWindow : : FindFocus ( ) | |
2010-08-01 04:09:59 +00:00
m_RenderParent = = wxWindow : : FindFocus ( ) - > GetParent ( ) | |
m_RenderParent - > GetParent ( ) = = wxWindow : : FindFocus ( ) - > GetParent ( ) )
2010-06-26 13:07:33 +00:00
return true ;
2010-04-12 01:33:10 +00:00
# endif
2010-06-26 13:07:33 +00:00
return false ;
2010-04-12 01:33:10 +00:00
}
2009-01-28 16:51:05 +00:00
void CFrame : : OnGameListCtrl_ItemActivated ( wxListEvent & WXUNUSED ( event ) )
2009-01-07 09:06:42 +00:00
{
2009-06-09 05:08:58 +00:00
// Show all platforms and regions if...
// 1. All platforms are set to hide
// 2. All Regions are set to hide
// Otherwise call BootGame to either...
// 1. Boot the selected iso
2009-07-01 04:55:53 +00:00
// 2. Boot the default or last loaded iso.
// 3. Call BrowseForDirectory if the gamelist is empty
2009-06-09 05:08:58 +00:00
if ( ! m_GameListCtrl - > GetGameNames ( ) . size ( ) & &
2009-09-25 16:29:00 +00:00
! ( ( SConfig : : GetInstance ( ) . m_ListGC & &
SConfig : : GetInstance ( ) . m_ListWii & &
2009-06-09 05:08:58 +00:00
SConfig : : GetInstance ( ) . m_ListWad ) & &
2009-09-25 16:29:00 +00:00
( SConfig : : GetInstance ( ) . m_ListJap & &
SConfig : : GetInstance ( ) . m_ListUsa & &
2010-01-11 05:07:56 +00:00
SConfig : : GetInstance ( ) . m_ListPal & &
SConfig : : GetInstance ( ) . m_ListFrance & &
SConfig : : GetInstance ( ) . m_ListItaly & &
SConfig : : GetInstance ( ) . m_ListKorea & &
SConfig : : GetInstance ( ) . m_ListTaiwan & &
SConfig : : GetInstance ( ) . m_ListUnknown ) ) )
2009-06-09 05:08:58 +00:00
{
2010-01-11 05:07:56 +00:00
SConfig : : GetInstance ( ) . m_ListGC = SConfig : : GetInstance ( ) . m_ListWii =
SConfig : : GetInstance ( ) . m_ListWad = SConfig : : GetInstance ( ) . m_ListJap =
SConfig : : GetInstance ( ) . m_ListUsa = SConfig : : GetInstance ( ) . m_ListPal =
SConfig : : GetInstance ( ) . m_ListFrance = SConfig : : GetInstance ( ) . m_ListItaly =
2010-07-24 02:36:22 +00:00
SConfig : : GetInstance ( ) . m_ListKorea = SConfig : : GetInstance ( ) . m_ListTaiwan =
2010-01-11 05:07:56 +00:00
SConfig : : GetInstance ( ) . m_ListUnknown = true ;
2009-06-09 05:08:58 +00:00
GetMenuBar ( ) - > FindItem ( IDM_LISTGC ) - > Check ( true ) ;
GetMenuBar ( ) - > FindItem ( IDM_LISTWII ) - > Check ( true ) ;
GetMenuBar ( ) - > FindItem ( IDM_LISTWAD ) - > Check ( true ) ;
GetMenuBar ( ) - > FindItem ( IDM_LISTJAP ) - > Check ( true ) ;
GetMenuBar ( ) - > FindItem ( IDM_LISTUSA ) - > Check ( true ) ;
GetMenuBar ( ) - > FindItem ( IDM_LISTPAL ) - > Check ( true ) ;
2010-01-11 05:07:56 +00:00
GetMenuBar ( ) - > FindItem ( IDM_LISTFRANCE ) - > Check ( true ) ;
GetMenuBar ( ) - > FindItem ( IDM_LISTITALY ) - > Check ( true ) ;
GetMenuBar ( ) - > FindItem ( IDM_LISTKOREA ) - > Check ( true ) ;
GetMenuBar ( ) - > FindItem ( IDM_LISTTAIWAN ) - > Check ( true ) ;
GetMenuBar ( ) - > FindItem ( IDM_LIST_UNK ) - > Check ( true ) ;
2009-06-09 05:08:58 +00:00
m_GameListCtrl - > Update ( ) ;
2010-07-24 02:36:22 +00:00
}
2010-08-03 03:20:44 +00:00
else if ( ! m_GameListCtrl - > GetGameNames ( ) . size ( ) )
m_GameListCtrl - > BrowseForDirectory ( ) ;
2010-01-18 12:10:51 +00:00
else
// Game started by double click
2010-04-17 03:17:36 +00:00
BootGame ( std : : string ( " " ) ) ;
2009-01-07 09:06:42 +00:00
}
2009-01-28 16:51:05 +00:00
2010-04-12 01:33:10 +00:00
bool IsHotkey ( wxKeyEvent & event , int Id )
{
return ( event . GetKeyCode ( ) = = SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . iHotkey [ Id ] & &
event . GetModifiers ( ) = = SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . iHotkeyModifier [ Id ] ) ;
}
2011-02-14 01:18:01 +00:00
int GetCmdForHotkey ( unsigned int key )
{
if ( key = = HK_OPEN )
return wxID_OPEN ;
if ( key = = HK_CHANGE_DISC )
return IDM_CHANGEDISC ;
if ( key = = HK_REFRESH_LIST )
return wxID_REFRESH ;
if ( key = = HK_PLAY_PAUSE )
return IDM_PLAY ;
if ( key = = HK_STOP )
return IDM_STOP ;
if ( key = = HK_RESET )
return IDM_RESET ;
if ( key = = HK_FRAME_ADVANCE )
return IDM_FRAMESTEP ;
if ( key = = HK_START_RECORDING )
return IDM_RECORD ;
if ( key = = HK_PLAY_RECORDING )
return IDM_PLAYRECORD ;
if ( key = = HK_EXPORT_RECORDING )
return IDM_RECORDEXPORT ;
if ( key = = HK_READ_ONLY_MODE )
return IDM_RECORDREADONLY ;
if ( key = = HK_FULLSCREEN )
return IDM_TOGGLE_FULLSCREEN ;
if ( key = = HK_SCREENSHOT )
return IDM_SCREENSHOT ;
if ( key = = HK_WIIMOTE1_CONNECT )
return IDM_CONNECT_WIIMOTE1 ;
if ( key = = HK_WIIMOTE2_CONNECT )
return IDM_CONNECT_WIIMOTE2 ;
if ( key = = HK_WIIMOTE3_CONNECT )
return IDM_CONNECT_WIIMOTE3 ;
if ( key = = HK_WIIMOTE4_CONNECT )
return IDM_CONNECT_WIIMOTE4 ;
if ( key = = HK_LOAD_STATE_SLOT_1 )
return IDM_LOADSLOT1 ;
if ( key = = HK_LOAD_STATE_SLOT_2 )
return IDM_LOADSLOT2 ;
if ( key = = HK_LOAD_STATE_SLOT_3 )
return IDM_LOADSLOT3 ;
if ( key = = HK_LOAD_STATE_SLOT_4 )
return IDM_LOADSLOT4 ;
if ( key = = HK_LOAD_STATE_SLOT_5 )
return IDM_LOADSLOT5 ;
if ( key = = HK_LOAD_STATE_SLOT_6 )
return IDM_LOADSLOT6 ;
if ( key = = HK_LOAD_STATE_SLOT_7 )
return IDM_LOADSLOT7 ;
if ( key = = HK_LOAD_STATE_SLOT_8 )
return IDM_LOADSLOT8 ;
if ( key = = HK_SAVE_STATE_SLOT_1 )
return IDM_SAVESLOT1 ;
if ( key = = HK_SAVE_STATE_SLOT_2 )
return IDM_SAVESLOT2 ;
if ( key = = HK_SAVE_STATE_SLOT_3 )
return IDM_SAVESLOT3 ;
if ( key = = HK_SAVE_STATE_SLOT_4 )
return IDM_SAVESLOT4 ;
if ( key = = HK_SAVE_STATE_SLOT_5 )
return IDM_SAVESLOT5 ;
if ( key = = HK_SAVE_STATE_SLOT_6 )
return IDM_SAVESLOT6 ;
if ( key = = HK_SAVE_STATE_SLOT_7 )
return IDM_SAVESLOT7 ;
if ( key = = HK_SAVE_STATE_SLOT_8 )
return IDM_SAVESLOT8 ;
return - 1 ;
}
2011-12-18 09:15:59 +00:00
void OnAfterLoadCallback ( )
{
2011-12-19 04:38:54 +00:00
// warning: this gets called from the CPU thread, so we should only queue things to do on the proper thread
2011-12-18 09:15:59 +00:00
if ( main_frame )
2011-12-19 04:38:54 +00:00
{
wxCommandEvent event ( wxEVT_HOST_COMMAND , IDM_UPDATEGUI ) ;
main_frame - > GetEventHandler ( ) - > AddPendingEvent ( event ) ;
}
2011-12-18 09:15:59 +00:00
}
2011-06-24 06:50:50 +00:00
void TASManipFunction ( SPADStatus * PadStatus , int controllerID )
{
if ( main_frame )
main_frame - > g_TASInputDlg - > GetValues ( PadStatus , controllerID ) ;
}
2008-12-08 05:30:24 +00:00
void CFrame : : OnKeyDown ( wxKeyEvent & event )
{
2011-03-15 21:57:00 +00:00
if ( Core : : GetState ( ) ! = Core : : CORE_UNINITIALIZED & &
2011-07-13 05:53:56 +00:00
( RendererHasFocus ( ) | | g_TASInputDlg - > HasFocus ( ) ) )
2008-12-08 05:30:24 +00:00
{
2010-04-25 20:10:16 +00:00
int WiimoteId = - 1 ;
2010-04-10 20:44:56 +00:00
// Toggle fullscreen
2010-04-12 01:33:10 +00:00
if ( IsHotkey ( event , HK_FULLSCREEN ) )
DoFullscreen ( ! RendererIsFullscreen ( ) ) ;
2010-08-08 06:00:22 +00:00
// Send Debugger keys to CodeWindow
2011-02-14 18:53:54 +00:00
else if ( g_pCodeWindow & & ( event . GetKeyCode ( ) > = WXK_F9 & & event . GetKeyCode ( ) < = WXK_F11 ) )
2010-08-08 06:00:22 +00:00
event . Skip ( ) ;
2010-04-12 01:33:10 +00:00
// Pause and Unpause
else if ( IsHotkey ( event , HK_PLAY_PAUSE ) )
DoPause ( ) ;
// Stop
else if ( IsHotkey ( event , HK_STOP ) )
DoStop ( ) ;
2010-08-08 00:13:05 +00:00
// Screenshot hotkey
else if ( IsHotkey ( event , HK_SCREENSHOT ) )
2011-03-15 23:09:12 +00:00
Core : : SaveScreenShot ( ) ;
2010-04-25 20:10:16 +00:00
// Wiimote connect and disconnect hotkeys
else if ( IsHotkey ( event , HK_WIIMOTE1_CONNECT ) )
WiimoteId = 0 ;
else if ( IsHotkey ( event , HK_WIIMOTE2_CONNECT ) )
WiimoteId = 1 ;
else if ( IsHotkey ( event , HK_WIIMOTE3_CONNECT ) )
WiimoteId = 2 ;
else if ( IsHotkey ( event , HK_WIIMOTE4_CONNECT ) )
WiimoteId = 3 ;
2010-08-08 00:13:05 +00:00
// State save and state load hotkeys
2011-02-14 01:18:01 +00:00
/*else if (event.GetKeyCode() >= WXK_F1 && event.GetKeyCode() <= WXK_F8)
2010-04-12 01:33:10 +00:00
{
int slot_number = event . GetKeyCode ( ) - WXK_F1 + 1 ;
if ( event . GetModifiers ( ) = = wxMOD_NONE )
2011-03-17 10:17:45 +00:00
State : : Load ( slot_number ) ;
2010-04-12 01:33:10 +00:00
else if ( event . GetModifiers ( ) = = wxMOD_SHIFT )
2011-03-17 10:17:45 +00:00
State : : Save ( slot_number ) ;
2010-04-25 20:10:16 +00:00
else
event . Skip ( ) ;
2011-02-14 01:18:01 +00:00
} */
2010-04-19 19:20:33 +00:00
else if ( event . GetKeyCode ( ) = = WXK_F11 & & event . GetModifiers ( ) = = wxMOD_NONE )
2011-03-17 10:17:45 +00:00
State : : LoadLastSaved ( ) ;
2010-04-19 19:20:33 +00:00
else if ( event . GetKeyCode ( ) = = WXK_F12 )
2010-04-12 01:33:10 +00:00
{
if ( event . GetModifiers ( ) = = wxMOD_NONE )
2011-03-17 10:17:45 +00:00
State : : UndoSaveState ( ) ;
2010-04-12 01:33:10 +00:00
else if ( event . GetModifiers ( ) = = wxMOD_SHIFT )
2011-03-17 10:17:45 +00:00
State : : UndoLoadState ( ) ;
2010-06-13 09:26:00 +00:00
else
event . Skip ( ) ;
2010-04-12 01:33:10 +00:00
}
2010-06-13 09:26:00 +00:00
else
2011-02-14 01:18:01 +00:00
{
unsigned int i = NUM_HOTKEYS ;
if ( ! SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bRenderToMain )
{
for ( i = 0 ; i < NUM_HOTKEYS ; i + + )
{
if ( IsHotkey ( event , i ) )
{
int cmd = GetCmdForHotkey ( i ) ;
if ( cmd > = 0 )
{
wxCommandEvent evt ( wxEVT_COMMAND_MENU_SELECTED , cmd ) ;
wxMenuItem * item = GetMenuBar ( ) - > FindItem ( cmd ) ;
if ( item & & item - > IsCheckable ( ) )
{
item - > wxMenuItemBase : : Toggle ( ) ;
evt . SetInt ( item - > IsChecked ( ) ) ;
}
2011-02-22 02:02:56 +00:00
GetEventHandler ( ) - > AddPendingEvent ( evt ) ;
2011-02-14 01:18:01 +00:00
break ;
}
}
}
}
2010-12-22 20:25:24 +00:00
// On OS X, we claim all keyboard events while
// emulation is running to avoid wxWidgets sounding
// the system beep for unhandled key events when
// receiving pad/wiimote keypresses which take an
// entirely different path through the HID subsystem.
# ifndef __APPLE__
// On other platforms, we leave the key event alone
// so it can be passed on to the windowing system.
2011-02-14 01:18:01 +00:00
if ( i = = NUM_HOTKEYS )
event . Skip ( ) ;
2010-12-20 17:36:51 +00:00
# endif
2011-02-14 01:18:01 +00:00
}
2010-04-19 19:20:33 +00:00
2010-04-25 20:10:16 +00:00
// Actually perform the wiimote connection or disconnection
if ( WiimoteId > = 0 )
{
2011-01-07 15:18:00 +00:00
bool connect = ! GetMenuBar ( ) - > IsChecked ( IDM_CONNECT_WIIMOTE1 + WiimoteId ) ;
ConnectWiimote ( WiimoteId , connect ) ;
2010-04-25 20:10:16 +00:00
}
2011-02-14 02:18:03 +00:00
// Send the OSD hotkeys to the video backend
2010-04-19 19:20:33 +00:00
if ( event . GetKeyCode ( ) > = ' 3 ' & & event . GetKeyCode ( ) < = ' 7 ' & & event . GetModifiers ( ) = = wxMOD_NONE )
{
# ifdef _WIN32
PostMessage ( ( HWND ) Core : : GetWindowHandle ( ) , WM_USER , WM_USER_KEYDOWN , event . GetKeyCode ( ) ) ;
# elif defined(HAVE_X11) && HAVE_X11
2010-07-16 14:14:57 +00:00
X11Utils : : SendKeyEvent ( X11Utils : : XDisplayFromHandle ( GetHandle ( ) ) , event . GetKeyCode ( ) ) ;
2010-04-19 19:20:33 +00:00
# endif
}
2011-02-14 02:18:03 +00:00
// Send the freelook hotkeys to the video backend
2010-12-21 23:58:25 +00:00
if ( ( event . GetKeyCode ( ) = = ' ) ' | | event . GetKeyCode ( ) = = ' ( ' | |
event . GetKeyCode ( ) = = ' 0 ' | | event . GetKeyCode ( ) = = ' 9 ' | |
event . GetKeyCode ( ) = = ' W ' | | event . GetKeyCode ( ) = = ' S ' | |
event . GetKeyCode ( ) = = ' A ' | | event . GetKeyCode ( ) = = ' D ' | |
event . GetKeyCode ( ) = = ' R ' )
2010-04-19 19:20:33 +00:00
& & event . GetModifiers ( ) = = wxMOD_SHIFT )
2010-12-21 23:58:25 +00:00
{
# ifdef _WIN32
2010-04-19 19:20:33 +00:00
PostMessage ( ( HWND ) Core : : GetWindowHandle ( ) , WM_USER , WM_USER_KEYDOWN , event . GetKeyCode ( ) ) ;
2010-12-21 23:58:25 +00:00
# elif defined(HAVE_X11) && HAVE_X11
X11Utils : : SendKeyEvent ( X11Utils : : XDisplayFromHandle ( GetHandle ( ) ) , event . GetKeyCode ( ) ) ;
2010-04-19 19:20:33 +00:00
# endif
2010-12-21 23:58:25 +00:00
}
2010-04-10 20:44:56 +00:00
}
2010-04-12 01:33:10 +00:00
else
event . Skip ( ) ;
2008-12-28 18:50:24 +00:00
}
void CFrame : : OnKeyUp ( wxKeyEvent & event )
{
2009-09-06 13:36:05 +00:00
event . Skip ( ) ;
2008-12-08 05:30:24 +00:00
}
2009-09-01 12:44:02 +00:00
2010-12-21 23:58:25 +00:00
void CFrame : : OnMouse ( wxMouseEvent & event )
{
# if defined(HAVE_X11) && HAVE_X11
2011-06-18 04:04:48 +00:00
if ( Core : : GetState ( ) ! = Core : : CORE_UNINITIALIZED )
2010-12-21 23:58:25 +00:00
{
if ( event . Dragging ( ) )
X11Utils : : SendMotionEvent ( X11Utils : : XDisplayFromHandle ( GetHandle ( ) ) ,
event . GetPosition ( ) . x , event . GetPosition ( ) . y ) ;
else
X11Utils : : SendButtonEvent ( X11Utils : : XDisplayFromHandle ( GetHandle ( ) ) , event . GetButton ( ) ,
event . GetPosition ( ) . x , event . GetPosition ( ) . y , event . ButtonDown ( ) ) ;
}
# endif
2011-06-02 23:36:50 +00:00
event . Skip ( ) ;
2010-12-21 23:58:25 +00:00
}
2009-09-06 13:36:05 +00:00
void CFrame : : DoFullscreen ( bool bF )
2009-09-01 15:16:44 +00:00
{
2010-04-22 04:28:34 +00:00
ToggleDisplayMode ( bF ) ;
2011-03-24 16:51:37 +00:00
m_RenderFrame - > ShowFullScreen ( bF , wxFULLSCREEN_ALL ) ;
2010-04-22 04:28:34 +00:00
if ( SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bRenderToMain )
2009-09-01 15:16:44 +00:00
{
2010-04-22 04:28:34 +00:00
if ( bF )
2009-10-24 21:31:28 +00:00
{
2010-04-22 04:28:34 +00:00
// Save the current mode before going to fullscreen
AuiCurrent = m_Mgr - > SavePerspective ( ) ;
m_Mgr - > LoadPerspective ( AuiFullscreen , true ) ;
2009-10-24 21:31:28 +00:00
}
2010-04-12 01:33:10 +00:00
else
2010-04-22 04:28:34 +00:00
{
// Restore saved perspective
m_Mgr - > LoadPerspective ( AuiCurrent , true ) ;
}
2010-03-15 23:25:11 +00:00
}
2010-04-22 04:28:34 +00:00
else
m_RenderFrame - > Raise ( ) ;
2009-09-05 04:50:45 +00:00
}
2011-02-13 22:36:12 +00:00
2011-02-20 23:42:21 +00:00
const CGameListCtrl * CFrame : : GetGameListCtrl ( ) const
2011-02-13 22:36:12 +00:00
{
2011-02-20 23:42:21 +00:00
return m_GameListCtrl ;
2011-02-13 22:36:12 +00:00
}