From fabc064a4618b7bd9ab3b7a9d3ffe58f93ab10e1 Mon Sep 17 00:00:00 2001 From: Asval Date: Mon, 29 Jul 2024 12:48:35 +0200 Subject: [PATCH] update ui --- FModel/FModel.csproj | 2 +- FModel/ViewModels/CUE4ParseViewModel.cs | 28 +++++++------------ .../Commands/RightClickMenuCommand.cs | 9 +++--- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/FModel/FModel.csproj b/FModel/FModel.csproj index be042452..145ff39c 100644 --- a/FModel/FModel.csproj +++ b/FModel/FModel.csproj @@ -152,7 +152,7 @@ - + diff --git a/FModel/ViewModels/CUE4ParseViewModel.cs b/FModel/ViewModels/CUE4ParseViewModel.cs index 23c1c7a3..623d48e2 100644 --- a/FModel/ViewModels/CUE4ParseViewModel.cs +++ b/FModel/ViewModels/CUE4ParseViewModel.cs @@ -847,7 +847,7 @@ public void ExtractAndScroll(CancellationToken cancellationToken, string fullPat case UAnimMontage when HasFlag(bulk, EBulkType.Animations): case UAnimComposite when HasFlag(bulk, EBulkType.Animations): { - SaveExport(export, HasFlag(bulk, EBulkType.Auto)); + SaveExport(export, updateUi); return true; } default: @@ -893,29 +893,21 @@ private void SaveAndPlaySound(string fullPath, string ext, byte[] data) }); } - private void SaveExport(UObject export, bool auto) + private void SaveExport(UObject export, bool updateUi = true) { var toSave = new Exporter(export, UserSettings.Default.ExportOptions); - - string dir; - if (!auto) - { - var folderBrowser = new VistaFolderBrowserDialog(); - if (folderBrowser.ShowDialog() == true) - dir = folderBrowser.SelectedPath; - else return; - } - else dir = UserSettings.Default.ModelDirectory; - - var toSaveDirectory = new DirectoryInfo(dir); + var toSaveDirectory = new DirectoryInfo(UserSettings.Default.ModelDirectory); if (toSave.TryWriteToDir(toSaveDirectory, out var label, out var savedFilePath)) { Log.Information("Successfully saved {FilePath}", savedFilePath); - FLogger.Append(ELog.Information, () => + if (updateUi) { - FLogger.Text("Successfully saved ", Constants.WHITE); - FLogger.Link(label, savedFilePath, true); - }); + FLogger.Append(ELog.Information, () => + { + FLogger.Text("Successfully saved ", Constants.WHITE); + FLogger.Link(label, savedFilePath, true); + }); + } } else { diff --git a/FModel/ViewModels/Commands/RightClickMenuCommand.cs b/FModel/ViewModels/Commands/RightClickMenuCommand.cs index ab009a4b..acb48897 100644 --- a/FModel/ViewModels/Commands/RightClickMenuCommand.cs +++ b/FModel/ViewModels/Commands/RightClickMenuCommand.cs @@ -22,6 +22,7 @@ public override async void Execute(ApplicationViewModel contextViewModel, object var assetItems = ((IList) parameters[1]).Cast().ToArray(); if (!assetItems.Any()) return; + var updateUi = assetItems.Length > 1 ? EBulkType.Auto : EBulkType.None; await _threadWorkerView.Begin(cancellationToken => { switch (trigger) @@ -47,7 +48,7 @@ await _threadWorkerView.Begin(cancellationToken => { Thread.Yield(); cancellationToken.ThrowIfCancellationRequested(); - contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, false, EBulkType.Properties); + contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, false, EBulkType.Properties | updateUi); } break; case "Assets_Save_Textures": @@ -55,7 +56,7 @@ await _threadWorkerView.Begin(cancellationToken => { Thread.Yield(); cancellationToken.ThrowIfCancellationRequested(); - contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, false, EBulkType.Textures); + contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, false, EBulkType.Textures | updateUi); } break; case "Assets_Save_Models": @@ -63,7 +64,7 @@ await _threadWorkerView.Begin(cancellationToken => { Thread.Yield(); cancellationToken.ThrowIfCancellationRequested(); - contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, false, EBulkType.Meshes | EBulkType.Auto); + contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, false, EBulkType.Meshes | updateUi); } break; case "Assets_Save_Animations": @@ -71,7 +72,7 @@ await _threadWorkerView.Begin(cancellationToken => { Thread.Yield(); cancellationToken.ThrowIfCancellationRequested(); - contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, false, EBulkType.Animations | EBulkType.Auto); + contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, false, EBulkType.Animations | updateUi); } break; }