From 5b83b9e019a12ff880c2c7b291f0b14cf1d97ce5 Mon Sep 17 00:00:00 2001 From: adelikat Date: Mon, 14 Oct 2019 19:11:07 -0500 Subject: [PATCH] Ram Watch - Wire up column hiding/showing --- .../Extensions/ControlExtensions.cs | 35 +++++++++++++++++++ .../tools/Watch/RamWatch.cs | 4 +-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs b/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs index 756dcfca33..71d192046c 100644 --- a/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs +++ b/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs @@ -80,6 +80,41 @@ namespace BizHawk.Client.EmuHawk.WinFormExtensions } } + public static ToolStripMenuItem ToColumnsMenu(this InputRoll inputRoll) + { + var menu = new ToolStripMenuItem + { + Name = "GeneratedColumnsSubMenu", + Text = "Columns" + }; + + var columns = inputRoll.AllColumns; + + foreach (var column in columns) + { + var menuItem = new ToolStripMenuItem + { + 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(); + + 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/tools/Watch/RamWatch.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs index 32c70400d4..f0ce11fdc0 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs @@ -1100,7 +1100,7 @@ namespace BizHawk.Client.EmuHawk .OfType() .First(x => x.Name == "GeneratedColumnsSubMenu")); - RamWatchMenu.Items.Add(Settings.Columns.GenerateColumnsMenu(ColumnToggleCallback)); + RamWatchMenu.Items.Add(WatchListView.ToColumnsMenu()); Global.Config.DisplayRamWatch = false; @@ -1118,7 +1118,7 @@ namespace BizHawk.Client.EmuHawk TopMost = Settings.TopMost; _watches = new WatchList(MemoryDomains, Emu.SystemId); LoadConfigSettings(); - RamWatchMenu.Items.Add(Settings.Columns.GenerateColumnsMenu(ColumnToggleCallback)); + RamWatchMenu.Items.Add(WatchListView.ToColumnsMenu()); UpdateStatusBar(); PokeAddressToolBarItem.Enabled =