diff --git a/BizHawk.Client.Common/BizHawk.Client.Common.csproj b/BizHawk.Client.Common/BizHawk.Client.Common.csproj
index d56325fd9e..e803dbd392 100644
--- a/BizHawk.Client.Common/BizHawk.Client.Common.csproj
+++ b/BizHawk.Client.Common/BizHawk.Client.Common.csproj
@@ -132,6 +132,7 @@
+
diff --git a/BizHawk.Client.Common/movie/MnemonicsGenerator.cs b/BizHawk.Client.Common/movie/MnemonicsGenerator.cs
index 5757d43490..2b405258fc 100644
--- a/BizHawk.Client.Common/movie/MnemonicsGenerator.cs
+++ b/BizHawk.Client.Common/movie/MnemonicsGenerator.cs
@@ -467,7 +467,7 @@ namespace BizHawk.Client.Common
public class NewMnemonicsGenerator
{
public MnemonicLookupTable MnemonicLookup { get; private set; }
- public IController Source { get; private set; }
+ public IController Source { get; set; }
public List ActivePlayers { get; set; }
@@ -520,6 +520,31 @@ namespace BizHawk.Client.Common
}
}
+ public string GenerateMnemonicString(Dictionary buttons)
+ {
+ IEnumerable collections = MnemonicLookup[Global.Emulator.SystemId].Where(x => ActivePlayers.Contains(x.Name));
+ StringBuilder sb = new StringBuilder();
+
+ sb.Append('|');
+ foreach (var mc in collections)
+ {
+ foreach (var kvp in mc)
+ {
+ if (buttons.ContainsKey(kvp.Key))
+ {
+ sb.Append(buttons[kvp.Key] ? kvp.Value : '.');
+ }
+ else
+ {
+ sb.Append('.');
+ }
+ }
+ sb.Append('|');
+ }
+
+ return sb.ToString();
+ }
+
public string MnemonicString
{
get
diff --git a/BizHawk.Client.Common/movie/MovieRecord.cs b/BizHawk.Client.Common/movie/MovieRecord.cs
index df39296133..a285fef9a7 100644
--- a/BizHawk.Client.Common/movie/MovieRecord.cs
+++ b/BizHawk.Client.Common/movie/MovieRecord.cs
@@ -9,22 +9,12 @@ namespace BizHawk.Client.Common
{
public class MovieRecord
{
- // TODO: pass in ActivePlayers
- // TODO: pass in IController source, probably wasteful though
-
- private NewMnemonicsGenerator _mg;
+ private readonly byte[] _state;
private Dictionary _boolButtons = new Dictionary();
- private byte[] _state;
- public MovieRecord()
+ public MovieRecord(Dictionary buttons, bool captureState)
{
- _mg = new NewMnemonicsGenerator(Global.MovieOutputHardpoint);
- }
-
- public MovieRecord(IController source, bool captureState)
- {
- _mg = new NewMnemonicsGenerator(source);
- SetInput();
+ SetInput(buttons);
if (captureState)
{
Lagged = Global.Emulator.IsLagFrame;
@@ -32,27 +22,13 @@ namespace BizHawk.Client.Common
}
}
- public List ActivePlayers
+ public Dictionary Buttons
{
- get
- {
- return _mg.ActivePlayers;
- }
- set
- {
- _mg.ActivePlayers = value;
- }
- }
-
- public string Input
- {
- get
- {
- return _mg.MnemonicString;
- }
+ get { return _boolButtons; }
}
public bool Lagged { get; private set; }
+
public IEnumerable State
{
get { return _state; }
@@ -63,11 +39,15 @@ namespace BizHawk.Client.Common
return _boolButtons[buttonName];
}
+ public void SetButton(string button, bool pressed)
+ {
+ _boolButtons[button] = pressed;
+ }
- public void SetInput()
+ public void SetInput(Dictionary buttons)
{
_boolButtons.Clear();
- _boolButtons = _mg.GetBoolButtons();
+ _boolButtons = buttons;
}
public void ClearInput()
@@ -77,47 +57,7 @@ namespace BizHawk.Client.Common
public bool HasState
{
- get { return State.Count() > 0; }
- }
-
- public override string ToString()
- {
- return Input; // TODO: consider the fileformat of binary and lagged data
- }
- }
-
- public class MovieRecordList : List
- {
- public MovieRecordList()
- : base()
- {
-
- }
-
- public override string ToString()
- {
- var sb = new StringBuilder();
- sb
- .AppendLine("[Input]")
-
- .Append("Frame ")
- .Append(Global.Emulator.Frame)
- .AppendLine();
-
- foreach (var record in this)
- {
- sb.AppendLine(record.ToString());
- }
- sb.AppendLine("[/Input]");
- return sb.ToString();
- }
-
- public void Truncate(int index)
- {
- if (index < Count)
- {
- RemoveRange(index, Count - index);
- }
+ get { return State.Any(); }
}
}
}
diff --git a/BizHawk.Client.Common/movie/MovieRecordList.cs b/BizHawk.Client.Common/movie/MovieRecordList.cs
new file mode 100644
index 0000000000..a3b0e5be28
--- /dev/null
+++ b/BizHawk.Client.Common/movie/MovieRecordList.cs
@@ -0,0 +1,33 @@
+using System.Collections.Generic;
+using System.Text;
+
+namespace BizHawk.Client.Common
+{
+ public class MovieRecordList : List
+ {
+ public override string ToString()
+ {
+ var sb = new StringBuilder();
+ sb
+ .AppendLine("[Input]")
+
+ .Append("Frame ")
+ .Append(Global.Emulator.Frame)
+ .AppendLine();
+
+ ForEach(record => sb.Append(record.ToString()));
+
+ sb.AppendLine("[/Input]");
+
+ return sb.ToString();
+ }
+
+ public void Truncate(int index)
+ {
+ if (index < Count)
+ {
+ RemoveRange(index, Count - index);
+ }
+ }
+ }
+}
diff --git a/BizHawk.Client.Common/movie/TasMovie.cs b/BizHawk.Client.Common/movie/TasMovie.cs
index 557bc19052..e7cbb0b831 100644
--- a/BizHawk.Client.Common/movie/TasMovie.cs
+++ b/BizHawk.Client.Common/movie/TasMovie.cs
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Text;
using BizHawk.Emulation.Common;
@@ -10,17 +9,16 @@ namespace BizHawk.Client.Common
{
public class TasMovie : IMovie
{
+ // TODO: pass source into
// TODO: preloading, or benchmark and see how much of a performaance gain it really is
// TODO: support loop Offset
-
- private IController _source = Global.MovieOutputHardpoint; //TODO: don't do it this way;
+ // TODO: consider the fileformat of binary and lagged data
+ private readonly NewMnemonicsGenerator _mg;
+ private readonly IController _source = Global.MovieOutputHardpoint;
public MovieRecord this[int index]
{
- get
- {
- return _records[index];
- }
+ get { return _records[index]; }
}
public List ActivePlayers { get; set; }
@@ -29,8 +27,7 @@ namespace BizHawk.Client.Common
{
get
{
- NewMnemonicsGenerator mg = new NewMnemonicsGenerator(_source);
- mg.ActivePlayers = ActivePlayers;
+ var mg = new NewMnemonicsGenerator(_source) { ActivePlayers = this.ActivePlayers };
return mg.AvailableMnemonics;
}
}
@@ -50,6 +47,8 @@ namespace BizHawk.Client.Common
_records = new MovieRecordList();
_mode = Moviemode.Inactive;
IsCountingRerecords = true;
+
+ _mg = new NewMnemonicsGenerator(_source);
}
public string Filename { get; set; }
@@ -115,7 +114,7 @@ namespace BizHawk.Client.Common
{
if (frame >= 0)
{
- return _records[frame].Input;
+ return _mg.GenerateMnemonicString(_records[frame].Buttons);
}
else
{
@@ -181,7 +180,8 @@ namespace BizHawk.Client.Common
public void AppendFrame(IController source)
{
Changes = true;
- _records.Add(new MovieRecord(source, true));
+ _mg.Source = source;
+ _records.Add(new MovieRecord(_mg.GetBoolButtons(), true));
}
public void RecordFrame(int frame, IController source)
@@ -213,7 +213,8 @@ namespace BizHawk.Client.Common
if (frame < _records.Count)
{
Changes = true;
- _records[frame].SetInput();
+ _mg.Source = source;
+ _records[frame].SetInput(_mg.GetBoolButtons());
}
}
@@ -266,7 +267,7 @@ namespace BizHawk.Client.Common
#region Private
- private enum Moviemode { Inactive, Play, Record, Finished };
+ private enum Moviemode { Inactive, Play, Record, Finished }
private readonly MovieRecordList _records;
private Moviemode _mode;
private readonly PlatformFrameRates _frameRates = new PlatformFrameRates();
diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs
index c824bd2e1d..44447c223b 100644
--- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs
+++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
@@ -60,14 +59,20 @@ namespace BizHawk.Client.EmuHawk
public void UpdateValues()
{
- if (!IsHandleCreated || IsDisposed) return;
+ if (!IsHandleCreated || IsDisposed)
+ {
+ return;
+ }
TASView.ItemCount = _tas.InputLogLength;
}
public void Restart()
{
- if (!IsHandleCreated || IsDisposed) return;
+ if (!IsHandleCreated || IsDisposed)
+ {
+ return;
+ }
}
#endregion
@@ -81,14 +86,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
- if (record.Lagged)
- {
- color = Color.Pink;
- }
- else
- {
- color = Color.LightGreen;
- }
+ color = record.Lagged ? Color.Pink : Color.LightGreen;
}
}
@@ -96,13 +94,12 @@ namespace BizHawk.Client.EmuHawk
{
try
{
- text = String.Empty;
var columnName = TASView.Columns[column].Name;
var columnText = TASView.Columns[column].Text;
if (columnName == MarkerColumnName)
{
- text = "";
+ text = String.Empty;
}
else if (columnName == FrameColumnName)
{
@@ -116,7 +113,7 @@ namespace BizHawk.Client.EmuHawk
catch (Exception ex)
{
text = String.Empty;
- MessageBox.Show("oops\n" + ex.ToString());
+ MessageBox.Show("oops\n" + ex);
}
}
@@ -139,7 +136,6 @@ namespace BizHawk.Client.EmuHawk
LoadConfigSettings();
-
_tas.ActivePlayers = new List { "Player 1", "Player 2" };
SetUpColumns();
}
@@ -147,12 +143,10 @@ namespace BizHawk.Client.EmuHawk
private void SetUpColumns()
{
TASView.Columns.Clear();
- AddColumn(MarkerColumnName, "", 18);
+ AddColumn(MarkerColumnName, String.Empty, 18);
AddColumn(FrameColumnName, "Frame#", 68);
- var mnemonics = MnemonicConstants.BUTTONS[Global.Emulator.Controller.Type.Name].Select(x => x.Value);
-
- foreach(var kvp in _tas.AvailableMnemonics)
+ foreach (var kvp in _tas.AvailableMnemonics)
{
AddColumn(kvp.Key, kvp.Value.ToString(), 20);
}
@@ -221,6 +215,7 @@ namespace BizHawk.Client.EmuHawk
{
Global.Config.AutoloadTAStudio ^= true;
}
+
private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e)
{
Global.Config.TAStudioSaveWindowPosition ^= true;