From f091fa5ca96addae63fa5bc67e15126592ef3834 Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 17 Dec 2014 17:04:57 -0800 Subject: [PATCH] Simplifying Code and fixing ball population --- Misc/Legal.cs | 4 ++-- Misc/PKX.cs | 26 ++++++++++------------- Misc/Util.cs | 40 ++++++++++++++++++++++++++++++++++++ PKX/f1-Main.Designer.cs | 2 ++ PKX/f1-Main.cs | 4 +++- Resources/text/changelog.txt | 10 +++++++-- 6 files changed, 66 insertions(+), 20 deletions(-) diff --git a/Misc/Legal.cs b/Misc/Legal.cs index 3a0f65a15..f0e2ddaae 100644 --- a/Misc/Legal.cs +++ b/Misc/Legal.cs @@ -28,8 +28,8 @@ namespace PKHeX 752,753,754,755,756,757,758,759,760,761,762,763,764,767,768,769,770, }; internal static readonly int[] Items_Ball = { 4, 3, 2, 7, 576, 13, 492, 497, 14, 495, 493, 496, 494, 11, 498, 8, 6, 12, 15, 9, 5, 499, 10, 1, 16 }; - internal static readonly int[] Items_CommonBall = { 4, 3, 2 }; - internal static readonly int[] Items_UncommonBall = { 7, 576, 13, 492, 497, 14, 495, 493, 496, 494, 11, 498, 8, 6, 12, 15, 9, 5, 499, 10, 1, 16 }; + internal static readonly int[] Items_CommonBall = { 4, 3, 2, 1}; + internal static readonly int[] Items_UncommonBall = { 7, 576, 13, 492, 497, 14, 495, 493, 496, 494, 11, 498, 8, 6, 12, 15, 9, 5, 499, 10, 16 }; #endregion internal static readonly int[] Gen4EncounterTypes = { 2, 4, 9, 10, 24 }; #region Games diff --git a/Misc/PKX.cs b/Misc/PKX.cs index 14e7fc74a..f394a80cd 100644 --- a/Misc/PKX.cs +++ b/Misc/PKX.cs @@ -216,25 +216,21 @@ namespace PKHeX int growth = MonData.EXPGrowth; uint levelxp = (uint)table.Rows[tl][growth + 1]; - if (levelxp < exp) + while (levelxp < exp) { - while (levelxp < exp) + // While EXP for guessed level is below our current exp + tl += 1; + if (tl == 100) { - // While EXP for guessed level is below our current exp - tl += 1; - if (tl == 100) - { - exp = getEXP(100, species); - return tl; - } - levelxp = (uint)table.Rows[tl][growth + 1]; - // when calcexp exceeds our exp, we exit loop - } - if (levelxp == exp) // Matches level threshold + exp = getEXP(100, species); return tl; - else return (tl - 1); + } + levelxp = (uint)table.Rows[tl][growth + 1]; + // when calcexp >= our exp, we exit loop } - else return tl; + if (levelxp == exp) // Matches level threshold + return tl; + else return (tl - 1); } public static bool getIsShiny(uint PID, uint TID, uint SID) { diff --git a/Misc/Util.cs b/Misc/Util.cs index 0cc86d96a..a4757b0ab 100644 --- a/Misc/Util.cs +++ b/Misc/Util.cs @@ -431,6 +431,13 @@ namespace PKHeX return Text; } } + internal static string[] getFilteredList(string[] data, int[] chosen) + { + string[] result = new string[chosen.Length]; + for (int i = 0; i < chosen.Length; i++) + result[i] = data[chosen[i]]; + return result; + } internal static List getCBList(string textfile, string lang) { // Set up @@ -525,6 +532,39 @@ namespace PKHeX } return cbList; } + internal static List getVariedCBList(List cbList, string[] inStrings, int[] stringNum, int[] stringVal) + { + // Set up + List newlist = 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 = inStrings[i]; + ncbi.Value = i; + newlist.Add(ncbi); + } + + // Sort the Rest based on String Name + string[] ballnames = new string[stringNum.Length]; + for (int i = 0; i < stringNum.Length; i++) + ballnames[i] = inStrings[stringNum[i]]; + + string[] sortedballs = new string[stringNum.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 = stringVal[Array.IndexOf(ballnames, sortedballs[i])]; + newlist.Add(ncbi); + } + return newlist; + } internal static List getUnsortedCBList(string textfile) { // Set up diff --git a/PKX/f1-Main.Designer.cs b/PKX/f1-Main.Designer.cs index 19cb20afc..0134b087e 100644 --- a/PKX/f1-Main.Designer.cs +++ b/PKX/f1-Main.Designer.cs @@ -3277,6 +3277,7 @@ // PAN_BattleBox // this.PAN_BattleBox.BackgroundImage = global::PKHeX.Properties.Resources.party; + this.PAN_BattleBox.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.PAN_BattleBox.Controls.Add(this.bbpkx1); this.PAN_BattleBox.Controls.Add(this.bbpkx2); this.PAN_BattleBox.Controls.Add(this.bbpkx3); @@ -3385,6 +3386,7 @@ // PAN_Party // this.PAN_Party.BackgroundImage = global::PKHeX.Properties.Resources.party; + this.PAN_Party.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.PAN_Party.Controls.Add(this.ppkx1); this.PAN_Party.Controls.Add(this.ppkx2); this.PAN_Party.Controls.Add(this.ppkx3); diff --git a/PKX/f1-Main.cs b/PKX/f1-Main.cs index 82d75c693..4171c3d9d 100644 --- a/PKX/f1-Main.cs +++ b/PKX/f1-Main.cs @@ -765,7 +765,9 @@ namespace PKHeX // 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); + int[] ball_nums = new int[] { 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 = new int[] { 7, 25, 13, 17, 22, 14, 20, 18, 21, 19, 11, 23, 8, 6, 12, 15, 9, 5, 24, 10, 1, 16 }; + CB_Ball.DataSource = Util.getVariedCBList(Util.getCBList(itemlist, new int[] { 4 }, new int[] { 3 }, new int[] { 2 }, new int[] { 1 }), itemlist, ball_nums, ball_vals); 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); diff --git a/Resources/text/changelog.txt b/Resources/text/changelog.txt index 32c5c401b..65a72e9b9 100644 --- a/Resources/text/changelog.txt +++ b/Resources/text/changelog.txt @@ -410,9 +410,15 @@ http://projectpokemon.org/forums/showthread.php?36986 - Improved: Message popups should be much more appealing. - Fixed various bugs for drag&drop. -12/17/14 - New Update: +12/17/14 - New Update: (790) - Fixed: DexNav levels saving to species-1. - Fixed: EXP growth accessing the wrong exp table. - Fixed: Dragout sprite update triggering errors. - Changed: Gen4 Encounter Type will only appear for Pokemon that originate from Gen 4. - - Fixed: Some item sprites. \ No newline at end of file + - Fixed: Some item sprites. + +12/18/14 - New Update: + - Fixed: EXP-level defaulting to 100. + - Fixed: Abilities not populating correctly. + - Fixed: Balls not being set properly. + - Added: Some more PSS stat strings to the Trainer Editor. \ No newline at end of file