Move Markers from TAStudio to TasMovie, and implement saving and loading of markers
This commit is contained in:
parent
250dcbb108
commit
786b0238ba
|
@ -22,7 +22,8 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
// TasMovie
|
// TasMovie
|
||||||
LagLog,
|
LagLog,
|
||||||
Greenzone
|
Greenzone,
|
||||||
|
Markers
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BinaryStateFileNames
|
public class BinaryStateFileNames
|
||||||
|
@ -56,6 +57,7 @@ namespace BizHawk.Client.Common
|
||||||
// TasMovie
|
// TasMovie
|
||||||
LumpNames[BinaryStateLump.LagLog] = "LagLog";
|
LumpNames[BinaryStateLump.LagLog] = "LagLog";
|
||||||
LumpNames[BinaryStateLump.Greenzone] = "GreenZone";
|
LumpNames[BinaryStateLump.Greenzone] = "GreenZone";
|
||||||
|
LumpNames[BinaryStateLump.Markers] = "Markers";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string Get(BinaryStateLump lump)
|
public static string Get(BinaryStateLump lump)
|
||||||
|
|
|
@ -169,6 +169,7 @@
|
||||||
<Compile Include="movie\tasproj\TasMovie.Editing.cs" />
|
<Compile Include="movie\tasproj\TasMovie.Editing.cs" />
|
||||||
<Compile Include="movie\tasproj\TasMovie.IO.cs" />
|
<Compile Include="movie\tasproj\TasMovie.IO.cs" />
|
||||||
<Compile Include="movie\tasproj\TasMovie.cs" />
|
<Compile Include="movie\tasproj\TasMovie.cs" />
|
||||||
|
<Compile Include="movie\tasproj\TasMovieMarker.cs" />
|
||||||
<Compile Include="movie\tasproj\TasStateManager.cs" />
|
<Compile Include="movie\tasproj\TasStateManager.cs" />
|
||||||
<Compile Include="movie\tasproj\TasMovieRecord.cs" />
|
<Compile Include="movie\tasproj\TasMovieRecord.cs" />
|
||||||
<Compile Include="NESGameGenieEncoderDecoder.cs" />
|
<Compile Include="NESGameGenieEncoderDecoder.cs" />
|
||||||
|
|
|
@ -8,7 +8,6 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
public partial class TasMovie
|
public partial class TasMovie
|
||||||
{
|
{
|
||||||
// TODO: all these
|
|
||||||
public override void RecordFrame(int frame, Emulation.Common.IController source)
|
public override void RecordFrame(int frame, Emulation.Common.IController source)
|
||||||
{
|
{
|
||||||
base.RecordFrame(frame, source);
|
base.RecordFrame(frame, source);
|
||||||
|
@ -30,6 +29,7 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
LagLog.RemoveRange(frame + 2, LagLog.Count - frame - 1);
|
LagLog.RemoveRange(frame + 2, LagLog.Count - frame - 1);
|
||||||
StateManager.Invalidate(frame + 1);
|
StateManager.Invalidate(frame + 1);
|
||||||
|
// TODO: Markers? What does taseditor do?
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void PokeFrame(int frame, Emulation.Common.IController source)
|
public override void PokeFrame(int frame, Emulation.Common.IController source)
|
||||||
|
|
|
@ -29,6 +29,7 @@ namespace BizHawk.Client.Common
|
||||||
bs.PutLump(BinaryStateLump.Input, tw => tw.WriteLine(RawInputLog()));
|
bs.PutLump(BinaryStateLump.Input, tw => tw.WriteLine(RawInputLog()));
|
||||||
|
|
||||||
bs.PutLump(BinaryStateLump.LagLog, (BinaryWriter bw) => bw.Write(LagLog.ToByteArray()));
|
bs.PutLump(BinaryStateLump.LagLog, (BinaryWriter bw) => bw.Write(LagLog.ToByteArray()));
|
||||||
|
bs.PutLump(BinaryStateLump.Markers, tw => tw.WriteLine(Markers.ToString()));
|
||||||
|
|
||||||
if (StartsFromSavestate)
|
if (StartsFromSavestate)
|
||||||
{
|
{
|
||||||
|
@ -129,6 +130,18 @@ namespace BizHawk.Client.Common
|
||||||
LagLog = bytes.ToBools().ToList();
|
LagLog = bytes.ToBools().ToList();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
bl.GetLump(BinaryStateLump.Markers, true, delegate(TextReader tr)
|
||||||
|
{
|
||||||
|
string line;
|
||||||
|
while ((line = tr.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(line))
|
||||||
|
{
|
||||||
|
Markers.Add(new TasMovieMarker(line));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (StartsFromSavestate)
|
if (StartsFromSavestate)
|
||||||
{
|
{
|
||||||
bl.GetCoreState(
|
bl.GetCoreState(
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
private List<bool> LagLog = new List<bool>();
|
private List<bool> LagLog = new List<bool>();
|
||||||
private readonly TasStateManager StateManager = new TasStateManager();
|
private readonly TasStateManager StateManager = new TasStateManager();
|
||||||
|
private readonly TasMovieMarkerList Markers = new TasMovieMarkerList();
|
||||||
|
|
||||||
public TasMovie(string path) : base(path) { }
|
public TasMovie(string path) : base(path) { }
|
||||||
|
|
||||||
|
@ -46,7 +47,18 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
LagLog.Clear();
|
LagLog.Clear();
|
||||||
StateManager.Clear();
|
StateManager.Clear();
|
||||||
|
Markers.Clear();
|
||||||
base.StartNewRecording();
|
base.StartNewRecording();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Marker(int frame, string message)
|
||||||
|
{
|
||||||
|
Markers.Add(frame, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeleteMarker(int frame)
|
||||||
|
{
|
||||||
|
Markers.Remove(frame);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,164 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace BizHawk.Client.Common
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a TasMovie Marker
|
||||||
|
/// A marker is a tagged frame with a message
|
||||||
|
/// </summary>
|
||||||
|
public class TasMovieMarker
|
||||||
|
{
|
||||||
|
private int _frame;
|
||||||
|
|
||||||
|
public TasMovieMarker(int frame, string message = "")
|
||||||
|
{
|
||||||
|
_frame = frame;
|
||||||
|
Message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parses a Marker from a line of text
|
||||||
|
/// </summary>
|
||||||
|
public TasMovieMarker(string line)
|
||||||
|
{
|
||||||
|
var split = line.Split('\t');
|
||||||
|
_frame = int.Parse(split[0]);
|
||||||
|
Message = split[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual int Frame
|
||||||
|
{
|
||||||
|
get { return _frame; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual string Message { get; set; }
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Frame.ToString() + '\t' + Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return this.Frame.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (obj is TasMovieMarker)
|
||||||
|
{
|
||||||
|
return this.Frame == (obj as TasMovieMarker).Frame;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator ==(TasMovieMarker a, TasMovieMarker b)
|
||||||
|
{
|
||||||
|
return a.Frame == b.Frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator !=(TasMovieMarker a, TasMovieMarker b)
|
||||||
|
{
|
||||||
|
return a.Frame != b.Frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator ==(TasMovieMarker marker, int frame)
|
||||||
|
{
|
||||||
|
return marker.Frame == frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator !=(TasMovieMarker marker, int frame)
|
||||||
|
{
|
||||||
|
return marker.Frame != frame;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specialized Marker that represents the currently emulated frame
|
||||||
|
/// Frame always points to Global.Emulator.Frame, and setting it isn't possible
|
||||||
|
/// </summary>
|
||||||
|
public class CurrentFrameMarker : TasMovieMarker
|
||||||
|
{
|
||||||
|
public CurrentFrameMarker()
|
||||||
|
: base(0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int Frame
|
||||||
|
{
|
||||||
|
get { return Global.Emulator.Frame; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string Message
|
||||||
|
{
|
||||||
|
get { return string.Empty; }
|
||||||
|
set { return; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TasMovieMarkerList : List<TasMovieMarker>
|
||||||
|
{
|
||||||
|
private readonly CurrentFrameMarker _current;
|
||||||
|
public TasMovieMarkerList()
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
_current = new CurrentFrameMarker();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CurrentFrameMarker CurrentFrame
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
foreach (var marker in this)
|
||||||
|
{
|
||||||
|
sb.AppendLine(marker.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public new void Add(TasMovieMarker item)
|
||||||
|
{
|
||||||
|
var existingItem = this.FirstOrDefault(m => m.Frame == item.Frame);
|
||||||
|
if (existingItem != null)
|
||||||
|
{
|
||||||
|
existingItem.Message = item.Message;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
base.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(int frame, string message)
|
||||||
|
{
|
||||||
|
Add(new TasMovieMarker(frame, message));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Remove(int frame)
|
||||||
|
{
|
||||||
|
var existingItem = this.FirstOrDefault(m => m.Frame == frame);
|
||||||
|
if (existingItem != null)
|
||||||
|
{
|
||||||
|
this.Remove(existingItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -843,7 +843,6 @@
|
||||||
<DependentUpon>TAStudio.cs</DependentUpon>
|
<DependentUpon>TAStudio.cs</DependentUpon>
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="tools\TAStudio\Marker.cs" />
|
|
||||||
<Compile Include="tools\TAStudio\MarkerControl.cs">
|
<Compile Include="tools\TAStudio\MarkerControl.cs">
|
||||||
<SubType>UserControl</SubType>
|
<SubType>UserControl</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
@ -1,119 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
using BizHawk.Client.Common;
|
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a TasMovie Marker
|
|
||||||
/// A marker is a tagged frame with a message
|
|
||||||
/// </summary>
|
|
||||||
public class Marker
|
|
||||||
{
|
|
||||||
private int _frame;
|
|
||||||
|
|
||||||
public Marker(int frame, string message = "")
|
|
||||||
{
|
|
||||||
_frame = frame;
|
|
||||||
Message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual int Frame
|
|
||||||
{
|
|
||||||
get { return _frame; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual string Message { get; set; }
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return Frame.ToString() + '\t' + Message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return this.Frame.GetHashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
if (obj == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (obj is Marker)
|
|
||||||
{
|
|
||||||
return this.Frame == (obj as Marker).Frame;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator ==(Marker a, Marker b)
|
|
||||||
{
|
|
||||||
return a.Frame == b.Frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(Marker a, Marker b)
|
|
||||||
{
|
|
||||||
return a.Frame != b.Frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator ==(Marker marker, int frame)
|
|
||||||
{
|
|
||||||
return marker.Frame == frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(Marker marker, int frame)
|
|
||||||
{
|
|
||||||
return marker.Frame != frame;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Specialized Marker that represents the currently emulated frame
|
|
||||||
/// Frame always points to Global.Emulator.Frame, and setting it isn't possible
|
|
||||||
/// </summary>
|
|
||||||
public class CurrentFrameMarker : Marker
|
|
||||||
{
|
|
||||||
public CurrentFrameMarker()
|
|
||||||
: base(0)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int Frame
|
|
||||||
{
|
|
||||||
get { return Global.Emulator.Frame; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string Message
|
|
||||||
{
|
|
||||||
get { return String.Empty; }
|
|
||||||
set { return; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class MarkerList : List<Marker>
|
|
||||||
{
|
|
||||||
private readonly CurrentFrameMarker _current;
|
|
||||||
public MarkerList()
|
|
||||||
: base()
|
|
||||||
{
|
|
||||||
_current = new CurrentFrameMarker();
|
|
||||||
}
|
|
||||||
|
|
||||||
public CurrentFrameMarker CurrentFrame
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _current;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,26 +7,17 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
using BizHawk.Client.Common;
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
public partial class MarkerControl : UserControl
|
public partial class MarkerControl : UserControl
|
||||||
{
|
{
|
||||||
private Marker _marker = new Marker(0);
|
|
||||||
private int _markerIndex = 0;
|
|
||||||
|
|
||||||
public MarkerControl()
|
public MarkerControl()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetMarker(Marker marker, int index)
|
|
||||||
{
|
|
||||||
_marker = marker;
|
|
||||||
_markerIndex = index;
|
|
||||||
MarkerLabel.Text = "Marker " + _markerIndex;
|
|
||||||
MarkerBox.Text = _marker.Message;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MarkerControl_Load(object sender, EventArgs e)
|
private void MarkerControl_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
private const string MarkerColumnName = "MarkerColumn";
|
private const string MarkerColumnName = "MarkerColumn";
|
||||||
private const string FrameColumnName = "FrameColumn";
|
private const string FrameColumnName = "FrameColumn";
|
||||||
|
|
||||||
private readonly MarkerList _markers = new MarkerList();
|
private readonly TasMovieMarkerList _markers = new TasMovieMarkerList();
|
||||||
private readonly List<TasClipboardEntry> _tasClipboard = new List<TasClipboardEntry>();
|
private readonly List<TasClipboardEntry> _tasClipboard = new List<TasClipboardEntry>();
|
||||||
|
|
||||||
private int _defaultWidth;
|
private int _defaultWidth;
|
||||||
|
|
Loading…
Reference in New Issue