TAStudio - input painting for boolean input

This commit is contained in:
adelikat 2014-07-10 20:40:50 +00:00
parent 238e9b4f73
commit f0425f3cc5
5 changed files with 65 additions and 8 deletions

View File

@ -41,7 +41,18 @@ namespace BizHawk.Client.Common
public bool this[string button]
{
get { return MyBoolButtons[button]; }
get
{
return MyBoolButtons[button];
}
set
{
if (MyBoolButtons.ContainsKey(button))
{
MyBoolButtons[button] = value;
}
}
}
public bool IsPressed(string button)

View File

@ -8,7 +8,7 @@ namespace BizHawk.Client.Common
{
public partial class Bk2Movie
{
private readonly List<string> _log = new List<string>();
protected readonly List<string> _log = new List<string>();
private string _logKey = string.Empty;
public string GetInputLog()

View File

@ -84,5 +84,44 @@ namespace BizHawk.Client.Common
return "!";
}
public void ToggleBoolState(int frame, string buttonName)
{
if (frame < _log.Count)
{
var adapter = GetInputState(frame) as Bk2ControllerAdapter;
adapter[buttonName] = !adapter.IsPressed(buttonName);
var lg = LogGeneratorInstance();
lg.SetSource(adapter);
_log[frame] = lg.GenerateLogEntry();
Changes = true;
}
}
public void SetBoolState(int frame, string buttonName, bool val)
{
if (frame < _log.Count)
{
var adapter = GetInputState(frame) as Bk2ControllerAdapter;
var old = adapter[buttonName];
adapter[buttonName] = val;
var lg = LogGeneratorInstance();
lg.SetSource(adapter);
_log[frame] = lg.GenerateLogEntry();
if (old != val)
{
Changes = true;
}
}
}
public bool BoolIsPressed(int frame, string buttonName)
{
var adapter = GetInputState(frame) as Bk2ControllerAdapter;
return adapter.IsPressed(buttonName);
}
}
}

View File

@ -82,11 +82,18 @@ namespace BizHawk.Client.EmuHawk
}
else
{
//_tas.ToggleButton(TasView.PointedCell.Row.Value, TasView.PointedCell.Column);
TasView.Refresh();
var frame = TasView.PointedCell.Row.Value;
var buttonName = TasView.PointedCell.Column;
_startDrawColumn = TasView.PointedCell.Column;
//_startOn = _tas.IsPressed(TasView.PointedCell.Row.Value, TasView.PointedCell.Column);
// TODO: if float, store the original value and copy that on cell chaned
if (Global.MovieSession.MovieControllerAdapter.Type.BoolButtons.Contains(buttonName))
{
_tas.ToggleBoolState(TasView.PointedCell.Row.Value, TasView.PointedCell.Column);
TasView.Refresh();
_startDrawColumn = TasView.PointedCell.Column;
_startOn = _tas.BoolIsPressed(frame, buttonName);
}
}
}
}
@ -131,7 +138,7 @@ namespace BizHawk.Client.EmuHawk
}
else if (TasView.IsPaintDown && e.NewCell.Row.HasValue && !string.IsNullOrEmpty(_startDrawColumn))
{
//_tas.SetBoolButton(e.NewCell.Row.Value, _startDrawColumn, /*_startOn*/ false); // Notice it uses new row, old column, you can only paint across a single column
_tas.SetBoolState(e.NewCell.Row.Value, _startDrawColumn, _startOn); // Notice it uses new row, old column, you can only paint across a single column
TasView.Refresh();
}
}

View File

@ -24,7 +24,7 @@ namespace BizHawk.Client.EmuHawk
// Input Painting
private string _startDrawColumn = string.Empty;
//private bool _startOn;
private bool _startOn;
private bool _startMarkerDrag;
private bool _startFrameDrag;