From f462b183ee94319c5ed6dd0287b9b2c7f91bfe8b Mon Sep 17 00:00:00 2001 From: iAmAsval Date: Fri, 6 Aug 2021 16:57:01 +0200 Subject: [PATCH] fn live + version presets --- CUE4Parse | 2 +- FModel/App.xaml.cs | 2 +- FModel/Creator/Utils.cs | 2 +- FModel/FModel.csproj | 2 +- FModel/Settings/UserSettings.cs | 24 ++++++++++ FModel/ViewModels/CUE4ParseViewModel.cs | 4 +- FModel/ViewModels/ModelViewerViewModel.cs | 2 +- FModel/ViewModels/SettingsViewModel.cs | 51 ++++++++++++++++++++++ FModel/ViewModels/ThreadWorkerViewModel.cs | 2 + FModel/Views/SettingsView.xaml | 41 ++++++++++++----- FModel/Views/SettingsView.xaml.cs | 12 +++++ 11 files changed, 125 insertions(+), 19 deletions(-) diff --git a/CUE4Parse b/CUE4Parse index ced99f10..059f4a06 160000 --- a/CUE4Parse +++ b/CUE4Parse @@ -1 +1 @@ -Subproject commit ced99f105fedb66084c4d9689110ea92a66c7751 +Subproject commit 059f4a06ed9eb84560f7cb2381b989ecc2c1f671 diff --git a/FModel/App.xaml.cs b/FModel/App.xaml.cs index 6d8751ec..7c485483 100644 --- a/FModel/App.xaml.cs +++ b/FModel/App.xaml.cs @@ -97,7 +97,7 @@ namespace FModel if (messageBox.Result == MessageBoxResult.Custom && (EErrorKind) messageBox.ButtonPressed.Id != EErrorKind.Ignore) { if ((EErrorKind) messageBox.ButtonPressed.Id == EErrorKind.ResetSettings) - UserSettings.Delete(); + UserSettings.Default = new UserSettings(); ApplicationService.ApplicationView.Restart(); } diff --git a/FModel/Creator/Utils.cs b/FModel/Creator/Utils.cs index 42b071c2..412329c3 100644 --- a/FModel/Creator/Utils.cs +++ b/FModel/Creator/Utils.cs @@ -251,7 +251,7 @@ namespace FModel.Creator if (string.IsNullOrEmpty(text)) return null; var spaceWidth = paint.MeasureText(" "); - var lines = text.Replace("\\n", "\n").Split('\n', StringSplitOptions.RemoveEmptyEntries); + var lines = text.Split('\n', StringSplitOptions.RemoveEmptyEntries); var ret = new List(lines.Length); foreach (var line in lines) diff --git a/FModel/FModel.csproj b/FModel/FModel.csproj index 368da109..c530ce97 100644 --- a/FModel/FModel.csproj +++ b/FModel/FModel.csproj @@ -107,7 +107,7 @@ - + diff --git a/FModel/Settings/UserSettings.cs b/FModel/Settings/UserSettings.cs index add5372c..d617661a 100644 --- a/FModel/Settings/UserSettings.cs +++ b/FModel/Settings/UserSettings.cs @@ -204,6 +204,30 @@ namespace FModel.Settings set => SetProperty(ref _imageMergerMargin, value); } + private IDictionary _presets = new Dictionary + { + {FGame.Unknown, "None"}, + {FGame.FortniteGame, "None"}, + {FGame.ShooterGame, "None"}, + {FGame.DeadByDaylight, "None"}, + {FGame.OakGame, "None"}, + {FGame.Dungeons, "None"}, + {FGame.WorldExplorers, "None"}, + {FGame.g3, "None"}, + {FGame.StateOfDecay2, "None"}, + {FGame.Prospect, "None"}, + {FGame.Indiana, "None"}, + {FGame.RogueCompany, "None"}, + {FGame.SwGame, "None"}, + {FGame.Platform, "None"}, + {FGame.BendGame, "None"} + }; + public IDictionary Presets + { + get => _presets; + set => SetProperty(ref _presets, value); + } + private IDictionary _overridedGame = new Dictionary { {FGame.Unknown, EGame.GAME_UE4_LATEST}, diff --git a/FModel/ViewModels/CUE4ParseViewModel.cs b/FModel/ViewModels/CUE4ParseViewModel.cs index 06aaa1bc..b3ff68a3 100644 --- a/FModel/ViewModels/CUE4ParseViewModel.cs +++ b/FModel/ViewModels/CUE4ParseViewModel.cs @@ -6,7 +6,6 @@ using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Windows; -using System.Windows.Media; using AdonisUI.Controls; using CUE4Parse.Encryption.Aes; using CUE4Parse.FileProvider; @@ -21,7 +20,6 @@ using CUE4Parse.UE4.Assets.Exports.StaticMesh; using CUE4Parse.UE4.Assets.Exports.Texture; using CUE4Parse.UE4.Assets.Exports.Wwise; using CUE4Parse.UE4.Localization; -using CUE4Parse.UE4.Objects.UObject; using CUE4Parse.UE4.Oodle.Objects; using CUE4Parse.UE4.Shaders; using CUE4Parse.UE4.Versions; @@ -139,7 +137,7 @@ namespace FModel.ViewModels var manifest = new Manifest(manifestData, new ManifestOptions { - ChunkBaseUri = new Uri("http://epicgames-download1.akamaized.net/Builds/Fortnite/CloudDir/ChunksV3/", UriKind.Absolute), + ChunkBaseUri = new Uri("http://epicgames-download1.akamaized.net/Builds/Fortnite/CloudDir/ChunksV4/", UriKind.Absolute), ChunkCacheDirectory = chunksDir }); diff --git a/FModel/ViewModels/ModelViewerViewModel.cs b/FModel/ViewModels/ModelViewerViewModel.cs index 14af0bc0..29140f8b 100644 --- a/FModel/ViewModels/ModelViewerViewModel.cs +++ b/FModel/ViewModels/ModelViewerViewModel.cs @@ -185,7 +185,7 @@ namespace FModel.ViewModels { if (sections[j].Material == null || !sections[j].Material.TryLoad(out var unrealMaterial)) continue; - + var parameters = new CMaterialParams(); unrealMaterial.GetParams(parameters); if (parameters.Diffuse is not UTexture2D diffuse) continue; diff --git a/FModel/ViewModels/SettingsViewModel.cs b/FModel/ViewModels/SettingsViewModel.cs index ba4de94e..84956277 100644 --- a/FModel/ViewModels/SettingsViewModel.cs +++ b/FModel/ViewModels/SettingsViewModel.cs @@ -2,17 +2,22 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; +using System.Threading.Tasks; using CUE4Parse.UE4.Versions; using CUE4Parse_Conversion.Meshes; using CUE4Parse_Conversion.Textures; +using FModel.Extensions; using FModel.Framework; using FModel.Services; using FModel.Settings; +using FModel.ViewModels.ApiEndpoints.Models; namespace FModel.ViewModels { public class SettingsViewModel : ViewModel { + private ThreadWorkerViewModel _threadWorkerView => ApplicationService.ThreadWorkerView; + private ApiEndpointViewModel _apiEndpointView => ApplicationService.ApiEndpointView; private readonly DiscordHandler _discordHandler = DiscordService.DiscordHandler; private EUpdateMode _selectedUpdateMode; @@ -22,6 +27,13 @@ namespace FModel.ViewModels set => SetProperty(ref _selectedUpdateMode, value); } + private string _selectedPreset; + public string SelectedPreset + { + get => _selectedPreset; + set => SetProperty(ref _selectedPreset, value); + } + private EGame _selectedUeGame; public EGame SelectedUeGame { @@ -107,6 +119,7 @@ namespace FModel.ViewModels } public ReadOnlyObservableCollection UpdateModes { get; private set; } + public ObservableCollection Presets { get; private set; } public ReadOnlyObservableCollection UeGames { get; private set; } public ReadOnlyObservableCollection UeVersions { get; private set; } public ReadOnlyObservableCollection AssetLanguages { get; private set; } @@ -121,9 +134,11 @@ namespace FModel.ViewModels public ReadOnlyObservableCollection TextureExportFormats { get; private set; } private readonly FGame _game; + private Game _gamePreset; private string _outputSnapshot; private string _gameSnapshot; private EUpdateMode _updateModeSnapshot; + private string _presetSnapshot; private EGame _ueGameSnapshot; private UE4Version _ueVersionSnapshot; private ELanguage _assetLanguageSnapshot; @@ -145,6 +160,7 @@ namespace FModel.ViewModels _outputSnapshot = UserSettings.Default.OutputDirectory; _gameSnapshot = UserSettings.Default.GameDirectory; _updateModeSnapshot = UserSettings.Default.UpdateMode; + _presetSnapshot = UserSettings.Default.Presets[_game]; _ueGameSnapshot = UserSettings.Default.OverridedGame[_game]; _ueVersionSnapshot = UserSettings.Default.OverridedUEVersion[_game]; _assetLanguageSnapshot = UserSettings.Default.AssetLanguage; @@ -157,6 +173,7 @@ namespace FModel.ViewModels _textureExportFormatSnapshot = UserSettings.Default.TextureExportFormat; SelectedUpdateMode = _updateModeSnapshot; + SelectedPreset = _presetSnapshot; SelectedUeGame = _ueGameSnapshot; SelectedUeVersion = _ueVersionSnapshot; SelectedAssetLanguage = _assetLanguageSnapshot; @@ -171,6 +188,7 @@ namespace FModel.ViewModels SelectedDiscordRpc = UserSettings.Default.DiscordRpc; UpdateModes = new ReadOnlyObservableCollection(new ObservableCollection(EnumerateUpdateModes())); + Presets = new ObservableCollection(EnumeratePresets()); UeGames = new ReadOnlyObservableCollection(new ObservableCollection(EnumerateUeGames())); UeVersions = new ReadOnlyObservableCollection(new ObservableCollection(EnumerateUeVersions())); AssetLanguages = new ReadOnlyObservableCollection(new ObservableCollection(EnumerateAssetLanguages())); @@ -185,6 +203,34 @@ namespace FModel.ViewModels TextureExportFormats = new ReadOnlyObservableCollection(new ObservableCollection(EnumerateTextureExportFormat())); } + 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); + SelectedUeVersion = (UE4Version)version.UeVer; + } + + public void ResetPreset() + { + SelectedUeGame = _ueGameSnapshot; + SelectedUeVersion = _ueVersionSnapshot; + } + public SettingsOut Save() { var ret = SettingsOut.Nothing; @@ -198,6 +244,7 @@ namespace FModel.ViewModels ret = SettingsOut.ReloadLocres; UserSettings.Default.UpdateMode = SelectedUpdateMode; + UserSettings.Default.Presets[_game] = SelectedPreset; UserSettings.Default.OverridedGame[_game] = SelectedUeGame; UserSettings.Default.OverridedUEVersion[_game] = SelectedUeVersion; UserSettings.Default.AssetLanguage = SelectedAssetLanguage; @@ -218,6 +265,10 @@ namespace FModel.ViewModels } private IEnumerable EnumerateUpdateModes() => Enum.GetValues(SelectedUpdateMode.GetType()).Cast(); + private IEnumerable EnumeratePresets() + { + yield return "None"; + } private IEnumerable EnumerateUeGames() => Enum.GetValues(SelectedUeGame.GetType()).Cast(); private IEnumerable EnumerateUeVersions() => Enum.GetValues(SelectedUeVersion.GetType()).Cast(); private IEnumerable EnumerateAssetLanguages() => Enum.GetValues(SelectedAssetLanguage.GetType()).Cast(); diff --git a/FModel/ViewModels/ThreadWorkerViewModel.cs b/FModel/ViewModels/ThreadWorkerViewModel.cs index dc7f2e21..721672e4 100644 --- a/FModel/ViewModels/ThreadWorkerViewModel.cs +++ b/FModel/ViewModels/ThreadWorkerViewModel.cs @@ -3,6 +3,7 @@ using FModel.Services; using System; using System.Threading; using System.Threading.Tasks; +using FModel.Extensions; using FModel.Views.Resources.Controls; using Serilog; @@ -99,6 +100,7 @@ namespace FModel.ViewModels FLogger.AppendError(); FLogger.AppendText(e.Message, Constants.WHITE, true); + FLogger.AppendText(" " + e.StackTrace.SubstringBefore('\n').Trim(), Constants.WHITE, true); return; } } diff --git a/FModel/Views/SettingsView.xaml b/FModel/Views/SettingsView.xaml index c0dbd8c5..f7ef5ec6 100644 --- a/FModel/Views/SettingsView.xaml +++ b/FModel/Views/SettingsView.xaml @@ -7,7 +7,7 @@ xmlns:adonisUi="clr-namespace:AdonisUI;assembly=AdonisUI" xmlns:adonisControls="clr-namespace:AdonisUI.Controls;assembly=AdonisUI" xmlns:adonisExtensions="clr-namespace:AdonisUI.Extensions;assembly=AdonisUI" - WindowStartupLocation="CenterScreen" ResizeMode="NoResize" IconVisibility="Collapsed" SizeToContent="Height" + WindowStartupLocation="CenterScreen" ResizeMode="NoResize" IconVisibility="Collapsed" SizeToContent="Height" Loaded="OnLoaded" MinHeight="{Binding Source={x:Static SystemParameters.MaximizedPrimaryScreenHeight}, Converter={converters:RatioConverter}, ConverterParameter='0.10'}" Width="{Binding Source={x:Static SystemParameters.MaximizedPrimaryScreenWidth}, Converter={converters:RatioConverter}, ConverterParameter='0.35'}"> @@ -36,6 +36,8 @@ + + @@ -85,8 +87,13 @@ - - + + + + + @@ -95,8 +102,8 @@ - - + @@ -105,8 +112,20 @@ - - + + + + + + + +