Tastudio branches - save and load markers to disk

This commit is contained in:
adelikat 2015-09-06 10:18:23 -04:00
parent ff0844413c
commit 2f3f5ad465
3 changed files with 24 additions and 2 deletions

View File

@ -62,6 +62,8 @@ namespace BizHawk.Client.Common
public static BinaryStateLump BranchLagLog { get; private set; } public static BinaryStateLump BranchLagLog { get; private set; }
[Name("Branches\\Header", "json")] [Name("Branches\\Header", "json")]
public static BinaryStateLump BranchHeader { get; private set; } public static BinaryStateLump BranchHeader { get; private set; }
[Name("Branches\\Markers", "markers")]
public static BinaryStateLump BranchMarkers { get; private set; }
[AttributeUsage(AttributeTargets.Property)] [AttributeUsage(AttributeTargets.Property)]

View File

@ -28,6 +28,7 @@ namespace BizHawk.Client.Common
var ninput = new IndexedStateLump(BinaryStateLump.BranchInputLog); var ninput = new IndexedStateLump(BinaryStateLump.BranchInputLog);
var nframebuffer = new IndexedStateLump(BinaryStateLump.BranchFrameBuffer); var nframebuffer = new IndexedStateLump(BinaryStateLump.BranchFrameBuffer);
var nlaglog = new IndexedStateLump(BinaryStateLump.BranchLagLog); var nlaglog = new IndexedStateLump(BinaryStateLump.BranchLagLog);
var nmarkers = new IndexedStateLump(BinaryStateLump.BranchMarkers);
foreach (var b in this) foreach (var b in this)
{ {
bs.PutLump(nheader, delegate(TextWriter tw) bs.PutLump(nheader, delegate(TextWriter tw)
@ -58,6 +59,11 @@ namespace BizHawk.Client.Common
b.LagLog.Save(bw); b.LagLog.Save(bw);
}); });
bs.PutLump(nmarkers, delegate (TextWriter tw)
{
tw.WriteLine(b.Markers.ToString());
});
nheader.Increment(); nheader.Increment();
ncore.Increment(); ncore.Increment();
ninput.Increment(); ninput.Increment();
@ -66,13 +72,14 @@ namespace BizHawk.Client.Common
} }
} }
public void Load(BinaryStateLoader bl) public void Load(BinaryStateLoader bl, TasMovie movie)
{ {
var nheader = new IndexedStateLump(BinaryStateLump.BranchHeader); var nheader = new IndexedStateLump(BinaryStateLump.BranchHeader);
var ncore = new IndexedStateLump(BinaryStateLump.BranchCoreData); var ncore = new IndexedStateLump(BinaryStateLump.BranchCoreData);
var ninput = new IndexedStateLump(BinaryStateLump.BranchInputLog); var ninput = new IndexedStateLump(BinaryStateLump.BranchInputLog);
var nframebuffer = new IndexedStateLump(BinaryStateLump.BranchFrameBuffer); var nframebuffer = new IndexedStateLump(BinaryStateLump.BranchFrameBuffer);
var nlaglog = new IndexedStateLump(BinaryStateLump.BranchLagLog); var nlaglog = new IndexedStateLump(BinaryStateLump.BranchLagLog);
var nmarkers = new IndexedStateLump(BinaryStateLump.Markers);
Clear(); Clear();
@ -127,6 +134,19 @@ namespace BizHawk.Client.Common
b.LagLog.Load(br); b.LagLog.Load(br);
}); });
b.Markers = new TasMovieMarkerList(movie);
bl.GetLump(nmarkers, false, delegate (TextReader tr)
{
string line;
while ((line = tr.ReadLine()) != null)
{
if (!string.IsNullOrWhiteSpace(line))
{
b.Markers.Add(new TasMovieMarker(line));
}
}
});
Add(b); Add(b);
nheader.Increment(); nheader.Increment();

View File

@ -287,7 +287,7 @@ namespace BizHawk.Client.Common
}); });
} }
Branches.Load(bl); Branches.Load(bl, this);
} }
Changes = false; Changes = false;