mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-26 22:10:21 +00:00
35bf97eaf1
Shows on all tabs to make it clear. Obviously, status condition is only saved in formats that save status condition in their slot's resting format. Gen3 box mons won't store Burn, etc.
100 lines
2.8 KiB
C#
100 lines
2.8 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
|
|
using PKHeX.Core;
|
|
using PKHeX.Drawing.PokeSprite;
|
|
using PKHeX.WinForms.Controls;
|
|
|
|
namespace PKHeX.WinForms;
|
|
|
|
public partial class StatusBrowser : Form
|
|
{
|
|
public bool WasChosen { get; private set; }
|
|
public StatusCondition Choice { get; private set; }
|
|
|
|
private const int StatusHeight = 24;
|
|
private const int StatusWidth = StatusHeight * 2;
|
|
private const int StatusCount = 7;
|
|
private const int StatusBrowserWidth = StatusWidth * 2;
|
|
|
|
public StatusBrowser()
|
|
{
|
|
InitializeComponent();
|
|
NUD_Sleep = new NumericUpDown
|
|
{
|
|
Minimum = 1,
|
|
Maximum = 7,
|
|
Value = 1,
|
|
Width = StatusWidth,
|
|
TextAlign = HorizontalAlignment.Center,
|
|
Margin = Padding.Empty,
|
|
Padding = Padding.Empty,
|
|
};
|
|
|
|
Add(GetImage(StatusCondition.None, "None"));
|
|
Add(GetImage(StatusCondition.Sleep1, "Sleep"), false);
|
|
Add(NUD_Sleep);
|
|
Add(GetImage(StatusCondition.Poison, "Poison"));
|
|
Add(GetImage(StatusCondition.Burn, "Burn"));
|
|
Add(GetImage(StatusCondition.Paralysis, "Paralysis"));
|
|
Add(GetImage(StatusCondition.Freeze, "Freeze"));
|
|
Add(GetImage(StatusCondition.PoisonBad, "Toxic"));
|
|
|
|
Height = StatusCount * StatusHeight;
|
|
Width = StatusBrowserWidth;
|
|
}
|
|
|
|
private readonly NumericUpDown NUD_Sleep;
|
|
|
|
private void Add(Control c, bool flowBreak = true)
|
|
{
|
|
flp.Controls.Add(c);
|
|
if (flowBreak)
|
|
flp.SetFlowBreak(c, true);
|
|
}
|
|
|
|
public void LoadList(PKM pk)
|
|
{
|
|
var condition = (StatusCondition)pk.Status_Condition;
|
|
NUD_Sleep.Value = Math.Max(1, (int)condition & 7);
|
|
Text = condition.ToString();
|
|
}
|
|
|
|
private SelectablePictureBox GetImage(StatusCondition value, string name)
|
|
{
|
|
var color = value.GetStatusColor();
|
|
var pb = new SelectablePictureBox
|
|
{
|
|
BackColor = color,
|
|
Name = name,
|
|
AccessibleDescription = name,
|
|
AccessibleName = name,
|
|
AccessibleRole = AccessibleRole.Graphic,
|
|
Margin = Padding.Empty,
|
|
Padding = Padding.Empty,
|
|
Width = StatusWidth,
|
|
Height = StatusHeight,
|
|
};
|
|
|
|
pb.MouseEnter += (_, _) => Text = name;
|
|
pb.Click += (_, _) =>
|
|
{
|
|
if (value is StatusCondition.Sleep1)
|
|
value = (StatusCondition)NUD_Sleep.Value;
|
|
SelectValue(value);
|
|
};
|
|
pb.KeyDown += (_, e) =>
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
SelectValue(value);
|
|
};
|
|
return pb;
|
|
}
|
|
|
|
private void SelectValue(StatusCondition value)
|
|
{
|
|
Choice = value;
|
|
WasChosen = true;
|
|
Close();
|
|
}
|
|
}
|