From 53c7f4e5be8af834ec7e9e46de78608029c024ea Mon Sep 17 00:00:00 2001 From: feos Date: Sat, 7 May 2016 15:04:42 +0300 Subject: [PATCH] tastudio: ignore inputroll hotkeys and numeric branch hotkeys during float editing mode. --- .../CustomControls/InputRoll.cs | 138 +++++++++--------- .../tools/TAStudio/BookmarksBranchesBox.cs | 9 ++ .../tools/TAStudio/TAStudio.ListView.cs | 23 ++- 3 files changed, 98 insertions(+), 72 deletions(-) diff --git a/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs b/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs index 12f8744bb0..10b73aac6d 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs @@ -45,6 +45,7 @@ namespace BizHawk.Client.EmuHawk public bool denoteMarkersWithBGColor { get; set; } public bool allowRightClickSelecton { get; set; } public bool letKeysModifySelection { get; set; } + public bool suspendHotkeys { get; set; } private IntPtr RotatedFont; private readonly IntPtr NormalFont; @@ -1263,93 +1264,96 @@ namespace BizHawk.Client.EmuHawk protected override void OnKeyDown(KeyEventArgs e) { - if (e.Control && !e.Alt && e.Shift && e.KeyCode == Keys.F) // Ctrl+Shift+F + if (!suspendHotkeys) { - HorizontalOrientation ^= true; - } - else if (!e.Control && !e.Alt && !e.Shift && e.KeyCode == Keys.PageUp) // Page Up - { - if (FirstVisibleRow > 0) + if (e.Control && !e.Alt && e.Shift && e.KeyCode == Keys.F) // Ctrl+Shift+F { - LastVisibleRow = FirstVisibleRow; - Refresh(); + HorizontalOrientation ^= true; } - } - else if (!e.Control && !e.Alt && !e.Shift && e.KeyCode == Keys.PageDown) // Page Down - { - var totalRows = LastVisibleRow - FirstVisibleRow; - if (totalRows <= RowCount) + else if (!e.Control && !e.Alt && !e.Shift && e.KeyCode == Keys.PageUp) // Page Up { - var final = LastVisibleRow + totalRows; - if (final > RowCount) + if (FirstVisibleRow > 0) { - final = RowCount; + LastVisibleRow = FirstVisibleRow; + Refresh(); } + } + else if (!e.Control && !e.Alt && !e.Shift && e.KeyCode == Keys.PageDown) // Page Down + { + var totalRows = LastVisibleRow - FirstVisibleRow; + if (totalRows <= RowCount) + { + var final = LastVisibleRow + totalRows; + if (final > RowCount) + { + final = RowCount; + } - LastVisibleRow = final; - Refresh(); - } - } - else if (!e.Control && !e.Alt && !e.Shift && e.KeyCode == Keys.Home) // Home - { - FirstVisibleRow = 0; - Refresh(); - } - else if (!e.Control && !e.Alt && !e.Shift && e.KeyCode == Keys.End) // End - { - LastVisibleRow = RowCount; - Refresh(); - } - else if (e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.Up) // Ctrl + Up - { - if (SelectedRows.Any() && letKeysModifySelection) - { - foreach (var row in SelectedRows.ToList()) - { - SelectRow(row - 1, true); - SelectRow(row, false); + LastVisibleRow = final; + Refresh(); } } - } - else if (e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.Down) // Ctrl + Down - { - if (SelectedRows.Any() && letKeysModifySelection) + else if (!e.Control && !e.Alt && !e.Shift && e.KeyCode == Keys.Home) // Home { - foreach (var row in SelectedRows.Reverse().ToList()) + FirstVisibleRow = 0; + Refresh(); + } + else if (!e.Control && !e.Alt && !e.Shift && e.KeyCode == Keys.End) // End + { + LastVisibleRow = RowCount; + Refresh(); + } + else if (e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.Up) // Ctrl + Up + { + if (SelectedRows.Any() && letKeysModifySelection) { - SelectRow(row + 1, true); - SelectRow(row, false); + foreach (var row in SelectedRows.ToList()) + { + SelectRow(row - 1, true); + SelectRow(row, false); + } } } - } - else if (!e.Control && e.Shift && !e.Alt && e.KeyCode == Keys.Up) // Shift + Up - { - if (SelectedRows.Any() && letKeysModifySelection) + else if (e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.Down) // Ctrl + Down { - SelectRow(SelectedRows.First() - 1, true); + if (SelectedRows.Any() && letKeysModifySelection) + { + foreach (var row in SelectedRows.Reverse().ToList()) + { + SelectRow(row + 1, true); + SelectRow(row, false); + } + } } - } - else if (!e.Control && e.Shift && !e.Alt && e.KeyCode == Keys.Down) // Shift + Down - { - if (SelectedRows.Any() && letKeysModifySelection) + else if (!e.Control && e.Shift && !e.Alt && e.KeyCode == Keys.Up) // Shift + Up { - SelectRow(SelectedRows.Last() + 1, true); + if (SelectedRows.Any() && letKeysModifySelection) + { + SelectRow(SelectedRows.First() - 1, true); + } } - } - else if (!e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.Up) // Up - { - if (FirstVisibleRow > 0) + else if (!e.Control && e.Shift && !e.Alt && e.KeyCode == Keys.Down) // Shift + Down { - FirstVisibleRow--; - Refresh(); + if (SelectedRows.Any() && letKeysModifySelection) + { + SelectRow(SelectedRows.Last() + 1, true); + } } - } - else if (!e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.Down) // Down - { - if (FirstVisibleRow < RowCount - 1) + else if (!e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.Up) // Up { - FirstVisibleRow++; - Refresh(); + if (FirstVisibleRow > 0) + { + FirstVisibleRow--; + Refresh(); + } + } + else if (!e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.Down) // Down + { + if (FirstVisibleRow < RowCount - 1) + { + FirstVisibleRow++; + Refresh(); + } } } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs index c209b1a790..19a7aa7a27 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs @@ -276,6 +276,9 @@ namespace BizHawk.Client.EmuHawk public void LoadBranchExternal(int slot = -1) { + if (Tastudio.FloatEditingMode) + return; + if (slot != -1) { if (GetBranch(slot) != null) @@ -293,6 +296,9 @@ namespace BizHawk.Client.EmuHawk public void UpdateBranchExternal(int slot = -1) { + if (Tastudio.FloatEditingMode) + return; + if (slot != -1) { if (GetBranch(slot) != null) @@ -315,6 +321,9 @@ namespace BizHawk.Client.EmuHawk public void SelectBranchExternal(int slot) { + if (Tastudio.FloatEditingMode) + return; + if (GetBranch(slot) != null) { BranchView.SelectRow(slot, true); diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index 7c5236b0eb..b182669ae4 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -25,6 +25,14 @@ namespace BizHawk.Client.EmuHawk // SuuperW: For editing analog input private string _floatEditColumn = string.Empty; private int _floatEditRow = -1; + private int floatEditRow + { + set + { + _floatEditRow = value; + TasView.suspendHotkeys = FloatEditingMode; + } + } private string _floatTypedValue; private int _floatEditYPos = -1; // Right-click dragging @@ -86,6 +94,11 @@ namespace BizHawk.Client.EmuHawk _seekBackgroundWorker.CancelAsync(); } + public bool FloatEditingMode + { + get { return _floatEditRow != -1; } + } + // public static Color CurrentFrame_FrameCol = Color.FromArgb(0xCFEDFC); Why? public static Color CurrentFrame_InputLog = Color.FromArgb(0xB5E7F7); @@ -400,7 +413,7 @@ namespace BizHawk.Client.EmuHawk { if (_floatEditColumn != buttonName || _floatEditRow != frame) { - _floatEditRow = -1; + floatEditRow = -1; RefreshTasView(); } else @@ -486,12 +499,12 @@ namespace BizHawk.Client.EmuHawk else // Double-click enters float editing mode { if (_floatEditColumn == buttonName && _floatEditRow == frame) - _floatEditRow = -1; + floatEditRow = -1; else { CurrentTasMovie.ChangeLog.BeginNewBatch("Float Edit: " + frame); _floatEditColumn = buttonName; - _floatEditRow = frame; + floatEditRow = frame; _floatTypedValue = ""; _floatEditYPos = e.Y; _triggerAutoRestore = true; @@ -559,7 +572,7 @@ namespace BizHawk.Client.EmuHawk // Exit float editing if value was changed with cursor if (_floatEditRow != -1 && _floatPaintState != CurrentTasMovie.GetFloatState(_floatEditRow, _floatEditColumn)) { - _floatEditRow = -1; + floatEditRow = -1; RefreshDialog(); } _floatPaintState = 0; @@ -937,7 +950,7 @@ namespace BizHawk.Client.EmuHawk _floatEditYPos = -1; CurrentTasMovie.SetFloatState(_floatEditRow, _floatEditColumn, _floatPaintState); } - _floatEditRow = -1; + floatEditRow = -1; } else {