New Ram Search - some GUI work

This commit is contained in:
adelikat 2013-09-16 01:24:06 +00:00
parent a2d60ff2c8
commit 88a9b95b15
4 changed files with 278 additions and 55 deletions

View File

@ -61,6 +61,20 @@
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.modeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.DetailedMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.FastMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.MemoryDomainsSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();
this.sizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this._1ByteMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this._2ByteMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this._4ByteMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.DisplayTypeSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.BigEndianMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.CheckMisalignedMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.searchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.newSearchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
@ -77,8 +91,6 @@
this.toolStripSeparator13 = new System.Windows.Forms.ToolStripSeparator();
this.clearUndoHistoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.MemoryDomainsSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();
this.definePreviousValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.sinceLastSearchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.originalValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -119,7 +131,7 @@
this.TotalSearchLabel.TabIndex = 2;
this.TotalSearchLabel.Text = "0 addresses";
//
// SearchListView
// WatchListView
//
this.WatchListView.AllowColumnReorder = true;
this.WatchListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -137,7 +149,7 @@
this.WatchListView.ItemCount = 0;
this.WatchListView.LabelEdit = true;
this.WatchListView.Location = new System.Drawing.Point(9, 58);
this.WatchListView.Name = "SearchListView";
this.WatchListView.Name = "WatchListView";
this.WatchListView.selectedItem = -1;
this.WatchListView.Size = new System.Drawing.Size(221, 363);
this.WatchListView.TabIndex = 1;
@ -268,6 +280,7 @@
this.menuStrip1.ClickThrough = true;
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem,
this.settingsToolStripMenuItem,
this.searchToolStripMenuItem,
this.optionsToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
@ -362,6 +375,118 @@
this.exitToolStripMenuItem.Text = "&Close";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.CloseMenuItem_Click);
//
// settingsToolStripMenuItem
//
this.settingsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.modeToolStripMenuItem,
this.MemoryDomainsSubMenu,
this.sizeToolStripMenuItem,
this.DisplayTypeSubMenu,
this.BigEndianMenuItem,
this.CheckMisalignedMenuItem});
this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem";
this.settingsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
this.settingsToolStripMenuItem.Text = "&Settings";
this.settingsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.SettingsSubMenu_DropDownOpened);
//
// modeToolStripMenuItem
//
this.modeToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.DetailedMenuItem,
this.FastMenuItem});
this.modeToolStripMenuItem.Name = "modeToolStripMenuItem";
this.modeToolStripMenuItem.Size = new System.Drawing.Size(173, 22);
this.modeToolStripMenuItem.Text = "&Mode";
this.modeToolStripMenuItem.DropDownOpened += new System.EventHandler(this.ModeSubMenu_DropDownOpened);
//
// DetailedMenuItem
//
this.DetailedMenuItem.Name = "DetailedMenuItem";
this.DetailedMenuItem.Size = new System.Drawing.Size(152, 22);
this.DetailedMenuItem.Text = "&Detailed";
this.DetailedMenuItem.Click += new System.EventHandler(this.DetailedMenuItem_Click);
//
// FastMenuItem
//
this.FastMenuItem.Name = "FastMenuItem";
this.FastMenuItem.Size = new System.Drawing.Size(152, 22);
this.FastMenuItem.Text = "&Fast";
this.FastMenuItem.Click += new System.EventHandler(this.FastMenuItem_Click);
//
// MemoryDomainsSubMenu
//
this.MemoryDomainsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripSeparator6});
this.MemoryDomainsSubMenu.Name = "MemoryDomainsSubMenu";
this.MemoryDomainsSubMenu.Size = new System.Drawing.Size(173, 22);
this.MemoryDomainsSubMenu.Text = "&Memory Domains";
this.MemoryDomainsSubMenu.DropDownOpened += new System.EventHandler(this.MemoryDomainsSubMenu_DropDownOpened);
//
// toolStripSeparator6
//
this.toolStripSeparator6.Name = "toolStripSeparator6";
this.toolStripSeparator6.Size = new System.Drawing.Size(57, 6);
//
// sizeToolStripMenuItem
//
this.sizeToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this._1ByteMenuItem,
this._2ByteMenuItem,
this._4ByteMenuItem});
this.sizeToolStripMenuItem.Name = "sizeToolStripMenuItem";
this.sizeToolStripMenuItem.Size = new System.Drawing.Size(173, 22);
this.sizeToolStripMenuItem.Text = "&Size";
this.sizeToolStripMenuItem.DropDownOpened += new System.EventHandler(this.SizeSubMenu_DropDownOpened);
//
// _1ByteMenuItem
//
this._1ByteMenuItem.Name = "_1ByteMenuItem";
this._1ByteMenuItem.Size = new System.Drawing.Size(152, 22);
this._1ByteMenuItem.Text = "&1 Byte";
this._1ByteMenuItem.Click += new System.EventHandler(this._1ByteMenuItem_Click);
//
// _2ByteMenuItem
//
this._2ByteMenuItem.Name = "_2ByteMenuItem";
this._2ByteMenuItem.Size = new System.Drawing.Size(152, 22);
this._2ByteMenuItem.Text = "&2 Byte";
this._2ByteMenuItem.Click += new System.EventHandler(this._2ByteMenuItem_Click);
//
// _4ByteMenuItem
//
this._4ByteMenuItem.Name = "_4ByteMenuItem";
this._4ByteMenuItem.Size = new System.Drawing.Size(152, 22);
this._4ByteMenuItem.Text = "&4 Byte";
this._4ByteMenuItem.Click += new System.EventHandler(this._4ByteMenuItem_Click);
//
// DisplayTypeSubMenu
//
this.DisplayTypeSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripSeparator1});
this.DisplayTypeSubMenu.Name = "DisplayTypeSubMenu";
this.DisplayTypeSubMenu.Size = new System.Drawing.Size(173, 22);
this.DisplayTypeSubMenu.Text = "&Display Type";
this.DisplayTypeSubMenu.DropDownOpened += new System.EventHandler(this.DisplayTypeSubMenu_DropDownOpened);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(57, 6);
//
// BigEndianMenuItem
//
this.BigEndianMenuItem.Name = "BigEndianMenuItem";
this.BigEndianMenuItem.Size = new System.Drawing.Size(173, 22);
this.BigEndianMenuItem.Text = "&Big Endian";
this.BigEndianMenuItem.Click += new System.EventHandler(this.BigEndianMenuItem_Click);
//
// CheckMisalignedMenuItem
//
this.CheckMisalignedMenuItem.Name = "CheckMisalignedMenuItem";
this.CheckMisalignedMenuItem.Size = new System.Drawing.Size(173, 22);
this.CheckMisalignedMenuItem.Text = "Check Mis-aligned";
this.CheckMisalignedMenuItem.Click += new System.EventHandler(this.CheckMisalignedMenuItem_Click);
//
// searchToolStripMenuItem
//
this.searchToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -496,7 +621,6 @@
// optionsToolStripMenuItem
//
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.MemoryDomainsSubMenu,
this.definePreviousValueToolStripMenuItem,
this.fastModeToolStripMenuItem,
this.previewModeToolStripMenuItem,
@ -513,20 +637,6 @@
this.optionsToolStripMenuItem.Text = "&Options";
this.optionsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.OptionsSubMenu_DropDownOpened);
//
// MemoryDomainsSubMenu
//
this.MemoryDomainsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripSeparator6});
this.MemoryDomainsSubMenu.Name = "MemoryDomainsSubMenu";
this.MemoryDomainsSubMenu.Size = new System.Drawing.Size(240, 22);
this.MemoryDomainsSubMenu.Text = "&Memory Domains";
this.MemoryDomainsSubMenu.DropDownOpened += new System.EventHandler(this.MemoryDomainsSubMenu_DropDownOpened);
//
// toolStripSeparator6
//
this.toolStripSeparator6.Name = "toolStripSeparator6";
this.toolStripSeparator6.Size = new System.Drawing.Size(57, 6);
//
// definePreviousValueToolStripMenuItem
//
this.definePreviousValueToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -743,7 +853,19 @@
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
private System.Windows.Forms.ToolStripMenuItem newSearchToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator7;
private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem modeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem DetailedMenuItem;
private System.Windows.Forms.ToolStripMenuItem FastMenuItem;
private System.Windows.Forms.ToolStripMenuItem MemoryDomainsSubMenu;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator6;
private System.Windows.Forms.ToolStripMenuItem sizeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem _1ByteMenuItem;
private System.Windows.Forms.ToolStripMenuItem _2ByteMenuItem;
private System.Windows.Forms.ToolStripMenuItem _4ByteMenuItem;
private System.Windows.Forms.ToolStripMenuItem DisplayTypeSubMenu;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem BigEndianMenuItem;
private System.Windows.Forms.ToolStripMenuItem CheckMisalignedMenuItem;
}
}

