Misc reorg

bye bye SAVUtil and PKMUtil
This commit is contained in:
Kurt 2018-07-20 21:32:33 -07:00
parent f27f11bfc8
commit c7175fbdb4
15 changed files with 221 additions and 211 deletions

View File

@ -213,7 +213,7 @@ public static PKM ConvertToType(PKM pk, Type PKMType, out string comment)
// Try Incompatible Conversion
pkm = GetBlank(PKMType);
pk.TransferPropertiesWithReflection(pkm);
if (!SaveUtil.IsPKMCompatibleWithModifications(pkm))
if (!IsPKMCompatibleWithModifications(pkm))
return null;
comment = "Converted via reflection.";
return pkm;
@ -314,6 +314,41 @@ private static bool IsNotTransferrable(PKM pk, out string comment)
}
}
/// <summary>
/// Checks if the <see cref="PKM"/> is compatible with the input <see cref="PKM"/>, and makes any necessary modifications to force compatibility.
/// </summary>
/// <remarks>Should only be used when forcing a backwards conversion to sanitize the PKM fields to the target format.
/// If the PKM is compatible, some properties may be forced to sanitized values.</remarks>
/// <param name="pk">PKM input that is to be sanity checked.</param>
/// <returns>Indication whether or not the PKM is compatible.</returns>
public static bool IsPKMCompatibleWithModifications(PKM pk) => IsPKMCompatibleWithModifications(pk, pk);
public static bool IsPKMCompatibleWithModifications(PKM pk, IGameValueLimit limit)
{
if (pk.Species > limit.MaxSpeciesID)
return false;
if (pk.HeldItem > limit.MaxItemID)
pk.HeldItem = 0;
if (pk.Nickname.Length > limit.NickLength)
pk.Nickname = pk.Nickname.Substring(0, pk.NickLength);
if (pk.OT_Name.Length > limit.OTLength)
pk.OT_Name = pk.OT_Name.Substring(0, pk.OTLength);
if (pk.Moves.Any(move => move > limit.MaxMoveID))
pk.ClearInvalidMoves();
if (pk.EVs.Any(ev => ev > limit.MaxEV))
pk.EVs = pk.EVs.Select(ev => Math.Min(limit.MaxEV, ev)).ToArray();
if (pk.IVs.Any(iv => iv > limit.MaxIV))
pk.IVs = pk.IVs.Select(iv => Math.Min(limit.MaxIV, iv)).ToArray();
return true;
}
/// <summary>
/// Checks if a PKM is encrypted; if encrypted, decrypts the PKM.
/// </summary>

View File

