added new rarity design "Accurate Colors" which is Default design but with colors from the game files + updated .PAK Guid method

This commit is contained in:
Asval 2019-12-02 23:58:19 +01:00
parent 05e7b0a6da
commit 5c66437630
15 changed files with 206 additions and 114 deletions

View File

@ -595,6 +595,12 @@
<ItemGroup>
<Resource Include="Resources\settings_16x.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Template_AC_F.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Template_AC_N.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="AfterResolveReferences">
<ItemGroup>

View File

@ -56,6 +56,7 @@
<ComboBoxItem Content="Default"/>
<ComboBoxItem Content="Flat"/>
<ComboBoxItem Content="Minimalist"/>
<ComboBoxItem Content="Accurate Colors"/>
</ComboBox>
<Border BorderThickness="1" BorderBrush="#7F748198" Background="#FF252D36" HorizontalAlignment="Right" Height="164" Margin="398,0,0,0" Width="164" VerticalAlignment="Top">
<Image x:Name="ImageBox_RarityPreview" Source="/FModel;component/Resources/Template_D_N.png" UseLayoutRounding="True"/>

View File

@ -73,7 +73,9 @@ namespace FModel.Forms
[Description("Flat")]
Flat = 1,
[Description("Minimalist")]
Minimalist = 2
Minimalist = 2,
[Description("Accurate Colors")]
Accurate = 3
}
public static T GetEnumValueFromDescription<T>(string description)
@ -238,6 +240,9 @@ namespace FModel.Forms
case "Minimalist":
source = new BitmapImage(new Uri(isFeatured ? "pack://application:,,,/Resources/Template_M_F.png" : "pack://application:,,,/Resources/Template_M_N.png"));
break;
case "Accurate Colors":
source = new BitmapImage(new Uri(isFeatured ? "pack://application:,,,/Resources/Template_AC_F.png" : "pack://application:,,,/Resources/Template_AC_N.png"));
break;
}
drawingContext.DrawImage(source, new Rect(new Point(0, 0), new Size(515, 515)));

View File

@ -58,6 +58,7 @@
<ComboBoxItem Content="Default"/>
<ComboBoxItem Content="Flat"/>
<ComboBoxItem Content="Minimalist"/>
<ComboBoxItem Content="Accurate Colors"/>
</ComboBox>
<CheckBox x:Name="bFeaturedIcon" Content="Shop Item Icon" HorizontalAlignment="Left" Margin="438,143,0,0" VerticalAlignment="Top" Checked="UpdateImageBox" Unchecked="UpdateImageBox"/>
<CheckBox x:Name="bWatermarkIcon" Content="Watermark" HorizontalAlignment="Left" Margin="271,188,0,0" VerticalAlignment="Top" Checked="EnableDisableWatermark" Unchecked="EnableDisableWatermark"/>

View File

@ -108,7 +108,9 @@ namespace FModel.Forms
[Description("Flat")]
Flat = 1,
[Description("Minimalist")]
Minimalist = 2
Minimalist = 2,
[Description("Accurate Colors")]
Accurate = 3
}
public static T GetEnumValueFromDescription<T>(string description)
@ -199,6 +201,9 @@ namespace FModel.Forms
case "Minimalist":
source = new BitmapImage(new Uri(isFeatured ? "pack://application:,,,/Resources/Template_M_F.png" : "pack://application:,,,/Resources/Template_M_N.png"));
break;
case "Accurate Colors":
source = new BitmapImage(new Uri(isFeatured ? "pack://application:,,,/Resources/Template_AC_F.png" : "pack://application:,,,/Resources/Template_AC_N.png"));
break;
}
drawingContext.DrawImage(source, new Rect(new Point(0, 0), new Size(515, 515)));

View File

@ -1,9 +1,6 @@
using FModel.Methods.Utilities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PakReader;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows;

View File

@ -313,6 +313,7 @@ namespace FModel.Methods.Assets.IconCreator
break;
case "Default":
case "Minimalist":
case "Accurate Colors":
IconCreator.ICDrawingContext.DrawRectangle(new SolidColorBrush(Color.FromArgb(70, 0, 0, 50)), null, new Rect(3, 380, 509, 132));
break;
default:

View File

@ -1,9 +1,6 @@
using FModel.Methods.Utilities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PakReader;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows;
@ -13,6 +10,18 @@ using FProp = FModel.Properties.Settings;
namespace FModel.Methods.Assets.IconCreator
{
public enum RarityCollectionIndexes
{
Common = 0,
Uncommon = 1,
Rare = 2,
Epic = 3,
Legendary = 4,
Mythic = 5,
Transcendent = 6,
Impossible_T7 = 7,
}
static class Rarity
{
public static void DrawRarityBackground(JArray AssetProperties)
@ -28,6 +37,10 @@ namespace FModel.Methods.Assets.IconCreator
{
GetSerieAsset(serieToken, rarityToken);
}
else if (string.Equals(FProp.Default.FRarity_Design, "Accurate Colors"))
{
GetRarityData(rarityToken);
}
else
{
DrawNormalRarity(rarityToken);
@ -63,6 +76,99 @@ namespace FModel.Methods.Assets.IconCreator
}
}
private static void GetRarityData(JToken rarityToken)
{
string jsonData = AssetsUtility.GetAssetJsonDataByPath("/FortniteGame/Content/Balance/RarityData");
if (jsonData != null)
{
if (AssetsUtility.IsValidJson(jsonData))
{
JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
if (AssetMainToken != null)
{
JArray propertiesArray = AssetMainToken["properties"].Value<JArray>();
if (propertiesArray != null)
{
RarityCollectionIndexes rColor = RarityCollectionIndexes.Uncommon;
switch (rarityToken != null ? rarityToken.Value<string>() : string.Empty)
{
/*case "EFortRarity::Legendary": OLD IMPOSSIBLE (T9) but its EFortRarity doesn't exist anymore and T9 is now T7
rColor = RarityCollectionIndexes.Impossible_T7;
break;*/
case "EFortRarity::Transcendent":
rColor = RarityCollectionIndexes.Transcendent;
break;
case "EFortRarity::Mythic":
rColor = RarityCollectionIndexes.Mythic;
break;
case "EFortRarity::Legendary":
rColor = RarityCollectionIndexes.Legendary;
break;
case "EFortRarity::Epic":
case "EFortRarity::Quality":
rColor = RarityCollectionIndexes.Epic;
break;
case "EFortRarity::Rare":
rColor = RarityCollectionIndexes.Rare;
break;
case "EFortRarity::Common":
rColor = RarityCollectionIndexes.Common;
break;
}
JArray rarityCollectionArray = propertiesArray[(int)rColor]["tag_data"]["struct_type"]["properties"].Value<JArray>();
if (rarityCollectionArray != null)
{
DrawWithInGameColors(rarityCollectionArray, true);
}
}
}
}
}
else
DebugHelper.WriteLine("Rarity: This is kinda important because /FortniteGame/Content/Balance/RarityData.uasset couldn't be find");
}
private static void GetSerieAsset(JToken serieToken, JToken rarityToken)
{
//this will catch the full path if asset exists to be able to grab his PakReader and List<FPakEntry>
string seriesFullPath = AssetEntries.AssetEntriesDict.Where(x => x.Key.ToLowerInvariant().Contains("/" + serieToken.Value<string>().ToLowerInvariant() + ".uasset")).Select(d => d.Key).FirstOrDefault();
if (!string.IsNullOrEmpty(seriesFullPath))
{
string jsonData = AssetsUtility.GetAssetJsonDataByPath(seriesFullPath.Substring(0, seriesFullPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)));
if (jsonData != null)
{
if (AssetsUtility.IsValidJson(jsonData))
{
JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
if (AssetMainToken != null)
{
JArray propertiesArray = AssetMainToken["properties"].Value<JArray>();
if (propertiesArray != null)
{
JArray colorsArray = AssetsUtility.GetPropertyTagStruct<JArray>(propertiesArray, "Colors", "properties");
if (colorsArray != null)
{
DrawWithInGameColors(colorsArray,
string.Equals(seriesFullPath, "/FortniteGame/Content/Athena/Items/Cosmetics/Series/MarvelSeries.uasset") ? true : false //REVERSE COLORS IF MARVEL
); //BECAUSE IT LOOKS WEIRD
}
JToken backgroundTextureToken = AssetsUtility.GetPropertyTagText<JToken>(propertiesArray, "BackgroundTexture", "asset_path_name");
if (backgroundTextureToken != null)
{
string imagePath = FoldersUtility.FixFortnitePath(backgroundTextureToken.Value<string>());
DrawSerieImage(imagePath);
}
}
}
}
}
else { DrawNormalRarity(rarityToken); }
}
else { DrawNormalRarity(rarityToken); }
}
private static void DrawBackground(Color background, Color backgroundUpDown, Color border, bool series = false)
{
switch (FProp.Default.FRarity_Design)
@ -105,13 +211,14 @@ namespace FModel.Methods.Assets.IconCreator
//background
IconCreator.ICDrawingContext.DrawRectangle(new SolidColorBrush(background), null, new Rect(3, 3, 509, 509));
//up & down
IconCreator.ICDrawingContext.DrawGeometry(new SolidColorBrush(Color.FromArgb(125, backgroundUpDown.R, backgroundUpDown.G, backgroundUpDown.B)), null, uGeo);
IconCreator.ICDrawingContext.DrawGeometry(new SolidColorBrush(Color.FromArgb(125, backgroundUpDown.R, backgroundUpDown.G, backgroundUpDown.B)), null, dGeo);
break;
case "Default":
case "Minimalist":
case "Accurate Colors":
RadialGradientBrush radialGradient = new RadialGradientBrush();
radialGradient.GradientOrigin = new Point(0.5, 0.5);
radialGradient.Center = new Point(0.5, 0.5);
@ -148,64 +255,7 @@ namespace FModel.Methods.Assets.IconCreator
}
}
private static void GetSerieAsset(JToken serieToken, JToken rarityToken)
{
//this will catch the full path if asset exists to be able to grab his PakReader and List<FPakEntry>
string seriesFullPath = AssetEntries.AssetEntriesDict.Where(x => x.Key.ToLowerInvariant().Contains("/" + serieToken.Value<string>().ToLowerInvariant() + ".uasset")).Select(d => d.Key).FirstOrDefault();
if (!string.IsNullOrEmpty(seriesFullPath))
{
string jsonData = AssetsUtility.GetAssetJsonDataByPath(seriesFullPath.Substring(0, seriesFullPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)));
if (jsonData != null)
{
if (AssetsUtility.IsValidJson(jsonData))
{
JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
if (AssetMainToken != null)
{
JArray propertiesArray = AssetMainToken["properties"].Value<JArray>();
if (propertiesArray != null)
{
JArray colorsArray = AssetsUtility.GetPropertyTagStruct<JArray>(propertiesArray, "Colors", "properties");
if (colorsArray != null)
{
DrawSerieBackground(colorsArray);
}
JToken backgroundTextureToken = AssetsUtility.GetPropertyTagText<JToken>(propertiesArray, "BackgroundTexture", "asset_path_name");
if (backgroundTextureToken != null)
{
string imagePath = FoldersUtility.FixFortnitePath(backgroundTextureToken.Value<string>());
DrawSerieImage(imagePath);
}
}
}
}
}
else { DrawNormalRarity(rarityToken); }
}
else { DrawNormalRarity(rarityToken); }
}
private static void DrawSerieImage(string AssetPath)
{
using (Stream image = AssetsUtility.GetStreamImageFromPath(AssetPath))
{
if (image != null)
{
BitmapImage bmp = new BitmapImage();
bmp.BeginInit();
bmp.CacheOption = BitmapCacheOption.OnLoad;
bmp.StreamSource = image;
bmp.EndInit();
bmp.Freeze();
IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(3, 3, 509, 509));
}
}
}
private static void DrawSerieBackground(JArray colorsArray)
private static void DrawWithInGameColors(JArray colorsArray, bool shouldBeReversed = false)
{
Color background = new Color();
Color backgroundupdown = new Color();
@ -247,7 +297,7 @@ namespace FModel.Methods.Assets.IconCreator
border = Color.FromRgb((byte)r, (byte)g, (byte)b);
}
DrawBackground(background, backgroundupdown, ChangeColorBrightness(border, 0.25f), true);
DrawBackground(shouldBeReversed ? backgroundupdown : background, shouldBeReversed ? background : backgroundupdown, ChangeColorBrightness(border, 0.25f), true);
}
public static Color ChangeColorBrightness(Color color, float correctionFactor)
@ -272,5 +322,24 @@ namespace FModel.Methods.Assets.IconCreator
return Color.FromRgb((byte)red, (byte)green, (byte)blue);
}
private static void DrawSerieImage(string AssetPath)
{
using (Stream image = AssetsUtility.GetStreamImageFromPath(AssetPath))
{
if (image != null)
{
BitmapImage bmp = new BitmapImage();
bmp.BeginInit();
bmp.CacheOption = BitmapCacheOption.OnLoad;
bmp.StreamSource = image;
bmp.EndInit();
bmp.Freeze();
IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(3, 3, 509, 509));
}
}
}
}
}

View File

@ -38,27 +38,18 @@ namespace FModel.Methods.PAKs
{
if (!PAKsUtility.IsPAKLocked(new FileInfo(Pak)))
{
uint pVersion = PAKsUtility.GetPAKVersion(Pak);
if (pVersion == 8)
{
string PAKGuid = PAKsUtility.GetPAKGuid(Pak);
DebugHelper.WriteLine("Registering " + Pak + " with GUID " + PAKGuid + " (" + PAKsUtility.GetEpicGuid(PAKGuid) + ")");
string PAKGuid = PAKsUtility.GetPAKGuid(Pak);
DebugHelper.WriteLine("Registering " + Pak + " with GUID " + PAKGuid + " (" + PAKsUtility.GetEpicGuid(PAKGuid) + ")");
PAKEntries.PAKEntriesList.Add(new PAKInfosEntry(Pak, PAKGuid, string.Equals(PAKGuid, "0-0-0-0") ? false : true));
FWindow.FMain.Dispatcher.InvokeAsync(() =>
{
MenuItem MI_Pak = new MenuItem();
MI_Pak.Header = Path.GetFileName(Pak);
MI_Pak.Click += new RoutedEventHandler(FWindow.FMain.MI_Pak_Click);
FWindow.FMain.MI_LoadOnePAK.Items.Add(MI_Pak);
});
}
else
PAKEntries.PAKEntriesList.Add(new PAKInfosEntry(Pak, PAKGuid, string.Equals(PAKGuid, "0-0-0-0") ? false : true));
FWindow.FMain.Dispatcher.InvokeAsync(() =>
{
DebugHelper.WriteLine(Path.GetFileName(Pak) + " file version is " + pVersion + " instead of 8");
new UpdateMyProcessEvents($"Unsupported .PAK Version for {Path.GetFileName(Pak)}", "Error").Update();
}
MenuItem MI_Pak = new MenuItem();
MI_Pak.Header = Path.GetFileName(Pak);
MI_Pak.Click += new RoutedEventHandler(FWindow.FMain.MI_Pak_Click);
FWindow.FMain.MI_LoadOnePAK.Items.Add(MI_Pak);
});
}
else
{

View File

@ -1,4 +1,5 @@
using System;
using FModel.Methods.Utilities;
using System;
using System.IO;
namespace PakReader
@ -26,18 +27,20 @@ namespace PakReader
FPakInfo info = new FPakInfo(Reader);
if (info.Magic != FPakInfo.PAK_FILE_MAGIC)
{
DebugHelper.WriteLine(".PAKs: The file magic is invalid");
throw new FileLoadException("The file magic is invalid");
}
if (info.Version > (int)PAK_VERSION.PAK_LATEST)
{
Console.Error.WriteLine($"WARNING: Pak file \"{Name}\" has unsupported version {info.Version}");
DebugHelper.WriteLine($".PAKs: WARNING: Pak file \"{Name}\" has unsupported version {info.Version}");
}
if (info.bEncryptedIndex != 0)
{
if (Aes == null)
{
DebugHelper.WriteLine(".PAKs: The file has an encrypted index");
throw new FileLoadException("The file has an encrypted index");
}
}
@ -58,6 +61,7 @@ namespace PakReader
int stringLen = infoReader.ReadInt32();
if (stringLen > 512 || stringLen < -512)
{
DebugHelper.WriteLine(".PAKs: The AES key is invalid");
throw new FileLoadException("The AES key is invalid");
}
if (stringLen < 0)
@ -66,6 +70,7 @@ namespace PakReader
ushort c = infoReader.ReadUInt16();
if (c != 0)
{
DebugHelper.WriteLine(".PAKs: The AES key is invalid");
throw new FileLoadException("The AES key is invalid");
}
}
@ -75,6 +80,7 @@ namespace PakReader
byte c = infoReader.ReadByte();
if (c != 0)
{
DebugHelper.WriteLine(".PAKs: The AES key is invalid");
throw new FileLoadException("The AES key is invalid");
}
}
@ -102,7 +108,7 @@ namespace PakReader
if (badMountPoint)
{
Console.Error.WriteLine($"WARNING: Pak \"{Name}\" has strange mount point \"{MountPoint}\", mounting to root");
DebugHelper.WriteLine($".PAKs: WARNING: Pak \"{Name}\" has strange mount point \"{MountPoint}\", mounting to root");
MountPoint = "/";
}
@ -144,7 +150,7 @@ namespace PakReader
catch (IOException) { }
catch (Exception e)
{
Console.WriteLine(e);
DebugHelper.WriteException(e, "thrown in PakReader.cs by Export");
}
}
}

