PKHeX/PKHeX.WinForms/Controls/PKM Editor/EditPK5.cs

54 lines
1.5 KiB
C#
Raw Normal View History

using System;
using PKHeX.Core;
2016-07-09 23:17:55 +00:00
namespace PKHeX.WinForms.Controls
2016-07-09 23:17:55 +00:00
{
public partial class PKMEditor
2016-07-09 23:17:55 +00:00
{
private void PopulateFieldsPK5()
2016-07-09 23:17:55 +00:00
{
2020-12-23 05:24:41 +00:00
if (Entity is not PK5 pk5)
throw new FormatException(nameof(Entity));
2016-07-09 23:17:55 +00:00
LoadMisc1(pk5);
LoadMisc2(pk5);
LoadMisc3(pk5);
LoadMisc4(pk5);
CB_EncounterType.SelectedValue = pk5.Gen4 ? (int)pk5.GroundTile : 0;
CB_EncounterType.Visible = Label_EncounterType.Visible = pk5.Gen4;
CHK_NSparkle.Checked = pk5.NPokémon;
2016-07-09 23:17:55 +00:00
if (HaX)
DEV_Ability.SelectedValue = pk5.Ability;
else if (pk5.HiddenAbility)
CB_Ability.SelectedIndex = CB_Ability.Items.Count - 1;
else
LoadAbility4(pk5);
LoadPartyStats(pk5);
UpdateStats();
2016-07-09 23:17:55 +00:00
}
private PK5 PreparePK5()
2016-07-09 23:17:55 +00:00
{
2020-12-23 05:24:41 +00:00
if (Entity is not PK5 pk5)
throw new FormatException(nameof(Entity));
2016-07-09 23:17:55 +00:00
SaveMisc1(pk5);
SaveMisc2(pk5);
SaveMisc3(pk5);
SaveMisc4(pk5);
2016-07-09 23:17:55 +00:00
pk5.GroundTile = (GroundTileType)WinFormsUtil.GetIndex(CB_EncounterType);
pk5.NPokémon = CHK_NSparkle.Checked;
if (!HaX) // specify via extra 0x42 instead
pk5.HiddenAbility = CB_Ability.SelectedIndex > 1; // not 0 or 1
SavePartyStats(pk5);
2016-07-09 23:17:55 +00:00
pk5.FixMoves();
pk5.RefreshChecksum();
return pk5;
}
}
}