mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-09-14 01:55:19 -05:00
Split up setforms
individual forms do it themselves, allows for main window to handle more generations
This commit is contained in:
@@ -1027,7 +1027,7 @@ public void populateFields(PKM pk, bool focus = true)
|
||||
if (focus)
|
||||
Tab_Main.Focus();
|
||||
|
||||
pkm = pk;
|
||||
pkm = pk.Clone();
|
||||
if (fieldsInitialized & !pkm.ChecksumValid)
|
||||
Util.Alert("PKX File has an invalid checksum.");
|
||||
switch (pkm.Format)
|
||||
@@ -1261,8 +1261,8 @@ private void populateFieldsPK4(PK4 pk4)
|
||||
TB_PP3.Text = pk4.Move3_PP.ToString();
|
||||
TB_PP4.Text = pk4.Move4_PP.ToString();
|
||||
|
||||
// Set Form if count is enough, else if count is more than 1 set equal to max else zero.
|
||||
CB_Form.SelectedIndex = CB_Form.Items.Count > pk4.AltForm ? pk4.AltForm : (CB_Form.Items.Count > 1 ? CB_Form.Items.Count - 1 : 0);
|
||||
// Set Form if count is enough, else cap.
|
||||
CB_Form.SelectedIndex = CB_Form.Items.Count > pk4.AltForm ? pk4.AltForm : CB_Form.Items.Count - 1;
|
||||
|
||||
// Load Extrabyte Value
|
||||
TB_ExtraByte.Text = pk4.Data[Convert.ToInt32(CB_ExtraBytes.Text, 16)].ToString();
|
||||
@@ -1384,8 +1384,8 @@ private void populateFieldsPK5(PK5 pk5)
|
||||
TB_PP3.Text = pk5.Move3_PP.ToString();
|
||||
TB_PP4.Text = pk5.Move4_PP.ToString();
|
||||
|
||||
// Set Form if count is enough, else if count is more than 1 set equal to max else zero.
|
||||
CB_Form.SelectedIndex = CB_Form.Items.Count > pk5.AltForm ? pk5.AltForm : (CB_Form.Items.Count > 1 ? CB_Form.Items.Count - 1 : 0);
|
||||
// Set Form if count is enough, else cap.
|
||||
CB_Form.SelectedIndex = CB_Form.Items.Count > pk5.AltForm ? pk5.AltForm : CB_Form.Items.Count - 1;
|
||||
|
||||
// Load Extrabyte Value
|
||||
TB_ExtraByte.Text = pk5.Data[Convert.ToInt32(CB_ExtraBytes.Text, 16)].ToString();
|
||||
@@ -1521,8 +1521,8 @@ private void populateFieldsPK6(PK6 pk6)
|
||||
TB_PP3.Text = pk6.Move3_PP.ToString();
|
||||
TB_PP4.Text = pk6.Move4_PP.ToString();
|
||||
|
||||
// Set Form if count is enough, else if count is more than 1 set equal to max else zero.
|
||||
CB_Form.SelectedIndex = CB_Form.Items.Count > pk6.AltForm ? pk6.AltForm : (CB_Form.Items.Count > 1 ? CB_Form.Items.Count - 1 : 0);
|
||||
// Set Form if count is enough, else cap.
|
||||
CB_Form.SelectedIndex = CB_Form.Items.Count > pk6.AltForm ? pk6.AltForm : CB_Form.Items.Count - 1;
|
||||
|
||||
// Load Extrabyte Value
|
||||
TB_ExtraByte.Text = pk6.Data[Convert.ToInt32(CB_ExtraBytes.Text, 16)].ToString();
|
||||
@@ -1554,16 +1554,22 @@ internal static void setCountrySubRegion(ComboBox CB, string type)
|
||||
if (index > 0 && index < CB.Items.Count && fieldsInitialized)
|
||||
CB.SelectedIndex = index;
|
||||
}
|
||||
internal static void setForms(int species, ComboBox cb, Label l = null)
|
||||
private void setForms()
|
||||
{
|
||||
// Form Tables
|
||||
cb.DisplayMember = "Text";
|
||||
cb.ValueMember = "Value";
|
||||
bool hasForms = PKX.Personal[species].HasFormes || new[] { 664, 665, 414, }.Contains(species);
|
||||
cb.Enabled = cb.Visible = hasForms;
|
||||
if (l != null) l.Visible = hasForms;
|
||||
|
||||
cb.DataSource = PKX.getFormList(species, types, forms, gendersymbols).ToList();
|
||||
if (SAV.Generation < 4)
|
||||
{
|
||||
Label_Form.Visible = CB_Form.Visible = CB_Form.Enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
int species = Util.getIndex(CB_Species);
|
||||
bool hasForms = SAV.Personal[species].HasFormes || new[] { 664, 665, 414 }.Contains(species);
|
||||
CB_Form.Enabled = CB_Form.Visible = Label_Form.Visible = hasForms;
|
||||
|
||||
if (!hasForms)
|
||||
return;
|
||||
|
||||
CB_Form.DataSource = PKX.getFormList(species, types, forms, gendersymbols).ToList();
|
||||
}
|
||||
private void setAbilityList()
|
||||
{
|
||||
@@ -2155,7 +2161,7 @@ private void updateSpecies(object sender, EventArgs e)
|
||||
if (MT_Level.Visible) Level = Util.ToInt32(MT_Level.Text);
|
||||
|
||||
// Get Forms for Given Species
|
||||
setForms(Species, CB_Form, Label_Form);
|
||||
setForms();
|
||||
|
||||
// Recalculate EXP for Given Level
|
||||
uint EXP = PKX.getEXP(Level, Species);
|
||||
@@ -2885,7 +2891,7 @@ private PK4 preparePK4()
|
||||
|
||||
pk4.FatefulEncounter = CHK_Fateful.Checked;
|
||||
pk4.Gender = PKX.getGender(Label_Gender.Text);
|
||||
pk4.AltForm = (MT_Form.Enabled ? Convert.ToInt32(MT_Form.Text) : CB_Form.SelectedIndex) & 0x1F;
|
||||
pk4.AltForm = (MT_Form.Enabled ? Convert.ToInt32(MT_Form.Text) : CB_Form.Enabled ? CB_Form.SelectedIndex : 0) & 0x1F;
|
||||
pk4.EV_HP = Util.ToInt32(TB_HPEV.Text);
|
||||
pk4.EV_ATK = Util.ToInt32(TB_ATKEV.Text);
|
||||
pk4.EV_DEF = Util.ToInt32(TB_DEFEV.Text);
|
||||
@@ -3001,7 +3007,7 @@ private PK5 preparePK5()
|
||||
pk5.Nature = (byte)Util.getIndex(CB_Nature);
|
||||
pk5.FatefulEncounter = CHK_Fateful.Checked;
|
||||
pk5.Gender = PKX.getGender(Label_Gender.Text);
|
||||
pk5.AltForm = (MT_Form.Enabled ? Convert.ToInt32(MT_Form.Text) : CB_Form.SelectedIndex) & 0x1F;
|
||||
pk5.AltForm = (MT_Form.Enabled ? Convert.ToInt32(MT_Form.Text) : CB_Form.Enabled ? CB_Form.SelectedIndex : 0) & 0x1F;
|
||||
pk5.EV_HP = Util.ToInt32(TB_HPEV.Text);
|
||||
pk5.EV_ATK = Util.ToInt32(TB_ATKEV.Text);
|
||||
pk5.EV_DEF = Util.ToInt32(TB_DEFEV.Text);
|
||||
@@ -3145,7 +3151,7 @@ private PK6 preparePK6()
|
||||
pk6.Nature = (byte)Util.getIndex(CB_Nature);
|
||||
pk6.FatefulEncounter = CHK_Fateful.Checked;
|
||||
pk6.Gender = PKX.getGender(Label_Gender.Text);
|
||||
pk6.AltForm = (MT_Form.Enabled ? Convert.ToInt32(MT_Form.Text) : CB_Form.SelectedIndex) & 0x1F; // Form
|
||||
pk6.AltForm = (MT_Form.Enabled ? Convert.ToInt32(MT_Form.Text) : CB_Form.Enabled ? CB_Form.SelectedIndex : 0) & 0x1F;
|
||||
pk6.EV_HP = Util.ToInt32(TB_HPEV.Text); // EVs
|
||||
pk6.EV_ATK = Util.ToInt32(TB_ATKEV.Text);
|
||||
pk6.EV_DEF = Util.ToInt32(TB_DEFEV.Text);
|
||||
|
||||
@@ -231,7 +231,7 @@ private void NUP_PartyIndex_ValueChanged(object sender, EventArgs e)
|
||||
|
||||
CHK_Nicknamed.Checked = nick == 1;
|
||||
|
||||
Main.setForms(species, CB_Form);
|
||||
setForms();
|
||||
CB_Form.SelectedIndex = (int)form;
|
||||
setGenderLabel((int)gender);
|
||||
updateNickname(sender, e);
|
||||
@@ -359,10 +359,20 @@ private void updateNickname(object sender, EventArgs e)
|
||||
|
||||
Write_Entry(null, null);
|
||||
}
|
||||
private void updateSpecies(object sender, EventArgs e)
|
||||
|
||||
private void setForms()
|
||||
{
|
||||
int species = Util.getIndex(CB_Species);
|
||||
Main.setForms(species, CB_Form);
|
||||
bool hasForms = Legal.PersonalAO[species].HasFormes || new[] { 664, 665, 414 }.Contains(species);
|
||||
CB_Form.Enabled = CB_Form.Visible = hasForms;
|
||||
|
||||
CB_Form.DisplayMember = "Text";
|
||||
CB_Form.ValueMember = "Value";
|
||||
CB_Form.DataSource = PKX.getFormList(species, Main.types, Main.forms, Main.gendersymbols).ToList();
|
||||
}
|
||||
private void updateSpecies(object sender, EventArgs e)
|
||||
{
|
||||
setForms();
|
||||
updateNickname(null, null);
|
||||
}
|
||||
private void updateShiny(object sender, EventArgs e)
|
||||
|
||||
@@ -398,7 +398,7 @@ private void loadFavPKM()
|
||||
CHK_Shiny.Checked = isshiny;
|
||||
|
||||
// Set Form
|
||||
Main.setForms(spec, CB_Form);
|
||||
setForms();
|
||||
int form = genform >> 3;
|
||||
CB_Form.SelectedIndex = form;
|
||||
|
||||
@@ -425,10 +425,21 @@ private void setAbilityList()
|
||||
CB_Ability.SelectedIndex = newabil < 3 ? newabil : 0;
|
||||
}
|
||||
|
||||
private void setForms()
|
||||
{
|
||||
int species = Util.getIndex(CB_Species);
|
||||
bool hasForms = Legal.PersonalAO[species].HasFormes || new[] { 664, 665, 414 }.Contains(species);
|
||||
CB_Form.Enabled = CB_Form.Visible = hasForms;
|
||||
|
||||
CB_Form.DisplayMember = "Text";
|
||||
CB_Form.ValueMember = "Value";
|
||||
CB_Form.DataSource = PKX.getFormList(species, Main.types, Main.forms, Main.gendersymbols).ToList();
|
||||
}
|
||||
|
||||
private void updateSpecies(object sender, EventArgs e)
|
||||
{
|
||||
// Get Forms for Given Species
|
||||
Main.setForms(Util.getIndex(CB_Species), CB_Form);
|
||||
setForms();
|
||||
|
||||
// Check for Gender Changes
|
||||
// Get Gender Threshold
|
||||
|
||||
@@ -327,7 +327,9 @@ private void getComboBoxes()
|
||||
CB_MultiplayerSprite.DataSource = oras_sprite_list;
|
||||
|
||||
L_Vivillon.Text = Main.specieslist[666] + ":";
|
||||
Main.setForms(666, CB_Vivillon);
|
||||
CB_Vivillon.DisplayMember = "Text";
|
||||
CB_Vivillon.ValueMember = "Value";
|
||||
CB_Vivillon.DataSource = PKX.getFormList(666, Main.types, Main.forms, Main.gendersymbols).ToList();
|
||||
}
|
||||
private void getBadges()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user