diff --git a/BizHawk.Client.Common/movie/MovieRecord.cs b/BizHawk.Client.Common/movie/MovieRecord.cs index 2353e6829b..4b62c6327d 100644 --- a/BizHawk.Client.Common/movie/MovieRecord.cs +++ b/BizHawk.Client.Common/movie/MovieRecord.cs @@ -6,42 +6,27 @@ namespace BizHawk.Client.Common public class MovieRecord { private byte[] _state = new byte[0]; - private Dictionary _boolButtons = new Dictionary(); - public MovieRecord(Dictionary buttons, bool captureState) + public MovieRecord(string serializedInput, bool captureState) { - SetInput(buttons); + SerializedInput = serializedInput; if (captureState) { CaptureSate(); } } - public Dictionary Buttons - { - get { return _boolButtons; } - } - + public string SerializedInput { get; private set; } public bool Lagged { get; private set; } - #region Input Api - - public bool IsPressed(string buttonName) + public void ClearInput() { - return _boolButtons[buttonName]; + SerializedInput = string.Empty; } - public void SetButton(string button, bool pressed) + public void SetInput(string input) { - InputChanged(new Dictionary { { button, pressed } }); - _boolButtons[button] = pressed; - } - - public void SetInput(Dictionary buttons) - { - InputChanged(buttons); - _boolButtons.Clear(); - _boolButtons = buttons; + SerializedInput = input ?? string.Empty; } public void CaptureSate() @@ -50,16 +35,6 @@ namespace BizHawk.Client.Common _state = (byte[])Global.Emulator.SaveStateBinary().Clone(); } - public void ClearInput() - { - InputChanged(_boolButtons); - _boolButtons.Clear(); - } - - #endregion - - #region State API - public IEnumerable State { get { return _state; } @@ -74,32 +49,5 @@ namespace BizHawk.Client.Common { _state = new byte[0]; } - - #endregion - - #region Event Handling - - public class InputEventArgs - { - public InputEventArgs(Dictionary editedButtons) - { - EditedButtons = editedButtons; - } - - public Dictionary EditedButtons { get; private set; } - } - - public delegate void InputEventHandler(object sender, InputEventArgs e); - public event InputEventHandler OnChanged; - - private void InputChanged(Dictionary editedButtons) - { - if (OnChanged != null) - { - OnChanged(this, new InputEventArgs(editedButtons)); - } - } - - #endregion } } diff --git a/BizHawk.Client.Common/movie/TasMovie.cs b/BizHawk.Client.Common/movie/TasMovie.cs index 6b1ade0da9..4af915c268 100644 --- a/BizHawk.Client.Common/movie/TasMovie.cs +++ b/BizHawk.Client.Common/movie/TasMovie.cs @@ -34,29 +34,23 @@ namespace BizHawk.Client.Common public void ToggleButton(int frame, string buttonName) { InvalidateGreenzone(frame); + /*Serialize todo _records[frame].SetButton(buttonName, !_records[frame].Buttons[buttonName]); + */ } public void SetButton(int frame, string buttonName, bool value) { InvalidateGreenzone(frame); + /*Serialize TODO _records[frame].SetButton(buttonName, value); + */ } public bool IsPressed(int frame, string buttonName) { - return _records[frame].Buttons[buttonName]; - } - - private void InputChanged(object sender, MovieRecord.InputEventArgs e) - { - Changes = true; - - if (OnChanged != null) - { - OnChanged(sender, e); - } + return true; //Serialize TODO - _records[frame].Buttons[buttonName]; } /// @@ -71,14 +65,7 @@ namespace BizHawk.Client.Common } } - #region Events - - public delegate void MovieEventHandler(object sender, MovieRecord.InputEventArgs e); - public event MovieEventHandler OnChanged; - - #endregion - - #region Implementation + #region IMovie Implementation public TasMovie(string filename, bool startsFromSavestate = false) : this(startsFromSavestate) @@ -89,7 +76,7 @@ namespace BizHawk.Client.Common public TasMovie(bool startsFromSavestate = false) { _mg = MnemonicGeneratorFactory.Generate(); - Filename = String.Empty; + Filename = string.Empty; Header = new MovieHeader { StartsFromSavestate = startsFromSavestate }; Header[HeaderKeys.MOVIEVERSION] = HeaderKeys.MovieVersion2; _records = new MovieRecordList(); @@ -159,21 +146,24 @@ namespace BizHawk.Client.Common { _records[frame].CaptureSate(); } - return _mg.GenerateMnemonicString(_records[frame].Buttons); + + return string.Empty; //Serialize TODO _mg.GenerateMnemonicString(_records[frame].Buttons); } else { - return String.Empty; + return string.Empty; } } else { _mode = Moviemode.Record; + /* Serialize TODO var buttons = _mg.ParseMnemonicString(_mg.EmptyMnemonic); - _records.Add(new MovieRecord(buttons, true)); - return String.Empty; + */ + + return string.Empty; } } @@ -182,8 +172,9 @@ namespace BizHawk.Client.Common StringBuilder sb = new StringBuilder(); foreach (var record in _records) { - sb.AppendLine(_mg.GenerateMnemonicString(record.Buttons)); + sb.AppendLine(record.SerializedInput); } + return sb.ToString(); } @@ -207,15 +198,6 @@ namespace BizHawk.Client.Common { // adelikat: I think Tastudio should be in charge of saving, and so we should not attempt to manage any logic like that here // EmuHawk client UI assumes someone has already picked a filename ahead of time and that it is in charge of movies - /* - if (saveChanges) - { - if (_mode == Moviemode.Record || Changes) - { - Save(); - } - } - */ _mode = Moviemode.Inactive; } @@ -236,10 +218,11 @@ namespace BizHawk.Client.Common public void AppendFrame(IController source) { Changes = true; + /* Serialize TODO _mg.Source = source; var record = new MovieRecord(_mg.GetBoolButtons(), true); - record.OnChanged += InputChanged; _records.Add(record); + */ } public void RecordFrame(int frame, IController source) @@ -273,7 +256,9 @@ namespace BizHawk.Client.Common { Changes = true; _mg.Source = source; + /* Serialize TODO _records[frame].SetInput(_mg.GetBoolButtons()); + */ } } @@ -331,7 +316,7 @@ namespace BizHawk.Client.Common bl.GetLump(BinaryStateLump.Input, true, delegate(TextReader tr) { - string line = String.Empty; + string line = string.Empty; while (true) { line = tr.ReadLine(); @@ -341,8 +326,10 @@ namespace BizHawk.Client.Common } else if (line.StartsWith("|")) { + /* Serialize TODO var parsedButtons = _mg.ParseMnemonicString(line); _records.Add(new MovieRecord(parsedButtons, captureState: false)); + */ } } }); diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index f1614069d3..eda87f2d6d 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -151,7 +151,9 @@ namespace BizHawk.Client.EmuHawk } else { - text = _tas[index].IsPressed(columnName) ? columnText : string.Empty; + //Serialize TODO + //text = _tas[index].IsPressed(columnName) ? columnText : string.Empty; + text = string.Empty; } } catch (Exception ex) @@ -197,7 +199,6 @@ namespace BizHawk.Client.EmuHawk _tas = Global.MovieSession.Movie as TasMovie; _tas.StartNewRecording(); - _tas.OnChanged += OnMovieChanged; GlobalWin.MainForm.StartNewMovie(_tas, true, true); } @@ -417,7 +418,8 @@ namespace BizHawk.Client.EmuHawk var list = TasView.SelectedIndices; for (var i = 0; i < list.Count; i++) { - _tasClipboard.Add(new TasClipboardEntry(list[i], _tas[i].Buttons)); + //Serialize TODO + //_tasClipboard.Add(new TasClipboardEntry(list[i], _tas[i].Buttons)); } SetSplicer(); @@ -477,12 +479,6 @@ namespace BizHawk.Client.EmuHawk #region TASView Events - private void OnMovieChanged(object sender, MovieRecord.InputEventArgs e) - { - // TODO: move logic needs to go here - TasView.ItemCount = _tas.InputLogLength; - } - private void TasView_MouseDown(object sender, MouseEventArgs e) { if (TasView.PointedCell.Row.HasValue && !string.IsNullOrEmpty(TasView.PointedCell.Column))