diff --git a/BizHawk.Client.Common/BizHawk.Client.Common.csproj b/BizHawk.Client.Common/BizHawk.Client.Common.csproj index c866a9a85c..de8ff5983c 100644 --- a/BizHawk.Client.Common/BizHawk.Client.Common.csproj +++ b/BizHawk.Client.Common/BizHawk.Client.Common.csproj @@ -123,6 +123,7 @@ + diff --git a/BizHawk.Client.Common/config/RestoreDefaultsAttribute.cs b/BizHawk.Client.Common/config/RestoreDefaultsAttribute.cs new file mode 100644 index 0000000000..eb8584cd6e --- /dev/null +++ b/BizHawk.Client.Common/config/RestoreDefaultsAttribute.cs @@ -0,0 +1,12 @@ +using System; + +namespace BizHawk.Client.Common +{ + /// + /// Defines a method to be called when a tool dialog's Restore Defaults method is called + /// + [AttributeUsage(AttributeTargets.Method)] + public class RestoreDefaultsAttribute : Attribute + { + } +} diff --git a/BizHawk.Client.Common/lua/LuaFile.cs b/BizHawk.Client.Common/lua/LuaFile.cs index 63ae59c75e..dddb59a85d 100644 --- a/BizHawk.Client.Common/lua/LuaFile.cs +++ b/BizHawk.Client.Common/lua/LuaFile.cs @@ -48,6 +48,11 @@ public void Stop() { + if (Thread == null) + { + return; + } + State = RunState.Disabled; //if(NLua.Lua.WhichLua == "NLua") Thread.GetTable("keepalives")[Thread] = null; diff --git a/BizHawk.Client.Common/lua/LuaFileList.cs b/BizHawk.Client.Common/lua/LuaFileList.cs index 678a4c7809..a8148df357 100644 --- a/BizHawk.Client.Common/lua/LuaFileList.cs +++ b/BizHawk.Client.Common/lua/LuaFileList.cs @@ -140,11 +140,19 @@ namespace BizHawk.Client.Common var sb = new StringBuilder(); foreach (var file in this) { - sb - .Append(file.Enabled ? "1" : "0") - .Append(' ') - .Append(PathManager.MakeRelativeTo(PathManager.MakeAbsolutePath(file.Path, ""), Path.GetDirectoryName(path))) - .AppendLine(); + if (file.IsSeparator) + { + sb.AppendLine("---"); + } + else + { + sb + .Append(file.Enabled ? "1" : "0") + .Append(' ') + .Append(PathManager.MakeRelativeTo(PathManager.MakeAbsolutePath(file.Path, "") + , Path.GetDirectoryName(path))) + .AppendLine(); + } } sw.Write(sb.ToString()); diff --git a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj index 4e5ecd01d7..d1c2c3b684 100644 --- a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj +++ b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj @@ -628,9 +628,6 @@ Component - - Component - Component @@ -1518,9 +1515,6 @@ QuickProgressPopup.cs - - TasListView.cs - MainForm.cs Designer @@ -1892,6 +1886,7 @@ + diff --git a/BizHawk.Client.EmuHawk/CustomControls/InputRoll.Drawing.cs b/BizHawk.Client.EmuHawk/CustomControls/InputRoll.Drawing.cs index b5a2556f7b..f26d76fe3a 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/InputRoll.Drawing.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/InputRoll.Drawing.cs @@ -44,6 +44,25 @@ namespace BizHawk.Client.EmuHawk } } + private void DrawString(string text, int? width, Point point) + { + if (string.IsNullOrWhiteSpace(text)) + { + return; + } + + if (width.HasValue) + { + var max = (width.Value - CellWidthPadding) / _charSize.Width; + if (text.Length >= max) + { + text = text.Substring(0, max); + } + } + + _gdi.DrawString(text, point); + } + protected override void OnPaintBackground(PaintEventArgs pevent) { // Do nothing, and this should never be called @@ -105,12 +124,12 @@ namespace BizHawk.Client.EmuHawk if (IsHoveringOnColumnCell && column == CurrentCell.Column) { _gdi.PrepDrawString(_normalFont, SystemColors.HighlightText); - _gdi.DrawString(column.Text, point); + DrawString(column.Text, column.Width, point); _gdi.PrepDrawString(_normalFont, _foreColor); } else { - _gdi.DrawString(column.Text, point); + DrawString(column.Text, column.Width, point); } start += CellHeight; @@ -127,12 +146,12 @@ namespace BizHawk.Client.EmuHawk if (IsHoveringOnColumnCell && column == CurrentCell.Column) { _gdi.PrepDrawString(_normalFont, SystemColors.HighlightText); - _gdi.DrawString(column.Text, point); + DrawString(column.Text, column.Width, point); _gdi.PrepDrawString(_normalFont, _foreColor); } else { - _gdi.DrawString(column.Text, point); + DrawString(column.Text, column.Width, point); } } } @@ -198,10 +217,7 @@ namespace BizHawk.Client.EmuHawk _gdi.PrepDrawString(_rotatedFont, _foreColor); } - if (!string.IsNullOrWhiteSpace(text)) - { - _gdi.DrawString(text, point); - } + DrawString(text, ColumnWidth, point); if (rePrep) { @@ -250,10 +266,7 @@ namespace BizHawk.Client.EmuHawk rePrep = true; } - if (!string.IsNullOrWhiteSpace(text)) - { - _gdi.DrawString(text, new Point(point.X + strOffsetX, point.Y + strOffsetY)); - } + DrawString(text, col.Width, new Point(point.X + strOffsetX, point.Y + strOffsetY)); if (rePrep) { diff --git a/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs b/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs index e9489b93bb..ae12c73001 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs @@ -38,6 +38,7 @@ namespace BizHawk.Client.EmuHawk private Size _charSize; private RollColumn _columnDown; + private RollColumn _columnResizing; private int? _currentX; private int? _currentY; @@ -134,6 +135,41 @@ namespace BizHawk.Client.EmuHawk base.Dispose(disposing); } + protected override void OnDoubleClick(EventArgs e) + { + if (IsHoveringOnColumnEdge) + { + if (HorizontalOrientation) + { + // TODO + } + else + { + var maxLength = CurrentCell.Column.Text?.Length ?? 0; + + + for (int i = 0; i < RowCount; i++) + { + string text = ""; + int offSetX = 0, offSetY = 0; + QueryItemText?.Invoke(i, CurrentCell.Column, out text, ref offSetX, ref offSetY); + if (text.Length > maxLength) + { + maxLength = text.Length; + } + } + + var newWidth = (maxLength * _charSize.Width) + (CellWidthPadding * 2); + CurrentCell.Column.Width = newWidth; + _columns.ColumnsChanged(); + Refresh(); + } + + } + + base.OnDoubleClick(e); + } + #region Properties /// @@ -971,18 +1007,30 @@ namespace BizHawk.Client.EmuHawk #region Mouse and Key Events private bool _columnDownMoved; + private int _previousX = 0; // TODO: move me + protected override void OnMouseMove(MouseEventArgs e) { + _previousX = _currentX ?? 0; _currentX = e.X; _currentY = e.Y; - if (_columnDown != null) + if (_columnResizing != null) + { + if (_currentX != _previousX) + { + _columnResizing.Width += _currentX - _previousX; + _columns.ColumnsChanged(); + Refresh(); + } + } + else if (_columnDown != null) { _columnDownMoved = true; } Cell newCell = CalculatePointedCell(_currentX.Value, _currentY.Value); - + // SuuperW: Hide lag frames if (QueryFrameLag != null && newCell.RowIndex.HasValue) { @@ -1014,6 +1062,10 @@ namespace BizHawk.Client.EmuHawk Refresh(); } + Cursor = IsHoveringOnColumnEdge || _columnResizing != null + ? Cursors.VSplit + : Cursors.Default; + base.OnMouseMove(e); } @@ -1034,6 +1086,7 @@ namespace BizHawk.Client.EmuHawk _currentY = null; CurrentCell = null; IsPaintDown = false; + _columnResizing = null; _hoverTimer.Stop(); Refresh(); base.OnMouseLeave(e); @@ -1079,6 +1132,10 @@ namespace BizHawk.Client.EmuHawk if (e.Button == MouseButtons.Left) { + if (IsHoveringOnColumnEdge) + { + _columnResizing = CurrentCell.Column; + } if (IsHoveringOnColumnCell) { _columnDown = CurrentCell.Column; @@ -1209,7 +1266,7 @@ namespace BizHawk.Client.EmuHawk protected override void OnMouseUp(MouseEventArgs e) { - if (IsHoveringOnColumnCell) + if (_columnResizing == null && IsHoveringOnColumnCell) { if (_columnDown != null && _columnDownMoved) { @@ -1227,6 +1284,7 @@ namespace BizHawk.Client.EmuHawk } } + _columnResizing = null; _columnDown = null; _columnDownMoved = false; RightButtonHeld = false; @@ -1590,7 +1648,7 @@ namespace BizHawk.Client.EmuHawk } else { - NeedsVScrollbar = RowCount > 1; + NeedsVScrollbar = ColumnHeight + (RowCount * RowHeight) > Height; NeedsHScrollbar = TotalColWidth.HasValue && TotalColWidth.Value - DrawWidth + 1 > 0; } @@ -1731,12 +1789,35 @@ namespace BizHawk.Client.EmuHawk private bool IsHoveringOnColumnCell => CurrentCell?.Column != null && !CurrentCell.RowIndex.HasValue; + private bool IsHoveringOnColumnEdge => AllowColumnResize && IsHoveringOnColumnCell && IsPointingOnCellEdge(_currentX); + private bool IsHoveringOnDataCell => CurrentCell?.Column != null && CurrentCell.RowIndex.HasValue; private bool WasHoveringOnColumnCell => LastCell?.Column != null && !LastCell.RowIndex.HasValue; private bool WasHoveringOnDataCell => LastCell?.Column != null && LastCell.RowIndex.HasValue; + private bool IsPointingOnCellEdge(int? x) + { + if (x.HasValue) + { + if (HorizontalOrientation) + { + return false; // TODO: support column resize in horizontal orientation + } + + foreach (RollColumn column in _columns.VisibleColumns) + { + if (column.Left - _hBar.Value + (column.Width - column.Width / 6) <= x.Value && column.Right - _hBar.Value >= x.Value) + { + return true; + } + } + } + + return false; + } + /// /// Finds the specific cell that contains the (x, y) coordinate. /// @@ -1783,18 +1864,6 @@ namespace BizHawk.Client.EmuHawk // A boolean that indicates if the InputRoll is too large horizontally and requires a horizontal scrollbar. private bool NeedsHScrollbar { get; set; } - /// - /// Updates the width of the supplied column. - /// Call when changing the ColumnCell text, CellPadding, or text font. - /// - /// The RollColumn object to update. - /// The new width of the RollColumn object. - private int UpdateWidth(RollColumn col) - { - col.Width = (col.Text.Length * _charSize.Width) + (CellWidthPadding * 4); - return col.Width.Value; - } - /// /// Gets the total width of all the columns by using the last column's Right property. /// diff --git a/BizHawk.Client.EmuHawk/CustomControls/TasListView.cs b/BizHawk.Client.EmuHawk/CustomControls/TasListView.cs deleted file mode 100644 index 2fd17e6f68..0000000000 --- a/BizHawk.Client.EmuHawk/CustomControls/TasListView.cs +++ /dev/null @@ -1,181 +0,0 @@ -using System; -using System.Linq; -using System.Windows.Forms; - -namespace BizHawk.Client.EmuHawk -{ - public class TasListView : VirtualListView - { - public class Cell - { - public int? RowIndex; - public string Column; - - // Convenience hack - public override string ToString() - { - return string.IsNullOrEmpty(Column) ? "?" : $"{Column} - {(RowIndex.HasValue ? RowIndex.ToString() : "?")}"; - } - } - - public bool RightButtonHeld { get; set; } - - public int? LastSelectedIndex - { - get - { - if (SelectedIndices.Count > 0) - { - return SelectedIndices - .OfType() - .OrderBy(x => x) - .Last(); - } - - return null; - } - } - - private Cell _currentPointedCell = new Cell(); - public Cell CurrentCell - { - get { return _currentPointedCell; } - } - - private Cell _lastPointedCell = new Cell(); - public Cell LastCell - { - get { return _lastPointedCell; } - } - - public bool InputPaintingMode { get; set; } - public bool IsPaintDown { get; private set; } - - /// - /// Calculates the column name and row number that the point (x, y) lies in. - /// - /// X coordinate - /// Y coordinate - private void CalculatePointedCell(int x, int y) - { - int? newRow; - string newColumn = ""; - - var accumulator = 0; - foreach (ColumnHeader column in Columns) - { - accumulator += column.Width; - if (accumulator < x) - { - continue; - } - - newColumn = column.Name; - break; - } - - var rowHeight = this.LineHeight;// 5 (in VirtualListView) and 6 work here for me, but are they always dependable, how can I get the padding? - var headerHeight = rowHeight + 6; - - newRow = ((y - headerHeight) / rowHeight) + this.VScrollPos; - if (newRow >= ItemCount) - { - newRow = null; - } - - if (newColumn != CurrentCell.Column || newRow != CurrentCell.RowIndex) - { - LastCell.Column = CurrentCell.Column; - LastCell.RowIndex = CurrentCell.RowIndex; - - CurrentCell.Column = newColumn; - CurrentCell.RowIndex = newRow; - - CellChanged(LastCell, CurrentCell); - } - } - - 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) - { - _currentPointedCell.Column = ""; - _currentPointedCell.RowIndex = null; - IsPaintDown = false; - base.OnMouseLeave(e); - } - - protected override void OnMouseMove(MouseEventArgs e) - { - CalculatePointedCell(e.X, e.Y); - base.OnMouseMove(e); - } - - protected override void OnMouseDown(MouseEventArgs e) - { - if (e.Button == MouseButtons.Left && InputPaintingMode) - { - IsPaintDown = true; - } - - if (e.Button == MouseButtons.Right) - { - RightButtonHeld = true; - } - - base.OnMouseDown(e); - } - - protected override void OnMouseUp(MouseEventArgs e) - { - IsPaintDown = false; - RightButtonHeld = false; - - base.OnMouseUp(e); - } - - protected override void OnMouseWheel(MouseEventArgs e) - { - if (RightButtonHeld) - { - DoRightMouseScroll(this, e); - } - else - { - base.OnMouseWheel(e); - } - } - - public delegate void RightMouseScrollEventHandler(object sender, MouseEventArgs e); - public event RightMouseScrollEventHandler RightMouseScrolled; - - private void DoRightMouseScroll(object sender, MouseEventArgs e) - { - if (RightMouseScrolled != null) - { - RightMouseScrolled(sender, e); - } - } - } -} diff --git a/BizHawk.Client.EmuHawk/CustomControls/TasListView.resx b/BizHawk.Client.EmuHawk/CustomControls/TasListView.resx deleted file mode 100644 index 43b04417e2..0000000000 --- a/BizHawk.Client.EmuHawk/CustomControls/TasListView.resx +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - False - - \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs b/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs index 756dcfca33..9518dde03e 100644 --- a/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs +++ b/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs @@ -80,6 +80,42 @@ namespace BizHawk.Client.EmuHawk.WinFormExtensions } } + public static ToolStripMenuItem ToColumnsMenu(this InputRoll inputRoll, Action changeCallback) + { + var menu = new ToolStripMenuItem + { + Name = "GeneratedColumnsSubMenu", + Text = "Columns" + }; + + var columns = inputRoll.AllColumns; + + foreach (var column in columns) + { + var menuItem = new ToolStripMenuItem + { + Name = column.Name, + Text = $"{column.Text} ({column.Name})", + Checked = column.Visible, + CheckOnClick = true, + Tag = column.Name + }; + + menuItem.CheckedChanged += (o, ev) => + { + var sender = (ToolStripMenuItem)o; + columns.Find(c => c.Name == (string)sender.Tag).Visible = sender.Checked; + columns.ColumnsChanged(); + changeCallback(); + inputRoll.Refresh(); + }; + + menu.DropDownItems.Add(menuItem); + } + + return menu; + } + public static ToolStripMenuItem GenerateColumnsMenu(this ToolDialogSettings.ColumnList list, Action changeCallback) { var menu = new ToolStripMenuItem diff --git a/BizHawk.Client.EmuHawk/LogWindow.Designer.cs b/BizHawk.Client.EmuHawk/LogWindow.Designer.cs index fe03b76c7a..1b681d0bf9 100644 --- a/BizHawk.Client.EmuHawk/LogWindow.Designer.cs +++ b/BizHawk.Client.EmuHawk/LogWindow.Designer.cs @@ -1,4 +1,6 @@ -namespace BizHawk.Client.EmuHawk +using System.Windows.Forms; + +namespace BizHawk.Client.EmuHawk { partial class LogWindow { @@ -34,7 +36,7 @@ this.buttonCopy = new System.Windows.Forms.Button(); this.buttonCopyAll = new System.Windows.Forms.Button(); this.AddToGameDbBtn = new System.Windows.Forms.Button(); - this.virtualListView1 = new BizHawk.Client.EmuHawk.VirtualListView(); + this.virtualListView1 = new System.Windows.Forms.ListView(); this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.tableLayoutPanel1.SuspendLayout(); this.SuspendLayout(); @@ -118,23 +120,20 @@ // // virtualListView1 // - this.virtualListView1.BlazingFast = false; this.virtualListView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnHeader1}); this.virtualListView1.Dock = System.Windows.Forms.DockStyle.Fill; this.virtualListView1.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.virtualListView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; - this.virtualListView1.ItemCount = 0; + this.virtualListView1.VirtualListSize = 0; this.virtualListView1.Location = new System.Drawing.Point(0, 0); this.virtualListView1.Name = "virtualListView1"; - this.virtualListView1.SelectAllInProgress = false; - this.virtualListView1.selectedItem = -1; this.virtualListView1.Size = new System.Drawing.Size(675, 367); this.virtualListView1.TabIndex = 8; this.virtualListView1.UseCompatibleStateImageBehavior = false; this.virtualListView1.View = System.Windows.Forms.View.Details; this.virtualListView1.VirtualMode = true; - this.virtualListView1.QueryItemText += new BizHawk.Client.EmuHawk.QueryItemTextHandler(this.virtualListView1_QueryItemText); + this.virtualListView1.RetrieveVirtualItem += new RetrieveVirtualItemEventHandler(this.virtualListView1_QueryItemText); this.virtualListView1.ClientSizeChanged += new System.EventHandler(this.virtualListView1_ClientSizeChanged); this.virtualListView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.virtualListView1_KeyDown); // @@ -163,7 +162,7 @@ private System.Windows.Forms.Button btnClose; private System.Windows.Forms.Button btnClear; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; - private VirtualListView virtualListView1; + private System.Windows.Forms.ListView virtualListView1; private System.Windows.Forms.ColumnHeader columnHeader1; private System.Windows.Forms.Button buttonCopy; private System.Windows.Forms.Button buttonCopyAll; diff --git a/BizHawk.Client.EmuHawk/LogWindow.cs b/BizHawk.Client.EmuHawk/LogWindow.cs index af5d0d8968..212ec849d2 100644 --- a/BizHawk.Client.EmuHawk/LogWindow.cs +++ b/BizHawk.Client.EmuHawk/LogWindow.cs @@ -5,7 +5,6 @@ using System.IO; using System.Text; using System.Windows.Forms; -using BizHawk.Common.ReflectionExtensions; using BizHawk.Emulation.Common; using BizHawk.Emulation.Common.IEmulatorExtensions; using BizHawk.Client.Common; @@ -40,7 +39,7 @@ namespace BizHawk.Client.EmuHawk var ss = report.Split('\n'); foreach (var s in ss) dlg.Lines.Add(s.TrimEnd('\r')); - dlg.virtualListView1.ItemCount = ss.Length; + dlg.virtualListView1.VirtualListSize = ss.Length; dlg.Text = title; dlg.btnClear.Visible = false; dlg.ShowDialog(parent); @@ -55,7 +54,7 @@ namespace BizHawk.Client.EmuHawk if (!string.IsNullOrWhiteSpace(s)) { Lines.Add(s.TrimEnd('\r')); - virtualListView1.ItemCount++; + virtualListView1.VirtualListSize++; } } } @@ -63,7 +62,7 @@ namespace BizHawk.Client.EmuHawk private void btnClear_Click(object sender, EventArgs e) { Lines.Clear(); - virtualListView1.ItemCount = 0; + virtualListView1.VirtualListSize = 0; virtualListView1.SelectedIndices.Clear(); } @@ -99,9 +98,9 @@ namespace BizHawk.Client.EmuHawk } } - private void virtualListView1_QueryItemText(int item, int subItem, out string text) + private void virtualListView1_QueryItemText(object sender, RetrieveVirtualItemEventArgs e) { - text = Lines[item]; + e.Item = new ListViewItem(Lines[e.ItemIndex]); } private void virtualListView1_ClientSizeChanged(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/Properties/Resources.Designer.cs b/BizHawk.Client.EmuHawk/Properties/Resources.Designer.cs index d9e97b6eff..022c725cc6 100644 --- a/BizHawk.Client.EmuHawk/Properties/Resources.Designer.cs +++ b/BizHawk.Client.EmuHawk/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace BizHawk.Client.EmuHawk.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -1479,6 +1479,16 @@ namespace BizHawk.Client.EmuHawk.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap StopButton { + get { + object obj = ResourceManager.GetObject("StopButton", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/BizHawk.Client.EmuHawk/Properties/Resources.resx b/BizHawk.Client.EmuHawk/Properties/Resources.resx index 1876bfb3b7..610b6c155b 100644 --- a/BizHawk.Client.EmuHawk/Properties/Resources.resx +++ b/BizHawk.Client.EmuHawk/Properties/Resources.resx @@ -1563,4 +1563,7 @@ ..\Resources\MoveTop.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\images\StopButton.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/movie/PlayMovie.Designer.cs b/BizHawk.Client.EmuHawk/movie/PlayMovie.Designer.cs index 8afcc7d618..3ccf267f64 100644 --- a/BizHawk.Client.EmuHawk/movie/PlayMovie.Designer.cs +++ b/BizHawk.Client.EmuHawk/movie/PlayMovie.Designer.cs @@ -49,7 +49,7 @@ this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.StopOnFrameCheckbox = new System.Windows.Forms.CheckBox(); this.StopOnFrameTextBox = new BizHawk.Client.EmuHawk.WatchValueBox(); - this.MovieView = new BizHawk.Client.EmuHawk.VirtualListView(); + this.MovieView = new System.Windows.Forms.ListView(); this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); @@ -269,7 +269,6 @@ this.MovieView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.MovieView.BlazingFast = false; this.MovieView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnHeader1, this.columnHeader2, @@ -279,16 +278,13 @@ this.MovieView.FullRowSelect = true; this.MovieView.GridLines = true; this.MovieView.HideSelection = false; - this.MovieView.ItemCount = 0; + this.MovieView.VirtualListSize = 0; this.MovieView.Location = new System.Drawing.Point(12, 28); this.MovieView.MultiSelect = false; this.MovieView.Name = "MovieView"; - this.MovieView.SelectAllInProgress = false; - this.MovieView.selectedItem = -1; this.MovieView.Size = new System.Drawing.Size(480, 322); this.MovieView.TabIndex = 5; this.MovieView.UseCompatibleStateImageBehavior = false; - this.MovieView.UseCustomBackground = true; this.MovieView.View = System.Windows.Forms.View.Details; this.MovieView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.MovieView_ColumnClick); this.MovieView.SelectedIndexChanged += new System.EventHandler(this.MovieView_SelectedIndexChanged); @@ -381,7 +377,7 @@ private System.Windows.Forms.Button Cancel; private System.Windows.Forms.Button OK; private System.Windows.Forms.Button BrowseMovies; - private VirtualListView MovieView; + private System.Windows.Forms.ListView MovieView; private System.Windows.Forms.ColumnHeader columnHeader1; private System.Windows.Forms.ColumnHeader columnHeader2; private System.Windows.Forms.ColumnHeader columnHeader3; diff --git a/BizHawk.Client.EmuHawk/movie/PlayMovie.cs b/BizHawk.Client.EmuHawk/movie/PlayMovie.cs index b99913aeab..7a3169b96f 100644 --- a/BizHawk.Client.EmuHawk/movie/PlayMovie.cs +++ b/BizHawk.Client.EmuHawk/movie/PlayMovie.cs @@ -27,7 +27,7 @@ namespace BizHawk.Client.EmuHawk public PlayMovie() { InitializeComponent(); - MovieView.QueryItemText += MovieView_QueryItemText; + MovieView.RetrieveVirtualItem += MovieView_QueryItemText; MovieView.VirtualMode = true; _sortReverse = false; _sortedCol = ""; @@ -45,28 +45,13 @@ namespace BizHawk.Client.EmuHawk TurboCheckbox.Checked = Global.Config.TurboSeek; } - private void MovieView_QueryItemText(int index, int column, out string text) + private void MovieView_QueryItemText(object sender, RetrieveVirtualItemEventArgs e) { - text = ""; - if (column == 0) // File - { - text = Path.GetFileName(_movieList[index].Filename); - } - - if (column == 1) // System - { - text = _movieList[index].SystemID; - } - - if (column == 2) // Game - { - text = _movieList[index].GameName; - } - - if (column == 3) // Time - { - text = PlatformFrameRates.MovieTime(_movieList[index]).ToString(@"hh\:mm\:ss\.fff"); - } + var entry = _movieList[e.ItemIndex]; + e.Item = new ListViewItem(entry.Filename); + e.Item.SubItems.Add(entry.SystemID); + e.Item.SubItems.Add(entry.GameName); + e.Item.SubItems.Add(PlatformFrameRates.MovieTime(entry).ToString(@"hh\:mm\:ss\.fff")); } private void Run() @@ -230,14 +215,13 @@ namespace BizHawk.Client.EmuHawk private void HighlightMovie(int index) { MovieView.SelectedIndices.Clear(); - MovieView.setSelection(index); - MovieView.SelectItem(index, true); + MovieView.Items[index].Selected = true; } private void ScanFiles() { _movieList.Clear(); - MovieView.ItemCount = 0; + MovieView.VirtualListSize = 0; MovieView.Update(); var directory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null); @@ -293,7 +277,7 @@ namespace BizHawk.Client.EmuHawk void RefreshMovieList() { - MovieView.ItemCount = _movieList.Count; + MovieView.VirtualListSize = _movieList.Count; UpdateList(); } @@ -403,7 +387,7 @@ namespace BizHawk.Client.EmuHawk OK.Enabled = true; var firstIndex = MovieView.SelectedIndices[0]; - MovieView.ensureVisible(firstIndex); + MovieView.EnsureVisible(firstIndex); foreach (var kvp in _movieList[firstIndex].HeaderEntries) { @@ -593,8 +577,7 @@ namespace BizHawk.Client.EmuHawk if (index.HasValue) { MovieView.SelectedIndices.Clear(); - MovieView.setSelection(index.Value); - MovieView.SelectItem(index.Value, true); + MovieView.Items[index.Value].Selected = true; } } } diff --git a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.Designer.cs b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.Designer.cs index 63fce6be5a..f5d56cbd24 100644 --- a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.Designer.cs @@ -30,14 +30,7 @@ { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Cheats)); - this.CheatListView = new BizHawk.Client.EmuHawk.VirtualListView(); - this.CheatName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.Address = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.Value = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.Compare = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.ComparisonType = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.On = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.Domain = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.CheatListView = new InputRoll(); this.CheatsContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); this.ToggleContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.RemoveContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -102,35 +95,22 @@ // CheatListView // this.CheatListView.AllowColumnReorder = true; + this.CheatListView.AllowColumnResize = true; + this.CheatListView.MultiSelect = true; this.CheatListView.AllowDrop = true; this.CheatListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.CheatListView.AutoArrange = false; - this.CheatListView.BlazingFast = false; - this.CheatListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.CheatName, - this.Address, - this.Value, - this.Compare, - this.ComparisonType, - this.On, - this.Domain}); this.CheatListView.ContextMenuStrip = this.CheatsContextMenu; this.CheatListView.FullRowSelect = true; this.CheatListView.GridLines = true; - this.CheatListView.HideSelection = false; - this.CheatListView.ItemCount = 0; + this.CheatListView.RowCount = 0; this.CheatListView.Location = new System.Drawing.Point(12, 72); this.CheatListView.Name = "CheatListView"; - this.CheatListView.SelectAllInProgress = false; - this.CheatListView.selectedItem = -1; this.CheatListView.Size = new System.Drawing.Size(414, 321); this.CheatListView.TabIndex = 1; - this.CheatListView.UseCompatibleStateImageBehavior = false; this.CheatListView.UseCustomBackground = true; - this.CheatListView.View = System.Windows.Forms.View.Details; - this.CheatListView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.CheatListView_ColumnClick); + this.CheatListView.ColumnClick += new BizHawk.Client.EmuHawk.InputRoll.ColumnClickEventHandler(this.CheatListView_ColumnClick); this.CheatListView.SelectedIndexChanged += new System.EventHandler(this.CheatListView_SelectedIndexChanged); this.CheatListView.Click += new System.EventHandler(this.CheatListView_Click); this.CheatListView.DragDrop += new System.Windows.Forms.DragEventHandler(this.NewCheatForm_DragDrop); @@ -138,41 +118,6 @@ this.CheatListView.DoubleClick += new System.EventHandler(this.CheatListView_DoubleClick); this.CheatListView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.CheatListView_KeyDown); // - // CheatName - // - this.CheatName.Text = "Name"; - this.CheatName.Width = 104; - // - // Address - // - this.Address.Text = "Address"; - this.Address.Width = 52; - // - // Value - // - this.Value.Text = "Value"; - this.Value.Width = 40; - // - // Compare - // - this.Compare.Text = "Compare"; - // - // ComparisonType - // - this.ComparisonType.Text = "Comparison Type"; - this.ComparisonType.Width = 194; - // - // On - // - this.On.Text = "On"; - this.On.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - this.On.Width = 40; - // - // Domain - // - this.Domain.Text = "Domain"; - this.Domain.Width = 75; - // // CheatsContextMenu // this.CheatsContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -693,14 +638,7 @@ #endregion - private VirtualListView CheatListView; - private System.Windows.Forms.ColumnHeader CheatName; - private System.Windows.Forms.ColumnHeader Address; - private System.Windows.Forms.ColumnHeader Value; - private System.Windows.Forms.ColumnHeader ComparisonType; - private System.Windows.Forms.ColumnHeader Compare; - private System.Windows.Forms.ColumnHeader On; - private System.Windows.Forms.ColumnHeader Domain; + private InputRoll CheatListView; private MenuStripEx CheatsMenu; private System.Windows.Forms.ToolStripMenuItem FileSubMenu; private System.Windows.Forms.ToolStripMenuItem NewMenuItem; diff --git a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs index ef614a8e74..afb412e6f0 100644 --- a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs +++ b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs @@ -43,7 +43,6 @@ namespace BizHawk.Client.EmuHawk CheatListView.QueryItemText += CheatListView_QueryItemText; CheatListView.QueryItemBkColor += CheatListView_QueryItemBkColor; - CheatListView.VirtualMode = true; _sortedColumn = ""; _sortReverse = false; @@ -80,7 +79,7 @@ namespace BizHawk.Client.EmuHawk /// public void UpdateDialog() { - CheatListView.ItemCount = Global.CheatList.Count; + CheatListView.RowCount = Global.CheatList.Count; TotalLabel.Text = $"{Global.CheatList.CheatCount} {(Global.CheatList.CheatCount == 1 ? "cheat" : "cheats")} {Global.CheatList.ActiveCount} active"; } @@ -150,21 +149,36 @@ namespace BizHawk.Client.EmuHawk private void Cheats_Load(object sender, EventArgs e) { + // Hack for previous config settings + if (Settings.Columns.Any(c => string.IsNullOrWhiteSpace(c.Text))) + { + Settings = new CheatsSettings(); + } + TopMost = Settings.TopMost; CheatEditor.MemoryDomains = Core; LoadConfigSettings(); + CheatsMenu.Items.Add(CheatListView.ToColumnsMenu(ColumnToggleCallback)); ToggleGameGenieButton(); CheatEditor.SetAddEvent(AddCheat); CheatEditor.SetEditEvent(EditCheat); UpdateDialog(); + } - CheatsMenu.Items.Add(Settings.Columns.GenerateColumnsMenu(ColumnToggleCallback)); + private void SetColumns() + { + foreach (var column in Settings.Columns) + { + if (CheatListView.AllColumns[column.Name] == null) + { + CheatListView.AllColumns.Add(column); + } + } } private void ColumnToggleCallback() { - SaveColumnInfo(CheatListView, Settings.Columns); - LoadColumnInfo(CheatListView, Settings.Columns); + Settings.Columns = CheatListView.AllColumns; } private void ToggleGameGenieButton() @@ -195,7 +209,7 @@ namespace BizHawk.Client.EmuHawk private void SaveConfigSettings() { - SaveColumnInfo(CheatListView, Settings.Columns); + Settings.Columns =CheatListView.AllColumns; if (WindowState == FormWindowState.Normal) { @@ -221,10 +235,11 @@ namespace BizHawk.Client.EmuHawk Size = Settings.WindowSize; } - LoadColumnInfo(CheatListView, Settings.Columns); + CheatListView.AllColumns.Clear(); + SetColumns(); } - private void CheatListView_QueryItemText(int index, int column, out string text) + private void CheatListView_QueryItemText(int index, InputRoll.RollColumn column, out string text, ref int offsetX, ref int offsetY) { text = ""; if (index >= Global.CheatList.Count || Global.CheatList[index].IsSeparator) @@ -232,7 +247,7 @@ namespace BizHawk.Client.EmuHawk return; } - var columnName = CheatListView.Columns[column].Name; + var columnName = column.Name; switch (columnName) { @@ -296,7 +311,7 @@ namespace BizHawk.Client.EmuHawk } } - private void CheatListView_QueryItemBkColor(int index, int column, ref Color color) + private void CheatListView_QueryItemBkColor(int index, InputRoll.RollColumn column, ref Color color) { if (index < Global.CheatList.Count) { @@ -311,7 +326,7 @@ namespace BizHawk.Client.EmuHawk } } - private IEnumerable SelectedIndices => CheatListView.SelectedIndices.Cast(); + private IEnumerable SelectedIndices => CheatListView.SelectedRows; private IEnumerable SelectedItems { @@ -325,19 +340,16 @@ namespace BizHawk.Client.EmuHawk private void DoSelectedIndexChange() { - if (!CheatListView.SelectAllInProgress) + if (SelectedCheats.Any()) { - if (SelectedCheats.Any()) - { - var cheat = SelectedCheats.First(); - CheatEditor.SetCheat(cheat); - CheatGroupBox.Text = $"Editing Cheat {cheat.Name} - {cheat.AddressStr}"; - } - else - { - CheatEditor.ClearForm(); - CheatGroupBox.Text = "New Cheat"; - } + var cheat = SelectedCheats.First(); + CheatEditor.SetCheat(cheat); + CheatGroupBox.Text = $"Editing Cheat {cheat.Name} - {cheat.AddressStr}"; + } + else + { + CheatEditor.ClearForm(); + CheatGroupBox.Text = "New Cheat"; } } @@ -451,7 +463,7 @@ namespace BizHawk.Client.EmuHawk Global.CheatList.Remove(item); } - CheatListView.SelectedIndices.Clear(); + CheatListView.DeselectAll(); UpdateDialog(); } } @@ -486,12 +498,12 @@ namespace BizHawk.Client.EmuHawk Global.CheatList.Insert(index - 1, cheat); } - var newindices = indices.Select(t => t - 1); + var newIndices = indices.Select(t => t - 1); - CheatListView.SelectedIndices.Clear(); - foreach (var newi in newindices) + CheatListView.DeselectAll(); + foreach (var index in newIndices) { - CheatListView.SelectItem(newi, true); + CheatListView.SelectRow(index, true); } UpdateMessageLabel(); @@ -515,12 +527,12 @@ namespace BizHawk.Client.EmuHawk UpdateMessageLabel(); - var newindices = indices.Select(t => t + 1); + var newIndices = indices.Select(t => t + 1); - CheatListView.SelectedIndices.Clear(); - foreach (var newi in newindices) + CheatListView.DeselectAll(); + foreach (var index in newIndices) { - CheatListView.SelectItem(newi, true); + CheatListView.SelectRow(index, true); } UpdateDialog(); @@ -611,14 +623,15 @@ namespace BizHawk.Client.EmuHawk .OfType() .First(x => x.Name == "GeneratedColumnsSubMenu")); - CheatsMenu.Items.Add(Settings.Columns.GenerateColumnsMenu(ColumnToggleCallback)); + CheatsMenu.Items.Add(CheatListView.ToColumnsMenu(ColumnToggleCallback)); Global.Config.DisableCheatsOnLoad = false; Global.Config.LoadCheatFileByGame = true; Global.Config.CheatsAutoSaveOnClose = true; RefreshFloatingWindowControl(Settings.FloatingWindow); - LoadColumnInfo(CheatListView, Settings.Columns); + CheatListView.AllColumns.Clear(); + SetColumns(); } #endregion @@ -651,9 +664,9 @@ namespace BizHawk.Client.EmuHawk DoSelectedIndexChange(); } - private void CheatListView_ColumnClick(object sender, ColumnClickEventArgs e) + private void CheatListView_ColumnClick(object sender, InputRoll.ColumnClickEventArgs e) { - var column = CheatListView.Columns[e.Column]; + var column = e.Column; if (column.Name != _sortedColumn) { _sortReverse = false; @@ -723,22 +736,21 @@ namespace BizHawk.Client.EmuHawk { public CheatsSettings() { - Columns = new ColumnList + Columns = new List { - new Column { Name = NameColumn, Visible = true, Index = 0, Width = 128 }, - new Column { Name = AddressColumn, Visible = true, Index = 1, Width = 60 }, - new Column { Name = ValueColumn, Visible = true, Index = 2, Width = 59 }, - new Column { Name = CompareColumn, Visible = true, Index = 3, Width = 59 }, - new Column { Name = ComparisonTypeColumn, Visible = true, Index = 4, Width = 60 }, - new Column { Name = OnColumn, Visible = false, Index = 5, Width = 28 }, - new Column { Name = DomainColumn, Visible = true, Index = 6, Width = 55 }, - new Column { Name = SizeColumn, Visible = true, Index = 7, Width = 55 }, - new Column { Name = EndianColumn, Visible = false, Index = 8, Width = 55 }, - new Column { Name = TypeColumn, Visible = false, Index = 9, Width = 55 } + new InputRoll.RollColumn { Text = "Names", Name = NameColumn, Visible = true, Width = 128, Type = InputRoll.RollColumn.InputType.Text }, + new InputRoll.RollColumn { Text = "Address", Name = AddressColumn, Visible = true, Width = 60, Type = InputRoll.RollColumn.InputType.Text }, + new InputRoll.RollColumn { Text = "Value", Name = ValueColumn, Visible = true, Width = 59, Type = InputRoll.RollColumn.InputType.Text }, + new InputRoll.RollColumn { Text = "Compare", Name = CompareColumn, Visible = true, Width = 63, Type = InputRoll.RollColumn.InputType.Text }, + new InputRoll.RollColumn { Text = "Compare Type", Name = ComparisonTypeColumn, Visible = true, Width = 98, Type = InputRoll.RollColumn.InputType.Text }, + new InputRoll.RollColumn { Text = "On", Name = OnColumn, Visible = false, Width = 28, Type = InputRoll.RollColumn.InputType.Text }, + new InputRoll.RollColumn { Text = "Size", Name = SizeColumn, Visible = true, Width = 55, Type = InputRoll.RollColumn.InputType.Text }, + new InputRoll.RollColumn { Text = "Endian", Name = EndianColumn, Visible = false, Width = 55, Type = InputRoll.RollColumn.InputType.Text }, + new InputRoll.RollColumn { Text = "Display Type", Name = TypeColumn, Visible = false, Width = 88, Type = InputRoll.RollColumn.InputType.Text } }; } - public ColumnList Columns { get; set; } + public List Columns { get; set; } } } } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.Designer.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.Designer.cs index 01816fd1c6..fb7bfd1ac9 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.Designer.cs @@ -104,10 +104,7 @@ this.InsertSeparatorToolbarItem = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator(); this.EraseToolbarItem = new System.Windows.Forms.ToolStripButton(); - this.LuaListView = new BizHawk.Client.EmuHawk.VirtualListView(); - this.Script = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.PathName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.imageList1 = new System.Windows.Forms.ImageList(this.components); + this.LuaListView = new InputRoll(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.CopyContextItem = new System.Windows.Forms.ToolStripMenuItem(); this.ScriptListContextMenu.SuspendLayout(); @@ -805,46 +802,20 @@ this.LuaListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.LuaListView.BlazingFast = false; - this.LuaListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.Script, - this.PathName}); + this.LuaListView.AllowColumnResize = true; + this.LuaListView.AllowColumnReorder = false; this.LuaListView.ContextMenuStrip = this.ScriptListContextMenu; this.LuaListView.FullRowSelect = true; this.LuaListView.GridLines = true; - this.LuaListView.HideSelection = false; - this.LuaListView.ItemCount = 0; + this.LuaListView.RowCount = 0; this.LuaListView.Location = new System.Drawing.Point(4, 21); this.LuaListView.Name = "LuaListView"; - this.LuaListView.SelectAllInProgress = false; - this.LuaListView.selectedItem = -1; this.LuaListView.Size = new System.Drawing.Size(273, 271); - this.LuaListView.SmallImageList = this.imageList1; this.LuaListView.TabIndex = 0; - this.LuaListView.UseCompatibleStateImageBehavior = false; this.LuaListView.UseCustomBackground = true; - this.LuaListView.View = System.Windows.Forms.View.Details; - this.LuaListView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.LuaListView_ColumnClick); - this.LuaListView.ItemActivate += new System.EventHandler(this.LuaListView_ItemActivate); + this.LuaListView.ColumnClick += new BizHawk.Client.EmuHawk.InputRoll.ColumnClickEventHandler(this.LuaListView_ColumnClick); this.LuaListView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.LuaListView_KeyDown); - // - // Script - // - this.Script.Text = "Script"; - this.Script.Width = 92; - // - // PathName - // - this.PathName.Text = "Path"; - this.PathName.Width = 195; - // - // imageList1 - // - this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream"))); - this.imageList1.TransparentColor = System.Drawing.Color.Transparent; - this.imageList1.Images.SetKeyName(0, "StopButton.png"); - this.imageList1.Images.SetKeyName(1, "PlayButton.png"); - this.imageList1.Images.SetKeyName(2, "Pause.png"); + this.LuaListView.DoubleClick += new System.EventHandler(this.LuaListView_DoubleClick); // // splitContainer1 // @@ -910,8 +881,7 @@ #endregion - private VirtualListView LuaListView; - private System.Windows.Forms.ColumnHeader PathName; + private InputRoll LuaListView; private MenuStripEx menuStrip1; private System.Windows.Forms.ToolStripMenuItem FileSubMenu; private System.Windows.Forms.ToolStripMenuItem SaveSessionMenuItem; @@ -921,7 +891,6 @@ private System.Windows.Forms.ToolStripMenuItem ScriptSubMenu; private System.Windows.Forms.ToolStripMenuItem EditScriptMenuItem; private System.Windows.Forms.ToolStripMenuItem ToggleScriptMenuItem; - public System.Windows.Forms.ColumnHeader Script; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.ToolStripMenuItem NewSessionMenuItem; private System.Windows.Forms.ToolStripMenuItem SettingsSubMenu; @@ -980,7 +949,6 @@ private System.Windows.Forms.ToolStripMenuItem DuplicateScriptMenuItem; private System.Windows.Forms.TextBox InputBox; private System.Windows.Forms.SplitContainer splitContainer1; - private System.Windows.Forms.ImageList imageList1; private System.Windows.Forms.ToolStripMenuItem ReturnAllIfNoneSelectedMenuItem; private System.Windows.Forms.ToolStripMenuItem RemoveRegisteredFunctionsOnToggleMenuItem; private System.Windows.Forms.ToolStripMenuItem ReloadWhenScriptFileChangesMenuItem; diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index 63ff408725..fed33dd0b8 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -13,11 +13,16 @@ using BizHawk.Client.EmuHawk.ToolExtensions; using BizHawk.Client.EmuHawk.WinFormExtensions; using BizHawk.Common; using BizHawk.Emulation.Common; +using NLua; namespace BizHawk.Client.EmuHawk { public partial class LuaConsole : ToolFormBase, IToolFormAutoConfig { + private const string IconColumnName = "Icon"; + private const string ScriptColumnName = "Script"; + private const string PathColumnName = "PathName"; + [RequiredService] private IEmulator Emulator { get; set; } @@ -33,14 +38,15 @@ namespace BizHawk.Client.EmuHawk { public LuaConsoleSettings() { - Columns = new ToolDialogSettings.ColumnList + Columns = new List { - new ToolDialogSettings.Column { Name = "Script", Visible = true, Index = 0, Width = 92 }, - new ToolDialogSettings.Column { Name = "PathName", Visible = true, Index = 0, Width = 195 } + new InputRoll.RollColumn { Name = IconColumnName, Text = " ", Visible = true, Width = 22, Type = InputRoll.RollColumn.InputType.Image }, + new InputRoll.RollColumn { Name = ScriptColumnName, Text = "Script", Visible = true, Width = 92, Type = InputRoll.RollColumn.InputType.Text }, + new InputRoll.RollColumn { Name = PathColumnName, Text = "Path", Visible = true, Width = 300, Type = InputRoll.RollColumn.InputType.Text } }; } - public ToolDialogSettings.ColumnList Columns { get; set; } + public List Columns { get; set; } } [ConfigPersist] @@ -58,7 +64,7 @@ namespace BizHawk.Client.EmuHawk { if (AskSaveChanges()) { - SaveColumnInfo(LuaListView, Settings.Columns); + Settings.Columns = LuaListView.AllColumns; GlobalWin.DisplayManager.ClearLuaSurfaces(); @@ -85,9 +91,7 @@ namespace BizHawk.Client.EmuHawk LuaListView.QueryItemText += LuaListView_QueryItemText; LuaListView.QueryItemBkColor += LuaListView_QueryItemBkColor; - LuaListView.QueryItemImage += LuaListView_QueryItemImage; - LuaListView.QueryItemIndent += LuaListView_QueryItemIndent; - LuaListView.VirtualMode = true; + LuaListView.QueryItemIcon += LuaListView_QueryItemImage; // this is bad, in case we ever have more than one gui part running lua.. not sure how much other badness there is like that LuaSandbox.DefaultLogger = ConsoleLog; @@ -99,7 +103,7 @@ namespace BizHawk.Client.EmuHawk private IEnumerable SelectedItems { - get { return LuaListView.SelectedIndices().Select(index => LuaImp.ScriptList[index]); } + get { return LuaListView.SelectedRows.Select(index => LuaImp.ScriptList[index]); } } private IEnumerable SelectedFiles @@ -129,6 +133,12 @@ namespace BizHawk.Client.EmuHawk private void LuaConsole_Load(object sender, EventArgs e) { + // Hack for previous config settings + if (Settings.Columns.Any(c => c.Text == null)) + { + Settings = new LuaConsoleSettings(); + } + LuaImp.ScriptList.ChangedCallback = SessionChangedCallback; LuaImp.ScriptList.LoadCallback = ClearOutputWindow; @@ -144,7 +154,8 @@ namespace BizHawk.Client.EmuHawk } } - LoadColumnInfo(LuaListView, Settings.Columns); + LuaListView.AllColumns.Clear(); + SetColumns(); } public void Restart() @@ -217,10 +228,21 @@ namespace BizHawk.Client.EmuHawk private readonly List _watches = new List(); + private void SetColumns() + { + foreach (var column in Settings.Columns) + { + if (LuaListView.AllColumns[column.Name] == null) + { + LuaListView.AllColumns.Add(column); + } + } + } + private void AddFileWatches() { _watches.Clear(); - foreach (var item in LuaImp.ScriptList) + foreach (var item in LuaImp.ScriptList.Where(s => !s.IsSeparator)) { var processedPath = PathManager.TryMakeRelative(item.Path); string pathToLoad = ProcessPath(processedPath); @@ -263,7 +285,7 @@ namespace BizHawk.Client.EmuHawk var luaFile = new LuaFile("", processedPath); LuaImp.ScriptList.Add(luaFile); - LuaListView.ItemCount = LuaImp.ScriptList.Count; + LuaListView.RowCount = LuaImp.ScriptList.Count; Global.Config.RecentLua.Add(processedPath); if (!Global.Config.DisableLuaScriptsOnLoad) @@ -297,7 +319,7 @@ namespace BizHawk.Client.EmuHawk private void UpdateDialog() { - LuaListView.ItemCount = LuaImp.ScriptList.Count; + LuaListView.RowCount = LuaImp.ScriptList.Count; LuaListView.Refresh(); UpdateNumberOfScripts(); UpdateRegisteredFunctionsDialog(); @@ -305,7 +327,7 @@ namespace BizHawk.Client.EmuHawk private void RunLuaScripts() { - foreach (var file in LuaImp.ScriptList) + foreach (var file in LuaImp.ScriptList.Where(s => !s.IsSeparator)) { if (!file.Enabled && file.Thread == null) { @@ -340,62 +362,62 @@ namespace BizHawk.Client.EmuHawk Path.GetFileName(LuaImp.ScriptList.Filename); } - private void LuaListView_QueryItemImage(int item, int subItem, out int imageIndex) + private void LuaListView_QueryItemImage(int index, InputRoll.RollColumn column, ref Bitmap bitmap, ref int offsetX, ref int offsetY) { - imageIndex = -1; - if (subItem != 0) + if (column.Name != IconColumnName) { return; } - if (LuaImp.ScriptList[item].Paused) + if (LuaImp.ScriptList[index].IsSeparator) { - imageIndex = 2; + return; } - else if (LuaImp.ScriptList[item].Enabled) + + if (LuaImp.ScriptList[index].Paused) { - imageIndex = 1; + bitmap = Properties.Resources.Pause; + } + else if (LuaImp.ScriptList[index].Enabled) + { + bitmap = Properties.Resources.ts_h_arrow_green; } else { - imageIndex = 0; + bitmap = Properties.Resources.StopButton; } } - private void LuaListView_QueryItemIndent(int item, out int itemIndent) + private void LuaListView_QueryItemBkColor(int index, InputRoll.RollColumn column, ref Color color) { - itemIndent = 0; - } - - private void LuaListView_QueryItemBkColor(int index, int column, ref Color color) - { - if (column == 0) + if (LuaImp.ScriptList[index].IsSeparator) { - if (LuaImp.ScriptList[index].IsSeparator) - { - color = BackColor; - } - else if (LuaImp.ScriptList[index].Enabled && !LuaImp.ScriptList[index].Paused) - { - color = Color.LightCyan; - } - else if (LuaImp.ScriptList[index].Enabled && LuaImp.ScriptList[index].Paused) - { - color = Color.LightPink; - } + color = BackColor; + } + else if (LuaImp.ScriptList[index].Enabled && !LuaImp.ScriptList[index].Paused) + { + color = Color.LightCyan; + } + else if (LuaImp.ScriptList[index].Enabled && LuaImp.ScriptList[index].Paused) + { + color = Color.LightPink; } - - UpdateNumberOfScripts(); } - private void LuaListView_QueryItemText(int index, int column, out string text) + private void LuaListView_QueryItemText(int index, InputRoll.RollColumn column, out string text, ref int offsetX, ref int offsetY) { text = ""; - if (column == 0) + + if (LuaImp.ScriptList[index].IsSeparator) + { + return; + } + + if (column.Name == ScriptColumnName) { text = Path.GetFileNameWithoutExtension(LuaImp.ScriptList[index].Path); // TODO: how about allow the user to name scripts? } - else if (column == 1) + else if (column.Name == PathColumnName) { text = DressUpRelative(LuaImp.ScriptList[index].Path); } @@ -437,9 +459,9 @@ namespace BizHawk.Client.EmuHawk private void UpdateNumberOfScripts() { var message = ""; - var total = SelectedFiles.Count(); - var active = LuaImp.ScriptList.Count(file => file.Enabled); - var paused = LuaImp.ScriptList.Count(file => file.Enabled && file.Paused); + var total = LuaImp.ScriptList.Count(file => !file.IsSeparator); + var active = LuaImp.ScriptList.Count(file => !file.IsSeparator && file.Enabled); + var paused = LuaImp.ScriptList.Count(file => !file.IsSeparator && file.Enabled && file.Paused); if (total == 1) { @@ -780,7 +802,7 @@ namespace BizHawk.Client.EmuHawk DuplicateScriptMenuItem.Enabled = MoveUpMenuItem.Enabled = MoveDownMenuItem.Enabled = - LuaListView.SelectedIndices().Any(); + LuaListView.SelectedRows.Any(); SelectAllMenuItem.Enabled = LuaImp.ScriptList.Any(); StopAllScriptsMenuItem.Enabled = LuaImp.ScriptList.Any(script => script.Enabled); @@ -946,7 +968,7 @@ namespace BizHawk.Client.EmuHawk private void DuplicateScriptMenuItem_Click(object sender, EventArgs e) { - if (LuaListView.SelectedIndices().Any()) + if (LuaListView.SelectedRows.Any()) { var script = SelectedFiles.First(); @@ -976,7 +998,7 @@ namespace BizHawk.Client.EmuHawk private void InsertSeparatorMenuItem_Click(object sender, EventArgs e) { - var indices = LuaListView.SelectedIndices().ToList(); + var indices = LuaListView.SelectedRows.ToList(); if (indices.Any() && indices.Last() < LuaImp.ScriptList.Count) { LuaImp.ScriptList.Insert(indices.Last(), LuaFile.SeparatorInstance); @@ -991,7 +1013,7 @@ namespace BizHawk.Client.EmuHawk private void MoveUpMenuItem_Click(object sender, EventArgs e) { - var indices = LuaListView.SelectedIndices().ToList(); + var indices = LuaListView.SelectedRows.ToList(); if (indices.Count == 0 || indices[0] == 0) { return; @@ -1006,10 +1028,10 @@ namespace BizHawk.Client.EmuHawk var newIndices = indices.Select(t => t - 1); - LuaListView.SelectedIndices.Clear(); + LuaListView.DeselectAll(); foreach (var i in newIndices) { - LuaListView.SelectItem(i, true); + LuaListView.SelectRow(i, true); } UpdateDialog(); @@ -1017,7 +1039,7 @@ namespace BizHawk.Client.EmuHawk private void MoveDownMenuItem_Click(object sender, EventArgs e) { - var indices = LuaListView.SelectedIndices().ToList(); + var indices = LuaListView.SelectedRows.ToList(); if (indices.Count == 0 || indices.Last() == LuaImp.ScriptList.Count - 1) { return; @@ -1032,10 +1054,10 @@ namespace BizHawk.Client.EmuHawk var newIndices = indices.Select(t => t + 1); - LuaListView.SelectedIndices.Clear(); + LuaListView.DeselectAll(); foreach (var i in newIndices) { - LuaListView.SelectItem(i, true); + LuaListView.SelectRow(i, true); } UpdateDialog(); @@ -1280,11 +1302,6 @@ namespace BizHawk.Client.EmuHawk } } - private void LuaListView_ItemActivate(object sender, EventArgs e) - { - ToggleScriptMenuItem_Click(sender, e); - } - private void OutputBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.F12 && !e.Control && !e.Alt && !e.Shift) // F12 @@ -1296,9 +1313,9 @@ namespace BizHawk.Client.EmuHawk /// /// Sorts the column Ascending on the first click and Descending on the second click. /// - private void LuaListView_ColumnClick(object sender, ColumnClickEventArgs e) + private void LuaListView_ColumnClick(object sender, InputRoll.ColumnClickEventArgs e) { - var columnToSort = LuaListView.Columns[e.Column].Text; + var columnToSort = e.Column.Name; var luaListTemp = new List(); if (columnToSort != _lastColumnSorted) { @@ -1438,5 +1455,28 @@ namespace BizHawk.Client.EmuHawk } #endregion + + private void LuaListView_DoubleClick(object sender, EventArgs e) + { + var index = LuaListView.CurrentCell?.RowIndex; + if (index < LuaImp.ScriptList.Count) + { + var file = LuaImp.ScriptList[index.Value]; + if (!file.IsSeparator) + { + file.Toggle(); + UpdateDialog(); + } + } + } + + [RestoreDefaults] + private void RestoreDefaults() + { + Settings = new LuaConsoleSettings(); + LuaListView.AllColumns.Clear(); + SetColumns(); + UpdateDialog(); + } } } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.resx b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.resx index 7d82bb08eb..4b0fdcdf07 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.resx +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.resx @@ -144,78 +144,6 @@ S+GOLQu6U6BFjPvqKOP1AYw88WOoZif9DgmfLVtxaj1RSLdwNvrkPCA3M54KqxrnvRia9MKcGrUrqFOt 5H7qKsqT1mGO9+Lqhc2ELdw+U/r0i+gVZ8hMiCDx3DHORwZyKnQ/hw/uYt9uCTskPvh6e7Fp41rWr/Fg g6eHO+A/lyD8ARfG3mk9fv1YAAAAAElFTkSuQmCC - - - - 489, 17 - - - - AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w - LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 - ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABi - DgAAAk1TRnQBSQFMAgEBAwEAAVgBAAFYAQABEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA - AwABEAMAAQEBAAEgBgABECoAAWUBWwFdAeUBsgG0AdIB/wG7Ab4B1wH/AWYCXAHnMAABZQFdAVsB5QGy - AdIBtgH/AbsB1wG+Af8BZgJcAecwAAFnAlsB5QHSAb4BsgH/AdcBxQG7Af8BaQJcAedoAAFoAVkBbQH1 - ATUBPAGXAf8BAQEMAYcB/wECAQwBhwH/AQABCwGHAf8BBwERAYgB/wEKARQBiQH/AWkBXgGEAfkgAAFo - AW0BWQH1ATUBlwFBAf8BAQGHARAB/wECAYcBEQH/AQABhwEOAf8BBwGIARUB/wEKAYkBGAH/AWkBhAFe - AfkgAAF+AWABWQH1AZcBVwE1Af8BhwEvAQEB/wGHATABAgH/AYcBLgEAAf8BiAEzAQcB/wGJATYBCgH/ - AYsBaAFaAflcAAEwATgBmAH/AS0BNQGYAf8BsAGyAcsB/wHaAdsB2gH/AtEB1QH/AcsBzAHSAf8BxAHH - Ac4B/wFUAVoBpQH/AUcBRQFqAfkBJQEuAY8B/xgAASIBkgEuAf8BLQGYATkB/wGwAcsBswH/AdsC2gH/ - AdEB1QHSAf8BywHSAcsB/wHFAc4BxAH/AVQBpQFdAf8BRwFqAUYB+QElAY8BMAH/GAABkgFIASIB/wGY - AVIBLQH/AcsBugGwAf8C2gHbAf8B1QHTAdEB/wHSAc0BywH/Ac4BxgHEAf8BpQFvAVQB/wGEAVwBQQH5 - AY8BSAElAf9UAAJAAY0B/QFiAlgB4wL+Af0B/wH+Af0B9QH/AvcB8wH/Ae8C7gH/Au0B6wH/AdkC2wH/ - AeMB5AHiAf8CwAHMAf8BZgFYAV0B7QFMAUkBeQH7EAABQAGNAUAB/QFiAlgB4wH/Af4C/wH+AfUB/QH/ - AfcB8wH2Af8C7gHvAf8B7QHrAe0B/wLbAdkB/wHkAeIB4wH/AcABzAHCAf8BZgFdAVgB7QFMAXkBSwH7 - EAABkwFGAUAB/QFkAlgB4wH+A/8B9QH7Af4B/wHzAfUB9wH/Ae4B7wHuAf8B6wHsAe0B/wHbAdkB2gH/ - AuIB5AH/AcwBxQHAAf8BagFZAVcB7QGGAVkBQwH7TAABagFdAWwB8wFqAVkBYAHrBf8B/gH9F/8B/gH/ - AfAB7wHwAf8BzwHQAdYB/wFjAVQBXQHtAWQBWAFiAe8IAAFqAWwBXQHzAWoBYAFZAesF/wH9Bv8B4wHw - AeMB/wGcAc0BnAr/Af4C/wHvAvAB/wHPAdYBzwH/AWMBXQFUAe0BZAFiAVgB7wgAAXsBXwFdAfMBbgFg - AVkB6wT/Af0X/wH+A/8C4wHgAf8BzwHJAccB/wFpAVgBUwHtAWwCWAHvSAABagFeAYkB+QP+Jf8B8AHy - AfAB/wLGAc0B/wFHAUEBagH5CAABagGJAV4B+RD/AdwB7QHcAf8BDQF1AQ0B/wGDAcEBgw3/AfIB8QHw - Af8BxwHOAcgB/wFHAWoBQQH5CAABjAFqAV4B+Qz/AeEBzQG+Af8BvgGSAY0B/wH3AfEB7wH/AfsB+AH3 - Af8BwQGYAY8B/wHqAdoB0QX/AeUB4gHmAf8BzgHKAccB/wGAAVcBQQH5RAABbwFfAXAB8wFqAV0BYwHt - CP8C9QH7Af8BaQFlAdQB/wGhAZ8B5wH/AaMBoQHmAf8BogGhAeUB/wGUAZEB4QH/AZ4BnAHmBf8B+QH4 - AfcB/wHnAeQB3gH/AVkBVwFqAfUBXQFZAYkB+wFvAXABXwHzAWoBYwFdAe0Q/wHkAfEB5AH/AQABcQEA - Af8BDQF3AQ0B/wGcAc4BnAn/AfkB9wH5Af8B5gHeAecB/wFZAWoBWQH1AV0BiQFZAfsBgAFoAV8B8wFx - Al0B7Qz/Aa4BcgFQAf8BVQIAAf8B+AH1AfIB/wH6AfcB9QH/AVUCAAH/AbMBdwFWBf8B8QH0AfUB/wHe - AeYB5wH/AXQBWQFUAfUBkQFfAVQB+0AAAYIBiAHKAf8B0AHSAe0J/wL1AfoB/wE3ATQBuwH/AWMBYAHe - Af8BYAFcAdgB/wFbAVcB0wH/AU8BSgHRAf8BogGhAekF/wL5AfgB/wH8AfsB6gH/AaMBpgG+Af8BPwFG - AaAB/wGCAcoBigH/AdAB7QHUEf8B4gHwAeIB/wEAAXIBAAH/AQABcgEAAf8BDQGEAQ0B/wGYAcwBmAX/ - AfkB+AH5Af8B/AHqAfoB/wGjAb4BpQH/AT8BoAFKAf8BygGcAYIB/wHtAdsB0A3/AboBjAFmAf8BjQEe - AQAC/wL+Af8D/gH/AY0BHQEAAf8BuwGJAWQF/wHyAfQB9QH/AeoB9QH8Af8BvgGsAaMB/wGgAWABPwH/ - QAABcAF2AcIB/wHlAeYB9An/AvcB+wH/AUYBQwHDAf8BcQFvAeMB/wFsAWkB3QH/AWcBZAHYAf8BWwFW - AdMB/wGrAakB6gX/A/kB/wH+AfsB7wH/AbQBtgHFAf8BPQFFAZ8B/wFwAcIBgQH/AeUB9AHnEf8B4gHw - AeIB/wEAAXQBAAH/AQABdgEAAf8BAAFuAQAB/wENAYQBDQH/AfoB/AH6Af8D+QH/Af4B7wH+Af8BtAHF - AbYB/wE9AZ8BSAH/AcIBkwFwAf8B9AHrAeUN/wG5AYwBZwH/AacBNAEHAf8B+wH5AfgB/wH7AfoB+QH/ - AacBNAEHAf8BvQGMAWcF/wP0Af8B7wH6Af4B/wHFAboBtAH/AZ8BXgE9Af9AAAFsAXMBvQH/AtoB7wn/ - AvcB+wH/AUoBRwHHAf8BdwF1AeoB/wFyAXEB4wH/AW8BbQHfAf8BYgFfAdoB/wGtAasB6wX/AvoB+AH/ - Af0B/AHuAf8BnQGgAbsB/wFFAU0BowH/AWwBvQF0Af8B2gHvAd4R/wHiAfAB4gH/AQABdAEAAf8BAAFs - AQAB/wEoAY4BKAH/AeIB8AHiBf8B+gH4AfoB/wH9Ae4B+wH/AZ0BuwGhAf8BRQGjAU4B/wG9AY4BbAH/ - Ae8B4wHaDf8BtwGIAWIB/wHEAUMBIAH/Av0B/AH/AfwB+gH5Af8BxgFGASIB/wHCAY8BbAX/AfIB9QH3 - Af8B7gH3Af0B/wG7AagBnQH/AaMBZAFFAf9AAAFoAVgBYwHvAXMBZAFuAfEI/wL2AfsB/wFHAUMBxQH/ - AXYBdQHrAf8BcgFxAeQB/wFwAW0B4QH/AWABXQHbAf8BqQGnAesF/wL7AfkB/wH7AfwB7gH/AU0BSgGB - AfsBZQFYAWIB7wFoAWMBWAHvAXMBbgFkAfEQ/wHiAfAB4gH/AQABagEAAf8BJAGHASQB/wHnAfMB5wn/ - AfsB+QH7Af8B/AHuAfkB/wFNAYEBTAH7AWUBYgFYAe8BcgFiAVgB7wGAAWUBZAHxDP8BwQGXAXYB/wGk - AToBEgH/Af0B+wH6Af8B/AH6AfkB/wGTATUBCwH/AcwBqQGUBf8B9AH3AfkB/wHuAfUB/AH/AYoBWQFF - AfsBcAJYAe9EAAF3AYEBzwn/AvMB+QH/AUUBQgG5Af8BhwGGAdYB/wGHAYUB1QH/AYcBhQHVAf8BYQFe - AcgB/wFpAWgBzAb/Af4B/AH/As4B1wH/ATUBPQGYAf8IAAF3Ac8BjRH/AdMB6AHTAf8BIAGHASAB/wHi - AfAB4g3/Af4B/AL/Ac4B1wHQAf8BNQGYAT8B/wgAAc8BoQF3Kf8B+wP/AdcB0gHOAf8BmAFWATUB/0gA - AYIBagGQAfkBewFlAXQB8ST/AfwB+wH2Af8BMwE7AZYB/wFlAVgBWwHpCAABggGQAWoB+QF7AXQBbQHx - DP8B+gH8AfoB/wHvAfYB7xH/AfwB9gH8Af8BMwGWAT0B/wFlAVsBWAHpCAABngGBAWoB+QGCAW0BZQHx - JP8B9QH6AfwB/wGWAVQBMwH/AWoCWAHpTAACgwG4Af0BagFdAWIB6Rz/AfIB9QH4Af8CWQFqAfUBaQFZ - AW4B9RAAAYMBuAGIAf0BagFiAV0B6Rz/AfQB+AHyAf8BWQFqAVkB9QFpAW4BWQH1EAABugGdAXEB/QFs - AV8BXQHpHP8B+ALyAf8BdwFZAUsB9QGAAWABWQH1VAABdgFtAZsB+wGJAXcBmQH5AtMB9wH/AfEB8AH7 - Af8B9gH3Av8B9wH4Af0B/wHkAecB8wH/AWUBWAFiAe8BbAFfAWwB8wFrAVkBYAHrGAABdgGbAXkB+wGJ - AZkBhAH5AdMB9wHaAf8B8AH7AfMB/wH2Af8B9wH/AfcB/QH4Af8B5AHzAeQB/wFlAWIBWAHvAmwBXwHz - AWsBYAFZAesYAAGjAYgBZgH7AaUBiwF0AfkB9wHjAdMB/wH7AfYB8AL/AfkB9gH/Af0B+QH3Af8B8wHo - AeQB/wFwAlgB7wF8Al8B8wFxAWABWQHrXAABbgFgAWIB6wGNAZMB1wH/AY4BlAHdAf8BjwGVAeAB/wGN - AZQB2wH/AZoBnwHaAf8BZgJcAeckAAFuAWIBYAHrAY0B1wGWAf8BjgHdAZgB/wGPAeABmQH/AY0B2wGW - Af8BmgHaAaIB/wFmAlwB5yQAAXMCYAHrAdcBqAGNAf8B3QGsAY4B/wHgAa0BjwH/AdsBqQGNAf8B2gGy - AZoB/wFpAlwB51QAAUIBTQE+BwABPgMAASgDAAFAAwABEAMAAQEBAAEBBQABgBcAA/8BAAH8AT8B/AE/ - AfwBPwIAAfABDwHwAQ8B8AEPAgAB4AEHAeABBwHgAQcCAAHAAQMBwAEDAcABAwIAAYABAQGAAQEBgAEB - AgABgAEBAYABAQGAAQEqAAGAAQEBgAEBAYABAQIAAYABAQGAAQEBgAEBAgABwAEDAcABAwHAAQMCAAHg - AQcB4AEHAeABBwIAAfABHwHwAR8B8AEfAgAL diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.Designer.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.Designer.cs index 4805891afc..9c559ab2a4 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.Designer.cs @@ -34,7 +34,7 @@ this.FilterBox = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.ToWikiMarkupButton = new System.Windows.Forms.Button(); - this.FunctionView = new BizHawk.Client.EmuHawk.VirtualListView(); + this.FunctionView = new System.Windows.Forms.ListView(); this.LibraryReturn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.LibraryHead = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.LibraryName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); @@ -96,7 +96,6 @@ this.FunctionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.FunctionView.BlazingFast = false; this.FunctionView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.LibraryReturn, this.LibraryHead, @@ -105,11 +104,9 @@ this.LibraryDescription}); this.FunctionView.FullRowSelect = true; this.FunctionView.GridLines = true; - this.FunctionView.ItemCount = 0; + this.FunctionView.VirtualListSize = 0; this.FunctionView.Location = new System.Drawing.Point(12, 12); this.FunctionView.Name = "FunctionView"; - this.FunctionView.SelectAllInProgress = false; - this.FunctionView.selectedItem = -1; this.FunctionView.Size = new System.Drawing.Size(710, 291); this.FunctionView.TabIndex = 1; this.FunctionView.UseCompatibleStateImageBehavior = false; @@ -170,7 +167,7 @@ private System.Windows.Forms.Button OK; private System.DirectoryServices.DirectoryEntry directoryEntry1; - private VirtualListView FunctionView; + private System.Windows.Forms.ListView FunctionView; private System.Windows.Forms.ColumnHeader LibraryHead; private System.Windows.Forms.ColumnHeader LibraryReturn; private System.Windows.Forms.ColumnHeader LibraryName; diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.cs index 8a0aceb800..0f5772db3b 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.cs @@ -1,12 +1,10 @@ using System; using System.Collections.Generic; -using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using BizHawk.Client.Common; -using BizHawk.Common; namespace BizHawk.Client.EmuHawk { @@ -35,8 +33,7 @@ namespace BizHawk.Client.EmuHawk public LuaFunctionsForm() { InitializeComponent(); - FunctionView.QueryItemText += FunctionView_QueryItemText; - FunctionView.QueryItemBkColor += FunctionView_QueryItemBkColor; + FunctionView.RetrieveVirtualItem += FunctionView_QueryItemText; } private void LuaFunctionList_Load(object sender, EventArgs e) @@ -51,42 +48,14 @@ namespace BizHawk.Client.EmuHawk ToWikiMarkupButton.Visible = VersionInfo.DeveloperBuild; } - private void FunctionView_QueryItemBkColor(int index, int column, ref Color color) + private void FunctionView_QueryItemText(object sender, RetrieveVirtualItemEventArgs e) { - } - - private void FunctionView_QueryItemText(int index, int column, out string text) - { - text = ""; - - try - { - if (_filteredList.Any() && index < _filteredList.Count) - { - switch (column) - { - case 0: - text = _filteredList[index].ReturnType; - break; - case 1: - text = _filteredList[index].Library; - break; - case 2: - text = _filteredList[index].Name; - break; - case 3: - text = _filteredList[index].ParameterList; - break; - case 4: - text = _filteredList[index].Description; - break; - } - } - } - catch - { - /* Eat it*/ - } + var entry = _filteredList[e.ItemIndex]; + e.Item = new ListViewItem(entry.ReturnType); + e.Item.SubItems.Add(entry.Library); + e.Item.SubItems.Add(entry.Name); + e.Item.SubItems.Add(entry.ParameterList); + e.Item.SubItems.Add(entry.Description); } private void OrderColumn(int column) @@ -206,7 +175,12 @@ namespace BizHawk.Client.EmuHawk //FREVBHFYL? private void FunctionView_Copy(object sender, EventArgs e) { - var itm = _filteredList[FunctionView.selectedItem]; + if (FunctionView.SelectedIndices.Count == 0) + { + return; + } + + var itm = _filteredList[FunctionView.SelectedIndices[0]]; var sb = new StringBuilder($"//{itm.Library}.{itm.Name}{itm.ParameterList}"); //comment style not an accident: the 'declaration' is not legal lua, so use of -- to comment it shouldn't suggest it. right? if (itm.Example != null) { @@ -221,7 +195,7 @@ namespace BizHawk.Client.EmuHawk private void UpdateList() { GenerateFilteredList(); - FunctionView.ItemCount = _filteredList.Count; + FunctionView.VirtualListSize = _filteredList.Count; } private void FilterBox_KeyUp(object sender, KeyEventArgs e) diff --git a/BizHawk.Client.EmuHawk/tools/ToolHelpers.cs b/BizHawk.Client.EmuHawk/tools/ToolHelpers.cs index 870c8da835..05f3c4e27e 100644 --- a/BizHawk.Client.EmuHawk/tools/ToolHelpers.cs +++ b/BizHawk.Client.EmuHawk/tools/ToolHelpers.cs @@ -1,7 +1,5 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; -using System.Linq; using System.Windows.Forms; using BizHawk.Emulation.Common; @@ -105,29 +103,6 @@ namespace BizHawk.Client.EmuHawk e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None; } - protected void LoadColumnInfo(VirtualListView listView, ToolDialogSettings.ColumnList columns) - { - listView.Columns.Clear(); - - var cl = columns - .Where(c => c.Visible) - .OrderBy(c => c.Index); - - foreach (var column in cl) - { - listView.AddColumn(column); - } - } - - protected void SaveColumnInfo(VirtualListView listview, ToolDialogSettings.ColumnList columns) - { - foreach (ColumnHeader column in listview.Columns) - { - columns[column.Name].Index = column.DisplayIndex; - columns[column.Name].Width = column.Width; - } - } - protected void RefreshFloatingWindowControl(bool floatingWindow) { Owner = floatingWindow ? null : GlobalWin.MainForm; diff --git a/BizHawk.Client.EmuHawk/tools/ToolManager.cs b/BizHawk.Client.EmuHawk/tools/ToolManager.cs index e8bc2338ae..2adc46a38f 100644 --- a/BizHawk.Client.EmuHawk/tools/ToolManager.cs +++ b/BizHawk.Client.EmuHawk/tools/ToolManager.cs @@ -323,6 +323,11 @@ namespace BizHawk.Client.EmuHawk settings.RestoreDefaults(); RefreshSettings(form, dest, settings, idx); form.Size = oldsize; + + form.GetType() + .GetMethodsWithAttrib(typeof(RestoreDefaultsAttribute)) + .FirstOrDefault() + ?.Invoke(form, new object[0]); }; } diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.Designer.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.Designer.cs index b126c12fe1..e5322fd38a 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.Designer.cs @@ -32,12 +32,7 @@ System.Windows.Forms.ToolStripMenuItem SearchMenuItem; System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RamSearch)); this.TotalSearchLabel = new System.Windows.Forms.Label(); - this.WatchListView = new BizHawk.Client.EmuHawk.VirtualListView(); - this.AddressColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.ValueColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.PreviousColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.ChangesColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.DiffColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.WatchListView = new InputRoll(); this.ListViewContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); this.DoSearchContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.NewSearchContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -185,65 +180,29 @@ // WatchListView // this.WatchListView.AllowColumnReorder = true; + this.WatchListView.AllowColumnResize = true; this.WatchListView.AllowDrop = true; this.WatchListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.WatchListView.BlazingFast = false; - this.WatchListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.AddressColumn, - this.ValueColumn, - this.PreviousColumn, - this.ChangesColumn, - this.DiffColumn}); this.WatchListView.ContextMenuStrip = this.ListViewContextMenu; this.WatchListView.FullRowSelect = true; this.WatchListView.GridLines = true; - this.WatchListView.HideSelection = false; - this.WatchListView.ItemCount = 0; + this.WatchListView.RowCount = 0; this.WatchListView.Location = new System.Drawing.Point(9, 65); this.WatchListView.Name = "WatchListView"; - this.WatchListView.SelectAllInProgress = false; - this.WatchListView.selectedItem = -1; this.WatchListView.Size = new System.Drawing.Size(230, 366); this.WatchListView.TabIndex = 1; - this.WatchListView.UseCompatibleStateImageBehavior = false; this.WatchListView.UseCustomBackground = true; - this.WatchListView.View = System.Windows.Forms.View.Details; - this.WatchListView.VirtualMode = true; - this.WatchListView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.WatchListView_ColumnClick); + this.WatchListView.MultiSelect = true; + this.WatchListView.ColumnClick += new BizHawk.Client.EmuHawk.InputRoll.ColumnClickEventHandler(this.WatchListView_ColumnClick); this.WatchListView.SelectedIndexChanged += new System.EventHandler(this.WatchListView_SelectedIndexChanged); - this.WatchListView.VirtualItemsSelectionRangeChanged += new System.Windows.Forms.ListViewVirtualItemsSelectionRangeChangedEventHandler(this.WatchListView_VirtualItemsSelectionRangeChanged); this.WatchListView.DragDrop += new System.Windows.Forms.DragEventHandler(this.NewRamSearch_DragDrop); this.WatchListView.DragEnter += new System.Windows.Forms.DragEventHandler(this.DragEnterWrapper); this.WatchListView.Enter += new System.EventHandler(this.WatchListView_Enter); this.WatchListView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.WatchListView_KeyDown); this.WatchListView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.WatchListView_MouseDoubleClick); // - // AddressColumn - // - this.AddressColumn.Text = "Address"; - this.AddressColumn.Width = 61; - // - // ValueColumn - // - this.ValueColumn.Text = "Value"; - this.ValueColumn.Width = 48; - // - // PreviousColumn - // - this.PreviousColumn.Text = "Prev"; - this.PreviousColumn.Width = 48; - // - // ChangesColumn - // - this.ChangesColumn.Text = "Changes"; - this.ChangesColumn.Width = 55; - // - // DiffColumn - // - this.DiffColumn.Text = "Diff"; - // // ListViewContextMenu // this.ListViewContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -1422,11 +1381,7 @@ #endregion private System.Windows.Forms.Label TotalSearchLabel; - VirtualListView WatchListView; - private System.Windows.Forms.ColumnHeader AddressColumn; - private System.Windows.Forms.ColumnHeader ValueColumn; - private System.Windows.Forms.ColumnHeader PreviousColumn; - private System.Windows.Forms.ColumnHeader ChangesColumn; + InputRoll WatchListView; private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem OpenMenuItem; private System.Windows.Forms.ToolStripMenuItem SaveAsMenuItem; @@ -1530,7 +1485,6 @@ private WatchValueBox DifferenceBox; private System.Windows.Forms.ToolStripMenuItem AutoSearchMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator9; - private System.Windows.Forms.ColumnHeader DiffColumn; private System.Windows.Forms.ToolStripSeparator toolStripSeparator12; private System.Windows.Forms.ToolStripButton UndoToolBarButton; private System.Windows.Forms.ToolStripButton RedoToolBarItem; diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs index 91605466a5..a7be2ebb0e 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs @@ -53,13 +53,13 @@ namespace BizHawk.Client.EmuHawk InitializeComponent(); WatchListView.QueryItemText += ListView_QueryItemText; WatchListView.QueryItemBkColor += ListView_QueryItemBkColor; - WatchListView.VirtualMode = true; Closing += (o, e) => SaveConfigSettings(); _sortedColumn = ""; _sortReverse = false; Settings = new RamSearchSettings(); + SetColumns(); } [RequiredService] @@ -110,15 +110,20 @@ namespace BizHawk.Client.EmuHawk private void ColumnToggleCallback() { - SaveColumnInfo(WatchListView, Settings.Columns); - LoadColumnInfo(WatchListView, Settings.Columns); + Settings.Columns = WatchListView.AllColumns; } private void RamSearch_Load(object sender, EventArgs e) { + // Hack for previous config settings + if (Settings.Columns.Any(c => string.IsNullOrWhiteSpace(c.Text))) + { + Settings = new RamSearchSettings(); + } + TopMost = Settings.TopMost; - RamSearchMenu.Items.Add(Settings.Columns.GenerateColumnsMenu(ColumnToggleCallback)); + RamSearchMenu.Items.Add(WatchListView.ToColumnsMenu(ColumnToggleCallback)); _settings = new RamSearchEngine.Settings(MemoryDomains); _searches = new RamSearchEngine(_settings, MemoryDomains); @@ -161,39 +166,36 @@ namespace BizHawk.Client.EmuHawk ErrorIconButton.Visible = _searches.OutOfRangeAddress.Any(); } - private void ListView_QueryItemBkColor(int index, int column, ref Color color) + private void ListView_QueryItemBkColor(int index, InputRoll.RollColumn column, ref Color color) { - if (column == 0) + if (_searches.Count > 0) { - if (_searches.Count > 0 && column == 0) + var nextColor = Color.White; + + var isCheat = Global.CheatList.IsActive(_settings.Domain, _searches[index].Address); + var isWeeded = Settings.PreviewMode && !_forcePreviewClear && _searches.Preview(_searches[index].Address); + + if (_searches[index].Address >= _searches[index].Domain.Size) { - var nextColor = Color.White; - - var isCheat = Global.CheatList.IsActive(_settings.Domain, _searches[index].Address); - var isWeeded = Settings.PreviewMode && !_forcePreviewClear && _searches.Preview(_searches[index].Address); - - if (_searches[index].Address >= _searches[index].Domain.Size) - { - nextColor = Color.PeachPuff; - } - else if (isCheat) - { - nextColor = isWeeded ? Color.Lavender : Color.LightCyan; - } - else - { - if (isWeeded) - { - nextColor = Color.Pink; - } - } - - color = nextColor; + nextColor = Color.PeachPuff; } + else if (isCheat) + { + nextColor = isWeeded ? Color.Lavender : Color.LightCyan; + } + else + { + if (isWeeded) + { + nextColor = Color.Pink; + } + } + + color = nextColor; } } - private void ListView_QueryItemText(int index, int column, out string text) + private void ListView_QueryItemText(int index, InputRoll.RollColumn column, out string text, ref int offsetX, ref int offsetY) { text = ""; @@ -202,7 +204,7 @@ namespace BizHawk.Client.EmuHawk return; } - var columnName = WatchListView.Columns[column].Name; + var columnName = column.Name; switch (columnName) { case WatchList.ADDRESS: @@ -240,7 +242,19 @@ namespace BizHawk.Client.EmuHawk TopMost = Settings.TopMost; - LoadColumnInfo(WatchListView, Settings.Columns); + WatchListView.AllColumns.Clear(); + SetColumns(); + } + + private void SetColumns() + { + foreach (var column in Settings.Columns) + { + if (WatchListView.AllColumns[column.Name] == null) + { + WatchListView.AllColumns.Add(column); + } + } } #endregion @@ -252,7 +266,7 @@ namespace BizHawk.Client.EmuHawk /// private void UpdateList() { - WatchListView.ItemCount = _searches.Count; + WatchListView.RowCount = _searches.Count; SetTotal(); } @@ -282,9 +296,7 @@ namespace BizHawk.Client.EmuHawk } _forcePreviewClear = false; - WatchListView.BlazingFast = true; WatchListView.Invalidate(); - WatchListView.BlazingFast = false; } } @@ -314,7 +326,7 @@ namespace BizHawk.Client.EmuHawk private void SaveConfigSettings() { - SaveColumnInfo(WatchListView, Settings.Columns); + Settings.Columns = WatchListView.AllColumns; if (WindowState == FormWindowState.Normal) { @@ -551,7 +563,7 @@ namespace BizHawk.Client.EmuHawk _forcePreviewClear = true; } - private IEnumerable SelectedIndices => WatchListView.SelectedIndices.Cast(); + private IEnumerable SelectedIndices => WatchListView.SelectedRows; private IEnumerable SelectedItems { @@ -771,10 +783,27 @@ namespace BizHawk.Client.EmuHawk DifferenceRadio.Enabled = true; DifferentByBox.Enabled = true; ClearChangeCountsToolBarItem.Enabled = true; - WatchListView.Columns[WatchList.CHANGES].Width = Settings.Columns[WatchList.CHANGES].Width; + + WatchListView.AllColumns[WatchList.CHANGES].Visible = true; + ChangesMenuItem.Checked = true; + + ColumnToggleCallback(); SetReboot(true); } + private ToolStripMenuItem ChangesMenuItem + { + get + { + var subMenu = (ToolStripMenuItem)RamSearchMenu.Items + .Cast() + .Single(t => t.Name == "GeneratedColumnsSubMenu"); // TODO - make name a constant + return subMenu.DropDownItems + .Cast() + .Single(t => t.Name == WatchList.CHANGES); + } + } + private void SetToFastMode() { _settings.Mode = RamSearchEngine.Settings.SearchMode.Fast; @@ -794,8 +823,10 @@ namespace BizHawk.Client.EmuHawk PreviousValueRadio.Checked = true; } - Settings.Columns[WatchList.CHANGES].Width = WatchListView.Columns[WatchList.CHANGES].Width; - WatchListView.Columns[WatchList.CHANGES].Width = 0; + WatchListView.AllColumns[WatchList.CHANGES].Visible = false; + ChangesMenuItem.Checked = false; + + ColumnToggleCallback(); SetReboot(true); } @@ -808,7 +839,7 @@ namespace BizHawk.Client.EmuHawk _searches.RemoveRange(indices); UpdateList(); - WatchListView.SelectedIndices.Clear(); + WatchListView.DeselectAll(); ToggleSearchDependentToolBarItems(); } } @@ -899,7 +930,7 @@ namespace BizHawk.Client.EmuHawk private void GoToSpecifiedAddress() { - WatchListView.SelectedIndices.Clear(); + WatchListView.DeselectAll(); var prompt = new InputPrompt { Text = "Go to Address", @@ -916,8 +947,8 @@ namespace BizHawk.Client.EmuHawk { if (_searches[index].Address == addr) { - WatchListView.SelectItem(index, true); - WatchListView.ensureVisible(); + WatchListView.SelectRow(index, true); + WatchListView.ScrollToIndex(index); return; // Don't re-show dialog on success } } @@ -943,13 +974,13 @@ namespace BizHawk.Client.EmuHawk { public RamSearchSettings() { - Columns = new ColumnList + Columns = new List { - new Column { Name = WatchList.ADDRESS, Visible = true, Index = 0, Width = 60 }, - new Column { Name = WatchList.VALUE, Visible = true, Index = 1, Width = 59 }, - new Column { Name = WatchList.PREV, Visible = true, Index = 2, Width = 59 }, - new Column { Name = WatchList.CHANGES, Visible = true, Index = 3, Width = 55 }, - new Column { Name = WatchList.DIFF, Visible = false, Index = 4, Width = 59 }, + new InputRoll.RollColumn { Text = "Address", Name = WatchList.ADDRESS, Visible = true, Width = 60, Type = InputRoll.RollColumn.InputType.Text }, + new InputRoll.RollColumn { Text = "Value", Name = WatchList.VALUE, Visible = true, Width = 59, Type = InputRoll.RollColumn.InputType.Text }, + new InputRoll.RollColumn { Text = "Prev", Name = WatchList.PREV, Visible = true, Width = 59, Type = InputRoll.RollColumn.InputType.Text }, + new InputRoll.RollColumn { Text = "Changes", Name = WatchList.CHANGES, Visible = true, Width = 60, Type = InputRoll.RollColumn.InputType.Text }, + new InputRoll.RollColumn { Text = "Diff", Name = WatchList.DIFF, Visible = false, Width = 59, Type = InputRoll.RollColumn.InputType.Text }, }; PreviewMode = true; @@ -957,7 +988,7 @@ namespace BizHawk.Client.EmuHawk AutoSearchTakeLagFramesIntoAccount = true; } - public ColumnList Columns { get; } + public List Columns { get; set; } public bool PreviewMode { get; set; } public bool AlwaysExcludeRamWatch { get; set; } public bool AutoSearchTakeLagFramesIntoAccount { get; set; } @@ -1385,9 +1416,9 @@ namespace BizHawk.Client.EmuHawk RamSearchMenu.Items.Remove( RamSearchMenu.Items .OfType() - .First(x => x.Name == "GeneratedColumnsSubMenu")); + .Single(x => x.Name == "GeneratedColumnsSubMenu")); - RamSearchMenu.Items.Add(Settings.Columns.GenerateColumnsMenu(ColumnToggleCallback)); + RamSearchMenu.Items.Add(WatchListView.ToColumnsMenu(ColumnToggleCallback)); _settings = new RamSearchEngine.Settings(MemoryDomains); if (_settings.Mode == RamSearchEngine.Settings.SearchMode.Fast) @@ -1396,7 +1427,9 @@ namespace BizHawk.Client.EmuHawk } RefreshFloatingWindowControl(Settings.FloatingWindow); - LoadColumnInfo(WatchListView, Settings.Columns); + + WatchListView.AllColumns.Clear(); + SetColumns(); } #endregion @@ -1708,17 +1741,12 @@ namespace BizHawk.Client.EmuHawk } else if (e.KeyCode == Keys.Escape && !e.Control && !e.Alt && !e.Shift) { - WatchListView.SelectedIndices.Clear(); + WatchListView.DeselectAll(); } } private void WatchListView_SelectedIndexChanged(object sender, EventArgs e) { - if (WatchListView.SelectAllInProgress) - { - return; - } - RemoveToolBarItem.Enabled = AddToRamWatchToolBarItem.Enabled = SelectedIndices.Any(); @@ -1729,19 +1757,14 @@ namespace BizHawk.Client.EmuHawk _searches.Domain.CanPoke(); } - private void WatchListView_VirtualItemsSelectionRangeChanged(object sender, ListViewVirtualItemsSelectionRangeChangedEventArgs e) - { - WatchListView_SelectedIndexChanged(sender, e); - } - private void WatchListView_Enter(object sender, EventArgs e) { WatchListView.Refresh(); } - private void WatchListView_ColumnClick(object sender, ColumnClickEventArgs e) + private void WatchListView_ColumnClick(object sender, InputRoll.ColumnClickEventArgs e) { - var column = WatchListView.Columns[e.Column]; + var column = e.Column; if (column.Name != _sortedColumn) { _sortReverse = false; diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.Designer.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.Designer.cs index cafc1c6a6d..a353a41066 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.Designer.cs @@ -112,15 +112,7 @@ this.FloatingWindowMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); this.RestoreWindowSizeMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.WatchListView = new BizHawk.Client.EmuHawk.VirtualListView(); - this.AddressColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.ValueColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.PrevColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.ChangesColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.DiffColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.TypeColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.DomainColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.NotesColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.WatchListView = new InputRoll(); this.ListViewContextMenu.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.toolStrip1.SuspendLayout(); @@ -886,100 +878,35 @@ // // WatchListView // + this.WatchListView.AllowColumnResize = true; + this.WatchListView.AllowColumnReorder = true; + this.WatchListView.FullRowSelect = true; + this.WatchListView.MultiSelect = true; this.WatchListView.AllowColumnReorder = true; this.WatchListView.AllowDrop = true; this.WatchListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.WatchListView.AutoArrange = false; - this.WatchListView.BlazingFast = false; - this.WatchListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.AddressColumn, - this.ValueColumn, - this.PrevColumn, - this.ChangesColumn, - this.DiffColumn, - this.TypeColumn, - this.DomainColumn, - this.NotesColumn}); this.WatchListView.ContextMenuStrip = this.ListViewContextMenu; this.WatchListView.FullRowSelect = true; this.WatchListView.GridLines = true; - this.WatchListView.HideSelection = false; - this.WatchListView.ItemCount = 0; this.WatchListView.Location = new System.Drawing.Point(16, 76); this.WatchListView.Name = "WatchListView"; - this.WatchListView.SelectAllInProgress = false; - this.WatchListView.selectedItem = -1; - this.WatchListView.Size = new System.Drawing.Size(332, 281); + this.WatchListView.Size = new System.Drawing.Size(363, 281); this.WatchListView.TabIndex = 2; - this.WatchListView.UseCompatibleStateImageBehavior = false; this.WatchListView.UseCustomBackground = true; - this.WatchListView.View = System.Windows.Forms.View.Details; - this.WatchListView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.WatchListView_ColumnClick); + this.WatchListView.ColumnClick += new BizHawk.Client.EmuHawk.InputRoll.ColumnClickEventHandler(this.WatchListView_ColumnClick); this.WatchListView.SelectedIndexChanged += new System.EventHandler(this.WatchListView_SelectedIndexChanged); - this.WatchListView.VirtualItemsSelectionRangeChanged += new System.Windows.Forms.ListViewVirtualItemsSelectionRangeChangedEventHandler(this.WatchListView_VirtualItemsSelectionRangeChanged); this.WatchListView.DragDrop += new System.Windows.Forms.DragEventHandler(this.NewRamWatch_DragDrop); this.WatchListView.DragEnter += new System.Windows.Forms.DragEventHandler(this.DragEnterWrapper); this.WatchListView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.WatchListView_KeyDown); this.WatchListView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.WatchListView_MouseDoubleClick); // - // AddressColumn - // - this.AddressColumn.Name = "AddressColumn"; - this.AddressColumn.Text = "Address"; - // - // ValueColumn - // - this.ValueColumn.Name = "ValueColumn"; - this.ValueColumn.Text = "Value"; - this.ValueColumn.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - this.ValueColumn.Width = 59; - // - // PrevColumn - // - this.PrevColumn.Name = "PrevColumn"; - this.PrevColumn.Text = "Prev"; - this.PrevColumn.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - this.PrevColumn.Width = 59; - // - // ChangesColumn - // - this.ChangesColumn.Name = "ChangesColumn"; - this.ChangesColumn.Text = "Changes"; - this.ChangesColumn.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - this.ChangesColumn.Width = 54; - // - // DiffColumn - // - this.DiffColumn.Name = "DiffColumn"; - this.DiffColumn.Text = "Diff"; - this.DiffColumn.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - this.DiffColumn.Width = 59; - // - // TypeColumn - // - this.TypeColumn.Name = "TypeColumn"; - this.TypeColumn.Text = "Type"; - this.TypeColumn.Width = 55; - // - // DomainColumn - // - this.DomainColumn.Name = "DomainColumn"; - this.DomainColumn.Text = "Domain"; - this.DomainColumn.Width = 55; - // - // NotesColumn - // - this.NotesColumn.Name = "NotesColumn"; - this.NotesColumn.Text = "Notes"; - this.NotesColumn.Width = 128; - // // RamWatch // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(364, 378); + this.ClientSize = new System.Drawing.Size(395, 378); this.Controls.Add(this.statusStrip1); this.Controls.Add(this.WatchCountLabel); this.Controls.Add(this.toolStrip1); @@ -1009,15 +936,7 @@ #endregion - private VirtualListView WatchListView; - private System.Windows.Forms.ColumnHeader AddressColumn; - private System.Windows.Forms.ColumnHeader ValueColumn; - private System.Windows.Forms.ColumnHeader PrevColumn; - private System.Windows.Forms.ColumnHeader ChangesColumn; - private System.Windows.Forms.ColumnHeader DiffColumn; - private System.Windows.Forms.ColumnHeader TypeColumn; - private System.Windows.Forms.ColumnHeader DomainColumn; - private System.Windows.Forms.ColumnHeader NotesColumn; + private InputRoll WatchListView; private MenuStripEx RamWatchMenu; private System.Windows.Forms.ToolStripMenuItem FileSubMenu; private System.Windows.Forms.ToolStripMenuItem NewListMenuItem; diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs index 969a9f25cb..7377d33b4c 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs @@ -42,7 +42,6 @@ namespace BizHawk.Client.EmuHawk WatchListView.QueryItemText += WatchListView_QueryItemText; WatchListView.QueryItemBkColor += WatchListView_QueryItemBkColor; - WatchListView.VirtualMode = true; Closing += (o, e) => { if (AskSaveChanges()) @@ -57,6 +56,20 @@ namespace BizHawk.Client.EmuHawk _sortedColumn = ""; _sortReverse = false; + + + SetColumns(); + } + + private void SetColumns() + { + foreach (var column in Settings.Columns) + { + if (WatchListView.AllColumns[column.Name] == null) + { + WatchListView.AllColumns.Add(column); + } + } } [ConfigPersist] @@ -66,23 +79,23 @@ namespace BizHawk.Client.EmuHawk { public RamWatchSettings() { - Columns = new ColumnList + Columns = new List { - new Column { Name = WatchList.ADDRESS, Visible = true, Index = 0, Width = 60 }, - new Column { Name = WatchList.VALUE, Visible = true, Index = 1, Width = 59 }, - new Column { Name = WatchList.PREV, Visible = false, Index = 2, Width = 59 }, - new Column { Name = WatchList.CHANGES, Visible = true, Index = 3, Width = 55 }, - new Column { Name = WatchList.DIFF, Visible = false, Index = 4, Width = 59 }, - new Column { Name = WatchList.TYPE, Visible = false, Index = 5, Width = 55 }, - new Column { Name = WatchList.DOMAIN, Visible = true, Index = 6, Width = 55 }, - new Column { Name = WatchList.NOTES, Visible = true, Index = 7, Width = 128 }, + new InputRoll.RollColumn { Text = "Address", Name = WatchList.ADDRESS, Visible = true, Width = 60, Type = InputRoll.RollColumn.InputType.Text }, + new InputRoll.RollColumn { Text = "Value", Name = WatchList.VALUE, Visible = true, Width = 59, Type = InputRoll.RollColumn.InputType.Text }, + new InputRoll.RollColumn { Text = "Prev", Name = WatchList.PREV, Visible = false, Width = 59, Type = InputRoll.RollColumn.InputType.Text }, + new InputRoll.RollColumn { Text = "Changes", Name = WatchList.CHANGES, Visible = true, Width = 60, Type = InputRoll.RollColumn.InputType.Text }, + new InputRoll.RollColumn { Text = "Diff", Name = WatchList.DIFF, Visible = false, Width = 59, Type = InputRoll.RollColumn.InputType.Text }, + new InputRoll.RollColumn { Text = "Type", Name = WatchList.TYPE, Visible = false, Width = 55, Type = InputRoll.RollColumn.InputType.Text }, + new InputRoll.RollColumn { Text = "Domain", Name = WatchList.DOMAIN, Visible = true, Width = 55, Type = InputRoll.RollColumn.InputType.Text }, + new InputRoll.RollColumn { Text = "Notes", Name = WatchList.NOTES, Visible = true, Width = 128, Type = InputRoll.RollColumn.InputType.Text } }; } - public ColumnList Columns { get; set; } + public List Columns { get; set; } } - private IEnumerable SelectedIndices => WatchListView.SelectedIndices.Cast(); + private IEnumerable SelectedIndices => WatchListView.SelectedRows; private IEnumerable SelectedItems { @@ -117,7 +130,7 @@ namespace BizHawk.Client.EmuHawk public void AddWatch(Watch watch) { _watches.Add(watch); - WatchListView.ItemCount = _watches.Count; + WatchListView.RowCount = _watches.Count; UpdateValues(); UpdateWatchCount(); Changes(); @@ -174,7 +187,7 @@ namespace BizHawk.Client.EmuHawk else { Global.Config.RecentWatches.Add(path); - WatchListView.ItemCount = _watches.Count; + WatchListView.RowCount = _watches.Count; UpdateWatchCount(); UpdateStatusBar(); _watches.Changes = false; @@ -195,7 +208,7 @@ namespace BizHawk.Client.EmuHawk if (result) { _watches.Load(file.FullName, append); - WatchListView.ItemCount = _watches.Count; + WatchListView.RowCount = _watches.Count; UpdateWatchCount(); Global.Config.RecentWatches.Add(_watches.CurrentFileName); UpdateStatusBar(); @@ -271,10 +284,8 @@ namespace BizHawk.Client.EmuHawk return; } - WatchListView.BlazingFast = true; WatchListView.UseCustomBackground = NeedsBackground; WatchListView.Invalidate(); - WatchListView.BlazingFast = false; } } @@ -387,7 +398,7 @@ namespace BizHawk.Client.EmuHawk private void FullyUpdateWatchList() { - WatchListView.ItemCount = _watches.Count; + WatchListView.RowCount = _watches.Count; UpdateWatchCount(); UpdateStatusBar(); UpdateValues(); @@ -422,7 +433,7 @@ namespace BizHawk.Client.EmuHawk if (duplicate) { _watches.AddRange(we.Watches); - WatchListView.ItemCount = _watches.Count; + WatchListView.RowCount = _watches.Count; UpdateWatchCount(); } else @@ -514,7 +525,8 @@ namespace BizHawk.Client.EmuHawk Size = Settings.WindowSize; } - LoadColumnInfo(WatchListView, Settings.Columns); + WatchListView.AllColumns.Clear(); + SetColumns(); } private void NewWatchList(bool suppressAsk) @@ -528,7 +540,7 @@ namespace BizHawk.Client.EmuHawk if (result || suppressAsk) { _watches.Clear(); - WatchListView.ItemCount = _watches.Count; + WatchListView.RowCount = _watches.Count; UpdateWatchCount(); UpdateStatusBar(); _sortReverse = false; @@ -541,9 +553,8 @@ namespace BizHawk.Client.EmuHawk } } - private void OrderColumn(int index) + private void OrderColumn(InputRoll.RollColumn column) { - var column = WatchListView.Columns[index]; if (column.Name != _sortedColumn) { _sortReverse = false; @@ -568,7 +579,7 @@ namespace BizHawk.Client.EmuHawk private void SaveConfigSettings() { - SaveColumnInfo(WatchListView, Settings.Columns); + Settings.Columns = WatchListView.AllColumns; if (WindowState == FormWindowState.Normal) { @@ -610,42 +621,38 @@ namespace BizHawk.Client.EmuHawk WatchCountLabel.Text = _watches.WatchCount + (_watches.WatchCount == 1 ? " watch" : " watches"); } - private void WatchListView_QueryItemBkColor(int index, int column, ref Color color) + private void WatchListView_QueryItemBkColor(int index, InputRoll.RollColumn column, ref Color color) { if (index >= _watches.Count) { return; } - if (column == 0) - { - if (_watches[index].IsSeparator) - { - color = BackColor; - } - else if (_watches[index].Address >= _watches[index].Domain.Size) - { - color = Color.PeachPuff; - } - else if (Global.CheatList.IsActive(_watches[index].Domain, _watches[index].Address)) - { - color = Color.LightCyan; - } - } - } - - private void WatchListView_QueryItemText(int index, int column, out string text) - { - text = ""; - - if (index >= _watches.Count) - { - return; - } - if (_watches[index].IsSeparator) { - if (WatchListView.Columns[column].Name == WatchList.ADDRESS) + color = BackColor; + } + else if (_watches[index].Address >= _watches[index].Domain.Size) + { + color = Color.PeachPuff; + } + else if (Global.CheatList.IsActive(_watches[index].Domain, _watches[index].Address)) + { + color = Color.LightCyan; + } + } + + private void WatchListView_QueryItemText(int index, InputRoll.RollColumn column, out string text, ref int offsetX, ref int offsetY) + { + text = ""; + if (index >= _watches.Count) + { + return; + } + + if (_watches[index].IsSeparator) + { + if (column.Name == WatchList.ADDRESS) { text = _watches[index].Notes; } @@ -653,9 +660,7 @@ namespace BizHawk.Client.EmuHawk return; } - var columnName = WatchListView.Columns[column].Name; - - switch (columnName) + switch (column.Name) { case WatchList.ADDRESS: text = _watches[index].AddressString; @@ -796,7 +801,7 @@ namespace BizHawk.Client.EmuHawk _watches.Add(we.Watches[0]); Changes(); UpdateWatchCount(); - WatchListView.ItemCount = _watches.Count; + WatchListView.RowCount = _watches.Count; UpdateValues(); } } @@ -816,7 +821,7 @@ namespace BizHawk.Client.EmuHawk _watches.Remove(item); } - WatchListView.ItemCount = _watches.Count; + WatchListView.RowCount = _watches.Count; UpdateValues(); UpdateWatchCount(); } @@ -870,7 +875,7 @@ namespace BizHawk.Client.EmuHawk _watches.Add(SeparatorWatch.Instance); } - WatchListView.ItemCount = _watches.Count; + WatchListView.RowCount = _watches.Count; Changes(); UpdateWatchCount(); } @@ -900,13 +905,13 @@ namespace BizHawk.Client.EmuHawk var indices = indexes.Select(t => t - 1); - WatchListView.SelectedIndices.Clear(); + WatchListView.DeselectAll(); foreach (var t in indices) { - WatchListView.SelectItem(t, true); + WatchListView.SelectRow(t, true); } - WatchListView.ItemCount = _watches.Count; + WatchListView.RowCount = _watches.Count; } private void MoveDownMenuItem_Click(object sender, EventArgs e) @@ -926,14 +931,14 @@ namespace BizHawk.Client.EmuHawk var newIndices = indices.Select(t => t + 1); - WatchListView.SelectedIndices.Clear(); + WatchListView.DeselectAll(); foreach (var t in newIndices) { - WatchListView.SelectItem(t, true); + WatchListView.SelectRow(t, true); } Changes(); - WatchListView.ItemCount = _watches.Count; + WatchListView.RowCount = _watches.Count; } private void MoveTopMenuItem_Click(object sender, EventArgs e) @@ -954,13 +959,13 @@ namespace BizHawk.Client.EmuHawk Changes(); - WatchListView.SelectedIndices.Clear(); + WatchListView.DeselectAll(); foreach (var t in indexes) { - WatchListView.SelectItem(t, true); + WatchListView.SelectRow(t, true); } - WatchListView.ItemCount = _watches.Count; + WatchListView.RowCount = _watches.Count; } private void MoveBottomMenuItem_Click(object sender, EventArgs e) @@ -984,14 +989,14 @@ namespace BizHawk.Client.EmuHawk newInd.Add(x); } - WatchListView.SelectedIndices.Clear(); + WatchListView.DeselectAll(); foreach (var t in newInd) { - WatchListView.SelectItem(t, true); + WatchListView.SelectRow(t, true); } Changes(); - WatchListView.ItemCount = _watches.Count; + WatchListView.RowCount = _watches.Count; } private void SelectAllMenuItem_Click(object sender, EventArgs e) @@ -1078,12 +1083,14 @@ namespace BizHawk.Client.EmuHawk .OfType() .First(x => x.Name == "GeneratedColumnsSubMenu")); - RamWatchMenu.Items.Add(Settings.Columns.GenerateColumnsMenu(ColumnToggleCallback)); + RamWatchMenu.Items.Add(WatchListView.ToColumnsMenu(ColumnToggleCallback)); Global.Config.DisplayRamWatch = false; RefreshFloatingWindowControl(Settings.FloatingWindow); - LoadColumnInfo(WatchListView, Settings.Columns); + + WatchListView.AllColumns.Clear(); + SetColumns(); } #endregion @@ -1092,10 +1099,16 @@ namespace BizHawk.Client.EmuHawk private void NewRamWatch_Load(object sender, EventArgs e) { + // Hack for previous config settings + if (Settings.Columns.Any(c => string.IsNullOrWhiteSpace(c.Text))) + { + Settings = new RamWatchSettings(); + } + TopMost = Settings.TopMost; _watches = new WatchList(MemoryDomains, Emu.SystemId); LoadConfigSettings(); - RamWatchMenu.Items.Add(Settings.Columns.GenerateColumnsMenu(ColumnToggleCallback)); + RamWatchMenu.Items.Add(WatchListView.ToColumnsMenu(ColumnToggleCallback)); UpdateStatusBar(); PokeAddressToolBarItem.Enabled = @@ -1106,8 +1119,7 @@ namespace BizHawk.Client.EmuHawk private void ColumnToggleCallback() { - SaveColumnInfo(WatchListView, Settings.Columns); - LoadColumnInfo(WatchListView, Settings.Columns); + Settings.Columns = WatchListView.AllColumns; } private void NewRamWatch_Activated(object sender, EventArgs e) @@ -1122,7 +1134,7 @@ namespace BizHawk.Client.EmuHawk { _watches.Load(filePaths[0], append: false); Global.Config.RecentWatches.Add(_watches.CurrentFileName); - WatchListView.ItemCount = _watches.Count; + WatchListView.RowCount = _watches.Count; } } @@ -1133,7 +1145,7 @@ namespace BizHawk.Client.EmuHawk private void ListViewContextMenu_Opening(object sender, CancelEventArgs e) { - var indexes = WatchListView.SelectedIndices; + var indexes = WatchListView.SelectedRows.ToList(); EditContextMenuItem.Visible = RemoveContextMenuItem.Visible = @@ -1259,11 +1271,6 @@ namespace BizHawk.Client.EmuHawk private void WatchListView_SelectedIndexChanged(object sender, EventArgs e) { - if (WatchListView.SelectAllInProgress) - { - return; - } - PokeAddressToolBarItem.Enabled = FreezeAddressToolBarItem.Enabled = SelectedIndices.Any() && @@ -1275,7 +1282,8 @@ namespace BizHawk.Client.EmuHawk EditWatch(); } - private void WatchListView_ColumnClick(object sender, ColumnClickEventArgs e) + // InputRoll TODO + private void WatchListView_ColumnClick(object sender, InputRoll.ColumnClickEventArgs e) { OrderColumn(e.Column); } @@ -1291,7 +1299,7 @@ namespace BizHawk.Client.EmuHawk _watches.Remove(item); } - WatchListView.ItemCount = _watches.Count; + WatchListView.RowCount = _watches.Count; UpdateValues(); UpdateWatchCount(); UpdateStatusBar(); @@ -1300,14 +1308,6 @@ namespace BizHawk.Client.EmuHawk #endregion #endregion - private void WatchListView_VirtualItemsSelectionRangeChanged(object sender, ListViewVirtualItemsSelectionRangeChangedEventArgs e) - { - PokeAddressToolBarItem.Enabled = - FreezeAddressToolBarItem.Enabled = - SelectedIndices.Any() && - SelectedWatches.All(w => w.Domain.CanPoke()); - } - // Stupid designer protected void DragEnterWrapper(object sender, DragEventArgs e) { diff --git a/BizHawk.Client.MultiHawk/App.config b/BizHawk.Client.MultiHawk/App.config deleted file mode 100644 index 45437954e0..0000000000 --- a/BizHawk.Client.MultiHawk/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/BizHawk.Client.MultiHawk/BizHawk.Client.MultiHawk.csproj b/BizHawk.Client.MultiHawk/BizHawk.Client.MultiHawk.csproj deleted file mode 100644 index daf4e4ecc3..0000000000 --- a/BizHawk.Client.MultiHawk/BizHawk.Client.MultiHawk.csproj +++ /dev/null @@ -1,250 +0,0 @@ - - - - true - ..\output\ - TRACE;DEBUG;WINDOWS - true - full - AnyCPU - prompt - - MinimumRecommendedRules.ruleset - - - ..\output\ - TRACE;WINDOWS - true - true - pdbonly - AnyCPU - prompt - - MinimumRecommendedRules.ruleset - - - - Debug - x86 - {B95649F5-A0AE-41EB-B62B-578A2AFF5E18} - WinExe - Properties - BizHawk.Client.MultiHawk - MultiHawk - v4.6.1 - 512 - - None - true - - - - - False - ..\References\Newtonsoft.Json.dll - - - ..\References\OpenTK.dll - - - False - ..\References\x64\SlimDX.dll - - - - - - - - - - - - - - - Form - - - PlayMovie.cs - - - Form - - - RecordMovie.cs - - - - Form - - - EmulatorWindow.cs - - - - - - - - Form - - - Mainform.cs - - - - - - - - PlayMovie.cs - - - RecordMovie.cs - - - EmulatorWindow.cs - - - Mainform.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - True - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - - - - - - - - {24a0aa3c-b25f-4197-b23d-476d6462dba0} - BizHawk.Client.Common - - - {dd448b37-ba3f-4544-9754-5406e8094723} - BizHawk.Client.EmuHawk - - - {866f8d13-0678-4ff9-80a4-a3993fd4d8a3} - BizHawk.Common - - - {e1a23168-b571-411c-b360-2229e7225e0e} - BizHawk.Emulation.Common - - - {197d4314-8a9f-49ba-977d-54acefaeb6ba} - BizHawk.Emulation.Cores - - - {f51946ea-827f-4d82-b841-1f2f6d060312} - BizHawk.Emulation.DiscSystem - - - {337ca23e-65e7-44e1-9411-97ee08bb8116} - BizHawk.Bizware.BizwareGL.GdiPlus - - - {5160cfb1-5389-47c1-b7f6-8a0dc97641ee} - BizHawk.Bizware.BizwareGL.OpenTK - - - {e6b436b1-a3cd-4c9a-8f76-5d7154726884} - BizHawk.Bizware.BizwareGL.SlimDX - - - {9f84a0b2-861e-4ef4-b89b-5e2a3f38a465} - BizHawk.Bizware.BizwareGL - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/BizHawk.Client.MultiHawk/BizHawk.Client.MultiHawk.csproj.DotSettings b/BizHawk.Client.MultiHawk/BizHawk.Client.MultiHawk.csproj.DotSettings deleted file mode 100644 index 73e96563f9..0000000000 --- a/BizHawk.Client.MultiHawk/BizHawk.Client.MultiHawk.csproj.DotSettings +++ /dev/null @@ -1,2 +0,0 @@ - - CSharp60 \ No newline at end of file diff --git a/BizHawk.Client.MultiHawk/DisplayManager/DisplayManager.cs b/BizHawk.Client.MultiHawk/DisplayManager/DisplayManager.cs deleted file mode 100644 index ceb67d81e7..0000000000 --- a/BizHawk.Client.MultiHawk/DisplayManager/DisplayManager.cs +++ /dev/null @@ -1,724 +0,0 @@ -//TODO -//we could flag textures as 'actually' render targets (keep a reference to the render target?) which could allow us to convert between them more quickly in some cases - -using System; -using System.IO; -using System.Collections.Generic; -using System.Diagnostics; -using System.Drawing; - -using BizHawk.Emulation.Common; -using BizHawk.Client.Common; -using BizHawk.Client.EmuHawk; -using BizHawk.Client.EmuHawk.FilterManager; -using BizHawk.Bizware.BizwareGL; - -using OpenTK; -using BizHawk.Bizware.BizwareGL.Drivers.SlimDX; -using BizHawk.Bizware.BizwareGL.Drivers.GdiPlus; - -namespace BizHawk.Client.MultiHawk -{ - /// - /// A DisplayManager is destined forevermore to drive the PresentationPanel it gets initialized with. - /// Its job is to receive OSD and emulator outputs, and produce one single buffer (BitampBuffer? Texture2d?) for display by the PresentationPanel. - /// Details TBD - /// - public class DisplayManager : IDisposable - { - class DisplayManagerRenderTargetProvider : IRenderTargetProvider - { - public DisplayManagerRenderTargetProvider(Func callback) { Callback = callback; } - Func Callback; - RenderTarget IRenderTargetProvider.Get(Size size) - { - return Callback(size); - } - } - - public DisplayManager(PresentationPanel presentationPanel, IGL gl, GLManager glManager) - { - GL = gl; - GLManager = glManager; - this.presentationPanel = presentationPanel; - GraphicsControl = this.presentationPanel.GraphicsControl; - CR_GraphicsControl = GLManager.GetContextForGraphicsControl(GraphicsControl); - - //it's sort of important for these to be initialized to something nonzero - currEmuWidth = currEmuHeight = 1; - - Renderer = GL.CreateRenderer(); - - VideoTextureFrugalizer = new TextureFrugalizer(GL); - - ShaderChainFrugalizers = new RenderTargetFrugalizer[16]; //hacky hardcoded limit.. need some other way to manage these - for (int i = 0; i < 16; i++) - { - ShaderChainFrugalizers[i] = new RenderTargetFrugalizer(GL); - } - - RefreshUserShader(); - } - - public bool Disposed { get; private set; } - - public void Dispose() - { - if (Disposed) return; - Disposed = true; - VideoTextureFrugalizer.Dispose(); - foreach (var f in LuaSurfaceFrugalizers.Values) - f.Dispose(); - foreach (var f in ShaderChainFrugalizers) - if (f != null) - f.Dispose(); - Renderer.Dispose(); - } - - //rendering resources: - IGL GL; - GLManager GLManager; - IGuiRenderer Renderer; - - //layer resources - PresentationPanel presentationPanel; //well, its the final layer's target, at least - GraphicsControl GraphicsControl; //well, its the final layer's target, at least - GLManager.ContextRef CR_GraphicsControl; - FilterProgram CurrentFilterProgram; - - /// - /// these variables will track the dimensions of the last frame's (or the next frame? this is confusing) emulator native output size - /// THIS IS OLD JUNK. I should get rid of it, I think. complex results from the last filter ingestion should be saved instead. - /// - int currEmuWidth, currEmuHeight; - - /// - /// additional pixels added at the unscaled level for the use of lua drawing. essentially increases the input video provider dimensions - /// - public System.Windows.Forms.Padding GameExtraPadding; - - /// - /// additional pixels added at the native level for the use of lua drawing. essentially just gets tacked onto the final calculated window sizes. - /// - public System.Windows.Forms.Padding ClientExtraPadding; - - /// - /// custom fonts that don't need to be installed on the user side - /// - public System.Drawing.Text.PrivateFontCollection CustomFonts = new System.Drawing.Text.PrivateFontCollection(); - - TextureFrugalizer VideoTextureFrugalizer; - Dictionary LuaSurfaceFrugalizers = new Dictionary(); - RenderTargetFrugalizer[] ShaderChainFrugalizers; - EmuHawk.Filters.RetroShaderChain ShaderChain_user; - - public void RefreshUserShader() - { - if (ShaderChain_user != null) - ShaderChain_user.Dispose(); - if (File.Exists(Global.Config.DispUserFilterPath)) - { - var fi = new FileInfo(Global.Config.DispUserFilterPath); - using (var stream = fi.OpenRead()) - ShaderChain_user = new EmuHawk.Filters.RetroShaderChain(GL, new EmuHawk.Filters.RetroShaderPreset(stream), Path.GetDirectoryName(Global.Config.DispUserFilterPath)); - } - } - - System.Windows.Forms.Padding CalculateCompleteContentPadding(bool user, bool source) - { - var padding = new System.Windows.Forms.Padding(); - - if(user) - padding += GameExtraPadding; - - //an experimental feature - if(source) - if (Global.Emulator is BizHawk.Emulation.Cores.Sony.PSX.Octoshock) - { - var psx = Global.Emulator as BizHawk.Emulation.Cores.Sony.PSX.Octoshock; - var core_padding = psx.VideoProvider_Padding; - padding.Left += core_padding.Width / 2; - padding.Right += core_padding.Width - core_padding.Width / 2; - padding.Top += core_padding.Height / 2; - padding.Bottom += core_padding.Height - core_padding.Height / 2; - } - - return padding; - } - - FilterProgram BuildDefaultChain(Size chain_insize, Size chain_outsize, bool includeOSD) - { - //select user special FX shader chain - Dictionary selectedChainProperties = new Dictionary(); - EmuHawk.Filters.RetroShaderChain selectedChain = null; - if (Global.Config.TargetDisplayFilter == 3 && ShaderChain_user != null && ShaderChain_user.Available) - selectedChain = ShaderChain_user; - - EmuHawk.Filters.FinalPresentation fPresent = new EmuHawk.Filters.FinalPresentation(chain_outsize); - EmuHawk.Filters.SourceImage fInput = new EmuHawk.Filters.SourceImage(chain_insize); - EmuHawk.Filters.OSD fOSD = new EmuHawk.Filters.OSD(); - fOSD.RenderCallback = () => - { - if (!includeOSD) - return; - var size = fOSD.FindInput().SurfaceFormat.Size; - Renderer.Begin(size.Width, size.Height); - Renderer.SetBlendState(GL.BlendNormal); - Renderer.End(); - }; - - var chain = new FilterProgram(); - - //add the first filter, encompassing output from the emulator core - chain.AddFilter(fInput, "input"); - - //if a non-zero padding is required, add a filter to allow for that - //note, we have two sources of padding right now.. one can come from the videoprovider and one from the user. - //we're combining these now and just using black, for sake of being lean, despite the discussion below: - //keep in mind, the videoprovider design in principle might call for another color. - //we havent really been using this very hard, but users will probably want black there (they could fill it to another color if needed tho) - var padding = CalculateCompleteContentPadding(true,true); - if (padding.Vertical != 0 || padding.Horizontal != 0) - { - //TODO - add another filter just for this, its cumbersome to use final presentation... I think. but maybe theres enough similarities to justify it. - Size size = chain_insize; - size.Width += padding.Horizontal; - size.Height += padding.Vertical; - EmuHawk.Filters.FinalPresentation fPadding = new EmuHawk.Filters.FinalPresentation(size); - chain.AddFilter(fPadding, "padding"); - fPadding.GuiRenderer = Renderer; - fPadding.GL = GL; - fPadding.Config_PadOnly = true; - fPadding.Padding = padding; - } - - if (Global.Config.DispPrescale != 1) - { - EmuHawk.Filters.PrescaleFilter fPrescale = new EmuHawk.Filters.PrescaleFilter() { Scale = Global.Config.DispPrescale }; - chain.AddFilter(fPrescale, "user_prescale"); - } - - //AutoPrescale makes no sense for a None final filter - if (Global.Config.DispAutoPrescale && Global.Config.DispFinalFilter != (int)EmuHawk.Filters.FinalPresentation.eFilterOption.None) - { - var apf = new EmuHawk.Filters.AutoPrescaleFilter(); - chain.AddFilter(apf, "auto_prescale"); - } - - //choose final filter - EmuHawk.Filters.FinalPresentation.eFilterOption finalFilter = EmuHawk.Filters.FinalPresentation.eFilterOption.None; - fPresent.FilterOption = finalFilter; - - //add final presentation - chain.AddFilter(fPresent, "presentation"); - - return chain; - } - - /// - /// This will receive an emulated output frame from an IVideoProvider and run it through the complete frame processing pipeline - /// Then it will stuff it into the bound PresentationPanel. - /// --- - /// If the int[] is size=1, then it contains an openGL texture ID (and the size should be as specified from videoProvider) - /// Don't worry about the case where the frontend isnt using opengl; DisplayManager deals with it - /// - public void UpdateSource(IVideoProvider videoProvider) - { - bool displayNothing = Global.Config.DispSpeedupFeatures == 0; - var job = new JobInfo - { - videoProvider = videoProvider, - simulate = displayNothing, - chain_outsize = GraphicsControl.Size, - includeOSD = true, - }; - UpdateSourceInternal(job); - } - - public BitmapBuffer RenderVideoProvider(IVideoProvider videoProvider) - { - //TODO - we might need to gather more Global.Config.DispXXX properties here, so they can be overridden - var targetSize = new Size(videoProvider.BufferWidth, videoProvider.BufferHeight); - var padding = CalculateCompleteContentPadding(true,true); - targetSize.Width += padding.Horizontal; - targetSize.Height += padding.Vertical; - - var job = new JobInfo - { - videoProvider = videoProvider, - simulate = false, - chain_outsize = targetSize, - offscreen = true, - includeOSD = false - }; - UpdateSourceInternal(job); - return job.offscreenBB; - } - - /// - /// Does the entire display process to an offscreen buffer, suitable for a 'client' screenshot. - /// - public BitmapBuffer RenderOffscreen(IVideoProvider videoProvider, bool includeOSD) - { - var job = new JobInfo - { - videoProvider = videoProvider, - simulate = false, - chain_outsize = GraphicsControl.Size, - offscreen = true, - includeOSD = includeOSD - }; - UpdateSourceInternal(job); - return job.offscreenBB; - } - - class FakeVideoProvider : IVideoProvider - { - public int[] GetVideoBuffer() { return new int[] {}; } - - public int VirtualWidth { get; set; } - public int VirtualHeight { get; set; } - - public int BufferWidth { get; set; } - public int BufferHeight { get; set; } - public int BackgroundColor { get; set; } - - public int VsyncNumerator - { - get { throw new InvalidOperationException(); } - } - - public int VsyncDenominator - { - get { throw new InvalidOperationException(); } - } - } - - void FixRatio(float x, float y, int inw, int inh, out int outw, out int outh) - { - float ratio = x / y; - if (ratio <= 1) - { - //taller. weird. expand height. - outw = inw; - outh = (int)((float)inw / ratio); - } - else - { - //wider. normal. expand width. - outw = (int)((float)inh * ratio); - outh = inh; - } - } - - /// - /// Attempts to calculate a good client size with the given zoom factor, considering the user's DisplayManager preferences - /// TODO - this needs to be redone with a concept different from zoom factor. - /// basically, each increment of a 'zoomlike' factor should definitely increase the viewable area somehow, even if it isnt strictly by an entire zoom level. - /// - public Size CalculateClientSize(IVideoProvider videoProvider, int zoom) - { - bool ar_active = Global.Config.DispFixAspectRatio; - bool ar_system = Global.Config.DispManagerAR == Config.EDispManagerAR.System; - bool ar_custom = Global.Config.DispManagerAR == Config.EDispManagerAR.Custom; - bool ar_customRatio = Global.Config.DispManagerAR == Config.EDispManagerAR.CustomRatio; - bool ar_correct = ar_system || ar_custom || ar_customRatio; - bool ar_unity = !ar_correct; - bool ar_integer = Global.Config.DispFixScaleInteger; - - int bufferWidth = videoProvider.BufferWidth; - int bufferHeight = videoProvider.BufferHeight; - int virtualWidth = videoProvider.VirtualWidth; - int virtualHeight = videoProvider.VirtualHeight; - - if (ar_custom) - { - virtualWidth = Global.Config.DispCustomUserARWidth; - virtualHeight = Global.Config.DispCustomUserARHeight; - } - - if (ar_customRatio) - { - FixRatio(Global.Config.DispCustomUserARX, Global.Config.DispCustomUserARY, videoProvider.BufferWidth, videoProvider.BufferHeight, out virtualWidth, out virtualHeight); - } - - var padding = CalculateCompleteContentPadding(true, false); - virtualWidth += padding.Horizontal; - virtualHeight += padding.Vertical; - - padding = CalculateCompleteContentPadding(true, true); - bufferWidth += padding.Horizontal; - bufferHeight += padding.Vertical; - - //Console.WriteLine("DISPZOOM " + zoom); //test - - //old stuff - var fvp = new FakeVideoProvider(); - fvp.BufferWidth = bufferWidth; - fvp.BufferHeight = bufferHeight; - fvp.VirtualWidth = virtualWidth; - fvp.VirtualHeight = virtualHeight; - - Size chain_outsize = new Size(fvp.BufferWidth * zoom, fvp.BufferHeight * zoom); - - if (ar_active) - { - if (ar_correct) - { - if (ar_integer) - { - //ALERT COPYPASTE LAUNDROMAT - Vector2 VS = new Vector2(virtualWidth, virtualHeight); - Vector2 BS = new Vector2(bufferWidth, bufferHeight); - Vector2 AR = Vector2.Divide(VS, BS); - float target_par = (AR.X / AR.Y); - - //this would malfunction for AR <= 0.5 or AR >= 2.0 - //EDIT - in fact, we have AR like that coming from PSX, sometimes, so maybe we should solve this better - Vector2 PS = new Vector2(1, 1); - - //here's how we define zooming, in this case: - //make sure each step is an increment of zoom for at least one of the dimensions (or maybe both of them) - //look for the increment which helps the AR the best - //TODO - this cant possibly support scale factors like 1.5x - //TODO - also, this might be messing up zooms and stuff, we might need to run this on the output size of the filter chain - for (int i = 1; i < zoom;i++) - { - //would not be good to run this per frame, but it seems to only run when the resolution changes, etc. - Vector2[] trials = new[] { - PS + new Vector2(1, 0), - PS + new Vector2(0, 1), - PS + new Vector2(1, 1) - }; - int bestIndex = -1; - float bestValue = 1000.0f; - for (int t = 0; t < trials.Length; t++) - { - //I. - float test_ar = trials[t].X / trials[t].Y; - - //II. - //Vector2 calc = Vector2.Multiply(trials[t], VS); - //float test_ar = calc.X / calc.Y; - - //not clear which approach is superior - float deviation_linear = Math.Abs(test_ar - target_par); - float deviation_geom = test_ar / target_par; - if (deviation_geom < 1) deviation_geom = 1.0f / deviation_geom; - - float value = deviation_linear; - if (value < bestValue) - { - bestIndex = t; - bestValue = value; - } - } - //is it possible to get here without selecting one? doubtful. - //EDIT: YES IT IS. it happened with an 0,0 buffer size. of course, that was a mistake, but we shouldnt crash - if(bestIndex != -1) //so, what now? well, this will result in 0,0 getting picked, so thats probably all we can do - PS = trials[bestIndex]; - } - - chain_outsize = new Size((int)(bufferWidth * PS.X), (int)(bufferHeight * PS.Y)); - } - else - { - //obey the AR, but allow free scaling: just zoom the virtual size - chain_outsize = new Size(virtualWidth * zoom, virtualHeight * zoom); - } - } - else - { - //ar_unity: - //just choose to zoom the buffer (make no effort to incorporate AR) - chain_outsize = new Size(bufferWidth * zoom, bufferHeight * zoom); - } - } - else - { - //!ar_active: - //just choose to zoom the buffer (make no effort to incorporate AR) - chain_outsize = new Size(bufferWidth * zoom, bufferHeight * zoom); - } - - chain_outsize.Width += ClientExtraPadding.Horizontal; - chain_outsize.Height += ClientExtraPadding.Vertical; - - var job = new JobInfo - { - videoProvider = fvp, - simulate = true, - chain_outsize = chain_outsize, - }; - var filterProgram = UpdateSourceInternal(job); - - var size = filterProgram.Filters[filterProgram.Filters.Count - 1].FindOutput().SurfaceFormat.Size; - - return size; - } - - class JobInfo - { - public IVideoProvider videoProvider; - public bool simulate; - public Size chain_outsize; - public bool offscreen; - public BitmapBuffer offscreenBB; - public bool includeOSD; - } - - FilterProgram UpdateSourceInternal(JobInfo job) - { - if (job.chain_outsize.Width == 0 || job.chain_outsize.Height == 0) - { - //this has to be a NOP, because lots of stuff will malfunction on a 0-sized viewport - return null; - } - - //no drawing actually happens. it's important not to begin drawing on a control - if (!job.simulate && !job.offscreen) - { - GLManager.Activate(CR_GraphicsControl); - } - - IVideoProvider videoProvider = job.videoProvider; - bool simulate = job.simulate; - Size chain_outsize = job.chain_outsize; - - //simulate = true; - - int vw = videoProvider.BufferWidth; - int vh = videoProvider.BufferHeight; - - if (Global.Config.DispFixAspectRatio) - { - if (Global.Config.DispManagerAR == Config.EDispManagerAR.System) - { - vw = videoProvider.VirtualWidth; - vh = videoProvider.VirtualHeight; - } - if (Global.Config.DispManagerAR == Config.EDispManagerAR.Custom) - { - vw = Global.Config.DispCustomUserARWidth; - vh = Global.Config.DispCustomUserARHeight; - } - if (Global.Config.DispManagerAR == Config.EDispManagerAR.CustomRatio) - { - FixRatio(Global.Config.DispCustomUserARX, Global.Config.DispCustomUserARY, videoProvider.BufferWidth, videoProvider.BufferHeight, out vw, out vh); - } - } - - var padding = CalculateCompleteContentPadding(true,false); - vw += padding.Horizontal; - vh += padding.Vertical; - - int[] videoBuffer = videoProvider.GetVideoBuffer(); - - int bufferWidth = videoProvider.BufferWidth; - int bufferHeight = videoProvider.BufferHeight; - bool isGlTextureId = videoBuffer.Length == 1; - - BitmapBuffer bb = null; - Texture2d videoTexture = null; - if (!simulate) - { - if (isGlTextureId) - { - //FYI: this is a million years from happening on n64, since it's all geriatric non-FBO code - //is it workable for saturn? - videoTexture = GL.WrapGLTexture2d(new IntPtr(videoBuffer[0]), bufferWidth, bufferHeight); - } - else - { - //wrap the videoprovider data in a BitmapBuffer (no point to refactoring that many IVideoProviders) - bb = new BitmapBuffer(bufferWidth, bufferHeight, videoBuffer); - bb.DiscardAlpha(); - - //now, acquire the data sent from the videoProvider into a texture - videoTexture = VideoTextureFrugalizer.Get(bb); - - //lets not use this. lets define BizwareGL to make clamp by default (TBD: check opengl) - //GL.SetTextureWrapMode(videoTexture, true); - } - } - - //record the size of what we received, since lua and stuff is gonna want to draw onto it - currEmuWidth = bufferWidth; - currEmuHeight = bufferHeight; - - //build the default filter chain and set it up with services filters will need - Size chain_insize = new Size(bufferWidth, bufferHeight); - - var filterProgram = BuildDefaultChain(chain_insize, chain_outsize, job.includeOSD); - filterProgram.GuiRenderer = Renderer; - filterProgram.GL = GL; - - //setup the source image filter - EmuHawk.Filters.SourceImage fInput = filterProgram["input"] as EmuHawk.Filters.SourceImage; - fInput.Texture = videoTexture; - - //setup the final presentation filter - EmuHawk.Filters.FinalPresentation fPresent = filterProgram["presentation"] as EmuHawk.Filters.FinalPresentation; - fPresent.VirtualTextureSize = new Size(vw, vh); - fPresent.TextureSize = new Size(bufferWidth, bufferHeight); - fPresent.BackgroundColor = videoProvider.BackgroundColor; - fPresent.GuiRenderer = Renderer; - fPresent.Flip = isGlTextureId; - fPresent.Config_FixAspectRatio = Global.Config.DispFixAspectRatio; - fPresent.Config_FixScaleInteger = Global.Config.DispFixScaleInteger; - fPresent.Padding = ClientExtraPadding; - fPresent.AutoPrescale = Global.Config.DispAutoPrescale; - - fPresent.GL = GL; - - filterProgram.Compile("default", chain_insize, chain_outsize, !job.offscreen); - - if (simulate) - { - } - else - { - CurrentFilterProgram = filterProgram; - UpdateSourceDrawingWork(job); - } - - //cleanup: - if (bb != null) bb.Dispose(); - - return filterProgram; - } - - void UpdateSourceDrawingWork(JobInfo job) - { - bool vsync = false; - bool alternateVsync = false; - //only used by alternate vsync - IGL_SlimDX9 dx9 = null; - - if (!job.offscreen) - { - //apply the vsync setting (should probably try to avoid repeating this) - vsync = Global.Config.VSyncThrottle || Global.Config.VSync; - - //ok, now this is a bit undesireable. - //maybe the user wants vsync, but not vsync throttle. - //this makes sense... but we dont have the infrastructure to support it now (we'd have to enable triple buffering or something like that) - //so what we're gonna do is disable vsync no matter what if throttling is off, and maybe nobody will notice. - //update 26-mar-2016: this upsets me. When fastforwarding and skipping frames, vsync should still work. But I'm not changing it yet - if (Global.DisableSecondaryThrottling) - vsync = false; - - //for now, it's assumed that the presentation panel is the main window, but that may not always be true - if (vsync && Global.Config.DispAlternateVsync && Global.Config.VSyncThrottle) - { - dx9 = GL as IGL_SlimDX9; - if (dx9 != null) - { - alternateVsync = true; - //unset normal vsync if we've chosen the alternate vsync - vsync = false; - } - } - - //TODO - whats so hard about triple buffering anyway? just enable it always, and change api to SetVsync(enable,throttle) - //maybe even SetVsync(enable,throttlemethod) or just SetVsync(enable,throttle,advanced) - - if (LastVsyncSetting != vsync || LastVsyncSettingGraphicsControl != presentationPanel.GraphicsControl) - { - if (LastVsyncSetting == null && vsync) - { - // Workaround for vsync not taking effect at startup (Intel graphics related?) - presentationPanel.GraphicsControl.SetVsync(false); - } - presentationPanel.GraphicsControl.SetVsync(vsync); - LastVsyncSettingGraphicsControl = presentationPanel.GraphicsControl; - LastVsyncSetting = vsync; - } - } - - //begin rendering on this context - //should this have been done earlier? - //do i need to check this on an intel video card to see if running excessively is a problem? (it used to be in the FinalTarget command below, shouldnt be a problem) - //GraphicsControl.Begin(); //CRITICAL POINT for yabause+GL - - //TODO - auto-create and age these (and dispose when old) - int rtCounter = 0; - - CurrentFilterProgram.RenderTargetProvider = new DisplayManagerRenderTargetProvider((size) => ShaderChainFrugalizers[rtCounter++].Get(size)); - - GL.BeginScene(); - - //run filter chain - Texture2d texCurr = null; - RenderTarget rtCurr = null; - bool inFinalTarget = false; - foreach (var step in CurrentFilterProgram.Program) - { - switch (step.Type) - { - case FilterProgram.ProgramStepType.Run: - { - int fi = (int)step.Args; - var f = CurrentFilterProgram.Filters[fi]; - f.SetInput(texCurr); - f.Run(); - var orec = f.FindOutput(); - if (orec != null) - { - if (orec.SurfaceDisposition == SurfaceDisposition.Texture) - { - texCurr = f.GetOutput(); - rtCurr = null; - } - } - break; - } - case FilterProgram.ProgramStepType.NewTarget: - { - var size = (Size)step.Args; - rtCurr = ShaderChainFrugalizers[rtCounter++].Get(size); - rtCurr.Bind(); - CurrentFilterProgram.CurrRenderTarget = rtCurr; - break; - } - case FilterProgram.ProgramStepType.FinalTarget: - { - var size = (Size)step.Args; - inFinalTarget = true; - rtCurr = null; - CurrentFilterProgram.CurrRenderTarget = null; - GL.BindRenderTarget(null); - break; - } - } - } - - GL.EndScene(); - - if (job.offscreen) - { - job.offscreenBB = rtCurr.Texture2d.Resolve(); - job.offscreenBB.DiscardAlpha(); - } - else - { - Debug.Assert(inFinalTarget); - - //wait for vsync to begin - if (alternateVsync) dx9.AlternateVsyncPass(0); - - //present and conclude drawing - presentationPanel.GraphicsControl.SwapBuffers(); - - //wait for vsync to end - if (alternateVsync) dx9.AlternateVsyncPass(1); - - //nope. dont do this. workaround for slow context switching on intel GPUs. just switch to another context when necessary before doing anything - //presentationPanel.GraphicsControl.End(); - } - } - - bool? LastVsyncSetting; - GraphicsControl LastVsyncSettingGraphicsControl; - } -} \ No newline at end of file diff --git a/BizHawk.Client.MultiHawk/EmulatorWindow.Designer.cs b/BizHawk.Client.MultiHawk/EmulatorWindow.Designer.cs deleted file mode 100644 index 5fbddd196c..0000000000 --- a/BizHawk.Client.MultiHawk/EmulatorWindow.Designer.cs +++ /dev/null @@ -1,48 +0,0 @@ -namespace BizHawk.Client.MultiHawk -{ - partial class EmulatorWindow - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.SuspendLayout(); - // - // EmulatorWindow - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(284, 262); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.Name = "EmulatorWindow"; - this.ShowIcon = false; - this.Load += new System.EventHandler(this.EmulatorWindow_Load); - this.ResumeLayout(false); - - } - - #endregion - } -} \ No newline at end of file diff --git a/BizHawk.Client.MultiHawk/EmulatorWindow.cs b/BizHawk.Client.MultiHawk/EmulatorWindow.cs deleted file mode 100644 index 0ea193c46c..0000000000 --- a/BizHawk.Client.MultiHawk/EmulatorWindow.cs +++ /dev/null @@ -1,411 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; - -using BizHawk.Common; -using BizHawk.Common.BufferExtensions; -using BizHawk.Client.EmuHawk; -using BizHawk.Bizware.BizwareGL; -using BizHawk.Client.Common; -using BizHawk.Emulation.Common; -using BizHawk.Emulation.Common.IEmulatorExtensions; -using System.IO; - - -namespace BizHawk.Client.MultiHawk -{ - // TODO: we can safely assume videoprovider cores are a requirement of multihawk, - // but fail sooner and with a clear message instead of making misc calls to AsVideoProvider that will fail - public partial class EmulatorWindow : Form - { - public EmulatorWindow(Mainform parent) - { - InitializeComponent(); - Closing += (o, e) => - { - ShutDown(); - }; - - MainForm = parent; - } - - private void EmulatorWindow_Load(object sender, EventArgs e) - { - if (Game != null) - { - Text = Game.Name; - } - } - - public Mainform MainForm { get; private set; } - public IEmulator Emulator { get; set; } - public CoreComm CoreComm { get; set; } - public GameInfo Game { get; set; } - public string CurrentRomPath { get; set; } - - public IGL GL { get; set; } - public GLManager.ContextRef CR_GL { get; set; } - public GLManager GLManager { get; set; } - - public PresentationPanel PresentationPanel { get; set; } - - //public Sound Sound; // TODO - public DisplayManager DisplayManager; - - - public void Init() - { - PresentationPanel = new PresentationPanel(this, GL); - CR_GL = GLManager.GetContextForIGL(GL); - DisplayManager = new DisplayManager(PresentationPanel, GL ,GLManager); - - Controls.Add(PresentationPanel); - Controls.SetChildIndex(PresentationPanel, 0); - } - - public void ShutDown() - { - SaveRam(); - MainForm.EmulatorWindowClosed(this); - Emulator.Dispose(); - GL.Dispose(); - } - - public void LoadQuickSave(string quickSlotName) - { - if (!Emulator.HasSavestates()) - { - return; - } - - var path = PathManager.SaveStatePrefix(Game) + "." + quickSlotName + ".State"; - - if (LoadStateFile(path, quickSlotName)) - { - // SetMainformMovieInfo(); // TODO - MainForm.AddMessage("Loaded state: " + quickSlotName); - } - else - { - MainForm.AddMessage("Loadstate error!"); - } - } - - public bool LoadStateFile(string path, string name) - { - var core = Emulator.AsStatable(); - - // try to detect binary first - var bl = BinaryStateLoader.LoadAndDetect(path); - if (bl != null) - { - try - { - var succeed = false; - - // TODO - if (IAmMaster) - { - if (Global.MovieSession.Movie.IsActive) - { - bl.GetLump(BinaryStateLump.Input, true, tr => succeed = Global.MovieSession.HandleMovieLoadState_HackyStep1(tr)); - if (!succeed) - { - return false; - } - - bl.GetLump(BinaryStateLump.Input, true, tr => succeed = Global.MovieSession.HandleMovieLoadState_HackyStep2(tr)); - if (!succeed) - { - return false; - } - } - } - - using (new SimpleTime("Load Core")) - bl.GetCoreState(br => core.LoadStateBinary(br), tr => core.LoadStateText(tr)); - - bl.GetLump(BinaryStateLump.Framebuffer, false, PopulateFramebuffer); - } - catch - { - return false; - } - finally - { - bl.Dispose(); - } - - return true; - } - else // text mode - { - if (Global.MovieSession.HandleMovieLoadState(path)) - { - using (var reader = new StreamReader(path)) - { - core.LoadStateText(reader); - - while (true) - { - var str = reader.ReadLine(); - if (str == null) - { - break; - } - - if (str.Trim() == "") - { - continue; - } - - var args = str.Split(' '); - if (args[0] == "Framebuffer") - { - Emulator.AsVideoProvider().GetVideoBuffer().ReadFromHex(args[1]); - } - } - } - - return true; - } - else - { - return false; - } - } - } - - public void PopulateFramebuffer(BinaryReader br) - { - try - { - using (new SimpleTime("Load Framebuffer")) - QuickBmpFile.Load(Emulator.AsVideoProvider(), br.BaseStream); - } - catch - { - var buff = Emulator.AsVideoProvider().GetVideoBuffer(); - try - { - for (int i = 0; i < buff.Length; i++) - { - int j = br.ReadInt32(); - buff[i] = j; - } - } - catch (EndOfStreamException) { } - } - } - - public void SaveQuickSave(string quickSlotName) - { - if (!Emulator.HasSavestates()) - { - return; - } - - var path = PathManager.SaveStatePrefix(Game) + "." + quickSlotName + ".State"; - - var file = new FileInfo(path); - if (file.Directory != null && file.Directory.Exists == false) - { - file.Directory.Create(); - } - - // TODO - // Make backup first - //if (Global.Config.BackupSavestates && file.Exists) - //{ - // var backup = path + ".bak"; - // var backupFile = new FileInfo(backup); - // if (backupFile.Exists) - // { - // backupFile.Delete(); - // } - - // File.Move(path, backup); - //} - - try - { - SaveStateFile(path, quickSlotName); - - MainForm.AddMessage("Saved state: " + quickSlotName); - } - catch (IOException) - { - MainForm.AddMessage("Unable to save state " + path); - } - - // TODO - } - - private void SaveStateFile(string filename, string name) - { - var core = Emulator.AsStatable(); - - using (var bs = new BinaryStateSaver(filename)) - { - if (Global.Config.SaveStateType == Config.SaveStateTypeE.Text || - (Global.Config.SaveStateType == Config.SaveStateTypeE.Default && !core.BinarySaveStatesPreferred)) - { - // text savestate format - using (new SimpleTime("Save Core")) - bs.PutLump(BinaryStateLump.CorestateText, (tw) => core.SaveStateText(tw)); - } - else - { - // binary core lump format - using (new SimpleTime("Save Core")) - bs.PutLump(BinaryStateLump.Corestate, bw => core.SaveStateBinary(bw)); - } - - if (true) //TODO: Global.Config.SaveScreenshotWithStates) - { - var vp = Emulator.AsVideoProvider(); - var buff = vp.GetVideoBuffer(); - - int out_w = vp.BufferWidth; - int out_h = vp.BufferHeight; - - // if buffer is too big, scale down screenshot - if (true /* !Global.Config.NoLowResLargeScreenshotWithStates*/ && buff.Length >= Global.Config.BigScreenshotSize) - { - out_w /= 2; - out_h /= 2; - } - using (new SimpleTime("Save Framebuffer")) - bs.PutLump(BinaryStateLump.Framebuffer, (s) => QuickBmpFile.Save(Emulator.AsVideoProvider(), s, out_w, out_h)); - } - - if (IAmMaster) - { - if (Global.MovieSession.Movie.IsActive) - { - bs.PutLump(BinaryStateLump.Input, - delegate(TextWriter tw) - { - // this never should have been a core's responsibility - tw.WriteLine("Frame {0}", Emulator.Frame); - Global.MovieSession.HandleMovieSaveState(tw); - }); - } - } - } - } - - public bool IAmMaster - { - get - { - return MainForm.EmulatorWindows.First() == this; - } - } - - public void FrameBufferResized() - { - // run this entire thing exactly twice, since the first resize may adjust the menu stacking - for (int i = 0; i < 2; i++) - { - var video = Emulator.AsVideoProvider(); - int zoom = Global.Config.TargetZoomFactors[Global.Emulator.SystemId]; - var area = Screen.FromControl(this).WorkingArea; - - int borderWidth = Size.Width - PresentationPanel.Control.Size.Width; - int borderHeight = Size.Height - PresentationPanel.Control.Size.Height; - - // start at target zoom and work way down until we find acceptable zoom - Size lastComputedSize = new Size(1, 1); - for (; zoom >= 1; zoom--) - { - lastComputedSize = DisplayManager.CalculateClientSize(video, zoom); - if ((((lastComputedSize.Width) + borderWidth) < area.Width) - && (((lastComputedSize.Height) + borderHeight) < area.Height)) - { - break; - } - } - Console.WriteLine("Selecting display size " + lastComputedSize.ToString()); - - // Change size - Size = new Size((lastComputedSize.Width) + borderWidth, ((lastComputedSize.Height) + borderHeight)); - PerformLayout(); - PresentationPanel.Resized = true; - - // Is window off the screen at this size? - if (area.Contains(Bounds) == false) - { - if (Bounds.Right > area.Right) // Window is off the right edge - { - Location = new Point(area.Right - Size.Width, Location.Y); - } - - if (Bounds.Bottom > area.Bottom) // Window is off the bottom edge - { - Location = new Point(Location.X, area.Bottom - Size.Height); - } - } - } - } - - private Size _lastVideoSize = new Size(-1, -1), _lastVirtualSize = new Size(-1, -1); - public void Render() - { - var video = Emulator.AsVideoProvider(); - - Size currVideoSize = new Size(video.BufferWidth, video.BufferHeight); - Size currVirtualSize = new Size(video.VirtualWidth, video.VirtualWidth); - if (currVideoSize != _lastVideoSize || currVirtualSize != _lastVirtualSize) - { - _lastVideoSize = currVideoSize; - _lastVirtualSize = currVirtualSize; - FrameBufferResized(); - } - - DisplayManager.UpdateSource(video); - } - - public void FrameAdvance() - { - Emulator.FrameAdvance(Global.ControllerOutput, true); - } - - public void SaveRam() - { - if (Emulator.HasSaveRam() && Emulator.AsSaveRam().SaveRamModified) - { - var path = PathManager.SaveRamPath(Global.Game); - var f = new FileInfo(path); - if (f.Directory != null && f.Directory.Exists == false) - { - f.Directory.Create(); - } - - // Make backup first - if (Global.Config.BackupSaveram && f.Exists) - { - var backup = path + ".bak"; - var backupFile = new FileInfo(backup); - if (backupFile.Exists) - { - backupFile.Delete(); - } - - f.CopyTo(backup); - } - - var writer = new BinaryWriter(new FileStream(path, FileMode.Create, FileAccess.Write)); - var saveram = Emulator.AsSaveRam().CloneSaveRam(); - - writer.Write(saveram, 0, saveram.Length); - writer.Close(); - } - } - } -} diff --git a/BizHawk.Client.MultiHawk/EmulatorWindow.resx b/BizHawk.Client.MultiHawk/EmulatorWindow.resx deleted file mode 100644 index 29dcb1b3a3..0000000000 --- a/BizHawk.Client.MultiHawk/EmulatorWindow.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/BizHawk.Client.MultiHawk/EmulatorWindowList.cs b/BizHawk.Client.MultiHawk/EmulatorWindowList.cs deleted file mode 100644 index 1da78079a1..0000000000 --- a/BizHawk.Client.MultiHawk/EmulatorWindowList.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using Newtonsoft.Json; - -namespace BizHawk.Client.MultiHawk -{ - public class EmulatorWindowList : List - { - public string SessionName { get; set; } - - public EmulatorWindow Master - { - get - { - if (this.Any()) - { - return this.First(); - } - - return null; - } - } - - public IEnumerable Session - { - get - { - return this.Select(ew => new RomSessionEntry - { - RomName = ew.CurrentRomPath, - Wndx = ew.Location.X, - Wndy = ew.Location.Y - }); - } - } - - public string SessionJson - { - get - { - return JsonConvert.SerializeObject(Session); - } - } - - public static IEnumerable FromJson(string json) - { - return JsonConvert.DeserializeObject>(json); - } - - public new void Clear() - { - SessionName = ""; - base.Clear(); - } - - public class RomSessionEntry - { - public string RomName { get; set; } - public int Wndx { get; set; } - public int Wndy { get; set; } - } - } -} diff --git a/BizHawk.Client.MultiHawk/Extensions/ToolExtensions.cs b/BizHawk.Client.MultiHawk/Extensions/ToolExtensions.cs deleted file mode 100644 index 5648ebc66f..0000000000 --- a/BizHawk.Client.MultiHawk/Extensions/ToolExtensions.cs +++ /dev/null @@ -1,228 +0,0 @@ -using System; -using System.IO; -using System.Collections.Generic; -using System.Windows.Forms; -using System.Linq; - -using BizHawk.Common; - -using BizHawk.Emulation.Common; -using BizHawk.Client.Common; - -namespace BizHawk.Client.MultiHawk.ToolExtensions -{ - public static class ToolExtensions - { - public static ToolStripItem[] RecentMenu(this RecentFiles recent, Action loadFileCallback, bool autoload = false) - { - var items = new List(); - - if (recent.Empty) - { - var none = new ToolStripMenuItem { Enabled = false, Text = "None" }; - items.Add(none); - } - else - { - foreach (var filename in recent) - { - //TODO - do TSMI and TSDD need disposing? yuck - var temp = filename; - var item = new ToolStripMenuItem { Text = temp }; - items.Add(item); - - item.Click += (o, ev) => - { - loadFileCallback(temp); - }; - - //TODO - use standard methods to split filename (hawkfile acquire?) - var hf = new HawkFile(); - hf.Parse(temp); - bool canExplore = true; - if (!File.Exists(hf.FullPathWithoutMember)) - canExplore = false; - - var tsdd = new ToolStripDropDownMenu(); - - // TODO - if (canExplore) - { - //make a menuitem to show the last modified timestamp - // var timestamp = File.GetLastWriteTime(hf.FullPathWithoutMember); - // var tsmiTimestamp = new ToolStripLabel { Text = timestamp.ToString() }; - - // tsdd.Items.Add(tsmiTimestamp); - // tsdd.Items.Add(new ToolStripSeparator()); - - - - // if (hf.IsArchive) - // { - // //make a menuitem to let you copy the path - // var tsmiCopyCanonicalPath = new ToolStripMenuItem { Text = "&Copy Canonical Path" }; - // tsmiCopyCanonicalPath.Click += (o, ev) => { System.Windows.Forms.Clipboard.SetText(temp); }; - // tsdd.Items.Add(tsmiCopyCanonicalPath); - - // var tsmiCopyArchivePath = new ToolStripMenuItem { Text = "Copy Archive Path" }; - // tsmiCopyArchivePath.Click += (o, ev) => { System.Windows.Forms.Clipboard.SetText(hf.FullPathWithoutMember); }; - // tsdd.Items.Add(tsmiCopyArchivePath); - - // var tsmiOpenArchive = new ToolStripMenuItem { Text = "Open &Archive" }; - // tsmiOpenArchive.Click += (o, ev) => { System.Diagnostics.Process.Start(hf.FullPathWithoutMember); }; - // tsdd.Items.Add(tsmiOpenArchive); - // } - // else - // { - // //make a menuitem to let you copy the path - // var tsmiCopyPath = new ToolStripMenuItem { Text = "&Copy Path" }; - // tsmiCopyPath.Click += (o, ev) => { System.Windows.Forms.Clipboard.SetText(temp); }; - // tsdd.Items.Add(tsmiCopyPath); - // } - - // tsdd.Items.Add(new ToolStripSeparator()); - - // //make a menuitem to let you explore to it - // var tsmiExplore = new ToolStripMenuItem { Text = "&Explore" }; - // string explorePath = "\"" + hf.FullPathWithoutMember + "\""; - // tsmiExplore.Click += (o, ev) => { System.Diagnostics.Process.Start("explorer.exe", "/select, " + explorePath); }; - // tsdd.Items.Add(tsmiExplore); - - // var tsmiCopyFile = new ToolStripMenuItem { Text = "Copy &File" }; - // var lame = new System.Collections.Specialized.StringCollection(); - // lame.Add(hf.FullPathWithoutMember); - // tsmiCopyFile.Click += (o, ev) => { System.Windows.Forms.Clipboard.SetFileDropList(lame); }; - // tsdd.Items.Add(tsmiCopyFile); - - // var tsmiTest = new ToolStripMenuItem { Text = "&Shell Context Menu" }; - // tsmiTest.Click += (o, ev) => { - // var si = new GongSolutions.Shell.ShellItem(hf.FullPathWithoutMember); - // var scm = new GongSolutions.Shell.ShellContextMenu(si); - // var tsddi = o as ToolStripDropDownItem; - // tsddi.Owner.Update(); - // scm.ShowContextMenu(tsddi.Owner, new System.Drawing.Point(0, 0)); - // }; - // tsdd.Items.Add(tsmiTest); - - // tsdd.Items.Add(new ToolStripSeparator()); - //} - //else - //{ - // //make a menuitem to show the last modified timestamp - // var tsmiMissingFile = new ToolStripLabel { Text = "-Missing-" }; - // tsdd.Items.Add(tsmiMissingFile); - // tsdd.Items.Add(new ToolStripSeparator()); - //} - - ////in either case, make a menuitem to let you remove the path - //var tsmiRemovePath = new ToolStripMenuItem { Text = "&Remove" }; - //tsmiRemovePath.Click += (o, ev) => { recent.Remove(temp); }; - - //tsdd.Items.Add(tsmiRemovePath); - - //////experiment of popping open a submenu. doesnt work well. - ////item.MouseDown += (o, mev) => - ////{ - //// if (mev.Button != MouseButtons.Right) return; - //// //location of the menu containing this item that was just rightclicked - //// var pos = item.Owner.Bounds.Location; - //// //the offset within that menu of this item - //// var tsddi = item as ToolStripDropDownItem; - //// pos.Offset(tsddi.Bounds.Location); - //// //the offset of the click - //// pos.Offset(mev.Location); - //// //tsdd.OwnerItem = item; //has interesting promise, but breaks things otherwise - //// tsdd.Show(pos); - ////}; - - ////just add it to the submenu for now - //item.MouseDown += (o, mev) => - //{ - // if (mev.Button != MouseButtons.Right) return; - // if (item.DropDown != null) - // item.DropDown = tsdd; - // item.ShowDropDown(); - }; - } - } - - items.Add(new ToolStripSeparator()); - - var clearitem = new ToolStripMenuItem { Text = "&Clear", Enabled = !recent.Frozen }; - clearitem.Click += (o, ev) => recent.Clear(); - items.Add(clearitem); - - var freezeitem = new ToolStripMenuItem { Text = recent.Frozen ? "&Unfreeze" : "&Freeze" }; - freezeitem.Click += (o, ev) => recent.Frozen ^= true; - items.Add(freezeitem); - - if (autoload) - { - var auto = new ToolStripMenuItem { Text = "&Autoload", Checked = recent.AutoLoad }; - auto.Click += (o, ev) => recent.ToggleAutoLoad(); - items.Add(auto); - } - - // TODO - //var settingsitem = new ToolStripMenuItem { Text = "&Recent Settings..." }; - //settingsitem.Click += (o, ev) => - //{ - // using (var prompt = new InputPrompt - // { - // TextInputType = InputPrompt.InputType.Unsigned, - // Message = "Number of recent files to track", - // InitialValue = recent.MAX_RECENT_FILES.ToString() - // }) - // { - // var result = prompt.ShowDialog(); - // if (result == DialogResult.OK) - // { - // int val = int.Parse(prompt.PromptText); - // if (val > 0) - // recent.MAX_RECENT_FILES = val; - // } - // } - //}; - //items.Add(settingsitem); - - return items.ToArray(); - } - - public static void HandleLoadError(this RecentFiles recent, string path) - { - // TODO - //GlobalWin.Sound.StopSound(); - if (recent.Frozen) - { - var result = MessageBox.Show("Could not open " + path, "File not found", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - else - { - var result = MessageBox.Show("Could not open " + path + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error); - if (result == DialogResult.Yes) - { - recent.Remove(path); - } - } - - //GlobalWin.Sound.StartSound(); - } - - public static IEnumerable MenuItems(this IMemoryDomains domains, Action setCallback, string selected = "", int? maxSize = null) - { - foreach (var domain in domains) - { - var name = domain.Name; - var item = new ToolStripMenuItem - { - Text = name, - Enabled = !(maxSize.HasValue && domain.Size > maxSize.Value), - Checked = name == selected - }; - item.Click += (o, ev) => setCallback(name); - - yield return item; - } - } - } -} diff --git a/BizHawk.Client.MultiHawk/GlobalWin.cs b/BizHawk.Client.MultiHawk/GlobalWin.cs deleted file mode 100644 index 45794b7700..0000000000 --- a/BizHawk.Client.MultiHawk/GlobalWin.cs +++ /dev/null @@ -1,25 +0,0 @@ -using BizHawk.Client.Common; -using BizHawk.Bizware.BizwareGL; -using SlimDX.DirectSound; - -namespace BizHawk.Client.MultiHawk -{ - public static class GlobalWin - { - public static Mainform MainForm; - //public static ToolManager Tools; - public static IGL GL; - public static Bizware.BizwareGL.Drivers.OpenTK.IGL_TK IGL_GL; - public static BizHawk.Client.EmuHawk.GLManager.ContextRef CR_GL; - //public static Sound Sound; - //public static PresentationPanel PresentationPanel; - //public static OSDManager OSD = new OSDManager(); - //public static DisplayManager DisplayManager; - public static BizHawk.Client.EmuHawk.GLManager GLManager; - - //input state which has been destined for game controller inputs are coalesced here - //public static ControllerInputCoalescer ControllerInputCoalescer = new ControllerInputCoalescer(); - //input state which has been destined for client hotkey consumption are colesced here - public static InputCoalescer HotkeyCoalescer = new InputCoalescer(); - } -} diff --git a/BizHawk.Client.MultiHawk/Input/GamePad.cs b/BizHawk.Client.MultiHawk/Input/GamePad.cs deleted file mode 100644 index 75e03c44a2..0000000000 --- a/BizHawk.Client.MultiHawk/Input/GamePad.cs +++ /dev/null @@ -1,235 +0,0 @@ -using System; -using System.Collections.Generic; -using SlimDX; -using SlimDX.DirectInput; - -namespace BizHawk.Client.MultiHawk -{ - public class GamePad - { - // ********************************** Static interface ********************************** - - static DirectInput dinput; - public static List Devices; - - public static void Initialize(IntPtr parent) - { - if (dinput == null) - dinput = new DirectInput(); - - Devices = new List(); - - foreach (DeviceInstance device in dinput.GetDevices(DeviceClass.GameController, DeviceEnumerationFlags.AttachedOnly)) - { - Console.WriteLine("joydevice: {0} `{1}`", device.InstanceGuid, device.ProductName); - - if (device.ProductName.Contains("XBOX 360")) - continue; // Don't input XBOX 360 controllers into here; we'll process them via XInput (there are limitations in some trigger axes when xbox pads go over xinput) - - var joystick = new Joystick(dinput, device.InstanceGuid); - joystick.SetCooperativeLevel(parent, CooperativeLevel.Background | CooperativeLevel.Nonexclusive); - foreach (DeviceObjectInstance deviceObject in joystick.GetObjects()) - { - if ((deviceObject.ObjectType & ObjectDeviceType.Axis) != 0) - joystick.GetObjectPropertiesById((int)deviceObject.ObjectType).SetRange(-1000, 1000); - } - joystick.Acquire(); - - GamePad p = new GamePad(device.InstanceName, device.InstanceGuid, joystick); - Devices.Add(p); - } - } - - public static void UpdateAll() - { - foreach (var device in Devices) - device.Update(); - } - - public static void CloseAll() - { - if (Devices != null) - { - foreach (var device in Devices) - device.joystick.Dispose(); - Devices.Clear(); - } - } - - // ********************************** Instance Members ********************************** - - readonly string name; - readonly Guid guid; - readonly Joystick joystick; - JoystickState state = new JoystickState(); - - GamePad(string name, Guid guid, Joystick joystick) - { - this.name = name; - this.guid = guid; - this.joystick = joystick; - Update(); - InitializeCallbacks(); - } - - public void Update() - { - try - { - if (joystick.Acquire().IsFailure) - return; - } - catch - { - return; - } - if (joystick.Poll().IsFailure) - return; - - state = joystick.GetCurrentState(); - if (Result.Last.IsFailure) - // do something? - return; - } - - public IEnumerable> GetFloats() - { - var pis = typeof(JoystickState).GetProperties(); - foreach (var pi in pis) - yield return new Tuple(pi.Name, 10.0f * (float)(int)pi.GetValue(state, null)); - } - - /// FOR DEBUGGING ONLY - public JoystickState GetInternalState() - { - return state; - } - - public string Name { get { return name; } } - public Guid Guid { get { return guid; } } - - - public string ButtonName(int index) - { - return names[index]; - } - public bool Pressed(int index) - { - return actions[index](); - } - public int NumButtons { get; private set; } - - private readonly List names = new List(); - private readonly List> actions = new List>(); - - void AddItem(string _name, Func callback) - { - names.Add(_name); - actions.Add(callback); - NumButtons++; - } - - void InitializeCallbacks() - { - const int dzp = 400; - const int dzn = -400; - - names.Clear(); - actions.Clear(); - NumButtons = 0; - - AddItem("AccelerationX+", () => state.AccelerationX >= dzp); - AddItem("AccelerationX-", () => state.AccelerationX <= dzn); - AddItem("AccelerationY+", () => state.AccelerationY >= dzp); - AddItem("AccelerationY-", () => state.AccelerationY <= dzn); - AddItem("AccelerationZ+", () => state.AccelerationZ >= dzp); - AddItem("AccelerationZ-", () => state.AccelerationZ <= dzn); - AddItem("AngularAccelerationX+", () => state.AngularAccelerationX >= dzp); - AddItem("AngularAccelerationX-", () => state.AngularAccelerationX <= dzn); - AddItem("AngularAccelerationY+", () => state.AngularAccelerationY >= dzp); - AddItem("AngularAccelerationY-", () => state.AngularAccelerationY <= dzn); - AddItem("AngularAccelerationZ+", () => state.AngularAccelerationZ >= dzp); - AddItem("AngularAccelerationZ-", () => state.AngularAccelerationZ <= dzn); - AddItem("AngularVelocityX+", () => state.AngularVelocityX >= dzp); - AddItem("AngularVelocityX-", () => state.AngularVelocityX <= dzn); - AddItem("AngularVelocityY+", () => state.AngularVelocityY >= dzp); - AddItem("AngularVelocityY-", () => state.AngularVelocityY <= dzn); - AddItem("AngularVelocityZ+", () => state.AngularVelocityZ >= dzp); - AddItem("AngularVelocityZ-", () => state.AngularVelocityZ <= dzn); - AddItem("ForceX+", () => state.ForceX >= dzp); - AddItem("ForceX-", () => state.ForceX <= dzn); - AddItem("ForceY+", () => state.ForceY >= dzp); - AddItem("ForceY-", () => state.ForceY <= dzn); - AddItem("ForceZ+", () => state.ForceZ >= dzp); - AddItem("ForceZ-", () => state.ForceZ <= dzn); - AddItem("RotationX+", () => state.RotationX >= dzp); - AddItem("RotationX-", () => state.RotationX <= dzn); - AddItem("RotationY+", () => state.RotationY >= dzp); - AddItem("RotationY-", () => state.RotationY <= dzn); - AddItem("RotationZ+", () => state.RotationZ >= dzp); - AddItem("RotationZ-", () => state.RotationZ <= dzn); - AddItem("TorqueX+", () => state.TorqueX >= dzp); - AddItem("TorqueX-", () => state.TorqueX <= dzn); - AddItem("TorqueY+", () => state.TorqueY >= dzp); - AddItem("TorqueY-", () => state.TorqueY <= dzn); - AddItem("TorqueZ+", () => state.TorqueZ >= dzp); - AddItem("TorqueZ-", () => state.TorqueZ <= dzn); - AddItem("VelocityX+", () => state.VelocityX >= dzp); - AddItem("VelocityX-", () => state.VelocityX <= dzn); - AddItem("VelocityY+", () => state.VelocityY >= dzp); - AddItem("VelocityY-", () => state.VelocityY <= dzn); - AddItem("VelocityZ+", () => state.VelocityZ >= dzp); - AddItem("VelocityZ-", () => state.VelocityZ <= dzn); - AddItem("X+", () => state.X >= dzp); - AddItem("X-", () => state.X <= dzn); - AddItem("Y+", () => state.Y >= dzp); - AddItem("Y-", () => state.Y <= dzn); - AddItem("Z+", () => state.Z >= dzp); - AddItem("Z-", () => state.Z <= dzn); - - // i don't know what the "Slider"s do, so they're omitted for the moment - - for (int i = 0; i < state.GetButtons().Length; i++) - { - int j = i; - AddItem($"B{i + 1}", () => state.IsPressed(j)); - } - - for (int i = 0; i < state.GetPointOfViewControllers().Length; i++) - { - int j = i; - AddItem($"POV{i + 1}U", - () => { int t = state.GetPointOfViewControllers()[j]; return (t >= 0 && t <= 4500) || (t >= 31500 && t < 36000); }); - AddItem($"POV{i + 1}D", - () => { int t = state.GetPointOfViewControllers()[j]; return t >= 13500 && t <= 22500; }); - AddItem($"POV{i + 1}L", - () => { int t = state.GetPointOfViewControllers()[j]; return t >= 22500 && t <= 31500; }); - AddItem($"POV{i + 1}R", - () => { int t = state.GetPointOfViewControllers()[j]; return t >= 4500 && t <= 13500; }); - } - } - - // Note that this does not appear to work at this time. I probably need to have more infos. - public void SetVibration(int left, int right) - { - int[] temp1, temp2; - // my first clue that it doesnt work is that LEFT and RIGHT _ARENT USED_ - // I should just look for C++ examples instead of trying to look for SlimDX examples - - var parameters = new EffectParameters - { - Duration = 0x2710, - Gain = 0x2710, - SamplePeriod = 0, - TriggerButton = 0, - TriggerRepeatInterval = 0x2710, - Flags = EffectFlags.None - }; - parameters.GetAxes(out temp1, out temp2); - parameters.SetAxes(temp1, temp2); - var effect = new Effect(joystick, EffectGuid.ConstantForce); - effect.SetParameters(parameters); - effect.Start(1); - } - } -} \ No newline at end of file diff --git a/BizHawk.Client.MultiHawk/Input/Input.cs b/BizHawk.Client.MultiHawk/Input/Input.cs deleted file mode 100644 index 9c3abc76f0..0000000000 --- a/BizHawk.Client.MultiHawk/Input/Input.cs +++ /dev/null @@ -1,511 +0,0 @@ -using System; -using System.Linq; -using System.Collections.Generic; -using System.Threading; -#if WINDOWS -using SlimDX.DirectInput; -#endif - -using BizHawk.Common; -using BizHawk.Client.Common; - -namespace BizHawk.Client.MultiHawk -{ - //coalesces events back into instantaneous states - public class InputCoalescer : SimpleController - { - public void Receive(Input.InputEvent ie) - { - bool state = ie.EventType == Input.InputEventType.Press; - - string button = ie.LogicalButton.ToString(); - Buttons[button] = state; - - //when a button is released, all modified variants of it are released as well - if (!state) - { - var releases = Buttons.Where(kvp => kvp.Key.Contains("+") && kvp.Key.EndsWith(ie.LogicalButton.Button)).ToArray(); - foreach (var kvp in releases) - Buttons[kvp.Key] = false; - } - } - } - - public class ControllerInputCoalescer : SimpleController - { - public void Receive(Input.InputEvent ie) - { - bool state = ie.EventType == Input.InputEventType.Press; - - string button = ie.LogicalButton.ToString(); - Buttons[button] = state; - - //For controller input, we want Shift+X to register as both Shift and X (for Keyboard controllers) - string[] subgroups = button.Split('+'); - if (subgroups.Length > 0) - { - foreach (string s in subgroups) - { - Buttons[s] = state; - } - } - - //when a button is released, all modified variants of it are released as well - if (!state) - { - var releases = Buttons.Where((kvp) => kvp.Key.Contains("+") && kvp.Key.EndsWith(ie.LogicalButton.Button)).ToArray(); - foreach (var kvp in releases) - Buttons[kvp.Key] = false; - } - } - } - - public class Input - { - [Flags] - public enum InputFocus - { - None = 0, - Mouse = 1, - Keyboard = 2, - Pad = 4 - } - - /// - /// If your form needs this kind of input focus, be sure to say so. - /// Really, this only makes sense for mouse, but I've started building it out for other things - /// Why is this receiving a control, but actually using it as a Form (where the WantingMouseFocus is checked?) - /// Because later we might change it to work off the control, specifically, if a control is supplied (normally actually a Form will be supplied) - /// - public void ControlInputFocus(System.Windows.Forms.Control c, InputFocus types, bool wants) - { - if (types.HasFlag(InputFocus.Mouse) && wants) WantingMouseFocus.Add(c); - if (types.HasFlag(InputFocus.Mouse) && !wants) WantingMouseFocus.Remove(c); - } - - HashSet WantingMouseFocus = new HashSet(); - - [Flags] - public enum ModifierKey - { - // Summary: - // The bitmask to extract modifiers from a key value. - Modifiers = -65536, - // - // Summary: - // No key pressed. - None = 0, - // - // Summary: - // The SHIFT modifier key. - Shift = 65536, - // - // Summary: - // The CTRL modifier key. - Control = 131072, - // - // Summary: - // The ALT modifier key. - Alt = 262144, - } - - public static Input Instance { get; private set; } - readonly Thread UpdateThread; - - private Input() - { -#if WINDOWS - UpdateThread = new Thread(UpdateThreadProc) - { - IsBackground = true, - Priority = ThreadPriority.AboveNormal //why not? this thread shouldn't be very heavy duty, and we want it to be responsive - }; - UpdateThread.Start(); -#endif - } - - public static void Initialize(IntPtr parent) - { -#if WINDOWS - KeyInput.Initialize(parent); - GamePad.Initialize(parent); - BizHawk.Client.EmuHawk.GamePad360.Initialize(); -#endif - Instance = new Input(); - } - - public enum InputEventType - { - Press, Release - } - public struct LogicalButton - { - public LogicalButton(string button, ModifierKey modifiers) - { - Button = button; - Modifiers = modifiers; - } - public readonly string Button; - public readonly ModifierKey Modifiers; - - public bool Alt { get { return ((Modifiers & ModifierKey.Alt) != 0); } } - public bool Control { get { return ((Modifiers & ModifierKey.Control) != 0); } } - public bool Shift { get { return ((Modifiers & ModifierKey.Shift) != 0); } } - - public override string ToString() - { - string ret = ""; - if (Control) ret += "Ctrl+"; - if (Alt) ret += "Alt+"; - if (Shift) ret += "Shift+"; - ret += Button; - return ret; - } - public override bool Equals(object obj) - { - var other = (LogicalButton)obj; - return other == this; - } - public override int GetHashCode() - { - return Button.GetHashCode() ^ Modifiers.GetHashCode(); - } - public static bool operator ==(LogicalButton lhs, LogicalButton rhs) - { - return lhs.Button == rhs.Button && lhs.Modifiers == rhs.Modifiers; - } - public static bool operator !=(LogicalButton lhs, LogicalButton rhs) - { - return !(lhs == rhs); - } - } - public class InputEvent - { - public LogicalButton LogicalButton; - public InputEventType EventType; - public override string ToString() => $"{EventType.ToString()}:{LogicalButton.ToString()}"; - } - - private readonly WorkingDictionary ModifierState = new WorkingDictionary(); - private readonly WorkingDictionary LastState = new WorkingDictionary(); - private readonly WorkingDictionary UnpressState = new WorkingDictionary(); - private readonly HashSet IgnoreKeys = new HashSet(new[] { "LeftShift", "RightShift", "LeftControl", "RightControl", "LeftAlt", "RightAlt" }); - private readonly WorkingDictionary FloatValues = new WorkingDictionary(); - private readonly WorkingDictionary FloatDeltas = new WorkingDictionary(); - private bool trackdeltas = false; - - void HandleButton(string button, bool newState) - { - bool isModifier = IgnoreKeys.Contains(button); - if (EnableIgnoreModifiers && isModifier) return; - if (LastState[button] && newState) return; - if (!LastState[button] && !newState) return; - - //apply - //NOTE: this is not quite right. if someone held leftshift+rightshift it would be broken. seems unlikely, though. - if (button == "LeftShift") - { - _Modifiers &= ~ModifierKey.Shift; - if (newState) - _Modifiers |= ModifierKey.Shift; - } - if (button == "RightShift") { _Modifiers &= ~ModifierKey.Shift; if (newState) _Modifiers |= ModifierKey.Shift; } - if (button == "LeftControl") { _Modifiers &= ~ModifierKey.Control; if (newState) _Modifiers |= ModifierKey.Control; } - if (button == "RightControl") { _Modifiers &= ~ModifierKey.Control; if (newState) _Modifiers |= ModifierKey.Control; } - if (button == "LeftAlt") { _Modifiers &= ~ModifierKey.Alt; if (newState) _Modifiers |= ModifierKey.Alt; } - if (button == "RightAlt") { _Modifiers &= ~ModifierKey.Alt; if (newState) _Modifiers |= ModifierKey.Alt; } - - if (UnpressState.ContainsKey(button)) - { - if (newState) return; - Console.WriteLine($"Removing Unpress {button} with {nameof(newState)} {newState}"); - UnpressState.Remove(button); - LastState[button] = false; - return; - } - - - //dont generate events for things like Ctrl+LeftControl - ModifierKey mods = _Modifiers; - if (button == "LeftShift") mods &= ~ModifierKey.Shift; - if (button == "RightShift") mods &= ~ModifierKey.Shift; - if (button == "LeftControl") mods &= ~ModifierKey.Control; - if (button == "RightControl") mods &= ~ModifierKey.Control; - if (button == "LeftAlt") mods &= ~ModifierKey.Alt; - if (button == "RightAlt") mods &= ~ModifierKey.Alt; - - var ie = new InputEvent - { - EventType = newState ? InputEventType.Press : InputEventType.Release, - LogicalButton = new LogicalButton(button, mods) - }; - LastState[button] = newState; - - //track the pressed events with modifiers that we send so that we can send corresponding unpresses with modifiers - //this is an interesting idea, which we may need later, but not yet. - //for example, you may see this series of events: press:ctrl+c, release:ctrl, release:c - //but you might would rather have press:ctr+c, release:ctrl+c - //this code relates the releases to the original presses. - //UPDATE - this is necessary for the frame advance key, which has a special meaning when it gets stuck down - //so, i am adding it as of 11-sep-2011 - if (newState) - { - ModifierState[button] = ie.LogicalButton; - } - else - { - if (ModifierState[button] != null) - { - LogicalButton alreadyReleased = ie.LogicalButton; - var ieModified = new InputEvent - { - LogicalButton = (LogicalButton)ModifierState[button], - EventType = InputEventType.Release - }; - if (ieModified.LogicalButton != alreadyReleased) - _NewEvents.Add(ieModified); - } - ModifierState[button] = null; - } - - _NewEvents.Add(ie); - } - - ModifierKey _Modifiers; - private readonly List _NewEvents = new List(); - - //do we need this? - public void ClearEvents() - { - lock (this) - { - InputEvents.Clear(); - } - } - - private readonly Queue InputEvents = new Queue(); - public InputEvent DequeueEvent() - { - lock (this) - { - if (InputEvents.Count == 0) return null; - else return InputEvents.Dequeue(); - } - } - void EnqueueEvent(InputEvent ie) - { - lock (this) - { - InputEvents.Enqueue(ie); - } - } - - public List> GetFloats() - { - List> FloatValuesCopy = new List>(); - lock (FloatValues) - { - foreach (var kvp in FloatValues) - FloatValuesCopy.Add(new Tuple(kvp.Key, kvp.Value)); - } - return FloatValuesCopy; - } - -#if WINDOWS - void UpdateThreadProc() - { - for (; ; ) - { - var keyEvents = KeyInput.Update(); - GamePad.UpdateAll(); - BizHawk.Client.EmuHawk.GamePad360.UpdateAll(); - - //this block is going to massively modify data structures that the binding method uses, so we have to lock it all - lock (this) - { - _NewEvents.Clear(); - - //analyze keys - foreach (var ke in keyEvents) - HandleButton(ke.Key.ToString(), ke.Pressed); - - lock (FloatValues) - { - //FloatValues.Clear(); - - //analyze xinput - foreach (var pad in BizHawk.Client.EmuHawk.GamePad360.EnumerateDevices()) - { - string xname = "X" + pad.PlayerNumber + " "; - for (int b = 0; b < pad.NumButtons; b++) - HandleButton(xname + pad.ButtonName(b), pad.Pressed(b)); - foreach (var sv in pad.GetFloats()) - { - string n = xname + sv.Item1; - float f = sv.Item2; - if (trackdeltas) - FloatDeltas[n] += Math.Abs(f - FloatValues[n]); - FloatValues[n] = f; - } - } - - //analyze joysticks - for (int i = 0; i < GamePad.Devices.Count; i++) - { - var pad = GamePad.Devices[i]; - string jname = "J" + (i + 1) + " "; - - for (int b = 0; b < pad.NumButtons; b++) - HandleButton(jname + pad.ButtonName(b), pad.Pressed(b)); - foreach (var sv in pad.GetFloats()) - { - string n = jname + sv.Item1; - float f = sv.Item2; - //if (n == "J5 RotationZ") - // System.Diagnostics.Debugger.Break(); - if (trackdeltas) - FloatDeltas[n] += Math.Abs(f - FloatValues[n]); - FloatValues[n] = f; - } - } - - // analyse moose - // other sorts of mouse api (raw input) could easily be added as a separate listing under a different class - if (WantingMouseFocus.Contains(System.Windows.Forms.Form.ActiveForm)) - { - var P = System.Windows.Forms.Control.MousePosition; - if (trackdeltas) - { - // these are relative to screen coordinates, but that's not terribly important - FloatDeltas["WMouse X"] += Math.Abs(P.X - FloatValues["WMouse X"]) * 50; - FloatDeltas["WMouse Y"] += Math.Abs(P.Y - FloatValues["WMouse Y"]) * 50; - } - // coordinate translation happens later - FloatValues["WMouse X"] = P.X; - FloatValues["WMouse Y"] = P.Y; - - var B = System.Windows.Forms.Control.MouseButtons; - HandleButton("WMouse L", (B & System.Windows.Forms.MouseButtons.Left) != 0); - HandleButton("WMouse C", (B & System.Windows.Forms.MouseButtons.Middle) != 0); - HandleButton("WMouse R", (B & System.Windows.Forms.MouseButtons.Right) != 0); - HandleButton("WMouse 1", (B & System.Windows.Forms.MouseButtons.XButton1) != 0); - HandleButton("WMouse 2", (B & System.Windows.Forms.MouseButtons.XButton2) != 0); - } - else - { - //dont do this: for now, it will interfere with the virtualpad. dont do something similar for the mouse position either - //unpress all buttons - //HandleButton("WMouse L", false); - //HandleButton("WMouse C", false); - //HandleButton("WMouse R", false); - //HandleButton("WMouse 1", false); - //HandleButton("WMouse 2", false); - } - - } - - bool swallow = !GlobalWin.MainForm.AllowInput; - - foreach (var ie in _NewEvents) - { - //events are swallowed in some cases: - if (ie.EventType == InputEventType.Press && swallow) - { } - else - EnqueueEvent(ie); - } - } //lock(this) - - //arbitrary selection of polling frequency: - Thread.Sleep(10); - } - } -#endif - - public void StartListeningForFloatEvents() - { - lock (FloatValues) - { - FloatDeltas.Clear(); - trackdeltas = true; - } - } - - public string GetNextFloatEvent() - { - lock (FloatValues) - { - foreach (var kvp in FloatDeltas) - { - // need to wiggle the stick a bit - if (kvp.Value >= 20000.0f) - return kvp.Key; - } - } - return null; - } - - public void StopListeningForFloatEvents() - { - lock (FloatValues) - { - trackdeltas = false; - } - } - - public void Update() - { - //TODO - for some reason, we may want to control when the next event processing step happens - //so i will leave this method here for now.. - } - - //returns the next Press event, if available. should be useful - public string GetNextBindEvent() - { - //this whole process is intimately involved with the data structures, which can conflict with the input thread. - lock (this) - { - if (InputEvents.Count == 0) return null; - if (!GlobalWin.MainForm.AllowInput) return null; - - //we only listen to releases for input binding, because we need to distinguish releases of pure modifierkeys from modified keys - //if you just pressed ctrl, wanting to bind ctrl, we'd see: pressed:ctrl, unpressed:ctrl - //if you just pressed ctrl+c, wanting to bind ctrl+c, we'd see: pressed:ctrl, pressed:ctrl+c, unpressed:ctrl+c, unpressed:ctrl - //so its the first unpress we need to listen for - - while (InputEvents.Count != 0) - { - var ie = DequeueEvent(); - - //as a special perk, we'll accept escape immediately - if (ie.EventType == InputEventType.Press && ie.LogicalButton.Button == "Escape") - goto ACCEPT; - - if (ie.EventType == InputEventType.Press) continue; - - ACCEPT: - Console.WriteLine("Bind Event: {0} ", ie); - - foreach (var kvp in LastState) - if (kvp.Value) - { - Console.WriteLine("Unpressing " + kvp.Key); - UnpressState[kvp.Key] = true; - } - - InputEvents.Clear(); - - return ie.LogicalButton.ToString(); - } - - return null; - } - } - - //controls whether modifier keys will be ignored as key press events - //this should be used by hotkey binders, but we may want modifier key events - //to get triggered in the main form - public bool EnableIgnoreModifiers = false; - - } -} diff --git a/BizHawk.Client.MultiHawk/Input/Keyboard.cs b/BizHawk.Client.MultiHawk/Input/Keyboard.cs deleted file mode 100644 index 33f5ba938a..0000000000 --- a/BizHawk.Client.MultiHawk/Input/Keyboard.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System.Collections.Generic; -using SlimDX; -using SlimDX.DirectInput; -using System; - -namespace BizHawk.Client.MultiHawk -{ - public static class KeyInput - { - private static DirectInput dinput; - private static Keyboard keyboard; - private static KeyboardState state = new KeyboardState(); - - public static void Initialize(IntPtr parent) - { - if (dinput == null) - dinput = new DirectInput(); - - if (keyboard == null || keyboard.Disposed) - keyboard = new Keyboard(dinput); - keyboard.SetCooperativeLevel(parent, CooperativeLevel.Background | CooperativeLevel.Nonexclusive); - keyboard.Properties.BufferSize = 8; - } - - static List EmptyList = new List(); - static List EventList = new List(); - - public static IEnumerable Update() - { - EventList.Clear(); - - if (keyboard.Acquire().IsFailure) - return EmptyList; - if (keyboard.Poll().IsFailure) - return EmptyList; - - for (; ; ) - { - var events = keyboard.GetBufferedData(); - if (Result.Last.IsFailure) - return EventList; - if (events.Count == 0) - break; - foreach (var e in events) - { - foreach (var k in e.PressedKeys) - EventList.Add(new KeyEvent { Key = k, Pressed = true }); - foreach (var k in e.ReleasedKeys) - EventList.Add(new KeyEvent { Key = k, Pressed = false }); - } - } - - return EventList; - } - - public struct KeyEvent - { - public Key Key; - public bool Pressed; - } - - - public static bool IsPressed(Key key) - { - if (state.IsPressed(key)) - return true; - - if (key == Key.LeftShift && state.IsPressed(Key.RightShift)) - return true; - if (key == Key.LeftControl && state.IsPressed(Key.RightControl)) - return true; - if (key == Key.LeftAlt && state.IsPressed(Key.RightAlt)) - return true; - - return false; - } - - public static bool ShiftModifier - { - get - { - if (state.IsPressed(Key.LeftShift)) return true; - if (state.IsPressed(Key.RightShift)) return true; - return false; - } - } - - public static bool CtrlModifier - { - get - { - if (state.IsPressed(Key.LeftControl)) return true; - if (state.IsPressed(Key.RightControl)) return true; - return false; - } - } - - public static bool AltModifier - { - get - { - if (state.IsPressed(Key.LeftAlt)) return true; - if (state.IsPressed(Key.RightAlt)) return true; - return false; - } - } - - public static Input.ModifierKey GetModifierKeysAsKeys() - { - Input.ModifierKey ret = Input.ModifierKey.None; - if (ShiftModifier) ret |= Input.ModifierKey.Shift; - if (CtrlModifier) ret |= Input.ModifierKey.Control; - if (AltModifier) ret |= Input.ModifierKey.Alt; - return ret; - } - - } - - internal static class KeyExtensions - { - public static bool IsModifier(this Key key) - { - if (key == Key.LeftShift) return true; - if (key == Key.RightShift) return true; - if (key == Key.LeftControl) return true; - if (key == Key.RightControl) return true; - if (key == Key.LeftAlt) return true; - if (key == Key.RightAlt) return true; - return false; - } - } -} diff --git a/BizHawk.Client.MultiHawk/InputManager.cs b/BizHawk.Client.MultiHawk/InputManager.cs deleted file mode 100644 index a1e7470727..0000000000 --- a/BizHawk.Client.MultiHawk/InputManager.cs +++ /dev/null @@ -1,121 +0,0 @@ -using System.Collections.Generic; -using System.Linq; - -using BizHawk.Emulation.Common; -using BizHawk.Client.Common.InputAdapterExtensions; - -using BizHawk.Client.Common; - -namespace BizHawk.Client.MultiHawk -{ - public class InputManager - { - Mainform _mainForm; - - public InputManager(Mainform mainForm) - { - _mainForm = mainForm; - } - - public void RewireInputChain() - { - Global.ControllerInputCoalescer.Clear(); - Global.ControllerInputCoalescer.Definition = Global.ActiveController.Definition; - - // TODO? - //Global.UD_LR_ControllerAdapter.Source = Global.ActiveController.Or(Global.AutoFireController); - Global.UD_LR_ControllerAdapter.Source = Global.ActiveController; - - Global.StickyXORAdapter.Source = Global.UD_LR_ControllerAdapter; - - // TODO? - //Global.AutofireStickyXORAdapter.Source = Global.StickyXORAdapter; - - //Global.MultitrackRewiringAdapter.Source = Global.AutofireStickyXORAdapter; - - Global.MultitrackRewiringAdapter.Source = Global.StickyXORAdapter; - Global.MovieInputSourceAdapter.Source = Global.MultitrackRewiringAdapter; - Global.ControllerOutput.Source = Global.MovieOutputHardpoint; - - Global.MovieSession.MovieControllerAdapter.Definition = Global.MovieInputSourceAdapter.Definition; - - // connect the movie session before MovieOutputHardpoint if it is doing anything - // otherwise connect the MovieInputSourceAdapter to it, effectively bypassing the movie session - if (Global.MovieSession != null) - { - Global.MovieOutputHardpoint.Source = Global.MovieSession.MovieControllerAdapter; - } - else - { - Global.MovieOutputHardpoint.Source = Global.MovieInputSourceAdapter; - } - } - - public void SyncControls() - { - var def = _mainForm.EmulatorWindows.First().Emulator.ControllerDefinition; - - Global.ActiveController = BindToDefinition(def, Global.Config.AllTrollers, Global.Config.AllTrollersAnalog); - // TODO? - //Global.AutoFireController = BindToDefinitionAF(def, Global.Config.AllTrollersAutoFire); - - // allow propogating controls that are in the current controller definition but not in the prebaked one - // these two lines shouldn't be required anymore under the new system? - Global.ActiveController.ForceType(new ControllerDefinition(def)); - Global.ClickyVirtualPadController.Definition = new ControllerDefinition(def); - RewireInputChain(); - } - - private Controller BindToDefinition(ControllerDefinition def, IDictionary> allbinds, IDictionary> analogbinds) - { - var ret = new Controller(def); - Dictionary binds; - if (allbinds.TryGetValue(def.Name, out binds)) - { - foreach (var cbutton in def.BoolButtons) - { - string bind; - if (binds.TryGetValue(cbutton, out bind)) - { - ret.BindMulti(cbutton, bind); - } - } - } - - Dictionary abinds; - if (analogbinds.TryGetValue(def.Name, out abinds)) - { - foreach (var cbutton in def.FloatControls) - { - Config.AnalogBind bind; - if (abinds.TryGetValue(cbutton, out bind)) - { - ret.BindFloat(cbutton, bind); - } - } - } - - return ret; - } - - // TODO? - //private AutofireController BindToDefinitionAF(ControllerDefinition def, IDictionary> allbinds) - //{ - // var ret = new AutofireController(def); - // Dictionary binds; - // if (allbinds.TryGetValue(def.Name, out binds)) - // { - // foreach (var cbutton in def.BoolButtons) - // { - // string bind; - // if (binds.TryGetValue(cbutton, out bind)) - // { - // ret.BindMulti(cbutton, bind); - // } - // } - // } - - // return ret; - //} - } -} \ No newline at end of file diff --git a/BizHawk.Client.MultiHawk/Mainform.Designer.cs b/BizHawk.Client.MultiHawk/Mainform.Designer.cs deleted file mode 100644 index 51157dee4f..0000000000 --- a/BizHawk.Client.MultiHawk/Mainform.Designer.cs +++ /dev/null @@ -1,548 +0,0 @@ -namespace BizHawk.Client.MultiHawk -{ - partial class Mainform - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.MainformMenu = new MenuStripEx(); - this.FileSubMenu = new System.Windows.Forms.ToolStripMenuItem(); - this.NewSessionMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.OpenSessionMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.SaveSessionMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.SaveSessionAsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.RecentSessionSubMenu = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); - this.OpenRomMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.RecentRomSubMenu = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); - this.RebootCoresMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); - this.ExitMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.ViewSubMenu = new System.Windows.Forms.ToolStripMenuItem(); - this._1xMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this._2xMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this._3xMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this._4xMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.MovieSubMenu = new System.Windows.Forms.ToolStripMenuItem(); - this.RecordMovieMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.PlayMovieMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.StopMovieMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.RestartMovieMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.RecentMovieSubMenu = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); - this.ToggleReadonlyMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.configToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.controllerConfigToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.hotkeyConfigToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); - this.saveConfigToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.WorkspacePanel = new System.Windows.Forms.Panel(); - this.MainStatusBar = new System.Windows.Forms.StatusStrip(); - this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); - this.FameStatusBarLabel = new System.Windows.Forms.ToolStripStatusLabel(); - this.PlayRecordStatusButton = new System.Windows.Forms.ToolStripDropDownButton(); - this.StatusBarMessageLabel = new System.Windows.Forms.ToolStripStatusLabel(); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.RecordMovieContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.PlayMovieContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.LoadLastMovieContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.StopMovieContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.RestartMovieContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.MainformMenu.SuspendLayout(); - this.WorkspacePanel.SuspendLayout(); - this.MainStatusBar.SuspendLayout(); - this.contextMenuStrip1.SuspendLayout(); - this.SuspendLayout(); - // - // MainformMenu - // - this.MainformMenu.ClickThrough = true; - this.MainformMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.FileSubMenu, - this.ViewSubMenu, - this.MovieSubMenu, - this.configToolStripMenuItem}); - this.MainformMenu.Location = new System.Drawing.Point(0, 0); - this.MainformMenu.Name = "MainformMenu"; - this.MainformMenu.Size = new System.Drawing.Size(655, 24); - this.MainformMenu.TabIndex = 0; - this.MainformMenu.Text = "menuStrip1"; - // - // FileSubMenu - // - this.FileSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.NewSessionMenuItem, - this.OpenSessionMenuItem, - this.SaveSessionMenuItem, - this.SaveSessionAsMenuItem, - this.RecentSessionSubMenu, - this.toolStripSeparator7, - this.OpenRomMenuItem, - this.RecentRomSubMenu, - this.toolStripSeparator5, - this.RebootCoresMenuItem, - this.toolStripSeparator3, - this.ExitMenuItem}); - this.FileSubMenu.Name = "FileSubMenu"; - this.FileSubMenu.Size = new System.Drawing.Size(37, 20); - this.FileSubMenu.Text = "&File"; - this.FileSubMenu.DropDownOpened += new System.EventHandler(this.FileSubMenu_DropDownOpened); - // - // NewSessionMenuItem - // - this.NewSessionMenuItem.Name = "NewSessionMenuItem"; - this.NewSessionMenuItem.Size = new System.Drawing.Size(165, 22); - this.NewSessionMenuItem.Text = "&New Session"; - this.NewSessionMenuItem.Click += new System.EventHandler(this.NewSessionMenuItem_Click); - // - // OpenSessionMenuItem - // - this.OpenSessionMenuItem.Name = "OpenSessionMenuItem"; - this.OpenSessionMenuItem.Size = new System.Drawing.Size(165, 22); - this.OpenSessionMenuItem.Text = "&Open Session"; - this.OpenSessionMenuItem.Click += new System.EventHandler(this.OpenSessionMenuItem_Click); - // - // SaveSessionMenuItem - // - this.SaveSessionMenuItem.Name = "SaveSessionMenuItem"; - this.SaveSessionMenuItem.Size = new System.Drawing.Size(165, 22); - this.SaveSessionMenuItem.Text = "&Save Session"; - this.SaveSessionMenuItem.Click += new System.EventHandler(this.SaveSessionMenuItem_Click); - // - // SaveSessionAsMenuItem - // - this.SaveSessionAsMenuItem.Name = "SaveSessionAsMenuItem"; - this.SaveSessionAsMenuItem.Size = new System.Drawing.Size(165, 22); - this.SaveSessionAsMenuItem.Text = "Save Session &As..."; - this.SaveSessionAsMenuItem.Click += new System.EventHandler(this.SaveSessionAsMenuItem_Click); - // - // RecentSessionSubMenu - // - this.RecentSessionSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripSeparator6}); - this.RecentSessionSubMenu.Name = "RecentSessionSubMenu"; - this.RecentSessionSubMenu.Size = new System.Drawing.Size(165, 22); - this.RecentSessionSubMenu.Text = "Recent Session"; - this.RecentSessionSubMenu.DropDownOpened += new System.EventHandler(this.RecentSessionSubMenu_DropDownOpened); - // - // toolStripSeparator6 - // - this.toolStripSeparator6.Name = "toolStripSeparator6"; - this.toolStripSeparator6.Size = new System.Drawing.Size(57, 6); - // - // toolStripSeparator7 - // - this.toolStripSeparator7.Name = "toolStripSeparator7"; - this.toolStripSeparator7.Size = new System.Drawing.Size(162, 6); - // - // OpenRomMenuItem - // - this.OpenRomMenuItem.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.OpenFile; - this.OpenRomMenuItem.Name = "OpenRomMenuItem"; - this.OpenRomMenuItem.Size = new System.Drawing.Size(165, 22); - this.OpenRomMenuItem.Text = "Open ROM"; - this.OpenRomMenuItem.Click += new System.EventHandler(this.OpenRomMenuItem_Click); - // - // RecentRomSubMenu - // - this.RecentRomSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripSeparator1}); - this.RecentRomSubMenu.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.Recent; - this.RecentRomSubMenu.Name = "RecentRomSubMenu"; - this.RecentRomSubMenu.Size = new System.Drawing.Size(165, 22); - this.RecentRomSubMenu.Text = "Recent"; - this.RecentRomSubMenu.DropDownOpened += new System.EventHandler(this.RecentRomSubMenu_DropDownOpened); - // - // toolStripSeparator1 - // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(57, 6); - // - // toolStripSeparator5 - // - this.toolStripSeparator5.Name = "toolStripSeparator5"; - this.toolStripSeparator5.Size = new System.Drawing.Size(162, 6); - // - // RebootCoresMenuItem - // - this.RebootCoresMenuItem.Name = "RebootCoresMenuItem"; - this.RebootCoresMenuItem.Size = new System.Drawing.Size(165, 22); - this.RebootCoresMenuItem.Text = "Reboot Cores"; - this.RebootCoresMenuItem.Click += new System.EventHandler(this.RebootCoresMenuItem_Click); - // - // toolStripSeparator3 - // - this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(162, 6); - // - // ExitMenuItem - // - this.ExitMenuItem.Name = "ExitMenuItem"; - this.ExitMenuItem.ShortcutKeyDisplayString = "Alt+F4"; - this.ExitMenuItem.Size = new System.Drawing.Size(165, 22); - this.ExitMenuItem.Text = "E&xit"; - this.ExitMenuItem.Click += new System.EventHandler(this.ExitMenuItem_Click); - // - // ViewSubMenu - // - this.ViewSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this._1xMenuItem, - this._2xMenuItem, - this._3xMenuItem, - this._4xMenuItem}); - this.ViewSubMenu.Enabled = false; - this.ViewSubMenu.Name = "ViewSubMenu"; - this.ViewSubMenu.Size = new System.Drawing.Size(44, 20); - this.ViewSubMenu.Text = "&View"; - this.ViewSubMenu.DropDownOpened += new System.EventHandler(this.ViewSubMenu_DropDownOpened); - // - // _1xMenuItem - // - this._1xMenuItem.Name = "_1xMenuItem"; - this._1xMenuItem.Size = new System.Drawing.Size(85, 22); - this._1xMenuItem.Text = "&1x"; - this._1xMenuItem.Click += new System.EventHandler(this._1xMenuItem_Click); - // - // _2xMenuItem - // - this._2xMenuItem.Name = "_2xMenuItem"; - this._2xMenuItem.Size = new System.Drawing.Size(85, 22); - this._2xMenuItem.Text = "&2x"; - this._2xMenuItem.Click += new System.EventHandler(this._2xMenuItem_Click); - // - // _3xMenuItem - // - this._3xMenuItem.Name = "_3xMenuItem"; - this._3xMenuItem.Size = new System.Drawing.Size(85, 22); - this._3xMenuItem.Text = "&3x"; - this._3xMenuItem.Click += new System.EventHandler(this._3xMenuItem_Click); - // - // _4xMenuItem - // - this._4xMenuItem.Name = "_4xMenuItem"; - this._4xMenuItem.Size = new System.Drawing.Size(85, 22); - this._4xMenuItem.Text = "&4x"; - this._4xMenuItem.Click += new System.EventHandler(this._4xMenuItem_Click); - // - // MovieSubMenu - // - this.MovieSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.RecordMovieMenuItem, - this.PlayMovieMenuItem, - this.StopMovieMenuItem, - this.RestartMovieMenuItem, - this.RecentMovieSubMenu, - this.toolStripSeparator2, - this.ToggleReadonlyMenuItem}); - this.MovieSubMenu.Name = "MovieSubMenu"; - this.MovieSubMenu.Size = new System.Drawing.Size(52, 20); - this.MovieSubMenu.Text = "&Movie"; - this.MovieSubMenu.DropDownOpened += new System.EventHandler(this.MovieSubMenu_DropDownOpened); - // - // RecordMovieMenuItem - // - this.RecordMovieMenuItem.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.RecordHS; - this.RecordMovieMenuItem.Name = "RecordMovieMenuItem"; - this.RecordMovieMenuItem.Size = new System.Drawing.Size(168, 22); - this.RecordMovieMenuItem.Text = "Record Movie"; - this.RecordMovieMenuItem.Click += new System.EventHandler(this.RecordMovieMenuItem_Click); - // - // PlayMovieMenuItem - // - this.PlayMovieMenuItem.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.Play; - this.PlayMovieMenuItem.Name = "PlayMovieMenuItem"; - this.PlayMovieMenuItem.Size = new System.Drawing.Size(168, 22); - this.PlayMovieMenuItem.Text = "Play Movie"; - this.PlayMovieMenuItem.Click += new System.EventHandler(this.PlayMovieMenuItem_Click); - // - // StopMovieMenuItem - // - this.StopMovieMenuItem.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.Stop; - this.StopMovieMenuItem.Name = "StopMovieMenuItem"; - this.StopMovieMenuItem.Size = new System.Drawing.Size(168, 22); - this.StopMovieMenuItem.Text = "&Stop Movie"; - this.StopMovieMenuItem.Click += new System.EventHandler(this.StopMovieMenuItem_Click); - // - // RestartMovieMenuItem - // - this.RestartMovieMenuItem.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.restart; - this.RestartMovieMenuItem.Name = "RestartMovieMenuItem"; - this.RestartMovieMenuItem.Size = new System.Drawing.Size(168, 22); - this.RestartMovieMenuItem.Text = "Restart Movie"; - this.RestartMovieMenuItem.Click += new System.EventHandler(this.RestartMovieMenuItem_Click); - // - // RecentMovieSubMenu - // - this.RecentMovieSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripSeparator8}); - this.RecentMovieSubMenu.Name = "RecentMovieSubMenu"; - this.RecentMovieSubMenu.Size = new System.Drawing.Size(168, 22); - this.RecentMovieSubMenu.Text = "Recent"; - this.RecentMovieSubMenu.DropDownOpened += new System.EventHandler(this.RecentMovieSubMenu_DropDownOpened); - // - // toolStripSeparator8 - // - this.toolStripSeparator8.Name = "toolStripSeparator8"; - this.toolStripSeparator8.Size = new System.Drawing.Size(57, 6); - // - // toolStripSeparator2 - // - this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(165, 6); - // - // ToggleReadonlyMenuItem - // - this.ToggleReadonlyMenuItem.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.ReadOnly; - this.ToggleReadonlyMenuItem.Name = "ToggleReadonlyMenuItem"; - this.ToggleReadonlyMenuItem.Size = new System.Drawing.Size(168, 22); - this.ToggleReadonlyMenuItem.Text = "Toggle Read-only"; - this.ToggleReadonlyMenuItem.Click += new System.EventHandler(this.ToggleReadonlyMenuItem_Click); - // - // configToolStripMenuItem - // - this.configToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.controllerConfigToolStripMenuItem, - this.hotkeyConfigToolStripMenuItem, - this.toolStripSeparator4, - this.saveConfigToolStripMenuItem}); - this.configToolStripMenuItem.Name = "configToolStripMenuItem"; - this.configToolStripMenuItem.Size = new System.Drawing.Size(55, 20); - this.configToolStripMenuItem.Text = "&Config"; - // - // controllerConfigToolStripMenuItem - // - this.controllerConfigToolStripMenuItem.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.GameController; - this.controllerConfigToolStripMenuItem.Name = "controllerConfigToolStripMenuItem"; - this.controllerConfigToolStripMenuItem.Size = new System.Drawing.Size(166, 22); - this.controllerConfigToolStripMenuItem.Text = "Controller Config"; - this.controllerConfigToolStripMenuItem.Click += new System.EventHandler(this.controllerConfigToolStripMenuItem_Click); - // - // hotkeyConfigToolStripMenuItem - // - this.hotkeyConfigToolStripMenuItem.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.HotKeys; - this.hotkeyConfigToolStripMenuItem.Name = "hotkeyConfigToolStripMenuItem"; - this.hotkeyConfigToolStripMenuItem.Size = new System.Drawing.Size(166, 22); - this.hotkeyConfigToolStripMenuItem.Text = "Hotkey Config"; - this.hotkeyConfigToolStripMenuItem.Click += new System.EventHandler(this.hotkeyConfigToolStripMenuItem_Click); - // - // toolStripSeparator4 - // - this.toolStripSeparator4.Name = "toolStripSeparator4"; - this.toolStripSeparator4.Size = new System.Drawing.Size(163, 6); - // - // saveConfigToolStripMenuItem - // - this.saveConfigToolStripMenuItem.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.Save; - this.saveConfigToolStripMenuItem.Name = "saveConfigToolStripMenuItem"; - this.saveConfigToolStripMenuItem.Size = new System.Drawing.Size(166, 22); - this.saveConfigToolStripMenuItem.Text = "Save Config"; - this.saveConfigToolStripMenuItem.Click += new System.EventHandler(this.saveConfigToolStripMenuItem_Click); - // - // WorkspacePanel - // - this.WorkspacePanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.WorkspacePanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - this.WorkspacePanel.Controls.Add(this.MainStatusBar); - this.WorkspacePanel.Location = new System.Drawing.Point(0, 25); - this.WorkspacePanel.Name = "WorkspacePanel"; - this.WorkspacePanel.Size = new System.Drawing.Size(655, 405); - this.WorkspacePanel.TabIndex = 1; - // - // MainStatusBar - // - this.MainStatusBar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripStatusLabel1, - this.FameStatusBarLabel, - this.PlayRecordStatusButton, - this.StatusBarMessageLabel}); - this.MainStatusBar.Location = new System.Drawing.Point(0, 379); - this.MainStatusBar.Name = "MainStatusBar"; - this.MainStatusBar.Size = new System.Drawing.Size(651, 22); - this.MainStatusBar.TabIndex = 0; - this.MainStatusBar.Text = "statusStrip1"; - // - // toolStripStatusLabel1 - // - this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; - this.toolStripStatusLabel1.Size = new System.Drawing.Size(46, 17); - this.toolStripStatusLabel1.Text = "Frame: "; - // - // FameStatusBarLabel - // - this.FameStatusBarLabel.Name = "FameStatusBarLabel"; - this.FameStatusBarLabel.Size = new System.Drawing.Size(13, 17); - this.FameStatusBarLabel.Text = "0"; - // - // PlayRecordStatusButton - // - this.PlayRecordStatusButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.PlayRecordStatusButton.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.Blank; - this.PlayRecordStatusButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.PlayRecordStatusButton.Name = "PlayRecordStatusButton"; - this.PlayRecordStatusButton.Size = new System.Drawing.Size(29, 20); - this.PlayRecordStatusButton.Text = "No movie is active"; - // - // StatusBarMessageLabel - // - this.StatusBarMessageLabel.Name = "StatusBarMessageLabel"; - this.StatusBarMessageLabel.Size = new System.Drawing.Size(35, 17); - this.StatusBarMessageLabel.Text = "Hello"; - // - // contextMenuStrip1 - // - this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.RecordMovieContextMenuItem, - this.PlayMovieContextMenuItem, - this.RestartMovieContextMenuItem, - this.StopMovieContextMenuItem, - this.LoadLastMovieContextMenuItem}); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(161, 114); - this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening); - // - // RecordMovieContextMenuItem - // - this.RecordMovieContextMenuItem.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.RecordHS; - this.RecordMovieContextMenuItem.Name = "RecordMovieContextMenuItem"; - this.RecordMovieContextMenuItem.Size = new System.Drawing.Size(160, 22); - this.RecordMovieContextMenuItem.Text = "Record Movie"; - this.RecordMovieContextMenuItem.Click += new System.EventHandler(this.RecordMovieMenuItem_Click); - // - // PlayMovieContextMenuItem - // - this.PlayMovieContextMenuItem.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.Play; - this.PlayMovieContextMenuItem.Name = "PlayMovieContextMenuItem"; - this.PlayMovieContextMenuItem.Size = new System.Drawing.Size(160, 22); - this.PlayMovieContextMenuItem.Text = "Play Movie"; - this.PlayMovieContextMenuItem.Click += new System.EventHandler(this.PlayMovieMenuItem_Click); - // - // LoadLastMovieContextMenuItem - // - this.LoadLastMovieContextMenuItem.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.Recent; - this.LoadLastMovieContextMenuItem.Name = "LoadLastMovieContextMenuItem"; - this.LoadLastMovieContextMenuItem.Size = new System.Drawing.Size(160, 22); - this.LoadLastMovieContextMenuItem.Text = "Load Last Movie"; - this.LoadLastMovieContextMenuItem.Click += new System.EventHandler(this.LoadLastMovieMenuItem_Click); - // - // StopMovieContextMenuItem - // - this.StopMovieContextMenuItem.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.Stop; - this.StopMovieContextMenuItem.Name = "StopMovieContextMenuItem"; - this.StopMovieContextMenuItem.Size = new System.Drawing.Size(160, 22); - this.StopMovieContextMenuItem.Text = "Stop Movie"; - this.StopMovieContextMenuItem.Click += new System.EventHandler(this.StopMovieMenuItem_Click); - // - // RestartMovieContextMenuItem - // - this.RestartMovieContextMenuItem.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.restart; - this.RestartMovieContextMenuItem.Name = "RestartMovieContextMenuItem"; - this.RestartMovieContextMenuItem.Size = new System.Drawing.Size(160, 22); - this.RestartMovieContextMenuItem.Text = "Restart Movie"; - this.RestartMovieContextMenuItem.Click += new System.EventHandler(this.RestartMovieMenuItem_Click); - // - // Mainform - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(655, 431); - this.ContextMenuStrip = this.contextMenuStrip1; - this.Controls.Add(this.WorkspacePanel); - this.Controls.Add(this.MainformMenu); - this.MainMenuStrip = this.MainformMenu; - this.Name = "Mainform"; - this.Text = "MultiHawk"; - this.Load += new System.EventHandler(this.Mainform_Load); - this.MainformMenu.ResumeLayout(false); - this.MainformMenu.PerformLayout(); - this.WorkspacePanel.ResumeLayout(false); - this.WorkspacePanel.PerformLayout(); - this.MainStatusBar.ResumeLayout(false); - this.MainStatusBar.PerformLayout(); - this.contextMenuStrip1.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private MenuStripEx MainformMenu; - private System.Windows.Forms.ToolStripMenuItem FileSubMenu; - private System.Windows.Forms.ToolStripMenuItem OpenRomMenuItem; - private System.Windows.Forms.Panel WorkspacePanel; - private System.Windows.Forms.StatusStrip MainStatusBar; - private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; - private System.Windows.Forms.ToolStripStatusLabel FameStatusBarLabel; - private System.Windows.Forms.ToolStripStatusLabel StatusBarMessageLabel; - private System.Windows.Forms.ToolStripMenuItem RecentRomSubMenu; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; - private System.Windows.Forms.ToolStripMenuItem MovieSubMenu; - private System.Windows.Forms.ToolStripMenuItem RecordMovieMenuItem; - private System.Windows.Forms.ToolStripMenuItem PlayMovieMenuItem; - private System.Windows.Forms.ToolStripMenuItem StopMovieMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; - private System.Windows.Forms.ToolStripMenuItem ToggleReadonlyMenuItem; - private System.Windows.Forms.ToolStripDropDownButton PlayRecordStatusButton; - private System.Windows.Forms.ToolStripMenuItem configToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem controllerConfigToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem hotkeyConfigToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; - private System.Windows.Forms.ToolStripMenuItem ExitMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; - private System.Windows.Forms.ToolStripMenuItem saveConfigToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator5; - private System.Windows.Forms.ToolStripMenuItem RebootCoresMenuItem; - private System.Windows.Forms.ToolStripMenuItem OpenSessionMenuItem; - private System.Windows.Forms.ToolStripMenuItem SaveSessionMenuItem; - private System.Windows.Forms.ToolStripMenuItem RecentSessionSubMenu; - private System.Windows.Forms.ToolStripMenuItem NewSessionMenuItem; - private System.Windows.Forms.ToolStripMenuItem SaveSessionAsMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator6; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator7; - private System.Windows.Forms.ToolStripMenuItem ViewSubMenu; - private System.Windows.Forms.ToolStripMenuItem _1xMenuItem; - private System.Windows.Forms.ToolStripMenuItem _2xMenuItem; - private System.Windows.Forms.ToolStripMenuItem _3xMenuItem; - private System.Windows.Forms.ToolStripMenuItem _4xMenuItem; - private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; - private System.Windows.Forms.ToolStripMenuItem LoadLastMovieContextMenuItem; - private System.Windows.Forms.ToolStripMenuItem RecentMovieSubMenu; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator8; - private System.Windows.Forms.ToolStripMenuItem RecordMovieContextMenuItem; - private System.Windows.Forms.ToolStripMenuItem StopMovieContextMenuItem; - private System.Windows.Forms.ToolStripMenuItem PlayMovieContextMenuItem; - private System.Windows.Forms.ToolStripMenuItem RestartMovieMenuItem; - private System.Windows.Forms.ToolStripMenuItem RestartMovieContextMenuItem; - } -} - diff --git a/BizHawk.Client.MultiHawk/Mainform.cs b/BizHawk.Client.MultiHawk/Mainform.cs deleted file mode 100644 index 10ca3fab7e..0000000000 --- a/BizHawk.Client.MultiHawk/Mainform.cs +++ /dev/null @@ -1,1560 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Diagnostics; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Windows.Forms; - -using BizHawk.Common; -using BizHawk.Common.IOExtensions; -using BizHawk.Client.EmuHawk; -using BizHawk.Bizware.BizwareGL; -using BizHawk.Emulation.Common; -using BizHawk.Emulation.Common.IEmulatorExtensions; -using BizHawk.Emulation.Cores.Nintendo.NES; -using BizHawk.Client.Common; -using BizHawk.Client.MultiHawk.ToolExtensions; - -namespace BizHawk.Client.MultiHawk -{ - public partial class Mainform : Form - { - static Mainform() - { - // If this isnt here, then our assemblyresolving hacks wont work due to the check for MainForm.INTERIM - // its.. weird. dont ask. - } - - public Mainform(string[] args) - { - GLManager.CreateInstance(GlobalWin.IGL_GL); - - InitializeComponent(); - _throttle = new BizHawk.Client.EmuHawk.Throttle(); - _inputManager = new InputManager(this); - Global.Config = ConfigService.Load(PathManager.DefaultIniPath); - Global.Config.DispFixAspectRatio = false; // TODO: don't hardcode this - Global.Config.ResolveDefaults(); - GlobalWin.MainForm = this; - - Global.ControllerInputCoalescer = new ControllerInputCoalescer(); - Global.FirmwareManager = new FirmwareManager(); - Global.MovieSession = new MovieSession - { - Movie = MovieService.DefaultInstance, - MovieControllerAdapter = MovieService.DefaultInstance.LogGeneratorInstance().MovieControllerAdapter, - MessageCallback = AddMessage, - - AskYesNoCallback = StateErrorAskUser, - PauseCallback = PauseEmulator, - ModeChangedCallback = SetMainformMovieInfo - }; - - new AutoResetEvent(false); - // TODO - //Icon = Properties.Resources.logo; - Global.Game = GameInfo.NullInstance; - - // In order to allow late construction of this database, we hook up a delegate here to dearchive the data and provide it on demand - // we could background thread this later instead if we wanted to be real clever - NES.BootGodDB.GetDatabaseBytes = () => - { - string xmlPath = Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "NesCarts.xml"); - string x7zPath = Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "NesCarts.7z"); - bool loadXml = File.Exists(xmlPath); - using (var NesCartFile = new HawkFile(loadXml ? xmlPath : x7zPath)) - { - if (!loadXml) { NesCartFile.BindFirst(); } - return NesCartFile - .GetStream() - .ReadAllBytes(); - } - }; - - Database.LoadDatabase(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "gamedb.txt")); - - Input.Initialize(this.Handle); - InitControls(); - - // TODO - //CoreFileProvider.SyncCoreCommInputSignals(); - - Global.ActiveController = new Controller(NullController.Instance.Definition); - Global.AutoFireController = AutofireNullControls; - Global.AutofireStickyXORAdapter.SetOnOffPatternFromConfig(); - - Closing += (o, e) => - { - Global.MovieSession.Movie.Stop(); - - foreach (var ew in EmulatorWindows) - { - ew.ShutDown(); - } - - SaveConfig(); - }; - - if (Global.Config.MainWndx != -1 && Global.Config.MainWndy != -1 && Global.Config.SaveWindowPosition) - { - Location = new Point(Global.Config.MainWndx, Global.Config.MainWndy); - } - } - - // TODO: make this an actual property, set it when loading a Rom, and pass it dialogs, etc - // This is a quick hack to reduce the dependency on Global.Emulator - public IEmulator Emulator - { - get { return Global.Emulator; } - set { Global.Emulator = value; } - } - - private static bool StateErrorAskUser(string title, string message) - { - var result = MessageBox.Show( - message, - title, - MessageBoxButtons.YesNo, - MessageBoxIcon.Question - ); - - return result == DialogResult.Yes; - } - - private void Mainform_Load(object sender, EventArgs e) - { - SetMainformMovieInfo(); - - if (Global.Config.RecentRomSessions.AutoLoad) - { - LoadRomSessionFromRecent(Global.Config.RecentRomSessions.MostRecent); - - if (Global.Config.RecentMovies.AutoLoad && !Global.Config.RecentMovies.Empty) - { - LoadMoviesFromRecent(Global.Config.RecentMovies.MostRecent); - } - } - - if (Global.Config.SaveWindowPosition && Global.Config.MainWidth > 0 && Global.Config.MainHeight > 0) - { - this.Size = new Size(Global.Config.MainWidth, Global.Config.MainHeight); - - } - } - - public EmulatorWindowList EmulatorWindows = new EmulatorWindowList(); - private AutofireController AutofireNullControls; - private bool _exit; - - protected override void OnClosed(EventArgs e) - { - _exit = true; - base.OnClosed(e); - } - - private void SaveConfig() - { - if (Global.Config.SaveWindowPosition) - { - if (Global.Config.MainWndx != -32000) // When minimized location is -32000, don't save this into the config file! - { - Global.Config.MainWndx = Location.X; - } - - if (Global.Config.MainWndy != -32000) - { - Global.Config.MainWndy = Location.Y; - } - } - else - { - Global.Config.MainWndx = -1; - Global.Config.MainWndy = -1; - } - - Global.Config.MainWidth = this.Width; - Global.Config.MainHeight = this.Height; - - ConfigService.Save(PathManager.DefaultIniPath, Global.Config); - } - - private void InitControls() - { - var controls = new Controller( - new ControllerDefinition - { - Name = "Emulator Frontend Controls", - BoolButtons = Global.Config.HotkeyBindings.Select(x => x.DisplayName).ToList() - }); - - foreach (var b in Global.Config.HotkeyBindings) - { - controls.BindMulti(b.DisplayName, b.Bindings); - } - - Global.ClientControls = controls; - AutofireNullControls = new AutofireController(NullController.Instance.Definition, Emulator); - } - - private void OpenRomMenuItem_Click(object sender, EventArgs e) - { - var ofd = new OpenFileDialog - { - InitialDirectory = PathManager.GetExeDirectoryAbsolute() - }; - - ofd.Filter = FormatFilter( - "Rom Files", "*.nes;*.fds;*.sms;*.gg;*.sg;*.pce;*.sgx;*.bin;*.smd;*.rom;*.a26;*.a78;*.lnx;*.m3u;*.cue;*.ccd;*.exe;*.gb;*.gbc;*.gba;*.gen;*.md;*.col;.int;*.smc;*.sfc;*.prg;*.d64;*.g64;*.crt;*.sgb;*.xml;*.z64;*.v64;*.n64;*.ws;*.wsc;%ARCH%", - "Music Files", "*.psf;*.sid", - "Disc Images", "*.cue;*.ccd;*.m3u", - "NES", "*.nes;*.fds;%ARCH%", - "Super NES", "*.smc;*.sfc;*.xml;%ARCH%", - "Master System", "*.sms;*.gg;*.sg;%ARCH%", - "PC Engine", "*.pce;*.sgx;*.cue;*.ccd;%ARCH%", - "TI-83", "*.rom;%ARCH%", - "Archive Files", "%ARCH%", - "Savestate", "*.state", - "Atari 2600", "*.a26;*.bin;%ARCH%", - "Atari 7800", "*.a78;*.bin;%ARCH%", - "Atari Lynx", "*.lnx;%ARCH%", - "Genesis", "*.gen;*.smd;*.bin;*.md;*.cue;*.ccd;%ARCH%", - "Gameboy", "*.gb;*.gbc;*.sgb;%ARCH%", - "Gameboy Advance", "*.gba;%ARCH%", - "Colecovision", "*.col;%ARCH%", - "Intellivision (very experimental)", "*.int;*.bin;*.rom;%ARCH%", - "PSX Executables (experimental)", "*.exe", - "PSF Playstation Sound File", "*.psf;*.minipsf", - "Commodore 64 (experimental)", "*.prg; *.d64, *.g64; *.crt;%ARCH%", - "SID Commodore 64 Music File", "*.sid;%ARCH%", - "Nintendo 64", "*.z64;*.v64;*.n64", - "WonderSwan", "*.ws;*.wsc;%ARCH%", - "All Files", "*.*"); - - var result = ofd.ShowDialog(); - if (result != DialogResult.OK) - { - return; - } - - LoadRom(ofd.FileName); - } - - private readonly InputManager _inputManager; - - private bool ReloadRom(EmulatorWindow ew) - { - bool deterministic = ew.Emulator.DeterministicEmulation; - string path = ew.CurrentRomPath; - - var loader = new RomLoader - { - ChooseArchive = LoadArhiveChooser, - ChoosePlatform = ChoosePlatformForRom, - Deterministic = deterministic, - MessageCallback = AddMessage - }; - - - loader.OnLoadError += ShowLoadError; - loader.OnLoadSettings += CoreSettings; - loader.OnLoadSyncSettings += CoreSyncSettings; - - var nextComm = new CoreComm(ShowMessageCoreComm, AddMessage); - - var result = loader.LoadRom(path, nextComm); - - if (result) - { - ew.SaveRam(); - ew.Emulator.Dispose(); - ew.Emulator = loader.LoadedEmulator; - ew.CoreComm = nextComm; - - _inputManager.SyncControls(); - - if (EmulatorWindows.First() == ew) - { - Emulator = ew.Emulator; - } - - return true; - } - else - { - return false; - } - } - - private string StripArchivePath(string path) - { - if (path.Contains("|")) - { - return path.Split('|').Last(); - } - - return path; - } - - private bool LoadRom(string path) - { - bool deterministic = true; - - var loader = new RomLoader - { - ChooseArchive = LoadArhiveChooser, - ChoosePlatform = ChoosePlatformForRom, - Deterministic = deterministic, - MessageCallback = AddMessage - }; - - - loader.OnLoadError += ShowLoadError; - loader.OnLoadSettings += CoreSettings; - loader.OnLoadSyncSettings += CoreSyncSettings; - - var nextComm = new CoreComm(ShowMessageCoreComm, AddMessage); - nextComm.CoreFileProvider = new CoreFileProvider(s => MessageBox.Show(s)); - - var result = loader.LoadRom(path, nextComm); - - if (result) - { - var ew = new EmulatorWindow(this) - { - TopLevel = false, - Text = Path.GetFileNameWithoutExtension(StripArchivePath(path)), - Emulator = loader.LoadedEmulator, - GL = new Bizware.BizwareGL.Drivers.OpenTK.IGL_TK(2,0,false), - //GL = new Bizware.BizwareGL.Drivers.SlimDX.IGL_SlimDX9(), - GLManager = GLManager.Instance, - Game = loader.Game, - CurrentRomPath = loader.CanonicalFullPath - }; - - nextComm.ReleaseGLContext = (o) => GlobalWin.GLManager.ReleaseGLContext(o); - nextComm.RequestGLContext = (major, minor, forward) => GlobalWin.GLManager.CreateGLContext(major, minor, forward); - nextComm.ActivateGLContext = (gl) => GlobalWin.GLManager.Activate((GLManager.ContextRef)gl); - nextComm.DeactivateGLContext = () => GlobalWin.GLManager.Deactivate(); - - ew.CoreComm = nextComm; - ew.Init(); - - if (EmulatorWindows.Any()) - { - // Attempt to open the window is a smart location - var last = EmulatorWindows.Last(); - - int x = last.Location.X + last.Width + 5; - int y = last.Location.Y; - if (x + (last.Width / 2) > Width) // If it will go too far off screen - { - y += last.Height + 5; - x = EmulatorWindows.First().Location.X; - } - - ew.Location = new Point(x, y); - } - - - EmulatorWindows.Add(ew); - - WorkspacePanel.Controls.Add(ew); - ew.Show(); - - Global.Config.RecentRoms.Add(loader.CanonicalFullPath); - - if (EmulatorWindows.Count == 1) - { - Emulator = ew.Emulator; - ViewSubMenu.Enabled = true; - } - - _inputManager.SyncControls(); - - return true; - } - else - { - return false; - } - } - - /// - /// Controls whether the app generates input events. should be turned off for most modal dialogs - /// - public bool AllowInput - { - get - { - // the main form gets input - if (ActiveForm == this) - { - return true; - } - - // modals that need to capture input for binding purposes get input, of course - if (ActiveForm is BizHawk.Client.EmuHawk.HotkeyConfig - || ActiveForm is BizHawk.Client.EmuHawk.ControllerConfig - //|| ActiveForm is TAStudio - //|| ActiveForm is VirtualpadTool - ) - { - return true; - } - - return false; - } - } - - private static string FormatFilter(params string[] args) - { - var sb = new StringBuilder(); - if (args.Length % 2 != 0) - { - throw new ArgumentException(); - } - - var num = args.Length / 2; - for (int i = 0; i < num; i++) - { - sb.AppendFormat("{0} ({1})|{1}", args[i * 2], args[i * 2 + 1]); - if (i != num - 1) - { - sb.Append('|'); - } - } - - var str = sb.ToString().Replace("%ARCH%", "*.zip;*.rar;*.7z;*.gz"); - str = str.Replace(";", "; "); - return str; - } - - public void AddMessage(string message) - { - StatusBarMessageLabel.Text = message; - } - - private string ChoosePlatformForRom(RomGame rom) - { - // TODO - return null; - } - - private int? LoadArhiveChooser(HawkFile file) - { - var ac = new BizHawk.Client.EmuHawk.ArchiveChooser(file); - if (ac.ShowDialog(this) == DialogResult.OK) - { - return ac.SelectedMemberIndex; - } - else - { - return null; - } - } - - private void ShowLoadError(object sender, RomLoader.RomErrorArgs e) - { - string title = "load error"; - if (e.AttemptedCoreLoad != null) - { - title = e.AttemptedCoreLoad + " load error"; - } - - MessageBox.Show(this, e.Message, title, MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - private static void CoreSettings(object sender, RomLoader.SettingsLoadArgs e) - { - e.Settings = Global.Config.GetCoreSettings(e.Core); - } - - private void CoreSyncSettings(object sender, RomLoader.SettingsLoadArgs e) - { - if (Global.MovieSession.QueuedMovie != null) - { - if (!string.IsNullOrWhiteSpace(Global.MovieSession.QueuedMovie.SyncSettingsJson)) - { - e.Settings = ConfigService.LoadWithType(Global.MovieSession.QueuedMovie.SyncSettingsJson); - } - else - { - MessageBox.Show( - "No sync settings found, using currently configured settings for this core.", - "No sync settings found", - MessageBoxButtons.OK, - MessageBoxIcon.Warning - ); - - e.Settings = Global.Config.GetCoreSyncSettings(e.Core); - } - } - else - { - e.Settings = Global.Config.GetCoreSyncSettings(e.Core); - } - - } - - public void FlagNeedsReboot() - { - // TODO - } - - private void ShowMessageCoreComm(string message) - { - MessageBox.Show(this, message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); - } - - private static void CheckMessages() - { - Application.DoEvents(); - if (ActiveForm != null) - { - BizHawk.Client.EmuHawk.ScreenSaver.ResetTimerPeriodically(); - } - } - - // sends an alt+mnemonic combination - private void SendAltKeyChar(char c) - { - typeof(ToolStrip).InvokeMember("ProcessMnemonicInternal", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Instance, null, MainformMenu, new object[] { c }); - } - - // sends a simulation of a plain alt key keystroke - private void SendPlainAltKey(int lparam) - { - var m = new Message { WParam = new IntPtr(0xF100), LParam = new IntPtr(lparam), Msg = 0x0112, HWnd = Handle }; - base.WndProc(ref m); - } - - public void ProcessInput() - { - ControllerInputCoalescer conInput = Global.ControllerInputCoalescer as ControllerInputCoalescer; - - for (; ; ) - { - - // loop through all available events - var ie = Input.Instance.DequeueEvent(); - if (ie == null) { break; } - - // look for hotkey bindings for this key - var triggers = Global.ClientControls.SearchBindings(ie.LogicalButton.ToString()); - if (triggers.Count == 0) - { - // Maybe it is a system alt-key which hasnt been overridden - if (ie.EventType == Input.InputEventType.Press) - { - if (ie.LogicalButton.Alt && ie.LogicalButton.Button.Length == 1) - { - var c = ie.LogicalButton.Button.ToLower()[0]; - if ((c >= 'a' && c <= 'z') || c == ' ') - { - SendAltKeyChar(c); - } - } - if (ie.LogicalButton.Alt && ie.LogicalButton.Button == "Space") - { - SendPlainAltKey(32); - } - } - } - - bool handled; - switch (Global.Config.Input_Hotkey_OverrideOptions) - { - default: - case 0: // Both allowed - conInput.Receive(ie); - - handled = false; - if (ie.EventType == Input.InputEventType.Press) - { - handled = triggers.Aggregate(handled, (current, trigger) => current | CheckHotkey(trigger)); - } - - // hotkeys which arent handled as actions get coalesced as pollable virtual client buttons - if (!handled) - { - GlobalWin.HotkeyCoalescer.Receive(ie); - } - - break; - case 1: // Input overrides Hokeys - conInput.Receive(ie); - if (!Global.ActiveController.HasBinding(ie.LogicalButton.ToString())) - { - handled = false; - if (ie.EventType == Input.InputEventType.Press) - { - handled = triggers.Aggregate(handled, (current, trigger) => current | CheckHotkey(trigger)); - } - - // hotkeys which arent handled as actions get coalesced as pollable virtual client buttons - if (!handled) - { - GlobalWin.HotkeyCoalescer.Receive(ie); - } - } - break; - case 2: // Hotkeys override Input - handled = false; - if (ie.EventType == Input.InputEventType.Press) - { - handled = triggers.Aggregate(handled, (current, trigger) => current | CheckHotkey(trigger)); - } - - // hotkeys which arent handled as actions get coalesced as pollable virtual client buttons - if (!handled) - { - GlobalWin.HotkeyCoalescer.Receive(ie); - conInput.Receive(ie); - } - break; - } - } - } - - public void ProgramRunLoop() - { - CheckMessages(); - - for (; ; ) - { - Input.Instance.Update(); - - // handle events and dispatch as a hotkey action, or a hotkey button, or an input button - ProcessInput(); - Global.ClientControls.LatchFromPhysical(GlobalWin.HotkeyCoalescer); - - Global.ActiveController.LatchFromPhysical(Global.ControllerInputCoalescer); - - // TODO - //Global.ActiveController.ApplyAxisConstraints( - // (Emulator is N64 && Global.Config.N64UseCircularAnalogConstraint) ? "Natural Circle" : null); - - Global.ActiveController.OR_FromLogical(Global.ClickyVirtualPadController); - Global.AutoFireController.LatchFromPhysical(Global.ControllerInputCoalescer); - - if (Global.ClientControls["Autohold"]) - { - Global.StickyXORAdapter.MassToggleStickyState(Global.ActiveController.PressedButtons); - Global.AutofireStickyXORAdapter.MassToggleStickyState(Global.AutoFireController.PressedButtons); - } - else if (Global.ClientControls["Autofire"]) - { - Global.AutofireStickyXORAdapter.MassToggleStickyState(Global.ActiveController.PressedButtons); - } - - // autohold/autofire must not be affected by the following inputs - Global.ActiveController.Overrides(Global.LuaAndAdaptor); - - if (EmulatorWindows.Any()) - { - StepRunLoop_Core(); - StepRunLoop_Throttle(); - - foreach (var window in EmulatorWindows) - { - window.Render(); - } - } - - CheckMessages(); - - if (_exit) - { - break; - } - - Thread.Sleep(0); - } - - Shutdown(); - } - - private void Shutdown() - { - //TODO - //if (_currAviWriter != null) - //{ - // _currAviWriter.CloseFile(); - // _currAviWriter = null; - //} - } - - public void LoadQuickSave(string quickSlotName) - { - try - { - foreach (var window in EmulatorWindows) - { - window.LoadQuickSave(quickSlotName); - } - } - catch - { - MessageBox.Show("Could not load " + quickSlotName); - } - } - - public void SaveQuickSave(string quickSlotName) - { - try - { - foreach (var window in EmulatorWindows) - { - window.SaveQuickSave(quickSlotName); - } - } - catch - { - MessageBox.Show("Could not save " + quickSlotName); - } - } - - private void SelectSlot(int num) - { - Global.Config.SaveSlot = num; - UpdateStatusSlots(); - } - - private void UpdateStatusSlots() - { - // TODO - SaveSlotSelectedMessage(); - UpdateAfterFrameChanged(); - } - - private void SaveSlotSelectedMessage() - { - AddMessage("Slot " + Global.Config.SaveSlot + " selected."); - } - - public void TogglePause() - { - EmulatorPaused ^= true; - //SetPauseStatusbarIcon(); // TODO - } - private bool CheckHotkey(string trigger) - { - switch (trigger) - { - default: - return false; - - case "Pause": - TogglePause(); - break; - case "Reboot Core": - RebootCoresMenuItem_Click(null, null); - break; - case "Quick Load": - LoadQuickSave("QuickSave" + Global.Config.SaveSlot); - break; - case "Quick Save": - SaveQuickSave("QuickSave" + Global.Config.SaveSlot); - break; - - // Save States - case "Save State 0": - SaveQuickSave("QuickSave0"); - Global.Config.SaveSlot = 0; - UpdateStatusSlots(); - break; - case "Save State 1": - SaveQuickSave("QuickSave1"); - Global.Config.SaveSlot = 1; - UpdateStatusSlots(); - break; - case "Save State 2": - SaveQuickSave("QuickSave2"); - Global.Config.SaveSlot = 2; - UpdateStatusSlots(); - break; - case "Save State 3": - SaveQuickSave("QuickSave3"); - Global.Config.SaveSlot = 3; - UpdateStatusSlots(); - break; - case "Save State 4": - SaveQuickSave("QuickSave4"); - Global.Config.SaveSlot = 4; - UpdateStatusSlots(); - break; - case "Save State 5": - SaveQuickSave("QuickSave5"); - Global.Config.SaveSlot = 5; - UpdateStatusSlots(); - break; - case "Save State 6": - SaveQuickSave("QuickSave6"); - Global.Config.SaveSlot = 6; - UpdateStatusSlots(); - break; - case "Save State 7": - SaveQuickSave("QuickSave7"); - Global.Config.SaveSlot = 7; - UpdateStatusSlots(); - break; - case "Save State 8": - SaveQuickSave("QuickSave8"); - Global.Config.SaveSlot = 8; - UpdateStatusSlots(); - break; - case "Save State 9": - SaveQuickSave("QuickSave9"); - Global.Config.SaveSlot = 9; - //UpdateStatusSlots(); - break; - case "Load State 0": - LoadQuickSave("QuickSave0"); - Global.Config.SaveSlot = 0; - UpdateStatusSlots(); - break; - case "Load State 1": - LoadQuickSave("QuickSave1"); - Global.Config.SaveSlot = 1; - UpdateStatusSlots(); - break; - case "Load State 2": - LoadQuickSave("QuickSave2"); - Global.Config.SaveSlot = 2; - UpdateStatusSlots(); - break; - case "Load State 3": - LoadQuickSave("QuickSave3"); - Global.Config.SaveSlot = 3; - UpdateStatusSlots(); - break; - case "Load State 4": - LoadQuickSave("QuickSave4"); - Global.Config.SaveSlot = 4; - UpdateStatusSlots(); - break; - case "Load State 5": - LoadQuickSave("QuickSave5"); - Global.Config.SaveSlot = 5; - UpdateStatusSlots(); - break; - case "Load State 6": - LoadQuickSave("QuickSave6"); - Global.Config.SaveSlot = 6; - UpdateStatusSlots(); - break; - case "Load State 7": - LoadQuickSave("QuickSave7"); - Global.Config.SaveSlot = 7; - break; - case "Load State 8": - LoadQuickSave("QuickSave8"); - Global.Config.SaveSlot = 8; - UpdateStatusSlots(); - break; - case "Load State 9": - LoadQuickSave("QuickSave9"); - Global.Config.SaveSlot = 9; - UpdateStatusSlots(); - break; - - case "Select State 0": - SelectSlot(0); - break; - case "Select State 1": - SelectSlot(1); - break; - case "Select State 2": - SelectSlot(2); - break; - case "Select State 3": - SelectSlot(3); - break; - case "Select State 4": - SelectSlot(4); - break; - case "Select State 5": - SelectSlot(5); - break; - case "Select State 6": - SelectSlot(6); - break; - case "Select State 7": - SelectSlot(7); - break; - case "Select State 8": - SelectSlot(8); - break; - case "Select State 9": - SelectSlot(9); - break; - - // Movie - case "Stop Movie": - StopMovieMenuItem_Click(null, null); - break; - case "Toggle read-only": - ToggleReadonlyMenuItem_Click(null, null); - break; - // TODO - //case "Play from beginning": - // RestartMovie(); - // break; - // TODO - //case "Save Movie": - // SaveMovie(); - // break; - } - - return true; - } - - public bool PressFrameAdvance = false; - public bool PressRewind = false; - public bool FastForward = false; - public bool TurboFastForward = false; - public bool EmulatorPaused = true; - private readonly BizHawk.Client.EmuHawk.Throttle _throttle; - //private bool _unthrottled; // TODO - private bool _runloopFrameAdvance; - private bool _runloopFrameProgress; - private long _frameAdvanceTimestamp; - private bool _runloopLastFf; - private int _runloopFps; - private long _runloopSecond; - private int _runloopLastFps; - - public bool IsTurboing - { - get - { - return Global.ClientControls["Turbo"]; - } - } - - private void SyncThrottle() - { - // "unthrottled" = throttle was turned off with "Toggle Throttle" hotkey - // "turbo" = throttle is off due to the "Turbo" hotkey being held - // They are basically the same thing but one is a toggle and the other requires a - // hotkey to be held. There is however slightly different behavior in that turbo - // skips outputting the audio. There's also a third way which is when no throttle - // method is selected, but the clock throttle determines that by itself and - // everything appears normal here. - - var fastForward = Global.ClientControls["Fast Forward"] || FastForward; - var turbo = IsTurboing; - - int speedPercent = fastForward ? Global.Config.SpeedPercentAlternate : Global.Config.SpeedPercent; - - Global.DisableSecondaryThrottling = /*_unthrottled || TODO */ turbo || fastForward; - - // realtime throttle is never going to be so exact that using a double here is wrong - _throttle.SetCoreFps(EmulatorWindows.Master.Emulator.VsyncRate()); - _throttle.signal_paused = EmulatorPaused; - _throttle.signal_unthrottle = /*_unthrottled || TODO */ turbo; - _throttle.signal_overrideSecondaryThrottle = fastForward && (Global.Config.SoundThrottle || Global.Config.VSyncThrottle || Global.Config.VSync); - _throttle.SetSpeedPercent(speedPercent); - } - - private void StepRunLoop_Throttle() - { - SyncThrottle(); - _throttle.signal_frameAdvance = _runloopFrameAdvance; - _throttle.signal_continuousFrameAdvancing = _runloopFrameProgress; - - _throttle.Step(true, -1); - } - - public void PauseEmulator() - { - EmulatorPaused = true; - //SetPauseStatusbarIcon(); // TODO - } - - public void UnpauseEmulator() - { - EmulatorPaused = false; - //SetPauseStatusbarIcon(); // TODO - } - - private void StepRunLoop_Core() - { - var runFrame = false; - _runloopFrameAdvance = false; - var currentTimestamp = Stopwatch.GetTimestamp(); - double frameAdvanceTimestampDeltaMs = (double)(currentTimestamp - _frameAdvanceTimestamp) / Stopwatch.Frequency * 1000.0; - bool frameProgressTimeElapsed = frameAdvanceTimestampDeltaMs >= Global.Config.FrameProgressDelayMs; - - if (Global.ClientControls["Frame Advance"]) - { - // handle the initial trigger of a frame advance - if (_frameAdvanceTimestamp == 0) - { - PauseEmulator(); - runFrame = true; - _runloopFrameAdvance = true; - _frameAdvanceTimestamp = currentTimestamp; - } - else - { - // handle the timed transition from countdown to FrameProgress - if (frameProgressTimeElapsed) - { - runFrame = true; - _runloopFrameProgress = true; - UnpauseEmulator(); - } - } - } - else - { - // handle release of frame advance: do we need to deactivate FrameProgress? - if (_runloopFrameProgress) - { - _runloopFrameProgress = false; - PauseEmulator(); - } - - _frameAdvanceTimestamp = 0; - } - - if (!EmulatorPaused) - { - runFrame = true; - } - - if (runFrame) - { - var isFastForwarding = Global.ClientControls["Fast Forward"] || IsTurboing; - var updateFpsString = _runloopLastFf != isFastForwarding; - _runloopLastFf = isFastForwarding; - _runloopFps++; - - if ((double)(currentTimestamp - _runloopSecond) / Stopwatch.Frequency >= 1.0) - { - _runloopLastFps = _runloopFps; - _runloopSecond = currentTimestamp; - _runloopFps = 0; - updateFpsString = true; - } - - if (updateFpsString) - { - var fps_string = _runloopLastFps + " fps"; - if (IsTurboing) - { - fps_string += " >>>>"; - } - else if (isFastForwarding) - { - fps_string += " >>"; - } - - //GlobalWin.OSD.FPS = fps_string; // TODO - } - - Global.MovieSession.HandleMovieOnFrameLoop(); - - foreach (var window in EmulatorWindows) - { - window.FrameAdvance(); - } - - PressFrameAdvance = false; - - UpdateAfterFrameChanged(); - } - } - - private void UpdateAfterFrameChanged() - { - if (EmulatorWindows.Any()) - { - string frame = EmulatorWindows.Master.Emulator.Frame.ToString(); - - if (Global.MovieSession.Movie.IsActive) - { - if (Global.MovieSession.Movie.IsFinished) - { - frame += $" / {Global.MovieSession.Movie.FrameCount} (finished)"; - } - else if (Global.MovieSession.Movie.IsPlaying) - { - frame += $" / {Global.MovieSession.Movie.FrameCount}"; - } - } - - FameStatusBarLabel.Text = frame; - } - } - - private void FileSubMenu_DropDownOpened(object sender, EventArgs e) - { - SaveSessionMenuItem.Enabled = !string.IsNullOrWhiteSpace(EmulatorWindows.SessionName); - SaveSessionAsMenuItem.Enabled = EmulatorWindows.Any(); - } - - private void LoadRomFromRecent(string rom) - { - if (!LoadRom(rom)) - { - Global.Config.RecentRoms.HandleLoadError(rom); - } - } - - private void MovieSubMenu_DropDownOpened(object sender, EventArgs e) - { - PlayMovieMenuItem.Enabled = - RecordMovieMenuItem.Enabled = - EmulatorWindows.Any(); - - StopMovieMenuItem.Enabled = - RestartMovieMenuItem.Enabled = - Global.MovieSession.Movie.IsActive; - } - - private void RecordMovieMenuItem_Click(object sender, EventArgs e) - { - new RecordMovie(Emulator).ShowDialog(); - UpdateMainText(); - UpdateAfterFrameChanged(); - } - - private void PlayMovieMenuItem_Click(object sender, EventArgs e) - { - new PlayMovie().ShowDialog(); - UpdateMainText(); - UpdateAfterFrameChanged(); - } - - private void StopMovieMenuItem_Click(object sender, EventArgs e) - { - Global.MovieSession.StopMovie(true); - SetMainformMovieInfo(); - UpdateMainText(); - UpdateAfterFrameChanged(); - //UpdateStatusSlots(); // TODO - } - - private void ToggleReadonlyMenuItem_Click(object sender, EventArgs e) - { - Global.MovieSession.ReadOnly ^= true; - if (Global.MovieSession.ReadOnly) - { - AddMessage("Movie is now Read-only"); - } - else - { - AddMessage("Movie is now read+write"); - } - } - - private void LoadMoviesFromRecent(string path) - { - if (File.Exists(path)) - { - var movie = MovieService.Get(path); - Global.MovieSession.ReadOnly = true; - StartNewMovie(movie, false); - } - else - { - Global.Config.RecentMovies.HandleLoadError(path); - } - } - - public void SetMainformMovieInfo() - { - if (Global.MovieSession.Movie.IsPlaying) - { - PlayRecordStatusButton.Image = Properties.Resources.Play; - PlayRecordStatusButton.ToolTipText = "Movie is in playback mode"; - PlayRecordStatusButton.Visible = true; - } - else if (Global.MovieSession.Movie.IsRecording) - { - PlayRecordStatusButton.Image = Properties.Resources.RecordHS; - PlayRecordStatusButton.ToolTipText = "Movie is in record mode"; - PlayRecordStatusButton.Visible = true; - } - else if (!Global.MovieSession.Movie.IsActive) - { - PlayRecordStatusButton.Image = Properties.Resources.Blank; - PlayRecordStatusButton.ToolTipText = "No movie is active"; - PlayRecordStatusButton.Visible = false; - } - } - - public bool StartNewMovie(IMovie movie, bool record) - { - if (movie.IsActive) - { - movie.Save(); - } - - try - { - Global.MovieSession.QueueNewMovie(movie, record, Emulator); - } - catch (MoviePlatformMismatchException ex) - { - MessageBox.Show(this, ex.Message, "Movie/Platform Mismatch", MessageBoxButtons.OK, MessageBoxIcon.Error); - return false; - } - - RebootCoresMenuItem_Click(null, null); - - Emulator = EmulatorWindows.Master.Emulator; - - if (Global.MovieSession.PreviousNES_InQuickNES.HasValue) - { - Global.Config.NES_InQuickNES = Global.MovieSession.PreviousNES_InQuickNES.Value; - Global.MovieSession.PreviousNES_InQuickNES = null; - } - - if (Global.MovieSession.PreviousSNES_InSnes9x.HasValue) - { - Global.Config.SNES_InSnes9x = Global.MovieSession.PreviousSNES_InSnes9x.Value; - Global.MovieSession.PreviousSNES_InSnes9x = null; - } - - if (Global.MovieSession.PreviousGBA_UsemGBA.HasValue) - { - Global.Config.GBA_UsemGBA = Global.MovieSession.PreviousGBA_UsemGBA.Value; - Global.MovieSession.PreviousGBA_UsemGBA = null; - } - - Global.Config.RecentMovies.Add(movie.Filename); - - if (EmulatorWindows.Master.Emulator.HasSavestates() && movie.StartsFromSavestate) - { - if (movie.TextSavestate != null) - { - EmulatorWindows.Master.Emulator.AsStatable().LoadStateText(new StringReader(movie.TextSavestate)); - } - else - { - EmulatorWindows.Master.Emulator.AsStatable().LoadStateBinary(new BinaryReader(new MemoryStream(movie.BinarySavestate, false))); - } - - foreach (var ew in EmulatorWindows) - { - ew.Emulator.ResetCounters(); - } - } - - Global.MovieSession.RunQueuedMovie(record); - - SetMainformMovieInfo(); - UpdateAfterFrameChanged(); - return true; - } - - private void hotkeyConfigToolStripMenuItem_Click(object sender, EventArgs e) - { - if (new BizHawk.Client.EmuHawk.HotkeyConfig().ShowDialog() == DialogResult.OK) - { - InitControls(); - _inputManager.SyncControls(); - } - } - - private void controllerConfigToolStripMenuItem_Click(object sender, EventArgs e) - { - var controller = new BizHawk.Client.EmuHawk.ControllerConfig(EmulatorWindows.Master.Emulator.ControllerDefinition); - if (controller.ShowDialog() == DialogResult.OK) - { - InitControls(); - _inputManager.SyncControls(); - } - } - - public void EmulatorWindowClosed(EmulatorWindow ew) - { - EmulatorWindows.Remove(ew); - WorkspacePanel.Controls.Remove(ew); - - if (ew.Emulator == Emulator) - { - if (EmulatorWindows.Any()) - { - Emulator = EmulatorWindows.Master.Emulator; - } - else - { - Emulator = null; - ViewSubMenu.Enabled = false; - } - } - } - - private void ExitMenuItem_Click(object sender, EventArgs e) - { - Close(); - } - - private void saveConfigToolStripMenuItem_Click(object sender, EventArgs e) - { - SaveConfig(); - AddMessage("Saved settings"); - } - - private void RebootCoresMenuItem_Click(object sender, EventArgs e) - { - foreach (var ew in EmulatorWindows) - { - ReloadRom(ew); - } - - AddMessage("Rebooted all cores"); - } - - private void SaveSessionMenuItem_Click(object sender, EventArgs e) - { - if (!string.IsNullOrWhiteSpace(EmulatorWindows.SessionName)) - { - File.WriteAllText(EmulatorWindows.SessionName, EmulatorWindows.SessionJson); - AddMessage("Session saved."); - } - } - - private void SaveSessionAsMenuItem_Click(object sender, EventArgs e) - { - if (EmulatorWindows.Any()) - { - var file = GetSaveFileFromUser(); - if (file != null) - { - EmulatorWindows.SessionName = file.FullName; - Global.Config.RecentRomSessions.Add(file.FullName); - SaveSessionMenuItem_Click(sender, e); - UpdateMainText(); - } - } - } - - private FileInfo GetSaveFileFromUser() - { - var sfd = new SaveFileDialog(); - if (!string.IsNullOrWhiteSpace(EmulatorWindows.SessionName)) - { - sfd.FileName = Path.GetFileNameWithoutExtension(EmulatorWindows.SessionName); - sfd.InitialDirectory = Path.GetDirectoryName(EmulatorWindows.SessionName); - } - else if (EmulatorWindows.Master != null) - { - sfd.FileName = PathManager.FilesystemSafeName(EmulatorWindows.Master.Game); - sfd.InitialDirectory = PathManager.GetRomsPath("Global"); - } - else - { - sfd.FileName = "NULL"; - sfd.InitialDirectory = PathManager.GetRomsPath("Global"); - } - - sfd.Filter = "Rom Session Files (*.romses)|*.romses|All Files|*.*"; - sfd.RestoreDirectory = true; - var result = sfd.ShowDialog(); - if (result != DialogResult.OK) - { - return null; - } - - return new FileInfo(sfd.FileName); - } - - private void OpenSessionMenuItem_Click(object sender, EventArgs e) - { - var file = GetFileFromUser("Rom Session Files (*.romses)|*.romses|All Files|*.*"); - if (file != null) - { - NewSessionMenuItem_Click(null, null); - var json = File.ReadAllText(file.FullName); - EmulatorWindows.SessionName = file.FullName; - LoadRomSession(EmulatorWindowList.FromJson(json)); - Global.Config.RecentRomSessions.Add(file.FullName); - UpdateMainText(); - } - } - - private void UpdateMainText() - { - string text = "MultiHawk"; - - if (!string.IsNullOrWhiteSpace(EmulatorWindows.SessionName)) - { - text += " - " + Path.GetFileNameWithoutExtension(EmulatorWindows.SessionName); - } - - if (Global.MovieSession.Movie.IsActive) - { - text += " - " + Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename); - } - - Text = text; - } - - private static FileInfo GetFileFromUser(string filter) - { - var ofd = new OpenFileDialog - { - InitialDirectory = PathManager.GetRomsPath("Global"), - Filter = filter, - RestoreDirectory = true - }; - - if (!Directory.Exists(ofd.InitialDirectory)) - { - Directory.CreateDirectory(ofd.InitialDirectory); - } - - var result = ofd.ShowDialog(); - return result == DialogResult.OK ? new FileInfo(ofd.FileName) : null; - } - - private void CloseAllWindows() - { - foreach (var ew in EmulatorWindows) - { - ew.Close(); - } - - EmulatorWindows.Clear(); - } - - private void NewSessionMenuItem_Click(object sender, EventArgs e) - { - foreach (var ew in EmulatorWindows) - { - ew.Close(); - } - - EmulatorWindows.Clear(); - UpdateMainText(); - } - - private void LoadRomSession(IEnumerable entries) - { - foreach (var entry in entries) - { - LoadRom(entry.RomName); - EmulatorWindows.Last().Location = new Point(entry.Wndx, entry.Wndy); - UpdateMainText(); - } - } - - private void LoadRomSessionFromRecent(string path) - { - var file = new FileInfo(path); - if (file.Exists) - { - NewSessionMenuItem_Click(null, null); - var json = File.ReadAllText(file.FullName); - EmulatorWindows.SessionName = file.FullName; - LoadRomSession(EmulatorWindowList.FromJson(json)); - Global.Config.RecentRomSessions.Add(file.FullName); - UpdateMainText(); - } - else - { - Global.Config.RecentRomSessions.HandleLoadError(path); - } - } - - private void RecentSessionSubMenu_DropDownOpened(object sender, EventArgs e) - { - RecentSessionSubMenu.DropDownItems.Clear(); - RecentSessionSubMenu.DropDownItems.AddRange( - Global.Config.RecentRomSessions.RecentMenu(LoadRomSessionFromRecent, autoload: true)); - } - - private void RecentRomSubMenu_DropDownOpened(object sender, EventArgs e) - { - RecentRomSubMenu.DropDownItems.Clear(); - RecentRomSubMenu.DropDownItems.AddRange( - Global.Config.RecentRoms.RecentMenu(LoadRomFromRecent, autoload: false)); - } - - private void ViewSubMenu_DropDownOpened(object sender, EventArgs e) - { - _1xMenuItem.Checked = Global.Config.TargetZoomFactors[Emulator.SystemId] == 1; - _2xMenuItem.Checked = Global.Config.TargetZoomFactors[Emulator.SystemId] == 2; - _3xMenuItem.Checked = Global.Config.TargetZoomFactors[Emulator.SystemId] == 3; - _4xMenuItem.Checked = Global.Config.TargetZoomFactors[Emulator.SystemId] == 4; - } - - private void _1xMenuItem_Click(object sender, EventArgs e) - { - Global.Config.TargetZoomFactors[Emulator.SystemId] = 1; - ReRenderAllWindows(); - } - - private void _2xMenuItem_Click(object sender, EventArgs e) - { - Global.Config.TargetZoomFactors[Emulator.SystemId] = 2; - ReRenderAllWindows(); - } - - private void _3xMenuItem_Click(object sender, EventArgs e) - { - Global.Config.TargetZoomFactors[Emulator.SystemId] = 3; - ReRenderAllWindows(); - } - - private void _4xMenuItem_Click(object sender, EventArgs e) - { - Global.Config.TargetZoomFactors[Emulator.SystemId] = 4; - ReRenderAllWindows(); - } - - private void ReRenderAllWindows() - { - foreach (var ew in EmulatorWindows) - { - ew.FrameBufferResized(); - ew.Render(); - } - } - - private void LoadLastMovieMenuItem_Click(object sender, EventArgs e) - { - LoadMoviesFromRecent(Global.Config.RecentMovies.MostRecent); - } - - private void contextMenuStrip1_Opening(object sender, CancelEventArgs e) - { - LoadLastMovieContextMenuItem.Visible = !Global.Config.RecentMovies.Empty; - PlayMovieContextMenuItem.Visible = - RecordMovieContextMenuItem.Visible = - !Global.MovieSession.Movie.IsActive; - - StopMovieContextMenuItem.Visible = - RestartMovieContextMenuItem.Visible = - Global.MovieSession.Movie.IsActive; - - } - - private void RecentMovieSubMenu_DropDownOpened(object sender, EventArgs e) - { - RecentMovieSubMenu.DropDownItems.Clear(); - RecentMovieSubMenu.DropDownItems.AddRange( - Global.Config.RecentMovies.RecentMenu(LoadMoviesFromRecent, autoload: true)); - } - - private void RestartMovieMenuItem_Click(object sender, EventArgs e) - { - if (Global.MovieSession.Movie.IsActive) - { - StartNewMovie(Global.MovieSession.Movie, false); - AddMessage("Replaying movie file in read-only mode"); - } - } - } -} diff --git a/BizHawk.Client.MultiHawk/Mainform.resx b/BizHawk.Client.MultiHawk/Mainform.resx deleted file mode 100644 index bdf629369a..0000000000 --- a/BizHawk.Client.MultiHawk/Mainform.resx +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 153, 17 - - - 153, 17 - - - 283, 17 - - \ No newline at end of file diff --git a/BizHawk.Client.MultiHawk/PresentationPanel.cs b/BizHawk.Client.MultiHawk/PresentationPanel.cs deleted file mode 100644 index 881f13960a..0000000000 --- a/BizHawk.Client.MultiHawk/PresentationPanel.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Drawing; -using sd=System.Drawing; -using sysdrawingfont=System.Drawing.Font; -using sysdrawing2d=System.Drawing.Drawing2D; -using System.IO; -using System.Threading; -using System.Windows.Forms; -#if WINDOWS -using SlimDX; -#endif - -using BizHawk.Client.Common; -using BizHawk.Bizware.BizwareGL; - -using OpenTK.Graphics.OpenGL; - -namespace BizHawk.Client.MultiHawk -{ - /// - /// Thinly wraps a BizwareGL.GraphicsControl for EmuHawk's needs - /// - public class PresentationPanel - { - public PresentationPanel(Form parent, IGL gl) - { - GL = gl; - - GraphicsControl = new GraphicsControl(GL); - GraphicsControl.Dock = DockStyle.Fill; - GraphicsControl.BackColor = Color.Black; - - //pass through these events to the form. we might need a more scalable solution for mousedown etc. for zapper and whatnot. - //http://stackoverflow.com/questions/547172/pass-through-mouse-events-to-parent-control (HTTRANSPARENT) - - // TODO - //GraphicsControl.MouseClick += (o, e) => GlobalWin.MainForm.MainForm_MouseClick(o, e); - } - - bool IsDisposed = false; - public void Dispose() - { - if (IsDisposed) return; - IsDisposed = true; - GraphicsControl.Dispose(); - } - - //graphics resources - public IGL GL { get; set; } - public GraphicsControl GraphicsControl; - - public Control Control { get { return GraphicsControl; } } - public static implicit operator Control(PresentationPanel self) { return self.GraphicsControl; } - - public bool Resized { get; set; } - - public Size NativeSize { get { return GraphicsControl.ClientSize; } } - } - - - - public interface IBlitterFont { } - -} diff --git a/BizHawk.Client.MultiHawk/Program.cs b/BizHawk.Client.MultiHawk/Program.cs deleted file mode 100644 index 9ee5ddddc7..0000000000 --- a/BizHawk.Client.MultiHawk/Program.cs +++ /dev/null @@ -1,171 +0,0 @@ -using System; -using System.IO; -using System.Collections.Generic; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Windows.Forms; -#if WINDOWS -using SlimDX.DirectSound; -using Microsoft.VisualBasic.ApplicationServices; -#endif - -using BizHawk.Common; -using BizHawk.Client.Common; - -namespace BizHawk.Client.MultiHawk -{ - static class Program - { - static Program() - { - //http://www.codeproject.com/Articles/310675/AppDomain-AssemblyResolve-Event-Tips -#if WINDOWS - // this will look in subdirectory "dll" to load pinvoked stuff - string dllDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dll"); - SetDllDirectory(dllDir); - - //in case assembly resolution fails, such as if we moved them into the dll subdiretory, this event handler can reroute to them - AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); - - //but before we even try doing that, whack the MOTW from everything in that directory (thats a dll) - //otherwise, some people will have crashes at boot-up due to .net security disliking MOTW. - //some people are getting MOTW through a combination of browser used to download bizhawk, and program used to dearchive it - WhackAllMOTW(dllDir); -#endif - } - - - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main(string[] args) - { - SubMain(args); - } - - - //NoInlining should keep this code from getting jammed into Main() which would create dependencies on types which havent been setup by the resolver yet... or something like that - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] - static void SubMain(string[] args) - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - string iniPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.ini"); - Global.Config = ConfigService.Load(iniPath); - Global.Config.ResolveDefaults(); - HawkFile.ArchiveHandlerFactory = new SevenZipSharpArchiveHandler(); - - //super hacky! this needs to be done first. still not worth the trouble to make this system fully proper - for (int i = 0; i < args.Length; i++) - { - var arg = args[i].ToLower(); - if (arg.StartsWith("--gdi")) - { - Global.Config.DispMethod = Config.EDispMethod.GdiPlus; - } - } - - - //WHY do we have to do this? some intel graphics drivers (ig7icd64.dll 10.18.10.3304 on an unknown chip on win8.1) are calling SetDllDirectory() for the process, which ruins stuff. - //The relevant initialization happened just before in "create IGL context". - //It isn't clear whether we need the earlier SetDllDirectory(), but I think we do. - //note: this is pasted instead of being put in a static method due to this initialization code being sensitive to things like that, and not wanting to cause it to break - //pasting should be safe (not affecting the jit order of things) - string dllDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dll"); - SetDllDirectory(dllDir); - - try - { - using (var mf = new Mainform(args)) - { - var title = mf.Text; - mf.Show(); - mf.Text = title; - try - { - mf.ProgramRunLoop(); - } - catch (Exception e) when (Global.MovieSession.Movie.IsActive) - { - var result = MessageBox.Show( - "EmuHawk has thrown a fatal exception and is about to close.\nA movie has been detected. Would you like to try to save?\n(Note: Depending on what caused this error, this may or may not succeed)", - "Fatal error: " + e.GetType().Name, - MessageBoxButtons.YesNo, - MessageBoxIcon.Exclamation - ); - if (result == DialogResult.Yes) - { - Global.MovieSession.Movie.Save(); - } - } - } - } - catch (Exception e) - { - string message = e.ToString(); - if (e.InnerException != null) - { - message += "\n\nInner Exception:\n\n" + e.InnerException; - } - - message += "\n\nStackTrace:\n" + e.StackTrace; - MessageBox.Show(message); - } -#if WINDOWS - finally - { - GamePad.CloseAll(); - } -#endif - } - - - static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) - { - lock (AppDomain.CurrentDomain) - { - var asms = AppDomain.CurrentDomain.GetAssemblies(); - foreach (var asm in asms) - if (asm.FullName == args.Name) - return asm; - - //load missing assemblies by trying to find them in the dll directory - string dllname = new AssemblyName(args.Name).Name + ".dll"; - string directory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dll"); - string fname = Path.Combine(directory, dllname); - if (!File.Exists(fname)) return null; - //it is important that we use LoadFile here and not load from a byte array; otherwise mixed (managed/unamanged) assemblies can't load - return Assembly.LoadFile(fname); - } - } - - //declared here instead of a more usual place to avoid dependencies on the more usual place -#if WINDOWS - [DllImport("kernel32.dll", SetLastError = true)] - static extern uint SetDllDirectory(string lpPathName); - - [DllImport("kernel32.dll", EntryPoint = "DeleteFileW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] - static extern bool DeleteFileW([MarshalAs(UnmanagedType.LPWStr)]string lpFileName); - static void RemoveMOTW(string path) - { - DeleteFileW(path + ":Zone.Identifier"); - } - - static void WhackAllMOTW(string dllDir) - { - var todo = new Queue(new[] { new DirectoryInfo(dllDir) }); - while (todo.Count > 0) - { - var di = todo.Dequeue(); - foreach (var disub in di.GetDirectories()) todo.Enqueue(disub); - foreach (var fi in di.GetFiles("*.dll")) - RemoveMOTW(fi.FullName); - foreach (var fi in di.GetFiles("*.exe")) - RemoveMOTW(fi.FullName); - } - - } -#endif - } -} diff --git a/BizHawk.Client.MultiHawk/Properties/AssemblyInfo.cs b/BizHawk.Client.MultiHawk/Properties/AssemblyInfo.cs deleted file mode 100644 index e0b3f137d4..0000000000 --- a/BizHawk.Client.MultiHawk/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("BizHawk.Client.MultiHawk")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("BizHawk.Client.MultiHawk")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("fcf20c42-6452-46c7-bb88-bc9f5bd0ce71")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/BizHawk.Client.MultiHawk/Properties/Resources.Designer.cs b/BizHawk.Client.MultiHawk/Properties/Resources.Designer.cs deleted file mode 100644 index 3855218b5a..0000000000 --- a/BizHawk.Client.MultiHawk/Properties/Resources.Designer.cs +++ /dev/null @@ -1,293 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.34209 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace BizHawk.Client.MultiHawk.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BizHawk.Client.MultiHawk.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Blank { - get { - object obj = ResourceManager.GetObject("Blank", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Byte[]. - /// - internal static byte[] courier16px { - get { - object obj = ResourceManager.GetObject("courier16px", resourceCulture); - return ((byte[])(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap courier16px_0 { - get { - object obj = ResourceManager.GetObject("courier16px_0", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Byte[]. - /// - internal static byte[] courier16px1 { - get { - object obj = ResourceManager.GetObject("courier16px1", resourceCulture); - return ((byte[])(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap CutHS { - get { - object obj = ResourceManager.GetObject("CutHS", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ExclamationRed { - get { - object obj = ResourceManager.GetObject("ExclamationRed", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap GameController { - get { - object obj = ResourceManager.GetObject("GameController", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap GreenCheck { - get { - object obj = ResourceManager.GetObject("GreenCheck", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Help { - get { - object obj = ResourceManager.GetObject("Help", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap HotKeys { - get { - object obj = ResourceManager.GetObject("HotKeys", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap OpenFile { - get { - object obj = ResourceManager.GetObject("OpenFile", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Pause { - get { - object obj = ResourceManager.GetObject("Pause", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Play { - get { - object obj = ResourceManager.GetObject("Play", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ReadOnly { - get { - object obj = ResourceManager.GetObject("ReadOnly", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap reboot { - get { - object obj = ResourceManager.GetObject("reboot", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Recent { - get { - object obj = ResourceManager.GetObject("Recent", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap RecordHS { - get { - object obj = ResourceManager.GetObject("RecordHS", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap restart { - get { - object obj = ResourceManager.GetObject("restart", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Save { - get { - object obj = ResourceManager.GetObject("Save", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SaveAllHS { - get { - object obj = ResourceManager.GetObject("SaveAllHS", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SaveAs { - get { - object obj = ResourceManager.GetObject("SaveAs", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Scan { - get { - object obj = ResourceManager.GetObject("Scan", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Stop { - get { - object obj = ResourceManager.GetObject("Stop", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - } -} diff --git a/BizHawk.Client.MultiHawk/Properties/Resources.resx b/BizHawk.Client.MultiHawk/Properties/Resources.resx deleted file mode 100644 index 88761a4c4d..0000000000 --- a/BizHawk.Client.MultiHawk/Properties/Resources.resx +++ /dev/null @@ -1,190 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - ..\images\Blank.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\courier16px.bmfc;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - ..\Resources\courier16px.fnt;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - ..\Resources\courier16px_0.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\images\CutHS.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\images\ExclamationRed.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\images\GreenCheck.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\images\OpenFile.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\images\Pause.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\images\Play.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\images\ReadOnly.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\images\reboot.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\images\Recent.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\images\RecordHS.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\images\SaveAllHS.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\images\SaveAs.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\images\Scan.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\images\Stop.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\images\GameController.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\images\Help.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\images\HotKeys.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\images\Save.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\images\restart.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - \ No newline at end of file diff --git a/BizHawk.Client.MultiHawk/Properties/Settings.Designer.cs b/BizHawk.Client.MultiHawk/Properties/Settings.Designer.cs deleted file mode 100644 index fb9499495c..0000000000 --- a/BizHawk.Client.MultiHawk/Properties/Settings.Designer.cs +++ /dev/null @@ -1,26 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace BizHawk.Client.MultiHawk.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - } -} diff --git a/BizHawk.Client.MultiHawk/Properties/Settings.settings b/BizHawk.Client.MultiHawk/Properties/Settings.settings deleted file mode 100644 index abf36c5d3d..0000000000 --- a/BizHawk.Client.MultiHawk/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/BizHawk.Client.MultiHawk/Resources/courier16px.bmfc b/BizHawk.Client.MultiHawk/Resources/courier16px.bmfc deleted file mode 100644 index df09355333..0000000000 --- a/BizHawk.Client.MultiHawk/Resources/courier16px.bmfc +++ /dev/null @@ -1,55 +0,0 @@ -# AngelCode Bitmap Font Generator configuration file -fileVersion=1 - -# font settings -fontName=Courier -fontFile= -charSet=0 -fontSize=16 -aa=1 -scaleH=100 -useSmoothing=0 -isBold=1 -isItalic=0 -useUnicode=1 -disableBoxChars=1 -outputInvalidCharGlyph=1 -dontIncludeKerningPairs=0 -useHinting=1 -renderFromOutline=0 -useClearType=1 - -# character alignment -paddingDown=0 -paddingUp=0 -paddingRight=0 -paddingLeft=0 -spacingHoriz=1 -spacingVert=1 -useFixedHeight=0 -forceZero=0 - -# output file -outWidth=128 -outHeight=256 -outBitDepth=32 -fontDescFormat=1 -fourChnlPacked=0 -textureFormat=png -textureCompression=0 -alphaChnl=0 -redChnl=4 -greenChnl=4 -blueChnl=4 -invA=0 -invR=0 -invG=0 -invB=0 - -# outline -outlineThickness=0 - -# selected chars -chars=32-127,129,141,143-144,157,160-255 - -# imported icon images diff --git a/BizHawk.Client.MultiHawk/Resources/courier16px.fnt b/BizHawk.Client.MultiHawk/Resources/courier16px.fnt deleted file mode 100644 index 0e8d5e8a1f..0000000000 --- a/BizHawk.Client.MultiHawk/Resources/courier16px.fnt +++ /dev/null @@ -1,208 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/BizHawk.Client.MultiHawk/Resources/courier16px_0.png b/BizHawk.Client.MultiHawk/Resources/courier16px_0.png deleted file mode 100644 index 36d5051db4..0000000000 Binary files a/BizHawk.Client.MultiHawk/Resources/courier16px_0.png and /dev/null differ diff --git a/BizHawk.Client.MultiHawk/images/Blank.png b/BizHawk.Client.MultiHawk/images/Blank.png deleted file mode 100644 index c8d0a51cc0..0000000000 Binary files a/BizHawk.Client.MultiHawk/images/Blank.png and /dev/null differ diff --git a/BizHawk.Client.MultiHawk/images/CutHS.png b/BizHawk.Client.MultiHawk/images/CutHS.png deleted file mode 100644 index dd40e93a2a..0000000000 Binary files a/BizHawk.Client.MultiHawk/images/CutHS.png and /dev/null differ diff --git a/BizHawk.Client.MultiHawk/images/ExclamationRed.png b/BizHawk.Client.MultiHawk/images/ExclamationRed.png deleted file mode 100644 index e1e238ad30..0000000000 Binary files a/BizHawk.Client.MultiHawk/images/ExclamationRed.png and /dev/null differ diff --git a/BizHawk.Client.MultiHawk/images/GameController.png b/BizHawk.Client.MultiHawk/images/GameController.png deleted file mode 100644 index 3d0131cd16..0000000000 Binary files a/BizHawk.Client.MultiHawk/images/GameController.png and /dev/null differ diff --git a/BizHawk.Client.MultiHawk/images/GreenCheck.png b/BizHawk.Client.MultiHawk/images/GreenCheck.png deleted file mode 100644 index 9f243dcd9d..0000000000 Binary files a/BizHawk.Client.MultiHawk/images/GreenCheck.png and /dev/null differ diff --git a/BizHawk.Client.MultiHawk/images/Help.png b/BizHawk.Client.MultiHawk/images/Help.png deleted file mode 100644 index 30a424bbf1..0000000000 Binary files a/BizHawk.Client.MultiHawk/images/Help.png and /dev/null differ diff --git a/BizHawk.Client.MultiHawk/images/HotKeys.png b/BizHawk.Client.MultiHawk/images/HotKeys.png deleted file mode 100644 index 962eb51ed7..0000000000 Binary files a/BizHawk.Client.MultiHawk/images/HotKeys.png and /dev/null differ diff --git a/BizHawk.Client.MultiHawk/images/OpenFile.png b/BizHawk.Client.MultiHawk/images/OpenFile.png deleted file mode 100644 index 0bc670e2c0..0000000000 Binary files a/BizHawk.Client.MultiHawk/images/OpenFile.png and /dev/null differ diff --git a/BizHawk.Client.MultiHawk/images/Pause.png b/BizHawk.Client.MultiHawk/images/Pause.png deleted file mode 100644 index 206c71c233..0000000000 Binary files a/BizHawk.Client.MultiHawk/images/Pause.png and /dev/null differ diff --git a/BizHawk.Client.MultiHawk/images/Play.png b/BizHawk.Client.MultiHawk/images/Play.png deleted file mode 100644 index b8f7541b05..0000000000 Binary files a/BizHawk.Client.MultiHawk/images/Play.png and /dev/null differ diff --git a/BizHawk.Client.MultiHawk/images/ReadOnly.png b/BizHawk.Client.MultiHawk/images/ReadOnly.png deleted file mode 100644 index 119d155206..0000000000 Binary files a/BizHawk.Client.MultiHawk/images/ReadOnly.png and /dev/null differ diff --git a/BizHawk.Client.MultiHawk/images/Recent.png b/BizHawk.Client.MultiHawk/images/Recent.png deleted file mode 100644 index 42c559ad27..0000000000 Binary files a/BizHawk.Client.MultiHawk/images/Recent.png and /dev/null differ diff --git a/BizHawk.Client.MultiHawk/images/RecordHS.png b/BizHawk.Client.MultiHawk/images/RecordHS.png deleted file mode 100644 index 581741d36c..0000000000 Binary files a/BizHawk.Client.MultiHawk/images/RecordHS.png and /dev/null differ diff --git a/BizHawk.Client.MultiHawk/images/Save.png b/BizHawk.Client.MultiHawk/images/Save.png deleted file mode 100644 index 5ec0a2d762..0000000000 Binary files a/BizHawk.Client.MultiHawk/images/Save.png and /dev/null differ diff --git a/BizHawk.Client.MultiHawk/images/SaveAllHS.png b/BizHawk.Client.MultiHawk/images/SaveAllHS.png deleted file mode 100644 index 7bde10a6d2..0000000000 Binary files a/BizHawk.Client.MultiHawk/images/SaveAllHS.png and /dev/null differ diff --git a/BizHawk.Client.MultiHawk/images/SaveAs.png b/BizHawk.Client.MultiHawk/images/SaveAs.png deleted file mode 100644 index 5ca4d10623..0000000000 Binary files a/BizHawk.Client.MultiHawk/images/SaveAs.png and /dev/null differ diff --git a/BizHawk.Client.MultiHawk/images/Scan.png b/BizHawk.Client.MultiHawk/images/Scan.png deleted file mode 100644 index ea5e620d8f..0000000000 Binary files a/BizHawk.Client.MultiHawk/images/Scan.png and /dev/null differ diff --git a/BizHawk.Client.MultiHawk/images/Stop.png b/BizHawk.Client.MultiHawk/images/Stop.png deleted file mode 100644 index ef00c0f811..0000000000 Binary files a/BizHawk.Client.MultiHawk/images/Stop.png and /dev/null differ diff --git a/BizHawk.Client.MultiHawk/images/reboot.png b/BizHawk.Client.MultiHawk/images/reboot.png deleted file mode 100644 index 2d355ac56c..0000000000 Binary files a/BizHawk.Client.MultiHawk/images/reboot.png and /dev/null differ diff --git a/BizHawk.Client.MultiHawk/images/restart.png b/BizHawk.Client.MultiHawk/images/restart.png deleted file mode 100644 index 89eebbbd04..0000000000 Binary files a/BizHawk.Client.MultiHawk/images/restart.png and /dev/null differ diff --git a/BizHawk.Client.MultiHawk/movie/PlayMovie.Designer.cs b/BizHawk.Client.MultiHawk/movie/PlayMovie.Designer.cs deleted file mode 100644 index 39e0289bb3..0000000000 --- a/BizHawk.Client.MultiHawk/movie/PlayMovie.Designer.cs +++ /dev/null @@ -1,406 +0,0 @@ -namespace BizHawk.Client.MultiHawk -{ - partial class PlayMovie - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PlayMovie)); - this.Cancel = new System.Windows.Forms.Button(); - this.OK = new System.Windows.Forms.Button(); - this.BrowseMovies = new System.Windows.Forms.Button(); - this.DetailsView = new System.Windows.Forms.ListView(); - this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.SubtitlesBtn = new System.Windows.Forms.Button(); - this.CommentsBtn = new System.Windows.Forms.Button(); - this.MovieCount = new System.Windows.Forms.Label(); - this.ReadOnlyCheckBox = new System.Windows.Forms.CheckBox(); - this.IncludeSubDirectories = new System.Windows.Forms.CheckBox(); - this.Scan = new System.Windows.Forms.Button(); - this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); - this.MatchHashCheckBox = new System.Windows.Forms.CheckBox(); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.StopOnFrameCheckbox = new System.Windows.Forms.CheckBox(); - this.StopOnFrameTextBox = new BizHawk.Client.EmuHawk.WatchValueBox(); - this.MovieView = new BizHawk.Client.EmuHawk.VirtualListView(); - this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.LastFrameCheckbox = new System.Windows.Forms.CheckBox(); - this.TurboCheckbox = new System.Windows.Forms.CheckBox(); - this.groupBox1.SuspendLayout(); - this.contextMenuStrip1.SuspendLayout(); - this.SuspendLayout(); - // - // Cancel - // - this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.Cancel.Location = new System.Drawing.Point(687, 363); - this.Cancel.Name = "Cancel"; - this.Cancel.Size = new System.Drawing.Size(75, 23); - this.Cancel.TabIndex = 55; - this.Cancel.Text = "&Cancel"; - this.Cancel.UseVisualStyleBackColor = true; - this.Cancel.Click += new System.EventHandler(this.Cancel_Click); - // - // OK - // - this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.OK.Location = new System.Drawing.Point(606, 363); - this.OK.Name = "OK"; - this.OK.Size = new System.Drawing.Size(75, 23); - this.OK.TabIndex = 50; - this.OK.Text = "&OK"; - this.toolTip1.SetToolTip(this.OK, "Load selected movie"); - this.OK.UseVisualStyleBackColor = true; - this.OK.Click += new System.EventHandler(this.Ok_Click); - // - // BrowseMovies - // - this.BrowseMovies.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.BrowseMovies.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.OpenFile; - this.BrowseMovies.Location = new System.Drawing.Point(12, 364); - this.BrowseMovies.Name = "BrowseMovies"; - this.BrowseMovies.Size = new System.Drawing.Size(31, 23); - this.BrowseMovies.TabIndex = 25; - this.toolTip1.SetToolTip(this.BrowseMovies, "Browse for additional movie files"); - this.BrowseMovies.UseVisualStyleBackColor = true; - this.BrowseMovies.Click += new System.EventHandler(this.BrowseMovies_Click); - // - // DetailsView - // - this.DetailsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.DetailsView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader5, - this.columnHeader6}); - this.DetailsView.FullRowSelect = true; - this.DetailsView.GridLines = true; - this.DetailsView.HideSelection = false; - this.DetailsView.Location = new System.Drawing.Point(15, 19); - this.DetailsView.Name = "DetailsView"; - this.DetailsView.Size = new System.Drawing.Size(228, 261); - this.DetailsView.TabIndex = 10; - this.toolTip1.SetToolTip(this.DetailsView, "Contains the header information for the selected movie"); - this.DetailsView.UseCompatibleStateImageBehavior = false; - this.DetailsView.View = System.Windows.Forms.View.Details; - this.DetailsView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.DetailsView_ColumnClick); - // - // columnHeader5 - // - this.columnHeader5.Text = "Header"; - this.columnHeader5.Width = 102; - // - // columnHeader6 - // - this.columnHeader6.Text = "Value"; - this.columnHeader6.Width = 121; - // - // groupBox1 - // - this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.groupBox1.Controls.Add(this.SubtitlesBtn); - this.groupBox1.Controls.Add(this.CommentsBtn); - this.groupBox1.Controls.Add(this.DetailsView); - this.groupBox1.Location = new System.Drawing.Point(503, 28); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(259, 322); - this.groupBox1.TabIndex = 6; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Details"; - // - // SubtitlesBtn - // - this.SubtitlesBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.SubtitlesBtn.Enabled = false; - this.SubtitlesBtn.Location = new System.Drawing.Point(125, 286); - this.SubtitlesBtn.Name = "SubtitlesBtn"; - this.SubtitlesBtn.Size = new System.Drawing.Size(75, 23); - this.SubtitlesBtn.TabIndex = 20; - this.SubtitlesBtn.Text = "Subtitles"; - this.SubtitlesBtn.UseVisualStyleBackColor = true; - this.SubtitlesBtn.Click += new System.EventHandler(this.SubtitlesBtn_Click); - // - // CommentsBtn - // - this.CommentsBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.CommentsBtn.Enabled = false; - this.CommentsBtn.Location = new System.Drawing.Point(15, 286); - this.CommentsBtn.Name = "CommentsBtn"; - this.CommentsBtn.Size = new System.Drawing.Size(75, 23); - this.CommentsBtn.TabIndex = 15; - this.CommentsBtn.Text = "Comments"; - this.CommentsBtn.UseVisualStyleBackColor = true; - this.CommentsBtn.Click += new System.EventHandler(this.CommentsBtn_Click); - // - // MovieCount - // - this.MovieCount.AutoSize = true; - this.MovieCount.Location = new System.Drawing.Point(12, 9); - this.MovieCount.Name = "MovieCount"; - this.MovieCount.Size = new System.Drawing.Size(31, 13); - this.MovieCount.TabIndex = 7; - this.MovieCount.Text = " "; - // - // ReadOnlyCheckBox - // - this.ReadOnlyCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.ReadOnlyCheckBox.AutoSize = true; - this.ReadOnlyCheckBox.Checked = true; - this.ReadOnlyCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; - this.ReadOnlyCheckBox.Location = new System.Drawing.Point(503, 367); - this.ReadOnlyCheckBox.Name = "ReadOnlyCheckBox"; - this.ReadOnlyCheckBox.Size = new System.Drawing.Size(74, 17); - this.ReadOnlyCheckBox.TabIndex = 45; - this.ReadOnlyCheckBox.Text = "Read only"; - this.ReadOnlyCheckBox.UseVisualStyleBackColor = true; - // - // IncludeSubDirectories - // - this.IncludeSubDirectories.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.IncludeSubDirectories.AutoSize = true; - this.IncludeSubDirectories.Location = new System.Drawing.Point(94, 375); - this.IncludeSubDirectories.Name = "IncludeSubDirectories"; - this.IncludeSubDirectories.Size = new System.Drawing.Size(131, 17); - this.IncludeSubDirectories.TabIndex = 35; - this.IncludeSubDirectories.Text = "Include Subdirectories"; - this.IncludeSubDirectories.UseVisualStyleBackColor = true; - this.IncludeSubDirectories.CheckedChanged += new System.EventHandler(this.IncludeSubDirectories_CheckedChanged); - // - // Scan - // - this.Scan.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.Scan.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.Scan; - this.Scan.Location = new System.Drawing.Point(49, 364); - this.Scan.Name = "Scan"; - this.Scan.Size = new System.Drawing.Size(27, 23); - this.Scan.TabIndex = 30; - this.toolTip1.SetToolTip(this.Scan, "Rescan Movie folder for movie files"); - this.Scan.UseVisualStyleBackColor = true; - this.Scan.Click += new System.EventHandler(this.Scan_Click); - // - // MatchHashCheckBox - // - this.MatchHashCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.MatchHashCheckBox.AutoSize = true; - this.MatchHashCheckBox.Location = new System.Drawing.Point(94, 357); - this.MatchHashCheckBox.Name = "MatchHashCheckBox"; - this.MatchHashCheckBox.Size = new System.Drawing.Size(147, 17); - this.MatchHashCheckBox.TabIndex = 56; - this.MatchHashCheckBox.Text = "Match current game hash"; - this.MatchHashCheckBox.UseVisualStyleBackColor = true; - this.MatchHashCheckBox.CheckedChanged += new System.EventHandler(this.MatchHashCheckBox_CheckedChanged); - // - // contextMenuStrip1 - // - this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.editToolStripMenuItem}); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(93, 26); - // - // editToolStripMenuItem - // - this.editToolStripMenuItem.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.CutHS; - this.editToolStripMenuItem.Name = "editToolStripMenuItem"; - this.editToolStripMenuItem.Size = new System.Drawing.Size(92, 22); - this.editToolStripMenuItem.Text = "&Edit"; - this.editToolStripMenuItem.Click += new System.EventHandler(this.EditMenuItem_Click); - // - // StopOnFrameCheckbox - // - this.StopOnFrameCheckbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.StopOnFrameCheckbox.AutoSize = true; - this.StopOnFrameCheckbox.Location = new System.Drawing.Point(342, 357); - this.StopOnFrameCheckbox.Name = "StopOnFrameCheckbox"; - this.StopOnFrameCheckbox.Size = new System.Drawing.Size(95, 17); - this.StopOnFrameCheckbox.TabIndex = 57; - this.StopOnFrameCheckbox.Text = "Stop on frame:"; - this.StopOnFrameCheckbox.UseVisualStyleBackColor = true; - this.StopOnFrameCheckbox.CheckedChanged += new System.EventHandler(this.StopOnFrameCheckbox_CheckedChanged); - // - // StopOnFrameTextBox - // - this.StopOnFrameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.StopOnFrameTextBox.ByteSize = BizHawk.Client.Common.WatchSize.DWord; - this.StopOnFrameTextBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; - this.StopOnFrameTextBox.Location = new System.Drawing.Point(438, 355); - this.StopOnFrameTextBox.MaxLength = 10; - this.StopOnFrameTextBox.Name = "StopOnFrameTextBox"; - this.StopOnFrameTextBox.Nullable = true; - this.StopOnFrameTextBox.Size = new System.Drawing.Size(54, 20); - this.StopOnFrameTextBox.TabIndex = 58; - this.StopOnFrameTextBox.Type = BizHawk.Client.Common.DisplayType.Unsigned; - this.StopOnFrameTextBox.TextChanged += new System.EventHandler(this.StopOnFrameTextBox_TextChanged_1); - // - // MovieView - // - this.MovieView.AllowDrop = true; - this.MovieView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.MovieView.BlazingFast = false; - this.MovieView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader1, - this.columnHeader2, - this.columnHeader3, - this.columnHeader4}); - this.MovieView.ContextMenuStrip = this.contextMenuStrip1; - this.MovieView.FullRowSelect = true; - this.MovieView.GridLines = true; - this.MovieView.HideSelection = false; - this.MovieView.ItemCount = 0; - this.MovieView.Location = new System.Drawing.Point(12, 28); - this.MovieView.MultiSelect = false; - this.MovieView.Name = "MovieView"; - this.MovieView.SelectAllInProgress = false; - this.MovieView.selectedItem = -1; - this.MovieView.Size = new System.Drawing.Size(480, 322); - this.MovieView.TabIndex = 5; - this.MovieView.UseCompatibleStateImageBehavior = false; - this.MovieView.UseCustomBackground = true; - this.MovieView.View = System.Windows.Forms.View.Details; - this.MovieView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.MovieView_ColumnClick); - this.MovieView.SelectedIndexChanged += new System.EventHandler(this.MovieView_SelectedIndexChanged); - this.MovieView.DragDrop += new System.Windows.Forms.DragEventHandler(this.MovieView_DragDrop); - this.MovieView.DragEnter += new System.Windows.Forms.DragEventHandler(this.MovieView_DragEnter); - this.MovieView.DoubleClick += new System.EventHandler(this.MovieView_DoubleClick); - this.MovieView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MovieView_KeyDown); - // - // columnHeader1 - // - this.columnHeader1.Text = "File"; - this.columnHeader1.Width = 221; - // - // columnHeader2 - // - this.columnHeader2.Text = "SysID"; - this.columnHeader2.Width = 43; - // - // columnHeader3 - // - this.columnHeader3.Text = "Game"; - this.columnHeader3.Width = 129; - // - // columnHeader4 - // - this.columnHeader4.Text = "Length (est.)"; - this.columnHeader4.Width = 82; - // - // LastFrameCheckbox - // - this.LastFrameCheckbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.LastFrameCheckbox.AutoSize = true; - this.LastFrameCheckbox.Location = new System.Drawing.Point(342, 376); - this.LastFrameCheckbox.Name = "LastFrameCheckbox"; - this.LastFrameCheckbox.Size = new System.Drawing.Size(75, 17); - this.LastFrameCheckbox.TabIndex = 59; - this.LastFrameCheckbox.Text = "Last frame"; - this.LastFrameCheckbox.UseVisualStyleBackColor = true; - this.LastFrameCheckbox.CheckedChanged += new System.EventHandler(this.LastFrameCheckbox_CheckedChanged); - // - // TurboCheckbox - // - this.TurboCheckbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.TurboCheckbox.AutoSize = true; - this.TurboCheckbox.Location = new System.Drawing.Point(438, 376); - this.TurboCheckbox.Name = "TurboCheckbox"; - this.TurboCheckbox.Size = new System.Drawing.Size(54, 17); - this.TurboCheckbox.TabIndex = 60; - this.TurboCheckbox.Text = "Turbo"; - this.TurboCheckbox.UseVisualStyleBackColor = true; - // - // PlayMovie - // - this.AcceptButton = this.OK; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.Cancel; - this.ClientSize = new System.Drawing.Size(774, 398); - this.Controls.Add(this.TurboCheckbox); - this.Controls.Add(this.LastFrameCheckbox); - this.Controls.Add(this.StopOnFrameTextBox); - this.Controls.Add(this.StopOnFrameCheckbox); - this.Controls.Add(this.MatchHashCheckBox); - this.Controls.Add(this.Scan); - this.Controls.Add(this.IncludeSubDirectories); - this.Controls.Add(this.ReadOnlyCheckBox); - this.Controls.Add(this.MovieCount); - this.Controls.Add(this.groupBox1); - this.Controls.Add(this.MovieView); - this.Controls.Add(this.BrowseMovies); - this.Controls.Add(this.OK); - this.Controls.Add(this.Cancel); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(547, 228); - this.Name = "PlayMovie"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Play Movie"; - this.Load += new System.EventHandler(this.PlayMovie_Load); - this.groupBox1.ResumeLayout(false); - this.contextMenuStrip1.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button Cancel; - private System.Windows.Forms.Button OK; - private System.Windows.Forms.Button BrowseMovies; - private BizHawk.Client.EmuHawk.VirtualListView MovieView; - private System.Windows.Forms.ColumnHeader columnHeader1; - private System.Windows.Forms.ColumnHeader columnHeader2; - private System.Windows.Forms.ColumnHeader columnHeader3; - private System.Windows.Forms.ColumnHeader columnHeader4; - private System.Windows.Forms.ListView DetailsView; - private System.Windows.Forms.ColumnHeader columnHeader5; - private System.Windows.Forms.ColumnHeader columnHeader6; - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.Button SubtitlesBtn; - private System.Windows.Forms.Button CommentsBtn; - private System.Windows.Forms.Label MovieCount; - private System.Windows.Forms.CheckBox ReadOnlyCheckBox; - private System.Windows.Forms.CheckBox IncludeSubDirectories; - private System.Windows.Forms.Button Scan; - private System.Windows.Forms.ToolTip toolTip1; - private System.Windows.Forms.CheckBox MatchHashCheckBox; - private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; - private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; - private System.Windows.Forms.CheckBox StopOnFrameCheckbox; - private BizHawk.Client.EmuHawk.WatchValueBox StopOnFrameTextBox; - private System.Windows.Forms.CheckBox LastFrameCheckbox; - private System.Windows.Forms.CheckBox TurboCheckbox; - } -} \ No newline at end of file diff --git a/BizHawk.Client.MultiHawk/movie/PlayMovie.cs b/BizHawk.Client.MultiHawk/movie/PlayMovie.cs deleted file mode 100644 index 279ce50ee4..0000000000 --- a/BizHawk.Client.MultiHawk/movie/PlayMovie.cs +++ /dev/null @@ -1,673 +0,0 @@ -using System; -using System.Threading.Tasks; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Text; -using System.Windows.Forms; - -using BizHawk.Client.Common; -using BizHawk.Common; -using BizHawk.Client.EmuHawk; -namespace BizHawk.Client.MultiHawk -{ - public partial class PlayMovie : Form - { - private readonly PlatformFrameRates PlatformFrameRates = new PlatformFrameRates(); - - private List _movieList = new List(); - private bool _sortReverse; - private string _sortedCol; - - private bool _sortDetailsReverse; - private string _sortedDetailsCol; - - public PlayMovie() - { - InitializeComponent(); - MovieView.QueryItemText += MovieView_QueryItemText; - MovieView.VirtualMode = true; - _sortReverse = false; - _sortedCol = ""; - - _sortDetailsReverse = false; - _sortedDetailsCol = ""; - } - - private void PlayMovie_Load(object sender, EventArgs e) - { - IncludeSubDirectories.Checked = Global.Config.PlayMovie_IncludeSubdir; - MatchHashCheckBox.Checked = Global.Config.PlayMovie_MatchHash; - ScanFiles(); - PreHighlightMovie(); - TurboCheckbox.Checked = Global.Config.TurboSeek; - } - - private void MovieView_QueryItemText(int index, int column, out string text) - { - text = ""; - if (column == 0) // File - { - text = Path.GetFileName(_movieList[index].Filename); - } - - if (column == 1) // System - { - text = _movieList[index].SystemID; - } - - if (column == 2) // Game - { - text = _movieList[index].GameName; - } - - if (column == 3) // Time - { - text = PlatformFrameRates.MovieTime(_movieList[index]).ToString(@"hh\:mm\:ss\.fff"); - } - } - - private void Run() - { - var indices = MovieView.SelectedIndices; - if (indices.Count > 0) // Import file if necessary - { - GlobalWin.MainForm.StartNewMovie(_movieList[MovieView.SelectedIndices[0]], false); - } - } - - private int? AddMovieToList(string filename, bool force) - { - using (var file = new HawkFile(filename)) - { - if (!file.Exists) - { - return null; - } - - var index = IsDuplicateOf(filename); - if (!index.HasValue) - { - //System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start(); - var movie = PreLoadMovieFile(file, force); - if (movie == null) - { - return null; - } - //watch.Stop(); Console.WriteLine("[{0}] {1}",watch.ElapsedMilliseconds,Path.GetFileName(filename)); - - lock (_movieList) - { - _movieList.Add(movie); - index = _movieList.Count - 1; - } - - _sortReverse = false; - _sortedCol = ""; - } - - return index; - } - - } - - private int? IsDuplicateOf(string filename) - { - for (var i = 0; i < _movieList.Count; i++) - { - if (_movieList[i].Filename == filename) - { - return i; - } - } - - return null; - } - - private IMovie PreLoadMovieFile(HawkFile hf, bool force) - { - var movie = MovieService.Get(hf.CanonicalFullPath); - - try - { - movie.PreLoadHeaderAndLength(hf); - - // Don't do this from browse - if (movie.Hash == Global.Game.Hash || - Global.Config.PlayMovie_MatchHash == false || force) - { - return movie; - } - } - catch (Exception ex) - { - // TODO: inform the user that a movie failed to parse in some way - Console.WriteLine(ex.Message); - } - - return null; - } - - private void UpdateList() - { - MovieView.Refresh(); - MovieCount.Text = _movieList.Count + " movie" - + (_movieList.Count != 1 ? "s" : ""); - } - - private void PreHighlightMovie() - { - if (Global.Game == null) - { - return; - } - - var indices = new List(); - - // Pull out matching names - for (var i = 0; i < _movieList.Count; i++) - { - if (PathManager.FilesystemSafeName(Global.Game) == _movieList[i].GameName) - { - indices.Add(i); - } - } - - if (indices.Count == 0) - { - return; - } - - if (indices.Count == 1) - { - HighlightMovie(indices[0]); - return; - } - - // Prefer tas files - var tas = new List(); - for (var i = 0; i < indices.Count; i++) - { - foreach (var ext in MovieService.MovieExtensions) - { - if (Path.GetExtension(_movieList[indices[i]].Filename).ToUpper() == "." + ext) - { - tas.Add(i); - } - } - } - - if (tas.Count == 1) - { - HighlightMovie(tas[0]); - return; - } - - if (tas.Count > 1) - { - indices = new List(tas); - } - - // Final tie breaker - Last used file - var file = new FileInfo(_movieList[indices[0]].Filename); - var time = file.LastAccessTime; - var mostRecent = indices.First(); - for (var i = 1; i < indices.Count; i++) - { - file = new FileInfo(_movieList[indices[0]].Filename); - if (file.LastAccessTime > time) - { - time = file.LastAccessTime; - mostRecent = indices[i]; - } - } - - HighlightMovie(mostRecent); - return; - } - - private void HighlightMovie(int index) - { - MovieView.SelectedIndices.Clear(); - MovieView.setSelection(index); - MovieView.SelectItem(index, true); - } - - private void ScanFiles() - { - _movieList.Clear(); - MovieView.ItemCount = 0; - MovieView.Update(); - - var directory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null); - if (!Directory.Exists(directory)) - { - Directory.CreateDirectory(directory); - } - - var dpTodo = new Queue(); - var fpTodo = new List(); - dpTodo.Enqueue(directory); - Dictionary ordinals = new Dictionary(); - - while (dpTodo.Count > 0) - { - string dp = dpTodo.Dequeue(); - - //enqueue subdirectories if appropriate - if (Global.Config.PlayMovie_IncludeSubdir) - foreach(var subdir in Directory.GetDirectories(dp)) - dpTodo.Enqueue(subdir); - - //add movies - fpTodo.AddRange(Directory.GetFiles(dp, "*." + MovieService.DefaultExtension)); - fpTodo.AddRange(Directory.GetFiles(dp, "*." + TasMovie.Extension)); - } - - //in parallel, scan each movie - Parallel.For(0, fpTodo.Count, (i) => - //for(int i=0;i ordinals[a.Filename].CompareTo(ordinals[b.Filename])); - - RefreshMovieList(); - } - - #region Events - - #region Movie List - - void RefreshMovieList() - { - MovieView.ItemCount = _movieList.Count; - UpdateList(); - } - - private void MovieView_DragEnter(object sender, DragEventArgs e) - { - e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None; - } - - private void MovieView_DragDrop(object sender, DragEventArgs e) - { - var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop); - - foreach (var path in filePaths.Where(path => MovieService.MovieExtensions.Contains(Path.GetExtension(path).Replace(".", "")))) - { - AddMovieToList(path, force: true); - } - - RefreshMovieList(); - } - - private void MovieView_KeyDown(object sender, KeyEventArgs e) - { - if (e.Control && e.KeyCode == Keys.C) - { - var indexes = MovieView.SelectedIndices; - if (indexes.Count > 0) - { - var copyStr = new StringBuilder(); - foreach (int index in indexes) - { - copyStr - .Append(_movieList[index].Filename).Append('\t') - .Append(_movieList[index].SystemID).Append('\t') - .Append(_movieList[index].GameName).Append('\t') - .Append(PlatformFrameRates.MovieTime(_movieList[index]).ToString(@"hh\:mm\:ss\.fff")) - .AppendLine(); - } - Clipboard.SetDataObject(copyStr.ToString()); - } - } - } - - private void MovieView_DoubleClick(object sender, EventArgs e) - { - Run(); - Close(); - } - - private void MovieView_ColumnClick(object sender, ColumnClickEventArgs e) - { - var columnName = MovieView.Columns[e.Column].Text; - switch (columnName) - { - case "File": - default: - _movieList = _movieList.OrderBy(x => Path.GetFileName(x.Filename)) - .ThenBy(x => x.SystemID) - .ThenBy(x => x.GameName) - .ThenBy(x => x.FrameCount) - .ToList(); - break; - case "SysID": - _movieList = _movieList.OrderBy(x => x.SystemID) - .ThenBy(x => Path.GetFileName(x.Filename)) - .ThenBy(x => x.GameName) - .ThenBy(x => x.FrameCount) - .ToList(); - break; - case "Game": - _movieList = _movieList.OrderBy(x => x.GameName) - .ThenBy(x => Path.GetFileName(x.Filename)) - .ThenBy(x => x.SystemID) - .ThenBy(x => x.FrameCount) - .ToList(); - break; - case "Length (est.)": - _movieList = _movieList.OrderBy(x => x.FrameCount) - .ThenBy(x => Path.GetFileName(x.Filename)) - .ThenBy(x => x.SystemID) - .ThenBy(x => x.GameName) - .ToList(); - break; - } - if (_sortedCol == columnName && _sortReverse) - { - _movieList.Reverse(); - _sortReverse = false; - } - else - { - _sortReverse = true; - _sortedCol = columnName; - } - MovieView.Refresh(); - } - - private void MovieView_SelectedIndexChanged(object sender, EventArgs e) - { - toolTip1.SetToolTip(DetailsView, ""); - DetailsView.Items.Clear(); - if (MovieView.SelectedIndices.Count < 1) - { - OK.Enabled = false; - return; - } - - OK.Enabled = true; - - var firstIndex = MovieView.SelectedIndices[0]; - MovieView.ensureVisible(firstIndex); - - foreach (var kvp in _movieList[firstIndex].HeaderEntries) - { - var item = new ListViewItem(kvp.Key); - item.SubItems.Add(kvp.Value); - - bool add = true; - - switch (kvp.Key) - { - case HeaderKeys.SHA1: - if (kvp.Value != Global.Game.Hash) - { - item.BackColor = Color.Pink; - toolTip1.SetToolTip(DetailsView, "Current SHA1: " + Global.Game.Hash); - } - break; - // TODO - //case HeaderKeys.EMULATIONVERSION: - // if (kvp.Value != VersionInfo.GetEmuVersion()) - // { - // item.BackColor = Color.Yellow; - // } - // break; - case HeaderKeys.PLATFORM: - if (kvp.Value != Global.Game.System) - { - item.BackColor = Color.Pink; - } - break; - } - - if(add) - DetailsView.Items.Add(item); - } - - var FpsItem = new ListViewItem("Fps"); - FpsItem.SubItems.Add($"{Fps(_movieList[firstIndex]):0.#######}"); - DetailsView.Items.Add(FpsItem); - - var FramesItem = new ListViewItem("Frames"); - FramesItem.SubItems.Add(_movieList[firstIndex].FrameCount.ToString()); - DetailsView.Items.Add(FramesItem); - CommentsBtn.Enabled = _movieList[firstIndex].Comments.Any(); - SubtitlesBtn.Enabled = _movieList[firstIndex].Subtitles.Any(); - } - - public double Fps(IMovie movie) - { - var system = movie.HeaderEntries[HeaderKeys.PLATFORM]; - var pal = movie.HeaderEntries.ContainsKey(HeaderKeys.PAL) && - movie.HeaderEntries[HeaderKeys.PAL] == "1"; - - return new PlatformFrameRates()[system, pal]; - - } - - private void EditMenuItem_Click(object sender, EventArgs e) - { - foreach (var movie in MovieView.SelectedIndices.Cast() - .Select(index => _movieList[index])) - { - System.Diagnostics.Process.Start(movie.Filename); - } - } - - #endregion - - #region Details - - private void DetailsView_ColumnClick(object sender, ColumnClickEventArgs e) - { - var detailsList = new List(); - for (var i = 0; i < DetailsView.Items.Count; i++) - { - detailsList.Add(new MovieDetails - { - Keys = DetailsView.Items[i].Text, - Values = DetailsView.Items[i].SubItems[1].Text, - BackgroundColor = DetailsView.Items[i].BackColor - }); - } - - var columnName = DetailsView.Columns[e.Column].Text; - if (_sortedDetailsCol != columnName) - { - _sortDetailsReverse = false; - } - - switch (columnName) - { - // Header, Value - case "Header": - if (_sortDetailsReverse) - { - detailsList = detailsList - .OrderByDescending(x => x.Keys) - .ThenBy(x => x.Values).ToList(); - } - else - { - detailsList = detailsList - .OrderBy(x => x.Keys) - .ThenBy(x => x.Values).ToList(); - } - - break; - case "Value": - if (_sortDetailsReverse) - { - detailsList = detailsList - .OrderByDescending(x => x.Values) - .ThenBy(x => x.Keys).ToList(); - } - else - { - detailsList = detailsList - .OrderBy(x => x.Values) - .ThenBy(x => x.Keys).ToList(); - } - - break; - } - - DetailsView.Items.Clear(); - foreach (var detail in detailsList) - { - var item = new ListViewItem { Text = detail.Keys, BackColor = detail.BackgroundColor }; - item.SubItems.Add(detail.Values); - DetailsView.Items.Add(item); - } - - _sortedDetailsCol = columnName; - _sortDetailsReverse = !_sortDetailsReverse; - } - - private void CommentsBtn_Click(object sender, EventArgs e) - { - var indices = MovieView.SelectedIndices; - if (indices.Count > 0) - { - var form = new EditCommentsForm(); - form.GetMovie(_movieList[MovieView.SelectedIndices[0]]); - form.Show(); - } - } - - private void SubtitlesBtn_Click(object sender, EventArgs e) - { - var indices = MovieView.SelectedIndices; - if (indices.Count > 0) - { - var s = new EditSubtitlesForm { ReadOnly = true }; - s.GetMovie(_movieList[MovieView.SelectedIndices[0]]); - s.Show(); - } - } - - #endregion - - #region Misc Widgets - - private void BrowseMovies_Click(object sender, EventArgs e) - { - var ofd = new OpenFileDialog - { - Filter = "Movie Files (*." + MovieService.DefaultExtension + ")|*." + MovieService.DefaultExtension + - "|TAS project Files (*." + TasMovie.Extension + ")|*." + TasMovie.Extension + - "|All Files|*.*", - InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null) - }; - - var result = ofd.ShowDialog(); - if (result == DialogResult.OK) - { - var file = new FileInfo(ofd.FileName); - if (!file.Exists) - { - return; - } - - int? index = AddMovieToList(ofd.FileName, true); - RefreshMovieList(); - if (index.HasValue) - { - MovieView.SelectedIndices.Clear(); - MovieView.setSelection(index.Value); - MovieView.SelectItem(index.Value, true); - } - } - } - - private void Scan_Click(object sender, EventArgs e) - { - ScanFiles(); - PreHighlightMovie(); - } - - private void IncludeSubDirectories_CheckedChanged(object sender, EventArgs e) - { - Global.Config.PlayMovie_IncludeSubdir = IncludeSubDirectories.Checked; - ScanFiles(); - PreHighlightMovie(); - } - - private void MatchHashCheckBox_CheckedChanged(object sender, EventArgs e) - { - Global.Config.PlayMovie_MatchHash = MatchHashCheckBox.Checked; - ScanFiles(); - PreHighlightMovie(); - } - - private void Ok_Click(object sender, EventArgs e) - { - Global.Config.TurboSeek = TurboCheckbox.Checked; - Run(); - Global.MovieSession.ReadOnly = ReadOnlyCheckBox.Checked; - - if (StopOnFrameCheckbox.Checked && - (StopOnFrameTextBox.ToRawInt().HasValue || LastFrameCheckbox.Checked)) - { - if (LastFrameCheckbox.Checked) - { - // TODO - //GlobalWin.MainForm.PauseOnFrame = Global.MovieSession.Movie.InputLogLength; - } - else - { - //GlobalWin.MainForm.PauseOnFrame = StopOnFrameTextBox.ToRawInt(); - } - } - - Close(); - } - - private void Cancel_Click(object sender, EventArgs e) - { - Close(); - } - - #endregion - - private bool _programmaticallyChangingStopFrameCheckbox = false; - private void StopOnFrameCheckbox_CheckedChanged(object sender, EventArgs e) - { - if (!_programmaticallyChangingStopFrameCheckbox) - { - StopOnFrameTextBox.Focus(); - } - } - - private void StopOnFrameTextBox_TextChanged_1(object sender, EventArgs e) - { - _programmaticallyChangingStopFrameCheckbox = true; - StopOnFrameCheckbox.Checked = !string.IsNullOrWhiteSpace(StopOnFrameTextBox.Text); - _programmaticallyChangingStopFrameCheckbox = false; - } - - private void LastFrameCheckbox_CheckedChanged(object sender, EventArgs e) - { - if (LastFrameCheckbox.Checked == true) - { - _programmaticallyChangingStopFrameCheckbox = true; - StopOnFrameCheckbox.Checked = true; - _programmaticallyChangingStopFrameCheckbox = false; - } - - StopOnFrameTextBox.Enabled = !LastFrameCheckbox.Checked; - } - - #endregion - } -} diff --git a/BizHawk.Client.MultiHawk/movie/PlayMovie.resx b/BizHawk.Client.MultiHawk/movie/PlayMovie.resx deleted file mode 100644 index b726d762b7..0000000000 --- a/BizHawk.Client.MultiHawk/movie/PlayMovie.resx +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 114, 17 - - - - - AAABAAEAEBAAAAAAAABoBQAAFgAAACgAAAAQAAAAIAAAAAEACAAAAAAAQAEAAAAAAAAAAAAAAAAAAAAA - AAAAAAAA////AP64aABQUFAAwNjwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAMDAAMDAwAAAAAAAAAAAAMCAgMDAwMDAwAAAAMDAAADAgICAwMDAwMDAwMCAgMAAAMCAwMD - AwMDAwMDAgIDAAMEBAQDAgMDAwMDAwICAgMDBAQEAwICAwQDAwQDAgIDAAMDAwICAgMCAgIDAwMDAAAA - AwICAgMCAgIDAgMAAAAAAAAAAwMEBAQEBAQCAwAAAAAAAwMEBAQDAwMDAwMAAAAAAwQEAwMEBAMEBAQC - AwAAAAMEBAMDBAMEBAQEAgMAAAAAAwMDBAQDBAMDAwIDAAAAAAMCAgICAgICAgMEBAMAAAAAAwICAgIC - AwMEBAQDAAAAAAADAwMDAwAAAwMDAJH/AAAAcwAAAAEAAIABAAAAAAAAAAAAAIABAADABwAA8AMAAOAD - AADAAQAAwAEAAOABAADgAAAA8AAAAPgxAAA= - - - \ No newline at end of file diff --git a/BizHawk.Client.MultiHawk/movie/RecordMovie.Designer.cs b/BizHawk.Client.MultiHawk/movie/RecordMovie.Designer.cs deleted file mode 100644 index 252508deab..0000000000 --- a/BizHawk.Client.MultiHawk/movie/RecordMovie.Designer.cs +++ /dev/null @@ -1,210 +0,0 @@ -namespace BizHawk.Client.MultiHawk -{ - partial class RecordMovie - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RecordMovie)); - this.Cancel = new System.Windows.Forms.Button(); - this.OK = new System.Windows.Forms.Button(); - this.BrowseBtn = new System.Windows.Forms.Button(); - this.RecordBox = new System.Windows.Forms.TextBox(); - this.StartFromCombo = new System.Windows.Forms.ComboBox(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.DefaultAuthorCheckBox = new System.Windows.Forms.CheckBox(); - this.AuthorBox = new System.Windows.Forms.TextBox(); - this.label3 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.groupBox1.SuspendLayout(); - this.SuspendLayout(); - // - // Cancel - // - this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.Cancel.Location = new System.Drawing.Point(391, 139); - this.Cancel.Name = "Cancel"; - this.Cancel.Size = new System.Drawing.Size(75, 23); - this.Cancel.TabIndex = 1; - this.Cancel.Text = "&Cancel"; - this.Cancel.UseVisualStyleBackColor = true; - this.Cancel.Click += new System.EventHandler(this.Cancel_Click); - // - // OK - // - this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.OK.Location = new System.Drawing.Point(310, 139); - this.OK.Name = "OK"; - this.OK.Size = new System.Drawing.Size(75, 23); - this.OK.TabIndex = 0; - this.OK.Text = "&OK"; - this.OK.UseVisualStyleBackColor = true; - this.OK.Click += new System.EventHandler(this.Ok_Click); - // - // BrowseBtn - // - this.BrowseBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.BrowseBtn.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.OpenFile; - this.BrowseBtn.Location = new System.Drawing.Point(423, 13); - this.BrowseBtn.Name = "BrowseBtn"; - this.BrowseBtn.Size = new System.Drawing.Size(25, 23); - this.BrowseBtn.TabIndex = 1; - this.BrowseBtn.UseVisualStyleBackColor = true; - this.BrowseBtn.Click += new System.EventHandler(this.BrowseBtn_Click); - // - // RecordBox - // - this.RecordBox.AllowDrop = true; - this.RecordBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.RecordBox.Location = new System.Drawing.Point(83, 13); - this.RecordBox.Name = "RecordBox"; - this.RecordBox.Size = new System.Drawing.Size(334, 20); - this.RecordBox.TabIndex = 0; - this.RecordBox.DragDrop += new System.Windows.Forms.DragEventHandler(this.RecordBox_DragDrop); - this.RecordBox.DragEnter += new System.Windows.Forms.DragEventHandler(this.RecordBox_DragEnter); - // - // StartFromCombo - // - this.StartFromCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.StartFromCombo.Enabled = false; - this.StartFromCombo.FormattingEnabled = true; - this.StartFromCombo.Items.AddRange(new object[] { - "Power-On"}); - this.StartFromCombo.Location = new System.Drawing.Point(83, 65); - this.StartFromCombo.MaxDropDownItems = 32; - this.StartFromCombo.Name = "StartFromCombo"; - this.StartFromCombo.Size = new System.Drawing.Size(152, 21); - this.StartFromCombo.TabIndex = 3; - // - // groupBox1 - // - this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBox1.Controls.Add(this.DefaultAuthorCheckBox); - this.groupBox1.Controls.Add(this.AuthorBox); - this.groupBox1.Controls.Add(this.StartFromCombo); - this.groupBox1.Controls.Add(this.BrowseBtn); - this.groupBox1.Controls.Add(this.label3); - this.groupBox1.Controls.Add(this.label2); - this.groupBox1.Controls.Add(this.label1); - this.groupBox1.Controls.Add(this.RecordBox); - this.groupBox1.Location = new System.Drawing.Point(12, 12); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(454, 112); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - // - // DefaultAuthorCheckBox - // - this.DefaultAuthorCheckBox.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.DefaultAuthorCheckBox.AutoSize = true; - this.DefaultAuthorCheckBox.Location = new System.Drawing.Point(327, 64); - this.DefaultAuthorCheckBox.Name = "DefaultAuthorCheckBox"; - this.DefaultAuthorCheckBox.Size = new System.Drawing.Size(121, 17); - this.DefaultAuthorCheckBox.TabIndex = 6; - this.DefaultAuthorCheckBox.Text = "Make default author"; - this.DefaultAuthorCheckBox.UseVisualStyleBackColor = true; - // - // AuthorBox - // - this.AuthorBox.AllowDrop = true; - this.AuthorBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.AuthorBox.Location = new System.Drawing.Point(83, 39); - this.AuthorBox.Name = "AuthorBox"; - this.AuthorBox.Size = new System.Drawing.Size(365, 20); - this.AuthorBox.TabIndex = 2; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(36, 41); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(41, 13); - this.label3.TabIndex = 2; - this.label3.Text = "Author:"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(6, 68); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(71, 13); - this.label2.TabIndex = 5; - this.label2.Text = "Record From:"; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(51, 16); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(26, 13); - this.label1.TabIndex = 4; - this.label1.Text = "File:"; - // - // RecordMovie - // - this.AcceptButton = this.OK; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.Cancel; - this.ClientSize = new System.Drawing.Size(478, 163); - this.Controls.Add(this.groupBox1); - this.Controls.Add(this.OK); - this.Controls.Add(this.Cancel); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MaximumSize = new System.Drawing.Size(1440, 201); - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(425, 201); - this.Name = "RecordMovie"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Record Movie"; - this.Load += new System.EventHandler(this.RecordMovie_Load); - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Button Cancel; - private System.Windows.Forms.Button OK; - private System.Windows.Forms.Button BrowseBtn; - private System.Windows.Forms.TextBox RecordBox; - private System.Windows.Forms.ComboBox StartFromCombo; - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox AuthorBox; - private System.Windows.Forms.CheckBox DefaultAuthorCheckBox; - } -} \ No newline at end of file diff --git a/BizHawk.Client.MultiHawk/movie/RecordMovie.cs b/BizHawk.Client.MultiHawk/movie/RecordMovie.cs deleted file mode 100644 index 4c5cdb4e66..0000000000 --- a/BizHawk.Client.MultiHawk/movie/RecordMovie.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.IO; -using System.Windows.Forms; -using System.Linq; - -using BizHawk.Common.ReflectionExtensions; -using BizHawk.Emulation.Common; -using BizHawk.Emulation.Common.IEmulatorExtensions; -using BizHawk.Client.Common; -using BizHawk.Client.Common.MovieConversionExtensions; - -namespace BizHawk.Client.MultiHawk -{ - public partial class RecordMovie : Form - { - private IEmulator Emulator; - - // TODO - Allow relative paths in record textbox - public RecordMovie(IEmulator core) - { - InitializeComponent(); - - Emulator = core; - - if (!Emulator.HasSavestates()) - { - StartFromCombo.Items.Remove( - StartFromCombo.Items - .OfType() - .First(i => i.ToString() - .ToLower() == "now")); - } - } - - private string MakePath() - { - var path = RecordBox.Text; - - if (!string.IsNullOrWhiteSpace(path)) - { - if (path.LastIndexOf(Path.DirectorySeparatorChar) == -1) - { - if (path[0] != Path.DirectorySeparatorChar) - { - path = path.Insert(0, Path.DirectorySeparatorChar.ToString()); - } - - path = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null) + path; - - if (!MovieService.MovieExtensions.Contains(Path.GetExtension(path))) - { - // If no valid movie extension, add movie extension - path += "." + MovieService.DefaultExtension; - } - } - } - - return path; - } - - private void Ok_Click(object sender, EventArgs e) - { - var path = MakePath(); - if (!string.IsNullOrWhiteSpace(path)) - { - var test = new FileInfo(path); - if (test.Exists) - { - var result = MessageBox.Show(path + " already exists, overwrite?", "Confirm overwrite", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); - if (result == DialogResult.Cancel) - { - return; - } - } - - var movieToRecord = MovieService.Get(path); - - var fileInfo = new FileInfo(path); - if (!fileInfo.Exists) - { - Directory.CreateDirectory(fileInfo.DirectoryName); - } - - //if (StartFromCombo.SelectedItem.ToString() == "Now" && Emulator.HasSavestates()) - //{ - // var core = Emulator.AsStatable(); - - // movieToRecord.StartsFromSavestate = true; - - // if (core.BinarySaveStatesPreferred) - // { - // movieToRecord.BinarySavestate = (byte[])core.SaveStateBinary().Clone(); - // } - // else - // { - // using (var sw = new StringWriter()) - // { - // core.SaveStateText(sw); - // movieToRecord.TextSavestate = sw.ToString(); - // } - // } - // // TODO: do we want to support optionally not saving this? - // if (true) - // { - // // hack: some IMovies eat the framebuffer, so don't bother with them - // movieToRecord.SavestateFramebuffer = new int[0]; - // if (movieToRecord.SavestateFramebuffer != null) - // { - - // movieToRecord.SavestateFramebuffer = (int[])Emulator.VideoProvider().GetVideoBuffer().Clone(); - // } - // } - //} - - movieToRecord.PopulateWithDefaultHeaderValues(AuthorBox.Text); - movieToRecord.Save(); - GlobalWin.MainForm.StartNewMovie(movieToRecord, true); - - Global.Config.UseDefaultAuthor = DefaultAuthorCheckBox.Checked; - if (DefaultAuthorCheckBox.Checked) - { - Global.Config.DefaultAuthor = AuthorBox.Text; - } - - Close(); - } - else - { - MessageBox.Show("Please select a movie to record", "File selection error", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - private void Cancel_Click(object sender, EventArgs e) - { - Close(); - } - - private void BrowseBtn_Click(object sender, EventArgs e) - { - var sfd = new SaveFileDialog - { - InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null), - DefaultExt = "." + Global.MovieSession.Movie.PreferredExtension, - FileName = RecordBox.Text, - OverwritePrompt = false, - Filter = "Movie Files (*." + Global.MovieSession.Movie.PreferredExtension + ")|*." + Global.MovieSession.Movie.PreferredExtension + "|All Files|*.*" - }; - - var result = sfd.ShowDialog(); - if (result == DialogResult.OK - && !string.IsNullOrWhiteSpace(sfd.FileName)) - { - RecordBox.Text = sfd.FileName; - } - } - - private void RecordMovie_Load(object sender, EventArgs e) - { - RecordBox.Text = PathManager.FilesystemSafeName(GlobalWin.MainForm.EmulatorWindows.First().Game); - StartFromCombo.SelectedIndex = 0; - DefaultAuthorCheckBox.Checked = Global.Config.UseDefaultAuthor; - if (Global.Config.UseDefaultAuthor) - { - AuthorBox.Text = Global.Config.DefaultAuthor; - } - } - - private void RecordBox_DragEnter(object sender, DragEventArgs e) - { - e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None; - } - - private void RecordBox_DragDrop(object sender, DragEventArgs e) - { - var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop); - RecordBox.Text = filePaths[0]; - } - } -} diff --git a/BizHawk.Client.MultiHawk/movie/RecordMovie.resx b/BizHawk.Client.MultiHawk/movie/RecordMovie.resx deleted file mode 100644 index fb80888459..0000000000 --- a/BizHawk.Client.MultiHawk/movie/RecordMovie.resx +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - AAABAAEAEBAAAAAAAABoBQAAFgAAACgAAAAQAAAAIAAAAAEACAAAAAAAQAEAAAAAAAAAAAAAAAAAAAAA - AAAAAAAA////AP64aABQUFAAwNjwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAMDAAMDAwAAAAAAAAAAAAMCAgMDAwMDAwAAAAMDAAADAgICAwMDAwMDAwMCAgMAAAMCAwMD - AwMDAwMDAgIDAAMEBAQDAgMDAwMDAwICAgMDBAQEAwICAwQDAwQDAgIDAAMDAwICAgMCAgIDAwMDAAAA - AwICAgMCAgIDAgMAAAAAAAAAAwMEBAQEBAQCAwAAAAAAAwMEBAQDAwMDAwMAAAAAAwQEAwMEBAMEBAQC - AwAAAAMEBAMDBAMEBAQEAgMAAAAAAwMDBAQDBAMDAwIDAAAAAAMCAgICAgICAgMEBAMAAAAAAwICAgIC - AwMEBAQDAAAAAAADAwMDAwAAAwMDAJH/AAAAcwAAAAEAAIABAAAAAAAAAAAAAIABAADABwAA8AMAAOAD - AADAAQAAwAEAAOABAADgAAAA8AAAAPgxAAA= - - - \ No newline at end of file diff --git a/BizHawk.Common/Extensions/ReflectionExtensions.cs b/BizHawk.Common/Extensions/ReflectionExtensions.cs index 505939d717..ec997a25c9 100644 --- a/BizHawk.Common/Extensions/ReflectionExtensions.cs +++ b/BizHawk.Common/Extensions/ReflectionExtensions.cs @@ -19,6 +19,12 @@ namespace BizHawk.Common.ReflectionExtensions .Where(p => p.GetCustomAttributes(attributeType, false).Length > 0); } + public static IEnumerable GetMethodsWithAttrib(this Type type, Type attributeType) + { + return type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic) + .Where(p => p.GetCustomAttributes(attributeType, false).Length > 0); + } + /// /// Gets the description attribute from an object /// diff --git a/BizHawk.sln b/BizHawk.sln index 53559fc6dc..64985e34d0 100644 --- a/BizHawk.sln +++ b/BizHawk.sln @@ -55,8 +55,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BizHawk.Bizware.BizwareGL.G EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BizHawk.Bizware.BizwareGL.SlimDX", "Bizware\BizHawk.Bizware.BizwareGL.SlimDX\BizHawk.Bizware.BizwareGL.SlimDX.csproj", "{E6B436B1-A3CD-4C9A-8F76-5D7154726884}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BizHawk.Client.MultiHawk", "BizHawk.Client.MultiHawk\BizHawk.Client.MultiHawk.csproj", "{B95649F5-A0AE-41EB-B62B-578A2AFF5E18}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BizHawk.Client.ApiHawk", "BizHawk.Client.ApiHawk\BizHawk.Client.ApiHawk.csproj", "{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}" EndProject Global @@ -117,10 +115,6 @@ Global {E6B436B1-A3CD-4C9A-8F76-5D7154726884}.Debug|Any CPU.Build.0 = Debug|Any CPU {E6B436B1-A3CD-4C9A-8F76-5D7154726884}.Release|Any CPU.ActiveCfg = Release|Any CPU {E6B436B1-A3CD-4C9A-8F76-5D7154726884}.Release|Any CPU.Build.0 = Release|Any CPU - {B95649F5-A0AE-41EB-B62B-578A2AFF5E18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B95649F5-A0AE-41EB-B62B-578A2AFF5E18}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B95649F5-A0AE-41EB-B62B-578A2AFF5E18}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B95649F5-A0AE-41EB-B62B-578A2AFF5E18}.Release|Any CPU.Build.0 = Release|Any CPU {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|Any CPU.Build.0 = Debug|Any CPU {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -141,7 +135,6 @@ Global {2D2890A8-C338-4439-AD8B-CB9EE85A94F9} = {B51F1139-3D2C-41BE-A762-EF1F9B41EACA} {337CA23E-65E7-44E1-9411-97EE08BB8116} = {0540A9A6-977E-466D-8BD3-1D8590BD5282} {E6B436B1-A3CD-4C9A-8F76-5D7154726884} = {0540A9A6-977E-466D-8BD3-1D8590BD5282} - {B95649F5-A0AE-41EB-B62B-578A2AFF5E18} = {B51F1139-3D2C-41BE-A762-EF1F9B41EACA} {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA} = {B51F1139-3D2C-41BE-A762-EF1F9B41EACA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution