Example #1
0
        public UltimaStoreGump(PlayerMobile pm)
            : base(pm, 100, 200)
        {
            StoreList = UltimaStore.GetList(Category);
            UltimaStore.SortList(StoreList, SortBy);

            pm.Frozen    = true;
            pm.Hidden    = true;
            pm.Squelched = true;
        }
        public UltimaStoreGump(PlayerMobile pm, StoreEntry forcedEntry = null)
            : base(pm, 100, 200)
        {
            StoreList = UltimaStore.GetList(Category, forcedEntry);

            if (forcedEntry == null)
            {
                UltimaStore.SortList(StoreList, SortBy);
            }

            pm.Frozen        = true;
            pm.Hidden        = true;
            pm.TempSquelched = true;
        }
        public override void OnResponse(RelayInfo info)
        {
            int id = info.ButtonID;

            if (id == 0)
            {
                ReleaseHidden(User);
                return;
            }

            PlayerProfile profile = UltimaStore.GetProfile(User);

            switch (id)
            {
            // Change Category
            case 100:
            case 101:
            case 102:
            case 103:
            case 104:
            case 105:
            {
                Search = false;

                StoreCategory oldCat = profile.Category;

                profile.Category = (StoreCategory)id - 99;

                if (oldCat != profile.Category)
                {
                    StoreList = UltimaStore.GetList(Category);
                    Page      = 0;
                }

                Refresh();
                return;
            }

            // Promo Code
            case 106:
            {
                Refresh();
                SendGump(new PromoCodeGump(User, this));
                return;
            }

            // FAQ
            case 107:
            {
                if (!string.IsNullOrWhiteSpace(Configuration.Website))
                {
                    User.LaunchBrowser(Configuration.Website);
                }
                else
                {
                    User.LaunchBrowser("https://uo.com/ultima-store/");
                }

                Refresh();
                return;
            }

            // Change Sort Method
            case 108:
            case 109:
            case 110:
            case 111:
            case 112:
            {
                SortBy oldSort = profile.SortBy;

                profile.SortBy = (SortBy)id - 108;

                if (oldSort != profile.SortBy)
                {
                    // re-orders the list
                    if (oldSort == SortBy.Newest || oldSort == SortBy.Oldest)
                    {
                        ColUtility.Free(StoreList);

                        StoreList = UltimaStore.GetList(Category);
                    }

                    UltimaStore.SortList(StoreList, profile.SortBy);

                    Page = 0;
                }

                Refresh();
                return;
            }

            // Cart View
            case 113:
            {
                if (profile != null)
                {
                    profile.Category = StoreCategory.Cart;
                }

                Refresh();
                return;
            }

            // Search
            case 114:
            {
                TextRelay searchTxt = info.GetTextEntry(0);

                if (searchTxt != null && !string.IsNullOrEmpty(searchTxt.Text))
                {
                    Search     = true;
                    SearchText = searchTxt.Text;
                }
                else
                {
                    User.SendLocalizedMessage(1150315);         // That text is unacceptable.
                }

                Refresh();
                return;
            }

            // Buy
            case 115:
            {
                if (UltimaStore.CartCount(User) == 0)
                {
                    if (profile != null)
                    {
                        profile.Category = StoreCategory.Cart;
                    }

                    Refresh();
                    return;
                }

                int total = UltimaStore.GetSubTotal(Cart);

                if (total <= UltimaStore.GetCurrency(User, true))
                {
                    SendGump(new ConfirmPurchaseGump(User));
                }
                else
                {
                    SendGump(new NoFundsGump(User));
                }

                return;
            }

            // Next Page
            case 116:
            {
                ++Page;

                Refresh();
                return;
            }

            // Previous Page
            case 117:
            {
                --Page;

                Refresh();
                return;
            }
            }

            if (id < 2000) // Add To Cart
            {
                Refresh();

                StoreEntry entry = StoreList[id - 1000];

                if (Cart == null || Cart.Count < 10)
                {
                    SendGump(new ConfirmCartGump(User, this, entry));
                    return;
                }

                User.SendLocalizedMessage(1156745); // Your store cart is currently full.
            }
            else if (id < 3000)                     // Change Amount In Cart
            {
                Refresh();

                StoreEntry entry = UltimaStore.Entries[id - 2000];

                SendGump(new ConfirmCartGump(User, this, entry, Cart != null && Cart.ContainsKey(entry) ? Cart[entry] : 0));
                return;
            }
            else if (id < 4000) // Remove From Cart
            {
                StoreEntry entry = UltimaStore.Entries[id - 3000];

                if (profile != null)
                {
                    profile.RemoveFromCart(entry);
                }

                Refresh();
                return;
            }

            ReleaseHidden(User);
        }
