mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-26 05:50:22 +00:00
More records/sealing
This commit is contained in:
parent
ffebc74b90
commit
cacd6e9965
28 changed files with 47 additions and 115 deletions
|
@ -4,7 +4,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
/// <inheritdoc cref="ISuggestModification"/>
|
||||
/// <typeparam name="T">Specific (or not) type</typeparam>
|
||||
public class TypeSuggestion<T> : ISuggestModification where T : PKM
|
||||
public sealed class TypeSuggestion<T> : ISuggestModification where T : PKM
|
||||
{
|
||||
public readonly string Keyword;
|
||||
public readonly Action<T, string> Action;
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
using System;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Data representing info for an individual slot.
|
||||
/// </summary>
|
||||
public interface ISlotInfo : IEquatable<ISlotInfo>
|
||||
public interface ISlotInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates the type of format the slot originates. Useful for legality purposes.
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace PKHeX.Core
|
|||
/// <summary>
|
||||
/// Contains slot data and metadata indicating where the <see cref="PKM"/> originated from.
|
||||
/// </summary>
|
||||
public class SlotCache : IComparable<SlotCache>
|
||||
public sealed class SlotCache : IComparable<SlotCache>
|
||||
{
|
||||
/// <summary>
|
||||
/// Information regarding how the <see cref="Entity"/> was obtained.
|
||||
|
|
|
@ -3,20 +3,12 @@ namespace PKHeX.Core
|
|||
/// <summary>
|
||||
/// Box Data <see cref="ISlotInfo"/>
|
||||
/// </summary>
|
||||
public class SlotInfoBox : ISlotInfo
|
||||
public sealed record SlotInfoBox(int Box, int Slot) : ISlotInfo
|
||||
{
|
||||
public int Box { get; }
|
||||
public int Slot { get; }
|
||||
public SlotOrigin Origin => SlotOrigin.Box;
|
||||
public bool CanWriteTo(SaveFile sav) => sav.HasBox && !sav.IsSlotLocked(Box, Slot);
|
||||
public WriteBlockedMessage CanWriteTo(SaveFile sav, PKM pkm) => WriteBlockedMessage.None;
|
||||
|
||||
public SlotInfoBox(int box, int slot)
|
||||
{
|
||||
Box = box;
|
||||
Slot = slot;
|
||||
}
|
||||
|
||||
public bool WriteTo(SaveFile sav, PKM pkm, PKMImportSetting setting = PKMImportSetting.UseDefault)
|
||||
{
|
||||
sav.SetBoxSlotAtIndex(pkm, Box, Slot, setting, setting);
|
||||
|
@ -24,11 +16,5 @@ namespace PKHeX.Core
|
|||
}
|
||||
|
||||
public PKM Read(SaveFile sav) => sav.GetBoxSlotAtIndex(Box, Slot);
|
||||
|
||||
private bool Equals(SlotInfoBox other) => Box == other.Box && Slot == other.Slot;
|
||||
public bool Equals(ISlotInfo other) => other is SlotInfoBox b && Equals(b);
|
||||
public override bool Equals(object obj) => obj is SlotInfoBox b && Equals(b);
|
||||
|
||||
public override int GetHashCode() => (Box * 397) ^ Slot;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
public sealed class SlotInfoFile : ISlotInfo
|
||||
public sealed record SlotInfoFile(string Path) : ISlotInfo
|
||||
{
|
||||
public readonly string Path;
|
||||
public SlotOrigin Origin => SlotOrigin.Party;
|
||||
public int Slot => 0;
|
||||
|
||||
public SlotInfoFile(string path) => Path = path;
|
||||
public bool Equals(ISlotInfo other) => other is SlotInfoFile f && f.Path == Path;
|
||||
|
||||
public bool CanWriteTo(SaveFile sav) => false;
|
||||
public WriteBlockedMessage CanWriteTo(SaveFile sav, PKM pkm) => WriteBlockedMessage.InvalidDestination;
|
||||
public bool WriteTo(SaveFile sav, PKM pkm, PKMImportSetting setting = PKMImportSetting.UseDefault) => false;
|
||||
|
|
|
@ -3,38 +3,21 @@ namespace PKHeX.Core
|
|||
/// <summary>
|
||||
/// Miscellaneous origination <see cref="ISlotInfo"/>
|
||||
/// </summary>
|
||||
public sealed class SlotInfoMisc : ISlotInfo
|
||||
public sealed record SlotInfoMisc(byte[] Data, int Slot, int Offset, bool PartyFormat = false) : ISlotInfo
|
||||
{
|
||||
public int Slot { get; }
|
||||
public bool PartyFormat { get; }
|
||||
public int Offset { get; }
|
||||
public SlotOrigin Origin => PartyFormat ? SlotOrigin.Party : SlotOrigin.Box;
|
||||
public bool CanWriteTo(SaveFile sav) => false;
|
||||
public WriteBlockedMessage CanWriteTo(SaveFile sav, PKM pkm) => WriteBlockedMessage.InvalidDestination;
|
||||
public StorageSlotType Type { get; init; }
|
||||
|
||||
private readonly byte[] Data; // buffer to r/w
|
||||
public SlotInfoMisc(SaveFile sav, int slot, int offset, bool party = false) : this(GetBuffer(sav), slot, offset, party) { }
|
||||
|
||||
public SlotInfoMisc(SaveFile sav, int slot, int offset, bool party = false)
|
||||
{
|
||||
Slot = slot;
|
||||
Offset = offset;
|
||||
PartyFormat = party;
|
||||
Data = sav switch
|
||||
private static byte[] GetBuffer(SaveFile sav) => sav switch
|
||||
{
|
||||
SAV4 s => s.General,
|
||||
SAV3 s3 => s3.Large,
|
||||
_ => sav.Data,
|
||||
};
|
||||
}
|
||||
|
||||
public SlotInfoMisc(byte[] data, int slot, int offset, bool party = false)
|
||||
{
|
||||
Slot = slot;
|
||||
Offset = offset;
|
||||
PartyFormat = party;
|
||||
Data = data;
|
||||
}
|
||||
|
||||
public bool WriteTo(SaveFile sav, PKM pkm, PKMImportSetting setting = PKMImportSetting.UseDefault)
|
||||
{
|
||||
|
@ -49,10 +32,5 @@ namespace PKHeX.Core
|
|||
{
|
||||
return PartyFormat ? sav.GetPartySlot(Data, Offset) : sav.GetStoredSlot(Data, Offset);
|
||||
}
|
||||
|
||||
private bool Equals(SlotInfoMisc other) => Offset == other.Offset && Data == other.Data;
|
||||
public bool Equals(ISlotInfo other) => other is SlotInfoMisc p && Equals(p);
|
||||
public override bool Equals(object obj) => obj is SlotInfoMisc p && Equals(p);
|
||||
public override int GetHashCode() => Offset;
|
||||
}
|
||||
}
|
|
@ -5,9 +5,9 @@ namespace PKHeX.Core
|
|||
/// <summary>
|
||||
/// Party Data <see cref="ISlotInfo"/>
|
||||
/// </summary>
|
||||
public sealed class SlotInfoParty : ISlotInfo
|
||||
public sealed record SlotInfoParty(int Slot) : ISlotInfo
|
||||
{
|
||||
public int Slot { get; private set; }
|
||||
public int Slot { get; private set; } = Slot;
|
||||
public SlotOrigin Origin => SlotOrigin.Party;
|
||||
public bool CanWriteTo(SaveFile sav) => sav.HasParty;
|
||||
|
||||
|
@ -15,8 +15,6 @@ namespace PKHeX.Core
|
|||
? WriteBlockedMessage.InvalidPartyConfiguration
|
||||
: WriteBlockedMessage.None;
|
||||
|
||||
public SlotInfoParty(int slot) => Slot = slot;
|
||||
|
||||
public bool WriteTo(SaveFile sav, PKM pkm, PKMImportSetting setting = PKMImportSetting.UseDefault)
|
||||
{
|
||||
if (pkm.Species == 0)
|
||||
|
@ -31,10 +29,5 @@ namespace PKHeX.Core
|
|||
}
|
||||
|
||||
public PKM Read(SaveFile sav) => sav.GetPartySlotAtIndex(Slot);
|
||||
|
||||
private bool Equals(SlotInfoParty other) => Slot == other.Slot;
|
||||
public bool Equals(ISlotInfo other) => other is SlotInfoParty p && Equals(p);
|
||||
public override bool Equals(object obj) => obj is SlotInfoParty p && Equals(p);
|
||||
public override int GetHashCode() => Slot;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -200,17 +200,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
}
|
||||
|
||||
private class CombinedReference
|
||||
{
|
||||
public readonly SlotCache Slot;
|
||||
public readonly LegalityAnalysis Analysis;
|
||||
|
||||
public CombinedReference(SlotCache slot, LegalityAnalysis analysis)
|
||||
{
|
||||
Slot = slot;
|
||||
Analysis = analysis;
|
||||
}
|
||||
}
|
||||
private sealed record CombinedReference(SlotCache Slot, LegalityAnalysis Analysis);
|
||||
|
||||
private void CheckIDReuse()
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace PKHeX.Core
|
|||
/// <summary>
|
||||
/// Default formatter for Legality Result displays.
|
||||
/// </summary>
|
||||
public class BaseLegalityFormatter : ILegalityFormatter
|
||||
public sealed class BaseLegalityFormatter : ILegalityFormatter
|
||||
{
|
||||
public string GetReport(LegalityAnalysis l)
|
||||
{
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace PKHeX.Core
|
|||
/// <remarks>
|
||||
/// Serves as the main object that is accessed for stat data in a particular generation/game format.
|
||||
/// </remarks>
|
||||
public class PersonalTable
|
||||
public sealed class PersonalTable
|
||||
{
|
||||
/// <summary>
|
||||
/// Personal Table used in <see cref="GameVersion.BDSP"/>.
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace PKHeX.Core
|
|||
/// <summary>
|
||||
/// Generation 8 <see cref="SaveFile"/> object for <see cref="GameVersion.BDSP"/> games.
|
||||
/// </summary>
|
||||
public class SAV8BS : SaveFile, ISaveFileRevision, ITrainerStatRecord
|
||||
public sealed class SAV8BS : SaveFile, ISaveFileRevision, ITrainerStatRecord
|
||||
{
|
||||
// Save Data Attributes
|
||||
protected internal override string ShortSummary => $"{OT} ({Version}) - {System.LastSavedTime}";
|
||||
|
@ -135,7 +135,7 @@ namespace PKHeX.Core
|
|||
return base.GetFinalData();
|
||||
}
|
||||
|
||||
protected void ReloadBattleTeams()
|
||||
private void ReloadBattleTeams()
|
||||
{
|
||||
if (!State.Exportable)
|
||||
BoxLayout.ClearBattleTeams();
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace PKHeX.Core
|
|||
/// <summary>
|
||||
/// Tracks information about where the <see cref="SAV"/> originated from, and provides logic for saving to a file.
|
||||
/// </summary>
|
||||
public class SaveFileMetadata
|
||||
public sealed class SaveFileMetadata
|
||||
{
|
||||
private readonly SaveFile SAV;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/// <summary>
|
||||
/// Tracks information about modifications made to a <see cref="SaveFile"/>
|
||||
/// </summary>
|
||||
public class SaveFileState
|
||||
public sealed class SaveFileState
|
||||
{
|
||||
/// <summary>
|
||||
/// Mutable value tracking if the save file has been changed. This is set manually by modifications, and not for all modifications.
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace PKHeX.Core
|
|||
/// <summary>
|
||||
/// Generation 6 Secret Base Decoration Good Inventory stock for a given good-index.
|
||||
/// </summary>
|
||||
public class SecretBase6GoodStock
|
||||
public sealed class SecretBase6GoodStock
|
||||
{
|
||||
public const int SIZE = 4;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public class SecretBase6PKM
|
||||
public sealed class SecretBase6PKM
|
||||
{
|
||||
public const int SIZE = 0x34;
|
||||
public readonly byte[] Data;
|
||||
|
|
|
@ -143,7 +143,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public class HoneyTree8b
|
||||
public sealed class HoneyTree8b
|
||||
{
|
||||
public const int SIZE = 0xC;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public class FieldObject8b
|
||||
public sealed class FieldObject8b
|
||||
{
|
||||
public const int SIZE = 4 * 17;
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public class RecvData8b
|
||||
public sealed class RecvData8b
|
||||
{
|
||||
public const int SIZE = 0xE0;
|
||||
// private const int ItemCount = 7;
|
||||
|
@ -237,7 +237,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public class OneDay8b
|
||||
public sealed class OneDay8b
|
||||
{
|
||||
public const int SIZE = 0x10;
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public class AffixSealData8b
|
||||
public sealed class AffixSealData8b
|
||||
{
|
||||
public const int SIZE = 8; // u16 id, s16 x,y,z
|
||||
|
||||
|
|
|
@ -1,18 +1,9 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
public class SlotGroup
|
||||
{
|
||||
public readonly string GroupName;
|
||||
public readonly PKM[] Slots;
|
||||
namespace PKHeX.Core;
|
||||
|
||||
public sealed record SlotGroup(string GroupName, PKM[] Slots)
|
||||
{
|
||||
#if DEBUG
|
||||
public override string ToString() => $"{GroupName}: {Slots.Length} {Slots.GetType().Name}";
|
||||
#endif
|
||||
}
|
||||
|
||||
public SlotGroup(string name, PKM[] slots)
|
||||
{
|
||||
GroupName = name;
|
||||
Slots = slots;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace PKHeX.Core
|
|||
/// <summary>
|
||||
/// Logic for recognizing .duc save files dumped via an ARDS.
|
||||
/// </summary>
|
||||
public class SaveHandlerARDS : ISaveHandler
|
||||
public sealed class SaveHandlerARDS : ISaveHandler
|
||||
{
|
||||
private const int sizeHeader = 0xA4;
|
||||
private const int ExpectedSize = SaveUtil.SIZE_G4RAW + sizeHeader; // 0x800A4
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace PKHeX.Core
|
|||
/// <summary>
|
||||
/// Logic for recognizing .dsv save files from DeSmuME.
|
||||
/// </summary>
|
||||
public class SaveHandlerDeSmuME : ISaveHandler
|
||||
public sealed class SaveHandlerDeSmuME : ISaveHandler
|
||||
{
|
||||
private const int sizeFooter = 0x7A;
|
||||
private const int ExpectedSize = SaveUtil.SIZE_G4RAW + sizeFooter;
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace PKHeX.Core
|
|||
/// <summary>
|
||||
/// Logic for recognizing .gci save files.
|
||||
/// </summary>
|
||||
public class SaveHandlerGCI : ISaveHandler
|
||||
public sealed class SaveHandlerGCI : ISaveHandler
|
||||
{
|
||||
private const int headerSize = 0x40;
|
||||
private const int SIZE_G3BOXGCI = headerSize + SaveUtil.SIZE_G3BOX; // GCI data
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace PKHeX.Drawing.Misc.Properties {
|
|||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class Resources {
|
||||
public sealed class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace PKHeX.Drawing.PokeSprite.Properties {
|
|||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class Resources {
|
||||
public sealed class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace PKHeX.WinForms.Controls
|
|||
FlickerInterface();
|
||||
}
|
||||
|
||||
private class ValidationRequiredSet
|
||||
private sealed class ValidationRequiredSet
|
||||
{
|
||||
private readonly Control[] Controls;
|
||||
private readonly Func<PKM, bool> ShouldCheck;
|
||||
|
|
|
@ -220,7 +220,7 @@ namespace PKHeX.WinForms
|
|||
}
|
||||
|
||||
[Serializable]
|
||||
public class AdvancedSettings
|
||||
public sealed class AdvancedSettings
|
||||
{
|
||||
[LocalizedDescription("Allow PKM file conversion paths that are not possible via official methods. Individual properties will be copied sequentially.")]
|
||||
public bool AllowIncompatibleConversion { get; set; }
|
||||
|
@ -265,14 +265,14 @@ namespace PKHeX.WinForms
|
|||
}
|
||||
|
||||
[Serializable]
|
||||
public class EntityEditorSettings
|
||||
public sealed class EntityEditorSettings
|
||||
{
|
||||
[LocalizedDescription("When changing the Hidden Power type, automatically maximize the IVs to ensure the highest Base Power result. Otherwise, keep the IVs as close as possible to the original.")]
|
||||
public bool HiddenPowerOnChangeMaxPower { get; set; } = true;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class EncounterDatabaseSettings
|
||||
public sealed class EncounterDatabaseSettings
|
||||
{
|
||||
[LocalizedDescription("Skips searching if the user forgot to enter Species / Move(s) into the search criteria.")]
|
||||
public bool ReturnNoneIfEmptySearch { get; set; } = true;
|
||||
|
@ -288,7 +288,7 @@ namespace PKHeX.WinForms
|
|||
}
|
||||
|
||||
[Serializable]
|
||||
public class MysteryGiftDatabaseSettings
|
||||
public sealed class MysteryGiftDatabaseSettings
|
||||
{
|
||||
[LocalizedDescription("Hides gifts if the currently loaded save file cannot (indirectly) receive them.")]
|
||||
public bool FilterUnavailableSpecies { get; set; } = true;
|
||||
|
|
2
PKHeX.WinForms/Properties/Resources.Designer.cs
generated
2
PKHeX.WinForms/Properties/Resources.Designer.cs
generated
|
@ -22,7 +22,7 @@ namespace PKHeX.WinForms.Properties {
|
|||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class Resources {
|
||||
public sealed class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
|
|
Loading…
Reference in a new issue