View File

@ -1,4 +1,5 @@
using System;
using PakReader;
using System;
using System.IO;
using System.Linq;
using System.Text;
@ -9,21 +10,15 @@ namespace FModel.Methods.Utilities
{
static class PAKsUtility
{
private const int _SIZE = 4 * 2 + 8 * 2 + 20 + /* new fields */ 1 + 16;
public static string GetPAKGuid(string PAKPath)
{
using (BinaryReader reader = new BinaryReader(File.Open(PAKPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
{
reader.BaseStream.Seek(reader.BaseStream.Length - 61 - 160, SeekOrigin.Begin);
uint g1 = reader.ReadUInt32();
reader.BaseStream.Seek(reader.BaseStream.Length - 57 - 160, SeekOrigin.Begin);
uint g2 = reader.ReadUInt32();
reader.BaseStream.Seek(reader.BaseStream.Length - 53 - 160, SeekOrigin.Begin);
uint g3 = reader.ReadUInt32();
reader.BaseStream.Seek(reader.BaseStream.Length - 49 - 160, SeekOrigin.Begin);
uint g4 = reader.ReadUInt32();
string guid = g1 + "-" + g2 + "-" + g3 + "-" + g4;
return guid;
reader.BaseStream.Seek(-FPakInfo.Size, SeekOrigin.End);
FGuid gd = new FGuid(reader);
return gd.ToString();
}
}
@ -37,17 +32,6 @@ namespace FModel.Methods.Utilities
return sB.ToString();
}
public static uint GetPAKVersion(string PAKPath)
{
using (BinaryReader reader = new BinaryReader(File.Open(PAKPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
{
reader.BaseStream.Seek(reader.BaseStream.Length - 40 - 160, SeekOrigin.Begin);
uint version = reader.ReadUInt32();
return version;
}
}
public static bool IsPAKLocked(FileInfo PakFileInfo)
{
FileStream stream = null;

View File

@ -631,6 +631,26 @@ namespace FModel.Properties {
}
}
/// <summary>
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Template_AC_F {
get {
object obj = ResourceManager.GetObject("Template_AC_F", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Template_AC_N {
get {
object obj = ResourceManager.GetObject("Template_AC_N", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
/// </summary>

View File

@ -288,4 +288,10 @@ Usually, this isn't filled in.</value>
<data name="settings_16x" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\settings_16x.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Template_AC_F" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Template_AC_F.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Template_AC_N" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Template_AC_N.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB