public SAV_PokedexSM(SaveFile sav) { SAV = (SAV7)(Origin = sav).Clone(); InitializeComponent(); CP = new[] { CHK_P1, CHK_P2, CHK_P3, CHK_P4, CHK_P5, CHK_P6, CHK_P7, CHK_P8, CHK_P9, }; CL = new[] { CHK_L1, CHK_L2, CHK_L3, CHK_L4, CHK_L5, CHK_L6, CHK_L7, CHK_L8, CHK_L9, }; WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage); editing = true; // Clear Listbox and ComboBox LB_Species.Items.Clear(); CB_Species.Items.Clear(); LB_Forms.Items.Clear(); // Fill List CB_Species.DisplayMember = "Text"; CB_Species.ValueMember = "Value"; CB_Species.DataSource = new BindingSource(GameInfo.SpeciesDataSource.Skip(1).ToList(), null); for (int i = 1; i < SAV.MaxSpeciesID + 1; i++) { LB_Species.Items.Add($"{i:000} - {GameInfo.Strings.specieslist[i]}"); } // Add Formes int ctr = SAV.MaxSpeciesID; baseSpecies = new List <int>(); for (int i = 1; i < SAV.MaxSpeciesID + 1; i++) { int c = SAV.Personal[i].FormeCount; for (int j = 0; j < c; j++) { int x = SAV.USUM ? SaveUtil.GetDexFormIndexUSUM(i, c, j) : SaveUtil.GetDexFormIndexSM(i, c, j); if (x == -1 || j == 0) { continue; } baseSpecies.Add(i); ctr++; LB_Species.Items.Add($"{ctr:000} - {GameInfo.Strings.specieslist[i]}-{j}"); } } Dex = new PokeDex7(SAV); editing = false; LB_Species.SelectedIndex = 0; CB_Species.KeyDown += WinFormsUtil.RemoveDropCB; }
private void ChangeLBForms(object sender, EventArgs e) { if (allModifying) { return; } if (editing) { return; } SetEntry(); editing = true; int fspecies = LB_Species.SelectedIndex + 1; var bspecies = fspecies <= SAV.MaxSpeciesID ? fspecies : baseSpecies[fspecies - SAV.MaxSpeciesID - 1]; int form = LB_Forms.SelectedIndex; if (form > 0) { int fc = SAV.Personal[bspecies].FormeCount; if (fc > 1) // actually has forms { int f = SAV.USUM ? SaveUtil.GetDexFormIndexUSUM(bspecies, fc, SAV.MaxSpeciesID - 1) : SaveUtil.GetDexFormIndexSM(bspecies, fc, SAV.MaxSpeciesID - 1); if (f >= 0) // bit index valid { species = f + form + 1; } else { species = bspecies; } } else { species = bspecies; } } else { species = bspecies; } CB_Species.SelectedValue = species; LB_Species.SelectedIndex = species - 1; LB_Species.TopIndex = LB_Species.SelectedIndex; GetEntry(); editing = false; }
private IEnumerable <int> GetAllFormEntries(int spec, bool USUM) { var fc = SAV.Personal[spec].FormeCount; for (int j = 1; j < fc; j++) { int start = j; int end = j; if (SAV7.SanitizeFormsToIterate(spec, out int s, out int n, j, USUM)) { start = s; end = n; } start = Math.Max(1, start); for (int f = start; f <= end; f++) { int x = SAV.USUM ? SaveUtil.GetDexFormIndexUSUM(spec, fc, f) : SaveUtil.GetDexFormIndexSM(spec, fc, f); if (x >= 0) { yield return(SAV.MaxSpeciesID - 1 + x); } } } }
public int GetDexFormStart(int spec, int fc) { return(Parent.USUM ? SaveUtil.GetDexFormIndexUSUM(spec, fc, Parent.MaxSpeciesID - 1) : SaveUtil.GetDexFormIndexSM(spec, fc, Parent.MaxSpeciesID - 1)); }