BizHawk/BizHawk.Client.Common/movie/MovieRecord.cs

69 lines
1.3 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.Common
{
public class MovieRecord
{
2013-12-09 17:24:32 +00:00
private byte[] _state = new byte[0];
private Dictionary<string, bool> _boolButtons = new Dictionary<string, bool>();
public MovieRecord(Dictionary<string, bool> buttons, bool captureState)
{
SetInput(buttons);
if (captureState)
{
Lagged = Global.Emulator.IsLagFrame;
_state = Global.Emulator.SaveStateBinary();
}
}
public Dictionary<string, bool> Buttons
{
get { return _boolButtons; }
2013-12-06 18:27:06 +00:00
}
public bool Lagged { get; private set; }
public IEnumerable<byte> State
{
get { return _state; }
}
public bool IsPressed(string buttonName)
2013-12-06 18:27:06 +00:00
{
return _boolButtons[buttonName];
2013-12-06 18:27:06 +00:00
}
public void SetButton(string button, bool pressed)
{
_boolButtons[button] = pressed;
}
public void SetInput(Dictionary<string, bool> buttons)
{
_boolButtons.Clear();
_boolButtons = buttons;
}
public void ClearInput()
{
_boolButtons.Clear();
}
2013-12-09 17:24:32 +00:00
public void ClearState()
{
_state = new byte[0];
}
public bool HasState
{
get { return State.Any(); }
}
}
}