Add optional box slot coloring, add settings

This commit is contained in:
Kurt 2021-08-24 14:21:35 -07:00
parent 6e3bcd5b66
commit a121f4d617
5 changed files with 31 additions and 12 deletions

View file

@ -50,13 +50,13 @@ namespace PKHeX.Drawing
return bmp;
}
public static Bitmap ChangeTransparentTo(Image img, Color c)
public static Bitmap ChangeTransparentTo(Image img, Color c, byte trans)
{
var bmp = (Bitmap)img.Clone();
GetBitmapData(bmp, out BitmapData bmpData, out IntPtr ptr, out byte[] data);
Marshal.Copy(ptr, data, 0, data.Length);
SetAllTransparencyTo(data, c);
SetAllTransparencyTo(data, c, trans);
Marshal.Copy(data, 0, ptr, data.Length);
bmp.UnlockBits(bmpData);
@ -130,7 +130,7 @@ namespace PKHeX.Drawing
data[i + 3] = (byte)(data[i + 3] * trans);
}
public static void SetAllTransparencyTo(byte[] data, Color c)
public static void SetAllTransparencyTo(byte[] data, Color c, byte trans)
{
byte R = c.R;
byte G = c.G;
@ -142,7 +142,7 @@ namespace PKHeX.Drawing
data[i + 0] = B;
data[i + 1] = G;
data[i + 2] = R;
data[i + 3] = 0x3F;
data[i + 3] = trans;
}
}

View file

@ -7,8 +7,9 @@ namespace PKHeX.Drawing
public abstract class SpriteBuilder : ISpriteBuilder<Image>
{
public static bool ShowEggSpriteAsItem { get; set; } = true;
public static bool EncounterColorBackground { get; set; } = true;
public static bool EncounterShowFixedBall { get; set; } = true;
public static bool ShowEncounterColor { get; set; } = true;
public static bool ShowEncounterBall { get; set; } = true;
public static bool ShowEncounterColorPKM { get; set; }
/// <summary> Width of the generated Sprite image. </summary>
public abstract int Width { get; }

View file

@ -68,10 +68,10 @@ namespace PKHeX.Drawing
return Spriter.None;
var img = GetBaseImage(gift);
if (SpriteBuilder.EncounterColorBackground)
if (SpriteBuilder.ShowEncounterColor)
{
var color = Color.FromArgb(gift.GetType().Name.GetHashCode() * 0x43FD43FD);
img = ImageUtil.ChangeTransparentTo(img, color);
img = ImageUtil.ChangeTransparentTo(img, color, 0x3F);
}
if (gift.GiftUsed)
img = ImageUtil.ChangeOpacity(img, 0.3);
@ -86,7 +86,7 @@ namespace PKHeX.Drawing
{
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 (SpriteBuilder.EncounterShowFixedBall && gift is IFixedBall { FixedBall: not Ball.None } b)
if (SpriteBuilder.ShowEncounterBall && gift is IFixedBall { FixedBall: not Ball.None } b)
{
var ballSprite = GetBallSprite((int)b.FixedBall);
img = ImageUtil.LayerImage(img, ballSprite, 0, img.Height - ballSprite.Height);
@ -162,6 +162,12 @@ namespace PKHeX.Drawing
sprite = ImageUtil.LayerImage(sprite, Resources.warn, 0, FlagIllegalShiftY);
else if (pk.Format >= 8 && pk.Moves.Any(Legal.DummiedMoves_SWSH.Contains))
sprite = ImageUtil.LayerImage(sprite, Resources.hint, 0, FlagIllegalShiftY);
if (SpriteBuilder.ShowEncounterColorPKM)
{
var enc = la.EncounterOriginal;
var color = Color.FromArgb(enc.GetType().Name.GetHashCode() * 0x43FD43FD);
sprite = ImageUtil.ChangeTransparentTo(sprite, color, 0x1F);
}
}
if (inBox) // in box
{
@ -234,12 +240,12 @@ namespace PKHeX.Drawing
return g.Sprite();
var gender = GetDisplayGender(enc);
var img = GetSprite(enc.Species, enc.Form, gender, 0, 0, enc.EggEncounter, enc.IsShiny, enc.Generation);
if (SpriteBuilder.EncounterColorBackground)
if (SpriteBuilder.ShowEncounterColor)
{
var color = Color.FromArgb(enc.GetType().Name.GetHashCode() * 0x43FD43FD);
img = ImageUtil.ChangeTransparentTo(img, color);
img = ImageUtil.ChangeTransparentTo(img, color, 0x3F);
}
if (SpriteBuilder.EncounterShowFixedBall && enc is IFixedBall {FixedBall: not Ball.None} b)
if (SpriteBuilder.ShowEncounterBall && enc is IFixedBall {FixedBall: not Ball.None} b)
{
var ballSprite = GetBallSprite((int)b.FixedBall);
img = ImageUtil.LayerImage(img, ballSprite, 0, img.Height - ballSprite.Height);

View file

@ -453,6 +453,9 @@ namespace PKHeX.WinForms
C_SAV.FlagIllegal = settings.Display.FlagIllegal;
C_SAV.M.Hover.GlowHover = settings.Hover.HoverSlotGlowEdges;
SpriteBuilder.ShowEggSpriteAsItem = settings.Display.ShowEggSpriteAsHeldItem;
SpriteBuilder.ShowEncounterColor = settings.Display.ShowEncounterColor;
SpriteBuilder.ShowEncounterBall = settings.Display.ShowEncounterBall;
SpriteBuilder.ShowEncounterColorPKM = settings.Display.ShowEncounterColorPKM;
ParseSettings.InitFromSettings(settings.Legality);
PKME_Tabs.HideSecretValues = C_SAV.HideSecretDetails = settings.Privacy.HideSecretDetails;
PKMConverter.AllowIncompatibleConversion = settings.Advanced.AllowIncompatibleConversion;

View file

@ -322,11 +322,20 @@ namespace PKHeX.WinForms
[LocalizedDescription("Show an Egg Sprite As Held Item rather than hiding the PKM")]
public bool ShowEggSpriteAsHeldItem { get; set; } = true;
[LocalizedDescription("Show a background to differentiate an Encounter Template's type")]
public bool ShowEncounterColor { get; set; } = true;
[LocalizedDescription("Show a background to differentiate the recognized Encounter Template type for PKM slots")]
public bool ShowEncounterColorPKM { get; set; }
[LocalizedDescription("Don't show the Legality popup if Legal!")]
public bool IgnoreLegalPopup { get; set; }
[LocalizedDescription("Flag Illegal Slots in Save File")]
public bool FlagIllegal { get; set; } = true;
[LocalizedDescription("Show the required ball for an Encounter Template")]
public bool ShowEncounterBall { get; set; } = true;
}
[Serializable]