Allow replacing VC1/2 default transfer version

Exposed via settings
Conversion settings relocated from Advanced; `AllowIncompatibleConversion` will need to be re-set if you want to deviate from official rules.
This commit is contained in:
Kurt 2024-01-04 19:57:01 -08:00
parent 0777b9fbf8
commit a4ac8240b8
5 changed files with 50 additions and 5 deletions

View file

@ -165,6 +165,12 @@ public sealed class PK1 : GBPKML, IPersonalType
{
var rnd = Util.Rand;
var lang = TransferLanguage(RecentTrainerCache.Language);
var version = (byte)EntityConverter.VirtualConsoleSourceGen1;
if ((lang == 1) != Japanese)
lang = Japanese ? 1 : 2;
if (version == (byte)GameVersion.BU && !Japanese)
version = (byte)GameVersion.RD;
var pi = PersonalTable.SM[Species];
int abil = TransporterLogic.IsHiddenDisallowedVC1(Species) ? 0 : 2; // Hidden
var pk7 = new PK7
@ -179,7 +185,7 @@ public sealed class PK1 : GBPKML, IPersonalType
PID = rnd.Rand32(),
Ball = 4,
MetDate = EncounterDate.GetDate3DS(),
Version = (int)GameVersion.RD, // Default to red
Version = version,
Move1 = Move1,
Move2 = Move2,
Move3 = Move3,

View file

@ -133,6 +133,8 @@ public sealed class PK2 : GBPKML, ICaughtData2
{
var rnd = Util.Rand;
var lang = TransferLanguage(RecentTrainerCache.Language);
if ((lang == 1) != Japanese)
lang = Japanese ? 1 : 2;
var pi = PersonalTable.SM[Species];
int abil = TransporterLogic.IsHiddenDisallowedVC2(Species) ? 0 : 2; // Hidden
var pk7 = new PK7
@ -147,7 +149,7 @@ public sealed class PK2 : GBPKML, ICaughtData2
PID = rnd.Rand32(),
Ball = 4,
MetDate = EncounterDate.GetDate3DS(),
Version = HasOriginalMetLocation ? (int)GameVersion.C : (int)GameVersion.SI,
Version = HasOriginalMetLocation ? (byte)GameVersion.C : (byte)EntityConverter.VirtualConsoleSourceGen2,
Move1 = Move1,
Move2 = Move2,
Move3 = Move3,

View file

@ -1,6 +1,7 @@
using System;
using System.Diagnostics;
using static PKHeX.Core.EntityConverterResult;
using static PKHeX.Core.GameVersion;
namespace PKHeX.Core;
@ -29,6 +30,27 @@ public static class EntityConverter
/// </summary>
public static IHomeStorage HOME { get; set; } = new HomeStorageFacade();
private static GameVersion _vc1 = RD;
private static GameVersion _vc2 = SI;
/// <summary>
/// Default source game for trading from PK2 to PK7.
/// </summary>
public static GameVersion VirtualConsoleSourceGen1
{
get => _vc1;
set => _vc1 = (value is RD or BU or GN or YW) ? value : RD;
}
/// <summary>
/// Default source game for trading from PK2 to PK7.
/// </summary>
public static GameVersion VirtualConsoleSourceGen2
{
get => _vc2;
set => _vc2 = (value is GD or SI or C) ? value : SI;
}
/// <summary>
/// Checks if the input <see cref="PKM"/> file is capable of being converted to the desired format.
/// </summary>

View file

@ -420,11 +420,15 @@ public partial class Main : Form
C_SAV.M.Hover.GlowHover = settings.Hover.HoverSlotGlowEdges;
ParseSettings.InitFromSettings(settings.Legality);
PKME_Tabs.HideSecretValues = C_SAV.HideSecretDetails = settings.Privacy.HideSecretDetails;
EntityConverter.AllowIncompatibleConversion = settings.Advanced.AllowIncompatibleConversion;
EntityConverter.RejuvenateHOME = settings.Advanced.AllowGuessRejuvenateHOME;
WinFormsUtil.DetectSaveFileOnFileOpen = settings.Startup.TryDetectRecentSave;
SelectablePictureBox.FocusBorderDeflate = GenderToggle.FocusBorderDeflate = settings.Display.FocusBorderDeflate;
var converter = settings.Converter;
EntityConverter.AllowIncompatibleConversion = converter.AllowIncompatibleConversion;
EntityConverter.RejuvenateHOME = converter.AllowGuessRejuvenateHOME;
EntityConverter.VirtualConsoleSourceGen1 = converter.VirtualConsoleSourceGen1;
EntityConverter.VirtualConsoleSourceGen2 = converter.VirtualConsoleSourceGen2;
SpriteBuilder.LoadSettings(settings.Sprite);
}

View file

@ -25,6 +25,7 @@ public sealed class PKHeXSettings
// General
public LegalitySettings Legality { get; set; } = new();
public EntityConverterSettings Converter { get; set; } = new();
public SetImportSettings Import { get; set; } = new();
public SlotWriteSettings SlotWrite { get; set; } = new();
public PrivacySettings Privacy { get; set; } = new();
@ -237,7 +238,7 @@ public sealed class LegalitySettings : IParseSettings
}
[Serializable]
public sealed class AdvancedSettings
public sealed class EntityConverterSettings
{
[LocalizedDescription("Allow PKM file conversion paths that are not possible via official methods. Individual properties will be copied sequentially.")]
public EntityCompatibilitySetting AllowIncompatibleConversion { get; set; } = EntityCompatibilitySetting.DisallowIncompatible;
@ -245,6 +246,16 @@ public sealed class AdvancedSettings
[LocalizedDescription("Allow PKM file conversion paths to guess the legal original encounter data that is not stored in the format that it was converted from.")]
public EntityRejuvenationSetting AllowGuessRejuvenateHOME { get; set; } = EntityRejuvenationSetting.MissingDataHOME;
[LocalizedDescription("Default version to set when transferring from Generation 1 3DS Virtual Console to Generation 7.")]
public GameVersion VirtualConsoleSourceGen1 { get; set; } = GameVersion.RD;
[LocalizedDescription("Default version to set when transferring from Generation 2 3DS Virtual Console to Generation 7.")]
public GameVersion VirtualConsoleSourceGen2 { get; set; } = GameVersion.SI;
}
[Serializable]
public sealed class AdvancedSettings
{
[LocalizedDescription("Folder path that contains dump(s) of block hash-names. If a specific dump file does not exist, only names defined within the program's code will be loaded.")]
public string PathBlockKeyList { get; set; } = string.Empty;