/[pcsx2_0.9.7]/trunk/pcsx2/gui/MainFrame.cpp
ViewVC logotype

Contents of /trunk/pcsx2/gui/MainFrame.cpp

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.22