Exemplo n.º 1
0
        private void Scroll(UIBulletinBoardType type, int dir)
        {
            var strings = GameFacade.Strings;

            switch (type)
            {
            case UIBulletinBoardType.Community:
                CommunityPage += dir;
                CommunityTween?.Stop();
                CommunityTween = GameFacade.Screens.Tween.To(this, 0.5f, new Dictionary <string, float>()
                {
                    { "CommunityPostsScroll", CommunityPage }
                }, TweenQuad.EaseOut);
                CommunityPostsPage.Caption = strings.GetString("f120", "8", new string[] { (CommunityPage + 1).ToString() });
                break;

            case UIBulletinBoardType.Mayor:
                MayorPage += dir;
                MayorTween?.Stop();
                MayorTween = GameFacade.Screens.Tween.To(this, 0.5f, new Dictionary <string, float>()
                {
                    { "MayorPostsScroll", MayorPage }
                }, TweenQuad.EaseOut);
                MayorPostsPage.Caption = strings.GetString("f120", "8", new string[] { (MayorPage + 1).ToString() });

                var firstPage = MayorPosts.Count != 0 && (MayorPage <= 0);
                MayorPostsLabel.Alignment    = (firstPage ? TextAlignment.Left : TextAlignment.Center) | TextAlignment.Top;
                MayorPostsSubtitle.Alignment = (firstPage ? TextAlignment.Left : TextAlignment.Center) | TextAlignment.Top;
                break;

            case UIBulletinBoardType.System:
                SystemPage += dir;
                SystemTween?.Stop();
                SystemTween = GameFacade.Screens.Tween.To(this, 0.5f, new Dictionary <string, float>()
                {
                    { "SystemPostsScroll", SystemPage }
                }, TweenQuad.EaseOut);
                SystemPostsPage.Caption = strings.GetString("f120", "8", new string[] { (SystemPage + 1).ToString() });
                break;
            }

            UpdateScrollButtons();
        }
Exemplo n.º 2
0
        private void UpdateDisplay(UIBulletinBoardType type, int floor, bool fullUpdate)
        {
            int perPage           = (type == UIBulletinBoardType.Community) ? 8 : 4;
            int firstPageSrcMinus = type == UIBulletinBoardType.Community ? 1 : 0; //items lost from the perPage total on the first page.
            int firstPageUIMinus  = 0;
            List <BulletinItem>            items           = null;
            List <UIMediumBulletinSummary> uibuffer        = null;
            List <UIMediumBulletinSummary> firstPageBuffer = new List <UIMediumBulletinSummary>();

            switch (type)
            {
            case UIBulletinBoardType.Mayor:
                NoPostMayor.Visible = MayorPosts.Count == 0;
                firstPageUIMinus    = 1;
                uibuffer            = MayorPostsBuffer.ToList();
                firstPageBuffer.Add(LastMayorPost);
                items = MayorPosts;
                break;

            case UIBulletinBoardType.Community:
                NoPostCommunity.Visible = CommunityPosts.Count == 0;
                firstPageUIMinus        = 2;
                uibuffer = CommunityPostsBuffer.Cast <UIMediumBulletinSummary>().ToList();
                firstPageBuffer.Add(LastCommunityPost);
                items = CommunityPosts;
                break;

            case UIBulletinBoardType.System:
                NoPostSystem.Visible = SystemPosts.Count == 0;
                uibuffer             = SystemPostsBuffer.Cast <UIMediumBulletinSummary>().ToList();
                items = SystemPosts;
                break;
            }
            int startSrc  = floor * perPage;
            int startDest = (floor * perPage) % (perPage * 2);
            int todo      = (fullUpdate ? 2 : 1) * perPage;

            if (floor > 0)
            {
                startSrc -= firstPageSrcMinus;
            }
            else
            {
                for (int i = 0; i < firstPageBuffer.Count; i++)
                {
                    if (startSrc >= items.Count)
                    {
                        firstPageBuffer[i].SetItem(null);
                    }
                    else
                    {
                        firstPageBuffer[i].SetItem(items[startSrc]);
                    }
                    startSrc++;
                }
                startDest += firstPageUIMinus;
                todo      -= firstPageUIMinus;
            }

            for (int i = 0; i < todo; i++)
            {
                if (startSrc >= items.Count)
                {
                    uibuffer[startDest++].SetItem(null);
                }
                else
                {
                    uibuffer[startDest++].SetItem(items[startSrc]);
                }
                startSrc++;
                startDest %= (perPage * 2);
            }
        }