public async Task DisableMod() { _view.SaveButton.IsEnabled = false; _view.CancelButton.IsEnabled = false; _view.DisableButton.IsEnabled = false; _view.DisableButton.Content = UIStrings.Working_Ellipsis; var files = new List <string>(); // If we're disabling from the Edit Multi menu, diable all variant versions as well. if (_mode == MaterialEditorMode.EditMulti) { var sameModelItems = await _item.GetSharedModelItems(); var itemType = ItemType.GetPrimaryItemType(_item); // Find all the variant materials foreach (var item in sameModelItems) { var variantPath = await _mtrl.GetMtrlPath(item, _material.GetRace(), _material.GetMaterialIdentifier(), itemType); files.Add(variantPath.Folder + "/" + variantPath.File); } } else { // Just disabling this one. files.Add(_material.MTRLPath); } files = files.Distinct().ToList(); foreach (var file in files) { var modEntry = await _modding.TryGetModEntry(file); if (!modEntry.enabled) { continue; } // If the file is a custom addition, and not a modification. if (modEntry.source != XivStrings.TexTools) { await _modding.DeleteMod(file); } else { await _modding.ToggleModStatus(file, false); } } _view.Close(false); }
public async Task DisableMod() { _view.SaveButton.IsEnabled = false; _view.CancelButton.IsEnabled = false; _view.DisableButton.IsEnabled = false; _view.DisableButton.Content = UIStrings.Working_Ellipsis; var files = new HashSet <string>(); var root = _item.GetRoot(); if (root == null || !Imc.UsesImc(root)) { // This is the only copy of the material we know how to find. files.Add(_material.MTRLPath); } else { var imc = new Imc(XivCache.GameInfo.GameDirectory); var info = await imc.GetFullImcInfo(_item); var entries = info.GetAllEntries(root.Info.Slot); var materialSets = entries.Select(x => x.MaterialSet).ToHashSet(); var extract = new Regex("(v[0-9]{4})"); var rep = extract.Match(_material.MTRLPath).Groups[1].Value; // Remove the material in all of the referenced material sets. foreach (var setId in materialSets) { var newPath = _material.MTRLPath.Replace(rep, "v" + setId.ToString().PadLeft(4, '0')); files.Add(newPath); } } try { foreach (var file in files) { var modEntry = await _modding.TryGetModEntry(file); if (modEntry == null) { continue; } // If the file is a custom addition, and not a modification. if (modEntry.IsCustomFile()) { await _modding.DeleteMod(file); } else { await _modding.ToggleModStatus(file, false); } } } catch (Exception ex) { FlexibleMessageBox.Show("Unable to delete Mod.\n\nError: " + ex.Message, "Mod Delete Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } _view.Close(false); }