Save/Load cheats now accounts for comparison type column
This commit is contained in:
parent
992acd9e96
commit
52c587d712
|
@ -23,25 +23,7 @@ namespace BizHawk.Client.Common
|
|||
private COMPARISONTYPE _comparisonType;
|
||||
|
||||
|
||||
public Cheat(Watch watch, int value, int? compare = null, bool enabled = true)
|
||||
{
|
||||
_enabled = enabled;
|
||||
_watch = watch;
|
||||
_compare = compare;
|
||||
_val = value;
|
||||
|
||||
Pulse();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adding second constructor for comparison type because I fear updating the method signiture for something in the Common namespace
|
||||
/// </summary>
|
||||
/// <param name="watch"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="comparisonType"></param>
|
||||
/// <param name="compare"></param>
|
||||
/// <param name="enabled"></param>
|
||||
public Cheat(Watch watch, int value, COMPARISONTYPE comparisonType, int compare, bool enabled = true)
|
||||
public Cheat(Watch watch, int value, int? compare = null, bool enabled = true, COMPARISONTYPE comparisonType = COMPARISONTYPE.EQUAL)
|
||||
{
|
||||
_enabled = enabled;
|
||||
_watch = watch;
|
||||
|
@ -297,10 +279,7 @@ namespace BizHawk.Client.Common
|
|||
_watch.Poke(GetStringForPulse(_val));
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -397,6 +397,7 @@ namespace BizHawk.Client.Common
|
|||
.Append(cheat.SizeAsChar).Append('\t')
|
||||
.Append(cheat.TypeAsChar).Append('\t')
|
||||
.Append((cheat.BigEndian ?? false) ? '1' : '0').Append('\t')
|
||||
.Append(cheat.ComparisonType.ToString()).Append('\t')
|
||||
.AppendLine();
|
||||
}
|
||||
}
|
||||
|
@ -450,6 +451,7 @@ namespace BizHawk.Client.Common
|
|||
var size = WatchSize.Byte;
|
||||
var type = DisplayType.Hex;
|
||||
var bigendian = false;
|
||||
Cheat.COMPARISONTYPE comparisonType = Cheat.COMPARISONTYPE.EQUAL;
|
||||
|
||||
if (s.Length < 6)
|
||||
{
|
||||
|
@ -480,6 +482,15 @@ namespace BizHawk.Client.Common
|
|||
type = Watch.DisplayTypeFromChar(vals[7][0]);
|
||||
bigendian = vals[8] == "1";
|
||||
}
|
||||
|
||||
// For backwards compatibility, don't assume these values exist
|
||||
if (vals.Length > 8)
|
||||
{
|
||||
if(!Enum.TryParse<Cheat.COMPARISONTYPE>(vals[9], out comparisonType))
|
||||
{
|
||||
continue; //Not sure if this is the best answer, could just resort to ==
|
||||
}
|
||||
}
|
||||
|
||||
var watch = Watch.GenerateWatch(
|
||||
domain,
|
||||
|
@ -489,7 +500,7 @@ namespace BizHawk.Client.Common
|
|||
bigendian,
|
||||
name);
|
||||
|
||||
Add(new Cheat(watch, value, compare, !Global.Config.DisableCheatsOnLoad && enabled));
|
||||
Add(new Cheat(watch, value, compare, !Global.Config.DisableCheatsOnLoad && enabled, comparisonType));
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
|
|
@ -317,34 +317,27 @@ namespace BizHawk.Client.EmuHawk
|
|||
NameBox.Text
|
||||
);
|
||||
|
||||
if(CompareBox.ToRawInt() == null)
|
||||
switch (CompareTypeDropDown.SelectedItem.ToString())
|
||||
{
|
||||
return new Cheat(
|
||||
watch,
|
||||
ValueBox.ToRawInt().Value
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (CompareTypeDropDown.SelectedItem.ToString())
|
||||
{
|
||||
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.EQUAL; break;
|
||||
}
|
||||
|
||||
return new Cheat(
|
||||
watch,
|
||||
ValueBox.ToRawInt().Value,
|
||||
comparisonType,
|
||||
CompareBox.ToRawInt().Value
|
||||
);
|
||||
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.EQUAL; break;
|
||||
}
|
||||
|
||||
int? c = CompareBox.ToRawInt() == null ? null : (int?)CompareBox.ToRawInt().Value;
|
||||
|
||||
|
||||
return new Cheat(
|
||||
watch,
|
||||
ValueBox.ToRawInt().Value,
|
||||
CompareBox.ToRawInt() == null ? null : (int?)CompareBox.ToRawInt().Value,
|
||||
true,
|
||||
comparisonType
|
||||
);
|
||||
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue