TAStudio / TasMovie - Proof of concept that MovieRecords can hold an array of bool states and communicate with higher objects via IController
This commit is contained in:
parent
50d4a3307a
commit
94de0b0376
|
@ -187,7 +187,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public class MnemonicsGenerator
|
||||
{
|
||||
private IController Source;
|
||||
public IController Source; // Making this public is a temporary hack
|
||||
private string ControlType;
|
||||
|
||||
public bool this[int player, string mnemonic]
|
||||
|
|
|
@ -3,18 +3,29 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public class MovieRecord : IMovieRecord
|
||||
{
|
||||
private MnemonicsGenerator _mg;
|
||||
Dictionary<string, bool> BoolButtons = new Dictionary<string, bool>();
|
||||
private byte[] _state;
|
||||
|
||||
public string Input
|
||||
{
|
||||
get
|
||||
{
|
||||
return _mg.GetControllersAsMnemonic();
|
||||
SimpleController controller = new SimpleController { Type = new ControllerDefinition() };
|
||||
foreach (var kvp in BoolButtons)
|
||||
{
|
||||
controller["P1 " + kvp.Key] = kvp.Value; // TODO: multi-player, all cores
|
||||
}
|
||||
|
||||
controller.Type.Name = Global.Emulator.ControllerDefinition.Name;
|
||||
MnemonicsGenerator mg = new MnemonicsGenerator();
|
||||
mg.SetSource(controller);
|
||||
return mg.GetControllersAsMnemonic();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,22 +37,31 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public bool IsPressed(int player, string mnemonic)
|
||||
{
|
||||
return _mg[player, mnemonic];
|
||||
return BoolButtons[mnemonic]; // TODO: player
|
||||
}
|
||||
|
||||
public void SetInput(MnemonicsGenerator mg)
|
||||
|
||||
public void SetInput(IController controller)
|
||||
{
|
||||
_mg = mg;
|
||||
var mnemonics = MnemonicConstants.BUTTONS[Global.Emulator.Controller.Type.Name].Select(x => x.Value);
|
||||
foreach (var mnemonic in mnemonics)
|
||||
{
|
||||
BoolButtons[mnemonic] = controller["P1 " + mnemonic]; // TODO: doesn't work on every core, can't do multiplayer
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearInput()
|
||||
{
|
||||
_mg = new MnemonicsGenerator();
|
||||
foreach (var key in BoolButtons.Keys)
|
||||
{
|
||||
BoolButtons[key] = false;
|
||||
}
|
||||
}
|
||||
|
||||
public MovieRecord(MnemonicsGenerator mg, bool captureState)
|
||||
public MovieRecord(IController controller, bool captureState)
|
||||
{
|
||||
_mg = mg;
|
||||
SetInput(controller);
|
||||
|
||||
if (captureState)
|
||||
{
|
||||
Lagged = Global.Emulator.IsLagFrame;
|
||||
|
|
|
@ -165,7 +165,7 @@ namespace BizHawk.Client.Common
|
|||
public void AppendFrame(MnemonicsGenerator mg)
|
||||
{
|
||||
Changes = true;
|
||||
_records.Add(new MovieRecord(mg, true));
|
||||
_records.Add(new MovieRecord(mg.Source, true));
|
||||
}
|
||||
|
||||
public void RecordFrame(int frame, MnemonicsGenerator mg)
|
||||
|
@ -197,7 +197,7 @@ namespace BizHawk.Client.Common
|
|||
if (frame < _records.Count)
|
||||
{
|
||||
Changes = true;
|
||||
_records[frame].SetInput(mg);
|
||||
_records[frame].SetInput(mg.Source);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,20 +94,28 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void TASView_QueryItemText(int index, int column, out string text)
|
||||
{
|
||||
text = String.Empty;
|
||||
var columnName = TASView.Columns[column].Name;
|
||||
try
|
||||
{
|
||||
text = String.Empty;
|
||||
var columnName = TASView.Columns[column].Name;
|
||||
|
||||
if (columnName == MarkerColumn)
|
||||
{
|
||||
text = "X";
|
||||
if (columnName == MarkerColumn)
|
||||
{
|
||||
text = "X";
|
||||
}
|
||||
else if (columnName == FrameColumn)
|
||||
{
|
||||
text = index.ToString().PadLeft(5, '0');
|
||||
}
|
||||
else
|
||||
{
|
||||
text = _tas[index].IsPressed(1, columnName) ? columnName : String.Empty;
|
||||
}
|
||||
}
|
||||
else if (columnName == FrameColumn)
|
||||
catch (Exception ex)
|
||||
{
|
||||
text = index.ToString().PadLeft(5, '0');
|
||||
}
|
||||
else
|
||||
{
|
||||
text = _tas[index].IsPressed(1, columnName) ? columnName : String.Empty;
|
||||
text = "";
|
||||
MessageBox.Show("oops\n" + ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue