Refactoring of Hex Editor, and support poking of 4-byte addresses (how was that left as todo this whole time?)

This commit is contained in:
adelikat 2013-11-28 14:43:27 +00:00
parent e6d85a4087
commit 3ddf1f394b
3 changed files with 1123 additions and 1263 deletions

View File

@ -2,6 +2,8 @@
{
partial class HexEditor
{
private const int fontHeight = 14;
/// <summary>
/// Required designer variable.
/// </summary>
@ -47,9 +49,9 @@
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.memoryDomainsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dataSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.byteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.byteToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.byteToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.DataSizeByteMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.DataSizeWordMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.DataSizeDWordMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.enToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.goToAddressToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -176,7 +178,7 @@
this.copyToolStripMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Duplicate;
this.copyToolStripMenuItem.Name = "copyToolStripMenuItem";
this.copyToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C)));
this.copyToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
this.copyToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.copyToolStripMenuItem.Text = "&Copy";
this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click);
//
@ -185,20 +187,20 @@
this.pasteToolStripMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Paste;
this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem";
this.pasteToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.V)));
this.pasteToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
this.pasteToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.pasteToolStripMenuItem.Text = "&Paste";
this.pasteToolStripMenuItem.Click += new System.EventHandler(this.pasteToolStripMenuItem_Click);
//
// toolStripSeparator6
//
this.toolStripSeparator6.Name = "toolStripSeparator6";
this.toolStripSeparator6.Size = new System.Drawing.Size(143, 6);
this.toolStripSeparator6.Size = new System.Drawing.Size(149, 6);
//
// findToolStripMenuItem1
//
this.findToolStripMenuItem1.Name = "findToolStripMenuItem1";
this.findToolStripMenuItem1.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F)));
this.findToolStripMenuItem1.Size = new System.Drawing.Size(146, 22);
this.findToolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
this.findToolStripMenuItem1.Text = "&Find...";
this.findToolStripMenuItem1.Click += new System.EventHandler(this.findToolStripMenuItem1_Click);
//
@ -206,7 +208,7 @@
//
this.findNextToolStripMenuItem.Name = "findNextToolStripMenuItem";
this.findNextToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F3;
this.findNextToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
this.findNextToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.findNextToolStripMenuItem.Text = "Find Next";
this.findNextToolStripMenuItem.Click += new System.EventHandler(this.findNextToolStripMenuItem_Click);
//
@ -214,7 +216,7 @@
//
this.findPrevToolStripMenuItem.Name = "findPrevToolStripMenuItem";
this.findPrevToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F2;
this.findPrevToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
this.findPrevToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.findPrevToolStripMenuItem.Text = "Find Prev";
this.findPrevToolStripMenuItem.Click += new System.EventHandler(this.findPrevToolStripMenuItem_Click);
//
@ -245,33 +247,33 @@
// dataSizeToolStripMenuItem
//
this.dataSizeToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.byteToolStripMenuItem,
this.byteToolStripMenuItem1,
this.byteToolStripMenuItem2});
this.DataSizeByteMenuItem,
this.DataSizeWordMenuItem,
this.DataSizeDWordMenuItem});
this.dataSizeToolStripMenuItem.Name = "dataSizeToolStripMenuItem";
this.dataSizeToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
this.dataSizeToolStripMenuItem.Text = "Data Size";
//
// byteToolStripMenuItem
// DataSizeByteMenuItem
//
this.byteToolStripMenuItem.Name = "byteToolStripMenuItem";
this.byteToolStripMenuItem.Size = new System.Drawing.Size(106, 22);
this.byteToolStripMenuItem.Text = "1 Byte";
this.byteToolStripMenuItem.Click += new System.EventHandler(this.byteToolStripMenuItem_Click);
this.DataSizeByteMenuItem.Name = "DataSizeByteMenuItem";
this.DataSizeByteMenuItem.Size = new System.Drawing.Size(152, 22);
this.DataSizeByteMenuItem.Text = "1 Byte";
this.DataSizeByteMenuItem.Click += new System.EventHandler(this.byteToolStripMenuItem_Click);
//
// byteToolStripMenuItem1
// DataSizeWordMenuItem
//
this.byteToolStripMenuItem1.Name = "byteToolStripMenuItem1";
this.byteToolStripMenuItem1.Size = new System.Drawing.Size(106, 22);
this.byteToolStripMenuItem1.Text = "2 Byte";
this.byteToolStripMenuItem1.Click += new System.EventHandler(this.byteToolStripMenuItem1_Click);
this.DataSizeWordMenuItem.Name = "DataSizeWordMenuItem";
this.DataSizeWordMenuItem.Size = new System.Drawing.Size(152, 22);
this.DataSizeWordMenuItem.Text = "2 Byte";
this.DataSizeWordMenuItem.Click += new System.EventHandler(this.byteToolStripMenuItem1_Click);
//
// byteToolStripMenuItem2
// DataSizeDWordMenuItem
//
this.byteToolStripMenuItem2.Name = "byteToolStripMenuItem2";
this.byteToolStripMenuItem2.Size = new System.Drawing.Size(106, 22);
this.byteToolStripMenuItem2.Text = "4 Byte";
this.byteToolStripMenuItem2.Click += new System.EventHandler(this.byteToolStripMenuItem2_Click);
this.DataSizeDWordMenuItem.Name = "DataSizeDWordMenuItem";
this.DataSizeDWordMenuItem.Size = new System.Drawing.Size(152, 22);
this.DataSizeDWordMenuItem.Text = "4 Byte";
this.DataSizeDWordMenuItem.Click += new System.EventHandler(this.byteToolStripMenuItem2_Click);
//
// enToolStripMenuItem
//
@ -547,7 +549,6 @@
this.MemoryViewerBox.TabIndex = 2;
this.MemoryViewerBox.TabStop = false;
this.MemoryViewerBox.Paint += new System.Windows.Forms.PaintEventHandler(this.MemoryViewerBox_Paint);
this.MemoryViewerBox.Enter += new System.EventHandler(this.MemoryViewerBox_Enter);
//
// AddressLabel
//
@ -579,7 +580,6 @@
this.AddressesLabel.Size = new System.Drawing.Size(31, 13);
this.AddressesLabel.TabIndex = 0;
this.AddressesLabel.Text = "RAM";
this.AddressesLabel.Click += new System.EventHandler(this.AddressesLabel_Click);
this.AddressesLabel.MouseClick += new System.Windows.Forms.MouseEventHandler(this.AddressesLabel_MouseClick);
this.AddressesLabel.MouseDown += new System.Windows.Forms.MouseEventHandler(this.AddressesLabel_MouseDown);
this.AddressesLabel.MouseLeave += new System.EventHandler(this.AddressesLabel_MouseLeave);
@ -636,9 +636,9 @@
private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem memoryDomainsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem dataSizeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem byteToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem byteToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem byteToolStripMenuItem2;
private System.Windows.Forms.ToolStripMenuItem DataSizeByteMenuItem;
private System.Windows.Forms.ToolStripMenuItem DataSizeWordMenuItem;
private System.Windows.Forms.ToolStripMenuItem DataSizeDWordMenuItem;
private System.Windows.Forms.ToolStripMenuItem goToAddressToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem restoreWindowSizeToolStripMenuItem;

