-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7279edf
commit 326cecf
Showing
6 changed files
with
165 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using MessageStudio.Formats.BinaryText.Components; | ||
using MessageStudio.Formats.BinaryText.Extensions; | ||
using Revrs; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
namespace NxEditor.EpdPlugin.Models.MessageStudio.BinaryText.Tags; | ||
|
||
public class FlagTag | ||
{ | ||
public const string FLOAT_NAME = "IntFlag"; | ||
public const string INT_NAME = "FloatFlag"; | ||
public const string STRING_NAME = "StringFlag"; | ||
|
||
private const string NAME_PARAM = "Name"; | ||
private const string UNKNOWN_PARAM_1 = "Unknown1"; | ||
private const string UNKNOWN_PARAM_2 = "Unknown2"; | ||
|
||
public static bool WriteUtf16(RevrsWriter writer, in TagParams @params) | ||
{ | ||
ReadOnlySpan<char> name = @params.Get<string>(NAME_PARAM); | ||
ReadOnlySpan<byte> nameRawBytes = MemoryMarshal.Cast<char, byte>(name); | ||
|
||
writer.Write((ushort)( | ||
sizeof(ushort) + nameRawBytes.Length + | ||
sizeof(ushort) + sizeof(ushort))); | ||
|
||
writer.Write((ushort)nameRawBytes.Length); | ||
writer.Write(nameRawBytes); | ||
|
||
writer.Write(@params.Get<ushort>(UNKNOWN_PARAM_2)); | ||
writer.Write(@params.Get<ushort>(UNKNOWN_PARAM_1)); | ||
return true; | ||
} | ||
|
||
public static bool WriteText(StringBuilder sb, Span<byte> data) | ||
{ | ||
RevrsReader reader = RevrsReader.Native(data); | ||
|
||
ushort rawNameLength = reader.Read<ushort>(); | ||
|
||
sb.OpenParam(NAME_PARAM); | ||
sb.Append(MemoryMarshal.Cast<byte, char>(reader.ReadSpan<byte>(rawNameLength))); | ||
sb.CloseParam(); | ||
|
||
sb.OpenParam(UNKNOWN_PARAM_1); | ||
sb.Append(reader.Read<ushort>()); | ||
sb.CloseParam(); | ||
|
||
sb.OpenParam(UNKNOWN_PARAM_2); | ||
sb.Append(reader.Read<ushort>()); | ||
sb.CloseParam(); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using MessageStudio.Formats.BinaryText.Components; | ||
using MessageStudio.Formats.BinaryText.Extensions; | ||
using Revrs; | ||
using Revrs.Extensions; | ||
using System.Text; | ||
|
||
namespace NxEditor.EpdPlugin.Models.MessageStudio.BinaryText.Tags; | ||
|
||
public class FontSizeTag | ||
{ | ||
public const string NAME = "FontSize"; | ||
|
||
private const string FONT_SIZE_PARAM = "Scale"; | ||
|
||
public static bool WriteUtf16(RevrsWriter writer, in TagParams @params) | ||
{ | ||
writer.Write<ushort>(sizeof(ushort)); | ||
writer.Write(@params.Get<ushort>(FONT_SIZE_PARAM)); | ||
return true; | ||
} | ||
|
||
public static bool WriteText(StringBuilder sb, Span<byte> data) | ||
{ | ||
sb.OpenParam(FONT_SIZE_PARAM); | ||
sb.Append(data.Read<ushort>()); | ||
sb.CloseParam(); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Revrs; | ||
|
||
namespace NxEditor.EpdPlugin.Models.MessageStudio.BinaryText.Tags; | ||
|
||
public class PageBreakTag | ||
{ | ||
public const string NAME = "Break"; | ||
|
||
public static bool WriteUtf16(RevrsWriter writer) | ||
{ | ||
writer.Write<ushort>(0); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using MessageStudio.Formats.BinaryText.Components; | ||
using MessageStudio.Formats.BinaryText.Extensions; | ||
using Revrs; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
namespace NxEditor.EpdPlugin.Models.MessageStudio.BinaryText.Tags; | ||
|
||
public class RubyTag | ||
{ | ||
public const string NAME = "Ruby"; | ||
|
||
private const string CHAR_SPAN_PARAM = "SpanChars"; | ||
private const string TEXT_PARAM = "Text"; | ||
|
||
public static bool WriteUtf16(RevrsWriter writer, in TagParams @params) | ||
{ | ||
ReadOnlySpan<char> name = @params.Get<string>(TEXT_PARAM); | ||
ReadOnlySpan<byte> nameRawBytes = MemoryMarshal.Cast<char, byte>(name); | ||
|
||
writer.Write((ushort)(sizeof(ushort) + sizeof(ushort) + nameRawBytes.Length)); | ||
writer.Write(@params.Get<ushort>(CHAR_SPAN_PARAM)); | ||
|
||
writer.Write((ushort)nameRawBytes.Length); | ||
writer.Write(nameRawBytes); | ||
|
||
return true; | ||
} | ||
|
||
public static bool WriteText(StringBuilder sb, Span<byte> data) | ||
{ | ||
RevrsReader reader = RevrsReader.Native(data); | ||
|
||
sb.OpenParam(CHAR_SPAN_PARAM); | ||
sb.Append(reader.Read<ushort>()); | ||
sb.CloseParam(); | ||
|
||
ushort rawNameLength = reader.Read<ushort>(); | ||
sb.OpenParam(TEXT_PARAM); | ||
sb.Append(MemoryMarshal.Cast<byte, char>(reader.ReadSpan<byte>(rawNameLength))); | ||
sb.CloseParam(); | ||
|
||
return true; | ||
} | ||
} |