diff --git a/FModel/Converter/UnrealEngineDataToOGG.cs b/FModel/Converter/UnrealEngineDataToOGG.cs index a0c638f6..511180ad 100644 --- a/FModel/Converter/UnrealEngineDataToOGG.cs +++ b/FModel/Converter/UnrealEngineDataToOGG.cs @@ -5,12 +5,8 @@ using System.Linq; namespace FModel.Converter { - class UnrealEngineDataToOgg + static class UnrealEngineDataToOgg { - private static byte[] _oggFind = { 0x4F, 0x67, 0x67, 0x53 }; - private static byte[] _uexpToDelete = { 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00 }; - private static byte[] _oggOutNewArray; - private static string oggPattern = "OggS"; private static List SearchBytePattern(byte[] pattern, byte[] bytes) { List positions = new List(); @@ -34,16 +30,12 @@ namespace FModel.Converter } private static bool TryFindAndReplace(T[] source, T[] pattern, T[] replacement, out T[] newArray) { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (pattern == null) - throw new ArgumentNullException(nameof(pattern)); - if (replacement == null) - throw new ArgumentNullException(nameof(replacement)); + if (source == null) { throw new ArgumentNullException(nameof(source)); } + if (pattern == null) { throw new ArgumentNullException(nameof(pattern)); } + if (replacement == null) { throw new ArgumentNullException(nameof(replacement)); } newArray = null; - if (pattern.Length > source.Length) - return false; + if (pattern.Length > source.Length) { return false; } for (var start = 0; start < source.Length - pattern.Length + 1; start += 1) { @@ -68,22 +60,35 @@ namespace FModel.Converter return rv; } + /// + /// if no ubulk: if the uexp contains "OggS", once oggFind is found delete everything from the start to the pattern (excluding the pattern) + /// then just delete the last 4 bytes "Áƒ*ž" and all the empty bytes a then end (to avoid increasing file length if there's no sound) + /// if ubulk: do same as no ubulk but add the ubulk bytes after uexpToDelete is found + /// uexpToDelete is a pattern to find to delete everything from this pattern to the end of the uexp file (including the pattern) + /// + /// + /// path to the ogg sound file public static string ConvertToOgg(string file) { - var isUbulkFound = new DirectoryInfo(Path.GetDirectoryName(file) ?? throw new InvalidOperationException()).GetFiles(Path.GetFileNameWithoutExtension(file) + "*.ubulk", SearchOption.AllDirectories).FirstOrDefault(); + byte[] oggFind = { 0x4F, 0x67, 0x67, 0x53 }; + byte[] oggOutNewArray; + + FileInfo isUbulkFound = new DirectoryInfo(Path.GetDirectoryName(file)).GetFiles(Path.GetFileNameWithoutExtension(file) + "*.ubulk", SearchOption.AllDirectories).FirstOrDefault(); if (isUbulkFound == null) { - if (File.ReadAllText(file).Contains(oggPattern)) + if (File.ReadAllText(file).Contains("OggS")) { byte[] src = File.ReadAllBytes(file); - TryFindAndReplace(src, _oggFind, _oggFind, out _oggOutNewArray); //MAKE THE ARRAY START AT PATTERN POSITION + TryFindAndReplace(src, oggFind, oggFind, out oggOutNewArray); //MAKE THE ARRAY START AT PATTERN POSITION - byte[] tmp = new byte[_oggOutNewArray.Length - 4]; - Array.Copy(_oggOutNewArray, tmp, tmp.Length); //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) + { --i; + } byte[] bar = new byte[i + 1]; Array.Copy(tmp, bar, i + 1); //DELETE EMPTY BYTES AT THE END @@ -92,24 +97,27 @@ namespace FModel.Converter } else { - if (File.ReadAllText(file).Contains(oggPattern)) + if (File.ReadAllText(file).Contains("OggS")) { + byte[] uexpToDelete = { 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00 }; byte[] src = File.ReadAllBytes(file); byte[] srcUbulk = File.ReadAllBytes(Path.GetDirectoryName(file) + "\\" + isUbulkFound); - List positions = SearchBytePattern(_uexpToDelete, src); + List positions = SearchBytePattern(uexpToDelete, src); int lengthToDelete = src.Length - positions[0]; - TryFindAndReplace(src, _oggFind, _oggFind, out _oggOutNewArray); //MAKE THE ARRAY START AT PATTERN POSITION + TryFindAndReplace(src, oggFind, oggFind, out oggOutNewArray); //MAKE THE ARRAY START AT PATTERN POSITION - byte[] tmp = new byte[_oggOutNewArray.Length - lengthToDelete]; - Array.Copy(_oggOutNewArray, tmp, Math.Max(0, tmp.Length)); //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 int i = tmp2.Length - 1; while (tmp2[i] == 0) + { --i; + } byte[] bar = new byte[i + 1]; Array.Copy(tmp2, bar, i + 1); //DELETE EMPTY BYTES AT THE END diff --git a/FModel/Custom/Prompt.cs b/FModel/Custom/Prompt.cs deleted file mode 100644 index 9558f419..00000000 --- a/FModel/Custom/Prompt.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace FModel -{ - public static class Prompt - { - public static string ShowDialog(string text, string caption) - { - Form prompt = new Form() - { - Width = 500, - Height = 150, - FormBorderStyle = FormBorderStyle.FixedDialog, - MaximizeBox = false, - MinimizeBox = false, - Text = caption, - StartPosition = FormStartPosition.CenterScreen - }; - Label textLabel = new Label() { Left = 50, Top = 20, Text = text }; - TextBox textBox = new TextBox() { Left = 50, Top = 50, Width = 400 }; - Button confirmation = new Button() { Text = "Ok", Left = 350, Width = 100, Top = 70, DialogResult = DialogResult.OK }; - confirmation.Click += (sender, e) => { prompt.Close(); }; - prompt.Controls.Add(textBox); - prompt.Controls.Add(confirmation); - prompt.Controls.Add(textLabel); - prompt.AcceptButton = confirmation; - - return prompt.ShowDialog() == DialogResult.OK ? textBox.Text : ""; - } - } -} diff --git a/FModel/FModel.csproj b/FModel/FModel.csproj index d97fafdf..531d0ba1 100644 --- a/FModel/FModel.csproj +++ b/FModel/FModel.csproj @@ -117,7 +117,6 @@ - diff --git a/FModel/MainWindow.cs b/FModel/MainWindow.cs index bfcdab44..5c573b2e 100644 --- a/FModel/MainWindow.cs +++ b/FModel/MainWindow.cs @@ -1296,7 +1296,7 @@ namespace FModel #region DRAW TEXT try { - g.DrawString(theItem.DisplayName, new Font(FontUtilities._pfc.Families[0], 35), new SolidBrush(Color.White), new Point(522 / 2, 395), FontUtilities._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) { @@ -1307,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), FontUtilities._centeredStringLine); + g.DrawString(theItem.Description, new Font("Arial", 10), new SolidBrush(Color.White), new RectangleF(5, 441, 512, 49), FontUtilities.centeredStringLine); } catch (NullReferenceException) { @@ -1320,7 +1320,7 @@ namespace FModel { try { - g.DrawString(theItem.ShortDescription, new Font(FontUtilities._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) { @@ -1331,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(FontUtilities._pfc.Families[0], 13), new SolidBrush(Color.White), new Point(522 - 5, 500), FontUtilities._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) { @@ -1371,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(FontUtilities._pfc.Families[0], 13), new SolidBrush(Color.White), new Point(522 - 5, 500), FontUtilities._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) { @@ -1384,7 +1384,7 @@ namespace FModel { try { - 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); + 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) { @@ -1409,7 +1409,7 @@ namespace FModel { try { - g.DrawString("Max Stack Size: " + theItem.MaxStackSize, new Font(FontUtilities._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) { @@ -1428,7 +1428,7 @@ namespace FModel { try { - g.DrawString(theItem.ShortDescription, new Font(FontUtilities._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) { @@ -1439,7 +1439,7 @@ namespace FModel } //TYPE try { - g.DrawString(theItem.CosmeticItem, new Font(FontUtilities._pfc.Families[0], 13), new SolidBrush(Color.White), new Point(522 - 5, 500), FontUtilities._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) { @@ -1488,7 +1488,7 @@ namespace FModel { try { - g.DrawString(theItem.AttributeInitKey.AttributeInitCategory, new Font(FontUtilities._pfc.Families[0], 13), new SolidBrush(Color.White), new Point(522 - 5, 500), FontUtilities._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) { @@ -1499,7 +1499,7 @@ namespace FModel } //CHARACTER TYPE try { - g.DrawString("Power " + theItem.MinLevel + " to " + theItem.MaxLevel, new Font(FontUtilities._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) { @@ -1513,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(FontUtilities._pfc.Families[0], 13), new SolidBrush(Color.White), new Point(522 - 5, 500), FontUtilities._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) { @@ -1533,7 +1533,7 @@ namespace FModel } //CHARACTER TYPE try { - g.DrawString("Power " + theItem.MinLevel + " to " + theItem.MaxLevel, new Font(FontUtilities._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) { @@ -1635,10 +1635,10 @@ namespace FModel { justSkip += 1; iamY += 140; - g.DrawString(questParser[ii].Objectives[ii2].Description, new Font(FontUtilities._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(FontUtilities._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); @@ -1664,10 +1664,10 @@ namespace FModel questParser[ii].Rewards.Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest") .Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token") .FirstOrDefault().Quantity.ToString(), - FontUtilities._pfc.Families[1], + FontUtilities.pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, iamY + 25), FontUtilities._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); @@ -1684,10 +1684,10 @@ namespace FModel questParser[ii].Rewards.Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest") .Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token") .FirstOrDefault().Quantity.ToString(), - FontUtilities._pfc.Families[1], + FontUtilities.pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, iamY + 25), FontUtilities._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); @@ -1704,10 +1704,10 @@ namespace FModel questParser[ii].Rewards.Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest") .Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token") .FirstOrDefault().Quantity.ToString(), - FontUtilities._pfc.Families[1], + FontUtilities.pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, iamY + 25), FontUtilities._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); @@ -1837,9 +1837,9 @@ namespace FModel #endregion if (compCount == "-1") - 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)); + 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(FontUtilities._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 { @@ -1857,10 +1857,10 @@ namespace FModel GraphicsPath p = new GraphicsPath(); p.AddString( bundleParser[i].BundleCompletionRewards[i2].Rewards[i3].Quantity.ToString(), - FontUtilities._pfc.Families[1], + FontUtilities.pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, iamY + 25), FontUtilities._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); @@ -1875,10 +1875,10 @@ namespace FModel GraphicsPath p = new GraphicsPath(); p.AddString( bundleParser[i].BundleCompletionRewards[i2].Rewards[i3].Quantity.ToString(), - FontUtilities._pfc.Families[1], + FontUtilities.pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, iamY + 25), FontUtilities._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); @@ -1893,10 +1893,10 @@ namespace FModel GraphicsPath p = new GraphicsPath(); p.AddString( bundleParser[i].BundleCompletionRewards[i2].Rewards[i3].Quantity.ToString(), - FontUtilities._pfc.Families[1], + FontUtilities.pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, iamY + 25), FontUtilities._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); @@ -1906,9 +1906,9 @@ namespace FModel DrawRewardIcon(itemReward, g, iamY); if (compCount == "-1") - 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)); + 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(FontUtilities._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)); } } } @@ -1925,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(FontUtilities._pfc.Families[0], 20), new SolidBrush(Color.FromArgb(150, 255, 255, 255)), new Point(bmp.Width / 2, iamY + 250), FontUtilities._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) { @@ -1933,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(FontUtilities._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) { @@ -1944,7 +1944,7 @@ namespace FModel } //LAST SUBFOLDER try { - g.DrawString(theItem.DisplayName.ToUpper(), new Font(FontUtilities._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) { @@ -2004,7 +2004,7 @@ namespace FModel try { - 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)); + 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) { @@ -2015,7 +2015,7 @@ namespace FModel } //LAST SUBFOLDER try { - toDrawOn.DrawString(theItem.DisplayName.ToUpper(), new Font(FontUtilities._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) { @@ -2082,10 +2082,10 @@ namespace FModel toDrawOnLoop.TextRenderingHint = TextRenderingHint.AntiAlias; lineLoop += 1; yeayLoop += 140; - toDrawOnLoop.DrawString(questParser[i].Objectives[ii].Description, new Font(FontUtilities._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(FontUtilities._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); @@ -2112,10 +2112,10 @@ namespace FModel questParser[ii].Rewards.Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest") .Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token") .FirstOrDefault().Quantity.ToString(), - FontUtilities._pfc.Families[1], + FontUtilities.pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, yeayLoop + 25), FontUtilities._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); @@ -2132,10 +2132,10 @@ namespace FModel questParser[ii].Rewards.Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest") .Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token") .FirstOrDefault().Quantity.ToString(), - FontUtilities._pfc.Families[1], + FontUtilities.pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, yeayLoop + 25), FontUtilities._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); @@ -2152,10 +2152,10 @@ namespace FModel questParser[ii].Rewards.Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest") .Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token") .FirstOrDefault().Quantity.ToString(), - FontUtilities._pfc.Families[1], + FontUtilities.pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, yeayLoop + 25), FontUtilities._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); @@ -2225,10 +2225,10 @@ namespace FModel { lineLoop += 1; yeayLoop += 140; - toDrawOnLoop.DrawString(questParser[i].Objectives[ii].Description, new Font(FontUtilities._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(FontUtilities._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); @@ -2255,10 +2255,10 @@ namespace FModel questParser[ii].Rewards.Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest") .Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token") .FirstOrDefault().Quantity.ToString(), - FontUtilities._pfc.Families[1], + FontUtilities.pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, yeayLoop + 25), FontUtilities._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); @@ -2275,10 +2275,10 @@ namespace FModel questParser[ii].Rewards.Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest") .Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token") .FirstOrDefault().Quantity.ToString(), - FontUtilities._pfc.Families[1], + FontUtilities.pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, yeayLoop + 25), FontUtilities._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); @@ -2295,10 +2295,10 @@ namespace FModel questParser[ii].Rewards.Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest") .Where(x => x.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token") .FirstOrDefault().Quantity.ToString(), - FontUtilities._pfc.Families[1], + FontUtilities.pfc.Families[1], (int)FontStyle.Regular, 60, - new Point(2322, yeayLoop + 25), FontUtilities._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); @@ -2557,7 +2557,7 @@ namespace FModel try { - 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)); + 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) { @@ -2568,7 +2568,7 @@ namespace FModel } //LAST SUBFOLDER try { - g.DrawString(theItem.DisplayName.ToUpper(), new Font(FontUtilities._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) { @@ -2656,11 +2656,11 @@ namespace FModel justSkip += 1; iamY += 140; - g.DrawString(questParser[ii].Objectives[ii2].Description, new Font(FontUtilities._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(FontUtilities._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); @@ -2696,10 +2696,10 @@ namespace FModel justSkip += 1; iamY += 140; - g.DrawString(questParser[ii].Objectives[ii2].Description, new Font(FontUtilities._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(FontUtilities._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); @@ -2754,7 +2754,7 @@ namespace FModel } } - g.DrawString("Same Quest x" + damageOpCount, new Font(FontUtilities._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 @@ -2779,9 +2779,9 @@ namespace FModel DrawRewardIcon(itemReward, g, iamY); if (compCount == "-1") - 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)); + 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(FontUtilities._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)); } } } @@ -2796,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(FontUtilities._pfc.Families[0], 20), new SolidBrush(Color.FromArgb(150, 255, 255, 255)), new Point(bmp.Width / 2, iamY + 250), FontUtilities._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) { @@ -2804,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(FontUtilities._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) { @@ -2815,7 +2815,7 @@ namespace FModel } //LAST SUBFOLDER try { - g.DrawString(theItem.DisplayName.ToUpper(), new Font(FontUtilities._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) { diff --git a/FModel/Methods/BackPAKs/DynamicPAKs.cs b/FModel/Methods/BackPAKs/DynamicPAKs.cs index 42eb532a..67046578 100644 --- a/FModel/Methods/BackPAKs/DynamicPAKs.cs +++ b/FModel/Methods/BackPAKs/DynamicPAKs.cs @@ -7,10 +7,11 @@ using Newtonsoft.Json.Linq; using System.Globalization; using System.Collections.Generic; using System.Linq; +using System.Text; namespace FModel { - class DynamicPAKs + static class DynamicPAKs { /// /// get url content as string with authentication @@ -36,9 +37,6 @@ namespace FModel } catch (Exception ex) { - Console.ForegroundColor = ConsoleColor.Red; - Console.Write("[ERROR] "); - Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(ex.Message); } return content; @@ -95,21 +93,19 @@ namespace FModel /// the guid (ie 17722063-2246354315-4143272431-3887619937) public static string getPakGuidFromKeychain(string[] KeychainPart) { + StringBuilder sB = new StringBuilder(); IEnumerable guid = SplitGuid(KeychainPart[0], 8); int count = 0; - string pakguid = string.Empty; foreach (string p in guid) { count += 1; - if (count != guid.Count()) - pakguid += (uint)int.Parse(p, NumberStyles.HexNumber) + "-"; - else - pakguid += (uint)int.Parse(p, NumberStyles.HexNumber); + if (count != guid.Count()) { sB.Append((uint)int.Parse(p, NumberStyles.HexNumber) + "-"); } + else { sB.Append((uint)int.Parse(p, NumberStyles.HexNumber)); } } - return pakguid; + return sB.ToString(); } } } diff --git a/FModel/Methods/IconGenerator/ItemIcon.cs b/FModel/Methods/IconGenerator/ItemIcon.cs index 4b32d4e3..67defa06 100644 --- a/FModel/Methods/IconGenerator/ItemIcon.cs +++ b/FModel/Methods/IconGenerator/ItemIcon.cs @@ -9,7 +9,7 @@ using System.IO; namespace FModel { - class ItemIcon + static class ItemIcon { public static string ItemIconPath { get; set; } @@ -31,11 +31,11 @@ namespace FModel if (theItem.DisplayAssetPath != null && theItem.DisplayAssetPath.AssetPathName.Contains("/Game/Catalog/DisplayAssets/")) { string catalogName = theItem.DisplayAssetPath.AssetPathName; - SearchFeaturedIcon(theItem, catalogName); + SearchFeaturedIcon(theItem, catalogName.Substring(catalogName.LastIndexOf('.') + 1)); } else if (theItem.DisplayAssetPath == null) { - SearchFeaturedIcon(theItem, "DA_Featured_" + ThePak.CurrentUsedItem, true); + SearchFeaturedIcon(theItem, "DA_Featured_" + ThePak.CurrentUsedItem); } else { @@ -93,9 +93,13 @@ namespace FModel { //MANUAL FIX if (theItem.WeaponDefinition == "WID_Harvest_Pickaxe_NutCracker") + { theItem.WeaponDefinition = "WID_Harvest_Pickaxe_Nutcracker"; + } if (theItem.WeaponDefinition == "WID_Harvest_Pickaxe_Wukong") + { theItem.WeaponDefinition = "WID_Harvest_Pickaxe_WuKong"; + } string weaponFilePath; if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0") @@ -159,133 +163,95 @@ namespace FModel } /// - /// 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 + /// thank to epic, this is needed + /// do not load featured icon for these files /// /// /// - /// - public static void SearchFeaturedIcon(ItemsIdParser theItem, string catName, bool manualSearch = false) + public static void SearchFeaturedIcon(ItemsIdParser theItem, string catName) { - if (manualSearch == false) + switch (catName) { - ThePak.CurrentUsedItem = catName.Substring(catName.LastIndexOf('.') + 1); - - if (ThePak.CurrentUsedItem == "DA_Featured_Glider_ID_141_AshtonBoardwalk" || - ThePak.CurrentUsedItem == "DA_Featured_Glider_ID_150_TechOpsBlue" || - ThePak.CurrentUsedItem == "DA_Featured_Glider_ID_131_SpeedyMidnight" || - ThePak.CurrentUsedItem == "DA_Featured_Pickaxe_ID_178_SpeedyMidnight") + case "DA_Featured_Glider_ID_141_AshtonBoardwalk": + case "DA_Featured_Glider_ID_150_TechOpsBlue": + case "DA_Featured_Glider_ID_131_SpeedyMidnight": + case "DA_Featured_Pickaxe_ID_178_SpeedyMidnight": + case "DA_Featured_Glider_ID_015_Brite": + case "DA_Featured_Glider_ID_016_Tactical": + case "DA_Featured_Glider_ID_017_Assassin": + case "DA_Featured_Pickaxe_ID_027_Scavenger": + case "DA_Featured_Pickaxe_ID_028_Space": + case "DA_Featured_Pickaxe_ID_029_Assassin": + case "DA_Featured_EID_Dunk": GetItemIcon(theItem); + break; + default: + GetFeaturedItemIcon(theItem, catName); + break; + } + } + + /// + /// if the catalogFile is in AllpaksDictionary (is known) extract, serialize the catalogFile and parse to get and convert the featured file to a png image + /// + /// + /// + private static void GetFeaturedItemIcon(ItemsIdParser theItem, string catName) + { + if (ThePak.AllpaksDictionary.ContainsKey(catName)) + { + ThePak.CurrentUsedItem = catName; + + string catalogFilePath; + if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0") + { + catalogFilePath = JohnWick.ExtractAsset(ThePak.CurrentUsedPak, catName); + } else { - string catalogFilePath; - if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0") - catalogFilePath = JohnWick.ExtractAsset(ThePak.CurrentUsedPak, catName.Substring(catName.LastIndexOf('.') + 1)); - else - catalogFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[catName.Substring(catName.LastIndexOf('.') + 1)], catName.Substring(catName.LastIndexOf('.') + 1)); + catalogFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[catName], catName); + } - if (catalogFilePath != null) + if (catalogFilePath != null) + { + Checking.WasFeatured = true; + if (catalogFilePath.Contains(".uasset") || catalogFilePath.Contains(".uexp") || catalogFilePath.Contains(".ubulk")) { - Checking.WasFeatured = true; - if (catalogFilePath.Contains(".uasset") || catalogFilePath.Contains(".uexp") || catalogFilePath.Contains(".ubulk")) + JohnWick.MyAsset = new PakAsset(catalogFilePath.Substring(0, catalogFilePath.LastIndexOf('.'))); + try { - JohnWick.MyAsset = new PakAsset(catalogFilePath.Substring(0, catalogFilePath.LastIndexOf('.'))); - try + if (JohnWick.MyAsset.GetSerialized() != null) { - if (JohnWick.MyAsset.GetSerialized() != null) + string parsedJson = JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString(); + var featuredId = FeaturedParser.FromJson(parsedJson); + for (int i = 0; i < featuredId.Length; i++) { - string parsedJson = JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString(); - var featuredId = FeaturedParser.FromJson(parsedJson); - for (int i = 0; i < featuredId.Length; i++) + switch (catName) { - //Thanks EPIC - if (ThePak.CurrentUsedItem == "DA_Featured_CID_319_Athena_Commando_F_Nautilus") - { + case "DA_Featured_Glider_ID_070_DarkViking": + case "DA_Featured_CID_319_Athena_Commando_F_Nautilus": if (featuredId[i].TileImage != null) { string textureFile = featuredId[i].TileImage.ResourceObject; ItemIconPath = JohnWick.AssetToTexture2D(textureFile); } - } - else - { + break; + default: if (featuredId[i].DetailsImage != null) { string textureFile = featuredId[i].DetailsImage.ResourceObject; ItemIconPath = JohnWick.AssetToTexture2D(textureFile); } - } + break; } } } - catch (JsonSerializationException) { } } + catch (JsonSerializationException) { } } } } - if (manualSearch) - { - //Thanks EPIC - if (catName == "DA_Featured_Glider_ID_015_Brite" || - catName == "DA_Featured_Glider_ID_016_Tactical" || - catName == "DA_Featured_Glider_ID_017_Assassin" || - catName == "DA_Featured_Pickaxe_ID_027_Scavenger" || - catName == "DA_Featured_Pickaxe_ID_028_Space" || - catName == "DA_Featured_Pickaxe_ID_029_Assassin" || - catName == "DA_Featured_EID_Dunk") - GetItemIcon(theItem); - else if (ThePak.AllpaksDictionary.ContainsKey(catName)) - { - ThePak.CurrentUsedItem = catName; - - string catalogFilePath; - if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0") - catalogFilePath = JohnWick.ExtractAsset(ThePak.CurrentUsedPak, catName); - else - catalogFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[catName], catName); - - if (catalogFilePath != null) - { - Checking.WasFeatured = true; - if (catalogFilePath.Contains(".uasset") || catalogFilePath.Contains(".uexp") || catalogFilePath.Contains(".ubulk")) - { - JohnWick.MyAsset = new PakAsset(catalogFilePath.Substring(0, catalogFilePath.LastIndexOf('.'))); - try - { - if (JohnWick.MyAsset.GetSerialized() != null) - { - string parsedJson = JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString(); - var featuredId = FeaturedParser.FromJson(parsedJson); - for (int i = 0; i < featuredId.Length; i++) - { - //Thanks EPIC - if (ThePak.CurrentUsedItem == "DA_Featured_Glider_ID_070_DarkViking") - { - if (featuredId[i].TileImage != null) - { - string textureFile = featuredId[i].TileImage.ResourceObject; - ItemIconPath = JohnWick.AssetToTexture2D(textureFile); - } - } - else - { - if (featuredId[i].DetailsImage != null) - { - string textureFile = featuredId[i].DetailsImage.ResourceObject; - ItemIconPath = JohnWick.AssetToTexture2D(textureFile); - } - } - } - } - } - catch (JsonSerializationException) { } - } - } - } - else - GetItemIcon(theItem); - } + else { GetItemIcon(theItem); } } /// diff --git a/FModel/Methods/IconGenerator/Rarity.cs b/FModel/Methods/IconGenerator/Rarity.cs index 64da9907..daa6c1c8 100644 --- a/FModel/Methods/IconGenerator/Rarity.cs +++ b/FModel/Methods/IconGenerator/Rarity.cs @@ -4,7 +4,7 @@ using System.Drawing; namespace FModel { - class Rarity + static class Rarity { /// /// check the rarity and return the right image diff --git a/FModel/Methods/JohnWick/JohnWick.cs b/FModel/Methods/JohnWick/JohnWick.cs index 06616e62..1bd0ce43 100644 --- a/FModel/Methods/JohnWick/JohnWick.cs +++ b/FModel/Methods/JohnWick/JohnWick.cs @@ -9,7 +9,7 @@ using System.Linq; namespace FModel { - class JohnWick + static class JohnWick { public static PakAsset MyAsset; public static PakExtractor MyExtractor; @@ -25,10 +25,14 @@ namespace FModel /// 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) - return ThePak.PaksMountPoint[ThePak.CurrentUsedPak ?? throw new InvalidOperationException()]; + if (DynamicPak) + { + return ThePak.PaksMountPoint[ThePak.CurrentUsedPak]; + } else - return ThePak.PaksMountPoint[ThePak.AllpaksDictionary[currentItem ?? throw new InvalidOperationException()] ?? throw new InvalidOperationException()]; + { + return ThePak.PaksMountPoint[ThePak.AllpaksDictionary[currentItem]]; + } } /// @@ -74,9 +78,13 @@ namespace FModel string[] results; if (currentItem.Contains(".")) + { results = Array.FindAll(myArray, s => s.Contains("/" + currentItem)); + } else + { results = Array.FindAll(myArray, s => s.Contains("/" + currentItem + ".")); + } string AssetPath = string.Empty; for (int i = 0; i < results.Length; i++) @@ -102,9 +110,13 @@ namespace FModel { string textureFilePath; if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0") + { textureFilePath = ExtractAsset(ThePak.CurrentUsedPak, AssetName); + } else - textureFilePath = ExtractAsset(ThePak.AllpaksDictionary[AssetName ?? throw new InvalidOperationException()], AssetName); + { + textureFilePath = ExtractAsset(ThePak.AllpaksDictionary[AssetName], AssetName); + } string TexturePath = string.Empty; diff --git a/FModel/Methods/Utilities/FontUtilities.cs b/FModel/Methods/Utilities/FontUtilities.cs index 917eb0c4..363dcbd5 100644 --- a/FModel/Methods/Utilities/FontUtilities.cs +++ b/FModel/Methods/Utilities/FontUtilities.cs @@ -6,12 +6,12 @@ using System.Runtime.InteropServices; namespace FModel { - class FontUtilities + static 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(); + 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; } @@ -24,18 +24,18 @@ namespace FModel _fontdata = Resources.BurbankBigCondensed_Bold; IntPtr weirdData = Marshal.AllocCoTaskMem(_fontLength); Marshal.Copy(_fontdata, 0, weirdData, _fontLength); - _pfc.AddMemoryFont(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); + pfc.AddMemoryFont(weirdData2, _fontLength); - _centeredString.Alignment = StringAlignment.Center; - _rightString.Alignment = StringAlignment.Far; - _centeredStringLine.LineAlignment = StringAlignment.Center; - _centeredStringLine.Alignment = StringAlignment.Center; + 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 index f82572f0..227e39f4 100644 --- a/FModel/Methods/Utilities/ImageUtilities.cs +++ b/FModel/Methods/Utilities/ImageUtilities.cs @@ -4,7 +4,7 @@ using System.Drawing.Imaging; namespace FModel { - class ImageUtilities + static 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 diff --git a/FModel/Methods/Utilities/Utilities.cs b/FModel/Methods/Utilities/Utilities.cs index 9a7aac00..ccf4a67c 100644 --- a/FModel/Methods/Utilities/Utilities.cs +++ b/FModel/Methods/Utilities/Utilities.cs @@ -7,7 +7,7 @@ using System.Security.Principal; namespace FModel { - class Utilities + static class Utilities { /// /// OpenWithDefaultProgramAndNoFocus is used to automatically open sound file once they are converted @@ -26,14 +26,10 @@ namespace FModel /// 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\\"); + Directory.CreateDirectory(App.DefaultOutputPath + "\\Backup\\"); + Directory.CreateDirectory(App.DefaultOutputPath + "\\Extracted\\"); + Directory.CreateDirectory(App.DefaultOutputPath + "\\Icons\\"); + Directory.CreateDirectory(App.DefaultOutputPath + "\\Sounds\\"); } /// diff --git a/FModel/Methods/VarApp.cs b/FModel/Methods/VarApp.cs index 90b5c02c..c6d933a1 100644 --- a/FModel/Methods/VarApp.cs +++ b/FModel/Methods/VarApp.cs @@ -3,7 +3,7 @@ using System.IO; namespace FModel { - class ThePak + static class ThePak { public static string CurrentUsedPak { get; set; } public static string CurrentUsedPakGuid { get; set; } @@ -54,12 +54,12 @@ namespace FModel } } - class App + static class App { public static string DefaultOutputPath { get; set; } } - class Checking + static class Checking { public static bool WasFeatured { get; set; } public static int YAfterLoop { get; set; } diff --git a/FModel/Program.cs b/FModel/Program.cs index 192ebec9..9e3eb19f 100644 --- a/FModel/Program.cs +++ b/FModel/Program.cs @@ -22,8 +22,7 @@ namespace FModel { using (var stream = executingAssembly.GetManifestResourceStream(resource)) { - if (stream == null) - continue; + if (stream == null) { continue; } var bytes = new byte[stream.Length]; stream.Read(bytes, 0, bytes.Length);