Пример #1
0
        public static void CreateBoard()
        {
            Log("Creating Board");
            try
            {
                //    Log("Sorting Scores");
                Log("PlayerScores Count: " + playerScores.Count);
                playerScores.Sort(LeaderboardInfo.CompareScore);
                GameObject canvasobj = new GameObject("LeaderboardInSong");
                Canvas     canvas    = canvasobj.AddComponent <Canvas>();
                canvas.renderMode = RenderMode.WorldSpace;
                CanvasScaler cs = canvasobj.AddComponent <CanvasScaler>();
                cs.scaleFactor          = 1f;
                cs.dynamicPixelsPerUnit = 10f;
                GraphicRaycaster gr = canvasobj.AddComponent <GraphicRaycaster>();
                canvasobj.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 1f);
                canvasobj.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 1f);
                //      Log("Created Canvas");
                board = BeatSaberUI.CreateViewController <CustomListViewController>();
                board.transform.SetParent(canvasobj.GetComponent <RectTransform>());
                board.transform.localScale   *= 0.15f * UI.BasicUI.scale;
                board.transform.localPosition = new Vector3(UI.BasicUI.x, UI.BasicUI.y, UI.BasicUI.z);
                //           Log("Created board");
                int playerIndex = playerScores.IndexOf(playerScore);
                //      Log("Player Index: " + playerIndex);
                for (int i = playerIndex - 4; i <= playerIndex; i++)
                {
                    if (i >= 0 && i < playerScores.Count)
                    {
                        if (i != playerIndex)
                        {
                            board.Data.Add(new CustomCellInfo($"{playerScores[i].playerPosition}" + " | " + $"{playerScores[i].playerName}" + " | " + $"{playerScores[i].playerScore}", ""));
                        }
                        else
                        {
                            board.Data.Add(new CustomCellInfo($"<#59B0F4>{playerScores[i].playerName}" + " | " + $"{playerScores[i].playerScore}", ""));
                        }
                    }
                }
                //                  Log("Filled Data");
                //   foreach (LeaderboardInfo player in playerScores)
                //           {

                //                  board.Data.Add(new CustomCellInfo(player.playerPosition + '\t' + player.playerName + '\t' + player.playerScore, ""));
                //             }
                board.__Activate(VRUI.VRUIViewController.ActivationType.AddedToHierarchy);
                //            Log("Activated Board");
                (board._customListTableView.transform.parent as RectTransform).sizeDelta = new Vector2(100f, 120f);
                //              Log("SizeDelta");
                board._pageDownButton.gameObject.SetActive(false);
                board._pageUpButton.gameObject.SetActive(false);
                //                Log("Buttons");
            }
            catch (Exception ex)
            {
                Log(ex.ToString());
            }
        }
        private void RequestQueueControllerMain()
        {
            _customMenu = BeatSaberUI.CreateCustomMenu <CustomMenu>("QueueButtonOptions");
            _customListViewController = BeatSaberUI.CreateViewController <CustomListViewController>();

            CreateNextButton();
            CreateRandomizeButton();
            CreateSongToTopButton();
            CreateSubOnlyButton();
            CreateClearQueueButton();
            CreateBanSongButton();

            _customMenu.SetLeftViewController(_customListViewController, true);
            _customMenu.Present();
        }