/[pcsx2_0.9.7]/branch/r3113_0.9.7_beta_reference/pcsx2/gui/MainFrame.cpp
ViewVC logotype

Contents of /branch/r3113_0.9.7_beta_reference/pcsx2/gui/MainFrame.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 174 - (show annotations) (download)
Mon Sep 13 17:24:24 2010 UTC (9 years, 11 months ago) by william
File size: 25136 byte(s)
merge r171-173 from https://svn.netsolutions.dnsalias.com/websvn/ps2/pcsx2/pcsx2_0.9.7/branch/debug/0.X/0.9.X/0.9.7/r3113
-- pick up:
* local versioning support from trunk
* get rig of annoying warnings
1 /* PCSX2 - PS2 Emulator for PCs
2 * Copyright (C) 2002-2010 PCSX2 Dev Team
3 *
4 * PCSX2 is free software: you can redistribute it and/or modify it under the terms
5 * of the GNU Lesser General Public License as published by the Free Software Found-
6 * ation, either version 3 of the License, or (at your option) any later version.
7 *
8 * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10 * PURPOSE. See the GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License along with PCSX2.
13 * If not, see <http://www.gnu.org/licenses/>.
14 */
15
16 #include "PrecompiledHeader.h"
17 #include "MainFrame.h"
18 #include "AppSaveStates.h"
19 #include "ConsoleLogger.h"
20 #include "MSWstuff.h"
21
22 #include "Dialogs/ModalPopups.h"
23 #include "IsoDropTarget.h"
24
25 #include <wx/iconbndl.h>
26
27 #if _MSC_VER
28 # include "svnrev.h"
29 #endif
30
31 // ------------------------------------------------------------------------
32 wxMenu* MainEmuFrame::MakeStatesSubMenu( int baseid ) const
33 {
34 wxMenu* mnuSubstates = new wxMenu();
35
36 for (int i = 0; i < 10; i++)
37 {
38 mnuSubstates->Append( baseid+i+1, wxsFormat(L"Slot %d", i) );
39 }
40 mnuSubstates->AppendSeparator();
41 mnuSubstates->Append( baseid - 1, _("Other...") );
42 return mnuSubstates;
43 }
44
45 void MainEmuFrame::UpdateIsoSrcSelection()
46 {
47 MenuIdentifiers cdsrc = MenuId_Src_Iso;
48
49 switch( g_Conf->CdvdSource )
50 {
51 case CDVDsrc_Iso: cdsrc = MenuId_Src_Iso; break;
52 case CDVDsrc_Plugin: cdsrc = MenuId_Src_Plugin; break;
53 case CDVDsrc_NoDisc: cdsrc = MenuId_Src_NoDisc; break;
54
55 jNO_DEFAULT
56 }
57 sMenuBar.Check( cdsrc, true );
58 m_statusbar.SetStatusText( CDVD_SourceLabels[g_Conf->CdvdSource], 1 );
59
60 //sMenuBar.SetLabel( MenuId_Src_Iso, wxsFormat( L"%s -> %s", _("Iso"),
61 // exists ? Path::GetFilename(g_Conf->CurrentIso).c_str() : _("Empty") ) );
62 }
63
64 // ------------------------------------------------------------------------
65 // MainFrame OnEvent Handlers
66 // ------------------------------------------------------------------------
67
68 // Close out the console log windows along with the main emu window.
69 // Note: This event only happens after a close event has occurred and was *not* veto'd. Ie,
70 // it means it's time to provide an unconditional closure of said window.
71 //
72 void MainEmuFrame::OnCloseWindow(wxCloseEvent& evt)
73 {
74 if( IsBeingDeleted() ) return;
75
76 CoreThread.Suspend();
77
78 bool isClosing = false;
79
80 if( !evt.CanVeto() )
81 {
82 // Mandatory destruction...
83 isClosing = true;
84 }
85 else
86 {
87 // TODO : Add confirmation prior to exit here!
88 // Problem: Suspend is often slow because it needs to wait until the current EE frame
89 // has finished processing (if the GS or logging has incurred severe overhead this makes
90 // closing PCSX2 difficult). A non-blocking suspend with modal dialog might suffice
91 // however. --air
92
93 //evt.Veto( true );
94
95 }
96
97 wxGetApp().PrepForExit();
98 sApp.OnMainFrameClosed( GetId() );
99
100 if( m_menubar.FindItem(MenuId_IsoSelector) )
101 m_menuCDVD.Remove(MenuId_IsoSelector);
102
103 RemoveEventHandler( &wxGetApp().GetRecentIsoManager() );
104
105 evt.Skip();
106 }
107
108 void MainEmuFrame::OnMoveAround( wxMoveEvent& evt )
109 {
110 // Uncomment this when doing logger stress testing (and then move the window around
111 // while the logger spams itself)
112 // ... makes for a good test of the message pump's responsiveness.
113 if( EnableThreadedLoggingTest )
114 Console.Warning( "Threaded Logging Test! (a window move event)" );
115
116 // evt.GetPosition() returns the client area position, not the window frame position.
117 // So read the window's screen-relative position directly.
118 g_Conf->MainGuiPosition = GetScreenPosition();
119
120 // wxGTK note: X sends gratuitous amounts of OnMove messages for various crap actions
121 // like selecting or deselecting a window, which muck up docking logic. We filter them
122 // out using 'lastpos' here. :)
123
124 static wxPoint lastpos( wxDefaultCoord, wxDefaultCoord );
125 if( lastpos == evt.GetPosition() ) return;
126 lastpos = evt.GetPosition();
127
128 if( g_Conf->ProgLogBox.AutoDock )
129 {
130 g_Conf->ProgLogBox.DisplayPosition = GetRect().GetTopRight();
131 if( ConsoleLogFrame* proglog = wxGetApp().GetProgramLog() )
132 proglog->SetPosition( g_Conf->ProgLogBox.DisplayPosition );
133 }
134
135 //evt.Skip();
136 }
137
138 void MainEmuFrame::OnLogBoxHidden()
139 {
140 g_Conf->ProgLogBox.Visible = false;
141 m_MenuItem_Console.Check( false );
142 }
143
144 // ------------------------------------------------------------------------
145 void MainEmuFrame::ConnectMenus()
146 {
147 #define ConnectMenu( id, handler ) \
148 Connect( id, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainEmuFrame::handler) )
149
150 #define ConnectMenuRange( id_start, inc, handler ) \
151 Connect( id_start, id_start + inc, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainEmuFrame::handler) )
152
153 ConnectMenu( MenuId_Config_SysSettings, Menu_SysSettings_Click );
154 ConnectMenu( MenuId_Config_McdSettings, Menu_McdSettings_Click );
155 ConnectMenu( MenuId_Config_AppSettings, Menu_WindowSettings_Click );
156 ConnectMenu( MenuId_Config_BIOS, Menu_SelectPluginsBios_Click );
157 ConnectMenu( MenuId_Config_ResetAll, Menu_ResetAllSettings_Click );
158
159 ConnectMenu( MenuId_Config_Multitap0Toggle, Menu_MultitapToggle_Click );
160 ConnectMenu( MenuId_Config_Multitap1Toggle, Menu_MultitapToggle_Click );
161
162 ConnectMenu( MenuId_Video_WindowSettings, Menu_WindowSettings_Click );
163 ConnectMenu( MenuId_Video_CoreSettings, Menu_GSSettings_Click );
164
165
166 ConnectMenuRange(MenuId_Config_GS, PluginId_Count, Menu_ConfigPlugin_Click);
167 ConnectMenuRange(MenuId_Src_Iso, 3, Menu_CdvdSource_Click);
168
169 for( int i=0; i<PluginId_Count; ++i )
170 ConnectMenu( MenuId_PluginBase_Settings + (i*PluginMenuId_Interval), Menu_ConfigPlugin_Click);
171
172 ConnectMenu( MenuId_Boot_CDVD, Menu_BootCdvd_Click );
173 ConnectMenu( MenuId_Boot_CDVD2, Menu_BootCdvd2_Click );
174 ConnectMenu( MenuId_Boot_ELF, Menu_OpenELF_Click );
175 ConnectMenu( MenuId_IsoBrowse, Menu_IsoBrowse_Click );
176 ConnectMenu( MenuId_EnablePatches, Menu_EnablePatches_Click );
177 ConnectMenu( MenuId_EnableCheats, Menu_EnableCheats_Click );
178 ConnectMenu( MenuId_EnableHostFs, Menu_EnableHostFs_Click );
179 ConnectMenu( MenuId_Exit, Menu_Exit_Click );
180
181 ConnectMenu( MenuId_Sys_SuspendResume, Menu_SuspendResume_Click );
182 ConnectMenu( MenuId_Sys_Restart, Menu_SysReset_Click );
183 ConnectMenu( MenuId_Sys_Shutdown, Menu_SysShutdown_Click );
184
185 ConnectMenu( MenuId_State_LoadOther, Menu_LoadStateOther_Click );
186
187 ConnectMenuRange(MenuId_State_Load01+1, 10, Menu_LoadStates_Click);
188
189 ConnectMenu( MenuId_State_SaveOther, Menu_SaveStateOther_Click );
190
191 ConnectMenuRange(MenuId_State_Save01+1, 10, Menu_SaveStates_Click);
192
193 ConnectMenu( MenuId_Debug_Open, Menu_Debug_Open_Click );
194 ConnectMenu( MenuId_Debug_MemoryDump, Menu_Debug_MemoryDump_Click );
195 ConnectMenu( MenuId_Debug_Logging, Menu_Debug_Logging_Click );
196
197 ConnectMenu( MenuId_Console, Menu_ShowConsole );
198 ConnectMenu( MenuId_Console_Stdio, Menu_ShowConsole_Stdio );
199 ConnectMenu( MenuId_CDVD_Info, Menu_PrintCDVD_Info );
200
201 ConnectMenu( MenuId_About, Menu_ShowAboutBox );
202 }
203
204 void MainEmuFrame::InitLogBoxPosition( AppConfig::ConsoleLogOptions& conf )
205 {
206 conf.DisplaySize.Set(
207 std::min( std::max( conf.DisplaySize.GetWidth(), 160 ), wxGetDisplayArea().GetWidth() ),
208 std::min( std::max( conf.DisplaySize.GetHeight(), 160 ), wxGetDisplayArea().GetHeight() )
209 );
210
211 if( conf.AutoDock )
212 {
213 conf.DisplayPosition = GetScreenPosition() + wxSize( GetSize().x, 0 );
214 }
215 else if( conf.DisplayPosition != wxDefaultPosition )
216 {
217 if( !wxGetDisplayArea().Contains( wxRect( conf.DisplayPosition, conf.DisplaySize ) ) )
218 conf.DisplayPosition = wxDefaultPosition;
219 }
220 }
221
222 void MainEmuFrame::DispatchEvent( const PluginEventType& plugin_evt )
223 {
224 if( !pxAssertMsg( GetMenuBar()!=NULL, "Mainframe menu bar is NULL!" ) ) return;
225
226 //ApplyCoreStatus();
227
228 if( plugin_evt == CorePlugins_Unloaded )
229 {
230 for( int i=0; i<PluginId_Count; ++i )
231 m_PluginMenuPacks[i].OnUnloaded();
232 }
233 else if( plugin_evt == CorePlugins_Loaded )
234 {
235 for( int i=0; i<PluginId_Count; ++i )
236 m_PluginMenuPacks[i].OnLoaded();
237
238 // bleh this makes the menu too cluttered. --air
239 //m_menuCDVD.SetLabel( MenuId_Src_Plugin, wxsFormat( L"%s (%s)", _("Plugin"),
240 // GetCorePlugins().GetName( PluginId_CDVD ).c_str() ) );
241 }
242 }
243
244 void MainEmuFrame::DispatchEvent( const CoreThreadStatus& status )
245 {
246 if( !pxAssertMsg( GetMenuBar()!=NULL, "Mainframe menu bar is NULL!" ) ) return;
247 ApplyCoreStatus();
248 }
249
250 void MainEmuFrame::AppStatusEvent_OnSettingsLoadSave()
251 {
252 // nothing to do here right now.
253 }
254
255 void MainEmuFrame::AppStatusEvent_OnSettingsApplied()
256 {
257 ApplySettings();
258 }
259
260 static int GetPluginMenuId_Settings( PluginsEnum_t pid )
261 {
262 return MenuId_PluginBase_Settings + ((int)pid * PluginMenuId_Interval);
263 }
264
265 static int GetPluginMenuId_Name( PluginsEnum_t pid )
266 {
267 return MenuId_PluginBase_Name + ((int)pid * PluginMenuId_Interval);
268 }
269
270 // ------------------------------------------------------------------------
271 MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title)
272 : wxFrame(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE & ~(wxMAXIMIZE_BOX | wxRESIZE_BORDER) )
273
274 , m_statusbar( *CreateStatusBar(2, 0) )
275 , m_background( this, wxID_ANY, wxGetApp().GetLogoBitmap() )
276
277 // All menu components must be created on the heap!
278
279 , m_menubar( *new wxMenuBar() )
280
281 , m_menuCDVD ( *new wxMenu() )
282 , m_menuSys ( *new wxMenu() )
283 , m_menuConfig ( *new wxMenu() )
284 , m_menuMisc ( *new wxMenu() )
285 , m_menuDebug ( *new wxMenu() )
286
287 , m_LoadStatesSubmenu( *MakeStatesSubMenu( MenuId_State_Load01 ) )
288 , m_SaveStatesSubmenu( *MakeStatesSubMenu( MenuId_State_Save01 ) )
289
290 , m_MenuItem_Console( *new wxMenuItem( &m_menuMisc, MenuId_Console, L"Show Console", wxEmptyString, wxITEM_CHECK ) )
291 , m_MenuItem_Console_Stdio( *new wxMenuItem( &m_menuMisc, MenuId_Console_Stdio, L"Console to Stdio", wxEmptyString, wxITEM_CHECK ) )
292
293 {
294 m_RestartEmuOnDelete = false;
295
296 for( int i=0; i<PluginId_Count; ++i )
297 m_PluginMenuPacks[i].Populate( (PluginsEnum_t)i );
298
299 // ------------------------------------------------------------------------
300 // Initial menubar setup. This needs to be done first so that the menu bar's visible size
301 // can be factored into the window size (which ends up being background+status+menus)
302
303 //m_menubar.Append( &m_menuBoot, _("&Boot") );
304 m_menubar.Append( &m_menuSys, _("&System") );
305 m_menubar.Append( &m_menuCDVD, _("CD&VD") );
306 m_menubar.Append( &m_menuConfig, _("&Config") );
307 m_menubar.Append( &m_menuMisc, _("&Misc") );
308 #ifdef PCSX2_DEVBUILD
309 m_menubar.Append( &m_menuDebug, _("&Debug") );
310 #endif
311 SetMenuBar( &m_menubar );
312
313 // ------------------------------------------------------------------------
314
315 wxSize backsize( m_background.GetSize() );
316
317 wxString wintitle;
318 if( PCSX2_VersionLo & 1 )
319 {
320 // Odd versions: beta / development editions, which feature revision number and compile date.
321 //wintitle.Printf( _("%s %d.%d.%d.%d%s (svn) %s"), pxGetAppName().c_str(), PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo,
322 // SVN_REV, SVN_MODS ? L"m" : wxEmptyString, fromUTF8(__DATE__).c_str() );
323 wintitle.Printf( _("%s %s %s"), pxGetAppName().c_str(), wxPCSX2_FULL_VERSION().c_str(), fromUTF8(__DATE__).c_str() );
324 }
325 else
326 {
327 // evens: stable releases, with a simpler title.
328 //wintitle.Printf( _("%s %d.%d.%d %s"), pxGetAppName().c_str(), PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo,
329 // SVN_MODS ? _("(modded)") : wxEmptyString
330 //);
331 wintitle.Printf( _("%s %s"), pxGetAppName().c_str(), wxPCSX2_FULL_VERSION().c_str());
332 }
333
334 SetTitle( wintitle );
335
336 // Ideally the __WXMSW__ port should use the embedded IDI_ICON2 icon, because wxWidgets sucks and
337 // loses the transparency information when loading bitmaps into icons. But for some reason
338 // I cannot get it to work despite following various examples to the letter.
339
340
341 SetIcons( wxGetApp().GetIconBundle() );
342
343 int m_statusbar_widths[] = { (int)(backsize.GetWidth()*0.73), (int)(backsize.GetWidth()*0.25) };
344 m_statusbar.SetStatusWidths(2, m_statusbar_widths);
345 m_statusbar.SetStatusText( L"The Status is Good!", 0);
346 m_statusbar.SetStatusText( wxEmptyString, 1);
347
348 wxBoxSizer& joe( *new wxBoxSizer( wxVERTICAL ) );
349 joe.Add( &m_background );
350 SetSizerAndFit( &joe );
351
352 // Use default window position if the configured windowpos is invalid (partially offscreen)
353 if( g_Conf->MainGuiPosition == wxDefaultPosition || !pxIsValidWindowPosition( *this, g_Conf->MainGuiPosition) )
354 g_Conf->MainGuiPosition = GetScreenPosition();
355 else
356 SetPosition( g_Conf->MainGuiPosition );
357
358 // Updating console log positions after the main window has been fitted to its sizer ensures
359 // proper docked positioning, since the main window's size is invalid until after the sizer
360 // has been set/fit.
361
362 InitLogBoxPosition( g_Conf->ProgLogBox );
363
364 // ------------------------------------------------------------------------
365 // Some of the items in the System menu are configured by the UpdateCoreStatus() method.
366
367 m_menuSys.Append(MenuId_Boot_CDVD, _("Initializing..."));
368
369 m_menuSys.Append(MenuId_Boot_CDVD2, _("Initializing..."));
370
371 m_menuSys.Append(MenuId_Boot_ELF, _("Run ELF..."),
372 _("For running raw PS2 binaries directly"));
373
374 m_menuSys.AppendSeparator();
375 m_menuSys.Append(MenuId_Sys_SuspendResume, _("Initializing..."));
376 m_menuSys.AppendSeparator();
377
378 //m_menuSys.Append(MenuId_Sys_Close, _("Close"),
379 // _("Stops emulation and closes the GS window."));
380
381 m_menuSys.Append(MenuId_Sys_LoadStates, _("Load state"), &m_LoadStatesSubmenu);
382 m_menuSys.Append(MenuId_Sys_SaveStates, _("Save state"), &m_SaveStatesSubmenu);
383
384 m_menuSys.AppendSeparator();
385
386 m_menuSys.Append(MenuId_EnablePatches, _("Enable Patches"),
387 wxEmptyString, wxITEM_CHECK);
388
389 m_menuSys.Append(MenuId_EnableCheats, _("Enable Cheats"),
390 wxEmptyString, wxITEM_CHECK);
391
392 m_menuSys.Append(MenuId_EnableHostFs, _("Enable Host Filesystem"),
393 wxEmptyString, wxITEM_CHECK);
394
395 m_menuSys.AppendSeparator();
396
397 m_menuSys.Append(MenuId_Sys_Shutdown, _("Shutdown"),
398 _("Wipes all internal VM states and shuts down plugins."));
399
400 m_menuSys.Append(MenuId_Exit, _("Exit"),
401 _("Closing PCSX2 may be hazardous to your health"));
402
403
404 // ------------------------------------------------------------------------
405 wxMenu& isoRecents( wxGetApp().GetRecentIsoMenu() );
406
407 //m_menuCDVD.AppendSeparator();
408 m_menuCDVD.Append( MenuId_IsoSelector, _("Iso Selector"), &isoRecents );
409 m_menuCDVD.Append( GetPluginMenuId_Settings(PluginId_CDVD), _("Plugin Menu"), m_PluginMenuPacks[PluginId_CDVD] );
410
411 m_menuCDVD.AppendSeparator();
412 m_menuCDVD.Append( MenuId_Src_Iso, _("Iso"), _("Makes the specified ISO image the CDVD source."), wxITEM_RADIO );
413 m_menuCDVD.Append( MenuId_Src_Plugin, _("Plugin"), _("Uses an external plugin as the CDVD source."), wxITEM_RADIO );
414 m_menuCDVD.Append( MenuId_Src_NoDisc, _("No disc"), _("Use this to boot into your virtual PS2's BIOS configuration."), wxITEM_RADIO );
415
416 //m_menuCDVD.AppendSeparator();
417 //m_menuCDVD.Append( MenuId_SkipBiosToggle,_("Enable BOOT2 injection"),
418 // _("Skips PS2 splash screens when booting from Iso or DVD media"), wxITEM_CHECK );
419
420 // ------------------------------------------------------------------------
421
422 m_menuConfig.Append(MenuId_Config_SysSettings, _("Emulation &Settings") );
423 m_menuConfig.Append(MenuId_Config_McdSettings, _("&MemoryCards") );
424 m_menuConfig.Append(MenuId_Config_BIOS, _("&Plugin/BIOS Selector...") );
425 m_menuConfig.AppendSeparator();
426
427 m_menuConfig.Append(MenuId_Config_GS, _("&Video (GS)"), m_PluginMenuPacks[PluginId_GS]);
428 m_menuConfig.Append(MenuId_Config_SPU2, _("&Audio (SPU2)"), m_PluginMenuPacks[PluginId_SPU2]);
429 m_menuConfig.Append(MenuId_Config_PAD, _("&Controllers (PAD)"), m_PluginMenuPacks[PluginId_PAD]);
430 m_menuConfig.Append(MenuId_Config_DEV9, _("Dev9"), m_PluginMenuPacks[PluginId_DEV9]);
431 m_menuConfig.Append(MenuId_Config_USB, _("USB"), m_PluginMenuPacks[PluginId_USB]);
432 m_menuConfig.Append(MenuId_Config_FireWire, _("Firewire"), m_PluginMenuPacks[PluginId_FW]);
433
434 m_menuConfig.AppendSeparator();
435 m_menuConfig.Append(MenuId_Config_Patches, _("Patches (unimplemented)"), wxEmptyString);
436
437 m_menuConfig.AppendSeparator();
438 m_menuConfig.Append(MenuId_Config_Multitap0Toggle, _("Multitap 1"), wxEmptyString, wxITEM_CHECK );
439 m_menuConfig.Append(MenuId_Config_Multitap1Toggle, _("Multitap 2"), wxEmptyString, wxITEM_CHECK );
440
441 m_menuConfig.AppendSeparator();
442 m_menuConfig.Append(MenuId_Config_ResetAll, _("Clear all settings..."),
443 _("Clears all PCSX2 settings and re-runs the startup wizard."));
444
445 // ------------------------------------------------------------------------
446
447 m_menuMisc.Append( &m_MenuItem_Console );
448 #ifdef __LINUX__
449 m_menuMisc.Append( &m_MenuItem_Console_Stdio );
450 #endif
451 //Todo: Though not many people need this one :p
452 //m_menuMisc.Append(MenuId_Profiler, _("Show Profiler"), wxEmptyString, wxITEM_CHECK);
453 //m_menuMisc.AppendSeparator();
454
455 // No dialogs implemented for these yet...
456 //m_menuMisc.Append(41, "Patch Browser...", wxEmptyString, wxITEM_NORMAL);
457 //m_menuMisc.Append(42, "Patch Finder...", wxEmptyString, wxITEM_NORMAL);
458
459 m_menuMisc.Append(MenuId_CDVD_Info, _T("Print CDVD Info"), wxEmptyString, wxITEM_CHECK);
460 m_menuMisc.AppendSeparator();
461
462 //Todo:
463 //There's a great working "open website" in the about panel. Less clutter by just using that.
464 //m_menuMisc.Append(MenuId_Website, _("Visit Website..."),
465 // _("Opens your web-browser to our favorite website."));
466 m_menuMisc.Append(MenuId_About, _("About...") );
467 #ifdef PCSX2_DEVBUILD
468 m_menuDebug.Append(MenuId_Debug_Open, _("Open Debug Window..."), wxEmptyString);
469 m_menuDebug.Append(MenuId_Debug_MemoryDump, _("Memory Dump..."), wxEmptyString);
470 m_menuDebug.Append(MenuId_Debug_Logging, _("Logging..."), wxEmptyString);
471 #endif
472 m_MenuItem_Console.Check( g_Conf->ProgLogBox.Visible );
473
474 ConnectMenus();
475 Connect( wxEVT_MOVE, wxMoveEventHandler (MainEmuFrame::OnMoveAround) );
476 Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler (MainEmuFrame::OnCloseWindow) );
477 Connect( wxEVT_SET_FOCUS, wxFocusEventHandler (MainEmuFrame::OnFocus) );
478 Connect( wxEVT_ACTIVATE, wxActivateEventHandler (MainEmuFrame::OnActivate) );
479
480 PushEventHandler( &wxGetApp().GetRecentIsoManager() );
481 SetDropTarget( new IsoDropTarget( this ) );
482 ApplyCoreStatus();
483 }
484
485 MainEmuFrame::~MainEmuFrame() throw()
486 {
487 if( m_RestartEmuOnDelete )
488 {
489 sApp.SetExitOnFrameDelete( false );
490 sApp.PostAppMethod( &Pcsx2App::DetectCpuAndUserMode );
491 sApp.WipeUserModeSettings();
492 }
493 }
494
495 void MainEmuFrame::DoGiveHelp(const wxString& text, bool show)
496 {
497 _parent::DoGiveHelp(text, show);
498 wxGetApp().GetProgramLog()->DoGiveHelp(text, show);
499 }
500
501 // ----------------------------------------------------------------------------
502 // OnFocus / OnActivate : Special implementation to "connect" the console log window
503 // with the main frame window. When one is clicked, the other is assured to be brought
504 // to the foreground with it. (Currently only MSW only, as wxWidgets appears to have no
505 // equivalent to this). Both OnFocus and OnActivate are handled because Focus events do
506 // not propagate up the window hierarchy, and on Activate events don't always get sent
507 // on the first focusing event after PCSX2 starts.
508
509 void MainEmuFrame::OnFocus( wxFocusEvent& evt )
510 {
511 if( ConsoleLogFrame* logframe = wxGetApp().GetProgramLog() )
512 MSW_SetWindowAfter( logframe->GetHandle(), GetHandle() );
513
514 evt.Skip();
515 }
516
517 void MainEmuFrame::OnActivate( wxActivateEvent& evt )
518 {
519 if( ConsoleLogFrame* logframe = wxGetApp().GetProgramLog() )
520 MSW_SetWindowAfter( logframe->GetHandle(), GetHandle() );
521
522 evt.Skip();
523 }
524 // ----------------------------------------------------------------------------
525
526 void MainEmuFrame::ApplyCoreStatus()
527 {
528 wxMenuBar& menubar( *GetMenuBar() );
529
530 wxMenuItem* susres = menubar.FindItem( MenuId_Sys_SuspendResume );
531 wxMenuItem* cdvd = menubar.FindItem( MenuId_Boot_CDVD );
532 wxMenuItem* cdvd2 = menubar.FindItem( MenuId_Boot_CDVD2 );
533 wxMenuItem* restart = menubar.FindItem( MenuId_Sys_Restart );
534
535 // [TODO] : Ideally each of these items would bind a listener instance to the AppCoreThread
536 // dispatcher, and modify their states accordingly. This is just a hack (for now) -- air
537
538 bool vm = SysHasValidState();
539
540 if( susres )
541 {
542 if( CoreThread.IsOpen() )
543 {
544 susres->Enable();
545 susres->SetText(_("Suspend"));
546 susres->SetHelp(_("Safely pauses emulation and preserves the PS2 state."));
547 }
548 else
549 {
550 susres->Enable(vm);
551 if( vm )
552 {
553 susres->SetText(_("Resume"));
554 susres->SetHelp(_("Resumes the suspended emulation state."));
555 }
556 else
557 {
558 susres->SetText(_("Suspend/Resume"));
559 susres->SetHelp(_("No emulation state is active; cannot suspend or resume."));
560 }
561 }
562 }
563
564 if( restart )
565 {
566 if( vm )
567 {
568 restart->SetText(_("Restart"));
569 restart->SetHelp(_("Simulates hardware reset of the PS2 virtual machine."));
570 }
571 else
572 {
573 restart->Enable( false );
574 restart->SetHelp(_("No emulation state is active; boot something first."));
575 }
576 }
577
578 if( cdvd )
579 {
580 if( vm )
581 {
582 cdvd->SetText(_("Reboot CDVD (full)"));
583 cdvd->SetHelp(_("Hard reset of the active VM."));
584 }
585 else
586 {
587 cdvd->SetText(_("Boot CDVD (full)"));
588 cdvd->SetHelp(_("Boot the VM using the current DVD or Iso source media"));
589 }
590 }
591
592 if( cdvd2 )
593 {
594 if( vm )
595 {
596 cdvd2->SetText(_("Reboot CDVD (fast)"));
597 cdvd2->SetHelp(_("Reboot using BOOT2 injection (skips splash screens)"));
598 }
599 else
600 {
601 cdvd2->SetText(_("Boot CDVD (fast)"));
602 cdvd2->SetHelp(_("Use BOOT2 injection to skip PS2 startup and splash screens"));
603 }
604 }
605
606 menubar.Enable( MenuId_Sys_Shutdown, SysHasValidState() || CorePlugins.AreAnyInitialized() );
607 }
608
609 void MainEmuFrame::ApplySettings()
610 {
611 wxMenuBar& menubar( *GetMenuBar() );
612
613 menubar.Check( MenuId_EnablePatches, g_Conf->EmuOptions.EnablePatches );
614 menubar.Check( MenuId_EnableCheats, g_Conf->EmuOptions.EnableCheats );
615 menubar.Check( MenuId_EnableHostFs, g_Conf->EmuOptions.HostFs );
616 menubar.Check( MenuId_CDVD_Info, g_Conf->EmuOptions.CdvdVerboseReads );
617 #ifdef __LINUX__
618 menubar.Check( MenuId_Console_Stdio, g_Conf->EmuOptions.ConsoleToStdio );
619 #endif
620
621 menubar.Check( MenuId_Config_Multitap0Toggle, g_Conf->EmuOptions.MultitapPort0_Enabled );
622 menubar.Check( MenuId_Config_Multitap1Toggle, g_Conf->EmuOptions.MultitapPort1_Enabled );
623
624 UpdateIsoSrcSelection();
625 }
626
627 // ------------------------------------------------------------------------
628 // "Extensible" Plugin Menus
629 // ------------------------------------------------------------------------
630
631 PerPluginMenuInfo::~PerPluginMenuInfo() throw()
632 {
633 }
634
635 void PerPluginMenuInfo::Populate( PluginsEnum_t pid )
636 {
637 if( !pxAssert(pid < PluginId_Count) ) return;
638
639 PluginId = pid;
640
641 MyMenu.Append( GetPluginMenuId_Name(PluginId), _("No plugin loaded") )->Enable( false );
642 MyMenu.AppendSeparator();
643
644 if( PluginId == PluginId_GS )
645 {
646 MyMenu.Append( MenuId_Video_CoreSettings, _("Core GS Settings..."),
647 _("Modify hardware emulation settings regulated by the PCSX2 core virtual machine.") );
648
649 MyMenu.Append( MenuId_Video_WindowSettings, _("Window Settings..."),
650 _("Modify window and appearance options, including aspect ratio.") );
651
652 MyMenu.AppendSeparator();
653 }
654
655 // Populate options from the plugin here.
656
657 MyMenu.Append( GetPluginMenuId_Settings(PluginId), _("Plugin Settings..."),
658 wxsFormat( _("Opens the %s plugin's advanced settings dialog."), tbl_PluginInfo[pid].GetShortname().c_str() )
659 );
660 }
661
662 // deletes menu items belonging to (created by) the plugin. Leaves menu items created
663 // by the PCSX2 core intact.
664 void PerPluginMenuInfo::OnUnloaded()
665 {
666 // Delete any menu options added by plugins (typically a plugin will have already
667 // done its own proper cleanup when the plugin was shutdown or unloaded, but lets
668 // not trust them, shall we?)
669
670 MenuItemAddonList& curlist( m_PluginMenuItems );
671 for( uint mx=0; mx<curlist.size(); ++mx )
672 MyMenu.Delete( curlist[mx].Item );
673
674 curlist.clear();
675
676 MyMenu.SetLabel( GetPluginMenuId_Name(PluginId), _("No plugin loaded") );
677 MyMenu.Enable( GetPluginMenuId_Settings(PluginId), false );
678 }
679
680 void PerPluginMenuInfo::OnLoaded()
681 {
682 if( !CorePlugins.IsLoaded(PluginId) ) return;
683 MyMenu.SetLabel( GetPluginMenuId_Name(PluginId),
684 CorePlugins.GetName( PluginId ) + L" " + CorePlugins.GetVersion( PluginId )
685 );
686 MyMenu.Enable( GetPluginMenuId_Settings(PluginId), true );
687 }
688

  ViewVC Help
Powered by ViewVC 1.1.22