diff --git a/BizHawk.Client.Common/movie/MovieMnemonics.cs b/BizHawk.Client.Common/movie/MovieMnemonics.cs index 1542076cef..bf32a09576 100644 --- a/BizHawk.Client.Common/movie/MovieMnemonics.cs +++ b/BizHawk.Client.Common/movie/MovieMnemonics.cs @@ -187,7 +187,7 @@ namespace BizHawk.Client.Common public class MnemonicsGenerator { - private IController Source; + public IController Source; // Making this public is a temporary hack private string ControlType; public bool this[int player, string mnemonic] diff --git a/BizHawk.Client.Common/movie/MovieRecord.cs b/BizHawk.Client.Common/movie/MovieRecord.cs index 328acaed71..9e5194f695 100644 --- a/BizHawk.Client.Common/movie/MovieRecord.cs +++ b/BizHawk.Client.Common/movie/MovieRecord.cs @@ -3,18 +3,29 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using BizHawk.Emulation.Common; + namespace BizHawk.Client.Common { public class MovieRecord : IMovieRecord { - private MnemonicsGenerator _mg; + Dictionary BoolButtons = new Dictionary(); private byte[] _state; public string Input { get { - return _mg.GetControllersAsMnemonic(); + SimpleController controller = new SimpleController { Type = new ControllerDefinition() }; + foreach (var kvp in BoolButtons) + { + controller["P1 " + kvp.Key] = kvp.Value; // TODO: multi-player, all cores + } + + controller.Type.Name = Global.Emulator.ControllerDefinition.Name; + MnemonicsGenerator mg = new MnemonicsGenerator(); + mg.SetSource(controller); + return mg.GetControllersAsMnemonic(); } } @@ -26,22 +37,31 @@ namespace BizHawk.Client.Common public bool IsPressed(int player, string mnemonic) { - return _mg[player, mnemonic]; + return BoolButtons[mnemonic]; // TODO: player } - public void SetInput(MnemonicsGenerator mg) + + public void SetInput(IController controller) { - _mg = mg; + var mnemonics = MnemonicConstants.BUTTONS[Global.Emulator.Controller.Type.Name].Select(x => x.Value); + foreach (var mnemonic in mnemonics) + { + BoolButtons[mnemonic] = controller["P1 " + mnemonic]; // TODO: doesn't work on every core, can't do multiplayer + } } public void ClearInput() { - _mg = new MnemonicsGenerator(); + foreach (var key in BoolButtons.Keys) + { + BoolButtons[key] = false; + } } - public MovieRecord(MnemonicsGenerator mg, bool captureState) + public MovieRecord(IController controller, bool captureState) { - _mg = mg; + SetInput(controller); + if (captureState) { Lagged = Global.Emulator.IsLagFrame; diff --git a/BizHawk.Client.Common/movie/TasMovie.cs b/BizHawk.Client.Common/movie/TasMovie.cs index 9dfef831bb..08041f0454 100644 --- a/BizHawk.Client.Common/movie/TasMovie.cs +++ b/BizHawk.Client.Common/movie/TasMovie.cs @@ -165,7 +165,7 @@ namespace BizHawk.Client.Common public void AppendFrame(MnemonicsGenerator mg) { Changes = true; - _records.Add(new MovieRecord(mg, true)); + _records.Add(new MovieRecord(mg.Source, true)); } public void RecordFrame(int frame, MnemonicsGenerator mg) @@ -197,7 +197,7 @@ namespace BizHawk.Client.Common if (frame < _records.Count) { Changes = true; - _records[frame].SetInput(mg); + _records[frame].SetInput(mg.Source); } } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index 5426ece15d..682b357487 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -94,20 +94,28 @@ namespace BizHawk.Client.EmuHawk private void TASView_QueryItemText(int index, int column, out string text) { - text = String.Empty; - var columnName = TASView.Columns[column].Name; + try + { + text = String.Empty; + var columnName = TASView.Columns[column].Name; - if (columnName == MarkerColumn) - { - text = "X"; + if (columnName == MarkerColumn) + { + text = "X"; + } + else if (columnName == FrameColumn) + { + text = index.ToString().PadLeft(5, '0'); + } + else + { + text = _tas[index].IsPressed(1, columnName) ? columnName : String.Empty; + } } - else if (columnName == FrameColumn) + catch (Exception ex) { - text = index.ToString().PadLeft(5, '0'); - } - else - { - text = _tas[index].IsPressed(1, columnName) ? columnName : String.Empty; + text = ""; + MessageBox.Show("oops\n" + ex.ToString()); } }