Example #1
0
 public Task <List <SearchItem> > FindVendorItemsAsync(Mobile m, SearchCriteria criteria)
 {
     return(new Task <List <SearchItem> >(() =>
     {
         return criteria.Auction ? VendorSearch.DoSearchAuction(m, criteria) : VendorSearch.DoSearch(m, criteria);
     }));
 }
Example #2
0
        public override void OnResponse(RelayInfo info)
        {
            switch (info.ButtonID)
            {
            default: break;

            case 1:
            {
                if (Banker.GetBalance(User) < VendorMap.TeleportCost)
                {
                    User.SendLocalizedMessage(1154672);         // You cannot afford to teleport to the vendor.
                }
                else if (VendorMap.SetLocation == Point3D.Zero && !VendorSearch.CanSearch(User))
                {
                    User.SendLocalizedMessage(1154680);         //Before using vendor search, you must be in a justice region or a safe log-out location (such as an inn or a house which has you on its Owner, Co-owner, or Friends list).
                }
                else if (VendorMap.SetLocation == Point3D.Zero && !VendorSearch.CanSearch(User))
                {
                    User.SendLocalizedMessage(501035);         // You cannot teleport from here to the destination.
                }
                else
                {
                    new Spells.Fourth.RecallSpell(User, VendorMap, VendorMap).Cast();
                }

                break;
            }
            }
        }
Example #3
0
        public SearchVendors(PlayerMobile pm)
            : base(1154679, -1)
        {
            Player = pm;

            Enabled = VendorSearch.CanSearch(pm);
        }
Example #4
0
 public override void OnClick()
 {
     if (VendorSearch.CanSearch(Player))
     {
         BaseGump.SendGump(new VendorSearchGump(Player));
     }
 }
Example #5
0
        public override void OnResponse(RelayInfo info)
        {
            switch (info.ButtonID)
            {
            default: break;

            case 1:
                if (!VendorMap.CheckVendor())
                {
                    User.SendLocalizedMessage(1154643);     // That item is no longer for sale.
                }
                else if (VendorMap.SetLocation == Point3D.Zero && !VendorSearch.CanSearch(User))
                {
                    User.SendLocalizedMessage(1154680);     //Before using vendor search, you must be in a justice region or a safe log-out location (such as an inn or a house which has you on its Owner, Co-owner, or Friends list).
                }
                else if (VendorMap.SetLocation == Point3D.Zero && !VendorSearch.CanSearch(User))
                {
                    User.SendLocalizedMessage(501035);     // You cannot teleport from here to the destination.
                }
                else if (VendorMap.SetLocation != Point3D.Zero && (!Utility.InRange(VendorMap.SetLocation, User.Location, 100) || VendorMap.SetMap != User.Map))
                {
                    User.SendLocalizedMessage(501035);     // You cannot teleport from here to the destination.
                }
                else
                {
                    new Server.Spells.Fourth.RecallSpell(User, VendorMap, VendorMap).Cast();
                }

                break;
            }
        }
Example #6
0
 public Task <List <VendorItem> > FindVendorItemsAsync(Mobile m, SearchCriteria criteria)
 {
     return(new Task <List <VendorItem> >(() =>
     {
         return VendorSearch.DoSearch(m, criteria);
     }));
 }
Example #7
0
        public VendorSearchGump(PlayerMobile pm, int cat = -1)
            : base(pm, 10, 10)
        {
            Criteria       = VendorSearch.GetContext(pm);
            ChosenCategory = cat;

            if (Criteria == null)
            {
                Criteria = VendorSearch.AddNewContext(pm);
            }
        }
Example #8
0
        public VendorSearchGump(PlayerMobile pm, int feedback = -1)
            : base(pm, 10, 10)
        {
            TypeID   = 0xF3EC8;
            Feedback = feedback;
            Criteria = VendorSearch.GetContext(pm);

            if (Criteria == null)
            {
                Criteria = VendorSearch.AddNewContext(pm);
            }
        }
