Refactoring

Merging declaration and assignment outside of form constructor.

Alert user if they tried to set Eon Ticket to X/Y.
This commit is contained in:
Kaphotics 2016-02-11 00:43:44 -08:00
parent d2214f4fa1
commit f296154d30
12 changed files with 18 additions and 26 deletions

View file

@ -9,7 +9,6 @@ namespace PKHeX
{
InitializeComponent();
Util.TranslateInterface(this, Main.curlanguage);
sav = (byte[])Main.SAV.Data.Clone();
nup_spec = new[] { NUP_Red, NUP_Blue, NUP_Pink, NUP_Green, NUP_Yellow, NUP_Rainbow, NUP_RedPlus, NUP_BluePlus, NUP_PinkPlus, NUP_GreenPlus, NUP_YellowPlus, NUP_RainbowPlus };
Label[] lbl_spec = { L_Red, L_Blue, L_Pink, L_Green, L_Yellow, L_Rainbow, L_RedPlus, L_BluePlus, L_PinkPlus, L_GreenPlus, L_YellowPlus, L_RainbowPlus };
@ -20,7 +19,7 @@ namespace PKHeX
}
}
private readonly NumericUpDown[] nup_spec;
private readonly byte[] sav;
private readonly byte[] sav = (byte[])Main.SAV.Data.Clone();
private void B_Cancel_Click(object sender, EventArgs e)
{

View file

@ -9,10 +9,9 @@ namespace PKHeX
{
InitializeComponent();
Util.TranslateInterface(this, Main.curlanguage);
sav = (byte[])Main.SAV.Data.Clone();
listBox1.SelectedIndex = 0;
}
public readonly byte[] sav;
private readonly byte[] sav = (byte[])Main.SAV.Data.Clone();
private void changefield(object sender, EventArgs e)
{

View file

@ -10,7 +10,6 @@ namespace PKHeX
{
InitializeComponent();
Util.TranslateInterface(this, Main.curlanguage);
sav = new SAV6((byte[])Main.SAV.Data.Clone());
editing = true;
// Repopulate Wallpaper names
@ -24,8 +23,8 @@ namespace PKHeX
MT_BG2.Text = sav.Data[sav.PCFlags + 2].ToString();
LB_BoxSelect.SelectedIndex = box;
}
public SAV6 sav;
public bool editing;
private readonly SAV6 sav = new SAV6((byte[])Main.SAV.Data.Clone());
private bool editing;
private void changeBox(object sender, EventArgs e)
{

View file

@ -23,9 +23,9 @@ namespace PKHeX
MT_Ash.Text = BitConverter.ToUInt16(Main.SAV.Data, Main.SAV.EventAsh).ToString();
}
private bool setup = true;
public CheckBox[] chka;
public readonly bool[] flags = new bool[3072];
public readonly ushort[] Constants = new ushort[(Main.SAV.EventFlag - Main.SAV.EventConst) / 2];
private CheckBox[] chka;
private readonly bool[] flags = new bool[3072];
private readonly ushort[] Constants = new ushort[(Main.SAV.EventFlag - Main.SAV.EventConst) / 2];
private void B_Cancel_Click(object sender, EventArgs e)
{
Close();

View file

@ -10,7 +10,6 @@ namespace PKHeX
{
InitializeComponent();
Util.TranslateInterface(this, Main.curlanguage);
sav = (byte[])Main.SAV.Data.Clone();
item_val = getItems(Main.SAV.ORAS ? Legal.Pouch_Items_ORAS : Legal.Pouch_Items_XY);
keyitem_val = getItems(Main.SAV.ORAS ? Legal.Pouch_Key_ORAS : Legal.Pouch_Key_XY);
@ -30,7 +29,7 @@ namespace PKHeX
B_DisplayKeyItems.Text = Main.itempouch[4];
}
private readonly byte[] sav;
private readonly byte[] sav = (byte[])Main.SAV.Data.Clone();
private readonly string[] item_val, keyitem_val, tmhm_val, medicine_val, berries_val;

View file

@ -12,7 +12,6 @@ namespace PKHeX
CP = new[] { CHK_P1, CHK_P2, CHK_P3, CHK_P4, CHK_P5, CHK_P6, CHK_P7, CHK_P8, CHK_P9, };
CL = new[] { CHK_L1, CHK_L2, CHK_L3, CHK_L4, CHK_L5, CHK_L6, CHK_L7, };
Util.TranslateInterface(this, Main.curlanguage);
sav = (byte[])Main.SAV.Data.Clone();
Setup();
LB_Species.SelectedIndex = 0;
@ -21,7 +20,7 @@ namespace PKHeX
private readonly CheckBox[] CP;
private readonly CheckBox[] CL;
private readonly byte[] sav;
private readonly byte[] sav = (byte[])Main.SAV.Data.Clone();
private readonly bool[,] specbools = new bool[9, 0x60 * 8];
private readonly bool[,] langbools = new bool[7, 0x60 * 8];
private bool editing;

View file

@ -12,7 +12,6 @@ namespace PKHeX
CP = new[] { CHK_P1, CHK_P2, CHK_P3, CHK_P4, CHK_P5, CHK_P6, CHK_P7, CHK_P8, CHK_P9, };
CL = new[] { CHK_L1, CHK_L2, CHK_L3, CHK_L4, CHK_L5, CHK_L6, CHK_L7, };
Util.TranslateInterface(this, Main.curlanguage);
sav = (byte[])Main.SAV.Data.Clone();
Setup();
LB_Species.SelectedIndex = 0;
@ -21,7 +20,7 @@ namespace PKHeX
private readonly CheckBox[] CP;
private readonly CheckBox[] CL;
private readonly byte[] sav;
private readonly byte[] sav = (byte[])Main.SAV.Data.Clone();
private readonly bool[,] specbools = new bool[9, 0x60 * 8];
private readonly bool[,] langbools = new bool[7, 0x60 * 8];
private readonly bool[] foreignbools = new bool[0x52 * 8];

View file

@ -9,7 +9,6 @@ namespace PKHeX
{
InitializeComponent();
Util.TranslateInterface(this, Main.curlanguage);
sav = (byte[])Main.SAV.Data.Clone();
pfa = Main.puffs;
pfa[0] = "---";
@ -19,7 +18,7 @@ namespace PKHeX
new ToolTip().SetToolTip(B_All, "Hold CTRL to give Deluxe instead of Supreme.");
}
private readonly byte[] sav;
private readonly byte[] sav = (byte[])Main.SAV.Data.Clone();
private readonly string[] pfa;
private void Setup()
{

View file

@ -10,7 +10,6 @@ namespace PKHeX
{
InitializeComponent();
Util.TranslateInterface(this, Main.curlanguage);
sav = (byte[])Main.SAV.Data.Clone();
abilitylist = Main.abilitylist;
setupComboBoxes();
@ -23,7 +22,7 @@ namespace PKHeX
B_SAV2FAV(null, null);
}
private readonly byte[] sav;
private readonly byte[] sav = (byte[])Main.SAV.Data.Clone();
private bool editing;
private bool loading = true;

View file

@ -7,7 +7,6 @@ namespace PKHeX
{
public SAV_SuperTrain()
{
sav = (byte[])Main.SAV.Data.Clone();
trba = Main.trainingbags;
trba[0] = "---";
offsetTime = Main.SAV.SuperTrain + 0x08;
@ -23,7 +22,7 @@ namespace PKHeX
setup();
}
private readonly byte[] sav;
private readonly byte[] sav = (byte[])Main.SAV.Data.Clone();
private readonly string[] trba = {
"Empty",
"HP Bag S","HP Bag M","HP Bag L",

View file

@ -200,7 +200,7 @@ namespace PKHeX
CB_Stats.Items.Add(statdata[2 * i + 1]);
CB_Stats.SelectedIndex = 0;
}
private readonly string[] statdata = { };
private readonly string[] statdata;
private bool editing;
private readonly ToolTip Tip1 = new ToolTip(), Tip2 = new ToolTip();
private readonly MaskedTextBox[] MaisonRecords;

View file

@ -13,7 +13,6 @@ namespace PKHeX
{
InitializeComponent();
Util.TranslateInterface(this, Main.curlanguage);
sav = (byte[])Main.SAV.Data.Clone();
pba = new[]
{
PB_Card01, PB_Card02, PB_Card03, PB_Card04, PB_Card05, PB_Card06,
@ -42,7 +41,7 @@ namespace PKHeX
Array.Copy(wcdata, wondercard_data, wcdata.Length);
loadwcdata();
}
private readonly byte[] sav;
private readonly byte[] sav = (byte[])Main.SAV.Data.Clone();
private byte[] wondercard_data = new byte[WC6.Size];
private const uint EonTicketConst = 0x225D73C2;
private readonly PictureBox[] pba;
@ -175,7 +174,9 @@ namespace PKHeX
if (Main.SAV.ORAS) // ORAS Only
if (BitConverter.ToUInt16(wondercard_data, 0) == 0x800) // Eon Ticket #
if (BitConverter.ToUInt16(wondercard_data, 0x68) == 0x2D6) // Eon Ticket
BitConverter.GetBytes(EonTicketConst).CopyTo(sav, Main.SAV.EonTicket);
{ BitConverter.GetBytes(EonTicketConst).CopyTo(sav, Main.SAV.EonTicket); }
else
{ Util.Alert("Cannot set Eon Ticket to non OR/AS games."); return; }
Array.Copy(wondercard_data, 0, sav, offset, WC6.Size);
populateWClist();