mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 05:48:44 +00:00
Rearrange key list, add syntax sugar methods
This commit is contained in:
parent
e4e1681e1c
commit
2a7d475b5b
4 changed files with 21 additions and 5 deletions
|
@ -43,6 +43,8 @@ namespace PKHeX.Core
|
|||
var blocks = BlockInfo.Where(z => z.Data.Length != 0).Select(z => new KeyValuePair<uint, int>(z.Key, z.Data.Length)).Select(z => $"{z.Key:X8}, {z.Value:X5},");
|
||||
System.IO.File.WriteAllLines("blank.txt", blocks.ToArray());
|
||||
*/
|
||||
|
||||
// Objects (Blocks)
|
||||
private const uint KBox = 0x0d66012c; // Box Data
|
||||
private const uint KMysteryGift = 0x112d5141; // Mystery Gift Data
|
||||
private const uint KItem = 0x1177c2c4; // Items
|
||||
|
@ -51,17 +53,26 @@ namespace PKHeX.Core
|
|||
private const uint KMisc = 0x1b882b09; // Money
|
||||
private const uint KParty = 0x2985fe5d; // Party Data
|
||||
private const uint KDaycare = 0x2d6fba6a; // Daycare slots (2 daycares)
|
||||
internal const uint KRotoRally = 0x38548020;
|
||||
private const uint KRecord = 0x37da95a3;
|
||||
private const uint KZukan = 0x4716c404; // PokeDex
|
||||
private const uint KTrainerCard = 0x874da6fa; // Trainer Card
|
||||
private const uint KPlayTime = 0x8cbbfd90; // Time Played
|
||||
private const uint KRaidSpawnList = 0x9033eb7b; // Nest current values (hash, seed, meta)
|
||||
private const uint KRepel = 0x9ec079da;
|
||||
private const uint KFused = 0xc0de5c5f; // Fused PKM (*3)
|
||||
private const uint KFashionUnlock = 0xd224f9ac; // Fashion unlock bool array (owned for (each apparel type) * 0x80, then another array for "new")
|
||||
private const uint KMyStatus = 0xf25c070e; // Trainer Details
|
||||
|
||||
// Values
|
||||
public const uint KGameLanguage = 0x0BFDEBA1; // U32 Game Language
|
||||
public const uint KRepel = 0x9ec079da; // U16 Repel Steps remaining
|
||||
public const uint KRotoRally = 0x38548020; // U32 Roto Rally Score (99,999 cap)
|
||||
public const int KBattleTowerSinglesVictory = 0x436CAF2B; // U32 Singles victories (9,999,999 cap)
|
||||
public const int KBattleTowerDoublesVictory = 0x0D477836; // U32 Doubles victories (9,999,999 cap)
|
||||
public const int KBattleTowerSinglesStreak = 0x6226F5AD; // U16 Singles Streak (255 cap)
|
||||
public const int KBattleTowerDoublesStreak = 0x5F74FCEE; // U16 Doubles Streak (255 cap)
|
||||
public T GetBlockValue<T>(uint key) where T : struct => (T)GetBlock(key).GetValue();
|
||||
public void SetBlockValue<T>(uint key, T value) where T : struct => GetBlock(key).SetValue(value);
|
||||
|
||||
// Rather than storing a dictionary of keys, we can abuse the fact that the SCBlock[] is stored in order of ascending block key.
|
||||
// Binary Search doesn't require extra memory like a Dictionary would; also, we only need to find a few blocks.
|
||||
public SCBlock GetBlock(uint key) => BinarySearch(BlockInfo, key);
|
||||
|
|
|
@ -51,6 +51,8 @@ namespace PKHeX.Core
|
|||
|
||||
#region Blocks
|
||||
public SaveBlockAccessorSWSH Blocks { get; }
|
||||
public T GetValue<T>(uint key) where T : struct => Blocks.GetBlockValue<T>(key);
|
||||
public void SetValue<T>(uint key, T value) where T : struct => Blocks.SetBlockValue<T>(key, value);
|
||||
public override Box8 BoxInfo => Blocks.BoxInfo;
|
||||
public override Party8 PartyInfo => Blocks.PartyInfo;
|
||||
public override MyItem Items => Blocks.Items;
|
||||
|
|
|
@ -132,7 +132,11 @@ namespace PKHeX.Core
|
|||
public int Language
|
||||
{
|
||||
get => Data[Offset + 0xA7];
|
||||
set => Data[Offset + 0xA7] = (byte)value;
|
||||
set
|
||||
{
|
||||
Data[Offset + 0xA7] = (byte) value;
|
||||
((SAV8SWSH)SAV).SetValue(SaveBlockAccessorSWSH.KGameLanguage, (uint)value);
|
||||
}
|
||||
}
|
||||
|
||||
public string OT
|
||||
|
|
|
@ -31,8 +31,7 @@ namespace PKHeX.Core
|
|||
var data = BitConverter.GetBytes(value);
|
||||
SAV.SetData(Data, data, 0x28);
|
||||
// set to the other block since it doesn't have an accessor
|
||||
var used = ((SAV8SWSH) SAV).Blocks.GetBlock(SaveBlockAccessorSWSH.KRotoRally);
|
||||
SAV.SetData(used.Data, data, 0);
|
||||
((SAV8SWSH)SAV).SetValue(SaveBlockAccessorSWSH.KRotoRally, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue