simplify more

This commit is contained in:
adelikat 2020-02-29 13:48:23 -06:00
parent 3cdd36699f
commit 4337328709
3 changed files with 10 additions and 7 deletions

View File

@ -12,6 +12,7 @@ namespace BizHawk.Client.Common.cheats
int? Compare { get; }
WatchSize Size { get; }
bool IsValid { get; }
string Error { get; }
}
public class DecodeResult : IDecodeResult
@ -21,15 +22,22 @@ namespace BizHawk.Client.Common.cheats
public int? Compare { get; internal set; }
public WatchSize Size { get; internal set; }
public bool IsValid => true;
public string Error => "";
}
public class InvalidResult : IDecodeResult
{
public InvalidResult(string error)
{
Error = error;
}
public int Address => int.MaxValue;
public int Value => int.MaxValue;
public int? Compare => null;
public WatchSize Size => WatchSize.Separator;
public bool IsValid => false;
public string Error { get; }
}
public static class DecodeResultExtensions

View File

@ -34,7 +34,7 @@ namespace BizHawk.Client.Common.cheats
if (code.Length != 6 && code.Length != 8)
{
return new InvalidResult();
return new InvalidResult("Game Genie codes need to be six or eight characters in length.");
}
var result = new DecodeResult { Size = WatchSize.Byte };

View File

@ -279,11 +279,6 @@ namespace BizHawk.Client.EmuHawk
private void Nes(string code)
{
if (code.Length != 6 && code.Length != 8)
{
InputError("Game Genie codes need to be six or eight characters in length.");
}
var description = Description(code);
var result = NesGameGenieDecoder.Decode(code);
if (result.IsValid)
@ -292,7 +287,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
InputError("Invalid Game Genie code");
InputError(result.Error);
}
}