WExpGenericAccountItemDefinition support

This commit is contained in:
GMatrixGames 2020-10-17 17:05:43 -04:00
parent 7b71a43eab
commit fef39af079
No known key found for this signature in database
GPG Key ID: 19B7F96FB9AF302F
3 changed files with 334 additions and 187 deletions

View File

@ -0,0 +1,58 @@
using System;
using System.Windows;
using FModel.Creator.Rarities;
using FModel.Creator.Texts;
using PakReader.Parsers.Class;
using PakReader.Parsers.PropertyTagData;
using SkiaSharp;
namespace FModel.Creator.Bases
{
public class BaseBBDefinition : IBase
{
public SKBitmap FallbackImage;
public SKBitmap IconImage;
public SKColor[] RarityBackgroundColors;
public SKColor[] RarityBorderColor;
public string DisplayName;
public string Description;
public int Width = 512;
public int Height = 512;
public int Margin = 2;
public BaseBBDefinition(string exportType)
{
FallbackImage = SKBitmap.Decode(Application.GetResourceStream(new Uri("pack://application:,,,/Resources/T_Placeholder_Item_Image.png"))?.Stream);
IconImage = FallbackImage;
RarityBackgroundColors = new[] { SKColor.Parse("D0D0D0"), SKColor.Parse("636363") };
RarityBorderColor = new[] { SKColor.Parse("D0D0D0"), SKColor.Parse("FFFFFF") };
DisplayName = "";
Description = "";
}
public BaseBBDefinition(IUExport export, string exportType) : this(exportType)
{
// Not sure how to handle rarity for this. From what I can see, there is no data for colors
if (export.GetExport<SoftObjectProperty>("IconTextureAssetData") is {} previewImage)
IconImage = Utils.GetSoftObjectTexture(previewImage);
else if (export.GetExport<ObjectProperty>("IconTextureAssetData") is {} iconTexture)
IconImage = Utils.GetObjectTexture(iconTexture);
if (export.GetExport<TextProperty>("DisplayName") is {} displayName)
DisplayName = Text.GetTextPropertyBase(displayName);
if (export.GetExport<TextProperty>("Description") is {} description)
Description = Text.GetTextPropertyBase(description);
}
SKBitmap IBase.FallbackImage => FallbackImage;
SKBitmap IBase.IconImage => IconImage;
SKColor[] IBase.RarityBackgroundColors => RarityBackgroundColors;
SKColor[] IBase.RarityBorderColor => RarityBorderColor;
string IBase.DisplayName => DisplayName;
string IBase.Description => Description;
int IBase.Width => Width;
int IBase.Height => Height;
int IBase.Margin => Margin;
}
}

View File

