Ram Search & Watch - properly check/uncheck memory domain menu items

This commit is contained in:
andres.delikat 2011-03-29 20:32:46 +00:00
parent fe9ee404ee
commit 615b894a2e
6 changed files with 65 additions and 16 deletions

View File

@ -55,8 +55,8 @@
this.pokeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.freezeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.addToRamWatchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.MemoryViewer = new BizHawk.MultiClient.MemoryViewer();
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
this.MemoryViewer = new BizHawk.MultiClient.MemoryViewer();
this.menuStrip1.SuspendLayout();
this.ViewerContextMenuStrip.SuspendLayout();
this.SuspendLayout();
@ -122,6 +122,7 @@
this.memoryDomainsToolStripMenuItem.Name = "memoryDomainsToolStripMenuItem";
this.memoryDomainsToolStripMenuItem.Size = new System.Drawing.Size(204, 22);
this.memoryDomainsToolStripMenuItem.Text = "&Memory Domains";
this.memoryDomainsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.memoryDomainsToolStripMenuItem_DropDownOpened);
//
// dataSizeToolStripMenuItem
//
@ -260,6 +261,11 @@
this.addToRamWatchToolStripMenuItem.Text = "&Add to Ram Watch";
this.addToRamWatchToolStripMenuItem.Click += new System.EventHandler(this.addToRamWatchToolStripMenuItem_Click);
//
// toolStripSeparator3
//
this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(191, 6);
//
// MemoryViewer
//
this.MemoryViewer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -275,11 +281,6 @@
this.MemoryViewer.Paint += new System.Windows.Forms.PaintEventHandler(this.MemoryViewer_Paint);
this.MemoryViewer.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.MemoryViewer_MouseDoubleClick);
//
// toolStripSeparator3
//
this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(191, 6);
//
// HexEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

View File

@ -125,11 +125,8 @@ namespace BizHawk.MultiClient
}
}
private void SetMemoryDomain(int pos, ToolStripMenuItem item)
private void SetMemoryDomain(int pos)
{
for (int x = 0; x < domainMenuItems.Count; x++)
domainMenuItems[x].Checked = false;
item.Checked = true;
if (pos < Global.Emulator.MemoryDomains.Count) //Sanity check
{
MemoryViewer.SetMemoryDomain(Global.Emulator.MemoryDomains[pos]);
@ -157,11 +154,11 @@ namespace BizHawk.MultiClient
item.Text = str;
{
int z = x;
item.Click += (o, ev) => SetMemoryDomain(z, item);
item.Click += (o, ev) => SetMemoryDomain(z);
}
if (x == 0)
{
SetMemoryDomain(x, item);
SetMemoryDomain(x);
}
memoryDomainsToolStripMenuItem.DropDownItems.Add(item);
domainMenuItems.Add(item);
@ -344,5 +341,21 @@ namespace BizHawk.MultiClient
{
FreezeAddress();
}
private void CheckDomainMenuItems()
{
for (int x = 0; x < domainMenuItems.Count; x++)
{
if (MemoryViewer.GetDomain().Name == domainMenuItems[x].Text)
domainMenuItems[x].Checked = true;
else
domainMenuItems[x].Checked = false;
}
}
private void memoryDomainsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
CheckDomainMenuItems();
}
}
}

View File

@ -318,7 +318,7 @@
this.pokeAddressToolStripMenuItem1,
this.freezeAddressToolStripMenuItem1});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(176, 164);
this.contextMenuStrip1.Size = new System.Drawing.Size(176, 142);
this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening);
//
// startNewSearchToolStripMenuItem
@ -520,6 +520,7 @@
this.memoryDomainsToolStripMenuItem.Name = "memoryDomainsToolStripMenuItem";
this.memoryDomainsToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
this.memoryDomainsToolStripMenuItem.Text = "&Memory Domains";
this.memoryDomainsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.memoryDomainsToolStripMenuItem_DropDownOpened);
//
// searchToolStripMenuItem1
//

View File

@ -22,7 +22,7 @@ namespace BizHawk.MultiClient
List<Watch> weededList = new List<Watch>(); //When addresses are weeded out, the new list goes here, before going into searchList
List<Watch> prevList = new List<Watch>();
private bool IsAWeededList = false; //For deciding whether the weeded list is relevant (0 size could mean all were removed in a legit preview
List<ToolStripMenuItem> domainMenuItems = new List<ToolStripMenuItem>();
MemoryDomain Domain = new MemoryDomain("NULL", 1, Endian.Little, addr => 0, (a, v) => { });
public enum SCompareTo { PREV, VALUE, ADDRESS, CHANGES };
@ -115,10 +115,10 @@ namespace BizHawk.MultiClient
}
if (x == 0)
{
//item.Checked = true; //TODO: figure out how to check/uncheck these in SetMemoryDomain
SetMemoryDomain(x);
}
memoryDomainsToolStripMenuItem.DropDownItems.Add(item);
domainMenuItems.Add(item);
}
}
else
@ -1874,5 +1874,21 @@ namespace BizHawk.MultiClient
{
FreezeAddress();
}
private void CheckDomainMenuItems()
{
for (int x = 0; x < domainMenuItems.Count; x++)
{
if (Domain.Name == domainMenuItems[x].Text)
domainMenuItems[x].Checked = true;
else
domainMenuItems[x].Checked = false;
}
}
private void memoryDomainsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
CheckDomainMenuItems();
}
}
}

View File

@ -251,6 +251,7 @@
this.memoryDomainsToolStripMenuItem.Name = "memoryDomainsToolStripMenuItem";
this.memoryDomainsToolStripMenuItem.Size = new System.Drawing.Size(222, 22);
this.memoryDomainsToolStripMenuItem.Text = "Memory Domains";
this.memoryDomainsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.memoryDomainsToolStripMenuItem_DropDownOpened);
//
// toolStripSeparator8
//

View File

@ -33,6 +33,7 @@ namespace BizHawk.MultiClient
List<Watch> watchList = new List<Watch>();
string currentWatchFile = "";
bool changes = false;
List<ToolStripMenuItem> domainMenuItems = new List<ToolStripMenuItem>();
public List<Watch> GetRamWatchList()
{
@ -1240,14 +1241,30 @@ namespace BizHawk.MultiClient
}
if (x == 0)
{
//item.Checked = true; //TODO: figure out how to check/uncheck these in SetMemoryDomain
SetMemoryDomain(x);
}
memoryDomainsToolStripMenuItem.DropDownItems.Add(item);
domainMenuItems.Add(item);
}
}
else
memoryDomainsToolStripMenuItem.Enabled = false;
}
private void CheckDomainMenuItems()
{
for (int x = 0; x < domainMenuItems.Count; x++)
{
if (Domain.Name == domainMenuItems[x].Text)
domainMenuItems[x].Checked = true;
else
domainMenuItems[x].Checked = false;
}
}
private void memoryDomainsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
CheckDomainMenuItems();
}
}
}