2023-04-04 21:22:49 +00:00
|
|
|
using System;
|
2023-01-22 04:02:33 +00:00
|
|
|
using System.Windows.Forms;
|
|
|
|
using PKHeX.Core;
|
2023-04-04 21:22:49 +00:00
|
|
|
using PKHeX.Drawing.Misc;
|
2023-01-22 04:02:33 +00:00
|
|
|
|
|
|
|
namespace PKHeX.WinForms.Controls;
|
|
|
|
|
|
|
|
public partial class MoveChoice : UserControl
|
|
|
|
{
|
2023-04-04 21:22:49 +00:00
|
|
|
private EntityContext Context;
|
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
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; }
|
2023-04-04 21:22:49 +00:00
|
|
|
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);
|
2024-01-04 21:41:38 +00:00
|
|
|
PB_Type.Image = TypeSpriteUtil.GetTypeSpriteIconSmall(type);
|
2023-04-04 21:22:49 +00:00
|
|
|
}
|
2023-01-22 04:02:33 +00:00
|
|
|
|
|
|
|
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;
|
2023-11-15 03:36:11 +00:00
|
|
|
PB_Triangle.Image = MoveDisplayState.GetMoveImage(!move.Valid, entity, i);
|
2023-01-22 04:02:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void HealPP(PKM pk)
|
|
|
|
{
|
|
|
|
var move = SelectedMove;
|
|
|
|
PP = move <= 0 ? (PPUps = 0) : pk.GetMovePP(move, PPUps);
|
|
|
|
}
|
2023-04-04 21:22:49 +00:00
|
|
|
|
|
|
|
private void CB_Move_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
var value = WinFormsUtil.GetIndex(CB_Move);
|
|
|
|
UpdateTypeSprite(value);
|
|
|
|
}
|
2023-01-22 04:02:33 +00:00
|
|
|
}
|