diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index 09b2dcfc7..2785d802d 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -169,7 +169,7 @@ public Main() public static string[] gendersymbols = { "♂", "♀", "-" }; public static string[] specieslist, movelist, itemlist, abilitylist, types, natures, forms, memories, genloc, trainingbags, trainingstage, characteristics, - encountertypelist, gamelanguages, balllist, gamelist, pokeblocks, g3items, g1items = { }; + encountertypelist, gamelanguages, balllist, gamelist, pokeblocks, g3items, g2items, g1items = { }; public static string[] metGSC_00000, metRSEFRLG_00000 = { }; public static string[] metHGSS_00000, metHGSS_02000, metHGSS_03000 = { }; public static string[] metBW2_00000, metBW2_30000, metBW2_40000, metBW2_60000 = { }; @@ -874,9 +874,10 @@ private void loadSAV(SaveFile sav, string path) GB_Markings.Visible = SAV.Generation > 2; Label_HeldItem.Visible = CB_HeldItem.Visible = SAV.Generation > 1; - Label_Total.Visible = TB_IVTotal.Visible = TB_EVTotal.Visible = L_Potential.Visible = - Label_HiddenPowerPrefix.Visible = CB_HPType.Visible = SAV.Generation > 1; - Label_CharacteristicPrefix.Visible = L_Characteristic.Visible = SAV.Generation > 1; + Label_Total.Visible = TB_IVTotal.Visible = TB_EVTotal.Visible = L_Potential.Visible = SAV.Generation > 2; + Label_HiddenPowerPrefix.Visible = CB_HPType.Visible = SAV.Generation > 1; + CB_HPType.Enabled = SAV.Generation > 2; + Label_CharacteristicPrefix.Visible = L_Characteristic.Visible = SAV.Generation > 2; Label_ContestStats.Visible = Label_Cool.Visible = Label_Tough.Visible = Label_Smart.Visible = Label_Sheen.Visible = Label_Beauty.Visible = Label_Cute.Visible = TB_Cool.Visible = TB_Tough.Visible = TB_Smart.Visible = TB_Sheen.Visible = TB_Beauty.Visible = TB_Cute.Visible = Label_Nature.Visible = @@ -941,6 +942,11 @@ private void loadSAV(SaveFile sav, string path) getPKMfromFields = preparePK1; extraBytes = new byte[] {}; break; + case 2: + getFieldsfromPKM = populateFieldsPK2; + getPKMfromFields = preparePK2; + extraBytes = new byte[] { }; + break; case 3: getFieldsfromPKM = populateFieldsPK3; getPKMfromFields = preparePK3; @@ -970,7 +976,7 @@ private void loadSAV(SaveFile sav, string path) bool init = fieldsInitialized; fieldsInitialized = false; populateFilteredDataSources(); - populateFields((pkm.Format != SAV.Generation || SAV.Generation == 1) ? SAV.BlankPKM : pk); + populateFields((pkm.Format != SAV.Generation || SAV.Generation < 3) ? SAV.BlankPKM : pk); fieldsInitialized |= init; // SAV Specific Limits @@ -1046,6 +1052,7 @@ private void InitializeStrings() // Past Generation strings g3items = Util.getStringList("ItemsG3", "en"); + g2items = Util.getStringList("ItemsG2", "en"); g1items = Util.getStringList("ItemsG1", "en"); metRSEFRLG_00000 = Util.getStringList("rsefrlg_00000", "en"); metGSC_00000 = Util.getStringList("gsc_00000", "en"); @@ -1271,6 +1278,8 @@ private void populateFilteredDataSources() string[] items = itemlist; if (SAV.Generation == 3) items = g3items; + if (SAV.Generation == 2) + items = g2items; ItemDataSource = Util.getCBList(items, (HaX ? Enumerable.Range(0, SAV.MaxItemID) : SAV.HeldItems.Select(i => (int)i)).ToArray()); CB_HeldItem.DataSource = new BindingSource(ItemDataSource.Where(i => i.Value <= SAV.MaxItemID).ToList(), null); @@ -1410,7 +1419,7 @@ private void setIsShiny(object sender) bool isShiny = pkm.IsShiny; // Set the Controls - BTN_Shinytize.Visible = BTN_Shinytize.Enabled = !isShiny && SAV.Generation > 2; + BTN_Shinytize.Visible = BTN_Shinytize.Enabled = !isShiny && SAV.Generation > 1; Label_IsShiny.Visible = isShiny && SAV.Generation > 1; // Refresh Markings (for Shiny Star if applicable) @@ -1707,6 +1716,16 @@ private void updateIVs(object sender, EventArgs e) if (SAV.Generation < 3) { TB_HPIV.Text = pkm.IV_HP.ToString("00"); + if (SAV.Generation == 2) + { + Label_Gender.Text = gendersymbols[pkm.Gender]; + Label_Gender.ForeColor = pkm.Gender == 2 + ? Label_Species.ForeColor + : (pkm.Gender == 1 ? Color.Red : Color.Blue); + CB_Form.SelectedIndex = pkm.AltForm; + setIsShiny(null); + getQuickFiller(dragout); + } } CB_HPType.SelectedValue = pkm.HPType; @@ -2260,6 +2279,8 @@ private void updateIsEgg(object sender, EventArgs e) { CHK_Nicknamed.Checked = false; TB_Friendship.Text = "1"; + if (SAV.Generation == 2) + pkm.IsEgg = true; // If we are an egg, it won't have a met location. CHK_AsEgg.Checked = true; @@ -2273,6 +2294,9 @@ private void updateIsEgg(object sender, EventArgs e) if (!CHK_Nicknamed.Checked) updateNickname(null, null); + if (SAV.Generation == 2) + pkm.IsEgg = false; + TB_Friendship.Text = SAV.Personal[Util.getIndex(CB_Species)].BaseFriendship.ToString(); if (CB_EggLocation.SelectedIndex == 0) @@ -2284,7 +2308,7 @@ private void updateIsEgg(object sender, EventArgs e) } // Display hatch counter if it is an egg, Display Friendship if it is not. Label_HatchCounter.Visible = CHK_IsEgg.Checked && SAV.Generation > 1; - Label_Friendship.Visible = !CHK_IsEgg.Checked && SAV.Generation > 2; + Label_Friendship.Visible = !CHK_IsEgg.Checked && SAV.Generation > 1; // Update image to (not) show egg. @@ -2313,7 +2337,16 @@ private void updateShinyPID(object sender, EventArgs e) pkm.AltForm = CB_Form.SelectedIndex; pkm.Version = Util.getIndex(CB_GameOrigin); - pkm.setShinyPID(); + if (pkm.Format > 2) + pkm.setShinyPID(); + else + { + TB_ATKIV.Text = "15"; + TB_DEFIV.Text = "10"; + TB_SPEIV.Text = "10"; + TB_SPAIV.Text = "10"; + updateIVs(null, null); + } TB_PID.Text = pkm.PID.ToString("X8"); if (pkm.GenNumber < 6 && TB_EC.Visible) @@ -3454,7 +3487,7 @@ private void B_OpenPokedex_Click(object sender, EventArgs e) new SAV_PokedexORAS().ShowDialog(); else if (SAV.XY) new SAV_PokedexXY().ShowDialog(); - else if (SAV.RBY) + else if (SAV.RBY || SAV.GSC) new SAV_SimplePokedex().ShowDialog(); } private void B_OUTPasserby_Click(object sender, EventArgs e) diff --git a/PKHeX/MainWindow/MainPK2.cs b/PKHeX/MainWindow/MainPK2.cs new file mode 100644 index 000000000..1e83a5109 --- /dev/null +++ b/PKHeX/MainWindow/MainPK2.cs @@ -0,0 +1,133 @@ +using System; +using System.Drawing; + +namespace PKHeX +{ + public partial class Main + { + private void populateFieldsPK2() + { + PK2 pk2 = pkm as PK2; + if (pk2 == null) + return; + + // Do first + pk2.Stat_Level = PKX.getLevel(pk2.Species, pk2.EXP); + if (pk2.Stat_Level == 100) + pk2.EXP = PKX.getEXP(pk2.Stat_Level, pk2.Species); + + CB_Species.SelectedValue = pk2.Species; + TB_Level.Text = pk2.Stat_Level.ToString(); + TB_EXP.Text = pk2.EXP.ToString(); + CB_HeldItem.SelectedValue = pk2.HeldItem; + CB_Form.SelectedIndex = pk2.AltForm; + CHK_IsEgg.Checked = pk2.IsEgg; + + // Load rest + TB_TID.Text = pk2.TID.ToString("00000"); + CHK_Nicknamed.Checked = pk2.IsNicknamed; + TB_Nickname.Text = pk2.Nickname; + TB_OT.Text = pk2.OT_Name; + GB_OT.BackgroundImage = null; + + // Reset Label and ComboBox visibility, as well as non-data checked status. + Label_PKRS.Visible = false; + Label_PKRSdays.Visible = false; + + TB_HPIV.Text = pk2.IV_HP.ToString(); + TB_ATKIV.Text = pk2.IV_ATK.ToString(); + TB_DEFIV.Text = pk2.IV_DEF.ToString(); + TB_SPEIV.Text = pk2.IV_SPE.ToString(); + TB_SPAIV.Text = pk2.IV_SPA.ToString(); + + TB_HPEV.Text = pk2.EV_HP.ToString(); + TB_ATKEV.Text = pk2.EV_ATK.ToString(); + TB_DEFEV.Text = pk2.EV_DEF.ToString(); + TB_SPEEV.Text = pk2.EV_SPE.ToString(); + TB_SPAEV.Text = pk2.EV_SPA.ToString(); + + CB_Move1.SelectedValue = pk2.Move1; + CB_Move2.SelectedValue = pk2.Move2; + CB_Move3.SelectedValue = pk2.Move3; + CB_Move4.SelectedValue = pk2.Move4; + CB_PPu1.SelectedIndex = pk2.Move1_PPUps; + CB_PPu2.SelectedIndex = pk2.Move2_PPUps; + CB_PPu3.SelectedIndex = pk2.Move3_PPUps; + CB_PPu4.SelectedIndex = pk2.Move4_PPUps; + TB_PP1.Text = pk2.Move1_PP.ToString(); + TB_PP2.Text = pk2.Move2_PP.ToString(); + TB_PP3.Text = pk2.Move3_PP.ToString(); + TB_PP4.Text = pk2.Move4_PP.ToString(); + + CB_Language.SelectedIndex = pk2.Japanese ? 0 : 1; + + updateStats(); + setIsShiny(null); + + Label_Gender.Text = gendersymbols[pk2.Gender]; + Label_Gender.ForeColor = pk2.Gender == 2 ? Label_Species.ForeColor : (pk2.Gender == 1 ? Color.Red : Color.Blue); + TB_EXP.Text = pk2.EXP.ToString(); + } + private PKM preparePK2() + { + PK2 pk2 = pkm as PK2; + if (pk2 == null) + return null; + + pk2.Species = Util.getIndex(CB_Species); + pk2.TID = Util.ToInt32(TB_TID.Text); + pk2.EXP = Util.ToUInt32(TB_EXP.Text); + pk2.HeldItem = Util.getIndex(CB_HeldItem); + pk2.IsEgg = CHK_IsEgg.Checked; + + pk2.EV_HP = Util.ToInt32(TB_HPEV.Text); + pk2.EV_ATK = Util.ToInt32(TB_ATKEV.Text); + pk2.EV_DEF = Util.ToInt32(TB_DEFEV.Text); + pk2.EV_SPE = Util.ToInt32(TB_SPEEV.Text); + pk2.EV_SPC = Util.ToInt32(TB_SPAEV.Text); + + pk2.Nickname = TB_Nickname.Text; + pk2.Move1 = Util.getIndex(CB_Move1); + pk2.Move2 = Util.getIndex(CB_Move2); + pk2.Move3 = Util.getIndex(CB_Move3); + pk2.Move4 = Util.getIndex(CB_Move4); + pk2.Move1_PP = Util.getIndex(CB_Move1) > 0 ? Util.ToInt32(TB_PP1.Text) : 0; + pk2.Move2_PP = Util.getIndex(CB_Move2) > 0 ? Util.ToInt32(TB_PP2.Text) : 0; + pk2.Move3_PP = Util.getIndex(CB_Move3) > 0 ? Util.ToInt32(TB_PP3.Text) : 0; + pk2.Move4_PP = Util.getIndex(CB_Move4) > 0 ? Util.ToInt32(TB_PP4.Text) : 0; + pk2.Move1_PPUps = Util.getIndex(CB_Move1) > 0 ? CB_PPu1.SelectedIndex : 0; + pk2.Move2_PPUps = Util.getIndex(CB_Move2) > 0 ? CB_PPu2.SelectedIndex : 0; + pk2.Move3_PPUps = Util.getIndex(CB_Move3) > 0 ? CB_PPu3.SelectedIndex : 0; + pk2.Move4_PPUps = Util.getIndex(CB_Move4) > 0 ? CB_PPu4.SelectedIndex : 0; + + pk2.IV_HP = Util.ToInt32(TB_HPIV.Text); + pk2.IV_ATK = Util.ToInt32(TB_ATKIV.Text); + pk2.IV_DEF = Util.ToInt32(TB_DEFIV.Text); + pk2.IV_SPE = Util.ToInt32(TB_SPEIV.Text); + pk2.IV_SPA = Util.ToInt32(TB_SPAIV.Text); + + pk2.OT_Name = TB_OT.Text; + + // Toss in Party Stats + Array.Resize(ref pk2.Data, pk2.SIZE_PARTY); + pk2.Stat_Level = Util.ToInt32(TB_Level.Text); + pk2.Stat_HPCurrent = Util.ToInt32(Stat_HP.Text); + pk2.Stat_HPMax = Util.ToInt32(Stat_HP.Text); + pk2.Stat_ATK = Util.ToInt32(Stat_ATK.Text); + pk2.Stat_DEF = Util.ToInt32(Stat_DEF.Text); + pk2.Stat_SPE = Util.ToInt32(Stat_SPE.Text); + pk2.Stat_SPA = Util.ToInt32(Stat_SPA.Text); + pk2.Stat_SPD = Util.ToInt32(Stat_SPD.Text); + + if (HaX) + { + pk2.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue); + } + + // Fix Moves if a slot is empty + pk2.FixMoves(); + + return pk2; + } + } +} diff --git a/PKHeX/Misc/personal_gs b/PKHeX/Misc/personal_gs new file mode 100644 index 000000000..05130b80b Binary files /dev/null and b/PKHeX/Misc/personal_gs differ diff --git a/PKHeX/PKHeX.csproj b/PKHeX/PKHeX.csproj index ca856033b..b4231e5b5 100644 --- a/PKHeX/PKHeX.csproj +++ b/PKHeX/PKHeX.csproj @@ -73,6 +73,9 @@ + + Form + Form @@ -93,6 +96,7 @@ + @@ -100,6 +104,7 @@ + @@ -119,6 +124,7 @@ + @@ -422,6 +428,7 @@ Designer + SettingsSingleFileGenerator Settings.Designer.cs @@ -471,9 +478,11 @@ + + @@ -2746,6 +2755,9 @@ + + +