diff --git a/PKHeX.WinForms/Controls/SAV Editor/SlotChangeManager.cs b/PKHeX.WinForms/Controls/SAV Editor/SlotChangeManager.cs index ae768e361..a05ebecf9 100644 --- a/PKHeX.WinForms/Controls/SAV Editor/SlotChangeManager.cs +++ b/PKHeX.WinForms/Controls/SAV Editor/SlotChangeManager.cs @@ -580,7 +580,7 @@ private static string GetCryPath(PKM pk, string cryFolder) return path; } - private static string GetLocalizedPreviewText(PKM pk, string language) + public static string GetLocalizedPreviewText(PKM pk, string language) { var set = new ShowdownSet(pk); if (pk.Format <= 2) // Nature preview from IVs diff --git a/PKHeX.WinForms/Subforms/SAV_Database.cs b/PKHeX.WinForms/Subforms/SAV_Database.cs index a3a8f3f6c..ee07a10cd 100644 --- a/PKHeX.WinForms/Subforms/SAV_Database.cs +++ b/PKHeX.WinForms/Subforms/SAV_Database.cs @@ -11,6 +11,7 @@ using PKHeX.Core; using PKHeX.Core.Searching; using PKHeX.WinForms.Controls; +using PKHeX.WinForms.Properties; using static PKHeX.Core.MessageStrings; namespace PKHeX.WinForms @@ -68,6 +69,26 @@ public SAV_Database(PKMEditor f1, SAVEditor saveditor) else if (ModifierKeys == Keys.Shift) ClickSet(sender, e); }; + + if (Settings.Default.HoverSlotShowText) + { + slot.MouseEnter += (sender, e) => + { + int index = Array.IndexOf(PKXBOXES, slot); + if (!GetShiftedIndex(ref index)) + return; + + var pk = Results[index]; + if (pk.Species == 0) + { + ShowSet.RemoveAll(); + return; + } + + var text = SlotChangeManager.GetLocalizedPreviewText(pk, Settings.Default.Language); + ShowSet.SetToolTip(slot, text); + }; + } } Counter = L_Count.Text; @@ -113,19 +134,14 @@ public SAV_Database(PKMEditor f1, SAVEditor saveditor) private readonly string Viewed; private const int MAXFORMAT = PKX.Generation; private readonly string EXTERNAL_SAV = new DirectoryInfo(Main.BackupPath).Name + Path.DirectorySeparatorChar; + private readonly ToolTip ShowSet = new ToolTip {InitialDelay = 200, IsBalloon = false}; // Important Events private void ClickView(object sender, EventArgs e) { sender = WinFormsUtil.GetUnderlyingControl(sender); int index = Array.IndexOf(PKXBOXES, sender); - if (index >= RES_MAX) - { - System.Media.SystemSounds.Exclamation.Play(); - return; - } - index += SCR_Box.Value * RES_MIN; - if (index >= Results.Count) + if (!GetShiftedIndex(ref index)) { System.Media.SystemSounds.Exclamation.Play(); return; @@ -142,13 +158,7 @@ private void ClickDelete(object sender, EventArgs e) { sender = WinFormsUtil.GetUnderlyingControl(sender); int index = Array.IndexOf(PKXBOXES, sender); - if (index >= RES_MAX) - { - System.Media.SystemSounds.Exclamation.Play(); - return; - } - index += SCR_Box.Value * RES_MIN; - if (index >= Results.Count) + if (!GetShiftedIndex(ref index)) { System.Media.SystemSounds.Exclamation.Play(); return; @@ -235,6 +245,14 @@ private void ClickSet(object sender, EventArgs e) WinFormsUtil.Alert(MsgDBAddFromTabsSuccess); } + private bool GetShiftedIndex(ref int index) + { + if (index >= RES_MAX) + return false; + index += SCR_Box.Value * RES_MIN; + return index < Results?.Count; + } + private void PopulateComboBoxes() { // Set the Text