Пример #1
0
        void DrawObject(GameObject go)
        {
            RectTransform goRectTransform = go.GetComponent <RectTransform>();

            //calculate the width and height of each child item.
            float width  = containerRectTransform.rect.width;
            float ratio  = width / goRectTransform.rect.width;
            float height = goRectTransform.rect.height * ratio;

            //adjust the height of the container so that it will just barely fit all its children
            totalHeight += height;
            go.transform.SetParent(gameObject.transform);
            Resizer.SetDefScale(go);
            //move and size the new item
            RectTransform rectTransform = go.GetComponent <RectTransform>();

            float x = -containerRectTransform.rect.width / 2;
            float y = containerFinalHeight / 2 - totalHeight;

            rectTransform.offsetMin = new Vector2(x, y);

            x = rectTransform.offsetMin.x + width;
            y = rectTransform.offsetMin.y + height;
            rectTransform.offsetMax = new Vector2(x, y);
        }
        private void AddLine()
        {
            GameObject lineInstance = Instantiate(rowLinePrefab) as GameObject;

            lineInstance.transform.SetParent(checkListTransform);
            Resizer.SetDefScale(lineInstance);
        }
        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 AddStatus(string s)
        {
            GameObject statusInstance = Instantiate(rowStatusPrefab) as GameObject;

            statusInstance.transform.SetParent(checkListTransform);
            Resizer.SetDefScale(statusInstance);
            statusInstance.GetComponentInChildren <Text> ().text = s;
        }
        private void AddTitle(string s)
        {
            GameObject titleInstance = Instantiate(rowTitlePrefab) as GameObject;

            titleInstance.transform.SetParent(checkListTransform);
            Resizer.SetDefScale(titleInstance);
            titleInstance.GetComponentInChildren <Text> ().text = s;
        }
        GameObject DrawTable(XsollaFormElement element)
        {
            GameObject             newItem    = Instantiate(tablePrefab) as GameObject;
            ElementTableController controller = newItem.GetComponent <ElementTableController>();

            controller.InitScreen(element);
            Resizer.SetDefScale(newItem);
            return(newItem);
        }
Пример #7
0
        private void AddUserMenuBtn(String pTitle, Action pAction)
        {
            GameObject objSubs = Instantiate(Resources.Load(PREFAB_USER_MENU_BTN)) as GameObject;
            UserProfileBtnController controllerSubs = objSubs.GetComponentInChildren <UserProfileBtnController>();

            controllerSubs.InitScreen(pTitle, pAction);
            objSubs.transform.SetParent(_btnDropDownObj.transform);
            Resizer.SetDefScale(objSubs);
        }
Пример #8
0
        /// <summary>
        /// Adds the header row.
        /// </summary>
        private void AddHeader()
        {
            GameObject            itemRow    = Instantiate(Resources.Load(PREFAB_HISTORY_ROW)) as GameObject;
            HistoryElemController controller = itemRow.GetComponent <HistoryElemController>();

            controller.Init(mUtils, null, false, SortHistory, true, mSortDesc);
            itemRow.transform.SetParent(mHistoryContainer.transform);
            Resizer.SetDefScale(itemRow);
            MoveProgresBarOnLastChild();
        }
Пример #9
0
        private void AddSubs(XsollaSubscription pSub)
        {
            GameObject subObj = Instantiate(Resources.Load(PREFAB_SPEC_SUBS)) as GameObject;

            subObj.transform.SetParent(_listSubsView.transform);
            Resizer.SetDefScale(subObj);
            SubscriptionBtnController controller = subObj.GetComponent <SubscriptionBtnController>();

            controller.InitBtn(pSub, mUtils.GetTranslations());
        }
