TasMovie - make a TasLagLog class to simplify some code

This commit is contained in:
adelikat 2014-11-02 00:22:04 +00:00
parent f3e9958f07
commit 8197f96c98
4 changed files with 33 additions and 17 deletions

View File

@ -171,6 +171,7 @@
<Compile Include="movie\PlatformFrameRates.cs" />
<Compile Include="movie\Subtitle.cs" />
<Compile Include="movie\SubtitleList.cs" />
<Compile Include="movie\tasproj\TasLagLog.cs" />
<Compile Include="movie\tasproj\TasMovie.Editing.cs" />
<Compile Include="movie\tasproj\TasMovie.IO.cs" />
<Compile Include="movie\tasproj\TasMovie.cs" />

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace BizHawk.Client.Common
{
public class TasLagLog : List<bool>
{
public void RemoveFrom(int frame)
{
if (frame + 1 < this.Count)
{
this.RemoveRange(frame + 1, this.Count - frame - 1);
}
}
public bool? Lagged(int index)
{
if (index < this.Count)
{
return this[index];
}
return null;
}
}
}

View File

@ -14,11 +14,7 @@ namespace BizHawk.Client.Common
{
base.RecordFrame(frame, source);
if (frame < LagLog.Count)
{
LagLog.RemoveRange(frame, LagLog.Count - frame);
}
LagLog.RemoveFrom(frame);
LagLog.Add(Global.Emulator.IsLagFrame);
StateManager.Capture();
@ -33,11 +29,7 @@ namespace BizHawk.Client.Common
base.Truncate(frame);
if (frame < LagLog.Count)
{
LagLog.RemoveRange(frame, LagLog.Count - frame);
}
LagLog.RemoveFrom(frame);
StateManager.Invalidate(frame);
Markers.TruncateAt(frame);
}

View File

@ -16,7 +16,7 @@ namespace BizHawk.Client.Common
private readonly Bk2MnemonicConstants Mnemonics = new Bk2MnemonicConstants();
private readonly TasStateManager StateManager;
private readonly List<bool> LagLog = new List<bool>();
private readonly TasLagLog LagLog = new TasLagLog();
private readonly Dictionary<int, IController> InputStateCache = new Dictionary<int, IController>();
private readonly List<string> VerificationLog = new List<string>(); // For movies that do not begin with power-on, this is the input required to get into the initial state
@ -63,7 +63,7 @@ namespace BizHawk.Client.Common
{
State = StateManager[index],
LogEntry = GetInputLogEntry(index),
Lagged = (index < LagLog.Count) ? LagLog[index] : (bool?)null
Lagged = LagLog.Lagged(index)
};
}
}
@ -132,11 +132,7 @@ namespace BizHawk.Client.Common
/// <param name="frame">The last frame that can be valid.</param>
private void InvalidateAfter(int frame)
{
if (frame < LagLog.Count)
{
LagLog.RemoveRange(frame + 1, LagLog.Count - frame - 1);
}
LagLog.RemoveFrom(frame);
StateManager.Invalidate(frame + 1);
Changes = true; // TODO check if this actually removed anything before flagging changes
}