Fix some sound issues by creating PauseEmulator() & UnpauseEmulator() functions that toggle sound as well, changed all code that changes the EmulatorPaused bool to use these functions instead

This commit is contained in:
andres.delikat 2011-02-15 20:33:44 +00:00
parent cac6548fc3
commit 4ce8946c36
1 changed files with 21 additions and 16 deletions

View File

@ -107,6 +107,18 @@ namespace BizHawk.MultiClient
LoadRamSearch(); LoadRamSearch();
} }
private void PauseEmulator()
{
EmulatorPaused = true;
Global.Sound.StopSound();
}
private void UnpauseEmulator()
{
EmulatorPaused = false;
Global.Sound.StartSound();
}
private void LoadRomFromRecent(string rom) private void LoadRomFromRecent(string rom)
{ {
bool r = LoadRom(rom); bool r = LoadRom(rom);
@ -365,7 +377,7 @@ namespace BizHawk.MultiClient
if (FrameAdvanceDelay == 60) if (FrameAdvanceDelay == 60)
{ {
if (EmulatorPaused == false) if (EmulatorPaused == false)
EmulatorPaused = true; PauseEmulator();
Global.Emulator.FrameAdvance(true); Global.Emulator.FrameAdvance(true);
FrameAdvanceDelay--; FrameAdvanceDelay--;
} }
@ -486,9 +498,10 @@ namespace BizHawk.MultiClient
if (Global.ClientControls["Emulator Pause"]) if (Global.ClientControls["Emulator Pause"])
{ {
Global.ClientControls.UnpressButton("Emulator Pause"); Global.ClientControls.UnpressButton("Emulator Pause");
EmulatorPaused = !EmulatorPaused; if (EmulatorPaused)
//if (EmulatorPaused) Global.Sound.StopSound(); UnpauseEmulator();
//else Global.Sound.StartSound(); else
PauseEmulator();
} }
if (Global.ClientControls["Toggle Fullscreen"]) if (Global.ClientControls["Toggle Fullscreen"])
@ -638,15 +651,9 @@ namespace BizHawk.MultiClient
private void pauseToolStripMenuItem_Click(object sender, EventArgs e) private void pauseToolStripMenuItem_Click(object sender, EventArgs e)
{ {
if (EmulatorPaused == true) if (EmulatorPaused == true)
{ UnpauseEmulator();
Global.Sound.StartSound();
EmulatorPaused = false;
}
else else
{ PauseEmulator();
Global.Sound.StopSound();
EmulatorPaused = true;
}
} }
private void helpToolStripMenuItem1_Click(object sender, EventArgs e) private void helpToolStripMenuItem1_Click(object sender, EventArgs e)
@ -1162,12 +1169,11 @@ namespace BizHawk.MultiClient
{ {
if (Global.Config.PauseWhenMenuActivated) if (Global.Config.PauseWhenMenuActivated)
{ {
Global.Sound.StopSound();
if (EmulatorPaused) if (EmulatorPaused)
wasPaused = true; wasPaused = true;
else else
wasPaused = false; wasPaused = false;
EmulatorPaused = true; PauseEmulator();
} }
} }
@ -1175,8 +1181,7 @@ namespace BizHawk.MultiClient
{ {
if (!wasPaused) if (!wasPaused)
{ {
Global.Sound.StartSound(); UnpauseEmulator();
EmulatorPaused = false;
} }
} }