/// <summary> /// The event handler for the add current material button clicked /// </summary> private void AddCurrentMaterialButton_Click(object sender, RoutedEventArgs e) { var dat = new Dat(_gameDirectory); var selectedItem = MaterialComboBox.SelectedItem as ModComboBox; var mod = selectedItem.SelectedMod; var includedMod = new IncludedMods { Name = $"{Path.GetFileNameWithoutExtension(mod.fullPath)} ({((Category)ModListTreeView.SelectedItem).Name})", FullPath = mod.fullPath }; var includedModsList = IncludedModsList.Items.Cast <IncludedMods>().ToList(); if (includedModsList.Any(item => item.Name.Equals(includedMod.Name))) { if (FlexibleMessageBox.Show( string.Format(UIMessages.ExistingOption, includedMod.Name), UIMessages.OverwriteTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { var rawData = dat.GetRawData(mod.data.modOffset, XivDataFiles.GetXivDataFile(mod.datFile), mod.data.modSize); if (rawData == null) { FlexibleMessageBox.Show( string.Format(UIMessages.RawDataErrorMessage, mod.data.modOffset, mod.datFile), UIMessages.ModDataReadErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } _selectedModOption.Mods[mod.fullPath].ModDataBytes = rawData; } } else { var rawData = dat.GetRawData(mod.data.modOffset, XivDataFiles.GetXivDataFile(mod.datFile), mod.data.modSize); if (rawData == null) { FlexibleMessageBox.Show( string.Format(UIMessages.RawDataErrorMessage, mod.data.modOffset, mod.datFile), UIMessages.ModDataReadErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var modData = new ModData { Name = mod.name, Category = mod.category, FullPath = mod.fullPath, ModDataBytes = rawData, }; IncludedModsList.Items.Add(includedMod); _selectedModOption.Mods.Add(mod.fullPath, modData); } }
/// <summary> /// The event handler for the advanced options button clicked /// </summary> private async void AdvOptionsButton_Click(object sender, RoutedEventArgs e) { var selectedItem = ModelTypeComboBox.SelectedItem as ModComboBox; var mod = selectedItem.SelectedMod; var includedMod = new IncludedMods { Name = $"{Path.GetFileNameWithoutExtension(mod.fullPath)} ({((Category)ModListTreeView.SelectedItem).Name})", FullPath = mod.fullPath }; var itemModel = MakeItemModel(mod); var includedModsList = IncludedModsList.Items.Cast <IncludedMods>().ToList(); var mdl = new Mdl(_gameDirectory, XivDataFiles.GetXivDataFile(mod.datFile)); try { // TODO - Include Submesh ID ? // Do we even have any kind of UI To specify this in the wizard? // Submeshes are only used for Furniture anyways, so it might be a 'will not fix' bool success = await ImportModelView.ImportModel(itemModel, IOUtil.GetRaceFromPath(mod.fullPath), null, this, null, true); if (!success) { return; } } catch (Exception ex) { FlexibleMessageBox.Show(ex.Message, UIMessages.AdvancedImportErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var mdlData = ImportModelView.GetData(); if (includedModsList.Any(item => item.Name.Equals(includedMod.Name))) { if (FlexibleMessageBox.Show( string.Format(UIMessages.ExistingOption, includedMod.Name), UIMessages.OverwriteTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { _selectedModOption.Mods[mod.fullPath].ModDataBytes = mdlData; } } else { IncludedModsList.Items.Add(includedMod); _selectedModOption.Mods.Add(mod.fullPath, new ModData { Name = mod.name, Category = mod.category, FullPath = mod.fullPath, ModDataBytes = mdlData, }); } }
/// <summary> /// The event handler for the add custom texture button clicked /// </summary> private async void AddCustomTextureButton_Click(object sender, RoutedEventArgs e) { var selectedItem = TextureMapComboBox.SelectedItem as ModComboBox; var mod = selectedItem.SelectedMod; byte[] modData; var includedMod = new IncludedMods { Name = $"{Path.GetFileNameWithoutExtension(mod.fullPath)} ({((Category)ModListTreeView.SelectedItem).Name})", FullPath = mod.fullPath }; var includedModsList = IncludedModsList.Items.Cast <IncludedMods>().ToList(); var tex = new Tex(_gameDirectory); var ddsDirectory = new DirectoryInfo(CustomTextureTextBox.Text); if (selectedItem.TexTypePath.Type == XivTexType.ColorSet) { var mtrl = new Mtrl(_gameDirectory, XivDataFiles.GetXivDataFile(mod.datFile), GetLanguage()); var xivMtrl = await mtrl.GetMtrlData(mod.data.modOffset, mod.fullPath, int.Parse(Settings.Default.DX_Version)); modData = tex.DDStoMtrlData(xivMtrl, ddsDirectory, ((Category)ModListTreeView.SelectedItem).Item, GetLanguage()); } else { var texData = await tex.GetTexData(selectedItem.TexTypePath); modData = await tex.DDStoTexData(texData, ((Category)ModListTreeView.SelectedItem).Item, ddsDirectory); } if (includedModsList.Any(item => item.Name.Equals(includedMod.Name))) { if (FlexibleMessageBox.Show( string.Format(UIMessages.ExistingOption, includedMod.Name), UIMessages.OverwriteTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { _selectedModOption.Mods[mod.fullPath].ModDataBytes = modData; } } else { IncludedModsList.Items.Add(includedMod); _selectedModOption.Mods.Add(mod.fullPath, new ModData { Name = mod.name, Category = mod.category, FullPath = mod.fullPath, ModDataBytes = modData }); } }
/// <summary> /// The event handler for the option list selection changed /// </summary> private void OptionList_SelectionChanged(object sender, SelectionChangedEventArgs e) { IncludedModsList.Items.Clear(); if (OptionList.SelectedIndex != -1) { _selectedModOption = (from option in _modOptions where option.Name.Equals(OptionList.SelectedItem.ToString()) select option).FirstOrDefault(); if (_selectedModOption.Description != null) { OptionDescription.Text = _selectedModOption.Description; } else { OptionDescription.Text = string.Empty; } if (_selectedModOption.Image != null) { OptionImage.Source = _selectedModOption.Image.ToBitmapSource(); } else { OptionImage.Source = null; } if (_selectedModOption.Mods != null && _selectedModOption.Mods.Count > 0) { foreach (var mod in _selectedModOption.Mods) { var includedMods = new IncludedMods { Name = $"{Path.GetFileNameWithoutExtension(mod.Key)} ({mod.Value.Name})", FullPath = mod.Value.FullPath }; IncludedModsList.Items.Add(includedMods); } } ModListGrid.IsEnabled = true; OptionDescription.IsEnabled = true; OptionImageButton.IsEnabled = true; RemoveOptionButton.IsEnabled = true; } else { ModListGrid.IsEnabled = false; OptionDescription.IsEnabled = false; OptionImageButton.IsEnabled = false; RemoveOptionButton.IsEnabled = false; } }
/// <summary> /// The event handler for the custom model button clicked /// </summary> private async void AddCustomModelButton_Click(object sender, RoutedEventArgs e) { var selectedItem = ModelTypeComboBox.SelectedItem as ModComboBox; var mod = selectedItem.SelectedMod; var includedMod = new IncludedMods { Name = $"{Path.GetFileNameWithoutExtension(mod.fullPath)} ({((Category)ModListTreeView.SelectedItem).Name})", FullPath = mod.fullPath }; var itemModel = MakeItemModel(mod); var includedModsList = IncludedModsList.Items.Cast <IncludedMods>().ToList(); var mdl = new Mdl(_gameDirectory, XivDataFiles.GetXivDataFile(mod.datFile)); var xivMdl = await mdl.GetMdlData(itemModel, GetRace(mod.fullPath), null, null, mod.data.originalOffset); var warnings = await mdl.ImportModel(itemModel, xivMdl, new DirectoryInfo(CustomModelTextBox.Text), null, XivStrings.TexTools, Settings.Default.DAE_Plugin_Target, true); if (warnings.Count > 0) { foreach (var warning in warnings) { FlexibleMessageBox.Show( $"{warning.Value}", $"{warning.Key}", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } var mdlData = mdl.MDLRawData; if (includedModsList.Any(item => item.Name.Equals(includedMod.Name))) { if (FlexibleMessageBox.Show( string.Format(UIMessages.ExistingOption, includedMod.Name), UIMessages.OverwriteTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { _selectedModOption.Mods[mod.fullPath].ModDataBytes = mdlData; } } else { IncludedModsList.Items.Add(includedMod); _selectedModOption.Mods.Add(mod.fullPath, new ModData { Name = mod.name, Category = mod.category, FullPath = mod.fullPath, ModDataBytes = mdlData }); } }
/// <summary> /// The event handler for the advanced options button clicked /// </summary> private void AdvOptionsButton_Click(object sender, RoutedEventArgs e) { var selectedItem = ModelTypeComboBox.SelectedItem as ModComboBox; var mod = selectedItem.SelectedMod; var includedMod = new IncludedMods { Name = $"{Path.GetFileNameWithoutExtension(mod.fullPath)} ({((Category)ModListTreeView.SelectedItem).Name})", FullPath = mod.fullPath }; var itemModel = MakeItemModel(mod); var includedModsList = IncludedModsList.Items.Cast <IncludedMods>().ToList(); var mdl = new Mdl(_gameDirectory, XivDataFiles.GetXivDataFile(mod.datFile)); var xivMdl = mdl.GetMdlData(itemModel, GetRace(mod.fullPath), null, null, mod.data.originalOffset); var advancedImportView = new AdvancedModelImportView(xivMdl, itemModel, GetRace(mod.fullPath), true); var result = advancedImportView.ShowDialog(); if (result == true) { if (includedModsList.Any(item => item.Name.Equals(includedMod.Name))) { if (FlexibleMessageBox.Show( $"This Option already includes {includedMod.Name} \n\n Would you like to overwrite the existing mod for this option?", "Overwrite?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { _selectedModOption.Mods[mod.fullPath].ModDataBytes = advancedImportView.RawModelData; } } else { IncludedModsList.Items.Add(includedMod); _selectedModOption.Mods.Add(mod.fullPath, new ModData { Name = mod.name, Category = mod.category, FullPath = mod.fullPath, ModDataBytes = advancedImportView.RawModelData }); } } }
/// <summary> /// The event handler for the custom model button clicked /// </summary> private void AddCustomModelButton_Click(object sender, RoutedEventArgs e) { var selectedItem = ModelTypeComboBox.SelectedItem as ModComboBox; var mod = selectedItem.SelectedMod; var includedMod = new IncludedMods { Name = $"{Path.GetFileNameWithoutExtension(mod.fullPath)} ({((Category)ModListTreeView.SelectedItem).Name})", FullPath = mod.fullPath }; var itemModel = MakeItemModel(mod); var includedModsList = IncludedModsList.Items.Cast <IncludedMods>().ToList(); var mdl = new Mdl(_gameDirectory, XivDataFiles.GetXivDataFile(mod.datFile)); var xivMdl = mdl.GetMdlData(itemModel, GetRace(mod.fullPath)); var importResults = mdl.ImportModel(itemModel, xivMdl, new DirectoryInfo(CustomModelTextBox.Text), null, XivStrings.TexTools, true); //TODO: Add dialogs for import results (warning messages) var mdlData = mdl.MDLRawData; if (includedModsList.Any(item => item.Name.Equals(includedMod.Name))) { if (FlexibleMessageBox.Show( $"This Option already includes {includedMod.Name} \n\n Would you like to overwrite the existing mod for this option?", "Overwrite?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { _selectedModOption.Mods[mod.fullPath].ModDataBytes = mdlData; } } else { IncludedModsList.Items.Add(includedMod); _selectedModOption.Mods.Add(mod.fullPath, new ModData { Name = mod.name, Category = mod.category, FullPath = mod.fullPath, ModDataBytes = mdlData }); } }
/// <summary> /// The event handler for the current model button clicked /// </summary> private void AddCurrentModelButton_Click(object sender, RoutedEventArgs e) { var dat = new Dat(_gameDirectory); var selectedItem = ModelTypeComboBox.SelectedItem as ModComboBox; var mod = selectedItem.SelectedMod; var includedMod = new IncludedMods { Name = $"{Path.GetFileNameWithoutExtension(mod.fullPath)} ({((Category)ModListTreeView.SelectedItem).Name})", FullPath = mod.fullPath }; var includedModsList = IncludedModsList.Items.Cast <IncludedMods>().ToList(); if (includedModsList.Any(item => item.Name.Equals(includedMod.Name))) { if (FlexibleMessageBox.Show( $"This Option already includes {includedMod.Name} \n\n Would you like to overwrite the existing mod for this option?", "Overwrite?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { _selectedModOption.Mods[mod.fullPath].ModDataBytes = dat.GetRawData(mod.data.modOffset, XivDataFiles.GetXivDataFile(mod.datFile), mod.data.modSize); } } else { IncludedModsList.Items.Add(includedMod); var modData = new ModData { Name = mod.name, Category = mod.category, FullPath = mod.fullPath, ModDataBytes = dat.GetRawData(mod.data.modOffset, XivDataFiles.GetXivDataFile(mod.datFile), mod.data.modSize) }; _selectedModOption.Mods.Add(mod.fullPath, modData); } }
/// <summary> /// The event handler for the option list selection changed /// </summary> private void OptionList_SelectionChanged(object sender, SelectionChangedEventArgs e) { IncludedModsList.Items.Clear(); if (OptionList.SelectedIndex != -1) { _selectedModOption = (from option in _modOptions where option.Name.Equals(OptionList.SelectedItem.ToString()) select option).FirstOrDefault(); if (_selectedModOption.Description != null) { OptionDescription.Text = _selectedModOption.Description; } else { OptionDescription.Text = string.Empty; } if (_selectedModOption.Image != null) { BitmapImage bmp; using (var ms = new MemoryStream()) { _selectedModOption.Image.Save(ms, new PngEncoder()); bmp = new BitmapImage(); bmp.BeginInit(); bmp.StreamSource = ms; bmp.CacheOption = BitmapCacheOption.OnLoad; bmp.EndInit(); bmp.Freeze(); } OptionImage.Source = bmp; } else { OptionImage.Source = null; } if (_selectedModOption.Mods != null && _selectedModOption.Mods.Count > 0) { foreach (var mod in _selectedModOption.Mods) { var includedMods = new IncludedMods { Name = $"{Path.GetFileNameWithoutExtension(mod.Key)} ({mod.Value.Name})", FullPath = mod.Value.FullPath }; IncludedModsList.Items.Add(includedMods); } } ModListGrid.IsEnabled = true; OptionDescription.IsEnabled = true; OptionImageButton.IsEnabled = true; RemoveOptionButton.IsEnabled = true; } else { ModListGrid.IsEnabled = false; OptionDescription.IsEnabled = false; OptionImageButton.IsEnabled = false; RemoveOptionButton.IsEnabled = false; } }