@ -1,17 +1,16 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using PKHeX.Core;
using static PKHeX.Core.MessageStrings;
namespace PKHeX.WinForms
namespace PKHeX.Core
{
/// <summary>
/// Contains extension methods for use with a <see cref="SaveFile"/>.
/// </summary>
public static class SAVUtil
public static class BoxUtil
{
/// <summary>
/// Dumps a folder of files to the <see cref="SaveFile"/>.
@ -145,7 +144,7 @@ public static bool LoadBoxes(this SaveFile SAV, IEnumerable<PKM> pks, out string
if (!SAV.HasBox)
{ result = MsgSaveBoxFailNone; return false; }
var compat = GetPKMForSaveFile(SAV, pks);
var compat = SAV.GetCompatible(pks);
if (boxClear)
SAV.ClearBoxes(boxStart);
@ -160,34 +159,6 @@ public static bool LoadBoxes(this SaveFile SAV, IEnumerable<PKM> pks, out string
return true;
}
private static int ImportPKMs(this SaveFile SAV, IEnumerable<PKM> compat, int boxStart, bool? noSetb)
{
int startCount = boxStart * SAV.BoxSlotCount;
int maxCount = SAV.BoxCount * SAV.BoxSlotCount;
int i = startCount;
int getbox() => i / SAV.BoxSlotCount;
int getslot() => i % SAV.BoxSlotCount;
foreach (var pk in compat)
{
int box = getbox();
int slot = getslot();
while (SAV.IsSlotLocked(box, slot))
{
++i;
box = getbox();
slot = getslot();
}
int offset = SAV.GetBoxOffset(box) + slot * SAV.SIZE_STORED;
SAV.SetStoredSlot(pk, offset, noSetb);
if (++i == maxCount) // Boxes full!
break;
}
i -= startCount; // actual imported count
return i;
}
private static IEnumerable<PKM> GetPKMsFromPaths(IEnumerable<string> filepaths, int generation)
{
return filepaths
@ -196,81 +167,5 @@ private static IEnumerable<PKM> GetPKMsFromPaths(IEnumerable<string> filepaths,
.Select(data => PKMConverter.GetPKMfromBytes(data, prefer: generation))
.Where(temp => temp != null);
}
private static IEnumerable<PKM> GetPKMForSaveFile(this SaveFile SAV, IEnumerable<PKM> pks)
{
var savtype = SAV.PKMType;
foreach (var temp in pks)
{
PKM pk = PKMConverter.ConvertToType(temp, savtype, out string c);
if (pk == null)
{ Debug.WriteLine(c); continue; }
var compat = SAV.IsPKMCompatible(pk);
if (compat.Length > 0)
continue;
yield return pk;
}
}
/// <summary>
/// Checks a <see cref="PKM"/> file for compatibility to the <see cref="SaveFile"/>.
/// </summary>
/// <param name="SAV"><see cref="SaveFile"/> that is being checked.</param>
/// <param name="pkm"><see cref="PKM"/> that is being tested for compatibility.</param>
/// <returns></returns>
public static string[] IsPKMCompatible(this SaveFile SAV, PKM pkm)
{
// Check if PKM properties are outside of the valid range
List<string> errata = new List<string>();
if (SAV.Generation > 1)
{
ushort held = (ushort)pkm.HeldItem;
if (held > GameInfo.Strings.itemlist.Length)
errata.Add($"{MsgIndexItemRange} {held}");
else if (held > SAV.MaxItemID)
errata.Add($"{MsgIndexItemGame} {GameInfo.Strings.itemlist[held]}");
else if (!pkm.CanHoldItem(SAV.HeldItems))
errata.Add($"{MsgIndexItemHeld} {GameInfo.Strings.itemlist[held]}");
}
if (pkm.Species > GameInfo.Strings.specieslist.Length)
errata.Add($"{MsgIndexSpeciesRange} {pkm.Species}");
else if (SAV.MaxSpeciesID < pkm.Species)
errata.Add($"{MsgIndexSpeciesGame} {GameInfo.Strings.specieslist[pkm.Species]}");
if (!SAV.Personal[pkm.Species].IsFormeWithinRange(pkm.AltForm) && !FormConverter.IsValidOutOfBoundsForme(pkm.Species, pkm.AltForm, pkm.GenNumber))
errata.Add(string.Format(LegalityCheckStrings.V304, Math.Max(0, SAV.Personal[pkm.Species].FormeCount - 1), pkm.AltForm));
if (pkm.Moves.Any(m => m > GameInfo.Strings.movelist.Length))
errata.Add($"{MsgIndexMoveRange} {string.Join(", ", pkm.Moves.Where(m => m > GameInfo.Strings.movelist.Length).Select(m => m.ToString()))}");
else if (pkm.Moves.Any(m => m > SAV.MaxMoveID))
errata.Add($"{MsgIndexMoveGame} {string.Join(", ", pkm.Moves.Where(m => m > SAV.MaxMoveID).Select(m => GameInfo.Strings.movelist[m]))}");
if (pkm.Ability > GameInfo.Strings.abilitylist.Length)
errata.Add($"{MsgIndexAbilityRange} {pkm.Ability}");
else if (pkm.Ability > SAV.MaxAbilityID)
errata.Add($"{MsgIndexAbilityGame} {GameInfo.Strings.abilitylist[pkm.Ability]}");
return errata.ToArray();
}
/// <summary>
/// Removes the <see cref="PKM.HeldItem"/> for all <see cref="PKM"/> in the <see cref="SaveFile.BoxData"/>.
/// </summary>
/// <param name="SAV"><see cref="SaveFile"/> that is being operated on.</param>
/// <param name="item"><see cref="PKM.HeldItem"/> to set. If no argument is supplied, the held item will be removed.</param>
public static void SetBoxDataAllHeldItems(this SaveFile SAV, int item = 0)
{
var boxdata = SAV.BoxData;
foreach (PKM pk in boxdata)
{
pk.HeldItem = item;
pk.RefreshChecksum();
}
SAV.BoxData = boxdata;
}
}
}

View File

@ -0,0 +1,164 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using static PKHeX.Core.MessageStrings;
namespace PKHeX.Core
{
public static class SaveExtensions
{
/// <summary>
/// Checks if the <see cref="PKM"/> is compatible with the input <see cref="SaveFile"/>, and makes any necessary modifications to force compatibility.
/// </summary>
/// <remarks>Should only be used when forcing a backwards conversion to sanitize the PKM fields to the target format.
/// If the PKM is compatible, some properties may be forced to sanitized values.</remarks>
/// <param name="SAV">Save File target that the PKM will be injected.</param>
/// <param name="pk">PKM input that is to be injected into the Save File.</param>
/// <returns>Indication whether or not the PKM is compatible.</returns>
public static bool IsPKMCompatibleWithModifications(this SaveFile SAV, PKM pk) => PKMConverter.IsPKMCompatibleWithModifications(pk, SAV);
/// <summary>
/// Sets the details of a path to a <see cref="SaveFile"/> object.
/// </summary>
/// <param name="sav">Save File to set path details to.</param>
/// <param name="path">Full Path of the file</param>
public static void SetFileInfo(this SaveFile sav, string path)
{
if (!sav.Exportable) // Blank save file
{
sav.FileFolder = sav.FilePath = null;
sav.FileName = "Blank Save File";
return;
}
sav.FilePath = path;
sav.FileFolder = Path.GetDirectoryName(path);
sav.FileName = Path.GetFileName(path);
if (!sav.FileName.EndsWith(".bak"))
return;
// trim off any bak details to get original file name
int index = sav.FileName.LastIndexOf(" [", StringComparison.Ordinal);
if (index < 0)
return;
sav.FileName = sav.FileName.Substring(0, index);
}
/// <summary>
/// Checks a <see cref="PKM"/> file for compatibility to the <see cref="SaveFile"/>.
/// </summary>
/// <param name="SAV"><see cref="SaveFile"/> that is being checked.</param>
/// <param name="pkm"><see cref="PKM"/> that is being tested for compatibility.</param>
/// <returns></returns>
public static IReadOnlyList<string> IsPKMCompatible(this SaveFile SAV, PKM pkm)
{
IBasicStrings strings = GameInfo.Strings;
return SAV.GetSaveFileErrata(pkm, strings);
}
private static IReadOnlyList<string> GetSaveFileErrata(this SaveFile SAV, PKM pkm, IBasicStrings strings)
{
var errata = new List<string>();
if (SAV.Generation > 1)
{
ushort held = (ushort)pkm.HeldItem;
if (held > strings.Item.Count)
errata.Add($"{MsgIndexItemRange} {held}");
else if (held > SAV.MaxItemID)
errata.Add($"{MsgIndexItemGame} {strings.Item[held]}");
else if (!pkm.CanHoldItem(SAV.HeldItems))
errata.Add($"{MsgIndexItemHeld} {strings.Item[held]}");
}
if (pkm.Species > strings.Species.Count)
errata.Add($"{MsgIndexSpeciesRange} {pkm.Species}");
else if (SAV.MaxSpeciesID < pkm.Species)
errata.Add($"{MsgIndexSpeciesGame} {strings.Species[pkm.Species]}");
if (!SAV.Personal[pkm.Species].IsFormeWithinRange(pkm.AltForm) && !FormConverter.IsValidOutOfBoundsForme(pkm.Species, pkm.AltForm, pkm.GenNumber))
errata.Add(string.Format(LegalityCheckStrings.V304, Math.Max(0, SAV.Personal[pkm.Species].FormeCount - 1), pkm.AltForm));
if (pkm.Moves.Any(m => m > strings.Move.Count))
errata.Add($"{MsgIndexMoveRange} {string.Join(", ", pkm.Moves.Where(m => m > strings.Move.Count).Select(m => m.ToString()))}");
else if (pkm.Moves.Any(m => m > SAV.MaxMoveID))
errata.Add($"{MsgIndexMoveGame} {string.Join(", ", pkm.Moves.Where(m => m > SAV.MaxMoveID).Select(m => strings.Move[m]))}");
if (pkm.Ability > strings.Ability.Count)
errata.Add($"{MsgIndexAbilityRange} {pkm.Ability}");
else if (pkm.Ability > SAV.MaxAbilityID)
errata.Add($"{MsgIndexAbilityGame} {strings.Ability[pkm.Ability]}");
return errata;
}
public static int ImportPKMs(this SaveFile SAV, IEnumerable<PKM> compat, int boxStart, bool? noSetb)
{
int startCount = boxStart * SAV.BoxSlotCount;
int maxCount = SAV.BoxCount * SAV.BoxSlotCount;
int i = startCount;
int getbox() => i / SAV.BoxSlotCount;
int getslot() => i % SAV.BoxSlotCount;
foreach (var pk in compat)
{
int box = getbox();
int slot = getslot();
while (SAV.IsSlotLocked(box, slot))
{
++i;
box = getbox();
slot = getslot();
}
int offset = SAV.GetBoxOffset(box) + slot * SAV.SIZE_STORED;
SAV.SetStoredSlot(pk, offset, noSetb);
if (++i == maxCount) // Boxes full!
break;
}
i -= startCount; // actual imported count
return i;
}
public static IEnumerable<PKM> GetCompatible(this SaveFile SAV, IEnumerable<PKM> pks)
{
var savtype = SAV.PKMType;
foreach (var temp in pks)
{
var pk = PKMConverter.ConvertToType(temp, savtype, out string c);
if (pk == null)
{
Debug.WriteLine(c);
continue;
}
var compat = SAV.IsPKMCompatible(pk);
if (compat.Count > 0)
continue;
yield return pk;
}
}
/// <summary>
/// Removes the <see cref="PKM.HeldItem"/> for all <see cref="PKM"/> in the <see cref="SaveFile.BoxData"/>.
/// </summary>
/// <param name="SAV"><see cref="SaveFile"/> that is being operated on.</param>
/// <param name="item"><see cref="PKM.HeldItem"/> to set. If no argument is supplied, the held item will be removed.</param>
public static void SetBoxDataAllHeldItems(this SaveFile SAV, int item = 0)
{
var boxdata = SAV.BoxData;
foreach (PKM pk in boxdata)
{
pk.HeldItem = item;
pk.RefreshChecksum();
}
SAV.BoxData = boxdata;
}
}
}

View File

@ -1170,88 +1170,5 @@ public static byte[] GetMainFromSaveContainer(byte[] input)
}
return null;
}
/// <summary>
/// Checks if the <see cref="PKM"/> is compatible with the input <see cref="SaveFile"/>, and makes any necessary modifications to force compatibility.
/// </summary>
/// <remarks>Should only be used when forcing a backwards conversion to sanitize the PKM fields to the target format.
/// If the PKM is compatible, some properties may be forced to sanitized values.</remarks>
/// <param name="SAV">Save File target that the PKM will be injected.</param>
/// <param name="pk">PKM input that is to be injected into the Save File.</param>
/// <returns>Indication whether or not the PKM is compatible.</returns>
public static bool IsPKMCompatibleWithModifications(SaveFile SAV, PKM pk)
{
if (pk.Species > SAV.MaxSpeciesID)
return false;
if (pk.HeldItem > SAV.MaxItemID)
pk.HeldItem = 0;
if (pk.Nickname.Length > SAV.NickLength)
pk.Nickname = pk.Nickname.Substring(0, SAV.NickLength);
if (pk.OT_Name.Length > SAV.OTLength)
pk.OT_Name = pk.OT_Name.Substring(0, SAV.OTLength);
if (pk.Moves.Any(move => move > SAV.MaxMoveID))
pk.ClearInvalidMoves();
if (pk.EVs.Any(ev => ev > SAV.MaxEV))
pk.EVs = pk.EVs.Select(ev => Math.Min(SAV.MaxEV, ev)).ToArray();
if (pk.IVs.Any(iv => iv > SAV.MaxIV))
pk.IVs = pk.IVs.Select(iv => Math.Min(SAV.MaxIV, iv)).ToArray();
return true;
}
/// <summary>
/// Checks if the <see cref="PKM"/> is compatible with the input <see cref="PKM"/>, and makes any necessary modifications to force compatibility.
/// </summary>
/// <remarks>Should only be used when forcing a backwards conversion to sanitize the PKM fields to the target format.
/// If the PKM is compatible, some properties may be forced to sanitized values.</remarks>
/// <param name="pk">PKM input that is to be sanity checked.</param>
/// <returns>Indication whether or not the PKM is compatible.</returns>
public static bool IsPKMCompatibleWithModifications(PKM pk)
{
if (pk.Species > pk.MaxSpeciesID)
return false;
if (pk.HeldItem > pk.MaxItemID)
pk.HeldItem = 0;
if (pk.Nickname.Length > pk.NickLength)
pk.Nickname = pk.Nickname.Substring(0, pk.NickLength);
if (pk.OT_Name.Length > pk.OTLength)
pk.OT_Name = pk.OT_Name.Substring(0, pk.OTLength);
if (pk.Moves.Any(move => move > pk.MaxMoveID))
pk.ClearInvalidMoves();
if (pk.EVs.Any(ev => ev > pk.MaxEV))
pk.EVs = pk.EVs.Select(ev => Math.Min(pk.MaxEV, ev)).ToArray();
if (pk.IVs.Any(iv => iv > pk.MaxIV))
pk.IVs = pk.IVs.Select(iv => Math.Min(pk.MaxIV, iv)).ToArray();
return true;
}
/// <summary>
/// Sets the details of a path to a <see cref="SaveFile"/> object.
/// </summary>
/// <param name="sav">Save File to set path details to.</param>
/// <param name="path">Full Path of the file</param>
public static void SetFileInfo(this SaveFile sav, string path)
{
if (!sav.Exportable) // Blank save file
{
sav.FileFolder = sav.FilePath = null;
sav.FileName = "Blank Save File";
return;
}
sav.FilePath = path;
sav.FileFolder = Path.GetDirectoryName(path);
sav.FileName = Path.GetFileName(path);
if (!sav.FileName.EndsWith(".bak"))
return;
// trim off any bak details to get original file name
int index = sav.FileName.LastIndexOf(" [", StringComparison.Ordinal);
if (index < 0)
return;
sav.FileName = sav.FileName.Substring(0, index);
}
}
}