Пример #10
0
        private void addMenuBtn(string pIcon, string pName, RadioButton.RadioType pType, bool pOnlyAction = false)
        {
            GameObject  menuItemPrefab = Instantiate(Resources.Load(PREFAB_VIEW_MENU_ITEM)) as GameObject;
            RadioButton controller     = menuItemPrefab.GetComponent <RadioButton>();

            controller.init(pIcon, pName, pType, delegate { onNavMenuItemClick(pType, pOnlyAction); }, 0, pOnlyAction);

            menuItemPrefab.transform.SetParent(mNavMenuPanel.transform);
            Resizer.SetDefScale(menuItemPrefab);
            mRadioGroupController.AddButton(menuItemPrefab.GetComponent <RadioButton>());
        }
 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 // >>>>>>>>>>>>>>>>>>>>>>>>>>>> PAYMENT METHODS >>>>>>>>>>>>>>>>>>>>>>>>>>>>
 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 private void DrawPaymentListScreen()
 {
     currentActive = ActiveScreen.P_LIST;
     if (_paymentListScreenController == null)
     {
         GameObject paymentListScreen = Instantiate(paymentListScreenPrefab);
         _paymentListScreenController = paymentListScreen.GetComponent <PaymentListScreenController> ();
         _paymentListScreenController.transform.SetParent(mainScreenContainer.transform);
         Resizer.SetDefScale(paymentListScreen);
         _paymentListScreenController.GetComponent <RectTransform> ().anchoredPosition = new Vector2(0, 0);
         mainScreenContainer.GetComponentInParent <ScrollRect> ().content = _paymentListScreenController.GetComponent <RectTransform> ();
     }
 }
        GameObject DrawLabel(XsollaFormElement element)
        {
            if (element.GetTitle() == "")
            {
                return(null);
            }

            GameObject newItem = Instantiate(labelPrefab) as GameObject;

            newItem.GetComponentInChildren <Text> ().text = element.GetTitle();
            Resizer.SetDefScale(newItem);
            return(newItem);
        }
        private void DrawVPStatus(XsollaUtils utils, XVPStatus status)
        {
            currentActive = ActiveScreen.STATUS;
            GameObject statusScreen = Instantiate(Resources.Load(PREFAB_SCREEN_STATUS)) as GameObject;

            statusScreen.transform.SetParent(mainScreenContainer.transform);
            Resizer.SetDefScale(statusScreen);
            statusScreen.GetComponent <RectTransform> ().anchoredPosition    = new Vector2(0, 0);
            mainScreenContainer.GetComponentInParent <ScrollRect> ().content = statusScreen.GetComponent <RectTransform> ();
            StatusViewController controller = statusScreen.GetComponent <StatusViewController> ();

            controller.StatusHandler += OnUserStatusExit;
            controller.DrawVpStatus(utils, status);
        }
        private void DrawVPError(XsollaUtils utils, string error)
        {
            currentActive = ActiveScreen.VP_PAYMENT;
            GameObject statusScreen = Instantiate(Resources.Load(PREFAB_SCREEN_VP_SUMMARY)) as GameObject;

            statusScreen.transform.SetParent(mainScreenContainer.transform);
            Resizer.SetDefScale(statusScreen);
            statusScreen.GetComponent <RectTransform> ().anchoredPosition    = new Vector2(0, 0);
            mainScreenContainer.GetComponentInParent <ScrollRect> ().content = statusScreen.GetComponent <RectTransform> ();
            ScreenVPController screenVpController = statusScreen.GetComponent <ScreenVPController> ();

            screenVpController.DrawScreen(utils, _summary);
            screenVpController.ShowError(error);
        }
        private void DrawForm(XsollaUtils utils, XsollaForm form)
        {
            currentActive = ActiveScreen.PAYMENT;
            GameObject checkoutScreen = Instantiate(Resources.Load(PREFAB_SCREEN_CHECKOUT)) as GameObject;

            checkoutScreen.transform.SetParent(mainScreenContainer.transform);
            Resizer.SetDefScale(checkoutScreen);
            checkoutScreen.GetComponent <RectTransform> ().anchoredPosition = new Vector2(0, 0);
            //scroll.content = paymentScreen.GetComponent<RectTransform> ();
            mainScreenContainer.GetComponentInParent <ScrollRect> ().content = checkoutScreen.GetComponent <RectTransform> ();
            ScreenCheckoutController controller = checkoutScreen.GetComponent <ScreenCheckoutController> ();

            controller.InitScreen(utils, form);
        }
