Rework accessors for PKMConverter trainer cache

Might break downstream users, for the better. Internal behavior had to change!
This commit is contained in:
Kurt
2020-01-05 21:51:02 -08:00
parent 1906a1040f
commit efbac28b91
3 changed files with 13 additions and 4 deletions

View File

@@ -44,7 +44,8 @@ public static string[] GetFormList(int species, IReadOnlyList<string> types, IRe
return GetFormsGen8(species, types, forms, genders);
}
private static bool IsGG() => GameVersion.GG.Contains(PKMConverter.Trainer.Game);
// this is a hack; depends on currently loaded SaveFile's Game ID
private static bool IsGG() => GameVersion.GG.Contains(PKMConverter.Game);
public static bool IsTotemForm(int species, int form, int generation = 7)
{

View File

@@ -12,12 +12,20 @@ namespace PKHeX.Core
/// </summary>
public static class PKMConverter
{
public static ITrainerInfo Trainer { internal get; set; } = new SimpleTrainerInfo();
private static readonly ITrainerInfo Trainer67 = new SimpleTrainerInfo(GameVersion.SN);
public static void SetPrimaryTrainer(ITrainerInfo t)
{
Trainer = t;
if (t.ConsoleRegion != 0)
Trainer67 = t;
}
private static ITrainerInfo Trainer { get; set; } = new SimpleTrainerInfo();
private static ITrainerInfo Trainer67 { get; set; } = new SimpleTrainerInfo(GameVersion.SN);
public static string OT_Name => Trainer.OT;
public static int OT_Gender => Trainer.Gender;
public static int Language => Trainer.Language;
public static int Format => Trainer.Generation;
public static int Game => Trainer.Game;
public static bool AllowIncompatibleConversion { private get; set; }
public static void SetConsoleRegionData3DS(PKM pkm)

View File

@@ -738,7 +738,7 @@ private bool OpenSAV(SaveFile sav, string path)
PKME_Tabs.Focus(); // flush any pending changes
StoreLegalSaveGameData(sav);
PKMConverter.Trainer = sav;
PKMConverter.SetPrimaryTrainer(sav);
SpriteUtil.Initialize(sav); // refresh sprite generator
dragout.Size = new Size(SpriteUtil.Spriter.Width, SpriteUtil.Spriter.Height);