Example #9
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            switch (info.ButtonID)
            {
            default: break;

            case 1:
                if (!VendorMap.CheckVendor())
                {
                    User.SendLocalizedMessage(1154643);     // That item is no longer for sale.
                }
                else if (!VendorSearch.CanSearch(User))
                {
                    User.SendLocalizedMessage(1154680);     //Before using vendor search, you must be in a justice region or a safe log-out location (such as an inn or a house which has you on its Owner, Co-owner, or Friends list).
                }
                else
                {
                    new Server.Spells.Fourth.RecallSpell(User, null, VendorMap).Cast();
                }

                break;
            }
        }
Example #10
0
        public override void OnResponse(RelayInfo info)
        {
            if (info.ButtonID != 0)
            {
                if (!VendorSearch.CanSearch(User))
                {
                    User.SendLocalizedMessage(1154680); //Before using vendor search, you must be in a justice region or a safe log-out location (such as an inn or a house which has you on its Owner, Co-owner, or Friends list).
                    return;
                }

                TextRelay searchname = info.GetTextEntry(1);

                if (searchname != null && !string.IsNullOrEmpty(searchname.Text))
                {
                    string text = searchname.Text.Trim();

                    if (Criteria.SearchName == null || text.ToLower() != Criteria.SearchName.ToLower())
                    {
                        Criteria.SearchName = searchname.Text;
                    }
                }
            }

            switch (info.ButtonID)
            {
            case 0: break;

            case 1:     // Search
            {
                User.CloseGump(typeof(SearchResultsGump));

                if (Criteria.IsEmpty)
                {
                    SendGump(new VendorSearchGump(User, 1154586));         // Please select some criteria to search for.
                }
                else
                {
                    var resultsTask = FindVendorItemsAsync(User, Criteria);

                    var pollingTimer = new TaskPollingTimer <List <SearchItem> >(resultsTask, (results) =>
                        {
                            User.CloseGump(typeof(SearchWaitGump));

                            if (results == null || results.Count == 0)
                            {
                                SendGump(new VendorSearchGump(User, 1154587));     // No items matched your search.
                            }
                            else
                            {
                                Refresh(true);
                                SendGump(new SearchResultsGump(User, results));
                            }
                        });

                    resultsTask.Start();
                    pollingTimer.Start();

                    SendGump(new SearchWaitGump(User, pollingTimer));
                }
                break;
            }

            case 2:     // Clear Criteria
            {
                Criteria.Reset();
                Refresh(true);
                break;
            }

            case 4:     // Nothing, resend gump
                Refresh(true);
                break;

            case 7:     // remove item name
                Criteria.SearchName = null;
                Refresh(true);
                break;

            case 8:     // remove price entry
                Criteria.EntryPrice = false;
                Refresh(true);
                break;

            case 9:     // remove auction entry
                Refresh(true);
                break;

            case 236:     // Low to High
                Criteria.SortBy = SortBy.LowToHigh;
                Refresh(true);
                break;

            case 237:     // High to Low
                Criteria.SortBy = SortBy.HighToLow;
                Refresh(true);
                break;

            case 238:     // Non Auction Item
                Criteria.Auction = false;
                Refresh(true);
                break;

            case 239:     // Auction Item
                Criteria.Auction = true;
                Refresh(true);
                break;

            case 1154512:     // Set Min/Max price
                TextRelay tr1 = info.GetTextEntry(7);
                TextRelay tr2 = info.GetTextEntry(8);

                if (tr1 != null && tr1.Text != null)
                {
                    string text = tr1.Text.Trim();

                    if (int.TryParse(text, out int min))
                    {
                        Criteria.MinPrice = min;
                    }
                }

                if (tr2 != null && tr2.Text != null)
                {
                    string text = tr2.Text.Trim();

                    if (int.TryParse(text, out int max))
                    {
                        Criteria.MaxPrice = max;
                    }
                }

                Criteria.EntryPrice = true;
                Refresh(true);
                break;

            default:
                if (info.ButtonID > 1000)
                {
                    SearchDetail toRemove = Criteria.Details[info.ButtonID - 1001];

                    if (toRemove.Category == Category.Equipment)
                    {
                        Criteria.SearchType = Layer.Invalid;
                    }

                    Criteria.Details.Remove(toRemove);
                    Refresh(true);
                }
                else
                {
                    if (Criteria.Details.Count >= 20)
                    {
                        SendGump(new VendorSearchGump(User, 1154681));     // You may not add any more search criteria items.
                    }

                    var    criteria = SearchCriteriaCategory.AllCategories.SelectMany(x => x.Criteria, (x, c) => new { x.Category, c.Object, c.Cliloc, c.PropCliloc }).ToList()[info.ButtonID - 50];
                    object o        = criteria.Object;
                    int    value    = 0;

                    TextRelay valuetext = info.GetTextEntry(info.ButtonID - 40);

                    if (valuetext != null)
                    {
                        value = Math.Max(o is AosAttribute && (AosAttribute)o == AosAttribute.CastSpeed ? -1 : 0, Utility.ToInt32(valuetext.Text));
                    }

                    Criteria.TryAddDetails(o, criteria.Cliloc, criteria.PropCliloc, value, criteria.Category);
                    Refresh(true);
                }
                break;
            }
        }
