Tastudio - instead of disabling rewind, take it over with IControlMainform

This commit is contained in:
adelikat 2014-09-27 12:19:50 +00:00
parent d91256ceb9
commit e23c5ead86
4 changed files with 84 additions and 29 deletions

View File

@ -3,20 +3,34 @@
public interface IControlMainform
{
bool WantsToControlReadOnly { get; }
/// <summary>
/// Function that is called by Mainform instead of using its own code
/// when a Tool sets WantsToControlReadOnly.
/// Should not be called directly.
/// </summary>
/// <summary>
/// Function that is called by Mainform instead of using its own code
/// when a Tool sets WantsToControlReadOnly.
/// Should not be called directly.
/// </summary>
void ToggleReadOnly();
bool WantsToControlStopMovie { get; }
/// <summary>
/// Function that is called by Mainform instead of using its own code
/// when a Tool sets WantsToControlStopMovie.
/// Should not be called directly.
/// <remarks>Like MainForm's StopMovie(), saving the movie is part of this function's responsibility.</remarks>
/// </summary>
/// <summary>
/// Function that is called by Mainform instead of using its own code
/// when a Tool sets WantsToControlStopMovie.
/// Should not be called directly.
/// <remarks>Like MainForm's StopMovie(), saving the movie is part of this function's responsibility.</remarks>
/// </summary>
void StopMovie();
bool WantsToControlRewind { get; }
void CaptureRewind();
/// <summary>
/// Function that is called by Mainform instead of using its own code
/// when a Tool sets WantsToControlRewind
/// Returns whether or not the rewind action actually occured
/// </summary>
/// <returns></returns>
bool Rewind();
}
}

View File

@ -2580,16 +2580,7 @@ namespace BizHawk.Client.EmuHawk
runFrame = true;
}
bool isRewinding = false;
if (Global.Rewinder.RewindActive && (Global.ClientControls["Rewind"] || PressRewind)
&& !Global.MovieSession.Movie.IsRecording) // Rewind isn't "bulletproof" and can desync a recording movie!
{
Global.Rewinder.Rewind(1);
suppressCaptureRewind = true;
runFrame = Global.Rewinder.Count != 0;
isRewinding = true;
}
bool isRewinding = suppressCaptureRewind = Rewind(ref runFrame);
if (UpdateFrame)
{
@ -2663,10 +2654,7 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.OSD.FPS = fps_string;
}
if (!suppressCaptureRewind && Global.Rewinder.RewindActive)
{
Global.Rewinder.CaptureRewindState();
}
CaptureRewind(suppressCaptureRewind);
if (!_runloopFrameadvance)
{
@ -3418,6 +3406,11 @@ namespace BizHawk.Client.EmuHawk
}
}
public void ClearRewindData()
{
Global.Rewinder.ResetRewindBuffer();
}
#endregion
#region Tool Control API
@ -3478,6 +3471,43 @@ namespace BizHawk.Client.EmuHawk
GenericCoreConfig.DoDialog(this, "Gameboy Advance Settings");
}
private void CaptureRewind(bool suppressCaptureRewind)
{
if (IsSlave && master.WantsToControlRewind)
{
master.CaptureRewind();
}
else if (!suppressCaptureRewind && Global.Rewinder.RewindActive)
{
Global.Rewinder.CaptureRewindState();
}
}
private bool Rewind(ref bool runFrame)
{
if (IsSlave && master.WantsToControlRewind)
{
if (Global.ClientControls["Rewind"] || PressRewind)
{
runFrame = false; // TODO: the master should be deciding this!
return master.Rewind();
}
}
var isRewinding = false;
if (Global.Rewinder.RewindActive && (Global.ClientControls["Rewind"] || PressRewind)
&& !Global.MovieSession.Movie.IsRecording) // Rewind isn't "bulletproof" and can desync a recording movie!
{
Global.Rewinder.Rewind(1);
runFrame = Global.Rewinder.Count != 0;
isRewinding = true;
}
return isRewinding;
}
#endregion
private void LinkConnectStatusBarButton_Click(object sender, EventArgs e)

View File

@ -15,5 +15,19 @@
this.Focus();
//NewTasMenuItem_Click(null, null);
}
public bool WantsToControlRewind { get { return true; } }
public void CaptureRewind()
{
// Do nothing, Tastudio handles this just fine
}
public bool Rewind()
{
GoToPreviousFrame();
return true;
}
}
}

View File

@ -26,7 +26,6 @@ namespace BizHawk.Client.EmuHawk
private int _defaultWidth;
private int _defaultHeight;
private TasMovie _currentTasMovie;
private bool _originalRewindStatus; // The client rewind status before TAStudio was engaged (used to restore when disengaged)
private MovieEndAction _originalEndAction; // The movie end behavior selected by the user (that is overridden by TAStudio)
private Dictionary<string, string> GenerateColumnNames()
@ -80,10 +79,9 @@ namespace BizHawk.Client.EmuHawk
SetTextProperty();
GlobalWin.MainForm.PauseEmulator();
GlobalWin.MainForm.RelinquishControl(this);
_originalRewindStatus = Global.Rewinder.RewindActive;
_originalEndAction = Global.Config.MovieEndAction;
MarkerControl.Markers = _currentTasMovie.Markers;
GlobalWin.MainForm.EnableRewind(false);
GlobalWin.MainForm.ClearRewindData();
Global.Config.MovieEndAction = MovieEndAction.Record;
GlobalWin.MainForm.SetMainformMovieInfo();
}
@ -94,7 +92,6 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.OSD.AddMessage("TAStudio disengaged");
Global.MovieSession.Movie = MovieService.DefaultInstance;
GlobalWin.MainForm.TakeBackControl();
GlobalWin.MainForm.EnableRewind(_originalRewindStatus);
Global.Config.MovieEndAction = _originalEndAction;
GlobalWin.MainForm.SetMainformMovieInfo();
}