mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-04-26 10:44:07 -05:00
Remove unnecessary selection on launch (winforms bug?) Increase first column width so OT Version doesn't wrap to 2 lines. Remove some unused usings in other files (a result of color repointing to WinFormsUtil) ty @randomguy155 for the OnShown workaround Co-Authored-By: RandomGuy <69272011+RandomGuy155@users.noreply.github.com>
44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
using PKHeX.Core;
|
|
using PKHeX.Drawing.Misc;
|
|
|
|
namespace PKHeX.WinForms.Controls;
|
|
|
|
public partial class MoveDisplay : UserControl
|
|
{
|
|
public MoveDisplay() => InitializeComponent();
|
|
|
|
public int Populate(PKM pk, GameStrings strings, ushort move, EntityContext context, ReadOnlySpan<string> moves, bool valid = true)
|
|
{
|
|
if (move == 0 || move >= moves.Length)
|
|
{
|
|
Visible = false;
|
|
return 0;
|
|
}
|
|
Visible = true;
|
|
|
|
byte type = MoveInfo.GetType(move, context);
|
|
var name = moves[move];
|
|
if (move == (int)Core.Move.HiddenPower && pk.Context is not EntityContext.Gen8a)
|
|
{
|
|
if (HiddenPower.TryGetTypeIndex(pk.HPType, out type))
|
|
name = $"{name} ({strings.types[type]}) [{pk.HPPower}]";
|
|
}
|
|
|
|
var size = PokePreview.MeasureSize(name, L_Move.Font);
|
|
var ctrlWidth = PB_Type.Width + PB_Type.Margin.Horizontal + size.Width + L_Move.Margin.Horizontal;
|
|
|
|
PB_Type.Image = TypeSpriteUtil.GetTypeSpriteIconSmall(type);
|
|
L_Move.Text = name;
|
|
if (valid)
|
|
L_Move.ResetForeColor();
|
|
else
|
|
L_Move.ForeColor = WinFormsUtil.ColorWarn;
|
|
L_Move.Width = size.Width;
|
|
Width = ctrlWidth;
|
|
|
|
return ctrlWidth;
|
|
}
|
|
}
|