Beispiel #1
0
        private void SetupGamepadPoints(SpriteBatch spriteBatch)
        {
            UILinkPointNavigator.Shortcuts.BackButtonCommand = 1;
            int num = 3000;

            UILinkPointNavigator.SetPosition(num, _backPanel.GetInnerDimensions().ToRectangle().Center.ToVector2());
            UILinkPointNavigator.SetPosition(num + 1, _newPanel.GetInnerDimensions().ToRectangle().Center.ToVector2());
            int         num2        = num;
            UILinkPoint uILinkPoint = UILinkPointNavigator.Points[num2];

            uILinkPoint.Unlink();
            uILinkPoint.Right = num2 + 1;
            num2        = num + 1;
            uILinkPoint = UILinkPointNavigator.Points[num2];
            uILinkPoint.Unlink();
            uILinkPoint.Left = num2 - 1;
            float            scaleFactor       = 1f / Main.UIScale;
            Rectangle        clippingRectangle = _containerPanel.GetClippingRectangle(spriteBatch);
            Vector2          minimum           = clippingRectangle.TopLeft() * scaleFactor;
            Vector2          maximum           = clippingRectangle.BottomRight() * scaleFactor;
            List <SnapPoint> snapPoints        = GetSnapPoints();

            for (int i = 0; i < snapPoints.Count; i++)
            {
                if (!snapPoints[i].Position.Between(minimum, maximum))
                {
                    snapPoints.Remove(snapPoints[i]);
                    i--;
                }
            }
            SnapPoint[,] array = new SnapPoint[_playerList.Count, 4];
            foreach (SnapPoint item in snapPoints.Where((SnapPoint a) => a.Name == "Play"))
            {
                array[item.Id, 0] = item;
            }
            foreach (SnapPoint item2 in snapPoints.Where((SnapPoint a) => a.Name == "Favorite"))
            {
                array[item2.Id, 1] = item2;
            }
            foreach (SnapPoint item3 in snapPoints.Where((SnapPoint a) => a.Name == "Cloud"))
            {
                array[item3.Id, 2] = item3;
            }
            foreach (SnapPoint item4 in snapPoints.Where((SnapPoint a) => a.Name == "Delete"))
            {
                array[item4.Id, 3] = item4;
            }
            num2 = num + 2;
            int[] array2 = new int[_playerList.Count];
            for (int j = 0; j < array2.Length; j++)
            {
                array2[j] = -1;
            }
            for (int k = 0; k < 4; k++)
            {
                int num3 = -1;
                for (int l = 0; l < array.GetLength(0); l++)
                {
                    if (array[l, k] != null)
                    {
                        uILinkPoint = UILinkPointNavigator.Points[num2];
                        uILinkPoint.Unlink();
                        UILinkPointNavigator.SetPosition(num2, array[l, k].Position);
                        if (num3 != -1)
                        {
                            uILinkPoint.Up = num3;
                            UILinkPointNavigator.Points[num3].Down = num2;
                        }
                        if (array2[l] != -1)
                        {
                            uILinkPoint.Left = array2[l];
                            UILinkPointNavigator.Points[array2[l]].Right = num2;
                        }
                        uILinkPoint.Down = num;
                        if (k == 0)
                        {
                            UILinkPointNavigator.Points[num].Up = (UILinkPointNavigator.Points[num + 1].Up = num2);
                        }
                        num3      = num2;
                        array2[l] = num2;
                        UILinkPointNavigator.Shortcuts.FANCYUI_HIGHEST_INDEX = num2;
                        num2++;
                    }
                }
            }
            if (PlayerInput.UsingGamepadUI && _playerList.Count == 0 && UILinkPointNavigator.CurrentPoint > 3001)
            {
                UILinkPointNavigator.ChangePoint(3001);
            }
        }