2018-02-27 05:22:35 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using PKHeX.Core;
|
|
|
|
|
|
|
|
|
|
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};
|
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;
|
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
private IMainEditor MainEditor { get; set; }
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
public void SetMainEditor(IMainEditor editor)
|
|
|
|
|
{
|
|
|
|
|
MainEditor = editor;
|
|
|
|
|
CHK_HackedStats.Enabled = CHK_HackedStats.Visible = editor.HaX;
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-11-14 03:21:14 +00:00
|
|
|
|
public bool Valid
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (pkm.Format < 3)
|
|
|
|
|
return true;
|
|
|
|
|
if (CHK_HackedStats.Checked)
|
|
|
|
|
return true;
|
|
|
|
|
if (pkm is IAwakened a)
|
|
|
|
|
return a.AwakeningAllValid();
|
|
|
|
|
return Convert.ToUInt32(TB_EVTotal.Text) <= 510;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-02-27 05:22:35 +00:00
|
|
|
|
|
|
|
|
|
private readonly Label[] L_Stats;
|
2018-11-14 03:21:14 +00:00
|
|
|
|
private readonly MaskedTextBox[] MT_EVs, MT_IVs, MT_AVs, MT_Stats, MT_Base;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
private readonly ToolTip EVTip = new ToolTip();
|
|
|
|
|
private PKM pkm => MainEditor.pkm;
|
|
|
|
|
|
|
|
|
|
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 bool FieldsInitialized => MainEditor.FieldsInitialized;
|
|
|
|
|
|
|
|
|
|
private void ClickIV(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!(sender is MaskedTextBox t))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (ModifierKeys.HasFlag(Keys.Alt)) // Min
|
2018-07-27 02:34:27 +00:00
|
|
|
|
{
|
2018-02-27 05:22:35 +00:00
|
|
|
|
t.Text = 0.ToString();
|
2018-07-27 02:34:27 +00:00
|
|
|
|
}
|
2018-02-27 05:22:35 +00:00
|
|
|
|
else if (ModifierKeys.HasFlag(Keys.Control))
|
|
|
|
|
{
|
|
|
|
|
var index = Array.IndexOf(MT_IVs, t);
|
|
|
|
|
t.Text = pkm.GetMaximumIV(index, true).ToString();
|
|
|
|
|
}
|
2018-06-06 04:31:42 +00:00
|
|
|
|
else if (pkm is IHyperTrain h && ModifierKeys.HasFlag(Keys.Shift))
|
2018-02-27 05:22:35 +00:00
|
|
|
|
{
|
|
|
|
|
var index = Array.IndexOf(MT_IVs, t);
|
2018-06-06 04:31:42 +00:00
|
|
|
|
bool flag = h.HyperTrainInvert(index);
|
2018-02-27 05:22:35 +00:00
|
|
|
|
UpdateHyperTrainingFlag(index, flag);
|
|
|
|
|
UpdateStats();
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
private void ClickEV(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!(sender is MaskedTextBox t))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!ModifierKeys.HasFlag(Keys.Control)) // Max
|
|
|
|
|
{
|
|
|
|
|
if (ModifierKeys.HasFlag(Keys.Alt)) // Min
|
|
|
|
|
t.Text = 0.ToString();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int index = Array.IndexOf(MT_EVs, t);
|
|
|
|
|
int newEV = pkm.GetMaximumEV(index);
|
|
|
|
|
t.Text = newEV.ToString();
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-11-14 03:21:14 +00:00
|
|
|
|
private void ClickAV(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!(sender is MaskedTextBox t))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!ModifierKeys.HasFlag(Keys.Control)) // Max
|
|
|
|
|
{
|
|
|
|
|
if (ModifierKeys.HasFlag(Keys.Alt)) // Min
|
|
|
|
|
t.Text = 0.ToString();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-11-16 22:21:29 +00:00
|
|
|
|
var max = Legal.AwakeningMax.ToString();
|
|
|
|
|
t.Text = t.Text == max ? 0.ToString() : max;
|
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);
|
|
|
|
|
if (value > pkm.MaxIV)
|
|
|
|
|
{
|
|
|
|
|
m.Text = pkm.MaxIV.ToString();
|
|
|
|
|
return; // recursive on text set
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int index = Array.IndexOf(MT_IVs, m);
|
|
|
|
|
pkm.SetIV(index, value);
|
|
|
|
|
}
|
|
|
|
|
RefreshDerivedValues(e);
|
|
|
|
|
UpdateStats();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RefreshDerivedValues(object sender)
|
|
|
|
|
{
|
|
|
|
|
if (pkm.Format < 3)
|
|
|
|
|
{
|
2018-11-14 03:21:14 +00:00
|
|
|
|
TB_IVHP.Text = pkm.IV_HP.ToString();
|
|
|
|
|
TB_IVSPD.Text = pkm.IV_SPD.ToString();
|
2018-02-27 05:22:35 +00:00
|
|
|
|
|
|
|
|
|
MainEditor.UpdateIVsGB(sender == null);
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-28 01:48:19 +00:00
|
|
|
|
if (!ChangingFields)
|
|
|
|
|
{
|
|
|
|
|
ChangingFields = true;
|
|
|
|
|
CB_HPType.SelectedValue = pkm.HPType;
|
|
|
|
|
ChangingFields = false;
|
|
|
|
|
}
|
2018-02-27 05:22:35 +00:00
|
|
|
|
|
|
|
|
|
// Potential Reading
|
|
|
|
|
L_Potential.Text = pkm.GetPotentialString(MainEditor.Unicode);
|
|
|
|
|
|
|
|
|
|
TB_IVTotal.Text = pkm.IVTotal.ToString();
|
|
|
|
|
UpdateCharacteristic(pkm.Characteristic);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateEVs(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (sender is MaskedTextBox m)
|
|
|
|
|
{
|
|
|
|
|
int value = Util.ToInt32(m.Text);
|
|
|
|
|
if (value > pkm.MaxEV)
|
|
|
|
|
{
|
|
|
|
|
m.Text = pkm.MaxEV.ToString();
|
|
|
|
|
return; // recursive on text set
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int index = Array.IndexOf(MT_EVs, m);
|
|
|
|
|
pkm.SetEV(index, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UpdateEVTotals();
|
|
|
|
|
|
|
|
|
|
if (pkm.Format < 3)
|
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
if (!(pkm is IAwakened a))
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
private void UpdateRandomEVs(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bool zero = ModifierKeys.HasFlag(Keys.Control);
|
|
|
|
|
var evs = zero ? new int[6] : PKX.GetRandomEVs(pkm.Format);
|
|
|
|
|
LoadEVs(evs);
|
|
|
|
|
UpdateEVs(null, null);
|
|
|
|
|
}
|
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)
|
|
|
|
|
{
|
|
|
|
|
if (!CHK_HackedStats.Checked || !(sender is TextBox tb))
|
|
|
|
|
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
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
private void UpdateHyperTrainingFlag(int i, bool value)
|
|
|
|
|
{
|
|
|
|
|
if (value)
|
2018-07-14 20:17:56 +00:00
|
|
|
|
MT_IVs[i].BackColor = StatHyperTrained;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
else
|
|
|
|
|
MT_IVs[i].ResetBackColor();
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
private void UpdateHPType(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (ChangingFields || !FieldsInitialized)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Change IVs to match the new Hidden Power
|
|
|
|
|
int hpower = WinFormsUtil.GetIndex(CB_HPType);
|
2018-07-14 17:56:11 +00:00
|
|
|
|
int[] newIVs = PKX.SetHPIVs(hpower, pkm.IVs, pkm.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)
|
|
|
|
|
{
|
|
|
|
|
if (sender == Label_SPC)
|
|
|
|
|
sender = Label_SPA;
|
|
|
|
|
|
|
|
|
|
int index = Array.IndexOf(L_Stats, sender as Label);
|
|
|
|
|
if (ModifierKeys.HasFlag(Keys.Alt)) // EV
|
|
|
|
|
{
|
|
|
|
|
var value = e.Button != MouseButtons.Left ? 0 : pkm.GetMaximumEV(index);
|
|
|
|
|
MT_EVs[index].Text = value.ToString();
|
|
|
|
|
}
|
|
|
|
|
else if (ModifierKeys.HasFlag(Keys.Control)) // IV
|
|
|
|
|
{
|
|
|
|
|
var value = e.Button != MouseButtons.Left ? 0 : pkm.GetMaximumIV(index, true);
|
|
|
|
|
MT_IVs[index].Text = value.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadHyperTraining()
|
|
|
|
|
{
|
2018-06-06 04:31:42 +00:00
|
|
|
|
if (!(pkm is 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++)
|
2018-06-06 04:31:42 +00:00
|
|
|
|
UpdateHyperTrainingFlag(i, h.GetHT(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()
|
|
|
|
|
{
|
|
|
|
|
if (!(pkm is IAwakened a))
|
|
|
|
|
return;
|
|
|
|
|
var total = a.AwakeningSum();
|
|
|
|
|
TB_AVTotal.Text = total.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
private void UpdateEVTotals()
|
|
|
|
|
{
|
2018-08-26 00:04:01 +00:00
|
|
|
|
var evtotal = pkm.EVTotal;
|
|
|
|
|
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
|
|
|
|
|
2018-08-26 00:04:01 +00:00
|
|
|
|
private Color GetEVTotalColor(int evtotal, Color defaultColor)
|
|
|
|
|
{
|
|
|
|
|
if (evtotal > 510) // Background turns Red
|
|
|
|
|
return EVsInvalid;
|
|
|
|
|
if (evtotal == 510) // Maximum EVs
|
|
|
|
|
return EVsMaxed;
|
|
|
|
|
if (evtotal == 508) // Fishy EVs
|
|
|
|
|
return EVsFishy;
|
|
|
|
|
return defaultColor;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
public void UpdateStats()
|
|
|
|
|
{
|
|
|
|
|
// Generate the stats.
|
|
|
|
|
if (!CHK_HackedStats.Checked || pkm.Stat_HPCurrent == 0) // no stats when initially loaded from non-partyformat slot
|
|
|
|
|
{
|
2018-07-28 04:21:42 +00:00
|
|
|
|
var pt = MainEditor.RequestSaveFile.Personal;
|
|
|
|
|
var pi = pt.GetFormeEntry(pkm.Species, pkm.AltForm);
|
2018-03-18 17:38:29 +00:00
|
|
|
|
pkm.SetStats(pkm.GetStats(pi));
|
|
|
|
|
LoadBST(pi);
|
2018-02-27 05:22:35 +00:00
|
|
|
|
LoadPartyStats(pkm);
|
|
|
|
|
}
|
|
|
|
|
}
|
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;
|
2018-03-18 17:38:29 +00:00
|
|
|
|
for (int i = 0; i < stats.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
MT_Base[i].Text = stats[i].ToString("000");
|
2018-07-14 22:08:14 +00:00
|
|
|
|
MT_Base[i].BackColor = ImageUtil.ColorBaseStat(stats[i]);
|
2018-03-18 17:38:29 +00:00
|
|
|
|
}
|
2018-03-18 18:21:00 +00:00
|
|
|
|
var bst = pi.BST;
|
|
|
|
|
TB_BST.Text = bst.ToString("000");
|
2018-07-14 22:08:14 +00:00
|
|
|
|
TB_BST.BackColor = ImageUtil.ColorBaseStat((int)(Math.Max(0, bst - 175) / 3f));
|
2018-03-18 17:38:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
public void UpdateRandomIVs(object sender, EventArgs e)
|
|
|
|
|
{
|
2018-07-14 22:08:14 +00:00
|
|
|
|
int? flawless = ModifierKeys.HasFlag(Keys.Control) ? (int?)6 : null;
|
|
|
|
|
var IVs = pkm.SetRandomIVs(flawless);
|
|
|
|
|
LoadIVs(IVs);
|
2018-02-27 05:22:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-16 22:21:29 +00:00
|
|
|
|
private void UpdateRandomAVs(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!(pkm is IAwakened a))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
switch (ModifierKeys)
|
|
|
|
|
{
|
|
|
|
|
case Keys.Control:
|
|
|
|
|
a.SetSuggestedAwakenedValues(pkm);
|
|
|
|
|
break;
|
|
|
|
|
case Keys.Alt:
|
|
|
|
|
a.AwakeningSetAllTo(0);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
foreach (var index in Enumerable.Range(0, 6))
|
|
|
|
|
a.SetAV(index, Util.Rand.Next(Legal.AwakeningMax + 1));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
LoadAVs(a);
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-07 00:37:07 +00:00
|
|
|
|
public void UpdateCharacteristic() => UpdateCharacteristic(pkm.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)
|
|
|
|
|
{
|
|
|
|
|
pkm.SetATKIVGender(gender);
|
2018-11-14 03:21:14 +00:00
|
|
|
|
TB_IVATK.Text = pkm.IV_ATK.ToString();
|
2018-02-27 05:22:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LoadPartyStats(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
int size = pk.SIZE_PARTY;
|
|
|
|
|
if (pk.Data.Length != size)
|
|
|
|
|
Array.Resize(ref pk.Data, size);
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
int size = pk.SIZE_PARTY;
|
|
|
|
|
if (pk.Data.Length != size)
|
|
|
|
|
Array.Resize(ref pk.Data, size);
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
public void LoadEVs(int[] EVs)
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
public void LoadIVs(int[] IVs)
|
|
|
|
|
{
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
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()
|
|
|
|
|
{
|
2018-07-14 23:00:28 +00:00
|
|
|
|
CB_HPType.InitializeBinding();
|
2018-02-27 05:22:35 +00:00
|
|
|
|
CB_HPType.DataSource = Util.GetCBList(GameInfo.Strings.types.Skip(1).Take(16).ToArray(), null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|