/// <summary> /// Load the leaderboard result data from the service into the view. /// </summary> /// <param name="result"></param> private void LoadResult(LeaderboardResult result) { if (this.stat == null || (result.HasNext && (this.stat.ID != result.GetNextQuery().StatName || this.socialGroup != result.GetNextQuery().SocialGroup))) { return; } this.leaderboardData = result; uint displayCurrentPage = this.currentPage + 1; if (this.leaderboardData.TotalRowCount == 0) { this.totalPages = 0; displayCurrentPage = 0; } else if (this.totalPages == 0) { this.totalPages = (uint)Mathf.Ceil(this.leaderboardData.TotalRowCount / this.entryCount); } this.pageText.text = string.Format("Page: {0} / {1}", displayCurrentPage, this.totalPages); while (this.contentPanel.childCount > 0) { var entry = this.contentPanel.GetChild(0).gameObject; this.entryObjectPool.ReturnObject(entry); } var xuids = new List <string>(); foreach (LeaderboardRow row in this.leaderboardData.Rows) { xuids.Add(row.XboxUserId); GameObject entryObject = this.entryObjectPool.GetObject(); LeaderboardEntry entry = entryObject.GetComponent <LeaderboardEntry>(); entry.Data = row; entryObject.transform.SetParent(this.contentPanel); } userGroup = SocialManager.SingletonInstance.CreateSocialUserGroupFromList(XboxLiveUserManager.Instance.UserForSingleUserMode.User, xuids); // Reset the scroll view to the top. this.scrollRect.verticalNormalizedPosition = 1; this.UpdateButtons(); }
/// <summary> /// Load the leaderboard result data from the service into the view. /// </summary> /// <param name="result"></param> private void LoadResult(LeaderboardResult result) { if (this.stat == null || (result.HasNext && (this.stat.ID != result.GetNextQuery().StatName || this.socialGroup != result.GetNextQuery().SocialGroup))) { return; } this.leaderboardData = result; uint displayCurrentPage = this.currentPage + 1; if (this.leaderboardData.TotalRowCount == 0) { this.totalPages = 0; displayCurrentPage = 0; } else if (this.totalPages == 0) { this.totalPages = this.leaderboardData.TotalRowCount / this.entryCount; } this.pageText.text = string.Format("{0} | {1}", displayCurrentPage, Mathf.Max(displayCurrentPage, this.totalPages)); this.Clear(); IList <string> xuids = new List <string>(); var rowCount = 0; foreach (LeaderboardRow row in this.leaderboardData.Rows) { xuids.Add(row.XboxUserId); GameObject entryObject = this.entryObjectPool.GetObject(); PlayerProfile entry = entryObject.GetComponent <PlayerProfile>(); entry.Theme = this.Theme; entry.IsCurrentPlayer = this.xboxLiveUser != null && row.Gamertag.Equals(this.xboxLiveUser.Gamertag); entry.BackgroundColor = ((rowCount % 2 == 0) ? PlayerProfileBackgrounds.RowBackground02 : PlayerProfileBackgrounds.RowBackground01); entry.UpdateGamerTag(row.Gamertag); entry.UpdateRank(true, row.Rank); if (row.Values != null && row.Values.Count > 0) { entry.UpdateScore(true, row.Values[0]); } this.StartCoroutine(entry.Reload()); entryObject.transform.SetParent(this.contentPanel); this.currentEntries.Add(entry); rowCount++; entryObject.transform.localScale = Vector3.one; } if (xuids.Count > 0) { userGroup = XboxLive.Instance.SocialManager.CreateSocialUserGroupFromList(this.xboxLiveUser, xuids); } // Reset the scroll view to the top. this.scrollRect.verticalNormalizedPosition = 1; this.UpdateButtons(); }