tastudio: actually implement seeking progressbar.
This commit is contained in:
parent
c1e70077c8
commit
2535207a40
|
@ -2839,16 +2839,13 @@ namespace BizHawk.Client.EmuHawk
|
||||||
UpdateToolsAfter();
|
UpdateToolsAfter();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsSeeking)
|
if (IsSeeking && Global.Emulator.Frame == PauseOnFrame.Value)
|
||||||
{
|
{
|
||||||
if (Global.Emulator.Frame == PauseOnFrame.Value)
|
PauseEmulator();
|
||||||
|
PauseOnFrame = null;
|
||||||
|
if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||||
{
|
{
|
||||||
PauseEmulator();
|
GlobalWin.Tools.TAStudio.StopSeeking();
|
||||||
PauseOnFrame = null;
|
|
||||||
}
|
|
||||||
else if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
|
||||||
{
|
|
||||||
GlobalWin.Tools.TAStudio.ReportSeekingProgress();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
private int? _autoRestoreFrame; // The frame auto-restore will restore to, if set
|
private int? _autoRestoreFrame; // The frame auto-restore will restore to, if set
|
||||||
private bool? _autoRestorePaused = null;
|
private bool? _autoRestorePaused = null;
|
||||||
private int? _seekStartFrame = null;
|
private int? _seekStartFrame = null;
|
||||||
|
|
||||||
private void JumpToGreenzone()
|
private void JumpToGreenzone()
|
||||||
{
|
{
|
||||||
if (Global.Emulator.Frame > CurrentTasMovie.LastValidFrame)
|
if (Global.Emulator.Frame > CurrentTasMovie.LastValidFrame)
|
||||||
|
@ -58,11 +59,32 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
|
|
||||||
GoToLastEmulatedFrameIfNecessary(CurrentTasMovie.LastValidFrame);
|
GoToLastEmulatedFrameIfNecessary(CurrentTasMovie.LastValidFrame);
|
||||||
GlobalWin.MainForm.PauseOnFrame = _autoRestoreFrame;
|
StartSeeking(_autoRestoreFrame, true);
|
||||||
GlobalWin.MainForm.PauseEmulator();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void StartSeeking(int? frame, bool pause = false)
|
||||||
|
{
|
||||||
|
if (!frame.HasValue)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_seekStartFrame = Emulator.Frame;
|
||||||
|
GlobalWin.MainForm.PauseOnFrame = frame.Value;
|
||||||
|
|
||||||
|
if (pause)
|
||||||
|
GlobalWin.MainForm.PauseEmulator();
|
||||||
|
else
|
||||||
|
GlobalWin.MainForm.UnpauseEmulator();
|
||||||
|
|
||||||
|
if (!_seekBackgroundWorker.IsBusy)
|
||||||
|
_seekBackgroundWorker.RunWorkerAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StopSeeking()
|
||||||
|
{
|
||||||
|
_seekBackgroundWorker.CancelAsync();
|
||||||
|
}
|
||||||
|
|
||||||
// public static Color CurrentFrame_FrameCol = Color.FromArgb(0xCFEDFC); Why?
|
// public static Color CurrentFrame_FrameCol = Color.FromArgb(0xCFEDFC); Why?
|
||||||
public static Color CurrentFrame_InputLog = Color.FromArgb(0xB5E7F7);
|
public static Color CurrentFrame_InputLog = Color.FromArgb(0xB5E7F7);
|
||||||
|
|
||||||
|
|
|
@ -58,9 +58,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (lastState > Emulator.Frame)
|
if (lastState > Emulator.Frame)
|
||||||
LoadState(CurrentTasMovie.TasStateManager[lastState]); // STATE ACCESS
|
LoadState(CurrentTasMovie.TasStateManager[lastState]); // STATE ACCESS
|
||||||
|
|
||||||
_seekStartFrame = Emulator.Frame;
|
StartSeeking(frame);
|
||||||
GlobalWin.MainForm.UnpauseEmulator();
|
|
||||||
GlobalWin.MainForm.PauseOnFrame = frame;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
private readonly List<TasClipboardEntry> _tasClipboard = new List<TasClipboardEntry>();
|
private readonly List<TasClipboardEntry> _tasClipboard = new List<TasClipboardEntry>();
|
||||||
|
|
||||||
private BackgroundWorker _saveBackgroundWorker;
|
private BackgroundWorker _saveBackgroundWorker;
|
||||||
|
private BackgroundWorker _seekBackgroundWorker;
|
||||||
|
|
||||||
private MovieEndAction _originalEndAction; // The movie end behavior selected by the user (that is overridden by TAStudio)
|
private MovieEndAction _originalEndAction; // The movie end behavior selected by the user (that is overridden by TAStudio)
|
||||||
private Dictionary<string, string> GenerateColumnNames()
|
private Dictionary<string, string> GenerateColumnNames()
|
||||||
|
@ -127,6 +128,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
this.SavingProgressBar.Visible = false;
|
this.SavingProgressBar.Visible = false;
|
||||||
|
|
||||||
InitializeSaveWorker();
|
InitializeSaveWorker();
|
||||||
|
InitializeSeekWorker();
|
||||||
|
|
||||||
WantsToControlStopMovie = true;
|
WantsToControlStopMovie = true;
|
||||||
TasPlaybackBox.Tastudio = this;
|
TasPlaybackBox.Tastudio = this;
|
||||||
|
@ -178,6 +180,50 @@ namespace BizHawk.Client.EmuHawk
|
||||||
CurrentTasMovie.NewBGWorker(_saveBackgroundWorker);
|
CurrentTasMovie.NewBGWorker(_saveBackgroundWorker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void InitializeSeekWorker()
|
||||||
|
{
|
||||||
|
if (_seekBackgroundWorker != null)
|
||||||
|
{
|
||||||
|
_seekBackgroundWorker.Dispose();
|
||||||
|
_seekBackgroundWorker = null; // Idk if this line is even useful.
|
||||||
|
}
|
||||||
|
|
||||||
|
_seekBackgroundWorker = new BackgroundWorker();
|
||||||
|
_seekBackgroundWorker.WorkerReportsProgress = true;
|
||||||
|
_seekBackgroundWorker.WorkerSupportsCancellation = true;
|
||||||
|
|
||||||
|
_seekBackgroundWorker.DoWork += (s, e) =>
|
||||||
|
{
|
||||||
|
this.Invoke(() => this.MessageStatusLabel.Text = "Seeking...");
|
||||||
|
this.Invoke(() => this.SavingProgressBar.Visible = true);
|
||||||
|
for ( ; ; )
|
||||||
|
{
|
||||||
|
if (_seekBackgroundWorker.CancellationPending)
|
||||||
|
{
|
||||||
|
e.Cancel = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
double progress = (double)100d /
|
||||||
|
(GlobalWin.MainForm.PauseOnFrame.Value - _seekStartFrame.Value) *
|
||||||
|
(Global.Emulator.Frame - _seekStartFrame.Value);
|
||||||
|
_seekBackgroundWorker.ReportProgress((int)progress);
|
||||||
|
System.Threading.Thread.Sleep(1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
_seekBackgroundWorker.ProgressChanged += (s, e) =>
|
||||||
|
{
|
||||||
|
SavingProgressBar.Value = e.ProgressPercentage;
|
||||||
|
};
|
||||||
|
|
||||||
|
_seekBackgroundWorker.RunWorkerCompleted += (s, e) =>
|
||||||
|
{
|
||||||
|
this.Invoke(() => this.SavingProgressBar.Visible = false);
|
||||||
|
this.Invoke(() => this.MessageStatusLabel.Text = "");
|
||||||
|
InitializeSeekWorker(); // Required, or it will error when trying to report progress again.
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private bool _initialized = false;
|
private bool _initialized = false;
|
||||||
private void Tastudio_Load(object sender, EventArgs e)
|
private void Tastudio_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -641,9 +687,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
if (_autoRestoreFrame > Emulator.Frame) // Don't unpause if we are already on the desired frame, else runaway seek
|
if (_autoRestoreFrame > Emulator.Frame) // Don't unpause if we are already on the desired frame, else runaway seek
|
||||||
{
|
{
|
||||||
_seekStartFrame = Emulator.Frame;
|
StartSeeking(_autoRestoreFrame);
|
||||||
GlobalWin.MainForm.PauseOnFrame = _autoRestoreFrame;
|
|
||||||
GlobalWin.MainForm.UnpauseEmulator();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -653,8 +697,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
_autoRestorePaused = null;
|
_autoRestorePaused = null;
|
||||||
GlobalWin.MainForm.PauseOnFrame = null; // Cancel seek to autorestore point
|
GlobalWin.MainForm.PauseOnFrame = null; // Cancel seek to autorestore point
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_autoRestoreFrame = null;
|
_autoRestoreFrame = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -675,9 +717,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
if (GlobalWin.MainForm.EmulatorPaused || GlobalWin.MainForm.IsSeeking) // make seek frame keep up with emulation on fast scrolls
|
if (GlobalWin.MainForm.EmulatorPaused || GlobalWin.MainForm.IsSeeking) // make seek frame keep up with emulation on fast scrolls
|
||||||
{
|
{
|
||||||
_seekStartFrame = Emulator.Frame;
|
StartSeeking(frame);
|
||||||
GlobalWin.MainForm.PauseOnFrame = frame;
|
|
||||||
GlobalWin.MainForm.UnpauseEmulator();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -707,17 +747,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
BookMarkControl.RemoveBranchExtrenal();
|
BookMarkControl.RemoveBranchExtrenal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReportSeekingProgress()
|
|
||||||
{
|
|
||||||
if (_seekStartFrame.HasValue)
|
|
||||||
{
|
|
||||||
CurrentTasMovie.ReportProgress((double)100d /
|
|
||||||
(GlobalWin.MainForm.PauseOnFrame.Value - _seekStartFrame.Value) *
|
|
||||||
(Global.Emulator.Frame - _seekStartFrame.Value));
|
|
||||||
RefreshDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateOtherTools() // a hack probably, surely there is a better way to do this
|
private void UpdateOtherTools() // a hack probably, surely there is a better way to do this
|
||||||
{
|
{
|
||||||
_hackyDontUpdate = true;
|
_hackyDontUpdate = true;
|
||||||
|
|
Loading…
Reference in New Issue