Ram Poke - more text box tweaks

This commit is contained in:
andres.delikat 2011-02-24 14:03:35 +00:00
parent 98643b0599
commit f38c452da0
1 changed files with 45 additions and 43 deletions

View File

@ -13,10 +13,10 @@ namespace BizHawk.MultiClient
public partial class RamPoke : Form public partial class RamPoke : Form
{ {
//TODO: //TODO:
//If signed/unsigned/hex radios selected, auto-change the value box //If signed/unsigned/hex radios selected, auto-change the value box, and auto limit box length
//Checked signed/u/h value on RamPoke_Load and set value appopriately //Checked signed/u/h value on RamPoke_Load and set value appopriately
//Memory domain selection //Memory domain selection
//Overhaul input validation of textboxes to be like Ram Search //Output message, format number of digits appropriately
public Watch watch = new Watch(); public Watch watch = new Watch();
public Point location = new Point(); public Point location = new Point();
@ -123,49 +123,17 @@ namespace BizHawk.MultiClient
else if (LittleEndianRadio.Checked) else if (LittleEndianRadio.Checked)
watch.bigendian = false; watch.bigendian = false;
switch (watch.signed) int x = GetSpecificValue();
if (x == -99999999)
{ {
case asigned.UNSIGNED: MessageBox.Show("Missing or invalid value", "Invalid Value", MessageBoxButtons.OK, MessageBoxIcon.Error);
if (InputValidate.IsValidUnsignedNumber(ValueBox.Text)) ValueBox.Focus();
{ ValueBox.SelectAll();
watch.value = int.Parse(ValueBox.Text); return;
}
else
{
MessageBox.Show("Invalid Address, must be a valid number number", "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Error);
ValueBox.Focus();
ValueBox.SelectAll();
return;
}
break;
case asigned.SIGNED:
if (InputValidate.IsValidSignedNumber(ValueBox.Text))
{
watch.value = int.Parse(ValueBox.Text);
}
else
{
MessageBox.Show("Invalid Address, must be a valid number number", "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Error);
ValueBox.Focus();
ValueBox.SelectAll();
}
break;
case asigned.HEX:
if (InputValidate.IsValidHexNumber(ValueBox.Text))
{
watch.value = int.Parse(ValueBox.Text);
}
else
{
MessageBox.Show("Invalid Address, must be a valid hex number", "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Error);
ValueBox.Focus();
ValueBox.SelectAll();
return;
}
break;
default:
return;
} }
else
watch.value = int.Parse(ValueBox.Text);
watch.PokeAddress(Global.Emulator.MainMemory); watch.PokeAddress(Global.Emulator.MainMemory);
//TODO: format value based on watch.type //TODO: format value based on watch.type
@ -236,5 +204,39 @@ namespace BizHawk.MultiClient
break; break;
} }
} }
private atype GetDataSize()
{
if (Byte1Radio.Checked)
return atype.BYTE;
if (Byte2Radio.Checked)
return atype.WORD;
if (Byte4Radio.Checked)
return atype.DWORD;
return atype.BYTE;
}
private int GetSpecificValue()
{
if (ValueBox.Text == "" || ValueBox.Text == "-") return 0;
bool i = false;
switch (GetDataType())
{
case asigned.UNSIGNED:
i = InputValidate.IsValidUnsignedNumber(ValueBox.Text);
if (!i) return -99999999;
return (int)Int64.Parse(ValueBox.Text); //Note: 64 to be safe since 4 byte values can be entered
case asigned.SIGNED:
i = InputValidate.IsValidSignedNumber(ValueBox.Text);
if (!i) return -99999999;
return (int)Int64.Parse(ValueBox.Text);
case asigned.HEX:
i = InputValidate.IsValidHexNumber(ValueBox.Text);
if (!i) return -99999999;
return (int)Int64.Parse(ValueBox.Text, NumberStyles.HexNumber);
}
return -99999999; //What are the odds someone wants to search for this value?
}
} }
} }