mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 14:44:24 +00:00
Fix off-by-1 for Hidden Power hover preview card
This commit is contained in:
parent
50209c4f0d
commit
9897630b08
2 changed files with 19 additions and 2 deletions
|
@ -71,6 +71,23 @@ public static class HiddenPower
|
|||
/// </summary>
|
||||
public const int TypeCount = 16;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Type Name index of the input Hidden Power Type
|
||||
/// </summary>
|
||||
/// <param name="type">Fetched Hidden Power Type</param>
|
||||
/// <param name="index">Type Name index</param>
|
||||
/// <returns>True if the input Hidden Power Type is valid</returns>
|
||||
public static bool TryGetTypeIndex(int type, out byte index)
|
||||
{
|
||||
if ((uint)type >= TypeCount)
|
||||
{
|
||||
index = default;
|
||||
return false;
|
||||
}
|
||||
index = (byte)(type + 1); // Normal type is not a valid Hidden Power type
|
||||
return true;
|
||||
}
|
||||
|
||||
private static ReadOnlySpan<byte> SixBitType =>
|
||||
[
|
||||
// (low-bit mash) * 15 / 63
|
||||
|
|
|
@ -23,8 +23,8 @@ public partial class MoveDisplay : UserControl
|
|||
var name = moves[move];
|
||||
if (move == (int)Core.Move.HiddenPower && pk.Context is not EntityContext.Gen8a)
|
||||
{
|
||||
type = (byte)pk.HPType;
|
||||
name = $"{name} ({GameInfo.Strings.types[type]}) [{pk.HPPower}]";
|
||||
if (HiddenPower.TryGetTypeIndex(pk.HPType, out type))
|
||||
name = $"{name} ({GameInfo.Strings.types[type]}) [{pk.HPPower}]";
|
||||
}
|
||||
|
||||
var size = PokePreview.MeasureSize(name, L_Move.Font);
|
||||
|
|
Loading…
Reference in a new issue