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\MovieMnemonics.cs" />
|
||||
<Compile Include="movie\MovieRecord.cs" />
|
||||
<Compile Include="movie\MovieRecordList.cs" />
|
||||
<Compile Include="movie\MovieSession.cs" />
|
||||
<Compile Include="movie\MultitrackRecording.cs" />
|
||||
<Compile Include="movie\MnemonicsLookupTable.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<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
|
||||
{
|
||||
get
|
||||
|
|
|
@ -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<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);
|
||||
}
|
||||
|
||||
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<string> ActivePlayers
|
||||
public Dictionary<string, bool> 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<byte> 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<string, bool> 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<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);
|
||||
}
|
||||
get { return State.Any(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.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<string> 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();
|
||||
|
|
|
@ -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<string> { "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;
|
||||
|
|
Loading…
Reference in New Issue