mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-09-11 17:35:26 -05:00
Expose decoration list for editing
Closes #2785 , not making a GUI for this (someone else can do it) Moves RTC3 to the appropriate folder
This commit is contained in:
@@ -1025,19 +1025,11 @@ public bool ResetPersonal(GameVersion g)
|
||||
_personal = SaveUtil.GetG3Personal(g);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// RTC
|
||||
public sealed class RTC3
|
||||
{
|
||||
public readonly byte[] Data;
|
||||
public const int Size = 8;
|
||||
|
||||
public RTC3(byte[] data) => Data = data;
|
||||
|
||||
public int Day { get => BitConverter.ToUInt16(Data, 0x00); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x00); }
|
||||
public int Hour { get => Data[2]; set => Data[2] = (byte)value; }
|
||||
public int Minute { get => Data[3]; set => Data[3] = (byte)value; }
|
||||
public int Second { get => Data[4]; set => Data[4] = (byte)value; }
|
||||
public DecorationInventory3 Decorations
|
||||
{
|
||||
get => Data.Slice(GetBlockOffset(3) + 0x7A0, DecorationInventory3.SIZE).ToStructure<DecorationInventory3>();
|
||||
set => SetData(value.ToBytes(), GetBlockOffset(3) + 0x7A0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
127
PKHeX.Core/Saves/Substructures/Gen3/Decoration3.cs
Normal file
127
PKHeX.Core/Saves/Substructures/Gen3/Decoration3.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public enum Decoration3 : byte
|
||||
{
|
||||
NONE,
|
||||
SMALL_DESK,
|
||||
POKEMON_DESK,
|
||||
HEAVY_DESK,
|
||||
RAGGED_DESK,
|
||||
COMFORT_DESK,
|
||||
PRETTY_DESK,
|
||||
BRICK_DESK,
|
||||
CAMP_DESK,
|
||||
HARD_DESK,
|
||||
SMALL_CHAIR,
|
||||
POKEMON_CHAIR,
|
||||
HEAVY_CHAIR,
|
||||
PRETTY_CHAIR,
|
||||
COMFORT_CHAIR,
|
||||
RAGGED_CHAIR,
|
||||
BRICK_CHAIR,
|
||||
CAMP_CHAIR,
|
||||
HARD_CHAIR,
|
||||
RED_PLANT,
|
||||
TROPICAL_PLANT,
|
||||
PRETTY_FLOWERS,
|
||||
COLORFUL_PLANT,
|
||||
BIG_PLANT,
|
||||
GORGEOUS_PLANT,
|
||||
RED_BRICK,
|
||||
YELLOW_BRICK,
|
||||
BLUE_BRICK,
|
||||
RED_BALLOON,
|
||||
BLUE_BALLOON,
|
||||
YELLOW_BALLOON,
|
||||
RED_TENT,
|
||||
BLUE_TENT,
|
||||
SOLID_BOARD,
|
||||
SLIDE,
|
||||
FENCE_LENGTH,
|
||||
FENCE_WIDTH,
|
||||
TIRE,
|
||||
STAND,
|
||||
MUD_BALL,
|
||||
BREAKABLE_DOOR,
|
||||
SAND_ORNAMENT,
|
||||
SILVER_SHIELD,
|
||||
GOLD_SHIELD,
|
||||
GLASS_ORNAMENT,
|
||||
TV,
|
||||
ROUND_TV,
|
||||
CUTE_TV,
|
||||
GLITTER_MAT,
|
||||
JUMP_MAT,
|
||||
SPIN_MAT,
|
||||
C_LOW_NOTE_MAT,
|
||||
D_NOTE_MAT,
|
||||
E_NOTE_MAT,
|
||||
F_NOTE_MAT,
|
||||
G_NOTE_MAT,
|
||||
A_NOTE_MAT,
|
||||
B_NOTE_MAT,
|
||||
C_HIGH_NOTE_MAT,
|
||||
SURF_MAT,
|
||||
THUNDER_MAT,
|
||||
FIRE_BLAST_MAT,
|
||||
POWDER_SNOW_MAT,
|
||||
ATTRACT_MAT,
|
||||
FISSURE_MAT,
|
||||
SPIKES_MAT,
|
||||
BALL_POSTER,
|
||||
GREEN_POSTER,
|
||||
RED_POSTER,
|
||||
BLUE_POSTER,
|
||||
CUTE_POSTER,
|
||||
PIKA_POSTER,
|
||||
LONG_POSTER,
|
||||
SEA_POSTER,
|
||||
SKY_POSTER,
|
||||
KISS_POSTER,
|
||||
PICHU_DOLL,
|
||||
PIKACHU_DOLL,
|
||||
MARILL_DOLL,
|
||||
TOGEPI_DOLL,
|
||||
CYNDAQUIL_DOLL,
|
||||
CHIKORITA_DOLL,
|
||||
TOTODILE_DOLL,
|
||||
JIGGLYPUFF_DOLL,
|
||||
MEOWTH_DOLL,
|
||||
CLEFAIRY_DOLL,
|
||||
DITTO_DOLL,
|
||||
SMOOCHUM_DOLL,
|
||||
TREECKO_DOLL,
|
||||
TORCHIC_DOLL,
|
||||
MUDKIP_DOLL,
|
||||
DUSKULL_DOLL,
|
||||
WYNAUT_DOLL,
|
||||
BALTOY_DOLL,
|
||||
KECLEON_DOLL,
|
||||
AZURILL_DOLL,
|
||||
SKITTY_DOLL,
|
||||
SWABLU_DOLL,
|
||||
GULPIN_DOLL,
|
||||
LOTAD_DOLL,
|
||||
SEEDOT_DOLL,
|
||||
PIKA_CUSHION,
|
||||
ROUND_CUSHION,
|
||||
KISS_CUSHION,
|
||||
ZIGZAG_CUSHION,
|
||||
SPIN_CUSHION,
|
||||
DIAMOND_CUSHION,
|
||||
BALL_CUSHION,
|
||||
GRASS_CUSHION,
|
||||
FIRE_CUSHION,
|
||||
WATER_CUSHION,
|
||||
SNORLAX_DOLL,
|
||||
RHYDON_DOLL,
|
||||
LAPRAS_DOLL,
|
||||
VENUSAUR_DOLL,
|
||||
CHARIZARD_DOLL,
|
||||
BLASTOISE_DOLL,
|
||||
WAILMER_DOLL,
|
||||
REGIROCK_DOLL,
|
||||
REGICE_DOLL,
|
||||
REGISTEEL_DOLL,
|
||||
}
|
||||
}
|
||||
27
PKHeX.Core/Saves/Substructures/Gen3/DecorationInventory3.cs
Normal file
27
PKHeX.Core/Saves/Substructures/Gen3/DecorationInventory3.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct DecorationInventory3
|
||||
{
|
||||
public const int SIZE = 150;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
|
||||
public readonly Decoration3[] Desk;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
|
||||
public readonly Decoration3[] Chair;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
|
||||
public readonly Decoration3[] Plant;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 30)]
|
||||
public readonly Decoration3[] Ornament;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 30)]
|
||||
public readonly Decoration3[] Mat;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
|
||||
public readonly Decoration3[] Poster;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 40)]
|
||||
public readonly Decoration3[] Doll;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
|
||||
public readonly Decoration3[] Cushion;
|
||||
}
|
||||
}
|
||||
17
PKHeX.Core/Saves/Substructures/Gen3/RTC3.cs
Normal file
17
PKHeX.Core/Saves/Substructures/Gen3/RTC3.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public sealed class RTC3
|
||||
{
|
||||
public readonly byte[] Data;
|
||||
public const int Size = 8;
|
||||
|
||||
public RTC3(byte[] data) => Data = data;
|
||||
|
||||
public int Day { get => BitConverter.ToUInt16(Data, 0x00); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x00); }
|
||||
public int Hour { get => Data[2]; set => Data[2] = (byte)value; }
|
||||
public int Minute { get => Data[3]; set => Data[3] = (byte)value; }
|
||||
public int Second { get => Data[4]; set => Data[4] = (byte)value; }
|
||||
}
|
||||
}
|
||||
46
PKHeX.Core/Saves/Substructures/Gen3/StructConverter.cs
Normal file
46
PKHeX.Core/Saves/Substructures/Gen3/StructConverter.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
internal static class StructConverter
|
||||
{
|
||||
public static T ToStructure<T>(this byte[] bytes) where T : struct
|
||||
{
|
||||
var handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
|
||||
try { return (T)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T)); }
|
||||
finally { handle.Free(); }
|
||||
}
|
||||
|
||||
public static T ToClass<T>(this byte[] bytes) where T : class
|
||||
{
|
||||
var handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
|
||||
try { return (T)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T)); }
|
||||
finally { handle.Free(); }
|
||||
}
|
||||
|
||||
public static byte[] ToBytesClass<T>(this T obj) where T : class
|
||||
{
|
||||
int size = Marshal.SizeOf(obj);
|
||||
byte[] arr = new byte[size];
|
||||
|
||||
IntPtr ptr = Marshal.AllocHGlobal(size);
|
||||
Marshal.StructureToPtr(obj, ptr, true);
|
||||
Marshal.Copy(ptr, arr, 0, size);
|
||||
Marshal.FreeHGlobal(ptr);
|
||||
return arr;
|
||||
}
|
||||
|
||||
public static byte[] ToBytes<T>(this T obj) where T : struct
|
||||
{
|
||||
int size = Marshal.SizeOf(obj);
|
||||
byte[] arr = new byte[size];
|
||||
|
||||
IntPtr ptr = Marshal.AllocHGlobal(size);
|
||||
Marshal.StructureToPtr(obj, ptr, true);
|
||||
Marshal.Copy(ptr, arr, 0, size);
|
||||
Marshal.FreeHGlobal(ptr);
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user