mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-16 21:38:40 +00:00
Relocate resource naming for sprite fetch to draw
This commit is contained in:
parent
39eedb1db2
commit
ffe3a4ba15
8 changed files with 119 additions and 99 deletions
|
@ -37,30 +37,6 @@ namespace PKHeX.Core
|
|||
358, // Chimecho
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Species that show their default Species sprite regardless of current <see cref="PKM.AltForm"/>
|
||||
/// </summary>
|
||||
public static readonly HashSet<int> SpeciesDefaultFormSprite = new HashSet<int>
|
||||
{
|
||||
414, // Mothim
|
||||
493, // Arceus
|
||||
664, // Scatterbug
|
||||
665, // Spewpa
|
||||
773, // Silvally
|
||||
778, // Mimikyu
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Species that show a <see cref="PKM.Gender"/> specific Sprite
|
||||
/// </summary>
|
||||
public static readonly HashSet<int> SpeciesGenderedSprite = new HashSet<int>
|
||||
{
|
||||
521, // Unfezant
|
||||
592, // Frillish
|
||||
593, // Jellicent
|
||||
668, // Pyroar
|
||||
};
|
||||
|
||||
public static readonly HashSet<int> FormChange = new HashSet<int> // Pokémon that can change form and retain it
|
||||
{
|
||||
386, // Deoxys
|
||||
|
|
|
@ -418,36 +418,6 @@ namespace PKHeX.Core
|
|||
}
|
||||
}
|
||||
|
||||
// Data Requests
|
||||
public static string GetResourceStringBall(int ball) => $"_ball{ball}";
|
||||
private const string ResourceSeparator = "_";
|
||||
private const string ResourcePikachuCosplay = "c"; // osplay
|
||||
private const string ResourceShiny = "s"; // hiny
|
||||
private const string ResourceGGStarter = "p"; //artner
|
||||
public static bool AllowShinySprite { get; set; }
|
||||
|
||||
public static string GetResourceStringSprite(int species, int form, int gender, int generation = Generation, bool shiny = false)
|
||||
{
|
||||
if (Legal.SpeciesDefaultFormSprite.Contains(species)) // Species who show their default sprite regardless of Form
|
||||
form = 0;
|
||||
|
||||
var sb = new System.Text.StringBuilder();
|
||||
{ sb.Append(ResourceSeparator); sb.Append(species); }
|
||||
if (form > 0)
|
||||
{ sb.Append(ResourceSeparator); sb.Append(form); }
|
||||
else if (gender == 1 && Legal.SpeciesGenderedSprite.Contains(species)) // Frillish & Jellicent, Unfezant & Pyroar
|
||||
{ sb.Append(ResourceSeparator); sb.Append(gender); }
|
||||
|
||||
if (species == 25 && form > 0 && generation == 6) // Cosplay Pikachu
|
||||
sb.Append(ResourcePikachuCosplay);
|
||||
else if (GameVersion.GG.Contains(PKMConverter.Trainer.Game) && (species == 25 || species == 133) && form != 0)
|
||||
sb.Append(ResourceGGStarter);
|
||||
|
||||
if (shiny && AllowShinySprite)
|
||||
sb.Append(ResourceShiny);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Unown Forme ID from PID.
|
||||
/// </summary>
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
using static PKHeX.Core.GameVersion;
|
||||
using PKHeX.Core;
|
||||
|
||||
namespace PKHeX.Core
|
||||
using static PKHeX.Core.GameVersion;
|
||||
|
||||
namespace PKHeX.Drawing
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves Box Storage wallpaper metadata.
|
||||
|
@ -9,7 +11,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
public static string GetWallpaperResourceName(GameVersion version, int index)
|
||||
{
|
||||
index++;
|
||||
index++; // start indexes at 1
|
||||
var suffix = GetResourceSuffix(version, index);
|
||||
return $"box_wp{index:00}{suffix}";
|
||||
}
|
||||
|
@ -54,52 +56,42 @@ namespace PKHeX.Core
|
|||
case 3:
|
||||
if (CXD.Contains(version))
|
||||
return wallpaperID == 7; // flame pattern in XD
|
||||
switch (wallpaperID)
|
||||
|
||||
return wallpaperID switch
|
||||
{
|
||||
case 5: // Volcano
|
||||
return true;
|
||||
case 13: // PokéCenter
|
||||
return E == version;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
5 => true, // Volcano
|
||||
13 => E == version, // PokéCenter
|
||||
_ => false,
|
||||
};
|
||||
case 4:
|
||||
switch (wallpaperID)
|
||||
return wallpaperID switch
|
||||
{
|
||||
case 5: // Volcano
|
||||
case 12: // Checks
|
||||
case 13: // PokéCenter
|
||||
case 22: // Special
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
5 => true, // Volcano
|
||||
12 => true, // Checks
|
||||
13 => true, // PokéCenter
|
||||
22 => true, // Special
|
||||
_ => false
|
||||
};
|
||||
case 5:
|
||||
switch (wallpaperID)
|
||||
return wallpaperID switch
|
||||
{
|
||||
case 5: // Volcano
|
||||
case 12: // Checks
|
||||
return true;
|
||||
case 19: // PWT
|
||||
case 22: // Reshiram
|
||||
return B2W2.Contains(version);
|
||||
case 21: // Zoroark
|
||||
case 23: // Musical
|
||||
return BW.Contains(version);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
5 => true, // Volcano
|
||||
12 => true, // Checks
|
||||
19 => B2W2.Contains(version), // PWT
|
||||
22 => B2W2.Contains(version), // Reshiram
|
||||
21 => BW.Contains(version), // Zoroark
|
||||
23 => BW.Contains(version), // Musical
|
||||
_ => false
|
||||
};
|
||||
case 6:
|
||||
case 7:
|
||||
switch (wallpaperID)
|
||||
return wallpaperID switch
|
||||
{
|
||||
case 5: // Volcano
|
||||
case 12: // PokéCenter
|
||||
case 20: // Special5 Flare/Magma
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
5 => true, // Volcano
|
||||
12 => true, // PokéCenter
|
||||
20 => true, // Special5 Flare/Magma
|
||||
_ => false
|
||||
};
|
||||
case 8: // todo swsh
|
||||
return true;
|
||||
default:
|
81
PKHeX.Drawing/Names/SpriteName.cs
Normal file
81
PKHeX.Drawing/Names/SpriteName.cs
Normal file
|
@ -0,0 +1,81 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using PKHeX.Core;
|
||||
|
||||
namespace PKHeX.Drawing
|
||||
{
|
||||
public static class SpriteName
|
||||
{
|
||||
public static bool AllowShinySprite { get; set; }
|
||||
|
||||
private const string Separator = "_";
|
||||
private const string Cosplay = "c";
|
||||
private const string Shiny = "s";
|
||||
private const string GGStarter = "p";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the resource name of the <see cref="Ball"/> sprite.
|
||||
/// </summary>
|
||||
public static string GetResourceStringBall(int ball) => $"_ball{ball}";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the resource name of the Pokémon sprite.
|
||||
/// </summary>
|
||||
public static string GetResourceStringSprite(int species, int form, int gender, int generation = PKX.Generation, bool shiny = false)
|
||||
{
|
||||
if (SpeciesDefaultFormSprite.Contains(species)) // Species who show their default sprite regardless of Form
|
||||
form = 0;
|
||||
|
||||
var sb = new StringBuilder();
|
||||
{ sb.Append(Separator); sb.Append(species); }
|
||||
|
||||
if (form != 0)
|
||||
{
|
||||
sb.Append(Separator); sb.Append(form);
|
||||
|
||||
if (species == (int) Species.Pikachu)
|
||||
{
|
||||
if (generation == 6)
|
||||
sb.Append(Cosplay);
|
||||
else if (form == 8)
|
||||
sb.Append(GGStarter);
|
||||
}
|
||||
else if (species == (int) Species.Eevee)
|
||||
{
|
||||
if (form == 1)
|
||||
sb.Append(GGStarter);
|
||||
}
|
||||
}
|
||||
else if (gender == 1 && SpeciesGenderedSprite.Contains(species))
|
||||
{ sb.Append(Separator); sb.Append(gender); }
|
||||
|
||||
if (shiny && AllowShinySprite)
|
||||
sb.Append(Shiny);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Species that show their default Species sprite regardless of current <see cref="PKM.AltForm"/>
|
||||
/// </summary>
|
||||
private static readonly HashSet<int> SpeciesDefaultFormSprite = new HashSet<int>
|
||||
{
|
||||
(int)Species.Mothim,
|
||||
(int)Species.Arceus,
|
||||
(int)Species.Scatterbug,
|
||||
(int)Species.Spewpa,
|
||||
(int)Species.Silvally,
|
||||
(int)Species.Mimikyu,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Species that show a <see cref="PKM.Gender"/> specific Sprite
|
||||
/// </summary>
|
||||
private static readonly HashSet<int> SpeciesGenderedSprite = new HashSet<int>
|
||||
{
|
||||
(int)Species.Unfezant,
|
||||
(int)Species.Frillish,
|
||||
(int)Species.Jellicent,
|
||||
(int)Species.Pyroar,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -81,7 +81,7 @@ namespace PKHeX.Drawing
|
|||
|
||||
private static Image GetBaseImageDefault(int species, int form, int gender, bool shiny, int generation)
|
||||
{
|
||||
var file = PKX.GetResourceStringSprite(species, form, gender, generation, shiny);
|
||||
var file = SpriteName.GetResourceStringSprite(species, form, gender, generation, shiny);
|
||||
return (Image)Resources.ResourceManager.GetObject(file);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace PKHeX.Drawing
|
|||
|
||||
public static Image GetBallSprite(int ball)
|
||||
{
|
||||
string resource = PKX.GetResourceStringBall(ball);
|
||||
string resource = SpriteName.GetResourceStringBall(ball);
|
||||
return (Image)Resources.ResourceManager.GetObject(resource) ?? Resources._ball4; // Poké Ball (default)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.IO;
|
||||
using System.Media;
|
||||
using PKHeX.Core;
|
||||
using PKHeX.Drawing;
|
||||
|
||||
namespace PKHeX.WinForms.Controls
|
||||
{
|
||||
|
@ -26,7 +27,7 @@ namespace PKHeX.WinForms.Controls
|
|||
|
||||
private static string GetCryPath(PKM pk, string cryFolder)
|
||||
{
|
||||
var name = PKX.GetResourceStringSprite(pk.Species, pk.AltForm, pk.Gender, pk.Format).Replace('_', '-').Substring(1);
|
||||
var name = SpriteName.GetResourceStringSprite(pk.Species, pk.AltForm, pk.Gender, pk.Format).Replace('_', '-').Substring(1);
|
||||
var path = Path.Combine(cryFolder, $"{name}.wav");
|
||||
if (!File.Exists(path))
|
||||
path = Path.Combine(cryFolder, $"{pk.Species}.wav");
|
||||
|
|
|
@ -428,7 +428,7 @@ namespace PKHeX.WinForms
|
|||
Draw.LoadBrushes();
|
||||
PKME_Tabs.Unicode = Unicode = settings.Unicode;
|
||||
PKME_Tabs.UpdateUnicode(GenderSymbols);
|
||||
PKX.AllowShinySprite = settings.ShinySprites;
|
||||
SpriteName.AllowShinySprite = settings.ShinySprites;
|
||||
SaveFile.SetUpdateDex = settings.SetUpdateDex ? PKMImportSetting.Update : PKMImportSetting.Skip;
|
||||
SaveFile.SetUpdatePKM = settings.SetUpdatePKM ? PKMImportSetting.Update : PKMImportSetting.Skip;
|
||||
C_SAV.ModifyPKM = PKME_Tabs.ModifyPKM = settings.SetUpdatePKM;
|
||||
|
|
Loading…
Add table
Reference in a new issue