diff --git a/FModel/Creator/Bases/FN/BaseMaterialInstance.cs b/FModel/Creator/Bases/FN/BaseMaterialInstance.cs index 566a5e87..1578d40b 100644 --- a/FModel/Creator/Bases/FN/BaseMaterialInstance.cs +++ b/FModel/Creator/Bases/FN/BaseMaterialInstance.cs @@ -17,11 +17,11 @@ namespace FModel.Creator.Bases.FN public override void ParseForInfo() { - if (!(Object is UMaterialInstanceConstant material)) return; + if (Object is not UMaterialInstanceConstant material) return; foreach (var textureParameter in material.TextureParameterValues) // get texture from base material { - if (!(textureParameter.ParameterValue is UTexture2D texture) || Preview != null) continue; + if (textureParameter.ParameterValue is not UTexture2D texture || Preview != null) continue; switch (textureParameter.ParameterInfo.Name.Text) { case "SeriesTexture": diff --git a/FModel/Creator/Bases/SB/BaseGameModeInfo.cs b/FModel/Creator/Bases/SB/BaseGameModeInfo.cs new file mode 100644 index 00000000..9737497e --- /dev/null +++ b/FModel/Creator/Bases/SB/BaseGameModeInfo.cs @@ -0,0 +1,50 @@ +using CUE4Parse.UE4.Assets.Exports; +using CUE4Parse.UE4.Assets.Exports.Material; +using CUE4Parse.UE4.Assets.Exports.Texture; +using CUE4Parse.UE4.Objects.Core.i18N; +using SkiaSharp; + +namespace FModel.Creator.Bases.SB +{ + public class BaseGameModeInfo : UCreator + { + private SKBitmap _icon; + + public BaseGameModeInfo(UObject uObject, EIconStyle style) : base(uObject, style) + { + Width = 738; + Height = 1024; + } + + public override void ParseForInfo() + { + if (Object.TryGetValue(out FText displayName, "DisplayName")) + DisplayName = displayName.Text; + if (Object.TryGetValue(out FText description, "Description")) + Description = description.Text; + if (Object.TryGetValue(out UMaterialInstanceConstant portrait, "Portrait")) + Preview = Utils.GetBitmap(portrait); + if (Object.TryGetValue(out UTexture2D icon, "Icon")) + _icon = Utils.GetBitmap(icon).Resize(25); + } + + public override SKImage Draw() + { + using var ret = new SKBitmap(Width, Height, SKColorType.Rgba8888, SKAlphaType.Premul); + using var c = new SKCanvas(ret); + + DrawPreview(c); + DrawTextBackground(c); + DrawDisplayName(c); + DrawIcon(c); + + return SKImage.FromBitmap(ret); + } + + private void DrawIcon(SKCanvas c) + { + if (_icon == null) return; + c.DrawBitmap(_icon, new SKPoint(5, 5), ImagePaint); + } + } +} \ No newline at end of file diff --git a/FModel/Creator/Bases/UCreator.cs b/FModel/Creator/Bases/UCreator.cs index deedc79a..3c288df6 100644 --- a/FModel/Creator/Bases/UCreator.cs +++ b/FModel/Creator/Bases/UCreator.cs @@ -131,7 +131,11 @@ namespace FModel.Creator.Bases } protected void DrawPreview(SKCanvas c) - => c.DrawBitmap(Preview ?? DefaultPreview, new SKRect(Margin, Margin, Width - Margin, Height - Margin), ImagePaint); + { + var i = Preview ?? DefaultPreview; + var x = i.Width < Width ? Width / 2 - i.Width / 2 : Margin; + c.DrawBitmap(i, new SKRect(x, Margin, x + i.Width - Margin * 2, i.Height - Margin), ImagePaint); + } protected void DrawTextBackground(SKCanvas c) { diff --git a/FModel/Creator/CreatorPackage.cs b/FModel/Creator/CreatorPackage.cs index 48a97404..72d852ea 100644 --- a/FModel/Creator/CreatorPackage.cs +++ b/FModel/Creator/CreatorPackage.cs @@ -212,7 +212,6 @@ namespace FModel.Creator case "GRMTStoreOffer": case "GCosmeticEmote": case "GCosmeticCard": - case "GGameModeInfo": case "GCosmeticSkin": case "GStoreOffer": case "GAccolade": @@ -226,6 +225,10 @@ namespace FModel.Creator case "GLeagueDivision": creator = new BaseDivision(_object, EIconStyle.Default); return true; + // TODO: Draw this properly + // case "GGameModeInfo": + // creator = new BaseGameModeInfo(_object, EIconStyle.Default); + // return true; default: creator = null; return false; diff --git a/FModel/Creator/Utils.cs b/FModel/Creator/Utils.cs index 67a3014e..3be4a495 100644 --- a/FModel/Creator/Utils.cs +++ b/FModel/Creator/Utils.cs @@ -107,9 +107,10 @@ namespace FModel.Creator if (material == null) return null; foreach (var textureParameter in material.TextureParameterValues) { - if (!(textureParameter.ParameterValue is UTexture2D texture)) continue; + if (textureParameter.ParameterValue is not UTexture2D texture) continue; switch (textureParameter.ParameterInfo.Name.Text) { + case "MainTex": case "TextureA": case "TextureB": case "OfferImage":