Cheats, Ram Watch - Fix bugs in column hide/show in new system

This commit is contained in:
adelikat 2015-01-01 01:21:06 +00:00
parent 6440c9c44b
commit 31823693ae
5 changed files with 64 additions and 60 deletions

View File

@ -74,7 +74,7 @@ namespace BizHawk.Client.EmuHawk.WinFormExtensions
}
}
public static ToolStripMenuItem GenerateColumnsMenu(this ToolDialogSettings.ColumnList list)
public static ToolStripMenuItem GenerateColumnsMenu(this ToolDialogSettings.ColumnList list, Action changeCallback)
{
var menu = new ToolStripMenuItem
{
@ -95,6 +95,7 @@ namespace BizHawk.Client.EmuHawk.WinFormExtensions
menuItem.Click += (o, ev) =>
{
dummyList[menuItem.Name].Visible ^= true;
changeCallback();
};
menu.DropDownItems.Add(menuItem);
@ -137,6 +138,11 @@ namespace BizHawk.Client.EmuHawk.WinFormExtensions
return listView.SelectedIndices.Cast<int>();
}
public static IEnumerable<ColumnHeader> ColumnHeaders(this ListView listView)
{
return listView.Columns.OfType<ColumnHeader>();
}
#endregion
}

View File

@ -493,7 +493,7 @@
this.RestoreWindowSizeMenuItem.Name = "RestoreWindowSizeMenuItem";
this.RestoreWindowSizeMenuItem.Size = new System.Drawing.Size(199, 22);
this.RestoreWindowSizeMenuItem.Text = "Restore Default Settings";
this.RestoreWindowSizeMenuItem.Click += new System.EventHandler(this.RestoreWindowSizeMenuItem_Click);
this.RestoreWindowSizeMenuItem.Click += new System.EventHandler(this.RestoreDefaultsMenuItem_Click);
//
// toolStrip1
//

View File

@ -181,7 +181,13 @@ namespace BizHawk.Client.EmuHawk
CheatEditor.SetEditEvent(EditCheat);
UpdateDialog();
CheatsMenu.Items.Add(Settings.Columns.GenerateColumnsMenu());
CheatsMenu.Items.Add(Settings.Columns.GenerateColumnsMenu(ColumnToggleCallback));
}
private void ColumnToggleCallback()
{
SaveColumnInfo();
LoadColumnInfo();
}
private void ToggleGameGenieButton()
@ -235,28 +241,14 @@ namespace BizHawk.Client.EmuHawk
{
CheatListView.Columns.Clear();
foreach (var column in Settings.Columns)
var columns = Settings.Columns
.Where(c => c.Visible)
.OrderBy(c => c.Index);
foreach (var column in columns)
{
CheatListView.AddColumn(column);
}
ColumnPositions();
}
private void ColumnPositions()
{
foreach (ColumnHeader column in CheatListView.Columns)
{
var index = Settings.Columns[column.Name].Index;
if (index < CheatListView.Columns.Count)
{
column.DisplayIndex = Settings.Columns[column.Name].Index;
}
else
{
column.DisplayIndex = CheatListView.Columns.Count - 1;
}
}
}
private void SaveColumnInfo()
@ -621,17 +613,24 @@ namespace BizHawk.Client.EmuHawk
RefreshFloatingWindowControl();
}
private void RestoreWindowSizeMenuItem_Click(object sender, EventArgs e)
private void RestoreDefaultsMenuItem_Click(object sender, EventArgs e)
{
Size = new Size(_defaultWidth, _defaultHeight);
Settings = new CheatsSettings();
CheatsMenu.Items.Remove(
CheatsMenu.Items
.OfType<ToolStripMenuItem>()
.First(x => x.Name == "GeneratedColumnsSubMenu")
);
CheatsMenu.Items.Add(Settings.Columns.GenerateColumnsMenu(ColumnToggleCallback));
Global.Config.DisableCheatsOnLoad = false;
Global.Config.LoadCheatFileByGame = true;
Global.Config.CheatsAutoSaveOnClose = true;
RefreshFloatingWindowControl();
ColumnPositions();
LoadColumnInfo();
}

View File

