mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 06:20:25 +00:00
94baab1c45
With the approaching games, PKM sprites are a different size from the 3DS era (as already hinted by LGPE, which has 56x68). It'll be a little easier to manage with this portion of the library walled off from the rest of the codebase. Eventually the net46 target will use fody or something to merge in these extra dependency dll's automatically to not disturb the usual exe/dll experience.
78 lines
No EOL
2.4 KiB
C#
78 lines
No EOL
2.4 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using PKHeX.Core;
|
|
using PKHeX.Drawing;
|
|
using PKHeX.WinForms.Properties;
|
|
|
|
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 class SlotHoverHandler : IDisposable
|
|
{
|
|
public DrawConfig Draw { private get; set; }
|
|
public bool GlowHover { private get; set; } = true;
|
|
|
|
public static readonly CryPlayer CryPlayer = new CryPlayer();
|
|
public static readonly SummaryPreviewer Preview = new SummaryPreviewer();
|
|
|
|
private readonly BitmapAnimator HoverWorker = new BitmapAnimator(Resources.slotHover);
|
|
|
|
private PictureBox Slot;
|
|
|
|
public void Start(PictureBox pb, SlotTrackerImage LastSlot)
|
|
{
|
|
var view = WinFormsUtil.FindFirstControlOfType<ISlotViewer<PictureBox>>(pb);
|
|
var data = view.GetSlotData(pb);
|
|
var pk = data.Read(view.SAV);
|
|
Slot = pb;
|
|
|
|
var orig = LastSlot.OriginalBackground = pb.BackgroundImage;
|
|
|
|
Bitmap bg;
|
|
if (GlowHover)
|
|
{
|
|
HoverWorker.Stop();
|
|
|
|
SpriteUtil.GetSpriteGlow(pk, Draw.GlowInitial.B, Draw.GlowInitial.G, Draw.GlowInitial.R, out var glowdata, out var GlowBase);
|
|
bg = ImageUtil.LayerImage(GlowBase, Resources.slotHover, 0, 0);
|
|
HoverWorker.GlowToColor = Draw.GlowFinal;
|
|
HoverWorker.GlowFromColor = Draw.GlowInitial;
|
|
HoverWorker.Start(pb, GlowBase, glowdata, orig);
|
|
}
|
|
else
|
|
{
|
|
bg = Resources.slotHover;
|
|
}
|
|
|
|
if (orig != null)
|
|
bg = ImageUtil.LayerImage(orig, bg, 0, 0);
|
|
pb.BackgroundImage = LastSlot.CurrentBackground = bg;
|
|
|
|
if (Settings.Default.HoverSlotShowText)
|
|
Preview.Show(pb, pk);
|
|
if (Settings.Default.HoverSlotPlayCry)
|
|
CryPlayer.PlayCry(pk);
|
|
}
|
|
|
|
public void Stop()
|
|
{
|
|
if (Slot != null)
|
|
{
|
|
HoverWorker.Stop();
|
|
Slot = null;
|
|
}
|
|
Preview.Clear();
|
|
CryPlayer.Stop();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
HoverWorker?.Dispose();
|
|
Slot?.Dispose();
|
|
Draw?.Dispose();
|
|
}
|
|
}
|
|
} |