/// <summary> /// Registers the specified mod, tagging it with the given info. /// </summary> /// <param name="p_strModPath">The path to the mod to register.</param> /// <param name="p_mifTagInfo">The info with which to tag the mod.</param> /// <returns>The mod that was registered, or <c>null</c> if the mod at the given path /// could not be registered.</returns> public IMod RegisterMod(string p_strModPath, IModInfo p_mifTagInfo, IEnvironmentInfo p_eiEnvironmentInfo) { Int32 intExistingIndex = -1; IMod modMod = null; for (intExistingIndex = 0; intExistingIndex < m_oclRegisteredMods.Count; intExistingIndex++) { if (p_strModPath.Equals(m_oclRegisteredMods[intExistingIndex].Filename, StringComparison.OrdinalIgnoreCase)) { break; } } modMod = CreateMod(p_strModPath, string.Empty, GameMode, p_eiEnvironmentInfo); if (p_mifTagInfo != null) { modMod.UpdateInfo(p_mifTagInfo, false); } if (modMod == null) { return(null); } if (intExistingIndex < m_oclRegisteredMods.Count) { m_oclRegisteredMods[intExistingIndex] = modMod; } else { m_oclRegisteredMods.Add(modMod); } return(modMod); }
/// <summary> /// Loads the categories. /// </summary> /// <param name="p_strDefaultCategories">The string containing the default categories.</param> public void LoadCategories(string p_strDefaultCategories) { if (!File.Exists(CategoryFilePath)) { m_tslCategories.Add(new ModCategory()); if (!String.IsNullOrEmpty(p_strDefaultCategories)) { LoadCategories(XDocument.Parse(p_strDefaultCategories)); } SaveCategories(); return; } else { LoadCategories(XDocument.Load(CategoryFilePath)); } }
/// <summary> /// Adds a task to the monitor. /// </summary> /// <param name="p_tskTask">The task to monitor.</param> public void AddActivity(AddModTask p_tskTask) { p_tskTask.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(Task_PropertyChanged); m_oclTasks.Add(p_tskTask); if (p_tskTask.IsActive) { m_setActiveTasks.Add(p_tskTask); } }
/// <summary> /// Adds a profile to the profile manager. /// </summary> /// <remarks> /// Adding a profile to the profile manager assigns it a unique key. /// </remarks> /// <param name="p_mctCategory">The <see cref="IModCategory"/> being added.</param> public IModProfile AddProfile(byte[] p_bteModList, byte[] p_bteIniList, byte[] p_bteLoadOrder, string p_strGameModeId, Int32 p_intModCount, string[] p_strOptionalFiles) { string strId = GetNextId; int intNewProfile = 1; if (m_tslProfiles.Count > 0) { List <IModProfile> lstNewProfile = m_tslProfiles.Where(x => x.Name.IndexOf("Profile") == 0).ToList(); if ((lstNewProfile != null) && (lstNewProfile.Count > 0)) { List <Int32> lstID = new List <Int32>(); foreach (IModProfile imp in lstNewProfile) { string n = imp.Name.Substring(8); int i = 0; if (int.TryParse(n, out i)) { lstID.Add(Convert.ToInt32(i)); } } if (lstID.Count > 0) { intNewProfile = Enumerable.Range(1, lstID.Max() + 1).Except(lstID).Min(); } } } ModProfile mprModProfile = new ModProfile(strId, "Profile " + intNewProfile.ToString(), p_strGameModeId, (p_intModCount < 0 ? VirtualModActivator.ModCount : p_intModCount)); mprModProfile.IsDefault = true; SaveProfile(mprModProfile, p_bteModList, p_bteIniList, p_bteLoadOrder, p_strOptionalFiles); m_tslProfiles.Add(mprModProfile); m_strCurrentProfileId = mprModProfile.Id; SetDefaultProfile(mprModProfile); SaveConfig(); string strLogPath = Path.Combine(ModManager.GameMode.GameModeEnvironmentInfo.InstallInfoDirectory, "Scripted"); if (Directory.Exists(strLogPath)) { lock (m_objLock) DirectoryCopy(strLogPath, Path.Combine(m_strProfileManagerPath, mprModProfile.Id, "Scripted"), true); } return(mprModProfile); }
/// <summary> /// Registers the given mod as being active, and associates it with the given key. /// </summary> /// <param name="p_modNewMod">The mod to register.</param> /// <param name="p_strModKey">The key with which to associate the mod.</param> /// <param name="p_booHiddenMod">Whether or not the mod should be included in the /// list of active mods.</param> public void RegisterMod(IMod p_modNewMod, string p_strModKey, bool p_booHiddenMod) { if (m_dicModKeys.ContainsValue(p_strModKey)) { IMod modOld = m_dicModKeys.First(x => x.Value.Equals(p_strModKey)).Key; DeregisterMod(modOld); } m_dicModKeys.Add(p_modNewMod, p_strModKey); if (!p_booHiddenMod) { m_oclRegisteredMods.Add(p_modNewMod); } }
/// <summary> /// Sets the load order of the plugins. /// </summary> /// <remarks> /// <param name="p_strPlugins">The list of plugins in the desired order.</param> public void SetLoadOrder(string[] p_strPlugins) { string[] strOrderedPluginNames; if ((p_strPlugins == null) || (p_strPlugins.Length == 0)) { return; } else { LastValidLoadOrder = p_strPlugins.ToList(); strOrderedPluginNames = p_strPlugins; } if (TimestampOrder) { try { WriteLoadOrderTask wltTask = new WriteLoadOrderTask(String.Empty, strOrderedPluginNames, TimestampOrder, false, m_dtiMasterDate); TaskList.Add(wltTask); } catch { } } else { strOrderedPluginNames = StripPluginDirectory(strOrderedPluginNames); SetSortedListLoadOrder(strOrderedPluginNames); } if (!TimestampOrder && ((m_lstActivePlugins != null) && (m_lstActivePlugins.Count > 0))) { string[] strOrderedActivePluginNames = strOrderedPluginNames.Intersect(StripPluginDirectory(m_lstActivePlugins.ToArray()), StringComparer.InvariantCultureIgnoreCase).ToArray(); if ((strOrderedActivePluginNames != null) && (strOrderedActivePluginNames.Length > 0)) { SetActivePluginsTask(strOrderedActivePluginNames); } } }
/// <summary> /// Adds the newest information for the given mod. /// </summary> /// <param name="p_modMod">The mod for which to add the newest info.</param> /// <param name="p_mifNewestInfo">The newest info to add for the given mod.</param> public void AddNewVersionNumberForMod(IMod p_modMod, IModInfo p_mifNewestInfo) { lock (m_oclNewInfo) { Int32 intExistingIndex = m_oclNewInfo.IndexOf(x => (x.Mod == p_modMod)); if (intExistingIndex < 0) { m_oclNewInfo.Add(new UpdateInfo(p_modMod, p_mifNewestInfo)); } else { m_oclNewInfo[intExistingIndex] = new UpdateInfo(p_modMod, p_mifNewestInfo); } } }
/// <summary> /// Adds the newest information for the given mod. /// </summary> /// <param name="mod">The mod for which to add the newest info.</param> /// <param name="newestInfo">The newest info to add for the given mod.</param> public void AddNewVersionNumberForMod(IMod mod, IModInfo newestInfo) { lock (_newInfo) { var existingIndex = _newInfo.IndexOf(x => x.Mod == mod); if (existingIndex < 0) { _newInfo.Add(new UpdateInfo(mod, newestInfo)); } else { _newInfo[existingIndex] = new UpdateInfo(mod, newestInfo); } } }
/// <summary> /// Registers the specified mod, tagging it with the given info. /// </summary> /// <param name="p_strModPath">The path to the mod to register.</param> /// <param name="p_mifTagInfo">The info with which to tag the mod.</param> /// <returns>The mod that was registered, or <c>null</c> if the mod at the given path /// could not be registered.</returns> public IMod RegisterMod(string p_strModPath, IModInfo p_mifTagInfo) { Int32 intExistingIndex = -1; IMod modMod = null; for (intExistingIndex = 0; intExistingIndex < m_oclRegisteredMods.Count; intExistingIndex++) if (p_strModPath.Equals(m_oclRegisteredMods[intExistingIndex].Filename, StringComparison.OrdinalIgnoreCase)) break; modMod = CreateMod(p_strModPath, string.Empty, GameMode); if (p_mifTagInfo != null) modMod.UpdateInfo(p_mifTagInfo, false); if (modMod == null) return null; if (intExistingIndex < m_oclRegisteredMods.Count) m_oclRegisteredMods[intExistingIndex] = modMod; else m_oclRegisteredMods.Add(modMod); return modMod; }
/// <summary> /// Loads the plugin order data from the permanent store. /// </summary> private void LoadPluginOrder() { Trace.TraceInformation("Loading Plugin Order..."); Trace.Indent(); m_oclOrderedPlugins = new ThreadSafeObservableList <Plugin>(); if (LogSerializer != null) { foreach (string strPlugin in LogSerializer.LoadPluginOrder()) { Plugin plgPlugin = ManagedPluginRegistry.GetPlugin(strPlugin); Trace.TraceInformation("Loading {0} (IsNull={1})", strPlugin, (plgPlugin == null)); if (plgPlugin != null) { m_oclOrderedPlugins.Add(plgPlugin); } } } Trace.Unindent(); }
public ThreadSafeObservableList <IModProfile> LoadConfig(string p_strXMLFilePath) { ThreadSafeObservableList <IModProfile> lstProfiles = new ThreadSafeObservableList <IModProfile>(); if (File.Exists(p_strXMLFilePath)) { XDocument docProfile = XDocument.Load(p_strXMLFilePath); string strVersion = docProfile.Element("profileManager").Attribute("fileVersion").Value; if (!CURRENT_VERSION.ToString().Equals(strVersion)) { throw new Exception(String.Format("Invalid Profile Manager version: {0} Expecting {1}", strVersion, CURRENT_VERSION)); } try { XElement xelProfiles = docProfile.Descendants("profileList").FirstOrDefault(); if ((xelProfiles != null) && xelProfiles.HasElements) { foreach (XElement xelProfile in xelProfiles.Elements("profile")) { string strProfileId = xelProfile.Attribute("profileId").Value; string strProfileName = xelProfile.Attribute("profileName").Value; bool booDefault = (xelProfile.Attribute("isDefault").Value == "1") ? true : false; string strGameModeId = xelProfile.Element("gameModeId").Value; Int32 intModCount = Int32.TryParse(xelProfile.Element("modCount").Value, out intModCount) ? intModCount : 0; lstProfiles.Add(new ModProfile(strProfileId, strProfileName, strGameModeId, intModCount, booDefault)); if (booDefault) { m_strCurrentProfileId = strProfileId; } } } } catch { } } return(lstProfiles); }
/// <summary> /// Loads the plugin order data from the permanent store. /// </summary> private void LoadPluginOrder() { Trace.TraceInformation("Loading Plugin Order..."); Trace.Indent(); m_oclOrderedPlugins = new ThreadSafeObservableList<Plugin>(); if (LogSerializer != null) foreach (string strPlugin in LogSerializer.LoadPluginOrder()) { Plugin plgPlugin = ManagedPluginRegistry.GetPlugin(strPlugin); Trace.TraceInformation("Loading {0} (IsNull={1})", strPlugin, (plgPlugin == null)); if ((plgPlugin != null) && !m_oclOrderedPlugins.Contains(plgPlugin)) m_oclOrderedPlugins.Add(plgPlugin); } Trace.Unindent(); }
/// <summary> /// Adds a task to the monitor. /// </summary> /// <param name="p_tskTask">The task to monitor.</param> public void AddActivity(IBackgroundTaskSet p_bstTask) { m_oclTasks.Add(p_bstTask); }