mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-08-27 22:54:35 -05:00
Cleanup
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -278,8 +277,8 @@ private void mainMenuOpen(object sender, EventArgs e)
|
||||
OpenFileDialog ofd = new OpenFileDialog
|
||||
{
|
||||
Filter = $"Supported Files|main;*.sav;*.bin;*.{ekx};{supported};*.bak" +
|
||||
$"|3DS Main Files|main" +
|
||||
$"|Save Files|*.sav" +
|
||||
"|3DS Main Files|main" +
|
||||
"|Save Files|*.sav" +
|
||||
$"|Decrypted PKM File|{supported}" +
|
||||
$"|Encrypted PKM File|*.{ekx}" +
|
||||
"|Binary File|*.bin" +
|
||||
|
||||
@@ -41,10 +41,7 @@ private void populateFieldsCK3()
|
||||
CB_GameOrigin.SelectedValue = ck3.Version;
|
||||
CB_EncounterType.SelectedValue = ck3.Gen4 ? ck3.EncounterType : 0;
|
||||
CB_Ball.SelectedValue = ck3.Ball;
|
||||
|
||||
int cr = ck3.CurrentRegion;
|
||||
int or = ck3.OriginalRegion;
|
||||
int ver = ck3.Version;
|
||||
|
||||
CB_MetLocation.SelectedValue = ck3.Met_Location;
|
||||
|
||||
TB_MetLevel.Text = ck3.Met_Level.ToString();
|
||||
|
||||
@@ -51,14 +51,7 @@ private void populateFieldsPK4()
|
||||
GB_EggConditions.Enabled = true;
|
||||
|
||||
CB_EggLocation.SelectedValue = pk4.Egg_Location;
|
||||
if (pk4.EggMetDate.HasValue)
|
||||
{
|
||||
CAL_EggDate.Value = pk4.EggMetDate.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
CAL_EggDate.Value = new DateTime(2000, 1, 1);
|
||||
}
|
||||
CAL_EggDate.Value = pk4.EggMetDate ?? new DateTime(2000, 1, 1);
|
||||
}
|
||||
else { CAL_EggDate.Value = new DateTime(2000, 01, 01); CHK_AsEgg.Checked = GB_EggConditions.Enabled = false; CB_EggLocation.SelectedValue = 0; }
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ private void popEntry(int index)
|
||||
row.Cells[r++].Value = p.SPE.ToString("000");
|
||||
row.Cells[r++].Value = abilities[p.Abilities[0]];
|
||||
row.Cells[r++].Value = abilities[p.Abilities[1]];
|
||||
row.Cells[r++].Value = abilities[p.Abilities[2]];
|
||||
row.Cells[r].Value = abilities[p.Abilities[2]];
|
||||
DGV.Rows.Add(row);
|
||||
}
|
||||
private static Color mapColor(int v)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using PKHeX.Core;
|
||||
|
||||
namespace PKHeX.WinForms
|
||||
{
|
||||
|
||||
@@ -17,8 +17,7 @@ public SAV_ZygardeCell()
|
||||
// Use constants 0x18C/2 = 198 thru +95
|
||||
ushort[] constants = SAV.EventConsts;
|
||||
ushort[] cells = constants.Skip(celloffset).Take(cellcount).ToArray();
|
||||
|
||||
int receivedCount = cells.Count(cell => cell == 2);
|
||||
|
||||
int cellCount = constants[cellstotal];
|
||||
int cellCollected = constants[cellscollected];
|
||||
|
||||
@@ -92,7 +91,7 @@ private void B_GiveAll_Click(object sender, EventArgs e)
|
||||
|
||||
#region locations -- lazy
|
||||
|
||||
private string[] locations =
|
||||
private readonly string[] locations =
|
||||
{
|
||||
"Verdant Cave - Trial Site",
|
||||
"Ruins of Conflict - Outside",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
namespace PKHeX.WinForms
|
||||
{
|
||||
public class CyberGadgetUtil
|
||||
public static class CyberGadgetUtil
|
||||
{
|
||||
public static string GetTempFolder()
|
||||
{
|
||||
@@ -13,7 +13,7 @@ public static string GetCacheFolder()
|
||||
{
|
||||
return Path.Combine(GetBackupLocation(), "cache");
|
||||
}
|
||||
public static string GetRegistryValue(string key)
|
||||
private static string GetRegistryValue(string key)
|
||||
{
|
||||
Microsoft.Win32.RegistryKey currentUser = Microsoft.Win32.Registry.CurrentUser;
|
||||
Microsoft.Win32.RegistryKey key3 = currentUser.OpenSubKey(GetRegistryBase());
|
||||
@@ -25,11 +25,11 @@ public static string GetRegistryValue(string key)
|
||||
currentUser.Close();
|
||||
return str;
|
||||
}
|
||||
public static string GetRegistryBase()
|
||||
private static string GetRegistryBase()
|
||||
{
|
||||
return @"SOFTWARE\CYBER Gadget\3DSSaveEditor";
|
||||
}
|
||||
public static string GetBackupLocation()
|
||||
private static string GetBackupLocation()
|
||||
{
|
||||
string registryValue = GetRegistryValue("Location");
|
||||
if (!string.IsNullOrEmpty(registryValue))
|
||||
|
||||
@@ -9,7 +9,7 @@ public class PL6 //: PokemonLink
|
||||
public const int Size = 0xA47;
|
||||
public const string Filter = "Pokémon Link Data|*.pl6|All Files (*.*)|*.*";
|
||||
|
||||
public byte[] Data;
|
||||
public readonly byte[] Data;
|
||||
public PL6(byte[] data = null)
|
||||
{
|
||||
Data = (byte[])(data?.Clone() ?? new byte[Size]);
|
||||
|
||||
@@ -191,7 +191,6 @@
|
||||
<Compile Include="Game\ComboItem.cs" />
|
||||
<Compile Include="Util\BigEndian.cs" />
|
||||
<Compile Include="Util\CryptoUtil.cs" />
|
||||
<Compile Include="Util\CyberGadgetUtil.cs" />
|
||||
<Compile Include="Util\DataUtil.cs" />
|
||||
<Compile Include="Util\DateUtil.cs" />
|
||||
<Compile Include="Util\ImageUtil.cs" />
|
||||
|
||||
@@ -267,7 +267,7 @@ public byte[] Write()
|
||||
public bool AO => Version == (int)GameVersion.AS || Version == (int)GameVersion.OR;
|
||||
public bool SM => Version == (int)GameVersion.SN || Version == (int)GameVersion.MN;
|
||||
protected bool PtHGSS => GameVersion.Pt == (GameVersion)Version || HGSS;
|
||||
public bool HGSS => new[] {GameVersion.HG, GameVersion.SS}.Contains((GameVersion)Version);
|
||||
protected bool HGSS => new[] {GameVersion.HG, GameVersion.SS}.Contains((GameVersion)Version);
|
||||
public bool Gen5 => Version >= 20 && Version <= 23;
|
||||
public bool Gen4 => Version >= 7 && Version <= 12 && Version != 9;
|
||||
public bool Gen3 => Version >= 1 && Version <= 5 || Version == 15;
|
||||
@@ -506,7 +506,7 @@ public virtual ushort[] getStats(PersonalInfo p)
|
||||
{
|
||||
int level = CurrentLevel;
|
||||
ushort[] Stats = new ushort[6];
|
||||
Stats[0] = (ushort)(p.HP == 1 ? 1 : (((HT_HP ? 31 : IV_HP) + 2 * p.HP + EV_HP / 4 + 100) * level / 100 + 10));
|
||||
Stats[0] = (ushort)(p.HP == 1 ? 1 : ((HT_HP ? 31 : IV_HP) + 2 * p.HP + EV_HP / 4 + 100) * level / 100 + 10);
|
||||
Stats[1] = (ushort)(((HT_ATK ? 31 : IV_ATK) + 2 * p.ATK + EV_ATK / 4) * level / 100 + 5);
|
||||
Stats[2] = (ushort)(((HT_DEF ? 31 : IV_DEF) + 2 * p.DEF + EV_DEF / 4) * level / 100 + 5);
|
||||
Stats[4] = (ushort)(((HT_SPA ? 31 : IV_SPA) + 2 * p.SPA + EV_SPA / 4) * level / 100 + 5);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
|
||||
@@ -40,9 +40,9 @@ public abstract class PersonalInfo
|
||||
public virtual int Height { get; set; } = 0;
|
||||
public virtual int Weight { get; set; } = 0;
|
||||
|
||||
public bool[] TMHM { get; set; }
|
||||
public bool[] TypeTutors { get; set; }
|
||||
public bool[][] SpecialTutors { get; set; } = new bool[0][];
|
||||
public bool[] TMHM { get; protected set; }
|
||||
public bool[] TypeTutors { get; protected set; }
|
||||
public bool[][] SpecialTutors { get; protected set; } = new bool[0][];
|
||||
|
||||
protected static bool[] getBits(byte[] data)
|
||||
{
|
||||
|
||||
@@ -617,7 +617,7 @@ public override void setSeen(PKM pkm, bool seen = true)
|
||||
int ofs = bit >> 3;
|
||||
byte bitval = (byte)(1 << (bit & 7));
|
||||
// Set the Seen Flag
|
||||
Data[PokedexSeenOffset + ofs] &= (byte)(~bitval);
|
||||
Data[PokedexSeenOffset + ofs] &= (byte)~bitval;
|
||||
if (seen)
|
||||
Data[PokedexSeenOffset + ofs] |= bitval;
|
||||
}
|
||||
@@ -634,7 +634,7 @@ public override void setCaught(PKM pkm, bool caught = true)
|
||||
int ofs = bit >> 3;
|
||||
byte bitval = (byte)(1 << (bit & 7));
|
||||
// Set the Captured Flag
|
||||
Data[PokedexCaughtOffset + ofs] &= (byte)(~bitval);
|
||||
Data[PokedexCaughtOffset + ofs] &= (byte)~bitval;
|
||||
if (caught)
|
||||
{
|
||||
Data[PokedexCaughtOffset + ofs] |= bitval;
|
||||
@@ -643,7 +643,7 @@ public override void setCaught(PKM pkm, bool caught = true)
|
||||
// Give all Unown caught to prevent a crash on pokedex view
|
||||
for (int i = 1; i <= 26; i++)
|
||||
{
|
||||
Data[PokedexSeenOffset + 0x1F + i] = (byte)(i);
|
||||
Data[PokedexSeenOffset + 0x1F + i] = (byte)i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1179,12 +1179,6 @@ public override string MiscSaveInfo()
|
||||
$"{b.ID:00}: {b.Offset:X5}-{b.Offset + b.Length:X5}, {b.Length:X5}{Environment.NewLine}");
|
||||
}
|
||||
|
||||
public override bool RequiresMemeCrypto
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public override bool RequiresMemeCrypto => true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,7 +461,8 @@ public static bool detectSaveFile(out string path, params string[] extra)
|
||||
/// </summary>
|
||||
/// <param name="folderPath">Folder to look within</param>
|
||||
/// <param name="deep">Search all subfolders</param>
|
||||
/// <returns>Full path of all save files that match criteria.</returns>
|
||||
/// <param name="result">Full path of all save files that match criteria.</param>
|
||||
/// <returns>Boolean indicating whether or not operation was successful.</returns>
|
||||
public static bool getSavesFromFolder(string folderPath, bool deep, out IEnumerable<string> result)
|
||||
{
|
||||
if (!Directory.Exists(folderPath))
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.ComponentModel.Design;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
@@ -270,7 +269,7 @@ public static byte[] Resign(byte[] sav7, bool throwIfUnsupported = true)
|
||||
byte[] ChecksumTable = new byte[0x140];
|
||||
Array.Copy(sav7, 0x6BC00, ChecksumTable, 0, 0x140);
|
||||
|
||||
SignMemeData(sha256.ComputeHash(ChecksumTable).Concat((ReverseCrypt(CurSig) ?? new byte[0x60])).ToArray()).CopyTo(outSav, 0x6BB00);
|
||||
SignMemeData(sha256.ComputeHash(ChecksumTable).Concat(ReverseCrypt(CurSig) ?? new byte[0x60]).ToArray()).CopyTo(outSav, 0x6BB00);
|
||||
}
|
||||
return outSav;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace PKHeX.Core
|
||||
// sizeof(QR7) == 0x1A2
|
||||
|
||||
|
||||
public class QR7
|
||||
public static class QR7
|
||||
{
|
||||
private static bool hasGenderDifferences(int species)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public class CyberGadgetUtil
|
||||
{
|
||||
public static string GetTempFolder()
|
||||
{
|
||||
return Path.Combine(Path.GetTempPath(), "3DSSE");
|
||||
}
|
||||
public static string GetCacheFolder()
|
||||
{
|
||||
return Path.Combine(GetBackupLocation(), "cache");
|
||||
}
|
||||
public static string GetRegistryValue(string key)
|
||||
{
|
||||
Microsoft.Win32.RegistryKey currentUser = Microsoft.Win32.Registry.CurrentUser;
|
||||
Microsoft.Win32.RegistryKey key3 = currentUser.OpenSubKey(GetRegistryBase());
|
||||
if (key3 == null)
|
||||
return null;
|
||||
|
||||
string str = key3.GetValue(key) as string;
|
||||
key3.Close();
|
||||
currentUser.Close();
|
||||
return str;
|
||||
}
|
||||
public static string GetRegistryBase()
|
||||
{
|
||||
return @"SOFTWARE\CYBER Gadget\3DSSaveEditor";
|
||||
}
|
||||
public static string GetBackupLocation()
|
||||
{
|
||||
string registryValue = GetRegistryValue("Location");
|
||||
if (!string.IsNullOrEmpty(registryValue))
|
||||
{
|
||||
Directory.CreateDirectory(registryValue);
|
||||
return registryValue;
|
||||
}
|
||||
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "3DSSaveBank");
|
||||
if (Directory.Exists(GetRegistryBase()))
|
||||
Directory.CreateDirectory(path);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using PKHeX.Core;
|
||||
|
||||
namespace PKHeX.Tests.Util
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user