Fixed issue where save/load state shortcuts were not working correctly until the menu was manually opened by the user

This commit is contained in:
Souryo 2015-07-05 19:12:41 -04:00
parent 3858397d6e
commit 6ab9f63476
3 changed files with 21 additions and 41 deletions

View file

@ -109,22 +109,25 @@ void Console::Stop()
{ {
_stop = true; _stop = true;
Console::ClearFlags(EmulationFlags::Paused); Console::ClearFlags(EmulationFlags::Paused);
Console::Instance->_stopLock.Acquire(); _stopLock.Acquire();
Console::Instance->_stopLock.Release(); _stopLock.Release();
} }
void Console::Pause() void Console::Pause()
{ {
Console::Instance->_pauseLock.Acquire(); if(Console::Instance) {
Console::Instance->_pauseLock.Acquire();
//Spin wait until emu pauses //Spin wait until emu pauses
Console::Instance->_runLock.Acquire(); Console::Instance->_runLock.Acquire();
}
} }
void Console::Resume() void Console::Resume()
{ {
Console::Instance->_runLock.Release(); if(Console::Instance) {
Console::Instance->_pauseLock.Release(); Console::Instance->_runLock.Release();
Console::Instance->_pauseLock.Release();
}
} }
void Console::SetFlags(int flags) void Console::SetFlags(int flags)

View file

@ -38,9 +38,7 @@
this.mnuOpen = new System.Windows.Forms.ToolStripMenuItem(); this.mnuOpen = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripSeparator();
this.mnuSaveState = new System.Windows.Forms.ToolStripMenuItem(); this.mnuSaveState = new System.Windows.Forms.ToolStripMenuItem();
this.mnuSaveState1 = new System.Windows.Forms.ToolStripMenuItem();
this.mnuLoadState = new System.Windows.Forms.ToolStripMenuItem(); this.mnuLoadState = new System.Windows.Forms.ToolStripMenuItem();
this.mnuLoadState1 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem7 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripMenuItem7 = new System.Windows.Forms.ToolStripSeparator();
this.mnuRecentFiles = new System.Windows.Forms.ToolStripMenuItem(); this.mnuRecentFiles = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripSeparator();
@ -116,70 +114,49 @@
// //
this.mnuOpen.Name = "mnuOpen"; this.mnuOpen.Name = "mnuOpen";
this.mnuOpen.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O))); this.mnuOpen.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
this.mnuOpen.Size = new System.Drawing.Size(146, 22); this.mnuOpen.Size = new System.Drawing.Size(152, 22);
this.mnuOpen.Text = "Open"; this.mnuOpen.Text = "Open";
this.mnuOpen.Click += new System.EventHandler(this.mnuOpen_Click); this.mnuOpen.Click += new System.EventHandler(this.mnuOpen_Click);
// //
// toolStripMenuItem4 // toolStripMenuItem4
// //
this.toolStripMenuItem4.Name = "toolStripMenuItem4"; this.toolStripMenuItem4.Name = "toolStripMenuItem4";
this.toolStripMenuItem4.Size = new System.Drawing.Size(143, 6); this.toolStripMenuItem4.Size = new System.Drawing.Size(149, 6);
// //
// mnuSaveState // mnuSaveState
// //
this.mnuSaveState.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.mnuSaveState1});
this.mnuSaveState.Name = "mnuSaveState"; this.mnuSaveState.Name = "mnuSaveState";
this.mnuSaveState.Size = new System.Drawing.Size(146, 22); this.mnuSaveState.Size = new System.Drawing.Size(152, 22);
this.mnuSaveState.Text = "Save State"; this.mnuSaveState.Text = "Save State";
this.mnuSaveState.DropDownOpening += new System.EventHandler(this.mnuSaveState_DropDownOpening); this.mnuSaveState.DropDownOpening += new System.EventHandler(this.mnuSaveState_DropDownOpening);
// //
// mnuSaveState1
//
this.mnuSaveState1.Font = new System.Drawing.Font("Segoe UI", 9F);
this.mnuSaveState1.Name = "mnuSaveState1";
this.mnuSaveState1.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Shift | System.Windows.Forms.Keys.F1)));
this.mnuSaveState1.Size = new System.Drawing.Size(187, 22);
this.mnuSaveState1.Text = "1. <empty>";
this.mnuSaveState1.Click += new System.EventHandler(this.mnuSaveState1_Click);
//
// mnuLoadState // mnuLoadState
// //
this.mnuLoadState.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.mnuLoadState1});
this.mnuLoadState.Name = "mnuLoadState"; this.mnuLoadState.Name = "mnuLoadState";
this.mnuLoadState.Size = new System.Drawing.Size(146, 22); this.mnuLoadState.Size = new System.Drawing.Size(152, 22);
this.mnuLoadState.Text = "Load State"; this.mnuLoadState.Text = "Load State";
this.mnuLoadState.DropDownOpening += new System.EventHandler(this.mnuLoadState_DropDownOpening); this.mnuLoadState.DropDownOpening += new System.EventHandler(this.mnuLoadState_DropDownOpening);
// //
// mnuLoadState1
//
this.mnuLoadState1.Name = "mnuLoadState1";
this.mnuLoadState1.ShortcutKeys = System.Windows.Forms.Keys.F1;
this.mnuLoadState1.Size = new System.Drawing.Size(155, 22);
this.mnuLoadState1.Text = "1. <empty>";
this.mnuLoadState1.Click += new System.EventHandler(this.mnuLoadState1_Click);
//
// toolStripMenuItem7 // toolStripMenuItem7
// //
this.toolStripMenuItem7.Name = "toolStripMenuItem7"; this.toolStripMenuItem7.Name = "toolStripMenuItem7";
this.toolStripMenuItem7.Size = new System.Drawing.Size(143, 6); this.toolStripMenuItem7.Size = new System.Drawing.Size(149, 6);
// //
// mnuRecentFiles // mnuRecentFiles
// //
this.mnuRecentFiles.Name = "mnuRecentFiles"; this.mnuRecentFiles.Name = "mnuRecentFiles";
this.mnuRecentFiles.Size = new System.Drawing.Size(146, 22); this.mnuRecentFiles.Size = new System.Drawing.Size(152, 22);
this.mnuRecentFiles.Text = "Recent Files"; this.mnuRecentFiles.Text = "Recent Files";
// //
// toolStripMenuItem6 // toolStripMenuItem6
// //
this.toolStripMenuItem6.Name = "toolStripMenuItem6"; this.toolStripMenuItem6.Name = "toolStripMenuItem6";
this.toolStripMenuItem6.Size = new System.Drawing.Size(143, 6); this.toolStripMenuItem6.Size = new System.Drawing.Size(149, 6);
// //
// mnuExit // mnuExit
// //
this.mnuExit.Name = "mnuExit"; this.mnuExit.Name = "mnuExit";
this.mnuExit.Size = new System.Drawing.Size(146, 22); this.mnuExit.Size = new System.Drawing.Size(152, 22);
this.mnuExit.Text = "Exit"; this.mnuExit.Text = "Exit";
this.mnuExit.Click += new System.EventHandler(this.mnuExit_Click); this.mnuExit.Click += new System.EventHandler(this.mnuExit_Click);
// //
@ -526,8 +503,6 @@
private System.Windows.Forms.ToolStripMenuItem mnuSaveState; private System.Windows.Forms.ToolStripMenuItem mnuSaveState;
private System.Windows.Forms.ToolStripMenuItem mnuLoadState; private System.Windows.Forms.ToolStripMenuItem mnuLoadState;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem7; private System.Windows.Forms.ToolStripSeparator toolStripMenuItem7;
private System.Windows.Forms.ToolStripMenuItem mnuSaveState1;
private System.Windows.Forms.ToolStripMenuItem mnuLoadState1;
private System.Windows.Forms.ToolStripMenuItem mnuCheats; private System.Windows.Forms.ToolStripMenuItem mnuCheats;
} }
} }

View file

@ -52,6 +52,8 @@ namespace Mesen.GUI.Forms
{ {
if(e.NotificationType == InteropEmu.ConsoleNotificationType.GameLoaded) { if(e.NotificationType == InteropEmu.ConsoleNotificationType.GameLoaded) {
CheatInfo.ApplyCheats(); CheatInfo.ApplyCheats();
InitializeStateMenu(mnuSaveState, true);
InitializeStateMenu(mnuLoadState, false);
this.StartEmuThread(); this.StartEmuThread();
} else if(e.NotificationType == InteropEmu.ConsoleNotificationType.GameStopped) { } else if(e.NotificationType == InteropEmu.ConsoleNotificationType.GameStopped) {
CheatInfo.ClearCheats(); CheatInfo.ClearCheats();