From 3e89b784e5ef245fc29daa25f373bfecc103aa56 Mon Sep 17 00:00:00 2001 From: 4sval Date: Sun, 7 Aug 2022 18:16:25 +0200 Subject: [PATCH] panda missions --- FModel/Creator/Bases/MV/BasePandaIcon.cs | 17 ++++---- FModel/Creator/Bases/MV/BaseQuest.cs | 54 ++++++++++++++++++++++++ FModel/Creator/CreatorPackage.cs | 5 ++- 3 files changed, 67 insertions(+), 9 deletions(-) create mode 100644 FModel/Creator/Bases/MV/BaseQuest.cs diff --git a/FModel/Creator/Bases/MV/BasePandaIcon.cs b/FModel/Creator/Bases/MV/BasePandaIcon.cs index 0f139b03..cab2f3a1 100644 --- a/FModel/Creator/Bases/MV/BasePandaIcon.cs +++ b/FModel/Creator/Bases/MV/BasePandaIcon.cs @@ -16,7 +16,7 @@ public class BasePandaIcon : UCreator private ERewardRarity _rarity; private string _type; - private readonly List<(SKBitmap, string)> _pictos; + protected readonly List<(SKBitmap, string)> Pictos; public BasePandaIcon(UObject uObject, EIconStyle style) : base(uObject, style) { @@ -29,7 +29,7 @@ public class BasePandaIcon : UCreator DefaultPreview = Utils.GetBitmap("/Game/Panda_Main/UI/PreMatch/Images/DiamondPortraits/0010_Random.0010_Random"); _y_offset = Height / 2 + DescriptionPaint.TextSize; - _pictos = new List<(SKBitmap, string)>(); + Pictos = new List<(SKBitmap, string)>(); } public override void ParseForInfo() @@ -47,6 +47,7 @@ public class BasePandaIcon : UCreator "RingOutVfxData" => EItemType.Ringout, "BannerData" => EItemType.Banner, "EmoteData" => EItemType.Sticker, + "QuestData" => EItemType.Mission, "TauntData" => EItemType.Emote, "SkinData" => EItemType.Variant, "PerkData" when category == EPerkCategory.CharacterSpecific => EItemType.SignaturePerk, @@ -62,15 +63,15 @@ public class BasePandaIcon : UCreator else if (Object.TryGetValue(out FPackageIndex icon, "Icon")) Preview = Utils.GetBitmap(icon); - if (Object.TryGetValue(out FText displayName, "DisplayName")) + if (Object.TryGetValue(out FText displayName, "DisplayName", "QuestName")) DisplayName = displayName.Text; - if (Object.TryGetValue(out FText description, "Description")) + if (Object.TryGetValue(out FText description, "Description", "QuestDescription")) Description = Utils.RemoveHtmlTags(description.Text); var unlockLocation = Object.GetOrDefault("UnlockLocation", EUnlockLocation.None); if (t == EItemType.Unknown && unlockLocation == EUnlockLocation.CharacterMastery) t = EItemType.MasteryLevel; - _pictos.Add((Utils.GetBitmap("/Game/Panda_Main/UI/Assets/Icons/ui_icons_unlocked.ui_icons_unlocked"), Utils.GetLocalizedResource(unlockLocation))); + Pictos.Add((Utils.GetBitmap("/Game/Panda_Main/UI/Assets/Icons/ui_icons_unlocked.ui_icons_unlocked"), Utils.GetLocalizedResource(unlockLocation))); if (Object.TryGetValue(out string slug, "Slug")) { t = _type switch @@ -80,7 +81,7 @@ public class BasePandaIcon : UCreator "HydraSyncedDataAsset" when slug == "match_toasts" => EItemType.Toast, _ => t }; - _pictos.Add((Utils.GetBitmap("/Game/Panda_Main/UI/Assets/Icons/ui_icons_link.ui_icons_link"), slug)); + Pictos.Add((Utils.GetBitmap("/Game/Panda_Main/UI/Assets/Icons/ui_icons_link.ui_icons_link"), slug)); } if (Object.TryGetValue(out int xpValue, "XPValue")) @@ -240,7 +241,7 @@ public class BasePandaIcon : UCreator private void DrawPictos(SKCanvas c) { - if (_pictos.Count < 1) return; + if (Pictos.Count < 1) return; const float x = 450f; const int size = 24; @@ -256,7 +257,7 @@ public class BasePandaIcon : UCreator ImagePaint.ColorFilter = SKColorFilter.CreateBlendMode(color, SKBlendMode.SrcIn); - foreach (var picto in _pictos) + foreach (var picto in Pictos) { c.DrawBitmap(picto.Item1, new SKRect(x, _y_offset + 10, x + size, _y_offset + 10 + size), ImagePaint); c.DrawText(picto.Item2, x + size + 10, _y_offset + size + 6, paint); diff --git a/FModel/Creator/Bases/MV/BaseQuest.cs b/FModel/Creator/Bases/MV/BaseQuest.cs new file mode 100644 index 00000000..71d24624 --- /dev/null +++ b/FModel/Creator/Bases/MV/BaseQuest.cs @@ -0,0 +1,54 @@ +using System.ComponentModel; +using CUE4Parse.UE4.Assets.Exports; +using CUE4Parse.UE4.Assets.Objects; +using CUE4Parse.UE4.Objects.UObject; +using FModel.Extensions; + +namespace FModel.Creator.Bases.MV; + +public class BaseQuest : BasePandaIcon +{ + public BaseQuest(UObject uObject, EIconStyle style) : base(uObject, style) + { + } + + public override void ParseForInfo() + { + if (Object.TryGetValue(out FStructFallback[] questCompletionRewards, "QuestCompletionRewards") && + questCompletionRewards.Length > 0 && questCompletionRewards[0] is { } actualReward) + { + var rewardType = actualReward.GetOrDefault("RewardType", EQuestRewardType.Inventory); + var count = actualReward.GetOrDefault("Count", 0); + Pictos.Add((Utils.GetBitmap("/Game/Panda_Main/UI/Assets/Icons/ui_icons_plus.ui_icons_plus"), count.ToString())); + + base.ParseForInfo(); + + if (actualReward.TryGetValue(out FPackageIndex assetReward, "AssetReward") && + Utils.TryGetPackageIndexExport(assetReward, out UObject export)) + { + var item = new BasePandaIcon(export, Style); + item.ParseForInfo(); + Preview = item.Preview; + } + else if (rewardType != EQuestRewardType.Inventory) + { + Preview = Utils.GetBitmap(rewardType.GetDescription()); + } + } + else + { + base.ParseForInfo(); + } + } +} + +public enum EQuestRewardType : byte +{ + Inventory = 0, // Default + + [Description("/Game/Panda_Main/UI/Assets/Icons/UI_CharacterTicket.UI_CharacterTicket")] + AccountXP = 1, + + [Description("/Game/Panda_Main/UI/Assets/Icons/UI_BattlepassToken.UI_BattlepassToken")] + BattlepassXP = 2 +} diff --git a/FModel/Creator/CreatorPackage.cs b/FModel/Creator/CreatorPackage.cs index 84e6fd4f..64f8cd1b 100644 --- a/FModel/Creator/CreatorPackage.cs +++ b/FModel/Creator/CreatorPackage.cs @@ -149,7 +149,7 @@ public class CreatorPackage : IDisposable case "FortQuestItemDefinition_Athena": case "AthenaDailyQuestDefinition": case "FortUrgentQuestItemDefinition": - creator = new BaseQuest(_object, _style); + creator = new Bases.FN.BaseQuest(_object, _style); return true; case "FortCompendiumItemDefinition": case "FortChallengeBundleItemDefinition": @@ -194,6 +194,9 @@ public class CreatorPackage : IDisposable case "PerkData": creator = new BasePandaIcon(_object, _style); return true; + case "QuestData": + creator = new Bases.MV.BaseQuest(_object, _style); + return true; // Battle Breakers case "WExpGenericAccountItemDefinition": case "WExpGearAccountItemDefinition":