Ram Watch - floating window and refactor

This commit is contained in:
adelikat 2014-01-30 14:29:34 +00:00
parent 0e88359f1e
commit dead076979
3 changed files with 62 additions and 39 deletions

View File

@ -41,7 +41,7 @@ namespace BizHawk.Client.Common
public PathEntryCollection PathEntries = new PathEntryCollection(); public PathEntryCollection PathEntries = new PathEntryCollection();
// BIOS Paths // BIOS Paths
public Dictionary<string, string> FirmwareUserSpecifications = new Dictionary<string, string>(); //key: sysid+firmwareId; value: absolute path public Dictionary<string, string> FirmwareUserSpecifications = new Dictionary<string, string>(); // key: sysid+firmwareId; value: absolute path
public string FFMpegPath = "%exe%/dll/ffmpeg.exe"; public string FFMpegPath = "%exe%/dll/ffmpeg.exe";
@ -49,12 +49,12 @@ namespace BizHawk.Client.Common
public int Input_Hotkey_OverrideOptions = 0; public int Input_Hotkey_OverrideOptions = 0;
public bool StackOSDMessages = true; public bool StackOSDMessages = true;
public int TargetZoomFactor = 2; public int TargetZoomFactor = 2;
public int TargetScanlineFilterIntensity = 0; //choose between 0 and 256 public int TargetScanlineFilterIntensity = 0; // choose between 0 and 256
public RecentFiles RecentRoms = new RecentFiles(8); public RecentFiles RecentRoms = new RecentFiles(8);
public bool PauseWhenMenuActivated = true; public bool PauseWhenMenuActivated = true;
public bool SaveWindowPosition = true; public bool SaveWindowPosition = true;
public bool StartPaused = false; public bool StartPaused = false;
public int MainWndx = -1; //Negative numbers will be ignored public int MainWndx = -1; // Negative numbers will be ignored
public int MainWndy = -1; public int MainWndy = -1;
public bool RunInBackground = true; public bool RunInBackground = true;
public bool AcceptBackgroundInput = false; public bool AcceptBackgroundInput = false;
@ -179,13 +179,8 @@ namespace BizHawk.Client.Common
public bool DisableLuaScriptsOnLoad = false; public bool DisableLuaScriptsOnLoad = false;
// RamWatch Settings // RamWatch Settings
public ToolDialogSettings RamWatchSettings = new ToolDialogSettings();
public RecentFiles RecentWatches = new RecentFiles(8); public RecentFiles RecentWatches = new RecentFiles(8);
public bool RamWatchSaveWindowPosition = true;
public bool RamWatchAlwaysOnTop = false;
public int RamWatchWndx = -1; // Negative numbers will be ignored even with save window position set
public int RamWatchWndy = -1;
public int RamWatchWidth = -1;
public int RamWatchHeight = -1;
public bool RamWatchShowChangeColumn = true; public bool RamWatchShowChangeColumn = true;
public bool RamWatchShowPrevColumn = false; public bool RamWatchShowPrevColumn = false;
public bool RamWatchShowDiffColumn = false; public bool RamWatchShowDiffColumn = false;

View File

