TAstudio - start capturing states and lag, basic background color logic, start item text logic

This commit is contained in:
adelikat 2013-12-06 15:47:23 +00:00
parent 0c3818a37e
commit 98f1e02df3
6 changed files with 87 additions and 16 deletions

View File

@ -10,7 +10,7 @@ namespace BizHawk.Client.Common
/// <summary> /// <summary>
/// Gets or sets the string representation of the controller input as a series of mnemonics /// Gets or sets the string representation of the controller input as a series of mnemonics
/// </summary> /// </summary>
string Input { get; set; } string Input { get; }
/// <summary> /// <summary>
/// Gets a value indicating whether or not this was a lag frame, /// Gets a value indicating whether or not this was a lag frame,
@ -18,6 +18,11 @@ namespace BizHawk.Client.Common
/// </summary> /// </summary>
bool Lagged { get; } bool Lagged { get; }
/// <summary>
/// Gets a valude indicating whether or not this record has a captured state
/// </summary>
bool HasState { get; }
/// <summary> /// <summary>
/// Gets the Savestate for this frame of input /// Gets the Savestate for this frame of input
/// </summary> /// </summary>

View File

@ -187,13 +187,14 @@ namespace BizHawk.Client.Common
public class MnemonicsGenerator public class MnemonicsGenerator
{ {
IController Source; private IController Source;
private string ControlType;
public void SetSource(IController source) public void SetSource(IController source)
{ {
Source = source; Source = source;
ControlType = source.Type.Name; ControlType = source.Type.Name;
} }
string ControlType;
bool IsBasePressed(string name) bool IsBasePressed(string name)
{ {
@ -359,7 +360,6 @@ namespace BizHawk.Client.Common
return input.ToString(); return input.ToString();
} }
private string GetA78ControllersAsMnemonic() private string GetA78ControllersAsMnemonic()
{ {
StringBuilder input = new StringBuilder("|"); StringBuilder input = new StringBuilder("|");

View File

@ -7,18 +7,43 @@ namespace BizHawk.Client.Common
{ {
public class MovieRecord : IMovieRecord public class MovieRecord : IMovieRecord
{ {
private List<byte> _state = new List<byte>(); private MnemonicsGenerator _mg;
private byte[] _state;
public string Input { get; private set; }
public string Input { get; set; }
public bool Lagged { get; private set; } public bool Lagged { get; private set; }
public IEnumerable<byte> State public IEnumerable<byte> State
{ {
get { return _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() public override string ToString()

View File

@ -10,6 +10,15 @@ namespace BizHawk.Client.Common
{ {
// TODO: preloading, or benchmark and see how much of a performaance gain it really is // TODO: preloading, or benchmark and see how much of a performaance gain it really is
// TODO: support loop Offset // TODO: support loop Offset
public MovieRecord this[int index]
{
get
{
return _records[index];
}
}
#region Implementation #region Implementation
public TasMovie(string filename, bool startsFromSavestate = false) public TasMovie(string filename, bool startsFromSavestate = false)
@ -149,17 +158,14 @@ namespace BizHawk.Client.Common
if (frame < _records.Count) if (frame < _records.Count)
{ {
Changes = true; Changes = true;
_records[frame].Input = MnemonicsGenerator.GetEmptyMnemonic; _records[frame].ClearInput();
} }
} }
public void AppendFrame(MnemonicsGenerator mg) public void AppendFrame(MnemonicsGenerator mg)
{ {
Changes = true; Changes = true;
_records.Add(new MovieRecord _records.Add(new MovieRecord(mg, true));
{
Input = mg.GetControllersAsMnemonic(),
});
} }
public void RecordFrame(int frame, MnemonicsGenerator mg) 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) if (frame < _records.Count)
{ {
Changes = true; Changes = true;
_records[frame].Input = mg.GetControllersAsMnemonic(); _records[frame].SetInput(mg);
} }
} }

View File

@ -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.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.Location = new System.Drawing.Point(118, 495);
this.MarkerDescriptionBox.Name = "MarkerDescriptionBox"; 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; this.MarkerDescriptionBox.TabIndex = 3;
// //
// TopMarkerBox // TopMarkerBox

View File

@ -12,6 +12,9 @@ namespace BizHawk.Client.EmuHawk
{ {
public partial class TAStudio : Form, IToolForm public partial class TAStudio : Form, IToolForm
{ {
private const string MarkerColumn = "";
private const string FrameColumn = "Frame#";
private int _defaultWidth; private int _defaultWidth;
private int _defaultHeight; private int _defaultHeight;
private TasMovie _tas; private TasMovie _tas;
@ -71,12 +74,37 @@ namespace BizHawk.Client.EmuHawk
private void TASView_QueryItemBkColor(int index, int column, ref Color color) 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) private void TASView_QueryItemText(int index, int column, out string text)
{ {
text = String.Empty; 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) private void TAStudio_Load(object sender, EventArgs e)