refactor IMovie to expose the movie mode, and make extension methods that do IsPlaying type logic. This way there can be direct checks, and more variety of methods without cluttering the interface

This commit is contained in:
adelikat 2019-12-21 16:34:29 -06:00
parent d26cb7d272
commit b80b367831
25 changed files with 216 additions and 182 deletions

View File

@ -15,13 +15,13 @@ namespace BizHawk.Client.Common
private readonly Action<string> LogCallback; private readonly Action<string> LogCallback;
public bool StartsFromSavestate() => Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie.StartsFromSavestate; public bool StartsFromSavestate() => Global.MovieSession.Movie.IsActive() && Global.MovieSession.Movie.StartsFromSavestate;
public bool StartsFromSaveram() => Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie.StartsFromSaveRam; public bool StartsFromSaveram() => Global.MovieSession.Movie.IsActive() && Global.MovieSession.Movie.StartsFromSaveRam;
public Dictionary<string, dynamic> GetInput(int frame) public Dictionary<string, dynamic> GetInput(int frame)
{ {
if (!Global.MovieSession.Movie.IsActive) if (Global.MovieSession.Movie.NotActive())
{ {
LogCallback("No movie loaded"); LogCallback("No movie loaded");
return null; return null;
@ -40,7 +40,10 @@ namespace BizHawk.Client.Common
public string GetInputAsMnemonic(int frame) public string GetInputAsMnemonic(int frame)
{ {
if (!Global.MovieSession.Movie.IsActive || frame >= Global.MovieSession.Movie.InputLogLength) return string.Empty; if (Global.MovieSession.Movie.NotActive() || frame >= Global.MovieSession.Movie.InputLogLength)
{
return string.Empty;
}
var lg = Global.MovieSession.LogGeneratorInstance(); var lg = Global.MovieSession.LogGeneratorInstance();
lg.SetSource(Global.MovieSession.Movie.GetInputState(frame)); lg.SetSource(Global.MovieSession.Movie.GetInputState(frame));
return lg.GenerateLogEntry(); return lg.GenerateLogEntry();
@ -48,7 +51,11 @@ namespace BizHawk.Client.Common
public void Save(string filename = null) public void Save(string filename = null)
{ {
if (!Global.MovieSession.Movie.IsActive) return; if (Global.MovieSession.Movie.NotActive())
{
return;
}
if (!string.IsNullOrEmpty(filename)) if (!string.IsNullOrEmpty(filename))
{ {
filename += $".{Global.MovieSession.Movie.PreferredExtension}"; filename += $".{Global.MovieSession.Movie.PreferredExtension}";
@ -65,7 +72,10 @@ namespace BizHawk.Client.Common
public Dictionary<string, string> GetHeader() public Dictionary<string, string> GetHeader()
{ {
var table = new Dictionary<string, string>(); var table = new Dictionary<string, string>();
if (!Global.MovieSession.Movie.IsActive) return table; if (Global.MovieSession.Movie.NotActive())
{
return table;
}
foreach (var kvp in Global.MovieSession.Movie.HeaderEntries) table[kvp.Key] = kvp.Value; foreach (var kvp in Global.MovieSession.Movie.HeaderEntries) table[kvp.Key] = kvp.Value;
return table; return table;
} }
@ -73,7 +83,11 @@ namespace BizHawk.Client.Common
public List<string> GetComments() public List<string> GetComments()
{ {
var list = new List<string>(Global.MovieSession.Movie.Comments.Count); var list = new List<string>(Global.MovieSession.Movie.Comments.Count);
if (!Global.MovieSession.Movie.IsActive) return list; if (Global.MovieSession.Movie.NotActive())
{
return list;
}
for (var i = 0; i < Global.MovieSession.Movie.Comments.Count; i++) list[i] = Global.MovieSession.Movie.Comments[i]; for (var i = 0; i < Global.MovieSession.Movie.Comments.Count; i++) list[i] = Global.MovieSession.Movie.Comments[i];
return list; return list;
} }
@ -81,7 +95,11 @@ namespace BizHawk.Client.Common
public List<string> GetSubtitles() public List<string> GetSubtitles()
{ {
var list = new List<string>(Global.MovieSession.Movie.Subtitles.Count); var list = new List<string>(Global.MovieSession.Movie.Subtitles.Count);
if (!Global.MovieSession.Movie.IsActive) return list; if (Global.MovieSession.Movie.NotActive())
{
return list;
}
for (var i = 0; i < Global.MovieSession.Movie.Subtitles.Count; i++) list[i] = Global.MovieSession.Movie.Subtitles[i].ToString(); for (var i = 0; i < Global.MovieSession.Movie.Subtitles.Count; i++) list[i] = Global.MovieSession.Movie.Subtitles[i].ToString();
return list; return list;
} }
@ -94,17 +112,11 @@ namespace BizHawk.Client.Common
public bool GetRerecordCounting() => Global.MovieSession.Movie.IsCountingRerecords; public bool GetRerecordCounting() => Global.MovieSession.Movie.IsCountingRerecords;
public bool IsLoaded() => Global.MovieSession.Movie.IsActive; public bool IsLoaded() => Global.MovieSession.Movie.IsActive();
public double Length() => Global.MovieSession.Movie.FrameCount; public double Length() => Global.MovieSession.Movie.FrameCount;
public string Mode() => Global.MovieSession.Movie.IsFinished public string Mode() => Global.MovieSession.Movie.Mode.ToString().ToUpper();
? "FINISHED"
: Global.MovieSession.Movie.IsPlaying
? "PLAY"
: Global.MovieSession.Movie.IsRecording
? "RECORD"
: "INACTIVE";
public void SetReadOnly(bool readOnly) => Global.MovieSession.ReadOnly = readOnly; public void SetReadOnly(bool readOnly) => Global.MovieSession.ReadOnly = readOnly;
@ -117,7 +129,11 @@ namespace BizHawk.Client.Common
public double GetFps() public double GetFps()
{ {
var movie = Global.MovieSession.Movie; var movie = Global.MovieSession.Movie;
if (!movie.IsActive) return default; if (movie.NotActive())
{
return default;
}
return new PlatformFrameRates()[ return new PlatformFrameRates()[
movie.HeaderEntries[HeaderKeys.PLATFORM], movie.HeaderEntries[HeaderKeys.PLATFORM],
movie.HeaderEntries.TryGetValue(HeaderKeys.PAL, out var isPal) && isPal == "1" movie.HeaderEntries.TryGetValue(HeaderKeys.PAL, out var isPal) && isPal == "1"

View File

@ -261,7 +261,7 @@ namespace BizHawk.Client.Common
public static string SaveRamPath(GameInfo game) public static string SaveRamPath(GameInfo game)
{ {
var name = FilesystemSafeName(game); var name = FilesystemSafeName(game);
if (Global.MovieSession.Movie.IsActive) if (Global.MovieSession.Movie.IsActive())
{ {
name += $".{Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename)}"; name += $".{Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename)}";
} }
@ -288,7 +288,7 @@ namespace BizHawk.Client.Common
name = FilesystemSafeName(game); name = FilesystemSafeName(game);
} }
if (Global.MovieSession.Movie.IsActive) if (Global.MovieSession.Movie.IsActive())
{ {
name = Path.Combine(name, $"movie-{Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename)}"); name = Path.Combine(name, $"movie-{Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename)}");
} }
@ -363,7 +363,7 @@ namespace BizHawk.Client.Common
name += $".{Global.Emulator.Attributes().CoreName}"; name += $".{Global.Emulator.Attributes().CoreName}";
} }
if (Global.MovieSession.Movie.IsActive) if (Global.MovieSession.Movie.IsActive())
{ {
name += $".{Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename)}"; name += $".{Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename)}";
} }

View File

@ -65,7 +65,7 @@ namespace BizHawk.Client.Common
} }
} }
if (Global.MovieSession.Movie.IsActive) if (Global.MovieSession.Movie.IsActive())
{ {
bs.PutLump(BinaryStateLump.Input, bs.PutLump(BinaryStateLump.Input,
delegate(TextWriter tw) delegate(TextWriter tw)
@ -86,7 +86,7 @@ namespace BizHawk.Client.Common
}); });
} }
if (Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie is TasMovie) if (Global.MovieSession.Movie.IsActive() && Global.MovieSession.Movie is TasMovie)
{ {
bs.PutLump(BinaryStateLump.LagLog, bs.PutLump(BinaryStateLump.LagLog,
delegate(TextWriter tw) delegate(TextWriter tw)
@ -139,7 +139,7 @@ namespace BizHawk.Client.Common
{ {
var succeed = false; var succeed = false;
if (Global.MovieSession.Movie.IsActive) if (Global.MovieSession.Movie.IsActive())
{ {
bl.GetLump(BinaryStateLump.Input, true, tr => succeed = Global.MovieSession.HandleMovieLoadState_HackyStep1(tr)); bl.GetLump(BinaryStateLump.Input, true, tr => succeed = Global.MovieSession.HandleMovieLoadState_HackyStep1(tr));
if (!succeed) if (!succeed)
@ -179,7 +179,7 @@ namespace BizHawk.Client.Common
Global.UserBag = (Dictionary<string, object>)ConfigService.LoadWithType(userData); Global.UserBag = (Dictionary<string, object>)ConfigService.LoadWithType(userData);
} }
if (Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie is TasMovie) if (Global.MovieSession.Movie.IsActive() && Global.MovieSession.Movie is TasMovie)
{ {
bl.GetLump(BinaryStateLump.LagLog, false, delegate(TextReader tr) bl.GetLump(BinaryStateLump.LagLog, false, delegate(TextReader tr)
{ {

View File

@ -64,7 +64,7 @@ namespace BizHawk.Client.Common
{ {
get get
{ {
if (Movie.IsActive && !Movie.IsFinished && Global.Emulator.Frame > 0) if (Movie.IsPlayingOrRecording() && Global.Emulator.Frame > 0)
{ {
return Movie.GetInputState(Global.Emulator.Frame - 1); return Movie.GetInputState(Global.Emulator.Frame - 1);
} }
@ -77,7 +77,7 @@ namespace BizHawk.Client.Common
{ {
get get
{ {
if (Movie.IsActive && !Movie.IsFinished && Global.Emulator.Frame > 1) if (Movie.IsPlayingOrRecording() && Global.Emulator.Frame > 1)
{ {
return Movie.GetInputState(Global.Emulator.Frame - 2); return Movie.GetInputState(Global.Emulator.Frame - 2);
} }
@ -170,18 +170,18 @@ namespace BizHawk.Client.Common
public void StopMovie(bool saveChanges = true) public void StopMovie(bool saveChanges = true)
{ {
var message = "Movie "; var message = "Movie ";
if (Movie.IsRecording) if (Movie.IsRecording())
{ {
message += "recording "; message += "recording ";
} }
else if (Movie.IsPlaying) else if (Movie.IsPlaying())
{ {
message += "playback "; message += "playback ";
} }
message += "stopped."; message += "stopped.";
if (Movie.IsActive) if (Movie.IsActive())
{ {
var result = Movie.Stop(saveChanges); var result = Movie.Stop(saveChanges);
if (result) if (result)
@ -199,7 +199,7 @@ namespace BizHawk.Client.Common
public void HandleMovieSaveState(TextWriter writer) public void HandleMovieSaveState(TextWriter writer)
{ {
if (Movie.IsActive) if (Movie.IsActive())
{ {
Movie.WriteInputLog(writer); Movie.WriteInputLog(writer);
} }
@ -207,7 +207,7 @@ namespace BizHawk.Client.Common
public void ClearFrame() public void ClearFrame()
{ {
if (Movie.IsPlaying) if (Movie.IsPlaying())
{ {
Movie.ClearFrame(Global.Emulator.Frame); Movie.ClearFrame(Global.Emulator.Frame);
Output($"Scrubbed input at frame {Global.Emulator.Frame}"); Output($"Scrubbed input at frame {Global.Emulator.Frame}");
@ -216,11 +216,11 @@ namespace BizHawk.Client.Common
public void HandleMovieOnFrameLoop() public void HandleMovieOnFrameLoop()
{ {
if (!Movie.IsActive) if (!Movie.IsActive())
{ {
LatchInputFromPlayer(Global.MovieInputSourceAdapter); LatchInputFromPlayer(Global.MovieInputSourceAdapter);
} }
else if (Movie.IsFinished) else if (Movie.IsFinished())
{ {
if (Global.Emulator.Frame < Movie.FrameCount) // This scenario can happen from rewinding (suddenly we are back in the movie, so hook back up to the movie if (Global.Emulator.Frame < Movie.FrameCount) // This scenario can happen from rewinding (suddenly we are back in the movie, so hook back up to the movie
{ {
@ -232,18 +232,18 @@ namespace BizHawk.Client.Common
LatchInputFromPlayer(Global.MovieInputSourceAdapter); LatchInputFromPlayer(Global.MovieInputSourceAdapter);
} }
} }
else if (Movie.IsPlaying) else if (Movie.IsPlaying())
{ {
LatchInputFromLog(); LatchInputFromLog();
if (Movie.IsRecording) // The movie end situation can cause the switch to record mode, in that case we need to capture some input for this frame if (Movie.IsRecording()) // The movie end situation can cause the switch to record mode, in that case we need to capture some input for this frame
{ {
HandleFrameLoopForRecordMode(); HandleFrameLoopForRecordMode();
} }
else else
{ {
// Movie may go into finished mode as a result from latching // Movie may go into finished mode as a result from latching
if (!Movie.IsFinished) if (!Movie.IsFinished())
{ {
if (Global.ClientControls.IsPressed("Scrub Input")) if (Global.ClientControls.IsPressed("Scrub Input"))
{ {
@ -269,7 +269,7 @@ namespace BizHawk.Client.Common
} }
} }
} }
else if (Movie.IsRecording) else if (Movie.IsRecording())
{ {
HandleFrameLoopForRecordMode(); HandleFrameLoopForRecordMode();
} }
@ -278,7 +278,7 @@ namespace BizHawk.Client.Common
private void HandleFrameLoopForRecordMode() private void HandleFrameLoopForRecordMode()
{ {
// we don't want TasMovie to latch user input outside its internal recording mode, so limit it to autohold // we don't want TasMovie to latch user input outside its internal recording mode, so limit it to autohold
if (Movie is TasMovie && Movie.IsPlaying) if (Movie is TasMovie && Movie.IsPlaying())
{ {
MovieControllerAdapter.LatchSticky(); MovieControllerAdapter.LatchSticky();
} }
@ -304,12 +304,12 @@ namespace BizHawk.Client.Common
if (Movie is TasMovie tasMovie) if (Movie is TasMovie tasMovie)
{ {
tasMovie.GreenzoneCurrentFrame(); tasMovie.GreenzoneCurrentFrame();
if (tasMovie.IsPlaying && Global.Emulator.Frame >= tasMovie.InputLogLength) if (tasMovie.IsPlaying() && Global.Emulator.Frame >= tasMovie.InputLogLength)
{ {
HandleFrameLoopForRecordMode(); HandleFrameLoopForRecordMode();
} }
} }
else if (Movie.IsPlaying && !Movie.IsFinished && Global.Emulator.Frame >= Movie.InputLogLength) else if (Movie.Mode == MovieMode.Play && Global.Emulator.Frame >= Movie.InputLogLength)
{ {
HandlePlaybackEnd(); HandlePlaybackEnd();
} }
@ -324,7 +324,7 @@ namespace BizHawk.Client.Common
// TODO: maybe someone who understands more about what's going on here could rename these step1 and step2 into something more descriptive // TODO: maybe someone who understands more about what's going on here could rename these step1 and step2 into something more descriptive
public bool HandleMovieLoadState_HackyStep2(TextReader reader) public bool HandleMovieLoadState_HackyStep2(TextReader reader)
{ {
if (!Movie.IsActive) if (Movie.NotActive())
{ {
return true; return true;
} }
@ -361,7 +361,7 @@ namespace BizHawk.Client.Common
public bool HandleMovieLoadState_HackyStep1(TextReader reader) public bool HandleMovieLoadState_HackyStep1(TextReader reader)
{ {
if (!Movie.IsActive) if (!Movie.IsActive())
{ {
return true; return true;
} }
@ -375,22 +375,22 @@ namespace BizHawk.Client.Common
return false; return false;
} }
if (Movie.IsRecording) if (Movie.IsRecording())
{ {
Movie.SwitchToPlay(); Movie.SwitchToPlay();
} }
else if (Movie.IsFinished) else if (Movie.IsFinished())
{ {
LatchInputFromPlayer(Global.MovieInputSourceAdapter); LatchInputFromPlayer(Global.MovieInputSourceAdapter);
} }
} }
else else
{ {
if (Movie.IsFinished) if (Movie.IsFinished())
{ {
Movie.StartNewRecording(); Movie.StartNewRecording();
} }
else if (Movie.IsPlaying) else if (Movie.IsPlaying())
{ {
Movie.SwitchToRecord(); Movie.SwitchToRecord();
} }
@ -401,7 +401,7 @@ namespace BizHawk.Client.Common
public void ToggleMultitrack() public void ToggleMultitrack()
{ {
if (Movie.IsActive) if (Movie.IsActive())
{ {
if (Global.Config.VBAStyleMovieLoadState) if (Global.Config.VBAStyleMovieLoadState)
{ {

View File

@ -245,7 +245,7 @@ namespace BizHawk.Client.Common
if (Log.Count < stateFrame) if (Log.Count < stateFrame)
{ {
if (IsFinished) if (this.IsFinished())
{ {
return true; return true;
} }

View File

@ -4,20 +4,7 @@ namespace BizHawk.Client.Common
{ {
public partial class Bk2Movie public partial class Bk2Movie
{ {
protected enum MovieMode public MovieMode Mode { get; protected set; } = MovieMode.Inactive;
{
Inactive, Play, Record, Finished
}
protected MovieMode Mode { get; set; } = MovieMode.Inactive;
public bool IsActive => Mode != MovieMode.Inactive;
public bool IsPlaying => Mode == MovieMode.Play || Mode == MovieMode.Finished;
public bool IsRecording => Mode == MovieMode.Record;
public bool IsFinished => Mode == MovieMode.Finished;
public virtual void StartNewRecording() public virtual void StartNewRecording()
{ {
@ -51,7 +38,7 @@ namespace BizHawk.Client.Common
bool saved = false; bool saved = false;
if (saveChanges) if (saveChanges)
{ {
if (Mode == MovieMode.Record || (IsActive && Changes)) if (Mode == MovieMode.Record || (this.IsActive() && Changes))
{ {
Save(); Save();
saved = true; saved = true;

View File

@ -6,17 +6,42 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Client.Common namespace BizHawk.Client.Common
{ {
public enum MovieMode
{
/// <summary>
/// There is no movie loaded
/// </summary>
Inactive,
/// <summary>
/// The movie is in playback mode
/// </summary>
Play,
/// <summary>
/// The movie is currently recording
/// </summary>
Record,
/// <summary>
/// The movie has played past the end, but is still loaded in memory
/// </summary>
Finished
}
// TODO: message callback / event handler // TODO: message callback / event handler
// TODO: consider other event handlers, switching modes? // TODO: consider other event handlers, switching modes?
public interface IMovie public interface IMovie
{ {
#region Status #region Status
/// <summary>
/// Gets the current movie mode
/// </summary>
MovieMode Mode { get; }
bool IsCountingRerecords { get; set; } bool IsCountingRerecords { get; set; }
bool IsActive { get; }
bool IsPlaying { get; }
bool IsRecording { get; }
bool IsFinished { get; }
bool Changes { get; } bool Changes { get; }
#endregion #endregion
@ -218,4 +243,14 @@ namespace BizHawk.Client.Common
#endregion #endregion
} }
public static class MovieExtensions
{
public static bool IsActive(this IMovie movie) => movie.Mode != MovieMode.Inactive;
public static bool NotActive(this IMovie movie) => movie.Mode == MovieMode.Inactive;
public static bool IsPlaying(this IMovie movie) => movie.Mode == MovieMode.Play || movie.Mode == MovieMode.Finished;
public static bool IsRecording(this IMovie movie) => movie.Mode == MovieMode.Record;
public static bool IsFinished(this IMovie movie) => movie.Mode == MovieMode.Finished;
public static bool IsPlayingOrRecording(this IMovie movie) => movie.Mode == MovieMode.Play && movie.Mode == MovieMode.Record;
}
} }

View File

@ -22,7 +22,7 @@ namespace BizHawk.Client.Common
TasLagLog.RemoveFrom(frame); TasLagLog.RemoveFrom(frame);
TasLagLog[frame] = Global.Emulator.AsInputPollable().IsLagFrame; TasLagLog[frame] = Global.Emulator.AsInputPollable().IsLagFrame;
if (IsRecording) if (this.IsRecording())
{ {
TasStateManager.Invalidate(frame + 1); TasStateManager.Invalidate(frame + 1);
} }

View File

@ -115,12 +115,12 @@ namespace BizHawk.Client.Common
public override void SwitchToPlay() public override void SwitchToPlay()
{ {
Mode = Moviemode.Play; Mode = MovieMode.Play;
} }
public override void SwitchToRecord() public override void SwitchToRecord()
{ {
Mode = Moviemode.Record; Mode = MovieMode.Record;
} }
/// <summary> /// <summary>
@ -379,7 +379,7 @@ namespace BizHawk.Client.Common
Truncate(Log.Count); Truncate(Log.Count);
} }
Mode = Moviemode.Finished; Mode = MovieMode.Finished;
} }
if (IsCountingRerecords) if (IsCountingRerecords)

View File

@ -313,7 +313,7 @@ namespace BizHawk.Client.Common
// each one records how to get back to the previous state, once we've gone back to // each one records how to get back to the previous state, once we've gone back to
// the second item, it's already resulted in the first state being loaded. The // the second item, it's already resulted in the first state being loaded. The
// first item is just a junk entry with the initial value of _lastState (0 bytes). // first item is just a junk entry with the initial value of _lastState (0 bytes).
if (_rewindBuffer.Count <= 1 || (Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie.InputLogLength == 0)) if (_rewindBuffer.Count <= 1 || (Global.MovieSession.Movie.IsActive() && Global.MovieSession.Movie.InputLogLength == 0))
{ {
break; break;
} }

View File

@ -68,7 +68,7 @@ namespace BizHawk.Client.EmuHawk
private string MakeFrameCounter() private string MakeFrameCounter()
{ {
if (Global.MovieSession.Movie.IsFinished) if (Global.MovieSession.Movie.IsFinished())
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
sb sb
@ -79,7 +79,7 @@ namespace BizHawk.Client.EmuHawk
return sb.ToString(); return sb.ToString();
} }
if (Global.MovieSession.Movie.IsPlaying) if (Global.MovieSession.Movie.IsPlaying())
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
sb sb
@ -188,7 +188,7 @@ namespace BizHawk.Client.EmuHawk
public string InputPrevious() public string InputPrevious()
{ {
if (Global.MovieSession.Movie.IsActive && !Global.MovieSession.Movie.IsFinished) if (Global.MovieSession.Movie.IsPlayingOrRecording())
{ {
var lg = Global.MovieSession.LogGeneratorInstance(); var lg = Global.MovieSession.LogGeneratorInstance();
var state = Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1); var state = Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1);
@ -204,11 +204,9 @@ namespace BizHawk.Client.EmuHawk
public string InputStrOrAll() public string InputStrOrAll()
{ {
var m = (Global.MovieSession.Movie.IsActive && var m = Global.MovieSession.Movie.IsPlayingOrRecording() && Global.Emulator.Frame > 0
!Global.MovieSession.Movie.IsFinished && ? Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1)
Global.Emulator.Frame > 0) ? : Global.MovieSession.MovieControllerInstance();
Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1) :
Global.MovieSession.MovieControllerInstance();
var lg = Global.MovieSession.LogGeneratorInstance(); var lg = Global.MovieSession.LogGeneratorInstance();
@ -225,11 +223,11 @@ namespace BizHawk.Client.EmuHawk
public string MakeIntersectImmediatePrevious() public string MakeIntersectImmediatePrevious()
{ {
if (Global.MovieSession.Movie.IsActive) if (Global.MovieSession.Movie.IsActive())
{ {
var m = Global.MovieSession.Movie.IsActive && !Global.MovieSession.Movie.IsFinished ? var m = Global.MovieSession.Movie.IsPlayingOrRecording()
Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1) : ? Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1)
Global.MovieSession.MovieControllerInstance(); : Global.MovieSession.MovieControllerInstance();
var lg = Global.MovieSession.LogGeneratorInstance(); var lg = Global.MovieSession.LogGeneratorInstance();
lg.SetSource(Global.AutofireStickyXORAdapter.And(m)); lg.SetSource(Global.AutofireStickyXORAdapter.And(m));
@ -241,7 +239,7 @@ namespace BizHawk.Client.EmuHawk
public string MakeRerecordCount() public string MakeRerecordCount()
{ {
return Global.MovieSession.Movie.IsActive return Global.MovieSession.Movie.IsActive()
? Global.MovieSession.Movie.Rerecords.ToString() ? Global.MovieSession.Movie.Rerecords.ToString()
: ""; : "";
} }
@ -270,8 +268,8 @@ namespace BizHawk.Client.EmuHawk
if (Global.Config.DisplayInput && !Global.Game.IsNullInstance()) if (Global.Config.DisplayInput && !Global.Game.IsNullInstance())
{ {
if ((Global.MovieSession.Movie.IsPlaying && !Global.MovieSession.Movie.IsFinished) if (Global.MovieSession.Movie.Mode == MovieMode.Play
|| (Global.MovieSession.Movie.IsFinished && Global.Emulator.Frame == Global.MovieSession.Movie.InputLogLength)) // Account for the last frame of the movie, the movie state is immediately "Finished" here but we still want to show the input || (Global.MovieSession.Movie.IsFinished() && Global.Emulator.Frame == Global.MovieSession.Movie.InputLogLength)) // Account for the last frame of the movie, the movie state is immediately "Finished" here but we still want to show the input
{ {
var input = InputStrMovie(); var input = InputStrMovie();
var point = GetCoordinates(g, Global.Config.InputDisplay, input); var point = GetCoordinates(g, Global.Config.InputDisplay, input);
@ -366,7 +364,7 @@ namespace BizHawk.Client.EmuHawk
g.DrawString(message, MessageFont, Color.White, point.X, point.Y); g.DrawString(message, MessageFont, Color.White, point.X, point.Y);
} }
if (Global.MovieSession.Movie.IsActive && Global.Config.DisplaySubtitles) if (Global.MovieSession.Movie.IsActive() && Global.Config.DisplaySubtitles)
{ {
var subList = Global.MovieSession.Movie.Subtitles.GetSubtitles(Global.Emulator.Frame); var subList = Global.MovieSession.Movie.Subtitles.GetSubtitles(Global.Emulator.Frame);

View File

@ -237,12 +237,12 @@ namespace BizHawk.Client.EmuHawk
private void MovieSubMenu_DropDownOpened(object sender, EventArgs e) private void MovieSubMenu_DropDownOpened(object sender, EventArgs e)
{ {
FullMovieLoadstatesMenuItem.Enabled = !MovieSession.MultiTrack.IsActive; FullMovieLoadstatesMenuItem.Enabled = !MovieSession.MultiTrack.IsActive;
StopMovieWithoutSavingMenuItem.Enabled = MovieSession.Movie.IsActive && MovieSession.Movie.Changes; StopMovieWithoutSavingMenuItem.Enabled = MovieSession.Movie.IsActive() && MovieSession.Movie.Changes;
StopMovieMenuItem.Enabled StopMovieMenuItem.Enabled
= PlayFromBeginningMenuItem.Enabled = PlayFromBeginningMenuItem.Enabled
= SaveMovieMenuItem.Enabled = SaveMovieMenuItem.Enabled
= SaveMovieAsMenuItem.Enabled = SaveMovieAsMenuItem.Enabled
= MovieSession.Movie.IsActive; = MovieSession.Movie.IsActive();
ReadonlyMenuItem.Checked = MovieSession.ReadOnly; ReadonlyMenuItem.Checked = MovieSession.ReadOnly;
AutomaticallyBackupMoviesMenuItem.Checked = Config.EnableBackupMovies; AutomaticallyBackupMoviesMenuItem.Checked = Config.EnableBackupMovies;
@ -683,11 +683,11 @@ namespace BizHawk.Client.EmuHawk
{ {
PauseMenuItem.Checked = _didMenuPause ? _wasPaused : EmulatorPaused; PauseMenuItem.Checked = _didMenuPause ? _wasPaused : EmulatorPaused;
SoftResetMenuItem.Enabled = Emulator.ControllerDefinition.BoolButtons.Contains("Reset") && SoftResetMenuItem.Enabled = Emulator.ControllerDefinition.BoolButtons.Contains("Reset")
(!MovieSession.Movie.IsPlaying || MovieSession.Movie.IsFinished); && MovieSession.Movie.Mode != MovieMode.Play;
HardResetMenuItem.Enabled = Emulator.ControllerDefinition.BoolButtons.Contains("Power") && HardResetMenuItem.Enabled = Emulator.ControllerDefinition.BoolButtons.Contains("Power")
(!MovieSession.Movie.IsPlaying || MovieSession.Movie.IsFinished); && MovieSession.Movie.Mode != MovieMode.Play;;
PauseMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Pause"].Bindings; PauseMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Pause"].Bindings;
RebootCoreMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Reboot Core"].Bindings; RebootCoreMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Reboot Core"].Bindings;
@ -1543,10 +1543,10 @@ namespace BizHawk.Client.EmuHawk
NESSoundChannelsMenuItem.Enabled = Tools.IsAvailable<NESSoundConfig>(); NESSoundChannelsMenuItem.Enabled = Tools.IsAvailable<NESSoundConfig>();
MovieSettingsMenuItem.Enabled = (Emulator is NES || Emulator is SubNESHawk) MovieSettingsMenuItem.Enabled = (Emulator is NES || Emulator is SubNESHawk)
&& !MovieSession.Movie.IsActive; && !MovieSession.Movie.IsActive();
NesControllerSettingsMenuItem.Enabled = Tools.IsAvailable<NesControllerSettings>() NesControllerSettingsMenuItem.Enabled = Tools.IsAvailable<NesControllerSettings>()
&& !MovieSession.Movie.IsActive; && !MovieSession.Movie.IsActive();
barcodeReaderToolStripMenuItem.Enabled = ServiceInjector.IsAvailable(Emulator.ServiceProvider, typeof(BarcodeEntry)); barcodeReaderToolStripMenuItem.Enabled = ServiceInjector.IsAvailable(Emulator.ServiceProvider, typeof(BarcodeEntry));
@ -1633,7 +1633,7 @@ namespace BizHawk.Client.EmuHawk
private void FdsEjectDiskMenuItem_Click(object sender, EventArgs e) private void FdsEjectDiskMenuItem_Click(object sender, EventArgs e)
{ {
if (!MovieSession.Movie.IsPlaying || MovieSession.Movie.IsFinished) if (MovieSession.Movie.Mode != MovieMode.Play)
{ {
ClickyVirtualPadController.Click("FDS Eject"); ClickyVirtualPadController.Click("FDS Eject");
AddOnScreenMessage("FDS disk ejected."); AddOnScreenMessage("FDS disk ejected.");
@ -1645,7 +1645,7 @@ namespace BizHawk.Client.EmuHawk
if (Emulator is NES nes && nes.IsVS if (Emulator is NES nes && nes.IsVS
|| Emulator is SubNESHawk sub && sub.IsVs) || Emulator is SubNESHawk sub && sub.IsVs)
{ {
if (!MovieSession.Movie.IsPlaying || MovieSession.Movie.IsFinished) if (MovieSession.Movie.Mode != MovieMode.Play)
{ {
ClickyVirtualPadController.Click("Insert Coin P1"); ClickyVirtualPadController.Click("Insert Coin P1");
AddOnScreenMessage("P1 Coin Inserted"); AddOnScreenMessage("P1 Coin Inserted");
@ -1658,7 +1658,7 @@ namespace BizHawk.Client.EmuHawk
if (Emulator is NES nes && nes.IsVS if (Emulator is NES nes && nes.IsVS
|| Emulator is SubNESHawk sub && sub.IsVs) || Emulator is SubNESHawk sub && sub.IsVs)
{ {
if (!MovieSession.Movie.IsPlaying || MovieSession.Movie.IsFinished) if (MovieSession.Movie.Mode != MovieMode.Play)
{ {
ClickyVirtualPadController.Click("Insert Coin P2"); ClickyVirtualPadController.Click("Insert Coin P2");
AddOnScreenMessage("P2 Coin Inserted"); AddOnScreenMessage("P2 Coin Inserted");
@ -1671,7 +1671,7 @@ namespace BizHawk.Client.EmuHawk
if (Emulator is NES nes && nes.IsVS if (Emulator is NES nes && nes.IsVS
|| Emulator is SubNESHawk sub && sub.IsVs) || Emulator is SubNESHawk sub && sub.IsVs)
{ {
if (!MovieSession.Movie.IsPlaying || MovieSession.Movie.IsFinished) if (MovieSession.Movie.Mode != MovieMode.Play)
{ {
ClickyVirtualPadController.Click("Service Switch"); ClickyVirtualPadController.Click("Service Switch");
AddOnScreenMessage("Service Switch Pressed"); AddOnScreenMessage("Service Switch Pressed");
@ -1725,8 +1725,7 @@ namespace BizHawk.Client.EmuHawk
{ {
var s = ((PCEngine)Emulator).GetSettings(); var s = ((PCEngine)Emulator).GetSettings();
PceControllerSettingsMenuItem.Enabled = !MovieSession.Movie.IsActive; PceControllerSettingsMenuItem.Enabled = MovieSession.Movie.NotActive();
PCEAlwaysPerformSpriteLimitMenuItem.Checked = s.SpriteLimit; PCEAlwaysPerformSpriteLimitMenuItem.Checked = s.SpriteLimit;
PCEAlwaysEqualizeVolumesMenuItem.Checked = s.EqualizeVolume; PCEAlwaysEqualizeVolumesMenuItem.Checked = s.EqualizeVolume;
PCEArcadeCardRewindEnableMenuItem.Checked = s.ArcadeCardRewindHack; PCEArcadeCardRewindEnableMenuItem.Checked = s.ArcadeCardRewindHack;
@ -2079,8 +2078,9 @@ namespace BizHawk.Client.EmuHawk
private void A7800SubMenu_DropDownOpened(object sender, EventArgs e) private void A7800SubMenu_DropDownOpened(object sender, EventArgs e)
{ {
A7800ControllerSettingsMenuItem.Enabled = !MovieSession.Movie.IsActive; A7800ControllerSettingsMenuItem.Enabled
A7800FilterSettingsMenuItem.Enabled = !MovieSession.Movie.IsActive; = A7800FilterSettingsMenuItem.Enabled
= MovieSession.Movie.NotActive();
} }
private void A7800ControllerSettingsToolStripMenuItem_Click(object sender, EventArgs e) private void A7800ControllerSettingsToolStripMenuItem_Click(object sender, EventArgs e)
@ -2180,7 +2180,7 @@ namespace BizHawk.Client.EmuHawk
private void PSXSubMenu_DropDownOpened(object sender, EventArgs e) private void PSXSubMenu_DropDownOpened(object sender, EventArgs e)
{ {
PSXControllerSettingsMenuItem.Enabled = !MovieSession.Movie.IsActive; PSXControllerSettingsMenuItem.Enabled = MovieSession.Movie.NotActive();
} }
private void PSXControllerSettingsMenuItem_Click(object sender, EventArgs e) private void PSXControllerSettingsMenuItem_Click(object sender, EventArgs e)
@ -2230,7 +2230,7 @@ namespace BizHawk.Client.EmuHawk
SnesGBInSGBMenuItem.Visible = false; SnesGBInSGBMenuItem.Visible = false;
} }
SNESControllerConfigurationMenuItem.Enabled = !MovieSession.Movie.IsActive; SNESControllerConfigurationMenuItem.Enabled = MovieSession.Movie.NotActive();
} }
private void SNESControllerConfigurationMenuItem_Click(object sender, EventArgs e) private void SNESControllerConfigurationMenuItem_Click(object sender, EventArgs e)
@ -2280,7 +2280,7 @@ namespace BizHawk.Client.EmuHawk
var ss = ((ColecoVision)Emulator).GetSyncSettings(); var ss = ((ColecoVision)Emulator).GetSyncSettings();
ColecoSkipBiosMenuItem.Checked = ss.SkipBiosIntro; ColecoSkipBiosMenuItem.Checked = ss.SkipBiosIntro;
ColecoUseSGMMenuItem.Checked = ss.UseSGM; ColecoUseSGMMenuItem.Checked = ss.UseSGM;
ColecoControllerSettingsMenuItem.Enabled = !MovieSession.Movie.IsActive; ColecoControllerSettingsMenuItem.Enabled = MovieSession.Movie.NotActive();
} }
private void ColecoSkipBiosMenuItem_Click(object sender, EventArgs e) private void ColecoSkipBiosMenuItem_Click(object sender, EventArgs e)
@ -2315,7 +2315,7 @@ namespace BizHawk.Client.EmuHawk
N64PluginSettingsMenuItem.Enabled = N64PluginSettingsMenuItem.Enabled =
N64ControllerSettingsMenuItem.Enabled = N64ControllerSettingsMenuItem.Enabled =
N64ExpansionSlotMenuItem.Enabled = N64ExpansionSlotMenuItem.Enabled =
!MovieSession.Movie.IsActive; MovieSession.Movie.NotActive();
N64CircularAnalogRangeMenuItem.Checked = Config.N64UseCircularAnalogConstraint; N64CircularAnalogRangeMenuItem.Checked = Config.N64UseCircularAnalogConstraint;
@ -2568,7 +2568,7 @@ namespace BizHawk.Client.EmuHawk
private void IntVSubMenu_DropDownOpened(object sender, EventArgs e) private void IntVSubMenu_DropDownOpened(object sender, EventArgs e)
{ {
IntVControllerSettingsMenuItem.Enabled = !MovieSession.Movie.IsActive; IntVControllerSettingsMenuItem.Enabled = MovieSession.Movie.NotActive();
} }
private void IntVControllerSettingsMenuItem_Click(object sender, EventArgs e) private void IntVControllerSettingsMenuItem_Click(object sender, EventArgs e)
@ -2959,7 +2959,7 @@ namespace BizHawk.Client.EmuHawk
RecordMovieContextMenuItem.Visible = RecordMovieContextMenuItem.Visible =
PlayMovieContextMenuItem.Visible = PlayMovieContextMenuItem.Visible =
LoadLastMovieContextMenuItem.Visible = LoadLastMovieContextMenuItem.Visible =
!Emulator.IsNull() && !MovieSession.Movie.IsActive; !Emulator.IsNull() && MovieSession.Movie.NotActive();
RestartMovieContextMenuItem.Visible = RestartMovieContextMenuItem.Visible =
StopMovieContextMenuItem.Visible = StopMovieContextMenuItem.Visible =
@ -2967,13 +2967,13 @@ namespace BizHawk.Client.EmuHawk
ViewCommentsContextMenuItem.Visible = ViewCommentsContextMenuItem.Visible =
SaveMovieContextMenuItem.Visible = SaveMovieContextMenuItem.Visible =
SaveMovieAsContextMenuItem.Visible = SaveMovieAsContextMenuItem.Visible =
MovieSession.Movie.IsActive; MovieSession.Movie.IsActive();
BackupMovieContextMenuItem.Visible = MovieSession.Movie.IsActive; BackupMovieContextMenuItem.Visible = MovieSession.Movie.IsActive();
StopNoSaveContextMenuItem.Visible = MovieSession.Movie.IsActive && MovieSession.Movie.Changes; StopNoSaveContextMenuItem.Visible = MovieSession.Movie.IsActive() && MovieSession.Movie.Changes;
AddSubtitleContextMenuItem.Visible = !Emulator.IsNull() && MovieSession.Movie.IsActive && !MovieSession.ReadOnly; AddSubtitleContextMenuItem.Visible = !Emulator.IsNull() && MovieSession.Movie.IsActive() && !MovieSession.ReadOnly;
ConfigContextMenuItem.Visible = _inFullscreen; ConfigContextMenuItem.Visible = _inFullscreen;
@ -2984,7 +2984,7 @@ namespace BizHawk.Client.EmuHawk
LoadLastRomContextMenuItem.Enabled = !Config.RecentRoms.Empty; LoadLastRomContextMenuItem.Enabled = !Config.RecentRoms.Empty;
LoadLastMovieContextMenuItem.Enabled = !Config.RecentMovies.Empty; LoadLastMovieContextMenuItem.Enabled = !Config.RecentMovies.Empty;
if (MovieSession.Movie.IsActive) if (MovieSession.Movie.IsActive())
{ {
if (MovieSession.ReadOnly) if (MovieSession.ReadOnly)
{ {
@ -3084,7 +3084,7 @@ namespace BizHawk.Client.EmuHawk
private void ViewSubtitlesContextMenuItem_Click(object sender, EventArgs e) private void ViewSubtitlesContextMenuItem_Click(object sender, EventArgs e)
{ {
if (MovieSession.Movie.IsActive) if (MovieSession.Movie.IsActive())
{ {
using var form = new EditSubtitlesForm { ReadOnly = MovieSession.ReadOnly }; using var form = new EditSubtitlesForm { ReadOnly = MovieSession.ReadOnly };
form.GetMovie(MovieSession.Movie); form.GetMovie(MovieSession.Movie);
@ -3130,7 +3130,7 @@ namespace BizHawk.Client.EmuHawk
private void ViewCommentsContextMenuItem_Click(object sender, EventArgs e) private void ViewCommentsContextMenuItem_Click(object sender, EventArgs e)
{ {
if (MovieSession.Movie.IsActive) if (MovieSession.Movie.IsActive())
{ {
using var form = new EditCommentsForm(); using var form = new EditCommentsForm();
form.GetMovie(MovieSession.Movie); form.GetMovie(MovieSession.Movie);
@ -3237,7 +3237,7 @@ namespace BizHawk.Client.EmuHawk
private void LinkConnectStatusBarButton_Click(object sender, EventArgs e) private void LinkConnectStatusBarButton_Click(object sender, EventArgs e)
{ {
// toggle Link status (only outside of a movie session) // toggle Link status (only outside of a movie session)
if (!MovieSession.Movie.IsPlaying || MovieSession.Movie.IsFinished) if (MovieSession.Movie.Mode != MovieMode.Play)
{ {
Emulator.AsLinkable().LinkConnected ^= true; Emulator.AsLinkable().LinkConnected ^= true;
Console.WriteLine("Cable connect status to {0}", Emulator.AsLinkable().LinkConnected); Console.WriteLine("Cable connect status to {0}", Emulator.AsLinkable().LinkConnected);

View File

@ -14,7 +14,7 @@ namespace BizHawk.Client.EmuHawk
{ {
// SuuperW: Check changes. adelikat: this could break bk2 movies // SuuperW: Check changes. adelikat: this could break bk2 movies
// TODO: Clean up the saving process // TODO: Clean up the saving process
if (movie.IsActive && (movie.Changes || !(movie is TasMovie))) if (movie.IsActive() && (movie.Changes || !(movie is TasMovie)))
{ {
movie.Save(); movie.Save();
} }
@ -98,19 +98,19 @@ namespace BizHawk.Client.EmuHawk
public void SetMainformMovieInfo() public void SetMainformMovieInfo()
{ {
if (MovieSession.Movie.IsPlaying) if (MovieSession.Movie.IsPlaying())
{ {
PlayRecordStatusButton.Image = Properties.Resources.Play; PlayRecordStatusButton.Image = Properties.Resources.Play;
PlayRecordStatusButton.ToolTipText = "Movie is in playback mode"; PlayRecordStatusButton.ToolTipText = "Movie is in playback mode";
PlayRecordStatusButton.Visible = true; PlayRecordStatusButton.Visible = true;
} }
else if (MovieSession.Movie.IsRecording) else if (MovieSession.Movie.IsRecording())
{ {
PlayRecordStatusButton.Image = Properties.Resources.RecordHS; PlayRecordStatusButton.Image = Properties.Resources.RecordHS;
PlayRecordStatusButton.ToolTipText = "Movie is in record mode"; PlayRecordStatusButton.ToolTipText = "Movie is in record mode";
PlayRecordStatusButton.Visible = true; PlayRecordStatusButton.Visible = true;
} }
else if (!MovieSession.Movie.IsActive) else if (!MovieSession.Movie.IsActive())
{ {
PlayRecordStatusButton.Image = Properties.Resources.Blank; PlayRecordStatusButton.Image = Properties.Resources.Blank;
PlayRecordStatusButton.ToolTipText = "No movie is active"; PlayRecordStatusButton.ToolTipText = "No movie is active";
@ -129,7 +129,7 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
if (MovieSession.Movie.IsActive) if (MovieSession.Movie.IsActive())
{ {
StartNewMovie(MovieSession.Movie, false); StartNewMovie(MovieSession.Movie, false);
AddOnScreenMessage("Replaying movie file in read-only mode"); AddOnScreenMessage("Replaying movie file in read-only mode");

View File

@ -1568,7 +1568,7 @@ namespace BizHawk.Client.EmuHawk
{ {
str += $" - {Game.Name}"; str += $" - {Game.Name}";
if (MovieSession.Movie.IsActive) if (MovieSession.Movie.IsActive())
{ {
str += $" - {Path.GetFileName(MovieSession.Movie.Filename)}"; str += $" - {Path.GetFileName(MovieSession.Movie.Filename)}";
} }
@ -2388,7 +2388,7 @@ namespace BizHawk.Client.EmuHawk
public void PutCoreSyncSettings(object o) public void PutCoreSyncSettings(object o)
{ {
var settable = new SettingsAdapter(Emulator); var settable = new SettingsAdapter(Emulator);
if (MovieSession.Movie.IsActive) if (MovieSession.Movie.IsActive())
{ {
AddOnScreenMessage("Attempt to change sync-relevant settings while recording BLOCKED."); AddOnScreenMessage("Attempt to change sync-relevant settings while recording BLOCKED.");
} }
@ -2485,7 +2485,7 @@ namespace BizHawk.Client.EmuHawk
// is it enough to run this for one frame? maybe.. // is it enough to run this for one frame? maybe..
if (Emulator.ControllerDefinition.BoolButtons.Contains("Reset")) if (Emulator.ControllerDefinition.BoolButtons.Contains("Reset"))
{ {
if (!MovieSession.Movie.IsPlaying || MovieSession.Movie.IsFinished) if (MovieSession.Movie.Mode != MovieMode.Play)
{ {
ClickyVirtualPadController.Click("Reset"); ClickyVirtualPadController.Click("Reset");
AddOnScreenMessage("Reset button pressed."); AddOnScreenMessage("Reset button pressed.");
@ -2498,7 +2498,7 @@ namespace BizHawk.Client.EmuHawk
// is it enough to run this for one frame? maybe.. // is it enough to run this for one frame? maybe..
if (Emulator.ControllerDefinition.BoolButtons.Contains("Power")) if (Emulator.ControllerDefinition.BoolButtons.Contains("Power"))
{ {
if (!MovieSession.Movie.IsPlaying || MovieSession.Movie.IsFinished) if (MovieSession.Movie.Mode != MovieMode.Play)
{ {
ClickyVirtualPadController.Click("Power"); ClickyVirtualPadController.Click("Power");
AddOnScreenMessage("Power button pressed."); AddOnScreenMessage("Power button pressed.");
@ -2671,7 +2671,7 @@ namespace BizHawk.Client.EmuHawk
private void SaveMovie() private void SaveMovie()
{ {
if (MovieSession.Movie.IsActive) if (MovieSession.Movie.IsActive())
{ {
MovieSession.Movie.Save(); MovieSession.Movie.Save();
AddOnScreenMessage($"{MovieSession.Movie.Filename} saved."); AddOnScreenMessage($"{MovieSession.Movie.Filename} saved.");
@ -2780,7 +2780,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (Emulator.ControllerDefinition.BoolButtons.Contains(button)) if (Emulator.ControllerDefinition.BoolButtons.Contains(button))
{ {
if (!MovieSession.Movie.IsPlaying || MovieSession.Movie.IsFinished) if (MovieSession.Movie.Mode != MovieMode.Play)
{ {
ClickyVirtualPadController.Click(button); ClickyVirtualPadController.Click(button);
AddOnScreenMessage(msg); AddOnScreenMessage(msg);
@ -3059,7 +3059,7 @@ namespace BizHawk.Client.EmuHawk
MovieSession.Movie.SwitchToRecord(); MovieSession.Movie.SwitchToRecord();
} }
if (isRewinding && !IsRewindSlave && MovieSession.Movie.IsRecording) if (isRewinding && !IsRewindSlave && MovieSession.Movie.IsRecording())
{ {
MovieSession.Movie.Truncate(Global.Emulator.Frame); MovieSession.Movie.Truncate(Global.Emulator.Frame);
} }
@ -3930,7 +3930,7 @@ namespace BizHawk.Client.EmuHawk
Config.PutCoreSettings(settable.GetSettings(), t); Config.PutCoreSettings(settable.GetSettings(), t);
} }
if (settable.HasSyncSettings && !MovieSession.Movie.IsActive) if (settable.HasSyncSettings && !MovieSession.Movie.IsActive())
{ {
// don't trample config with loaded-from-movie settings // don't trample config with loaded-from-movie settings
Config.PutCoreSyncSettings(settable.GetSyncSettings(), t); Config.PutCoreSyncSettings(settable.GetSyncSettings(), t);
@ -3970,7 +3970,7 @@ namespace BizHawk.Client.EmuHawk
StopAv(); StopAv();
CommitCoreSettingsToConfig(); CommitCoreSettingsToConfig();
if (MovieSession.Movie.IsActive) // Note: this must be called after CommitCoreSettingsToConfig() if (MovieSession.Movie.IsActive()) // Note: this must be called after CommitCoreSettingsToConfig()
{ {
StopMovie(); StopMovie();
} }
@ -4120,7 +4120,7 @@ namespace BizHawk.Client.EmuHawk
UpdateToolsLoadstate(); UpdateToolsLoadstate();
AutoFireController.ClearStarts(); AutoFireController.ClearStarts();
if (!IsRewindSlave && MovieSession.Movie.IsActive) if (!IsRewindSlave && MovieSession.Movie.IsActive())
{ {
ClearRewindData(); ClearRewindData();
} }
@ -4417,7 +4417,7 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
if (MovieSession.Movie.IsActive) if (MovieSession.Movie.IsActive())
{ {
MovieSession.ReadOnly ^= true; MovieSession.ReadOnly ^= true;
AddOnScreenMessage(MovieSession.ReadOnly ? "Movie read-only mode" : "Movie read+write mode"); AddOnScreenMessage(MovieSession.ReadOnly ? "Movie read-only mode" : "Movie read+write mode");
@ -4535,7 +4535,7 @@ namespace BizHawk.Client.EmuHawk
{ {
runFrame = Rewinder.Rewind(1) && Emulator.Frame > 1; runFrame = Rewinder.Rewind(1) && Emulator.Frame > 1;
if (runFrame && MovieSession.Movie.IsRecording) if (runFrame && MovieSession.Movie.IsRecording())
{ {
MovieSession.Movie.SwitchToPlay(); MovieSession.Movie.SwitchToPlay();
returnToRecording = true; returnToRecording = true;

View File

@ -223,8 +223,7 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
using (var mf = new MainForm(args)) using var mf = new MainForm(args);
{
var title = mf.Text; var title = mf.Text;
mf.Show(); mf.Show();
mf.Text = title; mf.Text = title;
@ -232,7 +231,7 @@ namespace BizHawk.Client.EmuHawk
{ {
GlobalWin.ExitCode = mf.ProgramRunLoop(); GlobalWin.ExitCode = mf.ProgramRunLoop();
} }
catch (Exception e) when (Global.MovieSession.Movie.IsActive && !(Debugger.IsAttached || VersionInfo.DeveloperBuild)) catch (Exception e) when (Global.MovieSession.Movie.IsActive() && !(Debugger.IsAttached || VersionInfo.DeveloperBuild))
{ {
var result = MessageBox.Show( var result = MessageBox.Show(
"EmuHawk has thrown a fatal exception and is about to close.\nA movie has been detected. Would you like to try to save?\n(Note: Depending on what caused this error, this may or may not succeed)", "EmuHawk has thrown a fatal exception and is about to close.\nA movie has been detected. Would you like to try to save?\n(Note: Depending on what caused this error, this may or may not succeed)",
@ -247,7 +246,6 @@ namespace BizHawk.Client.EmuHawk
} }
} }
} }
}
catch (Exception e) when (!Debugger.IsAttached) catch (Exception e) when (!Debugger.IsAttached)
{ {
new ExceptionBox(e).ShowDialog(); new ExceptionBox(e).ShowDialog();

View File

@ -28,7 +28,7 @@ namespace BizHawk.Client.EmuHawk
_s = s ?? new Gameboy.GambatteSettings(); _s = s ?? new Gameboy.GambatteSettings();
_ss = ss ?? new Gameboy.GambatteSyncSettings(); _ss = ss ?? new Gameboy.GambatteSyncSettings();
propertyGrid1.SelectedObject = _ss; propertyGrid1.SelectedObject = _ss;
propertyGrid1.Enabled = !Global.MovieSession.Movie.IsActive; propertyGrid1.Enabled = Global.MovieSession.Movie.NotActive();
checkBoxMuted.Checked = _s.Muted; checkBoxMuted.Checked = _s.Muted;
cbDisplayBG.Checked = _s.DisplayBG; cbDisplayBG.Checked = _s.DisplayBG;
cbDisplayOBJ.Checked = _s.DisplayOBJ; cbDisplayOBJ.Checked = _s.DisplayOBJ;
@ -43,8 +43,8 @@ namespace BizHawk.Client.EmuHawk
private void ButtonDefaults_Click(object sender, EventArgs e) private void ButtonDefaults_Click(object sender, EventArgs e)
{ {
PutSettings(null, Global.MovieSession.Movie.IsActive ? _ss : null); PutSettings(null, Global.MovieSession.Movie.IsActive() ? _ss : null);
if (!Global.MovieSession.Movie.IsActive) if (Global.MovieSession.Movie.NotActive())
{ {
SyncSettingsChanged = true; SyncSettingsChanged = true;
} }

View File

@ -52,7 +52,7 @@ namespace BizHawk.Client.EmuHawk
tabControl1.TabPages.Remove(tabPage2); tabControl1.TabPages.Remove(tabPage2);
} }
if (Global.MovieSession.Movie.IsActive) if (Global.MovieSession.Movie.IsActive())
{ {
propertyGrid2.Enabled = false; // disable changes to sync setting when movie, so as not to confuse user propertyGrid2.Enabled = false; // disable changes to sync setting when movie, so as not to confuse user
} }

View File

@ -1099,7 +1099,7 @@ namespace BizHawk.Client.EmuHawk
GoalGroupBox.Enabled = false; GoalGroupBox.Enabled = false;
_currentBotAttempt = new BotAttempt { Attempt = Attempts }; _currentBotAttempt = new BotAttempt { Attempt = Attempts };
if (Global.MovieSession.Movie.IsRecording) if (Global.MovieSession.Movie.IsRecording())
{ {
_oldCountingSetting = Global.MovieSession.Movie.IsCountingRerecords; _oldCountingSetting = Global.MovieSession.Movie.IsCountingRerecords;
Global.MovieSession.Movie.IsCountingRerecords = false; Global.MovieSession.Movie.IsCountingRerecords = false;
@ -1156,7 +1156,7 @@ namespace BizHawk.Client.EmuHawk
_currentBotAttempt = null; _currentBotAttempt = null;
GoalGroupBox.Enabled = true; GoalGroupBox.Enabled = true;
if (Global.MovieSession.Movie.IsRecording) if (Global.MovieSession.Movie.IsRecording())
{ {
Global.MovieSession.Movie.IsCountingRerecords = _oldCountingSetting; Global.MovieSession.Movie.IsCountingRerecords = _oldCountingSetting;
} }

View File

@ -39,7 +39,7 @@ namespace BizHawk.Client.EmuHawk
{ {
// Movie recording must be active (check TAStudio because opening a project re-loads the ROM, // Movie recording must be active (check TAStudio because opening a project re-loads the ROM,
// which resets tools before the movie session becomes active) // which resets tools before the movie session becomes active)
if (!Global.MovieSession.Movie.IsActive && !GlobalWin.Tools.IsLoaded<TAStudio>()) if (!Global.MovieSession.Movie.IsActive() && !GlobalWin.Tools.IsLoaded<TAStudio>())
{ {
MessageBox.Show("In order to use this tool you must be recording a movie."); MessageBox.Show("In order to use this tool you must be recording a movie.");
Close(); Close();

View File

@ -40,7 +40,7 @@ namespace BizHawk.Client.EmuHawk
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool RecordingMode public bool RecordingMode
{ {
get => Global.MovieSession.Movie.IsRecording; get => Global.MovieSession.Movie.IsRecording();
set set
{ {
RecordingModeCheckbox.Checked = value; RecordingModeCheckbox.Checked = value;

View File

@ -1,4 +1,6 @@
namespace BizHawk.Client.EmuHawk using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
{ {
public partial class TAStudio : IControlMainform public partial class TAStudio : IControlMainform
{ {
@ -60,11 +62,11 @@
public void ToggleReadOnly() public void ToggleReadOnly()
{ {
if (CurrentTasMovie.IsPlaying) if (CurrentTasMovie.IsPlaying())
{ {
TastudioRecordMode(); TastudioRecordMode();
} }
else if (CurrentTasMovie.IsRecording) else if (CurrentTasMovie.IsRecording())
{ {
TastudioPlayMode(); TastudioPlayMode();
} }

View File

@ -91,7 +91,7 @@ namespace BizHawk.Client.EmuHawk
Mainform.PauseOnFrame = frame.Value; Mainform.PauseOnFrame = frame.Value;
int? diff = Mainform.PauseOnFrame - _seekStartFrame; int? diff = Mainform.PauseOnFrame - _seekStartFrame;
WasRecording = CurrentTasMovie.IsRecording || WasRecording; WasRecording = CurrentTasMovie.IsRecording() || WasRecording;
TastudioPlayMode(); // suspend rec mode until seek ends, to allow mouse editing TastudioPlayMode(); // suspend rec mode until seek ends, to allow mouse editing
Mainform.UnpauseEmulator(); Mainform.UnpauseEmulator();
@ -541,7 +541,7 @@ namespace BizHawk.Client.EmuHawk
int frame = TasView.CurrentCell.RowIndex.Value; int frame = TasView.CurrentCell.RowIndex.Value;
string buttonName = TasView.CurrentCell.Column.Name; string buttonName = TasView.CurrentCell.Column.Name;
WasRecording = CurrentTasMovie.IsRecording || WasRecording; WasRecording = CurrentTasMovie.IsRecording() || WasRecording;
if (e.Button == MouseButtons.Left) if (e.Button == MouseButtons.Left)
{ {
@ -953,7 +953,7 @@ namespace BizHawk.Client.EmuHawk
// skip rerecord counting on drawing entirely, mouse down is enough // skip rerecord counting on drawing entirely, mouse down is enough
// avoid introducing another global // avoid introducing another global
bool wasCountingRerecords = CurrentTasMovie.IsCountingRerecords; bool wasCountingRerecords = CurrentTasMovie.IsCountingRerecords;
WasRecording = CurrentTasMovie.IsRecording || WasRecording; WasRecording = CurrentTasMovie.IsRecording() || WasRecording;
int startVal, endVal; int startVal, endVal;
int frame = e.NewCell.RowIndex.Value; int frame = e.NewCell.RowIndex.Value;

View File

@ -1,4 +1,6 @@
namespace BizHawk.Client.EmuHawk using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
{ {
public partial class TAStudio public partial class TAStudio
{ {
@ -27,7 +29,7 @@
{ {
// If seeking to a frame before or at the end of the movie, use StartAtNearestFrameAndEmulate // If seeking to a frame before or at the end of the movie, use StartAtNearestFrameAndEmulate
// Otherwise, load the latest state (if not already there) and seek while recording. // Otherwise, load the latest state (if not already there) and seek while recording.
WasRecording = CurrentTasMovie.IsRecording || WasRecording; WasRecording = CurrentTasMovie.IsRecording() || WasRecording;
if (frame <= CurrentTasMovie.InputLogLength) if (frame <= CurrentTasMovie.InputLogLength)
{ {

View File

@ -334,7 +334,7 @@ namespace BizHawk.Client.EmuHawk
} }
// Start Scenario 1: A regular movie is active // Start Scenario 1: A regular movie is active
if (Global.MovieSession.Movie.IsActive && !(Global.MovieSession.Movie is TasMovie)) if (Global.MovieSession.Movie.IsActive() && !(Global.MovieSession.Movie is TasMovie))
{ {
var result = MessageBox.Show("In order to use Tastudio, a new project must be created from the current movie\nThe current movie will be saved and closed, and a new project file will be created\nProceed?", "Convert movie", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); var result = MessageBox.Show("In order to use Tastudio, a new project must be created from the current movie\nThe current movie will be saved and closed, and a new project file will be created\nProceed?", "Convert movie", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (result == DialogResult.OK) if (result == DialogResult.OK)
@ -350,7 +350,7 @@ namespace BizHawk.Client.EmuHawk
} }
// Start Scenario 2: A tasproj is already active // Start Scenario 2: A tasproj is already active
else if (Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie is TasMovie) else if (Global.MovieSession.Movie.IsActive() && Global.MovieSession.Movie is TasMovie)
{ {
bool result = LoadFile(new FileInfo(CurrentTasMovie.Filename), gotoFrame: Emulator.Frame); bool result = LoadFile(new FileInfo(CurrentTasMovie.Filename), gotoFrame: Emulator.Frame);
if (!result) if (!result)

View File

@ -29,11 +29,7 @@ namespace BizHawk.Client.EmuHawk
public bool Readonly public bool Readonly
{ {
get get => _readOnly;
{
return _readOnly;
}
set set
{ {
_readOnly = value; _readOnly = value;
@ -149,8 +145,8 @@ namespace BizHawk.Client.EmuHawk
#region IToolForm Implementation #region IToolForm Implementation
public bool AskSaveChanges() { return true; } public bool AskSaveChanges() => true;
public bool UpdateBefore { get { return false; } } public bool UpdateBefore => false;
public void Restart() public void Restart()
{ {
@ -173,7 +169,7 @@ namespace BizHawk.Client.EmuHawk
Pads.ForEach(p => p.SetPrevious(null)); // Not the cleanest way to clear this every frame Pads.ForEach(p => p.SetPrevious(null)); // Not the cleanest way to clear this every frame
if (Global.MovieSession.Movie.IsPlaying && !Global.MovieSession.Movie.IsFinished) if (Global.MovieSession.Movie.Mode == MovieMode.Play)
{ {
Readonly = true; Readonly = true;
if (Global.MovieSession.CurrentInput != null) if (Global.MovieSession.CurrentInput != null)
@ -183,7 +179,7 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
if (Global.MovieSession.Movie.IsRecording) if (Global.MovieSession.Movie.IsRecording())
{ {
Pads.ForEach(p => p.SetPrevious(Global.MovieSession.PreviousFrame)); Pads.ForEach(p => p.SetPrevious(Global.MovieSession.PreviousFrame));
} }