Show preview tooltip in mgdb view

Show card header to differentiate gifts
This commit is contained in:
Kurt 2021-02-07 08:32:01 -08:00
parent a2d5d7d769
commit a0351efc81
2 changed files with 23 additions and 0 deletions

View file

@ -36,6 +36,8 @@ namespace PKHeX.WinForms.Controls
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);

View file

@ -19,6 +19,7 @@ namespace PKHeX.WinForms
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 @@ namespace PKHeX.WinForms
};
slot.ContextMenuStrip = mnu;
if (Settings.Default.HoverSlotShowText)
slot.MouseEnter += (o, args) => ShowHoverTextForSlot(slot, args);
}
Counter = L_Count.Text;
@ -88,6 +91,14 @@ namespace PKHeX.WinForms
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 @@ namespace PKHeX.WinForms
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]);
}
}
}