mirror of
https://github.com/4sval/FModel.git
synced 2026-03-21 17:24:26 -05:00
usable
This commit is contained in:
parent
25c10e8638
commit
2a265eae60
|
|
@ -41,6 +41,8 @@ public partial class App
|
|||
{
|
||||
UserSettings.Default = JsonConvert.DeserializeObject<UserSettings>(
|
||||
File.ReadAllText(UserSettings.FilePath), JsonNetSerializer.SerializerSettings);
|
||||
|
||||
/*if (UserSettings.Default.ShowChangelog) */MigrateV1Games();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -141,6 +143,17 @@ public partial class App
|
|||
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()
|
||||
{
|
||||
var productName = string.Empty;
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ public partial class MainWindow
|
|||
case EAesReload.Always:
|
||||
await _applicationView.CUE4Parse.RefreshAes();
|
||||
break;
|
||||
case EAesReload.OncePerDay when UserSettings.Default.LastAesReload != DateTime.Today:
|
||||
UserSettings.Default.LastAesReload = DateTime.Today;
|
||||
case EAesReload.OncePerDay when UserSettings.Default.CurrentDir.LastAesReload != DateTime.Today:
|
||||
UserSettings.Default.CurrentDir.LastAesReload = DateTime.Today;
|
||||
await _applicationView.CUE4Parse.RefreshAes();
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@ namespace FModel.Settings;
|
|||
public class DirectorySettings : ViewModel
|
||||
{
|
||||
public static DirectorySettings Default(
|
||||
string gameName, string gameDir, bool manual = false, EGame ue = EGame.GAME_UE4_LATEST,
|
||||
ETexturePlatform texture = ETexturePlatform.DesktopMobile, VersioningSettings ver = null)
|
||||
string gameName, string gameDir, bool manual = false, EGame ue = EGame.GAME_UE4_LATEST)
|
||||
{
|
||||
UserSettings.Default.PerDirectory.TryGetValue(gameDir, out var old);
|
||||
return new DirectorySettings
|
||||
|
|
@ -19,11 +18,13 @@ public class DirectorySettings : ViewModel
|
|||
GameName = gameName,
|
||||
GameDirectory = gameDir,
|
||||
IsManual = manual,
|
||||
UeVersion = ue,
|
||||
TexturePlatform = texture,
|
||||
Versioning = ver ?? new VersioningSettings(),
|
||||
UeVersion = old?.UeVersion ?? ue,
|
||||
TexturePlatform = old?.TexturePlatform ?? ETexturePlatform.DesktopMobile,
|
||||
Versioning = old?.Versioning ?? new VersioningSettings(),
|
||||
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);
|
||||
}
|
||||
|
||||
private DateTime _lastAesReload;
|
||||
public DateTime LastAesReload
|
||||
{
|
||||
get => _lastAesReload;
|
||||
set => SetProperty(ref _lastAesReload, value);
|
||||
}
|
||||
|
||||
private bool Equals(DirectorySettings other)
|
||||
{
|
||||
return GameDirectory == other.GameDirectory && UeVersion == other.UeVersion;
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using CUE4Parse.UE4.Assets.Exports.Texture;
|
||||
using CUE4Parse.UE4.Objects.Core.Serialization;
|
||||
using CUE4Parse.UE4.Versions;
|
||||
using CUE4Parse_Conversion.Meshes;
|
||||
using CUE4Parse_Conversion.Textures;
|
||||
|
|
@ -230,22 +228,12 @@ namespace FModel.Settings
|
|||
set => SetProperty(ref _perDirectory, value);
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public DirectorySettings CurrentDir { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// TO DELETEEEEEEEEEEEEE
|
||||
/// </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>();
|
||||
public IDictionary<string, GameSelectorViewModel.DetectedGame> ManualGames
|
||||
{
|
||||
|
|
@ -253,86 +241,6 @@ namespace FModel.Settings
|
|||
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};
|
||||
public AuthResponse LastAuthResponse
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,22 +35,7 @@ public class AesManagerViewModel : ViewModel
|
|||
{
|
||||
await _threadWorkerView.Begin(_ =>
|
||||
{
|
||||
if (_cue4Parse.Game == FGame.Unknown &&
|
||||
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
|
||||
};
|
||||
|
||||
_keysFromSettings = UserSettings.Default.CurrentDir.AesKeys;
|
||||
_mainKey.Key = Helper.FixKey(_keysFromSettings.MainKey);
|
||||
AesKeys = new FullyObservableCollection<FileItem>(EnumerateAesKeys());
|
||||
AesKeys.ItemPropertyChanged += AesKeysOnItemPropertyChanged;
|
||||
|
|
@ -105,9 +90,7 @@ public class AesManagerViewModel : ViewModel
|
|||
|
||||
public void SetAesKeys()
|
||||
{
|
||||
if (_cue4Parse.Game == FGame.Unknown && UserSettings.Default.ManualGames.ContainsKey(UserSettings.Default.GameDirectory))
|
||||
UserSettings.Default.ManualGames[UserSettings.Default.GameDirectory].AesKeys = _keysFromSettings;
|
||||
else UserSettings.Default.AesKeys[_cue4Parse.Game] = _keysFromSettings;
|
||||
UserSettings.Default.CurrentDir.AesKeys = _keysFromSettings;
|
||||
// Log.Information("{@Json}", UserSettings.Default);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -100,10 +100,10 @@ public class ApplicationViewModel : ViewModel
|
|||
if (!result.HasValue || !result.Value) return null;
|
||||
|
||||
UserSettings.Default.GameDirectory = gameLauncherViewModel.SelectedDirectory.GameDirectory;
|
||||
UserSettings.Default.PerDirectory[gameDirectory] = gameLauncherViewModel.SelectedDirectory;
|
||||
if (!bAlreadyLaunched || UserSettings.Default.CurrentDir.Equals(gameLauncherViewModel.SelectedDirectory))
|
||||
return gameLauncherViewModel.SelectedDirectory;
|
||||
|
||||
UserSettings.Default.CurrentDir = gameLauncherViewModel.SelectedDirectory;
|
||||
RestartWithWarning();
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -331,7 +331,7 @@ public class CUE4ParseViewModel : ViewModel
|
|||
var aes = _apiEndpointView.DynamicApi.GetAesKeys(cancellationToken, endpoint.Url, endpoint.Path);
|
||||
if (aes is not { IsValid: true }) return;
|
||||
|
||||
UserSettings.Default.AesKeys[Game] = aes;
|
||||
UserSettings.Default.CurrentDir.AesKeys = aes;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,26 +1,20 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Threading.Tasks;
|
||||
using CUE4Parse.UE4.Assets.Exports.Texture;
|
||||
using CUE4Parse.UE4.Objects.Core.Misc;
|
||||
using CUE4Parse.UE4.Objects.Core.Serialization;
|
||||
using CUE4Parse.UE4.Versions;
|
||||
using CUE4Parse_Conversion.Meshes;
|
||||
using CUE4Parse_Conversion.Textures;
|
||||
using CUE4Parse.UE4.Assets.Exports.Material;
|
||||
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 bool _useCustomOutputFolders;
|
||||
|
|
@ -211,20 +205,10 @@ public class SettingsViewModel : ViewModel
|
|||
_gameSnapshot = UserSettings.Default.GameDirectory;
|
||||
_updateModeSnapshot = UserSettings.Default.UpdateMode;
|
||||
_uePlatformSnapshot = UserSettings.Default.CurrentDir.TexturePlatform;
|
||||
if (_game == FGame.Unknown && UserSettings.Default.ManualGames.TryGetValue(_gameSnapshot, out var settings))
|
||||
{
|
||||
_ueGameSnapshot = settings.OverridedGame;
|
||||
_customVersionsSnapshot = settings.OverridedCustomVersions;
|
||||
_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;
|
||||
}
|
||||
_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];
|
||||
MappingEndpoint = UserSettings.Default.CurrentDir.Endpoints[1];
|
||||
|
|
@ -300,21 +284,11 @@ public class SettingsViewModel : ViewModel
|
|||
restart = true;
|
||||
|
||||
UserSettings.Default.UpdateMode = SelectedUpdateMode;
|
||||
UserSettings.Default.CurrentDir.UeVersion = SelectedUeGame;
|
||||
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 = (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.CurrentDir.Versioning.CustomVersions = SelectedCustomVersions;
|
||||
UserSettings.Default.CurrentDir.Versioning.Options = SelectedOptions;
|
||||
UserSettings.Default.CurrentDir.Versioning.MapStructTypes = SelectedMapStructTypes;
|
||||
|
||||
UserSettings.Default.AssetLanguage = SelectedAssetLanguage;
|
||||
UserSettings.Default.CompressedAudioMode = SelectedCompressedAudio;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
</Grid.RowDefinitions>
|
||||
|
||||
<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"
|
||||
Background="{DynamicResource {x:Static adonisUi:Brushes.Layer1BackgroundBrush}}"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using CUE4Parse.UE4.Objects.Core.Misc;
|
||||
|
|
@ -104,7 +103,7 @@ public partial class DictionaryEditor
|
|||
{
|
||||
Text = JsonConvert.SerializeObject(_defaultOptions, Formatting.Indented)
|
||||
},
|
||||
"MapStructTypes" => new TextDocument
|
||||
"Versioning Configuration (MapStructTypes)" => new TextDocument
|
||||
{
|
||||
Text = JsonConvert.SerializeObject(_defaultMapStructTypes, Formatting.Indented)
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user