Add setting to control what happens when double-clicking RAM watch (squashed PR #3802)

* Make RamWatch double click action configurable
* Make RamWatch Enter press share double-click behavior
* Make RamWatch double-click action default to poke
* Fix code style
* Reduce total diff size from extracting method
* Make sub-menu text more specific
This commit is contained in:
kalimag 2023-10-15 06:43:10 +02:00 committed by GitHub
parent b5ebee7cd5
commit f3796756bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 66 additions and 3 deletions

View File

@ -107,6 +107,9 @@ namespace BizHawk.Client.EmuHawk
this.OriginalMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.WatchesOnScreenMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.WatchListView = new InputRoll();
this.DoubleClickActionSubMenu = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.DoubleClickToEditMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.DoubleClickToPokeMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.ListViewContextMenu.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.toolStrip1.SuspendLayout();
@ -600,7 +603,8 @@ namespace BizHawk.Client.EmuHawk
//
this.OptionsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.DefinePreviousValueSubMenu,
this.WatchesOnScreenMenuItem});
this.WatchesOnScreenMenuItem,
this.DoubleClickActionSubMenu});
this.OptionsSubMenu.Text = "&Settings";
this.OptionsSubMenu.DropDownOpened += new System.EventHandler(this.SettingsSubMenu_DropDownOpened);
//
@ -659,6 +663,24 @@ namespace BizHawk.Client.EmuHawk
this.WatchListView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.WatchListView_KeyDown);
this.WatchListView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.WatchListView_MouseDoubleClick);
//
// DoubleClickActionSubMenu
//
this.DoubleClickActionSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.DoubleClickToEditMenuItem,
this.DoubleClickToPokeMenuItem});
this.DoubleClickActionSubMenu.Text = "On Double-Clicking a Watch";
this.DoubleClickActionSubMenu.DropDownOpening += new System.EventHandler(this.DoubleClickActionSubMenu_DropDownOpening);
//
// DoubleClickToEditMenuItem
//
this.DoubleClickToEditMenuItem.Text = "Edit Watch";
this.DoubleClickToEditMenuItem.Click += new System.EventHandler(this.DoubleClickToEditMenuItem_Click);
//
// DoubleClickToPokeMenuItem
//
this.DoubleClickToPokeMenuItem.Text = "Poke Address";
this.DoubleClickToPokeMenuItem.Click += new System.EventHandler(this.DoubleClickToPokeMenuItem_Click);
//
// RamWatch
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -765,5 +787,8 @@ namespace BizHawk.Client.EmuHawk
private BizHawk.WinForms.Controls.ToolStripMenuItemEx MoveBottomMenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx MoveTopContextMenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx MoveBottomContextMenuItem;
private ToolStripMenuItemEx DoubleClickActionSubMenu;
private ToolStripMenuItemEx DoubleClickToEditMenuItem;
private ToolStripMenuItemEx DoubleClickToPokeMenuItem;
}
}

View File

@ -179,6 +179,8 @@ namespace BizHawk.Client.EmuHawk
}
public List<RollColumn> Columns { get; set; }
public bool DoubleClickToPoke { get; set; } = true;
}
private IEnumerable<int> SelectedIndices => WatchListView.SelectedRows;
@ -433,6 +435,21 @@ namespace BizHawk.Client.EmuHawk
GeneralUpdate();
}
/// <summary>
/// Open Edit or Poke window for selected watch depending on user setting
/// </summary>
private void OpenWatch()
{
if (Settings.DoubleClickToPoke)
{
PokeAddress();
}
else
{
EditWatch();
}
}
private void EditWatch(bool duplicate = false)
{
var indexes = SelectedIndices.ToList();
@ -835,6 +852,11 @@ namespace BizHawk.Client.EmuHawk
}
private void PokeAddressMenuItem_Click(object sender, EventArgs e)
{
PokeAddress();
}
private void PokeAddress()
{
if (SelectedWatches.Any())
{
@ -1036,6 +1058,22 @@ namespace BizHawk.Client.EmuHawk
}
}
private void DoubleClickActionSubMenu_DropDownOpening(object sender, EventArgs e)
{
DoubleClickToEditMenuItem.Checked = !Settings.DoubleClickToPoke;
DoubleClickToPokeMenuItem.Checked = Settings.DoubleClickToPoke;
}
private void DoubleClickToEditMenuItem_Click(object sender, EventArgs e)
{
Settings.DoubleClickToPoke = false;
}
private void DoubleClickToPokeMenuItem_Click(object sender, EventArgs e)
{
Settings.DoubleClickToPoke = true;
}
[RestoreDefaults]
private void RestoreDefaultsMenuItem()
{
@ -1204,7 +1242,7 @@ namespace BizHawk.Client.EmuHawk
}
else if (e.IsPressed(Keys.Enter))
{
EditWatch();
OpenWatch();
}
}
@ -1217,7 +1255,7 @@ namespace BizHawk.Client.EmuHawk
private void WatchListView_MouseDoubleClick(object sender, MouseEventArgs e)
{
EditWatch();
OpenWatch();
}
private void WatchListView_ColumnClick(object sender, InputRoll.ColumnClickEventArgs e)