diff --git a/BizHawk.Client.Common/movie/IMovieRecord.cs b/BizHawk.Client.Common/movie/IMovieRecord.cs index fff30c9530..e3fed09c37 100644 --- a/BizHawk.Client.Common/movie/IMovieRecord.cs +++ b/BizHawk.Client.Common/movie/IMovieRecord.cs @@ -10,7 +10,7 @@ namespace BizHawk.Client.Common /// /// Gets or sets the string representation of the controller input as a series of mnemonics /// - string Input { get; set; } + string Input { get; } /// /// Gets a value indicating whether or not this was a lag frame, @@ -18,6 +18,11 @@ namespace BizHawk.Client.Common /// bool Lagged { get; } + /// + /// Gets a valude indicating whether or not this record has a captured state + /// + bool HasState { get; } + /// /// Gets the Savestate for this frame of input /// diff --git a/BizHawk.Client.Common/movie/MovieMnemonics.cs b/BizHawk.Client.Common/movie/MovieMnemonics.cs index 024f210d0e..092a88219d 100644 --- a/BizHawk.Client.Common/movie/MovieMnemonics.cs +++ b/BizHawk.Client.Common/movie/MovieMnemonics.cs @@ -187,13 +187,14 @@ namespace BizHawk.Client.Common public class MnemonicsGenerator { - IController Source; + private IController Source; + private string ControlType; + public void SetSource(IController source) { Source = source; ControlType = source.Type.Name; } - string ControlType; bool IsBasePressed(string name) { @@ -359,7 +360,6 @@ namespace BizHawk.Client.Common return input.ToString(); } - private string GetA78ControllersAsMnemonic() { StringBuilder input = new StringBuilder("|"); diff --git a/BizHawk.Client.Common/movie/MovieRecord.cs b/BizHawk.Client.Common/movie/MovieRecord.cs index 062e0dfeac..9726d9a7b5 100644 --- a/BizHawk.Client.Common/movie/MovieRecord.cs +++ b/BizHawk.Client.Common/movie/MovieRecord.cs @@ -7,18 +7,43 @@ namespace BizHawk.Client.Common { public class MovieRecord : IMovieRecord { - private List _state = new List(); + private MnemonicsGenerator _mg; + private byte[] _state; + + public string Input { get; private set; } - public string Input { get; set; } public bool Lagged { get; private set; } public IEnumerable State { get { return _state; } } - public MovieRecord() + public void SetInput(MnemonicsGenerator mg) { + _mg = mg; + } + public void ClearInput() + { + _mg = new MnemonicsGenerator(); + } + + public MovieRecord(MnemonicsGenerator mg, bool captureState) + { + _mg = mg; + if (captureState) + { + Lagged = Global.Emulator.IsLagFrame; + _state = Global.Emulator.SaveStateBinary(); + } + } + + public bool HasState + { + get + { + return State.Count() > 0; + } } public override string ToString() diff --git a/BizHawk.Client.Common/movie/TasMovie.cs b/BizHawk.Client.Common/movie/TasMovie.cs index 79bc43e9a9..9dfef831bb 100644 --- a/BizHawk.Client.Common/movie/TasMovie.cs +++ b/BizHawk.Client.Common/movie/TasMovie.cs @@ -10,6 +10,15 @@ namespace BizHawk.Client.Common { // TODO: preloading, or benchmark and see how much of a performaance gain it really is // TODO: support loop Offset + + public MovieRecord this[int index] + { + get + { + return _records[index]; + } + } + #region Implementation public TasMovie(string filename, bool startsFromSavestate = false) @@ -149,17 +158,14 @@ namespace BizHawk.Client.Common if (frame < _records.Count) { Changes = true; - _records[frame].Input = MnemonicsGenerator.GetEmptyMnemonic; + _records[frame].ClearInput(); } } public void AppendFrame(MnemonicsGenerator mg) { Changes = true; - _records.Add(new MovieRecord - { - Input = mg.GetControllersAsMnemonic(), - }); + _records.Add(new MovieRecord(mg, true)); } public void RecordFrame(int frame, MnemonicsGenerator mg) @@ -175,7 +181,14 @@ namespace BizHawk.Client.Common } } - PokeFrame(frame, mg); + if (frame < _records.Count) + { + PokeFrame(frame, mg); + } + else + { + AppendFrame(mg); + } } } @@ -184,7 +197,7 @@ namespace BizHawk.Client.Common if (frame < _records.Count) { Changes = true; - _records[frame].Input = mg.GetControllersAsMnemonic(); + _records[frame].SetInput(mg); } } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs index 33b08c3fae..2ca259717d 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs @@ -692,7 +692,7 @@ namespace BizHawk.Client.EmuHawk this.MarkerDescriptionBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.MarkerDescriptionBox.Location = new System.Drawing.Point(118, 495); this.MarkerDescriptionBox.Name = "MarkerDescriptionBox"; - this.MarkerDescriptionBox.Size = new System.Drawing.Size(194, 20); + this.MarkerDescriptionBox.Size = new System.Drawing.Size(185, 20); this.MarkerDescriptionBox.TabIndex = 3; // // TopMarkerBox diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index 38decbb241..173e4f9e2f 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -12,6 +12,9 @@ namespace BizHawk.Client.EmuHawk { public partial class TAStudio : Form, IToolForm { + private const string MarkerColumn = ""; + private const string FrameColumn = "Frame#"; + private int _defaultWidth; private int _defaultHeight; private TasMovie _tas; @@ -71,12 +74,37 @@ namespace BizHawk.Client.EmuHawk private void TASView_QueryItemBkColor(int index, int column, ref Color color) { - + var record = _tas[index]; + if (!record.HasState) + { + color = BackColor; + } + else + { + if (record.Lagged) + { + color = Color.Pink; + } + else + { + color = Color.LightGreen; + } + } } private void TASView_QueryItemText(int index, int column, out string text) { text = String.Empty; + var columnName = TASView.Columns[column].Name; + + if (columnName == MarkerColumn) + { + text = "X"; + } + else if (columnName == FrameColumn) + { + text = index.ToString().PadLeft(5, '0'); + } } private void TAStudio_Load(object sender, EventArgs e)