View File

@ -701,7 +701,7 @@ public void UpdateIVsGB(bool skipForm)
}
private void UpdateBall(object sender, EventArgs e)
{
PB_Ball.Image = PKMUtil.GetBallSprite(WinFormsUtil.GetIndex(CB_Ball));
PB_Ball.Image = SpriteUtil.GetBallSprite(WinFormsUtil.GetIndex(CB_Ball));
}
private void UpdateEXPLevel(object sender, EventArgs e)
{

View File

@ -56,8 +56,8 @@ private void ClickSet(object sender, EventArgs e)
PKM pk = editor.PreparePKM();
string[] errata = sav.IsPKMCompatible(pk);
if (errata.Length > 0 && DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, string.Join(Environment.NewLine, errata), MsgContinue))
var errata = sav.IsPKMCompatible(pk);
if (errata.Count > 0 && DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, string.Join(Environment.NewLine, errata), MsgContinue))
return;
if (info.Type == StorageSlotType.Party) // Party

View File

@ -347,8 +347,8 @@ private bool TryLoadFiles(string[] files, DragEventArgs e, bool noEgg)
if (noEgg && (pk.Species == 0 || pk.IsEgg))
return false;
string[] errata = SAV.IsPKMCompatible(pk);
if (errata.Length > 0)
var errata = SAV.IsPKMCompatible(pk);
if (errata.Count > 0)
{
string concat = string.Join(Environment.NewLine, errata);
if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, concat, "Continue?"))

