public void LoadSettings()
{
string strRegMod = (string)Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\NexusModManager\" + GameModeDescriptor.ModeId + " ", "Mods", null);
string strRegInst = (string)Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\NexusModManager\" + GameModeDescriptor.ModeId + " ", "InstallInfo", null);
if (!String.IsNullOrWhiteSpace(strRegMod))
if (Path.IsPathRooted(strRegMod) && !Directory.Exists(Path.GetPathRoot(strRegMod)))
strRegMod = null;
if (!String.IsNullOrWhiteSpace(strRegInst))
if (Path.IsPathRooted(strRegInst) && !Directory.Exists(Path.GetPathRoot(strRegInst)))
strRegInst = null;
string strInstallationPath = EnvironmentInfo.Settings.InstallationPaths[GameModeDescriptor.ModeId];
string strDirectory = null;
string strRandomGameKey = String.Empty;
bool booRetrieved = false;
if (!String.IsNullOrWhiteSpace(strRegMod))
ModDirectory = strRegMod;
else if (EnvironmentInfo.Settings.ModFolder.ContainsKey(GameModeDescriptor.ModeId))
ModDirectory = EnvironmentInfo.Settings.ModFolder[GameModeDescriptor.ModeId];
else if (EnvironmentInfo.Settings.ModFolder.Keys.Count > 0)
{
strRandomGameKey = EnvironmentInfo.Settings.ModFolder.FirstOrDefault().Key;
strRegMod = EnvironmentInfo.Settings.ModFolder[strRandomGameKey];
if (!String.IsNullOrEmpty(strRegMod))
{
if (!String.IsNullOrEmpty(strRandomGameKey))
{
if (strRegMod.IndexOf(strRandomGameKey) >= 0)
ModDirectory = strRegMod.Replace(strRandomGameKey, GameModeDescriptor.ModeId);
else
ModDirectory = strRegMod.Replace(Path.GetFileName(strRegMod), GameModeDescriptor.ModeId + Path.DirectorySeparatorChar + Path.GetFileName(strRegMod));
}
}
}
if (!String.IsNullOrWhiteSpace(ModDirectory))
if (Path.IsPathRooted(ModDirectory) && !Directory.Exists(Path.GetPathRoot(ModDirectory)))
ModDirectory = String.Empty;
if (string.IsNullOrEmpty(ModDirectory))
{
if (EnvironmentInfo.Settings.DelayedSettings.ContainsKey(GameModeDescriptor.ModeId))
booRetrieved = EnvironmentInfo.Settings.DelayedSettings[GameModeDescriptor.ModeId].TryGetValue(String.Format("ModFolder~{0}", GameModeDescriptor.ModeId), out strDirectory);
if (!booRetrieved)
EnvironmentInfo.Settings.ModFolder.TryGetValue(GameModeDescriptor.ModeId, out strDirectory);
if (String.IsNullOrEmpty(strDirectory))
{
string strDefault = Path.Combine(Path.Combine(Path.Combine(Path.Combine(Path.GetPathRoot(strInstallationPath), "Games"), EnvironmentInfo.Settings.ModManagerName), GameModeDescriptor.ModeId), "Mods");
strDirectory = strDefault;
}
ModDirectory = strDirectory;
}
if (!String.IsNullOrWhiteSpace(strRegInst))
InstallInfoDirectory = strRegInst;
else if (EnvironmentInfo.Settings.InstallInfoFolder.ContainsKey(GameModeDescriptor.ModeId))
InstallInfoDirectory = EnvironmentInfo.Settings.InstallInfoFolder[GameModeDescriptor.ModeId];
else if (EnvironmentInfo.Settings.ModFolder.Keys.Count > 0)
{
if (String.IsNullOrEmpty(strRandomGameKey))
strRandomGameKey = EnvironmentInfo.Settings.InstallInfoFolder.FirstOrDefault().Key;
strRegInst = EnvironmentInfo.Settings.InstallInfoFolder[strRandomGameKey];
if (!String.IsNullOrEmpty(strRegInst))
{
if (!String.IsNullOrEmpty(strRandomGameKey))
{
if (strRegInst.IndexOf(strRandomGameKey) >= 0)
InstallInfoDirectory = strRegInst.Replace(strRandomGameKey, GameModeDescriptor.ModeId);
else
InstallInfoDirectory = strRegInst.Replace(Path.GetFileName(strRegInst), GameModeDescriptor.ModeId + Path.DirectorySeparatorChar + Path.GetFileName(strRegInst));
}
}
}
if (!String.IsNullOrWhiteSpace(InstallInfoDirectory))
if (Path.IsPathRooted(InstallInfoDirectory) && !Directory.Exists(Path.GetPathRoot(InstallInfoDirectory)))
InstallInfoDirectory = String.Empty;
if (String.IsNullOrEmpty(InstallInfoDirectory))
{
strDirectory = null;
booRetrieved = false;
if (EnvironmentInfo.Settings.DelayedSettings.ContainsKey(GameModeDescriptor.ModeId))
booRetrieved = EnvironmentInfo.Settings.DelayedSettings[GameModeDescriptor.ModeId].TryGetValue(String.Format("InstallInfoFolder~{0}", GameModeDescriptor.ModeId), out strDirectory);
if (!booRetrieved)
EnvironmentInfo.Settings.InstallInfoFolder.TryGetValue(GameModeDescriptor.ModeId, out strDirectory);
if (String.IsNullOrEmpty(strDirectory))
{
string strDefault = Path.Combine(Path.Combine(Path.Combine(Path.Combine(Path.GetPathRoot(strInstallationPath), "Games"), EnvironmentInfo.Settings.ModManagerName), GameModeDescriptor.ModeId), "Install Info");
strDirectory = strDefault;
}
InstallInfoDirectory = strDirectory;
}
if (m_booRequiredTool)
{
if (EnvironmentInfo.Settings.ToolFolder.ContainsKey(GameModeDescriptor.ModeId))
ToolDirectory = EnvironmentInfo.Settings.ToolFolder[GameModeDescriptor.ModeId];
if (string.IsNullOrEmpty(ToolDirectory))
{
strDirectory = null;
booRetrieved = false;
foreach (string ToolFile in GameModeDescriptor.OrderedRequiredToolFileNames)
if (File.Exists(ToolFile))
booRetrieved = true;
else
{
booRetrieved = false;
break;
}
if (booRetrieved)
strDirectory = Path.GetDirectoryName(GameModeDescriptor.OrderedRequiredToolFileNames[0]);
if (!String.IsNullOrEmpty(strDirectory))
ToolDirectory = strDirectory;
}
}
ValidateSettings();
}