Example #11
0
        public void AddGumpLayout(bool nofind = false, bool nocrit = false)
        {
            AddBackground(0, 0, 780, 570, 30546);
            AddBackground(10, 45, 250, 22, 9350);

            AddHtmlLocalized(10, 25, 150, 20, 1154510, C32216(LabelColor), false, false);           // Item Name
            AddHtmlLocalized(0, 5, 780, 20, 1154645, "#1154508", C32216(LabelColor), false, false); // Vendor Search Query
            AddHtmlLocalized(520, 25, 150, 20, 1154546, C32216(LabelColor), false, false);          // Selected Search Criteria

            AddTextEntry(12, 45, 240, 25, TextColor, 0, Criteria.SearchName);

            for (int i = 0; i < VendorSearch.Categories.Count; i++)
            {
                if (i == 0)
                {
                    AddHtmlLocalized(50, 75 + (i * 22), 215, 20, VendorSearch.Categories[i].Label, String.Format("{0}\t{1}", Criteria.MinPrice.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Criteria.MaxPrice.ToString("N0", CultureInfo.GetCultureInfo("en-US"))), C32216(LabelColor), false, false);
                }
                else
                {
                    AddHtmlLocalized(50, 75 + (i * 22), 215, 20, VendorSearch.Categories[i].Label, C32216(LabelColor), false, false);
                }

                AddButton(10, 75 + (i * 22), 30533, 30533, i + 100, GumpButtonType.Reply, 0);
            }

            if (ChosenCategory >= 0 && ChosenCategory < VendorSearch.Categories.Count)
            {
                if (ChosenCategory == 0)
                {
                    AddHtmlLocalized(270, 25, 150, 20, 1154532, C32216(LabelColor), false, false); // Minimum Price
                    AddBackground(270, 45, 250, 22, 9350);
                    AddTextEntry(272, 45, 245, 20, TextColor, 1, Criteria.MinPrice.ToString("N0", CultureInfo.GetCultureInfo("en-US")));

                    AddHtmlLocalized(270, 75, 150, 20, 1154533, C32216(LabelColor), false, false); // Maximum Price
                    AddBackground(270, 95, 250, 22, 9350);
                    AddTextEntry(272, 95, 245, 20, TextColor, 2, Criteria.MaxPrice.ToString("N0", CultureInfo.GetCultureInfo("en-US")));

                    AddButton(270, 125, 4011, 4012, 1, GumpButtonType.Reply, 0);
                }
                else if (ChosenCategory == VendorSearch.Categories.Count - 1)
                {
                    AddHtmlLocalized(270, 25, 150, 20, VendorSearch.Categories[ChosenCategory].Label, C32216(LabelColor), false, false); // Sort Results

                    AddHtmlLocalized(310, 45, 150, 20, 1154696, C32216(LabelColor), false, false);                                       // Price: Low to High
                    AddButton(270, 45, 30533, 30533, 2, GumpButtonType.Reply, 0);

                    AddHtmlLocalized(310, 67, 150, 20, 1154697, C32216(LabelColor), false, false); // Price: High to Low
                    AddButton(270, 67, 30533, 30533, 3, GumpButtonType.Reply, 0);
                }
                else if (ChosenCategory >= 0 && ChosenCategory < VendorSearch.Categories.Count)
                {
                    AddHtmlLocalized(270, 25, 150, 20, VendorSearch.Categories[ChosenCategory].Label, C32216(LabelColor), false, false);

                    for (int index = 0; index < VendorSearch.Categories[ChosenCategory].Objects.Count; index++)
                    {
                        Tuple <object, int> data = VendorSearch.Categories[ChosenCategory].Objects[index];

                        AddHtmlLocalized(310, 45 + (index * 22), 215, 20, data.Item2, C32216(LabelColor), false, false);
                        AddButton(270, 45 + (index * 22), 30533, 30533, 200 + index, GumpButtonType.Reply, 0);

                        if (VendorSearch.HasValue(data.Item1, VendorSearch.Categories[ChosenCategory]))
                        {
                            int value = Criteria.GetValueForDetails(data.Item1);

                            AddBackground(475, 45 + (index * 22), 40, 22, 9350);
                            AddTextEntry(477, 45 + (index * 22), 38, 25, TextColor, 400 + index, value > 0 ? value.ToString() : "");
                        }
                    }
                }
            }

            int y = 45;

            if (!String.IsNullOrEmpty(Criteria.SearchName))
            {
                AddButton(520, 45, 4017, 4019, 7, GumpButtonType.Reply, 0);
                AddTooltip(1154694); // Remove Selected Search Criteria

                AddHtmlLocalized(560, 45, 215, 20, 1154510, C32216(CriteriaColor), false, false);

                y += 22;
            }

            for (int i = 0; i < Criteria.Details.Count; i++)
            {
                AddButton(520, y + (i * 22), 4017, 4019, 300 + i, GumpButtonType.Reply, 0);
                AddTooltip(1154694); // Remove Selected Search Criteria

                AddHtmlLocalized(560, y + (i * 22), 215, 20, Criteria.Details[i].Label, C32216(CriteriaColor), false, false);

                if (Criteria.Details[i].Value > 0)
                {
                    AddHtml(720, y + (i * 22), 60, 20, String.Format("<basefont color=#F5DEB3>{0}", FormatValue(Criteria.Details[i].Attribute, Criteria.Details[i].Value)), false, false);
                }
            }

            if (Criteria.SortBy != SortBy.None)
            {
                AddButton(520, 45 + (Criteria.Details.Count * 22), 4017, 4019, 4, GumpButtonType.Reply, 0);
                AddHtmlLocalized(560, 45 + (Criteria.Details.Count * 22), 215, 20, Criteria.SortBy == SortBy.LowToHigh ? 1154696 : 1154697, C32216(CriteriaColor), false, false);
            }

            AddHtmlLocalized(600, 518, 130, 20, 1114514, "#1154588", C32216(LabelColor), false, false); // Clear Search Criteria
            AddButton(740, 518, 30533, 30533, 5, GumpButtonType.Reply, 0);

            AddHtmlLocalized(600, 540, 130, 20, 1114514, "#1154641", C32216(LabelColor), false, false); // Search
            AddButton(740, 540, 30534, 30534, 6, GumpButtonType.Reply, 0);

            AddHtmlLocalized(50, 540, 150, 20, 3000091, C32216(LabelColor), false, false); // Cancel
            AddButton(10, 540, 30533, 30535, 0, GumpButtonType.Reply, 0);

            if (nofind)
            {
                AddHtmlLocalized(125, 540, 400, 16, 1154587, C32216(0xFF0000), false, false); // No items matched your search.
            }
            else if (nocrit)
            {
                AddHtmlLocalized(125, 540, 400, 16, 1154586, C32216(0xFF0000), false, false); // Please select some criteria to search for.
            }
        }
Example #12
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID != 0)
            {
                TextRelay searchname = info.GetTextEntry(0);

                if (searchname != null && !String.IsNullOrEmpty(searchname.Text))
                {
                    string text = searchname.Text.Trim();

                    if (Criteria.SearchName == null || text.ToLower() != Criteria.SearchName.ToLower())
                    {
                        Criteria.SearchName = searchname.Text;
                    }
                }
            }

            switch (info.ButtonID)
            {
            case 0: break;

            case 1:     // Set Min/Max price
                TextRelay tr1 = info.GetTextEntry(1);
                TextRelay tr2 = info.GetTextEntry(2);

                if (tr1 != null && tr1.Text != null)
                {
                    string text = tr1.Text.Trim();
                    int    min  = 0;

                    if (int.TryParse(text, out min))
                    {
                        Criteria.MinPrice = min;
                    }
                }

                if (tr2 != null && tr2.Text != null)
                {
                    string text = tr2.Text.Trim();
                    int    max  = 0;

                    if (int.TryParse(text, out max))
                    {
                        Criteria.MaxPrice = max;
                    }
                }
                Refresh();
                break;

            case 2:     // Low to High
                Criteria.SortBy = SortBy.LowToHigh;
                Refresh();
                break;

            case 3:     // High to Low
                Criteria.SortBy = SortBy.HighToLow;
                Refresh();
                break;

            case 4:     // Nothing, resend gump
                Criteria.SortBy = SortBy.None;
                Refresh();
                break;

            case 5:     // Clear Criteria
                Criteria.Reset();
                Refresh();
                break;

            case 6:     // Search
                User.CloseGump(typeof(SearchResultsGump));

                if (Criteria.IsEmpty)
                {
                    Refresh(false, true);
                }
                else
                {
                    List <VendorItem> list = VendorSearch.DoSearch(User, Criteria);

                    if (list == null || list.Count == 0)
                    {
                        Refresh(true);
                    }
                    else
                    {
                        Refresh();
                        User.SendGump(new SearchResultsGump(User, list));
                    }
                }
                break;

            case 7:     // remove item name
                Criteria.SearchName = null;
                Refresh();
                break;

            default:
                if (info.ButtonID >= 100 && info.ButtonID < 200)
                {
                    ChosenCategory = info.ButtonID - 100;
                    Refresh();
                }
                else if (info.ButtonID >= 200 && info.ButtonID < 300 && ChosenCategory >= 0 && ChosenCategory < VendorSearch.Categories.Count)
                {
                    int index = info.ButtonID - 200;

                    SearchCategory      category = VendorSearch.Categories[ChosenCategory];
                    Tuple <object, int> data     = category.Objects[index];
                    object o     = data.Item1;
                    int    value = 0;

                    TextRelay valuetext = info.GetTextEntry(index + 400);

                    if (valuetext != null)
                    {
                        value = Math.Max(o is AosAttribute && (AosAttribute)o == AosAttribute.CastSpeed ? -1 : 0, Utility.ToInt32(valuetext.Text));
                    }

                    Criteria.TryAddDetails(o, data.Item2, value, category.Category);
                    Refresh();
                }
                else if (info.ButtonID >= 300 && info.ButtonID - 300 >= 0 && info.ButtonID - 300 < Criteria.Details.Count)
                {
                    SearchDetail toRemove = Criteria.Details[info.ButtonID - 300];

                    if (toRemove.Category == Category.Equipment)
                    {
                        Criteria.SearchType = Layer.Invalid;
                    }

                    Criteria.Details.Remove(toRemove);
                    Refresh();
                }
                break;
            }
        }