View File

@ -710,7 +710,7 @@ private void OpenSAV(SaveFile sav, string path)
return;
StoreLegalSaveGameData(sav);
PKMConverter.Trainer = sav;
PKMUtil.Spriter.Initialize(sav); // refresh sprite generator
SpriteUtil.Spriter.Initialize(sav); // refresh sprite generator
// clean fields
C_SAV.M.Reset();

View File

@ -597,12 +597,11 @@
<Compile Include="Util\ImageUtil.cs" />
<Compile Include="Util\NetUtil.cs" />
<Compile Include="Util\PathUtilWindows.cs" />
<Compile Include="Util\PKMUtil.cs" />
<Compile Include="Util\SpriteUtil.cs" />
<Compile Include="Util\QRCoder\AbstractQRCode.cs" />
<Compile Include="Util\QRCoder\QRCode.cs" />
<Compile Include="Util\QRCoder\QRCodeData.cs" />
<Compile Include="Util\QRCoder\QRCodeGenerator.cs" />
<Compile Include="Util\SAVUtil.cs" />
<Compile Include="Util\SpriteBuilder.cs" />
<Compile Include="Util\WinFormsTranslator.cs" />
<Compile Include="Util\WinFormsUtil.cs" />

View File

@ -50,13 +50,13 @@ private void PopEntry(int index)
int r = 0;
row.Cells[r++].Value = s.ToString("000") + (f > 0 ? "-"+f.ToString("00") :"");
row.Cells[r++].Value = PKMUtil.GetSprite(s, f, 0, 0, false, false, SAV.Generation);
row.Cells[r++].Value = SpriteUtil.GetSprite(s, f, 0, 0, false, false, SAV.Generation);
row.Cells[r++].Value = species[index];
row.Cells[r++].Value = s > 721 || Legal.PastGenAlolanNatives.Contains(s);
row.Cells[r].Style.BackColor = ImageUtil.ColorBaseStat((int)((Math.Max(p.BST - 175, 0)) / 3f));
row.Cells[r++].Value = p.BST.ToString("000");
row.Cells[r++].Value = PKMUtil.GetTypeSprite(p.Type1, SAV.Generation);
row.Cells[r++].Value = p.Type1 == p.Type2 ? Resources.slotTrans : PKMUtil.GetTypeSprite(p.Type2, SAV.Generation);
row.Cells[r++].Value = SpriteUtil.GetTypeSprite(p.Type1, SAV.Generation);
row.Cells[r++].Value = p.Type1 == p.Type2 ? Resources.slotTrans : SpriteUtil.GetTypeSprite(p.Type2, SAV.Generation);
row.Cells[r].Style.BackColor = ImageUtil.ColorBaseStat(p.HP);
row.Cells[r++].Value = p.HP.ToString("000");
row.Cells[r].Style.BackColor = ImageUtil.ColorBaseStat(p.ATK);