@ -65,7 +65,7 @@
this.moveDownToolStripButton = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
this.pauseToolStripButton = new System.Windows.Forms.ToolStripButton();
this.menuStrip1 = new MenuStripEx();
this.RamWatchMenu = new MenuStripEx();
this.FileSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.NewListMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.OpenMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -116,7 +116,7 @@
this.ListViewContextMenu.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.RamWatchMenu.SuspendLayout();
this.SuspendLayout();
//
// WatchCountLabel
@ -467,16 +467,16 @@
//
// menuStrip1
//
this.menuStrip1.ClickThrough = true;
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.RamWatchMenu.ClickThrough = true;
this.RamWatchMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.FileSubMenu,
this.WatchesSubMenu,
this.OptionsSubMenu});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(364, 24);
this.menuStrip1.TabIndex = 3;
this.menuStrip1.Text = "menuStrip1";
this.RamWatchMenu.Location = new System.Drawing.Point(0, 0);
this.RamWatchMenu.Name = "menuStrip1";
this.RamWatchMenu.Size = new System.Drawing.Size(364, 24);
this.RamWatchMenu.TabIndex = 3;
this.RamWatchMenu.Text = "menuStrip1";
//
// FileSubMenu
//
@ -809,7 +809,7 @@
this.RestoreWindowSizeMenuItem.Name = "RestoreWindowSizeMenuItem";
this.RestoreWindowSizeMenuItem.Size = new System.Drawing.Size(217, 22);
this.RestoreWindowSizeMenuItem.Text = "Restore Default Settings";
this.RestoreWindowSizeMenuItem.Click += new System.EventHandler(this.RestoreWindowSizeMenuItem_Click);
this.RestoreWindowSizeMenuItem.Click += new System.EventHandler(this.RestoreDefaultsMenuItem_Click);
//
// WatchListView
//
@ -902,7 +902,7 @@
this.Controls.Add(this.MemDomainLabel);
this.Controls.Add(this.WatchCountLabel);
this.Controls.Add(this.toolStrip1);
this.Controls.Add(this.menuStrip1);
this.Controls.Add(this.RamWatchMenu);
this.Controls.Add(this.WatchListView);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "RamWatch";
@ -918,8 +918,8 @@
this.statusStrip1.PerformLayout();
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.RamWatchMenu.ResumeLayout(false);
this.RamWatchMenu.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@ -935,7 +935,7 @@
private System.Windows.Forms.ColumnHeader DiffColumn;
private System.Windows.Forms.ColumnHeader DomainColumn;
private System.Windows.Forms.ColumnHeader NotesColumn;
private MenuStripEx menuStrip1;
private MenuStripEx RamWatchMenu;
private System.Windows.Forms.ToolStripMenuItem FileSubMenu;
private System.Windows.Forms.ToolStripMenuItem NewListMenuItem;
private System.Windows.Forms.ToolStripMenuItem OpenMenuItem;

View File

@ -336,22 +336,6 @@ namespace BizHawk.Client.EmuHawk
UpdateStatusBar();
}
private void ColumnPositions()
{
foreach (ColumnHeader column in WatchListView.Columns)
{
var index = Settings.Columns[column.Name].Index;
if (index < WatchListView.Columns.Count)
{
column.DisplayIndex = Settings.Columns[column.Name].Index;
}
else
{
column.DisplayIndex = WatchListView.Columns.Count - 1;
}
}
}
private void CopyWatchesToClipBoard()
{
var indexes = SelectedIndices.ToList();
@ -440,12 +424,14 @@ namespace BizHawk.Client.EmuHawk
{
WatchListView.Columns.Clear();
foreach (var column in Settings.Columns)
var columns = Settings.Columns
.Where(c => c.Visible)
.OrderBy(c => c.Index);
foreach (var column in columns)
{
WatchListView.AddColumn(column);
}
ColumnPositions();
}
private void LoadConfigSettings()
@ -943,15 +929,22 @@ namespace BizHawk.Client.EmuHawk
RefreshFloatingWindowControl();
}
private void RestoreWindowSizeMenuItem_Click(object sender, EventArgs e)
private void RestoreDefaultsMenuItem_Click(object sender, EventArgs e)
{
Settings = new RamWatchSettings();
Size = new Size(_defaultWidth, _defaultHeight);
RamWatchMenu.Items.Remove(
RamWatchMenu.Items
.OfType<ToolStripMenuItem>()
.First(x => x.Name == "GeneratedColumnsSubMenu")
);
RamWatchMenu.Items.Add(Settings.Columns.GenerateColumnsMenu(ColumnToggleCallback));
Global.Config.DisplayRamWatch = false;
RefreshFloatingWindowControl();
ColumnPositions();
LoadColumnInfo();
}
@ -964,10 +957,16 @@ namespace BizHawk.Client.EmuHawk
TopMost = Settings.TopMost;
_watches = new WatchList(_core, _core.MemoryDomains.MainMemory, _emu.SystemId);
LoadConfigSettings();
menuStrip1.Items.Add(Settings.Columns.GenerateColumnsMenu());
RamWatchMenu.Items.Add(Settings.Columns.GenerateColumnsMenu(ColumnToggleCallback));
UpdateStatusBar();
}
private void ColumnToggleCallback()
{
SaveColumnInfo();
LoadColumnInfo();
}
private void NewRamWatch_Activated(object sender, EventArgs e)
{
WatchListView.Refresh();