Exemplo n.º 1
0
        private Packet Compile(NetState ns)
        {
            IGumpWriter disp;

            if (ns != null && ns.Version != null && ns.Version >= UnpackVersion)
            {
                disp = new DisplayGumpPacked(this);
            }
            else
            {
                disp = new DisplayGumpFast(this);
            }

            if (!m_Dragable)
            {
                disp.AppendLayout(m_NoMove);
            }

            if (!m_Closable)
            {
                disp.AppendLayout(m_NoClose);
            }

            if (!m_Disposable)
            {
                disp.AppendLayout(m_NoDispose);
            }

            if (!m_Resizable)
            {
                disp.AppendLayout(m_NoResize);
            }

            int       count = m_Entries.Count;
            GumpEntry e;

            for (int i = 0; i < count; ++i)
            {
                e = m_Entries[i];

                disp.AppendLayout(m_BeginLayout);
                e.AppendTo(disp);
                disp.AppendLayout(m_EndLayout);
            }

            disp.WriteStrings(m_Strings);

            disp.Flush();

            m_TextEntries = disp.TextEntries;
            m_Switches    = disp.Switches;

            return(disp as Packet);
        }
Exemplo n.º 2
0
        public Packet Compile(NetState ns = null)
        {
            IGumpWriter disp;

            if (ns?.Unpack == true)
            {
                disp = new DisplayGumpPacked(this);
            }
            else
            {
                disp = new DisplayGumpFast(this);
            }

            if (!Draggable)
            {
                disp.AppendLayout(m_NoMove);
            }

            if (!Closable)
            {
                disp.AppendLayout(m_NoClose);
            }

            if (!Disposable)
            {
                disp.AppendLayout(m_NoDispose);
            }

            if (!Resizable)
            {
                disp.AppendLayout(m_NoResize);
            }

            var count = Entries.Count;

            for (var i = 0; i < count; ++i)
            {
                var e = Entries[i];

                disp.AppendLayout(m_BeginLayout);
                e.AppendTo(ns, disp);
                disp.AppendLayout(m_EndLayout);
            }

            disp.WriteStrings(Strings);

            disp.Flush();

            m_TextEntries = disp.TextEntries;
            m_Switches    = disp.Switches;

            return((Packet)disp);
        }
Exemplo n.º 3
0
        public static Packet Compile(this Gump g, NetState ns = null)
        {
            IGumpWriter disp;

            if (ns?.Unpack == true)
            {
                disp = new DisplayGumpPacked(g);
            }
            else
            {
                disp = new DisplayGumpFast(g);
            }

            if (!g.Draggable)
            {
                disp.AppendLayout(Gump.NoMove);
            }

            if (!g.Closable)
            {
                disp.AppendLayout(Gump.NoClose);
            }

            if (!g.Disposable)
            {
                disp.AppendLayout(Gump.NoDispose);
            }

            if (!g.Resizable)
            {
                disp.AppendLayout(Gump.NoResize);
            }

            var count   = g.Entries.Count;
            var strings = new List <string>();

            for (var i = 0; i < count; ++i)
            {
                var e = g.Entries[i];

                disp.AppendLayout(m_BeginLayout);
                e.AppendToByType(disp, strings);
                disp.AppendLayout(m_EndLayout);
            }

            disp.WriteStrings(strings);

            disp.Flush();

            return((Packet)disp);
        }
Exemplo n.º 4
0
        protected Packet Compile()
        {
            IGumpWriter disp = new DisplayGumpPacked(this);

            if (!m_Dragable)
            {
                disp.AppendLayout(m_NoMove);
            }

            if (!m_Closable)
            {
                disp.AppendLayout(m_NoClose);
            }

            if (!m_Disposable)
            {
                disp.AppendLayout(m_NoDispose);
            }

            if (!m_Resizable)
            {
                disp.AppendLayout(m_NoResize);
            }


            var       count = m_Entries.Count;
            GumpEntry e;

            for (var i = 0; i < count; ++i)
            {
                e = m_Entries[i];

                disp.AppendLayout(m_BeginLayout);
                e.AppendTo(disp);
                disp.AppendLayout(m_EndLayout);
            }

            disp.WriteStrings(m_Strings);

            disp.Flush();

            m_TextEntries = disp.TextEntries;
            m_Switches    = disp.Switches;

            return(disp as Packet);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        private Packet Compile(NetState ns)
        {
            IGumpWriter disp;

            if (ns != null && ns.Unpack)
            {
                disp = new DisplayGumpPacked(this);
            }
            else
            {
                disp = new DisplayGumpFast(this);
            }

            if (!m_Dragable)
            {
                disp.AppendLayout(m_NoMove);
            }

            if (!m_Closable)
            {
                disp.AppendLayout(m_NoClose);
            }

            if (!m_Disposable)
            {
                disp.AppendLayout(m_NoDispose);
            }

            if (!m_Resizable)
            {
                disp.AppendLayout(m_NoResize);
            }

            int       count = m_Entries.Count;
            GumpEntry e;

            for (int i = 0; i < count; ++i)
            {
                e = m_Entries[i];
                if (e is GumpHtmlLocalized && ns?.Version?.Major <= 3)
                {
                    var localized = e as GumpHtmlLocalized;
                    if (localized.Type == GumpHtmlLocalizedType.Color)
                    {
                        localized.Type = GumpHtmlLocalizedType.Plain;
                    }
                    if (localized.Number > 0)
                    {
                        var text = CliLoc.LocToString(localized.Number, localized.Args);//  GetClioc(ns).Entries.Where(cl => cl.Number == localized.Number).FirstOrDefault()?.Text;

                        /*if (text == null)
                         *  text = "Failed";
                         * if (!string.IsNullOrWhiteSpace(localized.Args))
                         * {
                         *  text = text.Replace("~1_val~", localized.Args);
                         * }
                         * //e = new GumpLabel(localized.X, localized.Y, 0, text);*/
                        e        = new GumpHtml(localized.X, localized.Y, localized.Width, localized.Height, text, localized.Background, localized.Scrollbar);
                        e.Parent = localized.Parent;
                    }
                }
                disp.AppendLayout(m_BeginLayout);
                e.AppendTo(disp);
                disp.AppendLayout(m_EndLayout);
            }

            disp.WriteStrings(m_Strings);

            disp.Flush();

            m_TextEntries = disp.TextEntries;
            m_Switches    = disp.Switches;

            return(disp as Packet);
        }