Cheats - when editing a cheat's domain, if the address is out of range, don't update, rather than create a separator, fixes #539
This commit is contained in:
parent
175862a5f3
commit
0213755d16
|
@ -309,53 +309,50 @@ namespace BizHawk.Client.EmuHawk
|
||||||
get { return _cheat; }
|
get { return _cheat; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cheat Cheat
|
public Cheat GetCheat()
|
||||||
{
|
{
|
||||||
get
|
Cheat.COMPARISONTYPE comparisonType = Cheat.COMPARISONTYPE.NONE;
|
||||||
|
var domain = MemoryDomains[DomainDropDown.SelectedItem.ToString()];
|
||||||
|
var address = AddressBox.ToRawInt().Value;
|
||||||
|
if (address < domain.Size)
|
||||||
{
|
{
|
||||||
Cheat.COMPARISONTYPE comparisonType = Cheat.COMPARISONTYPE.NONE;
|
var watch = Watch.GenerateWatch(
|
||||||
var domain = MemoryDomains[DomainDropDown.SelectedItem.ToString()];
|
MemoryDomains[DomainDropDown.SelectedItem.ToString()],
|
||||||
var address = AddressBox.ToRawInt().Value;
|
AddressBox.ToRawInt().Value,
|
||||||
if (address < domain.Size)
|
GetCurrentSize(),
|
||||||
|
Watch.StringToDisplayType(DisplayTypeDropDown.SelectedItem.ToString()),
|
||||||
|
BigEndianCheckBox.Checked,
|
||||||
|
NameBox.Text
|
||||||
|
);
|
||||||
|
|
||||||
|
switch (CompareTypeDropDown.SelectedItem.ToString())
|
||||||
{
|
{
|
||||||
var watch = Watch.GenerateWatch(
|
case "": comparisonType = Cheat.COMPARISONTYPE.NONE; break;
|
||||||
MemoryDomains[DomainDropDown.SelectedItem.ToString()],
|
case "=": comparisonType = Cheat.COMPARISONTYPE.EQUAL; break;
|
||||||
AddressBox.ToRawInt().Value,
|
case ">": comparisonType = Cheat.COMPARISONTYPE.GREATER_THAN; break;
|
||||||
GetCurrentSize(),
|
case ">=": comparisonType = Cheat.COMPARISONTYPE.GREATER_THAN_OR_EQUAL; break;
|
||||||
Watch.StringToDisplayType(DisplayTypeDropDown.SelectedItem.ToString()),
|
case "<": comparisonType = Cheat.COMPARISONTYPE.LESS_THAN; break;
|
||||||
BigEndianCheckBox.Checked,
|
case "<=": comparisonType = Cheat.COMPARISONTYPE.LESS_THAN_OR_EQUAL; break;
|
||||||
NameBox.Text
|
case "!=": comparisonType = Cheat.COMPARISONTYPE.NOT_EQUAL; break;
|
||||||
);
|
default: comparisonType = Cheat.COMPARISONTYPE.NONE; break;
|
||||||
|
}
|
||||||
|
|
||||||
switch (CompareTypeDropDown.SelectedItem.ToString())
|
int? c = CompareBox.ToRawInt() == null ? null : (int?)CompareBox.ToRawInt().Value;
|
||||||
{
|
|
||||||
case "": comparisonType = Cheat.COMPARISONTYPE.NONE; break;
|
|
||||||
case "=": comparisonType = Cheat.COMPARISONTYPE.EQUAL; break;
|
|
||||||
case ">": comparisonType = Cheat.COMPARISONTYPE.GREATER_THAN; break;
|
|
||||||
case ">=": comparisonType = Cheat.COMPARISONTYPE.GREATER_THAN_OR_EQUAL; break;
|
|
||||||
case "<": comparisonType = Cheat.COMPARISONTYPE.LESS_THAN; break;
|
|
||||||
case "<=": comparisonType = Cheat.COMPARISONTYPE.LESS_THAN_OR_EQUAL; break;
|
|
||||||
case "!=": comparisonType = Cheat.COMPARISONTYPE.NOT_EQUAL; break;
|
|
||||||
default: comparisonType = Cheat.COMPARISONTYPE.NONE; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
int? c = CompareBox.ToRawInt() == null ? null : (int?)CompareBox.ToRawInt().Value;
|
|
||||||
|
|
||||||
|
|
||||||
return new Cheat(
|
return new Cheat(
|
||||||
watch,
|
watch,
|
||||||
ValueBox.ToRawInt().Value,
|
ValueBox.ToRawInt().Value,
|
||||||
CompareBox.ToRawInt() == null ? null : (int?)CompareBox.ToRawInt().Value,
|
CompareBox.ToRawInt() == null ? null : (int?)CompareBox.ToRawInt().Value,
|
||||||
true,
|
true,
|
||||||
comparisonType
|
comparisonType
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox.Show(address.ToString() + " is not a valid address for the domain " + domain.Name, "Index out of range", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
MessageBox.Show(address.ToString() + " is not a valid address for the domain " + domain.Name, "Index out of range", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
return Cheat.Separator;
|
return Cheat.Separator;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -177,16 +177,21 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void AddCheat()
|
private void AddCheat()
|
||||||
{
|
{
|
||||||
Global.CheatList.Add(CheatEditor.Cheat);
|
Global.CheatList.Add(CheatEditor.GetCheat());
|
||||||
UpdateDialog();
|
UpdateDialog();
|
||||||
UpdateMessageLabel();
|
UpdateMessageLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EditCheat()
|
private void EditCheat()
|
||||||
{
|
{
|
||||||
Global.CheatList.Exchange(CheatEditor.OriginalCheat, CheatEditor.Cheat);
|
var newCheat = CheatEditor.GetCheat();
|
||||||
UpdateDialog();
|
|
||||||
UpdateMessageLabel();
|
if (!newCheat.IsSeparator) // If a separator comes from the cheat editor something must have been invalid
|
||||||
|
{
|
||||||
|
Global.CheatList.Exchange(CheatEditor.OriginalCheat, newCheat);
|
||||||
|
UpdateDialog();
|
||||||
|
UpdateMessageLabel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveConfigSettings()
|
public void SaveConfigSettings()
|
||||||
|
|
Loading…
Reference in New Issue