mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 14:30:56 +00:00
88830e0d00
Updates from net46->net7, dropping support for mono in favor of using the latest runtime (along with the performance/API improvements). Releases will be posted as 64bit only for now. Refactors a good amount of internal API methods to be more performant and more customizable for future updates & fixes. Adds functionality for Batch Editor commands to `>`, `<` and <=/>= TID/SID properties renamed to TID16/SID16 for clarity; other properties exposed for Gen7 / display variants. Main window has a new layout to account for DPI scaling (8 point grid) Fixed: Tatsugiri and Paldean Tauros now output Showdown form names as Showdown expects Changed: Gen9 species now interact based on the confirmed National Dex IDs (closes #3724) Fixed: Pokedex set all no longer clears species with unavailable non-base forms (closes #3720) Changed: Hyper Training suggestions now apply for level 50 in SV. (closes #3714) Fixed: B2/W2 hatched egg met locations exclusive to specific versions are now explicitly checked (closes #3691) Added: Properties for ribbon/mark count (closes #3659) Fixed: Traded SV eggs are now checked correctly (closes #3692)
83 lines
2.4 KiB
C#
83 lines
2.4 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using PKHeX.Core;
|
|
using PKHeX.Drawing;
|
|
using PKHeX.Drawing.PokeSprite;
|
|
|
|
namespace PKHeX.WinForms.Controls;
|
|
|
|
/// <summary>
|
|
/// Handles Hovering operations for an editor, where only one (1) slot can be animated at a given time when hovering over it.
|
|
/// </summary>
|
|
public sealed class SlotHoverHandler : IDisposable
|
|
{
|
|
public DrawConfig Draw { private get; set; } = new();
|
|
public bool GlowHover { private get; set; } = true;
|
|
|
|
public static readonly CryPlayer CryPlayer = new();
|
|
public static readonly SummaryPreviewer Preview = new();
|
|
private static Bitmap Hover => SpriteUtil.Spriter.Hover;
|
|
|
|
private readonly BitmapAnimator HoverWorker = new();
|
|
|
|
private PictureBox? Slot;
|
|
private SlotTrackerImage? LastSlot;
|
|
|
|
public void Start(PictureBox pb, SlotTrackerImage lastSlot)
|
|
{
|
|
var view = WinFormsUtil.FindFirstControlOfType<ISlotViewer<PictureBox>>(pb);
|
|
if (view == null)
|
|
throw new InvalidCastException(nameof(view));
|
|
var data = view.GetSlotData(pb);
|
|
var pk = data.Read(view.SAV);
|
|
Slot = pb;
|
|
LastSlot = lastSlot;
|
|
|
|
var orig = LastSlot.OriginalBackground = pb.BackgroundImage;
|
|
|
|
Bitmap bg;
|
|
if (GlowHover)
|
|
{
|
|
HoverWorker.Stop();
|
|
var hover = Hover;
|
|
var glow = Draw.GlowInitial;
|
|
SpriteUtil.GetSpriteGlow(pk, glow.B, glow.G, glow.R, out var glowdata, out var imgGlowBase);
|
|
bg = ImageUtil.LayerImage(imgGlowBase, hover, 0, 0);
|
|
HoverWorker.GlowToColor = Draw.GlowFinal;
|
|
HoverWorker.GlowFromColor = Draw.GlowInitial;
|
|
HoverWorker.Start(pb, imgGlowBase, glowdata, orig, hover);
|
|
}
|
|
else
|
|
{
|
|
bg = Hover;
|
|
}
|
|
|
|
if (orig != null)
|
|
bg = ImageUtil.LayerImage(orig, bg, 0, 0);
|
|
pb.BackgroundImage = LastSlot.CurrentBackground = bg;
|
|
|
|
Preview.Show(pb, pk);
|
|
}
|
|
|
|
public void Stop()
|
|
{
|
|
if (Slot != null)
|
|
{
|
|
if (HoverWorker.Enabled)
|
|
HoverWorker.Stop();
|
|
else
|
|
Slot.BackgroundImage = LastSlot?.OriginalBackground;
|
|
Slot = null;
|
|
LastSlot = null;
|
|
}
|
|
Preview.Clear();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
HoverWorker.Dispose();
|
|
Slot = null;
|
|
Draw.Dispose();
|
|
}
|
|
}
|