2019-10-27 19:57:04 +00:00
|
|
|
|
using System;
|
|
|
|
|
using PKHeX.Core;
|
2016-07-09 23:17:55 +00:00
|
|
|
|
|
2017-05-23 04:55:05 +00:00
|
|
|
|
namespace PKHeX.WinForms.Controls
|
2016-07-09 23:17:55 +00:00
|
|
|
|
{
|
2017-05-23 04:55:05 +00:00
|
|
|
|
public partial class PKMEditor
|
2016-07-09 23:17:55 +00:00
|
|
|
|
{
|
2017-06-18 01:37:19 +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)
|
2019-10-27 19:57:04 +00:00
|
|
|
|
throw new FormatException(nameof(Entity));
|
2016-07-09 23:17:55 +00:00
|
|
|
|
|
2017-10-03 06:13:40 +00:00
|
|
|
|
LoadMisc1(pk5);
|
|
|
|
|
LoadMisc2(pk5);
|
|
|
|
|
LoadMisc3(pk5);
|
|
|
|
|
LoadMisc4(pk5);
|
2021-06-30 03:58:06 +00:00
|
|
|
|
CB_EncounterType.SelectedValue = pk5.Gen4 ? (int)pk5.GroundTile : 0;
|
2019-10-27 19:57:04 +00:00
|
|
|
|
CB_EncounterType.Visible = Label_EncounterType.Visible = pk5.Gen4;
|
2016-09-05 21:26:21 +00:00
|
|
|
|
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
|
2017-10-03 06:13:40 +00:00
|
|
|
|
LoadAbility4(pk5);
|
Implement PID-Ability corrections
Line 2211:
When the fields are loaded, if the user modifies the Ability on a <=Gen5
save file, if the ability is modified, the PID will be randomized to fit
the new PID.
When the Ability combobox is loaded, the personal entry may have 0 for
the ability2 (indicating same as ability1); if so, copy ability1 instead
of filtering it out.
When the Ability index is loaded, hidden ability is checked first, else
it tries to match: invalid, hidden (unflagged=illegal), if abilities
same use PIDAbility, else use the actual ability index.
2016-08-23 03:37:50 +00:00
|
|
|
|
|
2017-10-03 06:13:40 +00:00
|
|
|
|
LoadPartyStats(pk5);
|
|
|
|
|
UpdateStats();
|
2016-07-09 23:17:55 +00:00
|
|
|
|
}
|
2017-10-03 06:13:40 +00:00
|
|
|
|
|
2019-10-27 19:57:04 +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)
|
2019-10-27 19:57:04 +00:00
|
|
|
|
throw new FormatException(nameof(Entity));
|
2016-07-09 23:17:55 +00:00
|
|
|
|
|
2017-10-03 06:13:40 +00:00
|
|
|
|
SaveMisc1(pk5);
|
|
|
|
|
SaveMisc2(pk5);
|
|
|
|
|
SaveMisc3(pk5);
|
|
|
|
|
SaveMisc4(pk5);
|
2016-07-09 23:17:55 +00:00
|
|
|
|
|
2021-06-30 03:58:06 +00:00
|
|
|
|
pk5.GroundTile = (GroundTileType)WinFormsUtil.GetIndex(CB_EncounterType);
|
2016-09-05 21:26:21 +00:00
|
|
|
|
pk5.NPokémon = CHK_NSparkle.Checked;
|
2018-02-20 07:34:07 +00:00
|
|
|
|
if (!HaX) // specify via extra 0x42 instead
|
|
|
|
|
pk5.HiddenAbility = CB_Ability.SelectedIndex > 1; // not 0 or 1
|
2016-09-05 21:26:21 +00:00
|
|
|
|
|
2017-10-03 06:13:40 +00:00
|
|
|
|
SavePartyStats(pk5);
|
2016-07-09 23:17:55 +00:00
|
|
|
|
pk5.FixMoves();
|
|
|
|
|
pk5.RefreshChecksum();
|
|
|
|
|
return pk5;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|