Example #4
0
        public override void OnResponse(RelayInfo info)
        {
            int id = info.ButtonID;

            if (id == 0)
            {
                ReleaseHidden(User);
                return;
            }

            var profile = UltimaStore.GetProfile(User);

            if (id >= 100 && id <= 105) // Change Category
            {
                Search = false;

                var oldCat = profile.Category;
                profile.Category = (StoreCategory)id - 99;

                if (oldCat != profile.Category)
                {
                    StoreList = UltimaStore.GetList(Category);
                    Page      = 0;
                }

                Refresh();
                return;
            }
            else if (id == 106) // Promo Code
            {
                Refresh();
                BaseGump.SendGump(new PromoCodeGump(User, this));
                return;
            }
            else if (id == 107) // FAQ
            {
                if (!String.IsNullOrEmpty(Configuration.CurrencyInfoWebsite))
                {
                    User.LaunchBrowser(Configuration.CurrencyInfoWebsite);
                }
                else
                {
                    User.LaunchBrowser("https://uo.com/ultima-store/");
                }

                Refresh();
                return;
            }
            else if (id >= 108 && id <= 112) // Change Sort Method
            {
                var oldSort = profile.SortBy;
                profile.SortBy = (SortBy)id - 108;

                if (oldSort != profile.SortBy)
                {
                    // re-orders the list
                    if (oldSort == SortBy.Newest || oldSort == SortBy.Oldest)
                    {
                        ColUtility.Free(StoreList);
                        StoreList = UltimaStore.GetList(Category);
                    }

                    UltimaStore.SortList(StoreList, profile.SortBy);

                    Page = 0;
                }

                Refresh();
                return;
            }
            else if (id == 113) // Cart View
            {
                if (profile != null)
                {
                    profile.Category = StoreCategory.Cart;
                }

                Refresh();
                return;
            }
            else if (id == 114) // search
            {
                TextRelay searchTxt = info.GetTextEntry(0);

                if (searchTxt != null && !String.IsNullOrEmpty(searchTxt.Text))
                {
                    Search     = true;
                    SearchText = searchTxt.Text;
                }
                else
                {
                    User.SendLocalizedMessage(1150315); // That text is unacceptable.
                }

                Refresh();
                return;
            }
            else if (id == 115) // Buy
            {
                if (UltimaStore.CartCount(User) == 0)
                {
                    if (profile != null)
                    {
                        profile.Category = StoreCategory.Cart;
                    }

                    Refresh();
                    return;
                }

                int total = UltimaStore.GetSubTotal(Cart);

                if (total <= UltimaStore.GetCurrency(User, true))
                {
                    BaseGump.SendGump(new ConfirmPurchaseGump(User));
                }
                else
                {
                    BaseGump.SendGump(new NoFundsGump(User));
                }

                return;
            }
            else if (id == 116) // page forward
            {
                Page++;
                Refresh();
                return;
            }
            else if (id == 117) // page back
            {
                Page--;
                Refresh();
                return;
            }
            else if (id < 2000) // Add To Cart
            {
                Refresh();

                var entry = StoreList[id - 1000];

                if (Cart == null || Cart.Count < 10)
                {
                    BaseGump.SendGump(new ConfirmCartGump(User, this, entry));
                    return;
                }
                else
                {
                    User.SendLocalizedMessage(1156745); // Your store cart is currently full.
                }
            }
            else if (id < 3000) // Change Amount In Cart
            {
                Refresh();
                var entry = UltimaStore.Entries[id - 2000];

                BaseGump.SendGump(new ConfirmCartGump(User, this, entry, Cart != null && Cart.ContainsKey(entry) ? Cart[entry] : 0));
                return;
            }
            else if (id < 4000) // Remove From Cart
            {
                var entry = UltimaStore.Entries[id - 3000];

                if (profile != null)
                {
                    profile.RemoveFromCart(entry);
                }

                Refresh();
                return;
            }

            ReleaseHidden(User);
        }