public static void populate() { if (pluginInfo.Names.Count < 1) { RegistryAccess ra = new RegistryAccess(Microsoft.Win32.Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + "PluginSets\\"); if (ra.isOpen) { pluginInfo.Names = new List<string>(ra.getNames()); pluginInfo.Paths = new List<string>(Array.ConvertAll(ra.getValues(),new Converter<object,string>(Convert))); int i = pluginInfo.Names.IndexOf(""); if (i != -1) { pluginInfo.Names.RemoveAt(i); pluginInfo.Paths.RemoveAt(i); } } else { pluginInfo.Names.Add("Default"); pluginInfo.Paths.Add(Prefs.pathPluginsFolder); } ra.CloseReg(); } }
/// <summary> /// Adds a file to the Halo 2 recently used list /// </summary> /// <param name="pos">The position in which to add the fileName (0-9)</param> /// <param name="fileName">The location and name of the file</param> public static void AddRecentFile(int pos, string fileName) { int found = -1; int count = 0; string[] files = new string[10]; // Load recently used files list RegistryAccess ra = new RegistryAccess(Registry.CurrentUser, RegPaths.Halo2RecentFiles); for (int i = 0; i < files.Length; i++) { files[i] = ra.getValue(i.ToString()); if (files[i] != null) count++; if (files[i] == fileName) found = i; } ra.CloseReg(); if (found == -1) found = count; if (found < pos) { int z = found; found = pos; pos = z; } for (int i = found; i > pos; i--) setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2RecentFiles, i.ToString(), files[i-1]); setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2RecentFiles, pos.ToString(), fileName); }
public static void populate() { if (pluginInfo.Names.Count < 1) { RegistryAccess ra = new RegistryAccess(Microsoft.Win32.Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + "PluginSets\\"); if (ra.isOpen) { pluginInfo.Names = new List <string>(ra.getNames()); pluginInfo.Paths = new List <string>(Array.ConvertAll(ra.getValues(), new Converter <object, string>(Convert))); int i = pluginInfo.Names.IndexOf(""); if (i != -1) { pluginInfo.Names.RemoveAt(i); pluginInfo.Paths.RemoveAt(i); } } else { pluginInfo.Names.Add("Default"); pluginInfo.Paths.Add(Prefs.pathPluginsFolder); } ra.CloseReg(); } }
public static string getActivePlugin() { RegistryAccess ra = new RegistryAccess(Microsoft.Win32.Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + "PluginSets\\"); string s = ra.getValue(""); ra.CloseReg(); return s; }
public static string getActivePlugin() { RegistryAccess ra = new RegistryAccess(Microsoft.Win32.Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + "PluginSets\\"); string s = ra.getValue(""); ra.CloseReg(); return(s); }
private void PluginSetSelector_FormClosed(object sender, FormClosedEventArgs e) { // Clear any old plugin listings RegistryAccess.removeKey(Microsoft.Win32.Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + "PluginSets\\"); // We must always have at least a Default plugin if (pluginInfo.Names.Count == 0) { pluginInfo.Names.Add("Default"); pluginInfo.Paths.Add(Prefs.pathPluginsFolder); } // Write all the plugins back to the registry for (int i = 0; i < pluginInfo.Names.Count; i++) { RegistryAccess.setValue(Microsoft.Win32.Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + "PluginSets\\", pluginInfo.Names[i], pluginInfo.Paths[i]); } }
/// <summary> /// Adds a file to the Halo 2 recently used list /// </summary> /// <param name="pos">The position in which to add the fileName (0-9)</param> /// <param name="fileName">The location and name of the file</param> public static void AddRecentFile(int pos, string fileName) { int found = -1; int count = 0; string[] files = new string[10]; // Load recently used files list RegistryAccess ra = new RegistryAccess(Registry.CurrentUser, RegPaths.Halo2RecentFiles); for (int i = 0; i < files.Length; i++) { files[i] = ra.getValue(i.ToString()); if (files[i] != null) { count++; } if (files[i] == fileName) { found = i; } } ra.CloseReg(); if (found == -1) { found = count; } if (found < pos) { int z = found; found = pos; pos = z; } for (int i = found; i > pos; i--) { setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2RecentFiles, i.ToString(), files[i - 1]); } setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2RecentFiles, pos.ToString(), fileName); }
/// <summary> /// Returns true if file was loaded /// </summary> /// <returns></returns> /// <remarks></remarks> public static bool Load() { // check for settings file bool settingsFileExists = File.Exists(FilePath); // Parse the settings file if (settingsFileExists) { XmlDocument doc = new XmlDocument(); try { // load settings into document doc.Load(FilePath); // loop rootnode's nodes, and depending on what node we find // do a different action. foreach (XmlNode node in doc.DocumentElement.ChildNodes) { switch (node.Name) { case XML_NODE_MAINMENUFILE: { pathMainmenu = node.InnerText; break; } case XML_NODE_MPSHAREDFILE: { pathShared = node.InnerText; break; } case XML_NODE_SPSHAREDFILE: { pathSPShared = node.InnerText; break; } case XML_NODE_BITMAPSFILE: { pathBitmaps = node.InnerText; break; } case XML_NODE_MAPSFOLDER: { pathMapsFolder = node.InnerText; break; } case XML_NODE_CLEANMAPSFOLDER: { pathCleanMaps = node.InnerText; break; } case XML_NODE_PLUGINSFOLDER: { pathPluginsFolder = node.InnerText; break; } case XML_NODE_BITMAPSFOLDER: { pathBitmapsFolder = node.InnerText; break; } case XML_NODE_EXTRACTSFOLDER: { pathExtractsFolder = node.InnerText; break; } case XML_NODE_PATCHFOLDER: { pathPatchFolder = node.InnerText; break; } case XML_NODE_USEDEFMAPS: { useDefaultMaps = bool.Parse(node.InnerText); break; } case XML_NODE_USEREGISTRY: { useRegistryEntries = bool.Parse(node.InnerText); break; } case XML_NODE_CHECKUPDATE: { checkUpdate = (updateFrequency)Enum.Parse(typeof(updateFrequency), node.InnerText); break; } case XML_NODE_LASTUPDATECHECK: { lastCheck = DateTime.Parse(node.InnerText); break; } case XML_NODE_RECENTMAPSLIST: { foreach (XmlNode recentMapNode in node) { RecentFile rf = new RecentFile(); rf.Path = recentMapNode.InnerText; RecentOpenedMaps.Add(rf); } break; } case XML_NODE_QUICKACCESSTAGSLIST: { foreach (XmlNode quickAccessNode in node) { QuickAccessTagType quickAcess = new QuickAccessTagType(); quickAcess.TagType = quickAccessNode.Attributes[XML_ATTR_TAGTYPENAME].InnerText; foreach (XmlNode tagPathNode in quickAccessNode) { //switch (tagPathNode.Name) //{ // case XML_NODE_QUICKACCESSTAGPATH: // { quickAcess.TagPaths.Add(tagPathNode.InnerText); // break; // } //} } QuickAccessTagTypes.Add(quickAcess); } break; } case XML_NODE_USERPLUGINMASKS: { foreach (XmlNode pluginMaskNode in node) { CustomPluginMask mask = new CustomPluginMask(); mask.Name = pluginMaskNode.Attributes[XML_ATTR_PLUGINMASKNAME].InnerText; foreach (XmlNode maskNode in pluginMaskNode) { //switch (maskNode.Name) //{ // case XML_NODE_PLUGINMASK_VISIBLETAGTYPE: // { mask.VisibleTagTypes.Add( maskNode.Attributes[XML_ATTR_TAGTYPENAME].InnerText); // break; // } //} } CustomPluginMasks.Add(mask); } break; } } } } catch { settingsFileExists = false; } } // If useRegistryEntires is set to false & the settings file exists, then the // user doesn't wish to use the registry, so we are good to exit if (settingsFileExists && !useRegistryEntries) return true; // If enabled, load the settings from the registry if (useRegistryEntries) { // Used for accessing the registry RegistryAccess Reg; try { // UseSettingsFile contains a list of Entity directories that wish to use the settings file instead of // the registry. Check if our path is in the list for using the settings file. Reg = new RegistryAccess(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + @"Entity\UseSettingsFile\"); // If Entry exists in list, use settings file if it exists if (Reg.getValue(Globals.Global.StartupPath) != null) return settingsFileExists; // Try to open the settings for Halo 2, if it doesn't exist, Reg.isOpen == false Reg = new RegistryAccess(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths); if (Reg.isOpen) { string tempS = string.Empty; #region General Halo2 paths in registry tempS = Reg.getValue(RegistryAccess.RegNames.MainMenuFile); if (tempS != null) Prefs.pathMainmenu = tempS; tempS = Reg.getValue(RegistryAccess.RegNames.SharedFile); if (tempS != null) Prefs.pathShared = tempS; tempS = Reg.getValue(RegistryAccess.RegNames.SinglePlayerSharedFile); if (tempS != null) Prefs.pathSPShared = tempS; tempS = Reg.getValue(RegistryAccess.RegNames.BitmapsFile); if (tempS != null) Prefs.pathBitmaps = tempS; tempS = Reg.getValue(RegistryAccess.RegNames.MapsPath); if (tempS != null) Prefs.pathMapsFolder = tempS; tempS = Reg.getValue(RegistryAccess.RegNames.FontsPath); if (tempS != null) Prefs.pathFontsFolder = tempS; tempS = Reg.getValue(RegistryAccess.RegNames.BitmapsPath); if (tempS != null) Prefs.pathBitmapsFolder = tempS; tempS = Reg.getValue(RegistryAccess.RegNames.ExtractsPath); if (tempS != null) Prefs.pathExtractsFolder = tempS; tempS = Reg.getValue(RegistryAccess.RegNames.PluginsPath); if (tempS != null) Prefs.pathPluginsFolder = tempS; tempS = Reg.getValue(RegistryAccess.RegNames.CleanMapsPath); if (tempS != null) Prefs.pathCleanMaps = tempS; #endregion #region Entity specific paths & settings Reg = new RegistryAccess(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + @"Entity\"); tempS = Reg.getValue("PatchFolder"); if (tempS != null) Prefs.pathPatchFolder = tempS; tempS = Reg.getValue("UseDefaultMaps"); if (tempS != null) Prefs.useDefaultMaps = bool.Parse(tempS); Prefs.useRegistryEntries = true; #region Automatic Update tempS = Reg.getValue("lastCheck"); if (tempS != null) try { Prefs.lastCheck = DateTime.Parse(tempS); } catch { Prefs.lastCheck = DateTime.MinValue; } tempS = Reg.getValue("checkUpdate"); try { Prefs.updateFrequency updateFreq = (Prefs.updateFrequency)Enum.Parse(typeof(Prefs.updateFrequency), tempS); Prefs.checkUpdate = updateFreq; } catch { Prefs.checkUpdate = Prefs.updateFrequency.Daily; } #endregion; // Check for recent files in the registry Reg = new RegistryAccess(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2RecentFiles); if (Reg.isOpen) { for (int count = Prefs.MaxRecentFiles - 1; count >= 0; count--) { tempS = Reg.getValue(count.ToString()); if (tempS != null) { RecentFile rf = new RecentFile(); rf.Path = tempS; RecentOpenedMaps.Insert(0, rf); } } } #endregion #region Load Quick Access Tags if (Prefs.useRegistryEntries) { try { RegistryAccess ra = new RegistryAccess(Microsoft.Win32.Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + @"Entity\ME\Tags\"); string[] tags = ra.getKeys(); foreach (string tagType in tags) { QuickAccessTagType qatt = new QuickAccessTagType(); qatt.TagType = tagType; ra.setKey(Microsoft.Win32.Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + @"Entity\ME\Tags\" + tagType + @"\"); foreach (string tagName in ra.getNames()) { if (ra.getValue(tagName).ToLower() == "true") qatt.TagPaths.Add(tagName); } if (qatt.TagPaths.Count > 0) QuickAccessTagTypes.Add(qatt); } } catch { // Ignore errors regarding to Quick keys } } #endregion Reg.CloseReg(); return true; } } catch (Exception e) { Global.ShowErrorMsg("Prefs Load Exception", e); return settingsFileExists; } } return false; }
/// <summary> /// Saves this instance. /// </summary> /// <remarks></remarks> public static void Save() { #region Settings File XmlTextWriter writer = new XmlTextWriter(FilePath, Encoding.ASCII); writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); writer.WriteStartElement("entityUserSettings"); writer.WriteElementString(XML_NODE_MAINMENUFILE, pathMainmenu); writer.WriteElementString(XML_NODE_MPSHAREDFILE, pathShared); writer.WriteElementString(XML_NODE_SPSHAREDFILE, pathSPShared); writer.WriteElementString(XML_NODE_BITMAPSFILE, pathBitmaps); writer.WriteElementString(XML_NODE_MAPSFOLDER, pathMapsFolder); writer.WriteElementString(XML_NODE_FONTSFOLDER, pathFontsFolder); writer.WriteElementString(XML_NODE_CLEANMAPSFOLDER, pathCleanMaps); writer.WriteElementString(XML_NODE_PLUGINSFOLDER, pathPluginsFolder); writer.WriteElementString(XML_NODE_BITMAPSFOLDER, pathBitmapsFolder); writer.WriteElementString(XML_NODE_EXTRACTSFOLDER, pathExtractsFolder); writer.WriteElementString(XML_NODE_PATCHFOLDER, pathPatchFolder); writer.WriteElementString(XML_NODE_USEDEFMAPS, useDefaultMaps.ToString()); writer.WriteElementString(XML_NODE_USEREGISTRY, useRegistryEntries.ToString()); writer.WriteElementString(XML_NODE_CHECKUPDATE, checkUpdate.ToString()); writer.WriteElementString(XML_NODE_LASTUPDATECHECK, lastCheck.ToString()); writer.WriteStartElement(XML_NODE_RECENTMAPSLIST); // Only keep a list of the last 10 used maps (Entity only uses 4) for (int i = 0; i < Math.Min(RecentOpenedMaps.Count, 10); i++) { writer.WriteElementString(XML_NODE_RECENTMAP, RecentOpenedMaps[i].Path); } writer.WriteEndElement(); writer.WriteStartElement(XML_NODE_QUICKACCESSTAGSLIST); for (int i = 0; i < QuickAccessTagTypes.Count; i++) { writer.WriteStartElement(XML_NODE_QUICKACCESSTAG); writer.WriteAttributeString(XML_ATTR_TAGTYPENAME, QuickAccessTagTypes[i].TagType); foreach (string tagPath in QuickAccessTagTypes[i].TagPaths) { writer.WriteElementString(XML_NODE_QUICKACCESSTAGPATH, tagPath); } writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteStartElement(XML_NODE_USERPLUGINMASKS); foreach (CustomPluginMask mask in CustomPluginMasks) { writer.WriteStartElement(XML_NODE_PLUGINMASK); writer.WriteAttributeString(XML_ATTR_PLUGINMASKNAME, mask.Name); foreach (string tagType in mask.VisibleTagTypes) { writer.WriteStartElement(XML_NODE_PLUGINMASK_VISIBLETAGTYPE); writer.WriteAttributeString(XML_ATTR_TAGTYPENAME, tagType); writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndElement(); writer.Close(); #endregion #region Registry Entries if (useRegistryEntries) { //RegistryAccess.removeValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + @"Entity\UseSettingsFile\", Application.StartupPath); RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, "", ""); // General Halo2 program settings RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, RegistryAccess.RegNames.MainMenuFile, Prefs.pathMainmenu); RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, RegistryAccess.RegNames.SharedFile, Prefs.pathShared); RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, RegistryAccess.RegNames.SinglePlayerSharedFile, Prefs.pathSPShared); RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, RegistryAccess.RegNames.BitmapsFile, Prefs.pathBitmaps); RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, RegistryAccess.RegNames.MapsPath, Prefs.pathMapsFolder); RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, RegistryAccess.RegNames.FontsPath, Prefs.pathFontsFolder); RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, RegistryAccess.RegNames.CleanMapsPath, Prefs.pathCleanMaps); RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, RegistryAccess.RegNames.PluginsPath, Prefs.pathPluginsFolder); RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, RegistryAccess.RegNames.BitmapsPath, Prefs.pathBitmapsFolder); RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths, RegistryAccess.RegNames.ExtractsPath, Prefs.pathExtractsFolder); // Entity specific settings RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + @"Entity\", "PatchFolder", Prefs.pathPatchFolder); RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + @"Entity\", "UseDefaultMaps", Prefs.useDefaultMaps.ToString()); RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + @"Entity\", "checkUpdate", Prefs.checkUpdate.ToString()); RegistryAccess.setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + @"Entity\", "lastCheck", Prefs.lastCheck.ToString()); // Save recently used maps list in the registry (max 10) for (int count = 0; count < Math.Min(RecentOpenedMaps.Count, 10); count++) { RegistryAccess.setValue( Registry.CurrentUser, RegistryAccess.RegPaths.Halo2RecentFiles, count.ToString(), RecentOpenedMaps[count].Path); } } #endregion }
/// <summary> /// Returns true if file was loaded /// </summary> /// <returns></returns> /// <remarks></remarks> public static bool Load() { // check for settings file bool settingsFileExists = File.Exists(FilePath); // Parse the settings file if (settingsFileExists) { XmlDocument doc = new XmlDocument(); try { // load settings into document doc.Load(FilePath); // loop rootnode's nodes, and depending on what node we find // do a different action. foreach (XmlNode node in doc.DocumentElement.ChildNodes) { switch (node.Name) { case XML_NODE_MAINMENUFILE: { pathMainmenu = node.InnerText; break; } case XML_NODE_MPSHAREDFILE: { pathShared = node.InnerText; break; } case XML_NODE_SPSHAREDFILE: { pathSPShared = node.InnerText; break; } case XML_NODE_BITMAPSFILE: { pathBitmaps = node.InnerText; break; } case XML_NODE_MAPSFOLDER: { pathMapsFolder = node.InnerText; break; } case XML_NODE_CLEANMAPSFOLDER: { pathCleanMaps = node.InnerText; break; } case XML_NODE_PLUGINSFOLDER: { pathPluginsFolder = node.InnerText; break; } case XML_NODE_BITMAPSFOLDER: { pathBitmapsFolder = node.InnerText; break; } case XML_NODE_EXTRACTSFOLDER: { pathExtractsFolder = node.InnerText; break; } case XML_NODE_PATCHFOLDER: { pathPatchFolder = node.InnerText; break; } case XML_NODE_USEDEFMAPS: { useDefaultMaps = bool.Parse(node.InnerText); break; } case XML_NODE_USEREGISTRY: { useRegistryEntries = bool.Parse(node.InnerText); break; } case XML_NODE_CHECKUPDATE: { checkUpdate = (updateFrequency)Enum.Parse(typeof(updateFrequency), node.InnerText); break; } case XML_NODE_LASTUPDATECHECK: { lastCheck = DateTime.Parse(node.InnerText); break; } case XML_NODE_RECENTMAPSLIST: { foreach (XmlNode recentMapNode in node) { RecentFile rf = new RecentFile(); rf.Path = recentMapNode.InnerText; RecentOpenedMaps.Add(rf); } break; } case XML_NODE_QUICKACCESSTAGSLIST: { foreach (XmlNode quickAccessNode in node) { QuickAccessTagType quickAcess = new QuickAccessTagType(); quickAcess.TagType = quickAccessNode.Attributes[XML_ATTR_TAGTYPENAME].InnerText; foreach (XmlNode tagPathNode in quickAccessNode) { //switch (tagPathNode.Name) //{ // case XML_NODE_QUICKACCESSTAGPATH: // { quickAcess.TagPaths.Add(tagPathNode.InnerText); // break; // } //} } QuickAccessTagTypes.Add(quickAcess); } break; } case XML_NODE_USERPLUGINMASKS: { foreach (XmlNode pluginMaskNode in node) { CustomPluginMask mask = new CustomPluginMask(); mask.Name = pluginMaskNode.Attributes[XML_ATTR_PLUGINMASKNAME].InnerText; foreach (XmlNode maskNode in pluginMaskNode) { //switch (maskNode.Name) //{ // case XML_NODE_PLUGINMASK_VISIBLETAGTYPE: // { mask.VisibleTagTypes.Add( maskNode.Attributes[XML_ATTR_TAGTYPENAME].InnerText); // break; // } //} } CustomPluginMasks.Add(mask); } break; } } } } catch { settingsFileExists = false; } } // If useRegistryEntires is set to false & the settings file exists, then the // user doesn't wish to use the registry, so we are good to exit if (settingsFileExists && !useRegistryEntries) { return(true); } // If enabled, load the settings from the registry if (useRegistryEntries) { // Used for accessing the registry RegistryAccess Reg; try { // UseSettingsFile contains a list of Entity directories that wish to use the settings file instead of // the registry. Check if our path is in the list for using the settings file. Reg = new RegistryAccess(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + @"Entity\UseSettingsFile\"); // If Entry exists in list, use settings file if it exists if (Reg.getValue(Globals.Global.StartupPath) != null) { return(settingsFileExists); } // Try to open the settings for Halo 2, if it doesn't exist, Reg.isOpen == false Reg = new RegistryAccess(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2Paths); if (Reg.isOpen) { string tempS = string.Empty; #region General Halo2 paths in registry tempS = Reg.getValue(RegistryAccess.RegNames.MainMenuFile); if (tempS != null) { Prefs.pathMainmenu = tempS; } tempS = Reg.getValue(RegistryAccess.RegNames.SharedFile); if (tempS != null) { Prefs.pathShared = tempS; } tempS = Reg.getValue(RegistryAccess.RegNames.SinglePlayerSharedFile); if (tempS != null) { Prefs.pathSPShared = tempS; } tempS = Reg.getValue(RegistryAccess.RegNames.BitmapsFile); if (tempS != null) { Prefs.pathBitmaps = tempS; } tempS = Reg.getValue(RegistryAccess.RegNames.MapsPath); if (tempS != null) { Prefs.pathMapsFolder = tempS; } tempS = Reg.getValue(RegistryAccess.RegNames.FontsPath); if (tempS != null) { Prefs.pathFontsFolder = tempS; } tempS = Reg.getValue(RegistryAccess.RegNames.BitmapsPath); if (tempS != null) { Prefs.pathBitmapsFolder = tempS; } tempS = Reg.getValue(RegistryAccess.RegNames.ExtractsPath); if (tempS != null) { Prefs.pathExtractsFolder = tempS; } tempS = Reg.getValue(RegistryAccess.RegNames.PluginsPath); if (tempS != null) { Prefs.pathPluginsFolder = tempS; } tempS = Reg.getValue(RegistryAccess.RegNames.CleanMapsPath); if (tempS != null) { Prefs.pathCleanMaps = tempS; } #endregion #region Entity specific paths & settings Reg = new RegistryAccess(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + @"Entity\"); tempS = Reg.getValue("PatchFolder"); if (tempS != null) { Prefs.pathPatchFolder = tempS; } tempS = Reg.getValue("UseDefaultMaps"); if (tempS != null) { Prefs.useDefaultMaps = bool.Parse(tempS); } Prefs.useRegistryEntries = true; #region Automatic Update tempS = Reg.getValue("lastCheck"); if (tempS != null) { try { Prefs.lastCheck = DateTime.Parse(tempS); } catch { Prefs.lastCheck = DateTime.MinValue; } } tempS = Reg.getValue("checkUpdate"); try { Prefs.updateFrequency updateFreq = (Prefs.updateFrequency)Enum.Parse(typeof(Prefs.updateFrequency), tempS); Prefs.checkUpdate = updateFreq; } catch { Prefs.checkUpdate = Prefs.updateFrequency.Daily; } #endregion ; // Check for recent files in the registry Reg = new RegistryAccess(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2RecentFiles); if (Reg.isOpen) { for (int count = Prefs.MaxRecentFiles - 1; count >= 0; count--) { tempS = Reg.getValue(count.ToString()); if (tempS != null) { RecentFile rf = new RecentFile(); rf.Path = tempS; RecentOpenedMaps.Insert(0, rf); } } } #endregion #region Load Quick Access Tags if (Prefs.useRegistryEntries) { try { RegistryAccess ra = new RegistryAccess(Microsoft.Win32.Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + @"Entity\ME\Tags\"); string[] tags = ra.getKeys(); foreach (string tagType in tags) { QuickAccessTagType qatt = new QuickAccessTagType(); qatt.TagType = tagType; ra.setKey(Microsoft.Win32.Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + @"Entity\ME\Tags\" + tagType + @"\"); foreach (string tagName in ra.getNames()) { if (ra.getValue(tagName).ToLower() == "true") { qatt.TagPaths.Add(tagName); } } if (qatt.TagPaths.Count > 0) { QuickAccessTagTypes.Add(qatt); } } } catch { // Ignore errors regarding to Quick keys } } #endregion Reg.CloseReg(); return(true); } } catch (Exception e) { Global.ShowErrorMsg("Prefs Load Exception", e); return(settingsFileExists); } } return(false); }