private void chooseModDirectory()
{
var dialog = new FolderSelectDialog()
{
DirectoryPath = kModsDirectoryPath ?? Environment.CurrentDirectory,
Title = "Stonehearth Mods Root Directory"
};
DialogResult result = DialogResult.Abort;
do
{
result = dialog.ShowDialog();
if (result == DialogResult.OK)
{
string newPath = dialog.DirectoryPath;
if (this.checkModsFolder(ref newPath))
{
kModsDirectoryPath = JsonHelper.NormalizeSystemPath(newPath);
Properties.Settings.Default["ModsDirectory"] = kModsDirectoryPath;
Properties.Settings.Default.Save();
return;
}
else if (Directory.Exists(newPath))
{
// If the directory does exist, but doesn't seem to be valid, make it a user chocie
if (MessageBox.Show("The chosen directory does not appear to be a valid mods directory. Choose it anyway?", "Possibly invalid mods directory", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
return;
}
else
{
if (MessageBox.Show("Invalid mods directory chosen. Try again?", "Invalid directory", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.No)
return;
}
}
else
{
if (MessageBox.Show("No mods directory selected. Try again?", "No directory selected.", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
return;
}
}
while (true); // repeat until we've got a proper directory or the user aborts
}