tastudio: seek progress bar:

- stop dividing by zero!
- ignore if seeking closer than 2 frames ahead (todo: make cutoff configurable)
This commit is contained in:
feos 2016-01-27 15:44:42 +03:00
parent 1b8ef3738a
commit 1c6a40dec9
3 changed files with 12 additions and 7 deletions

View File

@ -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();
}

View File

@ -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
{

View File

@ -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) =>