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 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,