diff --git a/FModel/Enums.cs b/FModel/Enums.cs index b99682d6..d8d12490 100644 --- a/FModel/Enums.cs +++ b/FModel/Enums.cs @@ -18,10 +18,9 @@ public enum EErrorKind public enum SettingsOut { - Restart, ReloadLocres, - CheckForUpdates, - Nothing + ReloadMappings, + CheckForUpdates } public enum EStatusKind diff --git a/FModel/ViewModels/SettingsViewModel.cs b/FModel/ViewModels/SettingsViewModel.cs index b06ecfc3..7ab634c9 100644 --- a/FModel/ViewModels/SettingsViewModel.cs +++ b/FModel/ViewModels/SettingsViewModel.cs @@ -182,6 +182,8 @@ public class SettingsViewModel : ViewModel private ELodFormat _lodExportFormatSnapshot; private ETextureFormat _textureExportFormatSnapshot; + private bool _mappingsUpdate = false; + public SettingsViewModel(FGame game) { _game = game; @@ -216,6 +218,11 @@ public class SettingsViewModel : ViewModel { AesEndpoint = endpoints[0]; MappingEndpoint = endpoints[1]; + MappingEndpoint.PropertyChanged += (sender, args) => + { + if (sender is FEndpoint endpoint && !_mappingsUpdate) + _mappingsUpdate = args.PropertyName is "Overwrite" or "FilePath" && endpoint.IsValid; + }; } _assetLanguageSnapshot = UserSettings.Default.AssetLanguage; @@ -294,9 +301,17 @@ public class SettingsViewModel : ViewModel SelectedOptions = _optionsSnapshot; } - public SettingsOut Save() + public bool Save(out List whatShouldIDo) { - var ret = SettingsOut.Nothing; + var restart = false; + whatShouldIDo = new List(); + + if (_assetLanguageSnapshot != SelectedAssetLanguage) + whatShouldIDo.Add(SettingsOut.ReloadLocres); + if (_mappingsUpdate) + whatShouldIDo.Add(SettingsOut.ReloadMappings); + if (_updateModeSnapshot != SelectedUpdateMode) + whatShouldIDo.Add(SettingsOut.CheckForUpdates); if (_ueGameSnapshot != SelectedUeGame || _customVersionsSnapshot != SelectedCustomVersions || _uePlatformSnapshot != SelectedUePlatform || _optionsSnapshot != SelectedOptions || // combobox @@ -307,13 +322,7 @@ public class SettingsViewModel : ViewModel _audioSnapshot != UserSettings.Default.AudioDirectory || // textbox _modelSnapshot != UserSettings.Default.ModelDirectory || // textbox _gameSnapshot != UserSettings.Default.GameDirectory) // textbox - ret = SettingsOut.Restart; - - if (_assetLanguageSnapshot != SelectedAssetLanguage) - ret = SettingsOut.ReloadLocres; - - if (_updateModeSnapshot != SelectedUpdateMode) - ret = SettingsOut.CheckForUpdates; + restart = true; UserSettings.Default.UpdateMode = SelectedUpdateMode; UserSettings.Default.Presets[_game] = SelectedPreset; @@ -343,7 +352,7 @@ public class SettingsViewModel : ViewModel if (SelectedDiscordRpc == EDiscordRpc.Never) _discordHandler.Shutdown(); - return ret; + return restart; } private IEnumerable EnumerateUpdateModes() => Enum.GetValues(); diff --git a/FModel/Views/SettingsView.xaml.cs b/FModel/Views/SettingsView.xaml.cs index d8875a72..4a95a771 100644 --- a/FModel/Views/SettingsView.xaml.cs +++ b/FModel/Views/SettingsView.xaml.cs @@ -37,21 +37,27 @@ public partial class SettingsView private async void OnClick(object sender, RoutedEventArgs e) { - var whatShouldIDo = _applicationView.SettingsView.Save(); - if (whatShouldIDo == SettingsOut.Restart) + var restart = _applicationView.SettingsView.Save(out var whatShouldIDo); + if (restart) _applicationView.RestartWithWarning(); Close(); - switch (whatShouldIDo) + foreach (var dOut in whatShouldIDo) { - case SettingsOut.ReloadLocres: - _applicationView.CUE4Parse.LocalizedResourcesCount = 0; - await _applicationView.CUE4Parse.LoadLocalizedResources(); - break; - case SettingsOut.CheckForUpdates: - ApplicationService.ApiEndpointView.FModelApi.CheckForUpdates(UserSettings.Default.UpdateMode); - break; + switch (dOut) + { + case SettingsOut.ReloadLocres: + _applicationView.CUE4Parse.LocalizedResourcesCount = 0; + await _applicationView.CUE4Parse.LoadLocalizedResources(); + break; + case SettingsOut.ReloadMappings: + await _applicationView.CUE4Parse.InitBenMappings(); + break; + case SettingsOut.CheckForUpdates: + ApplicationService.ApiEndpointView.FModelApi.CheckForUpdates(UserSettings.Default.UpdateMode); + break; + } } } @@ -98,7 +104,7 @@ public partial class SettingsView if (TryBrowse(out var path)) UserSettings.Default.ModelDirectory = path; } - private async void OnBrowseMappings(object sender, RoutedEventArgs e) + private void OnBrowseMappings(object sender, RoutedEventArgs e) { var openFileDialog = new OpenFileDialog { @@ -111,7 +117,6 @@ public partial class SettingsView return; _applicationView.SettingsView.MappingEndpoint.FilePath = openFileDialog.FileName; - await _applicationView.CUE4Parse.InitBenMappings(); } private bool TryBrowse(out string path)