TAstudio - implement input log loading

This commit is contained in:
adelikat 2013-12-14 18:46:59 +00:00
parent 63e9fe9a6f
commit 69e8e42d61
3 changed files with 42 additions and 1 deletions

View File

@ -53,6 +53,25 @@ namespace BizHawk.Client.Common
}
}
public Dictionary<string, bool> ParseMnemonicString(string mnemonic)
{
// TODo: clean me up
var buttons = new Dictionary<string, bool>();
var collections = AllCollections.SelectMany(mc => mc).ToList();
var availMnemonics = AvailableMnemonics;
List<char> mnemonicList = mnemonic.Replace("|", "").ToCharArray().ToList();
for (int i = 0; i < collections.Count; i++)
{
if (availMnemonics.ContainsKey(collections[i].Key))
{
buttons.Add(collections[i].Key, mnemonicList[i] != '.');
}
}
return buttons;
}
public string GenerateMnemonicString(Dictionary<string, bool> buttons)
{
var collections = MnemonicLookup[Global.Emulator.SystemId].Where(x => ActivePlayers.Contains(x.Name));
@ -129,5 +148,13 @@ namespace BizHawk.Client.Common
return MnemonicLookup[Global.Emulator.SystemId].Where(x => ActivePlayers.Contains(x.Name));
}
}
private IEnumerable<MnemonicCollection> AllCollections
{
get
{
return MnemonicLookup[Global.Emulator.SystemId];
}
}
}
}

View File

@ -310,7 +310,20 @@ namespace BizHawk.Client.Common
delegate(Stream s)
{
StreamReader sr = new StreamReader(s);
// TODO: deserialize input log here
string line = String.Empty;
while (true)
{
line = sr.ReadLine();
if (line == null)
{
break;
}
else if (line.StartsWith("|"))
{
var parsedButtons = _mg.ParseMnemonicString(line);
_records.Add(new MovieRecord(parsedButtons, captureState: false));
}
}
});
if (Header.StartsFromSavestate)

View File

@ -292,6 +292,7 @@ namespace BizHawk.Client.EmuHawk
_tas.Filename = file.FullName;
_tas.Load();
Global.Config.RecentTas.Add(_tas.Filename);
TASView.ItemCount = _tas.InputLogLength;
// TOOD: message to the user
}
}