2017-10-03 06:13:40 +00:00
|
|
|
|
using System;
|
|
|
|
|
using PKHeX.Core;
|
2019-10-02 01:12:08 +00:00
|
|
|
|
using PKHeX.Drawing;
|
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)
|
|
|
|
|
{
|
|
|
|
|
// Do first
|
2019-11-16 01:34:18 +00:00
|
|
|
|
pk.Stat_Level = Experience.GetLevel(pk.EXP, pk.PersonalInfo.EXPGrowth);
|
2017-10-03 06:13:40 +00:00
|
|
|
|
if (pk.Stat_Level == 100 && !HaX)
|
2019-11-16 01:34:18 +00:00
|
|
|
|
pk.EXP = Experience.GetEXP(pk.Stat_Level, pk.PersonalInfo.EXPGrowth);
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-24 23:53:51 +00:00
|
|
|
|
private void LoadOT(PKM pk)
|
2017-10-03 06:13:40 +00:00
|
|
|
|
{
|
|
|
|
|
GB_OT.BackgroundImage = null;
|
|
|
|
|
TB_OT.Text = pk.OT_Name;
|
|
|
|
|
Label_OTGender.Text = gendersymbols[pk.OT_Gender];
|
2019-02-09 21:15:37 +00:00
|
|
|
|
Label_OTGender.ForeColor = Draw.GetGenderColor(pk.OT_Gender);
|
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;
|
|
|
|
|
pk.OT_Gender = PKX.GetGenderFromString(Label_OTGender.Text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadPKRS(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
Label_PKRS.Visible = CB_PKRSStrain.Visible = CHK_Infected.Checked = pk.PKRS_Strain != 0;
|
|
|
|
|
Label_PKRSdays.Visible = CB_PKRSDays.Visible = pk.PKRS_Days != 0;
|
|
|
|
|
CB_PKRSStrain.SelectedIndex = pk.PKRS_Strain;
|
|
|
|
|
CHK_Cured.Checked = pk.PKRS_Strain > 0 && pk.PKRS_Days == 0;
|
|
|
|
|
CB_PKRSDays.SelectedIndex = Math.Min(CB_PKRSDays.Items.Count - 1, pk.PKRS_Days); // to strip out bad hacked 'rus
|
|
|
|
|
}
|
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);
|
2018-11-14 03:25:03 +00:00
|
|
|
|
private void LoadAVs(IAwakened a) => Stats.LoadAVs(a);
|
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;
|
|
|
|
|
CB_PPu1.SelectedIndex = pk.Move1_PPUps;
|
|
|
|
|
CB_PPu2.SelectedIndex = pk.Move2_PPUps;
|
|
|
|
|
CB_PPu3.SelectedIndex = pk.Move3_PPUps;
|
|
|
|
|
CB_PPu4.SelectedIndex = pk.Move4_PPUps;
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadShadow3(IShadowPKM ck3)
|
|
|
|
|
{
|
|
|
|
|
NUD_ShadowID.Value = ck3.ShadowID;
|
|
|
|
|
FLP_Purification.Visible = ck3.ShadowID > 0;
|
|
|
|
|
if (ck3.ShadowID > 0)
|
|
|
|
|
{
|
|
|
|
|
int value = ck3.Purification;
|
|
|
|
|
if (value < NUD_Purification.Minimum)
|
|
|
|
|
value = (int)NUD_Purification.Minimum;
|
|
|
|
|
|
|
|
|
|
NUD_Purification.Value = value;
|
|
|
|
|
CHK_Shadow.Checked = value > 0;
|
|
|
|
|
|
|
|
|
|
NUD_ShadowID.Value = Math.Max(ck3.ShadowID, 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NUD_Purification.Value = 0;
|
|
|
|
|
CHK_Shadow.Checked = false;
|
|
|
|
|
NUD_ShadowID.Value = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-10-03 06:13:40 +00:00
|
|
|
|
private void SaveShadow3(IShadowPKM ck3)
|
|
|
|
|
{
|
|
|
|
|
ck3.ShadowID = (int)NUD_ShadowID.Value;
|
|
|
|
|
if (ck3.ShadowID > 0)
|
|
|
|
|
ck3.Purification = (int)NUD_Purification.Value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2017-10-03 06:13:40 +00:00
|
|
|
|
private void SaveRelearnMoves(PKM pk7)
|
|
|
|
|
{
|
|
|
|
|
pk7.RelearnMove1 = WinFormsUtil.GetIndex(CB_RelearnMove1);
|
|
|
|
|
pk7.RelearnMove2 = WinFormsUtil.GetIndex(CB_RelearnMove2);
|
|
|
|
|
pk7.RelearnMove3 = WinFormsUtil.GetIndex(CB_RelearnMove3);
|
|
|
|
|
pk7.RelearnMove4 = WinFormsUtil.GetIndex(CB_RelearnMove4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
CB_Form.SelectedIndex = CB_Form.Items.Count > pk.AltForm ? pk.AltForm : CB_Form.Items.Count - 1;
|
2019-11-29 18:44:52 +00:00
|
|
|
|
if (pk is IFormArgument f)
|
2020-01-14 01:09:03 +00:00
|
|
|
|
CB_FormArgument.SelectedIndex = CB_FormArgument.Items.Count > f.FormArgument ? (int)f.FormArgument : CB_FormArgument.Items.Count - 1;
|
2019-11-29 18:44:52 +00:00
|
|
|
|
|
2017-10-05 23:06:51 +00:00
|
|
|
|
TB_Friendship.Text = pk.CurrentFriendship.ToString();
|
2017-10-26 02:37:31 +00:00
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Label_HatchCounter.Visible = CHK_IsEgg.Checked && Entity.Format > 1;
|
|
|
|
|
Label_Friendship.Visible = !CHK_IsEgg.Checked && Entity.Format > 1;
|
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 SaveMisc2(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
SavePKRS(pk);
|
|
|
|
|
pk.IsEgg = CHK_IsEgg.Checked;
|
|
|
|
|
pk.HeldItem = WinFormsUtil.GetIndex(CB_HeldItem);
|
|
|
|
|
pk.AltForm = (MT_Form.Enabled ? Convert.ToInt32(MT_Form.Text) : CB_Form.Enabled ? CB_Form.SelectedIndex : 0) & 0x1F;
|
2019-11-29 18:44:52 +00:00
|
|
|
|
if (Entity is IFormArgument f)
|
|
|
|
|
f.FormArgument = (uint)Math.Max(0, CB_FormArgument.SelectedIndex);
|
2017-10-05 23:06:51 +00:00
|
|
|
|
pk.CurrentFriendship = Util.ToInt32(TB_Friendship.Text);
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadMisc3(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
TB_PID.Text = $"{pk.PID:X8}";
|
2019-12-26 22:27:17 +00:00
|
|
|
|
Label_Gender.Text = gendersymbols[Math.Min(2, pk.Gender)];
|
2019-02-09 21:15:37 +00:00
|
|
|
|
Label_Gender.ForeColor = Draw.GetGenderColor(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
|
|
|
|
|
TB_ExtraByte.Text = pk.Data[Convert.ToInt32(CB_ExtraBytes.Text, 16)].ToString();
|
|
|
|
|
}
|
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);
|
|
|
|
|
pk.Gender = PKX.GetGenderFromString(Label_Gender.Text);
|
|
|
|
|
|
2018-06-03 04:19:03 +00:00
|
|
|
|
if (pk is IContestStats s)
|
|
|
|
|
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);
|
|
|
|
|
if (pk.Egg_Location == 0)
|
|
|
|
|
{
|
|
|
|
|
CHK_AsEgg.Checked = GB_EggConditions.Enabled = false;
|
|
|
|
|
|
|
|
|
|
CB_EggLocation.SelectedValue = 0;
|
|
|
|
|
CAL_EggDate.Value = new DateTime(2000, 01, 01);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Was obtained initially as an egg.
|
|
|
|
|
CHK_AsEgg.Checked = GB_EggConditions.Enabled = true;
|
|
|
|
|
|
|
|
|
|
CB_EggLocation.SelectedValue = pk.Egg_Location;
|
|
|
|
|
CAL_EggDate.Value = pk.EggMetDate ?? new DateTime(2000, 1, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-10-03 06:13:40 +00:00
|
|
|
|
private void SaveMisc4(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
pk.MetDate = CAL_MetDate.Value;
|
|
|
|
|
|
|
|
|
|
// Default Dates
|
|
|
|
|
DateTime? egg_date = null;
|
|
|
|
|
int egg_location = 0;
|
|
|
|
|
if (CHK_AsEgg.Checked) // If encountered as an egg, load the Egg Met data from fields.
|
|
|
|
|
{
|
|
|
|
|
egg_date = CAL_EggDate.Value;
|
|
|
|
|
egg_location = WinFormsUtil.GetIndex(CB_EggLocation);
|
|
|
|
|
}
|
|
|
|
|
// Egg Met Data
|
|
|
|
|
pk.EggMetDate = egg_date;
|
|
|
|
|
pk.Egg_Location = egg_location;
|
|
|
|
|
if (pk.IsEgg && pk.Met_Location == 0) // If still an egg, it has no hatch location/date. Zero it!
|
|
|
|
|
pk.MetDate = null;
|
|
|
|
|
|
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}";
|
2017-11-09 05:56:56 +00:00
|
|
|
|
int abil = pk.AbilityNumber < 6 ? pk.AbilityNumber >> 1 : 0;
|
|
|
|
|
if (CB_Ability.Items.Count <= abil)
|
|
|
|
|
abil = CB_Ability.Items.Count - 1;
|
|
|
|
|
CB_Ability.SelectedIndex = abil; // with some simple error handling
|
2017-10-03 06:13:40 +00:00
|
|
|
|
DEV_Ability.SelectedValue = pk.Ability;
|
|
|
|
|
TB_AbilityNumber.Text = pk.AbilityNumber.ToString();
|
|
|
|
|
|
|
|
|
|
LoadRelearnMoves(pk);
|
|
|
|
|
LoadHandlingTrainer(pk);
|
|
|
|
|
LoadGeolocation(pk);
|
|
|
|
|
}
|
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);
|
|
|
|
|
pk.AbilityNumber = Util.ToInt32(TB_AbilityNumber.Text);
|
|
|
|
|
|
|
|
|
|
SaveRelearnMoves(pk);
|
|
|
|
|
SaveHandlingTrainer(pk);
|
2019-11-16 01:34:18 +00:00
|
|
|
|
|
|
|
|
|
if (pk.Format <= 7 && !(pk is PB7))
|
|
|
|
|
SaveGeolocation(pk);
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadGeolocation(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
CB_Country.SelectedValue = pk.Country;
|
|
|
|
|
CB_SubRegion.SelectedValue = pk.Region;
|
|
|
|
|
CB_3DSReg.SelectedValue = pk.ConsoleRegion;
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-10-03 06:13:40 +00:00
|
|
|
|
private void SaveGeolocation(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
pk.Country = WinFormsUtil.GetIndex(CB_Country);
|
|
|
|
|
pk.Region = WinFormsUtil.GetIndex(CB_SubRegion);
|
|
|
|
|
pk.ConsoleRegion = WinFormsUtil.GetIndex(CB_3DSReg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadHandlingTrainer(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
TB_OTt2.Text = pk.HT_Name;
|
|
|
|
|
int gender = pk.HT_Gender & 1;
|
|
|
|
|
// Set CT Gender to None if no CT, else set to gender symbol.
|
|
|
|
|
Label_CTGender.Text = string.IsNullOrEmpty(pk.HT_Name) ? string.Empty : gendersymbols[gender];
|
2019-02-09 21:15:37 +00:00
|
|
|
|
Label_CTGender.ForeColor = Draw.GetGenderColor(gender);
|
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
|
|
|
|
|
UpadteHandlingTrainerBackground(pk);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpadteHandlingTrainerBackground(PKM pk)
|
|
|
|
|
{
|
2017-10-03 06:13:40 +00:00
|
|
|
|
if (pk.CurrentHandler == 0) // OT
|
|
|
|
|
{
|
2019-11-16 01:34:18 +00:00
|
|
|
|
GB_OT.BackgroundImage = ImageUtil.ChangeOpacity(SpriteUtil.Spriter.Set, 0.5);
|
2017-10-03 06:13:40 +00:00
|
|
|
|
GB_nOT.BackgroundImage = null;
|
|
|
|
|
}
|
|
|
|
|
else // Handling Trainer
|
|
|
|
|
{
|
2019-11-16 01:34:18 +00:00
|
|
|
|
GB_nOT.BackgroundImage = ImageUtil.ChangeOpacity(SpriteUtil.Spriter.Set, 0.5);
|
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)
|
|
|
|
|
{
|
|
|
|
|
pk.HT_Name = TB_OTt2.Text;
|
|
|
|
|
pk.HT_Gender = PKX.GetGenderFromString(Label_CTGender.Text) & 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Misc
|
|
|
|
|
private void CheckTransferPIDValid()
|
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Version >= 24)
|
2017-10-03 06:13:40 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
uint EC = Util.GetHexValue(TB_EC.Text);
|
|
|
|
|
uint PID = Util.GetHexValue(TB_PID.Text);
|
|
|
|
|
uint LID = PID & 0xFFFF;
|
|
|
|
|
uint HID = PID >> 16;
|
2019-10-27 19:57:04 +00:00
|
|
|
|
uint XOR = (uint)(Entity.TID ^ LID ^ Entity.SID ^ HID);
|
2017-10-03 06:13:40 +00:00
|
|
|
|
|
|
|
|
|
// Ensure we don't have a shiny.
|
|
|
|
|
if (XOR >> 3 == 1) // Illegal, fix. (not 16<XOR>=8)
|
|
|
|
|
{
|
|
|
|
|
// Keep as shiny, so we have to mod the PID
|
|
|
|
|
PID ^= XOR;
|
|
|
|
|
TB_PID.Text = PID.ToString("X8");
|
|
|
|
|
TB_EC.Text = PID.ToString("X8");
|
|
|
|
|
}
|
|
|
|
|
else if ((XOR ^ 0x8000) >> 3 == 1 && PID != EC)
|
2018-07-27 02:34:27 +00:00
|
|
|
|
{
|
2017-10-03 06:13:40 +00:00
|
|
|
|
TB_EC.Text = (PID ^ 0x80000000).ToString("X8");
|
2018-07-27 02:34:27 +00:00
|
|
|
|
}
|
2017-10-03 06:13:40 +00:00
|
|
|
|
else // Not illegal, no fix.
|
2018-07-27 02:34:27 +00:00
|
|
|
|
{
|
2017-10-03 06:13:40 +00:00
|
|
|
|
TB_EC.Text = PID.ToString("X8");
|
2018-07-27 02:34:27 +00:00
|
|
|
|
}
|
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 LoadAbility4(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
int[] abils = pk.PersonalInfo.Abilities;
|
2018-02-11 01:43:00 +00:00
|
|
|
|
var index = GetAbilityIndex4(pk, abils);
|
|
|
|
|
|
|
|
|
|
CB_Ability.SelectedIndex = Math.Min(CB_Ability.Items.Count - 1, index);
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-02-11 01:43:00 +00:00
|
|
|
|
private static int GetAbilityIndex4(PKM pk, int[] abils)
|
|
|
|
|
{
|
|
|
|
|
int abilityIndex = Array.IndexOf(abils, pk.Ability);
|
|
|
|
|
if (abilityIndex < 0)
|
|
|
|
|
return 0;
|
|
|
|
|
if (abilityIndex >= 2)
|
|
|
|
|
return 2;
|
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;
|
|
|
|
|
Stats.CB_DynamaxLevel.SelectedIndex = pk8.DynamaxLevel;
|
|
|
|
|
Stats.CHK_Gigantamax.Checked = pk8.CanGigantamax;
|
|
|
|
|
CB_HTLanguage.SelectedValue = pk8.HT_Language;
|
2020-02-13 02:10:03 +00:00
|
|
|
|
TB_HomeTracker.Text = pk8.Tracker.ToString("X16");
|
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;
|
|
|
|
|
pk8.HT_Language = WinFormsUtil.GetIndex(CB_HTLanguage);
|
|
|
|
|
}
|
2017-10-03 06:13:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|