diff --git a/Misc/CodeGenerator.cs b/Misc/CodeGenerator.cs index 140c6c4fe..0c9f42804 100644 --- a/Misc/CodeGenerator.cs +++ b/Misc/CodeGenerator.cs @@ -140,7 +140,7 @@ private void B_Add_Click(object sender, EventArgs e) for (int i = 0; i < newdata.Length / 4; i++) { RTB_Code.AppendText((writeoffset + i * 4 + 0x20000000).ToString("X8") + " "); - RTB_Code.AppendText(BitConverter.ToUInt32(newdata,i*4).ToString("X8") + "\n"); + RTB_Code.AppendText(BitConverter.ToUInt32(newdata,i*4).ToString("X8") + System.Environment.NewLine); } // Mat's Code - Unfinished @@ -150,7 +150,7 @@ private void B_Add_Click(object sender, EventArgs e) // RTB_Code.AppendText("00000001 "); // 01 00 00 00 // RTB_Code.AppendText((writeoffset + i * 4).ToString("X8") + " "); - // RTB_Code.AppendText(BitConverter.ToUInt32(newdata,i*4).ToString("X8") + "\n"); + // RTB_Code.AppendText(BitConverter.ToUInt32(newdata,i*4).ToString("X8") + System.Environment.NewLine); //} } private void B_Clear_Click(object sender, EventArgs e) @@ -169,12 +169,12 @@ private void B_Load_Click(object sender, EventArgs e) if (ncf.Length != length + 4) { - MessageBox.Show("Not a valid code file.", "Error"); + Util.Error("Not a valid code file."); return; } if (RTB_Code.Text.Length > 0) { - DialogResult ld = MessageBox.Show("Replace current code?","Alert",MessageBoxButtons.YesNo); + DialogResult ld = Util.Prompt(MessageBoxButtons.YesNo, "Replace current code?"); if (ld == DialogResult.Yes) RTB_Code.Clear(); else if (ld != DialogResult.No) @@ -184,7 +184,7 @@ private void B_Load_Click(object sender, EventArgs e) { RTB_Code.AppendText(BitConverter.ToUInt32(ncf, i + 0 * 4).ToString("X8") + " "); RTB_Code.AppendText(BitConverter.ToUInt32(ncf, i + 1 * 4).ToString("X8") + " "); - RTB_Code.AppendText(BitConverter.ToUInt32(ncf, i + 2 * 4).ToString("X8") + "\n"); + RTB_Code.AppendText(BitConverter.ToUInt32(ncf, i + 2 * 4).ToString("X8") + System.Environment.NewLine); } } } @@ -225,21 +225,17 @@ private void B_Save_Click(object sender, EventArgs e) private void B_Copy_Click(object sender, EventArgs e) { if (RTB_Code.Text.Length > 0) - { Clipboard.SetText(RTB_Code.Text); - } else { B_Diff.PerformClick(); try { Clipboard.SetText(RTB_Code.Text); - MessageBox.Show("Code generated and copied to clipboard!\n\nNext time click [Create Diff] first.", "Alert"); + Util.Alert("Code generated and copied to clipboard!", "Next time click [Create Diff] first."); } catch - { - MessageBox.Show("No code created!\n\nClick [Create Diff], then make sure that data appears in the Text Box below.\nIf no code appears, then you didn't save your changes.\n\nBe sure to Set the Pokemon you edited back into a Box/Party slot!", "Alert"); - } + { Util.Alert("No code created!", "Click [Create Diff], then make sure that data appears in the Text Box below. If no code appears, then you didn't save your changes.", "Be sure to Set the Pokemon you edited back into a Box/Party slot!"); } } } private void B_Diff_Click(object sender, EventArgs e) @@ -265,11 +261,11 @@ private void B_Diff_Click(object sender, EventArgs e) if (BitConverter.ToUInt32(cybersav, i) != BitConverter.ToUInt32(newcyber, i)) { result += ((0x20000000 + i).ToString("X8") + " "); - result += (BitConverter.ToUInt32(newcyber, i).ToString("X8") + "\n"); + result += (BitConverter.ToUInt32(newcyber, i).ToString("X8") + System.Environment.NewLine); lines++; if ((lines % 128 == 0) && CHK_Break.Checked) - { result += ("\r\n--- Segment " + (lines / 128 + 1).ToString() + " ---\r\n\r\n"); } + { result += ("\n--- Segment " + (lines / 128 + 1).ToString() + " ---" + System.Environment.NewLine + System.Environment.NewLine); } if (lines > 10000) goto toomany; } } @@ -284,11 +280,11 @@ private void B_Diff_Click(object sender, EventArgs e) for (int z = 0; z < newdata.Length; z += 4) { result += ((0x20000000 + i + z).ToString("X8") + " "); - result += (BitConverter.ToUInt32(newdata, z).ToString("X8") + "\n"); + result += (BitConverter.ToUInt32(newdata, z).ToString("X8") + System.Environment.NewLine); lines++; if ((lines % 128 == 0) && CHK_Break.Checked) - { result += ("\r\n--- Segment " + (lines / 128 + 1).ToString() + " ---\r\n\r\n"); } + { result += ("\n--- Segment " + (lines / 128 + 1).ToString() + " ---" + System.Environment.NewLine + System.Environment.NewLine); } if (lines > 10000) goto toomany; } } @@ -298,11 +294,11 @@ private void B_Diff_Click(object sender, EventArgs e) if (cybersav[0x14818] != newcyber[0x14818]) { result += ((0x00000000 + 0x14818).ToString("X8") + " "); - result += (newcyber[0x14818].ToString("X8") + "\n"); + result += (newcyber[0x14818].ToString("X8") + System.Environment.NewLine); lines++; if ((lines % 128 == 0) && CHK_Break.Checked) - { result += ("\r\n--- Segment " + (lines / 128 + 1).ToString() + " ---\r\n\r\n"); } + { result += (System.Environment.NewLine + "--- Segment " + (lines / 128 + 1).ToString() + " ---" + System.Environment.NewLine + System.Environment.NewLine); } if (lines > 10000) goto toomany; } @@ -316,11 +312,11 @@ private void B_Diff_Click(object sender, EventArgs e) for (int z = 0; z < newdata.Length; z += 4) { result += ((0x20000000 + i + z).ToString("X8") + " "); - result += (BitConverter.ToUInt32(newdata, z).ToString("X8") + "\n"); + result += (BitConverter.ToUInt32(newdata, z).ToString("X8") + System.Environment.NewLine); lines++; if ((lines % 128 == 0) && CHK_Break.Checked) - { result += ("\r\n--- Segment " + (lines / 128 + 1).ToString() + " ---\r\n\r\n"); } + { result += (System.Environment.NewLine + "--- Segment " + (lines / 128 + 1).ToString() + " ---" + System.Environment.NewLine + System.Environment.NewLine); } if (lines > 10000) goto toomany; } } @@ -328,13 +324,13 @@ private void B_Diff_Click(object sender, EventArgs e) if ((lines / 128 > 0) && CHK_Break.Checked) { - MessageBox.Show((1 + (lines / 128)).ToString() + " Code Segments\n\nLines: " + lines.ToString(), "Alert"); + Util.Alert(String.Format("{0} Code Segments.", (1 + (lines / 128)).ToString()), String.Format("{0} Lines.", lines.ToString())); } RTB_Code.Text = result; return; toomany: { - MessageBox.Show("Too many differences. Export your save instead.", "Alert"); + Util.Alert("Too many differences detected.", "Export your save instead."); } } @@ -355,9 +351,7 @@ private void B_Import_Click(object sender, EventArgs e) if (RTB_Code.Lines[i].Length > 0) { if (RTB_Code.Lines[i].Length <= 2 * 8 && RTB_Code.Lines[i].Length > 2 * 8 + 2) - { - MessageBox.Show("Invalid code pasted (Type)", "Error"); return; - } + { Util.Error("Invalid code pasted (Type)"); return; } else { try @@ -368,10 +362,8 @@ private void B_Import_Click(object sender, EventArgs e) Array.Resize(ref data, data.Length + 4); Array.Copy(BitConverter.GetBytes(UInt32.Parse(rip[1], NumberStyles.HexNumber)), 0, data, data.Length - 4, 4); } - catch - { - MessageBox.Show("Invalid code pasted (Content)", "Error"); return; - } + catch (Exception x) + { Util.Error("Invalid code pasted (Content):", x.ToString()); return; } } } } @@ -389,7 +381,7 @@ private void B_Import_Click(object sender, EventArgs e) } else { - MessageBox.Show("Invalid code pasted (Length)", "Error"); return; + Util.Error("Invalid code pasted (Length)"); return; } } } diff --git a/Misc/PKX.cs b/Misc/PKX.cs index c32d1e8d5..e2e8d5da7 100644 --- a/Misc/PKX.cs +++ b/Misc/PKX.cs @@ -11,6 +11,10 @@ namespace PKHeX { public partial class PKX { + // C# PKX Function Library + // No WinForm object related code, only to calculate information. + // Relies on Util for some common operations. + // Data public static uint LCRNG(uint seed) { @@ -2235,43 +2239,6 @@ public static DataTable ExpTable() table.Rows.Add(100, 600000, 800000, 1000000, 1059860, 1250000, 1640000); return table; } - public static DataTable NatureTable() - { - DataTable table = new DataTable(); - table.Columns.Add("Nature", typeof(int)); - table.Columns.Add("A", typeof(int)); - table.Columns.Add("D", typeof(int)); - table.Columns.Add("Spe", typeof(int)); - table.Columns.Add("SpA", typeof(int)); - table.Columns.Add("SpD", typeof(int)); - - table.Rows.Add(0, 10, 10, 10, 10, 10); - table.Rows.Add(1, 11, 9, 10, 10, 10); - table.Rows.Add(2, 11, 10, 9, 10, 10); - table.Rows.Add(3, 11, 10, 10, 9, 10); - table.Rows.Add(4, 11, 10, 10, 10, 9); - table.Rows.Add(5, 9, 11, 10, 10, 10); - table.Rows.Add(6, 10, 10, 10, 10, 10); - table.Rows.Add(7, 10, 11, 9, 10, 10); - table.Rows.Add(8, 10, 11, 10, 9, 10); - table.Rows.Add(9, 10, 11, 10, 10, 9); - table.Rows.Add(10, 9, 10, 11, 10, 10); - table.Rows.Add(11, 10, 9, 11, 10, 10); - table.Rows.Add(12, 10, 10, 10, 10, 10); - table.Rows.Add(13, 10, 10, 11, 9, 10); - table.Rows.Add(14, 10, 10, 11, 10, 9); - table.Rows.Add(15, 9, 10, 10, 11, 10); - table.Rows.Add(16, 10, 9, 10, 11, 10); - table.Rows.Add(17, 10, 10, 9, 11, 10); - table.Rows.Add(18, 10, 10, 10, 10, 10); - table.Rows.Add(19, 10, 10, 10, 11, 9); - table.Rows.Add(20, 9, 10, 10, 10, 11); - table.Rows.Add(21, 10, 9, 10, 10, 11); - table.Rows.Add(22, 10, 10, 9, 10, 11); - table.Rows.Add(23, 10, 10, 10, 9, 11); - table.Rows.Add(24, 10, 10, 10, 10, 10); - return table; - } // Stat Fetching public static int getMovePP(int move, int ppup) @@ -2284,6 +2251,20 @@ public static int getBasePP(int move) DataTable movepptable = MovePPTable(); return (int)movepptable.Rows[move][1]; } + public static byte[] getRandomEVs() + { + byte[] evs = new Byte[6]; + start: + evs[0] = (byte)Math.Min(Util.rnd32() % 300, 252); // bias two to get maybe 252 + evs[1] = (byte)Math.Min(Util.rnd32() % 300, 252); + evs[2] = (byte)Math.Min(((Util.rnd32()) % (510 - evs[0] - evs[1])), 252); + evs[3] = (byte)Math.Min(((Util.rnd32()) % (510 - evs[0] - evs[1] - evs[2])), 252); + evs[4] = (byte)Math.Min(((Util.rnd32()) % (510 - evs[0] - evs[1] - evs[2] - evs[3])), 252); + evs[5] = (byte)Math.Min((510 - evs[0] - evs[1] - evs[2] - evs[3] - evs[4]), 252); + Util.Shuffle(evs); + if (evs.Sum(b => (ushort)b) > 510) goto start; // try again! + return evs; + } public static byte getBaseFriendship(int species) { return ((byte)PKX.Friendship().Rows[species][1]); @@ -2330,6 +2311,81 @@ public static uint getEXP(int level, int species) uint exp = (uint)PKX.ExpTable().Rows[level][growth+1]; return exp; } + public static int[] getAbilities(int species, int formnum) + { + if (formnum > 0) // For species with form-specific abilities. + { + // Previous Games + if (species == 492 && formnum == 1) { species = 727; } // Shaymin Sky + else if (species == 487 && formnum == 1) { species = 728; } // Giratina-O + else if (species == 550 && formnum == 1) { species = 738; } // Basculin Blue + else if (species == 646 && formnum == 1) { species = 741; } // Kyurem White + else if (species == 646 && formnum == 2) { species = 742; } // Kyurem Black + else if (species == 641 && formnum == 1) { species = 744; } // Tornadus-T + else if (species == 642 && formnum == 1) { species = 745; } // Thundurus-T + else if (species == 645 && formnum == 1) { species = 746; } // Landorus-T + + // XY + else if (species == 678 && formnum == 1) { species = 748; } // Meowstic Female + else if (species == 094 && formnum == 1) { species = 747; } // Mega Gengar + else if (species == 282 && formnum == 1) { species = 758; } // Mega Gardevoir + else if (species == 181 && formnum == 1) { species = 759; } // Mega Ampharos + else if (species == 003 && formnum == 1) { species = 760; } // Mega Venusaur + else if (species == 006 && formnum == 1) { species = 761; } // Mega Charizard X + else if (species == 006 && formnum == 2) { species = 762; } // Mega Charizard Y + else if (species == 150 && formnum == 1) { species = 763; } // Mega MewtwoX + else if (species == 150 && formnum == 2) { species = 764; } // Mega MewtwoY + else if (species == 257 && formnum == 1) { species = 765; } // Mega Blaziken + else if (species == 308 && formnum == 1) { species = 766; } // Mega Medicham + else if (species == 229 && formnum == 1) { species = 767; } // Mega Houndoom + else if (species == 306 && formnum == 1) { species = 768; } // Mega Aggron + else if (species == 354 && formnum == 1) { species = 769; } // Mega Banette + else if (species == 248 && formnum == 1) { species = 770; } // Mega Tyranitar + else if (species == 212 && formnum == 1) { species = 771; } // Mega Scizor + else if (species == 127 && formnum == 1) { species = 772; } // Mega Pinsir + else if (species == 142 && formnum == 1) { species = 773; } // Mega Aerodactyl + else if (species == 448 && formnum == 1) { species = 774; } // Mega Lucario + else if (species == 460 && formnum == 1) { species = 775; } // Mega Abomasnow + else if (species == 009 && formnum == 1) { species = 777; } // Mega Blastoise + else if (species == 115 && formnum == 1) { species = 778; } // Mega Kangaskhan + else if (species == 130 && formnum == 1) { species = 779; } // Mega Gyarados + else if (species == 359 && formnum == 1) { species = 780; } // Mega Absol + else if (species == 065 && formnum == 1) { species = 781; } // Mega Alakazam + else if (species == 214 && formnum == 1) { species = 782; } // Mega Heracross + else if (species == 303 && formnum == 1) { species = 783; } // Mega Mawile + else if (species == 310 && formnum == 1) { species = 784; } // Mega Manectric + else if (species == 445 && formnum == 1) { species = 785; } // Mega Garchomp + else if (species == 381 && formnum == 1) { species = 786; } // Mega Latios + else if (species == 380 && formnum == 1) { species = 787; } // Mega Latias + + // ORAS + else if (species == 382 && formnum == 1) { species = 812; } // Primal Kyogre + else if (species == 383 && formnum == 1) { species = 813; } // Primal Groudon + else if (species == 720 && formnum == 1) { species = 821; } // Hoopa Unbound + else if (species == 015 && formnum == 1) { species = 825; } // Mega Beedrill + else if (species == 018 && formnum == 1) { species = 808; } // Mega Pidgeot + else if (species == 080 && formnum == 1) { species = 806; } // Mega Slowbro + else if (species == 208 && formnum == 1) { species = 807; } // Mega Steelix + else if (species == 254 && formnum == 1) { species = 800; } // Mega Sceptile + else if (species == 260 && formnum == 1) { species = 799; } // Mega Swampert + else if (species == 302 && formnum == 1) { species = 801; } // Mega Sableye + else if (species == 319 && formnum == 1) { species = 805; } // Mega Sharpedo + else if (species == 323 && formnum == 1) { species = 822; } // Mega Camerupt + else if (species == 334 && formnum == 1) { species = 802; } // Mega Altaria + else if (species == 362 && formnum == 1) { species = 809; } // Mega Glalie + else if (species == 373 && formnum == 1) { species = 824; } // Mega Salamence + else if (species == 376 && formnum == 1) { species = 811; } // Mega Metagross + else if (species == 384 && formnum == 1) { species = 814; } // Mega Rayquaza + else if (species == 428 && formnum == 1) { species = 823; } // Mega Lopunny + else if (species == 475 && formnum == 1) { species = 803; } // Mega Gallade + else if (species == 531 && formnum == 1) { species = 804; } // Mega Audino + else if (species == 719 && formnum == 1) { species = 810; } // Mega Diancie + } + + int[] abils = { 0, 0, 0 }; + Array.Copy(speciesability, species * 4 + 1, abils, 0, 3); + return abils; + } public static int getGender(string s) { if (s == "♂" || s == "M") @@ -2338,6 +2394,121 @@ public static int getGender(string s) return 1; else return 2; } + public static ushort[] getStats(int species, int level, int nature, int form, + int HP_EV, int ATK_EV, int DEF_EV, int SPA_EV, int SPD_EV, int SPE_EV, + int HP_IV, int ATK_IV, int DEF_IV, int SPA_IV, int SPD_IV, int SPE_IV) + { + DataTable spectable = SpeciesTable(); + int HP_B = (int)spectable.Rows[species][2]; + int ATK_B = (int)spectable.Rows[species][3]; + int DEF_B = (int)spectable.Rows[species][4]; + int SPA_B = (int)spectable.Rows[species][5]; + int SPD_B = (int)spectable.Rows[species][6]; + int SPE_B = (int)spectable.Rows[species][7]; + + // Form Stat Recalculation + if (form != 0) + { + if ((form == 1) && (species == 3)) { HP_B = 80; ATK_B = 100; DEF_B = 123; SPA_B = 122; SPD_B = 120; SPE_B = 80; } + else if ((form == 1) && (species == 6)) { HP_B = 78; ATK_B = 130; DEF_B = 111; SPA_B = 130; SPD_B = 85; SPE_B = 100; } + else if ((form == 2) && (species == 6)) { HP_B = 78; ATK_B = 104; DEF_B = 78; SPA_B = 159; SPD_B = 115; SPE_B = 100; } + else if ((form == 1) && (species == 9)) { HP_B = 79; ATK_B = 103; DEF_B = 120; SPA_B = 135; SPD_B = 115; SPE_B = 78; } + else if ((form == 1) && (species == 65)) { HP_B = 55; ATK_B = 50; DEF_B = 65; SPA_B = 175; SPD_B = 95; SPE_B = 150; } + else if ((form == 1) && (species == 94)) { HP_B = 60; ATK_B = 65; DEF_B = 80; SPA_B = 170; SPD_B = 95; SPE_B = 130; } + else if ((form == 1) && (species == 115)) { HP_B = 105; ATK_B = 125; DEF_B = 100; SPA_B = 60; SPD_B = 100; SPE_B = 100; } + else if ((form == 1) && (species == 127)) { HP_B = 65; ATK_B = 155; DEF_B = 120; SPA_B = 65; SPD_B = 90; SPE_B = 105; } + else if ((form == 1) && (species == 130)) { HP_B = 95; ATK_B = 155; DEF_B = 109; SPA_B = 70; SPD_B = 130; SPE_B = 81; } + else if ((form == 1) && (species == 142)) { HP_B = 80; ATK_B = 135; DEF_B = 85; SPA_B = 70; SPD_B = 95; SPE_B = 150; } + else if ((form == 1) && (species == 150)) { HP_B = 106; ATK_B = 190; DEF_B = 100; SPA_B = 154; SPD_B = 100; SPE_B = 130; } + else if ((form == 2) && (species == 150)) { HP_B = 106; ATK_B = 150; DEF_B = 70; SPA_B = 194; SPD_B = 120; SPE_B = 140; } + else if ((form == 1) && (species == 181)) { HP_B = 90; ATK_B = 95; DEF_B = 105; SPA_B = 165; SPD_B = 110; SPE_B = 45; } + else if ((form == 1) && (species == 212)) { HP_B = 70; ATK_B = 150; DEF_B = 140; SPA_B = 65; SPD_B = 100; SPE_B = 75; } + else if ((form == 1) && (species == 214)) { HP_B = 80; ATK_B = 185; DEF_B = 115; SPA_B = 40; SPD_B = 105; SPE_B = 75; } + else if ((form == 1) && (species == 229)) { HP_B = 75; ATK_B = 90; DEF_B = 90; SPA_B = 140; SPD_B = 90; SPE_B = 115; } + else if ((form == 1) && (species == 248)) { HP_B = 100; ATK_B = 164; DEF_B = 150; SPA_B = 95; SPD_B = 120; SPE_B = 71; } + else if ((form == 1) && (species == 257)) { HP_B = 80; ATK_B = 160; DEF_B = 80; SPA_B = 130; SPD_B = 80; SPE_B = 100; } + else if ((form == 1) && (species == 282)) { HP_B = 68; ATK_B = 85; DEF_B = 65; SPA_B = 165; SPD_B = 135; SPE_B = 100; } + else if ((form == 1) && (species == 303)) { HP_B = 50; ATK_B = 105; DEF_B = 125; SPA_B = 55; SPD_B = 95; SPE_B = 50; } + else if ((form == 1) && (species == 306)) { HP_B = 70; ATK_B = 140; DEF_B = 230; SPA_B = 60; SPD_B = 80; SPE_B = 50; } + else if ((form == 1) && (species == 308)) { HP_B = 60; ATK_B = 100; DEF_B = 85; SPA_B = 80; SPD_B = 85; SPE_B = 100; } + else if ((form == 1) && (species == 310)) { HP_B = 70; ATK_B = 75; DEF_B = 80; SPA_B = 135; SPD_B = 80; SPE_B = 135; } + else if ((form == 1) && (species == 354)) { HP_B = 64; ATK_B = 165; DEF_B = 75; SPA_B = 93; SPD_B = 83; SPE_B = 75; } + else if ((form == 1) && (species == 359)) { HP_B = 65; ATK_B = 150; DEF_B = 60; SPA_B = 115; SPD_B = 60; SPE_B = 115; } + else if ((form == 1) && (species == 380)) { HP_B = 80; ATK_B = 100; DEF_B = 120; SPA_B = 140; SPD_B = 150; SPE_B = 110; } + else if ((form == 1) && (species == 381)) { HP_B = 80; ATK_B = 130; DEF_B = 100; SPA_B = 160; SPD_B = 120; SPE_B = 110; } + else if ((form == 1) && (species == 386)) { HP_B = 50; ATK_B = 180; DEF_B = 20; SPA_B = 180; SPD_B = 20; SPE_B = 150; } + else if ((form == 2) && (species == 386)) { HP_B = 50; ATK_B = 70; DEF_B = 160; SPA_B = 70; SPD_B = 160; SPE_B = 90; } + else if ((form == 3) && (species == 386)) { HP_B = 50; ATK_B = 95; DEF_B = 90; SPA_B = 95; SPD_B = 90; SPE_B = 180; } + else if ((form == 1) && (species == 413)) { HP_B = 60; ATK_B = 79; DEF_B = 105; SPA_B = 59; SPD_B = 85; SPE_B = 36; } + else if ((form == 2) && (species == 413)) { HP_B = 60; ATK_B = 69; DEF_B = 95; SPA_B = 69; SPD_B = 95; SPE_B = 36; } + else if ((form == 1) && (species == 445)) { HP_B = 108; ATK_B = 170; DEF_B = 115; SPA_B = 120; SPD_B = 95; SPE_B = 92; } + else if ((form == 1) && (species == 448)) { HP_B = 70; ATK_B = 145; DEF_B = 88; SPA_B = 140; SPD_B = 70; SPE_B = 112; } + else if ((form == 1) && (species == 460)) { HP_B = 90; ATK_B = 132; DEF_B = 105; SPA_B = 132; SPD_B = 105; SPE_B = 30; } + else if ((form == 1) && (species == 487)) { HP_B = 150; ATK_B = 120; DEF_B = 100; SPA_B = 120; SPD_B = 100; SPE_B = 90; } + else if ((form == 1) && (species == 492)) { HP_B = 100; ATK_B = 103; DEF_B = 75; SPA_B = 120; SPD_B = 75; SPE_B = 127; } + else if ((form == 1) && (species == 555)) { HP_B = 105; ATK_B = 30; DEF_B = 105; SPA_B = 140; SPD_B = 105; SPE_B = 55; } + else if ((form == 1) && (species == 641)) { HP_B = 79; ATK_B = 100; DEF_B = 80; SPA_B = 110; SPD_B = 90; SPE_B = 121; } + else if ((form == 1) && (species == 642)) { HP_B = 79; ATK_B = 105; DEF_B = 70; SPA_B = 145; SPD_B = 80; SPE_B = 101; } + else if ((form == 1) && (species == 645)) { HP_B = 89; ATK_B = 145; DEF_B = 90; SPA_B = 105; SPD_B = 80; SPE_B = 91; } + else if ((form == 1) && (species == 646)) { HP_B = 125; ATK_B = 120; DEF_B = 90; SPA_B = 170; SPD_B = 100; SPE_B = 95; } // white + else if ((form == 2) && (species == 646)) { HP_B = 125; ATK_B = 170; DEF_B = 100; SPA_B = 120; SPD_B = 90; SPE_B = 95; } // black + else if ((form == 1) && (species == 648)) { HP_B = 100; ATK_B = 128; DEF_B = 90; SPA_B = 77; SPD_B = 77; SPE_B = 128; } + else if ((form == 5) && (species == 670)) { HP_B = 74; ATK_B = 65; DEF_B = 67; SPA_B = 125; SPD_B = 128; SPE_B = 92; } + else if ((form == 1) && (species == 681)) { HP_B = 60; ATK_B = 150; DEF_B = 50; SPA_B = 150; SPD_B = 50; SPE_B = 60; } + else if ((form == 1) && (species == 710)) { HP_B = 49; ATK_B = 66; DEF_B = 70; SPA_B = 44; SPD_B = 55; SPE_B = 51; } + else if ((form == 2) && (species == 710)) { HP_B = 54; ATK_B = 66; DEF_B = 70; SPA_B = 44; SPD_B = 55; SPE_B = 46; } + else if ((form == 3) && (species == 710)) { HP_B = 59; ATK_B = 66; DEF_B = 70; SPA_B = 44; SPD_B = 55; SPE_B = 41; } + else if ((form == 1) && (species == 711)) { HP_B = 65; ATK_B = 90; DEF_B = 122; SPA_B = 58; SPD_B = 75; SPE_B = 84; } + else if ((form == 2) && (species == 711)) { HP_B = 75; ATK_B = 95; DEF_B = 122; SPA_B = 58; SPD_B = 75; SPE_B = 69; } + else if ((form == 3) && (species == 711)) { HP_B = 85; ATK_B = 100; DEF_B = 122; SPA_B = 58; SPD_B = 75; SPE_B = 54; } + + // ORAS Stats + else if ((form == 1) && (species == 382)) { HP_B = 100; ATK_B = 150; DEF_B = 90; SPA_B = 180; SPD_B = 160; SPE_B = 90; } // Primal Kyogre + else if ((form == 1) && (species == 383)) { HP_B = 100; ATK_B = 180; DEF_B = 160; SPA_B = 150; SPD_B = 90; SPE_B = 90; } // Primal + + else if ((form == 1) && (species == 015)) { HP_B = 65; ATK_B = 150; DEF_B = 40; SPA_B = 15; SPD_B = 80; SPE_B = 145; } // Beedrill + else if ((form == 1) && (species == 018)) { HP_B = 83; ATK_B = 80; DEF_B = 83; SPA_B = 135; SPD_B = 80; SPE_B = 121; } // Pidgeot + else if ((form == 1) && (species == 080)) { HP_B = 95; ATK_B = 75; DEF_B = 180; SPA_B = 130; SPD_B = 80; SPE_B = 30; } // Slowbro + else if ((form == 1) && (species == 208)) { HP_B = 75; ATK_B = 125; DEF_B = 230; SPA_B = 55; SPD_B = 95; SPE_B = 30; } // Steelix + else if ((form == 1) && (species == 254)) { HP_B = 70; ATK_B = 110; DEF_B = 75; SPA_B = 145; SPD_B = 85; SPE_B = 145; } // Sceptile + else if ((form == 1) && (species == 260)) { HP_B = 100; ATK_B = 150; DEF_B = 110; SPA_B = 95; SPD_B = 110; SPE_B = 70; } // Swampert + else if ((form == 1) && (species == 302)) { HP_B = 50; ATK_B = 85; DEF_B = 125; SPA_B = 85; SPD_B = 115; SPE_B = 20; } // Sableye + else if ((form == 1) && (species == 319)) { HP_B = 70; ATK_B = 140; DEF_B = 70; SPA_B = 110; SPD_B = 65; SPE_B = 105; } // Sharpedo + else if ((form == 1) && (species == 323)) { HP_B = 70; ATK_B = 120; DEF_B = 100; SPA_B = 145; SPD_B = 105; SPE_B = 20; } // Camerupt + else if ((form == 1) && (species == 334)) { HP_B = 75; ATK_B = 110; DEF_B = 110; SPA_B = 110; SPD_B = 105; SPE_B = 80; } // Altaria + else if ((form == 1) && (species == 362)) { HP_B = 80; ATK_B = 120; DEF_B = 80; SPA_B = 120; SPD_B = 80; SPE_B = 100; } // Glalie + else if ((form == 1) && (species == 373)) { HP_B = 95; ATK_B = 145; DEF_B = 130; SPA_B = 120; SPD_B = 90; SPE_B = 120; } // Salamence + else if ((form == 1) && (species == 376)) { HP_B = 80; ATK_B = 145; DEF_B = 150; SPA_B = 105; SPD_B = 110; SPE_B = 110; } // Metagross + else if ((form == 1) && (species == 384)) { HP_B = 105; ATK_B = 180; DEF_B = 100; SPA_B = 180; SPD_B = 100; SPE_B = 115; } // Rayquaza + else if ((form == 1) && (species == 428)) { HP_B = 65; ATK_B = 136; DEF_B = 94; SPA_B = 54; SPD_B = 96; SPE_B = 135; } // Lopunny + else if ((form == 1) && (species == 475)) { HP_B = 68; ATK_B = 165; DEF_B = 95; SPA_B = 65; SPD_B = 115; SPE_B = 110; } // Gallade + else if ((form == 1) && (species == 531)) { HP_B = 103; ATK_B = 60; DEF_B = 126; SPA_B = 80; SPD_B = 126; SPE_B = 50; } // Audino + else if ((form == 1) && (species == 719)) { HP_B = 50; ATK_B = 160; DEF_B = 110; SPA_B = 160; SPD_B = 110; SPE_B = 110; } // Diancie + + else if ((form == 1) && (species == 720)) { HP_B = 80; ATK_B = 160; DEF_B = 60; SPA_B = 170; SPD_B = 130; SPE_B = 80; } // Hoopa Unbound + } + + // Calculate Stats + ushort[] stats = new ushort[6]; // Stats are stored as ushorts in the PKX structure. We'll cap them as such. + stats[0] = (ushort)((((HP_IV + (2 * HP_B) + (HP_EV / 4) + 100) * level) / 100) + 10); + stats[1] = (ushort)((((ATK_IV + (2 * ATK_B) + (ATK_EV / 4)) * level) / 100) + 5); + stats[2] = (ushort)((((DEF_IV + (2 * DEF_B) + (DEF_EV / 4)) * level) / 100) + 5); + stats[4] = (ushort)((((SPA_IV + (2 * SPA_B) + (SPA_EV / 4)) * level) / 100) + 5); + stats[5] = (ushort)((((SPD_IV + (2 * SPD_B) + (SPD_EV / 4)) * level) / 100) + 5); + stats[3] = (ushort)((((SPE_IV + (2 * SPE_B) + (SPE_EV / 4)) * level) / 100) + 5); + + // Account for nature + int incr = nature / 5 + 1; + int decr = nature % 5 + 1; + if (incr != decr) + { + stats[incr] *= 11; stats[incr] /= 10; + stats[decr] *= 9; stats[decr] /= 10; + } + + // Return Result + return stats; + } // Manipulation public static byte[] shuffleArray(byte[] pkx, uint sv) @@ -2506,7 +2677,7 @@ public static uint getRandomPID(int species, int cg) } // Object - #region Define + #region PKX Object private Image pksprite; private uint mEC, mPID, mIV32, @@ -2542,7 +2713,6 @@ private ushort mball, mencountertype, mgamevers, mcountryID, mregionID, mdsregID, motlang; - #endregion public Image pkimg { get { return pksprite; } } public string Nickname { get { return mnicknamestr; } } public string Species { get { return mSpeciesName; } } @@ -2788,6 +2958,7 @@ public PKX(byte[] pkx) } catch { return; } } + #endregion // Save File Related internal static int detectSAVIndex(byte[] data, ref int savindex) @@ -2841,5 +3012,838 @@ internal static ushort ccitt16(byte[] data) } return crc; } + + // Table Related + #region Species/Form Ability Table: ORAS Personal Data + internal static int[] speciesability = new int[] + { + 000, 000, 000, 000, + 001, 065, 065, 034, + 002, 065, 065, 034, + 003, 065, 065, 034, + 004, 066, 066, 094, + 005, 066, 066, 094, + 006, 066, 066, 094, + 007, 067, 067, 044, + 008, 067, 067, 044, + 009, 067, 067, 044, + 010, 019, 019, 050, + 011, 061, 061, 061, + 012, 014, 014, 110, + 013, 019, 019, 050, + 014, 061, 061, 061, + 015, 068, 068, 097, + 016, 051, 077, 145, + 017, 051, 077, 145, + 018, 051, 077, 145, + 019, 050, 062, 055, + 020, 050, 062, 055, + 021, 051, 051, 097, + 022, 051, 051, 097, + 023, 022, 061, 127, + 024, 022, 061, 127, + 025, 009, 009, 031, + 026, 009, 009, 031, + 027, 008, 008, 146, + 028, 008, 008, 146, + 029, 038, 079, 055, + 030, 038, 079, 055, + 031, 038, 079, 125, + 032, 038, 079, 055, + 033, 038, 079, 055, + 034, 038, 079, 125, + 035, 056, 098, 132, + 036, 056, 098, 109, + 037, 018, 018, 070, + 038, 018, 018, 070, + 039, 056, 172, 132, + 040, 056, 172, 119, + 041, 039, 039, 151, + 042, 039, 039, 151, + 043, 034, 034, 050, + 044, 034, 034, 001, + 045, 034, 034, 027, + 046, 027, 087, 006, + 047, 027, 087, 006, + 048, 014, 110, 050, + 049, 019, 110, 147, + 050, 008, 071, 159, + 051, 008, 071, 159, + 052, 053, 101, 127, + 053, 007, 101, 127, + 054, 006, 013, 033, + 055, 006, 013, 033, + 056, 072, 083, 128, + 057, 072, 083, 128, + 058, 022, 018, 154, + 059, 022, 018, 154, + 060, 011, 006, 033, + 061, 011, 006, 033, + 062, 011, 006, 033, + 063, 028, 039, 098, + 064, 028, 039, 098, + 065, 028, 039, 098, + 066, 062, 099, 080, + 067, 062, 099, 080, + 068, 062, 099, 080, + 069, 034, 034, 082, + 070, 034, 034, 082, + 071, 034, 034, 082, + 072, 029, 064, 044, + 073, 029, 064, 044, + 074, 069, 005, 008, + 075, 069, 005, 008, + 076, 069, 005, 008, + 077, 050, 018, 049, + 078, 050, 018, 049, + 079, 012, 020, 144, + 080, 012, 020, 144, + 081, 042, 005, 148, + 082, 042, 005, 148, + 083, 051, 039, 128, + 084, 050, 048, 077, + 085, 050, 048, 077, + 086, 047, 093, 115, + 087, 047, 093, 115, + 088, 001, 060, 143, + 089, 001, 060, 143, + 090, 075, 092, 142, + 091, 075, 092, 142, + 092, 026, 026, 026, + 093, 026, 026, 026, + 094, 026, 026, 026, + 095, 069, 005, 133, + 096, 015, 108, 039, + 097, 015, 108, 039, + 098, 052, 075, 125, + 099, 052, 075, 125, + 100, 043, 009, 106, + 101, 043, 009, 106, + 102, 034, 034, 139, + 103, 034, 034, 139, + 104, 069, 031, 004, + 105, 069, 031, 004, + 106, 007, 120, 084, + 107, 051, 089, 039, + 108, 020, 012, 013, + 109, 026, 026, 026, + 110, 026, 026, 026, + 111, 031, 069, 120, + 112, 031, 069, 120, + 113, 030, 032, 131, + 114, 034, 102, 144, + 115, 048, 113, 039, + 116, 033, 097, 006, + 117, 038, 097, 006, + 118, 033, 041, 031, + 119, 033, 041, 031, + 120, 035, 030, 148, + 121, 035, 030, 148, + 122, 043, 111, 101, + 123, 068, 101, 080, + 124, 012, 108, 087, + 125, 009, 009, 072, + 126, 049, 049, 072, + 127, 052, 104, 153, + 128, 022, 083, 125, + 129, 033, 033, 155, + 130, 022, 022, 153, + 131, 011, 075, 093, + 132, 007, 007, 150, + 133, 050, 091, 107, + 134, 011, 011, 093, + 135, 010, 010, 095, + 136, 018, 018, 062, + 137, 036, 088, 148, + 138, 033, 075, 133, + 139, 033, 075, 133, + 140, 033, 004, 133, + 141, 033, 004, 133, + 142, 069, 046, 127, + 143, 017, 047, 082, + 144, 046, 046, 081, + 145, 046, 046, 009, + 146, 046, 046, 049, + 147, 061, 061, 063, + 148, 061, 061, 063, + 149, 039, 039, 136, + 150, 046, 046, 127, + 151, 028, 028, 028, + 152, 065, 065, 102, + 153, 065, 065, 102, + 154, 065, 065, 102, + 155, 066, 066, 018, + 156, 066, 066, 018, + 157, 066, 066, 018, + 158, 067, 067, 125, + 159, 067, 067, 125, + 160, 067, 067, 125, + 161, 050, 051, 119, + 162, 050, 051, 119, + 163, 015, 051, 110, + 164, 015, 051, 110, + 165, 068, 048, 155, + 166, 068, 048, 089, + 167, 068, 015, 097, + 168, 068, 015, 097, + 169, 039, 039, 151, + 170, 010, 035, 011, + 171, 010, 035, 011, + 172, 009, 009, 031, + 173, 056, 098, 132, + 174, 056, 172, 132, + 175, 055, 032, 105, + 176, 055, 032, 105, + 177, 028, 048, 156, + 178, 028, 048, 156, + 179, 009, 009, 057, + 180, 009, 009, 057, + 181, 009, 009, 057, + 182, 034, 034, 131, + 183, 047, 037, 157, + 184, 047, 037, 157, + 185, 005, 069, 155, + 186, 011, 006, 002, + 187, 034, 102, 151, + 188, 034, 102, 151, + 189, 034, 102, 151, + 190, 050, 053, 092, + 191, 034, 094, 048, + 192, 034, 094, 048, + 193, 003, 014, 119, + 194, 006, 011, 109, + 195, 006, 011, 109, + 196, 028, 028, 156, + 197, 028, 028, 039, + 198, 015, 105, 158, + 199, 012, 020, 144, + 200, 026, 026, 026, + 201, 026, 026, 026, + 202, 023, 023, 140, + 203, 039, 048, 157, + 204, 005, 005, 142, + 205, 005, 005, 142, + 206, 032, 050, 155, + 207, 052, 008, 017, + 208, 069, 005, 125, + 209, 022, 050, 155, + 210, 022, 095, 155, + 211, 038, 033, 022, + 212, 068, 101, 135, + 213, 005, 082, 126, + 214, 068, 062, 153, + 215, 039, 051, 124, + 216, 053, 095, 118, + 217, 062, 095, 127, + 218, 040, 049, 133, + 219, 040, 049, 133, + 220, 012, 081, 047, + 221, 012, 081, 047, + 222, 055, 030, 144, + 223, 055, 097, 141, + 224, 021, 097, 141, + 225, 072, 055, 015, + 226, 033, 011, 041, + 227, 051, 005, 133, + 228, 048, 018, 127, + 229, 048, 018, 127, + 230, 033, 097, 006, + 231, 053, 053, 008, + 232, 005, 005, 008, + 233, 036, 088, 148, + 234, 022, 119, 157, + 235, 020, 101, 141, + 236, 062, 080, 072, + 237, 022, 101, 080, + 238, 012, 108, 093, + 239, 009, 009, 072, + 240, 049, 049, 072, + 241, 047, 113, 157, + 242, 030, 032, 131, + 243, 046, 046, 010, + 244, 046, 046, 018, + 245, 046, 046, 011, + 246, 062, 062, 008, + 247, 061, 061, 061, + 248, 045, 045, 127, + 249, 046, 046, 136, + 250, 046, 046, 144, + 251, 030, 030, 030, + 252, 065, 065, 084, + 253, 065, 065, 084, + 254, 065, 065, 084, + 255, 066, 066, 003, + 256, 066, 066, 003, + 257, 066, 066, 003, + 258, 067, 067, 006, + 259, 067, 067, 006, + 260, 067, 067, 006, + 261, 050, 095, 155, + 262, 022, 095, 153, + 263, 053, 082, 095, + 264, 053, 082, 095, + 265, 019, 019, 050, + 266, 061, 061, 061, + 267, 068, 068, 079, + 268, 061, 061, 061, + 269, 019, 019, 014, + 270, 033, 044, 020, + 271, 033, 044, 020, + 272, 033, 044, 020, + 273, 034, 048, 124, + 274, 034, 048, 124, + 275, 034, 048, 124, + 276, 062, 062, 113, + 277, 062, 062, 113, + 278, 051, 051, 044, + 279, 051, 051, 044, + 280, 028, 036, 140, + 281, 028, 036, 140, + 282, 028, 036, 140, + 283, 033, 033, 044, + 284, 022, 022, 127, + 285, 027, 090, 095, + 286, 027, 090, 101, + 287, 054, 054, 054, + 288, 072, 072, 072, + 289, 054, 054, 054, + 290, 014, 014, 050, + 291, 003, 003, 151, + 292, 025, 025, 025, + 293, 043, 043, 155, + 294, 043, 043, 113, + 295, 043, 043, 113, + 296, 047, 062, 125, + 297, 047, 062, 125, + 298, 047, 037, 157, + 299, 005, 042, 159, + 300, 056, 096, 147, + 301, 056, 096, 147, + 302, 051, 100, 158, + 303, 052, 022, 125, + 304, 005, 069, 134, + 305, 005, 069, 134, + 306, 005, 069, 134, + 307, 074, 074, 140, + 308, 074, 074, 140, + 309, 009, 031, 058, + 310, 009, 031, 058, + 311, 057, 057, 031, + 312, 058, 058, 010, + 313, 035, 068, 158, + 314, 012, 110, 158, + 315, 030, 038, 102, + 316, 064, 060, 082, + 317, 064, 060, 082, + 318, 024, 024, 003, + 319, 024, 024, 003, + 320, 041, 012, 046, + 321, 041, 012, 046, + 322, 012, 086, 020, + 323, 040, 116, 083, + 324, 073, 073, 075, + 325, 047, 020, 082, + 326, 047, 020, 082, + 327, 020, 077, 126, + 328, 052, 071, 125, + 329, 026, 026, 026, + 330, 026, 026, 026, + 331, 008, 008, 011, + 332, 008, 008, 011, + 333, 030, 030, 013, + 334, 030, 030, 013, + 335, 017, 017, 137, + 336, 061, 061, 151, + 337, 026, 026, 026, + 338, 026, 026, 026, + 339, 012, 107, 093, + 340, 012, 107, 093, + 341, 052, 075, 091, + 342, 052, 075, 091, + 343, 026, 026, 026, + 344, 026, 026, 026, + 345, 021, 021, 114, + 346, 021, 021, 114, + 347, 004, 004, 033, + 348, 004, 004, 033, + 349, 033, 012, 091, + 350, 063, 172, 056, + 351, 059, 059, 059, + 352, 016, 016, 168, + 353, 015, 119, 130, + 354, 015, 119, 130, + 355, 026, 026, 119, + 356, 046, 046, 119, + 357, 034, 094, 139, + 358, 026, 026, 026, + 359, 046, 105, 154, + 360, 023, 023, 140, + 361, 039, 115, 141, + 362, 039, 115, 141, + 363, 047, 115, 012, + 364, 047, 115, 012, + 365, 047, 115, 012, + 366, 075, 075, 155, + 367, 033, 033, 041, + 368, 033, 033, 093, + 369, 033, 069, 005, + 370, 033, 033, 093, + 371, 069, 069, 125, + 372, 069, 069, 142, + 373, 022, 022, 153, + 374, 029, 029, 135, + 375, 029, 029, 135, + 376, 029, 029, 135, + 377, 029, 029, 005, + 378, 029, 029, 115, + 379, 029, 029, 135, + 380, 026, 026, 026, + 381, 026, 026, 026, + 382, 002, 002, 002, + 383, 070, 070, 070, + 384, 076, 076, 076, + 385, 032, 032, 032, + 386, 046, 046, 046, + 387, 065, 065, 075, + 388, 065, 065, 075, + 389, 065, 065, 075, + 390, 066, 066, 089, + 391, 066, 066, 089, + 392, 066, 066, 089, + 393, 067, 067, 128, + 394, 067, 067, 128, + 395, 067, 067, 128, + 396, 051, 051, 120, + 397, 022, 022, 120, + 398, 022, 022, 120, + 399, 086, 109, 141, + 400, 086, 109, 141, + 401, 061, 061, 050, + 402, 068, 068, 101, + 403, 079, 022, 062, + 404, 079, 022, 062, + 405, 079, 022, 062, + 406, 030, 038, 102, + 407, 030, 038, 101, + 408, 104, 104, 125, + 409, 104, 104, 125, + 410, 005, 005, 043, + 411, 005, 005, 043, + 412, 061, 061, 142, + 413, 107, 107, 142, + 414, 068, 068, 110, + 415, 118, 118, 055, + 416, 046, 046, 127, + 417, 050, 053, 010, + 418, 033, 033, 041, + 419, 033, 033, 041, + 420, 034, 034, 034, + 421, 122, 122, 122, + 422, 060, 114, 159, + 423, 060, 114, 159, + 424, 101, 053, 092, + 425, 106, 084, 138, + 426, 106, 084, 138, + 427, 050, 103, 007, + 428, 056, 103, 007, + 429, 026, 026, 026, + 430, 015, 105, 153, + 431, 007, 020, 051, + 432, 047, 020, 128, + 433, 026, 026, 026, + 434, 001, 106, 051, + 435, 001, 106, 051, + 436, 026, 085, 134, + 437, 026, 085, 134, + 438, 005, 069, 155, + 439, 043, 111, 101, + 440, 030, 032, 132, + 441, 051, 077, 145, + 442, 046, 046, 151, + 443, 008, 008, 024, + 444, 008, 008, 024, + 445, 008, 008, 024, + 446, 053, 047, 082, + 447, 080, 039, 158, + 448, 080, 039, 154, + 449, 045, 045, 159, + 450, 045, 045, 159, + 451, 004, 097, 051, + 452, 004, 097, 051, + 453, 107, 087, 143, + 454, 107, 087, 143, + 455, 026, 026, 026, + 456, 033, 114, 041, + 457, 033, 114, 041, + 458, 033, 011, 041, + 459, 117, 117, 043, + 460, 117, 117, 043, + 461, 046, 046, 124, + 462, 042, 005, 148, + 463, 020, 012, 013, + 464, 031, 116, 120, + 465, 034, 102, 144, + 466, 078, 078, 072, + 467, 049, 049, 072, + 468, 055, 032, 105, + 469, 003, 110, 119, + 470, 102, 102, 034, + 471, 081, 081, 115, + 472, 052, 008, 090, + 473, 012, 081, 047, + 474, 091, 088, 148, + 475, 080, 080, 154, + 476, 005, 042, 159, + 477, 046, 046, 119, + 478, 081, 081, 130, + 479, 026, 026, 026, + 480, 026, 026, 026, + 481, 026, 026, 026, + 482, 026, 026, 026, + 483, 046, 046, 140, + 484, 046, 046, 140, + 485, 018, 018, 049, + 486, 112, 112, 112, + 487, 046, 046, 140, + 488, 026, 026, 026, + 489, 093, 093, 093, + 490, 093, 093, 093, + 491, 123, 123, 123, + 492, 030, 030, 030, + 493, 121, 121, 121, + 494, 162, 162, 162, + 495, 065, 065, 126, + 496, 065, 065, 126, + 497, 065, 065, 126, + 498, 066, 066, 047, + 499, 066, 066, 047, + 500, 066, 066, 120, + 501, 067, 067, 075, + 502, 067, 067, 075, + 503, 067, 067, 075, + 504, 050, 051, 148, + 505, 035, 051, 148, + 506, 072, 053, 050, + 507, 022, 146, 113, + 508, 022, 146, 113, + 509, 007, 084, 158, + 510, 007, 084, 158, + 511, 082, 082, 065, + 512, 082, 082, 065, + 513, 082, 082, 066, + 514, 082, 082, 066, + 515, 082, 082, 067, + 516, 082, 082, 067, + 517, 108, 028, 140, + 518, 108, 028, 140, + 519, 145, 105, 079, + 520, 145, 105, 079, + 521, 145, 105, 079, + 522, 031, 078, 157, + 523, 031, 078, 157, + 524, 005, 005, 159, + 525, 005, 005, 159, + 526, 005, 005, 159, + 527, 109, 103, 086, + 528, 109, 103, 086, + 529, 146, 159, 104, + 530, 146, 159, 104, + 531, 131, 144, 103, + 532, 062, 125, 089, + 533, 062, 125, 089, + 534, 062, 125, 089, + 535, 033, 093, 011, + 536, 033, 093, 011, + 537, 033, 143, 011, + 538, 062, 039, 104, + 539, 005, 039, 104, + 540, 068, 034, 142, + 541, 102, 034, 142, + 542, 068, 034, 142, + 543, 038, 068, 003, + 544, 038, 068, 003, + 545, 038, 068, 003, + 546, 158, 151, 034, + 547, 158, 151, 034, + 548, 034, 020, 102, + 549, 034, 020, 102, + 550, 120, 091, 104, + 551, 022, 153, 083, + 552, 022, 153, 083, + 553, 022, 153, 083, + 554, 055, 055, 039, + 555, 125, 125, 161, + 556, 011, 034, 114, + 557, 005, 075, 133, + 558, 005, 075, 133, + 559, 061, 153, 022, + 560, 061, 153, 022, + 561, 147, 098, 110, + 562, 152, 152, 152, + 563, 152, 152, 152, + 564, 116, 005, 033, + 565, 116, 005, 033, + 566, 129, 129, 129, + 567, 129, 129, 129, + 568, 001, 060, 106, + 569, 001, 133, 106, + 570, 149, 149, 149, + 571, 149, 149, 149, + 572, 056, 101, 092, + 573, 056, 101, 092, + 574, 119, 172, 023, + 575, 119, 172, 023, + 576, 119, 172, 023, + 577, 142, 098, 144, + 578, 142, 098, 144, + 579, 142, 098, 144, + 580, 051, 145, 093, + 581, 051, 145, 093, + 582, 115, 115, 133, + 583, 115, 115, 133, + 584, 115, 115, 133, + 585, 034, 157, 032, + 586, 034, 157, 032, + 587, 009, 009, 078, + 588, 068, 061, 099, + 589, 068, 075, 142, + 590, 027, 027, 144, + 591, 027, 027, 144, + 592, 011, 130, 006, + 593, 011, 130, 006, + 594, 131, 093, 144, + 595, 014, 127, 068, + 596, 014, 127, 068, + 597, 160, 160, 160, + 598, 160, 160, 107, + 599, 057, 058, 029, + 600, 057, 058, 029, + 601, 057, 058, 029, + 602, 026, 026, 026, + 603, 026, 026, 026, + 604, 026, 026, 026, + 605, 140, 028, 148, + 606, 140, 028, 148, + 607, 018, 049, 151, + 608, 018, 049, 151, + 609, 018, 049, 151, + 610, 079, 104, 127, + 611, 079, 104, 127, + 612, 079, 104, 127, + 613, 081, 081, 155, + 614, 081, 081, 033, + 615, 026, 026, 026, + 616, 093, 075, 142, + 617, 093, 060, 084, + 618, 009, 007, 008, + 619, 039, 144, 120, + 620, 039, 144, 120, + 621, 024, 125, 104, + 622, 089, 103, 099, + 623, 089, 103, 099, + 624, 128, 039, 046, + 625, 128, 039, 046, + 626, 120, 157, 043, + 627, 051, 125, 055, + 628, 051, 125, 128, + 629, 145, 142, 133, + 630, 145, 142, 133, + 631, 082, 018, 073, + 632, 068, 055, 054, + 633, 055, 055, 055, + 634, 055, 055, 055, + 635, 026, 026, 026, + 636, 049, 049, 068, + 637, 049, 049, 068, + 638, 154, 154, 154, + 639, 154, 154, 154, + 640, 154, 154, 154, + 641, 158, 158, 128, + 642, 158, 158, 128, + 643, 163, 163, 163, + 644, 164, 164, 164, + 645, 159, 159, 125, + 646, 046, 046, 046, + 647, 154, 154, 154, + 648, 032, 032, 032, + 649, 088, 088, 088, + 650, 065, 065, 171, + 651, 065, 065, 171, + 652, 065, 065, 171, + 653, 066, 066, 170, + 654, 066, 066, 170, + 655, 066, 066, 170, + 656, 067, 067, 168, + 657, 067, 067, 168, + 658, 067, 067, 168, + 659, 053, 167, 037, + 660, 053, 167, 037, + 661, 145, 145, 177, + 662, 049, 049, 177, + 663, 049, 049, 177, + 664, 019, 014, 132, + 665, 061, 061, 132, + 666, 019, 014, 132, + 667, 079, 127, 153, + 668, 079, 127, 153, + 669, 166, 166, 180, + 670, 166, 166, 180, + 671, 166, 166, 180, + 672, 157, 157, 179, + 673, 157, 157, 179, + 674, 089, 104, 113, + 675, 089, 104, 113, + 676, 169, 169, 169, + 677, 051, 151, 020, + 678, 051, 151, 158, + 679, 099, 099, 099, + 680, 099, 099, 099, + 681, 176, 176, 176, + 682, 131, 131, 165, + 683, 131, 131, 165, + 684, 175, 175, 084, + 685, 175, 175, 084, + 686, 126, 021, 151, + 687, 126, 021, 151, + 688, 181, 097, 124, + 689, 181, 097, 124, + 690, 038, 143, 091, + 691, 038, 143, 091, + 692, 178, 178, 178, + 693, 178, 178, 178, + 694, 087, 008, 094, + 695, 087, 008, 094, + 696, 173, 173, 005, + 697, 173, 173, 069, + 698, 174, 174, 117, + 699, 174, 174, 117, + 700, 056, 056, 182, + 701, 007, 084, 104, + 702, 167, 053, 057, + 703, 029, 029, 005, + 704, 157, 093, 183, + 705, 157, 093, 183, + 706, 157, 093, 183, + 707, 158, 158, 170, + 708, 030, 119, 139, + 709, 030, 119, 139, + 710, 053, 119, 015, + 711, 053, 119, 015, + 712, 020, 115, 005, + 713, 020, 115, 005, + 714, 119, 151, 140, + 715, 119, 151, 140, + 716, 187, 187, 187, + 717, 186, 186, 186, + 718, 188, 188, 188, + 719, 029, 029, 029, + 720, 170, 170, 170, + 721, 011, 011, 011, + 722, 046, 046, 046, + 723, 046, 046, 046, + 724, 046, 046, 046, + 725, 107, 107, 142, + 726, 107, 107, 142, + 727, 032, 032, 032, + 728, 026, 026, 026, + 729, 026, 026, 026, + 730, 026, 026, 026, + 731, 026, 026, 026, + 732, 026, 026, 026, + 733, 026, 026, 026, + 734, 059, 059, 059, + 735, 059, 059, 059, + 736, 059, 059, 059, + 737, 122, 122, 122, + 738, 069, 091, 104, + 739, 125, 125, 161, + 740, 032, 032, 032, + 741, 163, 163, 163, + 742, 164, 164, 164, + 743, 154, 154, 154, + 744, 144, 144, 144, + 745, 010, 010, 010, + 746, 022, 022, 022, + 747, 023, 023, 023, + 748, 051, 151, 172, + 749, 169, 169, 169, + 750, 169, 169, 169, + 751, 169, 169, 169, + 752, 169, 169, 169, + 753, 169, 169, 169, + 754, 169, 169, 169, + 755, 169, 169, 169, + 756, 169, 169, 169, + 757, 169, 169, 169, + 758, 182, 182, 182, + 759, 104, 104, 104, + 760, 047, 047, 047, + 761, 181, 181, 181, + 762, 070, 070, 070, + 763, 080, 080, 080, + 764, 015, 015, 015, + 765, 003, 003, 003, + 766, 074, 074, 074, + 767, 094, 094, 094, + 768, 111, 111, 111, + 769, 158, 158, 158, + 770, 045, 045, 045, + 771, 101, 101, 101, + 772, 184, 184, 184, + 773, 181, 181, 181, + 774, 091, 091, 091, + 775, 117, 117, 117, + 776, 176, 176, 176, + 777, 178, 178, 178, + 778, 185, 185, 185, + 779, 104, 104, 104, + 780, 156, 156, 156, + 781, 036, 036, 036, + 782, 092, 092, 092, + 783, 037, 037, 037, + 784, 022, 022, 022, + 785, 159, 159, 159, + 786, 026, 026, 026, + 787, 026, 026, 026, + 788, 053, 119, 015, + 789, 053, 119, 015, + 790, 053, 119, 015, + 791, 053, 119, 015, + 792, 053, 119, 015, + 793, 053, 119, 015, + 794, 166, 166, 180, + 795, 166, 166, 180, + 796, 166, 166, 180, + 797, 166, 166, 180, + 798, 166, 166, 180, + 799, 033, 033, 033, + 800, 031, 031, 031, + 801, 156, 156, 156, + 802, 182, 182, 182, + 803, 039, 039, 039, + 804, 131, 131, 131, + 805, 173, 173, 173, + 806, 075, 075, 075, + 807, 159, 159, 159, + 808, 099, 099, 099, + 809, 174, 174, 174, + 810, 156, 156, 156, + 811, 181, 181, 181, + 812, 189, 189, 189, + 813, 190, 190, 190, + 814, 191, 191, 191, + 815, 009, 009, 031, + 816, 009, 009, 031, + 817, 009, 009, 031, + 818, 009, 009, 031, + 819, 009, 009, 031, + 820, 009, 009, 031, + 821, 170, 170, 170, + 822, 125, 125, 125, + 823, 113, 113, 113, + 824, 184, 184, 184, + 825, 091, 091, 091, + }; + #endregion } } diff --git a/Misc/Util.cs b/Misc/Util.cs index f3e14260c..e15d2b948 100644 --- a/Misc/Util.cs +++ b/Misc/Util.cs @@ -5,8 +5,8 @@ using System.Drawing; using System.IO; using System.Windows.Forms; -using System.Reflection; using System.Drawing.Imaging; +using System.Text.RegularExpressions; namespace PKHeX { @@ -73,6 +73,8 @@ internal static Color AlphaBlend(Color ForeGround, Color BackGround) B = 255; return Color.FromArgb(Math.Abs(A), Math.Abs(R), Math.Abs(G), Math.Abs(B)); } + + // Strings and Paths internal static FileInfo GetNewestFile(DirectoryInfo directory) { return directory.GetFiles() @@ -80,24 +82,16 @@ internal static FileInfo GetNewestFile(DirectoryInfo directory) .OrderByDescending(f => (f == null ? DateTime.MinValue : f.LastWriteTime)) .FirstOrDefault(); } - - //Adding a Normalize Path function using a variant of this answer from stack overflow - //http://stackoverflow.com/questions/1266674/how-can-one-get-an-absolute-or-normalized-file-path-in-net/21058121#21058121 internal static string NormalizePath(string path) { return Path.GetFullPath(new Uri(path).LocalPath) .TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); } - internal static string GetTempFolder() // From 3DSSE's decompiled source. + internal static string GetTempFolder() { - string tempPath = Path.GetTempPath(); - string str2 = "SE3DS"; - str2 = "3DSSE"; - tempPath = Path.Combine(tempPath, str2); - // Directory.CreateDirectory(tempPath); - return (tempPath); + return Path.Combine(Path.GetTempPath(), "3DSSE"); } - internal static string GetCacheFolder() // edited + internal static string GetCacheFolder() { return Path.Combine(GetBackupLocation(), "cache"); } @@ -133,17 +127,14 @@ internal static string GetSDFLocation() { try { - // start by checking if the 3DS file path exists or not. + // Start by checking if the 3DS file path exists or not. string path_SDF = null; string[] DriveList = Environment.GetLogicalDrives(); - for (int i = 1; i < DriveList.Length; i++) + for (int i = 1; i < DriveList.Length; i++) // Skip first drive (some users still have floppy drives and would chew up time!) { string potentialPath_SDF = NormalizePath(Path.Combine(DriveList[i], "filer" + Path.DirectorySeparatorChar + "UserSaveData")); if (Directory.Exists(potentialPath_SDF)) - { - path_SDF = potentialPath_SDF; - break; - } + { path_SDF = potentialPath_SDF; break; } } if (path_SDF == null) return null; @@ -159,12 +150,8 @@ internal static string GetSDFLocation() if (File.Exists(Path.Combine(folders[i], "000011c5" + Path.DirectorySeparatorChar + "main"))) return Path.Combine(folders[i], "000011c5"); // AS if (File.Exists(Path.Combine(folders[i], "0000055d" + Path.DirectorySeparatorChar + "main"))) return Path.Combine(folders[i], "0000055d"); // X if (File.Exists(Path.Combine(folders[i], "0000055e" + Path.DirectorySeparatorChar + "main"))) return Path.Combine(folders[i], "0000055e"); // Y - - // I don't know - if (File.Exists(Path.Combine(folders[i], "00055d00" + Path.DirectorySeparatorChar + "main"))) return Path.Combine(folders[i], "00055d00"); // X - if (File.Exists(Path.Combine(folders[i], "00055e00" + Path.DirectorySeparatorChar + "main"))) return Path.Combine(folders[i], "00055e00"); // Y } - return null; + return null; // Fallthrough } } catch { return null; } @@ -193,12 +180,14 @@ internal static string[] getStringList(string f, string l) return stringdata; } + // Randomization internal static Random rand = new Random(); internal static uint rnd32() { return (uint)(rand.Next(1 << 30)) << 2 | (uint)(rand.Next(1 << 2)); } + // Data Retrieval internal static int ToInt32(TextBox tb) { string value = tb.Text; @@ -283,18 +272,113 @@ internal static string getOnlyHex(string str) return s; } - internal static MaskedTextBox[] shuffle(MaskedTextBox[] charArray) + // Data Manipulation + internal static void Shuffle(T[] array) { - MaskedTextBox[] shuffledArray = new MaskedTextBox[charArray.Length]; - int rndNo; - - for (int i = charArray.Length; i >= 1; i--) + int n = array.Length; + for (int i = 0; i < n; i++) { - rndNo = rand.Next(1, i + 1) - 1; - shuffledArray[i - 1] = charArray[rndNo]; - charArray[rndNo] = charArray[i - 1]; + int r = i + (int)(rand.NextDouble() * (n - i)); + T t = array[r]; + array[r] = array[i]; + array[i] = t; } - return shuffledArray; + } + + // Form Manipulation + internal static void TranslateInterface(string FORM_NAME, string lang, Control.ControlCollection Controls, MenuStrip menu = null) + { + // Fetch a File + // Check to see if a the translation file exists in the same folder as the executable + string externalLangPath = System.Windows.Forms.Application.StartupPath + Path.DirectorySeparatorChar + "lang_" + lang + ".txt"; + string[] rawlist; + if (File.Exists(externalLangPath)) + rawlist = File.ReadAllLines(externalLangPath); + else + { + object txt; + txt = Properties.Resources.ResourceManager.GetObject("lang_" + lang); // Fetch File, \n to list. + if (txt == null) return; // Translation file does not exist as a resource; abort this function and don't translate UI. + string[] stringSeparators = new string[] { "\r\n" }; // Resource files are notepad compatible + rawlist = ((string)txt).Split(stringSeparators, StringSplitOptions.None); + rawlist = rawlist.Select(i => i.Trim()).ToArray(); // Remove trailing spaces + } + + string[] stringdata = new string[rawlist.Length]; + int itemsToRename = 0; + int start = Array.IndexOf(rawlist, "! " + FORM_NAME); + if (start < 0) return; // No Translation loaded for this Form. + for (int i = start; i < rawlist.Length; i++) + { + // Find our starting point + if (rawlist[i] == "! " + FORM_NAME) // Start our data + { + // Copy our Control Names and Text to a new array for later processing. + for (int j = i + 1; j < rawlist.Length; j++) + { + if (rawlist[j].Length == 0) + continue; // Skip Over Empty Lines, errhandled + if (rawlist[j][0].ToString() != "-") // If line is not a comment line... + { + if (rawlist[j][0].ToString() == "!") // Stop if we have reached the end of translation + break; // exit inner loop + stringdata[itemsToRename] = rawlist[j]; // Add the entry to process later. + itemsToRename++; + } + } + break; // exit outer loop + } + } + + // Now that we have our items to rename in: Control = Text format, let's execute the changes! + + for (int i = 0; i < itemsToRename; i++) + { + string[] SplitString = Regex.Split(stringdata[i], " = "); + if (SplitString.Length < 2) + continue; // Error in Input, errhandled + string ctrl = SplitString[0]; // Control to change the text of... + string text = SplitString[1]; // Text to set Control.Text to... + Control[] controllist = Controls.Find(ctrl, true); + if (controllist.Length == 0) // If Control isn't found... + { + // Menu Items can't be found with Controls.Find as they aren't Controls + ToolStripDropDownItem TSI = (ToolStripDropDownItem)menu.Items[ctrl]; + if (TSI != null) + { + // We'll rename the main and child in a row. + string[] ToolItems = Regex.Split(SplitString[1], " ; "); + TSI.Text = ToolItems[0]; // Set parent's text first + if (TSI.DropDownItems.Count != ToolItems.Length - 1) + continue; // Error in Input, errhandled + for (int ti = 1; ti <= TSI.DropDownItems.Count; ti++) + TSI.DropDownItems[ti - 1].Text = ToolItems[ti]; // Set child text + } + // If not found, it is not something to rename and is thus skipped. + } + else // Set the input control's text. + controllist[0].Text = text; + } + } + + // Message Displays + internal static DialogResult Error(params string[] lines) + { + System.Media.SystemSounds.Exclamation.Play(); + string msg = String.Join(System.Environment.NewLine + System.Environment.NewLine, lines); + return (DialogResult)MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + internal static DialogResult Alert(params string[] lines) + { + System.Media.SystemSounds.Asterisk.Play(); + string msg = String.Join(System.Environment.NewLine + System.Environment.NewLine, lines); + return (DialogResult)MessageBox.Show(msg, "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + internal static DialogResult Prompt(MessageBoxButtons btn, params string[] lines) + { + System.Media.SystemSounds.Question.Play(); + string msg = String.Join(System.Environment.NewLine + System.Environment.NewLine, lines); + return (DialogResult)MessageBox.Show(msg, "Prompt", btn, MessageBoxIcon.Asterisk); } } } diff --git a/PKX/f1-Main.Designer.cs b/PKX/f1-Main.Designer.cs index e6dcf6633..091230ec0 100644 --- a/PKX/f1-Main.Designer.cs +++ b/PKX/f1-Main.Designer.cs @@ -535,7 +535,7 @@ public void InitializeComponent() this.TB_PID.Size = new System.Drawing.Size(60, 20); this.TB_PID.TabIndex = 60; this.TB_PID.Text = "12345678"; - this.TB_PID.TextChanged += new System.EventHandler(this.updateTIDSID); + this.TB_PID.TextChanged += new System.EventHandler(this.update_ID); this.TB_PID.MouseHover += new System.EventHandler(this.getTSV); // // CHK_Nicknamed @@ -2154,7 +2154,7 @@ public void InitializeComponent() this.TB_EC.Size = new System.Drawing.Size(60, 20); this.TB_EC.TabIndex = 61; this.TB_EC.Text = "12345678"; - this.TB_EC.TextChanged += new System.EventHandler(this.updateTIDSID); + this.TB_EC.TextChanged += new System.EventHandler(this.update_ID); // // GB_nOT // @@ -2486,7 +2486,7 @@ public void InitializeComponent() this.TB_SID.Size = new System.Drawing.Size(40, 20); this.TB_SID.TabIndex = 2; this.TB_SID.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - this.TB_SID.TextChanged += new System.EventHandler(this.updateTIDSID); + this.TB_SID.TextChanged += new System.EventHandler(this.update_ID); this.TB_SID.MouseHover += new System.EventHandler(this.getTSV); // // TB_TID @@ -2498,7 +2498,7 @@ public void InitializeComponent() this.TB_TID.Size = new System.Drawing.Size(40, 20); this.TB_TID.TabIndex = 1; this.TB_TID.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - this.TB_TID.TextChanged += new System.EventHandler(this.updateTIDSID); + this.TB_TID.TextChanged += new System.EventHandler(this.update_ID); this.TB_TID.MouseHover += new System.EventHandler(this.getTSV); // // Label_OT diff --git a/PKX/f1-Main.cs b/PKX/f1-Main.cs index f26e1f110..dbdcfdc73 100644 --- a/PKX/f1-Main.cs +++ b/PKX/f1-Main.cs @@ -188,10 +188,7 @@ public Form1() this.Show(); this.WindowState = FormWindowState.Normal; if (HaX) - { - System.Media.SystemSounds.Exclamation.Play(); - MessageBox.Show("Illegal mode activated.\n\nPlease behave.", "Alert"); - } + Util.Alert("Illegal mode activated.", "Please behave."); #endregion } @@ -256,840 +253,6 @@ public Form1() private void InitializeFields() { // Initialize Fields - { - #region ability table - speciesability = new int[] { - // If you're tinkering with the program, just change the "e" in PKHeX to an "a". - // You can then choose any ability or use hacked stats. Please act responsibly. - 000, 000, 000, 000, - 001, 065, 065, 034, - 002, 065, 065, 034, - 003, 065, 065, 034, - 004, 066, 066, 094, - 005, 066, 066, 094, - 006, 066, 066, 094, - 007, 067, 067, 044, - 008, 067, 067, 044, - 009, 067, 067, 044, - 010, 019, 019, 050, - 011, 061, 061, 061, - 012, 014, 014, 110, - 013, 019, 019, 050, - 014, 061, 061, 061, - 015, 068, 068, 097, - 016, 051, 077, 145, - 017, 051, 077, 145, - 018, 051, 077, 145, - 019, 050, 062, 055, - 020, 050, 062, 055, - 021, 051, 051, 097, - 022, 051, 051, 097, - 023, 022, 061, 127, - 024, 022, 061, 127, - 025, 009, 009, 031, - 026, 009, 009, 031, - 027, 008, 008, 146, - 028, 008, 008, 146, - 029, 038, 079, 055, - 030, 038, 079, 055, - 031, 038, 079, 125, - 032, 038, 079, 055, - 033, 038, 079, 055, - 034, 038, 079, 125, - 035, 056, 098, 132, - 036, 056, 098, 109, - 037, 018, 018, 070, - 038, 018, 018, 070, - 039, 056, 172, 132, - 040, 056, 172, 119, - 041, 039, 039, 151, - 042, 039, 039, 151, - 043, 034, 034, 050, - 044, 034, 034, 001, - 045, 034, 034, 027, - 046, 027, 087, 006, - 047, 027, 087, 006, - 048, 014, 110, 050, - 049, 019, 110, 147, - 050, 008, 071, 159, - 051, 008, 071, 159, - 052, 053, 101, 127, - 053, 007, 101, 127, - 054, 006, 013, 033, - 055, 006, 013, 033, - 056, 072, 083, 128, - 057, 072, 083, 128, - 058, 022, 018, 154, - 059, 022, 018, 154, - 060, 011, 006, 033, - 061, 011, 006, 033, - 062, 011, 006, 033, - 063, 028, 039, 098, - 064, 028, 039, 098, - 065, 028, 039, 098, - 066, 062, 099, 080, - 067, 062, 099, 080, - 068, 062, 099, 080, - 069, 034, 034, 082, - 070, 034, 034, 082, - 071, 034, 034, 082, - 072, 029, 064, 044, - 073, 029, 064, 044, - 074, 069, 005, 008, - 075, 069, 005, 008, - 076, 069, 005, 008, - 077, 050, 018, 049, - 078, 050, 018, 049, - 079, 012, 020, 144, - 080, 012, 020, 144, - 081, 042, 005, 148, - 082, 042, 005, 148, - 083, 051, 039, 128, - 084, 050, 048, 077, - 085, 050, 048, 077, - 086, 047, 093, 115, - 087, 047, 093, 115, - 088, 001, 060, 143, - 089, 001, 060, 143, - 090, 075, 092, 142, - 091, 075, 092, 142, - 092, 026, 026, 026, - 093, 026, 026, 026, - 094, 026, 026, 026, - 095, 069, 005, 133, - 096, 015, 108, 039, - 097, 015, 108, 039, - 098, 052, 075, 125, - 099, 052, 075, 125, - 100, 043, 009, 106, - 101, 043, 009, 106, - 102, 034, 034, 139, - 103, 034, 034, 139, - 104, 069, 031, 004, - 105, 069, 031, 004, - 106, 007, 120, 084, - 107, 051, 089, 039, - 108, 020, 012, 013, - 109, 026, 026, 026, - 110, 026, 026, 026, - 111, 031, 069, 120, - 112, 031, 069, 120, - 113, 030, 032, 131, - 114, 034, 102, 144, - 115, 048, 113, 039, - 116, 033, 097, 006, - 117, 038, 097, 006, - 118, 033, 041, 031, - 119, 033, 041, 031, - 120, 035, 030, 148, - 121, 035, 030, 148, - 122, 043, 111, 101, - 123, 068, 101, 080, - 124, 012, 108, 087, - 125, 009, 009, 072, - 126, 049, 049, 072, - 127, 052, 104, 153, - 128, 022, 083, 125, - 129, 033, 033, 155, - 130, 022, 022, 153, - 131, 011, 075, 093, - 132, 007, 007, 150, - 133, 050, 091, 107, - 134, 011, 011, 093, - 135, 010, 010, 095, - 136, 018, 018, 062, - 137, 036, 088, 148, - 138, 033, 075, 133, - 139, 033, 075, 133, - 140, 033, 004, 133, - 141, 033, 004, 133, - 142, 069, 046, 127, - 143, 017, 047, 082, - 144, 046, 046, 081, - 145, 046, 046, 009, - 146, 046, 046, 049, - 147, 061, 061, 063, - 148, 061, 061, 063, - 149, 039, 039, 136, - 150, 046, 046, 127, - 151, 028, 028, 028, - 152, 065, 065, 102, - 153, 065, 065, 102, - 154, 065, 065, 102, - 155, 066, 066, 018, - 156, 066, 066, 018, - 157, 066, 066, 018, - 158, 067, 067, 125, - 159, 067, 067, 125, - 160, 067, 067, 125, - 161, 050, 051, 119, - 162, 050, 051, 119, - 163, 015, 051, 110, - 164, 015, 051, 110, - 165, 068, 048, 155, - 166, 068, 048, 089, - 167, 068, 015, 097, - 168, 068, 015, 097, - 169, 039, 039, 151, - 170, 010, 035, 011, - 171, 010, 035, 011, - 172, 009, 009, 031, - 173, 056, 098, 132, - 174, 056, 172, 132, - 175, 055, 032, 105, - 176, 055, 032, 105, - 177, 028, 048, 156, - 178, 028, 048, 156, - 179, 009, 009, 057, - 180, 009, 009, 057, - 181, 009, 009, 057, - 182, 034, 034, 131, - 183, 047, 037, 157, - 184, 047, 037, 157, - 185, 005, 069, 155, - 186, 011, 006, 002, - 187, 034, 102, 151, - 188, 034, 102, 151, - 189, 034, 102, 151, - 190, 050, 053, 092, - 191, 034, 094, 048, - 192, 034, 094, 048, - 193, 003, 014, 119, - 194, 006, 011, 109, - 195, 006, 011, 109, - 196, 028, 028, 156, - 197, 028, 028, 039, - 198, 015, 105, 158, - 199, 012, 020, 144, - 200, 026, 026, 026, - 201, 026, 026, 026, - 202, 023, 023, 140, - 203, 039, 048, 157, - 204, 005, 005, 142, - 205, 005, 005, 142, - 206, 032, 050, 155, - 207, 052, 008, 017, - 208, 069, 005, 125, - 209, 022, 050, 155, - 210, 022, 095, 155, - 211, 038, 033, 022, - 212, 068, 101, 135, - 213, 005, 082, 126, - 214, 068, 062, 153, - 215, 039, 051, 124, - 216, 053, 095, 118, - 217, 062, 095, 127, - 218, 040, 049, 133, - 219, 040, 049, 133, - 220, 012, 081, 047, - 221, 012, 081, 047, - 222, 055, 030, 144, - 223, 055, 097, 141, - 224, 021, 097, 141, - 225, 072, 055, 015, - 226, 033, 011, 041, - 227, 051, 005, 133, - 228, 048, 018, 127, - 229, 048, 018, 127, - 230, 033, 097, 006, - 231, 053, 053, 008, - 232, 005, 005, 008, - 233, 036, 088, 148, - 234, 022, 119, 157, - 235, 020, 101, 141, - 236, 062, 080, 072, - 237, 022, 101, 080, - 238, 012, 108, 093, - 239, 009, 009, 072, - 240, 049, 049, 072, - 241, 047, 113, 157, - 242, 030, 032, 131, - 243, 046, 046, 010, - 244, 046, 046, 018, - 245, 046, 046, 011, - 246, 062, 062, 008, - 247, 061, 061, 061, - 248, 045, 045, 127, - 249, 046, 046, 136, - 250, 046, 046, 144, - 251, 030, 030, 030, - 252, 065, 065, 084, - 253, 065, 065, 084, - 254, 065, 065, 084, - 255, 066, 066, 003, - 256, 066, 066, 003, - 257, 066, 066, 003, - 258, 067, 067, 006, - 259, 067, 067, 006, - 260, 067, 067, 006, - 261, 050, 095, 155, - 262, 022, 095, 153, - 263, 053, 082, 095, - 264, 053, 082, 095, - 265, 019, 019, 050, - 266, 061, 061, 061, - 267, 068, 068, 079, - 268, 061, 061, 061, - 269, 019, 019, 014, - 270, 033, 044, 020, - 271, 033, 044, 020, - 272, 033, 044, 020, - 273, 034, 048, 124, - 274, 034, 048, 124, - 275, 034, 048, 124, - 276, 062, 062, 113, - 277, 062, 062, 113, - 278, 051, 051, 044, - 279, 051, 051, 044, - 280, 028, 036, 140, - 281, 028, 036, 140, - 282, 028, 036, 140, - 283, 033, 033, 044, - 284, 022, 022, 127, - 285, 027, 090, 095, - 286, 027, 090, 101, - 287, 054, 054, 054, - 288, 072, 072, 072, - 289, 054, 054, 054, - 290, 014, 014, 050, - 291, 003, 003, 151, - 292, 025, 025, 025, - 293, 043, 043, 155, - 294, 043, 043, 113, - 295, 043, 043, 113, - 296, 047, 062, 125, - 297, 047, 062, 125, - 298, 047, 037, 157, - 299, 005, 042, 159, - 300, 056, 096, 147, - 301, 056, 096, 147, - 302, 051, 100, 158, - 303, 052, 022, 125, - 304, 005, 069, 134, - 305, 005, 069, 134, - 306, 005, 069, 134, - 307, 074, 074, 140, - 308, 074, 074, 140, - 309, 009, 031, 058, - 310, 009, 031, 058, - 311, 057, 057, 031, - 312, 058, 058, 010, - 313, 035, 068, 158, - 314, 012, 110, 158, - 315, 030, 038, 102, - 316, 064, 060, 082, - 317, 064, 060, 082, - 318, 024, 024, 003, - 319, 024, 024, 003, - 320, 041, 012, 046, - 321, 041, 012, 046, - 322, 012, 086, 020, - 323, 040, 116, 083, - 324, 073, 073, 075, - 325, 047, 020, 082, - 326, 047, 020, 082, - 327, 020, 077, 126, - 328, 052, 071, 125, - 329, 026, 026, 026, - 330, 026, 026, 026, - 331, 008, 008, 011, - 332, 008, 008, 011, - 333, 030, 030, 013, - 334, 030, 030, 013, - 335, 017, 017, 137, - 336, 061, 061, 151, - 337, 026, 026, 026, - 338, 026, 026, 026, - 339, 012, 107, 093, - 340, 012, 107, 093, - 341, 052, 075, 091, - 342, 052, 075, 091, - 343, 026, 026, 026, - 344, 026, 026, 026, - 345, 021, 021, 114, - 346, 021, 021, 114, - 347, 004, 004, 033, - 348, 004, 004, 033, - 349, 033, 012, 091, - 350, 063, 172, 056, - 351, 059, 059, 059, - 352, 016, 016, 168, - 353, 015, 119, 130, - 354, 015, 119, 130, - 355, 026, 026, 119, - 356, 046, 046, 119, - 357, 034, 094, 139, - 358, 026, 026, 026, - 359, 046, 105, 154, - 360, 023, 023, 140, - 361, 039, 115, 141, - 362, 039, 115, 141, - 363, 047, 115, 012, - 364, 047, 115, 012, - 365, 047, 115, 012, - 366, 075, 075, 155, - 367, 033, 033, 041, - 368, 033, 033, 093, - 369, 033, 069, 005, - 370, 033, 033, 093, - 371, 069, 069, 125, - 372, 069, 069, 142, - 373, 022, 022, 153, - 374, 029, 029, 135, - 375, 029, 029, 135, - 376, 029, 029, 135, - 377, 029, 029, 005, - 378, 029, 029, 115, - 379, 029, 029, 135, - 380, 026, 026, 026, - 381, 026, 026, 026, - 382, 002, 002, 002, - 383, 070, 070, 070, - 384, 076, 076, 076, - 385, 032, 032, 032, - 386, 046, 046, 046, - 387, 065, 065, 075, - 388, 065, 065, 075, - 389, 065, 065, 075, - 390, 066, 066, 089, - 391, 066, 066, 089, - 392, 066, 066, 089, - 393, 067, 067, 128, - 394, 067, 067, 128, - 395, 067, 067, 128, - 396, 051, 051, 120, - 397, 022, 022, 120, - 398, 022, 022, 120, - 399, 086, 109, 141, - 400, 086, 109, 141, - 401, 061, 061, 050, - 402, 068, 068, 101, - 403, 079, 022, 062, - 404, 079, 022, 062, - 405, 079, 022, 062, - 406, 030, 038, 102, - 407, 030, 038, 101, - 408, 104, 104, 125, - 409, 104, 104, 125, - 410, 005, 005, 043, - 411, 005, 005, 043, - 412, 061, 061, 142, - 413, 107, 107, 142, - 414, 068, 068, 110, - 415, 118, 118, 055, - 416, 046, 046, 127, - 417, 050, 053, 010, - 418, 033, 033, 041, - 419, 033, 033, 041, - 420, 034, 034, 034, - 421, 122, 122, 122, - 422, 060, 114, 159, - 423, 060, 114, 159, - 424, 101, 053, 092, - 425, 106, 084, 138, - 426, 106, 084, 138, - 427, 050, 103, 007, - 428, 056, 103, 007, - 429, 026, 026, 026, - 430, 015, 105, 153, - 431, 007, 020, 051, - 432, 047, 020, 128, - 433, 026, 026, 026, - 434, 001, 106, 051, - 435, 001, 106, 051, - 436, 026, 085, 134, - 437, 026, 085, 134, - 438, 005, 069, 155, - 439, 043, 111, 101, - 440, 030, 032, 132, - 441, 051, 077, 145, - 442, 046, 046, 151, - 443, 008, 008, 024, - 444, 008, 008, 024, - 445, 008, 008, 024, - 446, 053, 047, 082, - 447, 080, 039, 158, - 448, 080, 039, 154, - 449, 045, 045, 159, - 450, 045, 045, 159, - 451, 004, 097, 051, - 452, 004, 097, 051, - 453, 107, 087, 143, - 454, 107, 087, 143, - 455, 026, 026, 026, - 456, 033, 114, 041, - 457, 033, 114, 041, - 458, 033, 011, 041, - 459, 117, 117, 043, - 460, 117, 117, 043, - 461, 046, 046, 124, - 462, 042, 005, 148, - 463, 020, 012, 013, - 464, 031, 116, 120, - 465, 034, 102, 144, - 466, 078, 078, 072, - 467, 049, 049, 072, - 468, 055, 032, 105, - 469, 003, 110, 119, - 470, 102, 102, 034, - 471, 081, 081, 115, - 472, 052, 008, 090, - 473, 012, 081, 047, - 474, 091, 088, 148, - 475, 080, 080, 154, - 476, 005, 042, 159, - 477, 046, 046, 119, - 478, 081, 081, 130, - 479, 026, 026, 026, - 480, 026, 026, 026, - 481, 026, 026, 026, - 482, 026, 026, 026, - 483, 046, 046, 140, - 484, 046, 046, 140, - 485, 018, 018, 049, - 486, 112, 112, 112, - 487, 046, 046, 140, - 488, 026, 026, 026, - 489, 093, 093, 093, - 490, 093, 093, 093, - 491, 123, 123, 123, - 492, 030, 030, 030, - 493, 121, 121, 121, - 494, 162, 162, 162, - 495, 065, 065, 126, - 496, 065, 065, 126, - 497, 065, 065, 126, - 498, 066, 066, 047, - 499, 066, 066, 047, - 500, 066, 066, 120, - 501, 067, 067, 075, - 502, 067, 067, 075, - 503, 067, 067, 075, - 504, 050, 051, 148, - 505, 035, 051, 148, - 506, 072, 053, 050, - 507, 022, 146, 113, - 508, 022, 146, 113, - 509, 007, 084, 158, - 510, 007, 084, 158, - 511, 082, 082, 065, - 512, 082, 082, 065, - 513, 082, 082, 066, - 514, 082, 082, 066, - 515, 082, 082, 067, - 516, 082, 082, 067, - 517, 108, 028, 140, - 518, 108, 028, 140, - 519, 145, 105, 079, - 520, 145, 105, 079, - 521, 145, 105, 079, - 522, 031, 078, 157, - 523, 031, 078, 157, - 524, 005, 005, 159, - 525, 005, 005, 159, - 526, 005, 005, 159, - 527, 109, 103, 086, - 528, 109, 103, 086, - 529, 146, 159, 104, - 530, 146, 159, 104, - 531, 131, 144, 103, - 532, 062, 125, 089, - 533, 062, 125, 089, - 534, 062, 125, 089, - 535, 033, 093, 011, - 536, 033, 093, 011, - 537, 033, 143, 011, - 538, 062, 039, 104, - 539, 005, 039, 104, - 540, 068, 034, 142, - 541, 102, 034, 142, - 542, 068, 034, 142, - 543, 038, 068, 003, - 544, 038, 068, 003, - 545, 038, 068, 003, - 546, 158, 151, 034, - 547, 158, 151, 034, - 548, 034, 020, 102, - 549, 034, 020, 102, - 550, 120, 091, 104, - 551, 022, 153, 083, - 552, 022, 153, 083, - 553, 022, 153, 083, - 554, 055, 055, 039, - 555, 125, 125, 161, - 556, 011, 034, 114, - 557, 005, 075, 133, - 558, 005, 075, 133, - 559, 061, 153, 022, - 560, 061, 153, 022, - 561, 147, 098, 110, - 562, 152, 152, 152, - 563, 152, 152, 152, - 564, 116, 005, 033, - 565, 116, 005, 033, - 566, 129, 129, 129, - 567, 129, 129, 129, - 568, 001, 060, 106, - 569, 001, 133, 106, - 570, 149, 149, 149, - 571, 149, 149, 149, - 572, 056, 101, 092, - 573, 056, 101, 092, - 574, 119, 172, 023, - 575, 119, 172, 023, - 576, 119, 172, 023, - 577, 142, 098, 144, - 578, 142, 098, 144, - 579, 142, 098, 144, - 580, 051, 145, 093, - 581, 051, 145, 093, - 582, 115, 115, 133, - 583, 115, 115, 133, - 584, 115, 115, 133, - 585, 034, 157, 032, - 586, 034, 157, 032, - 587, 009, 009, 078, - 588, 068, 061, 099, - 589, 068, 075, 142, - 590, 027, 027, 144, - 591, 027, 027, 144, - 592, 011, 130, 006, - 593, 011, 130, 006, - 594, 131, 093, 144, - 595, 014, 127, 068, - 596, 014, 127, 068, - 597, 160, 160, 160, - 598, 160, 160, 107, - 599, 057, 058, 029, - 600, 057, 058, 029, - 601, 057, 058, 029, - 602, 026, 026, 026, - 603, 026, 026, 026, - 604, 026, 026, 026, - 605, 140, 028, 148, - 606, 140, 028, 148, - 607, 018, 049, 151, - 608, 018, 049, 151, - 609, 018, 049, 151, - 610, 079, 104, 127, - 611, 079, 104, 127, - 612, 079, 104, 127, - 613, 081, 081, 155, - 614, 081, 081, 033, - 615, 026, 026, 026, - 616, 093, 075, 142, - 617, 093, 060, 084, - 618, 009, 007, 008, - 619, 039, 144, 120, - 620, 039, 144, 120, - 621, 024, 125, 104, - 622, 089, 103, 099, - 623, 089, 103, 099, - 624, 128, 039, 046, - 625, 128, 039, 046, - 626, 120, 157, 043, - 627, 051, 125, 055, - 628, 051, 125, 128, - 629, 145, 142, 133, - 630, 145, 142, 133, - 631, 082, 018, 073, - 632, 068, 055, 054, - 633, 055, 055, 055, - 634, 055, 055, 055, - 635, 026, 026, 026, - 636, 049, 049, 068, - 637, 049, 049, 068, - 638, 154, 154, 154, - 639, 154, 154, 154, - 640, 154, 154, 154, - 641, 158, 158, 128, - 642, 158, 158, 128, - 643, 163, 163, 163, - 644, 164, 164, 164, - 645, 159, 159, 125, - 646, 046, 046, 046, - 647, 154, 154, 154, - 648, 032, 032, 032, - 649, 088, 088, 088, - 650, 065, 065, 171, - 651, 065, 065, 171, - 652, 065, 065, 171, - 653, 066, 066, 170, - 654, 066, 066, 170, - 655, 066, 066, 170, - 656, 067, 067, 168, - 657, 067, 067, 168, - 658, 067, 067, 168, - 659, 053, 167, 037, - 660, 053, 167, 037, - 661, 145, 145, 177, - 662, 049, 049, 177, - 663, 049, 049, 177, - 664, 019, 014, 132, - 665, 061, 061, 132, - 666, 019, 014, 132, - 667, 079, 127, 153, - 668, 079, 127, 153, - 669, 166, 166, 180, - 670, 166, 166, 180, - 671, 166, 166, 180, - 672, 157, 157, 179, - 673, 157, 157, 179, - 674, 089, 104, 113, - 675, 089, 104, 113, - 676, 169, 169, 169, - 677, 051, 151, 020, - 678, 051, 151, 158, - 679, 099, 099, 099, - 680, 099, 099, 099, - 681, 176, 176, 176, - 682, 131, 131, 165, - 683, 131, 131, 165, - 684, 175, 175, 084, - 685, 175, 175, 084, - 686, 126, 021, 151, - 687, 126, 021, 151, - 688, 181, 097, 124, - 689, 181, 097, 124, - 690, 038, 143, 091, - 691, 038, 143, 091, - 692, 178, 178, 178, - 693, 178, 178, 178, - 694, 087, 008, 094, - 695, 087, 008, 094, - 696, 173, 173, 005, - 697, 173, 173, 069, - 698, 174, 174, 117, - 699, 174, 174, 117, - 700, 056, 056, 182, - 701, 007, 084, 104, - 702, 167, 053, 057, - 703, 029, 029, 005, - 704, 157, 093, 183, - 705, 157, 093, 183, - 706, 157, 093, 183, - 707, 158, 158, 170, - 708, 030, 119, 139, - 709, 030, 119, 139, - 710, 053, 119, 015, - 711, 053, 119, 015, - 712, 020, 115, 005, - 713, 020, 115, 005, - 714, 119, 151, 140, - 715, 119, 151, 140, - 716, 187, 187, 187, - 717, 186, 186, 186, - 718, 188, 188, 188, - 719, 029, 029, 029, - 720, 170, 170, 170, - 721, 011, 011, 011, - 722, 046, 046, 046, - 723, 046, 046, 046, - 724, 046, 046, 046, - 725, 107, 107, 142, - 726, 107, 107, 142, - 727, 032, 032, 032, - 728, 026, 026, 026, - 729, 026, 026, 026, - 730, 026, 026, 026, - 731, 026, 026, 026, - 732, 026, 026, 026, - 733, 026, 026, 026, - 734, 059, 059, 059, - 735, 059, 059, 059, - 736, 059, 059, 059, - 737, 122, 122, 122, - 738, 069, 091, 104, - 739, 125, 125, 161, - 740, 032, 032, 032, - 741, 163, 163, 163, - 742, 164, 164, 164, - 743, 154, 154, 154, - 744, 144, 144, 144, - 745, 010, 010, 010, - 746, 022, 022, 022, - 747, 023, 023, 023, - 748, 051, 151, 172, - 749, 169, 169, 169, - 750, 169, 169, 169, - 751, 169, 169, 169, - 752, 169, 169, 169, - 753, 169, 169, 169, - 754, 169, 169, 169, - 755, 169, 169, 169, - 756, 169, 169, 169, - 757, 169, 169, 169, - 758, 182, 182, 182, - 759, 104, 104, 104, - 760, 047, 047, 047, - 761, 181, 181, 181, - 762, 070, 070, 070, - 763, 080, 080, 080, - 764, 015, 015, 015, - 765, 003, 003, 003, - 766, 074, 074, 074, - 767, 094, 094, 094, - 768, 111, 111, 111, - 769, 158, 158, 158, - 770, 045, 045, 045, - 771, 101, 101, 101, - 772, 184, 184, 184, - 773, 181, 181, 181, - 774, 091, 091, 091, - 775, 117, 117, 117, - 776, 176, 176, 176, - 777, 178, 178, 178, - 778, 185, 185, 185, - 779, 104, 104, 104, - 780, 156, 156, 156, - 781, 036, 036, 036, - 782, 092, 092, 092, - 783, 037, 037, 037, - 784, 022, 022, 022, - 785, 159, 159, 159, - 786, 026, 026, 026, - 787, 026, 026, 026, - 788, 053, 119, 015, - 789, 053, 119, 015, - 790, 053, 119, 015, - 791, 053, 119, 015, - 792, 053, 119, 015, - 793, 053, 119, 015, - 794, 166, 166, 180, - 795, 166, 166, 180, - 796, 166, 166, 180, - 797, 166, 166, 180, - 798, 166, 166, 180, - 799, 033, 033, 033, - 800, 031, 031, 031, - 801, 156, 156, 156, - 802, 182, 182, 182, - 803, 039, 039, 039, - 804, 131, 131, 131, - 805, 173, 173, 173, - 806, 075, 075, 075, - 807, 159, 159, 159, - 808, 099, 099, 099, - 809, 174, 174, 174, - 810, 156, 156, 156, - 811, 181, 181, 181, - 812, 189, 189, 189, - 813, 190, 190, 190, - 814, 191, 191, 191, - 815, 009, 009, 031, - 816, 009, 009, 031, - 817, 009, 009, 031, - 818, 009, 009, 031, - 819, 009, 009, 031, - 820, 009, 009, 031, - 821, 170, 170, 170, - 822, 125, 125, 125, - 823, 113, 113, 113, - 824, 184, 184, 184, - 825, 091, 091, 091, - }; - #endregion - } { #region var tables @@ -1493,77 +656,6 @@ private void InitializeLanguage() #endregion } - public void TranslateInterface(string FORM_NAME) - { - // Fetch a File - // Check to see if a the translation file exists in the same folder as the executable - string externalLangPath = System.Windows.Forms.Application.StartupPath + Path.DirectorySeparatorChar + "lang_" + curlanguage + ".txt"; - string[] rawlist; - if (File.Exists(externalLangPath)) - rawlist = File.ReadAllLines(externalLangPath); - else - { - object txt; - txt = Properties.Resources.ResourceManager.GetObject("lang_" + curlanguage); // Fetch File, \n to list. - if (txt == null) return; // Translation file does not exist as a resource; abort this function and don't translate UI. - string[] stringSeparators = new string[] { "\r\n" }; - rawlist = ((string)txt).Split(stringSeparators, StringSplitOptions.None); - } - - string[] stringdata = new string[rawlist.Length]; - int itemsToRename = 0; - for (int i = 0; i < rawlist.Length; i++) - { - // Find our starting point - if (rawlist[i] == "! "+FORM_NAME) // Start our data - { - // Copy our Control Names and Text to a new array for later processing. - for (int j = i + 1; j < rawlist.Length; j++) - { - if (rawlist[j].Length == 0) - continue; // Skip Over Empty Lines, errhandled - if (rawlist[j][0].ToString() != "-") // If line is not a comment line... - { - if (rawlist[j][0].ToString() == "!") // Stop if we have reached the end of translation - break; // exit inner loop - stringdata[itemsToRename] = rawlist[j]; // Add the entry to process later. - itemsToRename++; - } - } - break; // exit outer loop - } - } - - // Now that we have our items to rename in: Control = Text format, let's execute the changes! - - for (int i = 0; i < itemsToRename; i++) - { - string[] SplitString = Regex.Split(stringdata[i]," = "); - if (SplitString.Length < 2) - continue; // Error in Input, errhandled - string ctrl = SplitString[0]; // Control to change the text of... - string text = SplitString[1]; // Text to set Control.Text to... - Control[] controllist = Controls.Find(ctrl, true); - if (controllist.Length == 0) // If Control isn't found... - { - // Menu Items can't be found with Controls.Find as they aren't Controls - ToolStripDropDownItem TSI = (ToolStripDropDownItem)menuStrip1.Items[ctrl]; - if (TSI != null) - { - // We'll rename the main and child in a row. - string[] ToolItems = Regex.Split(SplitString[1], " ; "); - TSI.Text = ToolItems[0]; // Set parent's text first - if (TSI.DropDownItems.Count != ToolItems.Length - 1) - continue; // Error in Input, errhandled - for (int ti = 1; ti <= TSI.DropDownItems.Count; ti++) - TSI.DropDownItems[ti-1].Text = ToolItems[ti]; // Set child text - } - // If not found, it is not something to rename and is thus skipped. - } - else // Set the input control's text. - controllist[0].Text = text; - } - } private void populateFields(byte[] buff) { CAL_EggDate.Value = new DateTime(2000, 01, 01); @@ -1839,7 +931,7 @@ private void populateFields(byte[] buff) setIsShiny(); if (init) if (!PKX.verifychk(buff)) - MessageBox.Show("PKX File has an invalid checksum.", "Alert"); + Util.Alert("PKX File has an invalid checksum."); init = true; @@ -2495,7 +1587,9 @@ private void updateEXPLevel(object sender, EventArgs e) private void updateIVs(object sender, EventArgs e) { if (sender != null) - (sender as MaskedTextBox).Text = Math.Min(Util.ToInt32((sender as MaskedTextBox).Text), 31).ToString(); + if (Util.ToInt32((sender as MaskedTextBox).Text) > 31) + (sender as MaskedTextBox).Text = "31"; + int ivtotal, HP_IV, ATK_IV, DEF_IV, SPA_IV, SPD_IV, SPE_IV; HP_IV = Util.ToInt32(TB_HPIV.Text); ATK_IV = Util.ToInt32(TB_ATKIV.Text); @@ -2555,7 +1649,9 @@ private void updateIVs(object sender, EventArgs e) private void updateEVs(object sender, EventArgs e) { if (sender != null) - (sender as MaskedTextBox).Text = Math.Min(Util.ToInt32((sender as MaskedTextBox).Text), 252).ToString(); + if (Util.ToInt32((sender as MaskedTextBox).Text) > 252) + (sender as MaskedTextBox).Text = "252"; + int evtotal, HP_EV, ATK_EV, DEF_EV, SPA_EV, SPD_EV, SPE_EV; HP_EV = Util.ToInt32(TB_HPEV.Text); ATK_EV = Util.ToInt32(TB_ATKEV.Text); @@ -2565,7 +1661,6 @@ private void updateEVs(object sender, EventArgs e) SPE_EV = Util.ToInt32(TB_SPEEV.Text); int[] eva = new int[] { HP_EV, ATK_EV, DEF_EV, SPA_EV, SPD_EV, SPE_EV }; - MaskedTextBox[] evt = { TB_HPEV, TB_ATKEV, TB_DEFEV, TB_SPAEV, TB_SPDEV, TB_SPEEV }; evtotal = HP_EV + ATK_EV + DEF_EV + SPA_EV + SPD_EV + SPE_EV; @@ -2613,30 +1708,16 @@ private void updateRandomEVs(object sender, EventArgs e) TB_SPEEV.Text = 0.ToString(); return; } - - MaskedTextBox[] tbEV = { TB_HPEV, TB_ATKEV, TB_DEFEV, TB_SPAEV, TB_SPDEV, TB_SPEEV }; - MaskedTextBox[] slEV = Util.shuffle((MaskedTextBox[])tbEV.Clone()); // Shuffle List - - uint e1 = Math.Min(Util.rnd32() % 300, 252); // bias two to get maybe 252 - uint e2 = Math.Min(Util.rnd32() % 300, 252); - - uint e3 = Math.Min(((Util.rnd32()) % (510 - e1 - e2)), 252); - uint e4 = Math.Min(((Util.rnd32()) % (510 - e1 - e2 - e3)), 252); - uint e5 = Math.Min(((Util.rnd32()) % (510 - e1 - e2 - e3 - e4)), 252); - uint e6 = Math.Min((510 - e1 - e2 - e3 - e4 - e5), 252); - - if (e1 + e2 + e3 + e4 + e5 + e6 < 510) + else { - updateRandomEVs(sender, e); - return; + byte[] evs = PKX.getRandomEVs(); + TB_HPEV.Text = evs[0].ToString(); + TB_ATKEV.Text = evs[1].ToString(); + TB_DEFEV.Text = evs[2].ToString(); + TB_SPAEV.Text = evs[3].ToString(); + TB_SPDEV.Text = evs[4].ToString(); + TB_SPEEV.Text = evs[5].ToString(); } - - slEV[0].Text = e1.ToString(); - slEV[1].Text = e2.ToString(); - slEV[2].Text = e3.ToString(); - slEV[3].Text = e4.ToString(); - slEV[4].Text = e5.ToString(); - slEV[5].Text = e6.ToString(); } private void updateRandomPID(object sender, EventArgs e) { @@ -2660,7 +1741,8 @@ private void update255_MTB(object sender, EventArgs e) MaskedTextBox mtb = sender as MaskedTextBox; try { - mtb.Text = Math.Min(Util.ToInt32(mtb.Text), 255).ToString(); + if (Util.ToInt32((sender as MaskedTextBox).Text) > 255) + (sender as MaskedTextBox).Text = "255"; } catch { mtb.Text = "0"; } } @@ -2669,7 +1751,8 @@ private void update255_TB(object sender, EventArgs e) TextBox tb = sender as TextBox; try { - tb.Text = Math.Min(Util.ToInt32(tb.Text), 255).ToString(); + if (Util.ToInt32((sender as TextBox).Text) > 255) + (sender as TextBox).Text = "255"; } catch { tb.Text = "0"; } } @@ -3108,12 +2191,8 @@ private void updateLocations(int gameorigin) private void updateExtraByteValue(object sender, EventArgs e) { // Changed Extra Byte's Value - MaskedTextBox mtb = sender as MaskedTextBox; - try - { - mtb.Text = Math.Min(Util.ToInt32(mtb.Text), 255).ToString(); - } - catch { mtb.Text = "0"; } + if (Util.ToInt32((sender as MaskedTextBox).Text) > 255) + (sender as MaskedTextBox).Text = "255"; int value = Util.ToInt32(TB_ExtraByte.Text); int offset = Convert.ToInt32(CB_ExtraBytes.Text, 16); @@ -3272,7 +2351,7 @@ private void updateShinyPID(object sender, EventArgs e) setIsShiny(); } - private void updateTIDSID(object sender, EventArgs e) + private void update_ID(object sender, EventArgs e) { // Trim out nonhex characters TB_PID.Text = Util.getHEXval(TB_PID).ToString("X8"); @@ -3302,7 +2381,7 @@ private void validateComboBox2(object sender, EventArgs e) ComboBox cb = sender as ComboBox; validateComboBox(sender, e as CancelEventArgs); if (cb == CB_Ability) - updateAbilityNumber(); + TB_AbilityNumber.Text = (1 << CB_Ability.SelectedIndex).ToString(); else if ((cb == CB_Move1) || (cb == CB_Move2) || (cb == CB_Move3) || (cb == CB_Move4)) updatePP(sender, e); @@ -3314,27 +2393,11 @@ private void removedropCB(object sender, KeyEventArgs e) } private void updateStats() { - // First verify that our input stats are valid. - MaskedTextBox[] mbIV = new MaskedTextBox[] { - TB_HPIV, TB_ATKIV, TB_DEFIV, TB_SPAIV, TB_SPDIV, TB_SPEIV, - }; - MaskedTextBox[] mbEV = new MaskedTextBox[] { - TB_HPEV, TB_ATKEV, TB_DEFEV, TB_SPAEV, TB_SPDEV, TB_SPEEV, - }; - for (int i = 0; i < 6; i++) - if ( - Util.ToInt32(mbIV[i].Text) > 31 - || (Util.ToInt32(mbEV[i].Text) > 252 && !CHK_HackedStats.Checked) - || (CHK_HackedStats.Checked && Util.ToInt32(mbEV[i].Text) > 255) - ) - return; // if anything is illegal, don't calc stats. - - // EVs and IVs are valid, continue to generate the stats. + // Gather the needed information. species = Util.getIndex(CB_Species); - int level = Util.ToInt32(TB_Level.Text); - if (MT_Level.Enabled) level = Util.ToInt32(MT_Level.Text); + int level = Util.ToInt32(TB_Level.Text); if (MT_Level.Enabled) level = Util.ToInt32(MT_Level.Text); if (level == 0) { level = 1; } - DataTable spectable = PKX.SpeciesTable(); + int form = CB_Form.SelectedIndex; int HP_IV = Util.ToInt32(TB_HPIV.Text); int ATK_IV = Util.ToInt32(TB_ATKIV.Text); int DEF_IV = Util.ToInt32(TB_DEFIV.Text); @@ -3348,204 +2411,43 @@ private void updateStats() int SPA_EV = Util.ToInt32(TB_SPAEV.Text); int SPD_EV = Util.ToInt32(TB_SPDEV.Text); int SPE_EV = Util.ToInt32(TB_SPEEV.Text); - - int HP_B = (int)spectable.Rows[species][2]; - int ATK_B = (int)spectable.Rows[species][3]; - int DEF_B = (int)spectable.Rows[species][4]; - int SPA_B = (int)spectable.Rows[species][5]; - int SPD_B = (int)spectable.Rows[species][6]; - int SPE_B = (int)spectable.Rows[species][7]; - - int form = CB_Form.SelectedIndex; - // Form Stat Recalculation - if (form != 0) - { - if ((form == 1) && (species == 3)) { HP_B = 80; ATK_B = 100; DEF_B = 123; SPA_B = 122; SPD_B = 120; SPE_B = 80; } - else if ((form == 1) && (species == 6)) { HP_B = 78; ATK_B = 130; DEF_B = 111; SPA_B = 130; SPD_B = 85; SPE_B = 100; } - else if ((form == 2) && (species == 6)) { HP_B = 78; ATK_B = 104; DEF_B = 78; SPA_B = 159; SPD_B = 115; SPE_B = 100; } - else if ((form == 1) && (species == 9)) { HP_B = 79; ATK_B = 103; DEF_B = 120; SPA_B = 135; SPD_B = 115; SPE_B = 78; } - else if ((form == 1) && (species == 65)) { HP_B = 55; ATK_B = 50; DEF_B = 65; SPA_B = 175; SPD_B = 95; SPE_B = 150; } - else if ((form == 1) && (species == 94)) { HP_B = 60; ATK_B = 65; DEF_B = 80; SPA_B = 170; SPD_B = 95; SPE_B = 130; } - else if ((form == 1) && (species == 115)) { HP_B = 105; ATK_B = 125; DEF_B = 100; SPA_B = 60; SPD_B = 100; SPE_B = 100; } - else if ((form == 1) && (species == 127)) { HP_B = 65; ATK_B = 155; DEF_B = 120; SPA_B = 65; SPD_B = 90; SPE_B = 105; } - else if ((form == 1) && (species == 130)) { HP_B = 95; ATK_B = 155; DEF_B = 109; SPA_B = 70; SPD_B = 130; SPE_B = 81; } - else if ((form == 1) && (species == 142)) { HP_B = 80; ATK_B = 135; DEF_B = 85; SPA_B = 70; SPD_B = 95; SPE_B = 150; } - else if ((form == 1) && (species == 150)) { HP_B = 106; ATK_B = 190; DEF_B = 100; SPA_B = 154; SPD_B = 100; SPE_B = 130; } - else if ((form == 2) && (species == 150)) { HP_B = 106; ATK_B = 150; DEF_B = 70; SPA_B = 194; SPD_B = 120; SPE_B = 140; } - else if ((form == 1) && (species == 181)) { HP_B = 90; ATK_B = 95; DEF_B = 105; SPA_B = 165; SPD_B = 110; SPE_B = 45; } - else if ((form == 1) && (species == 212)) { HP_B = 70; ATK_B = 150; DEF_B = 140; SPA_B = 65; SPD_B = 100; SPE_B = 75; } - else if ((form == 1) && (species == 214)) { HP_B = 80; ATK_B = 185; DEF_B = 115; SPA_B = 40; SPD_B = 105; SPE_B = 75; } - else if ((form == 1) && (species == 229)) { HP_B = 75; ATK_B = 90; DEF_B = 90; SPA_B = 140; SPD_B = 90; SPE_B = 115; } - else if ((form == 1) && (species == 248)) { HP_B = 100; ATK_B = 164; DEF_B = 150; SPA_B = 95; SPD_B = 120; SPE_B = 71; } - else if ((form == 1) && (species == 257)) { HP_B = 80; ATK_B = 160; DEF_B = 80; SPA_B = 130; SPD_B = 80; SPE_B = 100; } - else if ((form == 1) && (species == 282)) { HP_B = 68; ATK_B = 85; DEF_B = 65; SPA_B = 165; SPD_B = 135; SPE_B = 100; } - else if ((form == 1) && (species == 303)) { HP_B = 50; ATK_B = 105; DEF_B = 125; SPA_B = 55; SPD_B = 95; SPE_B = 50; } - else if ((form == 1) && (species == 306)) { HP_B = 70; ATK_B = 140; DEF_B = 230; SPA_B = 60; SPD_B = 80; SPE_B = 50; } - else if ((form == 1) && (species == 308)) { HP_B = 60; ATK_B = 100; DEF_B = 85; SPA_B = 80; SPD_B = 85; SPE_B = 100; } - else if ((form == 1) && (species == 310)) { HP_B = 70; ATK_B = 75; DEF_B = 80; SPA_B = 135; SPD_B = 80; SPE_B = 135; } - else if ((form == 1) && (species == 354)) { HP_B = 64; ATK_B = 165; DEF_B = 75; SPA_B = 93; SPD_B = 83; SPE_B = 75; } - else if ((form == 1) && (species == 359)) { HP_B = 65; ATK_B = 150; DEF_B = 60; SPA_B = 115; SPD_B = 60; SPE_B = 115; } - else if ((form == 1) && (species == 380)) { HP_B = 80; ATK_B = 100; DEF_B = 120; SPA_B = 140; SPD_B = 150; SPE_B = 110; } - else if ((form == 1) && (species == 381)) { HP_B = 80; ATK_B = 130; DEF_B = 100; SPA_B = 160; SPD_B = 120; SPE_B = 110; } - else if ((form == 1) && (species == 386)) { HP_B = 50; ATK_B = 180; DEF_B = 20; SPA_B = 180; SPD_B = 20; SPE_B = 150; } - else if ((form == 2) && (species == 386)) { HP_B = 50; ATK_B = 70; DEF_B = 160; SPA_B = 70; SPD_B = 160; SPE_B = 90; } - else if ((form == 3) && (species == 386)) { HP_B = 50; ATK_B = 95; DEF_B = 90; SPA_B = 95; SPD_B = 90; SPE_B = 180; } - else if ((form == 1) && (species == 413)) { HP_B = 60; ATK_B = 79; DEF_B = 105; SPA_B = 59; SPD_B = 85; SPE_B = 36; } - else if ((form == 2) && (species == 413)) { HP_B = 60; ATK_B = 69; DEF_B = 95; SPA_B = 69; SPD_B = 95; SPE_B = 36; } - else if ((form == 1) && (species == 445)) { HP_B = 108; ATK_B = 170; DEF_B = 115; SPA_B = 120; SPD_B = 95; SPE_B = 92; } - else if ((form == 1) && (species == 448)) { HP_B = 70; ATK_B = 145; DEF_B = 88; SPA_B = 140; SPD_B = 70; SPE_B = 112; } - else if ((form == 1) && (species == 460)) { HP_B = 90; ATK_B = 132; DEF_B = 105; SPA_B = 132; SPD_B = 105; SPE_B = 30; } - else if ((form == 1) && (species == 487)) { HP_B = 150; ATK_B = 120; DEF_B = 100; SPA_B = 120; SPD_B = 100; SPE_B = 90; } - else if ((form == 1) && (species == 492)) { HP_B = 100; ATK_B = 103; DEF_B = 75; SPA_B = 120; SPD_B = 75; SPE_B = 127; } - else if ((form == 1) && (species == 555)) { HP_B = 105; ATK_B = 30; DEF_B = 105; SPA_B = 140; SPD_B = 105; SPE_B = 55; } - else if ((form == 1) && (species == 641)) { HP_B = 79; ATK_B = 100; DEF_B = 80; SPA_B = 110; SPD_B = 90; SPE_B = 121; } - else if ((form == 1) && (species == 642)) { HP_B = 79; ATK_B = 105; DEF_B = 70; SPA_B = 145; SPD_B = 80; SPE_B = 101; } - else if ((form == 1) && (species == 645)) { HP_B = 89; ATK_B = 145; DEF_B = 90; SPA_B = 105; SPD_B = 80; SPE_B = 91; } - else if ((form == 1) && (species == 646)) { HP_B = 125; ATK_B = 120; DEF_B = 90; SPA_B = 170; SPD_B = 100; SPE_B = 95; } // white - else if ((form == 2) && (species == 646)) { HP_B = 125; ATK_B = 170; DEF_B = 100; SPA_B = 120; SPD_B = 90; SPE_B = 95; } // black - else if ((form == 1) && (species == 648)) { HP_B = 100; ATK_B = 128; DEF_B = 90; SPA_B = 77; SPD_B = 77; SPE_B = 128; } - else if ((form == 5) && (species == 670)) { HP_B = 74; ATK_B = 65; DEF_B = 67; SPA_B = 125; SPD_B = 128; SPE_B = 92; } - else if ((form == 1) && (species == 681)) { HP_B = 60; ATK_B = 150; DEF_B = 50; SPA_B = 150; SPD_B = 50; SPE_B = 60; } - else if ((form == 1) && (species == 710)) { HP_B = 49; ATK_B = 66; DEF_B = 70; SPA_B = 44; SPD_B = 55; SPE_B = 51; } - else if ((form == 2) && (species == 710)) { HP_B = 54; ATK_B = 66; DEF_B = 70; SPA_B = 44; SPD_B = 55; SPE_B = 46; } - else if ((form == 3) && (species == 710)) { HP_B = 59; ATK_B = 66; DEF_B = 70; SPA_B = 44; SPD_B = 55; SPE_B = 41; } - else if ((form == 1) && (species == 711)) { HP_B = 65; ATK_B = 90; DEF_B = 122; SPA_B = 58; SPD_B = 75; SPE_B = 84; } - else if ((form == 2) && (species == 711)) { HP_B = 75; ATK_B = 95; DEF_B = 122; SPA_B = 58; SPD_B = 75; SPE_B = 69; } - else if ((form == 3) && (species == 711)) { HP_B = 85; ATK_B = 100; DEF_B = 122; SPA_B = 58; SPD_B = 75; SPE_B = 54; } - - // ORAS Stats - else if ((form == 1) && (species == 382)) { HP_B = 100; ATK_B = 150; DEF_B = 90; SPA_B = 180; SPD_B = 160; SPE_B = 90; } // Primal Kyogre - else if ((form == 1) && (species == 383)) { HP_B = 100; ATK_B = 180; DEF_B = 160; SPA_B = 150; SPD_B = 90; SPE_B = 90; } // Primal - - else if ((form == 1) && (species == 015)) { HP_B = 65; ATK_B = 150; DEF_B = 40; SPA_B = 15; SPD_B = 80; SPE_B = 145; } // Beedrill - else if ((form == 1) && (species == 018)) { HP_B = 83; ATK_B = 80; DEF_B = 83; SPA_B = 135; SPD_B = 80; SPE_B = 121; } // Pidgeot - else if ((form == 1) && (species == 080)) { HP_B = 95; ATK_B = 75; DEF_B = 180; SPA_B = 130; SPD_B = 80; SPE_B = 30; } // Slowbro - else if ((form == 1) && (species == 208)) { HP_B = 75; ATK_B = 125; DEF_B = 230; SPA_B = 55; SPD_B = 95; SPE_B = 30; } // Steelix - else if ((form == 1) && (species == 254)) { HP_B = 70; ATK_B = 110; DEF_B = 75; SPA_B = 145; SPD_B = 85; SPE_B = 145; } // Sceptile - else if ((form == 1) && (species == 260)) { HP_B = 100; ATK_B = 150; DEF_B = 110; SPA_B = 95; SPD_B = 110; SPE_B = 70; } // Swampert - else if ((form == 1) && (species == 302)) { HP_B = 50; ATK_B = 85; DEF_B = 125; SPA_B = 85; SPD_B = 115; SPE_B = 20; } // Sableye - else if ((form == 1) && (species == 319)) { HP_B = 70; ATK_B = 140; DEF_B = 70; SPA_B = 110; SPD_B = 65; SPE_B = 105; } // Sharpedo - else if ((form == 1) && (species == 323)) { HP_B = 70; ATK_B = 120; DEF_B = 100; SPA_B = 145; SPD_B = 105; SPE_B = 20; } // Camerupt - else if ((form == 1) && (species == 334)) { HP_B = 75; ATK_B = 110; DEF_B = 110; SPA_B = 110; SPD_B = 105; SPE_B = 80; } // Altaria - else if ((form == 1) && (species == 362)) { HP_B = 80; ATK_B = 120; DEF_B = 80; SPA_B = 120; SPD_B = 80; SPE_B = 100; } // Glalie - else if ((form == 1) && (species == 373)) { HP_B = 95; ATK_B = 145; DEF_B = 130; SPA_B = 120; SPD_B = 90; SPE_B = 120; } // Salamence - else if ((form == 1) && (species == 376)) { HP_B = 80; ATK_B = 145; DEF_B = 150; SPA_B = 105; SPD_B = 110; SPE_B = 110; } // Metagross - else if ((form == 1) && (species == 384)) { HP_B = 105; ATK_B = 180; DEF_B = 100; SPA_B = 180; SPD_B = 100; SPE_B = 115; } // Rayquaza - else if ((form == 1) && (species == 428)) { HP_B = 65; ATK_B = 136; DEF_B = 94; SPA_B = 54; SPD_B = 96; SPE_B = 135; } // Lopunny - else if ((form == 1) && (species == 475)) { HP_B = 68; ATK_B = 165; DEF_B = 95; SPA_B = 65; SPD_B = 115; SPE_B = 110; } // Gallade - else if ((form == 1) && (species == 531)) { HP_B = 103; ATK_B = 60; DEF_B = 126; SPA_B = 80; SPD_B = 126; SPE_B = 50; } // Audino - else if ((form == 1) && (species == 719)) { HP_B = 50; ATK_B = 160; DEF_B = 110; SPA_B = 160; SPD_B = 110; SPE_B = 110; } // Diancie - - else if ((form == 1) && (species == 720)) { HP_B = 80; ATK_B = 160; DEF_B = 60; SPA_B = 170; SPD_B = 130; SPE_B = 80; } // Hoopa Unbound - } - // End Form Stat Recalc - - DataTable naturetable = PKX.NatureTable(); + int nature = Util.getIndex(CB_Nature); - int n1 = (int)naturetable.Rows[nature][1]; - int n2 = (int)naturetable.Rows[nature][2]; - int n3 = (int)naturetable.Rows[nature][4]; - int n4 = (int)naturetable.Rows[nature][5]; - int n5 = (int)naturetable.Rows[nature][3]; - Label[] labarray = new Label[] { Label_HP, Label_ATK, Label_DEF, Label_SPE, Label_SPA, Label_SPD }; - for (int i = 1; i < 6; i++) + // Generate the stats. + ushort[] stats = PKX.getStats(species, level, nature, form, + HP_EV, ATK_EV, DEF_EV, SPA_EV, SPD_EV, SPE_EV, + HP_IV, ATK_IV, DEF_IV, SPA_IV, SPD_IV, SPE_IV); + + Stat_HP.Text = stats[0].ToString(); + Stat_ATK.Text = stats[1].ToString(); + Stat_DEF.Text = stats[2].ToString(); + Stat_SPA.Text = stats[4].ToString(); + Stat_SPD.Text = stats[5].ToString(); + Stat_SPE.Text = stats[3].ToString(); + + // Recolor the Stat Labels based on boosted stats. + int incr = nature / 5; + int decr = nature % 5; + + Label[] labarray = new Label[] { Label_ATK, Label_DEF, Label_SPE, Label_SPA, Label_SPD }; + for (int i = 0; i < 5; i++) + labarray[i].ForeColor = DefaultForeColor; + + if (incr != decr) // if stat isn't neutral { - int val = (int)naturetable.Rows[nature][i]; - - if (val == 10) labarray[i].ForeColor = DefaultForeColor; - else if (val == 9) labarray[i].ForeColor = Color.Blue; - else if (val == 11) labarray[i].ForeColor = Color.Red; + labarray[incr].ForeColor = Color.Red; + labarray[decr].ForeColor = Color.Blue; } - - Stat_HP.Text = ((((HP_IV + (2 * HP_B) + (HP_EV / 4) + 100) * level) / 100) + 10).ToString(); - Stat_ATK.Text = ((((((ATK_IV + (2 * ATK_B) + (ATK_EV / 4)) * level) / 100) + 5) * n1) / 10).ToString(); - Stat_DEF.Text = ((((((DEF_IV + (2 * DEF_B) + (DEF_EV / 4)) * level) / 100) + 5) * n2) / 10).ToString(); - Stat_SPA.Text = ((((((SPA_IV + (2 * SPA_B) + (SPA_EV / 4)) * level) / 100) + 5) * n3) / 10).ToString(); - Stat_SPD.Text = ((((((SPD_IV + (2 * SPD_B) + (SPD_EV / 4)) * level) / 100) + 5) * n4) / 10).ToString(); - Stat_SPE.Text = ((((((SPE_IV + (2 * SPE_B) + (SPE_EV / 4)) * level) / 100) + 5) * n5) / 10).ToString(); } public void updateAbilityList(MaskedTextBox tb_abil, int species, ComboBox cb_abil, ComboBox cb_forme) { if (!init) return; int newabil = Convert.ToInt16(tb_abil.Text) >> 1; - int[] abils = { 0, 0, 0 }; - // - // Alternate Forms have different abilities. We must account for them! - // - if (cb_forme.SelectedIndex > 0) - { - int formnum = cb_forme.SelectedIndex; - - // Previous Games - if (species == 492 && formnum == 1) { species = 727; } // Shaymin Sky - else if (species == 487 && formnum == 1) { species = 728; } // Giratina-O - else if (species == 550 && formnum == 1) { species = 738; } // Basculin Blue - else if (species == 646 && formnum == 1) { species = 741; } // Kyurem White - else if (species == 646 && formnum == 2) { species = 742; } // Kyurem Black - else if (species == 641 && formnum == 1) { species = 744; } // Tornadus-T - else if (species == 642 && formnum == 1) { species = 745; } // Thundurus-T - else if (species == 645 && formnum == 1) { species = 746; } // Landorus-T - - // XY - else if (species == 678 && formnum == 1) { species = 748; } // Meowstic Female - else if (species == 094 && formnum == 1) { species = 747; } // Mega Gengar - else if (species == 282 && formnum == 1) { species = 758; } // Mega Gardevoir - else if (species == 181 && formnum == 1) { species = 759; } // Mega Ampharos - else if (species == 003 && formnum == 1) { species = 760; } // Mega Venusaur - else if (species == 006 && formnum == 1) { species = 761; } // Mega Charizard X - else if (species == 006 && formnum == 2) { species = 762; } // Mega Charizard Y - else if (species == 150 && formnum == 1) { species = 763; } // Mega MewtwoX - else if (species == 150 && formnum == 2) { species = 764; } // Mega MewtwoY - else if (species == 257 && formnum == 1) { species = 765; } // Mega Blaziken - else if (species == 308 && formnum == 1) { species = 766; } // Mega Medicham - else if (species == 229 && formnum == 1) { species = 767; } // Mega Houndoom - else if (species == 306 && formnum == 1) { species = 768; } // Mega Aggron - else if (species == 354 && formnum == 1) { species = 769; } // Mega Banette - else if (species == 248 && formnum == 1) { species = 770; } // Mega Tyranitar - else if (species == 212 && formnum == 1) { species = 771; } // Mega Scizor - else if (species == 127 && formnum == 1) { species = 772; } // Mega Pinsir - else if (species == 142 && formnum == 1) { species = 773; } // Mega Aerodactyl - else if (species == 448 && formnum == 1) { species = 774; } // Mega Lucario - else if (species == 460 && formnum == 1) { species = 775; } // Mega Abomasnow - else if (species == 009 && formnum == 1) { species = 777; } // Mega Blastoise - else if (species == 115 && formnum == 1) { species = 778; } // Mega Kangaskhan - else if (species == 130 && formnum == 1) { species = 779; } // Mega Gyarados - else if (species == 359 && formnum == 1) { species = 780; } // Mega Absol - else if (species == 065 && formnum == 1) { species = 781; } // Mega Alakazam - else if (species == 214 && formnum == 1) { species = 782; } // Mega Heracross - else if (species == 303 && formnum == 1) { species = 783; } // Mega Mawile - else if (species == 310 && formnum == 1) { species = 784; } // Mega Manectric - else if (species == 445 && formnum == 1) { species = 785; } // Mega Garchomp - else if (species == 381 && formnum == 1) { species = 786; } // Mega Latios - else if (species == 380 && formnum == 1) { species = 787; } // Mega Latias - - // ORAS - else if (species == 382 && formnum == 1) { species = 812; } // Primal Kyogre - else if (species == 383 && formnum == 1) { species = 813; } // Primal Groudon - else if (species == 720 && formnum == 1) { species = 821; } // Hoopa Unbound - else if (species == 015 && formnum == 1) { species = 825; } // Mega Beedrill - else if (species == 018 && formnum == 1) { species = 808; } // Mega Pidgeot - else if (species == 080 && formnum == 1) { species = 806; } // Mega Slowbro - else if (species == 208 && formnum == 1) { species = 807; } // Mega Steelix - else if (species == 254 && formnum == 1) { species = 800; } // Mega Sceptile - else if (species == 260 && formnum == 1) { species = 799; } // Mega Swampert - else if (species == 302 && formnum == 1) { species = 801; } // Mega Sableye - else if (species == 319 && formnum == 1) { species = 805; } // Mega Sharpedo - else if (species == 323 && formnum == 1) { species = 822; } // Mega Camerupt - else if (species == 334 && formnum == 1) { species = 802; } // Mega Altaria - else if (species == 362 && formnum == 1) { species = 809; } // Mega Glalie - else if (species == 373 && formnum == 1) { species = 824; } // Mega Salamence - else if (species == 376 && formnum == 1) { species = 811; } // Mega Metagross - else if (species == 384 && formnum == 1) { species = 814; } // Mega Rayquaza - else if (species == 428 && formnum == 1) { species = 823; } // Mega Lopunny - else if (species == 475 && formnum == 1) { species = 803; } // Mega Gallade - else if (species == 531 && formnum == 1) { species = 804; } // Mega Audino - else if (species == 719 && formnum == 1) { species = 810; } // Mega Diancie - } - Array.Copy(speciesability, species * 4 + 1, abils, 0, 3); + int form = cb_forme.SelectedIndex; + int[] abils = PKX.getAbilities(species, form); // Build Ability List List ability_list = new List(); @@ -3557,10 +2459,6 @@ public void updateAbilityList(MaskedTextBox tb_abil, int species, ComboBox cb_ab if (newabil < 3) cb_abil.SelectedIndex = newabil; else cb_abil.SelectedIndex = 0; } - private void updateAbilityNumber() - { - TB_AbilityNumber.Text = (1 << CB_Ability.SelectedIndex).ToString(); - } // Main Menu Strip UI Functions // private void mainmenuOpen(object sender, EventArgs e) { @@ -3618,9 +2516,7 @@ private void mainmenuSave(object sender, EventArgs e) } else { - string message = "Foreign File Extension. Exporting as encrypted."; - string caption = "Error Detected in Input"; - MessageBox.Show(message, caption); + Util.Error("Foreign File Extension", "Exporting as encrypted."); pkx = PKX.encryptArray(pkx); File.WriteAllBytes(path, pkx); } @@ -3664,7 +2560,7 @@ private void mainmenuCodeGen(object sender, EventArgs e) { Array.Copy(new Byte[232], buff, 232); populateFields(buff); - MessageBox.Show("Imported code did not decrypt properly. Verify that what you imported was correct.", "Error"); + Util.Error("Imported code did not decrypt properly", "Please verify that what you imported was correct."); } } } @@ -3685,13 +2581,12 @@ private void openQuick(string path) string ext = Path.GetExtension(path); FileInfo fi = new FileInfo(path); if (fi.Length > 0x10009C) - MessageBox.Show("Input file is too large.\n\n" + path, "Alert"); - + Util.Error("Input file is too large.", path); else { byte[] input; try { input = File.ReadAllBytes(path); } - catch { MessageBox.Show("File is in use!\n\n"+path,"Error"); return; } + catch { Util.Error("File is in use by another program!", path); return; } try { openFile(input, path, ext); } catch @@ -3712,21 +2607,21 @@ private void openQuick(string path) private void openFile(byte[] input, string path, string ext) { #region Powersaves Read-Only Conversion - if (input.Length == 0x10009C) + if (input.Length == 0x10009C) // Resize to 1MB { Array.Copy(input, 0x9C, input, 0, 0x100000); Array.Resize(ref input, 0x100000); } #endregion #region Trade Packets - if ((input.Length == 363) && (input[0x6B] == 0) && (input[0x6C] == 00)) + if (input.Length == 363 && BitConverter.ToUInt16(input, 0x6B) == 0) { // EAD Packet of 363 length byte[] c = new Byte[260]; Array.Copy(input, 0x67, c, 0, 260); input = c; } - else if ((input.Length == 407) && (input[0x98] == 0) && (input[0x99] == 00)) + else if (input.Length == 407 && BitConverter.ToUInt16(input,0x98) == 0) { // EAD Packet of 407 length byte[] c = new Byte[260]; @@ -3749,10 +2644,10 @@ private void openFile(byte[] input, string path, string ext) if (BitConverter.ToUInt32(input, 0x7B210) == 0x42454546) GameType = "ORAS"; // BEEF magic in checksum block if ((BitConverter.ToUInt32(input, 0x100) != 0x41534944) && (BitConverter.ToUInt32(input, 0x5234) != 0x6E69616D)) { - DialogResult dialogResult = MessageBox.Show("Save file is not decrypted.\r\n\r\nPress Yes to ignore this warning and continue loading the save file.", "Error", MessageBoxButtons.YesNo); + DialogResult dialogResult = Util.Prompt(MessageBoxButtons.YesNo, "Save file is not decrypted.", "Press Yes to ignore this warning and continue loading the save file."); if (dialogResult == DialogResult.Yes) { - DialogResult sdr = MessageBox.Show("Press Yes to load the sav at 0x3000, No for the one at 0x82000", "Prompt", MessageBoxButtons.YesNoCancel); + DialogResult sdr = Util.Prompt(MessageBoxButtons.YesNoCancel, "Press Yes to load the sav at 0x3000", "Press No for the one at 0x82000"); if (sdr == DialogResult.Cancel) return; else if (sdr == DialogResult.Yes) @@ -3767,10 +2662,10 @@ private void openFile(byte[] input, string path, string ext) } else if (PKX.detectSAVIndex(input, ref savindex) == 2) { - DialogResult dialogResult = MessageBox.Show("Hash verification failed.\r\n\r\nPress Yes to ignore this warning and continue loading the save file.", "Error", MessageBoxButtons.YesNo); + DialogResult dialogResult = Util.Prompt(MessageBoxButtons.YesNo, "Hash verification failed.", "Press Yes to ignore this warning and continue loading the save file."); if (dialogResult == DialogResult.Yes) { - DialogResult sdr = MessageBox.Show("Press Yes to load the sav at 0x3000, No for the one at 0x82000", "Prompt", MessageBoxButtons.YesNoCancel); + DialogResult sdr = Util.Prompt(MessageBoxButtons.YesNoCancel, "Press Yes to load the sav at 0x3000", "Press No for the one at 0x82000"); if (sdr == DialogResult.Cancel) { savindex = 0; @@ -3816,18 +2711,14 @@ private void openFile(byte[] input, string path, string ext) } } else - { - string message = "Foreign File.\nOnly valid .pk* .ek* .bin supported."; - string caption = "Error Detected in Input"; - MessageBox.Show(message, caption); - } + Util.Error("Unable to recognize file.", "Only valid .pk* .ek* .bin supported."); } #endregion #region PK3/PK4/PK5 else if ((input.Length == 136) || (input.Length == 220) || (input.Length == 236) || (input.Length == 100) || (input.Length == 80)) // to convert g5pkm { var Converter = new pk2pk(); - if (!PKX.verifychk(input)) MessageBox.Show("Invalid File (Checksum Error)", "Error"); + if (!PKX.verifychk(input)) Util.Error("Invalid File (Checksum Error)"); try // to convert g5pkm { byte[] data = Converter.ConvertPKM(input, savefile, savindex); @@ -3838,18 +2729,12 @@ private void openFile(byte[] input, string path, string ext) { Array.Copy(new Byte[232], buff, 232); populateFields(buff); - string message = "Attempted to load previous generation PKM.\n\nConversion failed."; - string caption = "Alert"; - MessageBox.Show(message, caption); + Util.Error("Attempted to load previous generation PKM.", "Conversion failed."); } } #endregion else - { - string message = "Attempted to load an unsupported file type/size."; - string caption = "Error"; - MessageBox.Show(message, caption); - } + Util.Error("Attempted to load an unsupported file type/size.", "File Loaded:" + System.Environment.NewLine + path); } private void openMAIN(byte[] input, string path, string GameType, bool oras) { @@ -3980,10 +2865,10 @@ public bool verifiedpkx() public byte[] preparepkx(byte[] buff) { tabMain.Select(); // hack to make sure comboboxes are set (users scrolling through and immediately setting causes this) - // Stuff the Buff + // Stuff the global byte array with our PKX form data // Create a new storage so we don't muck up things with the original - byte[] pkx = buff; - // if (getHEXval(TB_EC) == 0) BTN_RerollEC.PerformClick(); + byte[] pkx = new byte[0x104]; + Array.Copy(buff, pkx, 0x104); // Repopulate PKX with Edited Stuff if (Util.getIndex(CB_GameOrigin) < 24) { @@ -4025,9 +2910,9 @@ public byte[] preparepkx(byte[] buff) Array.Copy(BitConverter.GetBytes(Util.getHEXval(TB_PID)), 0, pkx, 0x18, 4); // PID pkx[0x1C] = (byte)((Util.getIndex(CB_Nature))); // Nature int fegform = (int)(Convert.ToInt32(CHK_Fateful.Checked)); // Fateful - fegform += (PKX.getGender(Label_Gender.Text) << 1); // Gender - if (MT_Form.Enabled) fegform += (Math.Min(Convert.ToInt32(MT_Form.Text), 32) * 8); // Form - else fegform += ((Util.getIndex(CB_Form)) * 8); + fegform |= (PKX.getGender(Label_Gender.Text) << 1); // Gender + if (MT_Form.Enabled) fegform |= (Math.Min(Convert.ToInt32(MT_Form.Text), 32) << 3); // Form + else fegform |= ((Util.getIndex(CB_Form)) << 3); pkx[0x1D] = (byte)fegform; pkx[0x1E] = (byte)(Util.ToInt32(TB_HPEV.Text) & 0xFF); // EVs pkx[0x1F] = (byte)(Util.ToInt32(TB_ATKEV.Text) & 0xFF); @@ -4074,7 +2959,7 @@ public byte[] preparepkx(byte[] buff) nicknamestr = Regex.Replace(nicknamestr, "\u2642", "\uE08E"); } byte[] nicknamebytes = Encoding.Unicode.GetBytes(nicknamestr); - Array.Resize(ref nicknamebytes, 24); + Array.Resize(ref nicknamebytes, 24); // pad with zeroes and effectively keep no trash bytes Array.Copy(nicknamebytes, 0, pkx, 0x40, nicknamebytes.Length); // 0x58, 0x59 unused @@ -4240,7 +3125,7 @@ public byte[] preparepkx(byte[] buff) // Now we fix the checksum! ushort chk = 0; for (int i = 8; i < 232; i += 2) // Loop through the entire PKX - chk += BitConverter.ToUInt16(buff, i); + chk += BitConverter.ToUInt16(pkx, i); // Apply New Checksum Array.Copy(BitConverter.GetBytes(chk), 0, pkx, 06, 2); @@ -4287,8 +3172,8 @@ private void dragout_MouseDown(object sender, MouseEventArgs e) dragout.DoDragDrop(new DataObject(DataFormats.FileDrop, filesToDrag), DragDropEffects.Move); File.Delete(newfile); } - catch (ArgumentException x) - { MessageBox.Show("Drag&Drop Error\n\n" + x, "Error"); } + catch (Exception x) + { Util.Error("Drag & Drop Error", x.ToString()); } File.Delete(newfile); } } @@ -4325,10 +3210,8 @@ private void eragout_MouseDown(object sender, MouseEventArgs e) dragout.DoDragDrop(new DataObject(DataFormats.FileDrop, filesToDrag), DragDropEffects.Move); File.Delete(newfile); } - catch (ArgumentException x) - { - MessageBox.Show("Drag&Drop Error\n\n" + x, "Error"); - } + catch (Exception x) + { Util.Error("Drag & Drop Error", x.ToString()); } File.Delete(newfile); } } @@ -4353,7 +3236,7 @@ private void B_VerifyCHK_Click(object sender, EventArgs e) { if (savedited) { - RTB_S.Text = "Save has been edited.\r\nCannot integrity check."; + RTB_S.Text = "Save has been edited. Cannot integrity check."; return; } // Verify Checksums @@ -4379,10 +3262,10 @@ private void B_VerifyCHK_Click(object sender, EventArgs e) if (checksum != actualsum) { invalid1++; - RTB_S.Text += "Invalid: " + i.ToString("X2") + " @ region " + start[i].ToString("X5") + "\r\n"; + RTB_S.Text += "Invalid: " + i.ToString("X2") + " @ region " + start[i].ToString("X5") + System.Environment.NewLine; } } - RTB_S.Text += "1st SAV: " + (start.Length - invalid1).ToString() + "/" + start.Length.ToString() + "\r\n"; + RTB_S.Text += "1st SAV: " + (start.Length - invalid1).ToString() + "/" + start.Length.ToString() + System.Environment.NewLine; if (cybergadget) return; @@ -4402,10 +3285,10 @@ private void B_VerifyCHK_Click(object sender, EventArgs e) if (checksum != actualsum) { invalid2++; - RTB_S.Text += "Invalid: " + i.ToString("X2") + " @ region " + start[i].ToString("X5") + "\r\n"; + RTB_S.Text += "Invalid: " + i.ToString("X2") + " @ region " + start[i].ToString("X5") + System.Environment.NewLine; } } - RTB_S.Text += "2nd SAV: " + (start.Length - invalid2).ToString() + "/" + start.Length.ToString() + "\r\n"; + RTB_S.Text += "2nd SAV: " + (start.Length - invalid2).ToString() + "/" + start.Length.ToString() + System.Environment.NewLine; if (invalid1 + invalid2 == (start.Length * 2)) RTB_S.Text = "No checksums are valid."; } @@ -4413,7 +3296,7 @@ private void B_VerifySHA_Click(object sender, EventArgs e) { if (savedited) { - RTB_S.Text = "Save has been edited.\r\nCannot integrity check."; + RTB_S.Text = "Save has been edited. Cannot integrity check."; return; } // Verify Hashes @@ -4547,10 +3430,10 @@ private void B_VerifySHA_Click(object sender, EventArgs e) if (!hashValue.SequenceEqual(actualhash)) { invalid1++; - RTB_S.Text += "Invalid: " + hashtabledata[2 + 4 * i].ToString("X5") + " @ " + hashtabledata[0 + 4 * i].ToString("X5") + "-" + hashtabledata[1 + 4 * i].ToString("X5") + "\r\n"; + RTB_S.Text += "Invalid: " + hashtabledata[2 + 4 * i].ToString("X5") + " @ " + hashtabledata[0 + 4 * i].ToString("X5") + "-" + hashtabledata[1 + 4 * i].ToString("X5") + System.Environment.NewLine; } } - RTB_S.Text += "1st SAV: " + (106 - invalid1).ToString() + "/" + 106.ToString() + "\r\n"; + RTB_S.Text += "1st SAV: " + (106 - invalid1).ToString() + "/" + 106.ToString() + System.Environment.NewLine; // Check The Second Half of Hashes for (int i = 0; i < hashtabledata.Length; i += 4) @@ -4583,13 +3466,13 @@ private void B_VerifySHA_Click(object sender, EventArgs e) if (!hashValue.SequenceEqual(actualhash)) { invalid2++; - RTB_S.Text += "Invalid: " + hashtabledata[2 + 4 * i].ToString("X5") + " @ " + hashtabledata[0 + 4 * i].ToString("X5") + "-" + hashtabledata[1 + 4 * i].ToString("X5") + "\r\n"; + RTB_S.Text += "Invalid: " + hashtabledata[2 + 4 * i].ToString("X5") + " @ " + hashtabledata[0 + 4 * i].ToString("X5") + "-" + hashtabledata[1 + 4 * i].ToString("X5") + System.Environment.NewLine; } } - RTB_S.Text += "2nd SAV: " + (106 - invalid2).ToString() + "/" + 106.ToString() + "\r\n"; + RTB_S.Text += "2nd SAV: " + (106 - invalid2).ToString() + "/" + 106.ToString() + System.Environment.NewLine; if (invalid1 + invalid2 == (2 * 106)) - RTB_S.Text = "None of the IVFC hashes are valid." + "\r\n"; + RTB_S.Text = "None of the IVFC hashes are valid." + System.Environment.NewLine; // Check the Upper Level IVFC Hashes { @@ -4600,7 +3483,7 @@ private void B_VerifySHA_Click(object sender, EventArgs e) Array.Copy(savefile, 0x43C, actualhash, 0, 0x20); if (!hashValue.SequenceEqual(actualhash)) { - RTB_S.Text += "Invalid: " + 0x2000.ToString("X5") + " @ " + 0x43C.ToString("X3") + "\r\n"; + RTB_S.Text += "Invalid: " + 0x2000.ToString("X5") + " @ " + 0x43C.ToString("X3") + System.Environment.NewLine; } } { @@ -4611,7 +3494,7 @@ private void B_VerifySHA_Click(object sender, EventArgs e) Array.Copy(savefile, 0x30C, actualhash, 0, 0x20); if (!hashValue.SequenceEqual(actualhash)) { - RTB_S.Text += "Invalid: " + 0x81000.ToString("X5") + " @ " + 0x30C.ToString("X3") + "\r\n"; + RTB_S.Text += "Invalid: " + 0x81000.ToString("X5") + " @ " + 0x30C.ToString("X3") + System.Environment.NewLine; } } { @@ -4885,18 +3768,17 @@ private void exportSAV(object sender, EventArgs e) if (section.SequenceEqual(FFFF)) { string problem = String.Format("0x200 chunk @ 0x{0} is FF'd.", (i * 0x200).ToString("X5")) - + "\nCyber will screw up (as of August 31st).\n\n"; + + System.Environment.NewLine + "Cyber will screw up (as of August 31st)." + System.Environment.NewLine + System.Environment.NewLine; // Check to see if it is in the Pokedex if (i * 0x200 > 0x14E00 && i * 0x200 < 0x15700) { - problem += "Problem lies in the Pokedex"; + problem += "Problem lies in the Pokedex. "; if (i * 0x200 == 0x15400) - problem += "\nRemove a language flag for a species.\n\n(dex#44-649)"; + problem += "Remove a language flag for a species ~ ex " + specieslist[548]; } - DialogResult dr = MessageBox.Show(problem + "\n\nContinue saving?", "Alert", MessageBoxButtons.YesNo); - - if (dr != DialogResult.Yes) + + if (Util.Prompt(MessageBoxButtons.YesNo, problem, "Continue saving?") != DialogResult.Yes) return; } } @@ -4930,7 +3812,7 @@ private void exportSAV(object sender, EventArgs e) { string path = cySAV.FileName; File.WriteAllBytes(path, cybersav); - MessageBox.Show("Saved Cyber SAV to:\n\n"+path, "Alert"); + Util.Alert("Saved Cyber SAV to:", path); } } else @@ -4951,7 +3833,7 @@ private void exportSAV(object sender, EventArgs e) File.WriteAllBytes(path + ".bak", backupfile); } File.WriteAllBytes(path, editedsav); - MessageBox.Show("Saved SAV.", "Alert"); + Util.Alert("Saved 1MB SAV to:", path); } } } @@ -5031,7 +3913,7 @@ private void rcmSet_Click(object sender, EventArgs e) { if (!verifiedpkx()) { return; } int slot = getSlot(sender); - if (slot == 30 && (CB_Species.SelectedIndex == 0 || CHK_IsEgg.Checked)) { MessageBox.Show("Can't have empty/egg first slot.", "Alert"); return; } + if (slot == 30 && (CB_Species.SelectedIndex == 0 || CHK_IsEgg.Checked)) { Util.Alert("Can't have empty/egg first slot."); return; } int offset = getPKXOffset(slot); byte[] pkxdata = preparepkx(buff); @@ -5046,16 +3928,17 @@ private void rcmSet_Click(object sender, EventArgs e) int move4 = BitConverter.ToInt16(pkxdata,0x60); int ability = pkxdata[0x14]; int item = BitConverter.ToInt16(pkxdata,0x0A); - DialogResult dr = new DialogResult(); + string err = ""; if (move1 > 617 || move2 > 617 || move3 > 617 || move4 > 617) - dr = MessageBox.Show("Move does not exist in X/Y.\n\nContinue?", "Alert", MessageBoxButtons.YesNo); + err = "Move does not exist in X/Y."; else if (ability > 188) - dr = MessageBox.Show("Ability does not exist in X/Y.\n\nContinue?", "Alert", MessageBoxButtons.YesNo); + err = "Ability does not exist in X/Y."; else if (item > 717) - dr = MessageBox.Show("Item does not exist in X/Y.\n\nContinue?", "Alert", MessageBoxButtons.YesNo); + err = "Item does not exist in X/Y."; else goto next; - if (dr != DialogResult.Yes) + + if (Util.Prompt(MessageBoxButtons.YesNo, err, "Continue?") != DialogResult.Yes) return; } next: @@ -5076,7 +3959,7 @@ private void rcmDelete_Click(object sender, EventArgs e) { byte partycount = setParty(); int slot = getSlot(sender); - if (slot == 30 && partycount == 1 && !DEV_Ability.Enabled) { MessageBox.Show("Can't delete first slot.", "Alert"); return; } + if (slot == 30 && partycount == 1 && !DEV_Ability.Enabled) { Util.Alert("Can't delete first slot."); return; } int offset = getPKXOffset(slot); byte[] pkxdata = new Byte[0x104]; @@ -5101,7 +3984,7 @@ private void cloneBox(object sender, EventArgs e) int box = C_BoxSelect.SelectedIndex + 1; // get box we're cloning to { - DialogResult sdr = MessageBox.Show(String.Format("Clone Pokemon from Editing Tabs to all slots in Box {0}?",box), "Prompt", MessageBoxButtons.YesNo); + DialogResult sdr = Util.Prompt(MessageBoxButtons.YesNo, String.Format("Clone Pokemon from Editing Tabs to all slots in Box {0}?", box)); if (sdr != DialogResult.Yes) // give the option to abort return; } @@ -5238,7 +4121,7 @@ private int getSlot(object sender) { // try to cast as picturebox try { PictureBox pbItem = sender as PictureBox; sourceControl = pbItem as Control; } catch - { MessageBox.Show("Invalid slot!", "Error"); return 0; } + { Util.Error("Invalid slot!", "getSlot could not cast the control element."); return 0; } } string[] pba = { @@ -5367,7 +4250,7 @@ public void setBoxNames() private void setSAVLabel() { L_SAVINDEX.Text = (savindex + 1).ToString(); - RTB_S.AppendText("Loaded Save File " + (savindex + 1).ToString() + "\n"); + RTB_S.AppendText("Loaded Save File " + (savindex + 1).ToString() + System.Environment.NewLine); } private void getSAVOffsets() { @@ -5380,7 +4263,7 @@ private void getSAVOffsets() } else { - MessageBox.Show("Unrecognized Save File loaded.", "Error"); + Util.Error("Unrecognized Save File loaded."); SaveGame = new SaveGames.SaveStruct("Error"); } @@ -5511,7 +4394,7 @@ private void getTSV(object sender, EventArgs e) } private void Menu_DumpLoadBoxes_Click(object sender, EventArgs e) { - DialogResult dr = MessageBox.Show("Press Yes to Import All\r\nPress No to Dump All\r\nPress Cancel to abort.", "Alert", MessageBoxButtons.YesNoCancel); + DialogResult dr = Util.Prompt(MessageBoxButtons.YesNoCancel, "Press Yes to Import All from Folder." + System.Environment.NewLine + "Press No to Dump All to Folder.", "Press Cancel to Abort."); if (dr != DialogResult.Cancel) { string exepath = System.Windows.Forms.Application.StartupPath; @@ -5523,7 +4406,7 @@ private void Menu_DumpLoadBoxes_Click(object sender, EventArgs e) { if (Directory.Exists(Path.Combine(exepath, "db"))) { - DialogResult ld = MessageBox.Show("Load from PKHeX's database?", "Alert", MessageBoxButtons.YesNo); + DialogResult ld = Util.Prompt(MessageBoxButtons.YesNo, "Load from PKHeX's database?"); if (ld == DialogResult.Yes) path = Path.Combine(exepath, "db"); else if (ld == DialogResult.No) @@ -5548,7 +4431,7 @@ private void Menu_DumpLoadBoxes_Click(object sender, EventArgs e) { // Dump all of box content to files. { - DialogResult ld = MessageBox.Show("Save to PKHeX's database?", "Alert", MessageBoxButtons.YesNo); + DialogResult ld = Util.Prompt(MessageBoxButtons.YesNo, "Save to PKHeX's database?"); if (ld == DialogResult.Yes) { path = Path.Combine(exepath, "db"); @@ -5619,7 +4502,7 @@ private void loadBoxesFromDB(string path) // Clear out the box data array. // Array.Clear(savefile, offset, size * 30 * 31); - if (MessageBox.Show("Clear subsequent boxes when importing data?\n\nIf you only want to overwrite for new data, press no.","Alert",MessageBoxButtons.YesNo) == DialogResult.Yes) + if (Util.Prompt(MessageBoxButtons.YesNo, "Clear subsequent boxes when importing data?", "If you only want to overwrite for new data, press no.") == DialogResult.Yes) { byte[] ezeros = PKX.encryptArray(new Byte[232]); for (int i = ctr; i < 30 * 31; i++) @@ -5703,10 +4586,11 @@ private void loadBoxesFromDB(string path) tabBoxMulti.SelectedIndex = 0; } setPKXBoxes(); - string result = "Loaded " + ctr + " files to boxes."; + string result = String.Format("Loaded {0} files to boxes.", ctr); if (pastctr > 0) - result += "\n\nConversion successful for " + pastctr + " past generation files."; - MessageBox.Show(result, "Alert"); + Util.Alert(result, String.Format("Conversion successful for {0} past generation files.", pastctr)); + else + Util.Alert(result); } } // Subfunction Save Buttons // @@ -5738,7 +4622,7 @@ private void B_OpenBerryField_Click(object sender, EventArgs e) { if (savegame_oras) { - DialogResult dr = MessageBox.Show("No editing support for ORAS :(\n\nRepopulate all with random berries?","Alert",MessageBoxButtons.YesNo); + DialogResult dr = Util.Prompt(MessageBoxButtons.YesNo, "No editing support for ORAS :(", "Repopulate all with random berries?"); if (dr == DialogResult.Yes) { // Randomize the trees. @@ -5782,7 +4666,7 @@ private void B_OpenOPowers_Click(object sender, EventArgs e) // Open O-Power Menu if (savegame_oras) { - DialogResult dr = MessageBox.Show("No editing support for ORAS :(\n\nMax O-Powers with a working code?","Alert",MessageBoxButtons.YesNo); + DialogResult dr = Util.Prompt(MessageBoxButtons.YesNo, "No editing support for ORAS :(", "Max O-Powers with a working code?"); if (dr == DialogResult.Yes) { byte[] maxoras = new byte[] @@ -5822,7 +4706,7 @@ private void B_OpenPokedex_Click(object sender, EventArgs e) private void B_OUTPasserby_Click(object sender, EventArgs e) { string result = ""; - result += "PSS List\n\n"; + result += "PSS List" + System.Environment.NewLine + System.Environment.NewLine; string[] headers = { "PSS Data - Friends", "PSS Data - Acquaintances", @@ -5831,7 +4715,7 @@ private void B_OUTPasserby_Click(object sender, EventArgs e) int offset = savindex * 0x7F000 + SaveGame.PSS; for (int g = 0; g < 3; g++) { - result += "----\n" + headers[g] + "\n" + "----\n" + "\n"; + result += "----" + System.Environment.NewLine + headers[g] + System.Environment.NewLine + "----" + System.Environment.NewLine + System.Environment.NewLine; uint count = BitConverter.ToUInt32(savefile,offset + 0x4E20); int r_offset = offset; @@ -5866,15 +4750,15 @@ private void B_OUTPasserby_Click(object sender, EventArgs e) else if (game == 27) gamename = "OR"; else gamename = "UNK GAME"; - result += - "OT: " + otname + "\n" + - "Message: " + message + "\n" + - "Game: " + gamename + "\n" + - "Country ID: " + country + "\n" + - "Region ID: " + region + "\n" + - "Favorite: " + specieslist[favpkm] + "\n"; + result += + "OT: " + otname + System.Environment.NewLine + + "Message: " + message + System.Environment.NewLine + + "Game: " + gamename + System.Environment.NewLine + + "Country ID: " + country + System.Environment.NewLine + + "Region ID: " + region + System.Environment.NewLine + + "Favorite: " + specieslist[favpkm] + System.Environment.NewLine; - result += "\n"; + result += System.Environment.NewLine; r_offset += 0xC8; } offset += 0x5000; @@ -5903,7 +4787,7 @@ private void B_OpenTemp_Click(object sender, EventArgs e) if (Directory.Exists(path)) System.Diagnostics.Process.Start("explorer.exe", @path); else - MessageBox.Show("Can't find the cache folder.", "Alert"); + Util.Alert("Can't find the cache folder."); } else { @@ -5912,12 +4796,12 @@ private void B_OpenTemp_Click(object sender, EventArgs e) System.Diagnostics.Process.Start("explorer.exe", @Path.Combine(path, "root")); else if (Directory.Exists(path)) System.Diagnostics.Process.Start("explorer.exe", @path); - else { MessageBox.Show("Can't find the temporary file.\n\nMake sure the Cyber Gadget software is paused.", "Alert"); } + else { Util.Error("Can't find the temporary file.", "Make sure the Cyber Gadget software is paused."); } } } private void B_SwitchSAV_Click(object sender, EventArgs e) { - DialogResult switchsav = MessageBox.Show("Current Savefile is Save" + ((savindex + 1)).ToString() + ". Would you like to switch to Save" + ((savindex + 1) % 2 + 1).ToString() + "?", "Prompt", MessageBoxButtons.YesNo); + DialogResult switchsav = Util.Prompt(MessageBoxButtons.YesNo, String.Format("Current Savefile is Save {0}.",(savindex + 1)),String.Format("Would you like to switch to Save {0}?", ((savindex + 1) % 2 + 1))); if (switchsav == DialogResult.Yes) { savindex = (savindex + 1) % 2; @@ -5935,7 +4819,7 @@ private void B_JPEG_Click(object sender, EventArgs e) offset += 0x54; if (savefile[offset] != 0xFF) { - MessageBox.Show("No PGL picture data found!", "Error"); + Util.Alert("No PGL picture data found in the save file!"); return; } int length = 0xE004; @@ -5973,7 +4857,7 @@ private void changeMainLanguage(object sender, EventArgs e) Menu_Options.DropDown.Close(); InitializeStrings(); InitializeLanguage(); - TranslateInterface("Form1"); + Util.TranslateInterface("Form1", curlanguage, Controls, menuStrip1); populateFields(buff); // put data back in form } private void InitializeStrings() @@ -5989,14 +4873,18 @@ private void InitializeStrings() itemlist = Util.getStringList("Items", l); characteristics = Util.getStringList("Character", l); specieslist = Util.getStringList("Species", l); - forms = Util.getStringList("Forms", l); - memories = Util.getStringList("Memories", l); - genloc = Util.getStringList("GenLoc", l); - trainingbags = Util.getStringList("TrainingBag", l); - trainingstage = Util.getStringList("SuperTraining", l); - puffs = Util.getStringList("Puff", l); - itempouch = Util.getStringList("ItemPouch", l); wallpapernames = Util.getStringList("Wallpaper", l); + itempouch = Util.getStringList("ItemPouch", l); + + if ((l != "zh") || (l == "zh" && !init)) // load initial binaries + { + forms = Util.getStringList("Forms", l); + memories = Util.getStringList("Memories", l); + genloc = Util.getStringList("GenLoc", l); + trainingbags = Util.getStringList("TrainingBag", l); + trainingstage = Util.getStringList("SuperTraining", l); + puffs = Util.getStringList("Puff", l); + } // Fix Item Names (Duplicate entries) itemlist[456] += " (OLD)"; // S.S. Ticket @@ -6113,7 +5001,7 @@ private void pbBoxSlot_MouseDown(object sender, MouseEventArgs e) File.Delete(newfile); // after drop, delete the temporary file } catch (ArgumentException x) - { MessageBox.Show("Drag&Drop Error\n\n" + x, "Error"); } + { Util.Error("Drag & Drop Error:", x.ToString()); } File.Delete(newfile); pkm_from_offset = 0; } @@ -6137,7 +5025,7 @@ private void pbBoxSlot_DragDrop(object sender, DragEventArgs e) { byte[] input = File.ReadAllBytes(files[0]); var Converter = new pk2pk(); - if (!PKX.verifychk(input)) MessageBox.Show("Invalid File (Checksum Error)", "Error"); + if (!PKX.verifychk(input)) Util.Alert("Invalid File Loaded.", "Checksum is not valid."); try // to convert past gen pkm { byte[] data = Converter.ConvertPKM(input, savefile, savindex); @@ -6145,7 +5033,7 @@ private void pbBoxSlot_DragDrop(object sender, DragEventArgs e) Array.Copy(PKX.encryptArray(data), 0, savefile, offset, 0xE8); } catch - { MessageBox.Show("Attempted to load previous generation PKM.\n\nConversion failed.", "Alert"); } + { Util.Error("Attempted to load previous generation PKM.", "Conversion failed."); } } else if (fi.Length == 232 || fi.Length == 260) { @@ -6192,8 +5080,7 @@ private void L_Save_Click(object sender, EventArgs e) if (path != null) { - DialogResult sdr = MessageBox.Show("Open save file from the following location?\n\n"+path, "Prompt", MessageBoxButtons.YesNo); - if (sdr == DialogResult.Yes) + if (Util.Prompt(MessageBoxButtons.YesNo, "Open save file from the following location?", path) == DialogResult.Yes) openQuick(path); // load save } } diff --git a/PKX/f3-MemoryAmie.cs b/PKX/f3-MemoryAmie.cs index bbb229275..3500044a0 100644 --- a/PKX/f3-MemoryAmie.cs +++ b/PKX/f3-MemoryAmie.cs @@ -24,8 +24,8 @@ public partial class MemoryAmie : Form public MemoryAmie(Form1 frm1) { InitializeComponent(); + Util.TranslateInterface(this.Name, Form1.curlanguage, this.Controls); m_parent = frm1; - TranslateInterface("MemoryAmie"); string[] arguments = Regex.Split(L_Arguments.Text, " ; "); for (int i = 5; i < Math.Min(arguments.Length,vartypes.Length+5); i++) @@ -45,14 +45,10 @@ public MemoryAmie(Form1 frm1) h = m_parent.buff; // Set the current friendship from main window - if (m_parent.buff[0x93] == 0) - { + if (m_parent.buff[0x93] == 0) m_parent.buff[0xCA] = (byte)Convert.ToUInt16(m_parent.TB_Friendship.Text); - } else - { m_parent.buff[0xA2] = (byte)Convert.ToUInt16(m_parent.TB_Friendship.Text); - } getCountries(); getLangStrings(); @@ -62,72 +58,6 @@ public MemoryAmie(Form1 frm1) public string[] feeling; public string[] quality; - // Conversion - public void TranslateInterface(string FORM_NAME) - { - string curlanguage = Form1.curlanguage; - // Fetch a File - // Check to see if a the translation file exists in the same folder as the executable - string externalLangPath = System.Windows.Forms.Application.StartupPath + Path.DirectorySeparatorChar + "lang_" + curlanguage + ".txt"; - string[] rawlist; - if (File.Exists(externalLangPath)) - { - rawlist = File.ReadAllLines(externalLangPath); - } - else - { - object txt; - txt = Properties.Resources.ResourceManager.GetObject("lang_" + curlanguage); // Fetch File, \n to list. - if (txt == null) return; // Translation file does not exist as a resource; abort this function and don't translate UI. - string[] stringSeparators = new string[] { "\r\n" }; - rawlist = ((string)txt).Split(stringSeparators, StringSplitOptions.None); - } - - string[] stringdata = new string[rawlist.Length]; - int itemsToRename = 0; - for (int i = 0; i < rawlist.Length; i++) - { - // Find our starting point - if (rawlist[i] == "! " + FORM_NAME) // Start our data - { - // Copy our Control Names and Text to a new array for later processing. - for (int j = i + 1; j < rawlist.Length; j++) - { - if (rawlist[j].Length == 0) - continue; // Skip Over Empty Lines, errhandled - if (rawlist[j][0].ToString() != "-") // If line is not a comment line... - { - if (rawlist[j][0].ToString() == "!") // Stop if we have reached the end of translation - break; // exit inner loop - stringdata[itemsToRename] = rawlist[j]; // Add the entry to process later. - itemsToRename++; - } - } - break; // exit outer loop - } - } - - // Now that we have our items to rename in: Control = Text format, let's execute the changes! - - for (int i = 0; i < itemsToRename; i++) - { - string[] SplitString = Regex.Split(stringdata[i], " = "); - if (SplitString.Length < 2) - continue; // Error in Input, errhandled - string ctrl = SplitString[0]; // Control to change the text of... - string text = SplitString[1]; // Text to set Control.Text to... - Control[] controllist = Controls.Find(ctrl, true); - if (controllist.Length == 0) // If Control isn't found... - { - // If not found, it is not something to rename and is thus skipped. - } - else // Set the input control's text. - { - controllist[0].Text = text; - } - } - } - // Load/Save Actions private void loadFields() { @@ -153,7 +83,7 @@ private void loadFields() CB_Handler.Items.Clear(); CB_Handler.Items.AddRange(new object[] { m_parent.TB_OT.Text + " ("+ot+")"}); - if ((m_parent.TB_OTt2.Text != "") && (m_parent.TB_OTt2.Text != "\0\0\0\0\0\0\0\0\0\0\0\0")) + if (Util.TrimFromZero(m_parent.TB_OTt2.Text) != "") { CB_Handler.Items.AddRange(new object[] { m_parent.TB_OTt2.Text }); CB_Handler.Enabled = true; @@ -214,9 +144,7 @@ private void loadFields() GB_M_CT.Text = notleft + " " + ot + " - " + disabled; } else - { GB_M_CT.Text = withOT + " " + m_parent.TB_OTt2.Text; - } } RTB_OT.Visible = CB_OTQual.Enabled = CB_OTMemory.Enabled = CB_OTFeel.Enabled = CB_OTVar.Enabled = M_OT_Affection.Enabled = enable; } @@ -244,9 +172,7 @@ private void saveFields() m_parent.buff[0xA9] = 0; } else - { cb2v(CB_CTVar, 0xA8); - } // If memory doesn't contain a feeling/quality if (!CB_CTFeel.Enabled) @@ -268,9 +194,7 @@ private void saveFields() m_parent.buff[0xCF] = 0; } else - { cb2v(CB_OTVar, 0xCE); - } // If memory doesn't contain a feeling/quality if (!CB_OTFeel.Enabled) @@ -479,28 +403,13 @@ private void getCountries() }; #endregion - var c0_list = new BindingSource(country_list, null); - var c1_list = new BindingSource(country_list, null); - var c2_list = new BindingSource(country_list, null); - var c3_list = new BindingSource(country_list, null); - var c4_list = new BindingSource(country_list, null); - - - CB_Country0.DataSource = c0_list; - CB_Country0.DisplayMember = "Text"; - CB_Country0.ValueMember = "Value"; - CB_Country1.DataSource = c1_list; - CB_Country1.DisplayMember = "Text"; - CB_Country1.ValueMember = "Value"; - CB_Country2.DataSource = c2_list; - CB_Country2.DisplayMember = "Text"; - CB_Country2.ValueMember = "Value"; - CB_Country3.DataSource = c3_list; - CB_Country3.DisplayMember = "Text"; - CB_Country3.ValueMember = "Value"; - CB_Country4.DataSource = c4_list; - CB_Country4.DisplayMember = "Text"; - CB_Country4.ValueMember = "Value"; + ComboBox[] cba = new ComboBox[] { CB_Country0, CB_Country1, CB_Country2, CB_Country3, CB_Country4, }; + for (int i = 0; i < cba.Length; i++) + { + cba[i].DataSource = new BindingSource(country_list, null); + cba[i].DisplayMember = "Text"; + cba[i].ValueMember = "Value"; + } } private void getLangStrings() { diff --git a/SAV/SAV_BoxIO.cs b/SAV/SAV_BoxIO.cs index 9f529d1d1..3330fc76f 100644 --- a/SAV/SAV_BoxIO.cs +++ b/SAV/SAV_BoxIO.cs @@ -43,7 +43,7 @@ private void B_ImportBox_Click(object sender, EventArgs e) m_parent.setPKXBoxes(); } else - MessageBox.Show("Box data loaded is too big!", "Error"); + Util.Error("Box data loaded is too big!"); } } private void B_ExportBox_Click(object sender, EventArgs e) diff --git a/SAV/SAV_EventFlagsORAS.cs b/SAV/SAV_EventFlagsORAS.cs index f51f908d1..262e31e26 100644 --- a/SAV/SAV_EventFlagsORAS.cs +++ b/SAV/SAV_EventFlagsORAS.cs @@ -201,7 +201,7 @@ private void openSAV(object sender, EventArgs e) Array.Copy(data, 0x1A0FC - 0x5400, eventflags, 0, 0x180); } else - { MessageBox.Show("Invalid SAV Size", "Error"); return; } + { Util.Error("Invalid SAV Size", String.Format("File Size: {0} (bytes)"), fi.Length.ToString(), "File Loaded: " + path); return; } } else return; diff --git a/SAV/SAV_EventFlagsXY.cs b/SAV/SAV_EventFlagsXY.cs index 9ea169178..c6dcf04ab 100644 --- a/SAV/SAV_EventFlagsXY.cs +++ b/SAV/SAV_EventFlagsXY.cs @@ -169,9 +169,7 @@ private void openSAV(object sender, EventArgs e) Array.Copy(data, 0x1A0FC - 0x5400, eventflags, 0, 0x180); } else - { - MessageBox.Show("Invalid SAV Size", "Error"); return; - } + { Util.Error("Invalid SAV Size"); return; } } else return; diff --git a/SAV/SAV_HallOfFame.cs b/SAV/SAV_HallOfFame.cs index 9ea0fb569..de8dd0848 100644 --- a/SAV/SAV_HallOfFame.cs +++ b/SAV/SAV_HallOfFame.cs @@ -212,7 +212,7 @@ private void displayEntry(object sender, EventArgs e) uint vnd = BitConverter.ToUInt32(data, offset + 0x1B0); uint vn = vnd & 0xFF; TB_VN.Text = vn.ToString("000"); - s = "Entry #" + vn + "\r\n"; + s = "Entry #" + vn + Environment.NewLine; uint date = (vnd >> 14) & 0x1FFFF; uint year = (date & 0xFF) + 2000; uint month = (date >> 8) & 0xF; @@ -233,7 +233,7 @@ private void displayEntry(object sender, EventArgs e) ((Control)editor_spec[i]).Enabled = true; } - s += "Date: " + year.ToString() + "/" + month.ToString() + "/" + day.ToString() + "\r\n\r\n"; + s += "Date: " + year.ToString() + "/" + month.ToString() + "/" + day.ToString() + "" + Environment.NewLine + Environment.NewLine; CAL_MetDate.Value = new DateTime((int)year, (int)month, (int)day); int moncount = 0; for (int i = 0; i < 6; i++) @@ -266,16 +266,16 @@ private void displayEntry(object sender, EventArgs e) string shinystr = (shiny == 1) ? "Yes" : "No"; s += "Name: " + nickname; - s += " (" + Form1.specieslist[species] + " - " + genderstr + ")\r\n"; - s += "Level: " + level.ToString() + "\r\n"; - s += "Shiny: " + shinystr + "\r\n"; - s += "Held Item: " + Form1.itemlist[helditem] + "\r\n"; - s += "Move 1: " + Form1.movelist[move1] + "\r\n"; - s += "Move 2: " + Form1.movelist[move2] + "\r\n"; - s += "Move 3: " + Form1.movelist[move3] + "\r\n"; - s += "Move 4: " + Form1.movelist[move4] + "\r\n"; - s += "OT: " + OTname + " (" + TID.ToString() + "/" + SID.ToString() + ")\r\n"; - s += "\r\n"; + s += " (" + Form1.specieslist[species] + " - " + genderstr + ")" + Environment.NewLine; + s += "Level: " + level.ToString() + Environment.NewLine; + s += "Shiny: " + shinystr + Environment.NewLine; + s += "Held Item: " + Form1.itemlist[helditem] + Environment.NewLine; + s += "Move 1: " + Form1.movelist[move1] + Environment.NewLine; + s += "Move 2: " + Form1.movelist[move2] + Environment.NewLine; + s += "Move 3: " + Form1.movelist[move3] + Environment.NewLine; + s += "Move 4: " + Form1.movelist[move4] + Environment.NewLine; + s += "OT: " + OTname + " (" + TID.ToString() + "/" + SID.ToString() + ")" + Environment.NewLine; + s += Environment.NewLine; offset += 0x48; } diff --git a/SAV/SAV_Inventory.cs b/SAV/SAV_Inventory.cs index 34e32df44..55b29c6a7 100644 --- a/SAV/SAV_Inventory.cs +++ b/SAV/SAV_Inventory.cs @@ -274,7 +274,7 @@ private void populateList(string[] itemarr, int offset, int itemcount) try { itemname = Form1.itemlist[itemvalue]; } catch { - MessageBox.Show("Unknown item detected.\r\n\r\nItem ID: " + itemvalue + "\r\n" + "Item is after: " + itemname, "Error"); + Util.Error("Unknown item detected.", "Item ID: " + itemvalue, "Item is after: " + itemname); continue; } int itemarrayval = Array.IndexOf(itemarr,itemname); @@ -282,7 +282,7 @@ private void populateList(string[] itemarr, int offset, int itemcount) { dataGridView1.Rows[i].Cells[0].Value = itemarr[0]; dataGridView1.Rows[i].Cells[1].Value = 0; - MessageBox.Show(itemname + " removed.\n\nIf you exit the Item Editor by saving changes,\nthe item will no longer be in the pouch.", "Alert"); + Util.Alert(itemname + " removed from item pouch.", "If you exit the Item Editor by saving changes, the item will no longer be in the pouch."); } else { diff --git a/SAV/SAV_Pokepuff.cs b/SAV/SAV_Pokepuff.cs index 514794983..cdfafbd6b 100644 --- a/SAV/SAV_Pokepuff.cs +++ b/SAV/SAV_Pokepuff.cs @@ -25,7 +25,7 @@ public SAV_Pokepuff(Form1 frm1) ToolTip1.SetToolTip(this.B_Sort, "Hold CTRL to reverse sort."); ToolTip ToolTip2 = new ToolTip(); - ToolTip2.SetToolTip(this.B_All, "Hold CTRL to give Deluxe\r\ninstead of Supreme."); + ToolTip2.SetToolTip(this.B_All, "Hold CTRL to give Deluxe instead of Supreme."); } Form1 m_parent; public byte[] sav = new Byte[0x100000]; diff --git a/SAV/SAV_SecretBase.cs b/SAV/SAV_SecretBase.cs index efb219fd6..59e3cc4a0 100644 --- a/SAV/SAV_SecretBase.cs +++ b/SAV/SAV_SecretBase.cs @@ -285,11 +285,11 @@ private void B_FAV2SAV(object sender, EventArgs e) // Write data back to save int index = LB_Favorite.SelectedIndex; // store for restoring if (!GB_PKM.Enabled && index > 0) - { MessageBox.Show("Sorry, no overwriting someone else's base with your own data.", "Error"); return; } + { Util.Error("Sorry, no overwriting someone else's base with your own data."); return; } if (GB_PKM.Enabled && index == 0) - { MessageBox.Show("Sorry, no overwriting of your own base with someone else's.","Error"); return; } + { Util.Error("Sorry, no overwriting of your own base with someone else's."); return; } if (LB_Favorite.Items[index].ToString().Substring(LB_Favorite.Items[index].ToString().Length - 5, 5) == "Empty") - { MessageBox.Show("Sorry, no overwriting an empty base with someone else's.", "Error"); return; } + { Util.Error("Sorry, no overwriting an empty base with someone else's."); return; } if (index < 0) return; int offset = fav_offset + 0x5400 + 0x25A; diff --git a/SAV/SAV_Wondercard.cs b/SAV/SAV_Wondercard.cs index c109bcd92..2f920829e 100644 --- a/SAV/SAV_Wondercard.cs +++ b/SAV/SAV_Wondercard.cs @@ -54,49 +54,60 @@ private void populateWClist() } private void loadwcdata() { - // Load up the data according to the wiki! - int cardID = BitConverter.ToUInt16(wondercard_data, 0); - if (cardID == 0) + try { - RTB.Text = "Empty Slot. No data!"; - return; - } - string cardname = Encoding.Unicode.GetString(wondercard_data, 0x2, 0x48); - int cardtype = wondercard_data[0x51]; - RTB.Clear(); - RTB.AppendText("Card #: " + cardID.ToString("0000") + "\r\n" + cardname + "\r\n"); + // Load up the data according to the wiki! + int cardID = BitConverter.ToUInt16(wondercard_data, 0); + if (cardID == 0) + { + RTB.Text = "Empty Slot. No data!"; + return; + } + string cardname = Util.TrimFromZero(Encoding.Unicode.GetString(wondercard_data, 0x2, 0x48)); + int cardtype = wondercard_data[0x51]; + string s = ""; + s += "Card #: " + cardID.ToString("0000") + System.Environment.NewLine + cardname + System.Environment.NewLine + System.Environment.NewLine; - if (cardtype == 1) // Item - { - int item = BitConverter.ToUInt16(wondercard_data, 0x68); - int qty = BitConverter.ToUInt16(wondercard_data, 0x70); + if (cardtype == 1) // Item + { + int item = BitConverter.ToUInt16(wondercard_data, 0x68); + int qty = BitConverter.ToUInt16(wondercard_data, 0x70); - RTB.AppendText("\r\nItem: " + Form1.itemlist[item] + "\r\n" + "Quantity: " + qty.ToString()); - } - else if (cardtype == 0) // PKM - { - int species = BitConverter.ToUInt16(wondercard_data, 0x82); - int helditem = BitConverter.ToUInt16(wondercard_data, 0x78); - int move1 = BitConverter.ToUInt16(wondercard_data, 0x7A); - int move2 = BitConverter.ToUInt16(wondercard_data, 0x7C); - int move3 = BitConverter.ToUInt16(wondercard_data, 0x7E); - int move4 = BitConverter.ToUInt16(wondercard_data, 0x80); - int TID = BitConverter.ToUInt16(wondercard_data, 0x68); - int SID = BitConverter.ToUInt16(wondercard_data, 0x6A); + s += "Item: " + Form1.itemlist[item] + System.Environment.NewLine + "Quantity: " + qty.ToString(); + } + else if (cardtype == 0) // PKM + { + int species = BitConverter.ToUInt16(wondercard_data, 0x82); + int helditem = BitConverter.ToUInt16(wondercard_data, 0x78); + int move1 = BitConverter.ToUInt16(wondercard_data, 0x7A); + int move2 = BitConverter.ToUInt16(wondercard_data, 0x7C); + int move3 = BitConverter.ToUInt16(wondercard_data, 0x7E); + int move4 = BitConverter.ToUInt16(wondercard_data, 0x80); + int TID = BitConverter.ToUInt16(wondercard_data, 0x68); + int SID = BitConverter.ToUInt16(wondercard_data, 0x6A); - string OTname = Util.TrimFromZero(Encoding.Unicode.GetString(wondercard_data, 0xB6, 22)); - RTB.Text += - "\r\nSpecies: " + Form1.specieslist[species] + "\r\n" - + "Item: " + Form1.itemlist[helditem] + "\r\n" - + "Move 1: " + Form1.movelist[move1] + "\r\n" - + "Move 2: " + Form1.movelist[move2] + "\r\n" - + "Move 3: " + Form1.movelist[move3] + "\r\n" - + "Move 4: " + Form1.movelist[move4] + "\r\n" - + "OT: " + OTname + "\r\n" - + "ID: " + TID.ToString() + "/" + SID.ToString(); + string OTname = Util.TrimFromZero(Encoding.Unicode.GetString(wondercard_data, 0xB6, 22)); + s += + "Species: " + Form1.specieslist[species] + System.Environment.NewLine + + "Item: " + Form1.itemlist[helditem] + System.Environment.NewLine + + "Move 1: " + Form1.movelist[move1] + System.Environment.NewLine + + "Move 2: " + Form1.movelist[move2] + System.Environment.NewLine + + "Move 3: " + Form1.movelist[move3] + System.Environment.NewLine + + "Move 4: " + Form1.movelist[move4] + System.Environment.NewLine + + "OT: " + OTname + System.Environment.NewLine + + "ID: " + TID.ToString() + "/" + SID.ToString(); + } + else + s = "Unsupported Wondercard Type!"; + RTB.Text = s; + } + catch + { + Util.Error("Loading of data failed... is this really a Wondercard?"); + Array.Copy(new Byte[0x108], wondercard_data, 0x108); + RTB.Clear(); + return; } - else - RTB.Text = "Unsupported Wondercard Type!"; } private void populateReceived() { @@ -115,12 +126,12 @@ private void B_Import_Click(object sender, EventArgs e) if (importwc6.ShowDialog() == DialogResult.OK) { string path = importwc6.FileName; - byte[] newwc6 = File.ReadAllBytes(path); - if (newwc6.Length > 0x108) + if (new FileInfo(path).Length > 0x108) { - MessageBox.Show("Not a valid wondercard length.", "Error"); + Util.Error("File is not a Wondercard:", path); return; } + byte[] newwc6 = File.ReadAllBytes(path); Array.Copy(newwc6, wondercard_data, newwc6.Length); loadwcdata(); } @@ -215,6 +226,7 @@ private void B_Save_Click(object sender, EventArgs e) Close(); } + // Delete WC Flag private void B_DeleteReceived_Click(object sender, EventArgs e) { if (LB_Received.SelectedIndex > -1) @@ -222,6 +234,7 @@ private void B_DeleteReceived_Click(object sender, EventArgs e) LB_Received.Items.Remove(LB_Received.Items[LB_Received.SelectedIndex]); } + // Drag & Drop Wondercards private void tabMain_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy; @@ -230,13 +243,13 @@ private void tabMain_DragDrop(object sender, DragEventArgs e) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); string path = files[0]; // open first D&D - - byte[] newwc6 = File.ReadAllBytes(path); - if (newwc6.Length > 0x108) + + if (new FileInfo(path).Length > 0x108) { - MessageBox.Show("Not a valid wondercard length.", "Error"); + Util.Error("File is not a Wondercard:", path); return; } + byte[] newwc6 = File.ReadAllBytes(path); Array.Copy(newwc6, wondercard_data, newwc6.Length); loadwcdata(); }