File diff suppressed because it is too large Load Diff

View File

@ -17,8 +17,8 @@ namespace BizHawk.Client.EmuHawk
private Mode _mode = Mode.New;
private bool _loading = true;
private bool _changedSize = false;
private bool _changedDisplayType = false;
private bool _changedSize;
private bool _changedDisplayType;
public Mode EditorMode { get { return _mode; } }
public List<Watch> Watches { get { return _watchList; } }
@ -26,6 +26,7 @@ namespace BizHawk.Client.EmuHawk
public WatchEditor()
{
_changedDisplayType = false;
InitializeComponent();
}
@ -58,8 +59,8 @@ namespace BizHawk.Client.EmuHawk
SizeDropDown.SelectedItem = SizeDropDown.Items[2];
break;
}
int x = DisplayTypeDropDown.Items.IndexOf(Watch.DisplayTypeToString(_watchList[0].Type));
DisplayTypeDropDown.SelectedItem = DisplayTypeDropDown.Items[x];
var index = DisplayTypeDropDown.Items.IndexOf(Watch.DisplayTypeToString(_watchList[0].Type));
DisplayTypeDropDown.SelectedItem = DisplayTypeDropDown.Items[index];
if (_watchList.Count > 1)
{
@ -79,7 +80,7 @@ namespace BizHawk.Client.EmuHawk
else
{
NotesBox.Text = _watchList[0].Notes;
AddressBox.SetFromRawInt(_watchList[0].Address.Value);
AddressBox.SetFromRawInt(_watchList[0].Address ?? 0);
}
SetBigEndianCheckBox();
@ -135,13 +136,13 @@ namespace BizHawk.Client.EmuHawk
{
default:
case 0:
DisplayTypeDropDown.Items.AddRange(ByteWatch.ValidTypes.ConvertAll<string>(e => Watch.DisplayTypeToString(e)).ToArray());
DisplayTypeDropDown.Items.AddRange(ByteWatch.ValidTypes.ConvertAll(e => Watch.DisplayTypeToString(e)).ToArray());
break;
case 1:
DisplayTypeDropDown.Items.AddRange(WordWatch.ValidTypes.ConvertAll<string>(e => Watch.DisplayTypeToString(e)).ToArray());
DisplayTypeDropDown.Items.AddRange(WordWatch.ValidTypes.ConvertAll(e => Watch.DisplayTypeToString(e)).ToArray());
break;
case 2:
DisplayTypeDropDown.Items.AddRange(DWordWatch.ValidTypes.ConvertAll<string>(e => Watch.DisplayTypeToString(e)).ToArray());
DisplayTypeDropDown.Items.AddRange(DWordWatch.ValidTypes.ConvertAll(e => Watch.DisplayTypeToString(e)).ToArray());
break;
}
DisplayTypeDropDown.SelectedItem = DisplayTypeDropDown.Items[0];
@ -200,7 +201,7 @@ namespace BizHawk.Client.EmuHawk
default:
case Mode.New:
var domain = Global.Emulator.MemoryDomains.FirstOrDefault(d => d.Name == DomainDropDown.SelectedItem.ToString());
var address = AddressBox.ToRawInt().Value;
var address = AddressBox.ToRawInt() ?? 0;
var notes = NotesBox.Text;
var type = Watch.StringToDisplayType(DisplayTypeDropDown.SelectedItem.ToString());
var bigendian = BigEndianCheckBox.Checked;
@ -228,7 +229,7 @@ namespace BizHawk.Client.EmuHawk
{
_watchList.Add(Watch.GenerateWatch(
watch.Domain,
watch.Address.Value,
watch.Address ?? 0,
watch.Size,
watch.Type,
watch.Notes,
@ -250,9 +251,9 @@ namespace BizHawk.Client.EmuHawk
if (_changedSize)
{
for(int i = 0; i < _watchList.Count; i++)
for(var i = 0; i < _watchList.Count; i++)
{
Watch.WatchSize size = Watch.WatchSize.Byte;
var size = Watch.WatchSize.Byte;
switch(SizeDropDown.SelectedIndex)
{
case 0:
@ -265,10 +266,9 @@ namespace BizHawk.Client.EmuHawk
size = Watch.WatchSize.DWord;
break;
}
string tempNotes = _watchList[i].Notes;
_watchList[i] = Watch.GenerateWatch(
_watchList[i].Domain,
_watchList.Count == 1 ? AddressBox.ToRawInt().Value : _watchList[i].Address.Value,
_watchList.Count == 1 ? AddressBox.ToRawInt() ?? 0 : _watchList[i].Address ?? 0,
size,
_watchList[i].Type,
_watchList[i].Notes,