public void PopulateFields(PK1 pk, bool focus = true) { pk1 = pk ?? new PK1(); if (focus) { Tab_Main.Focus(); } pk1.Current_Level = (byte)Tables.getLevel(pk1.Species, pk1.EXP); if (pk1.Level == 100) { pk1.EXP = Tables.getEXP(pk1.Current_Level, pk1.Species); } pk1.Level = pk1.Current_Level; changingFields = true; CB_Species.SelectedValue = (int)pk1.Species; TB_TID.Text = pk1.TID.ToString("00000"); TB_OT.Text = RBY_Encoding.GetString(pk1.OT_Name, JP_Mode); TB_Nickname.Text = RBY_Encoding.GetString(pk1.Nickname, JP_Mode); TB_HPDV.Text = pk1.DV_HP.ToString(); TB_ATKDV.Text = pk1.DV_ATK.ToString(); TB_DEFDV.Text = pk1.DV_DEF.ToString(); TB_SPDDV.Text = pk1.DV_SPD.ToString(); TB_SPCDV.Text = pk1.DV_SPC.ToString(); TB_HPSTATEXP.Text = pk1.STATEXP_HP.ToString(); TB_ATKSTATEXP.Text = pk1.STATEXP_ATK.ToString(); TB_DEFSTATEXP.Text = pk1.STATEXP_DEF.ToString(); TB_SPCSTATEXP.Text = pk1.STATEXP_SPC.ToString(); TB_SPDSTATEXP.Text = pk1.STATEXP_SPD.ToString(); TB_EXP.Text = pk1.EXP.ToString(); TB_Level.Text = pk1.Current_Level.ToString(); CB_Move1.SelectedValue = (int)pk1.Move_1; CB_Move2.SelectedValue = (int)pk1.Move_2; CB_Move3.SelectedValue = (int)pk1.Move_3; CB_Move4.SelectedValue = (int)pk1.Move_4; CB_PPu1.SelectedIndex = pk1.PPUP_1; CB_PPu2.SelectedIndex = pk1.PPUP_2; CB_PPu3.SelectedIndex = pk1.PPUP_3; CB_PPu4.SelectedIndex = pk1.PPUP_4; TB_PP1.Text = pk1.PP_1.ToString(); TB_PP2.Text = pk1.PP_2.ToString(); TB_PP3.Text = pk1.PP_3.ToString(); TB_PP4.Text = pk1.PP_4.ToString(); changingFields = false; updateStats(); SetStatusViewing(); }
/// <summary> /// Accessible method to lead Fields from PKM /// The Loading is done in WinForms /// </summary> /// <param name="pk">The PKM file</param> /// <param name="focus">Set input focus to control</param> /// <param name="skipConversionCheck">Default this to true</param> public void LoadFieldsFromPKM2(PKM pk, bool focus = true, bool skipConversionCheck = true) { if (pk == null) { WinFormsUtil.Error("Attempted to load a null file."); return; } if (focus) { Tab_Main.Focus(); } if (!skipConversionCheck && !PKMConverter.TryMakePKMCompatible(pk, CurrentPKM, out string c, out pk)) { WinFormsUtil.Alert(c); return; } bool oldInit = FieldsInitialized; FieldsInitialized = FieldsLoaded = false; pkm = pk.Clone(); try { GetFieldsfromPKM(); } finally { FieldsInitialized = oldInit; } Stats.UpdateIVs(null, null); UpdatePKRSInfected(null, null); UpdatePKRSCured(null, null); if (HaX) // Load original values from pk not pkm { MT_Level.Text = (pk.Stat_HPMax != 0 ? pk.Stat_Level : PKX.GetLevel(pk.EXP, pk.Species, pk.AltForm)).ToString(); TB_EXP.Text = pk.EXP.ToString(); MT_Form.Text = pk.AltForm.ToString(); if (pk.Stat_HPMax != 0) // stats present { Stats.LoadPartyStats(pk); } } FieldsLoaded = true; SetMarkings(); UpdateLegality(); UpdateSprite(); LastData = PreparePKM()?.Data; }