Misc tweaks

This commit is contained in:
Kurt 2024-05-19 23:29:27 -05:00
parent 1735fd142d
commit 96bf5a6891
3 changed files with 40 additions and 20 deletions

View file

@ -45,7 +45,7 @@ public sealed class NicknameVerifier : Verifier
{
if (pk.VC)
VerifyG1NicknameWithinBounds(data, nickname);
else if (enc is MysteryGift {IsEgg: false})
else if (IsMysteryGiftNoNickname(enc))
data.AddLine(Get(LEncGiftNicknamed, ParseSettings.Settings.Nickname.NicknamedMysteryGift(enc.Context)));
}
@ -75,6 +75,20 @@ public sealed class NicknameVerifier : Verifier
}
}
private static bool IsMysteryGiftNoNickname(IEncounterable enc)
{
if (enc is not MysteryGift { IsEgg: false })
return false;
return enc switch
{
PCD pcd => !pcd.Gift.PK.IsNicknamed,
PGF pgf => !pgf.IsNicknamed,
WC6 wc6 => !wc6.IsNicknamed && wc6 is not { IsLinkGift: true, Species: (int)Species.Glalie or (int)Species.Steelix }, // Can nickname the demo gift
WC7 wc7 => !wc7.IsNicknamed,
_ => true,
};
}
private void VerifyFixedNicknameEncounter(LegalityAnalysis data, ILangNicknamedTemplate n, IEncounterTemplate enc, PKM pk, ReadOnlySpan<char> nickname)
{
var encounterNickname = n.GetNickname(pk.Language);

View file

@ -109,7 +109,10 @@ public static class SaveLanguage
if (sav.Metadata.FileName is not { } x)
return GetFallback(sav);
var result = InferFrom3(x, sav.Version);
var ver = sav.Version;
if (ver is FR)
ver = FRLG; // Reset since the SAV3 impl assumes FR by default
var result = InferFrom3(x, ver);
if (!IsResultValid(result, sav))
return GetFallback(sav);

View file

@ -215,32 +215,35 @@ public sealed partial class PKMEditor : UserControl, IMainEditor
{
get
{
// Find the first unfilled control, indicate as invalid.
TabPage? invalid = GetInvalidParentTab();
if (invalid is null)
return true; // No issue.
if (ModifierKeys == (Keys.Control | Keys.Shift | Keys.Alt))
return true; // Override
// Find the first unfilled control, indicate as invalid.
Control? cb = null;
foreach (var type in ValidatedControls)
{
cb = type.IsNotValid(Entity);
if (cb is not null)
break;
}
if (cb != null)
Hidden_TC.SelectedTab = WinFormsUtil.FindFirstControlOfType<TabPage>(cb);
else if (!Stats.Valid)
Hidden_TC.SelectedTab = Hidden_Stats;
else if (WinFormsUtil.GetIndex(CB_Species) == 0 && !HaX) // can't set an empty slot...
Hidden_TC.SelectedTab = Hidden_Main;
else
return true;
System.Media.SystemSounds.Exclamation.Play();
return false;
}
}
private TabPage? GetInvalidParentTab()
{
if (!Stats.Valid)
return Hidden_Stats;
if (WinFormsUtil.GetIndex(CB_Species) == 0 && !HaX) // can't set an empty slot...
return Hidden_Main;
foreach (var type in ValidatedControls)
{
var cb = type.IsNotValid(Entity);
if (cb is null)
continue;
return WinFormsUtil.FindFirstControlOfType<TabPage>(cb);
}
return null;
}
public void SetPKMFormatMode(PKM pk)
{
// Load Extra Byte List