diff --git a/PKHeX.Core/PKM/Util/PKMConverter.cs b/PKHeX.Core/PKM/Util/PKMConverter.cs index 001ef905c..9f4a272eb 100644 --- a/PKHeX.Core/PKM/Util/PKMConverter.cs +++ b/PKHeX.Core/PKM/Util/PKMConverter.cs @@ -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) } } + /// + /// Checks if the is compatible with the input , and makes any necessary modifications to force compatibility. + /// + /// 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. + /// PKM input that is to be sanity checked. + /// Indication whether or not the PKM is compatible. + 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; + } + /// /// Checks if a PKM is encrypted; if encrypted, decrypts the PKM. /// diff --git a/PKHeX.WinForms/Util/SAVUtil.cs b/PKHeX.Core/Saves/BoxUtil.cs similarity index 63% rename from PKHeX.WinForms/Util/SAVUtil.cs rename to PKHeX.Core/Saves/BoxUtil.cs index 8c701a302..8258b5279 100644 --- a/PKHeX.WinForms/Util/SAVUtil.cs +++ b/PKHeX.Core/Saves/BoxUtil.cs @@ -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 { /// /// Contains extension methods for use with a . /// - public static class SAVUtil + public static class BoxUtil { /// /// Dumps a folder of files to the . @@ -145,7 +144,7 @@ public static bool LoadBoxes(this SaveFile SAV, IEnumerable 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 pks, out string return true; } - private static int ImportPKMs(this SaveFile SAV, IEnumerable 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 GetPKMsFromPaths(IEnumerable filepaths, int generation) { return filepaths @@ -196,81 +167,5 @@ private static IEnumerable GetPKMsFromPaths(IEnumerable filepaths, .Select(data => PKMConverter.GetPKMfromBytes(data, prefer: generation)) .Where(temp => temp != null); } - private static IEnumerable GetPKMForSaveFile(this SaveFile SAV, IEnumerable 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; - } - } - - /// - /// Checks a file for compatibility to the . - /// - /// that is being checked. - /// that is being tested for compatibility. - /// - public static string[] IsPKMCompatible(this SaveFile SAV, PKM pkm) - { - // Check if PKM properties are outside of the valid range - List errata = new List(); - 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(); - } - - /// - /// Removes the for all in the . - /// - /// that is being operated on. - /// to set. If no argument is supplied, the held item will be removed. - 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; - } } } diff --git a/PKHeX.Core/Saves/SaveExtensions.cs b/PKHeX.Core/Saves/SaveExtensions.cs new file mode 100644 index 000000000..65e6de10a --- /dev/null +++ b/PKHeX.Core/Saves/SaveExtensions.cs @@ -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 + { + /// + /// Checks if the is compatible with the input , and makes any necessary modifications to force compatibility. + /// + /// 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. + /// Save File target that the PKM will be injected. + /// PKM input that is to be injected into the Save File. + /// Indication whether or not the PKM is compatible. + public static bool IsPKMCompatibleWithModifications(this SaveFile SAV, PKM pk) => PKMConverter.IsPKMCompatibleWithModifications(pk, SAV); + + /// + /// Sets the details of a path to a object. + /// + /// Save File to set path details to. + /// Full Path of the file + 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); + } + + /// + /// Checks a file for compatibility to the . + /// + /// that is being checked. + /// that is being tested for compatibility. + /// + public static IReadOnlyList IsPKMCompatible(this SaveFile SAV, PKM pkm) + { + IBasicStrings strings = GameInfo.Strings; + return SAV.GetSaveFileErrata(pkm, strings); + } + + private static IReadOnlyList GetSaveFileErrata(this SaveFile SAV, PKM pkm, IBasicStrings strings) + { + var errata = new List(); + 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 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 GetCompatible(this SaveFile SAV, IEnumerable 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; + } + } + + + /// + /// Removes the for all in the . + /// + /// that is being operated on. + /// to set. If no argument is supplied, the held item will be removed. + 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; + } + } +} diff --git a/PKHeX.Core/Saves/SaveUtil.cs b/PKHeX.Core/Saves/SaveUtil.cs index 3f978b407..4355faef8 100644 --- a/PKHeX.Core/Saves/SaveUtil.cs +++ b/PKHeX.Core/Saves/SaveUtil.cs @@ -1170,88 +1170,5 @@ public static byte[] GetMainFromSaveContainer(byte[] input) } return null; } - - /// - /// Checks if the is compatible with the input , and makes any necessary modifications to force compatibility. - /// - /// 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. - /// Save File target that the PKM will be injected. - /// PKM input that is to be injected into the Save File. - /// Indication whether or not the PKM is compatible. - 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; - } - /// - /// Checks if the is compatible with the input , and makes any necessary modifications to force compatibility. - /// - /// 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. - /// PKM input that is to be sanity checked. - /// Indication whether or not the PKM is compatible. - 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; - } - - /// - /// Sets the details of a path to a object. - /// - /// Save File to set path details to. - /// Full Path of the file - 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); - } } } diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs index edad75889..9c6206932 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs @@ -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) { diff --git a/PKHeX.WinForms/Controls/SAV Editor/ContextMenuSAV.cs b/PKHeX.WinForms/Controls/SAV Editor/ContextMenuSAV.cs index ab5d0683a..de37bd3dd 100644 --- a/PKHeX.WinForms/Controls/SAV Editor/ContextMenuSAV.cs +++ b/PKHeX.WinForms/Controls/SAV Editor/ContextMenuSAV.cs @@ -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 diff --git a/PKHeX.WinForms/Controls/SAV Editor/SlotChangeManager.cs b/PKHeX.WinForms/Controls/SAV Editor/SlotChangeManager.cs index 2a583d0de..2a7c5c3b5 100644 --- a/PKHeX.WinForms/Controls/SAV Editor/SlotChangeManager.cs +++ b/PKHeX.WinForms/Controls/SAV Editor/SlotChangeManager.cs @@ -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?")) diff --git a/PKHeX.WinForms/MainWindow/Main.cs b/PKHeX.WinForms/MainWindow/Main.cs index 3368c6baa..02730fd4a 100644 --- a/PKHeX.WinForms/MainWindow/Main.cs +++ b/PKHeX.WinForms/MainWindow/Main.cs @@ -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(); diff --git a/PKHeX.WinForms/PKHeX.WinForms.csproj b/PKHeX.WinForms/PKHeX.WinForms.csproj index d42593f24..4cf7549c5 100644 --- a/PKHeX.WinForms/PKHeX.WinForms.csproj +++ b/PKHeX.WinForms/PKHeX.WinForms.csproj @@ -597,12 +597,11 @@ - + - diff --git a/PKHeX.WinForms/Subforms/KChart.cs b/PKHeX.WinForms/Subforms/KChart.cs index 87a0078b6..25d7cdc22 100644 --- a/PKHeX.WinForms/Subforms/KChart.cs +++ b/PKHeX.WinForms/Subforms/KChart.cs @@ -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); diff --git a/PKHeX.WinForms/Subforms/PKM Editors/RibbonEditor.cs b/PKHeX.WinForms/Subforms/PKM Editors/RibbonEditor.cs index 2bd026fe3..2930f5a93 100644 --- a/PKHeX.WinForms/Subforms/PKM Editors/RibbonEditor.cs +++ b/PKHeX.WinForms/Subforms/PKM Editors/RibbonEditor.cs @@ -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) diff --git a/PKHeX.WinForms/Subforms/ReportGrid.cs b/PKHeX.WinForms/Subforms/ReportGrid.cs index 957d4697c..0bb1685f1 100644 --- a/PKHeX.WinForms/Subforms/ReportGrid.cs +++ b/PKHeX.WinForms/Subforms/ReportGrid.cs @@ -88,7 +88,7 @@ public void PopulateData(IList 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; } diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Misc5.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Misc5.cs index 794a94518..9debf1de8 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Misc5.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Misc5.cs @@ -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) diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_HallOfFame.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_HallOfFame.cs index acb0738ed..a7fdf4ec4 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_HallOfFame.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_HallOfFame.cs @@ -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); } diff --git a/PKHeX.WinForms/Util/PKMUtil.cs b/PKHeX.WinForms/Util/SpriteUtil.cs similarity index 99% rename from PKHeX.WinForms/Util/PKMUtil.cs rename to PKHeX.WinForms/Util/SpriteUtil.cs index af0c87dc5..2812c9dc5 100644 --- a/PKHeX.WinForms/Util/PKMUtil.cs +++ b/PKHeX.WinForms/Util/SpriteUtil.cs @@ -4,7 +4,7 @@ namespace PKHeX.WinForms { - public static class PKMUtil + public static class SpriteUtil { public static ISpriteBuilder Spriter { get; set; } = new SpriteBuilder();