fix(core): Adds Gump component functionality (#377)

- [X] Adds gump close packet
- [X] Fixes gump tooltip
- [X] Adds new compile/append functions for the new gump packets
This commit is contained in:
Kamron Batman 2021-01-02 19:08:35 -08:00 • committed by GitHub
parent cc91fe2b10
commit 3b413371dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 1696 additions and 137 deletions

View file

@ -1,3 +1,5 @@
using System.Buffers;
using Server.Collections;
using Server.Network;
namespace Server.Gumps
@ -88,9 +90,19 @@ namespace Server.Gumps
public GumpHtmlLocalizedType Type { get; set; }
public override string Compile(NetState ns)
{
return Type switch
public override string Compile(NetState ns) =>
Type switch
{
GumpHtmlLocalizedType.Plain =>
$"{{ xmfhtmlgump {X} {Y} {Width} {Height} {Number} {(Background ? 1 : 0)} {(Scrollbar ? 1 : 0)} }}",
GumpHtmlLocalizedType.Color =>
$"{{ xmfhtmlgumpcolor {X} {Y} {Width} {Height} {Number} {(Background ? 1 : 0)} {(Scrollbar ? 1 : 0)} {Color} }}",
_ =>
$"{{ xmfhtmltok {X} {Y} {Width} {Height} {(Background ? 1 : 0)} {(Scrollbar ? 1 : 0)} {Color} {Number} @{Args}@ }}"
};
public override string Compile(OrderedHashSet<string> strings) =>
Type switch
{
GumpHtmlLocalizedType.Plain =>
$"{{ xmfhtmlgump {X} {Y} {Width} {Height} {Number} {(Background ? 1 : 0)} {(Scrollbar ? 1 : 0)} }}",
@ -99,7 +111,6 @@ namespace Server.Gumps
_ =>
$"{{ xmfhtmltok {X} {Y} {Width} {Height} {(Background ? 1 : 0)} {(Scrollbar ? 1 : 0)} {Color} {Number} @{Args}@ }}"
};
}
public override void AppendTo(NetState ns, IGumpWriter disp)
{
@ -154,5 +165,81 @@ namespace Server.Gumps
}
}
}
public override void AppendTo(ref SpanWriter writer, OrderedHashSet<string> strings, ref int entries, ref int switches)
{
writer.Write((ushort)0x7B20); // "{ "
switch (Type)
{
case GumpHtmlLocalizedType.Plain:
{
writer.Write(m_LayoutNamePlain);
writer.WriteAscii(X.ToString());
writer.Write((byte)0x20); // ' '
writer.WriteAscii(Y.ToString());
writer.Write((byte)0x20); // ' '
writer.WriteAscii(Width.ToString());
writer.Write((byte)0x20); // ' '
writer.WriteAscii(Height.ToString());
writer.Write((byte)0x20); // ' '
writer.WriteAscii(Number.ToString());
writer.Write((byte)0x20); // ' '
writer.Write((byte)(Background ? 0x31 : 0x30)); // 1 or 0
writer.Write((byte)0x20); // ' '
writer.Write((byte)(Scrollbar ? 0x31 : 0x30)); // 1 or 0
break;
}
case GumpHtmlLocalizedType.Color:
{
writer.Write(m_LayoutNameColor);
writer.WriteAscii(X.ToString());
writer.Write((byte)0x20); // ' '
writer.WriteAscii(Y.ToString());
writer.Write((byte)0x20); // ' '
writer.WriteAscii(Width.ToString());
writer.Write((byte)0x20); // ' '
writer.WriteAscii(Height.ToString());
writer.Write((byte)0x20); // ' '
writer.WriteAscii(Number.ToString());
writer.Write((byte)0x20); // ' '
writer.Write((byte)(Background ? 0x31 : 0x30)); // 1 or 0
writer.Write((byte)0x20); // ' '
writer.Write((byte)(Scrollbar ? 0x31 : 0x30)); // 1 or 0
writer.Write((byte)0x20); // ' '
writer.WriteAscii(Color.ToString());
break;
}
case GumpHtmlLocalizedType.Args:
{
writer.Write(m_LayoutNameArgs);
writer.WriteAscii(X.ToString());
writer.Write((byte)0x20); // ' '
writer.WriteAscii(Y.ToString());
writer.Write((byte)0x20); // ' '
writer.WriteAscii(Width.ToString());
writer.Write((byte)0x20); // ' '
writer.WriteAscii(Height.ToString());
writer.Write((byte)0x20); // ' '
writer.Write((byte)(Background ? 0x31 : 0x30)); // 1 or 0
writer.Write((byte)0x20); // ' '
writer.Write((byte)(Scrollbar ? 0x31 : 0x30)); // 1 or 0
writer.Write((byte)0x20); // ' '
writer.WriteAscii(Color.ToString());
writer.Write((byte)0x20); // ' '
writer.WriteAscii(Number.ToString());
writer.Write((byte)0x20); // ' '
writer.Write((byte)0x40); // '@'
writer.WriteAscii(Args ?? "");
writer.Write((byte)0x40); // '@'
break;
}
}
writer.Write((ushort)0x207D); // " }"
}
}
}