Refactor use of Movie Frame count - also fix play movie to show infinite movie's frame count as "Infinity"
This commit is contained in:
parent
3eb3b41199
commit
e686e595b9
|
@ -71,16 +71,9 @@ namespace BizHawk.Client.Common
|
||||||
return Global.MovieSession.Movie.IsActive;
|
return Global.MovieSession.Movie.IsActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int movie_length()
|
public static double movie_length()
|
||||||
{
|
{
|
||||||
if (Global.MovieSession.Movie.Frames.HasValue)
|
return Global.MovieSession.Movie.FrameCount;
|
||||||
{
|
|
||||||
return Global.MovieSession.Movie.Frames.Value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string movie_mode()
|
public static string movie_mode()
|
||||||
|
|
|
@ -21,7 +21,15 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
|
|
||||||
|
double FrameCount { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Actual length of the input log, should only be used by code that iterates or needs a real length
|
||||||
|
/// </summary>
|
||||||
|
int InputLogLength { get; }
|
||||||
|
|
||||||
ulong Rerecords { get; set; }
|
ulong Rerecords { get; set; }
|
||||||
|
|
||||||
IMovieHeader Header { get; }
|
IMovieHeader Header { get; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -90,8 +98,6 @@ namespace BizHawk.Client.Common
|
||||||
LoadStateResult CheckTimeLines(TextReader reader, bool onlyGuid, bool ignoreGuidMismatch, out string errorMessage); // No need to return a status, no reason to have hacky flags, no need to pass a textreader
|
LoadStateResult CheckTimeLines(TextReader reader, bool onlyGuid, bool ignoreGuidMismatch, out string errorMessage); // No need to return a status, no reason to have hacky flags, no need to pass a textreader
|
||||||
string GetTime(bool preLoad); // Rename to simply: Time, and make it a Timespan
|
string GetTime(bool preLoad); // Rename to simply: Time, and make it a Timespan
|
||||||
void GetInputLog(TextReader reader, bool isMultitracking); // how about the movie know if it is multi-tracking rather than having to pass it in
|
void GetInputLog(TextReader reader, bool isMultitracking); // how about the movie know if it is multi-tracking rather than having to pass it in
|
||||||
int? Frames { get; } // Nullable is a hack, also why does calling code need to know the number of frames, can that be minimized?
|
|
||||||
int RawFrames { get; } // Hacky to need two different frame properties
|
|
||||||
|
|
||||||
string GetInput(int frame); // Should be a property of a Record object
|
string GetInput(int frame); // Should be a property of a Record object
|
||||||
|
|
||||||
|
|
|
@ -61,25 +61,23 @@ namespace BizHawk.Client.Common
|
||||||
get { return Header[HeaderKeys.GAMENAME]; }
|
get { return Header[HeaderKeys.GAMENAME]; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public int RawFrames
|
public int InputLogLength
|
||||||
{
|
{
|
||||||
get { return Loaded ? _log.Length : _preloadFramecount; }
|
get { return Loaded ? _log.Length : _preloadFramecount; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public int? Frames
|
public double FrameCount
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (Loaded)
|
if (_loopOffset.HasValue)
|
||||||
{
|
{
|
||||||
if (_loopOffset.HasValue)
|
return double.PositiveInfinity;
|
||||||
{
|
}
|
||||||
return null;
|
else if (Loaded)
|
||||||
}
|
{
|
||||||
else
|
|
||||||
{
|
return _log.Length;
|
||||||
return _log.Length;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -281,12 +279,22 @@ namespace BizHawk.Client.Common
|
||||||
string line;
|
string line;
|
||||||
while ((line = sr.ReadLine()) != null)
|
while ((line = sr.ReadLine()) != null)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrWhiteSpace(line) || Header.ParseLineFromFile(line))
|
if (line.Contains("LoopOffset"))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_loopOffset = int.Parse(line.Split(new[] { ' ' }, 2)[1]);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (String.IsNullOrWhiteSpace(line) || Header.ParseLineFromFile(line))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
else if (line.StartsWith("|"))
|
||||||
if (line.StartsWith("|"))
|
|
||||||
{
|
{
|
||||||
var frames = sr.ReadToEnd();
|
var frames = sr.ReadToEnd();
|
||||||
var length = line.Length;
|
var length = line.Length;
|
||||||
|
|
|
@ -168,7 +168,7 @@ namespace BizHawk.Client.Common
|
||||||
case '1':
|
case '1':
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
if (m.Frames != 0)
|
if (m.FrameCount != 0)
|
||||||
{
|
{
|
||||||
warningMsg = "hard reset";
|
warningMsg = "hard reset";
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
else if (Movie.IsFinished)
|
else if (Movie.IsFinished)
|
||||||
{
|
{
|
||||||
if (Global.Emulator.Frame < Movie.Frames) //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
|
||||||
{
|
{
|
||||||
Movie.SwitchToPlay();
|
Movie.SwitchToPlay();
|
||||||
LatchInputFromLog();
|
LatchInputFromLog();
|
||||||
|
|
|
@ -347,34 +347,23 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
if (Global.MovieSession.Movie.IsFinished)
|
if (Global.MovieSession.Movie.IsFinished)
|
||||||
{
|
{
|
||||||
StringBuilder s = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
s.Append(Global.Emulator.Frame);
|
sb
|
||||||
s.Append('/');
|
.Append(Global.Emulator.Frame)
|
||||||
if (Global.MovieSession.Movie.Frames.HasValue)
|
.Append('/')
|
||||||
{
|
.Append(Global.MovieSession.Movie.FrameCount)
|
||||||
s.Append(Global.MovieSession.Movie.Frames);
|
.Append(" (Finished)");
|
||||||
}
|
return sb.ToString();
|
||||||
else
|
|
||||||
{
|
|
||||||
s.Append("infinity");
|
|
||||||
}
|
|
||||||
s.Append(" (Finished)");
|
|
||||||
return s.ToString();
|
|
||||||
}
|
}
|
||||||
else if (Global.MovieSession.Movie.IsPlaying)
|
else if (Global.MovieSession.Movie.IsPlaying)
|
||||||
{
|
{
|
||||||
StringBuilder s = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
s.Append(Global.Emulator.Frame);
|
sb
|
||||||
s.Append('/');
|
.Append(Global.Emulator.Frame)
|
||||||
if (Global.MovieSession.Movie.Frames.HasValue)
|
.Append('/')
|
||||||
{
|
.Append(Global.MovieSession.Movie.FrameCount);
|
||||||
s.Append(Global.MovieSession.Movie.Frames);
|
|
||||||
}
|
return sb.ToString();
|
||||||
else
|
|
||||||
{
|
|
||||||
s.Append("infinity");
|
|
||||||
}
|
|
||||||
return s.ToString();
|
|
||||||
}
|
}
|
||||||
else if (Global.MovieSession.Movie.IsRecording)
|
else if (Global.MovieSession.Movie.IsRecording)
|
||||||
{
|
{
|
||||||
|
|
|
@ -603,7 +603,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
for (int i = 0; i < frames; i++)
|
for (int i = 0; i < frames; i++)
|
||||||
{
|
{
|
||||||
if (RewindBuf.Count == 0 || (Global.MovieSession.Movie.Loaded && Global.MovieSession.Movie.Frames == 0))
|
if (RewindBuf.Count == 0 || (Global.MovieSession.Movie.Loaded && Global.MovieSession.Movie.FrameCount == 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (LastState.Length < 0x10000)
|
if (LastState.Length < 0x10000)
|
||||||
|
|
|
@ -213,7 +213,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
// if user is dumping and didnt supply dump length, make it as long as the loaded movie
|
// if user is dumping and didnt supply dump length, make it as long as the loaded movie
|
||||||
if (_autoDumpLength == 0)
|
if (_autoDumpLength == 0)
|
||||||
{
|
{
|
||||||
_autoDumpLength = movie.RawFrames;
|
_autoDumpLength = movie.InputLogLength;
|
||||||
}
|
}
|
||||||
StartNewMovie(movie, false);
|
StartNewMovie(movie, false);
|
||||||
Global.Config.RecentMovies.Add(cmdMovie);
|
Global.Config.RecentMovies.Add(cmdMovie);
|
||||||
|
|
|
@ -88,7 +88,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
var movie = new Movie(file.FullName);
|
var movie = new Movie(file.FullName);
|
||||||
movie.Load(); //State files will have to load everything unfortunately
|
movie.Load(); //State files will have to load everything unfortunately
|
||||||
if (movie.Frames == 0)
|
if (movie.FrameCount == 0)
|
||||||
{
|
{
|
||||||
MessageBox.Show("No input log detected in this savestate, aborting", "Can not load file", MessageBoxButtons.OK,
|
MessageBox.Show("No input log detected in this savestate, aborting", "Can not load file", MessageBoxButtons.OK,
|
||||||
MessageBoxIcon.Hand);
|
MessageBoxIcon.Hand);
|
||||||
|
@ -117,7 +117,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
var movie = new Movie(file.CanonicalFullPath);
|
var movie = new Movie(file.CanonicalFullPath);
|
||||||
movie.Load(); //State files will have to load everything unfortunately
|
movie.Load(); //State files will have to load everything unfortunately
|
||||||
if (movie.Frames > 0)
|
if (movie.FrameCount > 0)
|
||||||
{
|
{
|
||||||
_movieList.Add(movie);
|
_movieList.Add(movie);
|
||||||
_sortReverse = false;
|
_sortReverse = false;
|
||||||
|
@ -376,7 +376,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
DetailsView.Items.Add(FpsItem);
|
DetailsView.Items.Add(FpsItem);
|
||||||
|
|
||||||
var FramesItem = new ListViewItem("Frames");
|
var FramesItem = new ListViewItem("Frames");
|
||||||
FramesItem.SubItems.Add(_movieList[firstIndex].RawFrames.ToString());
|
FramesItem.SubItems.Add(_movieList[firstIndex].FrameCount.ToString());
|
||||||
DetailsView.Items.Add(FramesItem);
|
DetailsView.Items.Add(FramesItem);
|
||||||
|
|
||||||
CommentsBtn.Enabled = _movieList[firstIndex].Header.Comments.Any();
|
CommentsBtn.Enabled = _movieList[firstIndex].Header.Comments.Any();
|
||||||
|
@ -448,7 +448,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
.OrderByDescending(x => Path.GetFileName(x.Filename))
|
.OrderByDescending(x => Path.GetFileName(x.Filename))
|
||||||
.ThenBy(x => x.SysID)
|
.ThenBy(x => x.SysID)
|
||||||
.ThenBy(x => x.GameName)
|
.ThenBy(x => x.GameName)
|
||||||
.ThenBy(x => x.RawFrames)
|
.ThenBy(x => x.FrameCount)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -457,7 +457,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
.OrderBy(x => Path.GetFileName(x.Filename))
|
.OrderBy(x => Path.GetFileName(x.Filename))
|
||||||
.ThenBy(x => x.SysID)
|
.ThenBy(x => x.SysID)
|
||||||
.ThenBy(x => x.GameName)
|
.ThenBy(x => x.GameName)
|
||||||
.ThenBy(x => x.RawFrames)
|
.ThenBy(x => x.FrameCount)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -468,7 +468,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
.OrderByDescending(x => x.SysID)
|
.OrderByDescending(x => x.SysID)
|
||||||
.ThenBy(x => Path.GetFileName(x.Filename))
|
.ThenBy(x => Path.GetFileName(x.Filename))
|
||||||
.ThenBy(x => x.GameName)
|
.ThenBy(x => x.GameName)
|
||||||
.ThenBy(x => x.RawFrames)
|
.ThenBy(x => x.FrameCount)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -477,7 +477,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
.OrderBy(x => x.SysID)
|
.OrderBy(x => x.SysID)
|
||||||
.ThenBy(x => Path.GetFileName(x.Filename))
|
.ThenBy(x => Path.GetFileName(x.Filename))
|
||||||
.ThenBy(x => x.GameName)
|
.ThenBy(x => x.GameName)
|
||||||
.ThenBy(x => x.RawFrames)
|
.ThenBy(x => x.FrameCount)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -488,7 +488,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
.OrderByDescending(x => x.GameName)
|
.OrderByDescending(x => x.GameName)
|
||||||
.ThenBy(x => Path.GetFileName(x.Filename))
|
.ThenBy(x => Path.GetFileName(x.Filename))
|
||||||
.ThenBy(x => x.SysID)
|
.ThenBy(x => x.SysID)
|
||||||
.ThenBy(x => x.RawFrames)
|
.ThenBy(x => x.FrameCount)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -497,7 +497,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
.OrderBy(x => x.GameName)
|
.OrderBy(x => x.GameName)
|
||||||
.ThenBy(x => Path.GetFileName(x.Filename))
|
.ThenBy(x => Path.GetFileName(x.Filename))
|
||||||
.ThenBy(x => x.SysID)
|
.ThenBy(x => x.SysID)
|
||||||
.ThenBy(x => x.RawFrames)
|
.ThenBy(x => x.FrameCount)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -505,16 +505,16 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (_sortReverse)
|
if (_sortReverse)
|
||||||
{
|
{
|
||||||
_movieList = _movieList
|
_movieList = _movieList
|
||||||
.OrderByDescending(x => x.RawFrames)
|
.OrderByDescending(x => x.FrameCount)
|
||||||
.ThenBy(x => Path.GetFileName(x.Filename))
|
.ThenBy(x => Path.GetFileName(x.Filename))
|
||||||
.ThenBy(x => x.SysID)
|
.ThenBy(x => x.SysID)
|
||||||
.ThenBy(x => x.GameName)
|
.ThenBy(x => x.FrameCount)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_movieList = _movieList
|
_movieList = _movieList
|
||||||
.OrderBy(x => x.RawFrames)
|
.OrderBy(x => x.FrameCount)
|
||||||
.ThenBy(x => Path.GetFileName(x.Filename))
|
.ThenBy(x => Path.GetFileName(x.Filename))
|
||||||
.ThenBy(x => x.SysID)
|
.ThenBy(x => x.SysID)
|
||||||
.ThenBy(x => x.GameName)
|
.ThenBy(x => x.GameName)
|
||||||
|
|
|
@ -125,7 +125,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
text = "";
|
text = "";
|
||||||
|
|
||||||
//If this is just for an actual frame and not just the list view cursor at the end
|
//If this is just for an actual frame and not just the list view cursor at the end
|
||||||
if (Global.MovieSession.Movie.Frames != index)
|
if (Global.MovieSession.Movie.FrameCount != index)
|
||||||
{
|
{
|
||||||
if (column == 0)
|
if (column == 0)
|
||||||
text = String.Format("{0:#,##0}", index);
|
text = String.Format("{0:#,##0}", index);
|
||||||
|
@ -136,7 +136,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void DisplayList()
|
private void DisplayList()
|
||||||
{
|
{
|
||||||
TASView.ItemCount = Global.MovieSession.Movie.RawFrames;
|
TASView.ItemCount = Global.MovieSession.Movie.InputLogLength;
|
||||||
//if (Global.MovieSession.Movie.Frames == Global.Emulator.Frame && Global.MovieSession.Movie.StateLastIndex == Global.Emulator.Frame - 1)
|
//if (Global.MovieSession.Movie.Frames == Global.Emulator.Frame && Global.MovieSession.Movie.StateLastIndex == Global.Emulator.Frame - 1)
|
||||||
//{
|
//{
|
||||||
// //If we're at the end of the movie add one to show the cursor as a blank frame
|
// //If we're at the end of the movie add one to show the cursor as a blank frame
|
||||||
|
@ -253,7 +253,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (Global.MovieSession.Movie.IsFinished || !Global.MovieSession.Movie.IsActive)
|
if (Global.MovieSession.Movie.IsFinished || !Global.MovieSession.Movie.IsActive)
|
||||||
{
|
{
|
||||||
GlobalWin.MainForm.Rewind(1);
|
GlobalWin.MainForm.Rewind(1);
|
||||||
if (Global.Emulator.Frame <= Global.MovieSession.Movie.Frames)
|
if (Global.Emulator.Frame <= Global.MovieSession.Movie.FrameCount)
|
||||||
{
|
{
|
||||||
Global.MovieSession.Movie.SwitchToPlay();
|
Global.MovieSession.Movie.SwitchToPlay();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue