From 59b41937e19730dd414014d2f699e1e6c8a4ed61 Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 6 Feb 2019 23:28:02 -0800 Subject: [PATCH] Misc variable name changes readability++ --- PKHeX.Core/Editing/Bulk/BatchEditor.cs | 8 ++--- PKHeX.Core/Game/GameStrings/GameStrings.cs | 2 +- PKHeX.Core/Game/GameStrings/GeoLocation.cs | 14 ++++---- .../Verifiers/VerifyCurrentMoves.cs | 2 +- PKHeX.Core/Legality/GBRestrictions.cs | 16 ++++----- PKHeX.Core/MysteryGifts/WB7.cs | 2 +- PKHeX.Core/MysteryGifts/WC6.cs | 2 +- PKHeX.Core/MysteryGifts/WC7.cs | 2 +- PKHeX.Core/PersonalInfo/PersonalInfo.cs | 8 ++--- PKHeX.Core/PersonalInfo/PersonalTable.cs | 8 ++--- PKHeX.Core/Saves/SAV4.cs | 8 ++--- PKHeX.Core/Saves/SAV6.cs | 22 ++++++------ PKHeX.Core/Saves/SAV7.cs | 22 ++++++------ PKHeX.Core/Util/RandUtil.cs | 6 ++-- .../Controls/PKM Editor/PKMEditor.cs | 24 ++++++------- .../Subforms/PKM Editors/MemoryAmie.cs | 36 +++++++++---------- .../Subforms/Save Editors/Gen3/SAV_Misc3.cs | 4 +-- .../Subforms/Save Editors/Gen4/SAV_Misc4.cs | 4 +-- .../Subforms/Save Editors/Gen5/SAV_Misc5.cs | 4 +-- .../Save Editors/Gen7/SAV_FestivalPlaza.cs | 10 +++--- .../Save Editors/Gen7/SAV_PokedexGG.cs | 8 ++--- .../Subforms/Save Editors/SAV_EventFlags.cs | 8 ++--- PKHeX.WinForms/Util/WinFormsTranslator.cs | 4 +-- 23 files changed, 111 insertions(+), 113 deletions(-) diff --git a/PKHeX.Core/Editing/Bulk/BatchEditor.cs b/PKHeX.Core/Editing/Bulk/BatchEditor.cs index 4904ef559..9d518148b 100644 --- a/PKHeX.Core/Editing/Bulk/BatchEditor.cs +++ b/PKHeX.Core/Editing/Bulk/BatchEditor.cs @@ -31,12 +31,12 @@ public bool ProcessPKM(PKM pkm, IEnumerable filters, IEnumera return false; } - var r = BatchEditing.TryModifyPKM(pkm, filters, modifications); - if (r != ModifyResult.Invalid) + var result = BatchEditing.TryModifyPKM(pkm, filters, modifications); + if (result != ModifyResult.Invalid) Iterated++; - if (r == ModifyResult.Error) + if (result == ModifyResult.Error) Errored++; - if (r != ModifyResult.Modified) + if (result != ModifyResult.Modified) return false; pkm.RefreshChecksum(); diff --git a/PKHeX.Core/Game/GameStrings/GameStrings.cs b/PKHeX.Core/Game/GameStrings/GameStrings.cs index e3608d1de..46b1610a4 100644 --- a/PKHeX.Core/Game/GameStrings/GameStrings.cs +++ b/PKHeX.Core/Game/GameStrings/GameStrings.cs @@ -136,7 +136,7 @@ private static string[] SanitizeMetStringsCXD(string[] cxd) var metSanitize = (string[])cxd.Clone(); for (int i = 0; i < metSanitize.Length; i++) { - if (cxd.Count(r => r == metSanitize[i]) > 1) + if (cxd.Count(z => z == metSanitize[i]) > 1) metSanitize[i] += $" [{i:000}]"; } diff --git a/PKHeX.Core/Game/GameStrings/GeoLocation.cs b/PKHeX.Core/Game/GameStrings/GeoLocation.cs index 6d0b3670c..4960b95e6 100644 --- a/PKHeX.Core/Game/GameStrings/GeoLocation.cs +++ b/PKHeX.Core/Game/GameStrings/GeoLocation.cs @@ -113,17 +113,17 @@ private static string GetRegionName(int countryID, int regionID, int l) /// /// Gets Country and Region strings for corresponding IDs and language. /// - /// Country ID - /// Region ID + /// Country ID + /// Region ID /// Language ID - /// - public static Tuple GetCountryRegionText(int country, int region, string language) + /// Tuple containing country and region + public static Tuple GetCountryRegionText(int countryID, int regionID, string language) { // Get Language we're fetching for int lang = Array.IndexOf(lang_geo, language); - string c = GetCountryName(country, lang); - string r = GetRegionName(country, region, lang); - return new Tuple(c, r); // country, region + var country = GetCountryName(countryID, lang); + var region = GetRegionName(countryID, regionID, lang); + return new Tuple(country, region); // country, region } private static int GetLanguageIndex(string language) => Array.IndexOf(lang_geo, language); diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs index e410d07ec..5917537fd 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs @@ -234,7 +234,7 @@ private static CheckMoveResult[] ParseMovesRelearn(PKM pkm, int[] Moves, LegalIn private static CheckMoveResult[] ParseMoves(PKM pkm, MoveParseSource source, LegalInfo info) { CheckMoveResult[] res = new CheckMoveResult[4]; - bool AllParsed() => res.All(r => r != null); + bool AllParsed() => res.All(z => z != null); var required = pkm.Format != 1 ? 1 : GBRestrictions.GetRequiredMoveCount(pkm, source.CurrentMoves, info, source.Base); // Check empty moves and relearn moves before generation specific moves diff --git a/PKHeX.Core/Legality/GBRestrictions.cs b/PKHeX.Core/Legality/GBRestrictions.cs index 58ea0eb2d..03de61706 100644 --- a/PKHeX.Core/Legality/GBRestrictions.cs +++ b/PKHeX.Core/Legality/GBRestrictions.cs @@ -59,19 +59,19 @@ internal static class GBRestrictions private static int[] GetMinLevelLearnMoveG1(int species, List moves) { - var r = new int[moves.Count]; - for (int i = 0; i < r.Length; i++) - r[i] = MoveLevelUp.GetIsLevelUp1(species, moves[i], 100, 0, 0).Level; - return r; + var result = new int[moves.Count]; + for (int i = 0; i < result.Length; i++) + result[i] = MoveLevelUp.GetIsLevelUp1(species, moves[i], 100, 0, 0).Level; + return result; } private static int[] GetMaxLevelLearnMoveG1(int species, List moves) { - var r = new int[moves.Count]; + var result = new int[moves.Count]; int index = PersonalTable.RB.GetFormeIndex(species, 0); if (index == 0) - return r; + return result; var pi_rb = ((PersonalInfoG1)PersonalTable.RB[index]).Moves; var pi_y = ((PersonalInfoG1)PersonalTable.Y[index]).Moves; @@ -79,10 +79,10 @@ private static int[] GetMaxLevelLearnMoveG1(int species, List moves) for (int m = 0; m < moves.Count; m++) { bool start = pi_rb.Contains(moves[m]) && pi_y.Contains(moves[m]); - r[m] = start ? 1 : Math.Max(GetHighest(LevelUpRB), GetHighest(LevelUpY)); + result[m] = start ? 1 : Math.Max(GetHighest(LevelUpRB), GetHighest(LevelUpY)); int GetHighest(IReadOnlyList learn) => learn[index].GetLevelLearnMove(moves[m]); } - return r; + return result; } private static List[] GetExclusiveMovesG1(int species1, int species2, IEnumerable tmhm, IEnumerable moves) diff --git a/PKHeX.Core/MysteryGifts/WB7.cs b/PKHeX.Core/MysteryGifts/WB7.cs index 8805ebf90..c20a35cc7 100644 --- a/PKHeX.Core/MysteryGifts/WB7.cs +++ b/PKHeX.Core/MysteryGifts/WB7.cs @@ -393,7 +393,7 @@ public override PKM ConvertToPKM(ITrainerInfo SAV, EncounterCriteria criteria) { int IVCount = ivflag - 0xFB; do { finalIVs[Util.Rand.Next(6)] = 31; } - while (finalIVs.Count(r => r == 31) < IVCount); + while (finalIVs.Count(iv => iv == 31) < IVCount); for (int i = 0; i < 6; i++) finalIVs[i] = finalIVs[i] == 31 ? pk.MaxIV : Util.Rand.Next(pk.MaxIV + 1); } diff --git a/PKHeX.Core/MysteryGifts/WC6.cs b/PKHeX.Core/MysteryGifts/WC6.cs index 8e7e1705c..8d51fbc6b 100644 --- a/PKHeX.Core/MysteryGifts/WC6.cs +++ b/PKHeX.Core/MysteryGifts/WC6.cs @@ -400,7 +400,7 @@ public override PKM ConvertToPKM(ITrainerInfo SAV, EncounterCriteria criteria) { int IVCount = ivflag - 0xFB; do { finalIVs[Util.Rand.Next(6)] = 31; } - while (finalIVs.Count(r => r == 31) < IVCount); + while (finalIVs.Count(iv => iv == 31) < IVCount); for (int i = 0; i < 6; i++) finalIVs[i] = finalIVs[i] == 31 ? pk.MaxIV : Util.Rand.Next(pk.MaxIV + 1); } diff --git a/PKHeX.Core/MysteryGifts/WC7.cs b/PKHeX.Core/MysteryGifts/WC7.cs index dfbf8f592..5fce98d50 100644 --- a/PKHeX.Core/MysteryGifts/WC7.cs +++ b/PKHeX.Core/MysteryGifts/WC7.cs @@ -431,7 +431,7 @@ public override PKM ConvertToPKM(ITrainerInfo SAV, EncounterCriteria criteria) { int IVCount = ivflag - 0xFB; do { finalIVs[Util.Rand.Next(6)] = 31; } - while (finalIVs.Count(r => r == 31) < IVCount); + while (finalIVs.Count(iv => iv == 31) < IVCount); for (int i = 0; i < 6; i++) finalIVs[i] = finalIVs[i] == 31 ? pk.MaxIV : Util.Rand.Next(pk.MaxIV + 1); } diff --git a/PKHeX.Core/PersonalInfo/PersonalInfo.cs b/PKHeX.Core/PersonalInfo/PersonalInfo.cs index 26cac3246..1d1787b32 100644 --- a/PKHeX.Core/PersonalInfo/PersonalInfo.cs +++ b/PKHeX.Core/PersonalInfo/PersonalInfo.cs @@ -242,10 +242,10 @@ protected static bool[] GetBits(byte[] data, int start = 0, int length = -1) { if (length < 0) length = data.Length; - bool[] r = new bool[length << 3]; - for (int i = 0; i < r.Length; i++) - r[i] = (data[start + (i >> 3)] >> (i & 7) & 0x1) == 1; - return r; + bool[] result = new bool[length << 3]; + for (int i = 0; i < result.Length; i++) + result[i] = (data[start + (i >> 3)] >> (i & 7) & 0x1) == 1; + return result; } protected static byte[] SetBits(bool[] bits) diff --git a/PKHeX.Core/PersonalInfo/PersonalTable.cs b/PKHeX.Core/PersonalInfo/PersonalTable.cs index 3c9639ba5..62e98865f 100644 --- a/PKHeX.Core/PersonalInfo/PersonalTable.cs +++ b/PKHeX.Core/PersonalInfo/PersonalTable.cs @@ -109,13 +109,13 @@ private static PersonalTable GetTable(string game, GameVersion format) private static byte[][] SplitBytes(byte[] data, int size) { - byte[][] r = new byte[data.Length / size][]; + byte[][] result = new byte[data.Length / size][]; for (int i = 0; i < data.Length; i += size) { - r[i / size] = new byte[size]; - Array.Copy(data, i, r[i / size], 0, size); + result[i / size] = new byte[size]; + Array.Copy(data, i, result[i / size], 0, size); } - return r; + return result; } private static Func GetConstructor(GameVersion format) diff --git a/PKHeX.Core/Saves/SAV4.cs b/PKHeX.Core/Saves/SAV4.cs index 92e534614..067e548db 100644 --- a/PKHeX.Core/Saves/SAV4.cs +++ b/PKHeX.Core/Saves/SAV4.cs @@ -778,10 +778,10 @@ protected override bool[] MysteryGiftReceivedFlags if (WondercardData < 0 || WondercardFlags < 0) return Array.Empty(); - bool[] r = new bool[GiftFlagMax]; - for (int i = 0; i < r.Length; i++) - r[i] = (Data[WondercardFlags + (i >> 3)] >> (i & 7) & 0x1) == 1; - return r; + bool[] result = new bool[GiftFlagMax]; + for (int i = 0; i < result.Length; i++) + result[i] = (Data[WondercardFlags + (i >> 3)] >> (i & 7) & 0x1) == 1; + return result; } set { diff --git a/PKHeX.Core/Saves/SAV6.cs b/PKHeX.Core/Saves/SAV6.cs index 2e314a1dd..5fb582f00 100644 --- a/PKHeX.Core/Saves/SAV6.cs +++ b/PKHeX.Core/Saves/SAV6.cs @@ -977,10 +977,10 @@ protected override bool[] MysteryGiftReceivedFlags if (WondercardData < 0 || WondercardFlags < 0) return Array.Empty(); - bool[] r = new bool[(WondercardData - WondercardFlags) * 8]; - for (int i = 0; i < r.Length; i++) - r[i] = (Data[WondercardFlags + (i >> 3)] >> (i & 7) & 0x1) == 1; - return r; + bool[] result = new bool[(WondercardData - WondercardFlags) * 8]; + for (int i = 0; i < result.Length; i++) + result[i] = (Data[WondercardFlags + (i >> 3)] >> (i & 7) & 0x1) == 1; + return result; } set { @@ -1104,27 +1104,27 @@ public ushort[][] GymTeams // Writeback Validity public override string MiscSaveChecks() { - var r = new StringBuilder(); + var sb = new StringBuilder(); // FFFF checks for (int i = 0; i < Data.Length / 0x200; i++) { if (Data.Skip(i * 0x200).Take(0x200).Any(z => z != 0xFF)) continue; - r.Append("0x200 chunk @ 0x").AppendFormat("{0:X5}", i * 0x200).AppendLine(" is FF'd."); - r.AppendLine("Cyber will screw up (as of August 31st 2014)."); - r.AppendLine(); + sb.Append("0x200 chunk @ 0x").AppendFormat("{0:X5}", i * 0x200).AppendLine(" is FF'd."); + sb.AppendLine("Cyber will screw up (as of August 31st 2014)."); + sb.AppendLine(); // Check to see if it is in the Pokedex if (i * 0x200 > PokeDex && i * 0x200 < PokeDex + 0x900) { - r.Append("Problem lies in the Pokedex. "); + sb.Append("Problem lies in the Pokedex. "); if (i * 0x200 == PokeDex + 0x400) - r.Append("Remove a language flag for a species < 585, ie Petilil"); + sb.Append("Remove a language flag for a species < 585, ie Petilil"); } break; } - return r.ToString(); + return sb.ToString(); } public override string MiscSaveInfo() => string.Join(Environment.NewLine, Blocks.Select(b => b.Summary)); diff --git a/PKHeX.Core/Saves/SAV7.cs b/PKHeX.Core/Saves/SAV7.cs index 244794759..092a13f23 100644 --- a/PKHeX.Core/Saves/SAV7.cs +++ b/PKHeX.Core/Saves/SAV7.cs @@ -1413,10 +1413,10 @@ protected override bool[] MysteryGiftReceivedFlags if (WondercardData < 0 || WondercardFlags < 0) return Array.Empty(); - bool[] r = new bool[(WondercardData-WondercardFlags)*8]; - for (int i = 0; i < r.Length; i++) - r[i] = (Data[WondercardFlags + (i>>3)] >> (i&7) & 0x1) == 1; - return r; + bool[] result = new bool[(WondercardData-WondercardFlags)*8]; + for (int i = 0; i < result.Length; i++) + result[i] = (Data[WondercardFlags + (i>>3)] >> (i&7) & 0x1) == 1; + return result; } set { @@ -1488,27 +1488,27 @@ private void SetWC7(MysteryGift wc7, int index) // Writeback Validity public override string MiscSaveChecks() { - var r = new StringBuilder(); + var sb = new StringBuilder(); // FFFF checks for (int i = 0; i < Data.Length / 0x200; i++) { if (Data.Skip(i * 0x200).Take(0x200).Any(z => z != 0xFF)) continue; - r.Append("0x200 chunk @ 0x").AppendFormat("{0:X5}", i * 0x200).AppendLine(" is FF'd."); - r.AppendLine("Cyber will screw up (as of August 31st 2014)."); - r.AppendLine(); + sb.Append("0x200 chunk @ 0x").AppendFormat("{0:X5}", i * 0x200).AppendLine(" is FF'd."); + sb.AppendLine("Cyber will screw up (as of August 31st 2014)."); + sb.AppendLine(); // Check to see if it is in the Pokedex if (i * 0x200 > PokeDex && i * 0x200 < PokeDex + 0x900) { - r.Append("Problem lies in the Pokedex. "); + sb.Append("Problem lies in the Pokedex. "); if (i * 0x200 == PokeDex + 0x400) - r.Append("Remove a language flag for a species < 585, ie Petilil"); + sb.Append("Remove a language flag for a species < 585, ie Petilil"); } break; } - return r.ToString(); + return sb.ToString(); } public override string MiscSaveInfo() => string.Join(Environment.NewLine, Blocks.Select(b => b.Summary)); diff --git a/PKHeX.Core/Util/RandUtil.cs b/PKHeX.Core/Util/RandUtil.cs index 9ea4ed542..9cd59fcbd 100644 --- a/PKHeX.Core/Util/RandUtil.cs +++ b/PKHeX.Core/Util/RandUtil.cs @@ -22,9 +22,9 @@ public static void Shuffle(IList items) int n = items.Count; for (int i = 0; i < n; i++) { - int r = i + Rand.Next(n-i); - T t = items[r]; - items[r] = items[i]; + int index = i + Rand.Next(n-i); + T t = items[index]; + items[index] = items[i]; items[i] = t; } } diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs index a7cdcdd7d..cd7293bd5 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs @@ -742,8 +742,8 @@ private bool SetSuggestedMoves(bool random = false, bool silent = false) if (!silent) { var movestrings = m.Select(v => v >= GameInfo.Strings.Move.Count ? MsgProgramError : GameInfo.Strings.Move[v]); - string r = string.Join(Environment.NewLine, movestrings); - if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgPKMSuggestionMoves, r)) + var msg = string.Join(Environment.NewLine, movestrings); + if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgPKMSuggestionMoves, msg)) return false; } @@ -758,23 +758,21 @@ private bool SetSuggestedRelearnMoves(bool silent = false) { if (pkm.Format < 6) return false; - int[] m = pkm.GetSuggestedRelearnMoves(Legality); + var m = pkm.GetSuggestedRelearnMoves(Legality); if (pkm.RelearnMoves.SequenceEqual(m)) return false; if (!silent) { var movestrings = m.Select(v => v >= GameInfo.Strings.Move.Count ? MsgProgramError : GameInfo.Strings.Move[v]); - string r = string.Join(Environment.NewLine, movestrings); - if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgPKMSuggestionRelearn, r)) + var msg = string.Join(Environment.NewLine, movestrings); + if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgPKMSuggestionRelearn, msg)) return false; } - CB_RelearnMove1.SelectedValue = m[0]; - CB_RelearnMove2.SelectedValue = m[1]; - CB_RelearnMove3.SelectedValue = m[2]; - CB_RelearnMove4.SelectedValue = m[3]; + pkm.RelearnMoves = m; + LoadRelearnMoves(pkm); return true; } @@ -801,12 +799,12 @@ private bool SetSuggestedMetLocation(bool silent = false) if (!silent) { - List suggestion = GetSuggestionMessage(pkm, level, location, minlvl); - if (suggestion.Count == 1) // no suggestion + var suggestions = GetSuggestionMessage(pkm, level, location, minlvl); + if (suggestions.Count <= 1) // no suggestion return false; - string suggest = string.Join(Environment.NewLine, suggestion); - if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, suggest) != DialogResult.Yes) + var msg = string.Join(Environment.NewLine, suggestions); + if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, msg) != DialogResult.Yes) return false; } diff --git a/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs b/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs index 2c754c9e6..e8a5958dd 100644 --- a/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs +++ b/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs @@ -13,25 +13,25 @@ public MemoryAmie(PKM pk) InitializeComponent(); WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage); pkm = pk; - cba = new[] { CB_Country0, CB_Country1, CB_Country2, CB_Country3, CB_Country4 }; - mta = new[] { CB_Region0, CB_Region1, CB_Region2, CB_Region3, CB_Region4, }; + PrevCountries = new[] { CB_Country0, CB_Country1, CB_Country2, CB_Country3, CB_Country4 }; + PrevRegions = new[] { CB_Region0, CB_Region1, CB_Region2, CB_Region3, CB_Region4, }; string[] arguments = L_Arguments.Text.Split(new[] {" ; "}, StringSplitOptions.None); TextArgs = new TextMarkup(arguments); - foreach (ComboBox comboBox in cba) + foreach (ComboBox comboBox in PrevCountries) { comboBox.InitializeBinding(); Main.SetCountrySubRegion(comboBox, "countries"); } - foreach (var r in mta) - r.InitializeBinding(); + foreach (var region in PrevRegions) + region.InitializeBinding(); GetLangStrings(); LoadFields(); } private bool init; - private readonly ComboBox[] cba; - private readonly ComboBox[] mta; + private readonly ComboBox[] PrevCountries; + private readonly ComboBox[] PrevRegions; private readonly PKM pkm; // Load/Save Actions @@ -267,18 +267,18 @@ private void ChangeMemory(object sender, EventArgs e) private void ChangeCountryIndex(object sender, EventArgs e) { - int index = Array.IndexOf(cba, sender); + int index = Array.IndexOf(PrevCountries, sender); int val; if (sender is ComboBox c && (val = WinFormsUtil.GetIndex(c)) > 0) { - Main.SetCountrySubRegion(mta[index], $"sr_{val:000}"); - mta[index].Enabled = true; + Main.SetCountrySubRegion(PrevRegions[index], $"sr_{val:000}"); + PrevRegions[index].Enabled = true; } else { - mta[index].DataSource = new[] { new { Text = "", Value = 0 } }; - mta[index].Enabled = false; - mta[index].SelectedValue = 0; + PrevRegions[index].DataSource = new[] { new { Text = "", Value = 0 } }; + PrevRegions[index].Enabled = false; + PrevRegions[index].SelectedValue = 0; } } @@ -301,17 +301,17 @@ private void ClickResetLocation(object sender, EventArgs e) { Label[] senderarr = { L_Geo0, L_Geo1, L_Geo2, L_Geo3, L_Geo4, }; int index = Array.IndexOf(senderarr, sender); - cba[index].SelectedValue = 0; + PrevCountries[index].SelectedValue = 0; - mta[index].InitializeBinding(); - mta[index].DataSource = new[] { new { Text = "", Value = 0 } }; - mta[index].SelectedValue = 0; + PrevRegions[index].InitializeBinding(); + PrevRegions[index].DataSource = new[] { new { Text = "", Value = 0 } }; + PrevRegions[index].SelectedValue = 0; } private void B_ClearAll_Click(object sender, EventArgs e) { for (int i = 0; i < 5; i++) - cba[i].SelectedValue = 0; + PrevCountries[i].SelectedValue = 0; } private class TextMarkup diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.cs index ba96c109d..dca51a6e5 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.cs @@ -269,8 +269,8 @@ private void ChangeStat1(object sender, EventArgs e) if (facility < 0 || facility >= BFN.Length) return; editingcont = true; CB_Stats2.Items.Clear(); - foreach (RadioButton r in StatRBA) - r.Checked = false; + foreach (RadioButton rb in StatRBA) + rb.Checked = false; if (BFT[BFF[facility][1]] == null) { diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen4/SAV_Misc4.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen4/SAV_Misc4.cs index 867ce5575..beac1aae3 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen4/SAV_Misc4.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen4/SAV_Misc4.cs @@ -562,8 +562,8 @@ private void ChangeStat1(object sender, EventArgs e) CB_Stats2.Items.AddRange(BFT[BFF[facility][1]]); StatRBA[0].Checked = true; - foreach (RadioButton r in StatRBA) - r.Visible = r.Enabled = facility == 1; + foreach (RadioButton rb in StatRBA) + rb.Visible = rb.Enabled = facility == 1; for (int i = 0; i < StatLabelA.Length; i++) StatLabelA[i].Visible = StatLabelA[i].Enabled = StatNUDA[i].Visible = StatNUDA[i].Enabled = Array.IndexOf(BFV[BFF[facility][0]], i) >= 0; diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Misc5.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Misc5.cs index 7b11a74c7..f5fe2cec4 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Misc5.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Misc5.cs @@ -660,8 +660,8 @@ private void B_RandForest_Click(object sender, EventArgs e) var source = (SAV.B2W2 ? Encounters5.B2W2_DreamWorld : Encounters5.BW_DreamWorld).ToList(); foreach (var s in AllSlots) { - int r = Util.Rand.Next(source.Count); - var slot = source[r]; + int index = Util.Rand.Next(source.Count); + var slot = source[index]; source.Remove(slot); s.Species = slot.Species; s.Form = slot.Form; diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_FestivalPlaza.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_FestivalPlaza.cs index 3c0843470..c4ecb2f38 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_FestivalPlaza.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_FestivalPlaza.cs @@ -81,9 +81,9 @@ public SAV_FestivalPlaza(SaveFile sav) string[] res2 = { "Rank 4: missions","Rank 8: facility","Rank 10: fashion","Rank 20: rename","Rank 30: special menu","Rank 40: BGM","Rank 50: theme Glitz","Rank 60: theme Fairy","Rank 70: theme Tone","Rank 100: phrase","Current Rank", }; CLB_Reward.Items.Clear(); - CLB_Reward.Items.Add(res2.Last(), (CheckState)r[SAV.GetFestPrizeReceived(10)]); //add CurrentRank before const-rewards + CLB_Reward.Items.Add(res2.Last(), (CheckState)RewardState[SAV.GetFestPrizeReceived(10)]); //add CurrentRank before const-rewards for (int i = 0; i < res2.Length - 1; i++) - CLB_Reward.Items.Add(res2[i], (CheckState)r[SAV.GetFestPrizeReceived(i)]); + CLB_Reward.Items.Add(res2[i], (CheckState)RewardState[SAV.GetFestPrizeReceived(i)]); for (int i = 0; i < 7; i++) f[i] = new FestaFacility(SAV, i); @@ -164,7 +164,7 @@ public SAV_FestivalPlaza(SaveFile sav) } private bool editing; - private readonly byte[] r = { 0, 2, 1 }; // CheckState.Indeterminate <-> CheckState.Checked + private readonly byte[] RewardState = { 0, 2, 1 }; // CheckState.Indeterminate <-> CheckState.Checked private readonly int typeMAX; private readonly FestaFacility[] f = new FestaFacility[7]; private readonly string[] RES_Color = { "Red", "Blue", "Gold", "Black", "Purple", "Yellow", "Brown", "Green", "Orange", "NavyBlue", "Pink", "White" }; @@ -264,9 +264,9 @@ private void Save() SAV.FestaCoins = (uint)NUD_FC_Current.Value; SAV.FestaDate = new DateTime(CAL_FestaStartDate.Value.Year, CAL_FestaStartDate.Value.Month, CAL_FestaStartDate.Value.Day, CAL_FestaStartTime.Value.Hour, CAL_FestaStartTime.Value.Minute, CAL_FestaStartTime.Value.Second); - SAV.SetFestaPrizeReceived(10, r[(int)CLB_Reward.GetItemCheckState(0)]); + SAV.SetFestaPrizeReceived(10, RewardState[(int)CLB_Reward.GetItemCheckState(0)]); for (int i = 1; i < CLB_Reward.Items.Count; i++) - SAV.SetFestaPrizeReceived(i - 1, r[(int)CLB_Reward.GetItemCheckState(i)]); + SAV.SetFestaPrizeReceived(i - 1, RewardState[(int)CLB_Reward.GetItemCheckState(i)]); SaveFacility(); foreach (FestaFacility facility in f) diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexGG.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexGG.cs index f05c719a2..d207e9bf7 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexGG.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexGG.cs @@ -425,14 +425,14 @@ private void SetRecords() { if (!GB_SizeRecords.Enabled) return; - for (var r = 0; r < RecordUsed.Length; r++) + for (var i = 0; i < RecordUsed.Length; i++) { - var ck = RecordUsed[r]; + var ck = RecordUsed[i]; if (ck.Checked) continue; ck.Checked = true; - RecordHeight[r].Value = r % 2 == 0 ? 0 : 255; - RecordWeight[r].Value = r % 2 == 0 ? 0 : 255; + RecordHeight[i].Value = i % 2 == 0 ? 0 : 255; + RecordWeight[i].Value = i % 2 == 0 ? 0 : 255; } } diff --git a/PKHeX.WinForms/Subforms/Save Editors/SAV_EventFlags.cs b/PKHeX.WinForms/Subforms/Save Editors/SAV_EventFlags.cs index 7a57d993c..0c6eeb4f6 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/SAV_EventFlags.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/SAV_EventFlags.cs @@ -475,7 +475,7 @@ private void DiffSaves() var tbIsSet = new List(); var tbUnSet = new List(); - var r = new List(); + var result = new List(); bool[] oldBits = s1.EventFlags; bool[] newBits = s2.EventFlags; var oldConst = s1.EventConsts; @@ -492,17 +492,17 @@ private void DiffSaves() for (int i = 0; i < newConst.Length; i++) { if (oldConst[i] != newConst[i]) - r.Add($"{i}: {oldConst[i]}->{newConst[i]}"); + result.Add($"{i}: {oldConst[i]}->{newConst[i]}"); } - if (r.Count == 0) + if (result.Count == 0) { WinFormsUtil.Alert("No Event Constant diff found."); return; } if (DialogResult.Yes == WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Copy Event Constant diff to clipboard?")) - Clipboard.SetText(string.Join(Environment.NewLine, r)); + Clipboard.SetText(string.Join(Environment.NewLine, result)); } private static void Main_DragEnter(object sender, DragEventArgs e) diff --git a/PKHeX.WinForms/Util/WinFormsTranslator.cs b/PKHeX.WinForms/Util/WinFormsTranslator.cs index a42595431..d7fbde366 100644 --- a/PKHeX.WinForms/Util/WinFormsTranslator.cs +++ b/PKHeX.WinForms/Util/WinFormsTranslator.cs @@ -210,8 +210,8 @@ public class TranslationContext public TranslationContext(IEnumerable content, char separator = Separator) { var entries = content.Select(z => z.Split(separator)).Where(z => z.Length == 2); - foreach (var r in entries.Where(z => !Translation.ContainsKey(z[0]))) - Translation.Add(r[0], r[1]); + foreach (var kvp in entries.Where(z => !Translation.ContainsKey(z[0]))) + Translation.Add(kvp[0], kvp[1]); } public string GetTranslatedText(string val, string fallback)