public void NextPage()
    {
        HideSelectedItem();
        int nextPage   = currentPage + 1;
        int lowerBound = this.itemsPerPage * currentPage;
        int upperBound = lowerBound + this.itemsPerPage;

        this.pageDisplay.text = string.Format(GlobalStrings.PAGE_NUMBER_MSG, nextPage, pageCount);

        int uiIndex = 0;

        for (int z = lowerBound; z < upperBound; z++, uiIndex++)
        {
            if (z < itemsToDisplay.Count)
            {
                CatalogItem CI = PF_GameData.ConvertStoreItemToCatalogItem(itemsToDisplay[z]);


                string iconName = "Default";
                if (!string.Equals(CI.CustomData, null))                 //should be !string.IsNullOrEmpty(CI.CustomData)
                {
                    Dictionary <string, string> kvps = PlayFab.Json.JsonWrapper.DeserializeObject <Dictionary <string, string> >(CI.CustomData);
                    kvps.TryGetValue("icon", out iconName);
                }
                Sprite icon = GameController.Instance.iconManager.GetIconById(iconName);

                this.inventory[uiIndex].Init();
                this.inventory[uiIndex].SetButton(icon, CI);
            }
            else
            {
                this.inventory[uiIndex].ClearButton();
            }
        }

        this.prevPage.interactable = true;

        if (pageCount > nextPage)
        {
            this.nextPage.interactable = true;
        }
        else
        {
            this.nextPage.interactable = false;
        }
        this.currentPage++;
    }
    //TODO solve the confusion with what VC balances are checked player VS character
    // close also needs to fire a callback to the calling area of the code
    public void InitiateStore(string name, List <StoreItem> items)
    {
        Dictionary <string, object> eventData = new Dictionary <string, object>()
        {
            { "store_name", name }
        };

        PF_Bridge.LogCustomEvent(PF_Bridge.CustomEventTypes.Client_StoreVisit, eventData);


        //reset
        this.currenciesInUse.Clear();
        this.currentPage      = 1;
        this.pageCount        = Mathf.CeilToInt((float)items.Count / (float)this.itemsPerPage);
        this.pageDisplay.text = string.Format("{0} / {1}", this.currentPage, this.pageCount);
        //HideSelectedItem();

        foreach (var item in this.inventory)
        {
            item.ClearButton();
        }


        this.itemsToDisplay = items;
        this.StoreName.text = name;

        if (pageCount > 1)
        {
            nextPage.interactable = true;
        }
        else
        {
            nextPage.interactable = false;
        }

        prevPage.interactable = false;


        for (int z = 0; z < items.Count; z++)
        {
            if (z >= this.itemsPerPage)
            {
                break;
            }

            CatalogItem CI = PF_GameData.ConvertStoreItemToCatalogItem(items[z]);


            string iconName = "Default";
            if (CI.CustomData != null && !string.Equals(CI.CustomData, "null"))
            {
                try
                {
                    Dictionary <string, string> kvps = PlayFab.Json.JsonWrapper.DeserializeObject <Dictionary <string, string> >(CI.CustomData);
                    kvps.TryGetValue("icon", out iconName);
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }
            Sprite icon = GameController.Instance.iconManager.GetIconById(iconName);

            this.inventory[z].Init();
            this.inventory[z].SetButton(icon, CI);



            // keep track of what currencies are being used in the store.
            List <string> VCs = items[z].VirtualCurrencyPrices.Keys.ToList();
            foreach (var vc in VCs)
            {
                int index = this.currenciesInUse.FindIndex((key) => { return(string.Equals(key, vc)); });
                // make sure not already in the list.
                if (index < 0)
                {
                    this.currenciesInUse.Add(vc);
                }
            }
        }

        //hide selected
        this.Currencies.Init();
        this.gameObject.SetActive(true);
    }
    //TODO solve the confusion with what VC balances are checked player VS character
    // close also needs to fire a callback to the calling area of the code
    public void InitiateStore(string name, List <StoreItem> items)
    {
        foreach (var slot in itemInventory)
        {
            slot.gameObject.SetActive(false);
        }

        //Dictionary<string, object> eventData = new Dictionary<string, object>()
        //{
        //    { "store_name", name }
        //};
        //PF_Bridge.LogCustomEvent(PF_Bridge.CustomEventTypes.Client_StoreVisit, eventData);

        //reset
        //itemInventory = new StoreDisplayItem[items.Count];

        this.currenciesInUse.Clear();

        //foreach (var item in this.itemInventory)
        //{
        //    item.ClearButton();
        //}


        this.itemsToDisplay = items;
        this.StoreName.text = name;

        for (int z = 0; z < items.Count; z++)
        {
            //todo : instance the item buttom and initialize

            itemInventory[z].gameObject.SetActive(true);
            itemInventory[z].ClearButton();
            //
            CatalogItem CI = PF_GameData.ConvertStoreItemToCatalogItem(items[z]);


            string iconName = "Default";
            if (CI.CustomData != null && !string.Equals(CI.CustomData, "null"))
            {
                try
                {
                    Dictionary <string, string> kvps = PlayFabSimpleJson.DeserializeObject <Dictionary <string, string> >(CI.CustomData);
                    kvps.TryGetValue("icon", out iconName);
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }
            Sprite icon = GameController.Instance.iconManager.GetIconById(iconName);

            this.itemInventory[z].Init();
            this.itemInventory[z].SetButton(icon, CI);

            // keep track of what currencies are being used in the store.
            List <string> VCs = items[z].VirtualCurrencyPrices.Keys.ToList();
            foreach (var vc in VCs)
            {
                int index = this.currenciesInUse.FindIndex((key) => { return(string.Equals(key, vc)); });
                // make sure not already in the list.
                if (index < 0)
                {
                    this.currenciesInUse.Add(vc);
                }
            }
        }

        //hide selected
        //this.Currencies.Init();
        this.gameObject.SetActive(true);
    }