Some cleaning up of logic of past commits, and separate MovieRecordList to its own file
This commit is contained in:
parent
d0cb81fbfc
commit
6873248ce8
|
@ -132,6 +132,7 @@
|
||||||
<Compile Include="movie\MovieLog.cs" />
|
<Compile Include="movie\MovieLog.cs" />
|
||||||
<Compile Include="movie\MovieMnemonics.cs" />
|
<Compile Include="movie\MovieMnemonics.cs" />
|
||||||
<Compile Include="movie\MovieRecord.cs" />
|
<Compile Include="movie\MovieRecord.cs" />
|
||||||
|
<Compile Include="movie\MovieRecordList.cs" />
|
||||||
<Compile Include="movie\MovieSession.cs" />
|
<Compile Include="movie\MovieSession.cs" />
|
||||||
<Compile Include="movie\MultitrackRecording.cs" />
|
<Compile Include="movie\MultitrackRecording.cs" />
|
||||||
<Compile Include="movie\MnemonicsLookupTable.cs" />
|
<Compile Include="movie\MnemonicsLookupTable.cs" />
|
||||||
|
|
|
@ -467,7 +467,7 @@ namespace BizHawk.Client.Common
|
||||||
public class NewMnemonicsGenerator
|
public class NewMnemonicsGenerator
|
||||||
{
|
{
|
||||||
public MnemonicLookupTable MnemonicLookup { get; private set; }
|
public MnemonicLookupTable MnemonicLookup { get; private set; }
|
||||||
public IController Source { get; private set; }
|
public IController Source { get; set; }
|
||||||
|
|
||||||
public List<string> ActivePlayers { get; set; }
|
public List<string> ActivePlayers { get; set; }
|
||||||
|
|
||||||
|
@ -520,6 +520,31 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GenerateMnemonicString(Dictionary<string, bool> buttons)
|
||||||
|
{
|
||||||
|
IEnumerable<MnemonicCollection> 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
|
public string MnemonicString
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
|
@ -9,22 +9,12 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
public class MovieRecord
|
public class MovieRecord
|
||||||
{
|
{
|
||||||
// TODO: pass in ActivePlayers
|
private readonly byte[] _state;
|
||||||
// TODO: pass in IController source, probably wasteful though
|
|
||||||
|
|
||||||
private NewMnemonicsGenerator _mg;
|
|
||||||
private Dictionary<string, bool> _boolButtons = new Dictionary<string, bool>();
|
private Dictionary<string, bool> _boolButtons = new Dictionary<string, bool>();
|
||||||
private byte[] _state;
|
|
||||||
|
|
||||||
public MovieRecord()
|
public MovieRecord(Dictionary<string, bool> buttons, bool captureState)
|
||||||
{
|
{
|
||||||
_mg = new NewMnemonicsGenerator(Global.MovieOutputHardpoint);
|
SetInput(buttons);
|
||||||
}
|
|
||||||
|
|
||||||
public MovieRecord(IController source, bool captureState)
|
|
||||||
{
|
|
||||||
_mg = new NewMnemonicsGenerator(source);
|
|
||||||
SetInput();
|
|
||||||
if (captureState)
|
if (captureState)
|
||||||
{
|
{
|
||||||
Lagged = Global.Emulator.IsLagFrame;
|
Lagged = Global.Emulator.IsLagFrame;
|
||||||
|
@ -32,27 +22,13 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<string> ActivePlayers
|
public Dictionary<string, bool> Buttons
|
||||||
{
|
{
|
||||||
get
|
get { return _boolButtons; }
|
||||||
{
|
|
||||||
return _mg.ActivePlayers;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_mg.ActivePlayers = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Input
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _mg.MnemonicString;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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; }
|
||||||
|
@ -63,11 +39,15 @@ namespace BizHawk.Client.Common
|
||||||
return _boolButtons[buttonName];
|
return _boolButtons[buttonName];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetButton(string button, bool pressed)
|
||||||
|
{
|
||||||
|
_boolButtons[button] = pressed;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetInput()
|
public void SetInput(Dictionary<string, bool> buttons)
|
||||||
{
|
{
|
||||||
_boolButtons.Clear();
|
_boolButtons.Clear();
|
||||||
_boolButtons = _mg.GetBoolButtons();
|
_boolButtons = buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearInput()
|
public void ClearInput()
|
||||||
|
@ -77,47 +57,7 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
public bool HasState
|
public bool HasState
|
||||||
{
|
{
|
||||||
get { return State.Count() > 0; }
|
get { return State.Any(); }
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return Input; // TODO: consider the fileformat of binary and lagged data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class MovieRecordList : List<MovieRecord>
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace BizHawk.Client.Common
|
||||||
|
{
|
||||||
|
public class MovieRecordList : List<MovieRecord>
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
using BizHawk.Emulation.Common;
|
using BizHawk.Emulation.Common;
|
||||||
|
|
||||||
|
@ -10,17 +9,16 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
public class TasMovie : IMovie
|
public class TasMovie : IMovie
|
||||||
{
|
{
|
||||||
|
// TODO: pass source into
|
||||||
// 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
|
||||||
|
// TODO: consider the fileformat of binary and lagged data
|
||||||
private IController _source = Global.MovieOutputHardpoint; //TODO: don't do it this way;
|
private readonly NewMnemonicsGenerator _mg;
|
||||||
|
private readonly IController _source = Global.MovieOutputHardpoint;
|
||||||
|
|
||||||
public MovieRecord this[int index]
|
public MovieRecord this[int index]
|
||||||
{
|
{
|
||||||
get
|
get { return _records[index]; }
|
||||||
{
|
|
||||||
return _records[index];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<string> ActivePlayers { get; set; }
|
public List<string> ActivePlayers { get; set; }
|
||||||
|
@ -29,8 +27,7 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
NewMnemonicsGenerator mg = new NewMnemonicsGenerator(_source);
|
var mg = new NewMnemonicsGenerator(_source) { ActivePlayers = this.ActivePlayers };
|
||||||
mg.ActivePlayers = ActivePlayers;
|
|
||||||
return mg.AvailableMnemonics;
|
return mg.AvailableMnemonics;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +47,8 @@ namespace BizHawk.Client.Common
|
||||||
_records = new MovieRecordList();
|
_records = new MovieRecordList();
|
||||||
_mode = Moviemode.Inactive;
|
_mode = Moviemode.Inactive;
|
||||||
IsCountingRerecords = true;
|
IsCountingRerecords = true;
|
||||||
|
|
||||||
|
_mg = new NewMnemonicsGenerator(_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Filename { get; set; }
|
public string Filename { get; set; }
|
||||||
|
@ -115,7 +114,7 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
if (frame >= 0)
|
if (frame >= 0)
|
||||||
{
|
{
|
||||||
return _records[frame].Input;
|
return _mg.GenerateMnemonicString(_records[frame].Buttons);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -181,7 +180,8 @@ namespace BizHawk.Client.Common
|
||||||
public void AppendFrame(IController source)
|
public void AppendFrame(IController source)
|
||||||
{
|
{
|
||||||
Changes = true;
|
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)
|
public void RecordFrame(int frame, IController source)
|
||||||
|
@ -213,7 +213,8 @@ namespace BizHawk.Client.Common
|
||||||
if (frame < _records.Count)
|
if (frame < _records.Count)
|
||||||
{
|
{
|
||||||
Changes = true;
|
Changes = true;
|
||||||
_records[frame].SetInput();
|
_mg.Source = source;
|
||||||
|
_records[frame].SetInput(_mg.GetBoolButtons());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +267,7 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
#region Private
|
#region Private
|
||||||
|
|
||||||
private enum Moviemode { Inactive, Play, Record, Finished };
|
private enum Moviemode { Inactive, Play, Record, Finished }
|
||||||
private readonly MovieRecordList _records;
|
private readonly MovieRecordList _records;
|
||||||
private Moviemode _mode;
|
private Moviemode _mode;
|
||||||
private readonly PlatformFrameRates _frameRates = new PlatformFrameRates();
|
private readonly PlatformFrameRates _frameRates = new PlatformFrameRates();
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -60,14 +59,20 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public void UpdateValues()
|
public void UpdateValues()
|
||||||
{
|
{
|
||||||
if (!IsHandleCreated || IsDisposed) return;
|
if (!IsHandleCreated || IsDisposed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
TASView.ItemCount = _tas.InputLogLength;
|
TASView.ItemCount = _tas.InputLogLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Restart()
|
public void Restart()
|
||||||
{
|
{
|
||||||
if (!IsHandleCreated || IsDisposed) return;
|
if (!IsHandleCreated || IsDisposed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -81,14 +86,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (record.Lagged)
|
color = record.Lagged ? Color.Pink : Color.LightGreen;
|
||||||
{
|
|
||||||
color = Color.Pink;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
color = Color.LightGreen;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,13 +94,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
text = String.Empty;
|
|
||||||
var columnName = TASView.Columns[column].Name;
|
var columnName = TASView.Columns[column].Name;
|
||||||
var columnText = TASView.Columns[column].Text;
|
var columnText = TASView.Columns[column].Text;
|
||||||
|
|
||||||
if (columnName == MarkerColumnName)
|
if (columnName == MarkerColumnName)
|
||||||
{
|
{
|
||||||
text = "";
|
text = String.Empty;
|
||||||
}
|
}
|
||||||
else if (columnName == FrameColumnName)
|
else if (columnName == FrameColumnName)
|
||||||
{
|
{
|
||||||
|
@ -116,7 +113,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
text = String.Empty;
|
text = String.Empty;
|
||||||
MessageBox.Show("oops\n" + ex.ToString());
|
MessageBox.Show("oops\n" + ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +136,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
LoadConfigSettings();
|
LoadConfigSettings();
|
||||||
|
|
||||||
|
|
||||||
_tas.ActivePlayers = new List<string> { "Player 1", "Player 2" };
|
_tas.ActivePlayers = new List<string> { "Player 1", "Player 2" };
|
||||||
SetUpColumns();
|
SetUpColumns();
|
||||||
}
|
}
|
||||||
|
@ -147,12 +143,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
private void SetUpColumns()
|
private void SetUpColumns()
|
||||||
{
|
{
|
||||||
TASView.Columns.Clear();
|
TASView.Columns.Clear();
|
||||||
AddColumn(MarkerColumnName, "", 18);
|
AddColumn(MarkerColumnName, String.Empty, 18);
|
||||||
AddColumn(FrameColumnName, "Frame#", 68);
|
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);
|
AddColumn(kvp.Key, kvp.Value.ToString(), 20);
|
||||||
}
|
}
|
||||||
|
@ -221,6 +215,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
Global.Config.AutoloadTAStudio ^= true;
|
Global.Config.AutoloadTAStudio ^= true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e)
|
private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Global.Config.TAStudioSaveWindowPosition ^= true;
|
Global.Config.TAStudioSaveWindowPosition ^= true;
|
||||||
|
|
Loading…
Reference in New Issue