mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 06:34:19 +00:00
Always use white outlines on box shiny icons
This commit is contained in:
parent
8f64f719ad
commit
376e8f2d4f
7 changed files with 16 additions and 100 deletions
|
@ -10,15 +10,13 @@ public interface ISpriteBuilder<T>
|
|||
/// Gets a sprite using the requested parameters.
|
||||
/// </summary>
|
||||
T GetSprite(ushort species, byte form, int gender, uint formarg, int heldItem, bool isEgg, Shiny shiny,
|
||||
EntityContext context = EntityContext.None,
|
||||
SpriteBuilderTweak tweak = SpriteBuilderTweak.None);
|
||||
EntityContext context = EntityContext.None);
|
||||
|
||||
/// <summary>
|
||||
/// Revises the sprite using the requested parameters.
|
||||
/// </summary>
|
||||
T GetSprite(T baseSprite, ushort species, int heldItem, bool isEgg, Shiny shiny,
|
||||
EntityContext context = EntityContext.None,
|
||||
SpriteBuilderTweak tweak = SpriteBuilderTweak.None);
|
||||
EntityContext context = EntityContext.None);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the implementation with the context details from the <see cref="sav"/>.
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace PKHeX.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Flags to tweak behavior of the sprite builder for the destination display.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum SpriteBuilderTweak
|
||||
{
|
||||
None = 0,
|
||||
BoxBackgroundRed = 1,
|
||||
}
|
|
@ -105,7 +105,7 @@ public abstract class SpriteBuilder : ISpriteBuilder<Image>
|
|||
/// <param name="shiny">Is it shiny</param>
|
||||
/// <param name="context">Context the sprite is for</param>
|
||||
/// <param name="tweak"></param>
|
||||
public Image GetSprite(ushort species, byte form, int gender, uint formarg, int heldItem, bool isEgg, Shiny shiny = Shiny.Never, EntityContext context = EntityContext.None, SpriteBuilderTweak tweak = SpriteBuilderTweak.None)
|
||||
public Image GetSprite(ushort species, byte form, int gender, uint formarg, int heldItem, bool isEgg, Shiny shiny = Shiny.Never, EntityContext context = EntityContext.None)
|
||||
{
|
||||
if (species == 0)
|
||||
return None;
|
||||
|
@ -116,10 +116,10 @@ public abstract class SpriteBuilder : ISpriteBuilder<Image>
|
|||
form = GetArceusForm4(form);
|
||||
|
||||
var baseImage = GetBaseImage(species, form, gender, formarg, shiny.IsShiny(), context);
|
||||
return GetSprite(baseImage, species, heldItem, isEgg, shiny, context, tweak);
|
||||
return GetSprite(baseImage, species, heldItem, isEgg, shiny, context);
|
||||
}
|
||||
|
||||
public Image GetSprite(Image baseSprite, ushort species, int heldItem, bool isEgg, Shiny shiny, EntityContext context = EntityContext.None, SpriteBuilderTweak tweak = SpriteBuilderTweak.None)
|
||||
public Image GetSprite(Image baseSprite, ushort species, int heldItem, bool isEgg, Shiny shiny, EntityContext context = EntityContext.None)
|
||||
{
|
||||
if (isEgg)
|
||||
baseSprite = LayerOverImageEgg(baseSprite, species, heldItem != 0);
|
||||
|
@ -129,7 +129,7 @@ public abstract class SpriteBuilder : ISpriteBuilder<Image>
|
|||
{
|
||||
if (shiny == Shiny.AlwaysSquare && context.Generation() != 8)
|
||||
shiny = Shiny.Always;
|
||||
baseSprite = LayerOverImageShiny(baseSprite, tweak, shiny);
|
||||
baseSprite = LayerOverImageShiny(baseSprite, shiny);
|
||||
}
|
||||
return baseSprite;
|
||||
}
|
||||
|
@ -195,24 +195,14 @@ public abstract class SpriteBuilder : ISpriteBuilder<Image>
|
|||
return ImageUtil.LayerImage(baseImage, itemimg, x, y);
|
||||
}
|
||||
|
||||
private static Image LayerOverImageShiny(Image baseImage, SpriteBuilderTweak tweak, Shiny shiny)
|
||||
private static Image LayerOverImageShiny(Image baseImage, Shiny shiny)
|
||||
{
|
||||
// Add shiny star to top left of image.
|
||||
Bitmap rare;
|
||||
if (shiny is Shiny.AlwaysSquare)
|
||||
{
|
||||
if (tweak.HasFlag(SpriteBuilderTweak.BoxBackgroundRed))
|
||||
rare = Resources.rare_icon_alt_2;
|
||||
else
|
||||
rare = Resources.rare_icon_2;
|
||||
}
|
||||
rare = Resources.rare_icon_alt_2;
|
||||
else
|
||||
{
|
||||
if (tweak.HasFlag(SpriteBuilderTweak.BoxBackgroundRed))
|
||||
rare = Resources.rare_icon_alt;
|
||||
else
|
||||
rare = Resources.rare_icon;
|
||||
}
|
||||
rare = Resources.rare_icon_alt;
|
||||
return ImageUtil.LayerImage(baseImage, rare, 0, 0, ShinyTransparency);
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.2 KiB |
|
@ -1,56 +0,0 @@
|
|||
using PKHeX.Core;
|
||||
using static PKHeX.Core.EntityContext;
|
||||
|
||||
namespace PKHeX.Drawing.PokeSprite;
|
||||
|
||||
internal static class BoxWallpaper
|
||||
{
|
||||
public static bool IsWallpaperRed(this SaveFile sav, int box) => IsWallpaperRed(sav.Context, sav.Version, sav.GetBoxWallpaper(box));
|
||||
|
||||
public static bool IsWallpaperRed(EntityContext context, GameVersion version, int wallpaperID) => context switch
|
||||
{
|
||||
Gen3 when GameVersion.CXD.Contains(version) => wallpaperID == 7, // flame pattern in XD
|
||||
Gen3 => wallpaperID switch
|
||||
{
|
||||
5 => true, // Volcano
|
||||
13 => version == GameVersion.E, // PokéCenter
|
||||
_ => false,
|
||||
},
|
||||
Gen4 => wallpaperID switch
|
||||
{
|
||||
5 => true, // Volcano
|
||||
12 => true, // Checks
|
||||
13 => true, // PokéCenter
|
||||
22 => true, // Special
|
||||
_ => false,
|
||||
},
|
||||
Gen5 => wallpaperID switch
|
||||
{
|
||||
5 => true, // Volcano
|
||||
12 => true, // Checks
|
||||
19 => GameVersion.B2W2.Contains(version), // PWT
|
||||
22 => GameVersion.B2W2.Contains(version), // Reshiram
|
||||
21 => GameVersion.BW.Contains(version), // Zoroark
|
||||
23 => GameVersion.BW.Contains(version), // Musical
|
||||
_ => false,
|
||||
},
|
||||
Gen6 or Gen7 => wallpaperID switch
|
||||
{
|
||||
5 => true, // Volcano
|
||||
12 => true, // PokéCenter
|
||||
20 => true, // Special5 Flare/Magma
|
||||
_ => false,
|
||||
},
|
||||
Gen8b => wallpaperID switch
|
||||
{
|
||||
6 => true, // Volcano
|
||||
15 => true, // Checks
|
||||
21 => true, // Trio
|
||||
29 => true, // Nostalgic (Platinum)
|
||||
30 => true, // Legend (Platinum)
|
||||
_ => false,
|
||||
},
|
||||
Gen8 or Gen9 => true, // Bad contrast with lots of void space, better to just highlight the shiny red.
|
||||
_ => false,
|
||||
};
|
||||
}
|
|
@ -59,22 +59,22 @@ public static class SpriteUtil
|
|||
|
||||
public static Image? GetItemSprite(int item) => Resources.ResourceManager.GetObject($"item_{item}") as Image;
|
||||
|
||||
public static Image GetSprite(ushort species, byte form, int gender, uint formarg, int item, bool isegg, Shiny shiny, EntityContext context = EntityContext.None, SpriteBuilderTweak tweak = SpriteBuilderTweak.None)
|
||||
public static Image GetSprite(ushort species, byte form, int gender, uint formarg, int item, bool isegg, Shiny shiny, EntityContext context = EntityContext.None)
|
||||
{
|
||||
return Spriter.GetSprite(species, form, gender, formarg, item, isegg, shiny, context, tweak);
|
||||
return Spriter.GetSprite(species, form, gender, formarg, item, isegg, shiny, context);
|
||||
}
|
||||
|
||||
private static Image GetSprite(PKM pk, SpriteBuilderTweak tweak = SpriteBuilderTweak.None)
|
||||
private static Image GetSprite(PKM pk)
|
||||
{
|
||||
var formarg = pk is IFormArgument f ? f.FormArgument : 0;
|
||||
var shiny = !pk.IsShiny ? Shiny.Never : (ShinyExtensions.IsSquareShinyExist(pk) ? Shiny.AlwaysSquare : Shiny.AlwaysStar);
|
||||
|
||||
var img = GetSprite(pk.Species, pk.Form, pk.Gender, formarg, pk.SpriteItem, pk.IsEgg, shiny, pk.Context, tweak);
|
||||
var img = GetSprite(pk.Species, pk.Form, pk.Gender, formarg, pk.SpriteItem, pk.IsEgg, shiny, pk.Context);
|
||||
if (pk is IShadowCapture {IsShadow: true})
|
||||
{
|
||||
const int Lugia = (int)Species.Lugia;
|
||||
if (pk.Species == Lugia) // show XD shadow sprite
|
||||
img = Spriter.GetSprite(Spriter.ShadowLugia, Lugia, pk.SpriteItem, pk.IsEgg, shiny, pk.Context, tweak);
|
||||
img = Spriter.GetSprite(Spriter.ShadowLugia, Lugia, pk.SpriteItem, pk.IsEgg, shiny, pk.Context);
|
||||
|
||||
GetSpriteGlow(pk, 75, 0, 130, out var pixels, out var baseSprite, true);
|
||||
var glowImg = ImageUtil.GetBitmap(pixels, baseSprite.Width, baseSprite.Height, baseSprite.PixelFormat);
|
||||
|
@ -97,10 +97,7 @@ public static class SpriteUtil
|
|||
{
|
||||
bool inBox = (uint)slot < MaxSlotCount;
|
||||
bool empty = pk.Species == 0;
|
||||
var tweak = inBox && sav.IsWallpaperRed(box)
|
||||
? SpriteBuilderTweak.BoxBackgroundRed
|
||||
: SpriteBuilderTweak.None;
|
||||
var sprite = empty ? Spriter.None : pk.Sprite(tweak: tweak);
|
||||
var sprite = empty ? Spriter.None : pk.Sprite();
|
||||
|
||||
if (!empty)
|
||||
{
|
||||
|
@ -244,7 +241,7 @@ public static class SpriteUtil
|
|||
public static Image GetLegalIndicator(bool valid) => valid ? Resources.valid : Resources.warn;
|
||||
|
||||
// Extension Methods
|
||||
public static Image Sprite(this PKM pk, SpriteBuilderTweak tweak = SpriteBuilderTweak.None) => GetSprite(pk, tweak);
|
||||
public static Image Sprite(this PKM pk) => GetSprite(pk);
|
||||
|
||||
public static Image Sprite(this IEncounterTemplate enc)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue