- ServUO Version
- Publish 57
- Ultima Expansion
- Endless Journey
Ok so.. been working on this tonight and have the code in for the gump to display resources and it looks like it's working okay, however I have 2 issues I am unsure how to solve. The first is Carpentry and Fletching appear to be pulling the same BODs, I don't think that's correct but I could be mistaken.. Second the gump mostly auto sized itself with the new additions but I think I went beyond it's limits and am not sure where to change it in the code to fix it.. anyways here is the code and what it looks like in game. I need to make it a tiny bit wider and longer
BOBGump
BOBFilterGump
BOBGump
C#:
using System;
using System.Collections;
using Server.Gumps;
using Server.Items;
using Server.Mobiles;
using Server.Prompts;
namespace Server.Engines.BulkOrders
{
public class BOBGump : Gump
{
private const int LabelColor = 0x7FFF;
private readonly PlayerMobile m_From;
private readonly BulkOrderBook m_Book;
private readonly ArrayList m_List;
private int m_Page;
public BOBGump(PlayerMobile from, BulkOrderBook book)
: this(from, book, 0, null)
{
}
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, 70, 32, 1062213, LabelColor, false, false); // Type
AddHtmlLocalized(147, 64, 70, 32, 1062214, LabelColor, false, false); // Item
AddHtmlLocalized(246, 64, 70, 32, 1062215, LabelColor, false, false); // Quality
AddHtmlLocalized(336, 64, 70, 32, 1062216, LabelColor, false, false); // Material
AddHtmlLocalized(429, 64, 70, 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 Item Reconstruct(object obj)
{
Item item = null;
if (obj is BOBLargeEntry)
item = ((BOBLargeEntry)obj).Reconstruct();
else if (obj is BOBSmallEntry)
item = ((BOBSmallEntry)obj).Reconstruct();
return item;
}
public bool CheckFilter(object obj)
{
if (obj is BOBLargeEntry)
{
BOBLargeEntry e = (BOBLargeEntry)obj;
return CheckFilter(e.Material, e.AmountMax, true, e.RequireExceptional, e.DeedType, (e.Entries.Length > 0 ? e.Entries[0].ItemType : null));
}
else if (obj is BOBSmallEntry)
{
BOBSmallEntry e = (BOBSmallEntry)obj;
return CheckFilter(e.Material, e.AmountMax, false, e.RequireExceptional, e.DeedType, e.ItemType);
}
return false;
}
public bool CheckFilter(BulkMaterialType mat, int amountMax, bool isLarge, bool reqExc, BODType deedType, Type itemType)
{
BOBFilter f = (m_From.UseOwnFilter ? m_From.BOBFilter : m_Book.Filter);
if (f.IsDefault)
return true;
if (f.Quality == 1 && reqExc)
return false;
else if (f.Quality == 2 && !reqExc)
return false;
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;
switch ( f.Material )
{
default:
case 0: return true;
case 1: return (deedType == BODType.Smith);
case 2: return (deedType == BODType.Tailor);
case 3: return (deedType == BODType.Tinkering);
case 4: return (deedType == BODType.Carpentry);
case 5: return (deedType == BODType.Fletching);
case 6: return (deedType == BODType.Alchemy);
case 7: return (deedType == BODType.Inscription);
case 8: return (deedType == BODType.Cooking);
// Smith
case 9: return (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Iron);
case 10: return (mat == BulkMaterialType.DullCopper);
case 11: return (mat == BulkMaterialType.ShadowIron);
case 12: return (mat == BulkMaterialType.Copper);
case 13: return (mat == BulkMaterialType.Bronze);
case 14: return (mat == BulkMaterialType.Gold);
case 15: return (mat == BulkMaterialType.Agapite);
case 16: return (mat == BulkMaterialType.Verite);
case 17: return (mat == BulkMaterialType.Valorite);
case 18: return (mat == BulkMaterialType.Blaze);
case 19: return (mat == BulkMaterialType.Ice);
case 20: return (mat == BulkMaterialType.Toxic);
case 21: return (mat == BulkMaterialType.Electrum);
case 22: return (mat == BulkMaterialType.Platinum);
// Tailor
case 23: return (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Cloth);
case 24: return (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather);
case 25: return (mat == BulkMaterialType.Spined);
case 26: return (mat == BulkMaterialType.Horned);
case 27: return (mat == BulkMaterialType.Barbed);
case 28: return (mat == BulkMaterialType.Polar);
case 29: return (mat == BulkMaterialType.Synthetic);
case 30: return (mat == BulkMaterialType.BlazeL);
case 31: return (mat == BulkMaterialType.Daemonic);
case 32: return (mat == BulkMaterialType.Shadow);
case 33: return (mat == BulkMaterialType.Frost);
case 34: return (mat == BulkMaterialType.Ethereal);
// Tinkering
case 35: return (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Iron);
case 36: return (mat == BulkMaterialType.DullCopper);
case 37: return (mat == BulkMaterialType.ShadowIron);
case 38: return (mat == BulkMaterialType.Copper);
case 39: return (mat == BulkMaterialType.Bronze);
case 40: return (mat == BulkMaterialType.Gold);
case 41: return (mat == BulkMaterialType.Agapite);
case 42: return (mat == BulkMaterialType.Verite);
case 43: return (mat == BulkMaterialType.Valorite);
case 44: return (mat == BulkMaterialType.Blaze);
case 45: return (mat == BulkMaterialType.Ice);
case 46: return (mat == BulkMaterialType.Toxic);
case 47: return (mat == BulkMaterialType.Electrum);
case 48: return (mat == BulkMaterialType.Platinum);
// Carpentry
case 49: return (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Wood);
case 50: return (mat == BulkMaterialType.OakWood);
case 51: return (mat == BulkMaterialType.AshWood);
case 52: return (mat == BulkMaterialType.YewWood);
case 53: return (mat == BulkMaterialType.Bloodwood);
case 54: return (mat == BulkMaterialType.Heartwood);
case 55: return (mat == BulkMaterialType.Frostwood);
case 56: return (mat == BulkMaterialType.Ebony);
case 57: return (mat == BulkMaterialType.Bamboo);
case 58: return (mat == BulkMaterialType.PurpleHeart);
case 59: return (mat == BulkMaterialType.Redwood);
case 60: return (mat == BulkMaterialType.Petrified);
// Fletching
case 61: return (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Wood);
case 62: return (mat == BulkMaterialType.OakWood);
case 63: return (mat == BulkMaterialType.AshWood);
case 64: return (mat == BulkMaterialType.YewWood);
case 65: return (mat == BulkMaterialType.Bloodwood);
case 66: return (mat == BulkMaterialType.Heartwood);
case 67: return (mat == BulkMaterialType.Frostwood);
case 68: return (mat == BulkMaterialType.Ebony);
case 69: return (mat == BulkMaterialType.Bamboo);
case 70: return (mat == BulkMaterialType.PurpleHeart);
case 71: return (mat == BulkMaterialType.Redwood);
case 72: return (mat == BulkMaterialType.Petrified);
}
if (BulkOrderSystem.NewSystemEnabled)
{
switch (f.Material)
{
default:
case 0:
return true;
case 1:
return deedType == BODType.Smith;
case 2:
return deedType == BODType.Tailor;
case 3:
return deedType == BODType.Tinkering;
case 4:
return deedType == BODType.Carpentry;
case 5:
return deedType == BODType.Fletching;
case 6:
return deedType == BODType.Alchemy;
case 7:
return deedType == BODType.Inscription;
case 8:
return deedType == BODType.Cooking;
case 9:
return (mat == BulkMaterialType.None && deedType == BODType.Smith);
case 10:
return (mat == BulkMaterialType.DullCopper && deedType == BODType.Smith);
case 11:
return (mat == BulkMaterialType.ShadowIron && deedType == BODType.Smith);
case 12:
return (mat == BulkMaterialType.Copper && deedType == BODType.Smith);
case 13:
return (mat == BulkMaterialType.Bronze && deedType == BODType.Smith);
case 14:
return (mat == BulkMaterialType.Gold && deedType == BODType.Smith);
case 15:
return (mat == BulkMaterialType.Agapite && deedType == BODType.Smith);
case 16:
return (mat == BulkMaterialType.Verite && deedType == BODType.Smith);
case 17:
return (mat == BulkMaterialType.Valorite && deedType == BODType.Smith);
case 18:
return (mat == BulkMaterialType.Blaze && deedType == BODType.Smith);
case 19:
return (mat == BulkMaterialType.Ice && deedType == BODType.Smith);
case 20:
return (mat == BulkMaterialType.Toxic && deedType == BODType.Smith);
case 21:
return (mat == BulkMaterialType.Electrum && deedType == BODType.Smith);
case 22:
return (mat == BulkMaterialType.Platinum && deedType == BODType.Smith);
case 23: // Tailoring
return (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Cloth);
case 24:
return (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather);
case 25:
return (mat == BulkMaterialType.Spined && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather);
case 26:
return (mat == BulkMaterialType.Horned && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather);
case 27:
return (mat == BulkMaterialType.Barbed && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather);
case 28:
return (mat == BulkMaterialType.Polar && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather);
case 29:
return (mat == BulkMaterialType.Synthetic && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather);
case 30:
return (mat == BulkMaterialType.BlazeL && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather);
case 31:
return (mat == BulkMaterialType.Daemonic && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather);
case 32:
return (mat == BulkMaterialType.Shadow && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather);
case 33:
return (mat == BulkMaterialType.Frost && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather);
case 34:
return (mat == BulkMaterialType.Ethereal && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather);
case 35: // Tinkering
return (mat == BulkMaterialType.None && deedType == BODType.Tinkering);
case 36:
return (mat == BulkMaterialType.DullCopper && deedType == BODType.Tinkering);
case 37:
return (mat == BulkMaterialType.ShadowIron && deedType == BODType.Tinkering);
case 38:
return (mat == BulkMaterialType.Copper && deedType == BODType.Tinkering);
case 39:
return (mat == BulkMaterialType.Bronze && deedType == BODType.Tinkering);
case 40:
return (mat == BulkMaterialType.Gold && deedType == BODType.Tinkering);
case 41:
return (mat == BulkMaterialType.Agapite && deedType == BODType.Tinkering);
case 42:
return (mat == BulkMaterialType.Verite && deedType == BODType.Tinkering);
case 43:
return (mat == BulkMaterialType.Valorite && deedType == BODType.Tinkering);
case 44:
return (mat == BulkMaterialType.Blaze && deedType == BODType.Tinkering);
case 45:
return (mat == BulkMaterialType.Ice && deedType == BODType.Tinkering);
case 46:
return (mat == BulkMaterialType.Toxic && deedType == BODType.Tinkering);
case 47:
return (mat == BulkMaterialType.Electrum && deedType == BODType.Tinkering);
case 48:
return (mat == BulkMaterialType.Platinum && deedType == BODType.Tinkering);
case 49: // Carpentry
return (mat == BulkMaterialType.None && deedType == BODType.Carpentry);
case 50:
return (mat == BulkMaterialType.OakWood && deedType == BODType.Carpentry);
case 51:
return (mat == BulkMaterialType.AshWood && deedType == BODType.Carpentry);
case 52:
return (mat == BulkMaterialType.YewWood && deedType == BODType.Carpentry);
case 53:
return (mat == BulkMaterialType.Bloodwood && deedType == BODType.Carpentry);
case 54:
return (mat == BulkMaterialType.Heartwood && deedType == BODType.Carpentry);
case 55:
return (mat == BulkMaterialType.Frostwood && deedType == BODType.Carpentry);
case 56:
return (mat == BulkMaterialType.Ebony && deedType == BODType.Carpentry);
case 57:
return (mat == BulkMaterialType.Bamboo && deedType == BODType.Carpentry);
case 58:
return (mat == BulkMaterialType.PurpleHeart && deedType == BODType.Carpentry);
case 59:
return (mat == BulkMaterialType.Redwood && deedType == BODType.Carpentry);
case 60:
return (mat == BulkMaterialType.Petrified && deedType == BODType.Carpentry);
case 61: // Fletching
return (mat == BulkMaterialType.None && deedType == BODType.Fletching);
case 62:
return (mat == BulkMaterialType.OakWood && deedType == BODType.Fletching);
case 63:
return (mat == BulkMaterialType.AshWood && deedType == BODType.Fletching);
case 64:
return (mat == BulkMaterialType.YewWood && deedType == BODType.Fletching);
case 65:
return (mat == BulkMaterialType.Bloodwood && deedType == BODType.Fletching);
case 66:
return (mat == BulkMaterialType.Heartwood && deedType == BODType.Fletching);
case 67:
return (mat == BulkMaterialType.Frostwood && deedType == BODType.Fletching);
case 68:
return (mat == BulkMaterialType.Ebony && deedType == BODType.Fletching);
case 69:
return (mat == BulkMaterialType.Bamboo && deedType == BODType.Fletching);
case 70:
return (mat == BulkMaterialType.PurpleHeart && deedType == BODType.Fletching);
case 71:
return (mat == BulkMaterialType.Redwood && deedType == BODType.Fletching);
case 72:
return (mat == BulkMaterialType.Petrified && deedType == BODType.Fletching);
}
}
else
{
switch (f.Material)
{
default:
case 0: return true;
case 1: return (deedType == BODType.Smith);
case 2: return (deedType == BODType.Tailor);
case 3: return (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Iron);
case 4: return (mat == BulkMaterialType.DullCopper);
case 5: return (mat == BulkMaterialType.ShadowIron);
case 6: return (mat == BulkMaterialType.Copper);
case 7: return (mat == BulkMaterialType.Bronze);
case 8: return (mat == BulkMaterialType.Gold);
case 9: return (mat == BulkMaterialType.Agapite);
case 10: return (mat == BulkMaterialType.Verite);
case 11: return (mat == BulkMaterialType.Valorite);
case 12: return (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Cloth);
case 13: return (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather);
case 14: return (mat == BulkMaterialType.Spined);
case 15: return (mat == BulkMaterialType.Horned);
case 16: return (mat == BulkMaterialType.Barbed);
}
}
}
public int GetIndexForPage(int page)
{
int index = 0;
while (page-- > 0)
index += GetCountForIndex(index);
return index;
}
public int GetCountForIndex(int index)
{
int slots = 0;
int count = 0;
ArrayList list = m_List;
for (int i = index; i >= 0 && i < list.Count; ++i)
{
object obj = list[i];
if (CheckFilter(obj))
{
int add;
if (obj is BOBLargeEntry)
add = ((BOBLargeEntry)obj).Entries.Length;
else
add = 1;
if ((slots + add) > 10)
break;
slots += add;
}
++count;
}
return count;
}
public int GetPageForIndex(int index, int sizeDropped)
{
if (index <= 0)
return 0;
int count = 0;
int add = 0;
int page = 0;
ArrayList list = m_List;
int i;
object obj;
for (i = 0; (i < index) && (i < list.Count); i++)
{
obj = list[i];
if (CheckFilter(obj))
{
if (obj is BOBLargeEntry)
add = ((BOBLargeEntry)obj).Entries.Length;
else
add = 1;
count += add;
if (count > 10)
{
page++;
count = add;
}
}
}
/* now we are on the page of the bod preceeding the dropped one.
* next step: checking whether we have to remain where we are.
* The counter i needs to be incremented as the bod to this very moment
* has not yet been removed from m_List */
i++;
/* if, for instance, a big bod of size 6 has been removed, smaller bods
* might fall back into this page. Depending on their sizes, the page eeds
* to be adjusted accordingly. This is done now.
*/
if (count + sizeDropped > 10)
{
while ((i < list.Count) && (count <= 10))
{
obj = list[i];
if (CheckFilter(obj))
{
if (obj is BOBLargeEntry)
count += ((BOBLargeEntry)obj).Entries.Length;
else
count += 1;
}
i++;
}
if (count > 10)
page++;
}
return page;
}
public object GetMaterialName(BulkMaterialType mat, BODType type, Type itemType)
{
switch ( type )
{
case BODType.Tinkering:
case BODType.Smith:
{
if (type == BODType.Tinkering && mat == BulkMaterialType.None && BGTClassifier.Classify(type, itemType) == BulkGenericType.Wood)
{
return 1079435;
}
else
{
switch (mat)
{
case BulkMaterialType.None:
return 1062226;
case BulkMaterialType.DullCopper:
return 1018332;
case BulkMaterialType.ShadowIron:
return 1018333;
case BulkMaterialType.Copper:
return 1018334;
case BulkMaterialType.Bronze:
return 1018335;
case BulkMaterialType.Gold:
return 1018336;
case BulkMaterialType.Agapite:
return 1018337;
case BulkMaterialType.Verite:
return 1018338;
case BulkMaterialType.Valorite:
return 1018339;
//daat9 OWLTR start - custom resources
case BulkMaterialType.Blaze:
return "Blaze";
case BulkMaterialType.Ice:
return "Ice";
case BulkMaterialType.Toxic:
return "Toxic";
case BulkMaterialType.Electrum:
return "Electrum";
case BulkMaterialType.Platinum:
return "Platinum";
//daat9 OWLTR end - custom resources
}
}
break;
}
case BODType.Tailor:
{
switch ( mat )
{
case BulkMaterialType.None:
{
if (itemType.IsSubclassOf(typeof(BaseArmor)) || itemType.IsSubclassOf(typeof(BaseShoes)))
return 1062235;
return 1044286;
}
case BulkMaterialType.Spined:
return 1062236;
case BulkMaterialType.Horned:
return 1062237;
case BulkMaterialType.Barbed:
return 1062238;
//daat9 OWLTR start - custom resources
case BulkMaterialType.Polar:
return "Polar";
case BulkMaterialType.Synthetic:
return "Synthetic";
case BulkMaterialType.BlazeL:
return "Blaze";
case BulkMaterialType.Daemonic:
return "Daemonic";
case BulkMaterialType.Shadow:
return "Shadow";
case BulkMaterialType.Frost:
return "Frost";
case BulkMaterialType.Ethereal:
return "Ethereal";
//daat9 OWLTR end - custom resources
}
break;
}
case BODType.Carpentry:
case BODType.Fletching:
{
if (mat == BulkMaterialType.None)
return 1079435;
switch (mat)
{
default:
case BulkMaterialType.OakWood: return 1071428;
case BulkMaterialType.AshWood: return 1071429;
case BulkMaterialType.YewWood: return 1071430;
case BulkMaterialType.Heartwood: return 1071432;
case BulkMaterialType.Bloodwood: return 1071431;
case BulkMaterialType.Frostwood: return 1071433;
}
}
}
return "";
}
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;
}
}
}
private class SetPricePrompt : Prompt
{
public override int MessageCliloc { get { return 1062383; } }
private readonly BulkOrderBook m_Book;
private readonly object m_Object;
private readonly int m_Page;
private readonly ArrayList m_List;
public SetPricePrompt(BulkOrderBook book, object obj, int page, ArrayList list)
{
m_Book = book;
m_Object = obj;
m_Page = page;
m_List = list;
}
public override void OnResponse(Mobile from, string text)
{
if (m_Object != null && !m_Book.Entries.Contains(m_Object))
{
from.SendLocalizedMessage(1062382); // The deed selected is not available.
return;
}
int price = Utility.ToInt32(text);
if (price < 0 || price > 250000000)
{
from.SendLocalizedMessage(1062390); // The price you requested is outrageous!
}
else if (m_Object == null)
{
for (int i = 0; i < m_List.Count; ++i)
{
object obj = m_List[i];
if (!m_Book.Entries.Contains(obj))
continue;
if (obj is BOBLargeEntry)
((BOBLargeEntry)obj).Price = price;
else if (obj is BOBSmallEntry)
((BOBSmallEntry)obj).Price = price;
}
from.SendMessage("Deed prices set.");
if (from is PlayerMobile)
from.SendGump(new BOBGump((PlayerMobile)from, m_Book, m_Page, m_List));
}
else if (m_Object is BOBLargeEntry)
{
((BOBLargeEntry)m_Object).Price = price;
from.SendLocalizedMessage(1062384); // Deed price set.
if (from is PlayerMobile)
from.SendGump(new BOBGump((PlayerMobile)from, m_Book, m_Page, m_List));
}
else if (m_Object is BOBSmallEntry)
{
((BOBSmallEntry)m_Object).Price = price;
from.SendLocalizedMessage(1062384); // Deed price set.
if (from is PlayerMobile)
from.SendGump(new BOBGump((PlayerMobile)from, m_Book, m_Page, m_List));
}
}
}
}
}
C#:
using System;
using Server.Gumps;
using Server.Mobiles;
namespace Server.Engines.BulkOrders
{
public class BOBFilterGump : Gump
{
private static int[,] m_MaterialFilters = new int[,]
{
{ 1044067, 1 }, // Blacksmithy
{ 1062226, 3 }, // Iron
{ 1018332, 4 }, // Dull Copper
{ 1018333, 5 }, // Shadow Iron
{ 1018334, 6 }, // Copper
{ 1018335, 7 }, // Bronze
{ 0, 0 }, // --Blank--
{ 1018336, 8 }, // Golden
{ 1018337, 9 }, // Agapite
{ 1018338, 10 }, // Verite
{ 1018339, 11 }, // Valorite
{ 0, 0 }, // --Blank--
{ 1044094, 2 }, // Tailoring
{ 1044286, 12 }, // Cloth
{ 1062235, 13 }, // Leather
{ 1062236, 14 }, // Spined
{ 1062237, 15 }, // Horned
{ 1062238, 16 } // Barbed
};
private static readonly int[,] m_MaterialFiltersNew = new int[,]
{
{ 1044067, 1 }, // Blacksmithy
{ 1062226, 9 }, // Iron
{ 1018332, 10 }, // Dull Copper
{ 1018333, 11 }, // Shadow Iron
{ 1018334, 12 }, // Copper
{ 1018335, 13 }, // Bronze
{ 0, 0 }, // --Blank--
{ 1018336, 14 }, // Golden
{ 1018337, 15 }, // Agapite
{ 1018338, 16 }, // Verite
{ 1018339, 17 }, // Valorite
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 1130038, 18 }, // Blaze
{ 1130039, 19 }, // Ice
{ 1130040, 20 }, // Toxic
{ 1130041, 21 }, // Electrum
{ 1130042, 22 }, // Platinum
{ 1044094, 2 }, // Tailoring
{ 1044286, 23 }, // Cloth
{ 1062235, 24 }, // Leather
{ 1062236, 25 }, // Spined
{ 1062237, 26 }, // Horned
{ 1062238, 27 }, // Barbed
{ 0, 0 }, // --Blank--
{ 1130043, 28 }, // Polar
{ 1130044, 29 }, // Synthetic
{ 1130045, 30 }, // Blaze
{ 1130046, 31 }, // Daemonic
{ 1130047, 32 }, // Shadow
{ 0, 0 }, // --Blank--
{ 1130048, 33 }, // Frost
{ 1130049, 34 }, // Ethereal
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 1044097, 3 }, // Tinkering
{ 1062226, 35 }, // Iron
{ 1018332, 36 }, // Dull Copper
{ 1018333, 37 }, // Shadow Iron
{ 1018334, 38 }, // Copper
{ 1018335, 39 }, // Bronze
{ 0, 0 }, // --Blank--
{ 1018336, 40 }, // Golden
{ 1018337, 41 }, // Agapite
{ 1018338, 42 }, // Verite
{ 1018339, 43 }, // Valorite
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 1130038, 44 }, // Blaze
{ 1130039, 45 }, // Ice
{ 1130040, 46 }, // Toxic
{ 1130041, 47 }, // Electrum
{ 1130042, 48 }, // Platinum
{ 1044071, 4 }, // Carpentry
{ 1079435, 49 }, // Wood
{ 1071428, 50 }, // Oak
{ 1071429, 51 }, // Ash
{ 1071430, 52 }, // Yew
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 1071431, 53 }, // Bloodwood
{ 1071432, 54 }, // Heartwood
{ 1071433, 55 }, // Frostwood
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 1130050, 56 }, // Ebony
{ 1130051, 57 }, // Bamboo
{ 1130052, 58 }, // PurpleHeart
{ 1130053, 59 }, // Redwood
{ 1130054, 60 }, // Petrified
{ 1044068, 5 }, // Fletching
{ 1079435, 61 }, // Wood
{ 1071428, 62 }, // Oak
{ 1071429, 63 }, // Ash
{ 1071430, 64 }, // Yew
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 1071431, 65 }, // Bloodwood
{ 1071432, 66 }, // Heartwood
{ 1071433, 67 }, // Frostwood
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 1130050, 68 }, // Ebony
{ 1130051, 69 }, // Bamboo
{ 1130052, 70 }, // PurpleHeart
{ 1130053, 71 }, // Redwood
{ 1130054, 72 }, // Petrified
{ 1044060, 6 }, // Alchemy
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 1044083, 7 }, // Inscription
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 1044073, 8 }, // Cooking
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
};
private static readonly int[,] m_TypeFilters = new int[,]
{
{ 1062229, 0 }, // All
{ 1062224, 1 }, // Small
{ 1062225, 2 }// Large
};
private static readonly int[,] m_QualityFilters = new int[,]
{
{ 1062229, 0 }, // All
{ 1011542, 1 }, // Normal
{ 1060636, 2 }// Exceptional
};
private static readonly int[,] m_AmountFilters = new int[,]
{
{ 1062229, 0 }, // All
{ 1049706, 1 }, // 10
{ 1016007, 2 }, // 15
{ 1062239, 3 }// 20
};
private static readonly int[][,] m_Filters = new int[][,]
{
m_TypeFilters,
m_QualityFilters,
m_MaterialFilters,
m_AmountFilters
};
private static readonly int[][,] m_FiltersNew = new int[][,]
{
m_TypeFilters,
m_QualityFilters,
m_MaterialFiltersNew,
m_AmountFilters
};
private static readonly int[] m_XOffsets_Type = new int[] { 0, 75, 170 };
private static readonly int[] m_XOffsets_Quality = new int[] { 0, 75, 170 };
private static readonly int[] m_XOffsets_Amount = new int[] { 0, 75, 180, 275 };
private static readonly int[] m_XOffsets_Material = new int[] { 0, 108, 212, 307, 392, 487 };
private static readonly int[] m_XWidths_Small = new int[] { 50, 50, 70, 50 };
private static readonly int[] m_XWidths_Large = new int[] { 80, 60, 60, 60, 60, 60 };
private const int LabelColor = 0x7FFF;
private readonly PlayerMobile m_From;
private readonly BulkOrderBook m_Book;
public BOBFilterGump(PlayerMobile from, BulkOrderBook book)
: base(12, 24)
{
from.CloseGump(typeof(BOBGump));
from.CloseGump(typeof(BOBFilterGump));
m_From = from;
m_Book = book;
BOBFilter f = (from.UseOwnFilter ? from.BOBFilter : book.Filter);
AddPage(0);
AddBackground(10, 10, 600, 695, 5054);
AddImageTiled(18, 20, 583, 676, 2624);
AddAlphaRegion(18, 20, 583, 676);
AddImage(5, 5, 10460);
AddImage(585, 5, 10460);
AddImage(5, 690, 10460);
AddImage(585, 690, 10460);
AddHtmlLocalized(270, 32, 200, 32, 1062223, LabelColor, false, false); // Filter Preference
AddHtmlLocalized(26, 64, 120, 32, 1062228, LabelColor, false, false); // Bulk Order Type
AddFilterList(25, 96, m_XOffsets_Type, 40, m_TypeFilters, m_XWidths_Small, f.Type, 0);
AddHtmlLocalized(320, 64, 50, 32, 1062215, LabelColor, false, false); // Quality
AddFilterList(320, 96, m_XOffsets_Quality, 40, m_QualityFilters, m_XWidths_Small, f.Quality, 1);
AddHtmlLocalized(26, 130, 120, 32, 1062232, LabelColor, false, false); // Material Type
AddFilterList(25, 162, m_XOffsets_Material, 35, BulkOrderSystem.NewSystemEnabled ? m_MaterialFiltersNew : m_MaterialFilters, m_XWidths_Large, f.Material, 2);
AddHtmlLocalized(26, 608, 120, 32, 1062217, LabelColor, false, false); // Amount
AddFilterList(25, 640, m_XOffsets_Amount, 40, m_AmountFilters, m_XWidths_Small, f.Quantity, 3);
AddHtmlLocalized(75, 670, 120, 32, 1062477, (from.UseOwnFilter ? LabelColor : 16927), false, false); // Set Book Filter
AddButton(40, 670, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(235, 670, 120, 32, 1062478, (from.UseOwnFilter ? 16927 : LabelColor), false, false); // Set Your Filter
AddButton(200, 670, 4005, 4007, 2, GumpButtonType.Reply, 0);
AddHtmlLocalized(405, 670, 120, 32, 1062231, LabelColor, false, false); // Clear Filter
AddButton(370, 670, 4005, 4007, 3, GumpButtonType.Reply, 0);
AddHtmlLocalized(540, 670, 50, 32, 1011046, LabelColor, false, false); // APPLY
AddButton(505, 670, 4017, 4018, 0, GumpButtonType.Reply, 0);
}
public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
{
BOBFilter f = (m_From.UseOwnFilter ? m_From.BOBFilter : m_Book.Filter);
int index = info.ButtonID;
switch ( index )
{
case 0: // Apply
{
m_From.SendGump(new BOBGump(m_From, m_Book));
break;
}
case 1: // Set Book Filter
{
m_From.UseOwnFilter = false;
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
break;
}
case 2: // Set Your Filter
{
m_From.UseOwnFilter = true;
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
break;
}
case 3: // Clear Filter
{
f.Clear();
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
break;
}
default:
{
index -= 4;
int type = index % 4;
index /= 4;
int[][,] filter = BulkOrderSystem.NewSystemEnabled ? m_FiltersNew : m_Filters;
if (type >= 0 && type < filter.Length)
{
int[,] filters = filter[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.Quality = filters[index, 1];
break;
case 2:
f.Material = filters[index, 1];
break;
case 3:
f.Quantity = filters[index, 1];
break;
}
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
}
}
break;
}
}
}
private void AddFilterList(int x, int y, int[] xOffsets, int yOffset, int[,] filters, int[] xWidths, int filterValue, int filterIndex)
{
for (int i = 0; i < filters.GetLength(0); ++i)
{
int number = filters[i, 0];
if (number == 0)
continue;
bool isSelected = (filters[i, 1] == filterValue);
if (!isSelected && (i % xOffsets.Length) == 0)
isSelected = (filterValue == 0);
AddHtmlLocalized(x + 35 + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), xWidths[i % xOffsets.Length], 32, number, isSelected ? 16927 : LabelColor, false, false);
AddButton(x + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), 4005, 4007, 4 + filterIndex + (i * 4), GumpButtonType.Reply, 0);
}
}
}
}
Last edited: