2018-02-27 05:22:35 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using PKHeX.Core;
|
2019-09-29 16:47:06 +00:00
|
|
|
|
using PKHeX.Drawing;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
|
|
|
|
|
namespace PKHeX.WinForms.Controls
|
|
|
|
|
{
|
|
|
|
|
public partial class StatEditor : UserControl
|
|
|
|
|
{
|
|
|
|
|
public StatEditor()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2018-11-14 03:21:14 +00:00
|
|
|
|
MT_IVs = new[] {TB_IVHP, TB_IVATK, TB_IVDEF, TB_IVSPE, TB_IVSPA, TB_IVSPD};
|
|
|
|
|
MT_EVs = new[] {TB_EVHP, TB_EVATK, TB_EVDEF, TB_EVSPE, TB_EVSPA, TB_EVSPD};
|
|
|
|
|
MT_AVs = new[] {TB_AVHP, TB_AVATK, TB_AVDEF, TB_AVSPE, TB_AVSPA, TB_AVSPD};
|
2022-02-05 01:36:51 +00:00
|
|
|
|
MT_GVs = new[] {TB_GVHP, TB_GVATK, TB_GVDEF, TB_GVSPE, TB_GVSPA, TB_GVSPD};
|
2018-02-27 05:22:35 +00:00
|
|
|
|
MT_Stats = new[] {Stat_HP, Stat_ATK, Stat_DEF, Stat_SPE, Stat_SPA, Stat_SPD};
|
|
|
|
|
L_Stats = new[] {Label_HP, Label_ATK, Label_DEF, Label_SPE, Label_SPA, Label_SPD};
|
2018-11-14 03:21:14 +00:00
|
|
|
|
MT_Base = new[] {TB_BaseHP, TB_BaseATK, TB_BaseDEF, TB_BaseSPE, TB_BaseSPA, TB_BaseSPD};
|
2018-03-18 17:38:29 +00:00
|
|
|
|
|
|
|
|
|
TB_BST.ResetForeColor();
|
|
|
|
|
TB_IVTotal.ForeColor = MT_EVs[0].ForeColor;
|
|
|
|
|
TB_EVTotal.ForeColor = MT_EVs[0].ForeColor;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-14 20:17:56 +00:00
|
|
|
|
public Color EVsInvalid { get; set; } = Color.Red;
|
|
|
|
|
public Color EVsMaxed { get; set; } = Color.Honeydew;
|
|
|
|
|
public Color EVsFishy { get; set; } = Color.LightYellow;
|
|
|
|
|
public Color StatIncreased { get; set; } = Color.Red;
|
|
|
|
|
public Color StatDecreased { get; set; } = Color.Blue;
|
|
|
|
|
public Color StatHyperTrained { get; set; } = Color.LightGreen;
|
|
|
|
|
|
2020-10-18 18:02:39 +00:00
|
|
|
|
public IMainEditor MainEditor { private get; set; } = null!;
|
2019-01-03 02:49:36 +00:00
|
|
|
|
public bool HaX { set => CHK_HackedStats.Enabled = CHK_HackedStats.Visible = value; }
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-11-14 03:21:14 +00:00
|
|
|
|
public bool Valid
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Format < 3)
|
2018-11-14 03:21:14 +00:00
|
|
|
|
return true;
|
|
|
|
|
if (CHK_HackedStats.Checked)
|
|
|
|
|
return true;
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity is IAwakened a)
|
2018-11-14 03:21:14 +00:00
|
|
|
|
return a.AwakeningAllValid();
|
|
|
|
|
return Convert.ToUInt32(TB_EVTotal.Text) <= 510;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-02-27 05:22:35 +00:00
|
|
|
|
|
|
|
|
|
private readonly Label[] L_Stats;
|
2022-02-05 01:36:51 +00:00
|
|
|
|
private readonly MaskedTextBox[] MT_EVs, MT_IVs, MT_AVs, MT_GVs, MT_Stats, MT_Base;
|
2019-10-27 19:57:04 +00:00
|
|
|
|
private PKM Entity => MainEditor.Entity;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
|
|
|
|
|
private bool ChangingFields
|
|
|
|
|
{
|
|
|
|
|
get => MainEditor.ChangingFields;
|
|
|
|
|
set => MainEditor.ChangingFields = value;
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
private void ClickIV(object sender, EventArgs e)
|
|
|
|
|
{
|
2020-12-23 05:24:41 +00:00
|
|
|
|
if (sender is not MaskedTextBox t)
|
2018-02-27 05:22:35 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-05-26 23:59:47 +00:00
|
|
|
|
switch (ModifierKeys)
|
2018-02-27 05:22:35 +00:00
|
|
|
|
{
|
2020-05-26 23:59:47 +00:00
|
|
|
|
case Keys.Alt: // Min
|
|
|
|
|
t.Text = 0.ToString();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case Keys.Control: // Max
|
|
|
|
|
{
|
|
|
|
|
var index = Array.IndexOf(MT_IVs, t);
|
|
|
|
|
t.Text = Entity.GetMaximumIV(index, true).ToString();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case Keys.Shift when Entity is IHyperTrain h: // HT
|
|
|
|
|
{
|
|
|
|
|
var index = Array.IndexOf(MT_IVs, t);
|
|
|
|
|
bool flag = h.HyperTrainInvert(index);
|
|
|
|
|
UpdateHyperTrainingFlag(index, flag);
|
|
|
|
|
UpdateStats();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-02-27 05:22:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
private void ClickEV(object sender, EventArgs e)
|
|
|
|
|
{
|
2020-12-23 05:24:41 +00:00
|
|
|
|
if (sender is not MaskedTextBox t)
|
2018-02-27 05:22:35 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-05-26 23:59:47 +00:00
|
|
|
|
if ((ModifierKeys & Keys.Control) != 0) // Max
|
2018-02-27 05:22:35 +00:00
|
|
|
|
{
|
2020-05-26 23:59:47 +00:00
|
|
|
|
int index = Array.IndexOf(MT_EVs, t);
|
|
|
|
|
int newEV = Entity.GetMaximumEV(index);
|
|
|
|
|
t.Text = newEV.ToString();
|
|
|
|
|
}
|
|
|
|
|
else if ((ModifierKeys & Keys.Alt) != 0) // Min
|
|
|
|
|
{
|
|
|
|
|
t.Text = 0.ToString();
|
2018-02-27 05:22:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-11-14 03:21:14 +00:00
|
|
|
|
private void ClickAV(object sender, EventArgs e)
|
|
|
|
|
{
|
2020-12-23 05:24:41 +00:00
|
|
|
|
if (sender is not MaskedTextBox t)
|
2018-11-14 03:21:14 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-05-26 23:59:47 +00:00
|
|
|
|
if ((ModifierKeys & Keys.Control) != 0) // Max
|
2018-11-14 03:21:14 +00:00
|
|
|
|
{
|
2020-05-26 23:59:47 +00:00
|
|
|
|
var max = Legal.AwakeningMax.ToString();
|
|
|
|
|
t.Text = t.Text == max ? 0.ToString() : max;
|
|
|
|
|
}
|
|
|
|
|
else if ((ModifierKeys & Keys.Alt) != 0) // Min
|
|
|
|
|
{
|
|
|
|
|
t.Text = 0.ToString();
|
2018-11-14 03:21:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-05 01:36:51 +00:00
|
|
|
|
private void ClickGV(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (sender is not MaskedTextBox t || Entity is not IGanbaru g)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if ((ModifierKeys & Keys.Control) != 0) // Max
|
|
|
|
|
{
|
|
|
|
|
int index = Array.IndexOf(MT_GVs, t);
|
|
|
|
|
var max = g.GetMax(Entity, index).ToString();
|
|
|
|
|
t.Text = t.Text == max ? 0.ToString() : max;
|
|
|
|
|
}
|
|
|
|
|
else if ((ModifierKeys & Keys.Alt) != 0) // Min
|
|
|
|
|
{
|
|
|
|
|
t.Text = 0.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-11-14 03:21:14 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
public void UpdateIVs(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (sender is MaskedTextBox m)
|
|
|
|
|
{
|
|
|
|
|
int value = Util.ToInt32(m.Text);
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (value > Entity.MaxIV)
|
2018-02-27 05:22:35 +00:00
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
m.Text = Entity.MaxIV.ToString();
|
2018-02-27 05:22:35 +00:00
|
|
|
|
return; // recursive on text set
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int index = Array.IndexOf(MT_IVs, m);
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.SetIV(index, value);
|
2022-02-05 01:36:51 +00:00
|
|
|
|
if (Entity is IGanbaru g)
|
|
|
|
|
RefreshGanbaru(Entity, g, index);
|
2018-02-27 05:22:35 +00:00
|
|
|
|
}
|
|
|
|
|
RefreshDerivedValues(e);
|
|
|
|
|
UpdateStats();
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-18 18:02:39 +00:00
|
|
|
|
private void RefreshDerivedValues(object _)
|
2018-02-27 05:22:35 +00:00
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Format < 3)
|
2018-02-27 05:22:35 +00:00
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
TB_IVHP.Text = Entity.IV_HP.ToString();
|
|
|
|
|
TB_IVSPD.Text = Entity.IV_SPD.ToString();
|
2018-02-27 05:22:35 +00:00
|
|
|
|
|
2020-10-18 18:02:39 +00:00
|
|
|
|
MainEditor.UpdateIVsGB(false);
|
2018-02-27 05:22:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-02-28 01:48:19 +00:00
|
|
|
|
if (!ChangingFields)
|
|
|
|
|
{
|
|
|
|
|
ChangingFields = true;
|
2019-10-27 19:57:04 +00:00
|
|
|
|
CB_HPType.SelectedValue = Entity.HPType;
|
2020-09-15 03:06:11 +00:00
|
|
|
|
Label_HiddenPowerPower.Text = Entity.HPPower.ToString();
|
2018-02-28 01:48:19 +00:00
|
|
|
|
ChangingFields = false;
|
|
|
|
|
}
|
2018-02-27 05:22:35 +00:00
|
|
|
|
|
|
|
|
|
// Potential Reading
|
2019-10-27 19:57:04 +00:00
|
|
|
|
L_Potential.Text = Entity.GetPotentialString(MainEditor.Unicode);
|
2018-02-27 05:22:35 +00:00
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
TB_IVTotal.Text = Entity.IVTotal.ToString();
|
|
|
|
|
UpdateCharacteristic(Entity.Characteristic);
|
2018-02-27 05:22:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateEVs(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (sender is MaskedTextBox m)
|
|
|
|
|
{
|
|
|
|
|
int value = Util.ToInt32(m.Text);
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (value > Entity.MaxEV)
|
2018-02-27 05:22:35 +00:00
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
m.Text = Entity.MaxEV.ToString();
|
2018-02-27 05:22:35 +00:00
|
|
|
|
return; // recursive on text set
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int index = Array.IndexOf(MT_EVs, m);
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.SetEV(index, value);
|
2018-02-27 05:22:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UpdateEVTotals();
|
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Format < 3)
|
2018-02-27 05:22:35 +00:00
|
|
|
|
{
|
|
|
|
|
ChangingFields = true;
|
2018-11-14 03:21:14 +00:00
|
|
|
|
TB_EVSPD.Text = TB_EVSPA.Text;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
ChangingFields = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UpdateStats();
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-11-14 03:21:14 +00:00
|
|
|
|
private void UpdateAVs(object sender, EventArgs e)
|
|
|
|
|
{
|
2020-12-23 05:24:41 +00:00
|
|
|
|
if (Entity is not IAwakened a)
|
2018-11-14 03:21:14 +00:00
|
|
|
|
return;
|
|
|
|
|
if (sender is MaskedTextBox m)
|
|
|
|
|
{
|
|
|
|
|
int value = Util.ToInt32(m.Text);
|
|
|
|
|
if (value > Legal.AwakeningMax)
|
|
|
|
|
{
|
|
|
|
|
m.Text = Legal.AwakeningMax.ToString();
|
|
|
|
|
return; // recursive on text set
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int index = Array.IndexOf(MT_AVs, m);
|
|
|
|
|
a.SetAV(index, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UpdateAVTotals();
|
|
|
|
|
UpdateStats();
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-05 01:36:51 +00:00
|
|
|
|
private void UpdateGVs(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Entity is not IGanbaru g)
|
|
|
|
|
return;
|
|
|
|
|
if (sender is MaskedTextBox m)
|
|
|
|
|
{
|
|
|
|
|
int value = Util.ToInt32(m.Text);
|
|
|
|
|
if (value > GanbaruExtensions.TrueMax)
|
|
|
|
|
{
|
|
|
|
|
m.Text = GanbaruExtensions.TrueMax.ToString();
|
|
|
|
|
return; // recursive on text set
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int index = Array.IndexOf(MT_GVs, m);
|
|
|
|
|
g.SetGV(index, value);
|
|
|
|
|
RefreshGanbaru(Entity, g, index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UpdateStats();
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
private void UpdateRandomEVs(object sender, EventArgs e)
|
|
|
|
|
{
|
2021-01-21 06:09:25 +00:00
|
|
|
|
var evs = ModifierKeys switch
|
|
|
|
|
{
|
|
|
|
|
Keys.Control => SetMaxEVs(Entity),
|
|
|
|
|
Keys.Alt => new int[6],
|
|
|
|
|
_ => PKX.GetRandomEVs(Entity.Format),
|
|
|
|
|
};
|
2018-02-27 05:22:35 +00:00
|
|
|
|
LoadEVs(evs);
|
2020-10-18 18:02:39 +00:00
|
|
|
|
UpdateEVs(sender, EventArgs.Empty);
|
2021-01-21 06:09:25 +00:00
|
|
|
|
|
|
|
|
|
static int[] SetMaxEVs(PKM entity)
|
|
|
|
|
{
|
|
|
|
|
if (entity.Format < 3)
|
|
|
|
|
return Enumerable.Repeat((int) ushort.MaxValue, 6).ToArray();
|
|
|
|
|
|
|
|
|
|
var stats = entity.PersonalInfo.Stats;
|
|
|
|
|
var ordered = stats.Select((z, i) => new {Stat = z, Index = i}).OrderByDescending(z => z.Stat).ToArray();
|
|
|
|
|
|
|
|
|
|
var result = new int[6];
|
|
|
|
|
result[ordered[0].Index] = 252;
|
|
|
|
|
result[ordered[1].Index] = 252;
|
|
|
|
|
result[ordered[2].Index] = 6;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2018-02-27 05:22:35 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
private void UpdateHackedStats(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
foreach (var s in MT_Stats)
|
2018-03-19 15:10:20 +00:00
|
|
|
|
s.Enabled = CHK_HackedStats.Checked;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
if (!CHK_HackedStats.Checked)
|
|
|
|
|
UpdateStats();
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
private void UpdateHackedStatText(object sender, EventArgs e)
|
|
|
|
|
{
|
2020-12-23 05:24:41 +00:00
|
|
|
|
if (!CHK_HackedStats.Checked || sender is not TextBox tb)
|
2018-02-27 05:22:35 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
string text = tb.Text;
|
|
|
|
|
if (string.IsNullOrWhiteSpace(text))
|
|
|
|
|
tb.Text = "0";
|
2018-08-26 00:04:01 +00:00
|
|
|
|
else if (Convert.ToUInt32(text) > ushort.MaxValue)
|
2018-02-27 05:22:35 +00:00
|
|
|
|
tb.Text = "65535";
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2020-09-18 01:13:08 +00:00
|
|
|
|
private void UpdateHyperTrainingFlag(int index, bool value)
|
2018-02-27 05:22:35 +00:00
|
|
|
|
{
|
2020-09-18 01:13:08 +00:00
|
|
|
|
var tb = MT_IVs[index];
|
2018-02-27 05:22:35 +00:00
|
|
|
|
if (value)
|
2020-09-18 01:13:08 +00:00
|
|
|
|
tb.BackColor = StatHyperTrained;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
else
|
2020-09-18 01:13:08 +00:00
|
|
|
|
tb.ResetBackColor();
|
2018-02-27 05:22:35 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
private void UpdateHPType(object sender, EventArgs e)
|
|
|
|
|
{
|
2019-02-10 01:07:44 +00:00
|
|
|
|
if (ChangingFields)
|
2018-02-27 05:22:35 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Change IVs to match the new Hidden Power
|
2021-10-30 19:38:00 +00:00
|
|
|
|
var ivs = Entity.IVs;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
int hpower = WinFormsUtil.GetIndex(CB_HPType);
|
2021-10-30 19:38:00 +00:00
|
|
|
|
if (Main.Settings.EntityEditor.HiddenPowerOnChangeMaxPower)
|
|
|
|
|
ivs = ivs.Select(_ => Entity.MaxIV).ToArray();
|
|
|
|
|
int[] newIVs = HiddenPower.SetIVs(hpower, ivs, Entity.Format);
|
2018-02-27 05:22:35 +00:00
|
|
|
|
LoadIVs(newIVs);
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
private void ClickStatLabel(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2022-01-26 00:45:41 +00:00
|
|
|
|
if (ModifierKeys == Keys.None)
|
|
|
|
|
return;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
|
2022-01-26 00:45:41 +00:00
|
|
|
|
int index = Array.IndexOf(L_Stats, sender as Label) - 1;
|
|
|
|
|
if (index < 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (Entity.Format < 3)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var current = Entity.StatNature;
|
|
|
|
|
var up = current / 5;
|
|
|
|
|
var dn = current % 5;
|
|
|
|
|
switch (ModifierKeys)
|
2018-02-27 05:22:35 +00:00
|
|
|
|
{
|
2022-01-26 00:45:41 +00:00
|
|
|
|
case Keys.Shift when up != index: up = index; break;
|
|
|
|
|
case Keys.Alt when dn != index: dn = index; break;
|
|
|
|
|
case Keys.Control when up != index && dn != index: up = dn = index; break;
|
|
|
|
|
default:
|
|
|
|
|
return;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
}
|
2022-01-26 00:45:41 +00:00
|
|
|
|
|
|
|
|
|
var newNature = (up * 5) + dn;
|
|
|
|
|
MainEditor.ChangeNature(newNature);
|
2018-02-27 05:22:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadHyperTraining()
|
|
|
|
|
{
|
2020-12-23 05:24:41 +00:00
|
|
|
|
if (Entity is not IHyperTrain h)
|
2018-07-27 02:34:27 +00:00
|
|
|
|
{
|
|
|
|
|
foreach (var iv in MT_IVs)
|
|
|
|
|
iv.ResetBackColor();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < MT_IVs.Length; i++)
|
2021-01-02 00:39:33 +00:00
|
|
|
|
UpdateHyperTrainingFlag(i, h.IsHyperTrained(i));
|
2018-02-27 05:22:35 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-11-14 03:21:14 +00:00
|
|
|
|
private void UpdateAVTotals()
|
|
|
|
|
{
|
2020-12-23 05:24:41 +00:00
|
|
|
|
if (Entity is not IAwakened a)
|
2018-11-14 03:21:14 +00:00
|
|
|
|
return;
|
|
|
|
|
var total = a.AwakeningSum();
|
|
|
|
|
TB_AVTotal.Text = total.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
private void UpdateEVTotals()
|
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
var evtotal = Entity.EVTotal;
|
2018-08-26 00:04:01 +00:00
|
|
|
|
TB_EVTotal.BackColor = GetEVTotalColor(evtotal, TB_IVTotal.BackColor);
|
2018-02-27 05:22:35 +00:00
|
|
|
|
TB_EVTotal.Text = evtotal.ToString();
|
|
|
|
|
EVTip.SetToolTip(TB_EVTotal, $"Remaining: {510 - evtotal}");
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2021-01-05 01:31:43 +00:00
|
|
|
|
private Color GetEVTotalColor(int evtotal, Color defaultColor) => evtotal switch
|
2018-08-26 00:04:01 +00:00
|
|
|
|
{
|
2021-01-05 01:31:43 +00:00
|
|
|
|
> 510 => EVsInvalid, // Background turns Red
|
|
|
|
|
510 => EVsMaxed, // Maximum EVs
|
|
|
|
|
508 => EVsFishy, // Fishy EVs
|
2021-08-20 20:49:20 +00:00
|
|
|
|
_ => defaultColor,
|
2021-01-05 01:31:43 +00:00
|
|
|
|
};
|
2018-08-26 00:04:01 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
public void UpdateStats()
|
|
|
|
|
{
|
|
|
|
|
// Generate the stats.
|
2020-09-18 01:13:08 +00:00
|
|
|
|
// Some entity formats don't store stat values regardless of Box/Party/Etc format.
|
|
|
|
|
// If its attack stat is zero, we need to generate party stats.
|
|
|
|
|
// PK1 format stores Current HP in the compact format, so we have to use attack stat!
|
|
|
|
|
if (!CHK_HackedStats.Checked || Entity.Stat_ATK == 0)
|
2018-02-27 05:22:35 +00:00
|
|
|
|
{
|
2018-07-28 04:21:42 +00:00
|
|
|
|
var pt = MainEditor.RequestSaveFile.Personal;
|
2020-12-11 04:42:30 +00:00
|
|
|
|
var pi = pt.GetFormEntry(Entity.Species, Entity.Form);
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.SetStats(Entity.GetStats(pi));
|
2018-03-18 17:38:29 +00:00
|
|
|
|
LoadBST(pi);
|
2019-10-27 19:57:04 +00:00
|
|
|
|
LoadPartyStats(Entity);
|
2018-02-27 05:22:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-18 17:38:29 +00:00
|
|
|
|
|
|
|
|
|
private void LoadBST(PersonalInfo pi)
|
|
|
|
|
{
|
2018-07-14 22:08:14 +00:00
|
|
|
|
var stats = pi.Stats;
|
2020-10-18 16:43:41 +00:00
|
|
|
|
for (int i = 0; i < stats.Count; i++)
|
2018-03-18 17:38:29 +00:00
|
|
|
|
{
|
|
|
|
|
MT_Base[i].Text = stats[i].ToString("000");
|
2021-12-10 08:15:04 +00:00
|
|
|
|
MT_Base[i].BackColor = ColorUtil.ColorBaseStat(stats[i]);
|
2018-03-18 17:38:29 +00:00
|
|
|
|
}
|
2020-10-18 16:43:41 +00:00
|
|
|
|
var bst = pi.Stats.Sum();
|
2018-03-18 18:21:00 +00:00
|
|
|
|
TB_BST.Text = bst.ToString("000");
|
2021-12-10 08:15:04 +00:00
|
|
|
|
TB_BST.BackColor = ColorUtil.ColorBaseStatTotal(bst);
|
2018-03-18 17:38:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
public void UpdateRandomIVs(object sender, EventArgs e)
|
|
|
|
|
{
|
2021-01-21 06:09:25 +00:00
|
|
|
|
var IVs = ModifierKeys switch
|
|
|
|
|
{
|
|
|
|
|
Keys.Control => Entity.SetRandomIVs(6),
|
|
|
|
|
Keys.Alt => new int[6],
|
|
|
|
|
_ => Entity.SetRandomIVs(),
|
|
|
|
|
};
|
2018-07-14 22:08:14 +00:00
|
|
|
|
LoadIVs(IVs);
|
2022-02-05 01:36:51 +00:00
|
|
|
|
if (Entity is IGanbaru g)
|
|
|
|
|
{
|
|
|
|
|
Entity.SetIVs(IVs);
|
|
|
|
|
if (ModifierKeys == Keys.Control)
|
|
|
|
|
g.SetSuggestedGanbaruValues(Entity);
|
|
|
|
|
else if (ModifierKeys == Keys.Alt)
|
|
|
|
|
g.ClearGanbaruValues();
|
|
|
|
|
LoadGVs(g);
|
|
|
|
|
}
|
2018-02-27 05:22:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-16 22:21:29 +00:00
|
|
|
|
private void UpdateRandomAVs(object sender, EventArgs e)
|
|
|
|
|
{
|
2020-12-23 05:24:41 +00:00
|
|
|
|
if (Entity is not IAwakened a)
|
2018-11-16 22:21:29 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
switch (ModifierKeys)
|
|
|
|
|
{
|
|
|
|
|
case Keys.Control:
|
2019-10-27 19:57:04 +00:00
|
|
|
|
a.SetSuggestedAwakenedValues(Entity);
|
2018-11-16 22:21:29 +00:00
|
|
|
|
break;
|
|
|
|
|
case Keys.Alt:
|
2020-09-18 01:13:08 +00:00
|
|
|
|
a.AwakeningClear();
|
2018-11-16 22:21:29 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2020-09-18 01:13:08 +00:00
|
|
|
|
a.AwakeningSetRandom();
|
2018-11-16 22:21:29 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
LoadAVs(a);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
public void UpdateCharacteristic() => UpdateCharacteristic(Entity.Characteristic);
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
private void UpdateCharacteristic(int characteristic)
|
|
|
|
|
{
|
|
|
|
|
L_Characteristic.Visible = Label_CharacteristicPrefix.Visible = characteristic > -1;
|
|
|
|
|
if (characteristic > -1)
|
|
|
|
|
L_Characteristic.Text = GameInfo.Strings.characteristics[characteristic];
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
public string UpdateNatureModification(int nature)
|
|
|
|
|
{
|
|
|
|
|
// Reset Label Colors
|
2018-08-26 00:04:01 +00:00
|
|
|
|
for (var i = 1; i < L_Stats.Length; i++)
|
|
|
|
|
L_Stats[i].ResetForeColor();
|
2018-02-27 05:22:35 +00:00
|
|
|
|
|
|
|
|
|
// Set Colored StatLabels only if Nature isn't Neutral
|
2018-03-01 05:50:50 +00:00
|
|
|
|
if (PKX.GetNatureModification(nature, out int incr, out int decr))
|
2018-02-27 05:22:35 +00:00
|
|
|
|
return "-/-";
|
2018-08-26 00:04:01 +00:00
|
|
|
|
|
|
|
|
|
L_Stats[incr].ForeColor = StatIncreased;
|
|
|
|
|
L_Stats[decr].ForeColor = StatDecreased;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
return $"+{L_Stats[incr].Text} / -{L_Stats[decr].Text}".Replace(":", "");
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
public void SetATKIVGender(int gender)
|
|
|
|
|
{
|
2020-06-17 02:46:22 +00:00
|
|
|
|
Entity.SetAttackIVFromGender(gender);
|
2019-10-27 19:57:04 +00:00
|
|
|
|
TB_IVATK.Text = Entity.IV_ATK.ToString();
|
2018-02-27 05:22:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LoadPartyStats(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
Stat_HP.Text = pk.Stat_HPCurrent.ToString();
|
|
|
|
|
Stat_ATK.Text = pk.Stat_ATK.ToString();
|
|
|
|
|
Stat_DEF.Text = pk.Stat_DEF.ToString();
|
|
|
|
|
Stat_SPA.Text = pk.Stat_SPA.ToString();
|
|
|
|
|
Stat_SPD.Text = pk.Stat_SPD.ToString();
|
|
|
|
|
Stat_SPE.Text = pk.Stat_SPE.ToString();
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
public void SavePartyStats(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
pk.Stat_HPCurrent = Util.ToInt32(Stat_HP.Text);
|
|
|
|
|
pk.Stat_HPMax = Util.ToInt32(Stat_HP.Text);
|
|
|
|
|
pk.Stat_ATK = Util.ToInt32(Stat_ATK.Text);
|
|
|
|
|
pk.Stat_DEF = Util.ToInt32(Stat_DEF.Text);
|
|
|
|
|
pk.Stat_SPE = Util.ToInt32(Stat_SPE.Text);
|
|
|
|
|
pk.Stat_SPA = Util.ToInt32(Stat_SPA.Text);
|
|
|
|
|
pk.Stat_SPD = Util.ToInt32(Stat_SPD.Text);
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2022-01-03 05:35:59 +00:00
|
|
|
|
public void LoadEVs(ReadOnlySpan<int> EVs)
|
2018-02-27 05:22:35 +00:00
|
|
|
|
{
|
|
|
|
|
ChangingFields = true;
|
2018-11-14 03:21:14 +00:00
|
|
|
|
TB_EVHP.Text = EVs[0].ToString();
|
|
|
|
|
TB_EVATK.Text = EVs[1].ToString();
|
|
|
|
|
TB_EVDEF.Text = EVs[2].ToString();
|
|
|
|
|
TB_EVSPE.Text = EVs[3].ToString();
|
|
|
|
|
TB_EVSPA.Text = EVs[4].ToString();
|
|
|
|
|
TB_EVSPD.Text = EVs[5].ToString();
|
2018-02-27 05:22:35 +00:00
|
|
|
|
ChangingFields = false;
|
2018-11-14 03:21:14 +00:00
|
|
|
|
UpdateStats();
|
2018-02-27 05:22:35 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2022-01-03 05:35:59 +00:00
|
|
|
|
public void LoadIVs(ReadOnlySpan<int> IVs)
|
2018-02-27 05:22:35 +00:00
|
|
|
|
{
|
|
|
|
|
ChangingFields = true;
|
2018-11-14 03:21:14 +00:00
|
|
|
|
TB_IVHP.Text = IVs[0].ToString();
|
|
|
|
|
TB_IVATK.Text = IVs[1].ToString();
|
|
|
|
|
TB_IVDEF.Text = IVs[2].ToString();
|
|
|
|
|
TB_IVSPE.Text = IVs[3].ToString();
|
|
|
|
|
TB_IVSPA.Text = IVs[4].ToString();
|
|
|
|
|
TB_IVSPD.Text = IVs[5].ToString();
|
2018-02-27 05:22:35 +00:00
|
|
|
|
ChangingFields = false;
|
|
|
|
|
LoadHyperTraining();
|
2018-11-14 03:21:14 +00:00
|
|
|
|
RefreshDerivedValues(TB_IVSPD);
|
|
|
|
|
UpdateStats();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LoadAVs(IAwakened a)
|
|
|
|
|
{
|
|
|
|
|
ChangingFields = true;
|
|
|
|
|
TB_AVHP.Text = a.AV_HP.ToString();
|
|
|
|
|
TB_AVATK.Text = a.AV_ATK.ToString();
|
|
|
|
|
TB_AVDEF.Text = a.AV_DEF.ToString();
|
|
|
|
|
TB_AVSPE.Text = a.AV_SPE.ToString();
|
|
|
|
|
TB_AVSPA.Text = a.AV_SPA.ToString();
|
|
|
|
|
TB_AVSPD.Text = a.AV_SPD.ToString();
|
|
|
|
|
ChangingFields = false;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
UpdateStats();
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-05 01:36:51 +00:00
|
|
|
|
public void LoadGVs(IGanbaru a)
|
|
|
|
|
{
|
|
|
|
|
ChangingFields = true;
|
|
|
|
|
TB_GVHP.Text = a.GV_HP.ToString();
|
|
|
|
|
TB_GVATK.Text = a.GV_ATK.ToString();
|
|
|
|
|
TB_GVDEF.Text = a.GV_DEF.ToString();
|
|
|
|
|
TB_GVSPE.Text = a.GV_SPE.ToString();
|
|
|
|
|
TB_GVSPA.Text = a.GV_SPA.ToString();
|
|
|
|
|
TB_GVSPD.Text = a.GV_SPD.ToString();
|
|
|
|
|
ChangingFields = false;
|
|
|
|
|
for (int i = 0; i < 6; i++)
|
|
|
|
|
RefreshGanbaru(Entity, a, i);
|
|
|
|
|
UpdateStats();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RefreshGanbaru(PKM entity, IGanbaru ganbaru, int i)
|
|
|
|
|
{
|
|
|
|
|
int current = ganbaru.GetGV(i);
|
|
|
|
|
var max = ganbaru.GetMax(entity, i);
|
|
|
|
|
if (current > max)
|
|
|
|
|
MT_GVs[i].BackColor = EVsInvalid;
|
|
|
|
|
else if (current == max)
|
|
|
|
|
MT_GVs[i].BackColor = StatHyperTrained;
|
|
|
|
|
else
|
|
|
|
|
MT_GVs[i].ResetBackColor();
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-14 03:21:14 +00:00
|
|
|
|
public void ToggleInterface(PKM pk, int gen)
|
2018-02-27 05:22:35 +00:00
|
|
|
|
{
|
|
|
|
|
FLP_StatsTotal.Visible = gen >= 3;
|
|
|
|
|
FLP_Characteristic.Visible = gen >= 3;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
FLP_HPType.Visible = gen <= 7;
|
2022-02-09 06:25:14 +00:00
|
|
|
|
Label_HiddenPowerPower.Visible = gen <= 5;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
FLP_DynamaxLevel.Visible = gen >= 8;
|
2022-02-05 01:36:51 +00:00
|
|
|
|
FLP_AlphaNoble.Visible = pk is PA8;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
|
|
|
|
|
switch (gen)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
FLP_SpD.Visible = false;
|
|
|
|
|
Label_SPA.Visible = false;
|
|
|
|
|
Label_SPC.Visible = true;
|
2018-11-14 03:21:14 +00:00
|
|
|
|
TB_IVHP.Enabled = false;
|
2018-08-13 02:27:11 +00:00
|
|
|
|
SetEVMaskSize(Stat_HP.Size, "00000");
|
2018-02-27 05:22:35 +00:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
FLP_SpD.Visible = true;
|
|
|
|
|
Label_SPA.Visible = true;
|
|
|
|
|
Label_SPC.Visible = false;
|
2018-11-14 03:21:14 +00:00
|
|
|
|
TB_IVHP.Enabled = false;
|
2018-08-13 02:27:11 +00:00
|
|
|
|
SetEVMaskSize(Stat_HP.Size, "00000");
|
2018-11-14 03:21:14 +00:00
|
|
|
|
TB_EVSPD.Enabled = TB_IVSPD.Enabled = false;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
FLP_SpD.Visible = true;
|
|
|
|
|
Label_SPA.Visible = true;
|
|
|
|
|
Label_SPC.Visible = false;
|
2018-11-14 03:21:14 +00:00
|
|
|
|
TB_IVHP.Enabled = true;
|
2018-08-13 02:27:11 +00:00
|
|
|
|
SetEVMaskSize(TB_EVTotal.Size, "000");
|
2018-11-14 03:21:14 +00:00
|
|
|
|
TB_EVSPD.Enabled = TB_IVSPD.Enabled = true;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-14 03:21:14 +00:00
|
|
|
|
var showAV = pk is IAwakened;
|
2018-11-16 22:21:29 +00:00
|
|
|
|
Label_AVs.Visible = TB_AVTotal.Visible = BTN_RandomAVs.Visible = showAV;
|
2018-11-14 03:21:14 +00:00
|
|
|
|
foreach (var mtb in MT_AVs)
|
|
|
|
|
mtb.Visible = showAV;
|
|
|
|
|
Label_EVs.Visible = TB_EVTotal.Visible = BTN_RandomEVs.Visible = !showAV;
|
|
|
|
|
foreach (var mtb in MT_EVs)
|
|
|
|
|
mtb.Visible = !showAV;
|
|
|
|
|
|
2022-02-05 01:36:51 +00:00
|
|
|
|
var showGV = pk is IGanbaru;
|
|
|
|
|
Label_GVs.Visible = showGV;
|
|
|
|
|
foreach (var mtb in MT_GVs)
|
|
|
|
|
mtb.Visible = showGV;
|
|
|
|
|
|
2018-08-13 02:27:11 +00:00
|
|
|
|
void SetEVMaskSize(Size s, string Mask)
|
2018-02-27 05:22:35 +00:00
|
|
|
|
{
|
2018-05-12 15:13:39 +00:00
|
|
|
|
foreach (var ctrl in MT_EVs)
|
2018-02-27 05:22:35 +00:00
|
|
|
|
{
|
|
|
|
|
ctrl.Size = s;
|
|
|
|
|
ctrl.Mask = Mask;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
public void InitializeDataSources()
|
|
|
|
|
{
|
2019-05-05 19:57:51 +00:00
|
|
|
|
ChangingFields = true;
|
2018-07-14 23:00:28 +00:00
|
|
|
|
CB_HPType.InitializeBinding();
|
2021-05-10 08:01:45 +00:00
|
|
|
|
CB_HPType.DataSource = Util.GetCBList(GameInfo.Strings.types.AsSpan(1, 16));
|
2019-05-05 19:57:51 +00:00
|
|
|
|
ChangingFields = false;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
}
|
2020-10-25 20:47:42 +00:00
|
|
|
|
|
|
|
|
|
private void CHK_Gigantamax_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!ChangingFields)
|
|
|
|
|
((PKMEditor) MainEditor).UpdateSprite();
|
|
|
|
|
}
|
2022-02-05 01:36:51 +00:00
|
|
|
|
|
|
|
|
|
private void CHK_IsAlpha_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!ChangingFields)
|
|
|
|
|
((PKMEditor) MainEditor).UpdateSprite();
|
|
|
|
|
}
|
2018-02-27 05:22:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|