Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BGM, MESSAG, and SCRIPT Frames #1

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions Libellus Library/Event/Types/Frame/PmdFlags.cs
Original file line number Diff line number Diff line change
@@ -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,
}
}
}
5 changes: 4 additions & 1 deletion Libellus Library/Event/Types/Frame/PmdFrameFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ private List<PmdTargetTypeID> 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
Expand Down
28 changes: 26 additions & 2 deletions Libellus Library/Event/Types/Frame/PmdTarget_Bgm.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
52 changes: 52 additions & 0 deletions Libellus Library/Event/Types/Frame/PmdTarget_Message.cs
Original file line number Diff line number Diff line change
@@ -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);
}

}
}
51 changes: 51 additions & 0 deletions Libellus Library/Event/Types/Frame/PmdTarget_Script.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}