View File

@ -74,7 +74,7 @@ private void AddRibbonSprite(RibbonInfo rib)
{
var name = rib.Name;
PictureBox pb = new PictureBox { AutoSize = false, Size = new Size(40,40), BackgroundImageLayout = ImageLayout.Center, Visible = false, Name = PrefixPB + name };
var img = PKMUtil.GetRibbonSprite(name);
var img = SpriteUtil.GetRibbonSprite(name);
if (img != null)
pb.BackgroundImage = (Bitmap)img;
if (img == null)

View File

@ -88,7 +88,7 @@ public void PopulateData(IList<PKM> Data)
}
private void Data_Sorted(object sender, EventArgs e)
{
int height = PKMUtil.GetSprite(1, 0, 0, 0, false, false).Height + 1; // dummy sprite, max height of a row
int height = SpriteUtil.GetSprite(1, 0, 0, 0, false, false).Height + 1; // dummy sprite, max height of a row
for (int i = 0; i < dgData.Rows.Count; i++)
dgData.Rows[i].Height = height;
}

View File

@ -602,7 +602,7 @@ private void UpdateSlotValue(object sender, EventArgs e)
private void SetSprite(EntreeSlot slot)
{
PB_SlotPreview.Image = PKMUtil.GetSprite(slot.Species, slot.Form, slot.Gender, 0, false, false);
PB_SlotPreview.Image = SpriteUtil.GetSprite(slot.Species, slot.Form, slot.Gender, 0, false, false);
}
private void SetGenders(EntreeSlot slot)

