private static void OnScoresDownloaded( LeaderboardScoresDownloaded_t scores, bool bIOFailure ) { if (!bIOFailure && scores.m_hSteamLeaderboardEntries.m_SteamLeaderboardEntries != 0) { readAction.Entries = new List <LeaderboardEntry>(scores.m_cEntryCount); LeaderboardEntry_t entry; for (int i = 0; i < scores.m_cEntryCount; i += 1) { SteamUserStats.GetDownloadedLeaderboardEntry( scores.m_hSteamLeaderboardEntries, i, out entry, null, 0 ); readAction.Entries.Add( new LeaderboardEntry( new LeaderboardGamer(entry.m_steamIDUser), entry.m_nScore, entry.m_nGlobalRank, readAction.Leaderboard ) ); } } readAction.IsCompleted = true; }
private void ParseLeaderboardData(LeaderboardScoresDownloaded_t steamData) { UnityEngine.Debug.Log("Steam ParseLeaderboardData"); List <OutrunLeaderboard.Entry> result = new List <OutrunLeaderboard.Entry> (); for (var i = 0; i < steamData.m_cEntryCount; i++) { LeaderboardEntry_t steamEntry; SteamUserStats.GetDownloadedLeaderboardEntry(steamData.m_hSteamLeaderboardEntries, i, out steamEntry, null, 0); OutrunLeaderboard.Entry resulEntry = new OutrunLeaderboard.Entry() { userId = steamEntry.m_steamIDUser.ToString() , userName = SteamFriends.GetFriendPersonaName(steamEntry.m_steamIDUser) , distance = steamEntry.m_nScore , rank = steamEntry.m_nGlobalRank , isMe = (steamEntry.m_steamIDUser == _playerId) }; result.Add(resulEntry); } if (OnLeaderboardData != null) { OnLeaderboardData(result); } }
private void DoPageUp( LeaderboardScoresDownloaded_t scores, bool bioFailure ) { if (scores.m_hSteamLeaderboardEntries.m_SteamLeaderboardEntries != 0) { LeaderboardEntry_t entry; for (int i = scores.m_cEntryCount - 1; i >= 0; i -= 1) { SteamUserStats.GetDownloadedLeaderboardEntry( scores.m_hSteamLeaderboardEntries, i, out entry, null, 0 ); entryCache.Insert( 0, new LeaderboardEntry( new LeaderboardGamer(entry.m_steamIDUser), entry.m_nScore, entry.m_nGlobalRank, readAction.Leaderboard ) ); } PageStart = PageStart + scores.m_cEntryCount - pageSize; } readAction.IsCompleted = true; }
/// <summary> /// 查询排行榜数据回调 /// </summary> /// <param name="pCallback"></param> /// <param name="bIOFailure"></param> void OnLeaderboardScoresDownloaded(LeaderboardScoresDownloaded_t pCallback, bool bIOFailure) { m_SteamLeaderboardEntries = pCallback.m_hSteamLeaderboardEntries; List <GetLeaderboardEntriesResult.LeaderboardEntries> listData = new List <GetLeaderboardEntriesResult.LeaderboardEntries>(); for (int i = 0; i < pCallback.m_cEntryCount; i++) { LeaderboardEntry_t entry_T; bool ret = SteamUserStats.GetDownloadedLeaderboardEntry(m_SteamLeaderboardEntries, i, out entry_T, null, 0); GetLeaderboardEntriesResult.LeaderboardEntries itemData = new GetLeaderboardEntriesResult.LeaderboardEntries(); itemData.score = entry_T.m_nScore; itemData.rank = entry_T.m_nGlobalRank; itemData.steamID = entry_T.m_steamIDUser.ToString(); listData.Add(itemData); } if (mFindDataType == 0) { OnLeaderboardEntriesFindResultCallBack.leaderboradEntriesFindResultForSelf(listData); } else if (mFindDataType == 1) { OnLeaderboardEntriesFindResultCallBack.leaderboradEntriesFindResultForAll(listData); } }
private void OnLeaderBoardScoresDownloaded(LeaderboardScoresDownloaded_t param, bool bIOFailure) { List <LeaderBoardVars> results = new List <LeaderBoardVars>(); if (bIOFailure) { Debug.LogError("Error getting leader board entries"); } else { int count = param.m_cEntryCount; SteamLeaderboardEntries_t entries = param.m_hSteamLeaderboardEntries; for (int i = 0; i < count; i++) { LeaderboardEntry_t entry; int[] details = new int[MAX_DETAILS]; if (SteamUserStats.GetDownloadedLeaderboardEntry(entries, i, out entry, details, MAX_DETAILS)) { LeaderBoardVars leaderBoardVars = ExtractLeaderBoardVars(entry, details); results.Add(leaderBoardVars); } } results = SortEntries(results); } callbackAction(results, false); }
private void OnLeaderboardScoresDownloadedForUserList(LeaderboardScoresDownloaded_t itemResult, bool bIOFailure) { if (bIOFailure) { if (mEntriesCallBack != null) { mEntriesCallBack.GetEntriesForUserListFail(SteamLeaderboardFailEnum.GETLIST_FAIL); } return; } SteamLeaderboardEntries_t entriesData = itemResult.m_hSteamLeaderboardEntries; List <SteamLeaderboardEntryBean> listData = new List <SteamLeaderboardEntryBean>(); for (int i = 0; i < itemResult.m_cEntryCount; i++) { LeaderboardEntry_t entry_T; int[] detailsInt = new int[64]; SteamUserStats.GetDownloadedLeaderboardEntry(entriesData, i, out entry_T, detailsInt, 64); SteamLeaderboardEntryBean itemData = new SteamLeaderboardEntryBean { score = entry_T.m_nScore, rank = entry_T.m_nGlobalRank, steamID = entry_T.m_steamIDUser, details = detailsInt }; listData.Add(itemData); } if (mEntriesCallBack != null) { mEntriesCallBack.GetEntriesForUserListSuccess(itemResult.m_hSteamLeaderboard.m_SteamLeaderboard, listData); } }
private void DoPageDown( LeaderboardScoresDownloaded_t scores, bool bioFailure ) { if (scores.m_hSteamLeaderboardEntries.m_SteamLeaderboardEntries != 0) { LeaderboardEntry_t entry; for (int i = 0; i < scores.m_cEntryCount; i += 1) { SteamUserStats.GetDownloadedLeaderboardEntry( scores.m_hSteamLeaderboardEntries, i, out entry, null, 0 ); entryCache.Add( new LeaderboardEntry( new LeaderboardGamer(entry.m_steamIDUser), entry.m_nScore, entry.m_nGlobalRank, readAction.Leaderboard ) ); } } readAction.IsCompleted = true; }
//This checks if the leaderboard was successfully downloaded or not and updates the variables that'll be used in conjuction with the SteamAPI Handler static private void OnLeaderBoardScoresDownloaded(LeaderboardScoresDownloaded_t _callback, bool _IOFailure) { m_leaderboardEntries = _callback.m_hSteamLeaderboardEntries; m_leaderboardCount = _callback.m_cEntryCount; Debug.Log("Leaderboard: " + _callback.m_hSteamLeaderboard + " Entries: " + _callback.m_hSteamLeaderboardEntries + "Count: " + _callback.m_cEntryCount); }
void OnDownloadScore(LeaderboardScoresDownloaded_t callback, bool ioFailure) { if (!ioFailure) { int leaderBoardEntryAmount = Mathf.Min(callback.m_cEntryCount, leaderBoardEntryMax); Debug.Log("Downloaded " + leaderBoardEntryAmount + " Scores:"); if (leaderBoardEntryAmount <= 0) { Debug.Log("Retrying Download as user without score..."); DownloadScores(true); return; } loadedScores = new SteamScoreEntry[leaderBoardEntryAmount]; LeaderboardEntry_t currentEntry; for (int i = 0; i < leaderBoardEntryAmount; i++) { SteamUserStats.GetDownloadedLeaderboardEntry(callback.m_hSteamLeaderboardEntries, i, out currentEntry, null, 0); loadedScores[i] = new SteamScoreEntry(currentEntry.m_steamIDUser, currentEntry.m_nGlobalRank, 1 / ((float)currentEntry.m_nScore / scoreMultiplier)); } } else { Debug.LogWarning("Failure to download scores"); } downloadInProgress = false; }
private void OnLeaderboardFindAroundUser(LeaderboardScoresDownloaded_t pCallback, bool failure) { Debug.Log("STEAM LEADERBOARDS: found " + pCallback.m_cEntryCount + " entries around user with failure: " + failure); s_entriesAroundUser = pCallback.m_hSteamLeaderboardEntries; entriesAroundUser = GetDownloadedEntries(s_entriesAroundUser, pCallback.m_cEntryCount); OnLeaderboardUpdate.Invoke(failure); }
private void OnLeaderboardFindTopTen(LeaderboardScoresDownloaded_t pCallback, bool failure) { Debug.Log("STEAM LEADERBOARDS: found top " + pCallback.m_cEntryCount + " entries with failure: " + failure); s_entriesTopTen = pCallback.m_hSteamLeaderboardEntries; entriesTopTen = GetDownloadedEntries(s_entriesTopTen, pCallback.m_cEntryCount); OnLeaderboardUpdate.Invoke(failure); }
// SteamAPICall_t public CallbackHandle DownloadLeaderboardEntries( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/, LeaderboardDataRequest eLeaderboardDataRequest /*ELeaderboardDataRequest*/, int nRangeStart /*int*/, int nRangeEnd /*int*/, Action<LeaderboardScoresDownloaded_t, bool> CallbackFunction = null /*Action<LeaderboardScoresDownloaded_t, bool>*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUserStats_DownloadLeaderboardEntries( hSteamLeaderboard.Value, eLeaderboardDataRequest, nRangeStart, nRangeEnd ); if ( CallbackFunction == null ) return null; return LeaderboardScoresDownloaded_t.CallResult( steamworks, callback, CallbackFunction ); }
private void download(SteamLeaderboard_t leaderboard) { #if STEAMWORKS this.globalLeaderboardDownloadCall = new CallResult <LeaderboardScoresDownloaded_t>((downloaded, downloadedFailure) => { this.globalLeaderboardDownloadCall = null; if (downloadedFailure) { this.OnLeaderboardError.Execute(); } else { if (downloaded.m_cEntryCount == 0) { // We're not ranked // Get the top global list this.globalLeaderboardDownloadCall = new CallResult <LeaderboardScoresDownloaded_t>((downloaded2, downloadedFailure2) => { if (downloadedFailure2) { this.OnLeaderboardError.Execute(); } else { this.globalScoresDownloaded = true; this.globalScores = downloaded2; this.checkLeaderboardsDownloaded(); } }); this.globalLeaderboardDownloadCall.Set(SteamUserStats.DownloadLeaderboardEntries(leaderboard, ELeaderboardDataRequest.k_ELeaderboardDataRequestGlobal, 0, this.before + this.after)); } else { this.globalScoresDownloaded = true; this.globalScores = downloaded; this.checkLeaderboardsDownloaded(); } } }); this.globalLeaderboardDownloadCall.Set(SteamUserStats.DownloadLeaderboardEntries(leaderboard, ELeaderboardDataRequest.k_ELeaderboardDataRequestGlobalAroundUser, -this.before, this.after)); this.friendLeaderboardDownloadCall = new CallResult <LeaderboardScoresDownloaded_t>((downloaded, downloadedFailure) => { this.friendLeaderboardDownloadCall = null; if (downloadedFailure) { this.OnLeaderboardError.Execute(); } else { this.friendScoresDownloaded = true; this.friendScores = downloaded; this.checkLeaderboardsDownloaded(); } }); this.friendLeaderboardDownloadCall.Set(SteamUserStats.DownloadLeaderboardEntries(leaderboard, ELeaderboardDataRequest.k_ELeaderboardDataRequestFriends, -this.friendsBefore, this.friendsAfter)); #endif }
// SteamAPICall_t public CallbackHandle DownloadLeaderboardEntriesForUsers( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/, IntPtr prgUsers /*class CSteamID **/, int cUsers /*int*/, Action<LeaderboardScoresDownloaded_t, bool> CallbackFunction = null /*Action<LeaderboardScoresDownloaded_t, bool>*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUserStats_DownloadLeaderboardEntriesForUsers( hSteamLeaderboard.Value, (IntPtr) prgUsers, cUsers ); if ( CallbackFunction == null ) return null; return LeaderboardScoresDownloaded_t.CallResult( steamworks, callback, CallbackFunction ); }
void OnLeaderboardScoresDownloaded(LeaderboardScoresDownloaded_t param, bool ioError) { // IF the score board has been destroyed if (bodyText == null) { return; } if (ioError) { // Handle score download failure Debug.Log("Fail"); return; } // If arcade mode make it so it says "points" instead of walls string wallsOrPoints = "Walls"; if (titleText.text.Contains("ARCADE MODE")) { wallsOrPoints = "Points"; } // You should probably check whether param.m_hSteamLeaderboard is // the one you want to handle. bool entryAdded = false; bodyText.text = ""; List <string> entries = new List <string>(); for (int i = 0; i < param.m_cEntryCount; ++i) { LeaderboardEntry_t entry; // I assume you don't store any details // Not sure if the array is required to be non-null if (SteamUserStats.GetDownloadedLeaderboardEntry(param.m_hSteamLeaderboardEntries, i, out entry, null, 0)) { entryAdded = true; string playerName = SteamFriends.GetFriendPersonaName(entry.m_steamIDUser); if (playerName.Length > 20) // Truncate Long names { string f = playerName.Substring(0, 15); playerName = f + "..." + playerName.Substring(playerName.Length - 3); } entries.Add(string.Format("Position {0} | {1} With {2} " + wallsOrPoints, entry.m_nGlobalRank, playerName, entry.m_nScore)); //entries.Add(string.Format("{0}: rank {1}, score {2}", playerName, entry.m_nGlobalRank, entry.m_nScore)); bodyText.text = bodyText.text + " " + entries[i] + "\n"; } } if (entryAdded == false) { bodyText.text = "Exercise to see where you land..."; } }
private void OnLeaderboardScoresDownloaded(LeaderboardScoresDownloaded_t param, bool bIOFailure) { var playerIncluded = ProcessScoresDownloaded(param, bIOFailure); //if (param.m_cEntryCount > 1 || (param.m_cEntryCount == 1 && !playerIncluded)) OnQueryResults.Invoke(new LeaderboardScoresDownloaded() { bIOFailure = bIOFailure, scoreData = param, playerIncluded = playerIncluded }); }
private void OnScores(LeaderboardScoresDownloaded_t result, bool error) { IsQuerying = false; if (client == null) { return; } if (error) return; }
/// <summary> /// Ons the leaderboard scores downloaded. /// </summary> /// <param name="pCallback">P callback.</param> /// <param name="bIOFailure">If set to <c>true</c> b IOF ailure.</param> private void OnLeaderboardScoresDownloaded(LeaderboardScoresDownloaded_t pCallback, bool bIOFailure) { Debug.Log("[" + LeaderboardScoresDownloaded_t.k_iCallback + " - LeaderboardScoresDownloaded] - " + pCallback.m_hSteamLeaderboard + " -- " + pCallback.m_hSteamLeaderboardEntries + " -- " + pCallback.m_cEntryCount); SteamLeaderboardEntries = pCallback.m_hSteamLeaderboardEntries; CurrentDownloadEntryCnt = pCallback.m_cEntryCount; if (callBackDownload != null) { callBackDownload(pCallback); } }
void DownloadResult(LeaderboardScoresDownloaded_t downResult, bool failure) { //Debug.Log("STEAM LEADERBOARDS: isfailure = " + failure + ") Num Entries = " + downResult.m_cEntryCount); List <LeaderboardElement> newList = new List <LeaderboardElement>(); LeaderboardEntry_t returnEntry; int[] details = new int[1]; int maxDetailElems = 1; //getting full leaderboard //downResult.m_cEntryCount for (int i = 0; i < 10; i++) { if (i < downResult.m_cEntryCount) { SteamUserStats.GetDownloadedLeaderboardEntry(downResult.m_hSteamLeaderboardEntries, i, out returnEntry, details, maxDetailElems); LeaderboardElement newElem; newElem.rank = returnEntry.m_nGlobalRank.ToString(); newElem.name = SteamFriends.GetFriendPersonaName(returnEntry.m_steamIDUser); newElem.score = returnEntry.m_nScore.ToString(); newList.Add(newElem); } else { LeaderboardElement newElm; newElm.rank = "NULL"; newElm.name = "NULL"; newElm.score = "NULL"; newList.Add(newElm); } } //store in the list we want switch (wantedType) { case (0): leaderboardElementsFriends = new List <LeaderboardElement>(newList); break; case (1): leaderboardElementsGlobalClose = new List <LeaderboardElement>(newList); break; case (2): leaderboardElementsGlobal = new List <LeaderboardElement>(newList); break; } //Debug.Log("Updated " + wantedType + " leaderboard"); }
private void IniSteamLeaderboardScoresDownloadedFriends(LeaderboardScoresDownloaded_t pCallback, bool bIOFailure) { if (pCallback.m_hSteamLeaderboard.m_SteamLeaderboard == 0 || bIOFailure) { Debug.Log("SteamLeaderboard_t Friends Error"); } else { Debug.Log("SteamLeaderboard_t Friends OK"); SteamleaderboardScoresDownloaded_Friends = pCallback; getterLeaderboardDownloadFriends = true; } }
private void OnLeaderboardTop100Downloaded(LeaderboardScoresDownloaded_t pCallback, bool bIOFailure) { if (pCallback.m_cEntryCount == 0) { Debug.Log("[LeaderBoard] Top100: No entries Found"); } else { Debug.Log("[LeaderBoardTop100] Top100: " + pCallback.m_cEntryCount + " entries found"); topEntriesCount = pCallback.m_cEntryCount; hSteamTop100Entries = pCallback.m_hSteamLeaderboardEntries; downLoadingTop100Entries = false; } }
void DownloadPersonalResult(LeaderboardScoresDownloaded_t downResult, bool failure) { LeaderboardEntry_t returnEntry; int[] details = new int[1]; int maxDetailElems = 1; //getting own score/rank/name SteamUserStats.GetDownloadedLeaderboardEntry(downResult.m_hSteamLeaderboardEntries, 0, out returnEntry, details, maxDetailElems); thisRank.text = returnEntry.m_nGlobalRank.ToString(); thisName.text = "YOU"; thisScore.text = returnEntry.m_nScore.ToString(); //Debug.Log("Updated personal leaderboard"); }
public void OnLeaderboardDownloadedEntries(LeaderboardScoresDownloaded_t pLeaderboardScoresDownloaded, bool bIOFailure) { if (!bIOFailure) { SteamStats.s_nLeaderboardEntriesFound = Math.Min(pLeaderboardScoresDownloaded.m_cEntryCount, 1000); for (int index = 0; index < SteamStats.s_nLeaderboardEntriesFound; index++) { SteamUserStats.GetDownloadedLeaderboardEntry( pLeaderboardScoresDownloaded.m_hSteamLeaderboardEntries, index, out SteamStats.m_leaderboardEntries[index], null, 0); } } SteamStats.s_OnDownload.Invoke(bIOFailure); }
private void OnleaderboardScoresDownloaded(LeaderboardScoresDownloaded_t pCallback, bool bIOFailure) { if (pCallback.m_cEntryCount == 0) { Debug.Log("[LeaderBoard] No entries Found"); SetLeaderBoardScore(1200); uic.intro_playerMMR.text = "mmr: 1200"; pc.playerMMR = 1200; pc.newPlayer = true; uic.fetchSteamLeaderboardEntry = false; } else { Debug.Log("[LeaderBoard] " + pCallback.m_cEntryCount + " entry found"); hSteamLeaderboardEntry = pCallback.m_hSteamLeaderboardEntries; downLoadingUserEntry = false; downloadedLeaderboard = true; } }
private void OnScores(LeaderboardScoresDownloaded_t result, bool error) { IsQuerying = false; if (client == null) { return; } if (error) { return; } var list = new List <Entry>(); ReadScores(result, list); Results = list.ToArray(); }
private void OnLeaderboardDownloaded(LeaderboardScoresDownloaded_t param, bool bIOFailure) { if (bIOFailure) { Console.WriteLine("Something broke while downloading the leaderboard"); } else { done = true; Console.WriteLine("Leaderboard Downloaded!"); for (int i = 0; i < param.m_cEntryCount; i++) { LeaderboardEntry_t leaderboardEntry; int[] details = new int[10]; SteamUserStats.GetDownloadedLeaderboardEntry(param.m_hSteamLeaderboardEntries, i, out leaderboardEntry, details, 10); this.leaderboard.Add(new LeaderboardEntry(leaderboardEntry)); } } }
void ScoresDownloaded_OnRun(ulong callHandle, LeaderboardScoresDownloaded_t param) { if (callHandle == personalCall) { try { this.Invoke(new MethodInvoker(() => { LeaderboardEntry001_t entry = LBContext.GetLBEntry(param.m_hSteamLeaderboardEntries, 0); rankLabel.Text = string.Format("#{0}", entry.m_nGlobalRank); rankBox.Text = entry.m_nScore.ToString(); })); LoadLeaderboard(param.m_hSteamLeaderboard); } finally { personalCall = 0; } } else if (callHandle == leaderCall) { try { this.Invoke(new MethodInvoker(() => { leaderPanel.Controls.Clear(); for (int x = 0; x < param.m_cEntryCount; ++x) { RankControl rc = new RankControl(LBContext.GetLBEntry(param.m_hSteamLeaderboardEntries, x)); leaderPanel.Controls.Add(rc); } })); } finally { leaderCall = 0; } } }
private void OnLeaderboardDownloadResult(LeaderboardScoresDownloaded_t pCallback, bool failure) { Debug.Log($"Steam Leaderboard Download: Did it fail? {failure}, Result - {pCallback.m_hSteamLeaderboardEntries}"); LeaderboardDataset = new List <LeaderboardData>(); //Iterates through each entry gathered in leaderboard for (int i = 0; i < pCallback.m_cEntryCount; i++) { LeaderboardEntry_t leaderboardEntry; SteamUserStats.GetDownloadedLeaderboardEntry(pCallback.m_hSteamLeaderboardEntries, i, out leaderboardEntry, null, 0); //Example of how leaderboardEntry might be held/used LeaderboardData lD; lD.username = SteamFriends.GetFriendPersonaName(leaderboardEntry.m_steamIDUser); lD.rank = leaderboardEntry.m_nGlobalRank; lD.score = leaderboardEntry.m_nScore; LeaderboardDataset.Add(lD); Debug.Log($"User: {lD.username} - Score: {lD.score} - Rank: {lD.rank}"); } //This is the callback for my own project - function is asynchronous so it must return from here rather than from GetLeaderBoardData FindObjectOfType <HighscoreUIMan>().FillLeaderboard(LeaderboardDataset); }
private void OnLeaderboardFindUser(LeaderboardScoresDownloaded_t pCallback, bool failure) { if (pCallback.m_cEntryCount == 0) { failure = true; } Debug.Log("STEAM LEADERBOARDS: found user entry with failure: " + failure); s_userEntry = pCallback.m_hSteamLeaderboardEntries; if (pCallback.m_cEntryCount == 1) { entryUser = GetDownloadedEntries(s_userEntry, pCallback.m_cEntryCount)[0]; } else { failure = true; } OnLeaderboardUpdate.Invoke(failure); }
private unsafe void ReadScores(LeaderboardScoresDownloaded_t result, List <Entry> dest) { for (var i = 0; i < result.CEntryCount; i++) fixed(int *ptr = subEntriesBuffer) { var entry = new LeaderboardEntry_t(); if (client.native.userstats.GetDownloadedLeaderboardEntry(result.SteamLeaderboardEntries, i, ref entry, (IntPtr)ptr, subEntriesBuffer.Length)) { dest.Add(new Entry { GlobalRank = entry.GlobalRank, Score = entry.Score, SteamId = entry.SteamIDUser, SubScores = entry.CDetails == 0 ? null : subEntriesBuffer.Take(entry.CDetails).ToArray(), Name = client.Friends.GetName(entry.SteamIDUser), AttachedFile = (entry.UGC >> 32) == 0xffffffff ? null : new RemoteFile(client.RemoteStorage, entry.UGC) }); } } }