various bugs fix

This commit is contained in:
Asval 2019-10-29 10:49:42 +01:00
parent 52a76dadc5
commit a252f737f2
12 changed files with 124 additions and 104 deletions

View File

@ -37,7 +37,7 @@
<MenuItem x:Name="MI_LoadOnePAK" Header="Load One PAK" IsEnabled="False"/>
<MenuItem x:Name="MI_LoadAllPAKs" Header="Load All PAKs" Padding="2,4,2,2" IsEnabled="False" Click="MI_LoadAllPAKs_Click"/>
<Separator/>
<MenuItem x:Name="reloadAES" Header="Reload AES Key" Click="MenuItem_Click"/>
<MenuItem x:Name="MI_ReloadAESs" Header="Reload AES Keys" Click="MI_ReloadAESs_Click"/>
<Separator/>
<MenuItem x:Name="MI_DownloadBackups" Header="Download Backups"/>
<MenuItem x:Name="MI_BackupPAKs" Header="Backup PAKs" Click="MI_BackupPAKs_Click" IsEnabled="False"/>

View File

@ -51,8 +51,7 @@ namespace FModel
FoldersUtility.LoadFolders();
FoldersUtility.CheckWatermark();
RegisterFromPath.FilterPAKs();
if (FProp.Default.ReloadAES)
DynamicKeysChecker.SetDynamicKeys();
DynamicKeysChecker.SetDynamicKeys();
RegisterDownloadedBackups.LoadBackupFiles();
}).ContinueWith(TheTask =>
{
@ -155,6 +154,10 @@ namespace FModel
//not done yet
}
}
private void MI_ReloadAESs_Click(object sender, RoutedEventArgs e)
{
DynamicKeysChecker.SetDynamicKeys(true);
}
private async void MI_BackupPAKs_Click(object sender, RoutedEventArgs e)
{
await BackupPAKs.CreateBackupFile();
@ -357,10 +360,5 @@ namespace FModel
}
}
#endregion
private void MenuItem_Click(object sender, RoutedEventArgs e)
{
DynamicKeysChecker.SetDynamicKeys();
}
}
}

View File

@ -6,7 +6,7 @@
xmlns:local="clr-namespace:FModel.Forms"
mc:Ignorable="d"
Title="Settings"
Height="585"
Height="581.5"
Width="610"
Style="{StaticResource {x:Type Window}}"
WindowStartupLocation="CenterScreen"
@ -14,23 +14,23 @@
ResizeMode="CanMinimize" Loaded="Window_Loaded"
>
<Grid>
<GroupBox Header=".PAK Files" HorizontalAlignment="Left" Height="72" Margin="10,10,0,0" VerticalAlignment="Top" Width="574" BorderBrush="#7F748198">
<GroupBox Header=".PAK Files" HorizontalAlignment="Left" Height="70" Margin="10,10,0,0" VerticalAlignment="Top" Width="574" BorderBrush="#7F748198">
<Grid>
<Label Content="Input:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="2,1,0,0"/>
<TextBox x:Name="InputTextBox" Height="19" Margin="41,4,35,0" TextWrapping="NoWrap" VerticalAlignment="Top" Foreground="#FFEFEFEF"/>
<Button x:Name="BrowseInput_Button" Content="..." HorizontalAlignment="Left" Margin="532,4,0,0" VerticalAlignment="Top" Width="20" Click="BrowseInput_Button_Click"/>
<CheckBox x:Name="bDiffFileSize" Content="Diff w/ File Size" HorizontalAlignment="Left" Margin="10,31,0,0" VerticalAlignment="Top"/>
<CheckBox x:Name="checkReloadAES" Content="AES reload automatically" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="120,31,0,0" Width="148" IsChecked="True"/>
<CheckBox x:Name="checkReloadAES" Content="Reload AES Keys at Launch" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="120,31,0,0" Width="148" IsChecked="True"/>
</Grid>
</GroupBox>
<GroupBox Header="Extraction" HorizontalAlignment="Left" Height="48" Margin="10,87,0,0" VerticalAlignment="Top" Width="574" BorderBrush="#7F748198">
<GroupBox Header="Extraction" HorizontalAlignment="Left" Height="48" Margin="10,85,0,0" VerticalAlignment="Top" Width="574" BorderBrush="#7F748198">
<Grid>
<Label Content="Output:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="2,2,0,-1"/>
<TextBox x:Name="OutputTextBox" Height="19" Margin="50,4,35,0" TextWrapping="NoWrap" VerticalAlignment="Top" Foreground="#FFEFEFEF"/>
<Button x:Name="BrowseOutput_Button" Content="..." HorizontalAlignment="Left" Margin="532,4,0,0" VerticalAlignment="Top" Width="20" Click="BrowseOutput_Button_Click"/>
</Grid>
</GroupBox>
<GroupBox Header="Icon Creator" HorizontalAlignment="Left" Height="206" Margin="10,140,0,0" VerticalAlignment="Top" Width="574" BorderBrush="#7F748198">
<GroupBox Header="Icon Creator" HorizontalAlignment="Left" Height="206" Margin="10,138,0,0" VerticalAlignment="Top" Width="574" BorderBrush="#7F748198">
<Grid>
<Label Content="Language:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="2,2,0,0"/>
<ComboBox x:Name="ComboBox_Language" HorizontalAlignment="Left" Margin="61,5,0,0" VerticalAlignment="Top" Width="332" BorderBrush="#7F748198" Background="#FF333C46">
@ -76,7 +76,7 @@
<Button x:Name="OpenIconCreator_Button" Content="Open Image" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="164" Click="OpenIconCreator_Button_Click"/>
</Grid>
</GroupBox>
<GroupBox Header="Challenges Theme" HorizontalAlignment="Left" Height="155" Margin="10,351,0,0" VerticalAlignment="Top" Width="574" BorderBrush="#7F748198">
<GroupBox Header="Challenges Theme" HorizontalAlignment="Left" Height="155" Margin="10,349,0,0" VerticalAlignment="Top" Width="574" BorderBrush="#7F748198">
<Grid>
<Label Content="Watermark:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="2,2,0,-1"/>
<TextBox x:Name="WatermarkChallenge_TextBox" Height="19" Margin="69,4,263,0" TextWrapping="NoWrap" VerticalAlignment="Top" Foreground="#FFEFEFEF" TextChanged="UpdateChallengeCustomTheme"/>

