From 2b4b1bd347cd61f9013ddd699392d29d46c251a3 Mon Sep 17 00:00:00 2001 From: Asval Date: Tue, 28 May 2019 20:21:58 +0200 Subject: [PATCH] just saving this --- FModel/Converter/UnrealEngineDataToOGG.cs | 10 +- FModel/FModel.csproj | 3 + FModel/Forms/Settings.Designer.cs | 6 +- FModel/Forms/Settings.cs | 101 ++---- FModel/Forms/UpdateModeSettings.cs | 40 +-- FModel/MainWindow.cs | 353 +++++++-------------- FModel/Methods/BackPAKs/DynamicPAKs.cs | 12 + FModel/Methods/IconGenerator/ItemIcon.cs | 37 ++- FModel/Methods/IconGenerator/Rarity.cs | 33 +- FModel/Methods/JohnWick/JohnWick.cs | 39 ++- FModel/Methods/Utilities/FontUtilities.cs | 41 +++ FModel/Methods/Utilities/ImageUtilities.cs | 74 +++++ FModel/Methods/Utilities/Utilities.cs | 94 ++++++ FModel/Methods/VarApp.cs | 13 + README.md | 1 + 15 files changed, 504 insertions(+), 353 deletions(-) create mode 100644 FModel/Methods/Utilities/FontUtilities.cs create mode 100644 FModel/Methods/Utilities/ImageUtilities.cs create mode 100644 FModel/Methods/Utilities/Utilities.cs diff --git a/FModel/Converter/UnrealEngineDataToOGG.cs b/FModel/Converter/UnrealEngineDataToOGG.cs index 410add53..a0c638f6 100644 --- a/FModel/Converter/UnrealEngineDataToOGG.cs +++ b/FModel/Converter/UnrealEngineDataToOGG.cs @@ -78,8 +78,8 @@ namespace FModel.Converter byte[] src = File.ReadAllBytes(file); TryFindAndReplace(src, _oggFind, _oggFind, out _oggOutNewArray); //MAKE THE ARRAY START AT PATTERN POSITION - byte[] tmp = new byte[_oggOutNewArray.Length]; - Array.Copy(_oggOutNewArray, tmp, Math.Max(0, _oggOutNewArray.Length - 4)); //DELETE LAST 4 BYTES + byte[] tmp = new byte[_oggOutNewArray.Length - 4]; + Array.Copy(_oggOutNewArray, tmp, tmp.Length); //DELETE LAST 4 BYTES int i = tmp.Length - 7; while (tmp[i] == 0) @@ -88,7 +88,6 @@ namespace FModel.Converter Array.Copy(tmp, bar, i + 1); //DELETE EMPTY BYTES AT THE END File.WriteAllBytes(App.DefaultOutputPath + "\\Sounds\\" + Path.GetFileNameWithoutExtension(file) + ".ogg", bar); - File.Delete(Path.GetFileNameWithoutExtension(file) + ".temp"); } } else @@ -103,8 +102,8 @@ namespace FModel.Converter TryFindAndReplace(src, _oggFind, _oggFind, out _oggOutNewArray); //MAKE THE ARRAY START AT PATTERN POSITION - byte[] tmp = new byte[_oggOutNewArray.Length]; - Array.Copy(_oggOutNewArray, tmp, Math.Max(0, _oggOutNewArray.Length - lengthToDelete)); //DELETE LAST BYTES WHEN _uexpToDelete IS FOUND + byte[] tmp = new byte[_oggOutNewArray.Length - lengthToDelete]; + Array.Copy(_oggOutNewArray, tmp, Math.Max(0, tmp.Length)); //DELETE LAST BYTES WHEN _uexpToDelete IS FOUND byte[] tmp2 = Combine(tmp, srcUbulk); //ADD UBULK ARRAY TO UEXP ARRAY @@ -115,7 +114,6 @@ namespace FModel.Converter Array.Copy(tmp2, bar, i + 1); //DELETE EMPTY BYTES AT THE END File.WriteAllBytes(App.DefaultOutputPath + "\\Sounds\\" + Path.GetFileNameWithoutExtension(file) + ".ogg", bar); - File.Delete(Path.GetFileNameWithoutExtension(file) + ".temp"); } } return App.DefaultOutputPath + "\\Sounds\\" + Path.GetFileNameWithoutExtension(file) + ".ogg"; diff --git a/FModel/FModel.csproj b/FModel/FModel.csproj index 45da7b48..d97fafdf 100644 --- a/FModel/FModel.csproj +++ b/FModel/FModel.csproj @@ -124,6 +124,7 @@ + @@ -162,7 +163,9 @@ MainWindow.cs + + diff --git a/FModel/Forms/Settings.Designer.cs b/FModel/Forms/Settings.Designer.cs index d21c2628..6f106627 100644 --- a/FModel/Forms/Settings.Designer.cs +++ b/FModel/Forms/Settings.Designer.cs @@ -342,11 +342,11 @@ // this.label7.AutoSize = true; this.label7.ForeColor = System.Drawing.Color.Red; - this.label7.Location = new System.Drawing.Point(214, 72); + this.label7.Location = new System.Drawing.Point(137, 72); this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(262, 13); + this.label7.Size = new System.Drawing.Size(355, 13); this.label7.TabIndex = 6; - this.label7.Text = "This is only used to get keys to backup dynamic PAKs"; + this.label7.Text = "2FA must be disabled to make it work or use another account without 2FA"; this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // textBox5 diff --git a/FModel/Forms/Settings.cs b/FModel/Forms/Settings.cs index e0ee6dc7..8d19bcb8 100644 --- a/FModel/Forms/Settings.cs +++ b/FModel/Forms/Settings.cs @@ -1,7 +1,5 @@ using System; using System.Drawing; -using System.Drawing.Drawing2D; -using System.Drawing.Imaging; using System.IO; using System.Windows.Forms; using FModel.Properties; @@ -13,65 +11,6 @@ namespace FModel.Forms private static string _paKsPathBefore; private static string _outputPathBefore; - public static Bitmap ResizeImage(Image image, int width, int height) - { - var destRect = new Rectangle(0, 0, width, height); - var destImage = new Bitmap(width, height); - - destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution); - - using (var graphics = Graphics.FromImage(destImage)) - { - graphics.CompositingMode = CompositingMode.SourceCopy; - graphics.CompositingQuality = CompositingQuality.HighQuality; - graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; - graphics.SmoothingMode = SmoothingMode.HighQuality; - graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; - - using (var wrapMode = new ImageAttributes()) - { - wrapMode.SetWrapMode(WrapMode.TileFlipXY); - graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode); - } - } - - return destImage; - } - public static Image SetImageOpacity(Image image, float opacity) - { - try - { - //create a Bitmap the size of the image provided - Bitmap bmp = new Bitmap(image.Width, image.Height); - - //create a graphics object from the image - using (Graphics gfx = Graphics.FromImage(bmp)) - { - - //create a color matrix object - ColorMatrix matrix = new ColorMatrix(); - - //set the opacity - matrix.Matrix33 = opacity; - - //create image attributes - ImageAttributes attributes = new ImageAttributes(); - - //set the color(opacity) of the image - attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); - - //now draw the image - gfx.DrawImage(image, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, attributes); - } - return bmp; - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - return null; - } - } - public Settings() { InitializeComponent(); @@ -106,8 +45,8 @@ namespace FModel.Forms Graphics g = Graphics.FromImage(bmp); Image watermark = Image.FromFile(Properties.Settings.Default.wFilename); - var opacityImage = SetImageOpacity(watermark, (float)Properties.Settings.Default.wOpacity / 100); - g.DrawImage(ResizeImage(opacityImage, Properties.Settings.Default.wSize, Properties.Settings.Default.wSize), (522 - Properties.Settings.Default.wSize) / 2, (522 - Properties.Settings.Default.wSize) / 2, Properties.Settings.Default.wSize, Properties.Settings.Default.wSize); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)Properties.Settings.Default.wOpacity / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, Properties.Settings.Default.wSize, Properties.Settings.Default.wSize), (522 - Properties.Settings.Default.wSize) / 2, (522 - Properties.Settings.Default.wSize) / 2, Properties.Settings.Default.wSize, Properties.Settings.Default.wSize); wPictureBox.Image = bmp; } @@ -122,8 +61,8 @@ namespace FModel.Forms Graphics g = Graphics.FromImage(bmp); Image watermark = Image.FromFile(Properties.Settings.Default.wFilename); - var opacityImage = SetImageOpacity(watermark, (float)Properties.Settings.Default.wOpacity / 100); - g.DrawImage(ResizeImage(opacityImage, Properties.Settings.Default.wSize, Properties.Settings.Default.wSize), (522 - Properties.Settings.Default.wSize) / 2, (522 - Properties.Settings.Default.wSize) / 2, Properties.Settings.Default.wSize, Properties.Settings.Default.wSize); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)Properties.Settings.Default.wOpacity / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, Properties.Settings.Default.wSize, Properties.Settings.Default.wSize), (522 - Properties.Settings.Default.wSize) / 2, (522 - Properties.Settings.Default.wSize) / 2, Properties.Settings.Default.wSize, Properties.Settings.Default.wSize); wPictureBox.Image = bmp; } @@ -200,8 +139,8 @@ namespace FModel.Forms Graphics g = Graphics.FromImage(bmp); Image watermark = Image.FromFile(Properties.Settings.Default.wFilename); - var opacityImage = SetImageOpacity(watermark, (float)trackBar1.Value / 100); - g.DrawImage(ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)trackBar1.Value / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); wPictureBox.Image = bmp; } @@ -214,8 +153,8 @@ namespace FModel.Forms Graphics g = Graphics.FromImage(bmp); Image watermark = Image.FromFile(Properties.Settings.Default.wFilename); - var opacityImage = SetImageOpacity(watermark, (float)trackBar1.Value / 100); - g.DrawImage(ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)trackBar1.Value / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); wPictureBox.Image = bmp; } @@ -235,8 +174,8 @@ namespace FModel.Forms Graphics g = Graphics.FromImage(bmp); Image watermark = Image.FromFile(Properties.Settings.Default.wFilename); - var opacityImage = SetImageOpacity(watermark, (float)trackBar1.Value / 100); - g.DrawImage(ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)trackBar1.Value / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); wPictureBox.Image = bmp; wPictureBox.Refresh(); @@ -250,8 +189,8 @@ namespace FModel.Forms Graphics g = Graphics.FromImage(bmp); Image watermark = Image.FromFile(Properties.Settings.Default.wFilename); - var opacityImage = SetImageOpacity(watermark, (float)trackBar1.Value / 100); - g.DrawImage(ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)trackBar1.Value / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); wPictureBox.Image = bmp; wPictureBox.Refresh(); @@ -268,8 +207,8 @@ namespace FModel.Forms Graphics g = Graphics.FromImage(bmp); Image watermark = Image.FromFile(Properties.Settings.Default.wFilename); - var opacityImage = SetImageOpacity(watermark, (float)trackBar1.Value / 100); - g.DrawImage(ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)trackBar1.Value / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); wPictureBox.Image = bmp; wPictureBox.Refresh(); @@ -283,8 +222,8 @@ namespace FModel.Forms Graphics g = Graphics.FromImage(bmp); Image watermark = Image.FromFile(Properties.Settings.Default.wFilename); - var opacityImage = SetImageOpacity(watermark, (float)trackBar1.Value / 100); - g.DrawImage(ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)trackBar1.Value / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); wPictureBox.Image = bmp; wPictureBox.Refresh(); @@ -318,8 +257,8 @@ namespace FModel.Forms if (!string.IsNullOrEmpty(Properties.Settings.Default.wFilename)) { Image watermark = Image.FromFile(Properties.Settings.Default.wFilename); - var opacityImage = SetImageOpacity(watermark, (float)trackBar1.Value / 100); - g.DrawImage(ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)trackBar1.Value / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); } wPictureBox.Image = bmp; } @@ -330,8 +269,8 @@ namespace FModel.Forms if (!string.IsNullOrEmpty(Properties.Settings.Default.wFilename)) { Image watermark = Image.FromFile(Properties.Settings.Default.wFilename); - var opacityImage = SetImageOpacity(watermark, (float)trackBar1.Value / 100); - g.DrawImage(ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)trackBar1.Value / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); } wPictureBox.Image = bmp; } diff --git a/FModel/Forms/UpdateModeSettings.cs b/FModel/Forms/UpdateModeSettings.cs index c40812a6..370ab716 100644 --- a/FModel/Forms/UpdateModeSettings.cs +++ b/FModel/Forms/UpdateModeSettings.cs @@ -31,8 +31,8 @@ namespace FModel.Forms Graphics g = Graphics.FromImage(bmp); Image watermark = Image.FromFile(Properties.Settings.Default.UMFilename); - var opacityImage = Settings.SetImageOpacity(watermark, (float)Properties.Settings.Default.UMOpacity / 100); - g.DrawImage(Settings.ResizeImage(opacityImage, Properties.Settings.Default.UMSize, Properties.Settings.Default.UMSize), (522 - Properties.Settings.Default.UMSize) / 2, (522 - Properties.Settings.Default.UMSize) / 2, Properties.Settings.Default.UMSize, Properties.Settings.Default.UMSize); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)Properties.Settings.Default.UMOpacity / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, Properties.Settings.Default.UMSize, Properties.Settings.Default.UMSize), (522 - Properties.Settings.Default.UMSize) / 2, (522 - Properties.Settings.Default.UMSize) / 2, Properties.Settings.Default.UMSize, Properties.Settings.Default.UMSize); wPictureBox.Image = bmp; } @@ -47,8 +47,8 @@ namespace FModel.Forms Graphics g = Graphics.FromImage(bmp); Image watermark = Image.FromFile(Properties.Settings.Default.UMFilename); - var opacityImage = Settings.SetImageOpacity(watermark, (float)Properties.Settings.Default.UMOpacity / 100); - g.DrawImage(Settings.ResizeImage(opacityImage, Properties.Settings.Default.UMSize, Properties.Settings.Default.UMSize), (522 - Properties.Settings.Default.UMSize) / 2, (522 - Properties.Settings.Default.UMSize) / 2, Properties.Settings.Default.UMSize, Properties.Settings.Default.UMSize); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)Properties.Settings.Default.UMOpacity / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, Properties.Settings.Default.UMSize, Properties.Settings.Default.UMSize), (522 - Properties.Settings.Default.UMSize) / 2, (522 - Properties.Settings.Default.UMSize) / 2, Properties.Settings.Default.UMSize, Properties.Settings.Default.UMSize); wPictureBox.Image = bmp; } @@ -165,8 +165,8 @@ namespace FModel.Forms Graphics g = Graphics.FromImage(bmp); Image watermark = Image.FromFile(Properties.Settings.Default.UMFilename); - var opacityImage = Settings.SetImageOpacity(watermark, (float)trackBar1.Value / 100); - g.DrawImage(Settings.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)trackBar1.Value / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); wPictureBox.Image = bmp; } @@ -179,8 +179,8 @@ namespace FModel.Forms Graphics g = Graphics.FromImage(bmp); Image watermark = Image.FromFile(Properties.Settings.Default.UMFilename); - var opacityImage = Settings.SetImageOpacity(watermark, (float)trackBar1.Value / 100); - g.DrawImage(Settings.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)trackBar1.Value / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); wPictureBox.Image = bmp; } @@ -200,8 +200,8 @@ namespace FModel.Forms Graphics g = Graphics.FromImage(bmp); Image watermark = Image.FromFile(Properties.Settings.Default.UMFilename); - var opacityImage = Settings.SetImageOpacity(watermark, (float)trackBar1.Value / 100); - g.DrawImage(Settings.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)trackBar1.Value / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); wPictureBox.Image = bmp; wPictureBox.Refresh(); @@ -215,8 +215,8 @@ namespace FModel.Forms Graphics g = Graphics.FromImage(bmp); Image watermark = Image.FromFile(Properties.Settings.Default.UMFilename); - var opacityImage = Settings.SetImageOpacity(watermark, (float)trackBar1.Value / 100); - g.DrawImage(Settings.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)trackBar1.Value / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); wPictureBox.Image = bmp; wPictureBox.Refresh(); @@ -233,8 +233,8 @@ namespace FModel.Forms Graphics g = Graphics.FromImage(bmp); Image watermark = Image.FromFile(Properties.Settings.Default.UMFilename); - var opacityImage = Settings.SetImageOpacity(watermark, (float)trackBar1.Value / 100); - g.DrawImage(Settings.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)trackBar1.Value / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); wPictureBox.Image = bmp; wPictureBox.Refresh(); @@ -248,8 +248,8 @@ namespace FModel.Forms Graphics g = Graphics.FromImage(bmp); Image watermark = Image.FromFile(Properties.Settings.Default.UMFilename); - var opacityImage = Settings.SetImageOpacity(watermark, (float)trackBar1.Value / 100); - g.DrawImage(Settings.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)trackBar1.Value / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); wPictureBox.Image = bmp; wPictureBox.Refresh(); @@ -283,8 +283,8 @@ namespace FModel.Forms if (!string.IsNullOrEmpty(Properties.Settings.Default.UMFilename)) { Image watermark = Image.FromFile(Properties.Settings.Default.UMFilename); - var opacityImage = Settings.SetImageOpacity(watermark, (float)trackBar1.Value / 100); - g.DrawImage(Settings.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)trackBar1.Value / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); } wPictureBox.Image = bmp; } @@ -295,8 +295,8 @@ namespace FModel.Forms if (!string.IsNullOrEmpty(Properties.Settings.Default.UMFilename)) { Image watermark = Image.FromFile(Properties.Settings.Default.UMFilename); - var opacityImage = Settings.SetImageOpacity(watermark, (float)trackBar1.Value / 100); - g.DrawImage(Settings.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)trackBar1.Value / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, trackBar2.Value, trackBar2.Value), (522 - trackBar2.Value) / 2, (522 - trackBar2.Value) / 2, trackBar2.Value, trackBar2.Value); } wPictureBox.Image = bmp; } diff --git a/FModel/MainWindow.cs b/FModel/MainWindow.cs index 2f49b87a..bfcdab44 100644 --- a/FModel/MainWindow.cs +++ b/FModel/MainWindow.cs @@ -10,8 +10,6 @@ using System.Globalization; using System.IO; using System.Linq; using System.Runtime.InteropServices; -using System.Security.AccessControl; -using System.Security.Principal; using System.Threading.Tasks; using System.Windows.Forms; using AutoUpdaterDotNET; @@ -50,17 +48,6 @@ namespace FModel public static string[] SelectedChallengesArray; #endregion - #region FONTS - PrivateFontCollection _pfc = new PrivateFontCollection(); - StringFormat _centeredString = new StringFormat(); - StringFormat _rightString = new StringFormat(); - StringFormat _centeredStringLine = new StringFormat(); - private int _fontLength; - private byte[] _fontdata; - private int _fontLength2; - private byte[] _fontdata2; - #endregion - #region DLLIMPORT [DllImport("wininet.dll")] private extern static bool InternetGetConnectedState(out int description, int reservedValue); @@ -124,73 +111,6 @@ namespace FModel richTextBox1.ScrollToCaret(); richTextBox1.ResumeLayout(); } - private void OpenWithDefaultProgramAndNoFocus(string path) - { - Process fileopener = new Process(); - fileopener.StartInfo.FileName = "explorer"; - fileopener.StartInfo.Arguments = "\"" + path + "\""; - fileopener.Start(); - } - public Image SetImageOpacity(Image image, float opacity) - { - try - { - //create a Bitmap the size of the image provided - Bitmap bmp = new Bitmap(image.Width, image.Height); - - //create a graphics object from the image - using (Graphics gfx = Graphics.FromImage(bmp)) - { - - //create a color matrix object - ColorMatrix matrix = new ColorMatrix(); - - //set the opacity - matrix.Matrix33 = opacity; - - //create image attributes - ImageAttributes attributes = new ImageAttributes(); - - //set the color(opacity) of the image - attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); - - //now draw the image - gfx.DrawImage(image, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, attributes); - } - return bmp; - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - return null; - } - } - private void CreateDir() - { - if (!Directory.Exists(App.DefaultOutputPath + "\\Backup\\")) - Directory.CreateDirectory(App.DefaultOutputPath + "\\Backup\\"); - if (!Directory.Exists(App.DefaultOutputPath + "\\Extracted\\")) - Directory.CreateDirectory(App.DefaultOutputPath + "\\Extracted\\"); - if (!Directory.Exists(App.DefaultOutputPath + "\\Icons\\")) - Directory.CreateDirectory(App.DefaultOutputPath + "\\Icons\\"); - if (!Directory.Exists(App.DefaultOutputPath + "\\Sounds\\")) - Directory.CreateDirectory(App.DefaultOutputPath + "\\Sounds\\"); - } - public static void SetFolderPermission(string folderPath) - { - var directoryInfo = new DirectoryInfo(folderPath); - var directorySecurity = directoryInfo.GetAccessControl(); - var currentUserIdentity = WindowsIdentity.GetCurrent(); - var fileSystemRule = new FileSystemAccessRule(currentUserIdentity.Name, - FileSystemRights.Read, - InheritanceFlags.ObjectInherit | - InheritanceFlags.ContainerInherit, - PropagationFlags.None, - AccessControlType.Allow); - - directorySecurity.AddAccessRule(fileSystemRule); - directoryInfo.SetAccessControl(directorySecurity); - } #endregion #region LOAD & LEAVE @@ -228,33 +148,6 @@ namespace FModel } } } - private void SetOutput() - { - App.DefaultOutputPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\FModel"; //DOCUMENTS FOLDER BY DEFAULT - if (string.IsNullOrEmpty(Settings.Default.ExtractOutput)) - { - Settings.Default.ExtractOutput = App.DefaultOutputPath; - Settings.Default.Save(); - } - else - { - App.DefaultOutputPath = Settings.Default.ExtractOutput; - } - - if (!Directory.Exists(App.DefaultOutputPath)) - Directory.CreateDirectory(App.DefaultOutputPath); - } - private void JohnWickCheck() - { - if (File.Exists(App.DefaultOutputPath + "\\john-wick-parse-modded.exe")) - { - File.Delete(App.DefaultOutputPath + "\\john-wick-parse-modded.exe"); - } - if (File.Exists(App.DefaultOutputPath + "\\john-wick-parse_custom.exe")) - { - File.Delete(App.DefaultOutputPath + "\\john-wick-parse_custom.exe"); - } - } private void KeyCheck() { if (InvokeRequired) @@ -291,25 +184,6 @@ namespace FModel scintilla1.ClearCmdKey(Keys.Control | Keys.Z); scintilla1.Lexer = Lexer.Json; } - private void SetFont() - { - _fontLength = Resources.BurbankBigCondensed_Bold.Length; - _fontdata = Resources.BurbankBigCondensed_Bold; - IntPtr weirdData = Marshal.AllocCoTaskMem(_fontLength); - Marshal.Copy(_fontdata, 0, weirdData, _fontLength); - _pfc.AddMemoryFont(weirdData, _fontLength); - - _fontLength2 = Resources.BurbankBigCondensed_Black.Length; - _fontdata2 = Resources.BurbankBigCondensed_Black; - IntPtr weirdData2 = Marshal.AllocCoTaskMem(_fontLength2); - Marshal.Copy(_fontdata2, 0, weirdData2, _fontLength2); - _pfc.AddMemoryFont(weirdData2, _fontLength2); - - _centeredString.Alignment = StringAlignment.Center; - _rightString.Alignment = StringAlignment.Far; - _centeredStringLine.LineAlignment = StringAlignment.Center; - _centeredStringLine.Alignment = StringAlignment.Center; - } //EVENTS private async void MainWindow_Load(object sender, EventArgs e) @@ -330,12 +204,12 @@ namespace FModel await Task.Run(() => { FillWithPaKs(); KeyCheck(); - SetOutput(); - SetFolderPermission(App.DefaultOutputPath); - JohnWickCheck(); - CreateDir(); + Utilities.SetOutputFolder(); + Utilities.SetFolderPermission(App.DefaultOutputPath); + Utilities.JohnWickCheck(); + Utilities.CreateDefaultFolders(); SetScintillaStyle(); - SetFont(); + FontUtilities.SetFont(); }); } private void MainWindow_FormClosing(object sender, FormClosingEventArgs e) @@ -980,7 +854,7 @@ namespace FModel { StopWatch = new Stopwatch(); StopWatch.Start(); - CreateDir(); + Utilities.CreateDefaultFolders(); ExtractAndSerializeItems(e, true); } private void backgroundWorker2_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) @@ -1392,7 +1266,7 @@ namespace FModel { itemIcon = new Bitmap(bmpTemp); } - g.DrawImage(Forms.Settings.ResizeImage(itemIcon, 512, 512), new Point(5, 5)); + g.DrawImage(ImageUtilities.ResizeImage(itemIcon, 512, 512), new Point(5, 5)); } else { @@ -1405,14 +1279,14 @@ namespace FModel if (Checking.UmWorking == false && (Settings.Default.isWatermark && !string.IsNullOrEmpty(Settings.Default.wFilename))) { Image watermark = Image.FromFile(Settings.Default.wFilename); - var opacityImage = SetImageOpacity(watermark, (float)Settings.Default.wOpacity / 100); - g.DrawImage(Forms.Settings.ResizeImage(opacityImage, Settings.Default.wSize, Settings.Default.wSize), (522 - Settings.Default.wSize) / 2, (522 - Settings.Default.wSize) / 2, Settings.Default.wSize, Settings.Default.wSize); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)Settings.Default.wOpacity / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, Settings.Default.wSize, Settings.Default.wSize), (522 - Settings.Default.wSize) / 2, (522 - Settings.Default.wSize) / 2, Settings.Default.wSize, Settings.Default.wSize); } if (Checking.UmWorking && (Settings.Default.UMWatermark && !string.IsNullOrEmpty(Settings.Default.UMFilename))) { Image watermark = Image.FromFile(Settings.Default.UMFilename); - var opacityImage = SetImageOpacity(watermark, (float)Settings.Default.UMOpacity / 100); - g.DrawImage(Forms.Settings.ResizeImage(opacityImage, Settings.Default.UMSize, Settings.Default.UMSize), (522 - Settings.Default.UMSize) / 2, (522 - Settings.Default.UMSize) / 2, Settings.Default.UMSize, Settings.Default.UMSize); + var opacityImage = ImageUtilities.SetImageOpacity(watermark, (float)Settings.Default.UMOpacity / 100); + g.DrawImage(ImageUtilities.ResizeImage(opacityImage, Settings.Default.UMSize, Settings.Default.UMSize), (522 - Settings.Default.UMSize) / 2, (522 - Settings.Default.UMSize) / 2, Settings.Default.UMSize, Settings.Default.UMSize); } #endregion @@ -1422,7 +1296,7 @@ namespace FModel #region DRAW TEXT try { - g.DrawString(theItem.DisplayName, new Font(_pfc.Families[0], 35), new SolidBrush(Color.White), new Point(522 / 2, 395), _centeredString); + g.DrawString(theItem.DisplayName, new Font(FontUtilities._pfc.Families[0], 35), new SolidBrush(Color.White), new Point(522 / 2, 395), FontUtilities._centeredString); } catch (NullReferenceException) { @@ -1433,7 +1307,7 @@ namespace FModel } //NAME try { - g.DrawString(theItem.Description, new Font("Arial", 10), new SolidBrush(Color.White), new RectangleF(5, 441, 512, 49), _centeredStringLine); + g.DrawString(theItem.Description, new Font("Arial", 10), new SolidBrush(Color.White), new RectangleF(5, 441, 512, 49), FontUtilities._centeredStringLine); } catch (NullReferenceException) { @@ -1446,7 +1320,7 @@ namespace FModel { try { - g.DrawString(theItem.ShortDescription, new Font(_pfc.Families[0], 13), new SolidBrush(Color.White), new Point(5, 500)); + g.DrawString(theItem.ShortDescription, new Font(FontUtilities._pfc.Families[0], 13), new SolidBrush(Color.White), new Point(5, 500)); } catch (NullReferenceException) { @@ -1457,7 +1331,7 @@ namespace FModel } //TYPE try { - g.DrawString(theItem.GameplayTags.GameplayTagsGameplayTags[Array.FindIndex(theItem.GameplayTags.GameplayTagsGameplayTags, x => x.StartsWith("Cosmetics.Source."))].Substring(17), new Font(_pfc.Families[0], 13), new SolidBrush(Color.White), new Point(522 - 5, 500), _rightString); + g.DrawString(theItem.GameplayTags.GameplayTagsGameplayTags[Array.FindIndex(theItem.GameplayTags.GameplayTagsGameplayTags, x => x.StartsWith("Cosmetics.Source."))].Substring(17), new Font(FontUtilities._pfc.Families[0], 13), new SolidBrush(Color.White), new Point(522 - 5, 500), FontUtilities._rightString); } catch (NullReferenceException) { @@ -1489,7 +1363,7 @@ namespace FModel { itemIcon = new Bitmap(bmpTemp); } - g.DrawImage(Forms.Settings.ResizeImage(itemIcon, 122, 122), new Point(395, 282)); + g.DrawImage(ImageUtilities.ResizeImage(itemIcon, 122, 122), new Point(395, 282)); } } } @@ -1497,7 +1371,7 @@ namespace FModel { try { - g.DrawString(theItem.GameplayTags.GameplayTagsGameplayTags[Array.FindIndex(theItem.GameplayTags.GameplayTagsGameplayTags, x => x.StartsWith("Athena.ItemAction."))].Substring(18), new Font(_pfc.Families[0], 13), new SolidBrush(Color.White), new Point(522 - 5, 500), _rightString); + g.DrawString(theItem.GameplayTags.GameplayTagsGameplayTags[Array.FindIndex(theItem.GameplayTags.GameplayTagsGameplayTags, x => x.StartsWith("Athena.ItemAction."))].Substring(18), new Font(FontUtilities._pfc.Families[0], 13), new SolidBrush(Color.White), new Point(522 - 5, 500), FontUtilities._rightString); } catch (NullReferenceException) { @@ -1510,7 +1384,7 @@ namespace FModel { try { - g.DrawString(theItem.GameplayTags.GameplayTagsGameplayTags[Array.FindIndex(theItem.GameplayTags.GameplayTagsGameplayTags, x => x.StartsWith("Weapon."))].Substring(7), new Font(_pfc.Families[0], 13), new SolidBrush(Color.White), new Point(522 - 5, 500), _rightString); + g.DrawString(theItem.GameplayTags.GameplayTagsGameplayTags[Array.FindIndex(theItem.GameplayTags.GameplayTagsGameplayTags, x => x.StartsWith("Weapon."))].Substring(7), new Font(FontUtilities._pfc.Families[0], 13), new SolidBrush(Color.White), new Point(522 - 5, 500), FontUtilities._rightString); } catch (NullReferenceException) { @@ -1535,7 +1409,7 @@ namespace FModel { try { - g.DrawString("Max Stack Size: " + theItem.MaxStackSize, new Font(_pfc.Families[0], 13), new SolidBrush(Color.White), new Point(5, 500)); + g.DrawString("Max Stack Size: " + theItem.MaxStackSize, new Font(FontUtilities._pfc.Families[0], 13), new SolidBrush(Color.White), new Point(5, 500)); } catch (NullReferenceException) { @@ -1554,7 +1428,7 @@ namespace FModel { try { - g.DrawString(theItem.ShortDescription, new Font(_pfc.Families[0], 13), new SolidBrush(Color.White), new Point(5, 500)); + g.DrawString(theItem.ShortDescription, new Font(FontUtilities._pfc.Families[0], 13), new SolidBrush(Color.White), new Point(5, 500)); } catch (NullReferenceException) { @@ -1565,7 +1439,7 @@ namespace FModel } //TYPE try { - g.DrawString(theItem.CosmeticItem, new Font(_pfc.Families[0], 13), new SolidBrush(Color.White), new Point(522 - 5, 500), _rightString); + g.DrawString(theItem.CosmeticItem, new Font(FontUtilities._pfc.Families[0], 13), new SolidBrush(Color.White), new Point(522 - 5, 500), FontUtilities._rightString); } catch (NullReferenceException) { @@ -1580,32 +1454,32 @@ namespace FModel if (theItem.GameplayTags.GameplayTagsGameplayTags[Array.FindIndex(theItem.GameplayTags.GameplayTagsGameplayTags, x => x.StartsWith("Cosmetics.UserFacingFlags."))].Contains("Animated")) { Image animatedLogo = Resources.T_Icon_Animated_64; - g.DrawImage(Forms.Settings.ResizeImage(animatedLogo, 32, 32), new Point(6, -2)); + g.DrawImage(ImageUtilities.ResizeImage(animatedLogo, 32, 32), new Point(6, -2)); } else if (theItem.GameplayTags.GameplayTagsGameplayTags[Array.FindIndex(theItem.GameplayTags.GameplayTagsGameplayTags, x => x.StartsWith("Cosmetics.UserFacingFlags."))].Contains("HasUpgradeQuests") && theItem.ExportType != "AthenaPetCarrierItemDefinition") { Image questLogo = Resources.T_Icon_Quests_64; - g.DrawImage(Forms.Settings.ResizeImage(questLogo, 32, 32), new Point(6, 6)); + g.DrawImage(ImageUtilities.ResizeImage(questLogo, 32, 32), new Point(6, 6)); } else if (theItem.GameplayTags.GameplayTagsGameplayTags[Array.FindIndex(theItem.GameplayTags.GameplayTagsGameplayTags, x => x.StartsWith("Cosmetics.UserFacingFlags."))].Contains("HasUpgradeQuests") && theItem.ExportType == "AthenaPetCarrierItemDefinition") { Image petLogo = Resources.T_Icon_Pets_64; - g.DrawImage(Forms.Settings.ResizeImage(petLogo, 32, 32), new Point(6, 6)); + g.DrawImage(ImageUtilities.ResizeImage(petLogo, 32, 32), new Point(6, 6)); } else if (theItem.GameplayTags.GameplayTagsGameplayTags[Array.FindIndex(theItem.GameplayTags.GameplayTagsGameplayTags, x => x.StartsWith("Cosmetics.UserFacingFlags."))].Contains("HasVariants")) { Image variantsLogo = Resources.T_Icon_Variant_64; - g.DrawImage(Forms.Settings.ResizeImage(variantsLogo, 32, 32), new Point(6, 6)); + g.DrawImage(ImageUtilities.ResizeImage(variantsLogo, 32, 32), new Point(6, 6)); } else if (theItem.GameplayTags.GameplayTagsGameplayTags[Array.FindIndex(theItem.GameplayTags.GameplayTagsGameplayTags, x => x.StartsWith("Cosmetics.UserFacingFlags."))].Contains("Reactive")) { Image reactiveLogo = Resources.T_Icon_Adaptive_64; - g.DrawImage(Forms.Settings.ResizeImage(reactiveLogo, 32, 32), new Point(7, 7)); + g.DrawImage(ImageUtilities.ResizeImage(reactiveLogo, 32, 32), new Point(7, 7)); } else if (theItem.GameplayTags.GameplayTagsGameplayTags[Array.FindIndex(theItem.GameplayTags.GameplayTagsGameplayTags, x => x.StartsWith("Cosmetics.UserFacingFlags."))].Contains("Traversal")) { Image traversalLogo = Resources.T_Icon_Traversal_64; - g.DrawImage(Forms.Settings.ResizeImage(traversalLogo, 32, 32), new Point(6, 3)); + g.DrawImage(ImageUtilities.ResizeImage(traversalLogo, 32, 32), new Point(6, 3)); } } catch (Exception) { } //COSMETIC USER FACING FLAGS @@ -1614,7 +1488,7 @@ namespace FModel { try { - g.DrawString(theItem.AttributeInitKey.AttributeInitCategory, new Font(_pfc.Families[0], 13), new SolidBrush(Color.White), new Point(522 - 5, 500), _rightString); + g.DrawString(theItem.AttributeInitKey.AttributeInitCategory, new Font(FontUtilities._pfc.Families[0], 13), new SolidBrush(Color.White), new Point(522 - 5, 500), FontUtilities._rightString); } catch (NullReferenceException) { @@ -1625,7 +1499,7 @@ namespace FModel } //CHARACTER TYPE try { - g.DrawString("Power " + theItem.MinLevel + " to " + theItem.MaxLevel, new Font(_pfc.Families[0], 13), new SolidBrush(Color.White), new Point(5, 500)); + g.DrawString("Power " + theItem.MinLevel + " to " + theItem.MaxLevel, new Font(FontUtilities._pfc.Families[0], 13), new SolidBrush(Color.White), new Point(5, 500)); } catch (NullReferenceException) { @@ -1639,7 +1513,7 @@ namespace FModel { try { - g.DrawString(theItem.GameplayTags.GameplayTagsGameplayTags[Array.FindIndex(theItem.GameplayTags.GameplayTagsGameplayTags, x => x.StartsWith("NPC.CharacterType.Survivor.Defender."))].Substring(36), new Font(_pfc.Families[0], 13), new SolidBrush(Color.White), new Point(522 - 5, 500), _rightString); + g.DrawString(theItem.GameplayTags.GameplayTagsGameplayTags[Array.FindIndex(theItem.GameplayTags.GameplayTagsGameplayTags, x => x.StartsWith("NPC.CharacterType.Survivor.Defender."))].Substring(36), new Font(FontUtilities._pfc.Families[0], 13), new SolidBrush(Color.White), new Point(522 - 5, 500), FontUtilities._rightString); } catch (NullReferenceException) { @@ -1659,7 +1533,7 @@ namespace FModel } //CHARACTER TYPE try { - g.DrawString("Power " + theItem.MinLevel + " to " + theItem.MaxLevel, new Font(_pfc.Families[0], 13), new SolidBrush(Color.White), new Point(5, 500)); + g.DrawString("Power " + theItem.MinLevel + " to " + theItem.MaxLevel, new Font(FontUtilities._pfc.Families[0], 13), new SolidBrush(Color.White), new Point(5, 500)); } catch (NullReferenceException) { @@ -1761,10 +1635,10 @@ namespace FModel { justSkip += 1; iamY += 140; - g.DrawString(questParser[ii].Objectives[ii2].Description, new Font(_pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, iamY)); + g.DrawString(questParser[ii].Objectives[ii2].Description, new Font(FontUtilities._pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, iamY)); Image slider = Resources.Challenges_Slider; g.DrawImage(slider, new Point(108, iamY + 86)); - g.DrawString(questParser[ii].Objectives[ii2].Count.ToString(), new Font(_pfc.Families[0], 20), new SolidBrush(Color.FromArgb(255, 255, 255, 255)), new Point(968, iamY + 87)); + g.DrawString(questParser[ii].Objectives[ii2].Count.ToString(), new Font(FontUtilities._pfc.Families[0], 20), new SolidBrush(Color.FromArgb(255, 255, 255, 255)), new Point(968, iamY + 87)); if (justSkip != 1) { g.DrawLine(new Pen(Color.FromArgb(30, 255, 255, 255)), 100, iamY - 10, 2410, iamY - 10); @@ -1783,17 +1657,17 @@ namespace FModel { #region DRAW ICON Image rewardIcon = Resources.T_FNBR_BattlePoints_L; - g.DrawImage(Forms.Settings.ResizeImage(rewardIcon, 75, 75), new Point(2325, iamY + 22)); + g.DrawImage(ImageUtilities.ResizeImage(rewardIcon, 75, 75), new Point(2325, iamY + 22)); GraphicsPath p = new GraphicsPath(); p.AddString( questParser[ii].Rewards.Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest") .Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token") .FirstOrDefault().Quantity.ToString(), - _pfc.Families[1], + FontUtilities._pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, iamY + 25), _rightString); + new Point(2322, iamY + 25), FontUtilities._rightString); g.DrawPath(new Pen(Color.FromArgb(255, 143, 74, 32), 5), p); g.FillPath(new SolidBrush(Color.FromArgb(255, 255, 219, 103)), p); @@ -1803,17 +1677,17 @@ namespace FModel { #region DRAW ICON Image rewardIcon = Resources.T_FNBR_SeasonalXP_L; - g.DrawImage(Forms.Settings.ResizeImage(rewardIcon, 75, 75), new Point(2325, iamY + 22)); + g.DrawImage(ImageUtilities.ResizeImage(rewardIcon, 75, 75), new Point(2325, iamY + 22)); GraphicsPath p = new GraphicsPath(); p.AddString( questParser[ii].Rewards.Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest") .Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token") .FirstOrDefault().Quantity.ToString(), - _pfc.Families[1], + FontUtilities._pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, iamY + 25), _rightString); + new Point(2322, iamY + 25), FontUtilities._rightString); g.DrawPath(new Pen(Color.FromArgb(255, 81, 131, 15), 5), p); g.FillPath(new SolidBrush(Color.FromArgb(255, 230, 253, 177)), p); @@ -1823,17 +1697,17 @@ namespace FModel { #region DRAW ICON Image rewardIcon = Resources.T_Items_MTX_L; - g.DrawImage(Forms.Settings.ResizeImage(rewardIcon, 75, 75), new Point(2325, iamY + 22)); + g.DrawImage(ImageUtilities.ResizeImage(rewardIcon, 75, 75), new Point(2325, iamY + 22)); GraphicsPath p = new GraphicsPath(); p.AddString( questParser[ii].Rewards.Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest") .Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token") .FirstOrDefault().Quantity.ToString(), - _pfc.Families[1], + FontUtilities._pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, iamY + 25), _rightString); + new Point(2322, iamY + 25), FontUtilities._rightString); g.DrawPath(new Pen(Color.FromArgb(255, 100, 160, 175), 5), p); g.FillPath(new SolidBrush(Color.FromArgb(255, 220, 230, 255)), p); @@ -1953,19 +1827,19 @@ namespace FModel { itemIcon = new Bitmap(bmpTemp); } - g.DrawImage(Forms.Settings.ResizeImage(itemIcon, 110, 110), new Point(2300, iamY + 6)); + g.DrawImage(ImageUtilities.ResizeImage(itemIcon, 110, 110), new Point(2300, iamY + 6)); } else { Image itemIcon = Resources.unknown512; - g.DrawImage(Forms.Settings.ResizeImage(itemIcon, 110, 110), new Point(2300, iamY + 6)); + g.DrawImage(ImageUtilities.ResizeImage(itemIcon, 110, 110), new Point(2300, iamY + 6)); } #endregion if (compCount == "-1") - g.DrawString("Complete ALL CHALLENGES to earn the reward item", new Font(_pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, iamY + 22)); + g.DrawString("Complete ALL CHALLENGES to earn the reward item", new Font(FontUtilities._pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, iamY + 22)); else - g.DrawString("Complete ANY " + compCount + " CHALLENGES to earn the reward item", new Font(_pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, iamY + 22)); + g.DrawString("Complete ANY " + compCount + " CHALLENGES to earn the reward item", new Font(FontUtilities._pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, iamY + 22)); } else { @@ -1978,15 +1852,15 @@ namespace FModel { #region DRAW ICON Image rewardIcon = Resources.T_FNBR_BattlePoints_L; - g.DrawImage(Forms.Settings.ResizeImage(rewardIcon, 75, 75), new Point(2325, iamY + 22)); + g.DrawImage(ImageUtilities.ResizeImage(rewardIcon, 75, 75), new Point(2325, iamY + 22)); GraphicsPath p = new GraphicsPath(); p.AddString( bundleParser[i].BundleCompletionRewards[i2].Rewards[i3].Quantity.ToString(), - _pfc.Families[1], + FontUtilities._pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, iamY + 25), _rightString); + new Point(2322, iamY + 25), FontUtilities._rightString); g.DrawPath(new Pen(Color.FromArgb(255, 143, 74, 32), 5), p); g.FillPath(new SolidBrush(Color.FromArgb(255, 255, 219, 103)), p); @@ -1996,15 +1870,15 @@ namespace FModel { #region DRAW ICON Image rewardIcon = Resources.T_FNBR_SeasonalXP_L; - g.DrawImage(Forms.Settings.ResizeImage(rewardIcon, 75, 75), new Point(2325, iamY + 22)); + g.DrawImage(ImageUtilities.ResizeImage(rewardIcon, 75, 75), new Point(2325, iamY + 22)); GraphicsPath p = new GraphicsPath(); p.AddString( bundleParser[i].BundleCompletionRewards[i2].Rewards[i3].Quantity.ToString(), - _pfc.Families[1], + FontUtilities._pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, iamY + 25), _rightString); + new Point(2322, iamY + 25), FontUtilities._rightString); g.DrawPath(new Pen(Color.FromArgb(255, 81, 131, 15), 5), p); g.FillPath(new SolidBrush(Color.FromArgb(255, 230, 253, 177)), p); @@ -2014,15 +1888,15 @@ namespace FModel { #region DRAW ICON Image rewardIcon = Resources.T_Items_MTX_L; - g.DrawImage(Forms.Settings.ResizeImage(rewardIcon, 75, 75), new Point(2325, iamY + 22)); + g.DrawImage(ImageUtilities.ResizeImage(rewardIcon, 75, 75), new Point(2325, iamY + 22)); GraphicsPath p = new GraphicsPath(); p.AddString( bundleParser[i].BundleCompletionRewards[i2].Rewards[i3].Quantity.ToString(), - _pfc.Families[1], + FontUtilities._pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, iamY + 25), _rightString); + new Point(2322, iamY + 25), FontUtilities._rightString); g.DrawPath(new Pen(Color.FromArgb(255, 100, 160, 175), 5), p); g.FillPath(new SolidBrush(Color.FromArgb(255, 220, 230, 255)), p); @@ -2032,9 +1906,9 @@ namespace FModel DrawRewardIcon(itemReward, g, iamY); if (compCount == "-1") - g.DrawString("Complete ALL CHALLENGES to earn the reward item", new Font(_pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, iamY + 22)); + g.DrawString("Complete ALL CHALLENGES to earn the reward item", new Font(FontUtilities._pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, iamY + 22)); else - g.DrawString("Complete ANY " + compCount + " CHALLENGES to earn the reward item", new Font(_pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, iamY + 22)); + g.DrawString("Complete ANY " + compCount + " CHALLENGES to earn the reward item", new Font(FontUtilities._pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, iamY + 22)); } } } @@ -2051,7 +1925,7 @@ namespace FModel { #region WATERMARK g.FillRectangle(new SolidBrush(Color.FromArgb(100, 0, 0, 0)), new Rectangle(0, iamY + 240, bmp.Width, 40)); - g.DrawString(theItem.DisplayName + " Generated using FModel & JohnWickParse - " + DateTime.Now.ToString("dd/MM/yyyy"), new Font(_pfc.Families[0], 20), new SolidBrush(Color.FromArgb(150, 255, 255, 255)), new Point(bmp.Width / 2, iamY + 250), _centeredString); + g.DrawString(theItem.DisplayName + " Generated using FModel & JohnWickParse - " + DateTime.Now.ToString("dd/MM/yyyy"), new Font(FontUtilities._pfc.Families[0], 20), new SolidBrush(Color.FromArgb(150, 255, 255, 255)), new Point(bmp.Width / 2, iamY + 250), FontUtilities._centeredString); #endregion if (v2 == false) { @@ -2059,7 +1933,7 @@ namespace FModel try { string seasonFolder = questJson.Substring(questJson.Substring(0, questJson.LastIndexOf("\\", StringComparison.Ordinal)).LastIndexOf("\\", StringComparison.Ordinal) + 1).ToUpper(); - g.DrawString(seasonFolder.Substring(0, seasonFolder.LastIndexOf("\\", StringComparison.Ordinal)), new Font(_pfc.Families[1], 42), new SolidBrush(Color.FromArgb(255, 149, 213, 255)), new Point(340, 40)); + g.DrawString(seasonFolder.Substring(0, seasonFolder.LastIndexOf("\\", StringComparison.Ordinal)), new Font(FontUtilities._pfc.Families[1], 42), new SolidBrush(Color.FromArgb(255, 149, 213, 255)), new Point(340, 40)); } catch (NullReferenceException) { @@ -2070,7 +1944,7 @@ namespace FModel } //LAST SUBFOLDER try { - g.DrawString(theItem.DisplayName.ToUpper(), new Font(_pfc.Families[1], 115), new SolidBrush(Color.White), new Point(325, 70)); + g.DrawString(theItem.DisplayName.ToUpper(), new Font(FontUtilities._pfc.Families[1], 115), new SolidBrush(Color.White), new Point(325, 70)); } catch (NullReferenceException) { @@ -2130,7 +2004,7 @@ namespace FModel try { - toDrawOn.DrawString(seasonFolder.Substring(0, seasonFolder.LastIndexOf("\\", StringComparison.Ordinal)), new Font(_pfc.Families[1], 42), new SolidBrush(Color.FromArgb(255, seasonRed, seasonGreen, seasonBlue)), new Point(340, 40)); + toDrawOn.DrawString(seasonFolder.Substring(0, seasonFolder.LastIndexOf("\\", StringComparison.Ordinal)), new Font(FontUtilities._pfc.Families[1], 42), new SolidBrush(Color.FromArgb(255, seasonRed, seasonGreen, seasonBlue)), new Point(340, 40)); } catch (NullReferenceException) { @@ -2141,7 +2015,7 @@ namespace FModel } //LAST SUBFOLDER try { - toDrawOn.DrawString(theItem.DisplayName.ToUpper(), new Font(_pfc.Families[1], 115), new SolidBrush(Color.White), new Point(325, 70)); + toDrawOn.DrawString(theItem.DisplayName.ToUpper(), new Font(FontUtilities._pfc.Families[1], 115), new SolidBrush(Color.White), new Point(325, 70)); } catch (NullReferenceException) { @@ -2161,7 +2035,7 @@ namespace FModel { challengeIcon = new Bitmap(bmpTemp); } - toDrawOn.DrawImage(Forms.Settings.ResizeImage(challengeIcon, 271, 271), new Point(40, 0)); + toDrawOn.DrawImage(ImageUtilities.ResizeImage(challengeIcon, 271, 271), new Point(40, 0)); } private void LoopStageQuest(string qAssetType, string qAssetName, Graphics toDrawOn, int yeay, int line) { @@ -2208,10 +2082,10 @@ namespace FModel toDrawOnLoop.TextRenderingHint = TextRenderingHint.AntiAlias; lineLoop += 1; yeayLoop += 140; - toDrawOnLoop.DrawString(questParser[i].Objectives[ii].Description, new Font(_pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, yeayLoop)); + toDrawOnLoop.DrawString(questParser[i].Objectives[ii].Description, new Font(FontUtilities._pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, yeayLoop)); Image slider = Resources.Challenges_Slider; toDrawOnLoop.DrawImage(slider, new Point(108, yeayLoop + 86)); - toDrawOnLoop.DrawString(questParser[i].Objectives[ii].Count.ToString(), new Font(_pfc.Families[0], 20), new SolidBrush(Color.FromArgb(255, 255, 255, 255)), new Point(968, yeayLoop + 87)); + toDrawOnLoop.DrawString(questParser[i].Objectives[ii].Count.ToString(), new Font(FontUtilities._pfc.Families[0], 20), new SolidBrush(Color.FromArgb(255, 255, 255, 255)), new Point(968, yeayLoop + 87)); if (lineLoop != 1) { toDrawOnLoop.DrawLine(new Pen(Color.FromArgb(30, 255, 255, 255)), 100, yeayLoop - 10, 2410, yeayLoop - 10); @@ -2231,17 +2105,17 @@ namespace FModel { #region DRAW ICON Image rewardIcon = Resources.T_FNBR_BattlePoints_L; - toDrawOnLoop.DrawImage(Forms.Settings.ResizeImage(rewardIcon, 75, 75), new Point(2325, yeayLoop + 22)); + toDrawOnLoop.DrawImage(ImageUtilities.ResizeImage(rewardIcon, 75, 75), new Point(2325, yeayLoop + 22)); GraphicsPath p = new GraphicsPath(); p.AddString( questParser[ii].Rewards.Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest") .Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token") .FirstOrDefault().Quantity.ToString(), - _pfc.Families[1], + FontUtilities._pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, yeayLoop + 25), _rightString); + new Point(2322, yeayLoop + 25), FontUtilities._rightString); toDrawOnLoop.DrawPath(new Pen(Color.FromArgb(255, 143, 74, 32), 5), p); toDrawOnLoop.FillPath(new SolidBrush(Color.FromArgb(255, 255, 219, 103)), p); @@ -2251,17 +2125,17 @@ namespace FModel { #region DRAW ICON Image rewardIcon = Resources.T_FNBR_SeasonalXP_L; - toDrawOnLoop.DrawImage(Forms.Settings.ResizeImage(rewardIcon, 75, 75), new Point(2325, yeayLoop + 22)); + toDrawOnLoop.DrawImage(ImageUtilities.ResizeImage(rewardIcon, 75, 75), new Point(2325, yeayLoop + 22)); GraphicsPath p = new GraphicsPath(); p.AddString( questParser[ii].Rewards.Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest") .Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token") .FirstOrDefault().Quantity.ToString(), - _pfc.Families[1], + FontUtilities._pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, yeayLoop + 25), _rightString); + new Point(2322, yeayLoop + 25), FontUtilities._rightString); toDrawOnLoop.DrawPath(new Pen(Color.FromArgb(255, 81, 131, 15), 5), p); toDrawOnLoop.FillPath(new SolidBrush(Color.FromArgb(255, 230, 253, 177)), p); @@ -2271,17 +2145,17 @@ namespace FModel { #region DRAW ICON Image rewardIcon = Resources.T_Items_MTX_L; - toDrawOnLoop.DrawImage(Forms.Settings.ResizeImage(rewardIcon, 75, 75), new Point(2325, yeayLoop + 22)); + toDrawOnLoop.DrawImage(ImageUtilities.ResizeImage(rewardIcon, 75, 75), new Point(2325, yeayLoop + 22)); GraphicsPath p = new GraphicsPath(); p.AddString( questParser[ii].Rewards.Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest") .Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token") .FirstOrDefault().Quantity.ToString(), - _pfc.Families[1], + FontUtilities._pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, yeayLoop + 25), _rightString); + new Point(2322, yeayLoop + 25), FontUtilities._rightString); toDrawOnLoop.DrawPath(new Pen(Color.FromArgb(255, 100, 160, 175), 5), p); toDrawOnLoop.FillPath(new SolidBrush(Color.FromArgb(255, 220, 230, 255)), p); @@ -2351,10 +2225,10 @@ namespace FModel { lineLoop += 1; yeayLoop += 140; - toDrawOnLoop.DrawString(questParser[i].Objectives[ii].Description, new Font(_pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, yeayLoop)); + toDrawOnLoop.DrawString(questParser[i].Objectives[ii].Description, new Font(FontUtilities._pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, yeayLoop)); Image slider = Resources.Challenges_Slider; toDrawOnLoop.DrawImage(slider, new Point(108, yeayLoop + 86)); - toDrawOnLoop.DrawString(questParser[i].Objectives[ii].Count.ToString(), new Font(_pfc.Families[0], 20), new SolidBrush(Color.FromArgb(255, 255, 255, 255)), new Point(968, yeayLoop + 87)); + toDrawOnLoop.DrawString(questParser[i].Objectives[ii].Count.ToString(), new Font(FontUtilities._pfc.Families[0], 20), new SolidBrush(Color.FromArgb(255, 255, 255, 255)), new Point(968, yeayLoop + 87)); if (lineLoop != 1) { toDrawOnLoop.DrawLine(new Pen(Color.FromArgb(30, 255, 255, 255)), 100, yeayLoop - 10, 2410, yeayLoop - 10); @@ -2374,17 +2248,17 @@ namespace FModel { #region DRAW ICON Image rewardIcon = Resources.T_FNBR_BattlePoints_L; - toDrawOnLoop.DrawImage(Forms.Settings.ResizeImage(rewardIcon, 75, 75), new Point(2325, yeayLoop + 22)); + toDrawOnLoop.DrawImage(ImageUtilities.ResizeImage(rewardIcon, 75, 75), new Point(2325, yeayLoop + 22)); GraphicsPath p = new GraphicsPath(); p.AddString( questParser[ii].Rewards.Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest") .Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token") .FirstOrDefault().Quantity.ToString(), - _pfc.Families[1], + FontUtilities._pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, yeayLoop + 25), _rightString); + new Point(2322, yeayLoop + 25), FontUtilities._rightString); toDrawOnLoop.DrawPath(new Pen(Color.FromArgb(255, 143, 74, 32), 5), p); toDrawOnLoop.FillPath(new SolidBrush(Color.FromArgb(255, 255, 219, 103)), p); @@ -2394,17 +2268,17 @@ namespace FModel { #region DRAW ICON Image rewardIcon = Resources.T_FNBR_SeasonalXP_L; - toDrawOnLoop.DrawImage(Forms.Settings.ResizeImage(rewardIcon, 75, 75), new Point(2325, yeayLoop + 22)); + toDrawOnLoop.DrawImage(ImageUtilities.ResizeImage(rewardIcon, 75, 75), new Point(2325, yeayLoop + 22)); GraphicsPath p = new GraphicsPath(); p.AddString( questParser[ii].Rewards.Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest") .Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token") .FirstOrDefault().Quantity.ToString(), - _pfc.Families[1], + FontUtilities._pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, yeayLoop + 25), _rightString); + new Point(2322, yeayLoop + 25), FontUtilities._rightString); toDrawOnLoop.DrawPath(new Pen(Color.FromArgb(255, 81, 131, 15), 5), p); toDrawOnLoop.FillPath(new SolidBrush(Color.FromArgb(255, 230, 253, 177)), p); @@ -2414,17 +2288,17 @@ namespace FModel { #region DRAW ICON Image rewardIcon = Resources.T_Items_MTX_L; - toDrawOnLoop.DrawImage(Forms.Settings.ResizeImage(rewardIcon, 75, 75), new Point(2325, yeayLoop + 22)); + toDrawOnLoop.DrawImage(ImageUtilities.ResizeImage(rewardIcon, 75, 75), new Point(2325, yeayLoop + 22)); GraphicsPath p = new GraphicsPath(); p.AddString( questParser[ii].Rewards.Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest") .Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token") .FirstOrDefault().Quantity.ToString(), - _pfc.Families[1], + FontUtilities._pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, yeayLoop + 25), _rightString); + new Point(2322, yeayLoop + 25), FontUtilities._rightString); toDrawOnLoop.DrawPath(new Pen(Color.FromArgb(255, 100, 160, 175), 5), p); toDrawOnLoop.FillPath(new SolidBrush(Color.FromArgb(255, 220, 230, 255)), p); @@ -2539,12 +2413,12 @@ namespace FModel { itemIcon = new Bitmap(bmpTemp); } - toDrawOn.DrawImage(Forms.Settings.ResizeImage(itemIcon, 110, 110), new Point(2300, y + 6)); + toDrawOn.DrawImage(ImageUtilities.ResizeImage(itemIcon, 110, 110), new Point(2300, y + 6)); } else { Image itemIcon = Resources.unknown512; - toDrawOn.DrawImage(Forms.Settings.ResizeImage(itemIcon, 110, 110), new Point(2300, y + 6)); + toDrawOn.DrawImage(ImageUtilities.ResizeImage(itemIcon, 110, 110), new Point(2300, y + 6)); } } } @@ -2614,12 +2488,12 @@ namespace FModel { itemIcon = new Bitmap(bmpTemp); } - toDrawOn.DrawImage(Forms.Settings.ResizeImage(itemIcon, 110, 110), new Point(2300, y + 6)); + toDrawOn.DrawImage(ImageUtilities.ResizeImage(itemIcon, 110, 110), new Point(2300, y + 6)); } else { Image itemIcon = Resources.unknown512; - toDrawOn.DrawImage(Forms.Settings.ResizeImage(itemIcon, 110, 110), new Point(2300, y + 6)); + toDrawOn.DrawImage(ImageUtilities.ResizeImage(itemIcon, 110, 110), new Point(2300, y + 6)); } } } @@ -2683,7 +2557,7 @@ namespace FModel try { - g.DrawString(seasonFolder.Substring(0, seasonFolder.LastIndexOf("\\", StringComparison.Ordinal)), new Font(_pfc.Families[1], 42), new SolidBrush(Color.FromArgb(255, seasonRed, seasonGreen, seasonBlue)), new Point(340, 40)); + g.DrawString(seasonFolder.Substring(0, seasonFolder.LastIndexOf("\\", StringComparison.Ordinal)), new Font(FontUtilities._pfc.Families[1], 42), new SolidBrush(Color.FromArgb(255, seasonRed, seasonGreen, seasonBlue)), new Point(340, 40)); } catch (NullReferenceException) { @@ -2694,7 +2568,7 @@ namespace FModel } //LAST SUBFOLDER try { - g.DrawString(theItem.DisplayName.ToUpper(), new Font(_pfc.Families[1], 115), new SolidBrush(Color.White), new Point(325, 70)); + g.DrawString(theItem.DisplayName.ToUpper(), new Font(FontUtilities._pfc.Families[1], 115), new SolidBrush(Color.White), new Point(325, 70)); } catch (NullReferenceException) { @@ -2713,7 +2587,7 @@ namespace FModel { challengeIcon = new Bitmap(bmpTemp); } - g.DrawImage(Forms.Settings.ResizeImage(challengeIcon, 271, 271), new Point(40, 0)); + g.DrawImage(ImageUtilities.ResizeImage(challengeIcon, 271, 271), new Point(40, 0)); #endregion } } @@ -2782,11 +2656,11 @@ namespace FModel justSkip += 1; iamY += 140; - g.DrawString(questParser[ii].Objectives[ii2].Description, new Font(_pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, iamY)); + g.DrawString(questParser[ii].Objectives[ii2].Description, new Font(FontUtilities._pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, iamY)); damageOpPosition = iamY; Image slider = Resources.Challenges_Slider; g.DrawImage(slider, new Point(108, iamY + 86)); - g.DrawString(questParser[ii].Objectives[ii2].Count.ToString(), new Font(_pfc.Families[0], 20), new SolidBrush(Color.FromArgb(255, 255, 255, 255)), new Point(968, iamY + 87)); + g.DrawString(questParser[ii].Objectives[ii2].Count.ToString(), new Font(FontUtilities._pfc.Families[0], 20), new SolidBrush(Color.FromArgb(255, 255, 255, 255)), new Point(968, iamY + 87)); if (justSkip != 1) { g.DrawLine(new Pen(Color.FromArgb(30, 255, 255, 255)), 100, iamY - 10, 2410, iamY - 10); @@ -2804,12 +2678,12 @@ namespace FModel { itemIcon = new Bitmap(bmpTemp); } - g.DrawImage(Forms.Settings.ResizeImage(itemIcon, 110, 110), new Point(2300, iamY + 6)); + g.DrawImage(ImageUtilities.ResizeImage(itemIcon, 110, 110), new Point(2300, iamY + 6)); } else { Image itemIcon = Resources.unknown512; - g.DrawImage(Forms.Settings.ResizeImage(itemIcon, 110, 110), new Point(2300, iamY + 6)); + g.DrawImage(ImageUtilities.ResizeImage(itemIcon, 110, 110), new Point(2300, iamY + 6)); } #endregion } @@ -2822,10 +2696,10 @@ namespace FModel justSkip += 1; iamY += 140; - g.DrawString(questParser[ii].Objectives[ii2].Description, new Font(_pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, iamY)); + g.DrawString(questParser[ii].Objectives[ii2].Description, new Font(FontUtilities._pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, iamY)); Image slider = Resources.Challenges_Slider; g.DrawImage(slider, new Point(108, iamY + 86)); - g.DrawString(questParser[ii].Objectives[ii2].Count.ToString(), new Font(_pfc.Families[0], 20), new SolidBrush(Color.FromArgb(255, 255, 255, 255)), new Point(968, iamY + 87)); + g.DrawString(questParser[ii].Objectives[ii2].Count.ToString(), new Font(FontUtilities._pfc.Families[0], 20), new SolidBrush(Color.FromArgb(255, 255, 255, 255)), new Point(968, iamY + 87)); if (justSkip != 1) { g.DrawLine(new Pen(Color.FromArgb(30, 255, 255, 255)), 100, iamY - 10, 2410, iamY - 10); @@ -2843,12 +2717,12 @@ namespace FModel { itemIcon = new Bitmap(bmpTemp); } - g.DrawImage(Forms.Settings.ResizeImage(itemIcon, 110, 110), new Point(2300, iamY + 6)); + g.DrawImage(ImageUtilities.ResizeImage(itemIcon, 110, 110), new Point(2300, iamY + 6)); } else { Image itemIcon = Resources.unknown512; - g.DrawImage(Forms.Settings.ResizeImage(itemIcon, 110, 110), new Point(2300, iamY + 6)); + g.DrawImage(ImageUtilities.ResizeImage(itemIcon, 110, 110), new Point(2300, iamY + 6)); } #endregion } @@ -2880,7 +2754,7 @@ namespace FModel } } - g.DrawString("Same Quest x" + damageOpCount, new Font(_pfc.Families[1], 50), new SolidBrush(Color.White), new Point(1500, damageOpPosition + 25)); + g.DrawString("Same Quest x" + damageOpCount, new Font(FontUtilities._pfc.Families[1], 50), new SolidBrush(Color.White), new Point(1500, damageOpPosition + 25)); iamY += 100; //BundleCompletionRewards @@ -2905,9 +2779,9 @@ namespace FModel DrawRewardIcon(itemReward, g, iamY); if (compCount == "-1") - g.DrawString("Complete ALL CHALLENGES to earn the reward item", new Font(_pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, iamY + 22)); + g.DrawString("Complete ALL CHALLENGES to earn the reward item", new Font(FontUtilities._pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, iamY + 22)); else - g.DrawString("Complete ANY " + compCount + " CHALLENGES to earn the reward item", new Font(_pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, iamY + 22)); + g.DrawString("Complete ANY " + compCount + " CHALLENGES to earn the reward item", new Font(FontUtilities._pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, iamY + 22)); } } } @@ -2922,7 +2796,7 @@ namespace FModel { #region WATERMARK g.FillRectangle(new SolidBrush(Color.FromArgb(100, 0, 0, 0)), new Rectangle(0, iamY + 240, bmp.Width, 40)); - g.DrawString(theItem.DisplayName + " Generated using FModel & JohnWickParse - " + DateTime.Now.ToString("dd/MM/yyyy"), new Font(_pfc.Families[0], 20), new SolidBrush(Color.FromArgb(150, 255, 255, 255)), new Point(bmp.Width / 2, iamY + 250), _centeredString); + g.DrawString(theItem.DisplayName + " Generated using FModel & JohnWickParse - " + DateTime.Now.ToString("dd/MM/yyyy"), new Font(FontUtilities._pfc.Families[0], 20), new SolidBrush(Color.FromArgb(150, 255, 255, 255)), new Point(bmp.Width / 2, iamY + 250), FontUtilities._centeredString); #endregion if (v2 == false) { @@ -2930,7 +2804,7 @@ namespace FModel try { string seasonFolder = questJson.Substring(questJson.Substring(0, questJson.LastIndexOf("\\", StringComparison.Ordinal)).LastIndexOf("\\", StringComparison.Ordinal) + 1).ToUpper(); - g.DrawString(seasonFolder.Substring(0, seasonFolder.LastIndexOf("\\", StringComparison.Ordinal)), new Font(_pfc.Families[1], 42), new SolidBrush(Color.FromArgb(255, 149, 213, 255)), new Point(340, 40)); + g.DrawString(seasonFolder.Substring(0, seasonFolder.LastIndexOf("\\", StringComparison.Ordinal)), new Font(FontUtilities._pfc.Families[1], 42), new SolidBrush(Color.FromArgb(255, 149, 213, 255)), new Point(340, 40)); } catch (NullReferenceException) { @@ -2941,7 +2815,7 @@ namespace FModel } //LAST SUBFOLDER try { - g.DrawString(theItem.DisplayName.ToUpper(), new Font(_pfc.Families[1], 115), new SolidBrush(Color.White), new Point(325, 70)); + g.DrawString(theItem.DisplayName.ToUpper(), new Font(FontUtilities._pfc.Families[1], 115), new SolidBrush(Color.White), new Point(325, 70)); } catch (NullReferenceException) { @@ -3005,9 +2879,16 @@ namespace FModel UpdateConsole(ThePak.CurrentUsedItem + " is a Sound", Color.FromArgb(255, 66, 244, 66), "Success"); string soundPathToConvert = ExtractedFilePath.Substring(0, ExtractedFilePath.LastIndexOf('\\')) + "\\" + ThePak.CurrentUsedItem + ".uexp"; + string soundPathConverted = UnrealEngineDataToOgg.ConvertToOgg(soundPathToConvert); UpdateConsole("Converting " + ThePak.CurrentUsedItem, Color.FromArgb(255, 244, 132, 66), "Processing"); - OpenWithDefaultProgramAndNoFocus(UnrealEngineDataToOgg.ConvertToOgg(soundPathToConvert)); - UpdateConsole("Opening " + ThePak.CurrentUsedItem + ".ogg", Color.FromArgb(255, 66, 244, 66), "Success"); + + if (File.Exists(soundPathConverted)) + { + Utilities.OpenWithDefaultProgramAndNoFocus(soundPathConverted); + UpdateConsole("Opening " + ThePak.CurrentUsedItem + ".ogg", Color.FromArgb(255, 66, 244, 66), "Success"); + } + else + UpdateConsole("Couldn't convert " + ThePak.CurrentUsedItem, Color.FromArgb(255, 244, 66, 66), "Error"); } private void ConvertToTtf(string file) { @@ -3020,7 +2901,7 @@ namespace FModel { StopWatch = new Stopwatch(); StopWatch.Start(); - CreateDir(); + Utilities.CreateDefaultFolders(); ExtractAndSerializeItems(e); } private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) @@ -3137,7 +3018,7 @@ Steps: { using (Graphics g = Graphics.FromImage(bmp)) { - g.DrawImage(Forms.Settings.ResizeImage(mySelectedImages[i], 522, 522), new PointF(curW, curH)); + g.DrawImage(ImageUtilities.ResizeImage(mySelectedImages[i], 522, 522), new PointF(curW, curH)); if (num % numperrow == 0) { curW = 0; diff --git a/FModel/Methods/BackPAKs/DynamicPAKs.cs b/FModel/Methods/BackPAKs/DynamicPAKs.cs index 73dd2442..42eb532a 100644 --- a/FModel/Methods/BackPAKs/DynamicPAKs.cs +++ b/FModel/Methods/BackPAKs/DynamicPAKs.cs @@ -12,6 +12,12 @@ namespace FModel { class DynamicPAKs { + /// + /// get url content as string with authentication + /// + /// + /// + /// url content public static string GetEndpoint(string url, bool auth) { string content = string.Empty; @@ -81,6 +87,12 @@ namespace FModel return Enumerable.Range(0, str.Length / chunkSize) .Select(i => str.Substring(i * chunkSize, chunkSize)); } + /// + /// split KeychainPart each 8 letter + /// for each of these letters, convert to hexadecimal as string + /// + /// + /// the guid (ie 17722063-2246354315-4143272431-3887619937) public static string getPakGuidFromKeychain(string[] KeychainPart) { IEnumerable guid = SplitGuid(KeychainPart[0], 8); diff --git a/FModel/Methods/IconGenerator/ItemIcon.cs b/FModel/Methods/IconGenerator/ItemIcon.cs index ee6fd17f..4b32d4e3 100644 --- a/FModel/Methods/IconGenerator/ItemIcon.cs +++ b/FModel/Methods/IconGenerator/ItemIcon.cs @@ -13,6 +13,12 @@ namespace FModel { public static string ItemIconPath { get; set; } + /// + /// if user doesn't want featured image, make WasFeatured false and move to SearchAthIteDefIcon + /// else search or guess the display asset, if found move to SearchFeaturedIcon, if not found move to SearchAthIteDefIcon + /// + /// + /// public static void GetItemIcon(ItemsIdParser theItem, bool featured = false) { if (featured == false) @@ -37,6 +43,12 @@ namespace FModel } } } + + /// + /// extract, serialize, get Large or Small image for HeroDefinition or WeaponDefinition + /// if no HeroDefinition and WeaponDefinition move to SearchLargeSmallIcon + /// + /// public static void SearchAthIteDefIcon(ItemsIdParser theItem) { if (theItem.HeroDefinition != null) @@ -123,6 +135,11 @@ namespace FModel else SearchLargeSmallIcon(theItem); } + + /// + /// convert Large or Small image to a png image + /// + /// private static void SearchLargeSmallIcon(ItemsIdParser theItem) { if (theItem.LargePreviewImage != null) @@ -140,6 +157,15 @@ namespace FModel ItemIconPath = JohnWick.AssetToTexture2D(textureFile); } } + + /// + /// With GetItemIcon we already know if manualSeach is True or False + /// manualSearch False: extract, serialize the catalogFile and parse to get and convert the featured file to a png image + /// manualSearch True: if the catalogFile is in AllpaksDictionary (is known) do same thing as manualSearch False + /// + /// + /// + /// public static void SearchFeaturedIcon(ItemsIdParser theItem, string catName, bool manualSearch = false) { if (manualSearch == false) @@ -261,6 +287,13 @@ namespace FModel GetItemIcon(theItem); } } + + /// + /// This is only triggered if ThePak.CurrentUsedItem is a weapon id, it's to display the bullet type + /// extract, serialize and parse the ammoFile, search a Large or Small icon, display this icon at the top left of the rarity image + /// + /// + /// public static void GetAmmoData(string ammoFile, Graphics toDrawOn) { string ammoFilePath; @@ -291,12 +324,12 @@ namespace FModel { itemIcon = new Bitmap(bmpTemp); } - toDrawOn.DrawImage(Forms.Settings.ResizeImage(itemIcon, 64, 64), new Point(6, 6)); + toDrawOn.DrawImage(ImageUtilities.ResizeImage(itemIcon, 64, 64), new Point(6, 6)); } else { Image itemIcon = Resources.unknown512; - toDrawOn.DrawImage(Forms.Settings.ResizeImage(itemIcon, 64, 64), new Point(6, 6)); + toDrawOn.DrawImage(ImageUtilities.ResizeImage(itemIcon, 64, 64), new Point(6, 6)); } } } diff --git a/FModel/Methods/IconGenerator/Rarity.cs b/FModel/Methods/IconGenerator/Rarity.cs index 80fdc918..64da9907 100644 --- a/FModel/Methods/IconGenerator/Rarity.cs +++ b/FModel/Methods/IconGenerator/Rarity.cs @@ -6,7 +6,12 @@ namespace FModel { class Rarity { - public static Image GetRarityImage(ItemsIdParser theItem) + /// + /// check the rarity and return the right image + /// + /// + /// the resource image depending on the rarity + private static Image GetRarityImage(ItemsIdParser theItem) { switch (theItem.Rarity) { @@ -27,7 +32,14 @@ namespace FModel return Resources.U512; } } - public static Image GetSeriesImage(ItemsIdParser theItem) + + /// + /// check the series and return the right image + /// if no series known, return the normal item rarity image with GetRarityImage + /// + /// + /// the resource image depending on the series + private static Image GetSeriesImage(ItemsIdParser theItem) { if (theItem.Series == "MarvelSeries") { @@ -38,7 +50,15 @@ namespace FModel return GetRarityImage(theItem); } } - public static Image GetSpecialModeImage(ItemsIdParser theItem, string specialMode) + + /// + /// if specialMode isn't null and is known return the right image + /// if specialMode is unknown, return the normal item rarity image with GetRarityImage + /// + /// + /// + /// the resource image depending on specialMode + private static Image GetSpecialModeImage(ItemsIdParser theItem, string specialMode) { if (specialMode == "ammo") { @@ -49,6 +69,13 @@ namespace FModel return GetRarityImage(theItem); } } + + /// + /// just draw the rarity + /// + /// + /// + /// public static void DrawRarity(ItemsIdParser theItem, Graphics toDrawOn, string specialMode = null) { Image rarityBg; diff --git a/FModel/Methods/JohnWick/JohnWick.cs b/FModel/Methods/JohnWick/JohnWick.cs index 6e8075a5..06616e62 100644 --- a/FModel/Methods/JohnWick/JohnWick.cs +++ b/FModel/Methods/JohnWick/JohnWick.cs @@ -16,6 +16,13 @@ namespace FModel private static string[] myArray { get; set; } private static string currentPakToCheck { get; set; } + /// + /// Normal pak file: using AllpaksDictionary, it tells you the pak name depending on currentItem. Using this pak name and PaksMountPoint we get the mount point + /// Dynamic pak file: It's made so we already know the name of the pak, so we just use PaksMountPoint to get the mount point + /// + /// + /// + /// the mount point as string, used to create subfolders when extracting or create the tree when loading all paks private static string GetMountPointFromDict(string currentItem, bool DynamicPak = false) { if (DynamicPak == true) @@ -23,6 +30,14 @@ namespace FModel else return ThePak.PaksMountPoint[ThePak.AllpaksDictionary[currentItem ?? throw new InvalidOperationException()] ?? throw new InvalidOperationException()]; } + + /// + /// just the method to create subfolders using GetMountPointFromDict and write the file from myResults with its byte[] data + /// + /// + /// + /// + /// the path to this brand new created file private static string WriteFile(string currentItem, string myResults, byte[] data) { if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0") @@ -41,6 +56,14 @@ namespace FModel } } + /// + /// We get the file list of currentPak, we find all files that matched our currentItem, for each result we get its indexes (it's used to get its data) + /// Then we can use WriteFile to write each results with its data + /// If currentPak is the same twice in a row, we do not try to get a new file list + /// + /// + /// + /// the path of the last created file (usually the uexp file but we don't care about the extension, so it's fine) public static string ExtractAsset(string currentPak, string currentItem) { if (currentPak != currentPakToCheck) @@ -69,6 +92,12 @@ namespace FModel currentPakToCheck = currentPak; return AssetPath; } + + /// + /// just convert the asset to a png image with some exceptions in case AssetName is a material + /// + /// + /// the path to the png image public static string AssetToTexture2D(string AssetName) { string textureFilePath; @@ -81,7 +110,7 @@ namespace FModel string TexturePath = string.Empty; if (textureFilePath != null && (textureFilePath.Contains("MI_UI_FeaturedRenderSwitch_") || textureFilePath.Contains("M_UI_ChallengeTile_PCB") || textureFilePath.Contains("Wraps\\FeaturedMaterials\\") || textureFilePath.Contains("M-Wraps-StreetDemon"))) { - return GetRenderSwitchMaterialTexture(AssetName, textureFilePath); + return GetRenderSwitchMaterialTexture(textureFilePath); } else if (textureFilePath != null) { @@ -91,7 +120,13 @@ namespace FModel } return TexturePath; } - public static string GetRenderSwitchMaterialTexture(string AssetName, string AssetPath) + + /// + /// serialize the material to get the texture and convert this texture to a png image + /// + /// + /// the path to the png image + public static string GetRenderSwitchMaterialTexture(string AssetPath) { string TexturePath = string.Empty; if (AssetPath.Contains(".uasset") || AssetPath.Contains(".uexp") || AssetPath.Contains(".ubulk")) diff --git a/FModel/Methods/Utilities/FontUtilities.cs b/FModel/Methods/Utilities/FontUtilities.cs new file mode 100644 index 00000000..917eb0c4 --- /dev/null +++ b/FModel/Methods/Utilities/FontUtilities.cs @@ -0,0 +1,41 @@ +using FModel.Properties; +using System; +using System.Drawing; +using System.Drawing.Text; +using System.Runtime.InteropServices; + +namespace FModel +{ + class FontUtilities + { + public static PrivateFontCollection _pfc = new PrivateFontCollection(); + public static StringFormat _centeredString = new StringFormat(); + public static StringFormat _rightString = new StringFormat(); + public static StringFormat _centeredStringLine = new StringFormat(); + private static int _fontLength { get; set; } + private static byte[] _fontdata { get; set; } + + /// + /// Register font in Resources to the PrivateFontCollection to use them in IconGenerator or other stuff + /// + public static void SetFont() + { + _fontLength = Resources.BurbankBigCondensed_Bold.Length; + _fontdata = Resources.BurbankBigCondensed_Bold; + IntPtr weirdData = Marshal.AllocCoTaskMem(_fontLength); + Marshal.Copy(_fontdata, 0, weirdData, _fontLength); + _pfc.AddMemoryFont(weirdData, _fontLength); + + _fontLength = Resources.BurbankBigCondensed_Black.Length; + _fontdata = Resources.BurbankBigCondensed_Black; + IntPtr weirdData2 = Marshal.AllocCoTaskMem(_fontLength); + Marshal.Copy(_fontdata, 0, weirdData2, _fontLength); + _pfc.AddMemoryFont(weirdData2, _fontLength); + + _centeredString.Alignment = StringAlignment.Center; + _rightString.Alignment = StringAlignment.Far; + _centeredStringLine.LineAlignment = StringAlignment.Center; + _centeredStringLine.Alignment = StringAlignment.Center; + } + } +} diff --git a/FModel/Methods/Utilities/ImageUtilities.cs b/FModel/Methods/Utilities/ImageUtilities.cs new file mode 100644 index 00000000..f82572f0 --- /dev/null +++ b/FModel/Methods/Utilities/ImageUtilities.cs @@ -0,0 +1,74 @@ +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Drawing.Imaging; + +namespace FModel +{ + class ImageUtilities + { + /// + /// Set the opacity of an Image -> convert Image to Bitmap, create a graphic object of the Bitmap, create a color matrix object to set the opacity + /// + /// + /// + /// the Bitmap image with its new opacity + public static Image SetImageOpacity(Image image, float opacity) + { + //create a Bitmap the size of the image provided + Bitmap bmp = new Bitmap(image.Width, image.Height); + + //create a graphics object from the image + using (Graphics gfx = Graphics.FromImage(bmp)) + { + + //create a color matrix object + ColorMatrix matrix = new ColorMatrix(); + + //set the opacity + matrix.Matrix33 = opacity; + + //create image attributes + ImageAttributes attributes = new ImageAttributes(); + + //set the color(opacity) of the image + attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); + + //now draw the image + gfx.DrawImage(image, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, attributes); + } + return bmp; + } + + /// + /// Resize an Image + /// + /// + /// + /// + /// the resized image + public static Bitmap ResizeImage(Image image, int width, int height) + { + var destRect = new Rectangle(0, 0, width, height); + var destImage = new Bitmap(width, height); + + destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution); + + using (var graphics = Graphics.FromImage(destImage)) + { + graphics.CompositingMode = CompositingMode.SourceCopy; + graphics.CompositingQuality = CompositingQuality.HighQuality; + graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; + graphics.SmoothingMode = SmoothingMode.HighQuality; + graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; + + using (var wrapMode = new ImageAttributes()) + { + wrapMode.SetWrapMode(WrapMode.TileFlipXY); + graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode); + } + } + + return destImage; + } + } +} diff --git a/FModel/Methods/Utilities/Utilities.cs b/FModel/Methods/Utilities/Utilities.cs new file mode 100644 index 00000000..9a7aac00 --- /dev/null +++ b/FModel/Methods/Utilities/Utilities.cs @@ -0,0 +1,94 @@ +using FModel.Properties; +using System; +using System.Diagnostics; +using System.IO; +using System.Security.AccessControl; +using System.Security.Principal; + +namespace FModel +{ + class Utilities + { + /// + /// OpenWithDefaultProgramAndNoFocus is used to automatically open sound file once they are converted + /// + /// path is the path to the converted sound file (in "Sounds" subfolder) + public static void OpenWithDefaultProgramAndNoFocus(string path) + { + Process fileopener = new Process(); + fileopener.StartInfo.FileName = "explorer"; + fileopener.StartInfo.Arguments = "\"" + path + "\""; + fileopener.Start(); + } + + /// + /// just create the default folders FModel needs to work + /// + public static void CreateDefaultFolders() + { + if (!Directory.Exists(App.DefaultOutputPath + "\\Backup\\")) + Directory.CreateDirectory(App.DefaultOutputPath + "\\Backup\\"); + if (!Directory.Exists(App.DefaultOutputPath + "\\Extracted\\")) + Directory.CreateDirectory(App.DefaultOutputPath + "\\Extracted\\"); + if (!Directory.Exists(App.DefaultOutputPath + "\\Icons\\")) + Directory.CreateDirectory(App.DefaultOutputPath + "\\Icons\\"); + if (!Directory.Exists(App.DefaultOutputPath + "\\Sounds\\")) + Directory.CreateDirectory(App.DefaultOutputPath + "\\Sounds\\"); + } + + /// + /// actually idk if it's useful, i added this for Admin windows account, when FModel can't even use CreateDefaultFolders + /// + /// + public static void SetFolderPermission(string folderPath) + { + var directoryInfo = new DirectoryInfo(folderPath); + var directorySecurity = directoryInfo.GetAccessControl(); + var currentUserIdentity = WindowsIdentity.GetCurrent(); + var fileSystemRule = new FileSystemAccessRule(currentUserIdentity.Name, + FileSystemRights.Read, + InheritanceFlags.ObjectInherit | + InheritanceFlags.ContainerInherit, + PropagationFlags.None, + AccessControlType.Allow); + + directorySecurity.AddAccessRule(fileSystemRule); + directoryInfo.SetAccessControl(directorySecurity); + } + + /// + /// By default the output folder is the Documents folder, however if user wanna change, once FModel restart SetOutputFolder is called + /// + public static void SetOutputFolder() + { + App.DefaultOutputPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\FModel"; //DOCUMENTS FOLDER BY DEFAULT + + if (string.IsNullOrEmpty(Settings.Default.ExtractOutput)) + { + Settings.Default.ExtractOutput = App.DefaultOutputPath; + Settings.Default.Save(); + } + else + { + App.DefaultOutputPath = Settings.Default.ExtractOutput; + } + + Directory.CreateDirectory(App.DefaultOutputPath); + } + + /// + /// Once upon a time, it was used for shitty stuff + /// + public static void JohnWickCheck() + { + if (File.Exists(App.DefaultOutputPath + "\\john-wick-parse-modded.exe")) //2.0- + { + File.Delete(App.DefaultOutputPath + "\\john-wick-parse-modded.exe"); + } + if (File.Exists(App.DefaultOutputPath + "\\john-wick-parse_custom.exe")) //2.0+ + { + File.Delete(App.DefaultOutputPath + "\\john-wick-parse_custom.exe"); + } + } + } +} diff --git a/FModel/Methods/VarApp.cs b/FModel/Methods/VarApp.cs index 93b2ebaf..90b5c02c 100644 --- a/FModel/Methods/VarApp.cs +++ b/FModel/Methods/VarApp.cs @@ -12,6 +12,13 @@ namespace FModel public static Dictionary PaksMountPoint { get; set; } public static Dictionary AllpaksDictionary { get; set; } + /// + /// read the GUID of a the param, it's basically just reading some bytes at the end of a pak file, but it's useful to tell if the pak is dynamically encrypted + /// "0-0-0-0" for normal pak + /// "123456789-9876543210-741085209630-015975306482" for dynamic pak (these numbers are an example) + /// + /// path to the pak file to get its GUID + /// the guid public static string ReadPakGuid(string pakPath) { using (BinaryReader reader = new BinaryReader(File.Open(pakPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) @@ -29,6 +36,12 @@ namespace FModel return guid; } } + + /// + /// read the pak version (v8 28.05.2019), it's basically just reading one byte at the end of a pak file + /// + /// path to the pak file to get its version + /// the version public static string ReadPakVersion(string pakPath) { using (BinaryReader reader = new BinaryReader(File.Open(pakPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) diff --git a/README.md b/README.md index 21ad4122..b7f6c021 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ I'd highly suggest you to use [UModel](https://github.com/gildor2/UModel) instea - [ ] Display support for .locres files + compare - [ ] Export Queue - [ ] AES Manager + - [ ] Nintendo Switch sound files - [x] Nintendo Switch PAKs - [x] Multithreading - [x] Stop button