diff --git a/Libellus Library/Event/Types/Frame/PmdFlags.cs b/Libellus Library/Event/Types/Frame/PmdFlags.cs new file mode 100644 index 0000000..e48ef9f --- /dev/null +++ b/Libellus Library/Event/Types/Frame/PmdFlags.cs @@ -0,0 +1,51 @@ +using System.Text.Json.Serialization; + +namespace LibellusLibrary.Event.Types.Frame +{ + internal class PmdFlags + { + [JsonPropertyOrder(-100)] + public ushort FlagNumber { get; set; } + + [JsonPropertyOrder(-99)] + public ushort CmpValue { get; set; } + + [JsonPropertyOrder(-98)] + [JsonConverter(typeof(JsonStringEnumConverter))] + public UnitFlagType FlagType { get; set; } + + [JsonPropertyOrder(-97)] + [JsonConverter(typeof(JsonStringEnumConverter))] + public UnitGFlagType GFlagType { get; set; } + + internal void ReadData(BinaryReader reader) + { + FlagNumber = reader.ReadUInt16(); + CmpValue = reader.ReadUInt16(); + FlagType = (UnitFlagType)reader.ReadUInt16(); + GFlagType = (UnitGFlagType)reader.ReadUInt16(); + } + + internal void WriteData(BinaryWriter writer) + { + writer?.Write((ushort)FlagNumber); + writer?.Write((ushort)CmpValue); + writer?.Write((ushort)FlagType); + writer?.Write((ushort)GFlagType); + } + + internal enum UnitFlagType : short + { + DISABLE = 0, + LOCAL = 1, + GLOBAL = 2, + } + + internal enum UnitGFlagType : short + { + EVT = 0, + COMMU = 1, + SYS = 2, + } + } +} diff --git a/Libellus Library/Event/Types/Frame/PmdFrameFactory.cs b/Libellus Library/Event/Types/Frame/PmdFrameFactory.cs index f597011..02e5543 100644 --- a/Libellus Library/Event/Types/Frame/PmdFrameFactory.cs +++ b/Libellus Library/Event/Types/Frame/PmdFrameFactory.cs @@ -39,7 +39,10 @@ private List ReadTypes(BinaryReader reader, uint typeTableCount public static PmdTargetType GetFrameType(PmdTargetTypeID Type) => Type switch { - _=>new PmdTarget_Unknown() + PmdTargetTypeID.MESSAGE => new PmdTarget_Message(), + PmdTargetTypeID.SCRIPT => new PmdTarget_Script(), + PmdTargetTypeID.BGM => new PmdTarget_Bgm(), + _ =>new PmdTarget_Unknown() }; public enum PmdTargetTypeID diff --git a/Libellus Library/Event/Types/Frame/PmdTarget_Bgm.cs b/Libellus Library/Event/Types/Frame/PmdTarget_Bgm.cs index e3bd323..8fc4f36 100644 --- a/Libellus Library/Event/Types/Frame/PmdTarget_Bgm.cs +++ b/Libellus Library/Event/Types/Frame/PmdTarget_Bgm.cs @@ -1,19 +1,43 @@ -using System; +using LibellusLibrary.JSON; +using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.Json.Serialization; using System.Threading.Tasks; namespace LibellusLibrary.Event.Types.Frame { internal class PmdTarget_Bgm : PmdTargetType { - protected override void ReadData(BinaryReader reader) + [JsonPropertyOrder(-96)] + [JsonConverter(typeof(ByteArrayToHexArray))] + public byte[] Data { get; set; } + + [JsonPropertyOrder(-95)] + public ushort Fade { get; set; } + + [JsonPropertyOrder(-94)] + public ushort Id { get; set; } + + [JsonPropertyOrder(-93)] + [JsonConverter(typeof(ByteArrayToHexArray))] + public byte[] Data2 { get; set; } + + protected override void ReadData(BinaryReader reader) { + Data = reader.ReadBytes(12); + Fade = reader.ReadUInt16(); + Id = reader.ReadUInt16(); + Data2 = reader.ReadBytes(36); } protected override void WriteData(BinaryWriter writer) { + writer?.Write(Data); + writer?.Write(Fade); + writer?.Write(Id); + writer?.Write(Data2); } } } diff --git a/Libellus Library/Event/Types/Frame/PmdTarget_Message.cs b/Libellus Library/Event/Types/Frame/PmdTarget_Message.cs new file mode 100644 index 0000000..a6d2b4f --- /dev/null +++ b/Libellus Library/Event/Types/Frame/PmdTarget_Message.cs @@ -0,0 +1,52 @@ +using LibellusLibrary.JSON; +using System.Text.Json.Serialization; + +namespace LibellusLibrary.Event.Types.Frame +{ + internal class PmdTarget_Message : PmdTargetType + { + [JsonPropertyOrder(-96)] + [JsonConverter(typeof(ByteArrayToHexArray))] + public byte[] Data { get; set; } + + [JsonPropertyOrder(-95)] + public PmdFlags Flags { get; set; } + + [JsonPropertyOrder(-94)] + public uint MessageIndex { get; set; } + + [JsonPropertyOrder(-93)] + [JsonConverter(typeof(JsonStringEnumConverter))] + public MessageModeEnum MessageMode { get; set; } + + [JsonPropertyOrder(-92)] + [JsonConverter(typeof(ByteArrayToHexArray))] + public byte[] Data2 { get; set; } + + internal enum MessageModeEnum : uint + { + STOP = 0, + NO_STOP = 1, + } + + protected override void ReadData(BinaryReader reader) + { + Data = reader.ReadBytes(4); + Flags = new PmdFlags(); + Flags.ReadData(reader); + MessageIndex = reader.ReadUInt32(); + MessageMode = (MessageModeEnum)reader.ReadUInt32(); + Data2 = reader.ReadBytes(32); + } + + protected override void WriteData(BinaryWriter writer) + { + writer?.Write(Data); + Flags.WriteData(writer); + writer?.Write(MessageIndex); + writer?.Write((uint)MessageMode); + writer?.Write(Data2); + } + + } +} diff --git a/Libellus Library/Event/Types/Frame/PmdTarget_Script.cs b/Libellus Library/Event/Types/Frame/PmdTarget_Script.cs new file mode 100644 index 0000000..9cc186a --- /dev/null +++ b/Libellus Library/Event/Types/Frame/PmdTarget_Script.cs @@ -0,0 +1,51 @@ +using LibellusLibrary.JSON; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; +using static LibellusLibrary.Event.Types.Frame.PmdTarget_Message; + +namespace LibellusLibrary.Event.Types.Frame +{ + internal class PmdTarget_Script : PmdTargetType + { + [JsonPropertyOrder(-96)] + [JsonConverter(typeof(ByteArrayToHexArray))] + public byte[] Data { get; set; } + + [JsonPropertyOrder(-95)] + public PmdFlags Flags { get; set; } + + [JsonPropertyOrder(-94)] + [JsonConverter(typeof(ByteArrayToHexArray))] + public byte[] Data2 { get; set; } + + [JsonPropertyOrder(-93)] + public ushort ProcedureIndex { get; set; } + + [JsonPropertyOrder(-92)] + [JsonConverter(typeof(ByteArrayToHexArray))] + public byte[] Data3 { get; set; } + + protected override void ReadData(BinaryReader reader) + { + Data = reader.ReadBytes(4); + Flags = new PmdFlags(); + Flags.ReadData(reader); + Data2 = reader.ReadBytes(6); + ProcedureIndex = reader.ReadUInt16(); + Data3 = reader.ReadBytes(32); + } + + protected override void WriteData(BinaryWriter writer) + { + writer?.Write(Data); + Flags.WriteData(writer); + writer?.Write(Data2); + writer?.Write(ProcedureIndex); + writer?.Write(Data3); + } + } +}