Minor refactoring

Do things better.
This commit is contained in:
Kurt 2015-12-26 21:17:23 -08:00
parent 494c622c40
commit 24703bfc22
10 changed files with 25 additions and 32 deletions

View file

@ -219,8 +219,7 @@ namespace PKHeX
av = (int)(Util.rnd32() % (AbilityType - 1));
break;
}
if (av == 2)
pk.HiddenAbility = true;
pk.HiddenAbility = av == 2;
pk.Ability = PKX.Personal[PKX.Personal[Species].FormeIndex(Species, pk.AltForm)].Abilities[av];
if (PID != 0)

View file

@ -115,7 +115,7 @@ namespace PKHeX
public int IV_SPA { get { return (int)(IV32 >> 20) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 20)) | (uint)((value > 31 ? 31 : value) << 20)); } }
public int IV_SPD { get { return (int)(IV32 >> 25) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 25)) | (uint)((value > 31 ? 31 : value) << 25)); } }
public bool IsEgg { get { return ((IV32 >> 30) & 1) == 1; } set { IV32 = (uint)((IV32 & ~0x40000000) | (uint)(value ? 0x40000000 : 0)); } }
public bool IsNicknamed { get { return ((IV32 >> 31) & 1) == 1; } set { IV32 = ((IV32 & ~0x80000000) | (value ? 0x80000000 : 0)); } }
public bool IsNicknamed { get { return ((IV32 >> 31) & 1) == 1; } set { IV32 = ((IV32 & 0x7FFFFFFF) | (value ? 0x80000000 : 0)); } }
private byte RIB4 { get { return Data[0x3C]; } set { Data[0x3C] = value; } } // Hoenn 1a
public bool RIB4_0 { get { return (RIB4 & (1 << 0)) == 1 << 0; } set { RIB4 = (byte)(RIB4 & ~(1 << 0) | (value ? 1 << 0 : 0)); } } // Cool Ribbon

View file

@ -115,7 +115,7 @@ namespace PKHeX
public int IV_SPA { get { return (int)(IV32 >> 20) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 20)) | (uint)((value > 31 ? 31 : value) << 20)); } }
public int IV_SPD { get { return (int)(IV32 >> 25) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 25)) | (uint)((value > 31 ? 31 : value) << 25)); } }
public bool IsEgg { get { return ((IV32 >> 30) & 1) == 1; } set { IV32 = (uint)((IV32 & ~0x40000000) | (uint)(value ? 0x40000000 : 0)); } }
public bool IsNicknamed { get { return ((IV32 >> 31) & 1) == 1; } set { IV32 = ((IV32 & ~0x80000000) | (value ? 0x80000000 : 0)); } }
public bool IsNicknamed { get { return ((IV32 >> 31) & 1) == 1; } set { IV32 = ((IV32 & 0x7FFFFFFF) | (value ? 0x80000000 : 0)); } }
private byte RIB4 { get { return Data[0x3C]; } set { Data[0x3C] = value; } } // Hoenn 1a
public bool RIB4_0 { get { return (RIB4 & (1 << 0)) == 1 << 0; } set { RIB4 = (byte)(RIB4 & ~(1 << 0) | (value ? 1 << 0 : 0)); } } // Cool Ribbon

View file

@ -288,7 +288,7 @@ namespace PKHeX
public int IV_SPA { get { return (int)(IV32 >> 20) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 20)) | (uint)((value > 31 ? 31 : value) << 20)); } }
public int IV_SPD { get { return (int)(IV32 >> 25) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 25)) | (uint)((value > 31 ? 31 : value) << 25)); } }
public bool IsEgg { get { return ((IV32 >> 30) & 1) == 1; } set { IV32 = (uint)((IV32 & ~0x40000000) | (uint)(value ? 0x40000000 : 0)); } }
public bool IsNicknamed { get { return ((IV32 >> 31) & 1) == 1; } set { IV32 = ((IV32 & ~0x80000000) | (value ? 0x80000000 : 0)); } }
public bool IsNicknamed { get { return ((IV32 >> 31) & 1) == 1; } set { IV32 = ((IV32 & 0x7FFFFFFF) | (value ? 0x80000000 : 0)); } }
#endregion
#region Block C
public string HT_Name

View file

@ -415,7 +415,7 @@ namespace PKHeX
// Calculate Stats
ushort[] stats = new ushort[6]; // Stats are stored as ushorts in the PKX structure. We'll cap them as such.
stats[0] = (HP_B == 1) ? (ushort)1 : (ushort)((((HP_IV + (2 * HP_B) + (HP_EV / 4) + 100) * level) / 100) + 10);
stats[0] = (ushort)(HP_B == 1 ? 1 : ((((HP_IV + (2 * HP_B) + (HP_EV / 4) + 100) * level) / 100) + 10));
stats[1] = (ushort)((((ATK_IV + (2 * ATK_B) + (ATK_EV / 4)) * level) / 100) + 5);
stats[2] = (ushort)((((DEF_IV + (2 * DEF_B) + (DEF_EV / 4)) * level) / 100) + 5);
stats[4] = (ushort)((((SPA_IV + (2 * SPA_B) + (SPA_EV / 4)) * level) / 100) + 5);

View file

@ -31,11 +31,11 @@ namespace PKHeX
public byte[] Data, BAK;
public bool Exportable;
public bool Edited;
public SAV6(byte[] data)
public SAV6(byte[] data = null)
{
Exportable = !data.SequenceEqual(new byte[data.Length]);
Data = (byte[])data.Clone();
BAK = (byte[])data.Clone();
Data = (byte[])(data ?? new byte[SIZE_ORAS]).Clone();
BAK = (byte[])Data.Clone();
Exportable = !Data.SequenceEqual(new byte[Data.Length]);
// Load Info
getBlockInfo();
@ -611,8 +611,7 @@ namespace PKHeX
if (i >= battlemem)
Array.Copy(encryptArray(new byte[PK6.SIZE_PARTY]), 0, Data, BattleBox + (i * PK6.SIZE_STORED), PK6.SIZE_STORED);
if (battlemem == 0)
BattleBoxLocked = false;
BattleBoxLocked &= battlemem != 0;
}
public void sortBoxes()
{

View file

@ -310,10 +310,6 @@
<DependentUpon>SplashScreen.cs</DependentUpon>
</EmbeddedResource>
<None Include="app.config" />
<None Include="Properties\DataSources\Editor.Properties.Resources.datasource" />
<None Include="Properties\DataSources\Editor.Properties.Settings.datasource" />
<None Include="Properties\DataSources\WindowsFormsApplication1.Form1.datasource" />
<None Include="Properties\DataSources\WindowsFormsApplication1.Program.datasource" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>

View file

@ -137,13 +137,13 @@ namespace PKHeX
#region Global Variables: Always Visible!
public static readonly byte[] blankEK6 = PKX.encryptArray(new byte[PK6.SIZE_PARTY]);
public static PK6 pk6 = new PK6(new byte[PK6.SIZE_PARTY]); // Tab Pokemon Data Storage
public static SAV6 SAV = new SAV6(new byte[SAV6.SIZE_ORAS]);
public static PK6 pk6 = new PK6(); // Tab Pokemon Data Storage
public static SAV6 SAV = new SAV6();
public static byte[] originalSAV; // original save for CyberGadget Codes
public static byte[] ramsav; // original ramsav for ramsav exporting
public string pathSDF;
public string path3DS;
public pk2pk Converter = new pk2pk();
public static pk2pk Converter = new pk2pk();
public static string pathSDF;
public static string path3DS;
public static volatile bool formInitialized, fieldsInitialized;
public static bool HaX;
@ -756,8 +756,7 @@ namespace PKHeX
InitializeLanguage();
Util.TranslateInterface(this, lang_val[CB_MainLanguage.SelectedIndex], menuStrip1); // Translate the UI to language.
populateFields(data); // put data back in form
if (alreadyInit)
fieldsInitialized = true;
fieldsInitialized |= alreadyInit;
}
private void InitializeStrings()
{

View file

@ -114,10 +114,10 @@ namespace PKHeX
CHK_P8.Checked = (sender as CheckBox == CHK_P8);
CHK_P9.Checked = (sender as CheckBox == CHK_P9);
if (CHK_P6.Checked) CHK_P2.Checked = true;
if (CHK_P7.Checked) CHK_P3.Checked = true;
if (CHK_P8.Checked) CHK_P4.Checked = true;
if (CHK_P9.Checked) CHK_P5.Checked = true;
CHK_P2.Checked |= CHK_P6.Checked;
CHK_P3.Checked |= CHK_P7.Checked;
CHK_P4.Checked |= CHK_P8.Checked;
CHK_P5.Checked |= CHK_P9.Checked;
}
private void changeEncountered(object sender, EventArgs e)
{
@ -306,7 +306,7 @@ namespace PKHeX
private void changeEncounteredCount(object sender, EventArgs e)
{
if (!editing)
Array.Copy(BitConverter.GetBytes(Math.Min(0xFFFF, Util.ToUInt32(MT_Count))), 0, sav, Main.SAV.EncounterCount + (Util.getIndex(CB_Species) - 1) * 2, 2);
BitConverter.GetBytes((ushort)Math.Min(0xFFFF, Util.ToUInt32(MT_Count))).CopyTo(sav, Main.SAV.EncounterCount + (Util.getIndex(CB_Species) - 1) * 2);
}
}
}

View file

@ -123,10 +123,10 @@ namespace PKHeX
CHK_P8.Checked = (sender as CheckBox == CHK_P8);
CHK_P9.Checked = (sender as CheckBox == CHK_P9);
if (CHK_P6.Checked) CHK_P2.Checked = true;
if (CHK_P7.Checked) CHK_P3.Checked = true;
if (CHK_P8.Checked) CHK_P4.Checked = true;
if (CHK_P9.Checked) CHK_P5.Checked = true;
CHK_P2.Checked |= CHK_P6.Checked;
CHK_P3.Checked |= CHK_P7.Checked;
CHK_P4.Checked |= CHK_P8.Checked;
CHK_P5.Checked |= CHK_P9.Checked;
}
private void changeEncountered(object sender, EventArgs e)
{