From 17f1b6ee683c862c8068c3009dab2619634d91d3 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 14 Dec 2014 10:31:53 -0800 Subject: [PATCH] Further code cleanup --- Misc/CodeGenerator.cs | 2 +- Misc/Legal.cs | 16 +- Misc/PKX.cs | 190 ++++++++-------- Misc/Util.cs | 123 ++++++++++ PKX/f1-Main.Designer.cs | 6 +- PKX/f1-Main.cs | 480 +++++----------------------------------- PKX/f3-MemoryAmie.cs | 10 + SAV/SAV_HallOfFame.cs | 98 +------- SAV/SAV_PokedexORAS.cs | 17 +- SAV/SAV_PokedexXY.cs | 17 +- SAV/SAV_SecretBase.cs | 144 +----------- SAV/SAV_SuperTrain.cs | 20 +- SAV/frmReport.cs | 2 +- 13 files changed, 326 insertions(+), 799 deletions(-) diff --git a/Misc/CodeGenerator.cs b/Misc/CodeGenerator.cs index 1732e9314..5b3d0c9d8 100644 --- a/Misc/CodeGenerator.cs +++ b/Misc/CodeGenerator.cs @@ -16,7 +16,7 @@ namespace PKHeX { byte[] codedata = new byte[232]; byte[] newdata = new byte[232]; - SaveGames.SaveStruct SaveGame = new SaveGames.SaveStruct(null); + PKX.SaveGames.SaveStruct SaveGame = new PKX.SaveGames.SaveStruct(null); Form1 m_parent; public CodeGenerator(Form1 frm1) diff --git a/Misc/Legal.cs b/Misc/Legal.cs index 1ea0e99ee..2fc1bd544 100644 --- a/Misc/Legal.cs +++ b/Misc/Legal.cs @@ -33,13 +33,25 @@ namespace PKHeX internal static readonly int[] Games_6xy = { 24, 25 }; internal static readonly int[] Games_6oras = { 26, 27 }; internal static readonly int[] Games_5 = { 20, 21, 22, 23 }; - internal static readonly int[] Games_4 = { 10, 11, 12 }; + internal static readonly int[] Games_4 = { 10, 11, }; internal static readonly int[] Games_4e = { 12 }; internal static readonly int[] Games_4r = { 7, 8 }; internal static readonly int[] Games_3 = { 1, 2 }; internal static readonly int[] Games_3e = { 3 }; internal static readonly int[] Games_3r = { 4, 5 }; internal static readonly int[] Games_3s = { 15 }; - + internal static readonly int[] Met_BW2c = { 0, 60002, 30003 }; + internal static readonly int[] Met_BW2_0 = { 1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153, }; + internal static readonly int[] Met_BW2_3 = { 30001,30002,30004,30005,30006,30007,30008,30010,30011,30012,30013,30014,30015, }; + internal static readonly int[] Met_BW2_4 = { 40001, 40002, 40003, 40004, 40005, 40006, 40007, 40008, 40009, 40010, 40011, 40012, 40013, 40014, 40015, 40016, 40017, 40018, 40019, 40020, 40021, 40022, 40023, 40024, 40025, 40026, 40027, 40028, 40029, 40030, 40031, 40032, 40033, 40034, 40035, 40036, 40037, 40038, 40039, 40040, 40041, 40042, 40043, 40044, 40045, 40046, 40047, 40048, 40049, 40050, 40051, 40052, 40053, 40054, 40055, 40056, 40057, 40058, 40059, 40060, 40061, 40062, 40063, 40064, 40065, 40066, 40067, 40068, 40069, 40070, 40071, 40072, 40073, 40074, 40075, 40076, 40077, 40078, 40079, 40080, 40081, 40082, 40083, 40084, 40085, 40086, 40087, 40088, 40089, 40090, 40091, 40092, 40093, 40094, 40095, 40096, 40097, 40098, 40099, 40100, 40101, 40102, 40103, 40104, 40105, 40106, 40107, 40108, 40109, }; + internal static readonly int[] Met_BW2_6 = { 60001,60003 }; + internal static readonly int[] Met_XYc = { 0, 60002, 30002, }; + internal static readonly int[] Met_XY_0 = { /* XY */ 2,6,8,10,12,14,16,17,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168, /* ORAS */ 170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,256,258,260,262,264,266,268,270,272,274,276,278,280,282,284,286,288,290,292,294,296,298,300,302,304,306,308,310,312,314,316,318,320,322,324,326,328,330,332,334,336,338,340,342,344,346,348,350,352,354,}; + internal static readonly int[] Met_XY_3 = { 30001,30003,30004,30005,30006,30007,30008,30009,30010,30011, }; + internal static readonly int[] Met_XY_4 = { 40001, 40002, 40003, 40004, 40005, 40006, 40007, 40008, 40009, 40010, 40011, 40012, 40013, 40014, 40015, 40016, 40017, 40018, 40019, 40020, 40021, 40022, 40023, 40024, 40025, 40026, 40027, 40028, 40029, 40030, 40031, 40032, 40033, 40034, 40035, 40036, 40037, 40038, 40039, 40040, 40041, 40042, 40043, 40044, 40045, 40046, 40047, 40048, 40049, 40050, 40051, 40052, 40053, 40054, 40055, 40056, 40057, 40058, 40059, 40060, 40061, 40062, 40063, 40064, 40065, 40066, 40067, 40068, 40069, 40070, 40071, 40072, 40073, 40074, 40075, 40076, 40077, 40078, 40079, }; + internal static readonly int[] Met_XY_6 = { /* XY */ 60001,60003, /* ORAS */ 60004,}; + internal static readonly int[] Met_HGSS_0 = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,}; + internal static readonly int[] Met_HGSS_2 = {2000,2001,2002,2003,2004,2005,2006,2008,2009,2010,2011,2012,2013,2014,}; + internal static readonly int[] Met_HGSS_3 = {3000,3001,3002,3003,3004,3005,3006,3007,3008,3009,3010,3011,3012,3013,3014,3015,3016,3017,3018,3019,3020,3021,3022,3023,3024,3025,3026,3027,3028,3029,3030,3031,3032,3033,3034,3035,3036,3037,3038,3039,3040,3041,3042,3043,3044,3045,3046,3047,3048,3049,3050,3051,3052,3053,3054,3055,3056,3057,3058,3059,3060,3061,3062,3063,3064,3065,3066,3067,3068,3069,3070,3071,3072,3073,3074,3075,3076}; } } diff --git a/Misc/PKX.cs b/Misc/PKX.cs index 6554c9466..b88e0068c 100644 --- a/Misc/PKX.cs +++ b/Misc/PKX.cs @@ -873,6 +873,103 @@ namespace PKHeX catch { return; } } #endregion + #region SaveGame + + public class SaveGames + { + public struct SaveStruct + { + public int Box, TrainerCard, Party, BattleBox, GTS, Daycare, Fused, SUBE, Puff, Item, Trainer1, Trainer2, PCLayout, Wondercard, BerryField, OPower, EventFlag, PokeDex, HoF, PSS, JPEG; + public string Name; + public SaveStruct(string GameID) + { + if (GameID == "XY") + { + Name = "XY"; + Box = 0x27A00; + TrainerCard = 0x19400; + Party = 0x19600; + BattleBox = 0x09E00; + Daycare = 0x20600; + GTS = 0x1CC00; + Fused = 0x1B400; + SUBE = 0x22C90; + + Puff = 0x5400; + Item = 0x5800; + Trainer1 = 0x6800; + Trainer2 = 0x9600; + PCLayout = 0x9800; + Wondercard = 0x21000; + BerryField = 0x20C00; + OPower = 0x1BE00; + EventFlag = 0x19E00; + PokeDex = 0x1A400; + + HoF = 0x1E800; + JPEG = 0x5C600; + PSS = 0x0A400; + } + else if (GameID == "ORAS") + { + // Temp + Name = "ORAS"; + Box = 0x38400; // Confirmed + TrainerCard = 0x19400; // Confirmed + Party = 0x19600; // Confirmed + BattleBox = 0x09E00;// Confirmed + Daycare = 0x21000; // Confirmed (thanks Rei) + GTS = 0x1D600; // Confirmed + Fused = 0x1BE00; // Confirmed + SUBE = 0x22C90; // ****not in use, not updating?**** + + Puff = 0x5400; // Confirmed + Item = 0x5800; // Confirmed + Trainer1 = 0x6800; // Confirmed + Trainer2 = 0x9600; // Confirmed + PCLayout = 0x9800; // Confirmed + Wondercard = 0x22000; // Confirmed + BerryField = 0x20C00; // ****changed**** + OPower = 0x1BE00; + EventFlag = 0x19E00; // Confirmed + PokeDex = 0x1A400; + + HoF = 0x1F200; // Confirmed + JPEG = 0x6D000; // Confirmed + PSS = 0x0A400; // Confirmed (thanks Rei) + } + else + { + // Copied... + Name = "Unknown"; + Box = 0x27A00; + TrainerCard = 0x19400; + Party = 0x19600; + BattleBox = 0x09E00; + Daycare = 0x20600; + GTS = 0x1CC00; + Fused = 0x1B400; + SUBE = 0x22C90; + + Puff = 0x5400; + Item = 0x5800; + Trainer1 = 0x6800; + Trainer2 = 0x9600; + PCLayout = 0x9800; + Wondercard = 0x21000; + BerryField = 0x20C00; + OPower = 0x1BE00; + EventFlag = 0x19E00; + PokeDex = 0x1A400; + + HoF = 0x1E800; + JPEG = 0x5C600; + PSS = 0x0A400; + } + } + } + } + #endregion // Save File Related internal static int detectSAVIndex(byte[] data, ref int savindex) @@ -947,99 +1044,6 @@ namespace PKHeX return new Font(fonts.Families[0], fontsize); } - // DataSource Providing - public class cbItem - { - public string Text { get; set; } - public object Value { get; set; } - - public override string ToString() - { - return Text; - } - } - internal static List getCBList(string textfile, string lang) - { - // Set up - List cbList = new List(); - string[] inputCSV = Util.getSimpleStringList(textfile); - - // Get Language we're fetching for - int index = Array.IndexOf(new string[] { "ja", "en", "fr", "de", "it", "es", "ko", "zh", }, lang); - - // Set up our Temporary Storage - string[] unsortedList = new string[inputCSV.Length - 1]; - int[] indexes = new int[inputCSV.Length - 1]; - - // Gather our data from the input file - for (int i = 1; i < inputCSV.Length; i++) - { - string[] countryData = inputCSV[i].Split(','); - indexes[i - 1] = Convert.ToInt32(countryData[0]); - unsortedList[i - 1] = countryData[index + 1]; - } - - // Sort our input data - string[] sortedList = new string[inputCSV.Length - 1]; - Array.Copy(unsortedList, sortedList, unsortedList.Length); - Array.Sort(sortedList); - - // Arrange the input data based on original number - for (int i = 0; i < sortedList.Length; i++) - { - cbItem ncbi = new cbItem(); - ncbi.Text = sortedList[i]; - ncbi.Value = indexes[Array.IndexOf(unsortedList, sortedList[i])]; - cbList.Add(ncbi); - } - return cbList; - } - internal static List getCBList(string[] inStrings, params int[][] allowed) - { - List cbList = new List(); - if (allowed == null) - allowed = new int[][] { Enumerable.Range(0, inStrings.Length).ToArray() }; - - foreach (int[] list in allowed) - { - // Sort the Rest based on String Name - string[] unsortedChoices = new string[list.Length]; - for (int i = 0; i < list.Length; i++) - unsortedChoices[i] = inStrings[list[i]]; - - string[] sortedChoices = new string[unsortedChoices.Length]; - Array.Copy(unsortedChoices, sortedChoices, unsortedChoices.Length); - Array.Sort(sortedChoices); - - // Add the rest of the items - for (int i = 0; i < sortedChoices.Length; i++) - { - cbItem ncbi = new cbItem(); - ncbi.Text = sortedChoices[i]; - ncbi.Value = list[Array.IndexOf(unsortedChoices, sortedChoices[i])]; - cbList.Add(ncbi); - } - } - return cbList; - } - internal static List getUnsortedCBList(string textfile) - { - // Set up - List cbList = new List(); - string[] inputCSV = Util.getSimpleStringList(textfile); - - // Gather our data from the input file - for (int i = 1; i < inputCSV.Length; i++) - { - string[] inputData = inputCSV[i].Split(','); - cbItem ncbi = new cbItem(); - ncbi.Value = Convert.ToInt32(inputData[0]); - ncbi.Text = inputData[1]; - cbList.Add(ncbi); - } - return cbList; - } - // Personal.dat internal static PersonalParser PersonalGetter = new PersonalParser(); internal class PersonalParser diff --git a/Misc/Util.cs b/Misc/Util.cs index 5da2b423b..da7731763 100644 --- a/Misc/Util.cs +++ b/Misc/Util.cs @@ -390,5 +390,128 @@ namespace PKHeX string msg = String.Join(Environment.NewLine + Environment.NewLine, lines); return (DialogResult)MessageBox.Show(msg, "Prompt", btn, MessageBoxIcon.Asterisk); } + + // DataSource Providing + public class cbItem + { + public string Text { get; set; } + public object Value { get; set; } + + public override string ToString() + { + return Text; + } + } + internal static List getCBList(string textfile, string lang) + { + // Set up + List cbList = new List(); + string[] inputCSV = Util.getSimpleStringList(textfile); + + // Get Language we're fetching for + int index = Array.IndexOf(new string[] { "ja", "en", "fr", "de", "it", "es", "ko", "zh", }, lang); + + // Set up our Temporary Storage + string[] unsortedList = new string[inputCSV.Length - 1]; + int[] indexes = new int[inputCSV.Length - 1]; + + // Gather our data from the input file + for (int i = 1; i < inputCSV.Length; i++) + { + string[] countryData = inputCSV[i].Split(','); + indexes[i - 1] = Convert.ToInt32(countryData[0]); + unsortedList[i - 1] = countryData[index + 1]; + } + + // Sort our input data + string[] sortedList = new string[inputCSV.Length - 1]; + Array.Copy(unsortedList, sortedList, unsortedList.Length); + Array.Sort(sortedList); + + // Arrange the input data based on original number + for (int i = 0; i < sortedList.Length; i++) + { + cbItem ncbi = new cbItem(); + ncbi.Text = sortedList[i]; + ncbi.Value = indexes[Array.IndexOf(unsortedList, sortedList[i])]; + cbList.Add(ncbi); + } + return cbList; + } + internal static List getCBList(string[] inStrings, params int[][] allowed) + { + List cbList = new List(); + if (allowed == null) + allowed = new int[][] { Enumerable.Range(0, inStrings.Length).ToArray() }; + + foreach (int[] list in allowed) + { + // Sort the Rest based on String Name + string[] unsortedChoices = new string[list.Length]; + for (int i = 0; i < list.Length; i++) + unsortedChoices[i] = inStrings[list[i]]; + + string[] sortedChoices = new string[unsortedChoices.Length]; + Array.Copy(unsortedChoices, sortedChoices, unsortedChoices.Length); + Array.Sort(sortedChoices); + + // Add the rest of the items + for (int i = 0; i < sortedChoices.Length; i++) + { + cbItem ncbi = new cbItem(); + ncbi.Text = sortedChoices[i]; + ncbi.Value = list[Array.IndexOf(unsortedChoices, sortedChoices[i])]; + cbList.Add(ncbi); + } + } + return cbList; + } + internal static List getOffsetCBList(List cbList, string[] inStrings, int offset, int[] allowed) + { + if (allowed == null) + allowed = Enumerable.Range(0, inStrings.Length).ToArray(); + + int[] list = (int[])allowed.Clone(); + for (int i = 0; i < list.Length; i++) + list[i] -= offset; + + { + // Sort the Rest based on String Name + string[] unsortedChoices = new string[allowed.Length]; + for (int i = 0; i < allowed.Length; i++) + unsortedChoices[i] = inStrings[list[i]]; + + string[] sortedChoices = new string[unsortedChoices.Length]; + Array.Copy(unsortedChoices, sortedChoices, unsortedChoices.Length); + Array.Sort(sortedChoices); + + // Add the rest of the items + for (int i = 0; i < sortedChoices.Length; i++) + { + cbItem ncbi = new cbItem(); + ncbi.Text = sortedChoices[i]; + ncbi.Value = allowed[Array.IndexOf(unsortedChoices, sortedChoices[i])]; + cbList.Add(ncbi); + } + } + return cbList; + } + internal static List getUnsortedCBList(string textfile) + { + // Set up + List cbList = new List(); + string[] inputCSV = Util.getSimpleStringList(textfile); + + // Gather our data from the input file + for (int i = 1; i < inputCSV.Length; i++) + { + string[] inputData = inputCSV[i].Split(','); + cbItem ncbi = new cbItem(); + ncbi.Value = Convert.ToInt32(inputData[0]); + ncbi.Text = inputData[1]; + cbList.Add(ncbi); + } + return cbList; + } } } diff --git a/PKX/f1-Main.Designer.cs b/PKX/f1-Main.Designer.cs index 8d61981b7..21826484f 100644 --- a/PKX/f1-Main.Designer.cs +++ b/PKX/f1-Main.Designer.cs @@ -4185,7 +4185,6 @@ private System.Windows.Forms.ComboBox CB_PKRSStrain; private System.Windows.Forms.ComboBox CB_Language; private System.Windows.Forms.ComboBox CB_Ability; - private System.Windows.Forms.ComboBox CB_Nature; private System.Windows.Forms.Label Label_3DSRegion; private System.Windows.Forms.Label Label_SubRegion; private System.Windows.Forms.Label Label_Country; @@ -4256,7 +4255,6 @@ private System.Windows.Forms.TextBox Stat_HP; private System.Windows.Forms.Label Label_PrevOT; private System.Windows.Forms.ComboBox CB_EncounterType; - private System.Windows.Forms.ComboBox CB_Ball; public System.Windows.Forms.ComboBox CB_GameOrigin; private System.Windows.Forms.GroupBox GB_EggConditions; private System.Windows.Forms.Label Label_EggDate; @@ -4298,7 +4296,6 @@ public System.Windows.Forms.TextBox TB_OTt2; public System.Windows.Forms.TextBox TB_OT; private System.Windows.Forms.Label Label_HeldItem; - private System.Windows.Forms.ComboBox CB_HeldItem; private System.Windows.Forms.CheckBox CHK_Cured; private System.Windows.Forms.CheckBox CHK_Infected; private System.Windows.Forms.ComboBox CB_Form; @@ -4464,6 +4461,9 @@ private System.Windows.Forms.MaskedTextBox MT_Form; private System.Windows.Forms.Button B_OpenSecretBase; private System.Windows.Forms.ToolStripMenuItem Menu_Unicode; + public System.Windows.Forms.ComboBox CB_Ball; + public System.Windows.Forms.ComboBox CB_HeldItem; + public System.Windows.Forms.ComboBox CB_Nature; } } diff --git a/PKX/f1-Main.cs b/PKX/f1-Main.cs index af8f1a547..bbd479528 100644 --- a/PKX/f1-Main.cs +++ b/PKX/f1-Main.cs @@ -45,18 +45,12 @@ namespace PKHeX "한국어", // KOR "中文", // CHN }; - int[] main_langnum = new int[] { 2,1,3,4,5,7,8,9 }; - string[] lang_val = { "en", "ja", "fr", "it", "de", "es", "ko", "zh" }; - - for (int i = 0; i < main_langlist.Length; i++) - { - cbItem item = new cbItem(); - item.Text = main_langlist[i]; - item.Value = main_langnum[i]; + foreach (var cbItem in main_langlist) + CB_MainLanguage.Items.Add(cbItem); - CB_MainLanguage.Items.Add(item); - } // Try and detect the language + int[] main_langnum = new int[] { 2, 1, 3, 4, 5, 7, 8, 9 }; + string[] lang_val = { "en", "ja", "fr", "it", "de", "es", "ko", "zh" }; string filename = Path.GetFileNameWithoutExtension(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName); string lastTwoChars = filename.Substring(filename.Length - 2); int lang = Array.IndexOf(main_langnum,Array.IndexOf(lang_val, lastTwoChars)); @@ -123,16 +117,18 @@ namespace PKHeX pba2[i].ContextMenuStrip = mnu2; #endregion #region Enable Drag and Drop on the form & tab control. - this.tabMain.AllowDrop = true; + this.AllowDrop = true; this.DragEnter += tabMain_DragEnter; this.DragDrop += tabMain_DragDrop; // Enable Drag and Drop on each tab. + tabMain.AllowDrop = true; this.tabMain.DragEnter += tabMain_DragEnter; this.tabMain.DragDrop += tabMain_DragDrop; foreach (TabPage tab in tabMain.Controls) { + tab.AllowDrop = true; tab.DragEnter += tabMain_DragEnter; tab.DragDrop += tabMain_DragDrop; } @@ -146,7 +142,6 @@ namespace PKHeX // Box Drag & Drop foreach (PictureBox pb in PAN_Box.Controls) pb.AllowDrop = true; - tabMain.AllowDrop = true; #endregion #region Finish Up @@ -229,7 +224,7 @@ namespace PKHeX public ToolTip Tip1 = new ToolTip(); public ToolTip Tip2 = new ToolTip(); public ToolTip Tip3 = new ToolTip(); - public SaveGames.SaveStruct SaveGame = new SaveGames.SaveStruct("XY"); + public PKX.SaveGames.SaveStruct SaveGame = new PKX.SaveGames.SaveStruct("XY"); #endregion #region //// MAIN MENU FUNCTIONS //// @@ -523,7 +518,7 @@ namespace PKHeX private void openMAIN(byte[] input, string path, string GameType, bool oras) { L_Save.Text = "SAV: " + Path.GetFileName(path); - SaveGame = new SaveGames.SaveStruct(GameType); + SaveGame = new PKX.SaveGames.SaveStruct(GameType); // Load CyberGadget this.savindex = 0; @@ -538,7 +533,7 @@ namespace PKHeX private void open1MB(byte[] input, string path, string GameType, bool oras) { L_Save.Text = "SAV: " + Path.GetFileName(path); - SaveGame = new SaveGames.SaveStruct(GameType); + SaveGame = new PKX.SaveGames.SaveStruct(GameType); savegame_oras = oras; savefile = input; @@ -737,17 +732,6 @@ namespace PKHeX { setCountrySubRegion(CB_Country, "countries"); - // Set the various ComboBox DataSources up with their allowed entries - CB_3DSReg.DataSource = PKX.getUnsortedCBList("regions3ds"); - CB_Language.DataSource = PKX.getUnsortedCBList("languages"); - CB_Ball.DataSource = PKX.getCBList(itemlist, new int[] { 4 }, new int[] { 3 }, new int[] { 2 }, Legal.Items_UncommonBall); - CB_HeldItem.DataSource = PKX.getCBList(itemlist, (DEV_Ability.Enabled) ? null : Legal.Items_Held); - CB_Species.DataSource = PKX.getCBList(specieslist, null); - DEV_Ability.DataSource = PKX.getCBList(abilitylist, null); - CB_Nature.DataSource = PKX.getCBList(natures, null); - CB_EncounterType.DataSource = PKX.getCBList(encountertypelist, Legal.Gen4EncounterTypes); - CB_GameOrigin.DataSource = PKX.getCBList(gamelist, Legal.Games_6oras, Legal.Games_6xy, Legal.Games_5, Legal.Games_4, Legal.Games_4e, Legal.Games_4r, Legal.Games_3, Legal.Games_3e, Legal.Games_3r, Legal.Games_3s); - // Set the Display CB_3DSReg.DisplayMember = CB_Language.DisplayMember = @@ -770,14 +754,24 @@ namespace PKHeX CB_EncounterType.ValueMember = CB_GameOrigin.ValueMember = "Value"; + // Set the various ComboBox DataSources up with their allowed entries + CB_3DSReg.DataSource = Util.getUnsortedCBList("regions3ds"); + CB_Language.DataSource = Util.getUnsortedCBList("languages"); + CB_Ball.DataSource = Util.getCBList(itemlist, new int[] { 4 }, new int[] { 3 }, new int[] { 2 }, Legal.Items_UncommonBall); + CB_HeldItem.DataSource = Util.getCBList(itemlist, (DEV_Ability.Enabled) ? null : Legal.Items_Held); + CB_Species.DataSource = Util.getCBList(specieslist, null); + DEV_Ability.DataSource = Util.getCBList(abilitylist, null); + CB_Nature.DataSource = Util.getCBList(natures, null); + CB_EncounterType.DataSource = Util.getCBList(encountertypelist, Legal.Gen4EncounterTypes); + CB_GameOrigin.DataSource = Util.getCBList(gamelist, Legal.Games_6oras, Legal.Games_6xy, Legal.Games_5, Legal.Games_4, Legal.Games_4e, Legal.Games_4r, Legal.Games_3, Legal.Games_3e, Legal.Games_3r, Legal.Games_3s); // Set the Move ComboBoxes too.. { - var moves = PKX.getCBList(movelist, null); + var moves = Util.getCBList(movelist, null); foreach (ComboBox cb in new ComboBox[] { CB_Move1, CB_Move2, CB_Move3, CB_Move4, CB_RelearnMove1, CB_RelearnMove2, CB_RelearnMove3, CB_RelearnMove4 }) { - cb.DataSource = new BindingSource(moves, null); cb.DisplayMember = "Text"; cb.ValueMember = "Value"; + cb.DataSource = new BindingSource(moves, null); } } } @@ -1093,6 +1087,7 @@ namespace PKHeX cb.DataSource = form_list; cb.DisplayMember = "Text"; cb.ValueMember = "Value"; + cb.Enabled = false; return; } var form_unown = new[] { @@ -1373,12 +1368,6 @@ namespace PKHeX else if (species == 382 || species == 383) { form_list = form_primal; } else if (species == 720) { form_list = form_hoopa; } - else - { - cb.Enabled = false; - return; - }; - cb.DataSource = form_list; cb.Enabled = true; } @@ -1468,6 +1457,7 @@ namespace PKHeX // CB_GameOrigin.SelectedValue = game; + CB_GameOrigin.SelectedValue = game; CB_SubRegion.SelectedValue = subreg; CB_Country.SelectedValue = country; CB_3DSReg.SelectedValue = _3DSreg; @@ -1492,7 +1482,7 @@ namespace PKHeX { ComboBox CB = sender as ComboBox; int index = Util.getIndex(CB); - CB.DataSource = PKX.getCBList(type, curlanguage); + CB.DataSource = Util.getCBList(type, curlanguage); CB.DisplayMember = "Text"; CB.ValueMember = "Value"; @@ -1817,114 +1807,26 @@ namespace PKHeX { #region BW2 Met Locations { - // Allowed Met Locations - int[] metlocs = { 0, 60002, 30003 }; - - // Set up - List met_list = new List(); - - for (int i = 0; i < metlocs.Length; i++) // add entries to the top - { - cbItem ncbi = new cbItem(); - int locval = metlocs[i]; - string loctext = ""; - - if (locval < 30000) - loctext = metBW2_00000[locval]; - else if (locval < 40000) - loctext = metBW2_30000[locval % 10000 - 1]; - else if (locval < 60000) - loctext = metBW2_40000[locval % 10000 - 1]; - else - loctext = metBW2_60000[locval % 10000 - 1]; - - ncbi.Text = loctext; - ncbi.Value = locval; - met_list.Add(ncbi); - } - - metlocs = new int[] - { - 1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153, - 30001,30002,30004,30005,30006,30007,30008,30010,30011,30012,30013,30014,30015, - 40001,40002,40003,40004,40005,40006,40007,40008,40009,40010,40011,40012,40013,40014,40015,40016,40017,40018,40019,40020,40021,40022,40023,40024,40025,40026,40027,40028,40029,40030,40031,40032,40033,40034,40035,40036,40037,40038,40039,40040,40041,40042,40043,40044,40045,40046,40047,40048,40049,40050,40051,40052,40053,40054,40055,40056,40057,40058,40059,40060,40061,40062,40063,40064,40065,40066,40067,40068,40069,40070,40071,40072,40073,40074,40075,40076,40077,40078,40079,40080,40081,40082,40083,40084,40085,40086,40087,40088,40089,40090,40091,40092,40093,40094,40095,40096,40097,40098,40099,40100,40101,40102,40103,40104,40105,40106,40107,40108,40109, - 60001,60003 - }; - - // Sort the Rest based on String Name - string[] lt00000 = new string[metBW2_00000.Length]; - string[] lt30000 = new string[metBW2_30000.Length]; - string[] lt40000 = new string[metBW2_40000.Length]; - string[] lt60000 = new string[metBW2_60000.Length]; - Array.Copy(metBW2_00000, lt00000, metBW2_00000.Length); - Array.Copy(metBW2_30000, lt30000, metBW2_30000.Length); - Array.Copy(metBW2_40000, lt40000, metBW2_40000.Length); - Array.Copy(metBW2_60000, lt60000, metBW2_60000.Length); - Array.Sort(lt00000); - Array.Sort(lt30000); - Array.Sort(lt40000); - Array.Sort(lt60000); - - // Add the rest of the 00000 - for (int i = 0; i < lt00000.Length; i++) - { - int locnum = Array.IndexOf(metlocs, Array.IndexOf(metBW2_00000, lt00000[i]) + 00000); - if (locnum > 0) // If the location is allowed (if found, >0) - { - cbItem ncbi = new cbItem(); - ncbi.Text = lt00000[i]; - ncbi.Value = metlocs[locnum]; - met_list.Add(ncbi); - } - } - // Add the rest of the 30000 - for (int i = 0; i < lt30000.Length; i++) - { - int locnum = Array.IndexOf(metlocs, Array.IndexOf(metBW2_30000, lt30000[i]) + 30001); - if (locnum > 0) // If the location is allowed (if found, >0) - { - cbItem ncbi = new cbItem(); - ncbi.Text = lt30000[i]; - ncbi.Value = metlocs[locnum]; - met_list.Add(ncbi); - } - } - // Add the rest of the 40000 - for (int i = 0; i < lt40000.Length; i++) - { - int locnum = Array.IndexOf(metlocs, Array.IndexOf(metBW2_40000, lt40000[i]) + 40001); - if (locnum > 0) // If the location is allowed (if found, >0) - { - cbItem ncbi = new cbItem(); - ncbi.Text = lt40000[i]; - ncbi.Value = metlocs[locnum]; - met_list.Add(ncbi); - } - } - // Add the rest of the 60000 - for (int i = 0; i < lt60000.Length; i++) - { - int locnum = Array.IndexOf(metlocs, Array.IndexOf(metBW2_60000, lt60000[i]) + 60001); - if (locnum > 0) // If the location is allowed (if found, >0) - { - cbItem ncbi = new cbItem(); - ncbi.Text = lt60000[i]; - ncbi.Value = metlocs[locnum]; - met_list.Add(ncbi); - } - } - + // Build up our met list + var met_list = Util.getCBList(metBW2_00000, new int[] { 0 }); + met_list = Util.getOffsetCBList(met_list, metBW2_60000, 60001, new int[] { 60002 }); + met_list = Util.getOffsetCBList(met_list, metBW2_30000, 30001, new int[] { 30003 }); + met_list = Util.getOffsetCBList(met_list, metBW2_00000, 00000, Legal.Met_BW2_0); + met_list = Util.getOffsetCBList(met_list, metBW2_30000, 30001, Legal.Met_BW2_3); + met_list = Util.getOffsetCBList(met_list, metBW2_40000, 40001, Legal.Met_BW2_4); + met_list = Util.getOffsetCBList(met_list, metBW2_60000, 60001, Legal.Met_BW2_6); CB_MetLocation.DataSource = met_list; CB_MetLocation.DisplayMember = "Text"; CB_MetLocation.ValueMember = "Value"; CB_EggLocation.DataSource = new BindingSource(met_list, null); - origintrack = "Past"; CB_EggLocation.DisplayMember = "Text"; CB_EggLocation.ValueMember = "Value"; CB_EggLocation.SelectedValue = 0; if (gameorigin < 20) CB_MetLocation.SelectedValue = 30001; // Transporter - else CB_MetLocation.SelectedValue = 60001; // Stranger + else + CB_MetLocation.SelectedValue = 60001; // Stranger + origintrack = "Past"; } #endregion } @@ -1932,207 +1834,46 @@ namespace PKHeX { #region XY Met Locations { - // Allowed Met Locations - int[] metlocs = { 0, 60002, 30002 }; - - // Set up - List met_list = new List(); - - for (int i = 0; i < metlocs.Length; i++) // add entries to the top - { - cbItem ncbi = new cbItem(); - int locval = metlocs[i]; - string loctext = ""; - - if (locval < 30000) - loctext = metXY_00000[locval]; - else if (locval < 40000) - loctext = metXY_30000[locval % 10000 - 1]; - else if (locval < 60000) - loctext = metXY_40000[locval % 10000 - 1]; - else - loctext = metXY_60000[locval % 10000 - 1]; - - ncbi.Text = loctext; - ncbi.Value = locval; - met_list.Add(ncbi); - } - - metlocs = new int[] - { - 2,6,8,10,12,14,16,17,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168, - // ORAS - 170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,256,258,260,262,264,266,268,270,272,274,276,278,280,282,284,286,288,290,292,294,296,298,300,302,304,306,308,310,312,314,316,318,320,322,324,326,328,330,332,334,336,338,340,342,344,346,348,350,352,354, - - 30001,30003,30004,30005,30006,30007,30008,30009,30010,30011, - 40001,40002,40003,40004,40005,40006,40007,40008,40009,40010,40011,40012,40013,40014,40015,40016,40017,40018,40019,40020,40021,40022,40023,40024,40025,40026,40027,40028,40029,40030,40031,40032,40033,40034,40035,40036,40037,40038,40039,40040,40041,40042,40043,40044,40045,40046,40047,40048,40049,40050,40051,40052,40053,40054,40055,40056,40057,40058,40059,40060,40061,40062,40063,40064,40065,40066,40067,40068,40069,40070,40071,40072,40073,40074,40075,40076,40077,40078,40079, - 60001,60003, - // ORAS - 60004, - }; - - // Sort the Rest based on String Name - string[] lt00000 = new string[metXY_00000.Length]; - string[] lt30000 = new string[metXY_30000.Length]; - string[] lt40000 = new string[metXY_40000.Length]; - string[] lt60000 = new string[metXY_60000.Length]; - Array.Copy(metXY_00000, lt00000, metXY_00000.Length); - Array.Copy(metXY_30000, lt30000, metXY_30000.Length); - Array.Copy(metXY_40000, lt40000, metXY_40000.Length); - Array.Copy(metXY_60000, lt60000, metXY_60000.Length); - Array.Sort(lt00000); - Array.Sort(lt30000); - Array.Sort(lt40000); - Array.Sort(lt60000); - - // Add the rest of the 00000 - for (int i = 0; i < lt00000.Length; i++) - { - int locnum = Array.IndexOf(metlocs, Array.IndexOf(metXY_00000, lt00000[i]) + 00000); - if (locnum > 0) // If the location is allowed (if found, >0) - { - cbItem ncbi = new cbItem(); - ncbi.Text = lt00000[i]; - ncbi.Value = metlocs[locnum]; - met_list.Add(ncbi); - } - } - // Add the rest of the 30000 - for (int i = 0; i < lt30000.Length; i++) - { - int locnum = Array.IndexOf(metlocs, Array.IndexOf(metXY_30000, lt30000[i]) + 30001); - if (locnum > 0) // If the location is allowed (if found, >0) - { - cbItem ncbi = new cbItem(); - ncbi.Text = lt30000[i]; - ncbi.Value = metlocs[locnum]; - met_list.Add(ncbi); - } - } - // Add the rest of the 40000 - for (int i = 0; i < lt40000.Length; i++) - { - int locnum = Array.IndexOf(metlocs, Array.IndexOf(metXY_40000, lt40000[i]) + 40001); - if (locnum > 0) // If the location is allowed (if found, >0) - { - cbItem ncbi = new cbItem(); - ncbi.Text = lt40000[i]; - ncbi.Value = metlocs[locnum]; - met_list.Add(ncbi); - } - } - // Add the rest of the 60000 - for (int i = 0; i < lt60000.Length; i++) - { - int locnum = Array.IndexOf(metlocs, Array.IndexOf(metXY_60000, lt60000[i]) + 60001); - if (locnum > 0) // If the location is allowed (if found, >0) - { - cbItem ncbi = new cbItem(); - ncbi.Text = lt60000[i]; - ncbi.Value = metlocs[locnum]; - met_list.Add(ncbi); - } - } - + // Build up our met list + var met_list = Util.getCBList(metXY_00000, new int[] { 0 }); + met_list = Util.getOffsetCBList(met_list, metXY_60000, 60001, new int[] { 60002 }); + met_list = Util.getOffsetCBList(met_list, metXY_30000, 30001, new int[] { 30002 }); + met_list = Util.getOffsetCBList(met_list, metXY_00000, 00000, Legal.Met_XY_0); + met_list = Util.getOffsetCBList(met_list, metXY_30000, 30001, Legal.Met_XY_3); + met_list = Util.getOffsetCBList(met_list, metXY_40000, 40001, Legal.Met_XY_4); + met_list = Util.getOffsetCBList(met_list, metXY_60000, 60001, Legal.Met_XY_6); CB_MetLocation.DataSource = met_list; CB_MetLocation.DisplayMember = "Text"; CB_MetLocation.ValueMember = "Value"; CB_EggLocation.DataSource = new BindingSource(met_list, null); CB_EggLocation.DisplayMember = "Text"; CB_EggLocation.ValueMember = "Value"; - origintrack = "XY"; CB_EggLocation.SelectedValue = 0; CB_MetLocation.SelectedValue = 0; + origintrack = "XY"; } #endregion } - if (gameorigin < 13 && gameorigin > 6 && origintrack != "Gen4") + if (((gameorigin < 10 && gameorigin > 6) || (gameorigin == 15)) && origintrack != "Gen4") { // Egg Met Locations for Gen 4 are unaltered when transferred to Gen 5. Need a new table if Gen 4 Origin. #region HGSS Met Locations // Allowed Met Locations int[] metlocs = { 0, 2000, 2002, 3001 }; // Set up - List met_list = new List(); - - for (int i = 0; i < metlocs.Length; i++) // add entries to the top - { - cbItem ncbi = new cbItem(); - int locval = metlocs[i]; - string loctext = ""; - - if (locval < 2000) - loctext = metHGSS_00000[locval]; - else if (locval < 3000) - loctext = metHGSS_02000[locval % 2000]; - else - loctext = metHGSS_03000[locval % 3000]; - - ncbi.Text = loctext; - ncbi.Value = locval; - met_list.Add(ncbi); - } - - metlocs = new int[] - { - 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234, - 2000,2001,2002,2003,2004,2005,2006,2008,2009,2010,2011,2012,2013,2014, - 3000,3001,3002,3003,3004,3005,3006,3007,3008,3009,3010,3011,3012,3013,3014,3015,3016,3017,3018,3019,3020,3021,3022,3023,3024,3025,3026,3027,3028,3029,3030,3031,3032,3033,3034,3035,3036,3037,3038,3039,3040,3041,3042,3043,3044,3045,3046,3047,3048,3049,3050,3051,3052,3053,3054,3055,3056,3057,3058,3059,3060,3061,3062,3063,3064,3065,3066,3067,3068,3069,3070,3071,3072,3073,3074,3075,3076 - }; - - // Sort the Rest based on String Name - string[] lt00000 = new string[metHGSS_00000.Length]; - string[] lt02000 = new string[metHGSS_02000.Length]; - string[] lt03000 = new string[metHGSS_03000.Length]; - Array.Copy(metHGSS_00000, lt00000, metHGSS_00000.Length); - Array.Copy(metHGSS_02000, lt02000, metHGSS_02000.Length); - Array.Copy(metHGSS_03000, lt03000, metHGSS_03000.Length); - Array.Sort(lt00000); - Array.Sort(lt02000); - Array.Sort(lt03000); - - // Add the rest of the 0000 - for (int i = 0; i < lt00000.Length; i++) - { - int locnum = Array.IndexOf(metlocs, Array.IndexOf(metHGSS_00000, lt00000[i]) + 0000); - if (locnum > 0) // If the location is allowed (if found, >0) - { - cbItem ncbi = new cbItem(); - ncbi.Text = lt00000[i]; - ncbi.Value = metlocs[locnum]; - met_list.Add(ncbi); - } - } - // Add the rest of the 2000 - for (int i = 0; i < lt02000.Length; i++) - { - int locnum = Array.IndexOf(metlocs, Array.IndexOf(metHGSS_02000, lt02000[i]) + 2000); - if (locnum > 0) // If the location is allowed (if found, >0) - { - cbItem ncbi = new cbItem(); - ncbi.Text = lt02000[i]; - ncbi.Value = metlocs[locnum]; - met_list.Add(ncbi); - } - } - // Add the rest of the 3000 - for (int i = 0; i < lt03000.Length; i++) - { - int locnum = Array.IndexOf(metlocs, Array.IndexOf(metHGSS_03000, lt03000[i]) + 3000); - if (locnum > 0) // If the location is allowed (if found, >0) - { - cbItem ncbi = new cbItem(); - ncbi.Text = lt03000[i]; - ncbi.Value = metlocs[locnum]; - met_list.Add(ncbi); - } - } + var met_list = Util.getCBList(metHGSS_00000, new int[] { 0 }); + met_list = Util.getOffsetCBList(met_list, metHGSS_02000, 2000, new int[] { 2000 }); + met_list = Util.getOffsetCBList(met_list, metHGSS_02000, 2000, new int[] { 2002 }); + met_list = Util.getOffsetCBList(met_list, metHGSS_03000, 3000, new int[] { 3001 }); + met_list = Util.getOffsetCBList(met_list, metHGSS_00000, 0000, Legal.Met_HGSS_0); + met_list = Util.getOffsetCBList(met_list, metHGSS_02000, 2000, Legal.Met_HGSS_2); + met_list = Util.getOffsetCBList(met_list, metHGSS_03000, 3000, Legal.Met_HGSS_3); CB_EggLocation.DataSource = met_list; - origintrack = "Gen4"; CB_EggLocation.DisplayMember = "Text"; CB_EggLocation.ValueMember = "Value"; CB_EggLocation.SelectedValue = 0; + origintrack = "Gen4"; #endregion } } @@ -3846,12 +3587,12 @@ namespace PKHeX if (BitConverter.ToUInt32(savefile, 0x6A810 + 0x7F000 * savindex) == 0x42454546) { enableInterface = true; - SaveGame = new SaveGames.SaveStruct("XY"); + SaveGame = new PKX.SaveGames.SaveStruct("XY"); } else { Util.Error("Unrecognized Save File loaded."); - SaveGame = new SaveGames.SaveStruct("Error"); + SaveGame = new PKX.SaveGames.SaveStruct("Error"); } // Enable Buttons @@ -4478,7 +4219,7 @@ namespace PKHeX File.WriteAllBytes(newfile, dragdata); string[] filesToDrag = { newfile }; - (sender as PictureBox).DoDragDrop(new DataObject(DataFormats.FileDrop, filesToDrag), DragDropEffects.Move); + this.DoDragDrop(new DataObject(DataFormats.FileDrop, filesToDrag), DragDropEffects.Move); File.Delete(newfile); // after drop, delete the temporary file } catch (ArgumentException x) @@ -4550,111 +4291,4 @@ namespace PKHeX private int pkm_from_offset = 0; #endregion } - - #region Structs & Classes - public class cbItem - { - public string Text { get; set; } - public object Value { get; set; } - - public override string ToString() - { - return Text; - } - } - public class SaveGames - { - public struct SaveStruct - { - public int Box, TrainerCard, Party, BattleBox, GTS, Daycare, Fused, SUBE, Puff, Item, Trainer1, Trainer2, PCLayout, Wondercard, BerryField, OPower, EventFlag, PokeDex, HoF, PSS, JPEG; - public string Name; - public SaveStruct(string GameID) - { - if (GameID == "XY") - { - Name = "XY"; - Box = 0x27A00; - TrainerCard = 0x19400; - Party = 0x19600; - BattleBox = 0x09E00; - Daycare = 0x20600; - GTS = 0x1CC00; - Fused = 0x1B400; - SUBE = 0x22C90; - - Puff = 0x5400; - Item = 0x5800; - Trainer1 = 0x6800; - Trainer2 = 0x9600; - PCLayout = 0x9800; - Wondercard = 0x21000; - BerryField = 0x20C00; - OPower = 0x1BE00; - EventFlag = 0x19E00; - PokeDex = 0x1A400; - - HoF = 0x1E800; - JPEG = 0x5C600; - PSS = 0x0A400; - } - else if (GameID == "ORAS") - { - // Temp - Name = "ORAS"; - Box = 0x38400; // Confirmed - TrainerCard = 0x19400; // Confirmed - Party = 0x19600; // Confirmed - BattleBox = 0x09E00;// Confirmed - Daycare = 0x21000; // Confirmed (thanks Rei) - GTS = 0x1D600; // Confirmed - Fused = 0x1BE00; // Confirmed - SUBE = 0x22C90; // ****not in use, not updating?**** - - Puff = 0x5400; // Confirmed - Item = 0x5800; // Confirmed - Trainer1 = 0x6800; // Confirmed - Trainer2 = 0x9600; // Confirmed - PCLayout = 0x9800; // Confirmed - Wondercard = 0x22000; // Confirmed - BerryField = 0x20C00; // ****changed**** - OPower = 0x1BE00; - EventFlag = 0x19E00; // Confirmed - PokeDex = 0x1A400; - - HoF = 0x1F200; // Confirmed - JPEG = 0x6D000; // Confirmed - PSS = 0x0A400; // Confirmed (thanks Rei) - } - else - { - // Copied... - Name = "Unknown"; - Box = 0x27A00; - TrainerCard = 0x19400; - Party = 0x19600; - BattleBox = 0x09E00; - Daycare = 0x20600; - GTS = 0x1CC00; - Fused = 0x1B400; - SUBE = 0x22C90; - - Puff = 0x5400; - Item = 0x5800; - Trainer1 = 0x6800; - Trainer2 = 0x9600; - PCLayout = 0x9800; - Wondercard = 0x21000; - BerryField = 0x20C00; - OPower = 0x1BE00; - EventFlag = 0x19E00; - PokeDex = 0x1A400; - - HoF = 0x1E800; - JPEG = 0x5C600; - PSS = 0x0A400; - } - } - } - } - #endregion } \ No newline at end of file diff --git a/PKX/f3-MemoryAmie.cs b/PKX/f3-MemoryAmie.cs index acc0dd985..09a1ad1c9 100644 --- a/PKX/f3-MemoryAmie.cs +++ b/PKX/f3-MemoryAmie.cs @@ -665,5 +665,15 @@ namespace PKHeX mta[index].DisplayMember = "Text"; mta[index].ValueMember = "Value"; } + private class cbItem + { + public string Text { get; set; } + public object Value { get; set; } + + public override string ToString() + { + return Text; + } + } } } diff --git a/SAV/SAV_HallOfFame.cs b/SAV/SAV_HallOfFame.cs index 9ea19d8ef..c2654623e 100644 --- a/SAV/SAV_HallOfFame.cs +++ b/SAV/SAV_HallOfFame.cs @@ -81,113 +81,27 @@ namespace PKHeX #region Species { - List species_list = new List(); - // Sort the Rest based on String Name - string[] sortedspecies = new string[Form1.specieslist.Length]; - Array.Copy(Form1.specieslist, sortedspecies, Form1.specieslist.Length); - Array.Sort(sortedspecies); - - // Add the rest of the items - for (int i = 0; i < sortedspecies.Length; i++) - { - cbItem ncbi = new cbItem(); - ncbi.Text = sortedspecies[i]; - ncbi.Value = Array.IndexOf(Form1.specieslist, sortedspecies[i]); - species_list.Add(ncbi); - } - species_list.RemoveAt(0); // Remove 0th Entry CB_Species.DisplayMember = "Text"; CB_Species.ValueMember = "Value"; - CB_Species.DataSource = species_list; + CB_Species.DataSource = new BindingSource(m_parent.CB_Species.DataSource, null); } #endregion #region Moves { - string[] movelist = Form1.movelist; - List move_list = new List(); - // Sort the Rest based on String Name - string[] sortedmoves = new string[movelist.Length]; - Array.Copy(movelist, sortedmoves, movelist.Length); - Array.Sort(sortedmoves); - - // Add the rest of the items - for (int i = 0; i < sortedmoves.Length; i++) - { - cbItem ncbi = new cbItem(); - ncbi.Text = sortedmoves[i]; - ncbi.Value = Array.IndexOf(movelist, sortedmoves[i]); - move_list.Add(ncbi); - } - CB_Move1.DisplayMember = CB_Move2.DisplayMember = CB_Move3.DisplayMember = CB_Move4.DisplayMember = "Text"; CB_Move1.ValueMember = CB_Move2.ValueMember = CB_Move3.ValueMember = CB_Move4.ValueMember = "Value"; - var move1_list = new BindingSource(move_list, null); - CB_Move1.DataSource = move1_list; - - var move2_list = new BindingSource(move_list, null); - CB_Move2.DataSource = move2_list; - - var move3_list = new BindingSource(move_list, null); - CB_Move3.DataSource = move3_list; - - var move4_list = new BindingSource(move_list, null); - CB_Move4.DataSource = move4_list; + CB_Move1.DataSource = new BindingSource(m_parent.CB_Move1.DataSource, null); + CB_Move2.DataSource = new BindingSource(m_parent.CB_Move1.DataSource, null); + CB_Move3.DataSource = new BindingSource(m_parent.CB_Move1.DataSource, null); + CB_Move4.DataSource = new BindingSource(m_parent.CB_Move1.DataSource, null); } #endregion #region Items { - string[] itemlist = Form1.itemlist; - int[] item_nums = { - 000,001,002,003,004,005,006,007,008,009,010,011,012,013,014,015,017,018,019,020,021,022,023,024,025,026,027,028,029,030,031,032,033,034,035, - 036,037,038,039,040,041,042,043,044,045,046,047,048,049,050,051,052,053,054,055,056,057,058,059,060,061,062,063,064,065,066,067,068,069,070, - 071,072,073,074,075,076,077,078,079,080,081,082,083,084,085,086,087,088,089,090,091,092,093,094,099,100,101,102,103,104,105,106,107,108,109, - 110,112,116,117,118,119,134,135,136,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174, - 175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209, - 210,211,212,213,214,215,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244, - 245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279, - 280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314, - 315,316,317,318,319,320,321,322,323,324,325,326,327,504,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557, - 558,559,560,561,562,563,564,565,566,567,568,569,570,571,572,573,577,580,581,582,583,584,585,586,587,588,589,590,591,639,640,644,645,646,647, - 648,649,650,652,653,654,655,656,657,658,659,660,661,662,663,664,665,666,667,668,669,670,671,672,673,674,675,676,677,678,679,680,681,682,683, - 684,685,686,687,688,699,704,708,709,710,711,715, - - // Appended ORAS Items (Orbs & Mega Stones) - 534,535, - 752,753,754,755,756,757,758,759,760,761,762,763,764,767,768,769,770, - }; - - string filename = Path.GetFileNameWithoutExtension(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName); - - - if (filename.IndexOf("HaX") >= 0) // allow all items to be selected - { - item_nums = new int[itemlist.Length]; - for (int i = 0; i < itemlist.Length; i++) - item_nums[i] = i; - } - - List item_list = new List(); - // Sort the Rest based on String Name - string[] itemnames = new string[item_nums.Length]; - for (int i = 0; i < item_nums.Length; i++) - itemnames[i] = itemlist[item_nums[i]]; - - string[] sorteditems = new string[item_nums.Length]; - Array.Copy(itemnames, sorteditems, itemnames.Length); - Array.Sort(sorteditems); - - // Add the rest of the items - for (int i = 0; i < sorteditems.Length; i++) - { - cbItem ncbi = new cbItem(); - ncbi.Text = sorteditems[i]; - ncbi.Value = item_nums[Array.IndexOf(itemnames, sorteditems[i])]; - item_list.Add(ncbi); - } CB_HeldItem.DisplayMember = "Text"; CB_HeldItem.ValueMember = "Value"; - CB_HeldItem.DataSource = item_list; + CB_HeldItem.DataSource = new BindingSource(m_parent.CB_HeldItem.DataSource, null); } #endregion } diff --git a/SAV/SAV_PokedexORAS.cs b/SAV/SAV_PokedexORAS.cs index 63baa6f14..f68ad0c8c 100644 --- a/SAV/SAV_PokedexORAS.cs +++ b/SAV/SAV_PokedexORAS.cs @@ -44,20 +44,7 @@ namespace PKHeX // Fill List #region Species { - List species_list = new List(); - // Sort the Rest based on String Name - string[] sortedspecies = new string[Form1.specieslist.Length]; - Array.Copy(Form1.specieslist, sortedspecies, Form1.specieslist.Length); - Array.Sort(sortedspecies); - - // Add the rest of the items - for (int i = 0; i < sortedspecies.Length; i++) - { - cbItem ncbi = new cbItem(); - ncbi.Text = sortedspecies[i]; - ncbi.Value = Array.IndexOf(Form1.specieslist, sortedspecies[i]); - species_list.Add(ncbi); - } + var species_list = Util.getCBList(Form1.specieslist, null); species_list.RemoveAt(0); // Remove 0th Entry CB_Species.DisplayMember = "Text"; CB_Species.ValueMember = "Value"; @@ -120,7 +107,7 @@ namespace PKHeX // Load Bools for the data int pk = 0; try - { pk = (int)((PKHeX.cbItem)(CB_Species.SelectedItem)).Value; } + { pk = Util.getIndex(CB_Species); } catch { pk = (int)LB_Species.SelectedIndex + 1; } CheckBox[] CP = new CheckBox[] { diff --git a/SAV/SAV_PokedexXY.cs b/SAV/SAV_PokedexXY.cs index ca0660fc4..a5b1fca08 100644 --- a/SAV/SAV_PokedexXY.cs +++ b/SAV/SAV_PokedexXY.cs @@ -43,20 +43,7 @@ namespace PKHeX // Fill List #region Species { - List species_list = new List(); - // Sort the Rest based on String Name - string[] sortedspecies = new string[Form1.specieslist.Length]; - Array.Copy(Form1.specieslist, sortedspecies, Form1.specieslist.Length); - Array.Sort(sortedspecies); - - // Add the rest of the items - for (int i = 0; i < sortedspecies.Length; i++) - { - cbItem ncbi = new cbItem(); - ncbi.Text = sortedspecies[i]; - ncbi.Value = Array.IndexOf(Form1.specieslist, sortedspecies[i]); - species_list.Add(ncbi); - } + var species_list = Util.getCBList(Form1.specieslist, null); species_list.RemoveAt(0); // Remove 0th Entry CB_Species.DisplayMember = "Text"; CB_Species.ValueMember = "Value"; @@ -131,7 +118,7 @@ namespace PKHeX int pk = 0; try { - pk = (int)((PKHeX.cbItem)(CB_Species.SelectedItem)).Value; + pk = Util.getIndex(CB_Species); } catch { pk = (int)LB_Species.SelectedIndex + 1; } diff --git a/SAV/SAV_SecretBase.cs b/SAV/SAV_SecretBase.cs index 86ba4805f..09f3b5e55 100644 --- a/SAV/SAV_SecretBase.cs +++ b/SAV/SAV_SecretBase.cs @@ -50,163 +50,35 @@ namespace PKHeX private void setupComboBoxes() { - #region Balls { - // Allowed Balls - int[] ball_nums = { 7, 576, 13, 492, 497, 14, 495, 493, 496, 494, 11, 498, 8, 6, 12, 15, 9, 5, 499, 10, 1, 16 }; - int[] ball_vals = { 7, 25, 13, 17, 22, 14, 20, 18, 21, 19, 11, 23, 8, 6, 12, 15, 9, 5, 24, 10, 1, 16 }; - - // Set up - List ball_list = new List(); - - for (int i = 4; i > 1; i--) // add 4,3,2 - { - // First 3 Balls are always first - cbItem ncbi = new cbItem(); - ncbi.Text = itemlist[i]; - ncbi.Value = i; - ball_list.Add(ncbi); - } - - // Sort the Rest based on String Name - string[] ballnames = new string[ball_nums.Length]; - for (int i = 0; i < ball_nums.Length; i++) - ballnames[i] = itemlist[ball_nums[i]]; - - string[] sortedballs = new string[ball_nums.Length]; - Array.Copy(ballnames, sortedballs, ballnames.Length); - Array.Sort(sortedballs); - - // Add the rest of the balls - for (int i = 0; i < sortedballs.Length; i++) - { - cbItem ncbi = new cbItem(); - ncbi.Text = sortedballs[i]; - ncbi.Value = ball_vals[Array.IndexOf(ballnames, sortedballs[i])]; - ball_list.Add(ncbi); - } CB_Ball.DisplayMember = "Text"; CB_Ball.ValueMember = "Value"; - CB_Ball.DataSource = ball_list; + CB_Ball.DataSource = new BindingSource(m_parent.CB_Ball.DataSource, null); } - #endregion - #region Held Items { - // List of valid items to hold - int[] item_nums = { - 000,001,002,003,004,005,006,007,008,009,010,011,012,013,014,015,017,018,019,020,021,022,023,024,025,026,027,028,029,030,031,032,033,034,035, - 036,037,038,039,040,041,042,043,044,045,046,047,048,049,050,051,052,053,054,055,056,057,058,059,060,061,062,063,064,065,066,067,068,069,070, - 071,072,073,074,075,076,077,078,079,080,081,082,083,084,085,086,087,088,089,090,091,092,093,094,099,100,101,102,103,104,105,106,107,108,109, - 110,112,116,117,118,119,134,135,136,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174, - 175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209, - 210,211,212,213,214,215,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244, - 245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279, - 280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314, - 315,316,317,318,319,320,321,322,323,324,325,326,327,504,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557, - 558,559,560,561,562,563,564,565,566,567,568,569,570,571,572,573,577,580,581,582,583,584,585,586,587,588,589,590,591,639,640,644,645,646,647, - 648,649,650,652,653,654,655,656,657,658,659,660,661,662,663,664,665,666,667,668,669,670,671,672,673,674,675,676,677,678,679,680,681,682,683, - 684,685,686,687,688,699,704,708,709,710,711,715, - - // Appended ORAS Items (Orbs & Mega Stones) - 534,535, - 752,753,754,755,756,757,758,759,760,761,762,763,764,767,768,769,770, - }; - List item_list = new List(); - // Sort the Rest based on String Name - string[] itemnames = new string[item_nums.Length]; - for (int i = 0; i < item_nums.Length; i++) - itemnames[i] = itemlist[item_nums[i]]; - - string[] sorteditems = new string[item_nums.Length]; - Array.Copy(itemnames, sorteditems, itemnames.Length); - Array.Sort(sorteditems); - - // Add the rest of the items - for (int i = 0; i < sorteditems.Length; i++) - { - cbItem ncbi = new cbItem(); - ncbi.Text = sorteditems[i]; - ncbi.Value = item_nums[Array.IndexOf(itemnames, sorteditems[i])]; - item_list.Add(ncbi); - } CB_HeldItem.DisplayMember = "Text"; CB_HeldItem.ValueMember = "Value"; - CB_HeldItem.DataSource = item_list; + CB_HeldItem.DataSource = new BindingSource(m_parent.CB_HeldItem.DataSource, null); } - #endregion - #region Species { - List species_list = new List(); - // Sort the Rest based on String Name - string[] sortedspecies = new string[specieslist.Length]; - Array.Copy(specieslist, sortedspecies, specieslist.Length); - Array.Sort(sortedspecies); - - // Add the rest of the items - for (int i = 0; i < sortedspecies.Length; i++) - { - cbItem ncbi = new cbItem(); - ncbi.Text = sortedspecies[i]; - ncbi.Value = Array.IndexOf(specieslist, sortedspecies[i]); - species_list.Add(ncbi); - } CB_Species.DisplayMember = "Text"; CB_Species.ValueMember = "Value"; - CB_Species.DataSource = species_list; + CB_Species.DataSource = new BindingSource(m_parent.CB_Species.DataSource, null); } - #endregion - #region Natures { - List natures_list = new List(); - // Sort the Rest based on String Name - string[] sortednatures = new string[natures.Length]; - Array.Copy(natures, sortednatures, natures.Length); - Array.Sort(sortednatures); - - // Add the rest of the items - for (int i = 0; i < sortednatures.Length; i++) - { - cbItem ncbi = new cbItem(); - ncbi.Text = sortednatures[i]; - ncbi.Value = Array.IndexOf(natures, sortednatures[i]); - natures_list.Add(ncbi); - } CB_Nature.DisplayMember = "Text"; CB_Nature.ValueMember = "Value"; - CB_Nature.DataSource = natures_list; + CB_Nature.DataSource = new BindingSource(m_parent.CB_Nature.DataSource, null); } - #endregion #region Moves { - List move_list = new List(); - // Sort the Rest based on String Name - string[] sortedmoves = new string[movelist.Length]; - Array.Copy(movelist, sortedmoves, movelist.Length); - Array.Sort(sortedmoves); - - // Add the rest of the items - for (int i = 0; i < sortedmoves.Length; i++) - { - cbItem ncbi = new cbItem(); - ncbi.Text = sortedmoves[i]; - ncbi.Value = Array.IndexOf(movelist, sortedmoves[i]); - move_list.Add(ncbi); - } - CB_Move1.DisplayMember = CB_Move2.DisplayMember = CB_Move3.DisplayMember = CB_Move4.DisplayMember = "Text"; CB_Move1.ValueMember = CB_Move2.ValueMember = CB_Move3.ValueMember = CB_Move4.ValueMember = "Value"; - var move1_list = new BindingSource(move_list, null); - CB_Move1.DataSource = move1_list; - - var move2_list = new BindingSource(move_list, null); - CB_Move2.DataSource = move2_list; - - var move3_list = new BindingSource(move_list, null); - CB_Move3.DataSource = move3_list; - - var move4_list = new BindingSource(move_list, null); - CB_Move4.DataSource = move4_list; + CB_Move1.DataSource = new BindingSource(m_parent.CB_Move1.DataSource, null); + CB_Move2.DataSource = new BindingSource(m_parent.CB_Move1.DataSource, null); + CB_Move3.DataSource = new BindingSource(m_parent.CB_Move1.DataSource, null); + CB_Move4.DataSource = new BindingSource(m_parent.CB_Move1.DataSource, null); } #endregion } diff --git a/SAV/SAV_SuperTrain.cs b/SAV/SAV_SuperTrain.cs index 30425f65d..989299474 100644 --- a/SAV/SAV_SuperTrain.cs +++ b/SAV/SAV_SuperTrain.cs @@ -55,31 +55,15 @@ namespace PKHeX { dataGridView1.Rows.Clear(); dataGridView1.Columns.Clear(); - #region Species { - List species_list = new List(); - // Sort the Rest based on String Name - string[] sortedspecies = new string[specieslist.Length]; - Array.Copy(specieslist, sortedspecies, specieslist.Length); - Array.Sort(sortedspecies); - - // Add the rest of the items - for (int i = 0; i < sortedspecies.Length; i++) - { - cbItem ncbi = new cbItem(); - ncbi.Text = sortedspecies[i]; - ncbi.Value = Array.IndexOf(specieslist, sortedspecies[i]); - species_list.Add(ncbi); - } CB_Species.DisplayMember = "Text"; CB_Species.ValueMember = "Value"; - CB_Species.DataSource = species_list; + CB_Species.DataSource = new BindingSource(m_parent.CB_Species.DataSource, null); CB_S2.DisplayMember = "Text"; CB_S2.ValueMember = "Value"; - CB_S2.DataSource = new BindingSource(species_list, null); + CB_S2.DataSource = new BindingSource(m_parent.CB_Species.DataSource, null); } - #endregion listBox1.SelectedIndex = 0; fillTrainingBags(); diff --git a/SAV/frmReport.cs b/SAV/frmReport.cs index 0069f31d6..47240fcf5 100644 --- a/SAV/frmReport.cs +++ b/SAV/frmReport.cs @@ -26,7 +26,7 @@ namespace PKHeX SaveData = new byte[InputData.Length]; Array.Copy(InputData, SaveData, InputData.Length); PokemonList PL = new PokemonList(); - SaveGames.SaveStruct SaveGame = new SaveGames.SaveStruct("XY"); + PKX.SaveGames.SaveStruct SaveGame = new PKX.SaveGames.SaveStruct("XY"); if (savindex > 1) savindex = 0; for (int BoxNum = 0; BoxNum < 31; BoxNum++) {