diff --git a/PKHeX.Core/Saves/Substructures/BoxWallpaper.cs b/PKHeX.Core/Saves/Substructures/BoxWallpaper.cs index 1fccabe0f..6b1a39ac5 100644 --- a/PKHeX.Core/Saves/Substructures/BoxWallpaper.cs +++ b/PKHeX.Core/Saves/Substructures/BoxWallpaper.cs @@ -1,90 +1,103 @@ -namespace PKHeX.Core +using static PKHeX.Core.GameVersion; + +namespace PKHeX.Core { public static class BoxWallpaper { - public static string GetWallpaperResourceName(SaveFile SAV, int index) + public static string GetWallpaperResourceName(GameVersion version, int index) { index++; - string s = $"box_wp{index:00}"; - switch (SAV.Generation) - { - case 7: s += "xy"; - break; - case 6: s += SAV.ORAS && index > 16 ? "ao" : "xy"; - break; - case 5: s += SAV.B2W2 && index > 16 ? "b2w2" : "bw"; - break; - case 4: - if (SAV.Pt && index > 16) - s += "pt"; - else if (SAV.HGSS && index > 16) - s += "hgss"; - else - s += "dp"; - break; - case 3: - if (SAV.E) - s += "e"; - else if (SAV.FRLG && index > 12) - s += "frlg"; - else - s += "rs"; - break; - } - return s; + var suffix = GetResourceSuffix(version, index); + return $"box_wp{index:00}{suffix}"; } - public static bool IsWallpaperRed(SaveFile SAV, int box) + private static string GetResourceSuffix(GameVersion version, int index) { - switch (SAV.Generation) + switch (version.GetGeneration()) + { + case 7: + return "xy"; + case 6: + return ORAS.Contains(version) && index > 16 ? "ao" : "xy"; + case 5: + return B2W2.Contains(version) && index > 16 ? "b2w2" : "bw"; + case 4: + if (index > 16) + { + if (Pt == version) + return "pt"; + if (HGSS.Contains(version)) + return "hgss"; + } + return "dp"; + case 3: + if (E == version) + return "e"; + else if (FRLG.Contains(version) && index > 12) + return "frlg"; + else + return "rs"; + default: + return string.Empty; + } + } + + public static bool IsWallpaperRed(GameVersion version, int wallpaperID) + { + switch (version.GetGeneration()) { case 3: - if (SAV.GameCube) - return box == 7 && SAV is SAV3XD; // flame pattern in XD - switch (SAV.GetBoxWallpaper(box)) + if (CXD.Contains(version)) + return wallpaperID == 7; // flame pattern in XD + switch (wallpaperID) { case 5: // Volcano return true; case 13: // PokéCenter - return SAV.E; + return E == version; + default: + return false; } - break; case 4: - switch (SAV.GetBoxWallpaper(box)) + switch (wallpaperID) { case 5: // Volcano case 12: // Checks case 13: // PokéCenter case 22: // Special return true; + default: + return false; } - break; case 5: - switch (SAV.GetBoxWallpaper(box)) + switch (wallpaperID) { case 5: // Volcano case 12: // Checks return true; case 19: // PWT case 22: // Reshiram - return SAV.B2W2; + return B2W2.Contains(version); case 21: // Zoroark case 23: // Musical - return SAV.BW; + return BW.Contains(version); + default: + return false; } - break; case 6: case 7: - switch (SAV.GetBoxWallpaper(box)) + switch (wallpaperID) { case 5: // Volcano case 12: // PokéCenter case 20: // Special5 Flare/Magma return true; + default: + return false; } - break; + default: + return false; } - return false; } } } diff --git a/PKHeX.WinForms/Util/SpriteUtil.cs b/PKHeX.WinForms/Util/SpriteUtil.cs index 7aed4ce97..f12f32fc8 100644 --- a/PKHeX.WinForms/Util/SpriteUtil.cs +++ b/PKHeX.WinForms/Util/SpriteUtil.cs @@ -111,7 +111,7 @@ private static Image GetSprite(SaveFile SAV) private static Image GetWallpaper(SaveFile SAV, int box) { - string s = BoxWallpaper.GetWallpaperResourceName(SAV, box); + string s = BoxWallpaper.GetWallpaperResourceName(SAV.Version, SAV.GetBoxWallpaper(box)); return (Bitmap)(Resources.ResourceManager.GetObject(s) ?? Resources.box_wp16xy); } @@ -121,7 +121,7 @@ private static Image GetSprite(PKM pkm, SaveFile SAV, int box, int slot, bool fl return null; bool inBox = slot >= 0 && slot < 30; - var sprite = pkm.Species != 0 ? pkm.Sprite(isBoxBGRed: inBox && BoxWallpaper.IsWallpaperRed(SAV, box)) : null; + var sprite = pkm.Species == 0 ? null : pkm.Sprite(isBoxBGRed: inBox && BoxWallpaper.IsWallpaperRed(SAV.Version, SAV.GetBoxWallpaper(box))); if (flagIllegal) {