Allow wc6fulls to be added to DB

Minor load/save improvements
This commit is contained in:
Kaphotics 2016-04-21 18:47:51 -07:00
parent 60205cd700
commit 2c523dcd97

View File

@ -245,6 +245,7 @@ private void mainMenuOpen(object sender, EventArgs e)
private void mainMenuSave(object sender, EventArgs e)
{
if (!verifiedPKX()) return;
PK6 pk = preparepkx();
SaveFileDialog sfd = new SaveFileDialog
{
Filter = "PKX File|*.pk6;*.pkx" +
@ -252,7 +253,7 @@ private void mainMenuSave(object sender, EventArgs e)
"|BIN File|*.bin" +
"|All Files|*.*",
DefaultExt = "pk6",
FileName = TB_Nickname.Text + " - " + TB_PID.Text
FileName = Util.CleanFileName(pk.FileName)
};
if (sfd.ShowDialog() != DialogResult.OK) return;
string path = sfd.FileName;
@ -267,7 +268,6 @@ private void mainMenuSave(object sender, EventArgs e)
File.WriteAllBytes(path + ".bak", backupfile);
}
PK6 pk = preparepkx();
if (new[] {".ekx", ".ek6", ".bin"}.Contains(ext))
File.WriteAllBytes(path, pk.EncryptedPartyData);
else if (new[] { ".pkx", ".pk6" }.Contains(ext))
@ -560,6 +560,7 @@ private void openQuick(string path)
try { openFile(input, path, ext); }
catch
{
if (input.Length <= PK6.SIZE_PARTY)
try
{
byte[] blank = (byte[])blankEK6.Clone();
@ -569,7 +570,9 @@ private void openQuick(string path)
openFile(blank, path, ext);
}
catch { openFile(input, path, ext); }
catch { try { openFile(input, path, ext); return; } catch {} }
Util.Error("Unable to load file.");
}
}
}
@ -852,7 +855,7 @@ private void refreshWC6DB()
if (Directory.Exists(WC6DatabasePath))
wc6db.AddRange(from file in Directory.GetFiles(WC6DatabasePath, "*", SearchOption.AllDirectories)
let fi = new FileInfo(file)
where fi.Extension == ".wc6" && fi.Length == WC6.Size
where new[] {".wc6full", ".wc6"}.Contains(fi.Extension) && new[] {WC6.Size, WC6.SizeFull}.Contains((int)fi.Length)
select new WC6(File.ReadAllBytes(file)));
Legal.WC6DB = wc6db.Distinct().ToArray();