2022-08-27 06:43:36 +00:00
|
|
|
using System.Drawing;
|
2021-11-27 23:48:08 +00:00
|
|
|
using PKHeX.Core;
|
|
|
|
using PKHeX.Drawing.Misc.Properties;
|
|
|
|
using PKHeX.Drawing.PokeSprite;
|
|
|
|
|
2021-12-10 08:15:04 +00:00
|
|
|
namespace PKHeX.Drawing.Misc;
|
|
|
|
|
|
|
|
public static class MysteryGiftSpriteUtil
|
2021-11-27 23:48:08 +00:00
|
|
|
{
|
2021-12-10 08:15:04 +00:00
|
|
|
public static Image Sprite(this MysteryGift gift) => GetSprite(gift);
|
|
|
|
|
|
|
|
private static Image GetSprite(MysteryGift gift)
|
2021-11-27 23:48:08 +00:00
|
|
|
{
|
2021-12-10 08:15:04 +00:00
|
|
|
if (gift.Empty)
|
|
|
|
return SpriteUtil.Spriter.None;
|
2021-11-27 23:48:08 +00:00
|
|
|
|
2021-12-10 08:15:04 +00:00
|
|
|
var img = GetBaseImage(gift);
|
|
|
|
if (SpriteBuilder.ShowEncounterColor != SpriteBackgroundType.None)
|
|
|
|
img = SpriteUtil.ApplyEncounterColor(gift, img, SpriteBuilder.ShowEncounterColor);
|
|
|
|
if (gift.GiftUsed)
|
|
|
|
img = ImageUtil.ChangeOpacity(img, 0.3);
|
|
|
|
return img;
|
|
|
|
}
|
2021-11-27 23:48:08 +00:00
|
|
|
|
2021-12-10 08:15:04 +00:00
|
|
|
private static Image GetBaseImage(MysteryGift gift)
|
|
|
|
{
|
|
|
|
if (gift.IsEgg && gift.Species == (int)Species.Manaphy) // Manaphy Egg
|
|
|
|
return SpriteUtil.GetMysteryGiftPreviewPoke(gift);
|
2022-06-11 22:32:12 +00:00
|
|
|
if (gift.IsEntity)
|
2021-12-10 08:15:04 +00:00
|
|
|
return SpriteUtil.GetMysteryGiftPreviewPoke(gift);
|
2021-11-27 23:48:08 +00:00
|
|
|
|
2021-12-10 08:15:04 +00:00
|
|
|
if (gift.IsItem)
|
2021-11-27 23:48:08 +00:00
|
|
|
{
|
2022-08-27 06:43:36 +00:00
|
|
|
var item = (ushort)gift.ItemID;
|
|
|
|
if (Legal.ZCrystalDictionary.TryGetValue(item, out var value))
|
2021-12-10 08:15:04 +00:00
|
|
|
item = value;
|
|
|
|
return SpriteUtil.GetItemSprite(item) ?? Resources.Bag_Key;
|
2021-11-27 23:48:08 +00:00
|
|
|
}
|
2021-12-10 08:15:04 +00:00
|
|
|
return PokeSprite.Properties.Resources.b_unknown;
|
2021-11-27 23:48:08 +00:00
|
|
|
}
|
|
|
|
}
|