diff --git a/Misc/PGT.cs b/Misc/PGT.cs index 4336783a5..1ed29fe66 100644 --- a/Misc/PGT.cs +++ b/Misc/PGT.cs @@ -18,9 +18,9 @@ public PCD(byte[] data = null) Information = new byte[Data.Length - PGT.Size]; Array.Copy(Data, PGT.Size, Information, 0, Information.Length); } - public PGT Gift; + public readonly PGT Gift; - public byte[] Information; + public readonly byte[] Information; /* Big thanks to Grovyle91's Pokémon Mystery Gift Editor, from which the structure was referenced. * http://projectpokemon.org/forums/member.php?829-Grovyle91 * http://projectpokemon.org/forums/showthread.php?6524 @@ -64,7 +64,7 @@ public PK4 convertToPK4(SAV6 SAV) PK4 pk4 = new PK4(PK.Data); if (!IsPokémon && Detail == 0) { - pk4.OT_Name = "pk4HeX"; + pk4.OT_Name = "PKHeX"; pk4.TID = 12345; pk4.SID = 54321; pk4.OT_Gender = (int)(Util.rnd32()%2); diff --git a/Misc/PKM.cs b/Misc/PKM.cs index 7cb34415e..54b92d7db 100644 --- a/Misc/PKM.cs +++ b/Misc/PKM.cs @@ -21,12 +21,12 @@ internal static uint LCRNG(ref uint seed) } internal static Converter Config = new Converter(); - internal static string[] speclang_ja = Util.getStringList("Species", "ja"); - internal static string[] speclang_en = Util.getStringList("Species", "en"); - internal static string[] speclang_fr = Util.getStringList("Species", "fr"); - internal static string[] speclang_it = Util.getStringList("Species", "it"); - internal static string[] speclang_de = Util.getStringList("Species", "de"); - internal static string[] speclang_es = Util.getStringList("Species", "es"); + internal static readonly string[] speclang_ja = Util.getStringList("Species", "ja"); + internal static readonly string[] speclang_en = Util.getStringList("Species", "en"); + internal static readonly string[] speclang_fr = Util.getStringList("Species", "fr"); + internal static readonly string[] speclang_it = Util.getStringList("Species", "it"); + internal static readonly string[] speclang_de = Util.getStringList("Species", "de"); + internal static readonly string[] speclang_es = Util.getStringList("Species", "es"); internal static string TrimFromFFFF(string input) { diff --git a/Misc/PKX.cs b/Misc/PKX.cs index 20f70a854..bb0162d7f 100644 --- a/Misc/PKX.cs +++ b/Misc/PKX.cs @@ -153,7 +153,7 @@ internal static string getSpeciesName(int species, int lang) try { return SpeciesLang[lang][species]; } catch { return ""; } } - internal static PersonalInfo[] Personal = getPersonalArray(Properties.Resources.personal); + internal static readonly PersonalInfo[] Personal = getPersonalArray(Properties.Resources.personal); internal static PersonalInfo[] getPersonalArray(byte[] data) { PersonalInfo[] d = new PersonalInfo[data.Length / PersonalInfo.Size]; diff --git a/Misc/SAV6.cs b/Misc/SAV6.cs index b2f20046b..391f33121 100644 --- a/Misc/SAV6.cs +++ b/Misc/SAV6.cs @@ -29,11 +29,12 @@ public class SAV6 : PKX internal static bool SetUpdateDex = true; internal static bool SetUpdatePK6 = true; // Save Data Attributes - public byte[] Data, BAK; - public string FileName, FilePath; - public string BAKName => $"{FileName} [{OT} ({Version.ToString()}) - {LastSavedTime}].bak"; - public bool Exportable; + public byte[] Data; public bool Edited; + public readonly bool Exportable; + public readonly byte[] BAK; + public string FileName, FilePath; + public string BAKName => $"{FileName} [{OT} ({Version}) - {LastSavedTime}].bak"; public SAV6(byte[] data = null) { Data = (byte[])(data ?? new byte[SIZE_ORAS]).Clone(); @@ -165,7 +166,7 @@ public void getSAVOffsets() } public class Inventory { - public int HeldItem, KeyItem, Medicine, TMHM, Berry; + public readonly int HeldItem, KeyItem, Medicine, TMHM, Berry; public Inventory(int Offset, int Game) { switch (Game) diff --git a/PKX/f1-Main.cs b/PKX/f1-Main.cs index 90bc7bacf..19e4199ff 100644 --- a/PKX/f1-Main.cs +++ b/PKX/f1-Main.cs @@ -2456,7 +2456,7 @@ private void clickExportSAVBAK(object sender, EventArgs e) if (!Directory.Exists(BackupPath)) if (DialogResult.Yes == Util.Prompt(MessageBoxButtons.YesNo, $"PKHeX can perform automatic backups if you create a folder with the name \"{BackupPath}\" in the same folder as PKHeX's executable.", - $"Would you like to create the backup folder now and save backup of current save?")) + "Would you like to create the backup folder now and save backup of current save?")) try { Directory.CreateDirectory(BackupPath); Util.Alert("Backup folder created!", "If you wish to no longer automatically back up save files, delete the \"{BackupPath}\" folder."); } catch { Util.Error($"Unable to create backup folder @ {BackupPath}"); } diff --git a/SAV/SAV_SecretBase.cs b/SAV/SAV_SecretBase.cs index 164c63f3c..66dcf8b59 100644 --- a/SAV/SAV_SecretBase.cs +++ b/SAV/SAV_SecretBase.cs @@ -26,41 +26,26 @@ public SAV_SecretBase() private bool editing; private bool loading = true; - private static string[] abilitylist = { }; + private static string[] abilitylist; private void setupComboBoxes() { - { - CB_Ball.DisplayMember = "Text"; - CB_Ball.ValueMember = "Value"; - CB_Ball.DataSource = new BindingSource(Main.BallDataSource, null); - } - { - CB_HeldItem.DisplayMember = "Text"; - CB_HeldItem.ValueMember = "Value"; - CB_HeldItem.DataSource = new BindingSource(Main.ItemDataSource, null); - } - { - CB_Species.DisplayMember = "Text"; - CB_Species.ValueMember = "Value"; - CB_Species.DataSource = new BindingSource(Main.SpeciesDataSource, null); - } - { - CB_Nature.DisplayMember = "Text"; - CB_Nature.ValueMember = "Value"; - CB_Nature.DataSource = new BindingSource(Main.NatureDataSource, null); - } - #region Moves - { - 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"; + CB_Ball.DisplayMember = CB_HeldItem.DisplayMember = CB_Species.DisplayMember = CB_Nature.DisplayMember = "Text"; + CB_Ball.ValueMember = CB_HeldItem.ValueMember = CB_Species.ValueMember = CB_Nature.ValueMember = "Value"; - CB_Move1.DataSource = new BindingSource(Main.MoveDataSource, null); - CB_Move2.DataSource = new BindingSource(Main.MoveDataSource, null); - CB_Move3.DataSource = new BindingSource(Main.MoveDataSource, null); - CB_Move4.DataSource = new BindingSource(Main.MoveDataSource, null); - } - #endregion + CB_Ball.DataSource = new BindingSource(Main.BallDataSource, null); + CB_HeldItem.DataSource = new BindingSource(Main.ItemDataSource, null); + CB_Species.DataSource = new BindingSource(Main.SpeciesDataSource, null); + CB_Nature.DataSource = new BindingSource(Main.NatureDataSource, null); + + + 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"; + + CB_Move1.DataSource = new BindingSource(Main.MoveDataSource, null); + CB_Move2.DataSource = new BindingSource(Main.MoveDataSource, null); + CB_Move3.DataSource = new BindingSource(Main.MoveDataSource, null); + CB_Move4.DataSource = new BindingSource(Main.MoveDataSource, null); } // Repopulation Functions @@ -471,7 +456,7 @@ private void B_FDelete_Click(object sender, EventArgs e) int favoff = Main.SAV.SecretBase + 0x63A; string BaseTrainer = Util.TrimFromZero(Encoding.Unicode.GetString(sav, favoff + index * 0x3E0 + 0x218, 0x1A)); - if (BaseTrainer.Length < 1 || BaseTrainer[0] == '\0') + if (string.IsNullOrEmpty(BaseTrainer)) BaseTrainer = "Empty"; if (DialogResult.Yes != Util.Prompt(MessageBoxButtons.YesNo, $"Delete {BaseTrainer}'s base (Entry {index}) from your records?"))