PKHeX/PKHeX.Drawing.Misc/Util/DonutSpriteUtil.cs
Kurt 2c541ad422
Update to .NET 10 (#4676)
* Update to .NET 10
* Property fields
* API signature updates
* Extension method blocks

* Completed dark mode support
  Outside of my control:
- vertical tab control (pkm editor)
- datetimepicker controls
- lgpe event flags (no idea)
- some control types having white-borders when they should really be gray

Box background is 50% transparency to effectively darken the image.

* Custom legality report popup
* Event diff dialog, version select dialog
* Add quick overwrite popup for export sav
* Extension methods
* Dark Mode: glow currently editing sprite
* Add invalid encounter hint for trade evolutions
* Extension properties
* Append legality hint on hover card
* Slot image loading: clear the screen-reader description if a slot is empty/invalid, rather than retain the previous description. Changing boxes would easily confuse users on this.
2025-12-31 01:42:05 -06:00

46 lines
1.8 KiB
C#

using PKHeX.Core;
using PKHeX.Drawing.Misc.Properties;
using System;
using System.Drawing;
namespace PKHeX.Drawing.Misc;
/// <summary>
/// Provides utility methods for retrieving and composing sprites for Donuts.
/// </summary>
public static class DonutSpriteUtil
{
/// <summary>
/// Gets the sprite image for the specified <see cref="Donut9a"/>.
/// </summary>
/// <param name="donut">The donut to get the sprite for.</param>
/// <returns>A <see cref="Bitmap"/> representing the sprite image.</returns>
public static Bitmap? Sprite(this Donut9a donut) => GetDonutImage(donut);
public static Bitmap? StarSprite => (Bitmap?)Resources.ResourceManager.GetObject("star");
public static Bitmap? GetDonutFlavorImage(string donut) => (Bitmap?)Resources.ResourceManager.GetObject(donut);
public static Bitmap? GetFlavorProfileImage() => (Bitmap?)Resources.ResourceManager.GetObject("flavorprofile");
private static Bitmap? GetDonutImage(Donut9a donut)
{
if (donut.Donut is >= 198 and <= 202)
return GetSpecialDonutImage(donut);
ReadOnlySpan<string> flavors = ["sweet", "spicy", "sour", "bitter", "fresh", "mix"];
var variant = donut.Donut % 6;
var stars = donut.Stars;
var flavor = flavors[variant];
var resource = $"donut_{flavor}{stars:00}";
return (Bitmap?)Resources.ResourceManager.GetObject(resource);
}
private static Bitmap? GetSpecialDonutImage(Donut9a donut) => donut.Donut switch
{
198 => Resources.donut_uni491, // Bad Dreams Cruller
199 => Resources.donut_uni383, // Omega Old-Fashioned Donut
200 => Resources.donut_uni382, // Alpha Old-Fashioned Donut
201 => Resources.donut_uni384, // Delta Old-Fashioned Donut
202 => Resources.donut_uni807, // Plasma-Glazed Donut
_ => null,
};
}