mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-04 01:39:13 +00:00
aeb6595887
Note this is only SV types, so moves that had their type changed (=>dark/steel/fairy) will be inaccurate in past game formats. Would need time to dump the info.
68 lines
1.9 KiB
C#
68 lines
1.9 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
using PKHeX.Core;
|
|
using PKHeX.Drawing.Misc;
|
|
|
|
namespace PKHeX.WinForms.Controls;
|
|
|
|
public partial class MoveChoice : UserControl
|
|
{
|
|
private EntityContext Context;
|
|
|
|
public MoveChoice()
|
|
{
|
|
InitializeComponent();
|
|
CB_Move.InitializeBinding();
|
|
}
|
|
|
|
public ushort SelectedMove { get => (ushort)WinFormsUtil.GetIndex(CB_Move); set => CB_Move.SelectedValue = (int)value; }
|
|
public int PP { get => SelectedMove == 0 ? 0 : Util.ToInt32(TB_PP.Text); set => TB_PP.Text = value.ToString(); }
|
|
public int PPUps { get => SelectedMove == 0 ? 0 : CB_PPUps.SelectedIndex; set => LoadClamp(CB_PPUps, value); }
|
|
public bool HideLegality { private get; set; }
|
|
public void SetContext(EntityContext context) => Context = context;
|
|
|
|
private void UpdateTypeSprite(int value)
|
|
{
|
|
if (value <= 0)
|
|
{
|
|
PB_Type.Image = null;
|
|
return;
|
|
}
|
|
|
|
var type = MoveInfo.GetType((ushort)value, Context);
|
|
PB_Type.Image = TypeSpriteUtil.GetTypeSpriteIcon(type);
|
|
}
|
|
|
|
private static void LoadClamp(ComboBox cb, int value)
|
|
{
|
|
var max = cb.Items.Count - 1;
|
|
if (value > max)
|
|
value = max;
|
|
else if (value < -1)
|
|
value = 0;
|
|
cb.SelectedIndex = value;
|
|
}
|
|
|
|
public void UpdateLegality(MoveResult move, PKM entity, int i)
|
|
{
|
|
if (HideLegality)
|
|
{
|
|
PB_Triangle.Visible = false;
|
|
return;
|
|
}
|
|
PB_Triangle.Visible = true;
|
|
PB_Triangle.Image = MoveDisplay.GetMoveImage(!move.Valid, entity, i);
|
|
}
|
|
|
|
public void HealPP(PKM pk)
|
|
{
|
|
var move = SelectedMove;
|
|
PP = move <= 0 ? (PPUps = 0) : pk.GetMovePP(move, PPUps);
|
|
}
|
|
|
|
private void CB_Move_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
var value = WinFormsUtil.GetIndex(CB_Move);
|
|
UpdateTypeSprite(value);
|
|
}
|
|
}
|