/// <summary> /// Toggles the mod on or off /// </summary> /// <param name="internalFilePath">The internal file path of the mod</param> /// <param name="enable">The status of the mod</param> public async Task ToggleModStatus(string internalFilePath, bool enable) { var index = new Index(_gameDirectory); if (string.IsNullOrEmpty(internalFilePath)) { throw new Exception("File Path missing, unable to toggle mod."); } var modEntry = await TryGetModEntry(internalFilePath); if (modEntry == null) { throw new Exception("Unable to find mod entry in modlist."); } // Matadd textures have the same mod offset as original so nothing to toggle if (modEntry.data.originalOffset == modEntry.data.modOffset) { // Added file. if (enable && !modEntry.enabled) { await index.AddFileDescriptor(modEntry.fullPath, modEntry.data.modOffset, IOUtil.GetDataFileFromPath(modEntry.fullPath)); } else if (!enable && modEntry.enabled) { await index.DeleteFileDescriptor(modEntry.fullPath, IOUtil.GetDataFileFromPath(modEntry.fullPath)); } } else { // Standard mod (file replacement) if (enable) { await index.UpdateDataOffset(modEntry.data.modOffset, internalFilePath); } else { await index.UpdateDataOffset(modEntry.data.originalOffset, internalFilePath); } } var modListDirectory = new DirectoryInfo(Path.Combine(_gameDirectory.Parent.Parent.FullName, XivStrings.ModlistFilePath)); var modList = GetModList(); var entryEnableUpdate = (from entry in modList.Mods where entry.fullPath.Equals(modEntry.fullPath) select entry).FirstOrDefault(); entryEnableUpdate.enabled = enable; SaveModList(modList); }
/// <summary> /// Toggles the mod on or off /// </summary> /// <param name="internalFilePath">The internal file path of the mod</param> /// <param name="enable">The status of the mod</param> public async Task ToggleModPackStatus(string modPackName, bool enable) { var index = new Index(_gameDirectory); var modList = GetModList(); var modListDirectory = new DirectoryInfo(Path.Combine(_gameDirectory.Parent.Parent.FullName, XivStrings.ModlistFilePath)); List <Mod> mods = null; if (modPackName.Equals("Standalone (Non-ModPack)")) { mods = (from mod in modList.Mods where mod.modPack == null select mod).ToList(); } else { mods = (from mod in modList.Mods where mod.modPack != null && mod.modPack.name.Equals(modPackName) select mod).ToList(); } if (mods == null) { throw new Exception("Unable to find mods with given Mod Pack Name in modlist."); } foreach (var modEntry in mods) { if (modEntry.name.Equals(string.Empty)) { continue; } // Matadd textures have the same mod offset as original so nothing to toggle if (modEntry.data.originalOffset == modEntry.data.modOffset) { // Added file. if (enable && !modEntry.enabled) { await index.AddFileDescriptor(modEntry.fullPath, modEntry.data.modOffset, IOUtil.GetDataFileFromPath(modEntry.fullPath)); } else if (!enable && modEntry.enabled) { await index.DeleteFileDescriptor(modEntry.fullPath, IOUtil.GetDataFileFromPath(modEntry.fullPath)); } } else { // Standard file (file replacement) if (enable) { await index.UpdateDataOffset(modEntry.data.modOffset, modEntry.fullPath); modEntry.enabled = true; } else { await index.UpdateDataOffset(modEntry.data.originalOffset, modEntry.fullPath); modEntry.enabled = false; } } } SaveModList(modList); }