This commit is contained in:
4sval
2023-06-18 03:26:50 +02:00
parent 25c10e8638
commit 2a265eae60
10 changed files with 44 additions and 159 deletions

View File

@@ -41,6 +41,8 @@ public partial class App
{ {
UserSettings.Default = JsonConvert.DeserializeObject<UserSettings>( UserSettings.Default = JsonConvert.DeserializeObject<UserSettings>(
File.ReadAllText(UserSettings.FilePath), JsonNetSerializer.SerializerSettings); File.ReadAllText(UserSettings.FilePath), JsonNetSerializer.SerializerSettings);
/*if (UserSettings.Default.ShowChangelog) */MigrateV1Games();
} }
catch catch
{ {
@@ -141,6 +143,17 @@ public partial class App
e.Handled = true; e.Handled = true;
} }
private void MigrateV1Games()
{
foreach ((var gameDir, var setting) in UserSettings.Default.ManualGames)
{
if (!Directory.Exists(gameDir)) continue;
UserSettings.Default.PerDirectory[gameDir] =
DirectorySettings.Default(setting.GameName, setting.GameDirectory, true, setting.OverridedGame);
}
UserSettings.Default.ManualGames.Clear();
}
private string GetOperatingSystemProductName() private string GetOperatingSystemProductName()
{ {
var productName = string.Empty; var productName = string.Empty;

View File

@@ -56,8 +56,8 @@ public partial class MainWindow
case EAesReload.Always: case EAesReload.Always:
await _applicationView.CUE4Parse.RefreshAes(); await _applicationView.CUE4Parse.RefreshAes();
break; break;
case EAesReload.OncePerDay when UserSettings.Default.LastAesReload != DateTime.Today: case EAesReload.OncePerDay when UserSettings.Default.CurrentDir.LastAesReload != DateTime.Today:
UserSettings.Default.LastAesReload = DateTime.Today; UserSettings.Default.CurrentDir.LastAesReload = DateTime.Today;
await _applicationView.CUE4Parse.RefreshAes(); await _applicationView.CUE4Parse.RefreshAes();
break; break;
} }

View File

@@ -10,8 +10,7 @@ namespace FModel.Settings;
public class DirectorySettings : ViewModel public class DirectorySettings : ViewModel
{ {
public static DirectorySettings Default( public static DirectorySettings Default(
string gameName, string gameDir, bool manual = false, EGame ue = EGame.GAME_UE4_LATEST, string gameName, string gameDir, bool manual = false, EGame ue = EGame.GAME_UE4_LATEST)
ETexturePlatform texture = ETexturePlatform.DesktopMobile, VersioningSettings ver = null)
{ {
UserSettings.Default.PerDirectory.TryGetValue(gameDir, out var old); UserSettings.Default.PerDirectory.TryGetValue(gameDir, out var old);
return new DirectorySettings return new DirectorySettings
@@ -19,11 +18,13 @@ public class DirectorySettings : ViewModel
GameName = gameName, GameName = gameName,
GameDirectory = gameDir, GameDirectory = gameDir,
IsManual = manual, IsManual = manual,
UeVersion = ue, UeVersion = old?.UeVersion ?? ue,
TexturePlatform = texture, TexturePlatform = old?.TexturePlatform ?? ETexturePlatform.DesktopMobile,
Versioning = ver ?? new VersioningSettings(), Versioning = old?.Versioning ?? new VersioningSettings(),
Endpoints = old?.Endpoints ?? EndpointSettings.Default(gameName), Endpoints = old?.Endpoints ?? EndpointSettings.Default(gameName),
Directories = old?.Directories ?? CustomDirectory.Default(gameName) Directories = old?.Directories ?? CustomDirectory.Default(gameName),
AesKeys = old?.AesKeys ?? new AesResponse { MainKey = string.Empty, DynamicKeys = null },
LastAesReload = old?.LastAesReload ?? DateTime.Today.AddDays(-1)
}; };
} }
@@ -90,6 +91,13 @@ public class DirectorySettings : ViewModel
set => SetProperty(ref _aesKeys, value); set => SetProperty(ref _aesKeys, value);
} }
private DateTime _lastAesReload;
public DateTime LastAesReload
{
get => _lastAesReload;
set => SetProperty(ref _lastAesReload, value);
}
private bool Equals(DirectorySettings other) private bool Equals(DirectorySettings other)
{ {
return GameDirectory == other.GameDirectory && UeVersion == other.UeVersion; return GameDirectory == other.GameDirectory && UeVersion == other.UeVersion;

View File

@@ -3,8 +3,6 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using CUE4Parse.UE4.Assets.Exports.Texture;
using CUE4Parse.UE4.Objects.Core.Serialization;
using CUE4Parse.UE4.Versions; using CUE4Parse.UE4.Versions;
using CUE4Parse_Conversion.Meshes; using CUE4Parse_Conversion.Meshes;
using CUE4Parse_Conversion.Textures; using CUE4Parse_Conversion.Textures;
@@ -230,22 +228,12 @@ namespace FModel.Settings
set => SetProperty(ref _perDirectory, value); set => SetProperty(ref _perDirectory, value);
} }
[JsonIgnore]
public DirectorySettings CurrentDir { get; set; } public DirectorySettings CurrentDir { get; set; }
/// <summary> /// <summary>
/// TO DELETEEEEEEEEEEEEE /// TO DELETEEEEEEEEEEEEE
/// </summary> /// </summary>
private IDictionary<FGame, AesResponse> _aesKeys = new Dictionary<FGame, AesResponse>();
public IDictionary<FGame, AesResponse> AesKeys
{
get => _aesKeys;
set => SetProperty(ref _aesKeys, value);
}
// <gameDirectory as string, settings>
// can't refactor to use this data layout for everything
// because it will wipe old user settings that relies on FGame
private IDictionary<string, GameSelectorViewModel.DetectedGame> _manualGames = new Dictionary<string, GameSelectorViewModel.DetectedGame>(); private IDictionary<string, GameSelectorViewModel.DetectedGame> _manualGames = new Dictionary<string, GameSelectorViewModel.DetectedGame>();
public IDictionary<string, GameSelectorViewModel.DetectedGame> ManualGames public IDictionary<string, GameSelectorViewModel.DetectedGame> ManualGames
{ {
@@ -253,86 +241,6 @@ namespace FModel.Settings
set => SetProperty(ref _manualGames, value); set => SetProperty(ref _manualGames, value);
} }
private IDictionary<FGame, IList<CustomDirectory>> _customDirectories = new Dictionary<FGame, IList<CustomDirectory>>
{
{FGame.Unknown, new List<CustomDirectory>()},
{
FGame.FortniteGame, new List<CustomDirectory>
{
new("Cosmetics", "FortniteGame/Content/Athena/Items/Cosmetics/"),
new("Emotes [AUDIO]", "FortniteGame/Content/Athena/Sounds/Emotes/"),
new("Music Packs [AUDIO]", "FortniteGame/Content/Athena/Sounds/MusicPacks/"),
new("Weapons", "FortniteGame/Content/Athena/Items/Weapons/"),
new("Strings", "FortniteGame/Content/Localization/")
}
},
{
FGame.ShooterGame, new List<CustomDirectory>
{
new("Audio", "ShooterGame/Content/WwiseAudio/Media/"),
new("Characters", "ShooterGame/Content/Characters/"),
new("Gun Buddies", "ShooterGame/Content/Equippables/Buddies/"),
new("Cards and Sprays", "ShooterGame/Content/Personalization/"),
new("Shop Backgrounds", "ShooterGame/Content/UI/OutOfGame/MainMenu/Store/Shared/Textures/"),
new("Weapon Renders", "ShooterGame/Content/UI/Screens/OutOfGame/MainMenu/Collection/Assets/Large/")
}
},
{
FGame.DeadByDaylight, new List<CustomDirectory>
{
new("Audio", "DeadByDaylight/Content/WwiseAudio/Windows/"),
new("Characters", "DeadByDaylight/Content/Characters/"),
new("Icons", "DeadByDaylight/Content/UI/UMGAssets/Icons/"),
new("Strings", "DeadByDaylight/Content/Localization/")
}
},
{FGame.OakGame, new List<CustomDirectory>()},
{
FGame.Dungeons, new List<CustomDirectory>
{
new("Levels", "Dungeons/Content/data/Lovika/Levels"),
new("Friendlies", "Dungeons/Content/Actor/Characters/Friendlies"),
new("Skins", "Dungeons/Content/Actor/Characters/Player/Master/Skins"),
new("Strings", "Dungeons/Content/Localization/")
}
},
{
FGame.WorldExplorers, new List<CustomDirectory>
{
new("Loot", "WorldExplorers/Content/Loot/"),
new("Strings", "WorldExplorers/Content/Localization/")
}
},
{
FGame.g3, new List<CustomDirectory>
{
new("Cosmetics", "g3/Content/Blueprints/Cosmetics/"),
new("Strings", "g3/Content/Localization/")
}
},
{FGame.StateOfDecay2, new List<CustomDirectory>()},
{FGame.Prospect, new List<CustomDirectory>()},
{FGame.Indiana, new List<CustomDirectory>()},
{FGame.RogueCompany, new List<CustomDirectory>()},
{FGame.SwGame, new List<CustomDirectory>()},
{FGame.Platform, new List<CustomDirectory>()},
{FGame.BendGame, new List<CustomDirectory>()},
{FGame.TslGame, new List<CustomDirectory>()},
{FGame.PortalWars, new List<CustomDirectory>()},
{FGame.Gameface, new List<CustomDirectory>()},
{FGame.Athena, new List<CustomDirectory>()},
{FGame.MultiVersus, new List<CustomDirectory>()},
{FGame.Hotta, new List<CustomDirectory>()},
{FGame.eFootball, new List<CustomDirectory>()}
};
private DateTime _lastAesReload = DateTime.Today.AddDays(-1);
public DateTime LastAesReload
{
get => _lastAesReload;
set => SetProperty(ref _lastAesReload, value);
}
private AuthResponse _lastAuthResponse = new() {AccessToken = "", ExpiresAt = DateTime.Now}; private AuthResponse _lastAuthResponse = new() {AccessToken = "", ExpiresAt = DateTime.Now};
public AuthResponse LastAuthResponse public AuthResponse LastAuthResponse
{ {

View File

@@ -35,22 +35,7 @@ public class AesManagerViewModel : ViewModel
{ {
await _threadWorkerView.Begin(_ => await _threadWorkerView.Begin(_ =>
{ {
if (_cue4Parse.Game == FGame.Unknown && _keysFromSettings = UserSettings.Default.CurrentDir.AesKeys;
UserSettings.Default.ManualGames.TryGetValue(UserSettings.Default.GameDirectory, out var settings))
{
_keysFromSettings = settings.AesKeys;
}
else
{
UserSettings.Default.AesKeys.TryGetValue(_cue4Parse.Game, out _keysFromSettings);
}
_keysFromSettings ??= new AesResponse
{
MainKey = string.Empty,
DynamicKeys = null
};
_mainKey.Key = Helper.FixKey(_keysFromSettings.MainKey); _mainKey.Key = Helper.FixKey(_keysFromSettings.MainKey);
AesKeys = new FullyObservableCollection<FileItem>(EnumerateAesKeys()); AesKeys = new FullyObservableCollection<FileItem>(EnumerateAesKeys());
AesKeys.ItemPropertyChanged += AesKeysOnItemPropertyChanged; AesKeys.ItemPropertyChanged += AesKeysOnItemPropertyChanged;
@@ -105,9 +90,7 @@ public class AesManagerViewModel : ViewModel
public void SetAesKeys() public void SetAesKeys()
{ {
if (_cue4Parse.Game == FGame.Unknown && UserSettings.Default.ManualGames.ContainsKey(UserSettings.Default.GameDirectory)) UserSettings.Default.CurrentDir.AesKeys = _keysFromSettings;
UserSettings.Default.ManualGames[UserSettings.Default.GameDirectory].AesKeys = _keysFromSettings;
else UserSettings.Default.AesKeys[_cue4Parse.Game] = _keysFromSettings;
// Log.Information("{@Json}", UserSettings.Default); // Log.Information("{@Json}", UserSettings.Default);
} }

View File

@@ -100,10 +100,10 @@ public class ApplicationViewModel : ViewModel
if (!result.HasValue || !result.Value) return null; if (!result.HasValue || !result.Value) return null;
UserSettings.Default.GameDirectory = gameLauncherViewModel.SelectedDirectory.GameDirectory; UserSettings.Default.GameDirectory = gameLauncherViewModel.SelectedDirectory.GameDirectory;
UserSettings.Default.PerDirectory[gameDirectory] = gameLauncherViewModel.SelectedDirectory;
if (!bAlreadyLaunched || UserSettings.Default.CurrentDir.Equals(gameLauncherViewModel.SelectedDirectory)) if (!bAlreadyLaunched || UserSettings.Default.CurrentDir.Equals(gameLauncherViewModel.SelectedDirectory))
return gameLauncherViewModel.SelectedDirectory; return gameLauncherViewModel.SelectedDirectory;
UserSettings.Default.CurrentDir = gameLauncherViewModel.SelectedDirectory;
RestartWithWarning(); RestartWithWarning();
return null; return null;
} }

View File

@@ -331,7 +331,7 @@ public class CUE4ParseViewModel : ViewModel
var aes = _apiEndpointView.DynamicApi.GetAesKeys(cancellationToken, endpoint.Url, endpoint.Path); var aes = _apiEndpointView.DynamicApi.GetAesKeys(cancellationToken, endpoint.Url, endpoint.Path);
if (aes is not { IsValid: true }) return; if (aes is not { IsValid: true }) return;
UserSettings.Default.AesKeys[Game] = aes; UserSettings.Default.CurrentDir.AesKeys = aes;
}); });
} }

View File

@@ -1,26 +1,20 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Threading.Tasks;
using CUE4Parse.UE4.Assets.Exports.Texture; using CUE4Parse.UE4.Assets.Exports.Texture;
using CUE4Parse.UE4.Objects.Core.Misc;
using CUE4Parse.UE4.Objects.Core.Serialization; using CUE4Parse.UE4.Objects.Core.Serialization;
using CUE4Parse.UE4.Versions; using CUE4Parse.UE4.Versions;
using CUE4Parse_Conversion.Meshes; using CUE4Parse_Conversion.Meshes;
using CUE4Parse_Conversion.Textures; using CUE4Parse_Conversion.Textures;
using CUE4Parse.UE4.Assets.Exports.Material; using CUE4Parse.UE4.Assets.Exports.Material;
using FModel.Extensions;
using FModel.Framework; using FModel.Framework;
using FModel.Services; using FModel.Services;
using FModel.Settings; using FModel.Settings;
using FModel.ViewModels.ApiEndpoints.Models;
namespace FModel.ViewModels; namespace FModel.ViewModels;
public class SettingsViewModel : ViewModel public class SettingsViewModel : ViewModel
{ {
private ThreadWorkerViewModel _threadWorkerView => ApplicationService.ThreadWorkerView;
private ApiEndpointViewModel _apiEndpointView => ApplicationService.ApiEndpointView;
private readonly DiscordHandler _discordHandler = DiscordService.DiscordHandler; private readonly DiscordHandler _discordHandler = DiscordService.DiscordHandler;
private bool _useCustomOutputFolders; private bool _useCustomOutputFolders;
@@ -211,20 +205,10 @@ public class SettingsViewModel : ViewModel
_gameSnapshot = UserSettings.Default.GameDirectory; _gameSnapshot = UserSettings.Default.GameDirectory;
_updateModeSnapshot = UserSettings.Default.UpdateMode; _updateModeSnapshot = UserSettings.Default.UpdateMode;
_uePlatformSnapshot = UserSettings.Default.CurrentDir.TexturePlatform; _uePlatformSnapshot = UserSettings.Default.CurrentDir.TexturePlatform;
if (_game == FGame.Unknown && UserSettings.Default.ManualGames.TryGetValue(_gameSnapshot, out var settings)) _ueGameSnapshot = UserSettings.Default.CurrentDir.UeVersion;
{ _customVersionsSnapshot = UserSettings.Default.CurrentDir.Versioning.CustomVersions;
_ueGameSnapshot = settings.OverridedGame; _optionsSnapshot = UserSettings.Default.CurrentDir.Versioning.Options;
_customVersionsSnapshot = settings.OverridedCustomVersions; _mapStructTypesSnapshot = UserSettings.Default.CurrentDir.Versioning.MapStructTypes;
_optionsSnapshot = settings.OverridedOptions;
_mapStructTypesSnapshot = settings.OverridedMapStructTypes;
}
else
{
_ueGameSnapshot = UserSettings.Default.CurrentDir.UeVersion;
_customVersionsSnapshot = UserSettings.Default.CurrentDir.Versioning.CustomVersions;
_optionsSnapshot = UserSettings.Default.CurrentDir.Versioning.Options;
_mapStructTypesSnapshot = UserSettings.Default.CurrentDir.Versioning.MapStructTypes;
}
AesEndpoint = UserSettings.Default.CurrentDir.Endpoints[0]; AesEndpoint = UserSettings.Default.CurrentDir.Endpoints[0];
MappingEndpoint = UserSettings.Default.CurrentDir.Endpoints[1]; MappingEndpoint = UserSettings.Default.CurrentDir.Endpoints[1];
@@ -300,21 +284,11 @@ public class SettingsViewModel : ViewModel
restart = true; restart = true;
UserSettings.Default.UpdateMode = SelectedUpdateMode; UserSettings.Default.UpdateMode = SelectedUpdateMode;
UserSettings.Default.CurrentDir.UeVersion = SelectedUeGame;
UserSettings.Default.CurrentDir.TexturePlatform = SelectedUePlatform; UserSettings.Default.CurrentDir.TexturePlatform = SelectedUePlatform;
if (_game == FGame.Unknown && UserSettings.Default.ManualGames.ContainsKey(UserSettings.Default.GameDirectory)) UserSettings.Default.CurrentDir.Versioning.CustomVersions = SelectedCustomVersions;
{ UserSettings.Default.CurrentDir.Versioning.Options = SelectedOptions;
UserSettings.Default.ManualGames[UserSettings.Default.GameDirectory].OverridedGame = SelectedUeGame; UserSettings.Default.CurrentDir.Versioning.MapStructTypes = SelectedMapStructTypes;
UserSettings.Default.ManualGames[UserSettings.Default.GameDirectory].OverridedCustomVersions = (List<FCustomVersion>) SelectedCustomVersions;
UserSettings.Default.ManualGames[UserSettings.Default.GameDirectory].OverridedOptions = (Dictionary<string, bool>) SelectedOptions;
UserSettings.Default.ManualGames[UserSettings.Default.GameDirectory].OverridedMapStructTypes = (Dictionary<string, KeyValuePair<string, string>>) SelectedMapStructTypes;
}
else
{
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; UserSettings.Default.AssetLanguage = SelectedAssetLanguage;
UserSettings.Default.CompressedAudioMode = SelectedCompressedAudio; UserSettings.Default.CompressedAudioMode = SelectedCompressedAudio;

View File

@@ -23,7 +23,7 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<avalonEdit:TextEditor x:Name="MyAvalonEditor" Grid.Row="0" Background="{DynamicResource {x:Static adonisUi:Brushes.Layer3BackgroundBrush}}" <avalonEdit:TextEditor x:Name="MyAvalonEditor" Grid.Row="0" Background="{DynamicResource {x:Static adonisUi:Brushes.Layer3BackgroundBrush}}"
FontFamily="Consolas" FontSize="8pt" IsReadOnly="True" ShowLineNumbers="True" Foreground="#DAE5F2" /> FontFamily="Consolas" FontSize="8pt" ShowLineNumbers="True" Foreground="#DAE5F2" />
<Border Grid.Row="1" <Border Grid.Row="1"
Background="{DynamicResource {x:Static adonisUi:Brushes.Layer1BackgroundBrush}}" Background="{DynamicResource {x:Static adonisUi:Brushes.Layer1BackgroundBrush}}"

View File

@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Media; using System.Windows.Media;
using CUE4Parse.UE4.Objects.Core.Misc; using CUE4Parse.UE4.Objects.Core.Misc;
@@ -104,7 +103,7 @@ public partial class DictionaryEditor
{ {
Text = JsonConvert.SerializeObject(_defaultOptions, Formatting.Indented) Text = JsonConvert.SerializeObject(_defaultOptions, Formatting.Indented)
}, },
"MapStructTypes" => new TextDocument "Versioning Configuration (MapStructTypes)" => new TextDocument
{ {
Text = JsonConvert.SerializeObject(_defaultMapStructTypes, Formatting.Indented) Text = JsonConvert.SerializeObject(_defaultMapStructTypes, Formatting.Indented)
}, },