Some fixups to TasMovie - mostly code cleanup but also some subtle bug fixes
This commit is contained in:
parent
dc2ca1f010
commit
6611ddd9ba
|
@ -141,7 +141,7 @@ namespace BizHawk.Client.Common.MovieConversionExtensions
|
|||
tas.TasStateManager.Clear();
|
||||
tas.ClearLagLog();
|
||||
|
||||
tas.CopyLog(old.Log);
|
||||
tas.CopyLog(old.GetLogEntries());
|
||||
tas.DeleteLogBefore(frame);
|
||||
|
||||
tas.HeaderEntries.Clear();
|
||||
|
|
|
@ -24,12 +24,13 @@ namespace BizHawk.Client.Common
|
|||
StateManager.Capture();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Truncate all frames including starting frame to end of movie.
|
||||
/// </summary>
|
||||
/// <param name="frame">First frame to be truncated.</param>
|
||||
public override void Truncate(int frame)
|
||||
{
|
||||
if (frame < _log.Count - 1)
|
||||
{
|
||||
Changes = true;
|
||||
}
|
||||
|
||||
base.Truncate(frame);
|
||||
|
||||
if (frame < LagLog.Count)
|
||||
|
@ -38,22 +39,13 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
StateManager.Invalidate(frame);
|
||||
|
||||
if (frame < _log.Count - 1)
|
||||
{
|
||||
Changes = true;
|
||||
}
|
||||
|
||||
//TAS Editor deletes markers that are in truncated portion of movie.
|
||||
Markers.TruncateAt(frame);
|
||||
}
|
||||
|
||||
public override void PokeFrame(int frame, IController source)
|
||||
{
|
||||
base.PokeFrame(frame, source);
|
||||
|
||||
LagLog.RemoveRange(frame, LagLog.Count - frame);
|
||||
StateManager.Invalidate(frame);
|
||||
InvalidateAfter(frame);
|
||||
}
|
||||
|
||||
public override void ClearFrame(int frame)
|
||||
|
@ -112,11 +104,7 @@ namespace BizHawk.Client.Common
|
|||
Changes = true;
|
||||
InvalidateAfter(frame);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="frame">Adds frame at this position, shifting all the rest down.</param>
|
||||
/// <param name="count">The number of frames to insert at the particular frame.</param>
|
||||
|
||||
public void InsertEmptyFrame(int frame, int count = 1)
|
||||
{
|
||||
var lg = LogGeneratorInstance();
|
||||
|
|
|
@ -78,7 +78,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
ClearBeforeLoad();
|
||||
ClearTasprojExtrasBeforeLoad();
|
||||
ClearTasprojExtras();
|
||||
|
||||
bl.GetLump(BinaryStateLump.Movieheader, true, delegate(TextReader tr)
|
||||
{
|
||||
|
@ -155,7 +155,7 @@ namespace BizHawk.Client.Common
|
|||
// TasMovie enhanced information
|
||||
bl.GetLump(BinaryStateLump.LagLog, false, delegate(BinaryReader br, long length)
|
||||
{
|
||||
LagLog = br.ReadBytes((int)length).ToBools().ToList();
|
||||
LagLog.AddRange(br.ReadBytes((int)length).ToBools());
|
||||
});
|
||||
|
||||
bl.GetLump(BinaryStateLump.GreenzoneSettings, false, delegate(TextReader tr)
|
||||
|
@ -206,10 +206,11 @@ namespace BizHawk.Client.Common
|
|||
return true;
|
||||
}
|
||||
|
||||
private void ClearTasprojExtrasBeforeLoad()
|
||||
private void ClearTasprojExtras()
|
||||
{
|
||||
LagLog.Clear();
|
||||
StateManager.Clear();
|
||||
Markers.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,13 +12,13 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public sealed partial class TasMovie : Bk2Movie, INotifyPropertyChanged
|
||||
{
|
||||
private readonly Bk2MnemonicConstants Mnemonics = new Bk2MnemonicConstants();
|
||||
private List<bool> LagLog = new List<bool>();
|
||||
private readonly TasStateManager StateManager;
|
||||
public TasMovieMarkerList Markers { get; set; }
|
||||
|
||||
public const string DefaultProjectName = "default";
|
||||
|
||||
private readonly Bk2MnemonicConstants Mnemonics = new Bk2MnemonicConstants();
|
||||
private readonly TasStateManager StateManager;
|
||||
private readonly List<bool> LagLog = new List<bool>();
|
||||
private readonly Dictionary<int, IController> InputStateCache = new Dictionary<int, IController>();
|
||||
|
||||
public TasMovie(string path, bool startsFromSavestate = false) : base(path)
|
||||
{
|
||||
// TODO: how to call the default constructor AND the base(path) constructor? And is base(path) calling base() ?
|
||||
|
@ -39,6 +39,9 @@ namespace BizHawk.Client.Common
|
|||
Markers.Add(0, startsFromSavestate ? "Savestate" : "Power on");
|
||||
}
|
||||
|
||||
public TasMovieMarkerList Markers { get; set; }
|
||||
public bool UseInputCache { get; set; }
|
||||
|
||||
public override string PreferredExtension
|
||||
{
|
||||
get { return Extension; }
|
||||
|
@ -64,11 +67,6 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
public override bool Stop(bool saveChanges = true)
|
||||
{
|
||||
return base.Stop(saveChanges);
|
||||
}
|
||||
|
||||
#region Events and Handlers
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
@ -116,12 +114,10 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public override void StartNewRecording()
|
||||
{
|
||||
LagLog.Clear();
|
||||
StateManager.Clear();
|
||||
Markers.Clear();
|
||||
base.StartNewRecording();
|
||||
|
||||
ClearTasprojExtras();
|
||||
Markers.Add(0, StartsFromSavestate ? "Savestate" : "Power on");
|
||||
|
||||
base.StartNewRecording();
|
||||
}
|
||||
|
||||
public override void SwitchToPlay()
|
||||
|
@ -165,9 +161,6 @@ namespace BizHawk.Client.Common
|
|||
return CreateDisplayValueForButton(adapter, buttonName);
|
||||
}
|
||||
|
||||
private readonly Dictionary<int, IController> InputStateCache = new Dictionary<int, IController>();
|
||||
|
||||
public bool UseInputCache { get; set; }
|
||||
public void FlushInputCache()
|
||||
{
|
||||
InputStateCache.Clear();
|
||||
|
@ -247,14 +240,14 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public bool BoolIsPressed(int frame, string buttonName)
|
||||
{
|
||||
var adapter = GetInputState(frame) as Bk2ControllerAdapter;
|
||||
return adapter.IsPressed(buttonName);
|
||||
return ((Bk2ControllerAdapter)GetInputState(frame))
|
||||
.IsPressed(buttonName);
|
||||
}
|
||||
|
||||
public float GetFloatValue(int frame, string buttonName)
|
||||
{
|
||||
var adapter = GetInputState(frame) as Bk2ControllerAdapter;
|
||||
return adapter.GetFloat(buttonName);
|
||||
return ((Bk2ControllerAdapter)GetInputState(frame))
|
||||
.GetFloat(buttonName);
|
||||
}
|
||||
|
||||
// TODO: try not to need this, or at least use GetInputState and then a log entry generator
|
||||
|
@ -327,11 +320,6 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
public List<string> Log
|
||||
{
|
||||
get { return _log; }
|
||||
}
|
||||
|
||||
public void CopyLog(List<string> log)
|
||||
{
|
||||
_log.Clear();
|
||||
|
@ -340,5 +328,10 @@ namespace BizHawk.Client.Common
|
|||
_log.Add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> GetLogEntries()
|
||||
{
|
||||
return _log;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue