2015-10-25 14:52:32 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Client.Common
|
|
|
|
|
{
|
|
|
|
|
public class TasSession
|
|
|
|
|
{
|
2017-05-10 19:19:46 +00:00
|
|
|
|
private readonly TasMovie _movie;
|
|
|
|
|
public int CurrentFrame { get; private set; }
|
|
|
|
|
public int CurrentBranch { get; private set; }
|
2015-10-25 14:52:32 +00:00
|
|
|
|
|
|
|
|
|
public TasSession(TasMovie movie)
|
|
|
|
|
{
|
|
|
|
|
_movie = movie;
|
|
|
|
|
CurrentFrame = 0;
|
|
|
|
|
CurrentBranch = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateValues()
|
|
|
|
|
{
|
|
|
|
|
CurrentFrame = Global.Emulator.Frame;
|
|
|
|
|
CurrentBranch = _movie.CurrentBranch;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
2017-05-10 19:19:46 +00:00
|
|
|
|
{
|
|
|
|
|
UpdateValues();
|
|
|
|
|
|
|
|
|
|
var sb = new StringBuilder();
|
2015-10-25 14:52:32 +00:00
|
|
|
|
sb.AppendLine(CurrentFrame.ToString());
|
|
|
|
|
sb.AppendLine(CurrentBranch.ToString());
|
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void PopulateFromString(string session)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(session))
|
|
|
|
|
{
|
2017-05-10 19:19:46 +00:00
|
|
|
|
string[] lines = session.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
|
2015-10-25 14:52:32 +00:00
|
|
|
|
|
2017-05-10 19:19:46 +00:00
|
|
|
|
CurrentFrame = lines.Length > 0 ? int.Parse(lines[0]) : 0;
|
2015-10-25 14:52:32 +00:00
|
|
|
|
|
|
|
|
|
if (lines.Length > 1)
|
2017-05-10 19:19:46 +00:00
|
|
|
|
{
|
2015-10-25 14:52:32 +00:00
|
|
|
|
CurrentBranch = int.Parse(lines[1]);
|
2017-05-10 19:19:46 +00:00
|
|
|
|
}
|
2015-10-25 14:52:32 +00:00
|
|
|
|
else
|
2017-05-10 19:19:46 +00:00
|
|
|
|
{
|
2015-10-25 14:52:32 +00:00
|
|
|
|
CurrentBranch = -1;
|
2017-05-10 19:19:46 +00:00
|
|
|
|
}
|
2015-10-25 14:52:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|