View File

@ -21,7 +21,8 @@ namespace BizHawk.MultiClient
public const string CHANGES = "ChangesColumn";
public const string DIFF = "DiffColumn";
private RamSearchEngine Searches = new RamSearchEngine(Global.Emulator.MainMemory);
private RamSearchEngine Searches;
private RamSearchEngine.Settings Settings;
private int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
private int defaultHeight;
@ -38,6 +39,9 @@ namespace BizHawk.MultiClient
WatchListView.QueryItemBkColor += ListView_QueryItemBkColor;
WatchListView.VirtualMode = true;
Closing += (o, e) => SaveConfigSettings();
Settings = new RamSearchEngine.Settings();
Searches = new RamSearchEngine(Settings);
}
private void RamSearch_Load(object sender, EventArgs e)
@ -85,6 +89,12 @@ namespace BizHawk.MultiClient
break;
}
}
private void SaveConfigSettings()
{
//TODO
}
#endregion
#region Public
@ -95,11 +105,6 @@ namespace BizHawk.MultiClient
WatchListView.Refresh();
}
public void SaveConfigSettings()
{
//TODO
}
public void Restart()
{
//TODO
@ -146,12 +151,8 @@ namespace BizHawk.MultiClient
{
if (pos < Global.Emulator.MemoryDomains.Count) //Sanity check
{
Searches = new RamSearchEngine(Global.Emulator.MemoryDomains[pos]); //We have to start a new search
Searches.Start();
Settings.Domain = Global.Emulator.MemoryDomains[pos];
}
SetPlatformAndMemoryDomainLabel();
Update();
}
private void LoadConfigSettings()
@ -203,6 +204,11 @@ namespace BizHawk.MultiClient
}
}
private void DoDisplayTypeClick(Watch.DisplayType type)
{
Settings.Type = type;
}
#endregion
#region Winform Events
@ -224,6 +230,85 @@ namespace BizHawk.MultiClient
Close();
}
/*************Settings***********************/
private void SettingsSubMenu_DropDownOpened(object sender, EventArgs e)
{
CheckMisalignedMenuItem.Checked = Settings.CheckMisAligned;
BigEndianMenuItem.Checked = Settings.BigEndian;
}
private void ModeSubMenu_DropDownOpened(object sender, EventArgs e)
{
DetailedMenuItem.Checked = Settings.Mode == RamSearchEngine.Settings.SearchMode.Detailed;
FastMenuItem.Checked = Settings.Mode == RamSearchEngine.Settings.SearchMode.Fast;
}
private void MemoryDomainsSubMenu_DropDownOpened(object sender, EventArgs e)
{
MemoryDomainsSubMenu.DropDownItems.Clear();
MemoryDomainsSubMenu.DropDownItems.AddRange(ToolHelpers.GenerateMemoryDomainMenuItems(SetMemoryDomain, Searches.DomainName));
}
private void SizeSubMenu_DropDownOpened(object sender, EventArgs e)
{
_1ByteMenuItem.Checked = Settings.Size == Watch.WatchSize.Byte;
_2ByteMenuItem.Checked = Settings.Size == Watch.WatchSize.Word;
_4ByteMenuItem.Checked = Settings.Size == Watch.WatchSize.DWord;
}
private void DisplayTypeSubMenu_DropDownOpened(object sender, EventArgs e)
{
DisplayTypeSubMenu.DropDownItems.Clear();
foreach (var type in Watch.AvailableTypes(Settings.Size))
{
var item = new ToolStripMenuItem()
{
Name = type.ToString() + "ToolStripMenuItem",
Text = Watch.DisplayTypeToString(type),
Checked = Settings.Type == type,
};
item.Click += (o, ev) => DoDisplayTypeClick(type);
DisplayTypeSubMenu.DropDownItems.Add(item);
}
}
private void DetailedMenuItem_Click(object sender, EventArgs e)
{
Settings.Mode = RamSearchEngine.Settings.SearchMode.Detailed;
}
private void FastMenuItem_Click(object sender, EventArgs e)
{
Settings.Mode = RamSearchEngine.Settings.SearchMode.Fast;
}
private void _1ByteMenuItem_Click(object sender, EventArgs e)
{
Settings.Size = Watch.WatchSize.Byte;
}
private void _2ByteMenuItem_Click(object sender, EventArgs e)
{
Settings.Size = Watch.WatchSize.Word;
}
private void _4ByteMenuItem_Click(object sender, EventArgs e)
{
Settings.Size = Watch.WatchSize.DWord;
}
private void BigEndianMenuItem_Click(object sender, EventArgs e)
{
Settings.BigEndian = BigEndianMenuItem.Checked;
}
private void CheckMisalignedMenuItem_Click(object sender, EventArgs e)
{
Settings.CheckMisAligned = CheckMisalignedMenuItem.Checked;
}
/*************Search***********************/
private void SearchSubMenu_DropDownOpened(object sender, EventArgs e)
{
@ -241,11 +326,7 @@ namespace BizHawk.MultiClient
AutoloadDialogMenuItem.Checked = Global.Config.RecentSearches.AutoLoad;
}
private void MemoryDomainsSubMenu_DropDownOpened(object sender, EventArgs e)
{
MemoryDomainsSubMenu.DropDownItems.Clear();
MemoryDomainsSubMenu.DropDownItems.AddRange(ToolHelpers.GenerateMemoryDomainMenuItems(SetMemoryDomain, Searches.DomainName));
}
private void AutoloadDialogMenuItem_Click(object sender, EventArgs e)
{

View File

@ -8,18 +8,14 @@ namespace BizHawk.MultiClient
{
class RamSearchEngine
{
public enum Mode { Fast, Detailed }
private MemoryDomain _domain;
private Mode _mode;
private WatchList _watchList;
private Settings _settings;
#region Constructors
public RamSearchEngine(MemoryDomain domain, Mode mode = Mode.Detailed)
public RamSearchEngine(Settings settings)
{
_domain = domain;
_mode = mode;
_settings = settings;
}
#endregion
@ -28,12 +24,12 @@ namespace BizHawk.MultiClient
public void Start()
{
_watchList = new WatchList(_domain);
_watchList = new WatchList(_settings.Domain);
//TODO: other byte sizes, mis-aligned
for(int i = 0; i < _domain.Size; i++)
for (int i = 0; i < _settings.Domain.Size; i++)
{
_watchList.Add(Watch.GenerateWatch(_domain, i, Watch.WatchSize.Byte, true));
_watchList.Add(Watch.GenerateWatch(_settings.Domain, i, _settings.Size, _settings.Mode == Settings.SearchMode.Detailed));
}
}
@ -56,21 +52,14 @@ namespace BizHawk.MultiClient
}
}
public Mode SearchMode
{
get { return _mode; }
}
public string DomainName
{
get { return _domain.Name; }
get { return _settings.Domain.Name; }
}
public void Update()
{
if (_mode == Mode.Detailed)
{
}
//TODO
}
#endregion
@ -105,5 +94,21 @@ namespace BizHawk.MultiClient
#region Private parts
#endregion
#region Classes
public class Settings
{
/*Require restart*/
public enum SearchMode { Fast, Detailed }
public SearchMode Mode = SearchMode.Detailed;
public MemoryDomain Domain = Global.Emulator.MainMemory;
public Watch.WatchSize Size = Watch.WatchSize.Byte;
public bool CheckMisAligned = false;
/*Can be changed mid-search*/
public Watch.DisplayType Type = Watch.DisplayType.Unsigned;
public bool BigEndian = false;
}
#endregion
}
}

View File

@ -272,6 +272,21 @@ namespace BizHawk.MultiClient
}
}
public static List<DisplayType> AvailableTypes(WatchSize size)
{
switch (size)
{
default:
case WatchSize.Separator:
return SeparatorWatch.ValidTypes;
case WatchSize.Byte:
return ByteWatch.ValidTypes;
case WatchSize.Word:
return WordWatch.ValidTypes;
case WatchSize.DWord:
return DWordWatch.ValidTypes;
}
}
/// <summary>
/// Temparary support of the legacy watch object