2021-02-07 06:33:13 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Windows.Forms;
|
2019-08-21 02:50:28 +00:00
|
|
|
|
using PKHeX.Core;
|
|
|
|
|
using PKHeX.WinForms.Properties;
|
|
|
|
|
|
2021-02-07 06:33:13 +00:00
|
|
|
|
using static PKHeX.Core.LegalityCheckStrings;
|
|
|
|
|
|
2019-08-21 02:50:28 +00:00
|
|
|
|
namespace PKHeX.WinForms.Controls
|
|
|
|
|
{
|
2019-10-04 02:09:02 +00:00
|
|
|
|
public sealed class SummaryPreviewer
|
2019-08-21 02:50:28 +00:00
|
|
|
|
{
|
2020-12-22 07:37:07 +00:00
|
|
|
|
private readonly ToolTip ShowSet = new() { InitialDelay = 200, IsBalloon = false };
|
2019-08-21 02:50:28 +00:00
|
|
|
|
|
|
|
|
|
public void Show(Control pb, PKM pk)
|
|
|
|
|
{
|
|
|
|
|
if (pk.Species == 0)
|
|
|
|
|
{
|
|
|
|
|
Clear();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-12-29 05:42:54 +00:00
|
|
|
|
var text = ShowdownParsing.GetLocalizedPreviewText(pk, Settings.Default.Language);
|
2021-03-07 20:35:26 +00:00
|
|
|
|
var la = new LegalityAnalysis(pk);
|
|
|
|
|
var result = new List<string>{ text, string.Empty };
|
2021-03-20 20:21:04 +00:00
|
|
|
|
LegalityFormatting.AddEncounterInfo(la, result);
|
2021-03-07 20:35:26 +00:00
|
|
|
|
ShowSet.SetToolTip(pb, string.Join(Environment.NewLine, result));
|
2019-08-21 02:50:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-07 06:33:13 +00:00
|
|
|
|
public void Show(Control pb, IEncounterInfo enc)
|
|
|
|
|
{
|
|
|
|
|
if (enc.Species == 0)
|
|
|
|
|
{
|
|
|
|
|
Clear();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var lines = new List<string>();
|
|
|
|
|
var str = GameInfo.Strings.Species;
|
|
|
|
|
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));
|
2021-02-07 16:32:01 +00:00
|
|
|
|
if (enc is MysteryGift mg)
|
|
|
|
|
lines.Add(mg.CardHeader);
|
2021-02-07 06:33:13 +00:00
|
|
|
|
|
|
|
|
|
var el = enc as ILocation;
|
|
|
|
|
var loc = el?.GetEncounterLocation(enc.Generation, (int)enc.Version);
|
|
|
|
|
if (!string.IsNullOrEmpty(loc))
|
|
|
|
|
lines.Add(string.Format(L_F0_1, "Location", loc));
|
|
|
|
|
lines.Add(string.Format(L_F0_1, nameof(GameVersion), enc.Version));
|
|
|
|
|
lines.Add(enc.LevelMin == enc.LevelMax
|
|
|
|
|
? $"Level: {enc.LevelMin}"
|
|
|
|
|
: $"Level: {enc.LevelMin}-{enc.LevelMax}");
|
|
|
|
|
|
|
|
|
|
var text = string.Join(Environment.NewLine, lines);
|
|
|
|
|
ShowSet.SetToolTip(pb, text);
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-21 02:50:28 +00:00
|
|
|
|
public void Clear() => ShowSet.RemoveAll();
|
|
|
|
|
}
|
2021-02-07 06:33:13 +00:00
|
|
|
|
}
|