public override int GetScore(string leaderbordId) { if (IsSignedIn) { if (leaderbordsStatus.ContainsKey(leaderbordId) && leaderbordsStatus[leaderbordId] != null) { CSteamID[] users = new CSteamID[1]; users[0] = SteamUser.GetSteamID(); SteamAPICall_t handle = SteamUserStats.DownloadLeaderboardEntriesForUsers(leaderbordsStatus[leaderbordId].Value, users, users.Length); CallResult <LeaderboardScoresDownloaded_t> getScoreCallBack = new CallResult <LeaderboardScoresDownloaded_t>(); getScoreCallBack.Set(handle, (LeaderboardScoresDownloaded_t pCallback, bool bIOFailure) => OnLeaderboardScoresDownloaded(pCallback, bIOFailure)); } else { if (leaderboardGetScoreQueue.IndexOf(leaderbordId) == -1) { InitLeaderboard(leaderbordId); leaderboardGetScoreQueue.Add(leaderbordId); } } } return(-1); }
public void DownloadUserEntry() { Debug.Log("[LeaderBoard] downloading your leaderboard entry"); downLoadingUserEntry = true; CSteamID[] cSteamID = new CSteamID[1]; cSteamID[0] = SteamUser.GetSteamID(); SteamAPICall_t handle3 = SteamUserStats.DownloadLeaderboardEntriesForUsers(hSteamLeaderboard, cSteamID, 1); m_LeaderBoardUserScoreDownloaded.Set(handle3); // set m_LeaderBoardUserScoreDownloaded with the user downloaded leaderboard entry }
/// <summary> /// Refreshes the user's entry for this board /// </summary> public void RefreshUserEntry() { if (!LeaderboardId.HasValue) { Debug.LogError(name + " Leaderboard Data Object, cannot download scores, the leaderboard has not been initalized and cannot download scores."); return; } CSteamID[] users = new CSteamID[] { SteamUser.GetSteamID() }; var handle = SteamUserStats.DownloadLeaderboardEntriesForUsers(LeaderboardId.Value, users, 1); OnLeaderboardScoresDownloadedCallResult.Set(handle, OnLeaderboardUserRefreshRequest); }
public void findLeaderboardEntriesForUser(ulong leaderboardId, LeaderboardEntriesFindResultCallBack callBack) { mFindDataType = 0; OnLeaderboardEntriesFindResultCallBack = callBack; m_SteamLeaderboard = new SteamLeaderboard_t(); m_SteamLeaderboard.m_SteamLeaderboard = leaderboardId; OnLeaderboardScoresDownloadedCallResult = CallResult <LeaderboardScoresDownloaded_t> .Create(OnLeaderboardScoresDownloaded); CSteamID[] Users = { SteamUser.GetSteamID() }; SteamAPICall_t handle = SteamUserStats.DownloadLeaderboardEntriesForUsers(m_SteamLeaderboard, Users, Users.Length); //TODO 必须要延迟才能设置回调 Thread.Sleep(1000); OnLeaderboardScoresDownloadedCallResult.Set(handle); }
/// <summary> /// 查询指定用户组所在的全球排名数据 /// </summary> /// <param name="leaderboardId"></param> /// <param name="userList"></param> /// <param name="callBack"></param> public void FindLeaderboardEntriesForUserList(ulong leaderboardId, CSteamID[] userList, ISteamLeaderboardEntriesCallBack callBack) { this.mEntriesCallBack = callBack; SteamLeaderboard_t tempBean = new SteamLeaderboard_t { m_SteamLeaderboard = leaderboardId }; CallResult <LeaderboardScoresDownloaded_t> callResult = CallResult <LeaderboardScoresDownloaded_t> .Create(OnLeaderboardScoresDownloadedForUserList); SteamAPICall_t handle = SteamUserStats.DownloadLeaderboardEntriesForUsers(tempBean, userList, userList.Length); //TODO 必须要延迟才能设置回调 //Thread.Sleep(1000); callResult.Set(handle); }
/// <summary> /// エントリ取得:指定スチームユーザID配列 /// </summary> /// <returns><c>true</c>, if score users was downloaded, <c>false</c> otherwise.</returns> /// <param name="_arrayIDs">ユーザID配列</param> public bool DownloadScoreUsers(CSteamID[] _arrayIDs, CallBackDownload _callback = null) { if (steamLeaderboard == null) { return(false); } callBackDownload = _callback; CurrentDownloadEntryCnt = 0; //CSteamID[] a = { SteamUser.GetSteamID() }; SteamAPICall_t handle = SteamUserStats.DownloadLeaderboardEntriesForUsers((SteamLeaderboard_t)steamLeaderboard, _arrayIDs, _arrayIDs.Length); leaderboardScoresDownloaded.Set(handle); return(true); }
public void DownloadEntries() { //download entries from steam! if (s_initialized == false) { return; } SteamAPICall_t hSteamAPICall = SteamUserStats.DownloadLeaderboardEntries(s_currentLeaderboard, ELeaderboardDataRequest.k_ELeaderboardDataRequestGlobal, 0, 9); m_downloadResultTopTen.Set(hSteamAPICall, OnLeaderboardFindTopTen); SteamAPICall_t hSteamAPICallB = SteamUserStats.DownloadLeaderboardEntries(s_currentLeaderboard, ELeaderboardDataRequest.k_ELeaderboardDataRequestGlobalAroundUser, -5, 4); m_downloadResultAroundUser.Set(hSteamAPICallB, OnLeaderboardFindAroundUser); SteamAPICall_t hSteamAPICallC = SteamUserStats.DownloadLeaderboardEntriesForUsers(s_currentLeaderboard, new CSteamID[] { SteamUser.GetSteamID() }, 1); m_downloadResultUser.Set(hSteamAPICallC, OnLeaderboardFindUser); }
private void RenderPageTwo() { if (GUILayout.Button("FindOrCreateLeaderboard(\"Feet Traveled\", k_ELeaderboardSortMethodAscending, k_ELeaderboardDisplayTypeNumeric)")) { SteamAPICall_t handle = SteamUserStats.FindOrCreateLeaderboard("Feet Traveled", ELeaderboardSortMethod.k_ELeaderboardSortMethodAscending, ELeaderboardDisplayType.k_ELeaderboardDisplayTypeNumeric); LeaderboardFindResult.Set(handle); print("FindOrCreateLeaderboard(\"Feet Traveled\", ELeaderboardSortMethod.k_ELeaderboardSortMethodAscending, ELeaderboardDisplayType.k_ELeaderboardDisplayTypeNumeric) - " + handle); } if (GUILayout.Button("FindLeaderboard(\"Feet Traveled\")")) { SteamAPICall_t handle = SteamUserStats.FindLeaderboard("Feet Traveled"); LeaderboardFindResult.Set(handle); print("FindLeaderboard(\"Feet Traveled\") - " + handle); } // Spams SteamAPI Warnings that the SteamLeaderboard does not exist. if (m_SteamLeaderboard != new SteamLeaderboard_t(0)) { GUILayout.Label("GetLeaderboardName(m_SteamLeaderboard) : " + SteamUserStats.GetLeaderboardName(m_SteamLeaderboard)); GUILayout.Label("GetLeaderboardEntryCount(m_SteamLeaderboard) : " + SteamUserStats.GetLeaderboardEntryCount(m_SteamLeaderboard)); GUILayout.Label("GetLeaderboardSortMethod(m_SteamLeaderboard) : " + SteamUserStats.GetLeaderboardSortMethod(m_SteamLeaderboard)); GUILayout.Label("GetLeaderboardDisplayType(m_SteamLeaderboard) : " + SteamUserStats.GetLeaderboardDisplayType(m_SteamLeaderboard)); } else { GUILayout.Label("GetLeaderboardName(m_SteamLeaderboard) : "); GUILayout.Label("GetLeaderboardEntryCount(m_SteamLeaderboard) : "); GUILayout.Label("GetLeaderboardSortMethod(m_SteamLeaderboard) : "); GUILayout.Label("GetLeaderboardDisplayType(m_SteamLeaderboard) : "); } if (GUILayout.Button("DownloadLeaderboardEntries(m_SteamLeaderboard, ELeaderboardDataRequest.k_ELeaderboardDataRequestGlobal, 1, 5)")) { SteamAPICall_t handle = SteamUserStats.DownloadLeaderboardEntries(m_SteamLeaderboard, ELeaderboardDataRequest.k_ELeaderboardDataRequestGlobal, 1, 5); LeaderboardScoresDownloaded.Set(handle); print("DownloadLeaderboardEntries(" + m_SteamLeaderboard + ", ELeaderboardDataRequest.k_ELeaderboardDataRequestGlobal, 1, 5) - " + handle); } if (GUILayout.Button("DownloadLeaderboardEntriesForUsers(m_SteamLeaderboard, Users, Users.Length)")) { CSteamID[] Users = { SteamUser.GetSteamID() }; SteamAPICall_t handle = SteamUserStats.DownloadLeaderboardEntriesForUsers(m_SteamLeaderboard, Users, Users.Length); LeaderboardScoresDownloaded.Set(handle); print("DownloadLeaderboardEntriesForUsers(" + m_SteamLeaderboard + ", " + Users + ", " + Users.Length + ") - " + handle); } if (GUILayout.Button("GetDownloadedLeaderboardEntry(m_SteamLeaderboardEntries, 0, out LeaderboardEntry, null, 0)")) { LeaderboardEntry_t LeaderboardEntry; bool ret = SteamUserStats.GetDownloadedLeaderboardEntry(m_SteamLeaderboardEntries, 0, out LeaderboardEntry, null, 0); print("GetDownloadedLeaderboardEntry(" + m_SteamLeaderboardEntries + ", 0, out LeaderboardEntry, null, 0) - " + ret + " -- " + LeaderboardEntry.m_steamIDUser + " -- " + LeaderboardEntry.m_nGlobalRank + " -- " + LeaderboardEntry.m_nScore + " -- " + LeaderboardEntry.m_cDetails + " -- " + LeaderboardEntry.m_hUGC); } if (GUILayout.Button("UploadLeaderboardScore(m_SteamLeaderboard, k_ELeaderboardUploadScoreMethodForceUpdate, (int)m_FeetTraveledStat, ScoreDetails, 0)")) { SteamAPICall_t handle = SteamUserStats.UploadLeaderboardScore(m_SteamLeaderboard, ELeaderboardUploadScoreMethod.k_ELeaderboardUploadScoreMethodForceUpdate, (int)m_FeetTraveledStat, null, 0); LeaderboardScoreUploaded.Set(handle); print("UploadLeaderboardScore(" + m_SteamLeaderboard + ", ELeaderboardUploadScoreMethod.k_ELeaderboardUploadScoreMethodForceUpdate, " + (int)m_FeetTraveledStat + ", null, 0) - " + handle); } if (GUILayout.Button("SteamUserStats.AttachLeaderboardUGC(m_SteamLeaderboard, RemoteStorageTest.m_UGCHandle)")) { SteamAPICall_t handle = SteamUserStats.AttachLeaderboardUGC(m_SteamLeaderboard, UGCHandle_t.Invalid); LeaderboardUGCSet.Set(handle); print("SteamUserStats.AttachLeaderboardUGC(" + m_SteamLeaderboard + ", " + UGCHandle_t.Invalid + ") - " + handle); } if (GUILayout.Button("GetNumberOfCurrentPlayers()")) { SteamAPICall_t handle = SteamUserStats.GetNumberOfCurrentPlayers(); NumberOfCurrentPlayers.Set(handle); print("GetNumberOfCurrentPlayers() - " + handle); } if (GUILayout.Button("RequestGlobalAchievementPercentages()")) { SteamAPICall_t handle = SteamUserStats.RequestGlobalAchievementPercentages(); GlobalAchievementPercentagesReady.Set(handle); print("RequestGlobalAchievementPercentages() - " + handle); } { int Iterator; { string Name; float Percent; bool Achieved; Iterator = SteamUserStats.GetMostAchievedAchievementInfo(out Name, 120, out Percent, out Achieved); if (Iterator != -1) { GUILayout.Label("GetMostAchievedAchievementInfo(out Name, 120, out Percent, out Achieved) : " + Iterator + " -- " + Name + " -- " + Percent + " -- " + Achieved); } else { GUILayout.Label("GetMostAchievedAchievementInfo(out Name, 120, out Percent, out Achieved) : " + Iterator); } } if (Iterator != -1) { string Name; float Percent; bool Achieved; Iterator = SteamUserStats.GetNextMostAchievedAchievementInfo(Iterator, out Name, 120, out Percent, out Achieved); GUILayout.Label("GetNextMostAchievedAchievementInfo(out Name, 120, out Percent, out Achieved) : " + Iterator + " -- " + Name + " -- " + Percent + " -- " + Achieved); } } { float Percent; bool ret = SteamUserStats.GetAchievementAchievedPercent("ACH_WIN_100_GAMES", out Percent); GUILayout.Label("GetAchievementAchievedPercent(\"ACH_WIN_100_GAMES\", out Percent) : " + ret + " -- " + Percent); } if (GUILayout.Button("SteamUserStats.RequestGlobalStats(3)")) { SteamAPICall_t handle = SteamUserStats.RequestGlobalStats(3); GlobalStatsReceived.Set(handle); print("SteamUserStats.RequestGlobalStats(3) - " + handle); } /* TODO - Spams SteamAPI warnings * Does SpaceWar have a stat marked as "aggregated" to try out these functions? * { * long Data; * bool ret = SteamUserStats.GetGlobalStat("", out Data); * GUILayout.Label("GetGlobalStat(\"\", out Data) : " + ret + " -- " + Data); * } * * { * double Data; * bool ret = SteamUserStats.GetGlobalStat("", out Data); * GUILayout.Label("GetGlobalStat(\"\", out Data) : " + ret + " -- " + Data); * } * * { * long[] Data = new long[1]; * int ret = SteamUserStats.GetGlobalStatHistory("", Data, (uint)Data.Length); * if (ret != 0) { * GUILayout.Label("GetGlobalStatHistory(\"\", Data, " + (uint)Data.Length + ") : " + ret + " -- " + Data[0]); * } * else { * GUILayout.Label("GetGlobalStatHistory(\"\", Data, " + (uint)Data.Length + ") : " + ret + " -- "); * } * } * * { * double[] Data = new double[1]; * int ret = SteamUserStats.GetGlobalStatHistory("", Data, (uint)Data.Length); * if (ret != 0) { * GUILayout.Label("GetGlobalStatHistory(\"\", Data, " + (uint)Data.Length + ") : " + ret + " -- " + Data[0]); * } * else { * GUILayout.Label("GetGlobalStatHistory(\"\", Data, " + (uint)Data.Length + ") : " + ret + " -- "); * } * } */ #if _PS3 if (GUILayout.Button("InstallPS3Trophies()")) { bool ret = SteamUserStats.InstallPS3Trophies(); print("InstallPS3Trophies() - " + ret); } if (GUILayout.Button("GetTrophySpaceRequiredBeforeInstall()")) { ulong ret = SteamUserStats.GetTrophySpaceRequiredBeforeInstall(); print("GetTrophySpaceRequiredBeforeInstall() - " + ret); } if (GUILayout.Button("SetUserStatsData(System.IntPtr.Zero, 0)")) { bool ret = SteamUserStats.SetUserStatsData(System.IntPtr.Zero, 0); print(" - " + ret); } if (GUILayout.Button("")) { uint Written; bool ret = SteamUserStats.GetUserStatsData(System.IntPtr.Zero, 0, out Written); print("GetUserStatsData(System.IntPtr.Zero, 0, out Written) - " + ret + " -- " + Written); } #endif }
public void RenderOnGUI() { GUILayout.BeginArea(new Rect(Screen.width - 200, 0, 200, Screen.height)); GUILayout.Label("Variables:"); GUILayout.Label("m_NumGamesStat: " + m_NumGamesStat); GUILayout.Label("m_FeetTraveledStat: " + m_FeetTraveledStat); GUILayout.Label("m_AchievedWinOneGame: " + m_AchievedWinOneGame); GUILayout.Label("m_SteamLeaderboard: " + m_SteamLeaderboard); GUILayout.Label("m_SteamLeaderboardEntries: " + m_SteamLeaderboardEntries); GUILayout.Label("m_Icon:"); GUILayout.Label(m_Icon); GUILayout.EndArea(); GUILayout.BeginVertical("box"); m_ScrollPos = GUILayout.BeginScrollView(m_ScrollPos, GUILayout.Width(Screen.width - 215), GUILayout.Height(Screen.height - 33)); if (GUILayout.Button("RequestCurrentStats()")) { bool ret = SteamUserStats.RequestCurrentStats(); print("SteamUserStats.RequestCurrentStats() : " + ret); } { bool ret = SteamUserStats.GetStat("NumGames", out m_NumGamesStat); GUILayout.Label("GetStat(\"NumGames\", out m_NumGamesStat) : " + ret + " -- " + m_NumGamesStat); } { bool ret = SteamUserStats.GetStat("FeetTraveled", out m_FeetTraveledStat); GUILayout.Label("GetStat(\"FeetTraveled\", out m_FeetTraveledStat) : " + ret + " -- " + m_FeetTraveledStat); } if (GUILayout.Button("SetStat(\"NumGames\", m_NumGamesStat + 1)")) { bool ret = SteamUserStats.SetStat("NumGames", m_NumGamesStat + 1); print("SteamUserStats.SetStat(" + "\"NumGames\"" + ", " + m_NumGamesStat + 1 + ") : " + ret); } if (GUILayout.Button("SetStat(\"FeetTraveled\", m_FeetTraveledStat + 1)")) { bool ret = SteamUserStats.SetStat("FeetTraveled", m_FeetTraveledStat + 1); print("SteamUserStats.SetStat(" + "\"FeetTraveled\"" + ", " + m_FeetTraveledStat + 1 + ") : " + ret); } if (GUILayout.Button("UpdateAvgRateStat(\"AverageSpeed\", 100, 60.0)")) { bool ret = SteamUserStats.UpdateAvgRateStat("AverageSpeed", 100, 60.0); print("SteamUserStats.UpdateAvgRateStat(" + "\"AverageSpeed\"" + ", " + 100 + ", " + 60.0 + ") : " + ret); } { bool ret = SteamUserStats.GetAchievement("ACH_WIN_ONE_GAME", out m_AchievedWinOneGame); GUILayout.Label("GetAchievement(\"ACH_WIN_ONE_GAME\", out m_AchievedWinOneGame) : " + ret + " -- " + m_AchievedWinOneGame); } if (GUILayout.Button("SetAchievement(\"ACH_WIN_ONE_GAME\")")) { bool ret = SteamUserStats.SetAchievement("ACH_WIN_ONE_GAME"); print("SteamUserStats.SetAchievement(" + "\"ACH_WIN_ONE_GAME\"" + ") : " + ret); } if (GUILayout.Button("ClearAchievement(\"ACH_WIN_ONE_GAME\")")) { bool ret = SteamUserStats.ClearAchievement("ACH_WIN_ONE_GAME"); print("SteamUserStats.ClearAchievement(" + "\"ACH_WIN_ONE_GAME\"" + ") : " + ret); } { bool Achieved; uint UnlockTime; bool ret = SteamUserStats.GetAchievementAndUnlockTime("ACH_WIN_ONE_GAME", out Achieved, out UnlockTime); GUILayout.Label("GetAchievementAndUnlockTime(\"ACH_WIN_ONE_GAME\", out Achieved, out UnlockTime) : " + ret + " -- " + Achieved + " -- " + UnlockTime); } if (GUILayout.Button("StoreStats()")) { bool ret = SteamUserStats.StoreStats(); print("SteamUserStats.StoreStats() : " + ret); } if (GUILayout.Button("GetAchievementIcon(\"ACH_WIN_ONE_GAME\")")) { int ret = SteamUserStats.GetAchievementIcon("ACH_WIN_ONE_GAME"); print("SteamUserStats.GetAchievementIcon(" + "\"ACH_WIN_ONE_GAME\"" + ") : " + ret); if (ret != 0) { m_Icon = SteamUtilsTest.GetSteamImageAsTexture2D(ret); } } GUILayout.Label("GetAchievementDisplayAttribute(\"ACH_WIN_ONE_GAME\", \"name\") : " + SteamUserStats.GetAchievementDisplayAttribute("ACH_WIN_ONE_GAME", "name")); if (GUILayout.Button("IndicateAchievementProgress(\"ACH_WIN_100_GAMES\", 10, 100)")) { bool ret = SteamUserStats.IndicateAchievementProgress("ACH_WIN_100_GAMES", 10, 100); print("SteamUserStats.IndicateAchievementProgress(" + "\"ACH_WIN_100_GAMES\"" + ", " + 10 + ", " + 100 + ") : " + ret); } GUILayout.Label("GetNumAchievements() : " + SteamUserStats.GetNumAchievements()); GUILayout.Label("GetAchievementName(0) : " + SteamUserStats.GetAchievementName(0)); if (GUILayout.Button("RequestUserStats(TestConstants.Instance.k_SteamId_rlabrecque)")) { SteamAPICall_t handle = SteamUserStats.RequestUserStats(TestConstants.Instance.k_SteamId_rlabrecque); OnUserStatsReceivedCallResult.Set(handle); print("SteamUserStats.RequestUserStats(" + TestConstants.Instance.k_SteamId_rlabrecque + ") : " + handle); } { int Data; bool ret = SteamUserStats.GetUserStat(TestConstants.Instance.k_SteamId_rlabrecque, "NumWins", out Data); GUILayout.Label("GetUserStat(TestConstants.Instance.k_SteamId_rlabrecque, \"NumWins\", out Data) : " + ret + " -- " + Data); } { float Data; bool ret = SteamUserStats.GetUserStat(TestConstants.Instance.k_SteamId_rlabrecque, "MaxFeetTraveled", out Data); GUILayout.Label("GetUserStat(TestConstants.Instance.k_SteamId_rlabrecque, \"MaxFeetTraveled\", out Data) : " + ret + " -- " + Data); } { bool Achieved; bool ret = SteamUserStats.GetUserAchievement(TestConstants.Instance.k_SteamId_rlabrecque, "ACH_TRAVEL_FAR_ACCUM", out Achieved); GUILayout.Label("GetUserAchievement(TestConstants.Instance.k_SteamId_rlabrecque, \"ACH_TRAVEL_FAR_ACCUM\", out Achieved) : " + ret + " -- " + Achieved); } { bool Achieved; uint UnlockTime; bool ret = SteamUserStats.GetUserAchievementAndUnlockTime(TestConstants.Instance.k_SteamId_rlabrecque, "ACH_WIN_ONE_GAME", out Achieved, out UnlockTime); GUILayout.Label("GetUserAchievementAndUnlockTime(TestConstants.Instance.k_SteamId_rlabrecque, \"ACH_WIN_ONE_GAME\", out Achieved, out UnlockTime) : " + ret + " -- " + Achieved + " -- " + UnlockTime); } if (GUILayout.Button("ResetAllStats(true)")) { bool ret = SteamUserStats.ResetAllStats(true); print("SteamUserStats.ResetAllStats(" + true + ") : " + ret); } if (GUILayout.Button("FindOrCreateLeaderboard(\"Feet Traveled\", ELeaderboardSortMethod.k_ELeaderboardSortMethodAscending, ELeaderboardDisplayType.k_ELeaderboardDisplayTypeNumeric)")) { SteamAPICall_t handle = SteamUserStats.FindOrCreateLeaderboard("Feet Traveled", ELeaderboardSortMethod.k_ELeaderboardSortMethodAscending, ELeaderboardDisplayType.k_ELeaderboardDisplayTypeNumeric); OnLeaderboardFindResultCallResult.Set(handle); print("SteamUserStats.FindOrCreateLeaderboard(" + "\"Feet Traveled\"" + ", " + ELeaderboardSortMethod.k_ELeaderboardSortMethodAscending + ", " + ELeaderboardDisplayType.k_ELeaderboardDisplayTypeNumeric + ") : " + handle); } if (GUILayout.Button("FindLeaderboard(\"Feet Traveled\")")) { SteamAPICall_t handle = SteamUserStats.FindLeaderboard("Feet Traveled"); OnLeaderboardFindResultCallResult.Set(handle); print("SteamUserStats.FindLeaderboard(" + "\"Feet Traveled\"" + ") : " + handle); } // Spams SteamAPI Warnings that the SteamLeaderboard does not exist. if (m_SteamLeaderboard != new SteamLeaderboard_t(0)) { GUILayout.Label("GetLeaderboardName(m_SteamLeaderboard) : " + SteamUserStats.GetLeaderboardName(m_SteamLeaderboard)); GUILayout.Label("GetLeaderboardEntryCount(m_SteamLeaderboard) : " + SteamUserStats.GetLeaderboardEntryCount(m_SteamLeaderboard)); GUILayout.Label("GetLeaderboardSortMethod(m_SteamLeaderboard) : " + SteamUserStats.GetLeaderboardSortMethod(m_SteamLeaderboard)); GUILayout.Label("GetLeaderboardDisplayType(m_SteamLeaderboard) : " + SteamUserStats.GetLeaderboardDisplayType(m_SteamLeaderboard)); } else { GUILayout.Label("GetLeaderboardName(m_SteamLeaderboard) : "); GUILayout.Label("GetLeaderboardEntryCount(m_SteamLeaderboard) : "); GUILayout.Label("GetLeaderboardSortMethod(m_SteamLeaderboard) : "); GUILayout.Label("GetLeaderboardDisplayType(m_SteamLeaderboard) : "); } if (GUILayout.Button("DownloadLeaderboardEntries(m_SteamLeaderboard, ELeaderboardDataRequest.k_ELeaderboardDataRequestGlobal, 1, 5)")) { SteamAPICall_t handle = SteamUserStats.DownloadLeaderboardEntries(m_SteamLeaderboard, ELeaderboardDataRequest.k_ELeaderboardDataRequestGlobal, 1, 5); OnLeaderboardScoresDownloadedCallResult.Set(handle); print("SteamUserStats.DownloadLeaderboardEntries(" + m_SteamLeaderboard + ", " + ELeaderboardDataRequest.k_ELeaderboardDataRequestGlobal + ", " + 1 + ", " + 5 + ") : " + handle); } if (GUILayout.Button("DownloadLeaderboardEntriesForUsers(m_SteamLeaderboard, Users, Users.Length)")) { CSteamID[] Users = { SteamUser.GetSteamID() }; SteamAPICall_t handle = SteamUserStats.DownloadLeaderboardEntriesForUsers(m_SteamLeaderboard, Users, Users.Length); OnLeaderboardScoresDownloadedCallResult.Set(handle); print("SteamUserStats.DownloadLeaderboardEntriesForUsers(" + m_SteamLeaderboard + ", " + Users + ", " + Users.Length + ") : " + handle); } if (GUILayout.Button("GetDownloadedLeaderboardEntry(m_SteamLeaderboardEntries, 0, out LeaderboardEntry, null, 0)")) { LeaderboardEntry_t LeaderboardEntry; bool ret = SteamUserStats.GetDownloadedLeaderboardEntry(m_SteamLeaderboardEntries, 0, out LeaderboardEntry, null, 0); print("SteamUserStats.GetDownloadedLeaderboardEntry(" + m_SteamLeaderboardEntries + ", " + 0 + ", " + "out LeaderboardEntry" + ", " + null + ", " + 0 + ") : " + ret + " -- " + LeaderboardEntry); } if (GUILayout.Button("UploadLeaderboardScore(m_SteamLeaderboard, ELeaderboardUploadScoreMethod.k_ELeaderboardUploadScoreMethodForceUpdate, (int)m_FeetTraveledStat, null, 0)")) { SteamAPICall_t handle = SteamUserStats.UploadLeaderboardScore(m_SteamLeaderboard, ELeaderboardUploadScoreMethod.k_ELeaderboardUploadScoreMethodForceUpdate, (int)m_FeetTraveledStat, null, 0); OnLeaderboardScoreUploadedCallResult.Set(handle); print("SteamUserStats.UploadLeaderboardScore(" + m_SteamLeaderboard + ", " + ELeaderboardUploadScoreMethod.k_ELeaderboardUploadScoreMethodForceUpdate + ", " + (int)m_FeetTraveledStat + ", " + null + ", " + 0 + ") : " + handle); } if (GUILayout.Button("AttachLeaderboardUGC(m_SteamLeaderboard, UGCHandle_t.Invalid)")) { SteamAPICall_t handle = SteamUserStats.AttachLeaderboardUGC(m_SteamLeaderboard, UGCHandle_t.Invalid); OnLeaderboardUGCSetCallResult.Set(handle); print("SteamUserStats.AttachLeaderboardUGC(" + m_SteamLeaderboard + ", " + UGCHandle_t.Invalid + ") : " + handle); } if (GUILayout.Button("GetNumberOfCurrentPlayers()")) { SteamAPICall_t handle = SteamUserStats.GetNumberOfCurrentPlayers(); OnNumberOfCurrentPlayersCallResult.Set(handle); print("SteamUserStats.GetNumberOfCurrentPlayers() : " + handle); } if (GUILayout.Button("RequestGlobalAchievementPercentages()")) { SteamAPICall_t handle = SteamUserStats.RequestGlobalAchievementPercentages(); OnGlobalAchievementPercentagesReadyCallResult.Set(handle); print("SteamUserStats.RequestGlobalAchievementPercentages() : " + handle); } { int Iterator; { string Name; float Percent; bool Achieved; Iterator = SteamUserStats.GetMostAchievedAchievementInfo(out Name, 120, out Percent, out Achieved); if (Iterator != -1) { GUILayout.Label("GetMostAchievedAchievementInfo(out Name, 120, out Percent, out Achieved) : " + Iterator + " -- " + Name + " -- " + Percent + " -- " + Achieved); } else { GUILayout.Label("GetMostAchievedAchievementInfo(out Name, 120, out Percent, out Achieved) : " + Iterator); } } if (Iterator != -1) { string Name; float Percent; bool Achieved; Iterator = SteamUserStats.GetNextMostAchievedAchievementInfo(Iterator, out Name, 120, out Percent, out Achieved); GUILayout.Label("GetNextMostAchievedAchievementInfo(out Name, 120, out Percent, out Achieved) : " + Iterator + " -- " + Name + " -- " + Percent + " -- " + Achieved); } } { float Percent; bool ret = SteamUserStats.GetAchievementAchievedPercent("ACH_WIN_100_GAMES", out Percent); GUILayout.Label("GetAchievementAchievedPercent(\"ACH_WIN_100_GAMES\", out Percent) : " + ret + " -- " + Percent); } if (GUILayout.Button("RequestGlobalStats(3)")) { SteamAPICall_t handle = SteamUserStats.RequestGlobalStats(3); OnGlobalStatsReceivedCallResult.Set(handle); print("SteamUserStats.RequestGlobalStats(" + 3 + ") : " + handle); } /* TODO - Spams SteamAPI warnings * Does SpaceWar have a stat marked as "aggregated" to try out these functions? * { * long Data; * bool ret = SteamUserStats.GetGlobalStat("", out Data); * GUILayout.Label("GetGlobalStat(\"\", out Data) : " + ret + " -- " + Data); * } */ { double Data; bool ret = SteamUserStats.GetGlobalStat("", out Data); GUILayout.Label("GetGlobalStat(\"\", out Data) : " + ret + " -- " + Data); } { long[] Data = new long[1]; int ret = SteamUserStats.GetGlobalStatHistory("", Data, (uint)Data.Length); if (ret != 0) { GUILayout.Label("GetGlobalStatHistory(\"\", Data, " + (uint)Data.Length + ") : " + ret + " -- " + Data[0]); } else { GUILayout.Label("GetGlobalStatHistory(\"\", Data, " + (uint)Data.Length + ") : " + ret + " -- "); } } { double[] Data = new double[1]; int ret = SteamUserStats.GetGlobalStatHistory("", Data, (uint)Data.Length); if (ret != 0) { GUILayout.Label("GetGlobalStatHistory(\"\", Data, " + (uint)Data.Length + ") : " + ret + " -- " + Data[0]); } else { GUILayout.Label("GetGlobalStatHistory(\"\", Data, " + (uint)Data.Length + ") : " + ret + " -- "); } } //SteamUserStats.InstallPS3Trophies() // PS3 Only. //SteamUserStats.GetTrophySpaceRequiredBeforeInstall() // PS3 Only. //SteamUserStats.SetUserStatsData() // PS3 Only. //SteamUserStats.GetUserStatsData() // PS3 Only. GUILayout.EndScrollView(); GUILayout.EndVertical(); }
internal static async Task <Tuple <LeaderboardEntry_t, int[]> > GetLeaderboardEntryWithDetails(string leaderboardName, int timeout = 10000, Func <Tuple <LeaderboardEntry_t, int[]>, bool> resultHandler = null, Func <bool> repeatHandler = null) { var resultLeaderboard = await GetLeaderboard(leaderboardName); return(await TaskHelper.RepeatTaskForeverIfFailed(() => SteamApiHelper.HandleApiCall <Tuple <LeaderboardEntry_t, int[]>, LeaderboardScoresDownloaded_t>(SteamUserStats.DownloadLeaderboardEntriesForUsers(resultLeaderboard.m_hSteamLeaderboard, new CSteamID[] { SteamUser.GetSteamID() }, 1), CancellationToken.None, (tcs, result, bIOFailure) => { if (result.m_hSteamLeaderboard.m_SteamLeaderboard == 0 || bIOFailure) { tcs.SetException(new Exception("Ошибка GetLeaderboardEntryWithDetails")); return; } int[] pData = null; if (result.m_cEntryCount > 0) { pData = new int[64]; } var entry = new LeaderboardEntry_t(); for (int index = 0; index < result.m_cEntryCount; index++) { SteamUserStats.GetDownloadedLeaderboardEntry(result.m_hSteamLeaderboardEntries, index, out entry, pData, 64); } tcs.SetResult(Tuple.Create(entry, pData)); }), timeout, CancellationToken.None, resultHandler : resultHandler, repeatHandler : repeatHandler)); }
internal static async Task <List <Tuple <LeaderboardEntry_t, int[]> > > GetLeaderboardEntriesForUsers(string leaderboardName, CSteamID[] steamIds, int timeout = 10000, Func <List <Tuple <LeaderboardEntry_t, int[]> >, bool> resultHandler = null, Func <bool> repeatHandler = null) { var resultLeaderboard = await GetLeaderboard(leaderboardName); return(await TaskHelper.RepeatTaskForeverIfFailed(() => SteamApiHelper.HandleApiCall <List <Tuple <LeaderboardEntry_t, int[]> >, LeaderboardScoresDownloaded_t>(SteamUserStats.DownloadLeaderboardEntriesForUsers(resultLeaderboard.m_hSteamLeaderboard, steamIds, steamIds.Length), CancellationToken.None, (tcs, result, bIOFailure) => { if (result.m_hSteamLeaderboard.m_SteamLeaderboard == 0 || bIOFailure) { tcs.SetException(new Exception("Ошибка GetLeaderboardEntriesForUsers")); return; } var entriesList = new List <Tuple <LeaderboardEntry_t, int[]> >(); LeaderboardEntry_t entry; for (int index = 0; index < result.m_cEntryCount; index++) { int[] pData = new int[64]; if (SteamUserStats.GetDownloadedLeaderboardEntry(result.m_hSteamLeaderboardEntries, index, out entry, pData, 64)) { entriesList.Add(Tuple.Create(entry, pData)); } } tcs.SetResult(entriesList); }), timeout, CancellationToken.None, resultHandler : resultHandler, repeatHandler : repeatHandler)); }