TAstudio - implement input log loading
This commit is contained in:
parent
63e9fe9a6f
commit
69e8e42d61
|
@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue