Example #1
0
        private void createListStep(Func <ScorePanelList> creationFunc)
        {
            AddStep("create list", () => Child = list = creationFunc().With(d =>
            {
                d.Anchor = Anchor.Centre;
                d.Origin = Anchor.Centre;
            }));

            AddUntilStep("wait for load", () => list.IsLoaded);
        }
Example #2
0
        public void TestAddScoreImmediately()
        {
            var score = TestResources.CreateTestScoreInfo();

            createListStep(() =>
            {
                var newList = new ScorePanelList {
                    SelectedScore = { Value = score }
                };
                newList.AddScore(score);
                return(newList);
            });

            assertScoreState(score, true);
            assertExpandedPanelCentred();
        }
Example #3
0
        protected override APIRequest FetchScores(Action <IEnumerable <ScoreInfo> > scoresCallback)
        {
            // This performs two requests:
            // 1. A request to show the user's score (and scores around).
            // 2. If that fails, a request to index the room starting from the highest score.

            var userScoreReq = new ShowPlaylistUserScoreRequest(roomId, playlistItem.ID, api.LocalUser.Value.Id);

            userScoreReq.Success += userScore =>
            {
                var allScores = new List <MultiplayerScore> {
                    userScore
                };

                // Other scores could have arrived between score submission and entering the results screen. Ensure the local player score position is up to date.
                if (Score != null)
                {
                    Score.Position = userScore.Position;
                    ScorePanelList.GetPanelForScore(Score).ScorePosition.Value = userScore.Position;
                }

                if (userScore.ScoresAround?.Higher != null)
                {
                    allScores.AddRange(userScore.ScoresAround.Higher.Scores);
                    higherScores = userScore.ScoresAround.Higher;

                    Debug.Assert(userScore.Position != null);
                    setPositions(higherScores, userScore.Position.Value, -1);
                }

                if (userScore.ScoresAround?.Lower != null)
                {
                    allScores.AddRange(userScore.ScoresAround.Lower.Scores);
                    lowerScores = userScore.ScoresAround.Lower;

                    Debug.Assert(userScore.Position != null);
                    setPositions(lowerScores, userScore.Position.Value, 1);
                }

                performSuccessCallback(scoresCallback, allScores);
            };

            // On failure, fallback to a normal index.
            userScoreReq.Failure += _ => api.Queue(createIndexRequest(scoresCallback));

            return(userScoreReq);
        }