2014-07-07 18:40:42 +00:00
|
|
|
|
using System;
|
2014-07-11 21:05:16 +00:00
|
|
|
|
using System.Collections.Generic;
|
2014-07-07 18:40:42 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
using BizHawk.Common;
|
2014-07-11 19:58:24 +00:00
|
|
|
|
using BizHawk.Emulation.Common;
|
2014-07-07 18:40:42 +00:00
|
|
|
|
|
|
|
|
|
namespace BizHawk.Client.Common
|
|
|
|
|
{
|
|
|
|
|
public partial class TasMovie
|
|
|
|
|
{
|
2014-07-11 19:58:24 +00:00
|
|
|
|
public override void RecordFrame(int frame, IController source)
|
2014-07-07 18:40:42 +00:00
|
|
|
|
{
|
|
|
|
|
base.RecordFrame(frame, source);
|
|
|
|
|
|
2014-07-07 19:48:58 +00:00
|
|
|
|
if (frame < LagLog.Count)
|
|
|
|
|
{
|
|
|
|
|
LagLog.RemoveRange(frame, LagLog.Count - frame);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-07 18:40:42 +00:00
|
|
|
|
LagLog.Add(Global.Emulator.IsLagFrame);
|
|
|
|
|
|
|
|
|
|
StateManager.Invalidate(frame);
|
|
|
|
|
StateManager.Capture();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Truncate(int frame)
|
|
|
|
|
{
|
|
|
|
|
base.Truncate(frame);
|
|
|
|
|
|
2014-07-12 01:23:38 +00:00
|
|
|
|
if (frame < LagLog.Count)
|
|
|
|
|
{
|
|
|
|
|
LagLog.RemoveRange(frame + 2, LagLog.Count - frame - 1);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-07 18:40:42 +00:00
|
|
|
|
StateManager.Invalidate(frame + 1);
|
2014-07-12 01:23:38 +00:00
|
|
|
|
|
|
|
|
|
if (frame < _log.Count - 1)
|
|
|
|
|
{
|
|
|
|
|
Changes = true;
|
|
|
|
|
}
|
2014-07-09 16:35:39 +00:00
|
|
|
|
// TODO: Markers? What does taseditor do?
|
2014-07-07 18:40:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-11 19:58:24 +00:00
|
|
|
|
public override void PokeFrame(int frame, IController source)
|
2014-07-07 18:40:42 +00:00
|
|
|
|
{
|
|
|
|
|
base.PokeFrame(frame, source);
|
|
|
|
|
|
|
|
|
|
LagLog.RemoveRange(frame, LagLog.Count - frame);
|
|
|
|
|
StateManager.Invalidate(frame);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void ClearFrame(int frame)
|
|
|
|
|
{
|
|
|
|
|
base.ClearFrame(frame);
|
2014-07-11 19:58:24 +00:00
|
|
|
|
InvalidateAfter(frame);
|
2014-07-07 18:40:42 +00:00
|
|
|
|
}
|
2014-07-11 19:11:30 +00:00
|
|
|
|
|
|
|
|
|
public void RemoveFrames(int[] frames)
|
|
|
|
|
{
|
|
|
|
|
if (frames.Any())
|
|
|
|
|
{
|
2014-07-11 19:58:24 +00:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-11 21:05:16 +00:00
|
|
|
|
Changes = true;
|
2014-07-11 19:58:24 +00:00
|
|
|
|
InvalidateAfter(invalidateAfter);
|
2014-07-11 19:11:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-11 21:05:16 +00:00
|
|
|
|
|
|
|
|
|
public void InsertInput(int frame, IEnumerable<string> inputLog)
|
|
|
|
|
{
|
|
|
|
|
_log.InsertRange(frame, inputLog);
|
|
|
|
|
Changes = true;
|
|
|
|
|
InvalidateAfter(frame);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-11 23:54:18 +00:00
|
|
|
|
public void InsertInput(int frame, IEnumerable<IController> inputStates)
|
|
|
|
|
{
|
|
|
|
|
var lg = LogGeneratorInstance();
|
|
|
|
|
|
|
|
|
|
var inputLog = new List<string>();
|
|
|
|
|
|
|
|
|
|
foreach (var input in inputStates)
|
|
|
|
|
{
|
|
|
|
|
lg.SetSource(input);
|
|
|
|
|
inputLog.Add(lg.GenerateLogEntry());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InsertInput(frame, inputLog);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CopyOverInput(int frame, IEnumerable<IController> inputStates)
|
|
|
|
|
{
|
|
|
|
|
var lg = LogGeneratorInstance();
|
|
|
|
|
var states = inputStates.ToList();
|
|
|
|
|
for (int i = 0; i < states.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
lg.SetSource(states[i]);
|
|
|
|
|
_log[frame + i] = lg.GenerateLogEntry();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Changes = true;
|
|
|
|
|
InvalidateAfter(frame);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-11 21:05:16 +00:00
|
|
|
|
public void InsertEmptyFrame(int frame)
|
|
|
|
|
{
|
|
|
|
|
var lg = LogGeneratorInstance();
|
|
|
|
|
lg.SetSource(Global.MovieSession.MovieControllerInstance());
|
|
|
|
|
_log.Insert(frame, lg.EmptyEntry);
|
|
|
|
|
|
|
|
|
|
Changes = true;
|
|
|
|
|
InvalidateAfter(frame - 1);
|
|
|
|
|
}
|
2014-07-07 18:40:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|