View File

@ -12,66 +12,71 @@ namespace FModel.Methods.AESManager
private static readonly string AESManager_PATH = FProp.Default.FOutput_Path + "\\FAESManager.xml";
private static List<AESInfosEntry> _oldAESEntriesList;
public static void SetDynamicKeys()
public static void SetDynamicKeys(bool reaload = false)
{
if (!File.Exists(AESManager_PATH))
if (FProp.Default.ReloadAES || reaload)
{
AESEntries.AESEntriesList = new List<AESInfosEntry>();
KeysManager.Serialize(string.Empty, string.Empty);
}
else
{
KeysManager.Deserialize();
_oldAESEntriesList = AESEntries.AESEntriesList;
}
if (PAKEntries.PAKEntriesList != null && PAKEntries.PAKEntriesList.Any())
{
string KeysFromBen = EndpointsUtility.GetKeysFromBen();
if (!string.IsNullOrEmpty(KeysFromBen))
if (!File.Exists(AESManager_PATH))
{
Dictionary<string, string> KeysDict = JsonConvert.DeserializeObject<Dictionary<string, string>>(KeysFromBen);
if (KeysDict != null)
{
AESEntries.AESEntriesList = new List<AESInfosEntry>();
foreach (PAKInfosEntry Pak in PAKEntries.PAKEntriesList.Where(x => x.bTheDynamicPAK == true //DYNAMIC PAK ONLY
&& !AESEntries.AESEntriesList.Where(w => string.Equals(w.ThePAKName, Path.GetFileNameWithoutExtension(x.ThePAKPath))).Any() //IS NOT ALREADY ADDED
))
{
if (KeysDict.ContainsKey(Path.GetFileName(Pak.ThePAKPath)))
{
KeysManager.Serialize(Path.GetFileNameWithoutExtension(Pak.ThePAKPath), KeysDict[Path.GetFileName(Pak.ThePAKPath)].ToUpperInvariant().Substring(2));
AESEntries.AESEntriesList = new List<AESInfosEntry>();
KeysManager.Serialize(string.Empty, string.Empty);
}
else
{
KeysManager.Deserialize();
_oldAESEntriesList = AESEntries.AESEntriesList;
}
if (_oldAESEntriesList != null)
if (PAKEntries.PAKEntriesList != null && PAKEntries.PAKEntriesList.Any())
{
string KeysFromBen = EndpointsUtility.GetKeysFromBen();
if (!string.IsNullOrEmpty(KeysFromBen))
{
Dictionary<string, string> KeysDict = JsonConvert.DeserializeObject<Dictionary<string, string>>(KeysFromBen);
if (KeysDict != null)
{
AESEntries.AESEntriesList = new List<AESInfosEntry>();
foreach (PAKInfosEntry Pak in PAKEntries.PAKEntriesList.Where(x => x.bTheDynamicPAK == true //DYNAMIC PAK ONLY
&& !AESEntries.AESEntriesList.Where(w => string.Equals(w.ThePAKName, Path.GetFileNameWithoutExtension(x.ThePAKPath))).Any() //IS NOT ALREADY ADDED
))
{
if (KeysDict.ContainsKey(Path.GetFileName(Pak.ThePAKPath)))
{
if (!_oldAESEntriesList.Where(x => string.Equals(x.ThePAKKey, KeysDict[Path.GetFileName(Pak.ThePAKPath)].ToUpperInvariant().Substring(2))).Any())
KeysManager.Serialize(Path.GetFileNameWithoutExtension(Pak.ThePAKPath), KeysDict[Path.GetFileName(Pak.ThePAKPath)].ToUpperInvariant().Substring(2));
if (_oldAESEntriesList != null)
{
new UpdateMyConsole(Path.GetFileName(Pak.ThePAKPath), CColors.Blue).Append();
new UpdateMyConsole(" can now be opened.", CColors.White, true).Append();
if (!_oldAESEntriesList.Where(x => string.Equals(x.ThePAKKey, KeysDict[Path.GetFileName(Pak.ThePAKPath)].ToUpperInvariant().Substring(2))).Any())
{
new UpdateMyConsole(Path.GetFileName(Pak.ThePAKPath), CColors.Blue).Append();
new UpdateMyConsole(" can now be opened.", CColors.White, true).Append();
}
//else mean there was a FAESManager.xml but the key was already there and didn't change
}
else
{
//mostly for new users
new UpdateMyConsole(Path.GetFileName(Pak.ThePAKPath), CColors.Blue).Append();
new UpdateMyConsole(" can be opened.", CColors.White, true).Append();
}
//else mean there was a FAESManager.xml but the key was already there and didn't change
}
else
{
//mostly for new users
new UpdateMyConsole(Path.GetFileName(Pak.ThePAKPath), CColors.Blue).Append();
new UpdateMyConsole(" can be opened.", CColors.White, true).Append();
KeysManager.Serialize(Path.GetFileName(Pak.ThePAKPath), string.Empty);
}
}
else
{
KeysManager.Serialize(Path.GetFileName(Pak.ThePAKPath), string.Empty);
}
}
}
}
}
Directory.CreateDirectory(Path.GetDirectoryName(AESManager_PATH));
using (var fileStream = new FileStream(AESManager_PATH, FileMode.Create))
{
KeysManager.serializer.Serialize(fileStream, AESEntries.AESEntriesList);
Directory.CreateDirectory(Path.GetDirectoryName(AESManager_PATH));
using (var fileStream = new FileStream(AESManager_PATH, FileMode.Create))
{
KeysManager.serializer.Serialize(fileStream, AESEntries.AESEntriesList);
}
}
else
KeysManager.Deserialize();
FWindow.FMain.Dispatcher.InvokeAsync(() =>
{

View File

@ -19,6 +19,7 @@ namespace FModel.Methods.Assets
public static async Task LoadSelectedAsset()
{
new UpdateMyProcessEvents("", "").Update();
FWindow.FMain.Button_Extract.IsEnabled = false;
FWindow.FMain.Button_Stop.IsEnabled = true;
FWindow.FMain.AssetPropertiesBox_Main.Text = string.Empty;
@ -57,6 +58,7 @@ namespace FModel.Methods.Assets
public static async Task ExtractFoldersAndSub(string path)
{
new UpdateMyProcessEvents("", "").Update();
FWindow.FMain.Button_Extract.IsEnabled = false;
FWindow.FMain.Button_Stop.IsEnabled = true;
FWindow.FMain.AssetPropertiesBox_Main.Text = string.Empty;

View File

@ -17,6 +17,7 @@ namespace FModel.Methods.Assets.IconCreator
public static DrawingVisual DrawNormalIconKThx(JArray AssetProperties)
{
FoldersUtility.CheckWatermark();
new UpdateMyProcessEvents("Creating Icon...", "Waiting").Update();
DrawingVisual drawingVisual = new DrawingVisual();

View File

@ -182,11 +182,11 @@ namespace FModel.Methods.Assets.IconCreator
private static void DrawDisplayName(string DisplayName)
{
Typeface typeface = new Typeface(TextsUtility.FBurbank, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
Typeface typeface = new Typeface(TextsUtility.FBurbank, FontStyles.Normal, string.Equals(FProp.Default.FLanguage, "Japanese") ? FontWeights.Black : FontWeights.Normal, FontStretches.Normal);
FormattedText formattedText =
new FormattedText(
string.Equals(FProp.Default.FRarity_Design, "Minimalist") ? DisplayName.ToUpperInvariant() : DisplayName,
string.Equals(FProp.Default.FRarity_Design, "Minimalist") || string.Equals(FProp.Default.FLanguage, "Russian") ? DisplayName.ToUpperInvariant() : DisplayName,
CultureInfo.CurrentUICulture,
FlowDirection.LeftToRight,
typeface,

View File

@ -29,49 +29,51 @@ namespace FModel.Methods.PAKs
{
new UpdateMyProcessEvents($"Writing {Path.GetFileName(BACKUP_FILE_PATH)}", "Waiting").Update();
Directory.CreateDirectory(Path.GetDirectoryName(BACKUP_FILE_PATH));
var fileStream = new FileStream(BACKUP_FILE_PATH, FileMode.Create);
var writer = new BinaryWriter(fileStream);
foreach (PAKInfosEntry Pak in PAKEntries.PAKEntriesList)
using (FileStream fileStream = new FileStream(BACKUP_FILE_PATH, FileMode.Create))
using (BinaryWriter writer = new BinaryWriter(fileStream))
{
byte[] AESKey = null;
if (Pak.bTheDynamicPAK)
foreach (PAKInfosEntry Pak in PAKEntries.PAKEntriesList)
{
if (AESEntries.AESEntriesList != null && AESEntries.AESEntriesList.Any())
byte[] AESKey = null;
if (Pak.bTheDynamicPAK)
{
string AESFromManager = AESEntries.AESEntriesList.Where(x => string.Equals(x.ThePAKName, Path.GetFileNameWithoutExtension(Pak.ThePAKPath))).Select(x => x.ThePAKKey).FirstOrDefault();
if (!string.IsNullOrEmpty(AESFromManager))
if (AESEntries.AESEntriesList != null && AESEntries.AESEntriesList.Any())
{
AESKey = AESUtility.StringToByteArray(AESFromManager);
string AESFromManager = AESEntries.AESEntriesList.Where(x => string.Equals(x.ThePAKName, Path.GetFileNameWithoutExtension(Pak.ThePAKPath))).Select(x => x.ThePAKKey).FirstOrDefault();
if (!string.IsNullOrEmpty(AESFromManager))
{
AESKey = AESUtility.StringToByteArray(AESFromManager);
}
}
}
}
else
{
AESKey = AESUtility.StringToByteArray(FProp.Default.FPak_MainAES);
}
if (AESKey != null)
{
PakReader.PakReader reader = new PakReader.PakReader(Pak.ThePAKPath, AESKey);
if (reader != null)
else
{
new UpdateMyProcessEvents($"{Path.GetFileNameWithoutExtension(Pak.ThePAKPath)} mount point: {reader.MountPoint}", "Waiting").Update();
AESKey = AESUtility.StringToByteArray(FProp.Default.FPak_MainAES);
}
foreach (FPakEntry entry in reader.FileInfos)
if (AESKey != null)
{
PakReader.PakReader reader = new PakReader.PakReader(Pak.ThePAKPath, AESKey);
if (reader != null)
{
writer.Write(entry.Pos);
writer.Write(entry.Size);
writer.Write(entry.UncompressedSize);
writer.Write(entry.Encrypted);
writer.Write(entry.StructSize);
writer.Write(entry.Name);
writer.Write(entry.CompressionMethod);
new UpdateMyProcessEvents($"{Path.GetFileNameWithoutExtension(Pak.ThePAKPath)} mount point: {reader.MountPoint}", "Waiting").Update();
foreach (FPakEntry entry in reader.FileInfos)
{
writer.Write(entry.Pos);
writer.Write(entry.Size);
writer.Write(entry.UncompressedSize);
writer.Write(entry.Encrypted);
writer.Write(entry.StructSize);
writer.Write(entry.Name);
writer.Write(entry.CompressionMethod);
}
}
}
}
}
fileStream.Close();
writer.Close();
if (new FileInfo(BACKUP_FILE_PATH).Length > 0) //HENCE WE CHECK THE LENGTH
{
new UpdateMyProcessEvents($"\\Backups\\{Path.GetFileName(BACKUP_FILE_PATH)} successfully created", "Success").Update();

View File

@ -91,6 +91,7 @@ namespace FModel.Methods.PAKs
ListBoxUtility.FilesListWithoutPath = null;
FWindow.FMain.ListBox_Main.Items.Clear();
FWindow.FMain.TreeView_Main.IsEnabled = false;
await Task.Run(async () =>
{
PAKEntries.PAKToDisplay = new Dictionary<string, FPakEntry[]>();
@ -102,6 +103,7 @@ namespace FModel.Methods.PAKs
{
TasksUtility.TaskCompleted(TheTask.Exception);
});
FWindow.FMain.TreeView_Main.IsEnabled = true;
FWindow.FMain.MI_LoadAllPAKs.IsEnabled = true;
FWindow.FMain.MI_BackupPAKs.IsEnabled = true;
@ -244,13 +246,13 @@ namespace FModel.Methods.PAKs
new UpdateMyProcessEvents("Comparing Files", "Waiting").Update();
FPakEntry[] BackupEntries;
using (var fileStream = new FileStream(openFiledialog.FileName, FileMode.Open))
using (FileStream fileStream = new FileStream(openFiledialog.FileName, FileMode.Open))
using (BinaryReader reader = new BinaryReader(fileStream))
{
List<FPakEntry> entries = new List<FPakEntry>();
var reader = new BinaryReader(fileStream);
while(reader.BaseStream.Position < reader.BaseStream.Length)
while (reader.BaseStream.Position < reader.BaseStream.Length)
{
var entry = new FPakEntry();
FPakEntry entry = new FPakEntry();
entry.Pos = reader.ReadInt64();
entry.Size = reader.ReadInt64();
entry.UncompressedSize = reader.ReadInt64();
@ -274,18 +276,22 @@ namespace FModel.Methods.PAKs
//FILTER WITH THE OVERRIDED EQUALS METHOD (CHECKING FILE NAME AND FILE UNCOMPRESSED SIZE)
IEnumerable<FPakEntry> newAssets = LocalEntries.ToArray().Except(BackupEntries);
//ADD TO TREE
foreach (FPakEntry entry in newAssets)
{
string onlyFolders = entry.Name.Substring(0, entry.Name.LastIndexOf('/'));
await FWindow.FMain.Dispatcher.InvokeAsync(() =>
{
TreeViewUtility.PopulateTreeView(srt, onlyFolders.Substring(1));
});
}
//ONLY LOAD THE DIFFERENCE WHEN WE CLICK ON A FOLDER
FWindow.FCurrentPAK = "ComparedPAK-WindowsClient.pak";
PAKEntries.PAKToDisplay.Add("ComparedPAK-WindowsClient.pak", newAssets.ToArray());
await FWindow.FMain.Dispatcher.InvokeAsync(() =>
{
//ADD TO TREE
foreach (FPakEntry entry in newAssets)
{
string onlyFolders = entry.Name.Substring(0, entry.Name.LastIndexOf('/'));
TreeViewUtility.PopulateTreeView(srt, onlyFolders.Substring(1));
}
//ONLY LOAD THE DIFFERENCE WHEN WE CLICK ON A FOLDER
FWindow.FCurrentPAK = "ComparedPAK-WindowsClient.pak";
PAKEntries.PAKToDisplay.Add("ComparedPAK-WindowsClient.pak", newAssets.ToArray());
FWindow.FMain.ViewModel = srt;
});

View File

@ -185,6 +185,11 @@ namespace FModel.Methods.Utilities
FWindow.FMain.Dispatcher.InvokeAsync(() =>
{
FWindow.FMain.ImageBox_Main.Source = BitmapFrame.Create((BitmapSource)img); //thread safe and fast af
if (FWindow.FMain.MI_Auto_Save_Images.IsChecked) //auto save images
{
ImagesUtility.SaveImage(FProp.Default.FOutput_Path + "\\Icons\\" + FWindow.FCurrentAsset + ".png");
}
});
}
}

View File

@ -53,6 +53,7 @@ namespace FModel.Methods.Utilities
FWindow.FMain.StateTextBlock.Background = new SolidColorBrush(Color.FromRgb(0, 158, 63));
break;
default:
FWindow.FMain.StateTextBlock.Background = new SolidColorBrush(Color.FromRgb(28, 32, 38));
break;
}
});

View File

@ -10,7 +10,7 @@
<p align="center">
<a href="https://github.com/iAmAsval/FModel/releases/latest">
<img src="https://img.shields.io/github/v/release/iamasval/fmodel"
<img src="https://img.shields.io/github/v/release/iamasval/fmodel?label=Release"
alt="Releases">
</a>
<a href="https://github.com/iAmAsval/FModel/releases/latest">