From a0351efc811ecd75d7b37ee82c1f5ea3d49bdfaa Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 7 Feb 2021 08:32:01 -0800 Subject: [PATCH] Show preview tooltip in mgdb view Show card header to differentiate gifts --- .../Controls/Slots/SummaryPreviewer.cs | 2 ++ PKHeX.WinForms/Subforms/SAV_MysteryGiftDB.cs | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/PKHeX.WinForms/Controls/Slots/SummaryPreviewer.cs b/PKHeX.WinForms/Controls/Slots/SummaryPreviewer.cs index 3c6f63872..5e666a46f 100644 --- a/PKHeX.WinForms/Controls/Slots/SummaryPreviewer.cs +++ b/PKHeX.WinForms/Controls/Slots/SummaryPreviewer.cs @@ -36,6 +36,8 @@ public void Show(Control pb, IEncounterInfo enc) var name = (uint)enc.Species < str.Count ? str[enc.Species] : enc.Species.ToString(); var EncounterName = $"{(enc is IEncounterable ie ? ie.LongName : "Special")} ({name})"; lines.Add(string.Format(L_FEncounterType_0, EncounterName)); + if (enc is MysteryGift mg) + lines.Add(mg.CardHeader); var el = enc as ILocation; var loc = el?.GetEncounterLocation(enc.Generation, (int)enc.Version); diff --git a/PKHeX.WinForms/Subforms/SAV_MysteryGiftDB.cs b/PKHeX.WinForms/Subforms/SAV_MysteryGiftDB.cs index 479f7437e..0a082b91e 100644 --- a/PKHeX.WinForms/Subforms/SAV_MysteryGiftDB.cs +++ b/PKHeX.WinForms/Subforms/SAV_MysteryGiftDB.cs @@ -19,6 +19,7 @@ public partial class SAV_MysteryGiftDB : Form private readonly PKMEditor PKME_Tabs; private readonly SaveFile SAV; private readonly SAVEditor BoxView; + private readonly SummaryPreviewer ShowSet = new(); public SAV_MysteryGiftDB(PKMEditor tabs, SAVEditor sav) { @@ -60,6 +61,8 @@ public SAV_MysteryGiftDB(PKMEditor tabs, SAVEditor sav) }; slot.ContextMenuStrip = mnu; + if (Settings.Default.HoverSlotShowText) + slot.MouseEnter += (o, args) => ShowHoverTextForSlot(slot, args); } Counter = L_Count.Text; @@ -88,6 +91,14 @@ public SAV_MysteryGiftDB(PKMEditor tabs, SAVEditor sav) private readonly string Viewed; private const int MAXFORMAT = PKX.Generation; + private bool GetShiftedIndex(ref int index) + { + if (index >= RES_MAX) + return false; + index += SCR_Box.Value * RES_MIN; + return index < Results.Count; + } + // Important Events private void ClickView(object sender, EventArgs e) { @@ -390,5 +401,15 @@ private void ChangeFormatFilter(object sender, EventArgs e) CB_Format.SelectedIndex = index < CB_Format.Items.Count ? index : 0; // SAV generation (offset by 1 for "Any") } } + + private void ShowHoverTextForSlot(object sender, EventArgs e) + { + var pb = (PictureBox)sender; + int index = Array.IndexOf(PKXBOXES, pb); + if (!GetShiftedIndex(ref index)) + return; + + ShowSet.Show(pb, Results[index]); + } } }