private void SetForms() { int species = WinFormsUtil.GetIndex(CB_Species); bool hasForms = FormInfo.HasFormSelection(PersonalTable.AO[species], species, 6); CB_Form.Enabled = CB_Form.Visible = hasForms; CB_Form.InitializeBinding(); CB_Form.DataSource = FormConverter.GetFormList(species, GameInfo.Strings.types, GameInfo.Strings.forms, Main.GenderSymbols, SAV.Generation); }
private bool FillLBForms(int index) { LB_Forms.DataSource = null; LB_Forms.Items.Clear(); DisplayedForms.Clear(); DisplayedForms.Add(new ComboItem(GameInfo.Strings.types[0], 0)); CB_DisplayForm.DataSource = new BindingSource(DisplayedForms, null); lastForm = 0; int species = DexToSpecies[index + 1]; bool hasForms = FormInfo.HasFormSelection(SAV.Personal[species], species, 8); LB_Forms.Enabled = CB_DisplayForm.Enabled = hasForms; if (!hasForms) { return(false); } var ds = FormConverter.GetFormList(species, GameInfo.Strings.types, GameInfo.Strings.forms, Main.GenderSymbols, SAV.Generation).ToList(); if (ds.Count == 1 && string.IsNullOrEmpty(ds[0])) { // empty LB_Forms.Enabled = CB_DisplayForm.Enabled = false; return(false); } // Sanitize forms to only show entries with form storage var formCount = SAV.Personal[species].FormCount; var sanitized = new List <string>(); DisplayedForms.Clear(); for (var form = 0; form < formCount; form++) { if (!Dex.HasFormStorage(species, form) || Dex.IsBlacklisted(species, form)) { continue; } sanitized.Add(ds[form]); DisplayedForms.Add(new ComboItem(ds[form], form)); } CB_DisplayForm.DataSource = new BindingSource(DisplayedForms, null); LB_Forms.DataSource = sanitized; LB_Forms.SelectedIndex = 0; return(true); }
private bool FillLBForms() { if (allModifying) { return(false); } LB_Forms.DataSource = null; LB_Forms.Items.Clear(); int fspecies = LB_Species.SelectedIndex + 1; var bspecies = Dex.GetBaseSpecies(fspecies); bool hasForms = FormInfo.HasFormSelection(SAV.Personal[bspecies], bspecies, 7); LB_Forms.Enabled = hasForms; if (!hasForms) { return(false); } var ds = FormConverter.GetFormList(bspecies, GameInfo.Strings.types, GameInfo.Strings.forms, Main.GenderSymbols, SAV.Generation).ToList(); if (ds.Count == 1 && string.IsNullOrEmpty(ds[0])) { // empty LB_Forms.Enabled = false; return(false); } // sanity check forms -- SM does not have totem form dex bits int count = SAV.Personal[bspecies].FormCount; if (count < ds.Count) { ds.RemoveAt(count); // remove last } LB_Forms.DataSource = ds; if (fspecies <= SAV.MaxSpeciesID) { LB_Forms.SelectedIndex = 0; } else { int fc = SAV.Personal[bspecies].FormCount; if (fc <= 1) { return(true); } int f = Dex.GetDexFormIndex(bspecies, fc, 0); if (f < 0) { return(true); // bit index valid } var findex = fspecies - f - 1; if (findex < LB_Forms.Items.Count) { LB_Forms.SelectedIndex = findex; } else { LB_Forms.SelectedIndex = -1; } } return(true); }