Пример #16
0
        /// <summary>
        /// Adds the history row.
        /// </summary>
        /// <param name="pItem">P history row.</param>
        private void AddHistoryRow(XsollaHistoryItem pItem)
        {
            GameObject            itemRow    = Instantiate(Resources.Load(PREFAB_HISTORY_ROW)) as GameObject;
            HistoryElemController controller = itemRow.GetComponent <HistoryElemController>();

            if (controller != null)
            {
                controller.Init(mUtils, pItem, (mList.Count + 1) % 2 != 0, null);
            }
            itemRow.transform.SetParent(mHistoryContainer.transform);
            Resizer.SetDefScale(itemRow);
            MoveProgresBarOnLastChild();
            mList.Add(controller);
        }
Пример #17
0
        private void AddPricePointItem(XsollaPricepoint pItem)
        {
            GameObject lBaseObj = Resources.Load(PREFAB_SHOP_PRICEPOINT_GRID) as GameObject;
            // создаем экземпляр объекта товара
            GameObject lItemObj = Instantiate(lBaseObj);
            // получаем контроллер
            PricePointItemController itemController = lItemObj.GetComponent <PricePointItemController>();

            // инициализируем контроллер
            itemController.init(pItem, mUtils);
            // добавляем на панель
            lItemObj.transform.SetParent(mItemsContentGrid.transform);
            // масштабирование
            Resizer.SetDefScale(lItemObj);
            mListItems.Add(itemController);
        }
        private void AddBigElement(string s, string s1)
        {
            // if key and value is empty
            if ((s == "") && (s1 == ""))
            {
                return;
            }

            GameObject elementInstance = Instantiate(rowInfoElementBigPrefab) as GameObject;

            elementInstance.transform.SetParent(checkListTransform);
            Resizer.SetDefScale(elementInstance);
            Text[] texts = elementInstance.GetComponentsInChildren <Text> ();
            texts [0].text = s;
            texts [1].text = s1;
        }
Пример #19
0
        private void AddShopItem(XsollaShopItem pItem)
        {
            GameObject lBaseObj = Resources.Load(mIsListLayout ? PREFAB_SHOP_ITEM_LIST : PREFAB_SHOP_ITEM_GRID) as GameObject;
            // создаем экземпляр объекта товара
            GameObject lItemObj = Instantiate(lBaseObj);
            // получаем контроллер
            ShopItemController itemController = lItemObj.GetComponent <ShopItemController>();

            // инициализируем контроллер
            itemController.init(pItem, mUtils, mCurrGroupId, SetCachedStateOnGroupId, mIsListLayout);
            itemController.mCollapseAnotherDesc = CollapseAllDesc;
            // добавляем на панель
            lItemObj.transform.SetParent(GetItemContainer.transform);
            // масштабирование
            Resizer.SetDefScale(lItemObj);
            // Добавляем в лист кэша магазина
            mListItems.Add(itemController);
        }
 protected override void SubsManagerListRecived(XsollaManagerSubscriptions pSubsList)
 {
     if (_SubsManagerController == null)
     {
         GameObject obj = Instantiate(Resources.Load(PREFAB_SCREEN_SUBSCRIPTION_MANAGER)) as GameObject;
         _SubsManagerController = obj.GetComponent <SubsManagerController>();
         _SubsManagerController.initScreen(Utils, pSubsList);
         obj.transform.SetParent(mainScreenContainer.transform);
         obj.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0);
         Resizer.ResizeToParrentRe(obj);
         Resizer.SetDefScale(obj);
     }
     else
     {
         _SubsManagerController.initScreen(Utils, pSubsList);
     }
     SetLoading(false);
 }
Пример #21
0
        private void CreatePopularBtn(XsollaPaymentMethod pMethod)
        {
            GameObject popularBtn = Instantiate(Resources.Load("Prefabs/SimpleView/_PaymentFormElements/ShopPaymentBtn")) as GameObject;

            popularBtn.transform.SetParent(recPanel.transform);
            Resizer.SetDefScale(popularBtn);
            ShopPaymentBtnController controller = popularBtn.GetComponent <ShopPaymentBtnController>();

            if (!pMethod.isVisible)
            {
                controller.Hide();
                return;
            }

            listPopularBtns.Add(controller);
            // Set method
            controller.setMethod(pMethod);
            // Set icon
            controller.setIcon(imageLoader);
            controller._btn.onClick.AddListener(() => OnChoosePaymentMethod(controller.getMethod().id));
        }
