Add backup prompt on first startup

if bak folder already exists, check is skipped.
Closes #531
This commit is contained in:
Kurt 2016-12-04 11:23:10 -08:00
parent a6671b2e63
commit 2cfeeb20d9
4 changed files with 34 additions and 2 deletions

View file

@ -136,6 +136,7 @@ namespace PKHeX
HaX = filename?.IndexOf("hax", StringComparison.Ordinal) >= 0;
bool showChangelog = false;
bool BAKprompt = false;
// Load User Settings
{
unicode = Menu_Unicode.Checked = Properties.Settings.Default.Unicode;
@ -157,6 +158,11 @@ namespace PKHeX
showChangelog = lastrev < currrev;
}
// BAK Prompt
if (!Properties.Settings.Default.BAKPrompt)
BAKprompt = Properties.Settings.Default.BAKPrompt = true;
Properties.Settings.Default.Version = Properties.Resources.ProgramVersion;
Properties.Settings.Default.Save();
}
@ -202,6 +208,10 @@ namespace PKHeX
if (showChangelog)
new About().ShowDialog();
if (BAKprompt && !Directory.Exists(BackupPath))
promptBackup();
#endregion
}
@ -3043,10 +3053,14 @@ namespace PKHeX
File.WriteAllBytes(path, SAV.BAK);
Util.Alert("Saved Backup of current SAV to:", path);
if (Directory.Exists(BackupPath)) return;
if (!Directory.Exists(BackupPath))
promptBackup();
}
private static void promptBackup()
{
if (DialogResult.Yes != Util.Prompt(MessageBoxButtons.YesNo,
$"PKHeX can perform automatic backups if you create a folder with the name \"{BackupPath}\" in the same folder as PKHeX's executable.",
"Would you like to create the backup folder now and save backup of current save?")) return;
"Would you like to create the backup folder now?")) return;
try { Directory.CreateDirectory(BackupPath); Util.Alert("Backup folder created!",
$"If you wish to no longer automatically back up save files, delete the \"{BackupPath}\" folder."); }

View file

@ -82,5 +82,17 @@ namespace PKHeX.Properties {
this["SetUpdatePKM"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool BAKPrompt {
get {
return ((bool)(this["BAKPrompt"]));
}
set {
this["BAKPrompt"] = value;
}
}
}
}

View file

@ -17,5 +17,8 @@
<Setting Name="SetUpdatePKM" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="BAKPrompt" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>

View file

@ -25,6 +25,9 @@
<setting name="SetUpdatePKM" serializeAs="String">
<value>True</value>
</setting>
<setting name="BAKPrompt" serializeAs="String">
<value>False</value>
</setting>
</PKHeX.Properties.Settings>
</userSettings>
</configuration>