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();
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-21 22:53:03 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Truncate all frames including starting frame to end of movie.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="frame">First frame to be truncated.</param>
|
2014-07-07 18:40:42 +00:00
|
|
|
|
public override void Truncate(int frame)
|
|
|
|
|
{
|
|
|
|
|
base.Truncate(frame);
|
|
|
|
|
|
2014-07-12 01:23:38 +00:00
|
|
|
|
if (frame < LagLog.Count)
|
|
|
|
|
{
|
2014-08-21 18:45:14 +00:00
|
|
|
|
LagLog.RemoveRange(frame, LagLog.Count - frame - 1);
|
2014-07-12 01:23:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
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-08-21 21:24:25 +00:00
|
|
|
|
|
|
|
|
|
//Taseditor deletes markers that are in truncated portion of movie.
|
2014-08-21 22:53:03 +00:00
|
|
|
|
Markers.TruncateAt(frame);
|
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-13 12:44:31 +00:00
|
|
|
|
public void InsertEmptyFrame(int frame, int count = 1)
|
2014-07-11 21:05:16 +00:00
|
|
|
|
{
|
|
|
|
|
var lg = LogGeneratorInstance();
|
|
|
|
|
lg.SetSource(Global.MovieSession.MovieControllerInstance());
|
2014-07-13 12:44:31 +00:00
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
_log.Insert(frame, lg.EmptyEntry);
|
|
|
|
|
}
|
2014-07-11 21:05:16 +00:00
|
|
|
|
|
|
|
|
|
Changes = true;
|
|
|
|
|
InvalidateAfter(frame - 1);
|
|
|
|
|
}
|
2014-07-07 18:40:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|