2023-11-09 07:32:41 +00:00
|
|
|
using System;
|
2019-10-04 01:23:40 +00:00
|
|
|
using System.Text;
|
|
|
|
using PKHeX.Core;
|
2023-11-09 07:32:41 +00:00
|
|
|
using static PKHeX.Core.Species;
|
2019-10-04 01:23:40 +00:00
|
|
|
|
2021-12-10 08:15:04 +00:00
|
|
|
namespace PKHeX.Drawing.PokeSprite;
|
|
|
|
|
|
|
|
public static class SpriteName
|
2019-10-04 01:23:40 +00:00
|
|
|
{
|
2021-12-10 08:15:04 +00:00
|
|
|
public static bool AllowShinySprite { get; set; }
|
2019-10-04 01:23:40 +00:00
|
|
|
|
2021-12-10 08:15:04 +00:00
|
|
|
private const char Separator = '_';
|
|
|
|
private const char Cosplay = 'c';
|
|
|
|
private const char Shiny = 's';
|
|
|
|
private const char GGStarter = 'p';
|
2019-10-04 01:23:40 +00:00
|
|
|
|
2021-12-10 08:15:04 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the resource name of the <see cref="Ball"/> sprite.
|
|
|
|
/// </summary>
|
|
|
|
public static string GetResourceStringBall(int ball) => $"_ball{ball}";
|
2019-10-04 01:23:40 +00:00
|
|
|
|
2021-12-10 08:15:04 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the resource name of the Pokémon sprite.
|
|
|
|
/// </summary>
|
2022-12-18 08:16:29 +00:00
|
|
|
public static string GetResourceStringSprite(ushort species, byte form, int gender, uint formarg, EntityContext context = PKX.Context, bool shiny = false)
|
2021-12-10 08:15:04 +00:00
|
|
|
{
|
|
|
|
if (SpeciesDefaultFormSprite.Contains(species)) // Species who show their default sprite regardless of Form
|
|
|
|
form = 0;
|
2019-10-04 01:23:40 +00:00
|
|
|
|
2021-12-10 08:15:04 +00:00
|
|
|
var sb = new StringBuilder(12); // longest expected string result
|
|
|
|
sb.Append(Separator).Append(species);
|
2019-10-04 01:23:40 +00:00
|
|
|
|
2021-12-10 08:15:04 +00:00
|
|
|
if (form != 0)
|
|
|
|
{
|
|
|
|
sb.Append(Separator).Append(form);
|
2019-10-04 01:23:40 +00:00
|
|
|
|
2023-11-09 07:32:41 +00:00
|
|
|
if (species == (ushort)Pikachu)
|
2021-12-10 08:15:04 +00:00
|
|
|
{
|
2022-12-18 08:16:29 +00:00
|
|
|
if (context == EntityContext.Gen6)
|
2019-10-04 01:23:40 +00:00
|
|
|
{
|
2021-12-10 08:15:04 +00:00
|
|
|
sb.Append(Cosplay);
|
|
|
|
gender = 1; // Cosplay Pikachu gift can only be Female, but personal entries are set to be either Gender
|
2019-10-04 01:23:40 +00:00
|
|
|
}
|
2021-12-10 08:15:04 +00:00
|
|
|
else if (form == 8)
|
2019-10-04 01:23:40 +00:00
|
|
|
{
|
2021-12-10 08:15:04 +00:00
|
|
|
sb.Append(GGStarter);
|
2019-10-04 01:23:40 +00:00
|
|
|
}
|
|
|
|
}
|
2023-11-09 07:32:41 +00:00
|
|
|
else if (species == (ushort)Eevee)
|
2020-03-04 04:22:57 +00:00
|
|
|
{
|
2021-12-10 08:15:04 +00:00
|
|
|
if (form == 1)
|
|
|
|
sb.Append(GGStarter);
|
2020-03-04 04:22:57 +00:00
|
|
|
}
|
2019-10-04 01:23:40 +00:00
|
|
|
}
|
2021-12-10 08:15:04 +00:00
|
|
|
if (gender == 1 && SpeciesGenderedSprite.Contains(species))
|
2019-10-04 01:23:40 +00:00
|
|
|
{
|
2021-12-10 08:15:04 +00:00
|
|
|
sb.Append('f');
|
|
|
|
}
|
2019-10-04 01:23:40 +00:00
|
|
|
|
2023-11-09 07:32:41 +00:00
|
|
|
if (species == (ushort)Alcremie)
|
2019-10-04 01:23:40 +00:00
|
|
|
{
|
2021-12-10 08:15:04 +00:00
|
|
|
if (form == 0)
|
|
|
|
sb.Append(Separator).Append(form);
|
|
|
|
sb.Append(Separator).Append(formarg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shiny && AllowShinySprite)
|
|
|
|
sb.Append(Shiny);
|
|
|
|
return sb.ToString();
|
2019-10-04 01:23:40 +00:00
|
|
|
}
|
2021-12-10 08:15:04 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Species that show their default Species sprite regardless of current <see cref="PKM.Form"/>
|
|
|
|
/// </summary>
|
2023-11-09 07:32:41 +00:00
|
|
|
private static ReadOnlySpan<ushort> SpeciesDefaultFormSprite => new[]
|
2021-12-10 08:15:04 +00:00
|
|
|
{
|
2023-11-09 07:32:41 +00:00
|
|
|
(ushort)Mothim,
|
|
|
|
(ushort)Scatterbug,
|
|
|
|
(ushort)Spewpa,
|
|
|
|
(ushort)Rockruff,
|
|
|
|
(ushort)Mimikyu,
|
|
|
|
(ushort)Sinistea,
|
|
|
|
(ushort)Polteageist,
|
|
|
|
(ushort)Urshifu,
|
|
|
|
(ushort)Dudunsparce,
|
|
|
|
(ushort)Poltchageist,
|
|
|
|
(ushort)Sinistcha,
|
2021-12-10 08:15:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Species that show a <see cref="PKM.Gender"/> specific Sprite
|
|
|
|
/// </summary>
|
2023-11-09 07:32:41 +00:00
|
|
|
private static ReadOnlySpan<ushort> SpeciesGenderedSprite => new[]
|
2021-12-10 08:15:04 +00:00
|
|
|
{
|
2023-11-09 07:32:41 +00:00
|
|
|
(ushort)Pikachu,
|
|
|
|
(ushort)Hippopotas,
|
|
|
|
(ushort)Hippowdon,
|
|
|
|
(ushort)Unfezant,
|
|
|
|
(ushort)Frillish,
|
|
|
|
(ushort)Jellicent,
|
|
|
|
(ushort)Pyroar,
|
2021-12-10 08:15:04 +00:00
|
|
|
};
|
2019-10-04 01:23:40 +00:00
|
|
|
}
|