Exemple #1
0
 public override void OnClick()
 {
     if (m_From.CheckAlive() && m_Book.IsChildOf(m_From.Backpack))
     {
         m_From.Prompt = new NameBookPrompt(m_Book);
         m_From.SendLocalizedMessage(1062479);                       // Type in the new name of the book:
     }
 }
Exemple #2
0
            public override void OnResponse(Mobile from, string text)
            {
                if (text.Length > 40)
                {
                    text = text.Substring(0, 40);
                }

                if (from.CheckAlive() && m_Book.IsChildOf(from.Backpack))
                {
                    m_Book.BookName = Utility.FixHtml(text.Trim());

                    from.SendLocalizedMessage(1062480);                       // The bulk order book's name has been changed.
                }
            }
Exemple #3
0
        public BOBGump2(PlayerMobile from, BulkOrderBook2 book, int page, ArrayList list) : base(12, 24)
        {
            from.CloseGump(typeof(BOBGump2));
            from.CloseGump(typeof(BOBFilterGump2));

            m_From = from;
            m_Book = book;
            m_Page = page;

            if (list == null)
            {
                list = new ArrayList(book.Entries.Count);

                for (int i = 0; i < book.Entries.Count; ++i)
                {
                    object obj = book.Entries[i];

                    if (CheckFilter(obj))
                    {
                        list.Add(obj);
                    }
                }
            }

            m_List = list;

            int index = GetIndexForPage(page);
            int count = GetCountForIndex(index);

            int tableIndex = 0;

            PlayerVendor pv = book.RootParent as PlayerVendor;

            bool canDrop  = book.IsChildOf(from.Backpack);
            bool canBuy   = (pv != null);
            bool canPrice = (canDrop || canBuy);

            if (canBuy)
            {
                VendorItem vi = pv.GetVendorItem(book);

                canBuy = (vi != null && !vi.IsForSale);
            }

            int width = 600;

            if (!canPrice)
            {
                width = 516;
            }

            X = (624 - width) / 2;

            AddPage(0);

            AddBackground(10, 10, width, 439, 5054);
            AddImageTiled(18, 20, width - 17, 420, 2624);

            if (canPrice)
            {
                AddImageTiled(573, 64, 24, 352, 200);
                AddImageTiled(493, 64, 78, 352, 1416);
            }

            if (canDrop)
            {
                AddImageTiled(24, 64, 32, 352, 1416);
            }

            AddImageTiled(58, 64, 36, 352, 200);
            AddImageTiled(96, 64, 133, 352, 1416);
            AddImageTiled(231, 64, 80, 352, 200);
            AddImageTiled(313, 64, 100, 352, 1416);
            AddImageTiled(415, 64, 76, 352, 200);

            for (int i = index; i < (index + count) && i >= 0 && i < list.Count; ++i)
            {
                object obj = list[i];

                if (!CheckFilter(obj))
                {
                    continue;
                }

                AddImageTiled(24, 94 + (tableIndex * 32), canPrice ? 573 : 489, 2, 2624);

                if (obj is BOBLargeEntry)
                {
                    tableIndex += ((BOBLargeEntry)obj).Entries.Length;
                }
                else if (obj is BOBSmallEntry)
                {
                    ++tableIndex;
                }
            }

            AddAlphaRegion(18, 20, width - 17, 420);
            AddImage(5, 5, 10460);
            AddImage(width - 15, 5, 10460);
            AddImage(5, 424, 10460);
            AddImage(width - 15, 424, 10460);

            AddHtmlLocalized(canPrice ? 266 : 224, 32, 200, 32, 1062220, LabelColor, false, false); // Bulk Order Book
            AddHtmlLocalized(63, 64, 200, 32, 1062213, LabelColor, false, false);                   // Type
            AddHtmlLocalized(147, 64, 200, 32, 1062214, LabelColor, false, false);                  // Item
            AddHtmlLocalized(246, 64, 200, 32, 1062215, LabelColor, false, false);                  // Quality
            AddHtmlLocalized(336, 64, 200, 32, 1062216, LabelColor, false, false);                  // Material
            AddHtmlLocalized(429, 64, 200, 32, 1062217, LabelColor, false, false);                  // Amount

            AddButton(35, 32, 4005, 4007, 1, GumpButtonType.Reply, 0);
            AddHtmlLocalized(70, 32, 200, 32, 1062476, LabelColor, false, false);               // Set Filter

            BOBFilter f = (from.UseOwnFilter ? from.BOBFilter : book.Filter);

            if (f.IsDefault)
            {
                AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062475, 16927, false, false);                   // Using No Filter
            }
            else if (from.UseOwnFilter)
            {
                AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062451, 16927, false, false);                   // Using Your Filter
            }
            else
            {
                AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062230, 16927, false, false);                   // Using Book Filter
            }
            AddButton(375, 416, 4017, 4018, 0, GumpButtonType.Reply, 0);
            AddHtmlLocalized(410, 416, 120, 20, 1011441, LabelColor, false, false);               // EXIT

            if (canDrop)
            {
                AddHtmlLocalized(26, 64, 50, 32, 1062212, LabelColor, false, false);                   // Drop
            }
            if (canPrice)
            {
                AddHtmlLocalized(516, 64, 200, 32, 1062218, LabelColor, false, false);                   // Price

                if (canBuy)
                {
                    AddHtmlLocalized(576, 64, 200, 32, 1062219, LabelColor, false, false);                       // Buy
                }
                else
                {
                    AddHtmlLocalized(576, 64, 200, 32, 1062227, LabelColor, false, false);                       // Set

                    AddButton(450, 416, 4005, 4007, 4, GumpButtonType.Reply, 0);
                    AddHtml(485, 416, 120, 20, "<BASEFONT COLOR=#FFFFFF>Price all</FONT>", false, false);
                }
            }

            tableIndex = 0;

            if (page > 0)
            {
                AddButton(75, 416, 4014, 4016, 2, GumpButtonType.Reply, 0);
                AddHtmlLocalized(110, 416, 150, 20, 1011067, LabelColor, false, false);                   // Previous page
            }

            if (GetIndexForPage(page + 1) < list.Count)
            {
                AddButton(225, 416, 4005, 4007, 3, GumpButtonType.Reply, 0);
                AddHtmlLocalized(260, 416, 150, 20, 1011066, LabelColor, false, false);                   // Next page
            }

            for (int i = index; i < (index + count) && i >= 0 && i < list.Count; ++i)
            {
                object obj = list[i];

                if (!CheckFilter(obj))
                {
                    continue;
                }

                if (obj is BOBLargeEntry)
                {
                    BOBLargeEntry e = (BOBLargeEntry)obj;

                    int y = 96 + (tableIndex * 32);

                    if (canDrop)
                    {
                        AddButton(35, y + 2, 5602, 5606, 5 + (i * 2), GumpButtonType.Reply, 0);
                    }

                    if (canDrop || (canBuy && e.Price > 0))
                    {
                        AddButton(579, y + 2, 2117, 2118, 6 + (i * 2), GumpButtonType.Reply, 0);
                        AddLabel(495, y, 1152, e.Price.ToString());
                    }

                    AddHtmlLocalized(61, y, 50, 32, 1062225, LabelColor, false, false);                       // Large

                    for (int j = 0; j < e.Entries.Length; ++j)
                    {
                        BOBLargeSubEntry sub = e.Entries[j];

                        AddHtmlLocalized(103, y, 130, 32, sub.Number, LabelColor, false, false);

                        if (e.RequireExceptional)
                        {
                            AddHtmlLocalized(235, y, 80, 20, 1060636, LabelColor, false, false);                               // exceptional
                        }
                        else
                        {
                            AddHtmlLocalized(235, y, 80, 20, 1011542, LabelColor, false, false);                               // normal
                        }
                        object name = GetMaterialName(e.Material, e.DeedType, sub.ItemType);

                        if (name is int)
                        {
                            AddHtmlLocalized(316, y, 100, 20, (int)name, LabelColor, false, false);
                        }
                        else if (name is string)
                        {
                            AddLabel(316, y, 1152, (string)name);
                        }

                        AddLabel(421, y, 1152, String.Format("{0} / {1}", sub.AmountCur, e.AmountMax));

                        ++tableIndex;
                        y += 32;
                    }
                }
                else if (obj is BOBSmallEntry)
                {
                    BOBSmallEntry e = (BOBSmallEntry)obj;

                    int y = 96 + (tableIndex++ *32);

                    if (canDrop)
                    {
                        AddButton(35, y + 2, 5602, 5606, 5 + (i * 2), GumpButtonType.Reply, 0);
                    }

                    if (canDrop || (canBuy && e.Price > 0))
                    {
                        AddButton(579, y + 2, 2117, 2118, 6 + (i * 2), GumpButtonType.Reply, 0);
                        AddLabel(495, y, 1152, e.Price.ToString());
                    }

                    AddHtmlLocalized(61, y, 50, 32, 1062224, LabelColor, false, false);                       // Small

                    AddHtmlLocalized(103, y, 130, 32, e.Number, LabelColor, false, false);

                    if (e.RequireExceptional)
                    {
                        AddHtmlLocalized(235, y, 80, 20, 1060636, LabelColor, false, false);                           // exceptional
                    }
                    else
                    {
                        AddHtmlLocalized(235, y, 80, 20, 1011542, LabelColor, false, false);                           // normal
                    }
                    object name = GetMaterialName(e.Material, e.DeedType, e.ItemType);

                    if (name is int)
                    {
                        AddHtmlLocalized(316, y, 100, 20, (int)name, LabelColor, false, false);
                    }
                    else if (name is string)
                    {
                        AddLabel(316, y, 1152, (string)name);
                    }

                    AddLabel(421, y, 1152, String.Format("{0} / {1}", e.AmountCur, e.AmountMax));
                }
            }
        }
