mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-16 21:38:40 +00:00
Add dialog message for empty/FF save files
Users incapable of saving in-game and using save states instead, or emulators not flushing save data on in-game save.
This commit is contained in:
parent
a571c2a3cb
commit
a93a626dad
2 changed files with 20 additions and 3 deletions
|
@ -48,6 +48,8 @@ public static class MessageStrings
|
|||
#region Main Window
|
||||
|
||||
public static string MsgFileLoad { get; set; } = "File Loaded:";
|
||||
public static string MsgFileLoadAllZero { get; set; } = "File is uninitialized (all zero). Please ensure it was properly saved.";
|
||||
public static string MsgFileLoadAllFFFF { get; set; } = "File is uninitialized (all 0xFF). Please ensure it was properly saved.";
|
||||
public static string MsgFileLoadFail { get; set; } = "Unable to load file.";
|
||||
public static string MsgFileLoadFailAuto { get; set; } = "An error occurred while attempting to auto-load your save file.";
|
||||
public static string MsgFileLoadFailAutoAdvise { get; set; } = "It is advised to manually remove bad filenames from the folder.";
|
||||
|
|
|
@ -579,13 +579,28 @@ public partial class Main : Form
|
|||
if (obj != null && LoadFile(obj, path))
|
||||
return;
|
||||
|
||||
bool isSAV = WinFormsUtil.IsFileExtensionSAV(path);
|
||||
var msg = isSAV ? MsgFileUnsupported : MsgPKMUnsupported;
|
||||
WinFormsUtil.Error(msg,
|
||||
WinFormsUtil.Error(GetHintInvalidFile(input, path),
|
||||
$"{MsgFileLoad}{Environment.NewLine}{path}",
|
||||
$"{string.Format(MsgFileSize, input.Length)}{Environment.NewLine}{input.Length} bytes (0x{input.Length:X4})");
|
||||
}
|
||||
|
||||
private static string GetHintInvalidFile(ReadOnlySpan<byte> input, string path)
|
||||
{
|
||||
bool isSAV = WinFormsUtil.IsFileExtensionSAV(path);
|
||||
if (!isSAV)
|
||||
return MsgPKMUnsupported;
|
||||
|
||||
// Include a hint for the user to check if the file is all 00 or all FF
|
||||
bool allZero = !input.ContainsAnyExcept<byte>(0x00);
|
||||
if (allZero)
|
||||
return MsgFileLoadAllZero;
|
||||
bool allFF = !input.ContainsAnyExcept<byte>(0xFF);
|
||||
if (allFF)
|
||||
return MsgFileLoadAllFFFF;
|
||||
|
||||
return MsgFileUnsupported;
|
||||
}
|
||||
|
||||
private bool LoadFile(object? input, string path)
|
||||
{
|
||||
if (input == null)
|
||||
|
|
Loading…
Add table
Reference in a new issue