@ -23,7 +23,8 @@ namespace FModel.Creator
var d = new DirectoryInfo(assetPath);
string assetName = d.Name;
string assetFolder = d.Parent.Name;
if (Text.TypeFaces.NeedReload(false)) Text.TypeFaces = new Typefaces(); // when opening bundle creator settings without loading paks first
if (Text.TypeFaces.NeedReload(false))
Text.TypeFaces = new Typefaces(); // when opening bundle creator settings without loading paks first
int index;
{
@ -137,11 +138,13 @@ namespace FModel.Creator
Text.DrawDescription(c, icon);
if ((EIconDesign) Properties.Settings.Default.AssetsIconDesign != EIconDesign.Mini)
{
if (!icon.ShortDescription.Equals(icon.DisplayName) && !icon.ShortDescription.Equals(icon.Description))
if (!icon.ShortDescription.Equals(icon.DisplayName) &&
!icon.ShortDescription.Equals(icon.Description))
Text.DrawToBottom(c, icon, ETextSide.Left, icon.ShortDescription);
Text.DrawToBottom(c, icon, ETextSide.Right, icon.CosmeticSource);
}
}
UserFacingFlag.DrawUserFacingFlags(c, icon);
// has more things to show
@ -154,6 +157,7 @@ namespace FModel.Creator
Watermark.DrawWatermark(c); // watermark should only be applied on icons with width = 512
ImageBoxVm.imageBoxViewModel.Set(ret, assetName);
}
return true;
}
case "FortPlaylistAthena":
@ -182,18 +186,21 @@ namespace FModel.Creator
// Watermark.DrawWatermark(c); // boi why would you watermark something you don't own ¯\_(ツ)_/¯
ImageBoxVm.imageBoxViewModel.Set(ret, assetName);
}
return true;
}
case "AthenaSeasonItemDefinition":
{
BaseSeason icon = new BaseSeason(exports[index], assetFolder);
using (var ret = new SKBitmap(icon.Width, icon.HeaderHeight + icon.AdditionalSize, SKColorType.Rgba8888, SKAlphaType.Opaque))
using (var ret = new SKBitmap(icon.Width, icon.HeaderHeight + icon.AdditionalSize,
SKColorType.Rgba8888, SKAlphaType.Opaque))
using (var c = new SKCanvas(ret))
{
icon.Draw(c);
ImageBoxVm.imageBoxViewModel.Set(ret, assetName);
}
return true;
}
case "FortMtxOfferData":
@ -206,11 +213,13 @@ namespace FModel.Creator
{
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;
}
case "MaterialInstanceConstant":
@ -225,13 +234,16 @@ namespace FModel.Creator
{
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":
@ -246,6 +258,7 @@ namespace FModel.Creator
Watermark.DrawWatermark(c); // watermark should only be applied on icons with width = 512
ImageBoxVm.imageBoxViewModel.Set(ret, assetName);
}
return true;
}
case "PlaylistUserOptionEnum":
@ -268,12 +281,14 @@ namespace FModel.Creator
Watermark.DrawWatermark(c); // watermark should only be applied on icons with width = 512
ImageBoxVm.imageBoxViewModel.Set(ret, assetName);
}
return true;
}
case "FortChallengeBundleItemDefinition":
{
BaseBundle icon = new BaseBundle(exports[index], assetFolder);
using (var ret = new SKBitmap(icon.Width, icon.HeaderHeight + icon.AdditionalSize, SKColorType.Rgba8888, SKAlphaType.Opaque))
using (var ret = new SKBitmap(icon.Width, icon.HeaderHeight + icon.AdditionalSize,
SKColorType.Rgba8888, SKAlphaType.Opaque))
using (var c = new SKCanvas(ret))
{
HeaderStyle.DrawHeaderPaint(c, icon);
@ -283,6 +298,7 @@ namespace FModel.Creator
ImageBoxVm.imageBoxViewModel.Set(ret, assetName);
}
return true;
}
case "FortItemAccessTokenType":
@ -296,6 +312,7 @@ namespace FModel.Creator
Watermark.DrawWatermark(c); // watermark should only be applied on icons with width = 512
ImageBoxVm.imageBoxViewModel.Set(ret, assetName);
}
return true;
}
case "MapUIData":
@ -307,6 +324,7 @@ namespace FModel.Creator
icon.Draw(c);
ImageBoxVm.imageBoxViewModel.Set(ret, assetName);
}
return true;
}
case "ArmorUIData":
@ -328,7 +346,8 @@ namespace FModel.Creator
case "EquippableCharmLevelUIData":
{
BaseUIData icon = new BaseUIData(exports, index);
using (var ret = new SKBitmap(icon.Width + icon.AdditionalWidth, icon.Height, SKColorType.Rgba8888, SKAlphaType.Premul))
using (var ret = new SKBitmap(icon.Width + icon.AdditionalWidth, icon.Height, SKColorType.Rgba8888,
SKAlphaType.Premul))
using (var c = new SKCanvas(ret))
{
icon.Draw(c);
@ -336,6 +355,7 @@ namespace FModel.Creator
Watermark.DrawWatermark(c); // watermark should only be applied on icons with width = 512
ImageBoxVm.imageBoxViewModel.Set(ret, assetName);
}
return true;
}
//case "StreamedVideoDataAsset": // must find a way to automatically gets the right version in the url
@ -395,6 +415,7 @@ namespace FModel.Creator
Watermark.DrawWatermark(c); // watermark should only be applied on icons with width = 512
ImageBoxVm.imageBoxViewModel.Set(ret, assetName);
}
return true;
}
case "GCosmeticCard":
@ -426,11 +447,44 @@ namespace FModel.Creator
Text.DrawDescription(c, icon);
}
}
ImageBoxVm.imageBoxViewModel.Set(ret, assetName);
}
return true;
}
// Battle Breakers
case "WExpGenericAccountItemDefinition":
{
BaseBBDefinition icon = new BaseBBDefinition(exports[index], exportType);
using (var ret = new SKBitmap(icon.Width, icon.Height, SKColorType.Rgba8888, SKAlphaType.Premul))
using (var c = new SKCanvas(ret))
{
if ((EIconDesign) Properties.Settings.Default.AssetsIconDesign != EIconDesign.NoBackground)
{
Rarity.DrawRarity(c, icon);
}
LargeSmallImage.DrawPreviewImage(c, icon);
if ((EIconDesign) Properties.Settings.Default.AssetsIconDesign != EIconDesign.NoBackground)
{
if ((EIconDesign) Properties.Settings.Default.AssetsIconDesign != EIconDesign.NoText)
{
Text.DrawBackground(c, icon);
Text.DrawDisplayName(c, icon);
Text.DrawDescription(c, icon);
}
}
Watermark.DrawWatermark(c); // watermark should only be applied on icons with width = 512
ImageBoxVm.imageBoxViewModel.Set(ret, assetName);
}
return true;
}
}
return false;
}
}

View File

@ -56,6 +56,17 @@ namespace FModel.Creator.Texts
private const string _NANUM_GOTHIC = "NanumGothic";
private const string _QUADRAT_BOLD = "Quadrat_Bold";
private const string _SEGOE_BOLD_ITALIC = "Segoe_Bold_Italic";
private const string _BATTLE_BREAKERS_BASE_PATH = "/Game/UMG/Fonts/Faces/";
private const string _HEMIHEAD426 = "HemiHead426";
private const string _ROBOTO_BOLD = "Roboto-Bold";
private const string _ROBOTO_BOLD_ALL_CAPS = "Roboto-BoldAllCaps";
private const string _ROBOTO_REGULAR = "Roboto-Regular";
private const string _NOTO_SANS_JP_REGULAR = "NotoSansJP-Regular";
private const string _LATO_LIGHT = "Lato-Light";
private const string _LATO_MEDIUM = "Lato-Medium";
private const string _LATO_BLACK_ITALIC = "Lato-BlackItalic";
private const string _LATO_BLACK = "Lato-Black";
#pragma warning restore IDE0051
public SKTypeface DefaultTypeface; // used as default font for all untranslated strings (item source, ...)
@ -67,7 +78,7 @@ namespace FModel.Creator.Texts
public Typefaces()
{
DefaultTypeface = SKTypeface.FromStream(Application.GetResourceStream(_BURBANK_BIG_CONDENSED_BOLD).Stream);
DefaultTypeface = SKTypeface.FromStream(Application.GetResourceStream(_BURBANK_BIG_CONDENSED_BOLD)?.Stream);
if (Globals.Game.ActualGame == EGame.Fortnite)
{
ArraySegment<byte>[] t = Utils.GetPropertyArraySegmentByte(_FORTNITE_BASE_PATH + _BURBANK_BIG_CONDENSED_BLACK);
@ -174,6 +185,30 @@ namespace FModel.Creator.Texts
DescriptionTypeface = SKTypeface.FromStream(t[2].AsStream());
else DescriptionTypeface = DefaultTypeface;
}
else if (Globals.Game.ActualGame == EGame.BattleBreakers)
{
string namePath = _BATTLE_BREAKERS_BASE_PATH + (
Properties.Settings.Default.AssetsLanguage == (long)ELanguage.Korean ? _NOTO_SANS_KR_REGULAR :
Properties.Settings.Default.AssetsLanguage == (long)ELanguage.Russian ? _LATO_BLACK :
Properties.Settings.Default.AssetsLanguage == (long)ELanguage.Japanese ? _NOTO_SANS_JP_REGULAR :
Properties.Settings.Default.AssetsLanguage == (long)ELanguage.Chinese ? _NOTO_SANS_SC_REGULAR :
_HEMIHEAD426);
ArraySegment<byte>[] t = Utils.GetPropertyArraySegmentByte(namePath);
if (t != null && t.Length == 3 && t[2].Array != null)
DisplayNameTypeface = SKTypeface.FromStream(t[2].AsStream());
else DisplayNameTypeface = DefaultTypeface;
string descriptionPath = _BATTLE_BREAKERS_BASE_PATH + (
Properties.Settings.Default.AssetsLanguage == (long)ELanguage.Korean ? _NOTO_SANS_KR_REGULAR :
Properties.Settings.Default.AssetsLanguage == (long)ELanguage.Russian ? _LATO_BLACK :
Properties.Settings.Default.AssetsLanguage == (long)ELanguage.Japanese ? _NOTO_SANS_JP_REGULAR :
Properties.Settings.Default.AssetsLanguage == (long)ELanguage.Chinese ? _NOTO_SANS_SC_REGULAR :
_HEMIHEAD426);
t = Utils.GetPropertyArraySegmentByte(descriptionPath);
if (t != null && t.Length == 3 && t[2].Array != null)
DescriptionTypeface = SKTypeface.FromStream(t[2].AsStream());
else DescriptionTypeface = DefaultTypeface;
}
}
public bool NeedReload(bool forceReload) => forceReload ?