@ -116,6 +116,7 @@
this.DiffColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.DiffColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.DomainColumn = ((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.NotesColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.FloatingWindowMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ListViewContextMenu.SuspendLayout(); this.ListViewContextMenu.SuspendLayout();
this.toolStrip1.SuspendLayout(); this.toolStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
@ -170,7 +171,7 @@
this.ShowDiffContextMenuItem, this.ShowDiffContextMenuItem,
this.ShowDomainContextMenuItem}); this.ShowDomainContextMenuItem});
this.ListViewContextMenu.Name = "contextMenuStrip1"; this.ListViewContextMenu.Name = "contextMenuStrip1";
this.ListViewContextMenu.Size = new System.Drawing.Size(204, 346); this.ListViewContextMenu.Size = new System.Drawing.Size(204, 324);
this.ListViewContextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.ListViewContextMenu_Opening); this.ListViewContextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.ListViewContextMenu_Opening);
// //
// EditContextMenuItem // EditContextMenuItem
@ -721,6 +722,7 @@
this.WatchesOnScreenMenuItem, this.WatchesOnScreenMenuItem,
this.SaveWindowPositionMenuItem, this.SaveWindowPositionMenuItem,
this.AlwaysOnTopMenuItem, this.AlwaysOnTopMenuItem,
this.FloatingWindowMenuItem,
this.toolStripSeparator7, this.toolStripSeparator7,
this.RestoreWindowSizeMenuItem}); this.RestoreWindowSizeMenuItem});
this.OptionsSubMenu.Name = "OptionsSubMenu"; this.OptionsSubMenu.Name = "OptionsSubMenu";
@ -843,6 +845,7 @@
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.WatchListView.AutoArrange = false; this.WatchListView.AutoArrange = false;
this.WatchListView.BlazingFast = false;
this.WatchListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.WatchListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.AddressColumn, this.AddressColumn,
this.ValueColumn, this.ValueColumn,
@ -915,6 +918,13 @@
this.NotesColumn.Text = "Notes"; this.NotesColumn.Text = "Notes";
this.NotesColumn.Width = 128; this.NotesColumn.Width = 128;
// //
// FloatingWindowMenuItem
//
this.FloatingWindowMenuItem.Name = "FloatingWindowMenuItem";
this.FloatingWindowMenuItem.Size = new System.Drawing.Size(217, 22);
this.FloatingWindowMenuItem.Text = "&Floating Window";
this.FloatingWindowMenuItem.Click += new System.EventHandler(this.FloatingWindowMenuItem_Click);
//
// RamWatch // RamWatch
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -1033,5 +1043,6 @@
private System.Windows.Forms.ToolStripMenuItem ShowDiffContextMenuItem; private System.Windows.Forms.ToolStripMenuItem ShowDiffContextMenuItem;
private System.Windows.Forms.ToolStripMenuItem ShowDomainContextMenuItem; private System.Windows.Forms.ToolStripMenuItem ShowDomainContextMenuItem;
private System.Windows.Forms.ToolStripMenuItem AlwaysOnTopMenuItem; private System.Windows.Forms.ToolStripMenuItem AlwaysOnTopMenuItem;
private System.Windows.Forms.ToolStripMenuItem FloatingWindowMenuItem;
} }
} }

View File

