/// <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 advanced options button clicked /// </summary> private async void AdvOptionsButton_Click(object sender, RoutedEventArgs e) { var selectedFile = ModelTypeComboBox.SelectedItem as FileEntry; var itemModel = (IItemModel)SelectedItem; var mdl = new Mdl(_gameDirectory, IOUtil.GetDataFileFromPath(selectedFile.Path)); 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(selectedFile.Path), 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(); AddFile(selectedFile, SelectedItem, mdlData); }
public ImportModelViewModel(ImportModelView view, IItemModel item, XivRace race, string submeshId, bool dataOnly, Action onComplete = null, string lastImportFilePath = null) { _view = view; _item = item; _race = race; _submeshId = submeshId; _dataOnly = dataOnly; _onComplete = onComplete; _lastImportFilePath = lastImportFilePath; if (typeof(XivCharacter) == _item.GetType()) { // Fix up naming scheme for character items to match user expectation. var clone = (XivCharacter)((XivCharacter)_item).Clone(); clone.Name = clone.SecondaryCategory; _item = clone; } var gameDirectory = new DirectoryInfo(Settings.Default.FFXIV_Directory); var saveDirectory = new DirectoryInfo(Settings.Default.Save_Directory); var dataFile = IOUtil.GetDataFileFromPath(_item.GetItemRootFolder()); _mdl = new Mdl(gameDirectory, dataFile); _importers = _mdl.GetAvailableImporters(); SetupRaces(); // We need to explicitly fork this onto a new thread to avoid deadlock. Task.Run(AssignPath).Wait(); var defaultPath = $"{IOUtil.MakeItemSavePath(_item, saveDirectory, _race)}\\3D".Replace("/", "\\"); var modelName = Path.GetFileNameWithoutExtension(_internalPath); // Scan to see which file type(s) actually exist. bool foundValidFile = false; // FBX is default, so check that first. var startingPath = Path.Combine(defaultPath, modelName) + ".fbx"; if (File.Exists(startingPath)) { foundValidFile = true; } if (!foundValidFile) { foreach (var suffix in _importers) { startingPath = Path.Combine(defaultPath, modelName) + "." + suffix; if (File.Exists(startingPath)) { foundValidFile = true; break; } } } if (!foundValidFile) { // Auto-fill the last import file path if the file still exists, otherwise just default to reusing the existing model startingPath = File.Exists(_lastImportFilePath) ? _lastImportFilePath : ""; } _view.FileNameTextBox.Text = startingPath; // Event Handlers _view.SelectFileButton.Click += SelectFileButton_Click; _view.ImportButton.Click += ImportButton_Click; _view.EditButton.Click += EditButton_Click; _view.Closing += _view_Closing; _view.OverrideRaceButton.Checked += OverrideRaceButton_Checked; _view.OverrideRaceButton.Unchecked += OverrideRaceButton_Unchecked; // Default Settings for specific categories, event handlers are added to allow users to opt out of these defaults if (item.SecondaryCategory == XivStrings.Face) { _view.UseOriginalShapeDataButton.IsChecked = Settings.Default.UseOriginalShapeDataForFace; _view.UseOriginalShapeDataButton.Click += UseOriginalShapeDataButton_Clicked; } if (item.SecondaryCategory == XivStrings.Hair) { _view.CloneUV1Button.IsChecked = Settings.Default.CloneUV1toUV2ForHair; _view.CloneUV1Button.Click += CloneUV1Button_Clicked; } var iType = item.GetPrimaryItemType(); if (iType == xivModdingFramework.Items.Enums.XivItemType.equipment || iType == xivModdingFramework.Items.Enums.XivItemType.accessory || iType == xivModdingFramework.Items.Enums.XivItemType.weapon) { _view.ForceUVsButton.IsChecked = Settings.Default.ForceUV1QuadrantForGear; _view.ForceUVsButton.Click += ForceUVsButton_Clicked; } }
public ImportModelViewModel(ImportModelView view, IItemModel item, XivRace race, string submeshId, bool dataOnly, Action onComplete = null) { _view = view; _item = item; _race = race; _submeshId = submeshId; _dataOnly = dataOnly; _onComplete = onComplete; var gameDirectory = new DirectoryInfo(Settings.Default.FFXIV_Directory); var saveDirectory = new DirectoryInfo(Settings.Default.Save_Directory); var dataFile = IOUtil.GetDataFileFromPath(_item.GetItemRootFolder()); _mdl = new Mdl(gameDirectory, dataFile); _importers = _mdl.GetAvailableImporters(); // We need to explicitly fork this onto a new thread to avoid deadlock. Task.Run(AssignPath).Wait(); var defaultPath = $"{IOUtil.MakeItemSavePath(_item, saveDirectory, _race)}\\3D"; defaultPath = defaultPath.Replace("/", "\\"); var modelName = Path.GetFileNameWithoutExtension(_internalPath); // Scan to see which file type(s) actually exist. bool foundValidFile = false; // FBX is default, so check that first. var startingPath = Path.Combine(defaultPath, modelName) + ".fbx"; if (File.Exists(startingPath)) { foundValidFile = true; } if (!foundValidFile) { foreach (var suffix in _importers) { startingPath = Path.Combine(defaultPath, modelName) + "." + suffix; if (File.Exists(startingPath)) { foundValidFile = true; break; } } } if (!foundValidFile) { startingPath = ""; } _view.FileNameTextBox.Text = startingPath; // Event Handlers _view.SelectFileButton.Click += SelectFileButton_Click; _view.ImportButton.Click += ImportButton_Click; _view.EditButton.Click += EditButton_Click; _view.Closing += _view_Closing; // Default Settings for specific categories. if (item.SecondaryCategory == XivStrings.Face) { _view.EnableShapeDataButton.IsChecked = true; } if (item.SecondaryCategory == XivStrings.Hair) { _view.CloneUV1Button.IsChecked = true; } var iType = item.GetPrimaryItemType(); if (iType == xivModdingFramework.Items.Enums.XivItemType.equipment || iType == xivModdingFramework.Items.Enums.XivItemType.accessory || iType == xivModdingFramework.Items.Enums.XivItemType.weapon) { _view.ForceUVsButton.IsChecked = true; } }