From eb546602eae74942d13989b86f85c801cdb42ee0 Mon Sep 17 00:00:00 2001 From: Asval Date: Sun, 28 Jan 2024 15:53:32 +0100 Subject: [PATCH] quest fix + juno icons --- CUE4Parse | 2 +- FModel/Creator/Bases/FN/BaseJuno.cs | 42 ++++++++++++++++++++++++++ FModel/Creator/Bases/FN/BaseQuest.cs | 27 ++++++++++++----- FModel/Creator/Bases/FN/Reward.cs | 44 ++++++++++++++-------------- FModel/Creator/CreatorPackage.cs | 3 ++ 5 files changed, 88 insertions(+), 30 deletions(-) create mode 100644 FModel/Creator/Bases/FN/BaseJuno.cs diff --git a/CUE4Parse b/CUE4Parse index 1cb082d1..20662a92 160000 --- a/CUE4Parse +++ b/CUE4Parse @@ -1 +1 @@ -Subproject commit 1cb082d145bc70f76cf7a0cefbff890ae9f82c47 +Subproject commit 20662a924df0c494b3576888fa5c3ae2ef38594d diff --git a/FModel/Creator/Bases/FN/BaseJuno.cs b/FModel/Creator/Bases/FN/BaseJuno.cs new file mode 100644 index 00000000..af1bbeb7 --- /dev/null +++ b/FModel/Creator/Bases/FN/BaseJuno.cs @@ -0,0 +1,42 @@ +using CUE4Parse.UE4.Assets.Exports; +using CUE4Parse.UE4.Assets.Objects; +using CUE4Parse.UE4.Objects.UObject; +using SkiaSharp; + +namespace FModel.Creator.Bases.FN; + +public class BaseJuno : BaseIcon +{ + private BaseIcon _character; + + public BaseJuno(UObject uObject, EIconStyle style) : base(uObject, style) + { + + } + + public override void ParseForInfo() + { + if (Object.TryGetValue(out FSoftObjectPath baseCid, "BaseAthenaCharacterItemDefinition") && + Utils.TryLoadObject(baseCid.AssetPathName.Text, out UObject cid)) + { + _character = new BaseIcon(cid, Style); + _character.ParseForInfo(); + + if (Object.TryGetValue(out FSoftObjectPath assembledMeshSchema, "AssembledMeshSchema") && + Utils.TryLoadObject(assembledMeshSchema.AssetPathName.Text, out UObject meshSchema) && + meshSchema.TryGetValue(out FInstancedStruct[] additionalData, "AdditionalData")) + { + foreach (var data in additionalData) + { + if (data.NonConstStruct?.TryGetValue(out FSoftObjectPath largePreview, "LargePreviewImage", "SmallPreviewImage") ?? false) + { + _character.Preview = Utils.GetBitmap(largePreview); + break; + } + } + } + } + } + + public override SKBitmap[] Draw() => _character.Draw(); +} diff --git a/FModel/Creator/Bases/FN/BaseQuest.cs b/FModel/Creator/Bases/FN/BaseQuest.cs index 4c0364b2..fd0c862b 100644 --- a/FModel/Creator/Bases/FN/BaseQuest.cs +++ b/FModel/Creator/Bases/FN/BaseQuest.cs @@ -69,13 +69,19 @@ public class BaseQuest : BaseIcon } else { - Description = ShortDescription; - if (Object.TryGetValue(out FText completionText, "CompletionText")) - Description += "\n" + completionText.Text; - if (Object.TryGetValue(out FSoftObjectPath tandemCharacterData, "TandemCharacterData") && + if (!string.IsNullOrEmpty(ShortDescription)) + Description = ShortDescription; + if (string.IsNullOrEmpty(DisplayName) && !string.IsNullOrEmpty(Description)) + DisplayName = Description; + if (DisplayName == Description) + Description = string.Empty; + + if ((Object.TryGetValue(out FSoftObjectPath icon, "QuestGiverWidgetIcon", "NotificationIconOverride") && + Utils.TryLoadObject(icon.AssetPathName.Text, out UObject iconObject)) || + (Object.TryGetValue(out FSoftObjectPath tandemCharacterData, "TandemCharacterData") && Utils.TryLoadObject(tandemCharacterData.AssetPathName.Text, out UObject uObject) && uObject.TryGetValue(out FSoftObjectPath tandemIcon, "EntryListIcon", "ToastIcon") && - Utils.TryLoadObject(tandemIcon.AssetPathName.Text, out UObject iconObject)) + Utils.TryLoadObject(tandemIcon.AssetPathName.Text, out iconObject))) { Preview = iconObject switch { @@ -127,9 +133,16 @@ public class BaseQuest : BaseIcon } } - if (_reward == null && Object.TryGetValue(out UDataTable rewardsTable, "RewardsTable")) + if (_reward == null) { - if (rewardsTable.TryGetDataTableRow("Default", StringComparison.InvariantCulture, out var row)) + FName rowName = null; + if (Object.TryGetValue(out UDataTable rewardsTable, "RewardsTable")) + rowName = new FName("Default"); + else if (Object.TryGetValue(out FStructFallback[] rewardTableRows, "IndividualRewardTableRows") && + rewardTableRows.Length > 0 && rewardTableRows[0].TryGetValue(out rowName, "RowName") && + rewardTableRows[0].TryGetValue(out rewardsTable, "DataTable")) {} + + if (rewardsTable != null && rowName != null && rewardsTable.TryGetDataTableRow(rowName.Text, StringComparison.InvariantCulture, out var row)) { if (row.TryGetValue(out FName templateId, "TemplateId") && row.TryGetValue(out int quantity, "Quantity")) diff --git a/FModel/Creator/Bases/FN/Reward.cs b/FModel/Creator/Bases/FN/Reward.cs index 0e5aad43..fe650617 100644 --- a/FModel/Creator/Bases/FN/Reward.cs +++ b/FModel/Creator/Bases/FN/Reward.cs @@ -64,7 +64,7 @@ public class Reward _rewardPaint.TextSize = 50; if (HasReward()) { - c.DrawBitmap(_theReward.Preview.Resize((int) rect.Height), new SKPoint(rect.Left, rect.Top), _rewardPaint); + c.DrawBitmap((_theReward.Preview ?? _theReward.DefaultPreview).Resize((int) rect.Height), new SKPoint(rect.Left, rect.Top), _rewardPaint); _rewardPaint.Color = _theReward.Border[0]; _rewardPaint.Typeface = _rewardQuantity.StartsWith("x") ? Utils.Typefaces.BundleNumber : Utils.Typefaces.Bundle; @@ -88,7 +88,7 @@ public class Reward public void DrawSeasonWin(SKCanvas c, int size) { if (!HasReward()) return; - c.DrawBitmap(_theReward.Preview.Resize(size), new SKPoint(0, 0), _rewardPaint); + c.DrawBitmap((_theReward.Preview ?? _theReward.DefaultPreview).Resize(size), new SKPoint(0, 0), _rewardPaint); } public void DrawSeason(SKCanvas c, int x, int y, int areaSize) @@ -115,33 +115,33 @@ public class Reward { switch (trigger.ToLower()) { - case "athenabattlestar": - _theReward = new BaseIcon(null, EIconStyle.Default); - _theReward.Border[0] = SKColor.Parse("FFDB67"); - _theReward.Background[0] = SKColor.Parse("8F4A20"); - _theReward.Preview = Utils.GetBitmap("FortniteGame/Content/Athena/UI/Frontend/Art/T_UI_BP_BattleStar_L.T_UI_BP_BattleStar_L"); - break; - case "athenaseasonalxp": - _theReward = new BaseIcon(null, EIconStyle.Default); - _theReward.Border[0] = SKColor.Parse("E6FDB1"); - _theReward.Background[0] = SKColor.Parse("51830F"); - _theReward.Preview = Utils.GetBitmap("FortniteGame/Content/UI/Foundation/Textures/Icons/Items/T-FNBR-XPUncommon-L.T-FNBR-XPUncommon-L"); - break; - case "mtxgiveaway": - _theReward = new BaseIcon(null, EIconStyle.Default); - _theReward.Border[0] = SKColor.Parse("DCE6FF"); - _theReward.Background[0] = SKColor.Parse("64A0AF"); - _theReward.Preview = Utils.GetBitmap("FortniteGame/Content/UI/Foundation/Textures/Icons/Items/T-Items-MTX.T-Items-MTX"); - break; + // case "athenabattlestar": + // _theReward = new BaseIcon(null, EIconStyle.Default); + // _theReward.Border[0] = SKColor.Parse("FFDB67"); + // _theReward.Background[0] = SKColor.Parse("8F4A20"); + // _theReward.Preview = Utils.GetBitmap("FortniteGame/Content/Athena/UI/Frontend/Art/T_UI_BP_BattleStar_L.T_UI_BP_BattleStar_L"); + // break; + // case "athenaseasonalxp": + // _theReward = new BaseIcon(null, EIconStyle.Default); + // _theReward.Border[0] = SKColor.Parse("E6FDB1"); + // _theReward.Background[0] = SKColor.Parse("51830F"); + // _theReward.Preview = Utils.GetBitmap("FortniteGame/Content/UI/Foundation/Textures/Icons/Items/T-FNBR-XPUncommon-L.T-FNBR-XPUncommon-L"); + // break; + // case "mtxgiveaway": + // _theReward = new BaseIcon(null, EIconStyle.Default); + // _theReward.Border[0] = SKColor.Parse("DCE6FF"); + // _theReward.Background[0] = SKColor.Parse("64A0AF"); + // _theReward.Preview = Utils.GetBitmap("FortniteGame/Content/UI/Foundation/Textures/Icons/Items/T-Items-MTX.T-Items-MTX"); + // break; default: { - var path = Utils.GetFullPath($"FortniteGame/Content/Athena/.*?/{trigger}.*"); // path has no objectname and its needed so we push the trigger again as the objectname + var path = Utils.GetFullPath($"FortniteGame/(?:Content/Athena|Content/Items|Plugins/GameFeatures)/.*?/{trigger}.uasset"); // path has no objectname and its needed so we push the trigger again as the objectname if (!string.IsNullOrWhiteSpace(path) && Utils.TryLoadObject(path.Replace("uasset", trigger), out UObject d)) { _theReward = new BaseIcon(d, EIconStyle.Default); _theReward.ParseForReward(false); _theReward.Border[0] = SKColors.White; - _rewardQuantity = _theReward.DisplayName; + _rewardQuantity = $"{_theReward.DisplayName} ({_rewardQuantity})"; } break; diff --git a/FModel/Creator/CreatorPackage.cs b/FModel/Creator/CreatorPackage.cs index fd2cea3f..6342482a 100644 --- a/FModel/Creator/CreatorPackage.cs +++ b/FModel/Creator/CreatorPackage.cs @@ -136,6 +136,9 @@ public class CreatorPackage : IDisposable _ => new BaseIcon(_object, _style) }; return true; + case "JunoAthenaCharacterItemOverrideDefinition": + creator = new BaseJuno(_object, _style); + return true; case "FortTandemCharacterData": creator = new BaseTandem(_object, _style); return true;