Ram Watch - clode cleanup

This commit is contained in:
adelikat 2013-11-20 01:17:01 +00:00
parent 701392f43c
commit df622ec9f1
4 changed files with 586 additions and 624 deletions

View File

@ -314,7 +314,7 @@ namespace BizHawk.Client.Common
}
}
public void RemoveRange(List<int> addresses)
public void RemoveRange(IEnumerable<int> addresses)
{
_watchList = _watchList.Where(x => !addresses.Contains(x.Address)).ToList();
}

View File

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
@ -156,37 +155,22 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.Sound.StartSound();
}
public static ToolStripMenuItem[] GenerateMemoryDomainMenuItems(Action<int> SetCallback, string SelectedDomain = "", int? maxSize = null)
public static IEnumerable<ToolStripMenuItem> GenerateMemoryDomainMenuItems(Action<string> setCallback, string selectedDomain = "", int? maxSize = null)
{
var items = new List<ToolStripMenuItem>();
if (Global.Emulator.MemoryDomains.Any())
foreach (var domain in Global.Emulator.MemoryDomains)
{
int counter = 0;
foreach (var domain in Global.Emulator.MemoryDomains)
{
string temp = domain.ToString();
var item = new ToolStripMenuItem { Text = temp };
string name = domain.Name;
int index = counter;
item.Click += (o, ev) => SetCallback(index);
if (temp == SelectedDomain)
{
item.Checked = true;
}
if (maxSize.HasValue && domain.Size > maxSize.Value)
{
item.Enabled = false;
}
items.Add(item);
counter++;
}
var item = new ToolStripMenuItem { Text = name };
item.Click += (o, ev) => setCallback(name);
item.Checked = name == selectedDomain;
item.Enabled = !(maxSize.HasValue && domain.Size > maxSize.Value);
items.Add(item);
}
return items.ToArray();
return items;
}
public static void PopulateMemoryDomainDropdown(ref ComboBox dropdown, MemoryDomain startDomain)
@ -226,7 +210,7 @@ namespace BizHawk.Client.EmuHawk
if (!watch.IsSeparator)
{
Global.CheatList.Add(
new Cheat(watch, watch.Value.Value, compare: null, enabled: true)
new Cheat(watch, watch.Value ?? 0)
);
}
}

View File

@ -521,16 +521,13 @@ namespace BizHawk.Client.EmuHawk
MemDomainLabel.Text = Global.Emulator.SystemId + " " + Searches.Domain.Name;
}
private void SetMemoryDomain(int pos)
private void SetMemoryDomain(string name)
{
if (pos < Global.Emulator.MemoryDomains.Count) //Sanity check
{
Settings.Domain = Global.Emulator.MemoryDomains[pos];
SetDomainLabel();
SetReboot(true);
SpecificAddressBox.MaxLength = IntHelpers.GetNumDigits(Settings.Domain.Size);
DoDomainSizeCheck();
}
Settings.Domain = Global.Emulator.MemoryDomains[name];
SetDomainLabel();
SetReboot(true);
SpecificAddressBox.MaxLength = IntHelpers.GetNumDigits(Settings.Domain.Size);
DoDomainSizeCheck();
}
private void DoDomainSizeCheck()
@ -1021,7 +1018,7 @@ namespace BizHawk.Client.EmuHawk
private void MemoryDomainsSubMenu_DropDownOpened(object sender, EventArgs e)
{
MemoryDomainsSubMenu.DropDownItems.Clear();
MemoryDomainsSubMenu.DropDownItems.AddRange(ToolHelpers.GenerateMemoryDomainMenuItems(SetMemoryDomain, Searches.Domain.Name, MaxSupportedSize));
MemoryDomainsSubMenu.DropDownItems.AddRange(ToolHelpers.GenerateMemoryDomainMenuItems(SetMemoryDomain, Searches.Domain.Name, MaxSupportedSize).ToArray());
}
private void SizeSubMenu_DropDownOpened(object sender, EventArgs e)

File diff suppressed because it is too large Load Diff