Пример #22
0
        private void CreateQuickBtn(XsollaPaymentMethod pMethod)
        {
            GameObject quickBtn = Instantiate(Resources.Load("Prefabs/SimpleView/_PaymentFormElements/QuickPaymentBtn")) as GameObject;

            quickBtn.transform.SetParent(quickPanel.transform);
            Resizer.SetDefScale(quickBtn);
            QuickPaymentBtnController controller = quickBtn.GetComponent <QuickPaymentBtnController>();

            listQuickBtns.Add(controller);
            if (pMethod == null)
            {
                controller.Hide();
                return;
            }

            // Set method
            controller.setMethod(pMethod);
            // Set name
            controller.setLable(pMethod.GetName());
            // Set icon
            controller.setIcon(pMethod.id, imageLoader);
            controller._btnMethod.onClick.AddListener(() => OnChoosePaymentMethod(controller.getMethod().id));
        }
        //    public int itemCount = 10, columnCount = 1;

//		void Start()
//		{
//			Dictionary<string, string> dict = new Dictionary<string, string> ();
//			dict.Add ("1", "assdsdasd");
//			dict.Add ("2", "bytyter");
//			dict.Add ("3", "trwegvbtrw");
//			dict.Add ("4", "45123412");
//			dict.Add ("5", "tgtv52345");
//			dict.Add ("6", "4321fff43214");
//			dict.Add ("7", "123412f43");
//			SetData (null, dict);
//		}

        public void SetData(Action <string> onItemClickAction, Dictionary <string, string> objects)
        {
            int itemCount   = objects.Count;
            int columnCount = 1;

            items = new List <GameObject> (columnCount);
            RectTransform rowRectTransform       = itemPrefab.GetComponent <RectTransform> ();
            RectTransform containerRectTransform = gameObject.GetComponent <RectTransform> ();

            //calculate the width and height of each child item.
            float width    = containerRectTransform.rect.width / columnCount;
            float ratio    = width / rowRectTransform.rect.width;
            float height   = rowRectTransform.rect.height * ratio;
            int   rowCount = itemCount / columnCount;

            if (itemCount % rowCount > 0)
            {
                rowCount++;
            }

            //adjust the height of the container so that it will just barely fit all its children
            float scrollHeight = height * rowCount;

            containerRectTransform.offsetMin = new Vector2(containerRectTransform.offsetMin.x, -scrollHeight / 2);
            containerRectTransform.offsetMax = new Vector2(containerRectTransform.offsetMax.x, scrollHeight / 2);

            int j = 0;

            for (int i = 0; i < itemCount; i++)
            {
                //this is used instead of a double for loop because itemCount may not fit perfectly into the rows/columns
                if (i % columnCount == 0)
                {
                    j++;
                }

                //create a new item, name it, and set the parent
                GameObject newItem = Instantiate(itemPrefab) as GameObject;
                newItem.name = gameObject.name + " item at (" + i + "," + j + ")";
                newItem.transform.SetParent(gameObject.transform);
                Resizer.SetDefScale(newItem);
                Text textField = newItem.GetComponentsInChildren <Text> (true)[0];
                KeyValuePair <string, string> o = objects.ElementAt(i);               //.Keys.ElementAt2(i);
                textField.text = o.Value;
                if (onItemClickAction != null)
                {
                    newItem.GetComponents <Button>()[0].onClick.AddListener(() => { onItemClickAction(o.Key); });
                }
                items.Add(newItem);
                //move and size the new item
                RectTransform rectTransform = newItem.GetComponent <RectTransform> ();

                float x = -containerRectTransform.rect.width / 2 + width * (i % columnCount);
                float y = containerRectTransform.rect.height / 2 - height * j;
                rectTransform.offsetMin = new Vector2(x, y);

                x = rectTransform.offsetMin.x + width;
                y = rectTransform.offsetMin.y + height;
                rectTransform.offsetMax = new Vector2(x, y);
            }
        }