/// <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</para> /// </summary> public static SteamAPICall FindOrCreateLeaderboard(string LeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType) { InteropHelp.TestIfAvailableClient(); using (var LeaderboardName2 = new InteropHelp.UTF8StringHandle(LeaderboardName)) { return((SteamAPICall)NativeMethods.ISteamUserStats_FindOrCreateLeaderboard(LeaderboardName2, eLeaderboardSortMethod, eLeaderboardDisplayType)); } }
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"); } } }
/// <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); }
/// <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> /// 创建排行榜 /// </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); }
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 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; }
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; }
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(); }
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> /// 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> /// 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_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 } }
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); } }
public static extern ulong ISteamUserStats_FindOrCreateLeaderboard(InteropHelp.UTF8StringHandle pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType 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); }
/// <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)); }
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 static SteamAPICall_t FindOrCreateLeaderboard(string pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType) { InteropHelp.TestIfAvailableClient(); using InteropHelp.UTF8StringHandle pchLeaderboardName2 = new InteropHelp.UTF8StringHandle(pchLeaderboardName); return((SteamAPICall_t)NativeMethods.ISteamUserStats_FindOrCreateLeaderboard(CSteamAPIContext.GetSteamUserStats(), pchLeaderboardName2, eLeaderboardSortMethod, eLeaderboardDisplayType)); }
private void FindOrCreateLeaderboard(ELeaderboardSortMethod sortMethod, ELeaderboardDisplayType displayType) { var handle = SteamUserStats.FindOrCreateLeaderboard(leaderboardName, sortMethod, displayType); OnLeaderboardFindResultCallResult.Set(handle); }
/// <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)); }
// 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); }
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); }
public UInt64 FindOrCreateLeaderboard(string pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType) { return(this.GetFunction <NativeFindOrCreateLeaderboardSEE>(this.Functions.FindOrCreateLeaderboard20)(this.ObjectAddress, pchLeaderboardName, eLeaderboardSortMethod, eLeaderboardDisplayType)); }
private static bool SteamUnityAPI_SteamUserStats_FindOrCreateLeaderboard(IntPtr stats, [MarshalAs(UnmanagedType.LPStr)] string leaderboardName, ELeaderboardSortMethod sortMethod, ELeaderboardDisplayType displayType, IntPtr OnLeaderboardRetrievedCallback);
/// 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); }