View File

@ -232,7 +232,7 @@ private void NUP_PartyIndex_ValueChanged(object sender, EventArgs e)
CB_Form.SelectedIndex = (int)form;
SetGenderLabel((int)gender);
UpdateNickname(sender, e);
bpkx.Image = PKMUtil.GetSprite(species, (int)form, (int)gender, item, false, shiny == 1);
bpkx.Image = SpriteUtil.GetSprite(species, (int)form, (int)gender, item, false, shiny == 1);
editing = true;
}
private void Write_Entry(object sender, EventArgs e)
@ -293,7 +293,7 @@ private void Write_Entry(object sender, EventArgs e)
vnd |= rawvnd & 0x80000000;
Array.Copy(BitConverter.GetBytes(vnd), 0, data, offset + 0x1B0, 4);
bpkx.Image = PKMUtil.GetSprite(WinFormsUtil.GetIndex(CB_Species), CB_Form.SelectedIndex & 0x1F, PKX.GetGenderFromString(Label_Gender.Text), WinFormsUtil.GetIndex(CB_HeldItem), false, CHK_Shiny.Checked);
bpkx.Image = SpriteUtil.GetSprite(WinFormsUtil.GetIndex(CB_Species), CB_Form.SelectedIndex & 0x1F, PKX.GetGenderFromString(Label_Gender.Text), WinFormsUtil.GetIndex(CB_HeldItem), false, CHK_Shiny.Checked);
DisplayEntry(null, null); // refresh text view
}
private void Validate_TextBoxes()
@ -341,7 +341,7 @@ private void UpdateShiny(object sender, EventArgs e)
{
if (!editing)
return; //Don't do writing until loaded
bpkx.Image = PKMUtil.GetSprite(WinFormsUtil.GetIndex(CB_Species), CB_Form.SelectedIndex & 0x1F, PKX.GetGenderFromString(Label_Gender.Text), WinFormsUtil.GetIndex(CB_HeldItem), false, CHK_Shiny.Checked);
bpkx.Image = SpriteUtil.GetSprite(WinFormsUtil.GetIndex(CB_Species), CB_Form.SelectedIndex & 0x1F, PKX.GetGenderFromString(Label_Gender.Text), WinFormsUtil.GetIndex(CB_HeldItem), false, CHK_Shiny.Checked);
Write_Entry(null, null);
}

View File

@ -4,7 +4,7 @@
namespace PKHeX.WinForms
{
public static class PKMUtil
public static class SpriteUtil
{
public static ISpriteBuilder<Image> Spriter { get; set; } = new SpriteBuilder();