/// <summary> /// Updates the mod's name. /// </summary> /// <param name="p_modMod">The mod whose name is to be updated.</param> /// <param name="p_strNewModName">The name to which to update the mod's name.</param> public void UpdateModName(IMod p_modMod, string p_strNewModName) { ModInfo mifNewInfo = new ModInfo(p_modMod); mifNewInfo.ModName = p_strNewModName; p_modMod.UpdateInfo(mifNewInfo, true); }
/// <summary> /// The method that is called to start the backgound task. /// </summary> /// <param name="p_objArgs">Arguments to for the task execution.</param> /// <returns>Always <c>null</c>.</returns> protected override object DoWork(object[] p_objArgs) { OverallMessage = "Toggling all update warnings..."; OverallProgress = 0; OverallProgressStepSize = 1; OverallProgressMaximum = m_hashMods.Count; ShowItemProgress = false; ConfirmActionMethod camConfirm = (ConfirmActionMethod)p_objArgs[0]; foreach (IMod modMod in m_hashMods) { ModInfo mifUpdatedMod = new ModInfo(modMod); if (m_booEnable == null) mifUpdatedMod.UpdateWarningEnabled = !modMod.UpdateWarningEnabled; else { if (modMod.UpdateWarningEnabled == m_booEnable.Value) continue; else mifUpdatedMod.UpdateWarningEnabled = m_booEnable.Value; } modMod.UpdateInfo((IModInfo)mifUpdatedMod, false); if (OverallProgress < OverallProgressMaximum) StepOverallProgress(); if (m_booCancel) break; } return null; }
/// <summary> /// Combines the given mod info and mod file info into one mod info. /// </summary> /// <param name="p_mifInfo">The mod info to combine.</param> /// <param name="p_mfiFileInfo">The mod file info to combine.</param> /// <returns>A mid info representing the information from both given info objects.</returns> public static IModInfo CombineInfo(IModInfo p_mifInfo, IModFileInfo p_mfiFileInfo) { Int32 intLineTracker = 0; ModInfo mifUpdatedInfo = null; try { if (p_mifInfo == null) { intLineTracker = 1; if (p_mfiFileInfo == null) return null; intLineTracker = 2; mifUpdatedInfo = new ModInfo(); intLineTracker = 3; } else { intLineTracker = 4; mifUpdatedInfo = new ModInfo(p_mifInfo); intLineTracker = 5; } intLineTracker = 6; if (p_mfiFileInfo != null) { intLineTracker = 7; if (!String.IsNullOrEmpty(p_mfiFileInfo.HumanReadableVersion)) { intLineTracker = 8; mifUpdatedInfo.HumanReadableVersion = p_mfiFileInfo.HumanReadableVersion; intLineTracker = 9; mifUpdatedInfo.MachineVersion = null; intLineTracker = 10; } intLineTracker = 11; if (!String.IsNullOrEmpty(p_mfiFileInfo.Name)) { intLineTracker = 12; mifUpdatedInfo.ModName = String.Format("{0} - {1}", mifUpdatedInfo.ModName, p_mfiFileInfo.Name); intLineTracker = 13; } intLineTracker = 14; } intLineTracker = 15; } catch (NullReferenceException) { Trace.TraceError("NullReferenceException in CombineInfo: LineTracker: {0}", intLineTracker); throw; } return mifUpdatedInfo; }
/// <summary> /// Switches the mod category. /// </summary> /// <param name="p_modMod">The mod.</param> /// <param name="p_intCategoryId">The new category id.</param> public void SwitchModCategory(IMod p_modMod, Int32 p_intCategoryId) { ModInfo mifUpdatedMod = new ModInfo(p_modMod); mifUpdatedMod.CustomCategoryId = p_intCategoryId; mifUpdatedMod.UpdateWarningEnabled = p_modMod.UpdateWarningEnabled; p_modMod.UpdateInfo((IModInfo)mifUpdatedMod, false); }
/// <summary> /// Toggles the endorsement for the given mod. /// </summary> /// <param name="p_modMod">The mod to endorse/unendorse.</param> public void ToggleModEndorsement(IMod p_modMod) { bool? booEndorsementState = ModRepository.ToggleEndorsement(p_modMod.Id, p_modMod.IsEndorsed == true ? 1 : (p_modMod.IsEndorsed == false ? -1 : 0)); ModInfo mifUpdatedMod = new ModInfo(p_modMod); mifUpdatedMod.IsEndorsed = booEndorsementState; mifUpdatedMod.HumanReadableVersion = String.IsNullOrEmpty(mifUpdatedMod.LastKnownVersion) ? mifUpdatedMod.HumanReadableVersion : mifUpdatedMod.LastKnownVersion; AddNewVersionNumberForMod(p_modMod, (IModInfo)mifUpdatedMod); p_modMod.UpdateInfo((IModInfo)mifUpdatedMod, false); }
/// <summary> /// Commits the current values to the <see cref="IModInfo"/> /// being edited. /// </summary> /// <returns>The <see cref="IModInfo"/> being edited with the new /// values, if they pass validation. If the current values are invalid, the /// original <see cref="IModInfo"/> is returned.</returns> public IModInfo Commit() { if (Validate() && (ModInfo != null)) { ModInfo midInfo = new ModInfo(ModInfo); midInfo.Author = Author; midInfo.Description = Description; midInfo.HumanReadableVersion = HumanReadableVersion; midInfo.LastKnownVersion = LastKnownVersion; midInfo.MachineVersion = String.IsNullOrEmpty(MachineVersion) ? null : new Version(MachineVersion); midInfo.ModName = ModName; midInfo.InstallDate = InstallDate; midInfo.Website = String.IsNullOrEmpty(Website) ? null : new Uri(Website); midInfo.Screenshot = Screenshot; midInfo.CategoryId = CategoryId; midInfo.IsEndorsed = IsEndorsed; ModInfo.UpdateInfo(midInfo, true); } return ModInfo; }