/// <summary> /// Formats p_score with SteamLeaderboardsMain.ScoreFormatNumeric or SteamLeaderboardsMain.ScoreFormatSeconds or SteamLeaderboardsMain.ScoreFormatMilliSeconds taking p_scoreType into account. /// </summary> /// <returns>formatted score string.</returns> /// <param name="p_score">integer score value to format.</param> /// <param name="p_scoreType">score display type of the target format.</param> public string FormatScore(int p_score, ELeaderboardDisplayType p_scoreType) { try { switch (p_scoreType) { case ELeaderboardDisplayType.k_ELeaderboardDisplayTypeTimeSeconds: { System.TimeSpan time = System.TimeSpan.FromSeconds(p_score); return(string.Format(m_scoreFormatSeconds, (int)time.TotalMinutes, time.Seconds, time.Milliseconds)); } case ELeaderboardDisplayType.k_ELeaderboardDisplayTypeTimeMilliSeconds: { System.TimeSpan time = System.TimeSpan.FromMilliseconds(p_score); return(string.Format(m_scoreFormatMilliSeconds, (int)time.TotalMinutes, time.Seconds, time.Milliseconds)); } case ELeaderboardDisplayType.k_ELeaderboardDisplayTypeNone: case ELeaderboardDisplayType.k_ELeaderboardDisplayTypeNumeric: default: return(p_score.ToString(m_scoreFormatNumeric)); } } catch (System.Exception ex) { HandleError("FormatScore: invalid format string! ", new ErrorEventArgs(ex.Message)); return(p_score.ToString()); } }
private void OnUploadLeaderboardScoreCallCompleted(string p_leaderboardName, int p_score, LeaderboardScoreUploaded_t p_callback, bool p_bIOFailure) { EResult callResultType = p_callback.m_bSuccess == 1 ? EResult.k_EResultOK : EResult.k_EResultUnexpectedError; if (CheckAndLogResult <LeaderboardScoreUploaded_t, LeaderboardsUploadedScoreEventArgs>("OnUploadLeaderboardScoreCallCompleted", callResultType, p_bIOFailure, GetEventNameForOnUploadedScore(p_leaderboardName, p_score), ref OnUploadedScore)) { // inform listeners if (OnUploadedScore != null) { ELeaderboardDisplayType scoreType = SteamUserStats.GetLeaderboardDisplayType(p_callback.m_hSteamLeaderboard); InvokeEventHandlerSafely(OnUploadedScore, new LeaderboardsUploadedScoreEventArgs() { LeaderboardName = p_leaderboardName, Score = p_callback.m_nScore, ScoreString = FormatScore(p_callback.m_nScore, scoreType), ScoreType = scoreType, IsScoreChanged = p_callback.m_bScoreChanged == 1, GlobalRankNew = p_callback.m_nGlobalRankNew, GlobalRankPrevious = p_callback.m_nGlobalRankPrevious, SteamNative = new LeaderboardsUploadedScoreEventArgs.SteamNativeData(p_callback.m_hSteamLeaderboard) }); ClearSingleShotEventHandlers(GetEventNameForOnUploadedScore(p_leaderboardName, p_score), ref OnUploadedScore); } } }
private void OnUploadScoreFindOrCreateLeaderboardCallCompleted(string p_leaderboardName, int p_score, ELeaderboardSortMethod p_scoreSorting, ELeaderboardDisplayType p_scoreType, int[] p_scoreDetails, LeaderboardFindResult_t p_callbackFind, bool p_bIOFailureFind) { EResult callResultType = p_callbackFind.m_bLeaderboardFound == 1 ? EResult.k_EResultOK : EResult.k_EResultFileNotFound; if (CheckAndLogResult <LeaderboardFindResult_t, LeaderboardsUploadedScoreEventArgs>("OnUploadScoreFindOrCreateLeaderboardCallCompleted", callResultType, p_bIOFailureFind, GetEventNameForOnUploadedScore(p_leaderboardName, p_score), ref OnUploadedScore)) { // compare sort and type -> warning on mismatch ELeaderboardSortMethod sorting = SteamUserStats.GetLeaderboardSortMethod(p_callbackFind.m_hSteamLeaderboard); if (sorting != p_scoreSorting) { Debug.LogWarning("UploadScore: sorting mismatch for leaderboard '" + p_leaderboardName + "' sort mode on Steam is '" + sorting + "', expected '" + p_scoreSorting + "'!"); } ELeaderboardDisplayType type = SteamUserStats.GetLeaderboardDisplayType(p_callbackFind.m_hSteamLeaderboard); if (type != p_scoreType) { Debug.LogWarning("UploadScore: type mismatch for leaderboard '" + p_leaderboardName + "' type on Steam is '" + type + "', expected '" + p_scoreType + "'!"); } // upload score if (p_scoreDetails == null) { p_scoreDetails = new int[0]; } Execute <LeaderboardScoreUploaded_t>(SteamUserStats.UploadLeaderboardScore(p_callbackFind.m_hSteamLeaderboard, m_scoreUploadMethod, p_score, p_scoreDetails, Mathf.Min(64, p_scoreDetails.Length)), (p_callbackUpload, p_bIOFailureUpload) => OnUploadLeaderboardScoreCallCompleted(p_leaderboardName, p_score, p_callbackUpload, p_bIOFailureUpload)); if (IsDebugLogEnabled) { Debug.Log("UploadScore: leaderboard '" + p_leaderboardName + "' found, starting score upload"); } } }
private void OnDownloadLeaderboardEntriesCallCompleted(string p_leaderboardName, LeaderboardScoresDownloaded_t p_callback, bool p_bIOFailure) { if (CheckAndLogResult <LeaderboardScoresDownloaded_t, LeaderboardsDownloadedScoresEventArgs>("OnDownloadLeaderboardEntriesCallCompleted", EResult.k_EResultOK, p_bIOFailure, "OnDownloadedScores", ref OnDownloadedScores)) { if (OnDownloadedScores != null) { lock (m_lock) { // get score list m_scores.Clear(); m_scoresMissingUserNames.Clear(); m_scoresLeaderboardName = p_leaderboardName; for (int i = 0; i < p_callback.m_cEntryCount; i++) { LeaderboardEntry_t entry; int[] details = new int[Mathf.Max(0, m_scoreDownloadDetailsLength)]; if (SteamUserStats.GetDownloadedLeaderboardEntry(p_callback.m_hSteamLeaderboardEntries, i, out entry, details, details.Length)) { if (SteamFriends.RequestUserInformation(entry.m_steamIDUser, true)) // request name only, avatars will be requested if needed with GetAvatarTexture { m_scoresMissingUserNames.Add(entry.m_steamIDUser); } int[] detailsDownloaded = new int[Mathf.Min(details.Length, entry.m_cDetails)]; System.Array.Copy(details, detailsDownloaded, detailsDownloaded.Length); string userName = SteamFriends.GetFriendPersonaName(entry.m_steamIDUser); ELeaderboardDisplayType scoreType = SteamUserStats.GetLeaderboardDisplayType(p_callback.m_hSteamLeaderboard); LeaderboardsScoreEntry parsedEntry = new LeaderboardsScoreEntry() { LeaderboardName = p_leaderboardName, UserName = userName, GlobalRank = entry.m_nGlobalRank, Score = entry.m_nScore, ScoreString = FormatScore(entry.m_nScore, scoreType), ScoreType = scoreType, DetailsAvailableLength = entry.m_cDetails, DetailsDownloaded = detailsDownloaded, IsCurrentUserScore = entry.m_steamIDUser == SteamUser.GetSteamID(), SteamNative = new LeaderboardsScoreEntry.SteamNativeData(p_callback.m_hSteamLeaderboard, entry.m_hUGC, entry.m_steamIDUser) }; m_scores.Add(parsedEntry); } } } // inform listeners if (m_scoresMissingUserNames.Count == 0) { InvokeEventHandlerSafely(OnDownloadedScores, new LeaderboardsDownloadedScoresEventArgs(p_leaderboardName, new List <LeaderboardsScoreEntry>(m_scores))); ClearSingleShotEventHandlers("OnDownloadedScores", ref OnDownloadedScores); } else if (IsDebugLogEnabled) { Debug.Log("OnDownloadLeaderboardEntriesCallCompleted: missing user names count: '" + m_scoresMissingUserNames.Count + "'"); } } } }
internal Leaderboard(Leaderboards leaderboards, ulong leaderboard, string leaderboardName, int entryCount, ELeaderboardSortMethod sortMethod, ELeaderboardDisplayType displayType) { this._stats = Leaderboard.SteamUnityAPI_SteamUserStats(); this._leaderboards = leaderboards; this._leaderboard = leaderboard; this._leaderboardName = leaderboardName; this._entryCount = entryCount; this._sortMethod = sortMethod; this._displayType = displayType; }
internal FindOrCreateLeaderboardCallback( JobID jobID, CMsgClientLBSFindOrCreateLBResponse resp ) { this.JobID = jobID; this.Result = ( EResult )resp.eresult; this.ID = resp.leaderboard_id; this.EntryCount = resp.leaderboard_entry_count; this.SortMethod = ( ELeaderboardSortMethod )resp.leaderboard_sort_method; this.DisplayType = ( ELeaderboardDisplayType )resp.leaderboard_display_type; }
internal FindOrCreateLeaderboardCallback(JobID jobID, CMsgClientLBSFindOrCreateLBResponse resp) { this.JobID = jobID; this.Result = ( EResult )resp.eresult; this.ID = resp.leaderboard_id; this.EntryCount = resp.leaderboard_entry_count; this.SortMethod = ( ELeaderboardSortMethod )resp.leaderboard_sort_method; this.DisplayType = ( ELeaderboardDisplayType )resp.leaderboard_display_type; }
public static SteamAPICall_t FindOrCreateLeaderboard(string pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType) { InteropHelp.TestIfAvailableClient(); SteamAPICall_t result; using (InteropHelp.UTF8StringHandle uTF8StringHandle = new InteropHelp.UTF8StringHandle(pchLeaderboardName)) { result = (SteamAPICall_t)NativeMethods.ISteamUserStats_FindOrCreateLeaderboard(uTF8StringHandle, eLeaderboardSortMethod, eLeaderboardDisplayType); } return result; }
private void OnLeaderboardRetrievedCallback(ref LeaderboardFindResult_t findLearderboardResult) { if ((int)findLearderboardResult.m_bLeaderboardFound != 0) { this._leaderboard = findLearderboardResult.m_hSteamLeaderboard; this._leaderboardName = Leaderboard.SteamUnityAPI_SteamUserStats_GetLeaderboardName(this._stats, findLearderboardResult.m_hSteamLeaderboard); this._sortMethod = Leaderboard.SteamUnityAPI_SteamUserStats_GetLeaderboardSortMethod(this._stats, findLearderboardResult.m_hSteamLeaderboard); this._displayType = Leaderboard.SteamUnityAPI_SteamUserStats_GetLeaderboardDisplayType(this._stats, findLearderboardResult.m_hSteamLeaderboard); } this._onLeaderboardRetrieved(this); }
public void Start() { ELeaderboardSortMethod sortMethod = type == LeaderboardTypes.Score ? ELeaderboardSortMethod.k_ELeaderboardSortMethodDescending : ELeaderboardSortMethod.k_ELeaderboardSortMethodAscending; ELeaderboardDisplayType displayType = type == LeaderboardTypes.Score ? ELeaderboardDisplayType.k_ELeaderboardDisplayTypeNumeric : ELeaderboardDisplayType.k_ELeaderboardDisplayTypeTimeMilliSeconds; SteamAPICall_t hSteamAPICall = SteamUserStats.FindOrCreateLeaderboard(s_leaderboardName, sortMethod, displayType); m_findResult.Set(hSteamAPICall, OnLeaderboardFindResult); InitTimer(); }
/// <summary> /// Asks the Steam back-end for a leaderboard by name, and will create it if it's not yet. /// Results are returned in a <see cref="FindOrCreateLeaderboardCallback"/>. /// </summary> /// <param name="appId">The AppID to request a leaderboard for.</param> /// <param name="name">Name of the leaderboard to create.</param> /// <param name="sortMethod">Sort method to use for this leaderboard</param> /// <param name="displayType">Display type for this leaderboard.</param> /// <returns>The Job ID of the request. This can be used to find the appropriate <see cref="FindOrCreateLeaderboardCallback"/>.</returns> public JobID CreateLeaderboard( uint appId, string name, ELeaderboardSortMethod sortMethod, ELeaderboardDisplayType displayType ) { var msg = new ClientMsgProtobuf<CMsgClientLBSFindOrCreateLB>( EMsg.ClientLBSFindOrCreateLB ); msg.SourceJobID = Client.GetNextJobID(); // routing_appid has to be set correctly to receive a response msg.ProtoHeader.routing_appid = appId; msg.Body.app_id = appId; msg.Body.leaderboard_name = name; msg.Body.leaderboard_display_type = ( int )displayType; msg.Body.leaderboard_sort_method = ( int )sortMethod; msg.Body.create_if_not_found = true; Client.Send( msg ); return msg.SourceJobID; }
/// <summary> /// Upload or update a score entry in the given leaderboard. The p_onUploadedScore callback is invoked when done.<br /> /// See also SteamLeaderboardsMain.OnUploadedScore. /// </summary> /// <returns><c>true</c>, if a request was started, <c>false</c> when the request could not have been started due to an error.</returns> /// <param name="p_leaderboardName">name of the leaderboard to update.</param> /// <param name="p_score">users score to submit.</param> /// <param name="p_scoreSorting">if the leaderboard with the given name does not yet exist, then it will be created with the given sorting</param> /// <param name="p_scoreType">if the leaderboard with the given name does not yet exist, then it will be created with the given score display type</param> /// <param name="p_onUploadedScore">invoked when the score upload is successfull or an error has occured.</param> public bool UploadScore(string p_leaderboardName, int p_score, ELeaderboardSortMethod p_scoreSorting, ELeaderboardDisplayType p_scoreType, System.Action <LeaderboardsUploadedScoreEventArgs> p_onUploadedScore) { return(UploadScore(p_leaderboardName, p_score, p_scoreSorting, p_scoreType, (int[])null, p_onUploadedScore)); }
/// <summary> /// 创建排行榜 /// </summary> /// <param name="leaderboardName">排行榜名字</param> /// <param name="sortMethod">排行榜排序方式 k_ELeaderboardSortMethodAscending:约小的数字约在前 k_ELeaderboardSortMethodDescending:约大的数字约在前</param> /// <param name="displayType"></param> public void FindOrCreateLeaderboard(string leaderboardName, ELeaderboardSortMethod sortMethod, ELeaderboardDisplayType displayType, ISteamLeaderboardCreateCallBack callBack) { this.mCreateCallBack = callBack; CallResult <LeaderboardFindResult_t> callResult = CallResult <LeaderboardFindResult_t> .Create(OnLeaderboardCreateResult); SteamAPICall_t handle = SteamUserStats.FindOrCreateLeaderboard(leaderboardName, sortMethod, displayType); callResult.Set(handle); }
public static extern ulong ISteamUserStats_FindOrCreateLeaderboard(InteropHelp.UTF8StringHandle pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType);
/// <summary> /// <para> Leaderboard functions</para> /// <para> asks the Steam back-end for a leaderboard by name, and will create it if it's not yet</para> /// <para> This call is asynchronous, with the result returned in LeaderboardFindResult_t</para> /// </summary> public static SteamAPICall_t FindOrCreateLeaderboard(string pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType) { InteropHelp.TestIfAvailableClient(); return((SteamAPICall_t)NativeMethods.ISteamUserStats_FindOrCreateLeaderboard(pchLeaderboardName, eLeaderboardSortMethod, eLeaderboardDisplayType)); }
public UInt64 FindOrCreateLeaderboard(string pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType) { UInt64 ret = 0; this.GetFunction <NativeFindOrCreateLeaderboardSEE>(this.Functions.FindOrCreateLeaderboard18)(this.ObjectAddress, ref ret, pchLeaderboardName, eLeaderboardSortMethod, eLeaderboardDisplayType); return((UInt64)ret); }
private void OnLeaderboardRetrievedCallback(ref LeaderboardFindResult_t findLearderboardResult) { if ((int) findLearderboardResult.m_bLeaderboardFound != 0) { this._leaderboard = findLearderboardResult.m_hSteamLeaderboard; this._leaderboardName = Leaderboard.SteamUnityAPI_SteamUserStats_GetLeaderboardName(this._stats, findLearderboardResult.m_hSteamLeaderboard); this._sortMethod = Leaderboard.SteamUnityAPI_SteamUserStats_GetLeaderboardSortMethod(this._stats, findLearderboardResult.m_hSteamLeaderboard); this._displayType = Leaderboard.SteamUnityAPI_SteamUserStats_GetLeaderboardDisplayType(this._stats, findLearderboardResult.m_hSteamLeaderboard); } this._onLeaderboardRetrieved(this); }
/// <summary> /// 创建排行榜 /// </summary> /// <param name="leaderboardName"></param> /// <param name="sortMethod"></param> /// <param name="displayType"></param> private void findOrCreateLeaderboard(string leaderboardName, ELeaderboardSortMethod sortMethod, ELeaderboardDisplayType displayType) { OnLeaderboardFindResultCallResult = CallResult <LeaderboardFindResult_t> .Create(OnLeaderboardFindResult); SteamAPICall_t handle = SteamUserStats.FindOrCreateLeaderboard(leaderboardName, sortMethod, displayType); OnLeaderboardFindResultCallResult.Set(handle); }
public static SteamAPICall_t FindOrCreateLeaderboard(string pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType) { InteropHelp.TestIfAvailableClient(); SteamAPICall_t result; using (InteropHelp.UTF8StringHandle uTF8StringHandle = new InteropHelp.UTF8StringHandle(pchLeaderboardName)) { result = (SteamAPICall_t)NativeMethods.ISteamUserStats_FindOrCreateLeaderboard(uTF8StringHandle, eLeaderboardSortMethod, eLeaderboardDisplayType); } return(result); }
private void FindOrCreateLeaderboard(ELeaderboardSortMethod sortMethod, ELeaderboardDisplayType displayType) { var handle = SteamUserStats.FindOrCreateLeaderboard(leaderboardName, sortMethod, displayType); OnLeaderboardFindResultCallResult.Set(handle); }
public void FindOrCreateLeaderboard(OnLeaderboardRetrieved onLeaderboardRetrieved, string leaderboardName, ELeaderboardSortMethod sortMethod, ELeaderboardDisplayType displayType) { Leaderboard leaderboard1 = (Leaderboard)null; foreach (Leaderboard leaderboard2 in this._leaderboardList) { if (leaderboard2.LeaderboardName == leaderboardName) { leaderboard1 = leaderboard2; break; } } if (leaderboard1 != null) { onLeaderboardRetrieved(leaderboard1); } else { this._onLeaderboardRetrieved = onLeaderboardRetrieved; if (this._internalOnLeaderboardRetrieved == null) { this._internalOnLeaderboardRetrieved = new OnLeaderboardRetrievedFromSteam(this.OnLeaderboardRetrievedCallback); } if (Leaderboards.SteamUnityAPI_SteamUserStats_FindOrCreateLeaderboard(this._stats, leaderboardName, sortMethod, displayType, Marshal.GetFunctionPointerForDelegate((Delegate)this._internalOnLeaderboardRetrieved))) { return; } this._onLeaderboardRetrieved((Leaderboard)null); } }
private static bool SteamUnityAPI_SteamUserStats_FindOrCreateLeaderboard(IntPtr stats, [MarshalAs(UnmanagedType.LPStr)] string leaderboardName, ELeaderboardSortMethod sortMethod, ELeaderboardDisplayType displayType, IntPtr OnLeaderboardRetrievedCallback);
/// <summary> /// Asks the Steam back-end for a leaderboard by name, and will create it if it's not yet. /// Results are returned in a <see cref="FindOrCreateLeaderboardCallback"/>. /// The returned <see cref="AsyncJob{T}"/> can also be awaited to retrieve the callback result. /// </summary> /// <param name="appId">The AppID to request a leaderboard for.</param> /// <param name="name">Name of the leaderboard to create.</param> /// <param name="sortMethod">Sort method to use for this leaderboard</param> /// <param name="displayType">Display type for this leaderboard.</param> /// <returns>The Job ID of the request. This can be used to find the appropriate <see cref="FindOrCreateLeaderboardCallback"/>.</returns> public AsyncJob <FindOrCreateLeaderboardCallback> CreateLeaderboard(uint appId, string name, ELeaderboardSortMethod sortMethod, ELeaderboardDisplayType displayType) { var msg = new ClientMsgProtobuf <CMsgClientLBSFindOrCreateLB>(EMsg.ClientLBSFindOrCreateLB); msg.SourceJobID = Client.GetNextJobID(); // routing_appid has to be set correctly to receive a response msg.ProtoHeader.routing_appid = appId; msg.Body.app_id = appId; msg.Body.leaderboard_name = name; msg.Body.leaderboard_display_type = ( int )displayType; msg.Body.leaderboard_sort_method = ( int )sortMethod; msg.Body.create_if_not_found = true; Client.Send(msg); return(new AsyncJob <FindOrCreateLeaderboardCallback>(this.Client, msg.SourceJobID)); }
public UInt64 FindOrCreateLeaderboard(string pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType) { return(this.GetFunction <NativeFindOrCreateLeaderboardSEE>(this.Functions.FindOrCreateLeaderboard20)(this.ObjectAddress, pchLeaderboardName, eLeaderboardSortMethod, eLeaderboardDisplayType)); }
// Leaderboard functions // asks the Steam back-end for a leaderboard by name, and will create it if it's not yet // This call is asynchronous, with the result returned in LeaderboardFindResult_t public static SteamAPICall_t FindOrCreateLeaderboard(string pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType) { InteropHelp.TestIfAvailableClient(); return (SteamAPICall_t)NativeMethods.ISteamUserStats_FindOrCreateLeaderboard(pchLeaderboardName, eLeaderboardSortMethod, eLeaderboardDisplayType); }
/// <summary> /// <para> Leaderboard functions</para> /// <para> asks the Steam back-end for a leaderboard by name, and will create it if it's not yet</para> /// <para> This call is asynchronous, with the result returned in LeaderboardFindResult_t</para> /// </summary> public static SteamAPICall_t FindOrCreateLeaderboard(string pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType) { InteropHelp.TestIfAvailableClient(); using (var pchLeaderboardName2 = new InteropHelp.UTF8StringHandle(pchLeaderboardName)) { return((SteamAPICall_t)NativeMethods.ISteamUserStats_FindOrCreateLeaderboard(CSteamAPIContext.GetSteamUserStats(), pchLeaderboardName2, eLeaderboardSortMethod, eLeaderboardDisplayType)); } }
/// <summary> /// Upload or update a score entry in the given leaderboard. The p_onUploadedScore callback is invoked when done.<br /> /// See also SteamLeaderboardsMain.OnUploadedScore. /// </summary> /// <returns><c>true</c>, if a request was started, <c>false</c> when the request could not have been started due to an error.</returns> /// <param name="p_leaderboardName">name of the leaderboard to update.</param> /// <param name="p_score">users score to submit.</param> /// <param name="p_scoreSorting">if the leaderboard with the given name does not yet exist, then it will be created with the given sorting</param> /// <param name="p_scoreType">if the leaderboard with the given name does not yet exist, then it will be created with the given score display type</param> /// <param name="p_scoreDetails">additional game-defined information regarding how the user got that score. E.g. a replay, a screenshot, etc...</param> /// <param name="p_onUploadedScore">invoked when the score upload is successfull or an error has occured.</param> public bool UploadScore(string p_leaderboardName, int p_score, ELeaderboardSortMethod p_scoreSorting, ELeaderboardDisplayType p_scoreType, string p_scoreDetails, System.Action <LeaderboardsUploadedScoreEventArgs> p_onUploadedScore) { if (p_scoreDetails != null && p_scoreDetails.Length > 252) { Debug.LogError("UploadScore: max. score details string length is 252 characters! Provided '" + p_scoreDetails.Length + "'! Data will be cutoff!"); p_scoreDetails = p_scoreDetails.Substring(0, 252); } return(UploadScore(p_leaderboardName, p_score, p_scoreSorting, p_scoreType, ConvertStrToIntArray(p_scoreDetails), p_onUploadedScore)); }
/// <summary> /// Upload or update a score entry in the given leaderboard. The p_onUploadedScore callback is invoked when done.<br /> /// See also SteamLeaderboardsMain.OnUploadedScore. /// </summary> /// <returns><c>true</c>, if a request was started, <c>false</c> when the request could not have been started due to an error.</returns> /// <param name="p_leaderboardName">name of the leaderboard to update.</param> /// <param name="p_score">users score to submit.</param> /// <param name="p_scoreSorting">if the leaderboard with the given name does not yet exist, then it will be created with the given sorting</param> /// <param name="p_scoreType">if the leaderboard with the given name does not yet exist, then it will be created with the given score display type</param> /// <param name="p_scoreDetails">additional game-defined information regarding how the user got that score. E.g. a replay, a screenshot, etc...</param> /// <param name="p_onUploadedScore">invoked when the score upload is successfull or an error has occured.</param> public bool UploadScore(string p_leaderboardName, int p_score, ELeaderboardSortMethod p_scoreSorting, ELeaderboardDisplayType p_scoreType, int[] p_scoreDetails, System.Action <LeaderboardsUploadedScoreEventArgs> p_onUploadedScore) { if (SteamManager.Initialized) { if (p_scoreDetails != null && p_scoreDetails.Length > 64) { Debug.LogError("UploadScore: max. score details array length is 64 integers! Provided '" + p_scoreDetails.Length + "'! Data will be cutoff!"); } SetSingleShotEventHandler(GetEventNameForOnUploadedScore(p_leaderboardName, p_score), ref OnUploadedScore, p_onUploadedScore); Execute <LeaderboardFindResult_t>(SteamUserStats.FindOrCreateLeaderboard(p_leaderboardName, p_scoreSorting, p_scoreType), (p_callback, p_bIOFailure) => OnUploadScoreFindOrCreateLeaderboardCallCompleted(p_leaderboardName, p_score, p_scoreSorting, p_scoreType, p_scoreDetails, p_callback, p_bIOFailure)); return(true); // request started } else { ErrorEventArgs errorArgs = ErrorEventArgs.CreateSteamNotInit(); InvokeEventHandlerSafely(p_onUploadedScore, new LeaderboardsUploadedScoreEventArgs(errorArgs)); HandleError("UploadScore: failed! ", errorArgs); return(false); // no request, because there is no connection to steam } }
/// Leaderboard functions /// asks the Steam back-end for a leaderboard by name, and will create it if it's not yet /// This call is asynchronous, with the result returned in LeaderboardFindResult_t public static SteamAPICall_t FindOrCreateLeaderboard(string pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType) { return((SteamAPICall_t)0); }