Exemplo n.º 1
0
        /// <summary>
        /// Get the initial content ID
        /// </summary>
        /// In the linear mode, the content ID will not be rounded,
        /// because the value will be used for considering that the box
        /// should be inactivated or not.
        /// <param name="listBoxID">The ID of requested list box</param>
        /// <returns>The content ID<para />
        /// If there is no content in the bank, return int.MinValue
        /// </returns>
        public int GetInitialContentID(int listBoxID)
        {
            if (_listBank.GetListLength() == 0)
            {
                return(int.MinValue);
            }

            var contentID = _listSetting.centeredContentID;

            // Adjust the contentID according to its initial order
            contentID +=
                _listSetting.reverseOrder ?
                _numOfBoxes / 2 - listBoxID :
                listBoxID - _numOfBoxes / 2;

            return(_idHandler(contentID));
        }
        /// <summary>
        /// Initialize the related list components
        /// </summary>
        private void InitializeListComponents()
        {
            _listPositionCtrl =
                new ListPositionCtrl(
                    _setting, _rectTransform, _canvasRefCamera, _listBoxes);
            _listContentManager =
                new ListContentManager(
                    _setting, _listBank, _listBoxes.Count);

            if (_setting.centerSelectedBox)
            {
                _setting.onBoxClick.AddListener(SelectContentID);
            }

            for (var i = 0; i < _listBoxes.Count; ++i)
            {
                _listBoxes[i].Initialize(
                    this, _listPositionCtrl, _listContentManager, i);
            }

            _hasNoContent = _listBank.GetListLength() == 0;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Manage the list content
        /// </summary>
        /// <param name="setting">The settings of the list</param>
        /// <param name="listBank">
        /// The bank containing the contents for list to display
        /// </param>
        /// <param name="numOfBoxes">The number of list boxes</param>
        public ListContentManager(
            CircularScrollingListSetting setting,
            BaseListBank listBank,
            int numOfBoxes)
        {
            _listSetting = setting;
            _listBank    = listBank;
            _numOfBoxes  = numOfBoxes;

            _idFactor  = setting.reverseOrder ? -1 : 1;
            _idHandler =
                setting.listType == CircularScrollingList.ListType.Circular
                    ? (Func <int, int>)(x =>
                                        (int)Mathf.Repeat(x, _listBank.GetListLength()))
                    : x => x;
        }