fix(core): Converts Gump Packets (v1) (#379)

- [X] Converts gump packets
This commit is contained in:
Kamron Batman 2021-01-05 01:17:34 -08:00 • committed by GitHub
parent 126b80f74b
commit a278623f38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 790 additions and 763 deletions

View file

@ -6,7 +6,7 @@ namespace Server.Gumps
{
public class GumpTextEntryLimited : GumpEntry
{
private static readonly byte[] m_LayoutName = Gump.StringToBuffer("textentrylimited");
public static readonly byte[] LayoutName = Gump.StringToBuffer("textentrylimited");
public GumpTextEntryLimited(
int x, int y, int width, int height, int hue, int entryID, string initialText, int size = 0
@ -38,31 +38,14 @@ namespace Server.Gumps
public int Size { get; set; }
public override string Compile(NetState ns) =>
$"{{ textentrylimited {X} {Y} {Width} {Height} {Hue} {EntryID} {Parent.Intern(InitialText)} {Size} }}";
public override string Compile(OrderedHashSet<string> strings) =>
$"{{ textentrylimited {X} {Y} {Width} {Height} {Hue} {EntryID} {strings.GetOrAdd(InitialText)} {Size} }}";
public override void AppendTo(NetState ns, IGumpWriter disp)
{
disp.AppendLayout(m_LayoutName);
disp.AppendLayout(X);
disp.AppendLayout(Y);
disp.AppendLayout(Width);
disp.AppendLayout(Height);
disp.AppendLayout(Hue);
disp.AppendLayout(EntryID);
disp.AppendLayout(Parent.Intern(InitialText));
disp.AppendLayout(Size);
disp.TextEntries++;
}
public override void AppendTo(ref SpanWriter writer, OrderedHashSet<string> strings, ref int entries, ref int switches)
{
writer.Write((ushort)0x7B20); // "{ "
writer.Write(m_LayoutName);
writer.Write(LayoutName);
writer.Write((byte)0x20); // ' '
writer.WriteAscii(X.ToString());
writer.Write((byte)0x20); // ' '
writer.WriteAscii(Y.ToString());