private static VendorItem GetParentVendorItem(PlayerVendor pv, Container parent) { VendorItem vendorItem = pv.GetVendorItem(parent); if (vendorItem == null) { if (parent.Parent is Container) { return(GetParentVendorItem(pv, (Container)parent.Parent)); } } return(vendorItem); }
private static void processContainer(PlayerVendor vendor, Container container) { foreach (Item i in container.Items) { VendorItem vi = vendor.GetVendorItem(i); if (vi != null) { if (vi.IsForSale) { MyVendorItem mvi = new MyVendorItem(); mvi.Name = vi.Item is BaseContainer ? "container" : StringUtils.GetString(vi.Item.Name, Sphere.ComputeName(vi.Item)); mvi.Description = vi.Description; mvi.Price = vi.Price; if (vi.Item is CommodityDeed) { Item commodity = (vi.Item as CommodityDeed).Commodity; if (commodity == null) // skip empty deeds { continue; } mvi.Amount = commodity.Amount; mvi.Name += " - " + Sphere.ComputeName(commodity); } else { mvi.Amount = vi.Item.Amount; } if (mvi.Amount != 0) { mvi.PricePer = mvi.Price / mvi.Amount; } else { mvi.PricePer = mvi.Price; } mvi.VendorName = vendor.Name; mvi.OwnerName = vendor.Owner.Name; mvi.Location = StringUtils.GetString(vendor.Region.Name, BaseRegion.GetRuneNameFor(vendor.Region)) + " " + vendor.Location.X + "," + vendor.Location.Y; m_VendorItems.Add(mvi); } else if (vi.Item is Container) { processContainer(vendor, vi.Item as Container); } } } }
private static VendorItem GetParentVendorItem(PlayerVendor pv, Container parent) { while (true) { VendorItem vendorItem = pv.GetVendorItem(parent); if (vendorItem == null) { if (parent.Parent is Container container) { parent = container; continue; } } return(vendorItem); } }
private void GetVendorItemsDisplay(StreamWriter op, PlayerVendor pv, Item item) { VendorItem vi = pv.GetVendorItem(item); if (vi == null) { return; } if (vi.IsForSale) { if (pv.Owner == null || pv.Owner.Name == "1k5g6se84f895s854f884s6a") //If name same as this it will not show items in list. { return; } string ownername = (pv.Name != pv.Owner.Name ? pv.Owner.Name : " "); string name = item.Name; if (string.IsNullOrEmpty(name)) { name = item.GetType().ToString(); if (name.LastIndexOf('.') >= 0) { name = name.Substring(name.LastIndexOf('.') + 1); } } if (name.Length > 25) { name = name.Substring(0, 25); } string des = (string.IsNullOrEmpty(vi.Description) ? " " : vi.Description); op.WriteLine("<tr><td bgcolor=\"green\"><font color = \"black\"><img src= http://aaaservices.homeip.net/UO/uopics/pouch.bmp align=\"absmiddle\"> {0} </td> <td bgcolor=\"green\"><font color = \"black\"><img src= http://aaaservices.homeip.net/UO/uopics/bodscroll.bmp align=\"absmiddle\"> {1,-25} </td> <td bgcolor=\"green\"><font color = \"black\"><img src= http://aaaservices.homeip.net/UO/uopics/gold.bmp align=\"absmiddle\"> {2,7} </td> <td bgcolor=\"green\"><font color = \"black\"><img src= http://aaaservices.homeip.net/UO/uopics/scroll.bmp align=\"absmiddle\"> {3} </td></tr>", item.Amount, name, vi.Price.ToString(), des); //Note want to add bag icon here } else if (item is Container) { foreach (Item containerItem in item.Items) { GetVendorItemsDisplay(op, pv, containerItem); // } } }
public override void OnResponse(Network.NetState sender, RelayInfo info) { if (info.ButtonID == 2) { PlayerVendor pv = m_Book.RootParent as PlayerVendor; if (m_Book.Entries.Contains(m_Object) && pv != null) { int price = 0; VendorItem vi = pv.GetVendorItem(m_Book); if (vi != null && !vi.IsForSale) { if (m_Object is BOBLargeEntry) { price = ((BOBLargeEntry)m_Object).Price; } else if (m_Object is BOBSmallEntry) { price = ((BOBSmallEntry)m_Object).Price; } } if (price != m_Price) { pv.SayTo(m_From, "The price has been been changed. If you like, you may offer to purchase the item again."); } else if (price == 0) { pv.SayTo(m_From, 1062382); // The deed selected is not available. } else { Item item = null; if (m_Object is BOBLargeEntry) { item = ((BOBLargeEntry)m_Object).Reconstruct(); } else if (m_Object is BOBSmallEntry) { item = ((BOBSmallEntry)m_Object).Reconstruct(); } if (item == null) { m_From.SendMessage("Internal error. The bulk order deed could not be reconstructed."); } else { pv.Say(m_From.Name); Container pack = m_From.Backpack; if ((pack == null) || ((pack != null) && (!pack.CheckHold(m_From, item, true, true, 0, item.PileWeight + item.TotalWeight)))) { pv.SayTo(m_From, 503204); // You do not have room in your backpack for this m_From.SendGump(new BOBGump(m_From, m_Book, m_Page, null)); } else { if ((pack != null && pack.ConsumeTotal(typeof(Gold), price)) || Banker.Withdraw(m_From, price)) { m_Book.Entries.Remove(m_Object); m_Book.InvalidateProperties(); pv.HoldGold += price; m_From.AddToBackpack(item); m_From.SendLocalizedMessage(1045152); // The bulk order deed has been placed in your backpack. if (m_Book.Entries.Count / 5 < m_Book.ItemCount) { m_Book.ItemCount--; m_Book.InvalidateItems(); } if (m_Book.Entries.Count > 0) { m_From.SendGump(new BOBGump(m_From, m_Book, m_Page, null)); } else { m_From.SendLocalizedMessage(1062381); // The book is empty. } } else { pv.SayTo(m_From, 503205); // You cannot afford this item. item.Delete(); } } } } } else { if (pv == null) { m_From.SendLocalizedMessage(1062382); // The deed selected is not available. } else { pv.SayTo(m_From, 1062382); // The deed selected is not available. } } } else { m_From.SendLocalizedMessage(503207); // Cancelled purchase. } }
public BOBGump(PlayerMobile from, BulkOrderBook book, int page = 0, List <IBOBEntry> list = null) : base(12, 24) { from.CloseGump <BOBGump>(); from.CloseGump <BOBFilterGump>(); m_From = from; m_Book = book; m_Page = page; if (list == null) { list = new List <IBOBEntry>(book.Entries.Count); for (int i = 0; i < book.Entries.Count; ++i) { IBOBEntry entry = book.Entries[i]; if (CheckFilter(entry)) { list.Add(entry); } } } 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?.IsForSale == false; } 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) { IBOBEntry entry = list[i]; if (!CheckFilter(entry)) { continue; } AddImageTiled(24, 94 + tableIndex * 32, canPrice ? 573 : 489, 2, 2624); tableIndex += entry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1; } 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); // Bulk Order Book AddHtmlLocalized(63, 64, 200, 32, 1062213, LabelColor); // Type AddHtmlLocalized(147, 64, 200, 32, 1062214, LabelColor); // Item AddHtmlLocalized(246, 64, 200, 32, 1062215, LabelColor); // Quality AddHtmlLocalized(336, 64, 200, 32, 1062216, LabelColor); // Material AddHtmlLocalized(429, 64, 200, 32, 1062217, LabelColor); // Amount AddButton(35, 32, 4005, 4007, 1); AddHtmlLocalized(70, 32, 200, 32, 1062476, LabelColor); // Set Filter BOBFilter f = from.UseOwnFilter ? from.BOBFilter : book.Filter; if (f.IsDefault) { AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062475, 16927); // Using No Filter } else if (from.UseOwnFilter) { AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062451, 16927); // Using Your Filter } else { AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062230, 16927); // Using Book Filter } AddButton(375, 416, 4017, 4018, 0); AddHtmlLocalized(410, 416, 120, 20, 1011441, LabelColor); // EXIT if (canDrop) { AddHtmlLocalized(26, 64, 50, 32, 1062212, LabelColor); // Drop } if (canPrice) { AddHtmlLocalized(516, 64, 200, 32, 1062218, LabelColor); // Price if (canBuy) { AddHtmlLocalized(576, 64, 200, 32, 1062219, LabelColor); // Buy } else { AddHtmlLocalized(576, 64, 200, 32, 1062227, LabelColor); // Set AddButton(450, 416, 4005, 4007, 4); AddHtml(485, 416, 120, 20, "<BASEFONT COLOR=#FFFFFF>Price all</FONT>"); } } tableIndex = 0; if (page > 0) { AddButton(75, 416, 4014, 4016, 2); AddHtmlLocalized(110, 416, 150, 20, 1011067, LabelColor); // Previous page } if (GetIndexForPage(page + 1) < list.Count) { AddButton(225, 416, 4005, 4007, 3); AddHtmlLocalized(260, 416, 150, 20, 1011066, LabelColor); // Next page } for (int i = index; i < index + count && i >= 0 && i < list.Count; ++i) { IBOBEntry entry = list[i]; if (!CheckFilter(entry)) { continue; } if (entry is BOBLargeEntry largeEntry) { int y = 96 + tableIndex * 32; if (canDrop) { AddButton(35, y + 2, 5602, 5606, 5 + i * 2); } if (canDrop || (canBuy && entry.Price > 0)) { AddButton(579, y + 2, 2117, 2118, 6 + i * 2); AddLabel(495, y, 1152, entry.Price.ToString()); } AddHtmlLocalized(61, y, 50, 32, 1062225, LabelColor); // Large for (int j = 0; j < largeEntry.Entries.Length; ++j) { BOBLargeSubEntry sub = largeEntry.Entries[j]; AddHtmlLocalized(103, y, 130, 32, sub.Number, LabelColor); if (entry.RequireExceptional) { AddHtmlLocalized(235, y, 80, 20, 1060636, LabelColor); // exceptional } else { AddHtmlLocalized(235, y, 80, 20, 1011542, LabelColor); // normal } TextDefinition name = GetMaterialName(entry.Material, entry.DeedType, sub.ItemType); if (name.Number > 0) { AddHtmlLocalized(316, y, 100, 20, name, LabelColor); } else { AddLabel(316, y, 1152, name); } AddLabel(421, y, 1152, $"{sub.AmountCur} / {entry.AmountMax}"); ++tableIndex; y += 32; } } else { BOBSmallEntry smallEntry = (BOBSmallEntry)entry; int y = 96 + tableIndex++ *32; if (canDrop) { AddButton(35, y + 2, 5602, 5606, 5 + i * 2); } if (canDrop || (canBuy && smallEntry.Price > 0)) { AddButton(579, y + 2, 2117, 2118, 6 + i * 2); AddLabel(495, y, 1152, smallEntry.Price.ToString()); } AddHtmlLocalized(61, y, 50, 32, 1062224, LabelColor); // Small AddHtmlLocalized(103, y, 130, 32, smallEntry.Number, LabelColor); if (smallEntry.RequireExceptional) { AddHtmlLocalized(235, y, 80, 20, 1060636, LabelColor); // exceptional } else { AddHtmlLocalized(235, y, 80, 20, 1011542, LabelColor); // normal } TextDefinition name = GetMaterialName(smallEntry.Material, smallEntry.DeedType, smallEntry.ItemType); if (name.Number > 0) { AddHtmlLocalized(316, y, 100, 20, name, LabelColor); } else { AddLabel(316, y, 1152, name); } AddLabel(421, y, 1152, $"{smallEntry.AmountCur} / {smallEntry.AmountMax}"); } } }
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 BOBFilterGump(m_From, m_Book)); break; } case 2: // Previous page { if (m_Page > 0) { m_From.SendGump(new BOBGump(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 BOBGump(m_From, m_Book, m_Page + 1, m_List)); } break; } default: { bool canDrop = m_Book.IsChildOf(m_From.Backpack); bool canPrice = canDrop || (m_Book.RootParent is PlayerVendor); index -= 4; 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) { 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 > 0) { m_From.SendGump(new BOBGump(m_From, m_Book, 0, 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); int price = 0; if (vi != null && !vi.IsForSale) { if (obj is BOBLargeEntry) { price = ((BOBLargeEntry)obj).Price; } else if (obj is BOBSmallEntry) { price = ((BOBSmallEntry)obj).Price; } } if (price == 0) { m_From.SendLocalizedMessage(1062382); // The deed selected is not available. } else { m_From.SendGump(new BODBuyGump(m_From, m_Book, obj, price)); } } } break; } } }
public override void OnResponse(Server.Network.NetState sender, RelayInfo info) { if (info.ButtonID == 2) { PlayerVendor pv = m_Book.RootParent as PlayerVendor; if (m_Book.Entries.Contains(m_Object) && pv != null) { int price = 0; VendorItem vi = pv.GetVendorItem(m_Book); if (vi != null && !vi.IsForSale) { if (m_Object is PowerScrollBookEntry) { price = ((PowerScrollBookEntry)m_Object).Price; } } if (price != m_Price) { pv.SayTo(m_From, "The price has been been changed. If you like, you may offer to purchase the item again."); } else if (price == 0) { pv.SayTo(m_From, 1062382); } else { Item item = null; if (m_Object is PowerScrollBookEntry) { item = ((PowerScrollBookEntry)m_Object).Reconstruct(); } if (item == null) { m_From.SendMessage("Internal error. The power scroll could not be reconstructed."); } else { pv.Say(m_From.Name); Container pack = m_From.Backpack; if ((pack != null && pack.ConsumeTotal(typeof(Gold), price)) || Banker.Withdraw(m_From, price)) { m_Book.Entries.Remove(m_Object); m_Book.InvalidateProperties(); pv.HoldGold += price; if (m_From.AddToBackpack(item)) { m_From.SendMessage("The power scroll has been placed in your backpack."); } else { pv.SayTo(m_From, 503204); } if (m_Book.Entries.Count > 0) { m_From.SendGump(new PowerScrollBookGump(m_From, m_Book)); } else { m_From.SendLocalizedMessage(1062381); } } else { pv.SayTo(m_From, 503205); item.Delete(); } } } } else { if (pv == null) { m_From.SendLocalizedMessage(1062382); } else { pv.SayTo(m_From, 1062382); } } } else { m_From.SendLocalizedMessage(503207); } }
public TamingBOBGump(PlayerMobile from, TamingBulkOrderBook book, int page, ArrayList list) : base(12, 24) { from.CloseGump(typeof(TamingBOBGump)); from.CloseGump(typeof(TamingBOBFilterGump)); 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); //AddImage( 231, 100, 5549 ); 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 TamingBOBLargeEntry) { tableIndex += ((TamingBOBLargeEntry)obj).Entries.Length; } else if (obj is TamingBOBSmallEntry) { ++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 AddLabel(147, 64, 1149, @"Animal"); 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 // TamingBOBFilter f = ( from.UseOwnFilter ? from.TamingBOBFilter : 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 // } // 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 TamingBOBLargeEntry ) // { // TamingBOBLargeEntry e = (TamingBOBLargeEntry)obj; // int y = 96 + (tableIndex * 32); // if ( canDrop ) // AddButton( 35, y + 2, 5602, 5606, 4 + (i * 2), GumpButtonType.Reply, 0 ); // if ( canDrop || (canBuy && e.Price > 0) ) // { // AddButton( 579, y + 2, 2117, 2118, 5 + (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 ) // { // TamingBOBLargeSubEntry sub = e.Entries[j]; // string s = sub.AnimalName; // int capsbreak = s.IndexOfAny("ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray(),1); // if( capsbreak > -1 ) // { // string secondhalf = s.Substring( capsbreak ); // string firsthalf = s.Substring(0, capsbreak ); // string newname = firsthalf + " " + secondhalf; // AddLabel( 103, y, 1149, newname.ToString() ); // } // else // { // AddLabel( 103, y, 1149, sub.AnimalName.ToString() ); // } // object name = GetMaterialName( sub.Type ); // 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 TamingBOBSmallEntry ) // { // TamingBOBSmallEntry e = (TamingBOBSmallEntry)obj; // int y = 96 + (tableIndex++ * 32); // if ( canDrop ) // AddButton( 35, y + 2, 5602, 5606, 4 + (i * 2), GumpButtonType.Reply, 0 ); // if ( canDrop || (canBuy && e.Price > 0) ) // { // AddButton( 579, y + 2, 2117, 2118, 5 + (i * 2), GumpButtonType.Reply, 0 ); // AddLabel( 495, y, 1152, e.Price.ToString() ); // } // AddHtmlLocalized( 61, y, 50, 32, 1062224, LabelColor, false, false ); // Small // string s = e.AnimalName; // int capsbreak = s.IndexOfAny("ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray(),1); // if( capsbreak > -1 ) // { // string secondhalf = s.Substring( capsbreak ); // string firsthalf = s.Substring(0, capsbreak ); // string newname = firsthalf + " " + secondhalf; // AddLabel( 103, y, 1149, newname.ToString() ); // } // else // { // AddLabel( 103, y, 1149, e.AnimalName.ToString() ); // } // object name = GetMaterialName( e.Type ); // 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 ) ); // } // } }
public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 2) { PlayerVendor pv = m_Book.RootParent as PlayerVendor; if (pv != null) { int price = 0; VendorItem vi = pv.GetVendorItem(m_Book); if (vi != null && !vi.IsForSale) { price = m_Recipe.Price; } if (price != m_Price) { pv.SayTo(m_From, 1150158); // The price of the selected item has been changed from the value you confirmed. You must select and confirm the purchase again at the new price in order to buy it. m_Book.Using = false; } else if (m_Recipe.Amount == 0 || price == 0) { pv.SayTo(m_From, 1158821); // The recipe selected is not available. m_Book.Using = false; } else { Item item = new RecipeScroll(m_Recipe.RecipeID); pv.Say(m_From.Name); Container pack = m_From.Backpack; if ((pack != null && pack.ConsumeTotal(typeof(Gold), price)) || Banker.Withdraw(m_From, price)) { m_Book.Recipes.ForEach(x => { if (x.RecipeID == m_Recipe.RecipeID) { x.Amount = x.Amount - 1; } }); m_Book.InvalidateProperties(); pv.HoldGold += price; if (m_From.AddToBackpack(item)) { m_From.SendLocalizedMessage(1158820); // The recipe has been placed in your backpack. } else { pv.SayTo(m_From, 503204); // You do not have room in your backpack for this. } m_From.SendGump(new RecipeBookGump(m_From, m_Book)); } else { pv.SayTo(m_From, 503205); // You cannot afford this item. item.Delete(); m_Book.Using = false; } } } else { m_Book.Using = false; if (pv == null) { m_From.SendLocalizedMessage(1158821); // The recipe selected is not available. } else { pv.SayTo(m_From, 1158821); // The recipe selected is not available. } } } else { m_Book.Using = false; m_From.SendLocalizedMessage(503207); // Cancelled purchase. } }
public static List <SearchItem> DoSearch(SearchCriteria criteria) { if (criteria == null || PlayerVendor.PlayerVendors == null || PlayerVendor.PlayerVendors.Count == 0) { return(null); } List <SearchItem> list = new List <SearchItem>(); SearchDetail first = null; for (var index = 0; index < criteria.Details.Count; index++) { var d = criteria.Details[index]; if (d.Attribute is Misc misc && misc == Misc.ExcludeFel) { first = d; break; } } bool excludefel = first != null; for (var i = 0; i < PlayerVendor.PlayerVendors.Count; i++) { PlayerVendor pv = PlayerVendor.PlayerVendors[i]; if (pv.Map != Map.Internal && pv.Map != null && pv.Backpack != null && pv.VendorSearch && pv.Backpack.Items.Count > 0 && (!excludefel || pv.Map != Map.Felucca)) { List <Item> items = GetItems(pv); for (var index = 0; index < items.Count; index++) { Item item = items[index]; VendorItem vendorItem = pv.GetVendorItem(item); int price = 0; bool isChild = false; if (vendorItem != null) { price = vendorItem.Price; } else if (item.Parent is Container parent) { vendorItem = GetParentVendorItem(pv, parent); if (vendorItem != null) { isChild = true; price = vendorItem.Price; } } if (price > 0 && CheckMatch(item, price, criteria)) { list.Add(new SearchItem(pv, item, price, isChild)); } } ColUtility.Free(items); } } switch (criteria.SortBy) { case SortBy.LowToHigh: list = list.OrderBy(vi => vi.Price).ToList(); break; case SortBy.HighToLow: list = list.OrderBy(vi => - vi.Price).ToList(); break; } return(list); }
public PowerScrollBookGump(PlayerMobile from, PowerScrollBook book, int page, ArrayList list) : base(12, 24) { from.CloseGump(typeof(PowerScrollBookGump)); from.CloseGump(typeof(PowerScrollFilterGump)); 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 PowerScrollBookEntry) { ++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); AddLabel(137, 64, 1149, @"Skill Name"); AddLabel(331, 64, 1149, @"Skill Value"); AddButton(35, 32, 4005, 4007, 1, GumpButtonType.Reply, 0); AddHtmlLocalized(70, 32, 200, 32, 1062476, LabelColor, false, false); PowerScrollFilter f = (book.Filter); if (f.IsDefault) { AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062475, 16927, false, false); } else if (from.UseOwnFilter) { AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062451, 16927, false, false); } else { AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062230, 16927, false, false); } AddButton(375, 416, 4017, 4018, 0, GumpButtonType.Reply, 0); AddHtmlLocalized(410, 416, 120, 20, 1011441, LabelColor, false, false); if (canDrop) { AddHtmlLocalized(26, 64, 50, 32, 1062212, LabelColor, false, false); } if (canPrice) { AddHtmlLocalized(516, 64, 200, 32, 1062218, LabelColor, false, false); if (canBuy) { AddHtmlLocalized(576, 64, 200, 32, 1062219, LabelColor, false, false); } else { AddHtmlLocalized(576, 64, 200, 32, 1062227, LabelColor, 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); } if (GetIndexForPage(page + 1) < list.Count) { AddButton(225, 416, 4005, 4007, 3, GumpButtonType.Reply, 0); AddHtmlLocalized(260, 416, 150, 20, 1011066, LabelColor, false, false); } for (int i = index; i < (index + count) && i >= 0 && i < list.Count; ++i) { object obj = list[i]; if (!CheckFilter(obj)) { continue; } if (obj is PowerScrollBookEntry) { PowerScrollBookEntry e = (PowerScrollBookEntry)obj; int y = 96 + (tableIndex++ *32); if (canDrop) { AddButton(35, y + 2, 5602, 5606, 4 + (i * 2), GumpButtonType.Reply, 0); } if (canDrop || (canBuy && e.Price > 0)) { AddButton(579, y + 2, 2117, 2118, 5 + (i * 2), GumpButtonType.Reply, 0); AddLabel(495, y, 1152, e.Price.ToString("N0")); } AddLabel(103, y, 1149, from.Skills[e.Skill].Name); AddLabel(350, y, 1152, e.SkillValue.ToString()); } } }
public override void OnResponse(Server.Network.NetState sender, RelayInfo info) { int index = info.ButtonID; switch (index) { case 0: { break; } case 1: { m_From.SendGump(new PowerScrollFilterGump(m_From, m_Book)); break; } case 2: { if (m_Page > 0) { m_From.SendGump(new PowerScrollBookGump(m_From, m_Book, m_Page - 1, m_List)); } return; } case 3: { if (GetIndexForPage(m_Page + 1) < m_List.Count) { m_From.SendGump(new PowerScrollBookGump(m_From, m_Book, m_Page + 1, m_List)); } break; } default: { bool canDrop = m_Book.IsChildOf(m_From.Backpack); bool canPrice = canDrop || (m_Book.RootParent is PlayerVendor); index -= 4; 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); break; } if (type == 0) { if (m_Book.IsChildOf(m_From.Backpack)) { Item item = Reconstruct(obj); if (item != null) { m_From.AddToBackpack(item); m_From.SendMessage("The power scroll has been placed in your backpack."); m_Book.Entries.Remove(obj); m_Book.InvalidateProperties(); if (m_Book.Entries.Count > 0) { m_From.SendGump(new PowerScrollBookGump(m_From, m_Book, 0, null)); } else { m_From.SendLocalizedMessage(1062381); } } else { m_From.SendMessage("Internal error. The power scroll could not be reconstructed."); } } } else { if (m_Book.IsChildOf(m_From.Backpack)) { m_From.Prompt = new SetPricePrompt(m_Book, obj, m_Page, m_List); m_From.SendMessage("Type in a price for the power scroll:"); } else if (m_Book.RootParent is PlayerVendor) { PlayerVendor pv = (PlayerVendor)m_Book.RootParent; VendorItem vi = pv.GetVendorItem(m_Book); int price = 0; if (vi != null && !vi.IsForSale) { if (obj is PowerScrollBookEntry) { price = ((PowerScrollBookEntry)obj).Price; } } if (price == 0) { m_From.SendLocalizedMessage(1062382); } else { m_From.SendGump(new PowerScrollBuyGump(m_From, m_Book, obj, price)); } } } break; } } }
private static void TempCommand_OnCommand(CommandEventArgs e) { (e.Mobile as BaseCreature).MinTameSkill = 100; List <Item> items = new List <Item>(); int vendors = 0; using (StreamWriter op = new StreamWriter("vendorlist.txt")) { try { foreach (Mobile m in World.Mobiles.Values) { if (!(m is PlayerVendor)) { continue; } PlayerVendor vendor = m as PlayerVendor; if (vendor.Owner != null) { vendors++; foreach (Item item in vendor.Backpack.Items) { items.Add(item); } } } for (int i = 0; i < items.Count; ++i) { Item item = items[i]; PlayerVendor pv = item.RootParent as PlayerVendor; if (pv != null) { VendorItem vi = pv.GetVendorItem(item); op.Write(item.ItemID.ToString()); op.Write(","); op.Write(item.Hue); op.Write(","); op.Write(item.Name ?? CliLoc.LocToString(item.LabelNumber)); op.Write(","); op.Write(item.Amount); op.Write(","); if (vi != null) { op.Write(vi.Description); op.Write(","); op.Write(vi.Created); op.Write(","); op.Write(vi.FormattedPrice); } op.WriteLine(); if (item is BaseContainer) { foreach (Item it in item.Items) { items.Add(it); } } } } } catch (Exception exception) { Console.WriteLine(exception); //throw new ArgumentException(); } } World.Broadcast(29, true, vendors + "vendors"); World.Broadcast(29, true, items.Count + "items"); }
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 BOBFilterGump(m_From, m_Book)); break; } case 2: // Previous page { if (m_Page > 0) { m_From.SendGump(new BOBGump(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 BOBGump(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 BOBGump(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 BOBGump(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 BODBuyGump(m_From, m_Book, obj, m_Page, price)); } else { m_From.SendLocalizedMessage(1062381); // The book is emptz } } } } } break; } } }
public RecipeBookGump(Mobile from, RecipeBook book, int page, List <RecipeScrollDefinition> list) : base(12, 24) { from.CloseGump(typeof(RecipeBookGump)); from.CloseGump(typeof(RecipeScrollFilterGump)); m_Book = book; m_Page = page; if (list == null) { list = new List <RecipeScrollDefinition>(); m_Book.Recipes.ForEach(x => { if (CheckFilter(x)) { list.Add(x); } }); } m_List = list; int index = GetIndexForPage(page); int count = GetCountForIndex(index); int tableIndex = 0; PlayerVendor pv = book.RootParent as PlayerVendor; bool canLocked = book.IsLockedDown; bool canDrop = book.IsChildOf(from.Backpack); bool canBuy = (pv != null); bool canPrice = (canDrop || canBuy || canLocked); 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); list = list.OrderBy(x => x.ID).ToList(); for (int i = index; i < (index + count) && i >= 0 && i < list.Count; ++i) { var recipe = list[i]; if (!CheckFilter(recipe)) { continue; } AddImageTiled(24, 94 + (tableIndex * 32), canPrice ? 573 : 489, 2, 2624); ++tableIndex; } AddAlphaRegion(18, 20, width - 17, 420); AddImage(0, 0, 10460); AddImage(width - 15, 5, 10460); AddImage(0, 429, 10460); AddImage(width - 15, 429, 10460); AddHtmlLocalized(266, 32, 200, 32, 1158810, LabelColor, false, false); // Recipe Book AddHtmlLocalized(147, 64, 200, 32, 1062214, LabelColor, false, false); // Item AddHtmlLocalized(246, 64, 200, 32, 1158814, LabelColor, false, false); // Expansion AddHtmlLocalized(336, 64, 200, 32, 1158816, LabelColor, false, false); // Crafting AddHtmlLocalized(429, 64, 100, 32, 1062217, LabelColor, false, false); // Amount AddHtmlLocalized(70, 32, 200, 32, 1062476, LabelColor, false, false); // Set Filter AddButton(35, 32, 4005, 4007, 1, GumpButtonType.Reply, 0); RecipeScrollFilter f = book.Filter; if (f.IsDefault) { AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062475, 16927, false, false); // Using No Filter } else if (((PlayerMobile)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 } } 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) { var recipe = list[i]; if (!CheckFilter(recipe) || !Recipe.Recipes.ContainsKey(recipe.RecipeID)) { continue; } int y = 96 + (tableIndex++ *32); if (recipe.Amount > 0 && (canDrop || canLocked)) { AddButton(35, y + 2, 5602, 5606, 4 + (i * 2), GumpButtonType.Reply, 0); } AddLabel(61, y, 0x480, string.Format("{0}", recipe.ID)); AddHtmlLocalized(103, y, 130, 32, Recipe.Recipes[recipe.RecipeID].TextDefinition.Number, "#103221", 0xFFFFFF, false, false); // ~1_val~ AddLabel(235, y, 0x480, GetExpansion(recipe.Expansion)); AddHtmlLocalized(316, y, 100, 20, GetSkillName(recipe.Skill), "#104409", 0xFFFFFF, false, false); // ~1_val~ AddLabel(421, y, 0x480, recipe.Amount.ToString()); if (canDrop || (canBuy && recipe.Price > 0)) { AddButton(579, y + 2, 2117, 2118, 5 + (i * 2), GumpButtonType.Reply, 0); AddLabel(495, y, 1152, recipe.Price.ToString("N0")); } } }
public BOBGump(PlayerMobile from, BulkOrderBook book, int page, ArrayList list) : base(12, 24) { from.CloseGump(typeof(BOBGump)); from.CloseGump(typeof(BOBFilterGump)); 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)); } } }
public override void OnResponse(NetState sender, RelayInfo info) { int index = info.ButtonID; switch (index) { case 0: { break; } case 1: { m_From.SendGump(new RecipeScrollFilterGump(m_From, m_Book)); break; } case 2: { if (m_Page > 0) { m_From.SendGump(new RecipeBookGump(m_From, m_Book, m_Page - 1, m_List)); } return; } case 3: { if (GetIndexForPage(m_Page + 1) < m_List.Count) { m_From.SendGump(new RecipeBookGump(m_From, m_Book, m_Page + 1, m_List)); } break; } default: { bool canDrop = m_Book.IsChildOf(m_From.Backpack); bool canPrice = canDrop || (m_Book.RootParent is PlayerVendor); index -= 4; int type = index % 2; index /= 2; if (index < 0 || index >= m_List.Count) { break; } var recipe = m_List[index]; if (type == 0) { if (m_Book.IsChildOf(m_From.Backpack)) { if (recipe.Amount == 0) { m_From.SendLocalizedMessage(1158821); // The recipe selected is not available. break; } Item item = new RecipeScroll(recipe.RecipeID); if (m_From.AddToBackpack(item)) { m_Book.Recipes.ForEach(x => { if (x.RecipeID == recipe.RecipeID) { x.Amount = x.Amount - 1; } }); m_Book.InvalidateProperties(); m_From.SendLocalizedMessage(1158820); // The recipe has been placed in your backpack. m_From.SendGump(new RecipeBookGump(m_From, m_Book, m_Page, null)); } else { item.Delete(); m_From.SendLocalizedMessage(1158819); // There is not enough room in your backpack for the recipe. } } } else { if (m_Book.IsChildOf(m_From.Backpack)) { m_From.Prompt = new SetPricePrompt(m_Book, recipe, 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); int price = 0; if (vi != null && !vi.IsForSale) { price = recipe.Price; } if (price == 0) { m_From.SendLocalizedMessage(1062382); } else { m_From.SendGump(new RecipeScrollBuyGump(m_From, m_Book, recipe, price)); } } } break; } } }