2017-10-03 06:13:40 +00:00
|
|
|
|
using System;
|
2022-06-05 03:21:36 +00:00
|
|
|
|
using System.Windows.Forms;
|
2017-10-03 06:13:40 +00:00
|
|
|
|
using PKHeX.Core;
|
2019-10-02 01:12:08 +00:00
|
|
|
|
using PKHeX.Drawing;
|
2021-11-27 23:48:08 +00:00
|
|
|
|
using PKHeX.Drawing.PokeSprite;
|
2017-10-03 06:13:40 +00:00
|
|
|
|
|
|
|
|
|
namespace PKHeX.WinForms.Controls
|
|
|
|
|
{
|
|
|
|
|
public partial class PKMEditor
|
|
|
|
|
{
|
|
|
|
|
private void LoadNickname(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
CHK_Nicknamed.Checked = pk.IsNicknamed;
|
|
|
|
|
TB_Nickname.Text = pk.Nickname;
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-10-03 06:13:40 +00:00
|
|
|
|
private void SaveNickname(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
pk.IsNicknamed = CHK_Nicknamed.Checked;
|
|
|
|
|
pk.Nickname = TB_Nickname.Text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadSpeciesLevelEXP(PKM pk)
|
|
|
|
|
{
|
2021-07-31 01:05:17 +00:00
|
|
|
|
if (!HaX)
|
|
|
|
|
{
|
|
|
|
|
// Sanity check level and EXP
|
|
|
|
|
var current = pk.CurrentLevel;
|
|
|
|
|
if (current == 100) // clamp back to max EXP
|
|
|
|
|
pk.CurrentLevel = 100;
|
|
|
|
|
}
|
2017-10-03 06:13:40 +00:00
|
|
|
|
|
|
|
|
|
CB_Species.SelectedValue = pk.Species;
|
|
|
|
|
TB_Level.Text = pk.Stat_Level.ToString();
|
|
|
|
|
TB_EXP.Text = pk.EXP.ToString();
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-10-03 06:13:40 +00:00
|
|
|
|
private void SaveSpeciesLevelEXP(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
pk.Species = WinFormsUtil.GetIndex(CB_Species);
|
|
|
|
|
pk.EXP = Util.ToUInt32(TB_EXP.Text);
|
2021-07-31 01:05:17 +00:00
|
|
|
|
pk.Stat_Level = Util.ToInt32(TB_Level.Text);
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-24 23:53:51 +00:00
|
|
|
|
private void LoadOT(PKM pk)
|
2017-10-03 06:13:40 +00:00
|
|
|
|
{
|
2021-07-31 01:05:17 +00:00
|
|
|
|
GB_OT.BackgroundImage = null; // clear the Current Handler indicator just in case we switched formats.
|
2017-10-03 06:13:40 +00:00
|
|
|
|
TB_OT.Text = pk.OT_Name;
|
2022-04-25 03:19:50 +00:00
|
|
|
|
UC_OTGender.Gender = pk.OT_Gender & 1;
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-05-24 23:53:51 +00:00
|
|
|
|
private void SaveOT(PKM pk)
|
2017-10-03 06:13:40 +00:00
|
|
|
|
{
|
|
|
|
|
pk.OT_Name = TB_OT.Text;
|
2022-04-25 03:19:50 +00:00
|
|
|
|
pk.OT_Gender = UC_OTGender.Gender;
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadPKRS(PKM pk)
|
|
|
|
|
{
|
2021-07-31 01:05:17 +00:00
|
|
|
|
Label_PKRS.Visible = CB_PKRSStrain.Visible = CHK_Infected.Checked = Label_PKRSdays.Visible = CB_PKRSDays.Visible = pk.PKRS_Infected;
|
2022-06-05 03:21:36 +00:00
|
|
|
|
LoadClamp(CB_PKRSStrain, pk.PKRS_Strain);
|
2021-07-31 01:05:17 +00:00
|
|
|
|
CHK_Cured.Checked = pk.PKRS_Cured;
|
2022-06-05 03:21:36 +00:00
|
|
|
|
LoadClamp(CB_PKRSDays, pk.PKRS_Days); // clamp to valid day values for the current strain
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-10-03 06:13:40 +00:00
|
|
|
|
private void SavePKRS(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
pk.PKRS_Days = CB_PKRSDays.SelectedIndex;
|
|
|
|
|
pk.PKRS_Strain = CB_PKRSStrain.SelectedIndex;
|
|
|
|
|
}
|
2018-05-12 15:13:39 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
private void LoadIVs(PKM pk) => Stats.LoadIVs(pk.IVs);
|
|
|
|
|
private void LoadEVs(PKM pk) => Stats.LoadEVs(pk.EVs);
|
2021-07-31 01:05:17 +00:00
|
|
|
|
private void LoadAVs(IAwakened pk) => Stats.LoadAVs(pk);
|
2022-02-05 01:36:51 +00:00
|
|
|
|
private void LoadGVs(IGanbaru pk) => Stats.LoadGVs(pk);
|
2017-10-03 06:13:40 +00:00
|
|
|
|
|
2022-06-05 03:21:36 +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;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-03 06:13:40 +00:00
|
|
|
|
private void LoadMoves(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
CB_Move1.SelectedValue = pk.Move1;
|
|
|
|
|
CB_Move2.SelectedValue = pk.Move2;
|
|
|
|
|
CB_Move3.SelectedValue = pk.Move3;
|
|
|
|
|
CB_Move4.SelectedValue = pk.Move4;
|
2022-06-05 03:21:36 +00:00
|
|
|
|
LoadClamp(CB_PPu1, pk.Move1_PPUps);
|
|
|
|
|
LoadClamp(CB_PPu2, pk.Move2_PPUps);
|
|
|
|
|
LoadClamp(CB_PPu3, pk.Move3_PPUps);
|
|
|
|
|
LoadClamp(CB_PPu4, pk.Move4_PPUps);
|
2017-10-03 06:13:40 +00:00
|
|
|
|
TB_PP1.Text = pk.Move1_PP.ToString();
|
|
|
|
|
TB_PP2.Text = pk.Move2_PP.ToString();
|
|
|
|
|
TB_PP3.Text = pk.Move3_PP.ToString();
|
|
|
|
|
TB_PP4.Text = pk.Move4_PP.ToString();
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-10-03 06:13:40 +00:00
|
|
|
|
private void SaveMoves(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
pk.Move1 = WinFormsUtil.GetIndex(CB_Move1);
|
|
|
|
|
pk.Move2 = WinFormsUtil.GetIndex(CB_Move2);
|
|
|
|
|
pk.Move3 = WinFormsUtil.GetIndex(CB_Move3);
|
|
|
|
|
pk.Move4 = WinFormsUtil.GetIndex(CB_Move4);
|
|
|
|
|
pk.Move1_PP = WinFormsUtil.GetIndex(CB_Move1) > 0 ? Util.ToInt32(TB_PP1.Text) : 0;
|
|
|
|
|
pk.Move2_PP = WinFormsUtil.GetIndex(CB_Move2) > 0 ? Util.ToInt32(TB_PP2.Text) : 0;
|
|
|
|
|
pk.Move3_PP = WinFormsUtil.GetIndex(CB_Move3) > 0 ? Util.ToInt32(TB_PP3.Text) : 0;
|
|
|
|
|
pk.Move4_PP = WinFormsUtil.GetIndex(CB_Move4) > 0 ? Util.ToInt32(TB_PP4.Text) : 0;
|
|
|
|
|
pk.Move1_PPUps = WinFormsUtil.GetIndex(CB_Move1) > 0 ? CB_PPu1.SelectedIndex : 0;
|
|
|
|
|
pk.Move2_PPUps = WinFormsUtil.GetIndex(CB_Move2) > 0 ? CB_PPu2.SelectedIndex : 0;
|
|
|
|
|
pk.Move3_PPUps = WinFormsUtil.GetIndex(CB_Move3) > 0 ? CB_PPu3.SelectedIndex : 0;
|
|
|
|
|
pk.Move4_PPUps = WinFormsUtil.GetIndex(CB_Move4) > 0 ? CB_PPu4.SelectedIndex : 0;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-31 01:05:17 +00:00
|
|
|
|
private void LoadShadow3(IShadowPKM pk)
|
2017-10-03 06:13:40 +00:00
|
|
|
|
{
|
2021-07-31 01:05:17 +00:00
|
|
|
|
NUD_ShadowID.Value = pk.ShadowID;
|
|
|
|
|
FLP_Purification.Visible = pk.ShadowID > 0;
|
|
|
|
|
if (pk.ShadowID > 0)
|
2017-10-03 06:13:40 +00:00
|
|
|
|
{
|
2021-07-31 01:05:17 +00:00
|
|
|
|
int value = pk.Purification;
|
2017-10-03 06:13:40 +00:00
|
|
|
|
if (value < NUD_Purification.Minimum)
|
|
|
|
|
value = (int)NUD_Purification.Minimum;
|
|
|
|
|
|
|
|
|
|
NUD_Purification.Value = value;
|
2021-07-31 01:05:17 +00:00
|
|
|
|
CHK_Shadow.Checked = pk.IsShadow;
|
2017-10-03 06:13:40 +00:00
|
|
|
|
|
2022-03-06 02:30:35 +00:00
|
|
|
|
NUD_ShadowID.Value = Math.Max(pk.ShadowID, (ushort)0);
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NUD_Purification.Value = 0;
|
|
|
|
|
CHK_Shadow.Checked = false;
|
|
|
|
|
NUD_ShadowID.Value = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2021-07-31 01:05:17 +00:00
|
|
|
|
private void SaveShadow3(IShadowPKM pk)
|
2017-10-03 06:13:40 +00:00
|
|
|
|
{
|
2022-03-06 02:30:35 +00:00
|
|
|
|
pk.ShadowID = (ushort)NUD_ShadowID.Value;
|
2021-07-31 01:05:17 +00:00
|
|
|
|
if (pk.ShadowID > 0)
|
|
|
|
|
pk.Purification = (int)NUD_Purification.Value;
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadRelearnMoves(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
CB_RelearnMove1.SelectedValue = pk.RelearnMove1;
|
|
|
|
|
CB_RelearnMove2.SelectedValue = pk.RelearnMove2;
|
|
|
|
|
CB_RelearnMove3.SelectedValue = pk.RelearnMove3;
|
|
|
|
|
CB_RelearnMove4.SelectedValue = pk.RelearnMove4;
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2021-07-31 01:05:17 +00:00
|
|
|
|
private void SaveRelearnMoves(PKM pk)
|
2017-10-03 06:13:40 +00:00
|
|
|
|
{
|
2021-07-31 01:05:17 +00:00
|
|
|
|
pk.RelearnMove1 = WinFormsUtil.GetIndex(CB_RelearnMove1);
|
|
|
|
|
pk.RelearnMove2 = WinFormsUtil.GetIndex(CB_RelearnMove2);
|
|
|
|
|
pk.RelearnMove3 = WinFormsUtil.GetIndex(CB_RelearnMove3);
|
|
|
|
|
pk.RelearnMove4 = WinFormsUtil.GetIndex(CB_RelearnMove4);
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadMisc1(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
LoadSpeciesLevelEXP(pk);
|
|
|
|
|
LoadNickname(pk);
|
2018-05-24 23:53:51 +00:00
|
|
|
|
LoadOT(pk);
|
2017-10-03 06:13:40 +00:00
|
|
|
|
LoadIVs(pk);
|
|
|
|
|
LoadEVs(pk);
|
|
|
|
|
LoadMoves(pk);
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-10-03 06:13:40 +00:00
|
|
|
|
private void SaveMisc1(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
SaveSpeciesLevelEXP(pk);
|
|
|
|
|
SaveNickname(pk);
|
2018-05-24 23:53:51 +00:00
|
|
|
|
SaveOT(pk);
|
2017-10-03 06:13:40 +00:00
|
|
|
|
SaveMoves(pk);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadMisc2(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
LoadPKRS(pk);
|
|
|
|
|
CHK_IsEgg.Checked = pk.IsEgg;
|
|
|
|
|
CB_HeldItem.SelectedValue = pk.HeldItem;
|
2022-06-05 03:21:36 +00:00
|
|
|
|
LoadClamp(CB_Form, pk.Form);
|
2019-11-29 18:44:52 +00:00
|
|
|
|
if (pk is IFormArgument f)
|
2020-12-28 19:51:25 +00:00
|
|
|
|
FA_Form.LoadArgument(f, pk.Species, pk.Form, pk.Format);
|
2019-11-29 18:44:52 +00:00
|
|
|
|
|
2021-11-22 03:53:13 +00:00
|
|
|
|
ReloadToFriendshipTextBox(pk);
|
2017-10-26 02:37:31 +00:00
|
|
|
|
|
2021-07-31 01:05:17 +00:00
|
|
|
|
Label_HatchCounter.Visible = CHK_IsEgg.Checked;
|
|
|
|
|
Label_Friendship.Visible = !CHK_IsEgg.Checked;
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2021-11-22 03:53:13 +00:00
|
|
|
|
private void ReloadToFriendshipTextBox(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
// Show OT friendship always if it is an egg.
|
|
|
|
|
var fs = (pk.IsEgg ? pk.OT_Friendship : pk.CurrentFriendship);
|
|
|
|
|
TB_Friendship.Text = fs.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-03 06:13:40 +00:00
|
|
|
|
private void SaveMisc2(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
SavePKRS(pk);
|
|
|
|
|
pk.IsEgg = CHK_IsEgg.Checked;
|
|
|
|
|
pk.HeldItem = WinFormsUtil.GetIndex(CB_HeldItem);
|
2021-08-07 05:04:11 +00:00
|
|
|
|
pk.Form = CB_Form.Enabled ? CB_Form.SelectedIndex & 0x1F : 0;
|
2019-11-29 18:44:52 +00:00
|
|
|
|
if (Entity is IFormArgument f)
|
2021-02-09 04:26:53 +00:00
|
|
|
|
FA_Form.SaveArgument(f);
|
2021-11-22 03:53:13 +00:00
|
|
|
|
|
|
|
|
|
var friendship = Util.ToInt32(TB_Friendship.Text);
|
|
|
|
|
UpdateFromFriendshipTextBox(pk, friendship);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void UpdateFromFriendshipTextBox(PKM pk, int friendship)
|
|
|
|
|
{
|
|
|
|
|
if (pk.IsEgg)
|
|
|
|
|
pk.OT_Friendship = friendship;
|
|
|
|
|
else
|
|
|
|
|
pk.CurrentFriendship = friendship;
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadMisc3(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
TB_PID.Text = $"{pk.PID:X8}";
|
2022-04-25 03:19:50 +00:00
|
|
|
|
UC_Gender.Gender = pk.Gender;
|
2017-10-03 06:13:40 +00:00
|
|
|
|
CB_Nature.SelectedValue = pk.Nature;
|
|
|
|
|
CB_Language.SelectedValue = pk.Language;
|
|
|
|
|
CB_GameOrigin.SelectedValue = pk.Version;
|
|
|
|
|
CB_Ball.SelectedValue = pk.Ball;
|
|
|
|
|
CB_MetLocation.SelectedValue = pk.Met_Location;
|
|
|
|
|
TB_MetLevel.Text = pk.Met_Level.ToString();
|
|
|
|
|
CHK_Fateful.Checked = pk.FatefulEncounter;
|
|
|
|
|
|
2018-06-03 04:19:03 +00:00
|
|
|
|
if (pk is IContestStats s)
|
|
|
|
|
s.CopyContestStatsTo(Contest);
|
|
|
|
|
|
2018-05-24 23:53:51 +00:00
|
|
|
|
TID_Trainer.LoadIDValues(pk);
|
2017-10-03 06:13:40 +00:00
|
|
|
|
|
|
|
|
|
// Load Extrabyte Value
|
2021-07-31 01:05:17 +00:00
|
|
|
|
var offset = Convert.ToInt32(CB_ExtraBytes.Text, 16);
|
|
|
|
|
var value = pk.Data[offset];
|
|
|
|
|
TB_ExtraByte.Text = value.ToString();
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-10-03 06:13:40 +00:00
|
|
|
|
private void SaveMisc3(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
pk.PID = Util.GetHexValue(TB_PID.Text);
|
|
|
|
|
pk.Nature = WinFormsUtil.GetIndex(CB_Nature);
|
2022-04-25 03:19:50 +00:00
|
|
|
|
pk.Gender = UC_Gender.Gender;
|
2017-10-03 06:13:40 +00:00
|
|
|
|
|
2020-12-24 08:06:40 +00:00
|
|
|
|
if (pk is IContestStatsMutable s)
|
2018-06-03 04:19:03 +00:00
|
|
|
|
Contest.CopyContestStatsTo(s);
|
2017-10-03 06:13:40 +00:00
|
|
|
|
|
|
|
|
|
pk.FatefulEncounter = CHK_Fateful.Checked;
|
|
|
|
|
pk.Ball = WinFormsUtil.GetIndex(CB_Ball);
|
|
|
|
|
pk.Version = WinFormsUtil.GetIndex(CB_GameOrigin);
|
|
|
|
|
pk.Language = WinFormsUtil.GetIndex(CB_Language);
|
2017-10-06 15:22:12 +00:00
|
|
|
|
pk.Met_Level = Util.ToInt32(TB_MetLevel.Text);
|
|
|
|
|
pk.Met_Location = WinFormsUtil.GetIndex(CB_MetLocation);
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadMisc4(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
CAL_MetDate.Value = pk.MetDate ?? new DateTime(2000, 1, 1);
|
2022-05-31 04:43:52 +00:00
|
|
|
|
if (!Legal.IsMetAsEgg(pk))
|
2017-10-03 06:13:40 +00:00
|
|
|
|
{
|
|
|
|
|
CHK_AsEgg.Checked = GB_EggConditions.Enabled = false;
|
|
|
|
|
CAL_EggDate.Value = new DateTime(2000, 01, 01);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Was obtained initially as an egg.
|
|
|
|
|
CHK_AsEgg.Checked = GB_EggConditions.Enabled = true;
|
|
|
|
|
CAL_EggDate.Value = pk.EggMetDate ?? new DateTime(2000, 1, 1);
|
|
|
|
|
}
|
2021-11-20 02:23:49 +00:00
|
|
|
|
CB_EggLocation.SelectedValue = pk.Egg_Location;
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-10-03 06:13:40 +00:00
|
|
|
|
private void SaveMisc4(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
if (CHK_AsEgg.Checked) // If encountered as an egg, load the Egg Met data from fields.
|
|
|
|
|
{
|
2022-05-31 04:43:52 +00:00
|
|
|
|
pk.EggMetDate = CAL_EggDate.Value;
|
|
|
|
|
pk.Egg_Location = WinFormsUtil.GetIndex(CB_EggLocation);
|
|
|
|
|
}
|
|
|
|
|
else // Default Dates
|
|
|
|
|
{
|
|
|
|
|
pk.EggMetDate = null; // clear
|
|
|
|
|
pk.Egg_Location = LocationEdits.GetNoneLocation(pk);
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
2022-05-31 04:43:52 +00:00
|
|
|
|
|
|
|
|
|
// Met Data
|
|
|
|
|
if (pk.IsEgg && pk.Met_Location == LocationEdits.GetNoneLocation(pk)) // If still an egg, it has no hatch location/date. Zero it!
|
|
|
|
|
pk.MetDate = null; // clear
|
|
|
|
|
else
|
|
|
|
|
pk.MetDate = CAL_MetDate.Value;
|
2017-10-03 06:13:40 +00:00
|
|
|
|
|
2019-11-16 01:34:18 +00:00
|
|
|
|
pk.Ability = WinFormsUtil.GetIndex(HaX ? DEV_Ability : CB_Ability);
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadMisc6(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
TB_EC.Text = $"{pk.EncryptionConstant:X8}";
|
|
|
|
|
DEV_Ability.SelectedValue = pk.Ability;
|
2021-07-31 01:05:17 +00:00
|
|
|
|
|
|
|
|
|
// with some simple error handling
|
|
|
|
|
var bitNumber = pk.AbilityNumber;
|
|
|
|
|
int abilityIndex = AbilityVerifier.IsValidAbilityBits(bitNumber) ? bitNumber >> 1 : 0;
|
2022-06-05 03:21:36 +00:00
|
|
|
|
LoadClamp(CB_Ability, abilityIndex);
|
2021-07-31 01:05:17 +00:00
|
|
|
|
TB_AbilityNumber.Text = bitNumber.ToString();
|
2017-10-03 06:13:40 +00:00
|
|
|
|
|
|
|
|
|
LoadRelearnMoves(pk);
|
|
|
|
|
LoadHandlingTrainer(pk);
|
2020-07-31 18:17:31 +00:00
|
|
|
|
|
2020-10-04 21:15:13 +00:00
|
|
|
|
if (pk is IRegionOrigin tr)
|
2020-07-31 18:17:31 +00:00
|
|
|
|
LoadGeolocation(tr);
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-10-03 06:13:40 +00:00
|
|
|
|
private void SaveMisc6(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
pk.EncryptionConstant = Util.GetHexValue(TB_EC.Text);
|
2021-07-31 01:05:17 +00:00
|
|
|
|
if (PIDVerifier.GetTransferEC(pk, out var ec))
|
|
|
|
|
pk.EncryptionConstant = ec;
|
|
|
|
|
|
2017-10-03 06:13:40 +00:00
|
|
|
|
pk.AbilityNumber = Util.ToInt32(TB_AbilityNumber.Text);
|
|
|
|
|
|
|
|
|
|
SaveRelearnMoves(pk);
|
|
|
|
|
SaveHandlingTrainer(pk);
|
2019-11-16 01:34:18 +00:00
|
|
|
|
|
2020-10-04 21:15:13 +00:00
|
|
|
|
if (pk is IRegionOrigin tr)
|
2020-07-31 18:17:31 +00:00
|
|
|
|
SaveGeolocation(tr);
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-04 21:15:13 +00:00
|
|
|
|
private void LoadGeolocation(IRegionOrigin pk)
|
2017-10-03 06:13:40 +00:00
|
|
|
|
{
|
2021-08-03 03:43:32 +00:00
|
|
|
|
CB_Country.SelectedValue = (int)pk.Country;
|
|
|
|
|
CB_SubRegion.SelectedValue = (int)pk.Region;
|
|
|
|
|
CB_3DSReg.SelectedValue = (int)pk.ConsoleRegion;
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2020-10-04 21:15:13 +00:00
|
|
|
|
private void SaveGeolocation(IRegionOrigin pk)
|
2017-10-03 06:13:40 +00:00
|
|
|
|
{
|
2021-08-03 02:43:57 +00:00
|
|
|
|
pk.Country = (byte)WinFormsUtil.GetIndex(CB_Country);
|
|
|
|
|
pk.Region = (byte)WinFormsUtil.GetIndex(CB_SubRegion);
|
|
|
|
|
pk.ConsoleRegion = (byte)WinFormsUtil.GetIndex(CB_3DSReg);
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadHandlingTrainer(PKM pk)
|
|
|
|
|
{
|
2021-07-31 01:05:17 +00:00
|
|
|
|
var handler = pk.HT_Name;
|
2017-10-03 06:13:40 +00:00
|
|
|
|
int gender = pk.HT_Gender & 1;
|
2021-07-31 01:05:17 +00:00
|
|
|
|
|
2022-04-25 03:19:50 +00:00
|
|
|
|
TB_HT.Text = handler;
|
|
|
|
|
UC_HTGender.Gender = gender;
|
|
|
|
|
if (handler.Length == 0)
|
|
|
|
|
UC_HTGender.Visible = false;
|
2017-10-03 06:13:40 +00:00
|
|
|
|
|
2019-10-02 01:12:08 +00:00
|
|
|
|
// Indicate who is currently in possession of the PKM
|
2021-07-31 01:05:17 +00:00
|
|
|
|
UpadteHandlingTrainerBackground(pk.CurrentHandler);
|
2019-10-02 01:12:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-31 01:05:17 +00:00
|
|
|
|
private void UpadteHandlingTrainerBackground(int handler)
|
2019-10-02 01:12:08 +00:00
|
|
|
|
{
|
2021-07-31 01:05:17 +00:00
|
|
|
|
var activeColor = ImageUtil.ChangeOpacity(SpriteUtil.Spriter.Set, 0.5);
|
|
|
|
|
if (handler == 0) // OT
|
2017-10-03 06:13:40 +00:00
|
|
|
|
{
|
2021-07-31 01:05:17 +00:00
|
|
|
|
GB_OT.BackgroundImage = activeColor;
|
2017-10-03 06:13:40 +00:00
|
|
|
|
GB_nOT.BackgroundImage = null;
|
|
|
|
|
}
|
|
|
|
|
else // Handling Trainer
|
|
|
|
|
{
|
2021-07-31 01:05:17 +00:00
|
|
|
|
GB_nOT.BackgroundImage = activeColor;
|
2017-10-03 06:13:40 +00:00
|
|
|
|
GB_OT.BackgroundImage = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-10-03 06:13:40 +00:00
|
|
|
|
private void SaveHandlingTrainer(PKM pk)
|
|
|
|
|
{
|
2022-04-25 03:19:50 +00:00
|
|
|
|
pk.HT_Name = TB_HT.Text;
|
|
|
|
|
pk.HT_Gender = UC_HTGender.Gender;
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadAbility4(PKM pk)
|
|
|
|
|
{
|
2020-09-06 17:53:13 +00:00
|
|
|
|
var index = GetAbilityIndex4(pk);
|
2022-06-05 03:21:36 +00:00
|
|
|
|
LoadClamp(CB_Ability, index);
|
2018-02-11 01:43:00 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2020-09-06 17:53:13 +00:00
|
|
|
|
private static int GetAbilityIndex4(PKM pk)
|
2018-02-11 01:43:00 +00:00
|
|
|
|
{
|
2020-09-06 17:53:13 +00:00
|
|
|
|
var pi = pk.PersonalInfo;
|
|
|
|
|
int abilityIndex = pi.GetAbilityIndex(pk.Ability);
|
2018-02-11 01:43:00 +00:00
|
|
|
|
if (abilityIndex < 0)
|
|
|
|
|
return 0;
|
|
|
|
|
if (abilityIndex >= 2)
|
|
|
|
|
return 2;
|
2020-09-06 17:53:13 +00:00
|
|
|
|
|
|
|
|
|
var abils = pi.Abilities;
|
2018-06-16 06:41:07 +00:00
|
|
|
|
if (abils[0] == abils[1])
|
2018-02-11 01:43:00 +00:00
|
|
|
|
return pk.PIDAbility;
|
|
|
|
|
return abilityIndex;
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
|
|
|
|
|
private void LoadMisc8(PK8 pk8)
|
|
|
|
|
{
|
|
|
|
|
CB_StatNature.SelectedValue = pk8.StatNature;
|
2022-06-05 03:21:36 +00:00
|
|
|
|
LoadClamp(Stats.CB_DynamaxLevel, pk8.DynamaxLevel);
|
2019-11-16 01:34:18 +00:00
|
|
|
|
Stats.CHK_Gigantamax.Checked = pk8.CanGigantamax;
|
2022-03-06 20:01:47 +00:00
|
|
|
|
CB_HTLanguage.SelectedValue = (int)pk8.HT_Language;
|
2020-02-13 02:10:03 +00:00
|
|
|
|
TB_HomeTracker.Text = pk8.Tracker.ToString("X16");
|
2022-03-06 20:01:47 +00:00
|
|
|
|
CB_BattleVersion.SelectedValue = (int)pk8.BattleVersion;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SaveMisc8(PK8 pk8)
|
|
|
|
|
{
|
|
|
|
|
pk8.StatNature = WinFormsUtil.GetIndex(CB_StatNature);
|
|
|
|
|
pk8.DynamaxLevel = (byte)Math.Max(0, Stats.CB_DynamaxLevel.SelectedIndex);
|
|
|
|
|
pk8.CanGigantamax = Stats.CHK_Gigantamax.Checked;
|
2022-03-06 20:01:47 +00:00
|
|
|
|
pk8.HT_Language = (byte)WinFormsUtil.GetIndex(CB_HTLanguage);
|
|
|
|
|
pk8.BattleVersion = (byte)WinFormsUtil.GetIndex(CB_BattleVersion);
|
2019-11-16 01:34:18 +00:00
|
|
|
|
}
|
2021-11-20 02:23:49 +00:00
|
|
|
|
|
|
|
|
|
private void LoadMisc8(PB8 pk8)
|
|
|
|
|
{
|
|
|
|
|
CB_StatNature.SelectedValue = pk8.StatNature;
|
2022-06-05 03:21:36 +00:00
|
|
|
|
LoadClamp(Stats.CB_DynamaxLevel, pk8.DynamaxLevel);
|
2021-11-20 02:23:49 +00:00
|
|
|
|
Stats.CHK_Gigantamax.Checked = pk8.CanGigantamax;
|
2022-03-06 20:01:47 +00:00
|
|
|
|
CB_HTLanguage.SelectedValue = (int)pk8.HT_Language;
|
2021-11-20 02:23:49 +00:00
|
|
|
|
TB_HomeTracker.Text = pk8.Tracker.ToString("X16");
|
2022-03-06 20:01:47 +00:00
|
|
|
|
CB_BattleVersion.SelectedValue = (int)pk8.BattleVersion;
|
2021-11-20 02:23:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SaveMisc8(PB8 pk8)
|
|
|
|
|
{
|
|
|
|
|
pk8.StatNature = WinFormsUtil.GetIndex(CB_StatNature);
|
|
|
|
|
pk8.DynamaxLevel = (byte)Math.Max(0, Stats.CB_DynamaxLevel.SelectedIndex);
|
|
|
|
|
pk8.CanGigantamax = Stats.CHK_Gigantamax.Checked;
|
2022-03-06 20:01:47 +00:00
|
|
|
|
pk8.HT_Language = (byte)WinFormsUtil.GetIndex(CB_HTLanguage);
|
|
|
|
|
pk8.BattleVersion = (byte)WinFormsUtil.GetIndex(CB_BattleVersion);
|
2021-11-20 02:23:49 +00:00
|
|
|
|
}
|
2022-02-05 01:36:51 +00:00
|
|
|
|
|
|
|
|
|
private void LoadMisc8(PA8 pk8)
|
|
|
|
|
{
|
|
|
|
|
CB_StatNature.SelectedValue = pk8.StatNature;
|
2022-06-05 03:21:36 +00:00
|
|
|
|
LoadClamp(Stats.CB_DynamaxLevel, pk8.DynamaxLevel);
|
2022-02-05 01:36:51 +00:00
|
|
|
|
Stats.CHK_Gigantamax.Checked = pk8.CanGigantamax;
|
2022-03-06 20:01:47 +00:00
|
|
|
|
CB_HTLanguage.SelectedValue = (int)pk8.HT_Language;
|
2022-02-05 01:36:51 +00:00
|
|
|
|
TB_HomeTracker.Text = pk8.Tracker.ToString("X16");
|
2022-03-06 20:01:47 +00:00
|
|
|
|
CB_BattleVersion.SelectedValue = (int)pk8.BattleVersion;
|
2022-02-05 01:36:51 +00:00
|
|
|
|
Stats.CHK_IsAlpha.Checked = pk8.IsAlpha;
|
|
|
|
|
Stats.CHK_IsNoble.Checked = pk8.IsNoble;
|
2022-03-06 20:01:47 +00:00
|
|
|
|
CB_AlphaMastered.SelectedValue = (int)pk8.AlphaMove;
|
2022-02-05 01:36:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SaveMisc8(PA8 pk8)
|
|
|
|
|
{
|
|
|
|
|
pk8.StatNature = WinFormsUtil.GetIndex(CB_StatNature);
|
|
|
|
|
pk8.DynamaxLevel = (byte)Math.Max(0, Stats.CB_DynamaxLevel.SelectedIndex);
|
|
|
|
|
pk8.CanGigantamax = Stats.CHK_Gigantamax.Checked;
|
2022-03-06 20:01:47 +00:00
|
|
|
|
pk8.HT_Language = (byte)WinFormsUtil.GetIndex(CB_HTLanguage);
|
|
|
|
|
pk8.BattleVersion = (byte)WinFormsUtil.GetIndex(CB_BattleVersion);
|
2022-02-05 01:36:51 +00:00
|
|
|
|
pk8.IsAlpha = Stats.CHK_IsAlpha.Checked;
|
|
|
|
|
pk8.IsNoble = Stats.CHK_IsNoble.Checked;
|
2022-03-06 20:01:47 +00:00
|
|
|
|
pk8.AlphaMove = (ushort)WinFormsUtil.GetIndex(CB_AlphaMastered);
|
2022-02-05 01:36:51 +00:00
|
|
|
|
}
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|