@ -28,7 +28,7 @@ namespace BizHawk.Client.EmuHawk
private int _defaultWidth; private int _defaultWidth;
private int _defaultHeight; private int _defaultHeight;
private string _sortedColumn = String.Empty; private string _sortedColumn = string.Empty;
private bool _sortReverse; private bool _sortReverse;
public RamWatch() public RamWatch()
@ -48,10 +48,11 @@ namespace BizHawk.Client.EmuHawk
e.Cancel = true; e.Cancel = true;
} }
}; };
_sortedColumn = String.Empty;
_sortedColumn = string.Empty;
_sortReverse = false; _sortReverse = false;
TopMost = Global.Config.RamWatchAlwaysOnTop; TopMost = Global.Config.RamWatchSettings.TopMost;
} }
private IEnumerable<int> SelectedIndices private IEnumerable<int> SelectedIndices
@ -177,7 +178,7 @@ namespace BizHawk.Client.EmuHawk
return; return;
} }
if (!String.IsNullOrWhiteSpace(_watches.CurrentFileName)) if (!string.IsNullOrWhiteSpace(_watches.CurrentFileName))
{ {
_watches.Reload(); _watches.Reload();
} }
@ -317,7 +318,7 @@ namespace BizHawk.Client.EmuHawk
switch (name) switch (name)
{ {
default: default:
return String.Empty; return string.Empty;
case WatchList.ADDRESS: case WatchList.ADDRESS:
return _watches[index].AddressString; return _watches[index].AddressString;
case WatchList.VALUE: case WatchList.VALUE:
@ -371,14 +372,14 @@ namespace BizHawk.Client.EmuHawk
_defaultWidth = Size.Width; // Save these first so that the user can restore to its original size _defaultWidth = Size.Width; // Save these first so that the user can restore to its original size
_defaultHeight = Size.Height; _defaultHeight = Size.Height;
if (Global.Config.RamWatchSaveWindowPosition && Global.Config.RamWatchWndx >= 0 && Global.Config.RamWatchWndy >= 0) if (Global.Config.RamWatchSettings.UseWindowPosition)
{ {
Location = new Point(Global.Config.RamWatchWndx, Global.Config.RamWatchWndy); Location = new Point(Global.Config.RamWatchSettings.Wndx.Value, Global.Config.RamWatchSettings.Wndy.Value);
} }
if (Global.Config.RamWatchWidth >= 0 && Global.Config.RamWatchHeight >= 0) if (Global.Config.RamWatchSettings.UseWindowSize)
{ {
Size = new Size(Global.Config.RamWatchWidth, Global.Config.RamWatchHeight); Size = new Size(Global.Config.RamWatchSettings.Width.Value, Global.Config.RamWatchSettings.Height.Value);
} }
LoadColumnInfo(); LoadColumnInfo();
@ -399,7 +400,7 @@ namespace BizHawk.Client.EmuHawk
UpdateWatchCount(); UpdateWatchCount();
UpdateMessageLabel(); UpdateMessageLabel();
_sortReverse = false; _sortReverse = false;
_sortedColumn = String.Empty; _sortedColumn = string.Empty;
} }
} }
@ -476,10 +477,10 @@ namespace BizHawk.Client.EmuHawk
private void SaveConfigSettings() private void SaveConfigSettings()
{ {
SaveColumnInfo(); SaveColumnInfo();
Global.Config.RamWatchWndx = Location.X; Global.Config.RamWatchSettings.Wndx = Location.X;
Global.Config.RamWatchWndy = Location.Y; Global.Config.RamWatchSettings.Wndy = Location.Y;
Global.Config.RamWatchWidth = Right - Left; Global.Config.RamWatchSettings.Width = Right - Left;
Global.Config.RamWatchHeight = Bottom - Top; Global.Config.RamWatchSettings.Height = Bottom - Top;
} }
private void SetMemoryDomain(string name) private void SetMemoryDomain(string name)
@ -496,8 +497,8 @@ namespace BizHawk.Client.EmuHawk
private void UpdateMessageLabel(bool saved = false) private void UpdateMessageLabel(bool saved = false)
{ {
var message = String.Empty; var message = string.Empty;
if (!String.IsNullOrWhiteSpace(_watches.CurrentFileName)) if (!string.IsNullOrWhiteSpace(_watches.CurrentFileName))
{ {
if (saved) if (saved)
{ {
@ -505,7 +506,7 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
message = Path.GetFileName(_watches.CurrentFileName) + (_watches.Changes ? " *" : String.Empty); message = Path.GetFileName(_watches.CurrentFileName) + (_watches.Changes ? " *" : string.Empty);
} }
} }
@ -539,7 +540,7 @@ namespace BizHawk.Client.EmuHawk
private void WatchListView_QueryItemText(int index, int column, out string text) private void WatchListView_QueryItemText(int index, int column, out string text)
{ {
text = String.Empty; text = string.Empty;
if (index >= _watches.ItemCount || _watches[index].IsSeparator) if (index >= _watches.ItemCount || _watches[index].IsSeparator)
{ {
@ -578,6 +579,11 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private void RefreshFloatingWindowControl()
{
Owner = Global.Config.RamWatchSettings.FloatingWindow ? null : GlobalWin.MainForm;
}
#endregion #endregion
#region Winform Events #region Winform Events
@ -602,7 +608,7 @@ namespace BizHawk.Client.EmuHawk
private void SaveMenuItem_Click(object sender, EventArgs e) private void SaveMenuItem_Click(object sender, EventArgs e)
{ {
if (!String.IsNullOrWhiteSpace(_watches.CurrentFileName)) if (!string.IsNullOrWhiteSpace(_watches.CurrentFileName))
{ {
if (_watches.Save()) if (_watches.Save())
{ {
@ -828,8 +834,9 @@ namespace BizHawk.Client.EmuHawk
private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e) private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e)
{ {
WatchesOnScreenMenuItem.Checked = Global.Config.DisplayRamWatch; WatchesOnScreenMenuItem.Checked = Global.Config.DisplayRamWatch;
SaveWindowPositionMenuItem.Checked = Global.Config.RamWatchSaveWindowPosition; SaveWindowPositionMenuItem.Checked = Global.Config.RamWatchSettings.SaveWindowPosition;
AlwaysOnTopMenuItem.Checked = Global.Config.RamWatchAlwaysOnTop; AlwaysOnTopMenuItem.Checked = Global.Config.RamWatchSettings.TopMost;
FloatingWindowMenuItem.Checked = Global.Config.RamWatchSettings.FloatingWindow;
} }
private void DefinePreviousValueSubMenu_DropDownOpened(object sender, EventArgs e) private void DefinePreviousValueSubMenu_DropDownOpened(object sender, EventArgs e)
@ -870,13 +877,19 @@ namespace BizHawk.Client.EmuHawk
private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e) private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.RamWatchSaveWindowPosition ^= true; Global.Config.RamWatchSettings.SaveWindowPosition ^= true;
} }
private void AlwaysOnTopMenuItem_Click(object sender, EventArgs e) private void AlwaysOnTopMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.RamWatchAlwaysOnTop ^= true; Global.Config.RamWatchSettings.TopMost ^= true;
TopMost = Global.Config.RamWatchAlwaysOnTop; TopMost = Global.Config.RamWatchSettings.TopMost;
}
private void FloatingWindowMenuItem_Click(object sender, EventArgs e)
{
Global.Config.RamWatchSettings.FloatingWindow ^= true;
RefreshFloatingWindowControl();
} }
private void RestoreWindowSizeMenuItem_Click(object sender, EventArgs e) private void RestoreWindowSizeMenuItem_Click(object sender, EventArgs e)
@ -903,15 +916,13 @@ namespace BizHawk.Client.EmuHawk
WatchListView.Columns[WatchList.ADDRESS].Width = _defaultColumnWidths[WatchList.ADDRESS]; WatchListView.Columns[WatchList.ADDRESS].Width = _defaultColumnWidths[WatchList.ADDRESS];
WatchListView.Columns[WatchList.VALUE].Width = _defaultColumnWidths[WatchList.VALUE]; WatchListView.Columns[WatchList.VALUE].Width = _defaultColumnWidths[WatchList.VALUE];
// WatchListView.Columns[WatchList.PREV].Width = DefaultColumnWidths[WatchList.PREV];
WatchListView.Columns[WatchList.CHANGES].Width = _defaultColumnWidths[WatchList.CHANGES]; WatchListView.Columns[WatchList.CHANGES].Width = _defaultColumnWidths[WatchList.CHANGES];
// WatchListView.Columns[WatchList.DIFF].Width = DefaultColumnWidths[WatchList.DIFF];
WatchListView.Columns[WatchList.DOMAIN].Width = _defaultColumnWidths[WatchList.DOMAIN]; WatchListView.Columns[WatchList.DOMAIN].Width = _defaultColumnWidths[WatchList.DOMAIN];
WatchListView.Columns[WatchList.NOTES].Width = _defaultColumnWidths[WatchList.NOTES]; WatchListView.Columns[WatchList.NOTES].Width = _defaultColumnWidths[WatchList.NOTES];
Global.Config.DisplayRamWatch = false; Global.Config.DisplayRamWatch = false;
Global.Config.RamWatchSaveWindowPosition = true; Global.Config.RamWatchSettings.SaveWindowPosition = true;
Global.Config.RamWatchAlwaysOnTop = TopMost = false; Global.Config.RamWatchSettings.TopMost = TopMost = false;
LoadColumnInfo(); LoadColumnInfo();
} }
@ -1100,8 +1111,14 @@ namespace BizHawk.Client.EmuHawk
Global.Config.RamWatchColumnIndexes[WatchList.NOTES] = WatchListView.Columns[WatchList.NOTES].DisplayIndex; Global.Config.RamWatchColumnIndexes[WatchList.NOTES] = WatchListView.Columns[WatchList.NOTES].DisplayIndex;
} }
protected override void OnShown(EventArgs e)
{
RefreshFloatingWindowControl();
base.OnShown(e);
}
#endregion #endregion
#endregion #endregion
} }
} }