diff --git a/FModel/Settings/UserSettings.cs b/FModel/Settings/UserSettings.cs index 979e156e..f937b6d2 100644 --- a/FModel/Settings/UserSettings.cs +++ b/FModel/Settings/UserSettings.cs @@ -613,4 +613,11 @@ public sealed class UserSettings : ViewModel get => _exportAllTextureMips; set => SetProperty(ref _exportAllTextureMips, value); } + + private bool _exportImmediately; + public bool ExportImmediately + { + get => _exportImmediately; + set => SetProperty(ref _exportImmediately, value); + } } diff --git a/FModel/ViewModels/Commands/RightClickMenuCommand.cs b/FModel/ViewModels/Commands/RightClickMenuCommand.cs index 42e4e8a3..fc4babba 100644 --- a/FModel/ViewModels/Commands/RightClickMenuCommand.cs +++ b/FModel/ViewModels/Commands/RightClickMenuCommand.cs @@ -162,6 +162,11 @@ public class RightClickMenuCommand : ViewModelCommand } } }); + + if (action is EAction.Export) + { + await ExportSessionViewModel.Instance.ExportAutomaticallyAsync(); + } } private void LogExport(ApplicationViewModel contextViewModel, string directory, string path, string basePath, string fileType, int queuedBefore = 0) diff --git a/FModel/ViewModels/Commands/TabCommand.cs b/FModel/ViewModels/Commands/TabCommand.cs index d7789537..4259fcbc 100644 --- a/FModel/ViewModels/Commands/TabCommand.cs +++ b/FModel/ViewModels/Commands/TabCommand.cs @@ -1,3 +1,4 @@ +using System; using System.Windows; using AdonisUI.Controls; using FModel.Framework; @@ -105,5 +106,10 @@ public class TabCommand : ViewModelCommand Clipboard.SetText(tabViewModel.Entry.NameWithoutExtension); break; } + + if (parameter is string command && command.StartsWith("Save_", StringComparison.Ordinal)) // This is kinda bad + { + await ExportSessionViewModel.Instance.ExportAutomaticallyAsync(); + } } } diff --git a/FModel/ViewModels/ExportOptionsViewModel.cs b/FModel/ViewModels/ExportOptionsViewModel.cs index dbf16b7d..5f41ed1b 100644 --- a/FModel/ViewModels/ExportOptionsViewModel.cs +++ b/FModel/ViewModels/ExportOptionsViewModel.cs @@ -47,6 +47,13 @@ public class ExportOptionsViewModel : ViewModel set => SetProperty(ref field, value); } + public bool ShowExportImmediatelyOption { get; } + public bool ExportImmediately + { + get; + set => SetProperty(ref field, value); + } + public IEnumerable MeshFormats { get; } = Enum.GetValues(); public EMeshFormat SelectedMeshFormat { @@ -162,8 +169,9 @@ public class ExportOptionsViewModel : ViewModel set => SetProperty(ref field, value); } - public ExportOptionsViewModel() + public ExportOptionsViewModel(bool showExportImmediatelyOption = false) { + ShowExportImmediatelyOption = showExportImmediatelyOption; ResetToUserDefaults(); } @@ -183,6 +191,7 @@ public class ExportOptionsViewModel : ViewModel ExportMorphTargets = UserSettings.Default.SaveMorphTargets; TextureQuality = UserSettings.Default.TextureQuality; ExportAllTextureMips = UserSettings.Default.ExportAllTextureMips; + ExportImmediately = UserSettings.Default.ExportImmediately; OverrideOptions = false; FeedbackMessage = "Reset to defaults"; @@ -204,6 +213,7 @@ public class ExportOptionsViewModel : ViewModel UserSettings.Default.SaveMorphTargets = ExportMorphTargets; UserSettings.Default.TextureQuality = TextureQuality; UserSettings.Default.ExportAllTextureMips = ExportAllTextureMips; + UserSettings.Default.ExportImmediately = ExportImmediately; UserSettings.Save(); OverrideOptions = false; diff --git a/FModel/ViewModels/ExportSessionViewModel.cs b/FModel/ViewModels/ExportSessionViewModel.cs index 85693b51..6d225ef1 100644 --- a/FModel/ViewModels/ExportSessionViewModel.cs +++ b/FModel/ViewModels/ExportSessionViewModel.cs @@ -239,6 +239,14 @@ public class ExportSessionViewModel : ViewModel } } + public async Task ExportAutomaticallyAsync() + { + if (UserSettings.Default.ExportImmediately) + { + await ExportAsync(); + } + } + public void CancelExport() { _cts?.Cancel(); diff --git a/FModel/ViewModels/SettingsViewModel.cs b/FModel/ViewModels/SettingsViewModel.cs index fd5a97cf..0b91ff26 100644 --- a/FModel/ViewModels/SettingsViewModel.cs +++ b/FModel/ViewModels/SettingsViewModel.cs @@ -124,7 +124,7 @@ public class SettingsViewModel : ViewModel set => SetProperty(ref _unluacOpcodeMap, value); } - public ExportOptionsViewModel Options { get; } = new(); + public ExportOptionsViewModel Options { get; } = new(showExportImmediatelyOption: true); public ReadOnlyObservableCollection UeGames { get; private set; } public ReadOnlyObservableCollection AssetLanguages { get; private set; } diff --git a/FModel/Views/Resources/Controls/ExportOptionsControl.xaml b/FModel/Views/Resources/Controls/ExportOptionsControl.xaml index 2f1069c4..f245aa23 100644 --- a/FModel/Views/Resources/Controls/ExportOptionsControl.xaml +++ b/FModel/Views/Resources/Controls/ExportOptionsControl.xaml @@ -31,6 +31,7 @@ + @@ -45,10 +46,20 @@ Text="{Binding OutputDirectory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />