mirror of
https://github.com/4sval/FModel.git
synced 2026-06-21 15:30:05 -05:00
added FortShopOfferDisplayData icon support (sort of)
This commit is contained in:
parent
545847d99a
commit
aeded745cf
116
FModel/Creator/Bases/BaseOfferMaterial.cs
Normal file
116
FModel/Creator/Bases/BaseOfferMaterial.cs
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
using PakReader.Parsers.Class;
|
||||
using PakReader.Parsers.Objects;
|
||||
using PakReader.Parsers.PropertyTagData;
|
||||
using SkiaSharp;
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace FModel.Creator.Bases
|
||||
{
|
||||
public class BaseOfferMaterial
|
||||
{
|
||||
public SKBitmap FallbackImage;
|
||||
public SKBitmap IconImage;
|
||||
public SKBitmap RarityBackgroundImage;
|
||||
public SKColor[] RarityBackgroundColors;
|
||||
public SKColor RarityBorderColor;
|
||||
public int Size = 512;
|
||||
public int Margin = 2;
|
||||
|
||||
public BaseOfferMaterial()
|
||||
{
|
||||
FallbackImage = SKBitmap.Decode(Application.GetResourceStream(new Uri("pack://application:,,,/Resources/T_Placeholder_Item_Image.png")).Stream);
|
||||
IconImage = FallbackImage;
|
||||
RarityBackgroundImage = null;
|
||||
RarityBackgroundColors = new SKColor[2] { SKColor.Parse("4F4F69"), SKColor.Parse("4F4F69") };
|
||||
RarityBorderColor = SKColor.Parse("9092AB");
|
||||
}
|
||||
|
||||
public BaseOfferMaterial(IUExport export) : this()
|
||||
{
|
||||
if (export.GetExport<ArrayProperty>("VectorParameterValues") is ArrayProperty vectorParameterValues)
|
||||
{
|
||||
foreach (StructProperty vectorParameter in vectorParameterValues.Value)
|
||||
{
|
||||
if (vectorParameter.Value is UObject parameter &&
|
||||
parameter.TryGetValue("ParameterValue", out var i) && i is StructProperty v && v.Value is FLinearColor value &&
|
||||
parameter.TryGetValue("ParameterInfo", out var i1) && i1 is StructProperty i2 && i2.Value is UObject info &&
|
||||
info.TryGetValue("Name", out var j1) && j1 is NameProperty name)
|
||||
{
|
||||
if (name.Value.String.Equals("Background_Color_A"))
|
||||
{
|
||||
RarityBackgroundColors[0] = SKColor.Parse(value.Hex);
|
||||
RarityBorderColor = RarityBackgroundColors[0];
|
||||
}
|
||||
else if (name.Value.String.Equals("Background_Color_B"))
|
||||
{
|
||||
RarityBackgroundColors[1] = SKColor.Parse(value.Hex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (export.GetExport<ArrayProperty>("TextureParameterValues") is ArrayProperty textureParameterValues)
|
||||
{
|
||||
foreach (StructProperty textureParameter in textureParameterValues.Value)
|
||||
{
|
||||
if (textureParameter.Value is UObject parameter &&
|
||||
parameter.TryGetValue("ParameterValue", out var i) && i is ObjectProperty value &&
|
||||
parameter.TryGetValue("ParameterInfo", out var i1) && i1 is StructProperty i2 && i2.Value is UObject info &&
|
||||
info.TryGetValue("Name", out var j1) && j1 is NameProperty name)
|
||||
{
|
||||
if (name.Value.String.Equals("OfferImage") || name.Value.String.Equals("Texture"))
|
||||
{
|
||||
IconImage = Utils.GetObjectTexture(value);
|
||||
}
|
||||
else if (name.Value.String.Equals("SeriesTexture"))
|
||||
{
|
||||
RarityBackgroundImage = Utils.GetObjectTexture(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawBackground(SKCanvas c)
|
||||
{
|
||||
if (RarityBackgroundColors[0] == RarityBackgroundColors[1])
|
||||
RarityBackgroundColors[0] = RarityBorderColor;
|
||||
|
||||
RarityBackgroundColors[0].ToHsl(out var _, out var _, out var l1);
|
||||
RarityBackgroundColors[1].ToHsl(out var _, out var _, out var l2);
|
||||
bool reverse = l1 > l2;
|
||||
|
||||
// border
|
||||
c.DrawRect(new SKRect(0, 0, Size, Size),
|
||||
new SKPaint
|
||||
{
|
||||
IsAntialias = true,
|
||||
FilterQuality = SKFilterQuality.High,
|
||||
Color = RarityBorderColor
|
||||
});
|
||||
|
||||
c.DrawRect(new SKRect(Margin, Margin, Size - Margin, Size - Margin),
|
||||
new SKPaint
|
||||
{
|
||||
IsAntialias = true,
|
||||
FilterQuality = SKFilterQuality.High,
|
||||
Shader = SKShader.CreateRadialGradient(
|
||||
new SKPoint(Size / 2, Size / 2),
|
||||
Size / 5 * 4,
|
||||
new SKColor[2] { reverse ? RarityBackgroundColors[0] : RarityBackgroundColors[1], reverse ? RarityBackgroundColors[1] : RarityBackgroundColors[0] },
|
||||
SKShaderTileMode.Clamp)
|
||||
});
|
||||
}
|
||||
|
||||
public void DrawImage(SKCanvas c)
|
||||
{
|
||||
if (RarityBackgroundImage != null)
|
||||
c.DrawBitmap(RarityBackgroundImage, new SKRect(Margin, Margin, Size - Margin, Size - Margin),
|
||||
new SKPaint { FilterQuality = SKFilterQuality.High, IsAntialias = true });
|
||||
|
||||
c.DrawBitmap(IconImage ?? FallbackImage, new SKRect(Margin, Margin, Size - Margin, Size - Margin),
|
||||
new SKPaint { FilterQuality = SKFilterQuality.High, IsAntialias = true });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -151,6 +151,27 @@ namespace FModel.Creator
|
|||
}
|
||||
return true;
|
||||
}
|
||||
case "MaterialInstanceConstant":
|
||||
{
|
||||
if (assetFolder.Equals("MI_OfferImages"))
|
||||
{
|
||||
BaseOfferMaterial icon = new BaseOfferMaterial(exports[index]);
|
||||
using (var ret = new SKBitmap(icon.Size, icon.Size, SKColorType.Rgba8888, SKAlphaType.Premul))
|
||||
using (var c = new SKCanvas(ret))
|
||||
{
|
||||
if ((EIconDesign)Properties.Settings.Default.AssetsIconDesign != EIconDesign.NoBackground)
|
||||
{
|
||||
icon.DrawBackground(c);
|
||||
}
|
||||
icon.DrawImage(c);
|
||||
|
||||
Watermark.DrawWatermark(c); // watermark should only be applied on icons with width = 512
|
||||
ImageBoxVm.imageBoxViewModel.Set(ret, assetName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case "FortItemSeriesDefinition":
|
||||
{
|
||||
BaseIcon icon = new BaseIcon();
|
||||
|
|
|
|||
|
|
@ -58,9 +58,13 @@ namespace FModel.Creator
|
|||
public static SKBitmap GetSoftObjectTexture(SoftObjectProperty s) => GetTexture(s.Value.AssetPathName.String);
|
||||
public static SKBitmap GetTexture(string s)
|
||||
{
|
||||
// FortniteGame/Content/Catalog/DisplayAssets/DA_BattlePassBundle_2020.uasset
|
||||
if (s != null && s.Equals("/Game/UI/Foundation/Textures/BattleRoyale/FeaturedItems/Outfit/T_UI_InspectScreen_annualPass"))
|
||||
s += "_1024";
|
||||
if (s != null)
|
||||
{
|
||||
if (s.Equals("/Game/UI/Foundation/Textures/BattleRoyale/FeaturedItems/Outfit/T_UI_InspectScreen_annualPass"))
|
||||
s += "_1024";
|
||||
else if (s.Equals("/Game/UI/Foundation/Textures/BattleRoyale/BattlePass/T-BattlePass-Season14-Tile") || s.Equals("/Game/UI/Foundation/Textures/BattleRoyale/BattlePass/T-BattlePassWithLevels-Season14-Tile"))
|
||||
s += "_1";
|
||||
}
|
||||
|
||||
PakPackage p = GetPropertyPakPackage(s);
|
||||
if (p.HasExport() && !p.Equals(default))
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user