public void init(XsollaGroupsManager pGoodsManager, Action <XsollaGoodsGroup> pSelectItem)
 {
     Logger.Log("Create goods menu");
     mRadioGroupController = this.gameObject.AddComponent <RadioGroupController>();
     pGoodsManager.GetItemsList().ForEach((item) =>
     {
         addMenuItem(item, pSelectItem, mMenuContainer);
     });
     mRadioGroupController.radioButtons[0].stateDevider(false);
 }
示例#2
0
        private void InitMenu(XsollaUtils pUtils)
        {
            mRadioGroupController = mNavMenuPanel.gameObject.AddComponent <RadioGroupController> ();
            GameObject menuItemEmptyPrefab             = Resources.Load(PREFAB_VIEW_MENU_ITEM_EMPTY) as GameObject;
            Dictionary <string, XComponent> components = pUtils.GetProject().components;

            if (components.ContainsKey("items") && components ["items"].IsEnabled)
            {
                string lName = (components ["items"].Name != "") ? components ["items"].Name : pUtils.GetTranslations().Get(XsollaTranslations.VIRTUALITEM_PAGE_TITLE);
                addMenuBtn("", lName, RadioButton.RadioType.SCREEN_GOODS);
            }

            if (components.ContainsKey("virtual_currency") && components ["virtual_currency"].IsEnabled)
            {
                string lName = (components ["virtual_currency"].Name != "") ? components["virtual_currency"].Name : pUtils.GetTranslations().Get(XsollaTranslations.PRICEPOINT_PAGE_TITLE);
                addMenuBtn("", lName, RadioButton.RadioType.SCREEN_PRICEPOINT);
            }

            if (components.ContainsKey("subscriptions") && components["subscriptions"].IsEnabled)
            {
                string lName = (components["subscriptions"].Name != "") ? components["subscriptions"].Name : pUtils.GetTranslations().Get("state_name_subscription");
                addMenuBtn("", lName, RadioButton.RadioType.SCREEN_SUBSCRIPTION);
            }

            if (components.ContainsKey("coupons") && components["coupons"].IsEnabled)
            {
                string lName = (components["coupons"].Name != "") ? components["coupons"].Name : pUtils.GetTranslations().Get(XsollaTranslations.COUPON_PAGE_TITLE);
                addMenuBtn("", lName, RadioButton.RadioType.SCREEN_REDEEMCOUPON);
            }

            GameObject menuItemEmpty = Instantiate(menuItemEmptyPrefab);

            menuItemEmpty.transform.SetParent(mNavMenuPanel.transform);

            if (!pUtils.IsServerLess())
            {
                addMenuBtn("", "", RadioButton.RadioType.SCREEN_FAVOURITE, true);
            }
        }
        //TODO minimize
        private void InitMenu(XsollaUtils utils)
        {
            _radioController = menuTransform.gameObject.AddComponent <RadioGroupController> ();
            GameObject menuItemPrefab      = Resources.Load(PREFAB_VIEW_MENU_ITEM) as GameObject;
            GameObject menuItemIconPrefab  = Resources.Load(PREFAB_VIEW_MENU_ITEM_ICON) as GameObject;
            GameObject menuItemEmptyPrefab = Resources.Load(PREFAB_VIEW_MENU_ITEM_EMPTY) as GameObject;
//			menuTransform = mainScreen.GetComponentInChildren<HorizontalLayoutGroup> ().gameObject.transform;
            Dictionary <string, XComponent> components = utils.GetProject().components;
            XsollaPaystation2 paystation2 = utils.GetSettings().paystation2;
            bool isGoodsRequred           = components.ContainsKey("items") && components ["items"].IsEnabled;

            if (isGoodsRequred)
            {
                GameObject menuItemGoods = Instantiate(menuItemPrefab) as GameObject;
                Text[]     texts         = menuItemGoods.GetComponentsInChildren <Text>();
                texts[0].text = "";
                texts[1].text = utils.GetTranslations().Get(XsollaTranslations.VIRTUALITEM_PAGE_TITLE);
                menuItemGoods.GetComponent <Button>().onClick.AddListener(delegate {
                    LoadGoodsGroups();
                    _radioController.SelectItem(0);
                });
                menuItemGoods.transform.SetParent(menuTransform);
                _radioController.AddButton(menuItemGoods.GetComponent <RadioButton>());
            }
            //HACK with Unity 5.3
            //bool isPricepointsRequired = components.ContainsKey("virtual_currency") && components ["virtual_currency"].IsEnabled;
            if (paystation2.pricepointsAtFirst != null && paystation2.pricepointsAtFirst.Equals("1"))
            {
                GameObject menuItemPricepoints = Instantiate(menuItemPrefab) as GameObject;
                Text[]     texts = menuItemPricepoints.GetComponentsInChildren <Text>();
                texts[0].text = "";
                texts[1].text = utils.GetTranslations().Get(XsollaTranslations.PRICEPOINT_PAGE_TITLE);
                menuItemPricepoints.GetComponent <Button>().onClick.AddListener(delegate {
                    LoadShopPricepoints();
                    _radioController.SelectItem(1);
                });
                menuItemPricepoints.transform.SetParent(menuTransform);
                _radioController.AddButton(menuItemPricepoints.GetComponent <RadioButton>());
            }

            if (components.ContainsKey("coupons") && components["coupons"].IsEnabled)
            {
                GameObject menuItemCoupons = Instantiate(menuItemPrefab) as GameObject;
                Text[]     texts           = menuItemCoupons.GetComponentsInChildren <Text>();
                texts[0].text = "";
                texts[1].text = utils.GetTranslations().Get(XsollaTranslations.COUPON_PAGE_TITLE);
                menuItemCoupons.GetComponent <Button>().onClick.AddListener(delegate {
                    ShowRedeemCoupon();
                    _radioController.SelectItem(2);
                });
                menuItemCoupons.transform.SetParent(menuTransform);
                _radioController.AddButton(menuItemCoupons.GetComponent <RadioButton>());
            }

            GameObject menuItemEmpty = Instantiate(menuItemEmptyPrefab);

            menuItemEmpty.transform.SetParent(menuTransform);


            GameObject menuItemFavorite = Instantiate(menuItemIconPrefab);

            menuItemFavorite.GetComponentInChildren <Text> ().text = "";
            menuItemFavorite.GetComponent <Button>().onClick.AddListener(delegate {
                _shopViewController.SetTitle(utils.GetTranslations().Get(XsollaTranslations.VIRTUALITEMS_TITLE_FAVORITE));
                LoadFavorites();
                _radioController.SelectItem(3);
            });
            menuItemFavorite.transform.SetParent(menuTransform);
            _radioController.AddButton(menuItemFavorite.GetComponent <RadioButton>());
        }