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

File diff suppressed because it is too large Load Diff

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