Example #13
0
        public override void OnResponse(RelayInfo info)
        {
            NoCrit = false;
            NoFind = false;

            if (info.ButtonID != 0)
            {
                if (!VendorSearch.CanSearch(User))
                {
                    User.SendLocalizedMessage(1154680); //Before using vendor search, you must be in a justice region or a safe log-out location (such as an inn or a house which has you on its Owner, Co-owner, or Friends list).
                    return;
                }

                TextRelay searchname = info.GetTextEntry(0);

                if (searchname != null && !String.IsNullOrEmpty(searchname.Text))
                {
                    string text = searchname.Text.Trim();

                    if (Criteria.SearchName == null || text.ToLower() != Criteria.SearchName.ToLower())
                    {
                        Criteria.SearchName = searchname.Text;
                    }
                }
            }

            switch (info.ButtonID)
            {
            case 0: break;

            case 1:     // Set Min/Max price
                TextRelay tr1 = info.GetTextEntry(1);
                TextRelay tr2 = info.GetTextEntry(2);

                if (tr1 != null && tr1.Text != null)
                {
                    string text = tr1.Text.Trim();
                    int    min  = 0;

                    if (int.TryParse(text, out min))
                    {
                        Criteria.MinPrice = min;
                    }
                }

                if (tr2 != null && tr2.Text != null)
                {
                    string text = tr2.Text.Trim();
                    int    max  = 0;

                    if (int.TryParse(text, out max))
                    {
                        Criteria.MaxPrice = max;
                    }
                }

                Criteria.EntryPrice = true;
                Refresh();
                break;

            case 2:     // Low to High
                Criteria.SortBy = SortBy.LowToHigh;
                Refresh();
                break;

            case 3:     // High to Low
                Criteria.SortBy = SortBy.HighToLow;
                Refresh();
                break;

            case 4:     // Nothing, resend gump
                Refresh();
                break;

            case 5:     // Clear Criteria
                Criteria.Reset();
                Refresh();
                break;

            case 6:     // Search
                User.CloseGump(typeof(SearchResultsGump));

                if (Criteria.IsEmpty)
                {
                    NoCrit = true;
                    Refresh();
                }
                else
                {
                    List <VendorItem> list = VendorSearch.DoSearch(User, Criteria);

                    if (list == null || list.Count == 0)
                    {
                        NoFind = true;
                        Refresh();
                    }
                    else
                    {
                        Refresh();
                        BaseGump.SendGump(new SearchResultsGump(User, list));
                    }
                }
                break;

            case 7:     // remove item name
                Criteria.SearchName = null;
                Refresh();
                break;

            case 8:     // remove price entry
                Criteria.EntryPrice = false;
                Refresh();
                break;

            default:
                if (info.ButtonID >= 100 && info.ButtonID < 200)
                {
                    ChosenCategory = info.ButtonID - 100;
                    Refresh();
                }
                else if (info.ButtonID >= 200 && info.ButtonID < 300 && ChosenCategory >= 0 && ChosenCategory < VendorSearch.Categories.Count)
                {
                    int index = info.ButtonID - 200;

                    SearchCategory      category = VendorSearch.Categories[ChosenCategory];
                    Tuple <object, int> data     = category.Objects[index];
                    object o     = data.Item1;
                    int    value = 0;

                    TextRelay valuetext = info.GetTextEntry(index + 400);

                    if (valuetext != null)
                    {
                        value = Math.Max(o is AosAttribute && (AosAttribute)o == AosAttribute.CastSpeed ? -1 : 0, Utility.ToInt32(valuetext.Text));
                    }

                    Criteria.TryAddDetails(o, data.Item2, value, category.Category);
                    Refresh();
                }
                else if (info.ButtonID >= 300 && info.ButtonID - 300 >= 0 && info.ButtonID - 300 < Criteria.Details.Count)
                {
                    SearchDetail toRemove = Criteria.Details[info.ButtonID - 300];

                    if (toRemove.Category == Category.Equipment)
                    {
                        Criteria.SearchType = Layer.Invalid;
                    }

                    Criteria.Details.Remove(toRemove);
                    Refresh();
                }
                break;
            }
        }