From 982d134cd244a389347e9c6d373e666557095d36 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 23 Aug 2014 14:30:12 +0000 Subject: [PATCH] More stuff for input roll and other tinkerings in preparation for obsoleting TasView --- .../Extensions/ControlExtensions.cs | 6 ++ .../tools/TAStudio/InputRoll.cs | 81 ++++++++++++++++++- .../tools/TAStudio/TAStudio.cs | 1 + 3 files changed, 85 insertions(+), 3 deletions(-) diff --git a/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs b/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs index ea33d5eb77..f335a62b65 100644 --- a/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs +++ b/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs @@ -80,6 +80,12 @@ namespace BizHawk.Client.EmuHawk.WinFormExtensions return listView.SelectedIndices.Cast(); } + // TODO: remove me + public static IEnumerable SelectedIndices(this InputRoll listView) + { + return listView.SelectedIndices; + } + #endregion } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs index 99197828ab..5b64a402a1 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Windows.Forms; using BizHawk.Client.EmuHawk.CustomControls; +using System.Collections; namespace BizHawk.Client.EmuHawk { @@ -67,6 +68,7 @@ namespace BizHawk.Client.EmuHawk LargeChange = 5 }; + GridLines = true; CellPadding = 3; CurrentCell = null; Font = new Font("Courier New", 8); // Only support fixed width @@ -109,11 +111,22 @@ namespace BizHawk.Client.EmuHawk [Category("Behavior")] public int CellPadding { get; set; } - // TODO: remove these, it is put here for more convenient replacing of a virtuallistview in tools with the need to refactor code + // TODO: remove these, it is put here for more convenient replacing of a virtuallistview in tools and minimize the amount of code to refactor, but these properties are useless public bool VirtualMode { get; set; } public bool BlazingFast { get; set; } + public bool SelectAllInProgress { get; set; } + public System.Windows.Forms.View View { get; set; } + public int selectedItem { get; set; } // ******************************************************** + // TODO: implement this + /// + /// Displays grid lines around cells + /// + [Category("Appearance")] + [DefaultValue(true)] + public bool GridLines { get; set; } + /// /// Gets or sets whether the control is horizontal or vertical /// @@ -177,6 +190,23 @@ namespace BizHawk.Client.EmuHawk [Category("Behavior")] public RollColumns Columns { get { return _columns; } } + public void SelectAll() + { + var oldFullRowVal = FullRowSelect; + FullRowSelect = true; + for (int i = 0; i < ItemCount; i++) + { + SelectItem(i, true); + } + + FullRowSelect = oldFullRowVal; + } + + public void DeselectAll() + { + SelectedItems.Clear(); + } + #endregion #region Event Handlers @@ -251,6 +281,27 @@ namespace BizHawk.Client.EmuHawk #region Api + // TODO: rename this, it is named this for legacy support from VirtualListVIew + public void SelectItem(int index, bool val) + { + if (_columns.Any()) + { + if (val) + { + SelectCell(new Cell + { + RowIndex = index, + Column = _columns[0] + }); + } + else + { + var items = SelectedItems.Where(i => i.RowIndex == index); + SelectedItems.RemoveAll(x => items.Contains(x)); + } + } + } + [Browsable(false)] [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)] public int? LastSelectedIndex @@ -373,16 +424,18 @@ namespace BizHawk.Client.EmuHawk } } + // TODO: make IEnumerable, IList is for legacy support [Browsable(false)] [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)] - public IEnumerable SelectedIndices + public IList SelectedIndices { get { return SelectedItems .Where(cell => cell.RowIndex.HasValue) .Select(cell => cell.RowIndex.Value) - .Distinct(); + .Distinct() + .ToList(); } } @@ -1176,6 +1229,28 @@ namespace BizHawk.Client.EmuHawk public class RollColumns : List { + // For legacy support + public void Add(ColumnHeader column) + { + Add(new RollColumn + { + Group = "", + Width = column.Width, + Name = column.Name, + Text = column.Text, + Type = RollColumn.InputType.Text, + }); + } + + // For legacy support + public void AddRange(ColumnHeader[] columns) + { + foreach (var column in columns) + { + Add(column); // TODO: this fires the change event each time, convert to an AddRange Call + } + } + public RollColumn this[string name] { get diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index c975752814..38f0225d20 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -826,6 +826,7 @@ namespace BizHawk.Client.EmuHawk private void DrawInputByDraggingMenuItem_Click(object sender, EventArgs e) { + // TOOD: integrate this logic into input roll, have it save and load through its own load/save settings methods, Global.Config.TAStudioDrawInput will go away TasView.InputPaintingMode = Global.Config.TAStudioDrawInput ^= true; }