Show gmax for encounters in encdb

This commit is contained in:
Kurt 2021-08-14 17:16:53 -07:00
parent c5919dbec4
commit 2f9b175cd2
2 changed files with 35 additions and 23 deletions

View file

@ -1,4 +1,5 @@
using System.Drawing;
using System;
using System.Drawing;
using System.Linq;
using PKHeX.Core;
using PKHeX.Drawing.Properties;
@ -67,11 +68,6 @@ namespace PKHeX.Drawing
return Spriter.None;
var img = GetBaseImage(gift);
if (gift is IGigantamax {CanGigantamax: true})
{
var gm = Resources.dyna;
return ImageUtil.LayerImage(img, gm, (img.Width - gm.Width) / 2, 0);
}
if (gift.GiftUsed)
img = ImageUtil.ChangeOpacity(img, 0.3);
return img;
@ -82,7 +78,16 @@ namespace PKHeX.Drawing
if (gift.IsEgg && gift.Species == (int)Species.Manaphy) // Manaphy Egg
return Resources.b_490_e;
if (gift.IsPokémon)
return GetSprite(gift.Species, gift.Form, gift.Gender, 0, gift.HeldItem, gift.IsEgg, gift.IsShiny, gift.Generation);
{
var gender = Math.Max(0, gift.Gender);
var img = GetSprite(gift.Species, gift.Form, gender, 0, gift.HeldItem, gift.IsEgg, gift.IsShiny, gift.Generation);
if (gift is IGigantamax {CanGigantamax: true})
{
var gm = Resources.dyna;
return ImageUtil.LayerImage(img, gm, (img.Width - gm.Width) / 2, 0);
}
return img;
}
if (gift.IsItem)
{
int item = gift.ItemID;
@ -213,6 +218,28 @@ namespace PKHeX.Drawing
public static Image? Sprite(this SaveFile sav) => GetSprite(sav);
public static Image Sprite(this PKM pk, bool isBoxBGRed = false) => GetSprite(pk, isBoxBGRed);
public static Image Sprite(this IEncounterTemplate enc)
{
if (enc is MysteryGift g)
return g.Sprite();
var gender = GetDisplayGender(enc);
var img = GetSprite(enc.Species, enc.Form, gender, 0, 0, enc.EggEncounter, enc.IsShiny, enc.Generation);
if (enc is IGigantamax {CanGigantamax: true})
{
var gm = Resources.dyna;
return ImageUtil.LayerImage(img, gm, (img.Width - gm.Width) / 2, 0);
}
return img;
}
public static int GetDisplayGender(IEncounterTemplate enc) => enc switch
{
EncounterSlotGO g => (int)g.Gender & 1,
EncounterStatic s => Math.Max(0, s.Gender),
EncounterTrade t => Math.Max(0, t.Gender),
_ => 0,
};
public static Image Sprite(this PKM pk, SaveFile sav, int box, int slot, bool flagIllegal = false)
=> GetSprite(pk, sav, box, slot, flagIllegal);

View file

@ -378,7 +378,7 @@ namespace PKHeX.WinForms
for (int i = 0; i < end; i++)
{
var enc = Results[i + begin];
boxes[i].Image = GetImage(enc);
boxes[i].Image = enc.Sprite();
}
// Clear empty slots
@ -394,21 +394,6 @@ namespace PKHeX.WinForms
boxes[slotSelected - begin].BackgroundImage = slotColor ?? SpriteUtil.Spriter.View;
}
private static Image GetImage(IEncounterTemplate enc)
{
var gender = GetDisplayGender(enc);
return SpriteUtil.GetSprite(enc.Species, enc.Form, gender, 0, 0, enc.EggEncounter, enc.IsShiny, enc.Generation);
}
public static int GetDisplayGender(IEncounterTemplate enc) => enc switch
{
EncounterSlotGO g => (int) g.Gender & 1,
EncounterStatic s => Math.Max(0, s.Gender),
EncounterTrade t => Math.Max(0, t.Gender),
MysteryGift f => Math.Max(0, f.Gender),
_ => 0,
};
private void Menu_Exit_Click(object sender, EventArgs e) => Close();
protected override void OnMouseWheel(MouseEventArgs e)