mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 04:23:12 +00:00
Split gamesync details to interface
This commit is contained in:
parent
15348d3fdd
commit
28767df0fb
6 changed files with 30 additions and 24 deletions
|
@ -5,7 +5,7 @@ namespace PKHeX.Core
|
|||
/// <summary>
|
||||
/// Generation 6 <see cref="SaveFile"/> object.
|
||||
/// </summary>
|
||||
public abstract class SAV6 : SAV_BEEF, ITrainerStatRecord, ISaveBlock6Core, IRegionOrigin
|
||||
public abstract class SAV6 : SAV_BEEF, ITrainerStatRecord, ISaveBlock6Core, IRegionOrigin, IGameSync
|
||||
{
|
||||
// Save Data Attributes
|
||||
protected override string BAKText => $"{OT} ({Version}) - {Played.LastSavedTime}";
|
||||
|
@ -63,8 +63,8 @@ namespace PKHeX.Core
|
|||
public int Region { get => Status.SubRegion; set => Status.SubRegion = value; }
|
||||
public int Country { get => Status.Country; set => Status.Country = value; }
|
||||
public int ConsoleRegion { get => Status.ConsoleRegion; set => Status.ConsoleRegion = value; }
|
||||
public override int GameSyncIDSize => MyStatus6.GameSyncIDSize; // 64 bits
|
||||
public override string GameSyncID { get => Status.GameSyncID; set => Status.GameSyncID = value; }
|
||||
public int GameSyncIDSize => MyStatus6.GameSyncIDSize; // 64 bits
|
||||
public string GameSyncID { get => Status.GameSyncID; set => Status.GameSyncID = value; }
|
||||
public override int PlayedHours { get => Played.PlayedHours; set => Played.PlayedHours = value; }
|
||||
public override int PlayedMinutes { get => Played.PlayedMinutes; set => Played.PlayedMinutes = value; }
|
||||
public override int PlayedSeconds { get => Played.PlayedSeconds; set => Played.PlayedSeconds = value; }
|
||||
|
|
|
@ -139,8 +139,8 @@ namespace PKHeX.Core
|
|||
public override int SID { get => MyStatus.SID; set => MyStatus.SID = value; }
|
||||
public override int Game { get => MyStatus.Game; set => MyStatus.Game = value; }
|
||||
public override int Gender { get => MyStatus.Gender; set => MyStatus.Gender = value; }
|
||||
public override int GameSyncIDSize => MyStatus7.GameSyncIDSize; // 64 bits
|
||||
public override string GameSyncID { get => MyStatus.GameSyncID; set => MyStatus.GameSyncID = value; }
|
||||
public int GameSyncIDSize => MyStatus7.GameSyncIDSize; // 64 bits
|
||||
public string GameSyncID { get => MyStatus.GameSyncID; set => MyStatus.GameSyncID = value; }
|
||||
public int Region { get => MyStatus.SubRegion; set => MyStatus.SubRegion = value; }
|
||||
public int Country { get => MyStatus.Country; set => MyStatus.Country = value; }
|
||||
public int ConsoleRegion { get => MyStatus.ConsoleRegion; set => MyStatus.ConsoleRegion = value; }
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace PKHeX.Core
|
|||
/// <summary>
|
||||
/// Generation 7 <see cref="SaveFile"/> object for <see cref="GameVersion.GG"/> games.
|
||||
/// </summary>
|
||||
public sealed class SAV7b : SAV_BEEF
|
||||
public sealed class SAV7b : SAV_BEEF, IGameSync
|
||||
{
|
||||
protected override string BAKText => $"{OT} ({Version}) - {Blocks.Played.LastSavedTime}";
|
||||
public override string Filter => "savedata|*.bin";
|
||||
|
@ -172,7 +172,7 @@ namespace PKHeX.Core
|
|||
protected override bool[] MysteryGiftReceivedFlags { get => Blocks.GiftRecords.Flags; set => Blocks.GiftRecords.Flags = value; }
|
||||
protected override DataMysteryGift[] MysteryGiftCards { get => Blocks.GiftRecords.Records; set => Blocks.GiftRecords.Records = (WR7[])value; }
|
||||
|
||||
public override int GameSyncIDSize => MyStatus7b.GameSyncIDSize; // 64 bits
|
||||
public override string GameSyncID { get => Blocks.Status.GameSyncID; set => Blocks.Status.GameSyncID = value; }
|
||||
public int GameSyncIDSize => MyStatus7b.GameSyncIDSize; // 64 bits
|
||||
public string GameSyncID { get => Blocks.Status.GameSyncID; set => Blocks.Status.GameSyncID = value; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -317,8 +317,6 @@ namespace PKHeX.Core
|
|||
|
||||
// Varied Methods
|
||||
protected abstract void SetChecksums();
|
||||
public virtual int GameSyncIDSize { get; } = 8;
|
||||
public virtual string GameSyncID { get => string.Empty; set { } }
|
||||
|
||||
#region Daycare
|
||||
public bool HasDaycare => DaycareOffset > -1;
|
||||
|
|
11
PKHeX.Core/Saves/Substructures/Misc/IGameSync.cs
Normal file
11
PKHeX.Core/Saves/Substructures/Misc/IGameSync.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides details about the save file's Game Sync identifier.
|
||||
/// </summary>
|
||||
public interface IGameSync
|
||||
{
|
||||
int GameSyncIDSize { get; }
|
||||
string GameSyncID { get; set; }
|
||||
}
|
||||
}
|
|
@ -462,10 +462,10 @@ namespace PKHeX.WinForms.Controls
|
|||
SAV.SetDaycareRNGSeed(SAV.DaycareIndex, value);
|
||||
SAV.Edited = true;
|
||||
}
|
||||
else if (tb == TB_GameSync)
|
||||
else if (tb == TB_GameSync && SAV is IGameSync sync)
|
||||
{
|
||||
var value = filterText.PadLeft(SAV.GameSyncIDSize, '0');
|
||||
SAV.GameSyncID = value;
|
||||
var value = filterText.PadLeft(sync.GameSyncIDSize, '0');
|
||||
sync.GameSyncID = value;
|
||||
SAV.Edited = true;
|
||||
}
|
||||
else if (SAV is ISecureValueStorage s)
|
||||
|
@ -1122,23 +1122,20 @@ namespace PKHeX.WinForms.Controls
|
|||
TB_Secure2.Text = s.TimeStampPrevious.ToString("X16");
|
||||
}
|
||||
|
||||
switch (sav.Generation)
|
||||
if (sav is IGameSync sync)
|
||||
{
|
||||
case 6:
|
||||
case 7:
|
||||
var gsid = sav.GameSyncID;
|
||||
TB_GameSync.Enabled = !string.IsNullOrEmpty(gsid);
|
||||
TB_GameSync.MaxLength = sav.GameSyncIDSize;
|
||||
TB_GameSync.Text = (string.IsNullOrEmpty(gsid) ? 0.ToString() : gsid).PadLeft(sav.GameSyncIDSize, '0');
|
||||
break;
|
||||
var gsid = sync.GameSyncID;
|
||||
TB_GameSync.Enabled = !string.IsNullOrEmpty(gsid);
|
||||
TB_GameSync.MaxLength = sync.GameSyncIDSize;
|
||||
TB_GameSync.Text = (string.IsNullOrEmpty(gsid) ? 0.ToString() : gsid).PadLeft(sync.GameSyncIDSize, '0');
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleSecrets(SaveFile sav, bool hide)
|
||||
{
|
||||
var g67 = 6 <= sav.Generation && sav.Generation <= 7;
|
||||
TB_Secure1.Visible = TB_Secure2.Visible = L_Secure1.Visible = L_Secure2.Visible = sav.Exportable && g67 && !hide;
|
||||
TB_GameSync.Visible = L_GameSync.Visible = sav.Exportable && g67 && !hide;
|
||||
var shouldShow = sav.Exportable && !hide;
|
||||
TB_Secure1.Visible = TB_Secure2.Visible = L_Secure1.Visible = L_Secure2.Visible = shouldShow && sav is ISecureValueStorage;
|
||||
TB_GameSync.Visible = L_GameSync.Visible = shouldShow && sav is IGameSync;
|
||||
}
|
||||
|
||||
// DragDrop
|
||||
|
|
Loading…
Reference in a new issue