internal static void FinishLoad()
        {
            if (_table == null)
            {
                return;
            }

            foreach (var cell in Resources.FindObjectsOfTypeAll <LeaderboardTableCell>())
            {
                var name      = cell.GetPrivateField <TextMeshProUGUI>("_playerNameText").text;
                var score     = cell.GetPrivateField <TextMeshProUGUI>("_scoreText");
                var scoreText = score.text;
                try
                {
                    var scoreInt = scoreToInt(scoreText);
                    if (cell.name.Equals("LeaderboardTableCell(Clone)"))
                    {
                        var acc = Math.Round((double)scoreInt / (double)_maxScore * 100, 2);
                        if (acc <= 100.1)
                        {
                            score.text += $" ({acc}%)";
                            //Logger.log.Debug($"{cell.name}, {score.text}");
                        }
                    }
                }
                catch (Exception e)
                {
                    Logger.log.Error($"Could not parse score: {scoreText}");
                }
            }

            _table = null;
        }
        static void Postfix(CampaignChallengeLeaderboardViewController __instance, ref LeaderboardTableView ___table, ref Challenge ___lastClicked)
        {
            int maxScore = 0;

            try
            {
                var id           = ___lastClicked.FindSong().levelID;
                var beatmapLevel = Loader.BeatmapLevelsModelSO.GetBeatmapLevelIfLoaded(id);
                if (beatmapLevel == null)
                {
                    Logger.log.Debug("beatmap level null");
                    return;
                }
                var levelDifficultyBeatmapSets = beatmapLevel.beatmapLevelData.difficultyBeatmapSets;
                var missionData             = ___lastClicked.GetMissionData(new Campaign()); // campaign doesn't matter here
                var levelDifficultyBeatmaps = levelDifficultyBeatmapSets.First(x => x.beatmapCharacteristic.Equals(missionData.beatmapCharacteristic)).difficultyBeatmaps;
                foreach (var diff in levelDifficultyBeatmaps)
                {
                    if (diff.difficulty.Equals(___lastClicked.difficulty))
                    {
                        Logger.log.Debug("Found note count");
                        var noteCount = diff.beatmapData.notesCount;
                        maxScore = ScoreModel.MaxRawScoreForNumberOfNotes(noteCount);
                    }
                }

                LeaderboardAcc.GiveParams(ref ___table, maxScore);
                Logger.log.Debug($"Max Score: {maxScore}");
            }
            catch (Exception e)
            {
                Logger.log.Debug($"Could not load level data: {e}");
                return;
            }
        }
Ejemplo n.º 3
0
        private void LeaderboardOpened_Event(IDifficultyBeatmap arg1, LeaderboardTableView arg2)
        {
            StopAllCoroutines();

            currentLeaderboard = arg2;
            StartCoroutine(GetMapData(arg1.level.levelID, arg1.difficulty));
            currentlySelectedBeatmap = arg1;

            Logger.Log.Warn(arg1.level.levelID);
        }
        public override GameObject CreateObject(Transform parent)
        {
            LeaderboardTableView table = MonoBehaviour.Instantiate(Resources.FindObjectsOfTypeAll <LeaderboardTableView>().First(x => x.name == "LeaderboardTableView"), parent, false);

            table.name = "BSMLLeaderboard";
            table.GetPrivateField <LeaderboardTableCell>("_cellPrefab").GetPrivateField <TextMeshProUGUI>("_scoreText").enableWordWrapping = false;
            foreach (Transform child in table.transform.GetChild(0).GetChild(0)) //This is to ensure if a leaderboard with scores already on it gets cloned that old scores are cleared off
            {
                GameObject.Destroy(child.gameObject);
            }

            return(table.gameObject);
        }
        public override GameObject CreateObject(Transform parent)
        {
            LeaderboardTableView table = MonoBehaviour.Instantiate(Resources.FindObjectsOfTypeAll <LeaderboardTableView>().First(x => x.name == "LeaderboardTableView"), parent, false);

            table.name = "BSMLLeaderboard";
            table.GetField <LeaderboardTableCell, LeaderboardTableView>("_cellPrefab").GetField <TextMeshProUGUI, LeaderboardTableCell>("_scoreText").enableWordWrapping = false;
            table.GetComponent <VRGraphicRaycaster>().SetField("_physicsRaycaster", BeatSaberUI.PhysicsRaycasterWithCache);
            foreach (LeaderboardTableCell tableCell in table.GetComponentsInChildren <LeaderboardTableCell>()) //This is to ensure if a leaderboard with scores already on it gets cloned that old scores are cleared off
            {
                GameObject.Destroy(tableCell.gameObject);
            }

            return(table.gameObject);
        }
Ejemplo n.º 6
0
        static bool Prefix(ref IDifficultyBeatmap ____difficultyBeatmap, ref List <LeaderboardTableView.ScoreData> ____scores, ref bool ____hasScoresData, ref LeaderboardTableView ____leaderboardTableView, ref int[] ____playerScorePos, ref PlatformLeaderboardsModel.ScoresScope ____scoresScope, ref IconSegmentedControl ____scopeSegmentedControl)
        {
            if (____difficultyBeatmap.level is CustomBeatmapLevel)
            {
                IconSegmentedControl.DataItem thirdCell = ____scopeSegmentedControl.GetPrivateField <IconSegmentedControl.DataItem[]>("_dataItems").Last();
                thirdCell.SetPrivateProperty("hintText", "Platform: PC");
                thirdCell.SetPrivateProperty("icon", BeatBoardsUIManager.Instance.PCIcon);

                ____hasScoresData = false;
                ____scores.Clear();
                ____leaderboardTableView.SetScores(____scores, ____playerScorePos[(int)____scoresScope]);

                Events.Instance.leaderboardOpened.Invoke(____difficultyBeatmap, ____leaderboardTableView);
                return(false);
            }
            return(true);
        }
 internal static void GiveParams(ref LeaderboardTableView table, int maxScore)
 {
     _table    = table;
     _maxScore = maxScore;
 }