From 5ae027c9349e4a62bf3d2d07a5d94a59d81108dd Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 28 Jan 2017 10:50:36 -0800 Subject: [PATCH] Misc user protections trycatch SD card readonly check Remove All medals now clears gen7 flags (for improper transfers) --- PKHeX.WinForms/MainWindow/Main.cs | 6 +++++- .../Subforms/PKM Editors/SuperTrainingEditor.cs | 12 +++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/PKHeX.WinForms/MainWindow/Main.cs b/PKHeX.WinForms/MainWindow/Main.cs index 6642f9096..fe998c290 100644 --- a/PKHeX.WinForms/MainWindow/Main.cs +++ b/PKHeX.WinForms/MainWindow/Main.cs @@ -1206,7 +1206,11 @@ namespace PKHeX.WinForms if (!string.IsNullOrWhiteSpace(path)) // Actual Save { // Check location write protection - if ((new DirectoryInfo(path).Attributes & FileAttributes.ReadOnly) != 0) + bool locked = true; + try { locked = (new DirectoryInfo(path).Attributes & FileAttributes.ReadOnly) != 0; } + catch { } + + if (locked) WinFormsUtil.Alert("Save file's location is write protected:\n" + path, "If the path is a removable disk (SD card), please ensure the write protection switch is not set."); } diff --git a/PKHeX.WinForms/Subforms/PKM Editors/SuperTrainingEditor.cs b/PKHeX.WinForms/Subforms/PKM Editors/SuperTrainingEditor.cs index 9e2bf6bc3..838713c15 100644 --- a/PKHeX.WinForms/Subforms/PKM Editors/SuperTrainingEditor.cs +++ b/PKHeX.WinForms/Subforms/PKM Editors/SuperTrainingEditor.cs @@ -121,6 +121,11 @@ namespace PKHeX.WinForms pk6.TrainingBag = CB_Bag.SelectedIndex; pk6.TrainingBagHits = (int)NUD_BagHits.Value; } + else // clear flags if manually cleared + { + pkm.SecretSuperTrainingUnlocked &= CHK_SecretUnlocked.Checked; + pkm.SecretSuperTrainingComplete &= CHK_SecretComplete.Checked; + } Main.pkm = pkm; } @@ -152,11 +157,8 @@ namespace PKHeX.WinForms } private void B_None_Click(object sender, EventArgs e) { - if (pkm is PK6) - { - CHK_SecretUnlocked.Checked = false; - CHK_SecretComplete.Checked = false; - } + CHK_SecretUnlocked.Checked = false; + CHK_SecretComplete.Checked = false; foreach (var c in TLP_SuperTrain.Controls.OfType()) c.Checked = false; foreach (var c in TLP_DistSuperTrain.Controls.OfType())