/// <summary> /// Imports a first generation mod pack /// </summary> /// <param name="modPackDirectory">The mod pack directory</param> private async Task ImportOldModPack() { Dispatcher.Invoke(() => { var progress = new Progress <(int count, int total)>(prog => { LockedStatusLabel.Content = $"{UIStrings.Loading} ({prog.count}, {prog.total})"; if (prog.count == prog.total) { LockedStatusLabel.Content = UIStrings.Finalizing; } }); }); var originalModPackData = await _texToolsModPack.GetOriginalModPackJsonData(_modPackDirectory); Dispatcher.Invoke(() => { // There is nearly no point to doing this on another thread if it's going to be constantly // re-invoking the main thread with literally every line. foreach (var modsJson in originalModPackData) { var jsonEntry = new ModsJson { Name = modsJson.Name, Category = modsJson.Category.GetDisplayName(), FullPath = modsJson.FullPath, DatFile = modsJson.DatFile, ModOffset = modsJson.ModOffset, ModSize = modsJson.ModSize, ModPackEntry = new ModPack { name = Path.GetFileNameWithoutExtension(_modPackDirectory.FullName), author = "N/A", version = "1.0.0" } }; JsonEntries.Add(jsonEntry); Entries.Add(new SimpleModpackEntry(JsonEntries.Count - 1, this)); } ModPackName.Content = Path.GetFileNameWithoutExtension(_modPackDirectory.FullName); ModPackAuthor.Content = "N/A"; ModPackVersion.Content = "1.0.0"; var cv = (CollectionView)CollectionViewSource.GetDefaultView(ModListView.ItemsSource); cv.SortDescriptions.Clear(); cv.SortDescriptions.Add(new SortDescription(nameof(SimpleModpackEntry.ItemName), _lastDirection)); long size = 0; for (int i = 0; i < JsonEntries.Count; i++) { SelectedEntries.Add(i); size += JsonEntries[i].ModSize; } ModListView.SelectAll(); ModSize = size; }); }
/// <summary> /// Imports a simple mod pack /// </summary> /// <param name="modPackJson">The mod pack json</param> private async Task ImportSimpleModPack(ModPackJson modPackJson) { var modding = new Modding(_gameDirectory); Dispatcher.Invoke(() => { // This does not need to be an async task set. for (int i = 0; i < modPackJson.SimpleModsList.Count; i++) { var jsonItem = modPackJson.SimpleModsList[i]; // For some reason the ModPackEntry was never set before 2.0.13 so this is necessary for modpacks created prior to then if (jsonItem.ModPackEntry == null) { // Manually add the modpack entry that this mod is a part of jsonItem.ModPackEntry = new ModPack { name = modPackJson.Name, author = modPackJson.Author, version = modPackJson.Version }; } JsonEntries.Add(jsonItem); Entries.Add(new SimpleModpackEntry(JsonEntries.Count - 1, this)); } if (String.IsNullOrEmpty(modPackJson.MinimumFrameworkVersion)) { Version ver; bool success = Version.TryParse(modPackJson.MinimumFrameworkVersion, out ver); if (success) { var frameworkVersion = typeof(XivCache).Assembly.GetName().Version; if (ver > frameworkVersion) { throw new NotSupportedException("This modpack requires a more recent TexTools version to install."); } } } ModPackName.Content = modPackJson.Name; ModPackAuthor.Content = modPackJson.Author; ModPackVersion.Content = modPackJson.Version; var cv = (CollectionView)CollectionViewSource.GetDefaultView(ModListView.ItemsSource); cv.SortDescriptions.Clear(); cv.SortDescriptions.Add(new SortDescription(nameof(SimpleModpackEntry.ItemName), _lastDirection)); SelectedEntries.Clear(); long size = 0; for (int i = 0; i < JsonEntries.Count; i++) { SelectedEntries.Add(i); size += JsonEntries[i].ModSize; } ModListView.SelectAll(); ModSize = size; }); }
/// <summary> /// Imports a first generation mod pack /// </summary> /// <param name="modPackDirectory">The mod pack directory</param> private void ImportOldModPack() { var modding = new Modding(_gameDirectory); var originalModPackData = _texToolsModPack.GetOriginalModPackJsonData(_modPackDirectory); foreach (var modsJson in originalModPackData) { var race = GetRace(modsJson.FullPath); var number = GetNumber(modsJson.FullPath); var type = GetType(modsJson.FullPath); var map = GetMap(modsJson.FullPath); var active = false; var isActive = modding.IsModEnabled(modsJson.FullPath, false); if (isActive == XivModStatus.Enabled) { active = true; } _simpleDataList.Add(new SimpleModPackEntries { Name = modsJson.Name, Category = modsJson.Category, Race = race.ToString(), Part = type, Num = number, Map = map, Active = active, JsonEntry = new ModsJson { Name = modsJson.Name, Category = modsJson.Category, FullPath = modsJson.FullPath, DatFile = modsJson.DatFile, ModOffset = modsJson.ModOffset, ModSize = modsJson.ModSize } }); } ModPackName.Content = "N/A"; ModPackAuthor.Content = "N/A"; ModPackVersion.Content = "N/A"; _simpleDataList.Sort(); ModListView.ItemsSource = new ObservableCollection <SimpleModPackEntries>(_simpleDataList); ModListView.SelectAll(); }
/// <summary> /// Imports a simple mod pack /// </summary> /// <param name="modPackJson">The mod pack json</param> private void ImportSimpleModPack(ModPackJson modPackJson) { var modding = new Modding(_gameDirectory); foreach (var modsJson in modPackJson.SimpleModsList) { var race = GetRace(modsJson.FullPath); var number = GetNumber(modsJson.FullPath); var type = GetType(modsJson.FullPath); var map = GetMap(modsJson.FullPath); var active = false; var isActive = modding.IsModEnabled(modsJson.FullPath, false); if (isActive == XivModStatus.Enabled) { active = true; } modsJson.ModPackEntry = new ModPack { name = modPackJson.Name, author = modPackJson.Author, version = modPackJson.Version }; _simpleDataList.Add(new SimpleModPackEntries { Name = modsJson.Name, Category = modsJson.Category, Race = race.ToString(), Part = type, Num = number, Map = map, Active = active, JsonEntry = modsJson, }); } ModPackName.Content = modPackJson.Name; ModPackAuthor.Content = modPackJson.Author; ModPackVersion.Content = modPackJson.Version; _simpleDataList.Sort(); ModListView.ItemsSource = new ObservableCollection <SimpleModPackEntries>(_simpleDataList); ModListView.SelectAll(); }
/// <summary> /// Imports a simple mod pack /// </summary> /// <param name="modPackJson">The mod pack json</param> private async Task ImportSimpleModPack(ModPackJson modPackJson) { var modding = new Modding(_gameDirectory); var tasks = modPackJson.SimpleModsList.Select(modsJson => AddToList(modsJson, modding, modPackJson)); await Task.WhenAll(tasks); ModPackName.Content = modPackJson.Name; ModPackAuthor.Content = modPackJson.Author; ModPackVersion.Content = modPackJson.Version; var cv = (CollectionView)CollectionViewSource.GetDefaultView(ModListView.ItemsSource); cv.SortDescriptions.Clear(); cv.SortDescriptions.Add(new SortDescription(nameof(SimpleModPackEntries.Name), _lastDirection)); ModListView.SelectAll(); }
/// <summary> /// Event handler for the select all button clicked /// </summary> private void SelectAllButton_Click(object sender, RoutedEventArgs e) { ModListView.SelectAll(); ModListView.Focus(); }