public override void SpecialFileUninstall(IMod p_modSelectedMod) { List <string> fileList = p_modSelectedMod.GetFileList(); if (fileList.Contains("info.json", StringComparer.OrdinalIgnoreCase)) { RemoveManifest(p_modSelectedMod); } }
/// <summary> /// Checks a mod if it needs a path adjust. /// Mods need path adjusts if they either are not exactly one folder deep. /// Also more than one content.xml is not allowed in one package. /// /// Ex: /// ZIP/ /// Mod1/ /// content.xml /// /// Wrong: /// ZIP/ /// Mod1/ /// XYZ/ /// content.xml /// </summary> /// <param name="p_modMod"></param> /// <returns></returns> private bool NeedsPathAdjustForContentXml(IMod p_modMod) { bool adjustPath = false; if (p_modMod.GetFileList().Exists(DoesContentFileExist)) { // this is ok to throw if nessecary, handled in calling function var strContentXmlPath = p_modMod.GetFileList().Single(f => f.Contains("content.xml")); var intNestLevels = strContentXmlPath.Split('\\').Count(); if (intNestLevels == 1 || intNestLevels > 2) { adjustPath = true; } } return(adjustPath); }
public override IEnumerable <string> SpecialFileInstall(IMod p_modSelectedMod) { List <string> fileList = p_modSelectedMod.GetFileList(); if (fileList.Contains("info.json", StringComparer.OrdinalIgnoreCase)) { AddManifest(p_modSelectedMod); } return(null); }
/// <summary> /// Checks a mod if it needs a path adjust. /// Mods need path adjusts if they either are not exactly one folder deep. /// Also more than one content.xml is not allowed in one package. /// /// Ex: /// ZIP/ /// Mod1/ /// content.xml /// /// Wrong: /// ZIP/ /// Mod1/ /// XYZ/ /// content.xml /// </summary> /// <param name="p_modMod"></param> /// <returns></returns> private bool NeedsPathAdjust(IMod p_modMod) { // this is ok to throw if nessecary, handled in calling function var strContentXmlPath = p_modMod.GetFileList().Single(f => f.Contains("content.xml")); var intNestLevels = strContentXmlPath.Split('\\').Count(); if (intNestLevels == 1 || intNestLevels > 2) { return(true); } return(false); }
/// <summary> /// Checks whether to use the secondary mod install method. /// </summary> /// <returns>Whether to use the secondary mod install method.</returns> /// <param name="p_modMod">The mod to be installed.</param> public override bool CheckSecondaryInstall(IMod p_modMod) { //string strPattern = String.Format(@"[^\{0}\{1}]+[\{0}\{1}]cook\.hash", Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); string strPattern = String.Format(@"cook\.hash", Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); foreach (string strFile in p_modMod.GetFileList()) { if (Regex.IsMatch(strFile, strPattern)) { return(true); } } return(false); }
public override IEnumerable <string> SpecialFileInstall(IMod p_modSelectedMod) { MessageBox.Show("The following mod is in an invalid state and can't be installed properly. The mod manager will attempt to install it anyway."); return(p_modSelectedMod.GetFileList()); }
/// <summary> /// Checks whether to use the secondary mod install method. /// </summary> /// <returns>Whether to use the secondary mod install method.</returns> /// <param name="p_modMod">The mod to be installed.</param> public override bool CheckSecondaryInstall(IMod p_modMod) { //string strPattern = String.Format(@"[^\{0}\{1}]+[\{0}\{1}]cook\.hash", Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); string strPattern = String.Format(@"cook\.hash", Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); foreach (string strFile in p_modMod.GetFileList()) if (Regex.IsMatch(strFile, strPattern)) return true; return false; }
/// <summary> /// Checks a mod if it needs a path adjust. /// Mods need path adjusts if they either are not exactly one folder deep. /// Also more than one content.xml is not allowed in one package. /// /// Ex: /// ZIP/ /// Mod1/ /// content.xml /// /// Wrong: /// ZIP/ /// Mod1/ /// XYZ/ /// content.xml /// </summary> /// <param name="p_modMod"></param> /// <returns></returns> private bool NeedsPathAdjust(IMod p_modMod) { // this is ok to throw if nessecary, handled in calling function var strContentXmlPath = p_modMod.GetFileList().Single(f => f.Contains("content.xml")); var intNestLevels = strContentXmlPath.Split('\\').Count(); if (intNestLevels == 1 || intNestLevels > 2) return true; return false; }
/// <summary> /// Merges the chargenmorphcfg.xml file of the Dragon Age mods. /// </summary> /// <param name="p_rolActiveMods">The list of active mods.</param> /// <param name="p_modMod">The current mod.</param> /// <param name="p_booRemove">Whether we're adding or removing the mod.</param> public override void ModFileMerge(ReadOnlyObservableList <IMod> p_rolActiveMods, IMod p_modMod, bool p_booRemove) { List <string> lstFiles = null; XDocument XDoc = null; XDocument XDocMerge = null; bool booMerge = false; Byte[] bFile = null; strXMLDirectory = Path.Combine(m_gmdGameModeInfo.InstallationPath, "NMM_chargenmorphcfg"); #region activeMods if (p_booRemove && File.Exists(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml"))) { File.Delete(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml")); } if ((!File.Exists(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml"))) || (p_booRemove)) { foreach (IMod modMod in p_rolActiveMods) { if (modMod.Filename != p_modMod.Filename) { lstFiles = modMod.GetFileList(); foreach (string strFile in lstFiles) { if (strFile.EndsWith("chargenmorphcfg.xml")) { bFile = modMod.GetFile(strFile); string responseText = Encoding.ASCII.GetString(bFile); XDoc = XDocument.Parse(responseText.Replace("???", "")); if (XDocMerge == null) { XDocMerge = XDoc; booMerge = true; } else { foreach (XElement ele in XDoc.Root.Elements()) { XElement xeDoc = XDoc.Root.Element(ele.Name.ToString()); XElement xeDocMerge = XDocMerge.Root.Element(ele.Name.ToString()); MergeElements(xeDoc, xeDocMerge); } } } } } } } else { bFile = File.ReadAllBytes(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml")); string responseText = Encoding.ASCII.GetString(bFile); XDoc = XDocument.Parse(responseText.Replace("???", "")); booMerge = true; } #endregion #region currentMod if ((p_modMod != null) && (!p_rolActiveMods.Contains(p_modMod))) { lstFiles = p_modMod.GetFileList(); foreach (string strFile in lstFiles) { if (strFile.EndsWith("chargenmorphcfg.xml")) { bFile = p_modMod.GetFile(strFile); string responseText = Encoding.ASCII.GetString(bFile); XDocMerge = XDocument.Parse(responseText.Replace("???", "")); if (booMerge) { foreach (XElement ele in XDoc.Root.Elements()) { XElement xeDoc = XDoc.Root.Element(ele.Name.ToString()); XElement xeDocMerge = XDocMerge.Root.Element(ele.Name.ToString()); MergeElements(xeDoc, xeDocMerge); } } } } } #endregion if (!Directory.Exists(strXMLDirectory)) { Directory.CreateDirectory(strXMLDirectory); } if (XDoc != null) { XDoc.Save(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml")); } else if (XDocMerge != null) { XDocMerge.Save(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml")); } }
/// <summary> /// Merges the chargenmorphcfg.xml file of the Dragon Age mods. /// </summary> /// <param name="p_rolActiveMods">The list of active mods.</param> /// <param name="p_modMod">The current mod.</param> /// <param name="p_booRemove">Whether we're adding or removing the mod.</param> public override void ModFileMerge(ReadOnlyObservableList<IMod> p_rolActiveMods, IMod p_modMod, bool p_booRemove) { List<string> lstFiles = null; XDocument XDoc = null; XDocument XDocMerge = null; bool booMerge = false; Byte[] bFile = null; strXMLDirectory = Path.Combine(m_gmdGameModeInfo.InstallationPath, "NMM_chargenmorphcfg"); #region activeMods if (p_booRemove && File.Exists(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml"))) File.Delete(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml")); if ((!File.Exists(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml"))) || (p_booRemove)) { foreach (IMod modMod in p_rolActiveMods) { if (modMod.Filename != p_modMod.Filename) { lstFiles = modMod.GetFileList(); foreach (string strFile in lstFiles) { if (strFile.EndsWith("chargenmorphcfg.xml")) { bFile = modMod.GetFile(strFile); string responseText = Encoding.ASCII.GetString(bFile); XDoc = XDocument.Parse(responseText.Replace("???", "")); if (XDocMerge == null) { XDocMerge = XDoc; booMerge = true; } else { foreach (XElement ele in XDoc.Root.Elements()) { XElement xeDoc = XDoc.Root.Element(ele.Name.ToString()); XElement xeDocMerge = XDocMerge.Root.Element(ele.Name.ToString()); MergeElements(xeDoc, xeDocMerge); } } } } } } } else { bFile = File.ReadAllBytes(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml")); string responseText = Encoding.ASCII.GetString(bFile); XDoc = XDocument.Parse(responseText.Replace("???", "")); booMerge = true; } #endregion #region currentMod if ((p_modMod != null) && (!p_rolActiveMods.Contains(p_modMod))) { lstFiles = p_modMod.GetFileList(); foreach (string strFile in lstFiles) { if (strFile.EndsWith("chargenmorphcfg.xml")) { bFile = p_modMod.GetFile(strFile); string responseText = Encoding.ASCII.GetString(bFile); XDocMerge = XDocument.Parse(responseText.Replace("???", "")); if (booMerge) { foreach (XElement ele in XDoc.Root.Elements()) { XElement xeDoc = XDoc.Root.Element(ele.Name.ToString()); XElement xeDocMerge = XDocMerge.Root.Element(ele.Name.ToString()); MergeElements(xeDoc, xeDocMerge); } } } } } #endregion if (!Directory.Exists(strXMLDirectory)) Directory.CreateDirectory(strXMLDirectory); if(XDoc != null) XDoc.Save(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml")); else if(XDocMerge != null) XDocMerge.Save(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml")); }
/// <summary> /// Checks a mod if it needs a path adjust. /// Mods need path adjusts if they either are not exactly one folder deep. /// Also more than one content.xml is not allowed in one package. /// /// Ex: /// ZIP/ /// Mod1/ /// content.xml /// /// Wrong: /// ZIP/ /// Mod1/ /// XYZ/ /// content.xml /// </summary> /// <param name="p_modMod"></param> /// <returns></returns> private bool NeedsPathAdjustForContentXml(IMod p_modMod) { bool adjustPath = false; if (p_modMod.GetFileList().Exists(DoesContentFileExist)) { // this is ok to throw if nessecary, handled in calling function var strContentXmlPath = p_modMod.GetFileList().Single(f => f.Contains("content.xml")); var intNestLevels = strContentXmlPath.Split('\\').Count(); if (intNestLevels == 1 || intNestLevels > 2) { adjustPath = true; } } return adjustPath; }