TasMovie - add a VerificationLog.txt file in the tasproj, doesn't use it yet but it does properly save and load it, will save if there is any log entries, will load it if the file exists in the tasproj

This commit is contained in:
adelikat 2014-11-01 13:37:18 +00:00
parent 6611ddd9ba
commit 900ce76a3b
3 changed files with 45 additions and 2 deletions

View File

@ -26,7 +26,8 @@ namespace BizHawk.Client.Common
Greenzone,
GreenzoneSettings,
Markers,
ClientSettings
ClientSettings,
VerificationLog
}
public static class BinaryStateFileNames
@ -61,6 +62,7 @@ namespace BizHawk.Client.Common
AddLumpName(BinaryStateLump.GreenzoneSettings, "GreenZoneSettings.txt");
AddLumpName(BinaryStateLump.Markers, "Markers.txt");
AddLumpName(BinaryStateLump.ClientSettings, "ClientSettings.json");
AddLumpName(BinaryStateLump.VerificationLog, "VerificationLog.txt");
}
public static string GetReadName(BinaryStateLump lump)

View File

@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using BizHawk.Common;
using BizHawk.Common.CollectionExtensions;
@ -30,7 +32,8 @@ namespace BizHawk.Client.Common
bs.PutLump(BinaryStateLump.Input, tw => tw.WriteLine(RawInputLog()));
// TasProj extras
bs.PutLump(BinaryStateLump.GreenzoneSettings, tw => tw.WriteLine(StateManager.Settings.ToString()));
if (StateManager.Settings.SaveGreenzone)
{
@ -57,6 +60,11 @@ namespace BizHawk.Client.Common
var clientSettingsJson = ClientSettingsForSave();
bs.PutLump(BinaryStateLump.ClientSettings, (TextWriter tw) => tw.Write(clientSettingsJson));
}
if (VerificationLog.Any())
{
bs.PutLump(BinaryStateLump.VerificationLog, tw => tw.WriteLine(InputLogToString(VerificationLog)));
}
}
Changes = false;
@ -200,6 +208,27 @@ namespace BizHawk.Client.Common
GetClientSettingsOnLoad(clientSettings);
}
if (bl.HasLump(BinaryStateLump.VerificationLog))
{
bl.GetLump(BinaryStateLump.VerificationLog, true, delegate(TextReader tr)
{
VerificationLog.Clear();
while (true)
{
var line = tr.ReadLine();
if (string.IsNullOrEmpty(line))
{
break;
}
if (line.StartsWith("|"))
{
VerificationLog.Add(line);
}
}
});
}
}
Changes = false;
@ -212,5 +241,16 @@ namespace BizHawk.Client.Common
StateManager.Clear();
Markers.Clear();
}
private static string InputLogToString(List<string> log)
{
var sb = new StringBuilder();
foreach (var record in log)
{
sb.AppendLine(record);
}
return sb.ToString();
}
}
}

View File

@ -18,6 +18,7 @@ namespace BizHawk.Client.Common
private readonly TasStateManager StateManager;
private readonly List<bool> LagLog = new List<bool>();
private readonly Dictionary<int, IController> InputStateCache = new Dictionary<int, IController>();
private readonly List<string> VerificationLog = new List<string>(); // For movies that do not begin with power-on, this is the input required to get into the initial state
public TasMovie(string path, bool startsFromSavestate = false) : base(path)
{