private PKM PreparePK5() { if (!(pkm is PK5 pk5)) { return(null); } SaveMisc1(pk5); SaveMisc2(pk5); SaveMisc3(pk5); SaveMisc4(pk5); pk5.EncounterType = 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); pk5.FixMoves(); pk5.RefreshChecksum(); return(pk5); }
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; } pk.Ability = WinFormsUtil.GetIndex(HaX ? DEV_Ability : CB_Ability); }
private void UpdateGender(object sender, EventArgs e) { // Get Gender Threshold int species = WinFormsUtil.GetIndex(CB_Species); var pi = SAV.Personal[species]; if (pi.IsDualGender) { var fg = EntityGender.GetFromString(Label_Gender.Text); fg = (fg ^ 1) & 1; Label_Gender.Text = gendersymbols[fg]; } else { var fg = pi.FixedGender; Label_Gender.Text = gendersymbols[fg]; return; } var g = EntityGender.GetFromString(CB_Form.Text); if (g == 0 && Label_Gender.Text != gendersymbols[0]) { CB_Form.SelectedIndex = 1; } else if (g == 1 && Label_Gender.Text != gendersymbols[1]) { CB_Form.SelectedIndex = 0; } if (species == (int)Species.Pyroar) { CB_Form.SelectedIndex = EntityGender.GetFromString(Label_Gender.Text); } Write_Entry(this, EventArgs.Empty); }
private PKM PreparePK4() { var pk4 = pkm; if (pk4?.Format != 4) { return(null); } pk4.Species = WinFormsUtil.GetIndex(CB_Species); pk4.HeldItem = WinFormsUtil.GetIndex(CB_HeldItem); pk4.TID = Util.ToInt32(TB_TID.Text); pk4.SID = Util.ToInt32(TB_SID.Text); pk4.EXP = Util.ToUInt32(TB_EXP.Text); pk4.PID = Util.GetHexValue(TB_PID.Text); if (CB_Ability.Text.Length >= 4) { pk4.Ability = (byte)Array.IndexOf(GameInfo.Strings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4)); } pk4.FatefulEncounter = CHK_Fateful.Checked; pk4.Gender = PKX.GetGender(Label_Gender.Text); 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); pk4.EV_SPE = Util.ToInt32(TB_SPEEV.Text); pk4.EV_SPA = Util.ToInt32(TB_SPAEV.Text); pk4.EV_SPD = Util.ToInt32(TB_SPDEV.Text); pk4.CNT_Cool = Contest.Cool; pk4.CNT_Beauty = Contest.Beauty; pk4.CNT_Cute = Contest.Cute; pk4.CNT_Smart = Contest.Smart; pk4.CNT_Tough = Contest.Tough; pk4.CNT_Sheen = Contest.Sheen; pk4.PKRS_Days = CB_PKRSDays.SelectedIndex; pk4.PKRS_Strain = CB_PKRSStrain.SelectedIndex; pk4.Nickname = TB_Nickname.Text; pk4.Move1 = WinFormsUtil.GetIndex(CB_Move1); pk4.Move2 = WinFormsUtil.GetIndex(CB_Move2); pk4.Move3 = WinFormsUtil.GetIndex(CB_Move3); pk4.Move4 = WinFormsUtil.GetIndex(CB_Move4); pk4.Move1_PP = WinFormsUtil.GetIndex(CB_Move1) > 0 ? Util.ToInt32(TB_PP1.Text) : 0; pk4.Move2_PP = WinFormsUtil.GetIndex(CB_Move2) > 0 ? Util.ToInt32(TB_PP2.Text) : 0; pk4.Move3_PP = WinFormsUtil.GetIndex(CB_Move3) > 0 ? Util.ToInt32(TB_PP3.Text) : 0; pk4.Move4_PP = WinFormsUtil.GetIndex(CB_Move4) > 0 ? Util.ToInt32(TB_PP4.Text) : 0; pk4.Move1_PPUps = WinFormsUtil.GetIndex(CB_Move1) > 0 ? CB_PPu1.SelectedIndex : 0; pk4.Move2_PPUps = WinFormsUtil.GetIndex(CB_Move2) > 0 ? CB_PPu2.SelectedIndex : 0; pk4.Move3_PPUps = WinFormsUtil.GetIndex(CB_Move3) > 0 ? CB_PPu3.SelectedIndex : 0; pk4.Move4_PPUps = WinFormsUtil.GetIndex(CB_Move4) > 0 ? CB_PPu4.SelectedIndex : 0; pk4.IV_HP = Util.ToInt32(TB_HPIV.Text); pk4.IV_ATK = Util.ToInt32(TB_ATKIV.Text); pk4.IV_DEF = Util.ToInt32(TB_DEFIV.Text); pk4.IV_SPE = Util.ToInt32(TB_SPEIV.Text); pk4.IV_SPA = Util.ToInt32(TB_SPAIV.Text); pk4.IV_SPD = Util.ToInt32(TB_SPDIV.Text); pk4.IsEgg = CHK_IsEgg.Checked; pk4.IsNicknamed = CHK_Nicknamed.Checked; pk4.OT_Name = TB_OT.Text; pk4.CurrentFriendship = Util.ToInt32(TB_Friendship.Text); pk4.Ball = WinFormsUtil.GetIndex(CB_Ball); pk4.Met_Level = Util.ToInt32(TB_MetLevel.Text); pk4.OT_Gender = PKX.GetGender(Label_OTGender.Text); pk4.EncounterType = WinFormsUtil.GetIndex(CB_EncounterType); pk4.Version = WinFormsUtil.GetIndex(CB_GameOrigin); pk4.Language = WinFormsUtil.GetIndex(CB_Language); // 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 pk4.EggMetDate = egg_date; pk4.Egg_Location = egg_location; // Met Data pk4.MetDate = CAL_MetDate.Value; pk4.Met_Location = WinFormsUtil.GetIndex(CB_MetLocation); if (pk4.IsEgg && pk4.Met_Location == 0) // If still an egg, it has no hatch location/date. Zero it! { pk4.MetDate = null; } // Toss in Party Stats Array.Resize(ref pk4.Data, pk4.SIZE_PARTY); pk4.Stat_Level = Util.ToInt32(TB_Level.Text); pk4.Stat_HPCurrent = Util.ToInt32(Stat_HP.Text); pk4.Stat_HPMax = Util.ToInt32(Stat_HP.Text); pk4.Stat_ATK = Util.ToInt32(Stat_ATK.Text); pk4.Stat_DEF = Util.ToInt32(Stat_DEF.Text); pk4.Stat_SPE = Util.ToInt32(Stat_SPE.Text); pk4.Stat_SPA = Util.ToInt32(Stat_SPA.Text); pk4.Stat_SPD = Util.ToInt32(Stat_SPD.Text); if (HaX) { pk4.Ability = (byte)WinFormsUtil.GetIndex(DEV_Ability); pk4.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue); } // Minor properties switch (pk4) { case PK4 p4: p4.ShinyLeaf = ShinyLeaf.Value; break; case BK4 b4: b4.ShinyLeaf = ShinyLeaf.Value; break; } // Fix Moves if a slot is empty pk4.FixMoves(); pk4.RefreshChecksum(); return(pk4); }
private void SaveSpeciesLevelEXP(PKM pk) { pk.Species = WinFormsUtil.GetIndex(CB_Species); pk.EXP = Util.ToUInt32(TB_EXP.Text); }
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 SaveGeolocation(IRegionOrigin pk) { pk.Country = (byte)WinFormsUtil.GetIndex(CB_Country); pk.Region = (byte)WinFormsUtil.GetIndex(CB_SubRegion); pk.ConsoleRegion = (byte)WinFormsUtil.GetIndex(CB_3DSReg); }
private PKM PrepareXK3() { XK3 xk3 = pkm as XK3; if (xk3 == null) { return(null); } xk3.Species = WinFormsUtil.GetIndex(CB_Species); xk3.HeldItem = WinFormsUtil.GetIndex(CB_HeldItem); xk3.TID = Util.ToInt32(TB_TID.Text); xk3.SID = Util.ToInt32(TB_SID.Text); xk3.EXP = Util.ToUInt32(TB_EXP.Text); xk3.PID = Util.GetHexValue(TB_PID.Text); xk3.AbilityNumber = 1 << CB_Ability.SelectedIndex; // to match gen6+ xk3.FatefulEncounter = CHK_Fateful.Checked; xk3.Gender = PKX.GetGender(Label_Gender.Text); xk3.EV_HP = Util.ToInt32(TB_HPEV.Text); xk3.EV_ATK = Util.ToInt32(TB_ATKEV.Text); xk3.EV_DEF = Util.ToInt32(TB_DEFEV.Text); xk3.EV_SPE = Util.ToInt32(TB_SPEEV.Text); xk3.EV_SPA = Util.ToInt32(TB_SPAEV.Text); xk3.EV_SPD = Util.ToInt32(TB_SPDEV.Text); xk3.CNT_Cool = Contest.Cool; xk3.CNT_Beauty = Contest.Beauty; xk3.CNT_Cute = Contest.Cute; xk3.CNT_Smart = Contest.Smart; xk3.CNT_Tough = Contest.Tough; xk3.CNT_Sheen = Contest.Sheen; xk3.PKRS_Days = CB_PKRSDays.SelectedIndex; xk3.PKRS_Strain = CB_PKRSStrain.SelectedIndex; xk3.Nickname = TB_Nickname.Text; xk3.Move1 = WinFormsUtil.GetIndex(CB_Move1); xk3.Move2 = WinFormsUtil.GetIndex(CB_Move2); xk3.Move3 = WinFormsUtil.GetIndex(CB_Move3); xk3.Move4 = WinFormsUtil.GetIndex(CB_Move4); xk3.Move1_PP = WinFormsUtil.GetIndex(CB_Move1) > 0 ? Util.ToInt32(TB_PP1.Text) : 0; xk3.Move2_PP = WinFormsUtil.GetIndex(CB_Move2) > 0 ? Util.ToInt32(TB_PP2.Text) : 0; xk3.Move3_PP = WinFormsUtil.GetIndex(CB_Move3) > 0 ? Util.ToInt32(TB_PP3.Text) : 0; xk3.Move4_PP = WinFormsUtil.GetIndex(CB_Move4) > 0 ? Util.ToInt32(TB_PP4.Text) : 0; xk3.Move1_PPUps = WinFormsUtil.GetIndex(CB_Move1) > 0 ? CB_PPu1.SelectedIndex : 0; xk3.Move2_PPUps = WinFormsUtil.GetIndex(CB_Move2) > 0 ? CB_PPu2.SelectedIndex : 0; xk3.Move3_PPUps = WinFormsUtil.GetIndex(CB_Move3) > 0 ? CB_PPu3.SelectedIndex : 0; xk3.Move4_PPUps = WinFormsUtil.GetIndex(CB_Move4) > 0 ? CB_PPu4.SelectedIndex : 0; xk3.IV_HP = Util.ToInt32(TB_HPIV.Text); xk3.IV_ATK = Util.ToInt32(TB_ATKIV.Text); xk3.IV_DEF = Util.ToInt32(TB_DEFIV.Text); xk3.IV_SPE = Util.ToInt32(TB_SPEIV.Text); xk3.IV_SPA = Util.ToInt32(TB_SPAIV.Text); xk3.IV_SPD = Util.ToInt32(TB_SPDIV.Text); xk3.IsEgg = CHK_IsEgg.Checked; xk3.IsNicknamed = CHK_Nicknamed.Checked; xk3.OT_Name = TB_OT.Text; xk3.CurrentFriendship = Util.ToInt32(TB_Friendship.Text); xk3.Ball = WinFormsUtil.GetIndex(CB_Ball); xk3.Met_Level = Util.ToInt32(TB_MetLevel.Text); xk3.OT_Gender = PKX.GetGender(Label_OTGender.Text); xk3.Version = WinFormsUtil.GetIndex(CB_GameOrigin); xk3.Language = WinFormsUtil.GetIndex(CB_Language); xk3.Met_Location = WinFormsUtil.GetIndex(CB_MetLocation); // Toss in Party Stats Array.Resize(ref xk3.Data, xk3.SIZE_PARTY); xk3.Stat_Level = Util.ToInt32(TB_Level.Text); xk3.Stat_HPCurrent = Util.ToInt32(Stat_HP.Text); xk3.Stat_HPMax = Util.ToInt32(Stat_HP.Text); xk3.Stat_ATK = Util.ToInt32(Stat_ATK.Text); xk3.Stat_DEF = Util.ToInt32(Stat_DEF.Text); xk3.Stat_SPE = Util.ToInt32(Stat_SPE.Text); xk3.Stat_SPA = Util.ToInt32(Stat_SPA.Text); xk3.Stat_SPD = Util.ToInt32(Stat_SPD.Text); if (HaX) { xk3.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue); } // Shadow Info xk3.ShadowID = (int)NUD_ShadowID.Value; if (xk3.ShadowID > 0) { xk3.Purification = (int)NUD_Purification.Value; } // Fix Moves if a slot is empty xk3.FixMoves(); xk3.RefreshChecksum(); return(xk3); }
private PKM PreparePK6() { PK6 pk6 = pkm as PK6; if (pk6 == null) { return(null); } // Repopulate PK6 with Edited Stuff CheckTransferPIDValid(); pk6.EncryptionConstant = Util.GetHexValue(TB_EC.Text); pk6.Checksum = 0; // 0 CHK for now // Block A pk6.Species = WinFormsUtil.GetIndex(CB_Species); pk6.HeldItem = WinFormsUtil.GetIndex(CB_HeldItem); pk6.TID = Util.ToInt32(TB_TID.Text); pk6.SID = Util.ToInt32(TB_SID.Text); pk6.EXP = Util.ToUInt32(TB_EXP.Text); if (CB_Ability.Text.Length >= 4) { pk6.Ability = (byte)Array.IndexOf(GameInfo.Strings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4)); pk6.AbilityNumber = Util.ToInt32(TB_AbilityNumber.Text); // Number } // pkx[0x16], pkx[0x17] are handled by the Medals UI (Hits & Training Bag) pk6.PID = Util.GetHexValue(TB_PID.Text); pk6.Nature = (byte)WinFormsUtil.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.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); pk6.EV_SPE = Util.ToInt32(TB_SPEEV.Text); pk6.EV_SPA = Util.ToInt32(TB_SPAEV.Text); pk6.EV_SPD = Util.ToInt32(TB_SPDEV.Text); pk6.CNT_Cool = Contest.Cool; pk6.CNT_Beauty = Contest.Beauty; pk6.CNT_Cute = Contest.Cute; pk6.CNT_Smart = Contest.Smart; pk6.CNT_Tough = Contest.Tough; pk6.CNT_Sheen = Contest.Sheen; pk6.PKRS_Days = CB_PKRSDays.SelectedIndex; pk6.PKRS_Strain = CB_PKRSStrain.SelectedIndex; // Already in buff (then transferred to new pkx) // 0x2C, 0x2D, 0x2E, 0x2F // 0x30, 0x31, 0x32, 0x33 // 0x34, 0x35, 0x36, 0x37 // 0x38, 0x39 // Unused // 0x3A, 0x3B // 0x3C, 0x3D, 0x3E, 0x3F // Block B // Convert Nickname field back to bytes pk6.Nickname = TB_Nickname.Text; pk6.Move1 = WinFormsUtil.GetIndex(CB_Move1); pk6.Move2 = WinFormsUtil.GetIndex(CB_Move2); pk6.Move3 = WinFormsUtil.GetIndex(CB_Move3); pk6.Move4 = WinFormsUtil.GetIndex(CB_Move4); pk6.Move1_PP = WinFormsUtil.GetIndex(CB_Move1) > 0 ? Util.ToInt32(TB_PP1.Text) : 0; pk6.Move2_PP = WinFormsUtil.GetIndex(CB_Move2) > 0 ? Util.ToInt32(TB_PP2.Text) : 0; pk6.Move3_PP = WinFormsUtil.GetIndex(CB_Move3) > 0 ? Util.ToInt32(TB_PP3.Text) : 0; pk6.Move4_PP = WinFormsUtil.GetIndex(CB_Move4) > 0 ? Util.ToInt32(TB_PP4.Text) : 0; pk6.Move1_PPUps = WinFormsUtil.GetIndex(CB_Move1) > 0 ? CB_PPu1.SelectedIndex : 0; pk6.Move2_PPUps = WinFormsUtil.GetIndex(CB_Move2) > 0 ? CB_PPu2.SelectedIndex : 0; pk6.Move3_PPUps = WinFormsUtil.GetIndex(CB_Move3) > 0 ? CB_PPu3.SelectedIndex : 0; pk6.Move4_PPUps = WinFormsUtil.GetIndex(CB_Move4) > 0 ? CB_PPu4.SelectedIndex : 0; pk6.RelearnMove1 = WinFormsUtil.GetIndex(CB_RelearnMove1); pk6.RelearnMove2 = WinFormsUtil.GetIndex(CB_RelearnMove2); pk6.RelearnMove3 = WinFormsUtil.GetIndex(CB_RelearnMove3); pk6.RelearnMove4 = WinFormsUtil.GetIndex(CB_RelearnMove4); // 0x72 - Ribbon editor sets this flag (Secret Super Training) // 0x73 pk6.IV_HP = Util.ToInt32(TB_HPIV.Text); pk6.IV_ATK = Util.ToInt32(TB_ATKIV.Text); pk6.IV_DEF = Util.ToInt32(TB_DEFIV.Text); pk6.IV_SPE = Util.ToInt32(TB_SPEIV.Text); pk6.IV_SPA = Util.ToInt32(TB_SPAIV.Text); pk6.IV_SPD = Util.ToInt32(TB_SPDIV.Text); pk6.IsEgg = CHK_IsEgg.Checked; pk6.IsNicknamed = CHK_Nicknamed.Checked; // Block C pk6.HT_Name = TB_OTt2.Text; // 0x90-0xAF pk6.HT_Gender = PKX.GetGender(Label_CTGender.Text) & 1; // Plus more, set by MemoryAmie (already in buff) // Block D pk6.OT_Name = TB_OT.Text; pk6.CurrentFriendship = Util.ToInt32(TB_Friendship.Text); 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 pk6.EggMetDate = egg_date; pk6.Egg_Location = egg_location; // Met Data pk6.MetDate = CAL_MetDate.Value; pk6.Met_Location = WinFormsUtil.GetIndex(CB_MetLocation); if (pk6.IsEgg && pk6.Met_Location == 0) // If still an egg, it has no hatch location/date. Zero it! { pk6.MetDate = null; } // 0xD7 Unknown pk6.Ball = WinFormsUtil.GetIndex(CB_Ball); pk6.Met_Level = Util.ToInt32(TB_MetLevel.Text); pk6.OT_Gender = PKX.GetGender(Label_OTGender.Text); pk6.EncounterType = WinFormsUtil.GetIndex(CB_EncounterType); pk6.Version = WinFormsUtil.GetIndex(CB_GameOrigin); pk6.Country = WinFormsUtil.GetIndex(CB_Country); pk6.Region = WinFormsUtil.GetIndex(CB_SubRegion); pk6.ConsoleRegion = WinFormsUtil.GetIndex(CB_3DSReg); pk6.Language = WinFormsUtil.GetIndex(CB_Language); // 0xE4-0xE7 // Toss in Party Stats Array.Resize(ref pk6.Data, pk6.SIZE_PARTY); pk6.Stat_Level = Util.ToInt32(TB_Level.Text); pk6.Stat_HPCurrent = Util.ToInt32(Stat_HP.Text); pk6.Stat_HPMax = Util.ToInt32(Stat_HP.Text); pk6.Stat_ATK = Util.ToInt32(Stat_ATK.Text); pk6.Stat_DEF = Util.ToInt32(Stat_DEF.Text); pk6.Stat_SPE = Util.ToInt32(Stat_SPE.Text); pk6.Stat_SPA = Util.ToInt32(Stat_SPA.Text); pk6.Stat_SPD = Util.ToInt32(Stat_SPD.Text); // Unneeded Party Stats (Status, Flags, Unused) pk6.Data[0xE8] = pk6.Data[0xE9] = pk6.Data[0xEA] = pk6.Data[0xEB] = pk6.Data[0xED] = pk6.Data[0xEE] = pk6.Data[0xEF] = pk6.Data[0xFE] = pk6.Data[0xFF] = pk6.Data[0x100] = pk6.Data[0x101] = pk6.Data[0x102] = pk6.Data[0x103] = 0; // Hax Illegality if (HaX) { pk6.Ability = (byte)WinFormsUtil.GetIndex(DEV_Ability); pk6.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue); } // Fix Moves if a slot is empty pk6.FixMoves(); pk6.FixRelearn(); // Fix Handler (Memories & OT) -- no foreign memories for Pokemon without a foreign trainer (none for eggs) if (ModifyPKM) { pk6.FixMemories(); } // PKX is now filled pk6.RefreshChecksum(); return(pk6); }
private void SetEntry(int index, int formIndex) { if (!CanSave || Editing || index < 0 || formIndex < 0) { return; } var empty = IsEntryEmpty(index, formIndex); if (!CHK_Seen.Checked && empty) { return; } var species = DexToSpecies[index + 1]; var form = DisplayedForms[formIndex].Value; if (!empty) { Dex.SetPokeHasBeenUpdated(species); } // Flags var seenWild = 0; var obtain = 0; var caughtWild = 0; for (var i = 0; i < CHK_SeenWild.Length; i++) { seenWild |= CHK_SeenWild[i].Checked ? (1 << i) : 0; obtain |= CHK_Obtained[i].Checked ? (1 << i) : 0; caughtWild |= CHK_CaughtWild[i].Checked ? (1 << i) : 0; } Dex.SetPokeSeenInWildFlags(species, form, (byte)seenWild); Dex.SetPokeObtainFlags(species, form, (byte)obtain); Dex.SetPokeCaughtInWildFlags(species, form, (byte)caughtWild); Dex.SetSolitudeComplete(species, CHK_Solitude.Checked); // Display var dispForm = form; if (CB_DisplayForm.Enabled) { dispForm = WinFormsUtil.GetIndex(CB_DisplayForm); } Dex.SetSelectedGenderForm(species, dispForm, CHK_G.Checked, CHK_S.Checked, CHK_A.Checked); // Set research for (var i = 0; i < PokedexConstants8a.ResearchTasks[index].Length; i++) { if (TaskControls[i].CanSetCurrentValue) { Dex.SetResearchTaskProgressByForce(species, TaskControls[i].Task, TaskControls[i].CurrentValue); } } // Statistics Dex.GetSizeStatistics(species, form, out _, out var oldMinHeight, out var oldMaxHeight, out var oldMinWeight, out var oldMaxWeight); if (!float.TryParse(TB_MinHeight.Text, out var minHeight)) { minHeight = oldMinHeight; } if (!float.TryParse(TB_MaxHeight.Text, out var maxHeight)) { maxHeight = oldMaxHeight; } if (!float.TryParse(TB_MinWeight.Text, out var minWeight)) { minWeight = oldMinWeight; } if (!float.TryParse(TB_MaxWeight.Text, out var maxWeight)) { maxWeight = oldMaxWeight; } Dex.SetSizeStatistics(species, form, CHK_MinAndMax.Checked, minHeight, maxHeight, minWeight, maxWeight); }
private void B_OK_Click(object sender, EventArgs e) { Result = (GameVersion)WinFormsUtil.GetIndex(CB_Game); Close(); }
private void UpdateCountry(object sender, EventArgs e) { int index; if (sender is ComboBox c && (index = WinFormsUtil.GetIndex(c)) > 0) Main.SetCountrySubRegion(CB_Region, $"sr_{index:000}"); }
private void Save() { SAV.Game = (byte)(CB_Game.SelectedIndex + 0x18); SAV.Gender = (byte)CB_Gender.SelectedIndex; SAV.TID = (ushort)Util.ToUInt32(MT_TID.Text); SAV.SID = (ushort)Util.ToUInt32(MT_SID.Text); SAV.Money = Util.ToUInt32(MT_Money.Text); SAV.Region = (byte)WinFormsUtil.GetIndex(CB_Region); SAV.Country = (byte)WinFormsUtil.GetIndex(CB_Country); SAV.ConsoleRegion = (byte)WinFormsUtil.GetIndex(CB_3DSReg); SAV.Language = WinFormsUtil.GetIndex(CB_Language); SAV.OT = TB_OTName.Text; var status = SAV.Status; status.Saying1 = TB_Saying1.Text; status.Saying2 = TB_Saying2.Text; status.Saying3 = TB_Saying3.Text; status.Saying4 = TB_Saying4.Text; status.Saying5 = TB_Saying5.Text; // Copy Maison Data in if (SAV is ISaveBlock6Main xyao) { for (int i = 0; i < MaisonBlock.MaisonStatCount; i++) xyao.Maison.SetMaisonStat(i, ushort.Parse(MaisonRecords[i].Text)); } // Copy Position var sit = SAV.Situation; if (GB_Map.Enabled && MapUpdated) { sit.M = (int)NUD_M.Value; sit.X = (float)NUD_X.Value; sit.Z = (float)NUD_Z.Value; sit.Y = (float)NUD_Y.Value; } SAV.BP = ushort.Parse(TB_BP.Text); // Set Current PokéMiles SAV.SetRecord(63, Util.ToInt32(TB_PM.Text)); // Set Max Obtained Pokémiles SAV.SetRecord(64, Util.ToInt32(TB_PM.Text)); sit.Style = byte.Parse(TB_Style.Text); // Copy Badges int badgeval = 0; for (int i = 0; i < 8; i++) badgeval |= (cba[i].Checked ? 1 : 0) << i; SAV.Badges = badgeval; // Save PlayTime SAV.PlayedHours = ushort.Parse(MT_Hours.Text); SAV.PlayedMinutes = ushort.Parse(MT_Minutes.Text)%60; SAV.PlayedSeconds = ushort.Parse(MT_Seconds.Text)%60; // Sprite if (SAV is IMultiplayerSprite ms) ms.MultiplayerSpriteID = Convert.ToByte(CB_MultiplayerSprite.SelectedValue); // Appearance if (SAV is SAV6XY xy) { var xystat = (MyStatus6XY)xy.Status; xystat.Fashion = (TrainerFashion6)PG_CurrentAppearance.SelectedObject; xystat.OT_Nick = TB_TRNick.Text; } // Vivillon SAV.Vivillon = CB_Vivillon.SelectedIndex; SAV.SecondsToStart = (uint)DateUtil.GetSecondsFrom2000(CAL_AdventureStartDate.Value, CAL_AdventureStartTime.Value); SAV.SecondsToFame = (uint)DateUtil.GetSecondsFrom2000(CAL_HoFDate.Value, CAL_HoFTime.Value); if (SAV.Played.LastSavedDate.HasValue) SAV.Played.LastSavedDate = new DateTime(CAL_LastSavedDate.Value.Year, CAL_LastSavedDate.Value.Month, CAL_LastSavedDate.Value.Day, CAL_LastSavedTime.Value.Hour, CAL_LastSavedTime.Value.Minute, 0); status.IsMegaEvolutionUnlocked = CHK_MegaUnlocked.Checked; status.IsMegaRayquazaUnlocked = CHK_MegaRayquazaUnlocked.Checked; }
public SettingsEditor(object obj) { InitializeComponent(); LoadSettings(obj); if (obj is PKHeXSettings s) { var noSelectVersions = new[] { GameVersion.GO }; CB_Blank.InitializeBinding(); CB_Blank.DataSource = GameInfo.VersionDataSource.Where(z => !noSelectVersions.Contains((GameVersion)z.Value)).ToList(); CB_Blank.SelectedValue = (int)s.Startup.DefaultSaveVersion; CB_Blank.SelectedValueChanged += (_, _) => s.Startup.DefaultSaveVersion = (GameVersion)WinFormsUtil.GetIndex(CB_Blank); CB_Blank.SelectedIndexChanged += (_, _) => BlankChanged = true; B_Reset.Click += (x, e) => DeleteSettings(); } else { FLP_Blank.Visible = false; B_Reset.Visible = false; } this.CenterToForm(FindForm()); }
private PKM PreparePK2() { PK2 pk2 = pkm as PK2; if (pk2 == null) { return(null); } pk2.Species = WinFormsUtil.GetIndex(CB_Species); pk2.TID = Util.ToInt32(TB_TID.Text); pk2.EXP = Util.ToUInt32(TB_EXP.Text); pk2.HeldItem = WinFormsUtil.GetIndex(CB_HeldItem); pk2.IsEgg = CHK_IsEgg.Checked; pk2.CurrentFriendship = Util.ToInt32(TB_Friendship.Text); pk2.OT_Gender = PKX.GetGender(Label_OTGender.Text); pk2.Met_Level = Util.ToInt32(TB_MetLevel.Text); pk2.Met_Location = WinFormsUtil.GetIndex(CB_MetLocation); pk2.Met_TimeOfDay = CB_MetTimeOfDay.SelectedIndex; 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.PKRS_Days = CB_PKRSDays.SelectedIndex; pk2.PKRS_Strain = CB_PKRSStrain.SelectedIndex; if (CHK_Nicknamed.Checked) { pk2.Nickname = TB_Nickname.Text; } else { pk2.SetNotNicknamed(); } pk2.Move1 = WinFormsUtil.GetIndex(CB_Move1); pk2.Move2 = WinFormsUtil.GetIndex(CB_Move2); pk2.Move3 = WinFormsUtil.GetIndex(CB_Move3); pk2.Move4 = WinFormsUtil.GetIndex(CB_Move4); pk2.Move1_PP = WinFormsUtil.GetIndex(CB_Move1) > 0 ? Util.ToInt32(TB_PP1.Text) : 0; pk2.Move2_PP = WinFormsUtil.GetIndex(CB_Move2) > 0 ? Util.ToInt32(TB_PP2.Text) : 0; pk2.Move3_PP = WinFormsUtil.GetIndex(CB_Move3) > 0 ? Util.ToInt32(TB_PP3.Text) : 0; pk2.Move4_PP = WinFormsUtil.GetIndex(CB_Move4) > 0 ? Util.ToInt32(TB_PP4.Text) : 0; pk2.Move1_PPUps = WinFormsUtil.GetIndex(CB_Move1) > 0 ? CB_PPu1.SelectedIndex : 0; pk2.Move2_PPUps = WinFormsUtil.GetIndex(CB_Move2) > 0 ? CB_PPu2.SelectedIndex : 0; pk2.Move3_PPUps = WinFormsUtil.GetIndex(CB_Move3) > 0 ? CB_PPu3.SelectedIndex : 0; pk2.Move4_PPUps = WinFormsUtil.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); }
private PKM PreparePK1() { PK1 pk1 = pkm as PK1; if (pk1 == null) { return(null); } pk1.Species = WinFormsUtil.GetIndex(CB_Species); pk1.TID = Util.ToInt32(TB_TID.Text); pk1.EXP = Util.ToUInt32(TB_EXP.Text); pk1.EV_HP = Util.ToInt32(TB_HPEV.Text); pk1.EV_ATK = Util.ToInt32(TB_ATKEV.Text); pk1.EV_DEF = Util.ToInt32(TB_DEFEV.Text); pk1.EV_SPE = Util.ToInt32(TB_SPEEV.Text); pk1.EV_SPC = Util.ToInt32(TB_SPAEV.Text); if (CHK_Nicknamed.Checked) { pk1.Nickname = TB_Nickname.Text; } else { pk1.SetNotNicknamed(); } pk1.Move1 = WinFormsUtil.GetIndex(CB_Move1); pk1.Move2 = WinFormsUtil.GetIndex(CB_Move2); pk1.Move3 = WinFormsUtil.GetIndex(CB_Move3); pk1.Move4 = WinFormsUtil.GetIndex(CB_Move4); pk1.Move1_PP = WinFormsUtil.GetIndex(CB_Move1) > 0 ? Util.ToInt32(TB_PP1.Text) : 0; pk1.Move2_PP = WinFormsUtil.GetIndex(CB_Move2) > 0 ? Util.ToInt32(TB_PP2.Text) : 0; pk1.Move3_PP = WinFormsUtil.GetIndex(CB_Move3) > 0 ? Util.ToInt32(TB_PP3.Text) : 0; pk1.Move4_PP = WinFormsUtil.GetIndex(CB_Move4) > 0 ? Util.ToInt32(TB_PP4.Text) : 0; pk1.Move1_PPUps = WinFormsUtil.GetIndex(CB_Move1) > 0 ? CB_PPu1.SelectedIndex : 0; pk1.Move2_PPUps = WinFormsUtil.GetIndex(CB_Move2) > 0 ? CB_PPu2.SelectedIndex : 0; pk1.Move3_PPUps = WinFormsUtil.GetIndex(CB_Move3) > 0 ? CB_PPu3.SelectedIndex : 0; pk1.Move4_PPUps = WinFormsUtil.GetIndex(CB_Move4) > 0 ? CB_PPu4.SelectedIndex : 0; pk1.IV_HP = Util.ToInt32(TB_HPIV.Text); pk1.IV_ATK = Util.ToInt32(TB_ATKIV.Text); pk1.IV_DEF = Util.ToInt32(TB_DEFIV.Text); pk1.IV_SPE = Util.ToInt32(TB_SPEIV.Text); pk1.IV_SPA = Util.ToInt32(TB_SPAIV.Text); pk1.OT_Name = TB_OT.Text; // Toss in Party Stats Array.Resize(ref pk1.Data, pk1.SIZE_PARTY); pk1.Stat_Level = Util.ToInt32(TB_Level.Text); pk1.Stat_HPCurrent = Util.ToInt32(Stat_HP.Text); pk1.Stat_HPMax = Util.ToInt32(Stat_HP.Text); pk1.Stat_ATK = Util.ToInt32(Stat_ATK.Text); pk1.Stat_DEF = Util.ToInt32(Stat_DEF.Text); pk1.Stat_SPE = Util.ToInt32(Stat_SPE.Text); pk1.Stat_SPA = Util.ToInt32(Stat_SPA.Text); pk1.Stat_SPD = Util.ToInt32(Stat_SPD.Text); if (HaX) { pk1.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue); } // Fix Moves if a slot is empty pk1.FixMoves(); pk1.RefreshChecksum(); return(pk1); }