TasListView - track the current and last cells pointed to, add a Cell changed event handler, add a Input Drawing flag, and track if the user is click dragging. TAStudio - hook up input drawing feature with toggle, still work to do as it doesn't work as intelligently as it should yet
This commit is contained in:
parent
14184c9ae9
commit
22ff2bff04
|
@ -481,6 +481,7 @@ namespace BizHawk.Client.Common
|
|||
public int TASWndy = -1;
|
||||
public int TASWidth = -1;
|
||||
public int TASHeight = -1;
|
||||
public bool TAStudioDrawInput = true;
|
||||
|
||||
// VirtualPad Dialog
|
||||
public bool VirtualPadsUpdatePads = true;
|
||||
|
|
|
@ -8,11 +8,38 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public class TasListView : VirtualListView
|
||||
{
|
||||
public string PointedColumnName { get; private set; }
|
||||
public int? PointedRowIndex { get; private set; }
|
||||
public class Cell
|
||||
{
|
||||
public int? Row;
|
||||
public string Column;
|
||||
|
||||
// Convenience hack
|
||||
public override string ToString()
|
||||
{
|
||||
return String.IsNullOrEmpty(Column) ? "?" : Column + " - " + (Row.HasValue ? Row.ToString() : "?");
|
||||
}
|
||||
}
|
||||
|
||||
private Cell _currentPointedCell = new Cell();
|
||||
public Cell PointedCell
|
||||
{
|
||||
get { return _currentPointedCell; }
|
||||
}
|
||||
|
||||
private Cell _lastPointedCell = new Cell();
|
||||
public Cell LastPointedCell
|
||||
{
|
||||
get { return _lastPointedCell; }
|
||||
}
|
||||
|
||||
public bool InputPaintingMode { get; set; }
|
||||
public bool IsPaintDown { get; private set; }
|
||||
|
||||
private void CalculatePointedCell(int x, int y)
|
||||
{
|
||||
int? newRow;
|
||||
string newColumn = String.Empty;
|
||||
|
||||
string columnName = String.Empty;
|
||||
|
||||
var accumulator = 0;
|
||||
|
@ -25,7 +52,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
PointedColumnName = column.Name;
|
||||
newColumn = column.Name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -33,17 +60,52 @@ namespace BizHawk.Client.EmuHawk
|
|||
var headerHeight = 24; //Are these always true? Don't know, is there a way to programmatically determine them?
|
||||
var rowHeight = 18;
|
||||
|
||||
PointedRowIndex = ((y - headerHeight) / rowHeight) + this.VScrollPos;
|
||||
if (PointedRowIndex >= ItemCount)
|
||||
newRow = ((y - headerHeight) / rowHeight) + this.VScrollPos;
|
||||
if (newRow >= ItemCount)
|
||||
{
|
||||
PointedRowIndex = null;
|
||||
newRow = null;
|
||||
}
|
||||
|
||||
if (newColumn != PointedCell.Column || newRow != PointedCell.Row)
|
||||
{
|
||||
LastPointedCell.Column = PointedCell.Column;
|
||||
LastPointedCell.Row = PointedCell.Row;
|
||||
|
||||
PointedCell.Column = newColumn;
|
||||
PointedCell.Row = newRow;
|
||||
|
||||
CellChanged(LastPointedCell, PointedCell);
|
||||
}
|
||||
}
|
||||
|
||||
public class CellEventArgs
|
||||
{
|
||||
public CellEventArgs(Cell oldCell, Cell newCell)
|
||||
{
|
||||
OldCell = oldCell;
|
||||
NewCell = newCell;
|
||||
}
|
||||
|
||||
public Cell OldCell { get; private set; }
|
||||
public Cell NewCell { get; private set; }
|
||||
}
|
||||
|
||||
public delegate void CellChangeEventHandler(object sender, CellEventArgs e);
|
||||
public event CellChangeEventHandler PointedCellChanged;
|
||||
|
||||
private void CellChanged(Cell oldCell, Cell newCell)
|
||||
{
|
||||
if (PointedCellChanged != null)
|
||||
{
|
||||
PointedCellChanged(this, new CellEventArgs(oldCell, newCell));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseLeave(EventArgs e)
|
||||
{
|
||||
PointedColumnName = String.Empty;
|
||||
PointedRowIndex = null;
|
||||
_currentPointedCell.Column = String.Empty;
|
||||
_currentPointedCell.Row = null;
|
||||
IsPaintDown = false;
|
||||
base.OnMouseLeave(e);
|
||||
}
|
||||
|
||||
|
@ -52,5 +114,20 @@ namespace BizHawk.Client.EmuHawk
|
|||
CalculatePointedCell(e.X, e.Y);
|
||||
base.OnMouseMove(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
if (InputPaintingMode)
|
||||
{
|
||||
IsPaintDown = true;
|
||||
}
|
||||
base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseEventArgs e)
|
||||
{
|
||||
IsPaintDown = false;
|
||||
base.OnMouseUp(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -441,6 +441,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
this.ConfigSubMenu.Name = "ConfigSubMenu";
|
||||
this.ConfigSubMenu.Size = new System.Drawing.Size(55, 20);
|
||||
this.ConfigSubMenu.Text = "&Config";
|
||||
this.ConfigSubMenu.DropDownOpened += new System.EventHandler(this.ConfigSubMenu_DropDownOpened);
|
||||
//
|
||||
// ProjectOptionsMenuItem
|
||||
//
|
||||
|
@ -496,10 +497,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
//
|
||||
// DrawInputByDraggingMenuItem
|
||||
//
|
||||
this.DrawInputByDraggingMenuItem.Enabled = false;
|
||||
this.DrawInputByDraggingMenuItem.Name = "DrawInputByDraggingMenuItem";
|
||||
this.DrawInputByDraggingMenuItem.Size = new System.Drawing.Size(288, 22);
|
||||
this.DrawInputByDraggingMenuItem.Text = "Draw Input by dragging";
|
||||
this.DrawInputByDraggingMenuItem.Click += new System.EventHandler(this.DrawInputByDraggingMenuItem_Click);
|
||||
//
|
||||
// CombineConsecutiveRecordingsMenuItem
|
||||
//
|
||||
|
@ -658,6 +659,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
this.TASView.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.TASView.FullRowSelect = true;
|
||||
this.TASView.GridLines = true;
|
||||
this.TASView.InputPaintingMode = false;
|
||||
this.TASView.ItemCount = 0;
|
||||
this.TASView.Location = new System.Drawing.Point(12, 43);
|
||||
this.TASView.Name = "TASView";
|
||||
|
|
|
@ -11,6 +11,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class TAStudio : Form, IToolForm
|
||||
{
|
||||
// TOOD: clean up Input painting logic (lock to a column, lock to on or off)
|
||||
|
||||
private const string MarkerColumnName = "MarkerColumn";
|
||||
private const string FrameColumnName = "FrameColumn";
|
||||
|
||||
|
@ -44,6 +46,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
};
|
||||
|
||||
TopMost = Global.Config.TAStudioTopMost;
|
||||
TASView.InputPaintingMode = Global.Config.TAStudioDrawInput;
|
||||
TASView.PointedCellChanged += TASView_PointedCellChanged;
|
||||
}
|
||||
|
||||
public bool AskSave()
|
||||
|
@ -202,8 +206,22 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
#endregion
|
||||
|
||||
#region Config
|
||||
|
||||
private void ConfigSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
DrawInputByDraggingMenuItem.Checked = Global.Config.TAStudioDrawInput;
|
||||
}
|
||||
|
||||
private void DrawInputByDraggingMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
TASView.InputPaintingMode = Global.Config.TAStudioDrawInput ^= true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Settings Menu
|
||||
|
||||
|
||||
private void SettingsSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
SaveWindowPositionMenuItem.Checked = Global.Config.TAStudioSaveWindowPosition;
|
||||
|
@ -232,15 +250,29 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void TASView_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (TASView.PointedRowIndex.HasValue && !String.IsNullOrEmpty(TASView.PointedColumnName))
|
||||
if (TASView.PointedCell.Row.HasValue && !String.IsNullOrEmpty(TASView.PointedCell.Column))
|
||||
{
|
||||
_tas.ToggleButton(TASView.PointedRowIndex.Value, TASView.PointedColumnName);
|
||||
_tas.ToggleButton(TASView.PointedCell.Row.Value, TASView.PointedCell.Column);
|
||||
TASView.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void TASView_PointedCellChanged(object sender, TasListView.CellEventArgs e)
|
||||
{
|
||||
if (TASView.IsPaintDown)
|
||||
{
|
||||
_tas.ToggleButton(TASView.PointedCell.Row.Value, TASView.PointedCell.Column);
|
||||
TASView.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Classes
|
||||
// Everything in here will probably need to be moved at some point
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue