BizHawk/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs

84 lines
1.8 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using BizHawk.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.Common
{
public partial class TasMovie
{
public override void RecordFrame(int frame, IController source)
{
base.RecordFrame(frame, source);
2014-07-07 19:48:58 +00:00
if (frame < LagLog.Count)
{
LagLog.RemoveRange(frame, LagLog.Count - frame);
}
LagLog.Add(Global.Emulator.IsLagFrame);
StateManager.Invalidate(frame);
StateManager.Capture();
}
public override void Truncate(int frame)
{
base.Truncate(frame);
LagLog.RemoveRange(frame + 2, LagLog.Count - frame - 1);
StateManager.Invalidate(frame + 1);
// TODO: Markers? What does taseditor do?
}
public override void PokeFrame(int frame, IController source)
{
base.PokeFrame(frame, source);
LagLog.RemoveRange(frame, LagLog.Count - frame);
StateManager.Invalidate(frame);
}
public override void ClearFrame(int frame)
{
base.ClearFrame(frame);
InvalidateAfter(frame);
}
2014-07-11 19:11:30 +00:00
public void RemoveFrames(int[] frames)
{
if (frames.Any())
{
var invalidateAfter = frames.Min(x => x);
2014-07-11 19:11:30 +00:00
foreach (var frame in frames.OrderByDescending(x => x)) // Removin them in reverse order allows us to remove by index;
{
_log.RemoveAt(frame);
}
Changes = true;
InvalidateAfter(invalidateAfter);
2014-07-11 19:11:30 +00:00
}
}
public void InsertInput(int frame, IEnumerable<string> inputLog)
{
_log.InsertRange(frame, inputLog);
Changes = true;
InvalidateAfter(frame);
}
public void InsertEmptyFrame(int frame)
{
var lg = LogGeneratorInstance();
lg.SetSource(Global.MovieSession.MovieControllerInstance());
_log.Insert(frame, lg.EmptyEntry);
Changes = true;
InvalidateAfter(frame - 1);
}
}
}