From 5aea683c8fae3db982c43c7a4b845ea6ef1c6346 Mon Sep 17 00:00:00 2001 From: iAmAsval Date: Sat, 26 Sep 2020 19:46:24 +0200 Subject: [PATCH] Added @NotOfficer fork locked to latest manifest --- FModel/Creator/Bases/BaseIcon.cs | 2 +- FModel/FModel.csproj | 1 + FModel/Grabber/Manifests/ManifestGrabber.cs | 38 +++++++++++ FModel/Grabber/Paks/PaksGrabber.cs | 63 ++++++++++++++++--- FModel/MainWindow.xaml | 5 -- FModel/PakReader/Pak/PakFileReader.cs | 10 +-- FModel/Properties/Resources.Designer.cs | 10 --- FModel/Properties/Resources.resx | 3 - FModel/Properties/Settings.Designer.cs | 26 +++++++- FModel/Properties/Settings.settings | 6 ++ FModel/Resources/rotate-3d.png | Bin 1285 -> 0 bytes FModel/Utils/Endpoints.cs | 45 ++++++++++++- FModel/Utils/Folders.cs | 6 +- FModel/Utils/Keys.cs | 15 +++-- FModel/Windows/AESManager/AESManager.xaml.cs | 47 ++++++++++---- FModel/Windows/Launcher/FLauncher.xaml | 4 +- FModel/Windows/Launcher/FLauncher.xaml.cs | 17 ++++- 17 files changed, 240 insertions(+), 58 deletions(-) create mode 100644 FModel/Grabber/Manifests/ManifestGrabber.cs delete mode 100644 FModel/Resources/rotate-3d.png diff --git a/FModel/Creator/Bases/BaseIcon.cs b/FModel/Creator/Bases/BaseIcon.cs index b5d620cd..0141de45 100644 --- a/FModel/Creator/Bases/BaseIcon.cs +++ b/FModel/Creator/Bases/BaseIcon.cs @@ -134,7 +134,7 @@ namespace FModel.Creator.Bases string IBase.DisplayName => DisplayName; string IBase.Description => Description; int IBase.Width => Size; - int IBase.Height => Size + AdditionalSize; + int IBase.Height => Size; int IBase.Margin => Margin; } } diff --git a/FModel/FModel.csproj b/FModel/FModel.csproj index 35ffdad2..e617a429 100644 --- a/FModel/FModel.csproj +++ b/FModel/FModel.csproj @@ -135,6 +135,7 @@ + diff --git a/FModel/Grabber/Manifests/ManifestGrabber.cs b/FModel/Grabber/Manifests/ManifestGrabber.cs new file mode 100644 index 00000000..c2cf3a01 --- /dev/null +++ b/FModel/Grabber/Manifests/ManifestGrabber.cs @@ -0,0 +1,38 @@ +using EpicManifestParser.Objects; +using FModel.Utils; +using System; +using System.Threading.Tasks; + +namespace FModel.Grabber.Manifests +{ + static class ManifestGrabber + { + public static async Task TryGetLatestManifestInfo() + { + if (IsExpired()) + { + OAuth auth = await Endpoints.GetOAuthInfo(); + if (auth != null) + { + Properties.Settings.Default.AccessToken = auth.AccessToken; + Properties.Settings.Default.LauncherExpiration = DateTimeOffset.Now.AddSeconds(Convert.ToDouble(auth.ExpiresIn)).ToUnixTimeMilliseconds(); + Properties.Settings.Default.Save(); + } + } + + string ret = await Endpoints.GetStringEndpoint("https://launcher-public-service-prod06.ol.epicgames.com/launcher/api/public/assets/v2/platform/Windows/namespace/fn/catalogItem/4fe75bbc5a674f4f9b356b5c90567da5/app/Fortnite/label/Live", Properties.Settings.Default.AccessToken); + if (!string.IsNullOrEmpty(ret)) return new ManifestInfo(ret); + else return null; + } + + private static bool IsExpired() + { + long currentTime = DateTimeOffset.Now.ToUnixTimeMilliseconds(); + if ((currentTime - 60000) >= Properties.Settings.Default.LauncherExpiration) + { + return true; + } + return false; + } + } +} \ No newline at end of file diff --git a/FModel/Grabber/Paks/PaksGrabber.cs b/FModel/Grabber/Paks/PaksGrabber.cs index 6d8b5c66..8d1dff8d 100644 --- a/FModel/Grabber/Paks/PaksGrabber.cs +++ b/FModel/Grabber/Paks/PaksGrabber.cs @@ -10,23 +10,29 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Media.Imaging; +using EpicManifestParser.Objects; +using System.Text.RegularExpressions; +using FModel.Grabber.Manifests; namespace FModel.Grabber.Paks { static class PaksGrabber { + private static readonly Regex _pakFileRegex = new Regex(@"^FortniteGame/Content/Paks/.+\.pak$", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.IgnoreCase); + public static async Task PopulateMenu() { PopulateBase(); - await Task.Run(() => + await Task.Run(async () => { if (string.IsNullOrEmpty(Properties.Settings.Default.PakPath)) { - Application.Current.Dispatcher.Invoke(delegate + await Application.Current.Dispatcher.InvokeAsync(delegate { var launcher = new FLauncher(); - if ((bool)launcher.ShowDialog()) + bool? result = launcher.ShowDialog(); + if (result.HasValue && result.Value) { Properties.Settings.Default.PakPath = launcher.Path; Properties.Settings.Default.Save(); @@ -34,12 +40,51 @@ namespace FModel.Grabber.Paks }); } - // define the current game thank to the pak path - Folders.SetGameName(Properties.Settings.Default.PakPath); - // Add Pak Files - if (Directory.Exists(Properties.Settings.Default.PakPath)) + if (Properties.Settings.Default.PakPath.EndsWith(".manifest") && await ManifestGrabber.TryGetLatestManifestInfo().ConfigureAwait(false) is ManifestInfo manifestInfo) { + var manifestData = await manifestInfo.DownloadManifestDataAsync(); + Manifest manifest = new Manifest(manifestData, new ManifestOptions + { + ChunkBaseUri = new Uri("http://download.epicgames.com/Builds/Fortnite/CloudDir/ChunksV3/", UriKind.Absolute), + ChunkCacheDirectory = Directory.CreateDirectory(Path.Combine(Properties.Settings.Default.OutputPath, "PakChunks")) + }); + int pakFiles = 0; + + foreach (FileManifest fileManifest in manifest.FileManifests) + { + if (!_pakFileRegex.IsMatch(fileManifest.Name)) + { + continue; + } + + var pakFileName = fileManifest.Name.Replace('/', '\\'); + PakFileReader pakFile = new PakFileReader(pakFileName, fileManifest.GetStream()); + + if (pakFiles++ == 0) + { + // define the current game thank to the pak path + Folders.SetGameName(pakFileName); + + Globals.Game.Version = pakFile.Info.Version; + Globals.Game.SubVersion = pakFile.Info.SubVersion; + } + + await Application.Current.Dispatcher.InvokeAsync(delegate + { + MenuItems.pakFiles.Add(new PakMenuItemViewModel + { + PakFile = pakFile, + IsEnabled = false + }); + }); + } + } + else if (Directory.Exists(Properties.Settings.Default.PakPath)) + { + // define the current game thank to the pak path + Folders.SetGameName(Properties.Settings.Default.PakPath); + string[] paks = Directory.GetFiles(Properties.Settings.Default.PakPath, "*.pak"); for (int i = 0; i < paks.Length; i++) { @@ -53,7 +98,7 @@ namespace FModel.Grabber.Paks Globals.Game.SubVersion = pakFile.Info.SubVersion; } - Application.Current.Dispatcher.Invoke(delegate + await Application.Current.Dispatcher.InvokeAsync(delegate { MenuItems.pakFiles.Add(new PakMenuItemViewModel { @@ -126,4 +171,4 @@ namespace FModel.Grabber.Paks MenuItems.pakFiles.Add(new Separator { }); } } -} +} \ No newline at end of file diff --git a/FModel/MainWindow.xaml b/FModel/MainWindow.xaml index cf767f61..0b5f7e10 100644 --- a/FModel/MainWindow.xaml +++ b/FModel/MainWindow.xaml @@ -71,11 +71,6 @@ - - - - - diff --git a/FModel/PakReader/Pak/PakFileReader.cs b/FModel/PakReader/Pak/PakFileReader.cs index d93a5d7a..ec460150 100644 --- a/FModel/PakReader/Pak/PakFileReader.cs +++ b/FModel/PakReader/Pak/PakFileReader.cs @@ -15,6 +15,7 @@ namespace PakReader.Pak { public FPakInfo Info { get; } public Stream Stream { get; } + public string Directory { get; } public string FileName { get; } public bool CaseSensitive { get; } @@ -45,6 +46,7 @@ namespace PakReader.Pak public PakFileReader(string path, Stream stream, bool caseSensitive = true) { + Directory = Path.GetDirectoryName(path); FileName = Path.GetFileName(path); Stream = stream; CaseSensitive = caseSensitive; @@ -164,7 +166,7 @@ namespace PakReader.Pak MountPoint = IndexReader.ReadFString() ?? ""; if (MountPoint.StartsWith("../../..")) { - MountPoint = MountPoint.Substring(8); + MountPoint = MountPoint[8..]; } else { @@ -209,7 +211,7 @@ namespace PakReader.Pak MountPoint = reader.ReadFString(); if (MountPoint.StartsWith("../../..")) { - MountPoint = MountPoint.Substring(8); + MountPoint = MountPoint[8..]; } else { @@ -278,7 +280,7 @@ namespace PakReader.Pak { var path = directoryEntry.Directory + hashIndexEntry.Filename; if (path.StartsWith("/")) - path = path.Substring(1); + path = path[1..]; if (!CaseSensitive) { path = path.ToLowerInvariant(); @@ -491,4 +493,4 @@ namespace PakReader.Pak IEnumerator IEnumerable.GetEnumerator() => Entries.GetEnumerator(); bool IReadOnlyDictionary.TryGetValue(string key, out FPakEntry value) => Entries.TryGetValue(key, out value); } -} +} \ No newline at end of file diff --git a/FModel/Properties/Resources.Designer.cs b/FModel/Properties/Resources.Designer.cs index 084bda2b..be14d3e9 100644 --- a/FModel/Properties/Resources.Designer.cs +++ b/FModel/Properties/Resources.Designer.cs @@ -2184,16 +2184,6 @@ namespace FModel.Properties { } } - /// - /// Recherche une ressource localisée de type System.Drawing.Bitmap. - /// - public static System.Drawing.Bitmap rotate_3d { - get { - object obj = ResourceManager.GetObject("rotate_3d", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - /// /// Recherche une chaîne localisée semblable à Russian. /// diff --git a/FModel/Properties/Resources.resx b/FModel/Properties/Resources.resx index 82ca3043..213e9591 100644 --- a/FModel/Properties/Resources.resx +++ b/FModel/Properties/Resources.resx @@ -1081,7 +1081,4 @@ It's now the most used free software to leak on Fortnite. Skip this Version - - ..\Resources\rotate-3d.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - \ No newline at end of file diff --git a/FModel/Properties/Settings.Designer.cs b/FModel/Properties/Settings.Designer.cs index 0f7a593a..4f81b53e 100644 --- a/FModel/Properties/Settings.Designer.cs +++ b/FModel/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace FModel.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.7.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")] public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -514,5 +514,29 @@ namespace FModel.Properties { this["ReloadAesKeys"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string AccessToken { + get { + return ((string)(this["AccessToken"])); + } + set { + this["AccessToken"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public long LauncherExpiration { + get { + return ((long)(this["LauncherExpiration"])); + } + set { + this["LauncherExpiration"] = value; + } + } } } diff --git a/FModel/Properties/Settings.settings b/FModel/Properties/Settings.settings index e26d4ac2..0a1694f5 100644 --- a/FModel/Properties/Settings.settings +++ b/FModel/Properties/Settings.settings @@ -125,5 +125,11 @@ True + + + + + 0 + \ No newline at end of file diff --git a/FModel/Resources/rotate-3d.png b/FModel/Resources/rotate-3d.png deleted file mode 100644 index 6420ca4883c968ac7832641332e113f473c33413..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1285 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTCmUKs7M+SzC{oH>NS%G|oWRD45dJguM!v-tY$DUh!@P+6=(yLU`z6LcLCBs@Y8vBJ&@uo z@Q5sCVBk9f!i-b3`J@>bm>+q%IEG~0yE-$rBg|Fe`2WqBo!P0KVqv$q!`69dj~Yq#pSTxDzUZ}=VbT9%u|!G42O!AjG9R;C5g z6&72c*>o&EX!C+4j=hgv;CaLI;OukF7SE3E&;6wSqtYNtVI9-km8Q=f_sk5w#`Y&w z;UC+yW!Gf5ErczEdX5;cEIsOE!y;oOPgG{ z@Q2gKXRW4KLeU1Jwccx2@*K%x{=i<~p5?odLAaT7Z^)!sURJXiYdGgHtYduMSbN~q zf_q=)Y(5vcKsvrc=@YpwaJ?}*H-9bTh1dO@xd*Zjh$Y}t-<&C1j{G;f&Gh_Erf2iNkN=d;%_+V+Y1@zEmXqQ% zKip!RJWrPO!5ry=bEUuU&s>oH%yU(q!G5A zC5iL5M_k&S{9)!ZBmXklI|*U!eDnX$Up-;H@y#nYg>RPyZ_xDBy_$QD*Yj7vrNsGH zML$+`d&>8)O(;=19=Y~j*2mf5;*l>dI3?8h_FuS=c*%NkHUEt?w+DNzN^gID_3QkK z^V8pcuKa4YDZEiIzOKVa-6x?p^T}+h(%C2Zk|wk=TQ|7>4NP+95NCM9Hjhb+@$}!m zC{cSBoer`0(i_>Acpr!@eWlOHc5?gshC)+@Pj5^<#AtqWo5K53S3BUpVS;g_$=g}- zy|xFUXY5GhJD^c;tp7w5m)!E#oWHJ^Y$!j&_doyh{f`}u6;@l9841KoH^@mD9*Jdt z!1-@)0>c_FP`YqqHefj81xzXnW=c1&+Ryxb*)>t_jWcwX#BQB?r)}bfa|v(XF~0L$ zt1b3uF~cMC1xwv*+4tO^usDSIkmQyjGu3iQH&AD&V~S(3+!j^zb zk0)uJI@De6{c75lGnVEt`&w&$v-6xj8)7nr)d*MwsFt`!l%ynrb^HVa@DsgLI^E#XY)F276Aviy+q&%@G lm7%=6TrV>(yEr+qAXP8FD1G)j8!4b722WQ%mvv4FO#lnlDT@FA diff --git a/FModel/Utils/Endpoints.cs b/FModel/Utils/Endpoints.cs index 1605016c..2021a158 100644 --- a/FModel/Utils/Endpoints.cs +++ b/FModel/Utils/Endpoints.cs @@ -1,7 +1,9 @@ using FModel.Logger; +using Newtonsoft.Json; using System; using System.IO; using System.Net.Http; +using System.Text; using System.Threading.Tasks; namespace FModel.Utils @@ -11,6 +13,8 @@ namespace FModel.Utils public const string BENBOT_AES = "https://benbotfn.tk/api/v1/aes"; public const string BENBOT_HOTFIXES = "https://benbotfn.tk/api/v1/hotfixes"; public const string FMODEL_JSON = "https://dl.dropbox.com/s/sxyaqo6zu1drlea/FModel.json?dl=0"; + public const string OAUTH_URL = "https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/token"; + private const string _BASIC_FN_TOKEN = "basic MzQ0NmNkNzI2OTRjNGE0NDg1ZDgxYjc3YWRiYjIxNDE6OTIwOWQ0YTVlMjVhNDU3ZmI5YjA3NDg5ZDMxM2I0MWE="; public static async Task GetStringEndpoint(string url) => await GetStringEndpoint(url, string.Empty); public static async Task GetStringEndpoint(string url, string token) @@ -21,7 +25,10 @@ namespace FModel.Utils using (HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, new Uri(url))) { if (!string.IsNullOrEmpty(token)) + { request.Headers.Add("Authorization", $"bearer {token}"); + request.Content = new StringContent("", Encoding.UTF8, "application/json"); + } try { @@ -72,5 +79,41 @@ namespace FModel.Utils return default; } + + public static async Task GetOAuthInfo() + { + DebugHelper.WriteLine("{0} {1} {2} {3}", "[FModel]", "[Endpoints]", "[GET]", OAUTH_URL); + + using (HttpClient client = new HttpClient { Timeout = TimeSpan.FromSeconds(2) }) + using (HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, new Uri(OAUTH_URL))) + { + request.Headers.Add("Authorization", _BASIC_FN_TOKEN); + request.Content = new StringContent("grant_type=client_credentials", Encoding.UTF8, "application/x-www-form-urlencoded"); + try + { + using HttpResponseMessage httpResponseMessage = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false); + using Stream stream = await httpResponseMessage.Content.ReadAsStreamAsync().ConfigureAwait(false); + if (httpResponseMessage.IsSuccessStatusCode) + { + return Streams.DeserializeJsonFromStream(stream); + } + } + catch (Exception) + { + /* TaskCanceledException + * HttpRequestException */ + } + } + + return default; + } } -} + + public class OAuth + { + [JsonProperty("access_token")] + public string AccessToken; + [JsonProperty("expires_in")] + public long ExpiresIn; + } +} \ No newline at end of file diff --git a/FModel/Utils/Folders.cs b/FModel/Utils/Folders.cs index 23b94b6d..e7cb4ca0 100644 --- a/FModel/Utils/Folders.cs +++ b/FModel/Utils/Folders.cs @@ -19,11 +19,11 @@ namespace FModel.Utils public static void SetGameName(string pakPath) { - int index = pakPath.LastIndexOf("\\Content\\Paks"); + int index = pakPath.LastIndexOf("\\Content\\Paks", StringComparison.Ordinal); if (index > -1) { string p = pakPath.Substring(0, index); - string game = p.Substring(p.LastIndexOf("\\") + 1); + string game = p.Substring(p.LastIndexOf('\\') + 1); Globals.Game.ActualGame = game switch { "FortniteGame" => EGame.Fortnite, @@ -169,4 +169,4 @@ namespace FModel.Utils return filePath; } } -} +} \ No newline at end of file diff --git a/FModel/Utils/Keys.cs b/FModel/Utils/Keys.cs index 0a573cd2..72086496 100644 --- a/FModel/Utils/Keys.cs +++ b/FModel/Utils/Keys.cs @@ -4,6 +4,7 @@ using FModel.ViewModels.StatusBar; using Newtonsoft.Json; using PakReader; using PakReader.Parsers.Objects; +using System; using System.Collections.Generic; namespace FModel.Utils @@ -50,7 +51,7 @@ namespace FModel.Utils if (menuItem.PakFile.Info.EncryptionKeyGuid.Equals(new FGuid(0u, 0u, 0u, 0u)) && staticKeys.TryGetValue(Globals.Game.ActualGame.ToString(), out var sKey)) { - sKey = sKey.StartsWith("0x") ? sKey.Substring(2).ToUpperInvariant() : sKey.ToUpperInvariant(); + sKey = sKey.StartsWith("0x") ? sKey[2..].ToUpperInvariant() : sKey.ToUpperInvariant(); try { // i can use TestAesKey here but that means it's gonna test here then right after to set the key @@ -70,10 +71,16 @@ namespace FModel.Utils } } - string trigger = $"{Properties.Settings.Default.PakPath.Substring(Properties.Settings.Default.PakPath.LastIndexOf(Folders.GetGameName())).Replace("\\", "/")}/{menuItem.PakFile.FileName}"; + string trigger; + { + if (Properties.Settings.Default.PakPath.EndsWith(".manifest")) + trigger = $"{menuItem.PakFile.Directory.Replace('\\', '/')}/{menuItem.PakFile.FileName}"; + else + trigger = $"{Properties.Settings.Default.PakPath[Properties.Settings.Default.PakPath.LastIndexOf(Folders.GetGameName(), StringComparison.Ordinal)..].Replace("\\", "/")}/{menuItem.PakFile.FileName}"; + } if (dynamicKeys.TryGetValue(Globals.Game.ActualGame.ToString(), out var gameDict) && gameDict.TryGetValue(trigger, out var key)) { - string dKey = key.StartsWith("0x") ? key.Substring(2).ToUpperInvariant() : key.ToUpperInvariant(); + string dKey = key.StartsWith("0x") ? key[2..].ToUpperInvariant() : key.ToUpperInvariant(); try { // i can use TestAesKey here but that means it's gonna test here then right after to set the key @@ -96,4 +103,4 @@ namespace FModel.Utils } } } -} +} \ No newline at end of file diff --git a/FModel/Windows/AESManager/AESManager.xaml.cs b/FModel/Windows/AESManager/AESManager.xaml.cs index 3a437fab..fdca7758 100644 --- a/FModel/Windows/AESManager/AESManager.xaml.cs +++ b/FModel/Windows/AESManager/AESManager.xaml.cs @@ -5,6 +5,7 @@ using FModel.ViewModels.MenuItem; using FModel.Windows.CustomNotifier; using Newtonsoft.Json; using PakReader.Pak; +using System; using System.Collections.Generic; using System.Text.RegularExpressions; using System.Windows; @@ -60,12 +61,20 @@ namespace FModel.Windows.AESManager foreach (PakFileReader pak in MenuItems.pakFiles.GetDynamicPakFileReaders()) { gridRow++; - string trigger = $"{Properties.Settings.Default.PakPath.Substring(Properties.Settings.Default.PakPath.LastIndexOf(Folders.GetGameName())).Replace("\\", "/")}/{pak.FileName}"; + string trigger; + { + if (Properties.Settings.Default.PakPath.EndsWith(".manifest")) + trigger = $"{pak.Directory.Replace('\\', '/')}/{pak.FileName}"; + else + trigger = $"{Properties.Settings.Default.PakPath[Properties.Settings.Default.PakPath.LastIndexOf(Folders.GetGameName(), StringComparison.Ordinal)..].Replace("\\", "/")}/{pak.FileName}"; + } string key; - if (dynamicAesKeys.TryGetValue(Globals.Game.ActualGame.ToString(), out var gameDict) && gameDict.TryGetValue(trigger, out var dKey)) - key = dKey; - else - key = ""; + { + if (dynamicAesKeys.TryGetValue(Globals.Game.ActualGame.ToString(), out var gameDict) && gameDict.TryGetValue(trigger, out var dKey)) + key = dKey; + else + key = ""; + } DebugHelper.WriteLine("{0} {1} {2} {3} {4}", "[FModel]", "[Window]", "[AES Manager]", "[GET]", $"{pak.FileName} with key: {key}"); DynamicKeys_Grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); @@ -116,7 +125,13 @@ namespace FModel.Windows.AESManager dynamicAesKeys[Globals.Game.ActualGame.ToString()] = new Dictionary(); foreach (PakFileReader pak in MenuItems.pakFiles.GetDynamicPakFileReaders()) { - string trigger = $"{Properties.Settings.Default.PakPath.Substring(Properties.Settings.Default.PakPath.LastIndexOf(Folders.GetGameName())).Replace("\\", "/")}/{pak.FileName}"; + string trigger; + { + if (Properties.Settings.Default.PakPath.EndsWith(".manifest")) + trigger = $"{pak.Directory.Replace('\\', '/')}/{pak.FileName}"; + else + trigger = $"{Properties.Settings.Default.PakPath[Properties.Settings.Default.PakPath.LastIndexOf(Folders.GetGameName(), StringComparison.Ordinal)..].Replace("\\", "/")}/{pak.FileName}"; + } TextBox textBox = DependencyObjects.FindChild(this, $"pakchunk{Regex.Match(pak.FileName[0..^4], @"\d+").Value}"); if (!string.IsNullOrEmpty(textBox.Text)) { @@ -162,12 +177,20 @@ namespace FModel.Windows.AESManager foreach (PakFileReader pak in MenuItems.pakFiles.GetDynamicPakFileReaders()) { - string trigger = $"{Properties.Settings.Default.PakPath.Substring(Properties.Settings.Default.PakPath.LastIndexOf(Folders.GetGameName())).Replace("\\", "/")}/{pak.FileName}"; + string trigger; + { + if (Properties.Settings.Default.PakPath.EndsWith(".manifest")) + trigger = $"{pak.Directory.Replace('\\', '/')}/{pak.FileName}"; + else + trigger = $"{Properties.Settings.Default.PakPath[Properties.Settings.Default.PakPath.LastIndexOf(Folders.GetGameName(), StringComparison.Ordinal)..].Replace("\\", "/")}/{pak.FileName}"; + } string key; - if (dynamicAesKeys.TryGetValue(Globals.Game.ActualGame.ToString(), out var gameDict) && gameDict.TryGetValue(trigger, out var dKey)) - key = dKey; - else - key = ""; + { + if (dynamicAesKeys.TryGetValue(Globals.Game.ActualGame.ToString(), out var gameDict) && gameDict.TryGetValue(trigger, out var dKey)) + key = dKey; + else + key = ""; + } DebugHelper.WriteLine("{0} {1} {2} {3} {4}", "[FModel]", "[Window]", "[AES Manager]", "[UPDATE]", $"{pak.FileName} with key: {key}"); TextBox textBox = DependencyObjects.FindChild(this, $"pakchunk{Regex.Match(pak.FileName[0..^4], @"\d+").Value}"); @@ -181,4 +204,4 @@ namespace FModel.Windows.AESManager } } } -} +} \ No newline at end of file diff --git a/FModel/Windows/Launcher/FLauncher.xaml b/FModel/Windows/Launcher/FLauncher.xaml index c505b172..2d68f9ae 100644 --- a/FModel/Windows/Launcher/FLauncher.xaml +++ b/FModel/Windows/Launcher/FLauncher.xaml @@ -63,7 +63,7 @@ Content="{x:Static properties:Resources.Path}" HorizontalAlignment="Left" VerticalAlignment="Top"/> + TextWrapping="NoWrap" VerticalAlignment="Top" Foreground="#FFEFEFEF" Margin="5,3,5,0" TextChanged="OnTextChange"/>