mirror of
https://github.com/4sval/FModel.git
synced 2026-04-19 16:17:44 -05:00
Merge pull request #36 from PsychoPast/master
Search in SubDirectories also to find .pak files + Get when possible automatically the Fortnite game files location.
This commit is contained in:
commit
0af43df308
|
|
@ -1,10 +1,15 @@
|
|||
using FModel.Methods;
|
||||
using FModel.Methods.AESManager;
|
||||
using FModel.Methods.Utilities;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
|
@ -26,10 +31,47 @@ namespace FModel.Forms
|
|||
this.SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Display);
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
private async void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AddLblTxtForDynamicPAKs();
|
||||
GetUserSettings();
|
||||
if (string.IsNullOrEmpty(FProp.Default.FPak_MainAES))
|
||||
{
|
||||
await SetMainKey();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetch latest version's main aes key.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task SetMainKey()
|
||||
{
|
||||
dynamic key = null;
|
||||
if (DLLImport.IsInternetAvailable())
|
||||
{
|
||||
try
|
||||
{
|
||||
using (HttpClient web = new HttpClient())
|
||||
{
|
||||
//Not using BenBot api since Rate Limit
|
||||
key = JsonConvert.DeserializeObject(await web.GetStringAsync("https://fnbot.shop/api/aes.json"));
|
||||
}
|
||||
MAesTextBox.Text = $"0x{key.aes}";
|
||||
FProp.Default.FPak_MainAES = $"{key.aes}";
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
new UpdateMyConsole("There was a problem getting the latest aes key for main pak files.", CColors.Blue, true).Append();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
new UpdateMyConsole("Your internet connection is currently unavailable, can't check for dynamic keys at the moment.", CColors.Blue, true).Append();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
|
|
@ -128,5 +170,7 @@ namespace FModel.Forms
|
|||
//SAVE
|
||||
FProp.Default.Save();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ using Ookii.Dialogs.Wpf;
|
|||
using System.Globalization;
|
||||
using FModel.Methods.Assets.IconCreator;
|
||||
using ColorPickerWPF;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using FModel.Methods.PAKs;
|
||||
|
||||
namespace FModel.Forms
|
||||
{
|
||||
|
|
@ -102,9 +105,56 @@ namespace FModel.Forms
|
|||
SetUserSettings();
|
||||
Close();
|
||||
}
|
||||
/// <summary>
|
||||
/// Get user's Directory Letter.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static string GetEpicDirectory() => Directory.Exists(@"C:\ProgramData\Epic") ? @"C:\ProgramData\Epic" : Directory.Exists(@"D:\ProgramData\Epic") ? @"D:\ProgramData\Epic" : @"E:\ProgramData\Epic";
|
||||
/// <summary>
|
||||
/// Check if the LauncherInstalled.dat exists.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static bool DatFileExists() => File.Exists($@"{GetEpicDirectory()}\UnrealEngineLauncher\LauncherInstalled.dat");
|
||||
/// <summary>
|
||||
/// Fetch automatically user's game file location.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private string GetGameFiles()
|
||||
{
|
||||
if (DatFileExists())
|
||||
{
|
||||
var games = JsonConvert.DeserializeObject<ParseDatFile>(File.ReadAllText($@"{GetEpicDirectory()}\UnrealEngineLauncher\LauncherInstalled.dat")).List;
|
||||
List<string> AllGames = new List<string>();
|
||||
foreach (var game in games)
|
||||
{
|
||||
AllGames.Add(game.installlocation);
|
||||
}
|
||||
return $@"{AllGames.Where(x => x.Contains("Fortnite")).FirstOrDefault()}\FortniteGame\Content\Paks";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private class ParseDatFile
|
||||
{
|
||||
[JsonProperty("InstallationList")] public InstallationList[] List { get; set; }
|
||||
}
|
||||
private class InstallationList
|
||||
{
|
||||
[JsonProperty("InstallLocation")] public string installlocation { get; set; }
|
||||
}
|
||||
|
||||
private async void GetUserSettings()
|
||||
{
|
||||
string AutoPath = GetGameFiles();
|
||||
if (string.IsNullOrEmpty(FProp.Default.FPak_Path) && DatFileExists() && AutoPath != null)
|
||||
{
|
||||
FProp.Default.FPak_Path = AutoPath;
|
||||
RegisterFromPath.PAK_PATH = AutoPath;
|
||||
RegisterFromPath.FilterPAKs();
|
||||
new UpdateMyProcessEvents("Process events", "State").Update();
|
||||
}
|
||||
|
||||
|
||||
InputTextBox.Text = FProp.Default.FPak_Path;
|
||||
bDiffFileSize.IsChecked = FProp.Default.FDiffFileSize;
|
||||
OutputTextBox.Text = FProp.Default.FOutput_Path;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace FModel.Methods.PAKs
|
|||
{
|
||||
static class RegisterFromPath
|
||||
{
|
||||
private static readonly string PAK_PATH = FProp.Default.FPak_Path;
|
||||
public static string PAK_PATH = FProp.Default.FPak_Path;
|
||||
|
||||
public static void FilterPAKs()
|
||||
{
|
||||
|
|
@ -55,7 +55,7 @@ namespace FModel.Methods.PAKs
|
|||
|
||||
private static IEnumerable<string> GetPAKsFromPath()
|
||||
{
|
||||
return Directory.GetFiles(PAK_PATH).Where(x => x.EndsWith(".pak"));
|
||||
return Directory.GetFiles(PAK_PATH, "*.pak", SearchOption.AllDirectories);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user