public bool OnAccept(string newBaseModsPath, string newSteamUploadsPath)
{
bool modsPathAccepted = false;
// First check that the mods directory is valid (we require it)
var check = form.checkModsFolder(ref newBaseModsPath);
if (check == ModFolderCheckResult.ZIPPED)
{
if (UnzipMods(newBaseModsPath))
{
check = ModFolderCheckResult.VALID;
}
}
if (check == ModFolderCheckResult.VALID)
{
kModsDirectoryPath = JsonHelper.NormalizeSystemPath(newBaseModsPath);
Properties.Settings.Default["ModsDirectory"] = kModsDirectoryPath;
Properties.Settings.Default.Save();
modsPathAccepted = true;
}
else if (Directory.Exists(newBaseModsPath))
{
// If the directory does exist, but doesn't seem to be valid, make it a user choice
if (MessageBox.Show("The chosen directory does not appear to be a valid mods directory. It should contain the uncompressed stonehearth mod. Choose it anyway?", "Possibly invalid mods directory", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
{
kModsDirectoryPath = JsonHelper.NormalizeSystemPath(newBaseModsPath);
Properties.Settings.Default["ModsDirectory"] = kModsDirectoryPath;
modsPathAccepted = true;
}
}
else
{
if (MessageBox.Show("Invalid mods directory chosen. Try again?", "Invalid directory", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.No)
{
modsPathAccepted = false;
}
}
// Check the steam_uploads directory (can be empty if the user is developing in the mods folder)
var check2 = form.checkModsFolder(ref newSteamUploadsPath);
if (check2 == ModFolderCheckResult.ZIPPED)
{
if (UnzipMods(newSteamUploadsPath))
{
check2 = ModFolderCheckResult.VALID;
}
}
if (check2 == ModFolderCheckResult.VALID)
{
kSteamUploadsDirectoryPath = JsonHelper.NormalizeSystemPath(newSteamUploadsPath);
Properties.Settings.Default["SteamUploadsDirectory"] = kSteamUploadsDirectoryPath;
Properties.Settings.Default.Save();
}
else if (Directory.Exists(newSteamUploadsPath))
{
// If the directory does exist, but doesn't seem to be valid, make it a user choice
if (MessageBox.Show("The chosen directory does not appear to be a valid mods directory. Choose it anyway?", "Possibly invalid additional mods directory", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
{
kSteamUploadsDirectoryPath = JsonHelper.NormalizeSystemPath(newSteamUploadsPath);
Properties.Settings.Default["SteamUploadsDirectory"] = kSteamUploadsDirectoryPath;
}
}
else if (newSteamUploadsPath == string.Empty)
{
// Accept cleaning the additional path to not show the mods in there
kSteamUploadsDirectoryPath = JsonHelper.NormalizeSystemPath(newSteamUploadsPath);
Properties.Settings.Default["SteamUploadsDirectory"] = kSteamUploadsDirectoryPath;
}
return(modsPathAccepted);
}