private void addMenuItem(XsollaGoodsGroup pGoodsGroup, Action <XsollaGoodsGroup> pSelectItem, GameObject pParent) { GameObject baseMenuItem = Resources.Load(PREFAB_MENU_ITEM) as GameObject; GameObject lMenuItem = Instantiate(baseMenuItem); RadioButton lController = lMenuItem.GetComponent <RadioButton>(); lController.init("", pGoodsGroup.GetName(), RadioButton.RadioType.GOODS_ITEM, delegate { mRadioGroupController.UnselectAll(); pSelectItem(pGoodsGroup); }, pGoodsGroup.mLevel); mRadioGroupController.AddButton(lController); // Задаем является ли родителем lController.setParentState(pGoodsGroup.mChildren.Count > 0); // Заносим детей if (pGoodsGroup.mChildren.Count > 0) { pGoodsGroup.mChildren.GetItemsList().ForEach((item) => { addMenuItem(item, pSelectItem, lController.mChildrenContainer); }); } lMenuItem.transform.SetParent(pParent.transform); Resizer.SetDefScale(lMenuItem); }
private void SelectGoodsGroup(XsollaGoodsGroup pGroup) { // Зачищаем панель с товарами ClearItemsContent(); // Запускаем прелоадер mProgressBar.SetLoading(true); // выбор товаров по группе // Меняем заголовок mShopTitle.text = pGroup.GetName(); mCurrGroupId = pGroup.id; // запрос на данные Logger.Log("Load goods from groupId:" + pGroup.id.ToString()); Dictionary <String, object> lParams = new Dictionary <string, object>(); lParams.Add(XsollaApiConst.ACCESS_TOKEN, mUtils.GetAcceessToken()); if (mUtils.GetUser().userBalance != null) { lParams.Add(XsollaApiConst.USER_INITIAL_CURRENCY, mUtils.GetUser().userBalance.currency); } lParams.Add("group_id", pGroup.id); // Если id = -1 то это распродажа и делаем запрос по другому адресу ApiRequest.Instance.getApiRequest(new XsollaRequestPckg((pGroup.id == -1) ? mSalesUrl : mGoodsUrl, lParams), GoodsRecived, ErrorRecived, mGroupUseCached.ContainsKey(mCurrGroupId) ? mGroupUseCached[mCurrGroupId] : true); SetCachedStateOnGroupId(mCurrGroupId, true); }
public void OpenGoods(XsollaGroupsManager groups) { Resizer.ResizeToParrent(gameObject); menu.transform.parent.parent.gameObject.SetActive(true); SetTitle(groups.GetItemByPosition(0).name); menu.SetData((groupId) => { XsollaGoodsGroup group = groups.GetItemByKey(groupId); radioGroup.SelectItem(groups.GetItemsList().IndexOf(group)); ChooseItemsGroup(group.id, group.name); }, groups.GetNamesDict()); radioGroup.SetButtons(menu.GetItems()); radioGroup.SelectItem(0); }
private void GoodsGroupRecived(JSONNode pNode) { // получили список групп товаров. XsollaGroupsManager lGoodsGroups = new XsollaGroupsManager().Parse(pNode["groups"]) as XsollaGroupsManager; // Строим меню mGoodsGroupController = this.gameObject.GetComponentInChildren <GoodsGroupMenuController>(); if (mUtils.mBonus.mHasSales) { XsollaGoodsGroup salesGroup = new XsollaGoodsGroup(); salesGroup.id = -1; salesGroup.mChildren = new XsollaGroupsManager(); salesGroup.name = "%" + " " + mUtils.GetTranslations().Get("sales_page_title"); lGoodsGroups.InsertItem(0, salesGroup); } mGoodsGroupController.init(lGoodsGroups, SelectGoodsGroup); // Выделяем первый активный элемент mGoodsGroupController.clickFirstActiveItem(); //mGoodsGroupController.clickItem(0); }