From 011046aa22e1ec5ad31d441b8ff733c4e62dcf94 Mon Sep 17 00:00:00 2001 From: 4sval Date: Wed, 14 Jun 2023 21:39:27 +0200 Subject: [PATCH] and this is where problems begin --- CUE4Parse | 2 +- FModel/Creator/Utils.cs | 2 +- FModel/Settings/DirectorySettings.cs | 90 ++++++++ FModel/Settings/UserSettings.cs | 211 ++---------------- FModel/Settings/VersioningSettings.cs | 29 +++ FModel/ViewModels/ApplicationViewModel.cs | 56 ++--- FModel/ViewModels/CUE4ParseViewModel.cs | 96 +++----- FModel/ViewModels/Commands/MenuCommand.cs | 2 +- .../ViewModels/CustomDirectoriesViewModel.cs | 24 +- FModel/ViewModels/GameSelectorViewModel.cs | 101 ++++----- FModel/ViewModels/SettingsViewModel.cs | 130 +++-------- FModel/ViewModels/TabControlViewModel.cs | 2 +- FModel/Views/AesManager.xaml | 10 +- FModel/Views/DirectorySelector.xaml | 12 +- FModel/Views/DirectorySelector.xaml.cs | 4 +- .../Controls/DictionaryEditor.xaml.cs | 21 +- .../Converters/EndpointToTypeConverter.cs | 13 +- FModel/Views/SettingsView.xaml | 54 ++--- FModel/Views/SettingsView.xaml.cs | 27 +-- FModel/Views/Snooper/Options.cs | 4 +- 20 files changed, 333 insertions(+), 557 deletions(-) create mode 100644 FModel/Settings/DirectorySettings.cs create mode 100644 FModel/Settings/VersioningSettings.cs diff --git a/CUE4Parse b/CUE4Parse index eb9ad66c..fb4e3d5f 160000 --- a/CUE4Parse +++ b/CUE4Parse @@ -1 +1 @@ -Subproject commit eb9ad66c5b1be089ea2b92f33dd299b291e13de1 +Subproject commit fb4e3d5f2fcae1b761dee4eed311a1b132ac5735 diff --git a/FModel/Creator/Utils.cs b/FModel/Creator/Utils.cs index 410b3ac9..0eeec083 100644 --- a/FModel/Creator/Utils.cs +++ b/FModel/Creator/Utils.cs @@ -112,7 +112,7 @@ public static SKBitmap GetBitmap(UMaterialInstanceConstant material) public static SKBitmap GetB64Bitmap(string b64) => SKBitmap.Decode(new MemoryStream(Convert.FromBase64String(b64)) { Position = 0 }); public static SKBitmap GetBitmap(FSoftObjectPath softObjectPath) => GetBitmap(softObjectPath.AssetPathName.Text); public static SKBitmap GetBitmap(string fullPath) => TryLoadObject(fullPath, out UTexture2D texture) ? GetBitmap(texture) : null; - public static SKBitmap GetBitmap(UTexture2D texture) => texture.IsVirtual ? null : texture.Decode(UserSettings.Default.OverridedPlatform); + public static SKBitmap GetBitmap(UTexture2D texture) => texture.IsVirtual ? null : texture.Decode(UserSettings.Default.CurrentDir.TexturePlatform); public static SKBitmap GetBitmap(byte[] data) => SKBitmap.Decode(data); public static SKBitmap ResizeWithRatio(this SKBitmap me, double width, double height) diff --git a/FModel/Settings/DirectorySettings.cs b/FModel/Settings/DirectorySettings.cs new file mode 100644 index 00000000..6023cec4 --- /dev/null +++ b/FModel/Settings/DirectorySettings.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using CUE4Parse.UE4.Assets.Exports.Texture; +using CUE4Parse.UE4.Versions; +using FModel.Framework; +using FModel.ViewModels; +using FModel.ViewModels.ApiEndpoints.Models; + +namespace FModel.Settings; + +public class DirectorySettings : ViewModel +{ + private string _gameName; + public string GameName + { + get => _gameName; + set => SetProperty(ref _gameName, value); + } + + private string _gameDirectory; + public string GameDirectory + { + get => _gameDirectory; + set => SetProperty(ref _gameDirectory, value); + } + + private bool _isManual; + public bool IsManual + { + get => _isManual; + set => SetProperty(ref _isManual, value); + } + + private EGame _ueVersion = EGame.GAME_UE4_LATEST; + public EGame UeVersion + { + get => _ueVersion; + set => SetProperty(ref _ueVersion, value); + } + + private ETexturePlatform _texturePlatform = ETexturePlatform.DesktopMobile; + public ETexturePlatform TexturePlatform + { + get => _texturePlatform; + set => SetProperty(ref _texturePlatform, value); + } + + private AesResponse _aesKeys; + public AesResponse AesKeys + { + get => _aesKeys; + set => SetProperty(ref _aesKeys, value); + } + + private VersioningSettings _versioning = new (); + public VersioningSettings Versioning + { + get => _versioning; + set => SetProperty(ref _versioning, value); + } + + private FEndpoint[] _endpoints = { new (), new () }; + public FEndpoint[] Endpoints + { + get => _endpoints; + set => SetProperty(ref _endpoints, value); + } + + private IList _directories = new List(); + public IList Directories + { + get => _directories; + set => SetProperty(ref _directories, value); + } + + private bool Equals(DirectorySettings other) + { + return GameDirectory == other.GameDirectory && UeVersion == other.UeVersion; + } + + public override bool Equals(object obj) + { + return obj is DirectorySettings other && Equals(other); + } + + public override int GetHashCode() + { + return HashCode.Combine(GameDirectory, (int) UeVersion); + } +} diff --git a/FModel/Settings/UserSettings.cs b/FModel/Settings/UserSettings.cs index 99af5eef..617d40e2 100644 --- a/FModel/Settings/UserSettings.cs +++ b/FModel/Settings/UserSettings.cs @@ -33,6 +33,7 @@ static UserSettings() public static void Save() { + Default.PerDirectory[Default.CurrentDir.GameDirectory] = Default.CurrentDir; File.WriteAllText(FilePath, JsonConvert.SerializeObject(Default, Formatting.Indented)); } @@ -41,13 +42,9 @@ public static void Delete() if (File.Exists(FilePath)) File.Delete(FilePath); } - public static bool IsEndpointValid(FGame game, EEndpointType type, out FEndpoint endpoint) + public static bool IsEndpointValid(EEndpointType type, out FEndpoint endpoint) { - endpoint = null; - if (!Default.CustomEndpoints.TryGetValue(game, out var endpoints)) - return false; - - endpoint = endpoints[(int) type]; + endpoint = Default.CurrentDir.Endpoints[(int) type]; return endpoint.Overwrite || endpoint.IsValid; } @@ -100,7 +97,7 @@ public string ModelDirectory set => SetProperty(ref _modelDirectory, value); } - private string _gameDirectory; + private string _gameDirectory = string.Empty; public string GameDirectory { get => _gameDirectory; @@ -135,13 +132,6 @@ public GridLength AvalonImageSize set => SetProperty(ref _avalonImageSize, value); } - private IDictionary _aesKeys = new Dictionary(); - public IDictionary AesKeys - { - get => _aesKeys; - set => SetProperty(ref _aesKeys, value); - } - private string _audioDeviceId; public string AudioDeviceId { @@ -233,177 +223,34 @@ public bool ReadScriptData set => SetProperty(ref _readScriptData, value); } - // - // can't refactor to use this data layout for everything - // because it will wipe old user settings that relies on FGame - private IDictionary _manualGames = new Dictionary(); - public IDictionary ManualGames + private IDictionary _perDirectory = new Dictionary(); + public IDictionary PerDirectory { - get => _manualGames; - set => SetProperty(ref _manualGames, value); + get => _perDirectory; + set => SetProperty(ref _perDirectory, value); } - private ETexturePlatform _overridedPlatform = ETexturePlatform.DesktopMobile; - public ETexturePlatform OverridedPlatform - { - get => _overridedPlatform; - set => SetProperty(ref _overridedPlatform, value); - } - - private IDictionary _presets = new Dictionary - { - {FGame.Unknown, Constants._NO_PRESET_TRIGGER}, - {FGame.FortniteGame, Constants._NO_PRESET_TRIGGER}, - {FGame.ShooterGame, Constants._NO_PRESET_TRIGGER}, - {FGame.DeadByDaylight, Constants._NO_PRESET_TRIGGER}, - {FGame.OakGame, Constants._NO_PRESET_TRIGGER}, - {FGame.Dungeons, Constants._NO_PRESET_TRIGGER}, - {FGame.WorldExplorers, Constants._NO_PRESET_TRIGGER}, - {FGame.g3, Constants._NO_PRESET_TRIGGER}, - {FGame.StateOfDecay2, Constants._NO_PRESET_TRIGGER}, - {FGame.Prospect, Constants._NO_PRESET_TRIGGER}, - {FGame.Indiana, Constants._NO_PRESET_TRIGGER}, - {FGame.RogueCompany, Constants._NO_PRESET_TRIGGER}, - {FGame.SwGame, Constants._NO_PRESET_TRIGGER}, - {FGame.Platform, Constants._NO_PRESET_TRIGGER}, - {FGame.BendGame, Constants._NO_PRESET_TRIGGER}, - {FGame.TslGame, Constants._NO_PRESET_TRIGGER}, - {FGame.PortalWars, Constants._NO_PRESET_TRIGGER}, - {FGame.Gameface, Constants._NO_PRESET_TRIGGER}, - {FGame.Athena, Constants._NO_PRESET_TRIGGER}, - {FGame.MultiVersus, Constants._NO_PRESET_TRIGGER}, - {FGame.Hotta, Constants._NO_PRESET_TRIGGER}, - {FGame.eFootball, Constants._NO_PRESET_TRIGGER} - }; - public IDictionary Presets - { - get => _presets; - set => SetProperty(ref _presets, value); - } - - private IDictionary _overridedGame = new Dictionary - { - {FGame.Unknown, EGame.GAME_UE4_LATEST}, - {FGame.FortniteGame, EGame.GAME_UE5_2}, - {FGame.ShooterGame, EGame.GAME_Valorant}, - {FGame.DeadByDaylight, EGame.GAME_UE4_27}, - {FGame.OakGame, EGame.GAME_Borderlands3}, - {FGame.Dungeons, EGame.GAME_UE4_22}, - {FGame.WorldExplorers, EGame.GAME_UE4_24}, - {FGame.g3, EGame.GAME_UE4_22}, - {FGame.StateOfDecay2, EGame.GAME_StateOfDecay2}, - {FGame.Prospect, EGame.GAME_Splitgate}, - {FGame.Indiana, EGame.GAME_UE4_21}, - {FGame.RogueCompany, EGame.GAME_RogueCompany}, - {FGame.SwGame, EGame.GAME_UE4_LATEST}, - {FGame.Platform, EGame.GAME_UE4_26}, - {FGame.BendGame, EGame.GAME_UE4_11}, - {FGame.TslGame, EGame.GAME_PlayerUnknownsBattlegrounds}, - {FGame.PortalWars, EGame.GAME_UE4_27}, - {FGame.Gameface, EGame.GAME_GTATheTrilogyDefinitiveEdition}, - {FGame.Athena, EGame.GAME_SeaOfThieves}, - {FGame.MultiVersus, EGame.GAME_UE4_26}, - {FGame.Hotta, EGame.GAME_TowerOfFantasy}, - {FGame.eFootball, EGame.GAME_UE4_26} - }; - public IDictionary OverridedGame - { - get => _overridedGame; - set => SetProperty(ref _overridedGame, value); - } - - private IDictionary> _overridedCustomVersions = new Dictionary> - { - {FGame.Unknown, null}, - {FGame.FortniteGame, null}, - {FGame.ShooterGame, null}, - {FGame.DeadByDaylight, null}, - {FGame.OakGame, null}, - {FGame.Dungeons, null}, - {FGame.WorldExplorers, null}, - {FGame.g3, null}, - {FGame.StateOfDecay2, null}, - {FGame.Prospect, null}, - {FGame.Indiana, null}, - {FGame.RogueCompany, null}, - {FGame.SwGame, null}, - {FGame.Platform, null}, - {FGame.BendGame, null}, - {FGame.TslGame, null}, - {FGame.PortalWars, null}, - {FGame.Gameface, null}, - {FGame.Athena, null}, - {FGame.MultiVersus, null}, - {FGame.Hotta, null}, - {FGame.eFootball, null} - }; - public IDictionary> OverridedCustomVersions - { - get => _overridedCustomVersions; - set => SetProperty(ref _overridedCustomVersions, value); - } - - private IDictionary> _overridedOptions = new Dictionary> - { - {FGame.Unknown, null}, - {FGame.FortniteGame, null}, - {FGame.ShooterGame, null}, - {FGame.DeadByDaylight, null}, - {FGame.OakGame, null}, - {FGame.Dungeons, null}, - {FGame.WorldExplorers, null}, - {FGame.g3, null}, - {FGame.StateOfDecay2, null}, - {FGame.Prospect, null}, - {FGame.Indiana, null}, - {FGame.RogueCompany, null}, - {FGame.SwGame, null}, - {FGame.Platform, null}, - {FGame.BendGame, null}, - {FGame.TslGame, null}, - {FGame.PortalWars, null}, - {FGame.Gameface, null}, - {FGame.Athena, null}, - {FGame.MultiVersus, null}, - {FGame.Hotta, null}, - {FGame.eFootball, null} - }; + public DirectorySettings CurrentDir { get; set; } - private IDictionary>> _overridedMapStructTypes = new Dictionary>> - { - {FGame.Unknown, null}, - {FGame.FortniteGame, null}, - {FGame.ShooterGame, null}, - {FGame.DeadByDaylight, null}, - {FGame.OakGame, null}, - {FGame.Dungeons, null}, - {FGame.WorldExplorers, null}, - {FGame.g3, null}, - {FGame.StateOfDecay2, null}, - {FGame.Prospect, null}, - {FGame.Indiana, null}, - {FGame.RogueCompany, null}, - {FGame.SwGame, null}, - {FGame.Platform, null}, - {FGame.BendGame, null}, - {FGame.TslGame, null}, - {FGame.PortalWars, null}, - {FGame.Gameface, null}, - {FGame.Athena, null}, - {FGame.MultiVersus, null}, - {FGame.Hotta, null}, - {FGame.eFootball, null} - }; - public IDictionary> OverridedOptions + /// + /// TO DELETEEEEEEEEEEEEE + /// + + private IDictionary _aesKeys = new Dictionary(); + public IDictionary AesKeys { - get => _overridedOptions; - set => SetProperty(ref _overridedOptions, value); + get => _aesKeys; + set => SetProperty(ref _aesKeys, value); } - public IDictionary>> OverridedMapStructTypes + // + // can't refactor to use this data layout for everything + // because it will wipe old user settings that relies on FGame + private IDictionary _manualGames = new Dictionary(); + public IDictionary ManualGames { - get => _overridedMapStructTypes; - set => SetProperty(ref _overridedMapStructTypes, value); + get => _manualGames; + set => SetProperty(ref _manualGames, value); } private IDictionary _customEndpoints = new Dictionary @@ -437,11 +284,6 @@ public IDictionary>> Over {FGame.Hotta, new FEndpoint[]{new (), new ()}}, {FGame.eFootball, new FEndpoint[]{new (), new ()}} }; - public IDictionary CustomEndpoints - { - get => _customEndpoints; - set => SetProperty(ref _customEndpoints, value); - } private IDictionary> _customDirectories = new Dictionary> { @@ -515,11 +357,6 @@ public IDictionary CustomEndpoints {FGame.Hotta, new List()}, {FGame.eFootball, new List()} }; - public IDictionary> CustomDirectories - { - get => _customDirectories; - set => SetProperty(ref _customDirectories, value); - } private DateTime _lastAesReload = DateTime.Today.AddDays(-1); public DateTime LastAesReload diff --git a/FModel/Settings/VersioningSettings.cs b/FModel/Settings/VersioningSettings.cs new file mode 100644 index 00000000..6092e5b3 --- /dev/null +++ b/FModel/Settings/VersioningSettings.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using CUE4Parse.UE4.Objects.Core.Serialization; +using FModel.Framework; + +namespace FModel.Settings; + +public class VersioningSettings : ViewModel +{ + private IList _customVersions; + public IList CustomVersions + { + get => _customVersions; + set => SetProperty(ref _customVersions, value); + } + + private IDictionary _options; + public IDictionary Options + { + get => _options; + set => SetProperty(ref _options, value); + } + + private IDictionary> _mapStructTypes; + public IDictionary> MapStructTypes + { + get => _mapStructTypes; + set => SetProperty(ref _mapStructTypes, value); + } +} diff --git a/FModel/ViewModels/ApplicationViewModel.cs b/FModel/ViewModels/ApplicationViewModel.cs index 7db8e534..8c342336 100644 --- a/FModel/ViewModels/ApplicationViewModel.cs +++ b/FModel/ViewModels/ApplicationViewModel.cs @@ -48,9 +48,7 @@ public FStatus Status public string InitialWindowTitle => $"FModel {UserSettings.Default.UpdateMode}"; public string GameDisplayName => CUE4Parse.Provider.GameDisplayName ?? "Unknown"; - public string TitleExtra => - $"({(CUE4Parse.Game == FGame.Unknown && UserSettings.Default.ManualGames.TryGetValue(UserSettings.Default.GameDirectory, out var settings) ? settings.OverridedGame : UserSettings.Default.OverridedGame[CUE4Parse.Game])})" + - $"{(Build != EBuildKind.Release ? $" ({Build})" : "")}"; + public string TitleExtra => $"({UserSettings.Default.CurrentDir.UeVersion}){(Build != EBuildKind.Release ? $" ({Build})" : "")}"; public LoadingModesViewModel LoadingModes { get; } public CustomDirectoriesViewModel CustomDirectories { get; } @@ -73,51 +71,41 @@ public ApplicationViewModel() #endif LoadingModes = new LoadingModesViewModel(); - AvoidEmptyGameDirectoryAndSetEGame(false); - if (UserSettings.Default.GameDirectory is null) + UserSettings.Default.CurrentDir = AvoidEmptyGameDirectory(false); + if (UserSettings.Default.CurrentDir is null) { //If no game is selected, many things will break before a shutdown request is processed in the normal way. //A hard exit is preferable to an unhandled expection in this case Environment.Exit(0); } - CUE4Parse = new CUE4ParseViewModel(UserSettings.Default.GameDirectory); - CustomDirectories = new CustomDirectoriesViewModel(CUE4Parse.Game, UserSettings.Default.GameDirectory); + CUE4Parse = new CUE4ParseViewModel(); + CustomDirectories = new CustomDirectoriesViewModel(); SettingsView = new SettingsViewModel(CUE4Parse.Game); AesManager = new AesManagerViewModel(CUE4Parse); MapViewer = new MapViewerViewModel(CUE4Parse); AudioPlayer = new AudioPlayerViewModel(); + Status.SetStatus(EStatusKind.Ready); } - public void AvoidEmptyGameDirectoryAndSetEGame(bool bAlreadyLaunched) + public DirectorySettings AvoidEmptyGameDirectory(bool bAlreadyLaunched) { var gameDirectory = UserSettings.Default.GameDirectory; - if (!string.IsNullOrEmpty(gameDirectory) && !bAlreadyLaunched) return; + if (!bAlreadyLaunched && UserSettings.Default.PerDirectory.TryGetValue(gameDirectory, out var currentDir)) + return currentDir; var gameLauncherViewModel = new GameSelectorViewModel(gameDirectory); var result = new DirectorySelector(gameLauncherViewModel).ShowDialog(); - if (!result.HasValue || !result.Value) return; + if (!result.HasValue || !result.Value) return null; - UserSettings.Default.GameDirectory = gameLauncherViewModel.SelectedDetectedGame.GameDirectory; - // UserSettings.Default.GameDirectory = gameLauncherViewModel.SelectedDetectedGame.OverridedGame; - if (!bAlreadyLaunched || gameDirectory == gameLauncherViewModel.SelectedDetectedGame.GameDirectory) return; + UserSettings.Default.GameDirectory = gameLauncherViewModel.SelectedDirectory.GameDirectory; + UserSettings.Default.PerDirectory[gameDirectory] = gameLauncherViewModel.SelectedDirectory; + if (!bAlreadyLaunched || UserSettings.Default.CurrentDir.Equals(gameLauncherViewModel.SelectedDirectory)) + return gameLauncherViewModel.SelectedDirectory; RestartWithWarning(); - } - - public async Task UpdateProvider(bool isLaunch) - { - if (!isLaunch && !AesManager.HasChange) return; - - CUE4Parse.ClearProvider(); - await ApplicationService.ThreadWorkerView.Begin(cancellationToken => - { - CUE4Parse.LoadVfs(cancellationToken, AesManager.AesKeys); - CUE4Parse.Provider.LoadIniConfigs(); - AesManager.SetAesKeys(); - }); - RaisePropertyChanged(nameof(GameDisplayName)); + return null; } public void RestartWithWarning() @@ -162,6 +150,20 @@ public void Restart() Application.Current.Shutdown(); } + public async Task UpdateProvider(bool isLaunch) + { + if (!isLaunch && !AesManager.HasChange) return; + + CUE4Parse.ClearProvider(); + await ApplicationService.ThreadWorkerView.Begin(cancellationToken => + { + CUE4Parse.LoadVfs(cancellationToken, AesManager.AesKeys); + CUE4Parse.Provider.LoadIniConfigs(); + AesManager.SetAesKeys(); + }); + RaisePropertyChanged(nameof(GameDisplayName)); + } + public async Task InitVgmStream() { var vgmZipFilePath = Path.Combine(UserSettings.Default.OutputDirectory, ".data", "vgmstream-win.zip"); diff --git a/FModel/ViewModels/CUE4ParseViewModel.cs b/FModel/ViewModels/CUE4ParseViewModel.cs index e07fb076..b2061531 100644 --- a/FModel/ViewModels/CUE4ParseViewModel.cs +++ b/FModel/ViewModels/CUE4ParseViewModel.cs @@ -123,84 +123,58 @@ public Snooper SnooperViewer public TabControlViewModel TabControl { get; } public ConfigIni BuildInfo { get; } - public CUE4ParseViewModel(string gameDirectory) + public CUE4ParseViewModel() { + var currentDir = UserSettings.Default.CurrentDir; + var gameDirectory = currentDir.GameDirectory; + var versionContainer = new VersionContainer( + game: currentDir.UeVersion, platform: currentDir.TexturePlatform, + customVersions: new FCustomVersionContainer(currentDir.Versioning.CustomVersions), + optionOverrides: currentDir.Versioning.Options, + mapStructTypesOverrides: currentDir.Versioning.MapStructTypes); + switch (gameDirectory) { case Constants._FN_LIVE_TRIGGER: { Game = FGame.FortniteGame; - Provider = new StreamedFileProvider("FortniteLive", true, - new VersionContainer( - UserSettings.Default.OverridedGame[Game], UserSettings.Default.OverridedPlatform, - customVersions: new FCustomVersionContainer(UserSettings.Default.OverridedCustomVersions[Game]), - optionOverrides: UserSettings.Default.OverridedOptions[Game])); + Provider = new StreamedFileProvider("FortniteLive", true, versionContainer); break; } case Constants._VAL_LIVE_TRIGGER: { Game = FGame.ShooterGame; - Provider = new StreamedFileProvider("ValorantLive", true, - new VersionContainer( - UserSettings.Default.OverridedGame[Game], UserSettings.Default.OverridedPlatform, - customVersions: new FCustomVersionContainer(UserSettings.Default.OverridedCustomVersions[Game]), - optionOverrides: UserSettings.Default.OverridedOptions[Game])); + Provider = new StreamedFileProvider("ValorantLive", true, versionContainer); break; } default: { - var parent = gameDirectory.SubstringBeforeLast("\\Content").SubstringAfterLast("\\"); - if (gameDirectory.Contains("eFootball")) parent = gameDirectory.SubstringBeforeLast("\\pak").SubstringAfterLast("\\"); + var parent = gameDirectory.SubstringBeforeLast(gameDirectory.Contains("eFootball") ? "\\pak" : "\\Content").SubstringAfterLast("\\"); Game = parent.ToEnum(FGame.Unknown); - var versions = new VersionContainer(UserSettings.Default.OverridedGame[Game], UserSettings.Default.OverridedPlatform, - customVersions: new FCustomVersionContainer(UserSettings.Default.OverridedCustomVersions[Game]), - optionOverrides: UserSettings.Default.OverridedOptions[Game], - mapStructTypesOverrides: UserSettings.Default.OverridedMapStructTypes[Game]); - - switch (Game) + Provider = Game switch { - case FGame.StateOfDecay2: - { - Provider = new DefaultFileProvider(new DirectoryInfo(gameDirectory), new List - { - new(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\StateOfDecay2\\Saved\\Paks"), - new(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\StateOfDecay2\\Saved\\DisabledPaks") - }, - SearchOption.AllDirectories, true, versions); - break; - } - case FGame.FortniteGame: - Provider = new DefaultFileProvider(new DirectoryInfo(gameDirectory), new List - { - new(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\FortniteGame\\Saved\\PersistentDownloadDir\\InstalledBundles"), - }, - SearchOption.AllDirectories, true, versions); - break; - case FGame.eFootball: - Provider = new DefaultFileProvider(new DirectoryInfo(gameDirectory), new List - { - new(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\KONAMI\\eFootball\\ST\\Download") - }, - SearchOption.AllDirectories, true, versions); - break; - case FGame.Unknown when UserSettings.Default.ManualGames.TryGetValue(gameDirectory, out var settings): - { - versions = new VersionContainer(settings.OverridedGame, UserSettings.Default.OverridedPlatform, - customVersions: new FCustomVersionContainer(settings.OverridedCustomVersions), - optionOverrides: settings.OverridedOptions, - mapStructTypesOverrides: settings.OverridedMapStructTypes); - goto default; - } - default: - { - Provider = new DefaultFileProvider(gameDirectory, SearchOption.AllDirectories, true, versions); - break; - } - } + FGame.StateOfDecay2 => new DefaultFileProvider(new DirectoryInfo(gameDirectory), + new List + { + new(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\StateOfDecay2\\Saved\\Paks"), + new(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\StateOfDecay2\\Saved\\DisabledPaks") + }, SearchOption.AllDirectories, true, versionContainer), + FGame.eFootball => new DefaultFileProvider(new DirectoryInfo(gameDirectory), + new List + { + new(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\KONAMI\\eFootball\\ST\\Download") + }, SearchOption.AllDirectories, true, versionContainer), + _ => new DefaultFileProvider(gameDirectory, SearchOption.AllDirectories, true, versionContainer) + }; break; } } + if (Game == FGame.FortniteGame) currentDir.Endpoints = new[] + { + new FEndpoint("https://fortnitecentral.genxgames.gg/api/v1/aes", "$.['mainKey','dynamicKeys']"), + new FEndpoint("https://fortnitecentral.genxgames.gg/api/v1/mappings", "$.[?(@.meta.compressionMethod=='Oodle')].['url','fileName']") + }; Provider.ReadScriptData = UserSettings.Default.ReadScriptData; GameDirectory = new GameDirectoryViewModel(); @@ -354,7 +328,7 @@ public async Task RefreshAes() { // game directory dependent, we don't have the provider game name yet since we don't have aes keys // except when this comes from the AES Manager - if (!UserSettings.IsEndpointValid(Game, EEndpointType.Aes, out var endpoint)) + if (!UserSettings.IsEndpointValid(EEndpointType.Aes, out var endpoint)) return; await _threadWorkerView.Begin(cancellationToken => @@ -385,7 +359,7 @@ await _threadWorkerView.Begin(cancellationToken => public Task InitMappings() { - if (!UserSettings.IsEndpointValid(Game, EEndpointType.Mapping, out var endpoint)) + if (!UserSettings.IsEndpointValid(EEndpointType.Mapping, out var endpoint)) { Provider.MappingsContainer = null; return Task.CompletedTask; @@ -604,7 +578,7 @@ public Task LoadVirtualPaths() if (_virtualPathCount > 0) return Task.CompletedTask; return Task.Run(() => { - _virtualPathCount = Provider.LoadVirtualPaths(UserSettings.Default.OverridedGame[Game].GetVersion()); + _virtualPathCount = Provider.LoadVirtualPaths(UserSettings.Default.CurrentDir.UeVersion.GetVersion()); if (_virtualPathCount > 0) { FLogger.Append(ELog.Information, () => @@ -1010,7 +984,7 @@ private void SaveExport(UObject export, bool auto) MaterialFormat = UserSettings.Default.MaterialExportFormat, TextureFormat = UserSettings.Default.TextureExportFormat, SocketFormat = UserSettings.Default.SocketExportFormat, - Platform = UserSettings.Default.OverridedPlatform, + Platform = UserSettings.Default.CurrentDir.TexturePlatform, ExportMorphTargets = UserSettings.Default.SaveMorphTargets }; var toSave = new Exporter(export, exportOptions); diff --git a/FModel/ViewModels/Commands/MenuCommand.cs b/FModel/ViewModels/Commands/MenuCommand.cs index f61dc8df..2081345f 100644 --- a/FModel/ViewModels/Commands/MenuCommand.cs +++ b/FModel/ViewModels/Commands/MenuCommand.cs @@ -23,7 +23,7 @@ public override async void Execute(ApplicationViewModel contextViewModel, object switch (parameter) { case "Directory_Selector": - contextViewModel.AvoidEmptyGameDirectoryAndSetEGame(true); + contextViewModel.AvoidEmptyGameDirectory(true); break; case "Directory_AES": Helper.OpenWindow("AES Manager", () => new AesManager().Show()); diff --git a/FModel/ViewModels/CustomDirectoriesViewModel.cs b/FModel/ViewModels/CustomDirectoriesViewModel.cs index 84efe771..279a77b7 100644 --- a/FModel/ViewModels/CustomDirectoriesViewModel.cs +++ b/FModel/ViewModels/CustomDirectoriesViewModel.cs @@ -54,13 +54,8 @@ public class CustomDirectoriesViewModel : ViewModel private readonly ObservableCollection _directories; public ReadOnlyObservableCollection Directories { get; } - private readonly FGame _game; - private readonly string _gameDirectoryAtLaunch; - - public CustomDirectoriesViewModel(FGame game, string directory) + public CustomDirectoriesViewModel() { - _game = game; - _gameDirectoryAtLaunch = directory; _directories = new ObservableCollection(EnumerateDirectories()); Directories = new ReadOnlyObservableCollection(_directories); } @@ -91,16 +86,14 @@ public void Delete(int index) public void Save() { - var cd = new List(); + var directories = new List(); for (var i = 2; i < _directories.Count; i++) { if (_directories[i] is not MenuItem m) continue; - cd.Add(new CustomDirectory(m.Header.ToString(), m.Tag.ToString())); + directories.Add(new CustomDirectory(m.Header.ToString(), m.Tag.ToString())); } - if (_game == FGame.Unknown && UserSettings.Default.ManualGames.ContainsKey(_gameDirectoryAtLaunch)) - UserSettings.Default.ManualGames[_gameDirectoryAtLaunch].CustomDirectories = cd; - else UserSettings.Default.CustomDirectories[_game] = cd; + UserSettings.Default.CurrentDir.Directories = directories; } private IEnumerable EnumerateDirectories() @@ -115,12 +108,7 @@ private IEnumerable EnumerateDirectories() }; yield return new Separator(); - IList cd; - if (_game == FGame.Unknown && UserSettings.Default.ManualGames.TryGetValue(_gameDirectoryAtLaunch, out var settings)) - cd = settings.CustomDirectories; - else cd = UserSettings.Default.CustomDirectories[_game]; - - foreach (var setting in cd) + foreach (var setting in UserSettings.Default.CurrentDir.Directories) { if (setting.DirectoryPath.EndsWith('/')) setting.DirectoryPath = setting.DirectoryPath[..^1]; @@ -167,4 +155,4 @@ private IEnumerable EnumerateCommands(CustomDirectory dir) CommandParameter = dir }; } -} \ No newline at end of file +} diff --git a/FModel/ViewModels/GameSelectorViewModel.cs b/FModel/ViewModels/GameSelectorViewModel.cs index 1202490e..bbf4f447 100644 --- a/FModel/ViewModels/GameSelectorViewModel.cs +++ b/FModel/ViewModels/GameSelectorViewModel.cs @@ -33,79 +33,58 @@ public class DetectedGame public IList CustomDirectories { get; set; } } - private DetectedGame _selectedDetectedGame; - public DetectedGame SelectedDetectedGame + private DirectorySettings _selectedDirectory; + public DirectorySettings SelectedDirectory { - get => _selectedDetectedGame; - set => SetProperty(ref _selectedDetectedGame, value); + get => _selectedDirectory; + set => SetProperty(ref _selectedDirectory, value); } - private readonly ObservableCollection _autoDetectedGames; - public ReadOnlyObservableCollection AutoDetectedGames { get; } - public ReadOnlyObservableCollection UeGames { get; private set; } + private readonly ObservableCollection _detectedDirectories; + public ReadOnlyObservableCollection DetectedDirectories { get; } + public ReadOnlyObservableCollection UeVersions { get; } public GameSelectorViewModel(string gameDirectory) { - _autoDetectedGames = new ObservableCollection(EnumerateDetectedGames().Where(x => x != null)); - foreach (var game in UserSettings.Default.ManualGames.Values) + _detectedDirectories = new ObservableCollection(EnumerateDetectedGames().Where(x => x != null)); + foreach (var dir in UserSettings.Default.PerDirectory.Values.Where(x => x.IsManual)) { - _autoDetectedGames.Add(game); + _detectedDirectories.Add(dir); } - AutoDetectedGames = new ReadOnlyObservableCollection(_autoDetectedGames); + DetectedDirectories = new ReadOnlyObservableCollection(_detectedDirectories); - if (AutoDetectedGames.FirstOrDefault(x => x.GameDirectory == gameDirectory) is { } detectedGame) - SelectedDetectedGame = detectedGame; + if (DetectedDirectories.FirstOrDefault(x => x.GameDirectory == gameDirectory) is { } detectedGame) + SelectedDirectory = detectedGame; else if (!string.IsNullOrEmpty(gameDirectory)) - AddUnknownGame(gameDirectory); + AddUndetectedDir(gameDirectory); else - SelectedDetectedGame = AutoDetectedGames.FirstOrDefault(); + SelectedDirectory = DetectedDirectories.FirstOrDefault(); - UeGames = new ReadOnlyObservableCollection(new ObservableCollection(EnumerateUeGames())); + UeVersions = new ReadOnlyObservableCollection(new ObservableCollection(EnumerateUeGames())); } - /// - /// dedicated to manual games - /// - public void AddUnknownGame(string gameName, string gameDirectory) + public void AddUndetectedDir(string gameDirectory) => AddUndetectedDir(gameDirectory.SubstringAfterLast('\\'), gameDirectory); + public void AddUndetectedDir(string gameName, string gameDirectory) { - var game = new DetectedGame - { - GameName = gameName, - GameDirectory = gameDirectory, - IsManual = true, - AesKeys = null, - OverridedGame = EGame.GAME_UE4_LATEST, - OverridedCustomVersions = null, - OverridedOptions = null, - OverridedMapStructTypes = null, - CustomDirectories = new List() - }; - - UserSettings.Default.ManualGames[gameDirectory] = game; - _autoDetectedGames.Add(game); - SelectedDetectedGame = AutoDetectedGames.Last(); - } - - public void AddUnknownGame(string gameDirectory) - { - _autoDetectedGames.Add(new DetectedGame { GameName = gameDirectory.SubstringAfterLast('\\'), GameDirectory = gameDirectory }); - SelectedDetectedGame = AutoDetectedGames.Last(); + var setting = new DirectorySettings { GameName = gameName, GameDirectory = gameDirectory, IsManual = true }; + UserSettings.Default.PerDirectory[gameDirectory] = setting; + _detectedDirectories.Add(setting); + SelectedDirectory = DetectedDirectories.Last(); } public void DeleteSelectedGame() { - UserSettings.Default.ManualGames.Remove(SelectedDetectedGame.GameDirectory); // should not be a problem - _autoDetectedGames.Remove(SelectedDetectedGame); - SelectedDetectedGame = AutoDetectedGames.Last(); + UserSettings.Default.PerDirectory.Remove(SelectedDirectory.GameDirectory); // should not be a problem + _detectedDirectories.Remove(SelectedDirectory); + SelectedDirectory = DetectedDirectories.Last(); } private IEnumerable EnumerateUeGames() => Enum.GetValues(); - - private IEnumerable EnumerateDetectedGames() + private IEnumerable EnumerateDetectedGames() { yield return GetUnrealEngineGame("Fortnite", "\\FortniteGame\\Content\\Paks", EGame.GAME_UE5_2); - yield return new DetectedGame { GameName = "Fortnite [LIVE]", GameDirectory = Constants._FN_LIVE_TRIGGER, OverridedGame = EGame.GAME_UE5_2 }; + yield return new DirectorySettings { GameName = "Fortnite [LIVE]", GameDirectory = Constants._FN_LIVE_TRIGGER, UeVersion = EGame.GAME_UE5_2 }; yield return GetUnrealEngineGame("Pewee", "\\RogueCompany\\Content\\Paks", EGame.GAME_RogueCompany); yield return GetUnrealEngineGame("Rosemallow", "\\Indiana\\Content\\Paks", EGame.GAME_UE4_21); yield return GetUnrealEngineGame("Catnip", "\\OakGame\\Content\\Paks", EGame.GAME_Borderlands3); @@ -115,7 +94,7 @@ private IEnumerable EnumerateDetectedGames() yield return GetUnrealEngineGame("711c5e95dc094ca58e5f16bd48e751d6", "\\MultiVersus\\Content\\Paks", EGame.GAME_UE4_26); yield return GetUnrealEngineGame("9361c8c6d2f34b42b5f2f61093eedf48", "\\TslGame\\Content\\Paks", EGame.GAME_PlayerUnknownsBattlegrounds); yield return GetRiotGame("VALORANT", "ShooterGame\\Content\\Paks", EGame.GAME_Valorant); - yield return new DetectedGame { GameName = "Valorant [LIVE]", GameDirectory = Constants._VAL_LIVE_TRIGGER, OverridedGame = EGame.GAME_Valorant }; + yield return new DirectorySettings { GameName = "Valorant [LIVE]", GameDirectory = Constants._VAL_LIVE_TRIGGER, UeVersion = EGame.GAME_Valorant }; yield return GetSteamGame(381210, "\\DeadByDaylight\\Content\\Paks", EGame.GAME_UE4_27); // Dead By Daylight yield return GetSteamGame(578080, "\\TslGame\\Content\\Paks", EGame.GAME_PlayerUnknownsBattlegrounds); // PUBG yield return GetSteamGame(1172380, "\\SwGame\\Content\\Paks", EGame.GAME_StarWarsJediFallenOrder); // STAR WARS Jedi: Fallen Order™ @@ -129,7 +108,7 @@ private IEnumerable EnumerateDetectedGames() } private LauncherInstalled _launcherInstalled; - private DetectedGame GetUnrealEngineGame(string gameName, string pakDirectory, EGame version) + private DirectorySettings GetUnrealEngineGame(string gameName, string pakDirectory, EGame ueVersion) { _launcherInstalled ??= GetDriveLauncherInstalls("ProgramData\\Epic\\UnrealEngineLauncher\\LauncherInstalled.dat"); if (_launcherInstalled?.InstallationList != null) @@ -140,7 +119,7 @@ private DetectedGame GetUnrealEngineGame(string gameName, string pakDirectory, E if (installationList.AppName.Equals(gameName, StringComparison.OrdinalIgnoreCase) && Directory.Exists(gameDir)) { Log.Debug("Found {GameName} in LauncherInstalled.dat", gameName); - return new DetectedGame { GameName = installationList.AppName, GameDirectory = gameDir, OverridedGame = version }; + return new DirectorySettings { GameName = installationList.AppName, GameDirectory = gameDir, UeVersion = ueVersion }; } } } @@ -149,7 +128,7 @@ private DetectedGame GetUnrealEngineGame(string gameName, string pakDirectory, E } private RiotClientInstalls _riotClientInstalls; - private DetectedGame GetRiotGame(string gameName, string pakDirectory, EGame version) + private DirectorySettings GetRiotGame(string gameName, string pakDirectory, EGame ueVersion) { _riotClientInstalls ??= GetDriveLauncherInstalls("ProgramData\\Riot Games\\RiotClientInstalls.json"); if (_riotClientInstalls is { AssociatedClient: { } }) @@ -160,7 +139,7 @@ private DetectedGame GetRiotGame(string gameName, string pakDirectory, EGame ver if (key.Contains(gameName, StringComparison.OrdinalIgnoreCase) && Directory.Exists(gameDir)) { Log.Debug("Found {GameName} in RiotClientInstalls.json", gameName); - return new DetectedGame { GameName = gameName, GameDirectory = gameDir, OverridedGame = version }; + return new DirectorySettings { GameName = gameName, GameDirectory = gameDir, UeVersion = ueVersion }; } } } @@ -169,7 +148,7 @@ private DetectedGame GetRiotGame(string gameName, string pakDirectory, EGame ver } private LauncherSettings _launcherSettings; - private DetectedGame GetMojangGame(string gameName, string pakDirectory, EGame version) + private DirectorySettings GetMojangGame(string gameName, string pakDirectory, EGame ueVersion) { _launcherSettings ??= GetDataLauncherInstalls("\\.minecraft\\launcher_settings.json"); if (_launcherSettings is { ProductLibraryDir: { } }) @@ -178,26 +157,26 @@ private DetectedGame GetMojangGame(string gameName, string pakDirectory, EGame v if (Directory.Exists(gameDir)) { Log.Debug("Found {GameName} in launcher_settings.json", gameName); - return new DetectedGame { GameName = gameName, GameDirectory = gameDir, OverridedGame = version }; + return new DirectorySettings { GameName = gameName, GameDirectory = gameDir, UeVersion = ueVersion }; } } return null; } - private DetectedGame GetSteamGame(int id, string pakDirectory, EGame version) + private DirectorySettings GetSteamGame(int id, string pakDirectory, EGame ueVersion) { var steamInfo = SteamDetection.GetSteamGameById(id); if (steamInfo is not null) { Log.Debug("Found {GameName} in steam manifests", steamInfo.Name); - return new DetectedGame { GameName = steamInfo.Name, GameDirectory = $"{steamInfo.GameRoot}{pakDirectory}", OverridedGame = version }; + return new DirectorySettings { GameName = steamInfo.Name, GameDirectory = $"{steamInfo.GameRoot}{pakDirectory}", UeVersion = ueVersion }; } return null; } - private DetectedGame GetRockstarGamesGame(string key, string pakDirectory, EGame version) + private DirectorySettings GetRockstarGamesGame(string key, string pakDirectory, EGame ueVersion) { var installLocation = string.Empty; try @@ -213,13 +192,13 @@ private DetectedGame GetRockstarGamesGame(string key, string pakDirectory, EGame if (Directory.Exists(gameDir)) { Log.Debug("Found {GameName} in the registry", key); - return new DetectedGame { GameName = key, GameDirectory = gameDir, OverridedGame = version }; + return new DirectorySettings { GameName = key, GameDirectory = gameDir, UeVersion = ueVersion }; } return null; } - private DetectedGame GetLevelInfiniteGame(string key, string pakDirectory, EGame version) + private DirectorySettings GetLevelInfiniteGame(string key, string pakDirectory, EGame ueVersion) { var installLocation = string.Empty; var displayName = string.Empty; @@ -238,7 +217,7 @@ private DetectedGame GetLevelInfiniteGame(string key, string pakDirectory, EGame if (Directory.Exists(gameDir)) { Log.Debug("Found {GameName} in the registry", key); - return new DetectedGame { GameName = displayName, GameDirectory = gameDir, OverridedGame = version }; + return new DirectorySettings { GameName = displayName, GameDirectory = gameDir, UeVersion = ueVersion }; } return null; diff --git a/FModel/ViewModels/SettingsViewModel.cs b/FModel/ViewModels/SettingsViewModel.cs index e74a96fb..4b130fb3 100644 --- a/FModel/ViewModels/SettingsViewModel.cs +++ b/FModel/ViewModels/SettingsViewModel.cs @@ -37,17 +37,6 @@ public EUpdateMode SelectedUpdateMode set => SetProperty(ref _selectedUpdateMode, value); } - private string _selectedPreset; - public string SelectedPreset - { - get => _selectedPreset; - set - { - SetProperty(ref _selectedPreset, value); - RaisePropertyChanged("EnableElements"); - } - } - private ETexturePlatform _selectedUePlatform; public ETexturePlatform SelectedUePlatform { @@ -62,22 +51,22 @@ public EGame SelectedUeGame set => SetProperty(ref _selectedUeGame, value); } - private List _selectedCustomVersions; - public List SelectedCustomVersions + private IList _selectedCustomVersions; + public IList SelectedCustomVersions { get => _selectedCustomVersions; set => SetProperty(ref _selectedCustomVersions, value); } - private Dictionary _selectedOptions; - public Dictionary SelectedOptions + private IDictionary _selectedOptions; + public IDictionary SelectedOptions { get => _selectedOptions; set => SetProperty(ref _selectedOptions, value); } - private Dictionary> _selectedMapStructTypes; - public Dictionary> SelectedMapStructTypes + private IDictionary> _selectedMapStructTypes; + public IDictionary> SelectedMapStructTypes { get => _selectedMapStructTypes; set => SetProperty(ref _selectedMapStructTypes, value); @@ -168,7 +157,6 @@ public ETextureFormat SelectedTextureExportFormat } public ReadOnlyObservableCollection UpdateModes { get; private set; } - public ObservableCollection Presets { get; private set; } public ReadOnlyObservableCollection UeGames { get; private set; } public ReadOnlyObservableCollection AssetLanguages { get; private set; } public ReadOnlyObservableCollection AesReloads { get; private set; } @@ -182,10 +170,7 @@ public ETextureFormat SelectedTextureExportFormat public ReadOnlyObservableCollection TextureExportFormats { get; private set; } public ReadOnlyObservableCollection Platforms { get; private set; } - public bool EnableElements => SelectedPreset == Constants._NO_PRESET_TRIGGER; - private readonly FGame _game; - private Game _gamePreset; private string _outputSnapshot; private string _rawDataSnapshot; private string _propertiesSnapshot; @@ -194,12 +179,11 @@ public ETextureFormat SelectedTextureExportFormat private string _modelSnapshot; private string _gameSnapshot; private EUpdateMode _updateModeSnapshot; - private string _presetSnapshot; private ETexturePlatform _uePlatformSnapshot; private EGame _ueGameSnapshot; - private List _customVersionsSnapshot; - private Dictionary _optionsSnapshot; - private Dictionary> _mapStructTypesSnapshot; + private IList _customVersionsSnapshot; + private IDictionary _optionsSnapshot; + private IDictionary> _mapStructTypesSnapshot; private ELanguage _assetLanguageSnapshot; private ECompressedAudio _compressedAudioSnapshot; private EIconStyle _cosmeticStyleSnapshot; @@ -226,8 +210,7 @@ public void Initialize() _modelSnapshot = UserSettings.Default.ModelDirectory; _gameSnapshot = UserSettings.Default.GameDirectory; _updateModeSnapshot = UserSettings.Default.UpdateMode; - _presetSnapshot = UserSettings.Default.Presets[_game]; - _uePlatformSnapshot = UserSettings.Default.OverridedPlatform; + _uePlatformSnapshot = UserSettings.Default.CurrentDir.TexturePlatform; if (_game == FGame.Unknown && UserSettings.Default.ManualGames.TryGetValue(_gameSnapshot, out var settings)) { _ueGameSnapshot = settings.OverridedGame; @@ -237,22 +220,19 @@ public void Initialize() } else { - _ueGameSnapshot = UserSettings.Default.OverridedGame[_game]; - _customVersionsSnapshot = UserSettings.Default.OverridedCustomVersions[_game]; - _optionsSnapshot = UserSettings.Default.OverridedOptions[_game]; - _mapStructTypesSnapshot = UserSettings.Default.OverridedMapStructTypes[_game]; + _ueGameSnapshot = UserSettings.Default.CurrentDir.UeVersion; + _customVersionsSnapshot = UserSettings.Default.CurrentDir.Versioning.CustomVersions; + _optionsSnapshot = UserSettings.Default.CurrentDir.Versioning.Options; + _mapStructTypesSnapshot = UserSettings.Default.CurrentDir.Versioning.MapStructTypes; } - if (UserSettings.Default.CustomEndpoints.TryGetValue(_game, out var endpoints)) + AesEndpoint = UserSettings.Default.CurrentDir.Endpoints[0]; + MappingEndpoint = UserSettings.Default.CurrentDir.Endpoints[1]; + MappingEndpoint.PropertyChanged += (_, args) => { - AesEndpoint = endpoints[0]; - MappingEndpoint = endpoints[1]; - MappingEndpoint.PropertyChanged += (_, args) => - { - if (!_mappingsUpdate) - _mappingsUpdate = args.PropertyName is "Overwrite" or "FilePath"; - }; - } + if (!_mappingsUpdate) + _mappingsUpdate = args.PropertyName is "Overwrite" or "FilePath"; + }; _assetLanguageSnapshot = UserSettings.Default.AssetLanguage; _compressedAudioSnapshot = UserSettings.Default.CompressedAudioMode; @@ -264,7 +244,6 @@ public void Initialize() _textureExportFormatSnapshot = UserSettings.Default.TextureExportFormat; SelectedUpdateMode = _updateModeSnapshot; - SelectedPreset = _presetSnapshot; SelectedUePlatform = _uePlatformSnapshot; SelectedUeGame = _ueGameSnapshot; SelectedCustomVersions = _customVersionsSnapshot; @@ -282,7 +261,6 @@ public void Initialize() SelectedDiscordRpc = UserSettings.Default.DiscordRpc; UpdateModes = new ReadOnlyObservableCollection(new ObservableCollection(EnumerateUpdateModes())); - Presets = new ObservableCollection(EnumeratePresets()); UeGames = new ReadOnlyObservableCollection(new ObservableCollection(EnumerateUeGames())); AssetLanguages = new ReadOnlyObservableCollection(new ObservableCollection(EnumerateAssetLanguages())); AesReloads = new ReadOnlyObservableCollection(new ObservableCollection(EnumerateAesReloads())); @@ -297,53 +275,6 @@ public void Initialize() Platforms = new ReadOnlyObservableCollection(new ObservableCollection(EnumerateUePlatforms())); } - public async Task InitPresets(string gameName) - { - await _threadWorkerView.Begin(cancellationToken => - { - if (string.IsNullOrEmpty(gameName)) return; - _gamePreset = _apiEndpointView.FModelApi.GetGames(cancellationToken, gameName); - }); - - if (_gamePreset?.Versions == null) return; - foreach (var version in _gamePreset.Versions.Keys) - { - Presets.Add(version); - } - } - - public void SwitchPreset(string key) - { - if (_gamePreset?.Versions == null || !_gamePreset.Versions.TryGetValue(key, out var version)) return; - SelectedUeGame = version.GameEnum.ToEnum(EGame.GAME_UE4_LATEST); - - SelectedCustomVersions = new List(); - foreach (var (guid, v) in version.CustomVersions) - { - SelectedCustomVersions.Add(new FCustomVersion { Key = new FGuid(guid), Version = v }); - } - - SelectedOptions = new Dictionary(); - foreach (var (k, v) in version.Options) - { - SelectedOptions[k] = v; - } - - SelectedMapStructTypes = new Dictionary>(); - foreach (var (k, v) in version.MapStructTypes) - { - SelectedMapStructTypes[k] = v; - } - } - - public void ResetPreset() - { - SelectedUeGame = _ueGameSnapshot; - SelectedCustomVersions = _customVersionsSnapshot; - SelectedOptions = _optionsSnapshot; - SelectedMapStructTypes = _mapStructTypesSnapshot; - } - public bool Save(out List whatShouldIDo) { var restart = false; @@ -369,21 +300,20 @@ public bool Save(out List whatShouldIDo) restart = true; UserSettings.Default.UpdateMode = SelectedUpdateMode; - UserSettings.Default.Presets[_game] = SelectedPreset; - UserSettings.Default.OverridedPlatform = SelectedUePlatform; + UserSettings.Default.CurrentDir.TexturePlatform = SelectedUePlatform; if (_game == FGame.Unknown && UserSettings.Default.ManualGames.ContainsKey(UserSettings.Default.GameDirectory)) { UserSettings.Default.ManualGames[UserSettings.Default.GameDirectory].OverridedGame = SelectedUeGame; - UserSettings.Default.ManualGames[UserSettings.Default.GameDirectory].OverridedCustomVersions = SelectedCustomVersions; - UserSettings.Default.ManualGames[UserSettings.Default.GameDirectory].OverridedOptions = SelectedOptions; - UserSettings.Default.ManualGames[UserSettings.Default.GameDirectory].OverridedMapStructTypes = SelectedMapStructTypes; + UserSettings.Default.ManualGames[UserSettings.Default.GameDirectory].OverridedCustomVersions = (List) SelectedCustomVersions; + UserSettings.Default.ManualGames[UserSettings.Default.GameDirectory].OverridedOptions = (Dictionary) SelectedOptions; + UserSettings.Default.ManualGames[UserSettings.Default.GameDirectory].OverridedMapStructTypes = (Dictionary>) SelectedMapStructTypes; } else { - UserSettings.Default.OverridedGame[_game] = SelectedUeGame; - UserSettings.Default.OverridedCustomVersions[_game] = SelectedCustomVersions; - UserSettings.Default.OverridedOptions[_game] = SelectedOptions; - UserSettings.Default.OverridedMapStructTypes[_game] = SelectedMapStructTypes; + UserSettings.Default.CurrentDir.UeVersion = SelectedUeGame; + UserSettings.Default.CurrentDir.Versioning.CustomVersions = SelectedCustomVersions; + UserSettings.Default.CurrentDir.Versioning.Options = SelectedOptions; + UserSettings.Default.CurrentDir.Versioning.MapStructTypes = SelectedMapStructTypes; } UserSettings.Default.AssetLanguage = SelectedAssetLanguage; @@ -404,10 +334,6 @@ public bool Save(out List whatShouldIDo) } private IEnumerable EnumerateUpdateModes() => Enum.GetValues(); - private IEnumerable EnumeratePresets() - { - yield return Constants._NO_PRESET_TRIGGER; - } private IEnumerable EnumerateUeGames() => Enum.GetValues(); private IEnumerable EnumerateAssetLanguages() => Enum.GetValues(); private IEnumerable EnumerateAesReloads() => Enum.GetValues(); diff --git a/FModel/ViewModels/TabControlViewModel.cs b/FModel/ViewModels/TabControlViewModel.cs index 3e603eb0..461dd34e 100644 --- a/FModel/ViewModels/TabControlViewModel.cs +++ b/FModel/ViewModels/TabControlViewModel.cs @@ -229,7 +229,7 @@ public void ClearImages() } public void AddImage(UTexture texture, bool save, bool updateUi) - => AddImage(texture.Name, texture.RenderNearestNeighbor, texture.Decode(UserSettings.Default.OverridedPlatform), save, updateUi); + => AddImage(texture.Name, texture.RenderNearestNeighbor, texture.Decode(UserSettings.Default.CurrentDir.TexturePlatform), save, updateUi); public void AddImage(string name, bool rnn, SKBitmap[] img, bool save, bool updateUi) { diff --git a/FModel/Views/AesManager.xaml b/FModel/Views/AesManager.xaml index f9a7e95f..1a720414 100644 --- a/FModel/Views/AesManager.xaml +++ b/FModel/Views/AesManager.xaml @@ -80,14 +80,8 @@ diff --git a/FModel/Views/DirectorySelector.xaml b/FModel/Views/DirectorySelector.xaml index eac9184b..b54fc840 100644 --- a/FModel/Views/DirectorySelector.xaml +++ b/FModel/Views/DirectorySelector.xaml @@ -51,8 +51,8 @@ - + @@ -61,8 +61,8 @@ - + @@ -71,11 +71,11 @@ - +