mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 04:23:12 +00:00
Minor clean
Magic number -> const usage default(T) -> default (c#7.x feature) remove some unused stuff fix indentation in some spots
This commit is contained in:
parent
62d08d7c30
commit
c5ebbbbe15
24 changed files with 223 additions and 237 deletions
|
@ -121,7 +121,7 @@ namespace PKHeX.Core
|
||||||
PersonalInfo = table?.GetFormeEntry(pkm.Species, pkm.AltForm) ?? pkm.PersonalInfo;
|
PersonalInfo = table?.GetFormeEntry(pkm.Species, pkm.AltForm) ?? pkm.PersonalInfo;
|
||||||
ParseLegality();
|
ParseLegality();
|
||||||
|
|
||||||
if (Parse.Count <= 0)
|
if (Parse.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Valid = Parse.All(chk => chk.Valid)
|
Valid = Parse.All(chk => chk.Valid)
|
||||||
|
@ -356,7 +356,7 @@ namespace PKHeX.Core
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
if (vRelearn[i].Valid)
|
if (vRelearn[i].Valid)
|
||||||
lines.Add(vRelearn[i].Format(L_F0_RM_1_2, i + 1));
|
lines.Add(vRelearn[i].Format(L_F0_RM_1_2, i + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,10 +69,12 @@ namespace PKHeX.Core
|
||||||
|
|
||||||
// Process Conditions
|
// Process Conditions
|
||||||
if (PKX.GetUnownForm(pid) == form) // matches form, does it match nature?
|
if (PKX.GetUnownForm(pid) == form) // matches form, does it match nature?
|
||||||
switch (VerifyPIDCriteria(pid, info))
|
|
||||||
{
|
{
|
||||||
case LockInfo.Pass: // yes
|
switch (VerifyPIDCriteria(pid, info))
|
||||||
yield break;
|
{
|
||||||
|
case LockInfo.Pass: // yes
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s1 = pidiv.RNG.Prev(s2);
|
s1 = pidiv.RNG.Prev(s2);
|
||||||
|
|
|
@ -205,7 +205,7 @@ namespace PKHeX.Core
|
||||||
if (pk4.IV32 == 0)
|
if (pk4.IV32 == 0)
|
||||||
{
|
{
|
||||||
uint iv1 = ((seed = RNG.LCRNG.Next(seed)) >> 16) & 0x7FFF;
|
uint iv1 = ((seed = RNG.LCRNG.Next(seed)) >> 16) & 0x7FFF;
|
||||||
uint iv2 = ((_ = RNG.LCRNG.Next(seed)) >> 16) & 0x7FFF;
|
uint iv2 = ((RNG.LCRNG.Next(seed)) >> 16) & 0x7FFF;
|
||||||
pk4.IV32 = iv1 | iv2 << 15;
|
pk4.IV32 = iv1 | iv2 << 15;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,8 @@ namespace PKHeX.Core
|
||||||
Data = new byte[Data.Length]; // Invalidate
|
Data = new byte[Data.Length]; // Invalidate
|
||||||
}
|
}
|
||||||
|
|
||||||
public int RestrictLanguage { get; set; } = 0; // None
|
public int RestrictLanguage { get; set; } // None
|
||||||
public byte RestrictVersion { get; set; } = 0; // Permit All
|
public byte RestrictVersion { get; set; } // Permit All
|
||||||
|
|
||||||
public bool CanBeReceivedByVersion(int v)
|
public bool CanBeReceivedByVersion(int v)
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,8 +34,8 @@ namespace PKHeX.Core
|
||||||
RawDate = SetDate((uint) now.Year, (uint) now.Month, (uint) now.Day);
|
RawDate = SetDate((uint) now.Year, (uint) now.Month, (uint) now.Day);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int RestrictLanguage { get; set; } = 0; // None
|
public int RestrictLanguage { get; set; } // None
|
||||||
public byte RestrictVersion { get; set; } = 0; // Permit All
|
public byte RestrictVersion { get; set; } // Permit All
|
||||||
|
|
||||||
public bool CanBeReceivedByVersion(int v)
|
public bool CanBeReceivedByVersion(int v)
|
||||||
{
|
{
|
||||||
|
|
|
@ -660,7 +660,7 @@ namespace PKHeX.Core
|
||||||
|
|
||||||
byte[] ekm = ShuffleArray3(pkm, blockPositionInvert[PID%24]);
|
byte[] ekm = ShuffleArray3(pkm, blockPositionInvert[PID%24]);
|
||||||
byte[] xorkey = BitConverter.GetBytes(seed);
|
byte[] xorkey = BitConverter.GetBytes(seed);
|
||||||
for (int i = 32; i < 80; i++)
|
for (int i = 32; i < SIZE_3STORED; i++)
|
||||||
ekm[i] ^= xorkey[i & 3];
|
ekm[i] ^= xorkey[i & 3];
|
||||||
return ekm;
|
return ekm;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,19 +23,19 @@ namespace PKHeX.Core
|
||||||
// Constructor
|
// Constructor
|
||||||
public MemeKey(MemeKeyIndex key)
|
public MemeKey(MemeKeyIndex key)
|
||||||
{
|
{
|
||||||
GetMemeData(key, out byte[] d, out byte[] der);
|
DER = GetMemeData(key);
|
||||||
DER = der;
|
|
||||||
var _N = new byte[0x61];
|
var _N = new byte[0x61];
|
||||||
var _E = new byte[0x3];
|
var _E = new byte[0x3];
|
||||||
Array.Copy(der, 0x18, _N, 0, 0x61);
|
Array.Copy(DER, 0x18, _N, 0, 0x61);
|
||||||
Array.Copy(der, 0x7B, _E, 0, 3);
|
Array.Copy(DER, 0x7B, _E, 0, 3);
|
||||||
Array.Reverse(_N);
|
Array.Reverse(_N);
|
||||||
N = new BigInteger(_N);
|
N = new BigInteger(_N);
|
||||||
Array.Reverse(_E);
|
Array.Reverse(_E);
|
||||||
E = new BigInteger(_E);
|
E = new BigInteger(_E);
|
||||||
if (d != null)
|
|
||||||
|
if (key == MemeKeyIndex.PokedexAndSaveFile)
|
||||||
{
|
{
|
||||||
var _D = (byte[])d.Clone();
|
var _D = (byte[])D_3.Clone();
|
||||||
Array.Reverse(_D);
|
Array.Reverse(_D);
|
||||||
D = new BigInteger(_D);
|
D = new BigInteger(_D);
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
if (data.Length < 0x60)
|
if (data.Length < 0x60)
|
||||||
throw new ArgumentException("Memebuffers must be atleast 0x60 bytes long!");
|
throw new ArgumentException("Memebuffers must be atleast 0x60 bytes long!");
|
||||||
|
|
||||||
var key = new byte[0x10];
|
var key = new byte[0x10];
|
||||||
var buffer = new byte[DER.Length + data.Length - 0x60];
|
var buffer = new byte[DER.Length + data.Length - 0x60];
|
||||||
Array.Copy(DER, 0, buffer, 0, DER.Length);
|
Array.Copy(DER, 0, buffer, 0, DER.Length);
|
||||||
|
@ -232,59 +233,26 @@ namespace PKHeX.Core
|
||||||
Array.Copy(rawSig, outSig, 0x60);
|
Array.Copy(rawSig, outSig, 0x60);
|
||||||
return outSig;
|
return outSig;
|
||||||
}
|
}
|
||||||
// Helper Method to retrieve data for loading
|
|
||||||
private static void GetMemeData(MemeKeyIndex key, out byte[] d, out byte[] der)
|
|
||||||
{
|
|
||||||
d = null;
|
|
||||||
|
|
||||||
|
private static byte[] GetMemeData(MemeKeyIndex key)
|
||||||
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case MemeKeyIndex.LocalWireless:
|
case MemeKeyIndex.LocalWireless: return DER_LW;
|
||||||
der = DER_LW;
|
case MemeKeyIndex.FriendlyCompetition: return DER_0;
|
||||||
break;
|
case MemeKeyIndex.LiveCompetition: return DER_1;
|
||||||
case MemeKeyIndex.FriendlyCompetition:
|
case MemeKeyIndex.RentalTeam: return DER_2;
|
||||||
der = DER_0;
|
case MemeKeyIndex.PokedexAndSaveFile: return DER_3;
|
||||||
break;
|
case MemeKeyIndex.GaOle: return DER_4;
|
||||||
case MemeKeyIndex.LiveCompetition:
|
case MemeKeyIndex.MagearnaEvent: return DER_5;
|
||||||
der = DER_1;
|
case MemeKeyIndex.MoncolleGet: return DER_6;
|
||||||
break;
|
case MemeKeyIndex.IslandScanEventSpecial: return DER_7;
|
||||||
case MemeKeyIndex.RentalTeam:
|
case MemeKeyIndex.TvTokyoDataBroadcasting: return DER_8;
|
||||||
der = DER_2;
|
case MemeKeyIndex.CapPikachuEvent: return DER_9;
|
||||||
break;
|
case MemeKeyIndex.Unknown10: return DER_A;
|
||||||
case MemeKeyIndex.PokedexAndSaveFile:
|
case MemeKeyIndex.Unknown11: return DER_B;
|
||||||
der = DER_3;
|
case MemeKeyIndex.Unknown12: return DER_C;
|
||||||
d = D_3;
|
case MemeKeyIndex.Unknown13: return DER_D;
|
||||||
break;
|
|
||||||
case MemeKeyIndex.GaOle:
|
|
||||||
der = DER_4;
|
|
||||||
break;
|
|
||||||
case MemeKeyIndex.MagearnaEvent:
|
|
||||||
der = DER_5;
|
|
||||||
break;
|
|
||||||
case MemeKeyIndex.MoncolleGet:
|
|
||||||
der = DER_6;
|
|
||||||
break;
|
|
||||||
case MemeKeyIndex.IslandScanEventSpecial:
|
|
||||||
der = DER_7;
|
|
||||||
break;
|
|
||||||
case MemeKeyIndex.TvTokyoDataBroadcasting:
|
|
||||||
der = DER_8;
|
|
||||||
break;
|
|
||||||
case MemeKeyIndex.CapPikachuEvent:
|
|
||||||
der = DER_9;
|
|
||||||
break;
|
|
||||||
case MemeKeyIndex.Unknown10:
|
|
||||||
der = DER_A;
|
|
||||||
break;
|
|
||||||
case MemeKeyIndex.Unknown11:
|
|
||||||
der = DER_B;
|
|
||||||
break;
|
|
||||||
case MemeKeyIndex.Unknown12:
|
|
||||||
der = DER_C;
|
|
||||||
break;
|
|
||||||
case MemeKeyIndex.Unknown13:
|
|
||||||
der = DER_D;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException(nameof(key), key, null);
|
throw new ArgumentOutOfRangeException(nameof(key), key, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,13 +214,13 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
SetAllDexSeenFlags(baseBit, f, 0, false, seen);
|
SetAllDexSeenFlags(baseBit, f, 0, false, seen);
|
||||||
if (shinyToo)
|
if (shinyToo)
|
||||||
SetAllDexSeenFlags(baseBit, f, 0, true, seen);
|
SetAllDexSeenFlags(baseBit, f, 0, true, seen);
|
||||||
}
|
}
|
||||||
if (!entry.OnlyMale && !entry.Genderless)
|
if (!entry.OnlyMale && !entry.Genderless)
|
||||||
{
|
{
|
||||||
SetAllDexSeenFlags(baseBit, f, 1, false, seen);
|
SetAllDexSeenFlags(baseBit, f, 1, false, seen);
|
||||||
if (shinyToo)
|
if (shinyToo)
|
||||||
SetAllDexSeenFlags(baseBit, f, 1, true, seen);
|
SetAllDexSeenFlags(baseBit, f, 1, true, seen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace PKHeX.Core
|
||||||
val |= data[offset + 0] << 24;
|
val |= data[offset + 0] << 24;
|
||||||
val |= data[offset + 1] << 16;
|
val |= data[offset + 1] << 16;
|
||||||
val |= data[offset + 2] << 8;
|
val |= data[offset + 2] << 8;
|
||||||
val |= data[offset + 3] << 0;
|
val |= data[offset + 3];
|
||||||
return (uint)val;
|
return (uint)val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
int val = 0;
|
int val = 0;
|
||||||
val |= data[offset + 0] << 8;
|
val |= data[offset + 0] << 8;
|
||||||
val |= data[offset + 1] << 0;
|
val |= data[offset + 1];
|
||||||
return (ushort)val;
|
return (ushort)val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ namespace PKHeX.Core
|
||||||
val |= data[offset + 0] << 24;
|
val |= data[offset + 0] << 24;
|
||||||
val |= data[offset + 1] << 16;
|
val |= data[offset + 1] << 16;
|
||||||
val |= data[offset + 2] << 8;
|
val |= data[offset + 2] << 8;
|
||||||
val |= data[offset + 3] << 0;
|
val |= data[offset + 3];
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
int val = 0;
|
int val = 0;
|
||||||
val |= data[offset + 0] << 8;
|
val |= data[offset + 0] << 8;
|
||||||
val |= data[offset + 1] << 0;
|
val |= data[offset + 1];
|
||||||
return (short)val;
|
return (short)val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,17 +116,16 @@ namespace PKHeX.Core
|
||||||
|
|
||||||
public static string GetStringResource(string name)
|
public static string GetStringResource(string name)
|
||||||
{
|
{
|
||||||
if (!resourceNameMap.ContainsKey(name))
|
if (!resourceNameMap.TryGetValue(name, out var resname))
|
||||||
{
|
{
|
||||||
bool Match(string x) => x.StartsWith("PKHeX.Core.Resources.text.") && x.EndsWith($"{name}.txt", StringComparison.OrdinalIgnoreCase);
|
bool Match(string x) => x.StartsWith("PKHeX.Core.Resources.text.") && x.EndsWith($"{name}.txt", StringComparison.OrdinalIgnoreCase);
|
||||||
var resname = Array.Find(manifestResourceNames, Match);
|
resname = Array.Find(manifestResourceNames, Match);
|
||||||
|
if (resname == null)
|
||||||
|
return null;
|
||||||
resourceNameMap.Add(name, resname);
|
resourceNameMap.Add(name, resname);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resourceNameMap[name] == null)
|
using (var resource = thisAssembly.GetManifestResourceStream(resname))
|
||||||
return null;
|
|
||||||
|
|
||||||
using (var resource = thisAssembly.GetManifestResourceStream(resourceNameMap[name]))
|
|
||||||
using (var reader = new StreamReader(resource))
|
using (var reader = new StreamReader(resource))
|
||||||
return reader.ReadToEnd();
|
return reader.ReadToEnd();
|
||||||
}
|
}
|
||||||
|
@ -318,9 +317,8 @@ namespace PKHeX.Core
|
||||||
public static void AddCBWithOffset(List<ComboItem> cbList, IReadOnlyList<string> inStrings, int offset, params int[] allowed)
|
public static void AddCBWithOffset(List<ComboItem> cbList, IReadOnlyList<string> inStrings, int offset, params int[] allowed)
|
||||||
{
|
{
|
||||||
int beginCount = cbList.Count;
|
int beginCount = cbList.Count;
|
||||||
for (int i = 0; i < allowed.Length; i++)
|
foreach (var index in allowed)
|
||||||
{
|
{
|
||||||
int index = allowed[i];
|
|
||||||
var item = new ComboItem(inStrings[index - offset], index);
|
var item = new ComboItem(inStrings[index - offset], index);
|
||||||
cbList.Add(item);
|
cbList.Add(item);
|
||||||
}
|
}
|
||||||
|
@ -330,9 +328,8 @@ namespace PKHeX.Core
|
||||||
public static void AddCB(List<ComboItem> cbList, IReadOnlyList<string> inStrings, int[] allowed)
|
public static void AddCB(List<ComboItem> cbList, IReadOnlyList<string> inStrings, int[] allowed)
|
||||||
{
|
{
|
||||||
int beginCount = cbList.Count;
|
int beginCount = cbList.Count;
|
||||||
for (int i = 0; i < allowed.Length; i++)
|
foreach (var index in allowed)
|
||||||
{
|
{
|
||||||
int index = allowed[i];
|
|
||||||
var item = new ComboItem(inStrings[index], index);
|
var item = new ComboItem(inStrings[index], index);
|
||||||
cbList.Add(item);
|
cbList.Add(item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
if (ext == ".pgt") // size collision with pk6
|
if (ext == ".pgt") // size collision with pk6
|
||||||
{
|
{
|
||||||
pk = default(PKM);
|
pk = default;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var format = PKX.GetPKMFormatFromExtension(ext, sav?.Generation ?? 6);
|
var format = PKX.GetPKMFormatFromExtension(ext, sav?.Generation ?? 6);
|
||||||
|
|
|
@ -55,12 +55,15 @@ namespace PKHeX.WinForms.Controls
|
||||||
imgWidth = baseImage.Width;
|
imgWidth = baseImage.Width;
|
||||||
imgHeight = baseImage.Height;
|
imgHeight = baseImage.Height;
|
||||||
GlowData = glowData;
|
GlowData = glowData;
|
||||||
pb = pbox;
|
|
||||||
GlowCounter = 0;
|
GlowCounter = 0;
|
||||||
OriginalBackground = original;
|
|
||||||
GlowCache = new Image[GlowFps];
|
GlowCache = new Image[GlowFps];
|
||||||
GlowInterval = 1000 / GlowFps;
|
GlowInterval = 1000 / GlowFps;
|
||||||
Interval = GlowInterval;
|
Interval = GlowInterval;
|
||||||
|
lock (Lock)
|
||||||
|
{
|
||||||
|
pb = pbox;
|
||||||
|
OriginalBackground = original;
|
||||||
|
}
|
||||||
Enabled = true;
|
Enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
using System;
|
namespace PKHeX.WinForms.Controls
|
||||||
using PKHeX.Core;
|
|
||||||
|
|
||||||
namespace PKHeX.WinForms.Controls
|
|
||||||
{
|
{
|
||||||
internal enum SlotIndex
|
internal enum SlotIndex
|
||||||
{
|
{
|
||||||
|
@ -9,29 +6,4 @@ namespace PKHeX.WinForms.Controls
|
||||||
BattleBox = 6,
|
BattleBox = 6,
|
||||||
Daycare = 12,
|
Daycare = 12,
|
||||||
}
|
}
|
||||||
|
|
||||||
public static partial class Extensions
|
|
||||||
{
|
|
||||||
internal static bool IsEditable(this SlotIndex type) => type == SlotIndex.Party;
|
|
||||||
internal static bool IsParty(this SlotIndex type, int format) => type < SlotIndex.BattleBox || (format == 5 && type == SlotIndex.BattleBox);
|
|
||||||
|
|
||||||
internal static SlotIndex GetMiscSlotType(int slot)
|
|
||||||
{
|
|
||||||
if (slot < (int)SlotIndex.BattleBox) return SlotIndex.Party;
|
|
||||||
if (slot < (int)SlotIndex.Daycare) return SlotIndex.BattleBox;
|
|
||||||
return SlotIndex.Daycare;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static StorageSlotType GetMiscSlotType(this SlotIndex type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case SlotIndex.Party: return StorageSlotType.Party;
|
|
||||||
case SlotIndex.Daycare: return StorageSlotType.Daycare;
|
|
||||||
case SlotIndex.BattleBox: return StorageSlotType.BattleBox;
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(type), type, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1105,10 +1105,8 @@ namespace PKHeX.WinForms
|
||||||
return;
|
return;
|
||||||
OpenQuick(files[0]);
|
OpenQuick(files[0]);
|
||||||
e.Effect = DragDropEffects.Copy;
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
|
||||||
Cursor = DefaultCursor;
|
|
||||||
}
|
}
|
||||||
// Decrypted Export
|
|
||||||
private void Dragout_MouseDown(object sender, MouseEventArgs e)
|
private void Dragout_MouseDown(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Button == MouseButtons.Left && (ModifierKeys == Keys.Alt || ModifierKeys == Keys.Shift))
|
if (e.Button == MouseButtons.Left && (ModifierKeys == Keys.Alt || ModifierKeys == Keys.Shift))
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
this.RB_Boxes = new System.Windows.Forms.RadioButton();
|
this.RB_Boxes = new System.Windows.Forms.RadioButton();
|
||||||
this.RB_Path = new System.Windows.Forms.RadioButton();
|
this.RB_Path = new System.Windows.Forms.RadioButton();
|
||||||
this.FLP_RB = new System.Windows.Forms.FlowLayoutPanel();
|
this.FLP_RB = new System.Windows.Forms.FlowLayoutPanel();
|
||||||
|
this.RB_Party = new System.Windows.Forms.RadioButton();
|
||||||
this.TB_Folder = new System.Windows.Forms.TextBox();
|
this.TB_Folder = new System.Windows.Forms.TextBox();
|
||||||
this.RTB_Instructions = new System.Windows.Forms.RichTextBox();
|
this.RTB_Instructions = new System.Windows.Forms.RichTextBox();
|
||||||
this.B_Go = new System.Windows.Forms.Button();
|
this.B_Go = new System.Windows.Forms.Button();
|
||||||
|
@ -42,7 +43,7 @@
|
||||||
this.B_Add = new System.Windows.Forms.Button();
|
this.B_Add = new System.Windows.Forms.Button();
|
||||||
this.L_PropType = new System.Windows.Forms.Label();
|
this.L_PropType = new System.Windows.Forms.Label();
|
||||||
this.L_PropValue = new System.Windows.Forms.Label();
|
this.L_PropValue = new System.Windows.Forms.Label();
|
||||||
this.RB_Party = new System.Windows.Forms.RadioButton();
|
this.b = new System.ComponentModel.BackgroundWorker();
|
||||||
this.FLP_RB.SuspendLayout();
|
this.FLP_RB.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
|
@ -89,6 +90,19 @@
|
||||||
this.FLP_RB.Size = new System.Drawing.Size(370, 24);
|
this.FLP_RB.Size = new System.Drawing.Size(370, 24);
|
||||||
this.FLP_RB.TabIndex = 2;
|
this.FLP_RB.TabIndex = 2;
|
||||||
//
|
//
|
||||||
|
// RB_Party
|
||||||
|
//
|
||||||
|
this.RB_Party.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||||
|
this.RB_Party.Appearance = System.Windows.Forms.Appearance.Button;
|
||||||
|
this.RB_Party.AutoSize = true;
|
||||||
|
this.RB_Party.Location = new System.Drawing.Point(46, 0);
|
||||||
|
this.RB_Party.Margin = new System.Windows.Forms.Padding(0);
|
||||||
|
this.RB_Party.Name = "RB_Party";
|
||||||
|
this.RB_Party.Size = new System.Drawing.Size(41, 23);
|
||||||
|
this.RB_Party.TabIndex = 5;
|
||||||
|
this.RB_Party.Text = "Party";
|
||||||
|
this.RB_Party.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
// TB_Folder
|
// TB_Folder
|
||||||
//
|
//
|
||||||
this.TB_Folder.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
this.TB_Folder.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
@ -199,18 +213,9 @@
|
||||||
this.L_PropValue.TabIndex = 13;
|
this.L_PropValue.TabIndex = 13;
|
||||||
this.L_PropValue.Text = "PropertyValue";
|
this.L_PropValue.Text = "PropertyValue";
|
||||||
//
|
//
|
||||||
// RB_Party
|
// b
|
||||||
//
|
//
|
||||||
this.RB_Party.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
this.b.WorkerReportsProgress = true;
|
||||||
this.RB_Party.Appearance = System.Windows.Forms.Appearance.Button;
|
|
||||||
this.RB_Party.AutoSize = true;
|
|
||||||
this.RB_Party.Location = new System.Drawing.Point(46, 0);
|
|
||||||
this.RB_Party.Margin = new System.Windows.Forms.Padding(0);
|
|
||||||
this.RB_Party.Name = "RB_Party";
|
|
||||||
this.RB_Party.Size = new System.Drawing.Size(41, 23);
|
|
||||||
this.RB_Party.TabIndex = 5;
|
|
||||||
this.RB_Party.Text = "Party";
|
|
||||||
this.RB_Party.UseVisualStyleBackColor = true;
|
|
||||||
//
|
//
|
||||||
// BatchEditor
|
// BatchEditor
|
||||||
//
|
//
|
||||||
|
@ -258,5 +263,6 @@
|
||||||
private System.Windows.Forms.Label L_PropType;
|
private System.Windows.Forms.Label L_PropType;
|
||||||
private System.Windows.Forms.Label L_PropValue;
|
private System.Windows.Forms.Label L_PropValue;
|
||||||
private System.Windows.Forms.RadioButton RB_Party;
|
private System.Windows.Forms.RadioButton RB_Party;
|
||||||
|
private System.ComponentModel.BackgroundWorker b;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -119,8 +118,6 @@ namespace PKHeX.WinForms
|
||||||
RB_Path.Checked = true;
|
RB_Path.Checked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BackgroundWorker b;
|
|
||||||
|
|
||||||
private void RunBackgroundWorker()
|
private void RunBackgroundWorker()
|
||||||
{
|
{
|
||||||
if (RTB_Instructions.Lines.Any(line => line.Length == 0))
|
if (RTB_Instructions.Lines.Any(line => line.Length == 0))
|
||||||
|
@ -167,7 +164,6 @@ namespace PKHeX.WinForms
|
||||||
private void RunBatchEdit(StringInstructionSet[] sets, string source, string destination)
|
private void RunBatchEdit(StringInstructionSet[] sets, string source, string destination)
|
||||||
{
|
{
|
||||||
editor = new Core.BatchEditor();
|
editor = new Core.BatchEditor();
|
||||||
b = new BackgroundWorker { WorkerReportsProgress = true };
|
|
||||||
b.DoWork += (sender, e) =>
|
b.DoWork += (sender, e) =>
|
||||||
{
|
{
|
||||||
if (RB_Boxes.Checked)
|
if (RB_Boxes.Checked)
|
||||||
|
@ -193,7 +189,7 @@ namespace PKHeX.WinForms
|
||||||
var files = Directory.GetFiles(source, "*", SearchOption.AllDirectories);
|
var files = Directory.GetFiles(source, "*", SearchOption.AllDirectories);
|
||||||
SetupProgressBar(files.Length * sets.Count);
|
SetupProgressBar(files.Length * sets.Count);
|
||||||
foreach (var set in sets)
|
foreach (var set in sets)
|
||||||
ProcessFolder(files, set.Filters, set.Instructions, destination);
|
ProcessFolder(files, set.Filters, set.Instructions, destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RunBatchEditSaveFile(IList<StringInstructionSet> sets, bool boxes = false, bool party = false)
|
private void RunBatchEditSaveFile(IList<StringInstructionSet> sets, bool boxes = false, bool party = false)
|
||||||
|
@ -207,7 +203,7 @@ namespace PKHeX.WinForms
|
||||||
{
|
{
|
||||||
SetupProgressBar(d.Count * sets.Count);
|
SetupProgressBar(d.Count * sets.Count);
|
||||||
foreach (var set in sets)
|
foreach (var set in sets)
|
||||||
ProcessSAV(d, set.Filters, set.Instructions);
|
ProcessSAV(d, set.Filters, set.Instructions);
|
||||||
return d.Count != 0;
|
return d.Count != 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,9 @@
|
||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="b.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
<value>
|
<value>
|
||||||
|
|
34
PKHeX.WinForms/Subforms/SAV_Database.Designer.cs
generated
34
PKHeX.WinForms/Subforms/SAV_Database.Designer.cs
generated
|
@ -28,6 +28,7 @@
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SAV_Database));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SAV_Database));
|
||||||
this.SCR_Box = new System.Windows.Forms.VScrollBar();
|
this.SCR_Box = new System.Windows.Forms.VScrollBar();
|
||||||
this.bpkx30 = new System.Windows.Forms.PictureBox();
|
this.bpkx30 = new System.Windows.Forms.PictureBox();
|
||||||
|
@ -159,6 +160,10 @@
|
||||||
this.L_Format = new System.Windows.Forms.Label();
|
this.L_Format = new System.Windows.Forms.Label();
|
||||||
this.FLP_Level = new System.Windows.Forms.FlowLayoutPanel();
|
this.FLP_Level = new System.Windows.Forms.FlowLayoutPanel();
|
||||||
this.RTB_Instructions = new System.Windows.Forms.RichTextBox();
|
this.RTB_Instructions = new System.Windows.Forms.RichTextBox();
|
||||||
|
this.mnu = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||||
|
this.mnuView = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.mnuDelete = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.hover = new System.Windows.Forms.ToolTip(this.components);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.bpkx30)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.bpkx30)).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.bpkx29)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.bpkx29)).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.bpkx28)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.bpkx28)).BeginInit();
|
||||||
|
@ -232,6 +237,7 @@
|
||||||
this.TLP_Filters.SuspendLayout();
|
this.TLP_Filters.SuspendLayout();
|
||||||
this.FLP_Format.SuspendLayout();
|
this.FLP_Format.SuspendLayout();
|
||||||
this.FLP_Level.SuspendLayout();
|
this.FLP_Level.SuspendLayout();
|
||||||
|
this.mnu.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// SCR_Box
|
// SCR_Box
|
||||||
|
@ -1625,6 +1631,7 @@
|
||||||
this.L_Viewed.TabIndex = 117;
|
this.L_Viewed.TabIndex = 117;
|
||||||
this.L_Viewed.Text = "Last Viewed: {0}";
|
this.L_Viewed.Text = "Last Viewed: {0}";
|
||||||
this.L_Viewed.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
this.L_Viewed.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
this.L_Viewed.MouseEnter += new System.EventHandler(this.L_Viewed_MouseEnter);
|
||||||
//
|
//
|
||||||
// FLP_Egg
|
// FLP_Egg
|
||||||
//
|
//
|
||||||
|
@ -1845,6 +1852,28 @@
|
||||||
this.RTB_Instructions.TabIndex = 119;
|
this.RTB_Instructions.TabIndex = 119;
|
||||||
this.RTB_Instructions.Text = "";
|
this.RTB_Instructions.Text = "";
|
||||||
//
|
//
|
||||||
|
// mnu
|
||||||
|
//
|
||||||
|
this.mnu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.mnuView,
|
||||||
|
this.mnuDelete});
|
||||||
|
this.mnu.Name = "mnu";
|
||||||
|
this.mnu.Size = new System.Drawing.Size(108, 48);
|
||||||
|
this.mnu.Click += new System.EventHandler(this.ClickView);
|
||||||
|
//
|
||||||
|
// mnuView
|
||||||
|
//
|
||||||
|
this.mnuView.Name = "mnuView";
|
||||||
|
this.mnuView.Size = new System.Drawing.Size(107, 22);
|
||||||
|
this.mnuView.Text = "View";
|
||||||
|
//
|
||||||
|
// mnuDelete
|
||||||
|
//
|
||||||
|
this.mnuDelete.Name = "mnuDelete";
|
||||||
|
this.mnuDelete.Size = new System.Drawing.Size(107, 22);
|
||||||
|
this.mnuDelete.Text = "Delete";
|
||||||
|
this.mnuDelete.Click += new System.EventHandler(this.ClickDelete);
|
||||||
|
//
|
||||||
// SAV_Database
|
// SAV_Database
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
@ -1944,6 +1973,7 @@
|
||||||
this.FLP_Format.ResumeLayout(false);
|
this.FLP_Format.ResumeLayout(false);
|
||||||
this.FLP_Level.ResumeLayout(false);
|
this.FLP_Level.ResumeLayout(false);
|
||||||
this.FLP_Level.PerformLayout();
|
this.FLP_Level.PerformLayout();
|
||||||
|
this.mnu.ResumeLayout(false);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
|
@ -2081,5 +2111,9 @@
|
||||||
private System.Windows.Forms.ToolStripMenuItem Menu_SearchClones;
|
private System.Windows.Forms.ToolStripMenuItem Menu_SearchClones;
|
||||||
private System.Windows.Forms.ToolStripMenuItem Menu_DeleteClones;
|
private System.Windows.Forms.ToolStripMenuItem Menu_DeleteClones;
|
||||||
private System.Windows.Forms.ToolStripMenuItem Menu_Import;
|
private System.Windows.Forms.ToolStripMenuItem Menu_Import;
|
||||||
|
private System.Windows.Forms.ContextMenuStrip mnu;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem mnuView;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem mnuDelete;
|
||||||
|
private System.Windows.Forms.ToolTip hover;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
#define LOADALL
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
@ -26,11 +25,7 @@ namespace PKHeX.WinForms
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
ToolStripMenuItem mnuView = new ToolStripMenuItem {Name = "mnuView", Text = "View"};
|
|
||||||
ToolStripMenuItem mnuDelete = new ToolStripMenuItem {Name = "mnuDelete", Text = "Delete" };
|
|
||||||
|
|
||||||
WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
|
WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
|
||||||
ContextMenuStrip mnu = new ContextMenuStrip();
|
|
||||||
mnu.Items.AddRange(new ToolStripItem[] { mnuView, mnuDelete });
|
mnu.Items.AddRange(new ToolStripItem[] { mnuView, mnuDelete });
|
||||||
|
|
||||||
SAV = saveditor.SAV;
|
SAV = saveditor.SAV;
|
||||||
|
@ -62,48 +57,23 @@ namespace PKHeX.WinForms
|
||||||
// Enable Click
|
// Enable Click
|
||||||
slot.MouseClick += (sender, e) =>
|
slot.MouseClick += (sender, e) =>
|
||||||
{
|
{
|
||||||
if (ModifierKeys == Keys.Control)
|
switch (ModifierKeys)
|
||||||
ClickView(sender, e);
|
{
|
||||||
else if (ModifierKeys == Keys.Alt)
|
case Keys.Control: ClickView(sender, e); break;
|
||||||
ClickDelete(sender, e);
|
case Keys.Alt: ClickDelete(sender, e); break;
|
||||||
else if (ModifierKeys == Keys.Shift)
|
case Keys.Shift: ClickSet(sender, e); break;
|
||||||
ClickSet(sender, e);
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Settings.Default.HoverSlotShowText)
|
if (Settings.Default.HoverSlotShowText)
|
||||||
{
|
slot.MouseEnter += ShowHoverTextForSlot;
|
||||||
slot.MouseEnter += (sender, e) =>
|
|
||||||
{
|
|
||||||
int index = Array.IndexOf(PKXBOXES, slot);
|
|
||||||
if (!GetShiftedIndex(ref index))
|
|
||||||
return;
|
|
||||||
|
|
||||||
var pk = Results[index];
|
|
||||||
if (pk.Species == 0)
|
|
||||||
{
|
|
||||||
ShowSet.RemoveAll();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var text = ShowdownSet.GetLocalizedPreviewText(pk, Settings.Default.Language);
|
|
||||||
ShowSet.SetToolTip(slot, text);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Counter = L_Count.Text;
|
Counter = L_Count.Text;
|
||||||
Viewed = L_Viewed.Text;
|
Viewed = L_Viewed.Text;
|
||||||
L_Viewed.Text = string.Empty; // invis for now
|
L_Viewed.Text = string.Empty; // invisible for now
|
||||||
var hover = new ToolTip();
|
|
||||||
L_Viewed.MouseEnter += (sender, e) => hover.SetToolTip(L_Viewed, L_Viewed.Text);
|
|
||||||
PopulateComboBoxes();
|
PopulateComboBoxes();
|
||||||
|
|
||||||
// Assign event handlers
|
|
||||||
mnuView.Click += ClickView;
|
|
||||||
mnuDelete.Click += ClickDelete;
|
|
||||||
|
|
||||||
// Add to main context menu
|
|
||||||
|
|
||||||
// Assign to datagridview
|
// Assign to datagridview
|
||||||
foreach (PictureBox p in PKXBOXES)
|
foreach (PictureBox p in PKXBOXES)
|
||||||
p.ContextMenuStrip = mnu;
|
p.ContextMenuStrip = mnu;
|
||||||
|
@ -134,7 +104,7 @@ namespace PKHeX.WinForms
|
||||||
private readonly string Viewed;
|
private readonly string Viewed;
|
||||||
private const int MAXFORMAT = PKX.Generation;
|
private const int MAXFORMAT = PKX.Generation;
|
||||||
private readonly string EXTERNAL_SAV = new DirectoryInfo(Main.BackupPath).Name + Path.DirectorySeparatorChar;
|
private readonly string EXTERNAL_SAV = new DirectoryInfo(Main.BackupPath).Name + Path.DirectorySeparatorChar;
|
||||||
private readonly ToolTip ShowSet = new ToolTip {InitialDelay = 200, IsBalloon = false};
|
private readonly SummaryPreviewer ShowSet = new SummaryPreviewer();
|
||||||
|
|
||||||
// Important Events
|
// Important Events
|
||||||
private void ClickView(object sender, EventArgs e)
|
private void ClickView(object sender, EventArgs e)
|
||||||
|
@ -149,7 +119,7 @@ namespace PKHeX.WinForms
|
||||||
|
|
||||||
PKME_Tabs.PopulateFields(Results[index], false);
|
PKME_Tabs.PopulateFields(Results[index], false);
|
||||||
slotSelected = index;
|
slotSelected = index;
|
||||||
slotColor = Properties.Resources.slotView;
|
slotColor = Resources.slotView;
|
||||||
FillPKXBoxes(SCR_Box.Value);
|
FillPKXBoxes(SCR_Box.Value);
|
||||||
L_Viewed.Text = string.Format(Viewed, Results[index].Identifier);
|
L_Viewed.Text = string.Format(Viewed, Results[index].Identifier);
|
||||||
}
|
}
|
||||||
|
@ -236,7 +206,7 @@ namespace PKHeX.WinForms
|
||||||
// Refresh database view.
|
// Refresh database view.
|
||||||
L_Count.Text = string.Format(Counter, Results.Count);
|
L_Count.Text = string.Format(Counter, Results.Count);
|
||||||
slotSelected = Results.Count - 1;
|
slotSelected = Results.Count - 1;
|
||||||
slotColor = Properties.Resources.slotSet;
|
slotColor = Resources.slotSet;
|
||||||
if ((SCR_Box.Maximum+1)*6 < Results.Count)
|
if ((SCR_Box.Maximum+1)*6 < Results.Count)
|
||||||
SCR_Box.Maximum++;
|
SCR_Box.Maximum++;
|
||||||
SCR_Box.Value = Math.Max(0, SCR_Box.Maximum - (PKXBOXES.Length/6) + 1);
|
SCR_Box.Value = Math.Max(0, SCR_Box.Maximum - (PKXBOXES.Length/6) + 1);
|
||||||
|
@ -331,6 +301,14 @@ namespace PKHeX.WinForms
|
||||||
if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgDBCreateReportPrompt, MsgDBCreateReportWarning) != DialogResult.Yes)
|
if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgDBCreateReportPrompt, MsgDBCreateReportWarning) != DialogResult.Yes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
var form = WinFormsUtil.FirstFormOfType<ReportGrid>();
|
||||||
|
if (form != null)
|
||||||
|
{
|
||||||
|
form.BringToFront();
|
||||||
|
form.CenterToForm(this);
|
||||||
|
}
|
||||||
|
|
||||||
ReportGrid reportGrid = new ReportGrid();
|
ReportGrid reportGrid = new ReportGrid();
|
||||||
reportGrid.Show();
|
reportGrid.Show();
|
||||||
reportGrid.PopulateData(Results.ToArray());
|
reportGrid.PopulateData(Results.ToArray());
|
||||||
|
@ -357,64 +335,70 @@ namespace PKHeX.WinForms
|
||||||
private static List<PKM> LoadPKMSaves(string pkmdb, string savdb, string EXTERNAL_SAV, SaveFile SAV)
|
private static List<PKM> LoadPKMSaves(string pkmdb, string savdb, string EXTERNAL_SAV, SaveFile SAV)
|
||||||
{
|
{
|
||||||
var dbTemp = new ConcurrentBag<PKM>();
|
var dbTemp = new ConcurrentBag<PKM>();
|
||||||
var files = Directory.EnumerateFiles(pkmdb, "*", SearchOption.AllDirectories);
|
|
||||||
var extensions = new HashSet<string>(PKM.Extensions.Select(z => $".{z}"));
|
var extensions = new HashSet<string>(PKM.Extensions.Select(z => $".{z}"));
|
||||||
Parallel.ForEach(files, file =>
|
|
||||||
{
|
|
||||||
var fi = new FileInfo(file);
|
|
||||||
if (!extensions.Contains(fi.Extension) || !PKX.IsPKM(fi.Length)) return;
|
|
||||||
var data = File.ReadAllBytes(file);
|
|
||||||
var prefer = PKX.GetPKMFormatFromExtension(fi.Extension, SAV.Generation);
|
|
||||||
var pk = PKMConverter.GetPKMfromBytes(data, prefer);
|
|
||||||
if (!(pk?.Species > 0))
|
|
||||||
return;
|
|
||||||
pk.Identifier = file;
|
|
||||||
dbTemp.Add(pk);
|
|
||||||
});
|
|
||||||
|
|
||||||
#if LOADALL
|
var files = Directory.EnumerateFiles(pkmdb, "*", SearchOption.AllDirectories);
|
||||||
|
Parallel.ForEach(files, file => TryAddPKMsFromFolder(dbTemp, file, SAV, extensions));
|
||||||
|
|
||||||
if (SaveUtil.GetSavesFromFolder(savdb, false, out IEnumerable<string> result))
|
if (SaveUtil.GetSavesFromFolder(savdb, false, out IEnumerable<string> result))
|
||||||
{
|
Parallel.ForEach(result, file => TryAddPKMsFromSaveFilePath(dbTemp, file, EXTERNAL_SAV));
|
||||||
Parallel.ForEach(result, file =>
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
var sav = SaveUtil.GetVariantSAV(file);
|
|
||||||
if (sav == null)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Unable to load SaveFile: " + file);
|
|
||||||
return; // bad backup
|
|
||||||
}
|
|
||||||
var path = EXTERNAL_SAV + Path.GetFileName(file);
|
|
||||||
if (sav.HasBox)
|
|
||||||
{
|
|
||||||
foreach (var pk in sav.BoxData)
|
|
||||||
addPKM(pk);
|
|
||||||
}
|
|
||||||
|
|
||||||
void addPKM(PKM pk)
|
|
||||||
{
|
|
||||||
pk.Identifier = Path.Combine(path, pk.Identifier);
|
|
||||||
dbTemp.Add(pk);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine("ERROR: Unable to load SaveFile: " + file);
|
|
||||||
Console.WriteLine(ex.Message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// Fetch from save file
|
// Fetch from save file
|
||||||
var savpkm = SAV.BoxData.Where(pk => pk.Species != 0);
|
var savpkm = SAV.BoxData.Where(pk => pk.Species != 0);
|
||||||
|
|
||||||
var bakpkm = dbTemp.Where(pk => pk.Species != 0).OrderBy(pk => pk.Identifier);
|
var bakpkm = dbTemp.Where(pk => pk.Species != 0).OrderBy(pk => pk.Identifier);
|
||||||
var db = bakpkm.Concat(savpkm).Where(pk => pk.ChecksumValid && pk.Sanity == 0);
|
var db = bakpkm.Concat(savpkm).Where(pk => pk.ChecksumValid && pk.Sanity == 0);
|
||||||
|
|
||||||
// Prepare Database
|
// Finalize the Database
|
||||||
return new List<PKM>(db);
|
return new List<PKM>(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void TryAddPKMsFromFolder(ConcurrentBag<PKM> dbTemp, string file, ITrainerInfo dest, ICollection<string> validExtensions)
|
||||||
|
{
|
||||||
|
var fi = new FileInfo(file);
|
||||||
|
if (!validExtensions.Contains(fi.Extension) || !PKX.IsPKM(fi.Length))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var data = File.ReadAllBytes(file);
|
||||||
|
var prefer = PKX.GetPKMFormatFromExtension(fi.Extension, dest.Generation);
|
||||||
|
var pk = PKMConverter.GetPKMfromBytes(data, prefer);
|
||||||
|
if (!(pk?.Species > 0))
|
||||||
|
return;
|
||||||
|
pk.Identifier = file;
|
||||||
|
dbTemp.Add(pk);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void TryAddPKMsFromSaveFilePath(ConcurrentBag<PKM> dbTemp, string file, string externalFilePrefix)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sav = SaveUtil.GetVariantSAV(file);
|
||||||
|
if (sav == null)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Unable to load SaveFile: " + file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var path = externalFilePrefix + Path.GetFileName(file);
|
||||||
|
if (sav.HasBox)
|
||||||
|
{
|
||||||
|
foreach (var pk in sav.BoxData)
|
||||||
|
addPKM(pk);
|
||||||
|
}
|
||||||
|
|
||||||
|
void addPKM(PKM pk)
|
||||||
|
{
|
||||||
|
pk.Identifier = Path.Combine(path, pk.Identifier);
|
||||||
|
dbTemp.Add(pk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("ERROR: Unable to load SaveFile: " + file);
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// IO Usage
|
// IO Usage
|
||||||
private void OpenDB(object sender, EventArgs e)
|
private void OpenDB(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -596,9 +580,9 @@ namespace PKHeX.WinForms
|
||||||
PKXBOXES[i].Image = null;
|
PKXBOXES[i].Image = null;
|
||||||
|
|
||||||
for (int i = 0; i < RES_MAX; i++)
|
for (int i = 0; i < RES_MAX; i++)
|
||||||
PKXBOXES[i].BackgroundImage = Properties.Resources.slotTrans;
|
PKXBOXES[i].BackgroundImage = Resources.slotTrans;
|
||||||
if (slotSelected != -1 && slotSelected >= begin && slotSelected < begin + RES_MAX)
|
if (slotSelected != -1 && slotSelected >= begin && slotSelected < begin + RES_MAX)
|
||||||
PKXBOXES[slotSelected - begin].BackgroundImage = slotColor ?? Properties.Resources.slotView;
|
PKXBOXES[slotSelected - begin].BackgroundImage = slotColor ?? Resources.slotView;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Misc Update Methods
|
// Misc Update Methods
|
||||||
|
@ -691,5 +675,17 @@ namespace PKHeX.WinForms
|
||||||
WinFormsUtil.Alert(string.Format(MsgFileDeleteCount, deleted), MsgWindowClose);
|
WinFormsUtil.Alert(string.Format(MsgFileDeleteCount, deleted), MsgWindowClose);
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void L_Viewed_MouseEnter(object sender, EventArgs e) => hover.SetToolTip(L_Viewed, L_Viewed.Text);
|
||||||
|
|
||||||
|
private void ShowHoverTextForSlot(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var pb = (PictureBox)sender;
|
||||||
|
int index = Array.IndexOf(PKXBOXES, pb);
|
||||||
|
if (!GetShiftedIndex(ref index))
|
||||||
|
return;
|
||||||
|
|
||||||
|
ShowSet.Show(pb, Results[index]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,6 +321,12 @@
|
||||||
<metadata name="bpkx61.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="bpkx61.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="mnu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>132, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="hover.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>208, 17</value>
|
||||||
|
</metadata>
|
||||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
<value>
|
<value>
|
||||||
|
|
|
@ -24,7 +24,6 @@ namespace PKHeX.WinForms
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly string[] pfa = GameInfo.Strings.puffs;
|
private readonly string[] pfa = GameInfo.Strings.puffs;
|
||||||
private int PuffCount { get; set; }
|
|
||||||
|
|
||||||
private void Setup(int rowCount)
|
private void Setup(int rowCount)
|
||||||
{
|
{
|
||||||
|
@ -58,7 +57,6 @@ namespace PKHeX.WinForms
|
||||||
|
|
||||||
private void LoadPuffs(byte[] Puffs)
|
private void LoadPuffs(byte[] Puffs)
|
||||||
{
|
{
|
||||||
PuffCount = Puffs.Length;
|
|
||||||
for (int i = 0; i < Puffs.Length; i++)
|
for (int i = 0; i < Puffs.Length; i++)
|
||||||
{
|
{
|
||||||
dgv.Rows[i].Cells[0].Value = (i + 1).ToString();
|
dgv.Rows[i].Cells[0].Value = (i + 1).ToString();
|
||||||
|
|
|
@ -329,7 +329,7 @@ namespace PKHeX.WinForms
|
||||||
SAV.ConsoleRegion = WinFormsUtil.GetIndex(CB_3DSReg);
|
SAV.ConsoleRegion = WinFormsUtil.GetIndex(CB_3DSReg);
|
||||||
SAV.Language = WinFormsUtil.GetIndex(CB_Language);
|
SAV.Language = WinFormsUtil.GetIndex(CB_Language);
|
||||||
if (CB_AlolaTime.Enabled)
|
if (CB_AlolaTime.Enabled)
|
||||||
SAV.GameTime.AlolaTime = (ulong)WinFormsUtil.GetIndex(CB_AlolaTime);
|
SAV.GameTime.AlolaTime = (ulong)WinFormsUtil.GetIndex(CB_AlolaTime);
|
||||||
|
|
||||||
SAV.OT = TB_OTName.Text;
|
SAV.OT = TB_OTName.Text;
|
||||||
|
|
||||||
|
|
|
@ -297,9 +297,16 @@ namespace PKHeX.WinForms
|
||||||
}
|
}
|
||||||
catch (Exception x)
|
catch (Exception x)
|
||||||
{
|
{
|
||||||
if (x is UnauthorizedAccessException || x is FileNotFoundException || x is IOException)
|
switch (x)
|
||||||
Error(MsgFileWriteFail + Environment.NewLine + x.Message, MsgFileWriteProtectedAdvice);
|
{
|
||||||
else throw;
|
case UnauthorizedAccessException _:
|
||||||
|
case FileNotFoundException _:
|
||||||
|
case IOException _:
|
||||||
|
Error(MsgFileWriteFail + Environment.NewLine + x.Message, MsgFileWriteProtectedAdvice);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,15 +46,15 @@ namespace PKHeX.Tests.PKM
|
||||||
CheckStringGetSet(nameof(pkm.Nickname), name_nidoran, pkm.Nickname, byte_nidoran, pkm.Nickname_Trash);
|
CheckStringGetSet(nameof(pkm.Nickname), name_nidoran, pkm.Nickname, byte_nidoran, pkm.Nickname_Trash);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CheckStringGetSet(string check, string instr, string outstr, byte[] indata, byte[] outdata)
|
private static void CheckStringGetSet(string check, string instr, string outstr, byte[] indata,
|
||||||
|
byte[] outdata)
|
||||||
{
|
{
|
||||||
Assert.Equal(instr, outstr);
|
instr.Should().BeEquivalentTo(outstr);
|
||||||
|
|
||||||
outdata = outdata.Take(indata.Length).ToArray();
|
outdata = outdata.Take(indata.Length).ToArray();
|
||||||
|
|
||||||
Assert.True(indata.SequenceEqual(outdata),
|
indata.SequenceEqual(outdata).Should()
|
||||||
$"{check} did not set properly."
|
.BeTrue($"expected {check} to set properly, instead got {string.Join(", ", outdata.Select(z => $"{z:X2}"))}");
|
||||||
+ Environment.NewLine + string.Join(", ", outdata.Select(z => $"{z:X2}")));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue