public TamingBOBFilterGump(PlayerMobile from, TamingBulkOrderBook book) : base(12, 24) { from.CloseGump(typeof(TamingBOBGump)); from.CloseGump(typeof(TamingBOBFilterGump)); m_From = from; m_Book = book; AnimalBODModule module = from.GetModule(typeof(AnimalBODModule)) as AnimalBODModule ?? new AnimalBODModule(from); TamingBOBFilter f = (from.UseOwnFilter ? module.TamingBOBFilter : m_Book.Filter); AddPage(0); AddBackground(10, 10, 600, 439, 5054); AddImageTiled(18, 20, 583, 420, 2624); AddAlphaRegion(18, 20, 583, 420); AddImage(5, 5, 10460); AddImage(585, 5, 10460); AddImage(5, 424, 10460); AddImage(585, 424, 10460); AddHtmlLocalized(270, 32, 200, 32, 1062223, LabelColor, false, false); // Filter Preference AddHtmlLocalized(26, 258, 120, 32, 1062228, LabelColor, false, false); // Bulk Order Type AddFilterList(25, 288, m_XOffsets_Type, 40, m_TypeFilters, m_XWidths_Small, f.Type, 0); AddHtmlLocalized(26, 320, 120, 32, 1062217, LabelColor, false, false); // Amount AddFilterList(25, 352, m_XOffsets_Amount, 40, m_AmountFilters, m_XWidths_Small, f.Quantity, 1); AddHtmlLocalized(75, 416, 120, 32, 1062477, (from.UseOwnFilter ? LabelColor : 16927), false, false); // Set Book Filter AddButton(40, 416, 4005, 4007, 1, GumpButtonType.Reply, 0); AddHtmlLocalized(235, 416, 120, 32, 1062478, (from.UseOwnFilter ? 16927 : LabelColor), false, false); // Set Your Filter AddButton(200, 416, 4005, 4007, 2, GumpButtonType.Reply, 0); AddHtmlLocalized(405, 416, 120, 32, 1062231, LabelColor, false, false); // Clear Filter AddButton(370, 416, 4005, 4007, 3, GumpButtonType.Reply, 0); AddHtmlLocalized(540, 416, 50, 32, 1011046, LabelColor, false, false); // APPLY AddButton(505, 416, 4017, 4018, 0, GumpButtonType.Reply, 0); }
public bool CheckFilter(int amountMax, bool isLarge) { AnimalBODModule module = m_From.GetModule(typeof(AnimalBODModule)) as AnimalBODModule ?? new AnimalBODModule(m_From); TamingBOBFilter f = (m_From.UseOwnFilter ? module.TamingBOBFilter : m_Book.Filter); //TamingBOBFilter f = ( m_From.UseOwnFilter ? m_From.TamingBOBFilter : m_Book.Filter ); if (f.IsDefault) { return(true); } if (f.Quantity == 1 && amountMax != 10) { return(false); } else if (f.Quantity == 2 && amountMax != 15) { return(false); } else if (f.Quantity == 3 && amountMax != 20) { return(false); } if (f.Type == 1 && isLarge) { return(false); } else if (f.Type == 2 && !isLarge) { return(false); } return(true); }
public override TimeSpan GetNextBulkOrder(Mobile from) { AnimalBODModule module = from.GetModule(typeof(AnimalBODModule)) as AnimalBODModule ?? new AnimalBODModule(from); return(module.NextTamingBulkOrder); }
public override void OnResponse(Server.Network.NetState sender, RelayInfo info) { AnimalBODModule module = m_From.GetModule(typeof(AnimalBODModule)) as AnimalBODModule ?? new AnimalBODModule(m_From); TamingBOBFilter f = (m_From.UseOwnFilter ? module.TamingBOBFilter : m_Book.Filter); int index = info.ButtonID; switch (index) { case 0: // Apply { m_From.SendGump(new TamingBOBGump(m_From, m_Book)); break; } case 1: // Set Book Filter { m_From.UseOwnFilter = false; m_From.SendGump(new TamingBOBFilterGump(m_From, m_Book)); break; } case 2: // Set Your Filter { m_From.UseOwnFilter = true; m_From.SendGump(new TamingBOBFilterGump(m_From, m_Book)); break; } case 3: // Clear Filter { f.Clear(); m_From.SendGump(new TamingBOBFilterGump(m_From, m_Book)); break; } default: { index -= 4; int type = index % 2; //index -= type; index /= 4; if (type >= 0 && type < m_Filters.Length) { int[,] filters = m_Filters[type]; if (index >= 0 && index < filters.GetLength(0)) { if (filters[index, 0] == 0) { break; } switch (type) { case 0: f.Type = filters[index, 1]; break; case 1: f.Quantity = filters[index, 1]; break; } m_From.SendGump(new TamingBOBFilterGump(m_From, m_Book)); } } break; } } }
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 AnimalBODModule module = from.GetModule(typeof(AnimalBODModule)) as AnimalBODModule ?? new AnimalBODModule(from); TamingBOBFilter f = (from.UseOwnFilter ? module.TamingBOBFilter : m_Book.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)); } } }