Ejemplo n.º 1
0
        public void Setup(ByteBuffer buffer)
        {
            int beginPos = buffer.position;

            buffer.Seek(beginPos, 0);

            name = buffer.ReadS();
            autoRadioGroupDepth = buffer.ReadBool();

            buffer.Seek(beginPos, 1);

            int cnt = buffer.ReadShort();

            _pageIds.Capacity   = cnt;
            _pageNames.Capacity = cnt;
            for (int i = 0; i < cnt; i++)
            {
                _pageIds.Add(buffer.ReadS());
                _pageNames.Add(buffer.ReadS());
            }

            int homePageIndex = 0;

            if (buffer.version >= 2)
            {
                int homePageType = buffer.ReadByte();
                switch (homePageType)
                {
                case 1:
                    homePageIndex = buffer.ReadShort();
                    break;

                case 2:
                    homePageIndex = _pageNames.IndexOf(UIPackage.branch);
                    if (homePageIndex == -1)
                    {
                        homePageIndex = 0;
                    }
                    break;

                case 3:
                    homePageIndex = _pageNames.IndexOf(UIPackage.GetVar(buffer.ReadS()));
                    if (homePageIndex == -1)
                    {
                        homePageIndex = 0;
                    }
                    break;
                }
            }

            buffer.Seek(beginPos, 2);

            cnt = buffer.ReadShort();
            if (cnt > 0)
            {
                if (_actions == null)
                {
                    _actions = new List <ControllerAction>(cnt);
                }

                for (int i = 0; i < cnt; i++)
                {
                    int nextPos = buffer.ReadShort();
                    nextPos += buffer.position;

                    ControllerAction action = ControllerAction.CreateAction((ControllerAction.ActionType)buffer.ReadByte());
                    action.Setup(buffer);
                    _actions.Add(action);

                    buffer.position = nextPos;
                }
            }

            if (parent != null && _pageIds.Count > 0)
            {
                _selectedIndex = homePageIndex;
            }
            else
            {
                _selectedIndex = -1;
            }
        }