Exemple #4
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            int index = info.ButtonID;

            switch (index)
            {
            case 0:                     // EXIT
            {
                break;
            }

            case 1:                     // Set Filter
            {
                m_From.SendGump(new BOBFilterGump2(m_From, m_Book));

                break;
            }

            case 2:                     // Previous page
            {
                if (m_Page > 0)
                {
                    m_From.SendGump(new BOBGump2(m_From, m_Book, m_Page - 1, m_List));
                }

                return;
            }

            case 3:                     // Next page
            {
                if (GetIndexForPage(m_Page + 1) < m_List.Count)
                {
                    m_From.SendGump(new BOBGump2(m_From, m_Book, m_Page + 1, m_List));
                }

                break;
            }

            case 4:                     // Price all
            {
                if (m_Book.IsChildOf(m_From.Backpack))
                {
                    m_From.Prompt = new SetPricePrompt(m_Book, null, m_Page, m_List);
                    m_From.SendMessage("Type in a price for all deeds in the book:");
                }

                break;
            }

            default:
            {
                bool canDrop  = m_Book.IsChildOf(m_From.Backpack);
                bool canPrice = canDrop || (m_Book.RootParent is PlayerVendor);

                index -= 5;

                int type = index % 2;
                index /= 2;

                if (index < 0 || index >= m_List.Count)
                {
                    break;
                }

                object obj = m_List[index];

                if (!m_Book.Entries.Contains(obj))
                {
                    m_From.SendLocalizedMessage(1062382);                               // The deed selected is not available.
                    break;
                }

                if (type == 0)                           // Drop
                {
                    if (m_Book.IsChildOf(m_From.Backpack))
                    {
                        Item item = Reconstruct(obj);

                        if (item != null)
                        {
                            Container pack = m_From.Backpack;
                            if ((pack == null) || ((pack != null) && (!pack.CheckHold(m_From, item, true, true, 0, item.PileWeight + item.TotalWeight))))
                            {
                                m_From.SendLocalizedMessage(503204);                                         // You do not have room in your backpack for this
                                m_From.SendGump(new BOBGump2(m_From, m_Book, m_Page, null));
                            }
                            else
                            {
                                if (m_Book.IsChildOf(m_From.Backpack))
                                {
                                    int sizeOfDroppedBod;
                                    if (obj is BOBLargeEntry)
                                    {
                                        sizeOfDroppedBod = ((BOBLargeEntry)obj).Entries.Length;
                                    }
                                    else
                                    {
                                        sizeOfDroppedBod = 1;
                                    }

                                    m_From.AddToBackpack(item);
                                    m_From.SendLocalizedMessage(1045152);                                             // The bulk order deed has been placed in your backpack.
                                    m_Book.Entries.Remove(obj);
                                    m_Book.InvalidateProperties();

                                    if (m_Book.Entries.Count / 5 < m_Book.ItemCount)
                                    {
                                        m_Book.ItemCount--;
                                        m_Book.InvalidateItems();
                                    }

                                    if (m_Book.Entries.Count > 0)
                                    {
                                        m_Page = GetPageForIndex(index, sizeOfDroppedBod);
                                        m_From.SendGump(new BOBGump2(m_From, m_Book, m_Page, null));
                                    }
                                    else
                                    {
                                        m_From.SendLocalizedMessage(1062381);                                                 // The book is empty.
                                    }
                                }
                            }
                        }
                        else
                        {
                            m_From.SendMessage("Internal error. The bulk order deed could not be reconstructed.");
                        }
                    }
                }
                else                         // Set Price | Buy
                {
                    if (m_Book.IsChildOf(m_From.Backpack))
                    {
                        m_From.Prompt = new SetPricePrompt(m_Book, obj, m_Page, m_List);
                        m_From.SendLocalizedMessage(1062383);                                   // Type in a price for the deed:
                    }
                    else if (m_Book.RootParent is PlayerVendor)
                    {
                        PlayerVendor pv = (PlayerVendor)m_Book.RootParent;
                        VendorItem   vi = pv.GetVendorItem(m_Book);

                        if (vi != null && !vi.IsForSale)
                        {
                            int sizeOfDroppedBod;
                            int price = 0;
                            if (obj is BOBLargeEntry)
                            {
                                price            = ((BOBLargeEntry)obj).Price;
                                sizeOfDroppedBod = ((BOBLargeEntry)obj).Entries.Length;
                            }
                            else
                            {
                                price            = ((BOBSmallEntry)obj).Price;
                                sizeOfDroppedBod = 1;
                            }
                            if (price == 0)
                            {
                                m_From.SendLocalizedMessage(1062382);                                         // The deed selected is not available.
                            }
                            else
                            {
                                if (m_Book.Entries.Count > 0)
                                {
                                    m_Page = GetPageForIndex(index, sizeOfDroppedBod);
                                    m_From.SendGump(new BODBuyGump2(m_From, m_Book, obj, m_Page, price));
                                }
                                else
                                {
                                    m_From.SendLocalizedMessage(1062381);                                             // The book is emptz
                                }
                            }
                        }
                    }
                }
                break;
            }
            }
        }