From 4258c4a57972110f62580348573d170bc258f263 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 27 Jul 2014 19:07:13 +0000 Subject: [PATCH] Make Pause status bar icon show turbo seeking and seeking if emulator is those modes, clicking it will cancel out the seek. Fix tastudio's integration with the seek feature, and refactor and simplify some of the code, and a few other tastudio tweaks --- BizHawk.Client.Common/config/Config.cs | 13 +++++- BizHawk.Client.EmuHawk/MainForm.Events.cs | 6 ++- BizHawk.Client.EmuHawk/MainForm.cs | 43 ++++++++++++++++--- .../tools/TAStudio/PlaybackBox.cs | 9 +++- .../tools/TAStudio/TAStudio.cs | 4 +- 5 files changed, 63 insertions(+), 12 deletions(-) diff --git a/BizHawk.Client.Common/config/Config.cs b/BizHawk.Client.Common/config/Config.cs index 902faeef52..9b3f2d25b8 100644 --- a/BizHawk.Client.Common/config/Config.cs +++ b/BizHawk.Client.Common/config/Config.cs @@ -94,7 +94,18 @@ namespace BizHawk.Client.Common public bool AVI_CaptureOSD = false; public bool Screenshot_CaptureOSD = false; public bool FirstBoot = true; - public bool TurboSeek = true; // When PauseOnFrame is set, this will decide whether the client goes into turbo mode or not + + //public bool TurboSeek = true; // When PauseOnFrame is set, this will decide whether the client goes into turbo mode or not + + private bool _turboSeek; + public bool TurboSeek + { + get { return _turboSeek; } + set + { + _turboSeek = value; + } + } public enum SaveStateTypeE { Default, Binary, Text }; diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index f582b68b7e..77c3627c46 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -625,7 +625,11 @@ namespace BizHawk.Client.EmuHawk private void PauseMenuItem_Click(object sender, EventArgs e) { - if (EmulatorPaused) + if (IsTurboSeeking || IsSeeking) + { + PauseOnFrame = null; + } + else if (EmulatorPaused) { UnpauseEmulator(); } diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index e20c775298..8370dadd5e 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -557,22 +557,34 @@ namespace BizHawk.Client.EmuHawk public bool EmulatorPaused { get; private set; } private int? _pauseOnFrame; - private bool _forceTurbo = false; public int? PauseOnFrame // If set, upon completion of this frame, the client wil pause { get { return _pauseOnFrame; } set { _pauseOnFrame = value; - _forceTurbo = _pauseOnFrame.HasValue && Global.Config.TurboSeek; + SetPauseStatusbarIcon(); } - } + } + + public bool IsSeeking + { + get { return PauseOnFrame.HasValue; } + } + + public bool IsTurboSeeking + { + get + { + return PauseOnFrame.HasValue && Global.Config.TurboSeek; + } + } public bool IsTurboing { get { - return Global.ClientControls["Turbo"] || _forceTurbo; + return Global.ClientControls["Turbo"] || IsTurboSeeking; } } @@ -828,6 +840,12 @@ namespace BizHawk.Client.EmuHawk { EmulatorPaused ^= true; SetPauseStatusbarIcon(); + + // TODO: have tastudio set a pause status change callback, or take control over pause + if (GlobalWin.Tools.Has()) + { + GlobalWin.Tools.UpdateValues(); + } } public void TakeScreenshotToClipboard() @@ -1560,7 +1578,19 @@ namespace BizHawk.Client.EmuHawk private void SetPauseStatusbarIcon() { - if (EmulatorPaused) + if (IsTurboing) + { + PauseStatusButton.Image = Properties.Resources.Lightning; + PauseStatusButton.Visible = true; + PauseStatusButton.ToolTipText = "Emulator is turbo seeking to frame " + PauseOnFrame.Value + " click to stop seek"; + } + else if (PauseOnFrame.HasValue) + { + PauseStatusButton.Image = Properties.Resources.YellowRight; + PauseStatusButton.Visible = true; + PauseStatusButton.ToolTipText = "Emulator is playing to frame " + PauseOnFrame.Value + " click to stop seek"; + } + else if (EmulatorPaused) { PauseStatusButton.Image = Properties.Resources.Pause; PauseStatusButton.Visible = true; @@ -2666,7 +2696,7 @@ namespace BizHawk.Client.EmuHawk GlobalWin.Tools.FastUpdateAfter(); } - if (PauseOnFrame.HasValue && Global.Emulator.Frame == PauseOnFrame.Value) + if (IsSeeking && Global.Emulator.Frame == PauseOnFrame.Value) { PauseEmulator(); PauseOnFrame = null; @@ -3321,7 +3351,6 @@ namespace BizHawk.Client.EmuHawk UpdateCoreStatusBarButton(); ClearHolds(); PauseOnFrame = null; - _forceTurbo = false; ToolHelpers.UpdateCheatRelatedTools(null, null); } } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.cs index d04e2f66f2..88a44afb26 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.cs @@ -13,6 +13,8 @@ namespace BizHawk.Client.EmuHawk { public partial class PlaybackBox : UserControl { + private bool _programmaticallyChangingSeekBox = false; + public TAStudio Tastudio { get; set; } public bool TurboSeek @@ -31,7 +33,9 @@ namespace BizHawk.Client.EmuHawk public PlaybackBox() { InitializeComponent(); + _programmaticallyChangingSeekBox = true; TurboSeekCheckbox.Checked = Global.Config.TurboSeek; + _programmaticallyChangingSeekBox = false; } private void PreviousMarkerButton_Click(object sender, EventArgs e) @@ -61,7 +65,10 @@ namespace BizHawk.Client.EmuHawk private void TurboSeekCheckbox_CheckedChanged(object sender, EventArgs e) { - Global.Config.TurboSeek ^= true; + if (!_programmaticallyChangingSeekBox) + { + Global.Config.TurboSeek ^= true; + } } } } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index e64362dd57..8a66276708 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -357,7 +357,6 @@ namespace BizHawk.Client.EmuHawk Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(_tas[_tas.LastEmulatedFrame].State.ToArray()))); GlobalWin.MainForm.UnpauseEmulator(); GlobalWin.MainForm.PauseOnFrame = frame; - // TODO: if turbo seek, ramp up the speed } } } @@ -368,8 +367,9 @@ namespace BizHawk.Client.EmuHawk Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(_tas[_tas.LastEmulatedFrame].State.ToArray()))); GlobalWin.MainForm.UnpauseEmulator(); GlobalWin.MainForm.PauseOnFrame = frame; - // TODO: if turbo seek, ramp up the speed } + + RefreshDialog(); } #region Playback Controls