added ammo type to weapon icon creation

This commit is contained in:
Asval 2019-05-12 00:25:20 +02:00
parent 89ccf356e7
commit faf44b8555
4 changed files with 203 additions and 123 deletions

View File

@ -39,6 +39,7 @@
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.commitHash = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
@ -142,19 +143,32 @@
//
this.commitHash.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.commitHash.AutoSize = true;
this.commitHash.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.commitHash.Location = new System.Drawing.Point(406, 124);
this.commitHash.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.commitHash.Location = new System.Drawing.Point(415, 124);
this.commitHash.Name = "commitHash";
this.commitHash.Size = new System.Drawing.Size(49, 13);
this.commitHash.Size = new System.Drawing.Size(40, 12);
this.commitHash.TabIndex = 9;
this.commitHash.Text = "1234567";
this.commitHash.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label7
//
this.label7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label7.AutoSize = true;
this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label7.Location = new System.Drawing.Point(370, 123);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(44, 13);
this.label7.TabIndex = 10;
this.label7.Text = "Commit:";
this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// About
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(467, 145);
this.Controls.Add(this.label7);
this.Controls.Add(this.commitHash);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
@ -190,5 +204,6 @@
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label commitHash;
private System.Windows.Forms.Label label7;
}
}

View File

@ -1480,11 +1480,7 @@ namespace FModel
}
else
{
Image itemIcon;
using (var bmpTemp = new Bitmap(ItemIconPath))
{
itemIcon = new Bitmap(bmpTemp);
}
Image itemIcon = Resources.unknown512;
g.DrawImage(itemIcon, new Point(0, 0));
}
#endregion
@ -1565,6 +1561,7 @@ namespace FModel
} //COSMETIC SOURCE
}
if (consAndWeap)
{
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);
@ -1601,6 +1598,11 @@ namespace FModel
AppendText("found", Color.Black, true);
}
} //ACTION
if (theItem.AmmoData != null && theItem.AmmoData.AssetPathName.Contains("Ammo")) //TO AVOID TRIGGERING CONSUMABLES, NAME SHOULD CONTAIN "AMMO"
{
getAmmoData(theItem.AmmoData.AssetPathName, g);
}
}
if (variant)
{
try
@ -2153,6 +2155,59 @@ namespace FModel
}
return toReturn;
}
private void getAmmoData(string ammoFile, Graphics toDrawOn)
{
if (CurrentUsedPakGuid != null && CurrentUsedPakGuid != "0-0-0-0")
JwpmProcess("extract \"" + Settings.Default.PAKsPath + "\\" + CurrentUsedPak + "\" \"" + ammoFile.Substring(ammoFile.LastIndexOf('.') + 1) + "\" \"" + DefaultOutputPath + "\" " + Settings.Default.AESKey);
else
JwpmProcess("extract \"" + Settings.Default.PAKsPath + "\\" + AllpaksDictionary[ammoFile.Substring(ammoFile.LastIndexOf('.') + 1)] + "\" \"" + ammoFile.Substring(ammoFile.LastIndexOf('.') + 1) + "\" \"" + DefaultOutputPath + "\" " + Settings.Default.AESKey);
string ammoFilePath = Directory.GetFiles(DefaultOutputPath + "\\Extracted", ammoFile.Substring(ammoFile.LastIndexOf('.') + 1) + ".*", SearchOption.AllDirectories).Where(x => !x.EndsWith(".png")).FirstOrDefault();
if (ammoFilePath != null)
{
UpdateConsole(ammoFile.Substring(ammoFile.LastIndexOf('.') + 1) + " successfully extracted", Color.FromArgb(255, 66, 244, 66), "Success");
if (ammoFilePath.Contains(".uasset") || ammoFilePath.Contains(".uexp") || ammoFilePath.Contains(".ubulk"))
{
MyAsset = new PakAsset(ammoFilePath.Substring(0, ammoFilePath.LastIndexOf('.')));
try
{
if (MyAsset.GetSerialized() != null)
{
UpdateConsole(ammoFile.Substring(ammoFile.LastIndexOf('.') + 1) + " successfully serialized", Color.FromArgb(255, 66, 244, 66), "Success");
string parsedJson = JToken.Parse(MyAsset.GetSerialized()).ToString();
var ammoId = ItemsIdParser.FromJson(parsedJson);
UpdateConsole("Parsing " + ammoFile.Substring(ammoFile.LastIndexOf('.') + 1) + "...", Color.FromArgb(255, 244, 132, 66), "Waiting");
for (int i = 0; i < ammoId.Length; i++)
{
SearchLargeSmallIcon(ammoId[i]);
if (File.Exists(ItemIconPath))
{
Image itemIcon;
using (var bmpTemp = new Bitmap(ItemIconPath))
{
itemIcon = new Bitmap(bmpTemp);
}
toDrawOn.DrawImage(Forms.Settings.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));
}
}
}
}
catch (JsonSerializationException)
{
AppendText(CurrentUsedItem + " ", Color.Red);
AppendText(".JSON file can't be displayed", Color.Black, true);
}
}
}
else
UpdateConsole("Error while extracting " + ammoFile.Substring(ammoFile.LastIndexOf('.') + 1), Color.FromArgb(255, 244, 66, 66), "Error");
}
//TODO: SIMPLIFY
private void CreateChallengesIcon(ItemsIdParser theItem, string theParsedJson, string questJson = null)
@ -2171,106 +2226,10 @@ namespace FModel
int justSkip = 0;
YAfterLoop = 0;
bool v2 = false;
int sRed;
int sGreen;
int sBlue;
var bundleParser = ChallengeBundleIdParser.FromJson(theParsedJson);
for (int i = 0; i < bundleParser.Length; i++)
{
#region DRAW BUNDLE ICON
try
{
if (Settings.Default.createIconForChallenges)
{
if (bundleParser[i].DisplayStyle.DisplayImage != null)
{
v2 = true;
string seasonFolder = questJson.Substring(questJson.Substring(0, questJson.LastIndexOf("\\", StringComparison.Ordinal)).LastIndexOf("\\", StringComparison.Ordinal) + 1).ToUpper();
#region COLORS + IMAGE
if (seasonFolder.Substring(0, seasonFolder.LastIndexOf("\\", StringComparison.Ordinal)) != "LTM")
{
sRed = (int)(bundleParser[i].DisplayStyle.SecondaryColor.R * 255);
sGreen = (int)(bundleParser[i].DisplayStyle.SecondaryColor.G * 255);
sBlue = (int)(bundleParser[i].DisplayStyle.SecondaryColor.B * 255);
}
else
{
sRed = (int)(bundleParser[i].DisplayStyle.AccentColor.R * 255);
sGreen = (int)(bundleParser[i].DisplayStyle.AccentColor.G * 255);
sBlue = (int)(bundleParser[i].DisplayStyle.AccentColor.B * 255);
}
int seasonRed = Convert.ToInt32(sRed / 1.5);
int seasonGreen = Convert.ToInt32(sGreen / 1.5);
int seasonBlue = Convert.ToInt32(sBlue / 1.5);
g.FillRectangle(new SolidBrush(Color.FromArgb(255, sRed, sGreen, sBlue)), new Rectangle(0, 0, bmp.Width, 271));
g.FillRectangle(new SolidBrush(Color.FromArgb(255, seasonRed, seasonGreen, seasonBlue)), new Rectangle(0, 271, bmp.Width, bmp.Height - 271));
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));
}
catch (NullReferenceException)
{
AppendText("[NullReferenceException] ", Color.Red);
AppendText("No ", Color.Black);
AppendText("Season ", Color.SteelBlue);
AppendText("found", Color.Black, true);
} //LAST SUBFOLDER
try
{
g.DrawString(theItem.DisplayName.ToUpper(), new Font(_pfc.Families[1], 115), new SolidBrush(Color.White), new Point(325, 70));
}
catch (NullReferenceException)
{
AppendText("[NullReferenceException] ", Color.Red);
AppendText("No ", Color.Black);
AppendText("DisplayName ", Color.SteelBlue);
AppendText("found", Color.Black, true);
} //NAME
string pngPath;
string textureFile = Path.GetFileName(bundleParser[i].DisplayStyle.DisplayImage.AssetPathName).Substring(0, Path.GetFileName(bundleParser[i].DisplayStyle.DisplayImage.AssetPathName).LastIndexOf('.'));
if (CurrentUsedPakGuid != null && CurrentUsedPakGuid != "0-0-0-0")
JwpmProcess("extract \"" + Settings.Default.PAKsPath + "\\" + CurrentUsedPak + "\" \"" + textureFile + "\" \"" + DefaultOutputPath + "\" " + Settings.Default.AESKey);
else
JwpmProcess("extract \"" + Settings.Default.PAKsPath + "\\" + AllpaksDictionary[textureFile] + "\" \"" + textureFile + "\" \"" + DefaultOutputPath + "\" " + Settings.Default.AESKey);
string textureFilePath = Directory.GetFiles(DefaultOutputPath + "\\Extracted", textureFile + ".*", SearchOption.AllDirectories).Where(x => !x.EndsWith(".png")).FirstOrDefault();
if (textureFilePath != null && textureFile == "M_UI_ChallengeTile_PCB")
{
pngPath = GetRenderSwitchMaterialTexture(textureFile, textureFilePath);
Image challengeIcon = Image.FromFile(pngPath);
g.DrawImage(Forms.Settings.ResizeImage(challengeIcon, 271, 271), new Point(40, 0)); //327
}
else if (textureFilePath != null)
{
MyAsset = new PakAsset(textureFilePath.Substring(0, textureFilePath.LastIndexOf('\\')) + "\\" + textureFile);
MyAsset.SaveTexture(textureFilePath.Substring(0, textureFilePath.LastIndexOf('\\')) + "\\" + textureFile + ".png");
pngPath = textureFilePath.Substring(0, textureFilePath.LastIndexOf('\\')) + "\\" + textureFile + ".png";
UpdateConsole(textureFile + " successfully converted to .PNG", Color.FromArgb(255, 66, 244, 66), "Success");
Image challengeIcon;
using (var bmpTemp = new Bitmap(pngPath))
{
challengeIcon = new Bitmap(bmpTemp);
}
g.DrawImage(Forms.Settings.ResizeImage(challengeIcon, 271, 271), new Point(40, 0)); //327
}
#endregion
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
#endregion
SelectedChallengesArray = new string[bundleParser[i].QuestInfos.Length];
for (int i2 = 0; i2 < bundleParser[i].QuestInfos.Length; i2++)
{
@ -2278,6 +2237,18 @@ namespace FModel
SelectedChallengesArray[i2] = cName.Substring(0, cName.LastIndexOf('.'));
}
try
{
if (Settings.Default.createIconForChallenges && bundleParser[i].DisplayStyle.DisplayImage != null)
{
drawV2(bundleParser[i], theItem, questJson, g, bmp);
v2 = true;
}
}
catch (Exception)
{
}
for (int i2 = 0; i2 < SelectedChallengesArray.Length; i2++)
{
try
@ -2677,6 +2648,88 @@ namespace FModel
}
}
}
private void drawV2(ChallengeBundleIdParser myBundle, ItemsIdParser theItem, string questJson, Graphics toDrawOn, Bitmap myBitmap)
{
int sRed;
int sGreen;
int sBlue;
string seasonFolder = questJson.Substring(questJson.Substring(0, questJson.LastIndexOf("\\", StringComparison.Ordinal)).LastIndexOf("\\", StringComparison.Ordinal) + 1).ToUpper();
if (seasonFolder.Substring(0, seasonFolder.LastIndexOf("\\", StringComparison.Ordinal)) != "LTM")
{
sRed = (int)(myBundle.DisplayStyle.SecondaryColor.R * 255);
sGreen = (int)(myBundle.DisplayStyle.SecondaryColor.G * 255);
sBlue = (int)(myBundle.DisplayStyle.SecondaryColor.B * 255);
}
else
{
sRed = (int)(myBundle.DisplayStyle.AccentColor.R * 255);
sGreen = (int)(myBundle.DisplayStyle.AccentColor.G * 255);
sBlue = (int)(myBundle.DisplayStyle.AccentColor.B * 255);
}
int seasonRed = Convert.ToInt32(sRed / 1.5);
int seasonGreen = Convert.ToInt32(sGreen / 1.5);
int seasonBlue = Convert.ToInt32(sBlue / 1.5);
toDrawOn.FillRectangle(new SolidBrush(Color.FromArgb(255, sRed, sGreen, sBlue)), new Rectangle(0, 0, myBitmap.Width, 271));
toDrawOn.FillRectangle(new SolidBrush(Color.FromArgb(255, seasonRed, seasonGreen, seasonBlue)), new Rectangle(0, 271, myBitmap.Width, myBitmap.Height - 271));
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));
}
catch (NullReferenceException)
{
AppendText("[NullReferenceException] ", Color.Red);
AppendText("No ", Color.Black);
AppendText("Season ", Color.SteelBlue);
AppendText("found", Color.Black, true);
} //LAST SUBFOLDER
try
{
toDrawOn.DrawString(theItem.DisplayName.ToUpper(), new Font(_pfc.Families[1], 115), new SolidBrush(Color.White), new Point(325, 70));
}
catch (NullReferenceException)
{
AppendText("[NullReferenceException] ", Color.Red);
AppendText("No ", Color.Black);
AppendText("DisplayName ", Color.SteelBlue);
AppendText("found", Color.Black, true);
} //NAME
string pngPath;
string textureFile = Path.GetFileName(myBundle.DisplayStyle.DisplayImage.AssetPathName).Substring(0, Path.GetFileName(myBundle.DisplayStyle.DisplayImage.AssetPathName).LastIndexOf('.'));
if (CurrentUsedPakGuid != null && CurrentUsedPakGuid != "0-0-0-0")
JwpmProcess("extract \"" + Settings.Default.PAKsPath + "\\" + CurrentUsedPak + "\" \"" + textureFile + "\" \"" + DefaultOutputPath + "\" " + Settings.Default.AESKey);
else
JwpmProcess("extract \"" + Settings.Default.PAKsPath + "\\" + AllpaksDictionary[textureFile] + "\" \"" + textureFile + "\" \"" + DefaultOutputPath + "\" " + Settings.Default.AESKey);
string textureFilePath = Directory.GetFiles(DefaultOutputPath + "\\Extracted", textureFile + ".*", SearchOption.AllDirectories).Where(x => !x.EndsWith(".png")).FirstOrDefault();
if (textureFilePath != null && textureFile == "M_UI_ChallengeTile_PCB")
{
pngPath = GetRenderSwitchMaterialTexture(textureFile, textureFilePath);
Image challengeIcon = Image.FromFile(pngPath);
toDrawOn.DrawImage(Forms.Settings.ResizeImage(challengeIcon, 271, 271), new Point(40, 0));
}
else if (textureFilePath != null)
{
MyAsset = new PakAsset(textureFilePath.Substring(0, textureFilePath.LastIndexOf('\\')) + "\\" + textureFile);
MyAsset.SaveTexture(textureFilePath.Substring(0, textureFilePath.LastIndexOf('\\')) + "\\" + textureFile + ".png");
pngPath = textureFilePath.Substring(0, textureFilePath.LastIndexOf('\\')) + "\\" + textureFile + ".png";
UpdateConsole(textureFile + " successfully converted to .PNG", Color.FromArgb(255, 66, 244, 66), "Success");
Image challengeIcon;
using (var bmpTemp = new Bitmap(pngPath))
{
challengeIcon = new Bitmap(bmpTemp);
}
toDrawOn.DrawImage(Forms.Settings.ResizeImage(challengeIcon, 271, 271), new Point(40, 0));
}
}
private void LoopStageQuest(string qAssetType, string qAssetName, Graphics toDrawOn, int yeay, int line)
{
Graphics toDrawOnLoop = toDrawOn;

View File

@ -47,6 +47,9 @@ namespace FModel.Parser.Items
[JsonProperty("DisplayAssetPath")]
public DisplayAssetPath DisplayAssetPath { get; set; }
[JsonProperty("AmmoData")]
public AmmoData AmmoData { get; set; }
}
public class GameplayTags
@ -73,6 +76,15 @@ namespace FModel.Parser.Items
public string SubPathString { get; set; }
}
public partial class AmmoData
{
[JsonProperty("asset_path_name")]
public string AssetPathName { get; set; }
[JsonProperty("sub_path_string")]
public string SubPathString { get; set; }
}
public partial class ItemsIdParser
{
public static ItemsIdParser[] FromJson(string json) => JsonConvert.DeserializeObject<ItemsIdParser[]>(json, Converter.Settings);

View File

@ -16,9 +16,9 @@
### How does it works
**1.** Once you start the executable, you'll be asked to set your path to your Fortnite .PAK files. Meanwhile a `FModel` subfolder will be created in your `Documents` folder and it'll automatically download the latest version of the custom [Fortnite Asset Parser](https://github.com/SirWaddles/JohnWickParse) in this subfolder.
![](https://i.imgur.com/NQWSBc2.gif)
![](https://i.imgur.com/so1iz1B.gif)
**2.** Restart the executable, enter the AES key, click **Load** and select your .PAK file
**2.** Restart the executable, enter the AES Key, click **Load** and select your .PAK file
- It will parse all Assets contained in the selected .PAK file with their respective path
**3.** Navigate through the tree to find the Asset you want
@ -57,20 +57,20 @@
## DOCUMENTATION
### Important
If you find this repository useful, feel free to give it a :star: thank you :kissing_heart:
If somehow FModel crash because of permissions, please either disable Windows Defender or add and exception for FModel.exe
If issues occur when compiling the source code, make sure that the software is being built for x64.
If somehow FModel crash because of permissions, please either disable Windows Defender or add and exception for FModel.exe.
Also if you find this project useful, feel free to give it a :star: thank you :kissing_heart:
### Features
1. Extract
2. Serialize (CTRL+F/G/I support)
3. Filter
3. Filter & Search
4. Create Cosmetics Icon
5. Merge Icons
6. Backup current .PAK files
7. Load difference between current .PAK files and backup file
8. Load, Extract and Save Assets automatically between current .PAK files and backup file
5. Create Challenges Icon
6. Merge Icons
7. Backup current .PAK files
8. Load difference between current .PAK files and backup file
9. Load, Extract and Save Assets automatically between current .PAK files and backup file
### What i'm using
- [Fortnite Asset Parser](https://github.com/SirWaddles/JohnWickParse) - Custom Version With Output Control And No `key.txt`
- [AutoUpdater.NET](https://github.com/ravibpatel/AutoUpdater.NET)
@ -78,19 +78,19 @@ If issues occur when compiling the source code, make sure that the software is b
- [ScintillaNET](https://www.nuget.org/packages/jacobslusser.ScintillaNET)
- [Find & Replace for ScintillaNET](https://www.nuget.org/packages/snt.ScintillaNet.FindReplaceDialog/)
- [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json)
### Contributors
| <a href="https://github.com/SirWaddles" target="_blank">**Waddlesworth**</a> | <a href="https://github.com/AyeTSG" target="_blank">**AyeTSG**</a> | <a href="https://github.com/ItsFireMonkey" target="_blank">**FireMonkey**</a> |
| :---: | :---: | :---: |
| [![Waddlesworth](https://avatars1.githubusercontent.com/u/769399?s=200&v=4)](https://github.com/SirWaddles) | [![AyeTSG](https://avatars1.githubusercontent.com/u/49595354?s=200&v=4)](https://github.com/AyeTSG) | [![FireMonkey](https://avatars2.githubusercontent.com/u/38590471?s=200&v=4)](https://github.com/ItsFireMonkey) |
| <a href="https://github.com/SirWaddles" target="_blank">`https://github.com/SirWaddles`</a> | <a href="https://twitter.com/AyeTSG" target="_blank">`https://twitter.com/AyeTSG`</a> | <a href="https://twitter.com/FireMonkeyFN" target="_blank">`https://twitter.com/FireMonkeyFN`</a> |
### Why FModel
This project is mainly based on what [UModel](https://github.com/gildor2/UModel) can do, in a personalized way, in case UModel doesn't work, as a temporary rescue solution.
I'd highly suggest you to use [UModel](https://github.com/gildor2/UModel) instead if you wanna use something made professionnaly.
### Contributors
| <a href="https://github.com/AyeTSG" target="_blank">**AyeTSG**</a> | <a href="https://github.com/ItsFireMonkey" target="_blank">**FireMonkey**</a> |
| :---: |:---:|
| [![AyeTSG](https://avatars1.githubusercontent.com/u/49595354?s=200&v=4)](https://github.com/AyeTSG) | [![FireMonkey](https://avatars2.githubusercontent.com/u/38590471?s=200&v=4)](https://github.com/ItsFireMonkey) |
| <a href="https://twitter.com/AyeTSG" target="_blank">`https://twitter.com/AyeTSG`</a> | <a href="https://twitter.com/FireMonkeyFN" target="_blank">`https://twitter.com/FireMonkeyFN`</a> |
## TODO
- [ ] Support for meshes
- [ ] Support for animations
- [ ] Display support for .locres files
- [ ] STW Icons
- [ ] Get new file content
- [ ] Display support for .locres files + compare
- [x] Code refactoring
- [x] Multithreading
- [x] Stop button