mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-22 18:33:14 +00:00
88830e0d00
Updates from net46->net7, dropping support for mono in favor of using the latest runtime (along with the performance/API improvements). Releases will be posted as 64bit only for now. Refactors a good amount of internal API methods to be more performant and more customizable for future updates & fixes. Adds functionality for Batch Editor commands to `>`, `<` and <=/>= TID/SID properties renamed to TID16/SID16 for clarity; other properties exposed for Gen7 / display variants. Main window has a new layout to account for DPI scaling (8 point grid) Fixed: Tatsugiri and Paldean Tauros now output Showdown form names as Showdown expects Changed: Gen9 species now interact based on the confirmed National Dex IDs (closes #3724) Fixed: Pokedex set all no longer clears species with unavailable non-base forms (closes #3720) Changed: Hyper Training suggestions now apply for level 50 in SV. (closes #3714) Fixed: B2/W2 hatched egg met locations exclusive to specific versions are now explicitly checked (closes #3691) Added: Properties for ribbon/mark count (closes #3659) Fixed: Traded SV eggs are now checked correctly (closes #3692)
62 lines
2 KiB
C#
62 lines
2 KiB
C#
using System;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
public static class EntityFileNamer
|
|
{
|
|
/// <summary>
|
|
/// Object that converts the <see cref="PKM"/> data into a <see cref="string"/> file name.
|
|
/// </summary>
|
|
public static IFileNamer<PKM> Namer { get; set; } = new DefaultEntityNamer();
|
|
|
|
/// <summary>
|
|
/// Gets the file name (without extension) for the input <see cref="pk"/> data.
|
|
/// </summary>
|
|
/// <param name="pk">Input entity to create a file name for.</param>
|
|
/// <returns>File name for the <see cref="pk"/> data</returns>
|
|
public static string GetName(PKM pk) => Namer.GetName(pk);
|
|
}
|
|
|
|
/// <summary>
|
|
/// PKHeX's default <see cref="PKM"/> file naming logic.
|
|
/// </summary>
|
|
public sealed class DefaultEntityNamer : IFileNamer<PKM>
|
|
{
|
|
public string GetName(PKM obj)
|
|
{
|
|
if (obj is GBPKM gb)
|
|
return GetGBPKM(gb);
|
|
return GetRegular(obj);
|
|
}
|
|
|
|
private static string GetRegular(PKM pk)
|
|
{
|
|
var chk = pk is ISanityChecksum s ? s.Checksum : PokeCrypto.GetCHK(pk.Data.AsSpan()[8..pk.SIZE_STORED]);
|
|
var form = pk.Form != 0 ? $"-{pk.Form:00}" : string.Empty;
|
|
var star = pk.IsShiny ? " ★" : string.Empty;
|
|
return $"{pk.Species:000}{form}{star} - {pk.Nickname} - {chk:X4}{pk.EncryptionConstant:X8}";
|
|
}
|
|
|
|
private static string GetGBPKM(GBPKM gb)
|
|
{
|
|
ReadOnlySpan<byte> raw = gb switch
|
|
{
|
|
PK1 pk1 => new PokeList1(pk1).Write(),
|
|
PK2 pk2 => new PokeList2(pk2).Write(),
|
|
_ => gb.Data,
|
|
};
|
|
var checksum = Checksums.CRC16_CCITT(raw);
|
|
var form = gb.Form != 0 ? $"-{gb.Form:00}" : string.Empty;
|
|
var star = gb.IsShiny ? " ★" : string.Empty;
|
|
return $"{gb.Species:000}{form}{star} - {gb.Nickname} - {checksum:X4}";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Exposes a method to get a file name (no extension) for the type.
|
|
/// </summary>
|
|
/// <typeparam name="T">Type that the implementer can create a file name for.</typeparam>
|
|
public interface IFileNamer<in T>
|
|
{
|
|
string GetName(T obj);
|
|
}
|