simplify more
This commit is contained in:
parent
3cdd36699f
commit
4337328709
|
@ -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
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue