This commit is contained in:
PsychoPast 2019-11-01 19:39:52 +02:00
parent cd160a1eee
commit 01699f6e43
3 changed files with 52 additions and 7 deletions

View File

@ -1,10 +1,14 @@
using FModel.Methods;
using FModel.Methods.AESManager;
using FModel.Methods.Utilities;
using Newtonsoft.Json;
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 +30,30 @@ 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;
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}";
}
private void Button_Click(object sender, RoutedEventArgs e)
@ -128,5 +152,7 @@ namespace FModel.Forms
//SAVE
FProp.Default.Save();
}
}
}

View File

@ -19,6 +19,7 @@ using FModel.Methods.Assets.IconCreator;
using ColorPickerWPF;
using Newtonsoft.Json;
using System.Collections.Generic;
using FModel.Methods.PAKs;
namespace FModel.Forms
{
@ -104,10 +105,20 @@ 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())
@ -135,7 +146,15 @@ namespace FModel.Forms
private async void GetUserSettings()
{
string AutoPath = GetGameFiles();
FProp.Default.FPak_Path = string.IsNullOrEmpty(FProp.Default.FPak_Path) && DatFileExists() && AutoPath != null ? AutoPath : FProp.Default.FPak_Path;
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;

View File

@ -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,"*.pak",SearchOption.AllDirectories);
return Directory.GetFiles(PAK_PATH, "*.pak", SearchOption.AllDirectories);
}
}
}
}