protected Packet Compile(NetState ns, bool convertToViewer = false)
{
IGumpWriter disp;
if (ns != null && ns.Unpack)
{
disp = new DisplayGumpPacked(this);
}
else
{
disp = new DisplayGumpFast(this);
}
if (!_Dragable)
{
disp.AppendLayout(_NoMove);
}
if (!_Closable)
{
disp.AppendLayout(_NoClose);
}
if (!_Disposable)
{
disp.AppendLayout(_NoDispose);
}
if (!_Resizable)
{
disp.AppendLayout(_NoResize);
}
int count = _Entries.Count;
for (int i = 0; i < count; ++i)
{
GumpEntry e = _Entries[i];
disp.AppendLayout(_BeginLayout);
if (!convertToViewer)
{
e.AppendTo(disp);
}
else
{
var button = e as GumpButton;
if (button != null)
{
new GumpImage(button.X, button.Y, button.NormalID).AppendTo(disp);
}
else
{
var tileButton = e as GumpImageTileButton;
if (tileButton != null)
{
new GumpImageTiled(tileButton.X, tileButton.Y, tileButton.Width, tileButton.Height, tileButton.NormalID).AppendTo
(disp);
}
else
{
var radio = e as GumpRadio;
if (radio != null)
{
new GumpImage(radio.X, radio.Y, radio.InitialState ? radio.ActiveID : radio.InactiveID).AppendTo(disp);
}
else
{
var check = e as GumpCheck;
if (check != null)
{
new GumpImage(check.X, check.Y, check.InitialState ? check.ActiveID : check.InactiveID).AppendTo(disp);
}
// Process text fields
}
}
}
}
disp.AppendLayout(_EndLayout);
}
disp.WriteStrings(_Strings);
disp.Flush();
_TextEntries = disp.TextEntries;
_Switches = disp.Switches;
return(disp as Packet);
}