public void Initialize(int page)
        {
            m_Page = page;

            int count = m_Heads.Count - (page * EntryCount);

            if (count < 0)
            {
                count = 0;
            }
            else if (count > EntryCount)
            {
                count = EntryCount;
            }

            int totalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (count + 1));

            AddPage(0);

            AddBackground(0, 0, BackWidth, BorderSize + totalHeight + BorderSize, BackGumpID);
            AddImageTiled(BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), totalHeight, OffsetGumpID);

            int x = BorderSize + OffsetSize;
            int y = BorderSize + OffsetSize;

            int emptyWidth = TotalWidth - PrevWidth - NextWidth - (OffsetSize * 4) - (OldStyle ? SetWidth + OffsetSize : 0);

            if (!OldStyle)
            {
                AddImageTiled(
                    x - (OldStyle ? OffsetSize : 0), y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0), EntryHeight, EntryGumpID);
            }

            AddLabel(
                x + TextOffsetX,
                y,
                TextHue,
                String.Format("Page {0} of {1} ({2})", page + 1, (m_Heads.Count + EntryCount - 1) / EntryCount, m_Heads.Count));

            x += emptyWidth + OffsetSize;

            if (OldStyle)
            {
                AddImageTiled(x, y, TotalWidth - (OffsetSize * 3) - SetWidth, EntryHeight, HeaderGumpID);
            }
            else
            {
                AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID);
            }

            if (page > 0)
            {
                AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1, GumpButtonType.Reply, 0);

                if (PrevLabel)
                {
                    AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous");
                }
            }

            x += PrevWidth + OffsetSize;

            if (!OldStyle)
            {
                AddImageTiled(x, y, NextWidth, EntryHeight, HeaderGumpID);
            }

            if ((page + 1) * EntryCount < m_Heads.Count)
            {
                AddButton(x + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 2, GumpButtonType.Reply, 1);

                if (NextLabel)
                {
                    AddLabel(x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next");
                }
            }

            for (int i = 0, index = page * EntryCount; i < EntryCount && index < m_Heads.Count; ++i, ++index)
            {
                x  = BorderSize + OffsetSize;
                y += EntryHeight + OffsetSize;

                Head2 head = m_Heads[index];

                AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
                AddLabelCropped(
                    x + TextOffsetX,
                    y,
                    EntryWidth - TextOffsetX,
                    EntryHeight,
                    GetHueFor(head.Owner),
                    (head.Deleted || head.Owner == null || head.Owner.Deleted) ? "(deleted)" : head.Owner.Name);

                x += EntryWidth + OffsetSize;

                if (SetGumpID != 0)
                {
                    AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
                }

                if (head.Owner != null && head.Owner.NetState != null && !head.Owner.Deleted)
                {
                    AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 3, GumpButtonType.Reply, 0);
                }
            }
        }
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            switch (info.ButtonID)
            {
            case 0:                     // Closed
                return;

            case 1:                     // Previous
            {
                if (m_Page > 0)
                {
                    from.SendGump(new HeadOwnerListGump(from, m_Heads, m_Page - 1));
                }
            }
            break;

            case 2:                     // Next
            {
                if ((m_Page + 1) * EntryCount < m_Heads.Count)
                {
                    from.SendGump(new HeadOwnerListGump(from, m_Heads, m_Page + 1));
                }
            }
            break;

            default:
            {
                int index = (m_Page * EntryCount) + (info.ButtonID - 3);

                if (index >= 0 && index < m_Heads.Count)
                {
                    Head2 head = m_Heads[index];

                    if (head.Deleted)
                    {
                        from.SendMessage("That head no longer exists!");
                        from.SendGump(new HeadOwnerListGump(from, m_Heads, m_Page));
                    }
                    else if (head.Owner == null)
                    {
                        from.SendMessage("Could not find the player who last had possession of your head!");
                        from.SendGump(new HeadOwnerListGump(from, m_Heads, m_Page));
                    }
                    else if (head.Owner.NetState == null)
                    {
                        from.SendMessage("That player is no longer online.");
                        from.SendGump(new HeadOwnerListGump(from, m_Heads, m_Page));
                    }
                    else if ((DateTime.UtcNow - head.LastOffer).TotalMinutes < 5.0)
                    {
                        from.SendMessage("You cannot send another offer just yet.");
                        from.SendGump(new HeadOwnerListGump(from, m_Heads, m_Page));
                    }
                    else if (from is PlayerMobile)
                    {
                        from.CloseGump(typeof(HeadNegotiateGump));
                        head.Owner.CloseGump(typeof(HeadNegotiateGump));

                        new VictimBuyHeadGump((PlayerMobile)from, head.Owner, head).Send();
                    }
                }
            }
            break;
            }
        }
Beispiel #3
0
 public Head2_Should()
 {
     _head2 = new Head2();
 }