diff --git a/Misc/PKX.cs b/Misc/PKX.cs index bb0162d7f..f312c0d03 100644 --- a/Misc/PKX.cs +++ b/Misc/PKX.cs @@ -1116,6 +1116,105 @@ namespace PKHeX } return new[] {""}; } + internal static int getDexFormIndexXY(int species, int formct) + { + if (formct < 1 || species < 0) + return -1; // invalid + switch (species) + { + case 201: return 000; // 28 Unown + case 386: return 028; // 4 Deoxys + case 492: return 032; // 2 Shaymin + case 487: return 034; // 2 Giratina + case 479: return 036; // 6 Rotom + case 422: return 042; // 2 Shellos + case 423: return 044; // 2 Gastrodon + case 412: return 046; // 3 Burmy + case 413: return 049; // 3 Wormadam + case 351: return 052; // 4 Castform + case 421: return 056; // 2 Cherrim + case 585: return 058; // 4 Deerling + case 586: return 062; // 4 Sawsbuck + case 648: return 066; // 2 Meloetta + case 555: return 068; // 2 Darmanitan + case 550: return 070; // 2 Basculin + case 646: return 072; // 3 Kyurem + case 647: return 075; // 2 Keldeo + case 642: return 077; // 2 Thundurus + case 641: return 079; // 2 Tornadus + case 645: return 081; // 2 Landorus + case 666: return 083; // 20 Vivillion + case 669: return 103; // 5 Flabébé + case 670: return 108; // 6 Floette + case 671: return 114; // 5 Florges + case 710: return 119; // 4 Pumpkaboo + case 711: return 123; // 4 Gourgeist + case 681: return 127; // 2 Aegislash + case 716: return 129; // 2 Xerneas + case 003: return 131; // 2 Venusaur + case 006: return 133; // 3 Charizard + case 009: return 136; // 2 Blastoise + case 065: return 138; // 2 Alakazam + case 094: return 140; // 2 Gengar + case 115: return 142; // 2 Kangaskhan + case 127: return 144; // 2 Pinsir + case 130: return 146; // 2 Gyarados + case 142: return 148; // 2 Aerodactyl + case 150: return 150; // 3 Mewtwo + case 181: return 153; // 2 Ampharos + case 212: return 155; // 2 Scizor + case 214: return 157; // 2 Heracros + case 229: return 159; // 2 Houndoom + case 248: return 161; // 2 Tyranitar + case 257: return 163; // 2 Blaziken + case 303: return 165; // 2 Mawile + case 306: return 167; // 2 Aggron + case 308: return 169; // 2 Medicham + case 310: return 171; // 2 Manetric + case 354: return 173; // 2 Banette + case 359: return 175; // 2 Absol + case 380: return 177; // 2 Latias + case 381: return 179; // 2 Latios + case 445: return 181; // 2 Garchomp + case 448: return 183; // 2 Lucario + case 460: return 185; // 2 Abomasnow + default: return -1; + } + } + internal static int getDexFormIndexORAS(int species, int formct) + { + if (formct < 1 || species < 0) + return -1; // invalid + switch (species) + { + case 025: return 187; // 7 Pikachu + case 720: return 194; // 2 Hoopa + case 015: return 196; // 2 Beedrill + case 018: return 198; // 2 Pidgeot + case 080: return 200; // 2 Slowbro + case 208: return 202; // 2 Steelix + case 254: return 204; // 2 Sceptile + case 360: return 206; // 2 Swampert + case 302: return 208; // 2 Sableye + case 319: return 210; // 2 Sharpedo + case 323: return 212; // 2 Camerupt + case 334: return 214; // 2 Altaria + case 362: return 216; // 2 Glalie + case 373: return 218; // 2 Salamence + case 376: return 220; // 2 Metagross + case 384: return 222; // 2 Rayquaza + case 428: return 224; // 2 Lopunny + case 475: return 226; // 2 Gallade + case 531: return 228; // 2 Audino + case 719: return 230; // 2 Diancie + case 382: return 232; // 2 Kyogre + case 383: return 234; // 2 Groudon + case 493: return 236; // 18 Arceus + case 649: return 254; // 5 Genesect + case 676: return 259; // 10 Furfrou + default: return getDexFormIndexXY(species, formct); + } + } /// Calculate the Hidden Power Type of the entered IVs. /// Order: HP,ATK,DEF,SPEED,SPA,SPD @@ -1157,11 +1256,11 @@ namespace PKHeX internal static readonly string[] StatNames = { "HP", "Atk", "Def", "SpA", "SpD", "Spe" }; public class ShowdownSet { - internal static readonly string[] species = Util.getStringList("Species", "en"); - internal static readonly string[] items = Util.getStringList("Items", "en"); - internal static readonly string[] natures = Util.getStringList("Natures", "en"); - internal static readonly string[] moves = Util.getStringList("Moves", "en"); - internal static readonly string[] abilities = Util.getStringList("Abilities", "en"); + private static readonly string[] species = Util.getStringList("Species", "en"); + private static readonly string[] items = Util.getStringList("Items", "en"); + private static readonly string[] natures = Util.getStringList("Natures", "en"); + private static readonly string[] moves = Util.getStringList("Moves", "en"); + private static readonly string[] abilities = Util.getStringList("Abilities", "en"); // Default Set Data public string Nickname; diff --git a/SAV/SAV_PokedexORAS.Designer.cs b/SAV/SAV_PokedexORAS.Designer.cs index ab657b444..cd9660978 100644 --- a/SAV/SAV_PokedexORAS.Designer.cs +++ b/SAV/SAV_PokedexORAS.Designer.cs @@ -67,18 +67,29 @@ this.mnuCaughtNone = new System.Windows.Forms.ToolStripMenuItem(); this.mnuCaughtAll = new System.Windows.Forms.ToolStripMenuItem(); this.mnuComplete = new System.Windows.Forms.ToolStripMenuItem(); - this.mnuDexNav = new System.Windows.Forms.ToolStripMenuItem(); this.mnuResetNav = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuDexNav = new System.Windows.Forms.ToolStripMenuItem(); + this.CLB_FormsSeen = new System.Windows.Forms.CheckedListBox(); + this.L_FormsSeen = new System.Windows.Forms.Label(); + this.CLB_FormDisplayed = new System.Windows.Forms.CheckedListBox(); + this.L_FormDisplayed = new System.Windows.Forms.Label(); + this.B_ModifyForms = new System.Windows.Forms.Button(); + this.modifyMenuForms = new System.Windows.Forms.ContextMenuStrip(this.components); + this.mnuFormNone = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuFormAll = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuForm1 = new System.Windows.Forms.ToolStripMenuItem(); this.GB_Language.SuspendLayout(); this.GB_Displayed.SuspendLayout(); this.GB_Owned.SuspendLayout(); this.GB_Encountered.SuspendLayout(); this.modifyMenu.SuspendLayout(); + this.modifyMenuForms.SuspendLayout(); this.SuspendLayout(); // // B_Cancel // - this.B_Cancel.Location = new System.Drawing.Point(297, 242); + this.B_Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.B_Cancel.Location = new System.Drawing.Point(461, 242); this.B_Cancel.Name = "B_Cancel"; this.B_Cancel.Size = new System.Drawing.Size(80, 23); this.B_Cancel.TabIndex = 0; @@ -88,6 +99,8 @@ // // LB_Species // + this.LB_Species.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); this.LB_Species.FormattingEnabled = true; this.LB_Species.Location = new System.Drawing.Point(12, 40); this.LB_Species.Name = "LB_Species"; @@ -256,7 +269,8 @@ // // B_Save // - this.B_Save.Location = new System.Drawing.Point(297, 218); + this.B_Save.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.B_Save.Location = new System.Drawing.Point(547, 242); this.B_Save.Name = "B_Save"; this.B_Save.Size = new System.Drawing.Size(80, 23); this.B_Save.TabIndex = 24; @@ -305,11 +319,12 @@ // // L_DexNav // - this.L_DexNav.Location = new System.Drawing.Point(184, 242); + this.L_DexNav.Location = new System.Drawing.Point(184, 239); this.L_DexNav.Name = "L_DexNav"; - this.L_DexNav.Size = new System.Drawing.Size(104, 27); + this.L_DexNav.Size = new System.Drawing.Size(104, 20); this.L_DexNav.TabIndex = 32; this.L_DexNav.Text = "DexNav Lv:"; + this.L_DexNav.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // MT_Count // @@ -319,7 +334,6 @@ this.MT_Count.Size = new System.Drawing.Size(32, 20); this.MT_Count.TabIndex = 31; this.MT_Count.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - this.MT_Count.TextChanged += new System.EventHandler(this.changeEncounteredCount); // // GB_Owned // @@ -335,7 +349,7 @@ // this.TB_Spinda.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.TB_Spinda.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.TB_Spinda.Location = new System.Drawing.Point(317, 196); + this.TB_Spinda.Location = new System.Drawing.Point(317, 195); this.TB_Spinda.Name = "TB_Spinda"; this.TB_Spinda.Size = new System.Drawing.Size(60, 20); this.TB_Spinda.TabIndex = 29; @@ -418,62 +432,146 @@ this.mnuResetNav, this.mnuDexNav}); this.modifyMenu.Name = "modifyMenu"; - this.modifyMenu.Size = new System.Drawing.Size(153, 180); + this.modifyMenu.Size = new System.Drawing.Size(149, 158); // // mnuSeenNone // this.mnuSeenNone.Name = "mnuSeenNone"; - this.mnuSeenNone.Size = new System.Drawing.Size(152, 22); + this.mnuSeenNone.Size = new System.Drawing.Size(148, 22); this.mnuSeenNone.Text = "Seen none"; this.mnuSeenNone.Click += new System.EventHandler(this.modifyAll); // // mnuSeenAll // this.mnuSeenAll.Name = "mnuSeenAll"; - this.mnuSeenAll.Size = new System.Drawing.Size(152, 22); + this.mnuSeenAll.Size = new System.Drawing.Size(148, 22); this.mnuSeenAll.Text = "Seen all"; this.mnuSeenAll.Click += new System.EventHandler(this.modifyAll); // // mnuCaughtNone // this.mnuCaughtNone.Name = "mnuCaughtNone"; - this.mnuCaughtNone.Size = new System.Drawing.Size(152, 22); + this.mnuCaughtNone.Size = new System.Drawing.Size(148, 22); this.mnuCaughtNone.Text = "Caught none"; this.mnuCaughtNone.Click += new System.EventHandler(this.modifyAll); // // mnuCaughtAll // this.mnuCaughtAll.Name = "mnuCaughtAll"; - this.mnuCaughtAll.Size = new System.Drawing.Size(152, 22); + this.mnuCaughtAll.Size = new System.Drawing.Size(148, 22); this.mnuCaughtAll.Text = "Caught all"; this.mnuCaughtAll.Click += new System.EventHandler(this.modifyAll); // // mnuComplete // this.mnuComplete.Name = "mnuComplete"; - this.mnuComplete.Size = new System.Drawing.Size(152, 22); + this.mnuComplete.Size = new System.Drawing.Size(148, 22); this.mnuComplete.Text = "Complete Dex"; this.mnuComplete.Click += new System.EventHandler(this.modifyAll); // - // mnuDexNav - // - this.mnuDexNav.Name = "mnuDexNav"; - this.mnuDexNav.Size = new System.Drawing.Size(152, 22); - this.mnuDexNav.Text = "999 DexNav"; - this.mnuDexNav.Click += new System.EventHandler(this.modifyAll); - // // mnuResetNav // this.mnuResetNav.Name = "mnuResetNav"; - this.mnuResetNav.Size = new System.Drawing.Size(152, 22); + this.mnuResetNav.Size = new System.Drawing.Size(148, 22); this.mnuResetNav.Text = "Reset DexNav"; this.mnuResetNav.Click += new System.EventHandler(this.modifyAll); // + // mnuDexNav + // + this.mnuDexNav.Name = "mnuDexNav"; + this.mnuDexNav.Size = new System.Drawing.Size(148, 22); + this.mnuDexNav.Text = "999 DexNav"; + this.mnuDexNav.Click += new System.EventHandler(this.modifyAll); + // + // CLB_FormsSeen + // + this.CLB_FormsSeen.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.CLB_FormsSeen.FormattingEnabled = true; + this.CLB_FormsSeen.Location = new System.Drawing.Point(383, 61); + this.CLB_FormsSeen.Name = "CLB_FormsSeen"; + this.CLB_FormsSeen.Size = new System.Drawing.Size(119, 154); + this.CLB_FormsSeen.TabIndex = 34; + // + // L_FormsSeen + // + this.L_FormsSeen.Location = new System.Drawing.Point(380, 40); + this.L_FormsSeen.Name = "L_FormsSeen"; + this.L_FormsSeen.Size = new System.Drawing.Size(104, 20); + this.L_FormsSeen.TabIndex = 35; + this.L_FormsSeen.Text = "Seen Forms:"; + this.L_FormsSeen.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // CLB_FormDisplayed + // + this.CLB_FormDisplayed.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.CLB_FormDisplayed.FormattingEnabled = true; + this.CLB_FormDisplayed.Location = new System.Drawing.Point(508, 61); + this.CLB_FormDisplayed.Name = "CLB_FormDisplayed"; + this.CLB_FormDisplayed.Size = new System.Drawing.Size(119, 154); + this.CLB_FormDisplayed.TabIndex = 36; + this.CLB_FormDisplayed.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.updateDisplayedForm); + // + // L_FormDisplayed + // + this.L_FormDisplayed.Location = new System.Drawing.Point(505, 40); + this.L_FormDisplayed.Name = "L_FormDisplayed"; + this.L_FormDisplayed.Size = new System.Drawing.Size(104, 20); + this.L_FormDisplayed.TabIndex = 37; + this.L_FormDisplayed.Text = "Displayed Form:"; + this.L_FormDisplayed.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // B_ModifyForms + // + this.B_ModifyForms.Location = new System.Drawing.Point(567, 11); + this.B_ModifyForms.Name = "B_ModifyForms"; + this.B_ModifyForms.Size = new System.Drawing.Size(60, 23); + this.B_ModifyForms.TabIndex = 38; + this.B_ModifyForms.Text = "Modify..."; + this.B_ModifyForms.UseVisualStyleBackColor = true; + this.B_ModifyForms.Click += new System.EventHandler(this.B_ModifyForms_Click); + // + // modifyMenuForms + // + this.modifyMenuForms.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mnuFormNone, + this.mnuForm1, + this.mnuFormAll}); + this.modifyMenuForms.Name = "modifyMenu"; + this.modifyMenuForms.Size = new System.Drawing.Size(130, 70); + // + // mnuFormNone + // + this.mnuFormNone.Name = "mnuFormNone"; + this.mnuFormNone.Size = new System.Drawing.Size(129, 22); + this.mnuFormNone.Text = "Seen none"; + this.mnuFormNone.Click += new System.EventHandler(this.modifyAllForms); + // + // mnuFormAll + // + this.mnuFormAll.Name = "mnuFormAll"; + this.mnuFormAll.Size = new System.Drawing.Size(129, 22); + this.mnuFormAll.Text = "Seen all"; + this.mnuFormAll.Click += new System.EventHandler(this.modifyAllForms); + // + // mnuForm1 + // + this.mnuForm1.Name = "mnuForm1"; + this.mnuForm1.Size = new System.Drawing.Size(129, 22); + this.mnuForm1.Text = "Seen one"; + this.mnuForm1.Click += new System.EventHandler(this.modifyAllForms); + // // SAV_PokedexORAS // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(394, 272); + this.ClientSize = new System.Drawing.Size(634, 272); + this.Controls.Add(this.B_ModifyForms); + this.Controls.Add(this.L_FormDisplayed); + this.Controls.Add(this.CLB_FormDisplayed); + this.Controls.Add(this.L_FormsSeen); + this.Controls.Add(this.CLB_FormsSeen); this.Controls.Add(this.L_DexNav); this.Controls.Add(this.GB_Encountered); this.Controls.Add(this.L_Spinda); @@ -505,6 +603,7 @@ this.GB_Encountered.ResumeLayout(false); this.GB_Encountered.PerformLayout(); this.modifyMenu.ResumeLayout(false); + this.modifyMenuForms.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -551,5 +650,14 @@ private System.Windows.Forms.ToolStripMenuItem mnuComplete; private System.Windows.Forms.ToolStripMenuItem mnuDexNav; private System.Windows.Forms.ToolStripMenuItem mnuResetNav; + private System.Windows.Forms.Label L_FormsSeen; + private System.Windows.Forms.CheckedListBox CLB_FormsSeen; + private System.Windows.Forms.CheckedListBox CLB_FormDisplayed; + private System.Windows.Forms.Label L_FormDisplayed; + private System.Windows.Forms.Button B_ModifyForms; + private System.Windows.Forms.ContextMenuStrip modifyMenuForms; + private System.Windows.Forms.ToolStripMenuItem mnuFormNone; + private System.Windows.Forms.ToolStripMenuItem mnuFormAll; + private System.Windows.Forms.ToolStripMenuItem mnuForm1; } } \ No newline at end of file diff --git a/SAV/SAV_PokedexORAS.cs b/SAV/SAV_PokedexORAS.cs index 839a0677c..2fadeab21 100644 --- a/SAV/SAV_PokedexORAS.cs +++ b/SAV/SAV_PokedexORAS.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Drawing; -using System.Linq; using System.Windows.Forms; namespace PKHeX @@ -30,7 +29,7 @@ namespace PKHeX for (int i = 1; i < Main.specieslist.Length; i++) LB_Species.Items.Add(i.ToString("000") + " - " + Main.specieslist[i]); - getBools(); + getData(); editing = false; LB_Species.SelectedIndex = 0; TB_Spinda.Text = BitConverter.ToUInt32(sav, Main.SAV.Spinda).ToString("X8"); @@ -41,59 +40,32 @@ namespace PKHeX private readonly byte[] sav = (byte[])Main.SAV.Data.Clone(); private readonly bool[,] specbools = new bool[9, 0x60 * 8]; private readonly bool[,] langbools = new bool[7, 0x60 * 8]; + private BitArray formbools; private bool editing; private int species = -1; + private const int FormLen = 0x26; private void changeCBSpecies(object sender, EventArgs e) { if (editing) return; - setBools(); + setEntry(); editing = true; species = (int)CB_Species.SelectedValue; LB_Species.SelectedIndex = species - 1; // Since we don't allow index0 in combobox, everything is shifted by 1 LB_Species.TopIndex = LB_Species.SelectedIndex; - loadchks(); + getEntry(); editing = false; } private void changeLBSpecies(object sender, EventArgs e) { if (editing) return; - setBools(); + setEntry(); editing = true; species = LB_Species.SelectedIndex + 1; CB_Species.SelectedValue = species; - loadchks(); - editing = false; - } - private void loadchks() - { - // Load Bools for the data - int pk = species; - - L_Spinda.Visible = TB_Spinda.Visible = pk == 327; - - // Load Partitions - for (int i = 0; i < 9; i++) - CP[i].Checked = specbools[i, pk-1]; - for (int i = 0; i < 7; i++) - CL[i].Checked = langbools[i, pk-1]; - - CHK_P1.Enabled = true; - - int index = LB_Species.SelectedIndex + 1; - int gt = PKX.Personal[index].Gender; - - CHK_P2.Enabled = CHK_P4.Enabled = CHK_P6.Enabled = CHK_P8.Enabled = gt != 254; // Not Female-Only - CHK_P3.Enabled = CHK_P5.Enabled = CHK_P7.Enabled = CHK_P9.Enabled = gt != 0 && gt != 255; // Not Male-Only and Not Genderless - - for (int i = 0; i < 7; i++) - CL[i].Enabled = true; - - // Load Encountered Count - editing = true; - MT_Count.Text = BitConverter.ToUInt16(sav, Main.SAV.EncounterCount + (pk - 1) * 2).ToString(); + getEntry(); editing = false; } private void removedropCB(object sender, KeyEventArgs e) @@ -132,7 +104,50 @@ namespace PKHeX } } - private void setBools() + private void getEntry() + { + // Load Bools for the data + int pk = species; + + L_Spinda.Visible = TB_Spinda.Visible = pk == 327; + + // Load Partitions + for (int i = 0; i < 9; i++) + CP[i].Checked = specbools[i, pk - 1]; + for (int i = 0; i < 7; i++) + CL[i].Checked = langbools[i, pk - 1]; + + int gt = PKX.Personal[pk].Gender; + + CHK_P2.Enabled = CHK_P4.Enabled = CHK_P6.Enabled = CHK_P8.Enabled = gt != 254; // Not Female-Only + CHK_P3.Enabled = CHK_P5.Enabled = CHK_P7.Enabled = CHK_P9.Enabled = gt != 0 && gt != 255; // Not Male-Only and Not Genderless + + // Load Encountered Count + MT_Count.Text = BitConverter.ToUInt16(sav, Main.SAV.EncounterCount + (pk - 1) * 2).ToString(); + + CLB_FormsSeen.Items.Clear(); + CLB_FormDisplayed.Items.Clear(); + + int fc = PKX.Personal[species].FormeCount; + int f = PKX.getDexFormIndexORAS(species, fc); + if (f < 0) + return; + string[] forms = PKX.getFormList(species, Main.types, Main.forms, Main.gendersymbols); + if (forms.Length < 1) + return; + + // 0x26 packs of bools + for (int i = 0; i < forms.Length; i++) // Seen + CLB_FormsSeen.Items.Add(forms[i], formbools[f + i + 0*FormLen*8]); + for (int i = 0; i < forms.Length; i++) // Seen Shiny + CLB_FormsSeen.Items.Add("* " + forms[i], formbools[f + i + 1*FormLen*8]); + + for (int i = 0; i < forms.Length; i++) // Displayed + CLB_FormDisplayed.Items.Add(forms[i], formbools[f + i + 2*FormLen*8]); + for (int i = 0; i < forms.Length; i++) // Displayed Shiny + CLB_FormDisplayed.Items.Add("* " + forms[i], formbools[f + i + 3*FormLen*8]); + } + private void setEntry() { if (species < 0) return; @@ -154,6 +169,87 @@ namespace PKHeX langbools[4, species - 1] = CHK_L5.Checked; langbools[5, species - 1] = CHK_L6.Checked; langbools[6, species - 1] = CHK_L7.Checked; + + BitConverter.GetBytes((ushort)Math.Min(0xFFFF, Util.ToUInt32(MT_Count.Text))).CopyTo(sav, Main.SAV.EncounterCount + (species - 1) * 2); + + int fc = PKX.Personal[species].FormeCount; + int f = PKX.getDexFormIndexORAS(species, fc); + if (f < 0) + return; + + for (int i = 0; i < CLB_FormsSeen.Items.Count/2; i++) // Seen + formbools[f + i + 0*FormLen*8] = CLB_FormsSeen.GetItemChecked(i); + for (int i = 0; i < CLB_FormsSeen.Items.Count/2; i++) // Seen Shiny + formbools[f + i + 1*FormLen*8] = CLB_FormsSeen.GetItemChecked(i + CLB_FormsSeen.Items.Count/2); + + editing = true; + for (int i = 0; i < CLB_FormDisplayed.Items.Count/2; i++) // Displayed + formbools[f + i + 2*FormLen*8] = CLB_FormDisplayed.GetItemChecked(i); + for (int i = 0; i < CLB_FormDisplayed.Items.Count/2; i++) // Displayed Shiny + formbools[f + i + 3*FormLen*8] = CLB_FormDisplayed.GetItemChecked(i + CLB_FormDisplayed.Items.Count/2); + editing = false; + } + + private void getData() + { + // Fill Bit arrays + for (int i = 0; i < 9; i++) + { + byte[] data = new byte[0x60]; + int offset = Main.SAV.PokeDex + 0x8 + 0x60 * i; + Array.Copy(sav, offset, data, 0, data.Length); + BitArray BitRegion = new BitArray(data); + for (int b = 0; b < 0x60 * 8; b++) + specbools[i, b] = BitRegion[b]; + } + + // Fill Language arrays + byte[] langdata = new byte[0x280]; + Array.Copy(sav, Main.SAV.PokeDexLanguageFlags, langdata, 0, langdata.Length); + BitArray LangRegion = new BitArray(langdata); + for (int b = 0; b < 721; b++) // 721 Species + for (int i = 0; i < 7; i++) // 7 Languages + langbools[i, b] = LangRegion[7 * b + i]; + + byte[] formdata = new byte[FormLen*4]; + Array.Copy(sav, Main.SAV.PokeDex + 0x368, formdata, 0, formdata.Length); + formbools = new BitArray(formdata); + } + private void setData() + { + // Save back the Species Bools + // Return to Byte Array + for (int p = 0; p < 9; p++) + { + byte[] sdata = new byte[0x60]; + + for (int i = 0; i < 0x60*8; i++) + if (specbools[p, i]) + sdata[i/8] |= (byte) (1 << i%8); + + sdata.CopyTo(sav, Main.SAV.PokeDex + 8 + 0x60*p); + } + + // Build new bool array for the Languages + bool[] languagedata = new bool[0x27C*8]; + for (int i = 0; i < 722; i++) + for (int l = 0; l < 7; l++) + languagedata[i*7 + l] = langbools[l, i]; + + // Return to Byte Array + byte[] ldata = new byte[languagedata.Length/8]; + + for (int i = 0; i < languagedata.Length; i++) + if (languagedata[i]) + ldata[i/8] |= (byte) (1 << i%8); + + ldata.CopyTo(sav, Main.SAV.PokeDexLanguageFlags); + + formbools.CopyTo(sav, Main.SAV.PokeDex + 0x368); + + // Store Spinda Spot + uint PID = Util.getHEXval(TB_Spinda.Text); + BitConverter.GetBytes(PID).CopyTo(sav, Main.SAV.Spinda); } private void B_Cancel_Click(object sender, EventArgs e) @@ -162,76 +258,17 @@ namespace PKHeX } private void B_Save_Click(object sender, EventArgs e) { - setBools(); - saveChanges(); + setEntry(); + setData(); // Return back to the parent savefile Array.Copy(sav, Main.SAV.Data, sav.Length); Main.SAV.Edited = true; Close(); } - private void saveChanges() - { - // Save back the Species Bools - // Return to Byte Array - for (int p = 0; p < 9; p++) - { - byte[] sdata = new byte[0x60]; - - for (int i = 0; i < 0x60 * 8; i++) - if (specbools[p, i]) - sdata[i / 8] |= (byte)(1 << i % 8); - - sdata.CopyTo(sav, Main.SAV.PokeDex + 8 + 0x60 * p); - } - - // Build new bool array for the Languages - { - bool[] languagedata = new bool[0x27C * 8]; - for (int i = 0; i < 722; i++) - for (int l = 0; l < 7; l++) - languagedata[i * 7 + l] = langbools[l, i]; - - // Return to Byte Array - byte[] ldata = new byte[languagedata.Length / 8]; - - for (int i = 0; i < languagedata.Length; i++) - if (languagedata[i]) - ldata[i / 8] |= (byte)(1 << i % 8); - - ldata.CopyTo(sav, Main.SAV.PokeDexLanguageFlags); - } - - // Store Spinda Spot - uint PID = Util.getHEXval(TB_Spinda.Text); - BitConverter.GetBytes(PID).CopyTo(sav, Main.SAV.Spinda); - } - - private void getBools() - { - // Fill Bit arrays - for (int i = 0; i < 9; i++) - { - byte[] data = new byte[0x60]; - int offset = Main.SAV.PokeDex + 0x8 + 0x60 * i; - Array.Copy(sav, offset, data, 0, 0x60); - BitArray BitRegion = new BitArray(data); - for (int b = 0; b < 0x60 * 8; b++) - specbools[i, b] = BitRegion[b]; - } - - // Fill Language arrays - byte[] langdata = new byte[0x280]; - Array.Copy(sav, Main.SAV.PokeDexLanguageFlags, langdata, 0, 0x280); - BitArray LangRegion = new BitArray(langdata); - for (int b = 0; b < 721; b++) // 721 Species - for (int i = 0; i < 7; i++) // 7 Languages - langbools[i, b] = LangRegion[7 * b + i]; - } private void B_GiveAll_Click(object sender, EventArgs e) { - if (LB_Species.SelectedIndex > 0x2D0) return; if (CHK_L1.Enabled) { CHK_L1.Checked = @@ -258,9 +295,13 @@ namespace PKHeX else if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) (gt != 254 ? CHK_P6 : CHK_P7).Checked = true; - int dexNav = Util.ToInt32(MT_Count.Text); - if (dexNav == 0) - MT_Count.Text = 1.ToString(); + for (int i = 0; i < CLB_FormsSeen.Items.Count; i++) + CLB_FormsSeen.SetItemChecked(i, ModifierKeys != Keys.Control); + if (CLB_FormsSeen.Items.Count > 0 && CLB_FormDisplayed.CheckedItems.Count == 0) + CLB_FormDisplayed.SetItemChecked(0, ModifierKeys != Keys.Control); + + if (Util.ToInt32(MT_Count.Text) == 0) + MT_Count.Text = "1"; } private void B_Modify_Click(object sender, EventArgs e) { @@ -269,98 +310,143 @@ namespace PKHeX } private void modifyAll(object sender, EventArgs e) { + if (mnuDexNav == sender) + { + for (int i = 0; i < 0x2D1; i++) + BitConverter.GetBytes((ushort)999).CopyTo(sav, Main.SAV.EncounterCount + i * 2); + return; + } + if (mnuResetNav == sender) + { + for (int i = 0; i < 0x2D1; i++) + BitConverter.GetBytes((ushort)0).CopyTo(sav, Main.SAV.EncounterCount + i * 2); + return; + } + int lang = Main.SAV.Language; if (lang > 5) lang -= 1; lang -= 1; - if (new[] { mnuSeenNone, mnuSeenAll, mnuComplete }.Contains(sender)) - for (int i = 0; i < CB_Species.Items.Count; i++) + if (sender == mnuSeenNone || sender == mnuSeenAll || sender == mnuComplete) + for (int i = 0; i < CB_Species.Items.Count; i++) { - int gt = PKX.Personal[i].Gender; - CB_Species.SelectedIndex = i; - foreach (CheckBox t in new[] {CHK_P2, CHK_P3, CHK_P4, CHK_P5}) + int gt = PKX.Personal[i + 1].Gender; + LB_Species.SelectedIndex = i; + foreach (CheckBox t in new[] { CHK_P2, CHK_P3, CHK_P4, CHK_P5 }) t.Checked = mnuSeenNone != sender && t.Enabled; if (mnuSeenNone != sender) { // if seen ensure at least one Displayed - if (!new[] {CHK_P6.Checked, CHK_P7.Checked, CHK_P8.Checked, CHK_P8.Checked}.Any(b => b)) + if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) (gt != 254 ? CHK_P6 : CHK_P7).Checked = true; } else { - for (int f = 0; f < 0x98; f++) - sav[Main.SAV.PokeDex + 0x368 + f] = 0; foreach (CheckBox t in CP) t.Checked = false; } - if (!new[] { CHK_P6.Checked, CHK_P7.Checked, CHK_P8.Checked, CHK_P8.Checked }.Any(b=> b)) + if (!CHK_P1.Checked) foreach (CheckBox t in CL) t.Checked = false; } - if (new[] {mnuCaughtNone, mnuCaughtAll, mnuComplete}.Contains(sender)) + if (sender == mnuCaughtNone || sender == mnuCaughtAll || sender == mnuComplete) for (int i = 0; i < CB_Species.Items.Count; i++) { - int gt = PKX.Personal[i].Gender; - CB_Species.SelectedIndex = i; - foreach (CheckBox t in new[] {CHK_P1}) + int gt = PKX.Personal[i + 1].Gender; + LB_Species.SelectedIndex = i; + foreach (CheckBox t in new[] { CHK_P1 }) t.Checked = mnuCaughtNone != sender; for (int j = 0; j < CL.Length; j++) CL[j].Checked = sender == mnuComplete || (mnuCaughtNone != sender && j == lang); if (mnuCaughtNone == sender) { - if (new[] { CHK_P1.Checked }.Any(b=> b)) // if seen, ensure at least one displayed - if (!new[] { CHK_P6.Checked, CHK_P7.Checked, CHK_P8.Checked, CHK_P8.Checked }.Any(b=> b)) - (gt != 254 ? CHK_P6 : CHK_P7).Checked = true; + if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked)) // if seen + if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) // not displayed + (gt != 254 ? CHK_P6 : CHK_P7).Checked = true; // check one } if (mnuCaughtNone != sender) { - // ensure at least one SEEN - if (!new[] { CHK_P2.Checked, CHK_P3.Checked, CHK_P4.Checked, CHK_P5.Checked }.Any(b=> b)) - (gt != 254 ? CHK_P2 : CHK_P3).Checked = true; + if (mnuComplete == sender) + { + // Seen All + foreach (var chk in new[] { CHK_P2, CHK_P3, CHK_P4, CHK_P5 }) + chk.Checked = true; + } + else + { + // ensure at least one SEEN + if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked)) + (gt != 254 ? CHK_P2 : CHK_P3).Checked = true; + } + // ensure at least one Displayed - if (!new[] { CHK_P6.Checked, CHK_P7.Checked, CHK_P8.Checked, CHK_P8.Checked }.Any(b=> b)) + if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) (gt != 254 ? CHK_P6 : CHK_P7).Checked = true; } - else - foreach (CheckBox t in CL) - t.Checked = false; } - - setBools(); - saveChanges(); - if (mnuComplete == sender) - { - // Forms Bool Writing - for (int i = 0; i < 0x98; i++) - sav[Main.SAV.PokeDex + 0x368 + i] = 0xFF; - - // Turn off Italian Petlil + setEntry(); + setData(); + if (mnuComplete == sender) // Turn off Italian Petlil sav[Main.SAV.PokeDexLanguageFlags + 0x1DF] &= 0xFE; - } - if (mnuDexNav == sender) - { - for (int i = 0; i < 0x2D1; i++) - BitConverter.GetBytes((ushort)999).CopyTo(sav, Main.SAV.EncounterCount + i * 2); - } - if (mnuResetNav == sender) - { - for (int i = 0; i < 0x2D1; i++) - BitConverter.GetBytes((ushort)0).CopyTo(sav, Main.SAV.EncounterCount + i * 2); - } - - getBools(); - loadchks(); + + getData(); + getEntry(); } - private void changeEncounteredCount(object sender, EventArgs e) + private void updateDisplayedForm(object sender, ItemCheckEventArgs e) { - if (!editing) - BitConverter.GetBytes((ushort)Math.Min(0xFFFF, Util.ToUInt32(MT_Count.Text))).CopyTo(sav, Main.SAV.EncounterCount + (Util.getIndex(CB_Species) - 1) * 2); + if (editing) + return; + + // Only allow one form to be displayed if the user sets a new display value + if (e.NewValue != CheckState.Checked) return; + for (int i = 0; i < CLB_FormDisplayed.Items.Count; i++) + if (i != e.Index) + CLB_FormDisplayed.SetItemChecked(i, false); + else if (sender == CLB_FormDisplayed) + CLB_FormsSeen.SetItemChecked(e.Index, true); // ensure this form is seen + } + private void B_ModifyForms_Click(object sender, EventArgs e) + { + Button btn = (Button)sender; + modifyMenuForms.Show(btn.PointToScreen(new Point(0, btn.Height))); + } + private void modifyAllForms(object sender, EventArgs e) + { + if (sender == mnuFormNone) + { + formbools = new BitArray(new bool[formbools.Length]); // reset false + getEntry(); + return; + } + + for (int i = 0; i < CB_Species.Items.Count; i++) + { + LB_Species.SelectedIndex = i; + if (CLB_FormsSeen.Items.Count == 0) + continue; + + if (sender == mnuForm1) + { + if (CLB_FormsSeen.CheckedItems.Count == 0) + CLB_FormsSeen.SetItemChecked(0, true); + + if (CLB_FormDisplayed.CheckedItems.Count == 0) + CLB_FormDisplayed.SetItemChecked(0, true); + } + else if (sender == mnuFormAll) + { + for (int f = 0; f < CLB_FormsSeen.Items.Count; f++) + CLB_FormsSeen.SetItemChecked(f, true); + if (CLB_FormDisplayed.CheckedItems.Count == 0) + CLB_FormDisplayed.SetItemChecked(0, true); + } + } } } } diff --git a/SAV/SAV_PokedexORAS.resx b/SAV/SAV_PokedexORAS.resx index 130bc12ab..40c9b0124 100644 --- a/SAV/SAV_PokedexORAS.resx +++ b/SAV/SAV_PokedexORAS.resx @@ -120,6 +120,9 @@ 17, 17 + + 172, 17 + diff --git a/SAV/SAV_PokedexXY.Designer.cs b/SAV/SAV_PokedexXY.Designer.cs index b7c0d5d7b..7658637a2 100644 --- a/SAV/SAV_PokedexXY.Designer.cs +++ b/SAV/SAV_PokedexXY.Designer.cs @@ -66,16 +66,26 @@ this.mnuCaughtNone = new System.Windows.Forms.ToolStripMenuItem(); this.mnuCaughtAll = new System.Windows.Forms.ToolStripMenuItem(); this.mnuComplete = new System.Windows.Forms.ToolStripMenuItem(); + this.B_ModifyForms = new System.Windows.Forms.Button(); + this.L_FormDisplayed = new System.Windows.Forms.Label(); + this.CLB_FormDisplayed = new System.Windows.Forms.CheckedListBox(); + this.L_FormsSeen = new System.Windows.Forms.Label(); + this.CLB_FormsSeen = new System.Windows.Forms.CheckedListBox(); + this.modifyMenuForms = new System.Windows.Forms.ContextMenuStrip(this.components); + this.mnuFormNone = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuForm1 = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuFormAll = new System.Windows.Forms.ToolStripMenuItem(); this.GB_Language.SuspendLayout(); this.GB_Encountered.SuspendLayout(); this.GB_Owned.SuspendLayout(); this.GB_Displayed.SuspendLayout(); this.modifyMenu.SuspendLayout(); + this.modifyMenuForms.SuspendLayout(); this.SuspendLayout(); // // B_Cancel // - this.B_Cancel.Location = new System.Drawing.Point(297, 242); + this.B_Cancel.Location = new System.Drawing.Point(461, 242); this.B_Cancel.Name = "B_Cancel"; this.B_Cancel.Size = new System.Drawing.Size(80, 23); this.B_Cancel.TabIndex = 0; @@ -297,7 +307,7 @@ // // B_Save // - this.B_Save.Location = new System.Drawing.Point(297, 218); + this.B_Save.Location = new System.Drawing.Point(547, 242); this.B_Save.Name = "B_Save"; this.B_Save.Size = new System.Drawing.Size(80, 23); this.B_Save.TabIndex = 24; @@ -369,7 +379,7 @@ // this.TB_Spinda.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.TB_Spinda.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.TB_Spinda.Location = new System.Drawing.Point(317, 196); + this.TB_Spinda.Location = new System.Drawing.Point(317, 195); this.TB_Spinda.Name = "TB_Spinda"; this.TB_Spinda.Size = new System.Drawing.Size(60, 20); this.TB_Spinda.TabIndex = 29; @@ -406,48 +416,132 @@ this.mnuCaughtAll, this.mnuComplete}); this.modifyMenu.Name = "modifyMenu"; - this.modifyMenu.Size = new System.Drawing.Size(153, 136); + this.modifyMenu.Size = new System.Drawing.Size(149, 114); // // mnuSeenNone // this.mnuSeenNone.Name = "mnuSeenNone"; - this.mnuSeenNone.Size = new System.Drawing.Size(152, 22); + this.mnuSeenNone.Size = new System.Drawing.Size(148, 22); this.mnuSeenNone.Text = "Seen none"; this.mnuSeenNone.Click += new System.EventHandler(this.modifyAll); // // mnuSeenAll // this.mnuSeenAll.Name = "mnuSeenAll"; - this.mnuSeenAll.Size = new System.Drawing.Size(152, 22); + this.mnuSeenAll.Size = new System.Drawing.Size(148, 22); this.mnuSeenAll.Text = "Seen all"; this.mnuSeenAll.Click += new System.EventHandler(this.modifyAll); // // mnuCaughtNone // this.mnuCaughtNone.Name = "mnuCaughtNone"; - this.mnuCaughtNone.Size = new System.Drawing.Size(152, 22); + this.mnuCaughtNone.Size = new System.Drawing.Size(148, 22); this.mnuCaughtNone.Text = "Caught none"; this.mnuCaughtNone.Click += new System.EventHandler(this.modifyAll); // // mnuCaughtAll // this.mnuCaughtAll.Name = "mnuCaughtAll"; - this.mnuCaughtAll.Size = new System.Drawing.Size(152, 22); + this.mnuCaughtAll.Size = new System.Drawing.Size(148, 22); this.mnuCaughtAll.Text = "Caught all"; this.mnuCaughtAll.Click += new System.EventHandler(this.modifyAll); // // mnuComplete // this.mnuComplete.Name = "mnuComplete"; - this.mnuComplete.Size = new System.Drawing.Size(152, 22); + this.mnuComplete.Size = new System.Drawing.Size(148, 22); this.mnuComplete.Text = "Complete Dex"; this.mnuComplete.Click += new System.EventHandler(this.modifyAll); // + // B_ModifyForms + // + this.B_ModifyForms.Location = new System.Drawing.Point(567, 11); + this.B_ModifyForms.Name = "B_ModifyForms"; + this.B_ModifyForms.Size = new System.Drawing.Size(60, 23); + this.B_ModifyForms.TabIndex = 43; + this.B_ModifyForms.Text = "Modify..."; + this.B_ModifyForms.UseVisualStyleBackColor = true; + this.B_ModifyForms.Click += new System.EventHandler(this.B_ModifyForms_Click); + // + // L_FormDisplayed + // + this.L_FormDisplayed.Location = new System.Drawing.Point(505, 40); + this.L_FormDisplayed.Name = "L_FormDisplayed"; + this.L_FormDisplayed.Size = new System.Drawing.Size(104, 20); + this.L_FormDisplayed.TabIndex = 42; + this.L_FormDisplayed.Text = "Displayed Form:"; + this.L_FormDisplayed.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // CLB_FormDisplayed + // + this.CLB_FormDisplayed.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.CLB_FormDisplayed.FormattingEnabled = true; + this.CLB_FormDisplayed.Location = new System.Drawing.Point(508, 61); + this.CLB_FormDisplayed.Name = "CLB_FormDisplayed"; + this.CLB_FormDisplayed.Size = new System.Drawing.Size(119, 154); + this.CLB_FormDisplayed.TabIndex = 41; + this.CLB_FormDisplayed.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.updateDisplayedForm); + // + // L_FormsSeen + // + this.L_FormsSeen.Location = new System.Drawing.Point(380, 40); + this.L_FormsSeen.Name = "L_FormsSeen"; + this.L_FormsSeen.Size = new System.Drawing.Size(104, 20); + this.L_FormsSeen.TabIndex = 40; + this.L_FormsSeen.Text = "Seen Forms:"; + this.L_FormsSeen.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // CLB_FormsSeen + // + this.CLB_FormsSeen.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.CLB_FormsSeen.FormattingEnabled = true; + this.CLB_FormsSeen.Location = new System.Drawing.Point(383, 61); + this.CLB_FormsSeen.Name = "CLB_FormsSeen"; + this.CLB_FormsSeen.Size = new System.Drawing.Size(119, 154); + this.CLB_FormsSeen.TabIndex = 39; + // + // modifyMenuForms + // + this.modifyMenuForms.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mnuFormNone, + this.mnuForm1, + this.mnuFormAll}); + this.modifyMenuForms.Name = "modifyMenu"; + this.modifyMenuForms.Size = new System.Drawing.Size(153, 92); + // + // mnuFormNone + // + this.mnuFormNone.Name = "mnuFormNone"; + this.mnuFormNone.Size = new System.Drawing.Size(152, 22); + this.mnuFormNone.Text = "Seen none"; + this.mnuFormNone.Click += new System.EventHandler(this.modifyAllForms); + // + // mnuForm1 + // + this.mnuForm1.Name = "mnuForm1"; + this.mnuForm1.Size = new System.Drawing.Size(152, 22); + this.mnuForm1.Text = "Seen one"; + this.mnuForm1.Click += new System.EventHandler(this.modifyAllForms); + // + // mnuFormAll + // + this.mnuFormAll.Name = "mnuFormAll"; + this.mnuFormAll.Size = new System.Drawing.Size(152, 22); + this.mnuFormAll.Text = "Seen all"; + this.mnuFormAll.Click += new System.EventHandler(this.modifyAllForms); + // // SAV_PokedexXY // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(394, 272); + this.ClientSize = new System.Drawing.Size(634, 272); + this.Controls.Add(this.B_ModifyForms); + this.Controls.Add(this.L_FormDisplayed); + this.Controls.Add(this.CLB_FormDisplayed); + this.Controls.Add(this.L_FormsSeen); + this.Controls.Add(this.CLB_FormsSeen); this.Controls.Add(this.GB_Displayed); this.Controls.Add(this.L_Spinda); this.Controls.Add(this.TB_Spinda); @@ -477,6 +571,7 @@ this.GB_Displayed.ResumeLayout(false); this.GB_Displayed.PerformLayout(); this.modifyMenu.ResumeLayout(false); + this.modifyMenuForms.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -520,5 +615,14 @@ private System.Windows.Forms.ToolStripMenuItem mnuCaughtNone; private System.Windows.Forms.ToolStripMenuItem mnuCaughtAll; private System.Windows.Forms.ToolStripMenuItem mnuComplete; + private System.Windows.Forms.CheckedListBox CLB_FormsSeen; + private System.Windows.Forms.Label L_FormsSeen; + private System.Windows.Forms.CheckedListBox CLB_FormDisplayed; + private System.Windows.Forms.Label L_FormDisplayed; + private System.Windows.Forms.Button B_ModifyForms; + private System.Windows.Forms.ContextMenuStrip modifyMenuForms; + private System.Windows.Forms.ToolStripMenuItem mnuFormNone; + private System.Windows.Forms.ToolStripMenuItem mnuForm1; + private System.Windows.Forms.ToolStripMenuItem mnuFormAll; } } \ No newline at end of file diff --git a/SAV/SAV_PokedexXY.cs b/SAV/SAV_PokedexXY.cs index 73611e2c9..806ea36e0 100644 --- a/SAV/SAV_PokedexXY.cs +++ b/SAV/SAV_PokedexXY.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Drawing; -using System.Linq; using System.Windows.Forms; namespace PKHeX @@ -30,7 +29,7 @@ namespace PKHeX for (int i = 1; i < Main.specieslist.Length; i++) LB_Species.Items.Add(i.ToString("000") + " - " + Main.specieslist[i]); - getBools(); + getData(); editing = false; LB_Species.SelectedIndex = 0; TB_Spinda.Text = BitConverter.ToUInt32(sav, Main.SAV.Spinda).ToString("X8"); @@ -42,70 +41,34 @@ namespace PKHeX private readonly bool[,] specbools = new bool[9, 0x60 * 8]; private readonly bool[,] langbools = new bool[7, 0x60 * 8]; private readonly bool[] foreignbools = new bool[0x52 * 8]; + private BitArray formbools; private bool editing; private int species = -1; + private const int FormLen = 0x18; private void changeCBSpecies(object sender, EventArgs e) { if (editing) return; - setBools(); + setEntry(); editing = true; species = (int)CB_Species.SelectedValue; LB_Species.SelectedIndex = species - 1; // Since we don't allow index0 in combobox, everything is shifted by 1 LB_Species.TopIndex = LB_Species.SelectedIndex; - loadchks(); + getEntry(); editing = false; } private void changeLBSpecies(object sender, EventArgs e) { if (editing) return; - setBools(); + setEntry(); editing = true; species = LB_Species.SelectedIndex + 1; CB_Species.SelectedValue = species; - loadchks(); + getEntry(); editing = false; } - private void loadchks() - { - // Load Bools for the data - int pk = species; - - L_Spinda.Visible = TB_Spinda.Visible = pk == 327; - - // Load Partitions - for (int i = 0; i < 9; i++) - CP[i].Checked = specbools[i, pk-1]; - for (int i = 0; i < 7; i++) - CL[i].Checked = langbools[i, pk-1]; - - if (pk < 650) { CHK_F1.Enabled = true; CHK_F1.Checked = foreignbools[pk - 1]; } - else { CHK_F1.Enabled = CHK_F1.Checked = false; } - - if (pk > 721) - { - for (int i = 0; i < 9; i++) - CP[i].Enabled = true; - - for (int i = 0; i < 7; i++) - CL[i].Checked = CL[i].Enabled = false; - } - else - { - CHK_P1.Enabled = true; - - int index = LB_Species.SelectedIndex + 1; - int gt = PKX.Personal[index].Gender; - - CHK_P2.Enabled = CHK_P4.Enabled = CHK_P6.Enabled = CHK_P8.Enabled = gt != 254; // Not Female-Only - CHK_P3.Enabled = CHK_P5.Enabled = CHK_P7.Enabled = CHK_P9.Enabled = !(gt == 0 || (gt == 255)); // Not Male-Only and Not Genderless - - for (int i = 0; i < 7; i++) - CL[i].Enabled = true; - } - } private void removedropCB(object sender, KeyEventArgs e) { ((ComboBox)sender).DroppedDown = false; @@ -142,7 +105,50 @@ namespace PKHeX } } - private void setBools() + private void getEntry() + { + // Load Bools for the data + int pk = species; + + L_Spinda.Visible = TB_Spinda.Visible = pk == 327; + + // Load Partitions + for (int i = 0; i < 9; i++) + CP[i].Checked = specbools[i, pk - 1]; + for (int i = 0; i < 7; i++) + CL[i].Checked = langbools[i, pk - 1]; + + if (pk < 650) { CHK_F1.Enabled = true; CHK_F1.Checked = foreignbools[pk - 1]; } + else { CHK_F1.Enabled = CHK_F1.Checked = false; } + + int gt = PKX.Personal[pk].Gender; + + CHK_P2.Enabled = CHK_P4.Enabled = CHK_P6.Enabled = CHK_P8.Enabled = gt != 254; // Not Female-Only + CHK_P3.Enabled = CHK_P5.Enabled = CHK_P7.Enabled = CHK_P9.Enabled = !(gt == 0 || (gt == 255)); // Not Male-Only and Not Genderless + + CLB_FormsSeen.Items.Clear(); + CLB_FormDisplayed.Items.Clear(); + + int fc = PKX.Personal[species].FormeCount; + int f = PKX.getDexFormIndexORAS(species, fc); + if (f < 0) + return; + string[] forms = PKX.getFormList(species, Main.types, Main.forms, Main.gendersymbols); + if (forms.Length < 1) + return; + + // 0x26 packs of bools + for (int i = 0; i < forms.Length; i++) // Seen + CLB_FormsSeen.Items.Add(forms[i], formbools[f + i + 0*FormLen*8]); + for (int i = 0; i < forms.Length; i++) // Seen Shiny + CLB_FormsSeen.Items.Add("* " + forms[i], formbools[f + i + 1*FormLen*8]); + + for (int i = 0; i < forms.Length; i++) // Displayed + CLB_FormDisplayed.Items.Add(forms[i], formbools[f + i + 2*FormLen*8]); + for (int i = 0; i < forms.Length; i++) // Displayed Shiny + CLB_FormDisplayed.Items.Add("* " + forms[i], formbools[f + i + 3*FormLen*8]); + } + private void setEntry() { if (species < 0) return; @@ -166,23 +172,57 @@ namespace PKHeX langbools[4, species - 1] = CHK_L5.Checked; langbools[5, species - 1] = CHK_L6.Checked; langbools[6, species - 1] = CHK_L7.Checked; + + int fc = PKX.Personal[species].FormeCount; + int f = PKX.getDexFormIndexORAS(species, fc); + if (f < 0) + return; + + for (int i = 0; i < CLB_FormsSeen.Items.Count/2; i++) // Seen + formbools[f + i + 0*FormLen*8] = CLB_FormsSeen.GetItemChecked(i); + for (int i = 0; i < CLB_FormsSeen.Items.Count/2; i++) // Seen Shiny + formbools[f + i + 1*FormLen*8] = CLB_FormsSeen.GetItemChecked(i + CLB_FormsSeen.Items.Count/2); + + editing = true; + for (int i = 0; i < CLB_FormDisplayed.Items.Count/2; i++) // Displayed + formbools[f + i + 2*FormLen*8] = CLB_FormDisplayed.GetItemChecked(i); + for (int i = 0; i < CLB_FormDisplayed.Items.Count/2; i++) // Displayed Shiny + formbools[f + i + 3*FormLen*8] = CLB_FormDisplayed.GetItemChecked(i + CLB_FormDisplayed.Items.Count/2); + editing = false; } - private void B_Cancel_Click(object sender, EventArgs e) + private void getData() { - Close(); - } - private void B_Save_Click(object sender, EventArgs e) - { - setBools(); - saveChanges(); + // Fill Bit arrays + for (int i = 0; i < 9; i++) + { + byte[] data = new byte[0x60]; + Array.Copy(sav, Main.SAV.PokeDex + 8 + 0x60 * i, data, 0, 0x60); + BitArray BitRegion = new BitArray(data); + for (int b = 0; b < 0x60 * 8; b++) + specbools[i, b] = BitRegion[b]; + } - // Return back to the parent savefile - Array.Copy(sav, Main.SAV.Data, sav.Length); - Main.SAV.Edited = true; - Close(); + // Fill Language arrays + byte[] langdata = new byte[0x280]; + Array.Copy(sav, Main.SAV.PokeDexLanguageFlags, langdata, 0, 0x280); + BitArray LangRegion = new BitArray(langdata); + for (int b = 0; b < 721; b++) // 721 Species + for (int i = 0; i < 7; i++) // 7 Languages + langbools[i, b] = LangRegion[7 * b + i]; + + // Fill Foreign array + byte[] foreigndata = new byte[0x52]; + Array.Copy(sav, Main.SAV.PokeDex + 0x64C, foreigndata, 0, 0x52); + BitArray ForeignRegion = new BitArray(foreigndata); + for (int b = 0; b < 0x52 * 8; b++) + foreignbools[b] = ForeignRegion[b]; + + byte[] formdata = new byte[FormLen*4]; + Array.Copy(sav, Main.SAV.PokeDex + 0x368, formdata, 0, formdata.Length); + formbools = new BitArray(formdata); } - private void saveChanges() + private void setData() { // Save back the Species Bools // Return to Byte Array @@ -228,34 +268,19 @@ namespace PKHeX BitConverter.GetBytes(PID).CopyTo(sav, Main.SAV.Spinda); } - private void getBools() + private void B_Cancel_Click(object sender, EventArgs e) { - // Fill Bit arrays - for (int i = 0; i < 9; i++) - { - byte[] data = new byte[0x60]; - Array.Copy(sav, Main.SAV.PokeDex + 8 + 0x60 * i, data, 0, 0x60); - BitArray BitRegion = new BitArray(data); - for (int b = 0; b < 0x60 * 8; b++) - specbools[i, b] = BitRegion[b]; - } + Close(); + } + private void B_Save_Click(object sender, EventArgs e) + { + setEntry(); + setData(); - // Fill Language arrays - byte[] langdata = new byte[0x280]; - Array.Copy(sav, Main.SAV.PokeDexLanguageFlags, langdata, 0, 0x280); - BitArray LangRegion = new BitArray(langdata); - for (int b = 0; b < 721; b++) // 721 Species - for (int i = 0; i < 7; i++) // 7 Languages - langbools[i, b] = LangRegion[7 * b + i]; - - // Fill Foreign array - { - byte[] foreigndata = new byte[0x52]; - Array.Copy(sav, Main.SAV.PokeDex + 0x64C, foreigndata, 0, 0x52); - BitArray ForeignRegion = new BitArray(foreigndata); - for (int b = 0; b < 0x52 * 8; b++) - foreignbools[b] = ForeignRegion[b]; - } + // Return back to the parent savefile + Array.Copy(sav, Main.SAV.Data, sav.Length); + Main.SAV.Edited = true; + Close(); } private void B_GiveAll_Click(object sender, EventArgs e) @@ -301,78 +326,126 @@ namespace PKHeX if (lang > 5) lang -= 1; lang -= 1; - if (new[] { mnuSeenNone, mnuSeenAll, mnuComplete }.Contains(sender)) + if (sender == mnuSeenNone || sender == mnuSeenAll || sender == mnuComplete) for (int i = 0; i < CB_Species.Items.Count; i++) { - int gt = PKX.Personal[i].Gender; - CB_Species.SelectedIndex = i; - foreach (CheckBox t in new[] {CHK_P2, CHK_P3, CHK_P4, CHK_P5}) + int gt = PKX.Personal[i + 1].Gender; + LB_Species.SelectedIndex = i; + foreach (CheckBox t in new[] { CHK_P2, CHK_P3, CHK_P4, CHK_P5 }) t.Checked = mnuSeenNone != sender && t.Enabled; if (mnuSeenNone != sender) { // if seen ensure at least one Displayed - if (!new[] {CHK_P6.Checked, CHK_P7.Checked, CHK_P8.Checked, CHK_P8.Checked}.Any(b => b)) + if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) (gt != 254 ? CHK_P6 : CHK_P7).Checked = true; } else { - for (int f = 0; f < 0x60; f++) - sav[Main.SAV.PokeDex + 0x368 + f] = 0; foreach (CheckBox t in CP) t.Checked = false; } - if (!new[] { CHK_P6.Checked, CHK_P7.Checked, CHK_P8.Checked, CHK_P8.Checked }.Any(b=> b)) + if (!CHK_P1.Checked) foreach (CheckBox t in CL) t.Checked = false; } - if (new[] { mnuCaughtNone, mnuCaughtAll, mnuComplete }.Contains(sender)) + if (sender == mnuCaughtNone || sender == mnuCaughtAll || sender == mnuComplete) for (int i = 0; i < CB_Species.Items.Count; i++) { - int gt = PKX.Personal[i].Gender; - CB_Species.SelectedIndex = i; - foreach (CheckBox t in new[] { CHK_P1, CHK_F1 }) + int gt = PKX.Personal[i + 1].Gender; + LB_Species.SelectedIndex = i; + foreach (CheckBox t in new[] { CHK_P1 }) t.Checked = mnuCaughtNone != sender; for (int j = 0; j < CL.Length; j++) CL[j].Checked = sender == mnuComplete || (mnuCaughtNone != sender && j == lang); if (mnuCaughtNone == sender) { - if (new[] { CHK_P1.Checked, CHK_F1.Checked }.Any(b=> b)) // if seen, ensure at least one displayed - if (!new[] { CHK_P6.Checked, CHK_P7.Checked, CHK_P8.Checked, CHK_P8.Checked }.Any(b=> b)) - (gt != 254 ? CHK_P6 : CHK_P7).Checked = true; + if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked)) // if seen + if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) // not displayed + (gt != 254 ? CHK_P6 : CHK_P7).Checked = true; // check one } if (mnuCaughtNone != sender) { - // ensure at least one SEEN - if (!new[] { CHK_P2.Checked, CHK_P3.Checked, CHK_P4.Checked, CHK_P5.Checked }.Any(b=> b)) - (gt != 254 ? CHK_P2 : CHK_P3).Checked = true; + if (mnuComplete == sender) + { + // Seen All + foreach (var chk in new[] { CHK_P2, CHK_P3, CHK_P4, CHK_P5 }) + chk.Checked = true; + } + else + { + // ensure at least one SEEN + if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked)) + (gt != 254 ? CHK_P2 : CHK_P3).Checked = true; + } + // ensure at least one Displayed - if (!new[] { CHK_P6.Checked, CHK_P7.Checked, CHK_P8.Checked, CHK_P8.Checked }.Any(b=> b)) + if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) (gt != 254 ? CHK_P6 : CHK_P7).Checked = true; } - else - foreach (CheckBox t in CL) - t.Checked = false; } - - setBools(); - saveChanges(); - if (mnuComplete == sender) - { - // Forms Bool Writing - for (int i = 0; i < 0x60; i++) - sav[Main.SAV.PokeDex + 0x368 + i] = 0xFF; - - // Turn off Italian Petlil + setEntry(); + setData(); + if (mnuComplete == sender) // Turn off Italian Petlil sav[Main.SAV.PokeDexLanguageFlags + 0x1DF] &= 0xFE; + + getData(); + getEntry(); + } + + private void updateDisplayedForm(object sender, ItemCheckEventArgs e) + { + if (editing) + return; + + // Only allow one form to be displayed if the user sets a new display value + if (e.NewValue != CheckState.Checked) return; + for (int i = 0; i < CLB_FormDisplayed.Items.Count; i++) + if (i != e.Index) + CLB_FormDisplayed.SetItemChecked(i, false); + else if (sender == CLB_FormDisplayed) + CLB_FormsSeen.SetItemChecked(e.Index, true); // ensure this form is seen + } + private void B_ModifyForms_Click(object sender, EventArgs e) + { + Button btn = (Button)sender; + modifyMenuForms.Show(btn.PointToScreen(new Point(0, btn.Height))); + } + private void modifyAllForms(object sender, EventArgs e) + { + if (sender == mnuFormNone) + { + formbools = new BitArray(new bool[formbools.Length]); // reset false + getEntry(); + return; } - getBools(); - loadchks(); + for (int i = 0; i < CB_Species.Items.Count; i++) + { + LB_Species.SelectedIndex = i; + if (CLB_FormsSeen.Items.Count == 0) + continue; + + if (sender == mnuForm1) + { + if (CLB_FormsSeen.CheckedItems.Count == 0) + CLB_FormsSeen.SetItemChecked(0, true); + + if (CLB_FormDisplayed.CheckedItems.Count == 0) + CLB_FormDisplayed.SetItemChecked(0, true); + } + else if (sender == mnuFormAll) + { + for (int f = 0; f < CLB_FormsSeen.Items.Count; f++) + CLB_FormsSeen.SetItemChecked(f, true); + if (CLB_FormDisplayed.CheckedItems.Count == 0) + CLB_FormDisplayed.SetItemChecked(0, true); + } + } } } } diff --git a/SAV/SAV_PokedexXY.resx b/SAV/SAV_PokedexXY.resx index 130bc12ab..40c9b0124 100644 --- a/SAV/SAV_PokedexXY.resx +++ b/SAV/SAV_PokedexXY.resx @@ -120,6 +120,9 @@ 17, 17 + + 172, 17 +