From 1c6a40dec97b2fc5adfea0ec406340d569c4dd4a Mon Sep 17 00:00:00 2001 From: feos Date: Wed, 27 Jan 2016 15:44:42 +0300 Subject: [PATCH] tastudio: seek progress bar: - stop dividing by zero! - ignore if seeking closer than 2 frames ahead (todo: make cutoff configurable) --- .../tools/TAStudio/TAStudio.ListView.cs | 4 +++- .../tools/TAStudio/TAStudio.Navigation.cs | 2 -- BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs | 13 +++++++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index 8f9e89dd16..b9cd757df2 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -70,13 +70,15 @@ namespace BizHawk.Client.EmuHawk _seekStartFrame = Emulator.Frame; GlobalWin.MainForm.PauseOnFrame = frame.Value; + int? diff = GlobalWin.MainForm.PauseOnFrame - _seekStartFrame; + int seekCutoff = 2; // todo if (pause) GlobalWin.MainForm.PauseEmulator(); else GlobalWin.MainForm.UnpauseEmulator(); - if (!_seekBackgroundWorker.IsBusy) + if (!_seekBackgroundWorker.IsBusy && diff.Value > seekCutoff) _seekBackgroundWorker.RunWorkerAsync(); } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs index 43fcf6d34f..53b806b1cc 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs @@ -38,8 +38,6 @@ namespace BizHawk.Client.EmuHawk StartAtNearestFrameAndEmulate(frame); MaybeFollowCursor(); - - //return; seriously? well, maybe it's for some insane speedup, but it skipped updating when putting playback to frame zero. } else // Emulate to a future frame { diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index 184a103660..cc6567755c 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -203,11 +203,16 @@ namespace BizHawk.Client.EmuHawk e.Cancel = true; break; } - double progress = (double)100d / - (GlobalWin.MainForm.PauseOnFrame.Value - _seekStartFrame.Value) * - (Global.Emulator.Frame - _seekStartFrame.Value); + + int diff = Global.Emulator.Frame - _seekStartFrame.Value; + int unit = GlobalWin.MainForm.PauseOnFrame.Value - _seekStartFrame.Value; + double progress = 0; + + if (diff != 0 && unit != 0) + progress = (double)100d / unit * diff; if (progress < 0) progress = 0; + _seekBackgroundWorker.ReportProgress((int)progress); System.Threading.Thread.Sleep(1); } @@ -215,7 +220,7 @@ namespace BizHawk.Client.EmuHawk _seekBackgroundWorker.ProgressChanged += (s, e) => { - SavingProgressBar.Value = e.ProgressPercentage; + this.Invoke(() => this.SavingProgressBar.Value = e.ProgressPercentage); }; _seekBackgroundWorker.RunWorkerCompleted += (s, e) =>