public static void UpdateItem(Item item) { if (fa.dontConnectSteam) { return; } if (!SteamManager.Initialized) { return; } //whats the next step for this item? //no reference? Ask steam for one, and return out if (!item.hasRef && !item.waitingForRef) { item.waitingForRef = true; RawFuncs.Print("1. Requesting: " + item.leaderboard); SteamAPICall_t hSteamAPICall = SteamUserStats.FindLeaderboard(item.leaderboard); m_findResult.Set(hSteamAPICall, OnFindLeaderboardResult); return; } //does it have a reference? if (item.hasRef && !item.waitingForUpload) { item.waitingForUpload = true; RawFuncs.Print("3. uploading score(" + item.score + ") to steam leaderboard(" + item.leaderboard + ")"); SteamAPICall_t hSteamAPICall = SteamUserStats.UploadLeaderboardScore(item.steamRef, s_leaderboardMethod, item.score, null, 0); m_uploadResult.Set(hSteamAPICall, OnLeaderboardUploadResult); } }
public void Find(Action action) { SteamAPICall_t steamAPICall = SteamUserStats.FindLeaderboard(boardName); OnLeaderboardFindResultCallResult.Set(steamAPICall, ( LeaderboardFindResult_t pCallback, bool bIOFailure) => FindResult(pCallback, bIOFailure, action)); }
private static void EndlessScoreUpload(LeaderboardFindResult_t pCallback, bool failure) { endlessscore = pCallback.m_hSteamLeaderboard; SteamAPICall_t h4 = SteamUserStats.FindLeaderboard("ENDLESSMODETIME"); m_findResult.Set(h4, EndlessTimeUpload); }
private static void StoryTimeUpload(LeaderboardFindResult_t pCallback, bool failure) { storytime = pCallback.m_hSteamLeaderboard; SteamAPICall_t h3 = SteamUserStats.FindLeaderboard("ENDLESSMODESCORE"); m_findResult.Set(h3, EndlessScoreUpload); }
private static void StoryScoreUpload(LeaderboardFindResult_t pCallback, bool failure) { storyscore = pCallback.m_hSteamLeaderboard; SteamAPICall_t h2 = SteamUserStats.FindLeaderboard("STORYMODETIME"); m_findResult.Set(h2, StoryTimeUpload); }
public LeaderboardEntry GetLeaderboard(LeaderboardIdentity leaderboardId) { // FIXME: Should we just magically have leaderboards by this point? -flibit if (!LeaderboardReader.Leaderboards.ContainsKey(leaderboardId.Key)) { latestKey = leaderboardId.Key; SteamAPICall_t call = SteamUserStats.FindLeaderboard(leaderboardId.Key); if (call.m_SteamAPICall != 0) { CallResult <LeaderboardFindResult_t> foundLeaderboard; foundLeaderboard = new CallResult <LeaderboardFindResult_t>(); foundLeaderboard.Set( call, OnLeaderboardFound ); while (GamerServicesDispatcher.UpdateAsync()) { if (string.IsNullOrEmpty(latestKey)) { break; } } } } // FIXME: Do these other parameters even matter? -flibit return(new LeaderboardEntry( null, 0, 0, LeaderboardReader.Leaderboards[leaderboardId.Key] )); }
public static void Init() { SteamAPICall_t hSteamAPICall = SteamUserStats.FindLeaderboard(s_leaderboardName); m_findResult.Set(hSteamAPICall, OnLeaderboardFindResult); InitTimer(); }
private void GetLeaderboardId() { UnityEngine.Debug.Log("Steam GetLeaderboardId"); _findLeaderboardRequest = CallResult <LeaderboardFindResult_t> .Create(OnFindLeaderboardResponse); _findLeaderboardRequest.Set(SteamUserStats.FindLeaderboard(LEADERBOARD_NAME)); }
public void FindLeaderboard(string leaderboardID) { downloadInProgress = true; SteamAPICall_t steamAPICall = SteamUserStats.FindLeaderboard(leaderboardID); callResultFindLeaderBoard.Set(steamAPICall, OnFindLeaderboard); }
/// <summary> /// 根据排行榜姓名查询ID /// </summary> /// <param name="leaderboardName"></param> /// <param name="callBack"></param> public void FindLeaderboard(string leaderboardName, ISteamLeaderboardFindCallBack callBack) { this.mFindCallBack = callBack; CallResult <LeaderboardFindResult_t> callResult = CallResult <LeaderboardFindResult_t> .Create(OnLeaderboardFindResult); SteamAPICall_t handle = SteamUserStats.FindLeaderboard(leaderboardName); callResult.Set(handle); }
/// <summary> /// 根据排行榜姓名查询ID /// </summary> /// <param name="leaderboardName"></param> /// <param name="callBack"></param> public void findLeaderboard(string leaderboardName, LeaderboardFindResultCallBack callBack) { OnLeaderboardFindResultCallResult = CallResult <LeaderboardFindResult_t> .Create(OnLeaderboardFindResult); OnLeaderboardFindResultCallBack = callBack; SteamAPICall_t handle = SteamUserStats.FindLeaderboard(leaderboardName); OnLeaderboardFindResultCallResult.Set(handle); }
public List <LeaderboardEntry> FetchLeaderboard() { SteamAPICall_t handle = SteamUserStats.FindLeaderboard(name); m_FoundLeaderboard.Set(handle); Console.WriteLine("Searching for leaderboard " + this.name + ", holup"); while (!done) { SteamAPI.RunCallbacks(); } return(this.leaderboard); }
public override void InitLeaderboard(string leaderboardId) { if (leaderbordsStatus.ContainsKey(leaderboardId)) { return; } leaderbordsStatus.Add(leaderboardId, null); SteamAPICall_t hSteamAPICall = SteamUserStats.FindLeaderboard(leaderboardId); CallResult <LeaderboardFindResult_t> m_findResult = new CallResult <LeaderboardFindResult_t>(); m_findResult.Set(hSteamAPICall, (LeaderboardFindResult_t pCallback, bool failure) => OnLeaderboardFindResult(pCallback, failure, leaderboardId)); }
/// <summary> /// this method is used to search the leaderboard by name with a SteamAPICall /// </summary> public static void FindLeaderboard() { //this call finds the leaderboard by name (in this case the nam is already on a variable, but you could use a string normally) SteamAPICall_t _steamAPICall = SteamUserStats.FindLeaderboard(m_leaderboardName); //--------------------------------------------------------------------------------------------------------------------------- //The variable "m_leaderboardFindResult" is a call result that needs to be used in conjuction with an "OnLeaderBoardFindResult" Method //if the result of the call is true, it'll change the m_steamLeaderboard //--------------------------------------------------------------------------------------------------------------------------- m_leaderboardFindResult.Set(_steamAPICall, OnLeaderBoardFindResult); }
public void InitLeaderboard(string lbName) { if (SteamManager.Initialized == true) { LeaderboardScoreUploaded = CallResult <LeaderboardScoreUploaded_t> .Create(this.OnLeaderboardScoreUploaded); LeaderboardFindResult = CallResult <LeaderboardFindResult_t> .Create(this.OnLeaderboardFindResult); SteamAPICall_t handle = SteamUserStats.FindLeaderboard(lbName); LeaderboardFindResult.Set(handle); lbNameTest = lbName; } }
private static void FindLeaderboard(string key) { SteamAPICall_t call = SteamUserStats.FindLeaderboard(key); if (call.m_SteamAPICall != 0) { CallResult <LeaderboardFindResult_t> foundLeaderboard; foundLeaderboard = new CallResult <LeaderboardFindResult_t>(); foundLeaderboard.Set( call, OnLeaderboardFound ); } }
protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here Font = Content.Load <SpriteFont>(@"Font"); if (!SteamAPI.Init()) { Console.WriteLine("SteamAPI.Init() failed!"); } else { // Steam is running IsSteamRunning = true; // It's important that the next call happens AFTER the call to SteamAPI.Init(). InitializeCallbacks(); SteamUtils.SetOverlayNotificationPosition(ENotificationPosition.k_EPositionTopRight); // Uncomment the next line to adjust the OverlayNotificationPosition. //SteamUtils.SetOverlayNotificationInset(400, 0); // Set collactible data. CurrentLanguage = $"CurrentGameLanguage: {SteamApps.GetCurrentGameLanguage()}"; AvailableLanguages = $"Languages: {SteamApps.GetAvailableGameLanguages()}"; UserStats = $"Reqesting Current Stats - {SteamUserStats.RequestCurrentStats()}"; mNumberOfCurrentPlayers.Set(SteamUserStats.GetNumberOfCurrentPlayers()); var hSteamApiCall = SteamUserStats.FindLeaderboard("Quickest Win"); mCallResultFindLeaderboard.Set(hSteamApiCall); string folder; var length = SteamApps.GetAppInstallDir(SteamUtils.GetAppID(), out folder, 260); InstallDir = $"AppInstallDir: {length} {folder}"; // Get your Steam Avatar (Image) as a Texture2D. UserAvatar = GetSteamUserAvatar(GraphicsDevice); // Get your trimmed Steam User Name. var untrimmedUserName = SteamFriends.GetPersonaName(); // Remove unsupported chars like emojis or other stuff our font cannot handle. untrimmedUserName = ReplaceUnsupportedChars(Font, untrimmedUserName); SteamUserName = untrimmedUserName.Trim(); Exiting += Game1_Exiting; } }
public override void RequestLeaderboardEntries(string level, int playerCount, int from, int to, LeaderboardAction action) { currDownloadedEntries.Clear(); for (int i = 0; i < to; i++) { currDownloadedEntries.Add(new LeaderboardEntry(null, new CSteamID(), 0, 0, 0, 0, 0, 0)); } currAction = action; downloadRange = new Vector2(from, to); downloadEntries = true; SteamAPICall_t findHandle = SteamUserStats.FindLeaderboard(level + " - " + playerCount); LeaderboardFindResult.Set(findHandle, OnLeaderboardFindResult); }
/// <summary> /// Downloads the leaderboard for the filter criteria. The p_onDownloadedScores callback is invoked when done. /// First all score entries are fetched, then all user names are loaded if they are not yet cached by Steam. /// Avatars are loaded as soon as they are requested with SteamLeaderboardsMain.GetAvatarTexture. /// See also SteamLeaderboardsMain.OnDownloadedScores. /// </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 load.</param> /// <param name="p_scoreSource">source of the leaderboard entries (Global, AroundUser, Friends).</param> /// <param name="p_rangeStart">score entries range to load. For example, [0,10] for Global, [-4,5] for AroundUser.</param> /// <param name="p_rangeEnd">score entries range to load. For example, [0,10] for Global, [-4,5] for AroundUser.</param> /// <param name="p_onDownloadedScores">invoked when the leaderboard is either fully loaded or an error has occured.</param> public bool DownloadScores(string p_leaderboardName, ELeaderboardDataRequest p_scoreSource, int p_rangeStart, int p_rangeEnd, System.Action <LeaderboardsDownloadedScoresEventArgs> p_onDownloadedScores) { if (SteamManager.Initialized) { SetSingleShotEventHandler("OnDownloadedScores", ref OnDownloadedScores, p_onDownloadedScores); Execute <LeaderboardFindResult_t>(SteamUserStats.FindLeaderboard(p_leaderboardName), (p_callback, p_bIOFailure) => OnDownloadScoresFindLeaderboardCallCompleted(p_leaderboardName, p_scoreSource, p_rangeStart, p_rangeEnd, p_callback, p_bIOFailure)); return(true); // request started } else { ErrorEventArgs errorArgs = ErrorEventArgs.CreateSteamNotInit(); InvokeEventHandlerSafely(p_onDownloadedScores, new LeaderboardsDownloadedScoresEventArgs(errorArgs)); HandleError("DownloadScores: failed! ", errorArgs); return(false); // no request, because there is no connection to steam } }
public void HandleScoreUploads() { if (this.ScoresToSubmit.Count == 0 || this.IsSubmittingScore || !SteamManager.Initialized) { return; } this.CurrentScoreToSubmit = this.ScoresToSubmit.Pop(); this.IsSubmittingScore = true; if (this.m_SteamLeaderboard[(int)this.CurrentScoreToSubmit.Type].m_SteamLeaderboard == 0uL) { SteamAPICall_t hAPICall = SteamUserStats.FindLeaderboard("L" + this.CurrentScoreToSubmit.Type.ToString()); this.LeaderboardFindResult.Set(hAPICall, null); } else { SteamUserStats.UploadLeaderboardScore(this.m_SteamLeaderboard[(int)this.CurrentScoreToSubmit.Type], ELeaderboardUploadScoreMethod.k_ELeaderboardUploadScoreMethodForceUpdate, this.CurrentScoreToSubmit.Score.ToInt(), null, 0); this.IsSubmittingScore = false; } }
public void FindLeaderboard(string LeaderboardName, Action <LeaderboardHandle, bool> OnFind) { //marshal_context context; // char pchLeaderboardName = context.marshal_as< char >( LeaderboardName ); s_OnFind = OnFind; InteropHelp.TestIfAvailableClient(); //if( SteamUserStats() == 0 ) //{ // return; //} SteamAPICall_t hSteamAPICall = (SteamAPICall_t)SteamUserStats.FindLeaderboard(LeaderboardName); SteamMatches.g_CallResultFindLeaderboard = new CallResult <LeaderboardFindResult_t>(CallbackClass.instance.OnFindLeaderboard); SteamMatches.g_CallResultFindLeaderboard.Set(hSteamAPICall); //, SteamStats.g_CallbackClassInstance, CallbackClass.OnFindLeaderboard); }
void Start() { Object.DontDestroyOnLoad(this); universalPrefab = Resources.Load <GameObject>("Prefabs/Tile_NoCollider"); universalPrefabCollider = Resources.Load <GameObject>("Prefabs/Tile"); Object.DontDestroyOnLoad(universalPrefab); Texture2D t = Resources.Load <Texture2D>(SpritePaths.MouseCursor); Cursor.SetCursor(t, Vector2.zero, CursorMode.ForceSoftware); prevMainMenuLocationX = -1; prevMainMenuLocationY = 4; p1Char = C.Null; p2Char = C.Null; usingGamepad1 = false; usingGamepad2 = false; initialDifficulty = 4; difficulty = 4; unlockNew = 0; isDemo = false; dontFade = false; isTransitioning = false; mostCommonFont = new FontData(TextAnchor.UpperCenter, TextAlignment.Center, 0.03f); SetupFadeVars(); LoadGeemu(); StartCoroutine(SameScreenSave(false, true)); KEY_DELAY = saveInfo.savedOptions["keydelay"]; SetRes(); override2P = false; forceOnlinePause = false; if (SteamManager.Initialized) { m_findResult = new CallResult <LeaderboardFindResult_t>(); m_uploadResult = new CallResult <LeaderboardScoreUploaded_t>(); Callback_statsReceived = Callback <UserStatsReceived_t> .Create(OnGetUserStats); intQueue = new List <KeyValuePair <string, int> >(); SteamAPICall_t h1 = SteamUserStats.FindLeaderboard("STORYMODESCORE"); m_findResult.Set(h1, StoryScoreUpload); new Timer(timer_tick, null, 0, 1000); } }
// Use this for initialization void Start() { SteamAPI.Init(); //create overlay call overlayCall = Callback <GameOverlayActivated_t> .Create(OverlayActivate); //new call to find the leaderboard SteamAPICall_t initLeaderboard = SteamUserStats.FindLeaderboard(leaderboardName); findResultLeaderboard = CallResult <LeaderboardFindResult_t> .Create(FindResult); findResultLeaderboard.Set(initLeaderboard); //create upload inst uploadResultLeaderboard = CallResult <LeaderboardScoreUploaded_t> .Create(UploadResult); //create download inst downloadResultLeaderboard = CallResult <LeaderboardScoresDownloaded_t> .Create(DownloadResult); downloadResultPersonal = CallResult <LeaderboardScoresDownloaded_t> .Create(DownloadPersonalResult); }
public Promise <ulong> GetLeaderboardID(string name, bool createIfAbsent) { var result = new SimplePromise <ulong>(); MakeCall( createIfAbsent ? SteamUserStats.FindOrCreateLeaderboard(name, ELeaderboardSortMethod.k_ELeaderboardSortMethodDescending, ELeaderboardDisplayType.k_ELeaderboardDisplayTypeNumeric) : SteamUserStats.FindLeaderboard(name), delegate(LeaderboardFindResult_t args, bool ioFailure) { if (ioFailure || args.m_bLeaderboardFound == 0) { result.Fail("Failed to get leaderboard ID"); } else { var id = args.m_hSteamLeaderboard.m_SteamLeaderboard; result.Succeed(id); } } ); return(result); }
private void Awake() { SteamAPICall_t hSteamAPICall = SteamUserStats.FindLeaderboard("Rounds Survived"); m_findResult.Set(hSteamAPICall, OnLeaderboardFindResult); }
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(); }
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 }
/// <summary> /// Performs all actions related to the game start event. /// </summary> /// <param name="e">The game start event.</param> private void PerformGameStartActions(Event e) { ingame = true; startTime = Time.time; currentMode = e.mode; playerDeath = 0; //find leaderboard SteamAPICall_t findHandle = SteamUserStats.FindLeaderboard(e.level + " - " + e.playerCount); LeaderboardFindResult.Set(findHandle, OnLeaderboardFindResult); //playercount achievements if (e.playerCount == 1) { UnlockAchievement(AchievementID.ACH_PLAY_ALONE); } else if (e.playerCount == 4) { UnlockAchievement(AchievementID.ACH_PLAY_WITH_FOUR); } if (e.mobilePlayers > 0) { UnlockAchievement(AchievementID.ACH_SMARTPHONE_JOIN); } //reset powerups characterPowerups.Clear(); totalPowerups = 0; foreach (string character in e.characters) { switch (character) //fill bitwise to save info in just one int { case "Timeshifter": if ((charactersPlayed & 1) != 1) { charactersPlayed += 1; } break; case "Birdman": if ((charactersPlayed & 2) != 2) { charactersPlayed += 2; } break; case "Charger": if ((charactersPlayed & 4) != 4) { charactersPlayed += 4; } break; case "Fatman": if ((charactersPlayed & 8) != 8) { charactersPlayed += 8; } break; case "Babuschka": if ((charactersPlayed & 16) != 16) { charactersPlayed += 16; } break; case "Pantomime": if ((charactersPlayed & 32) != 32) { charactersPlayed += 32; } break; case "Tomic": if ((charactersPlayed & 64) != 64) { charactersPlayed += 64; } break; } characterPowerups.Add(character, 0); } }
private void FindLeaderboard() { var handle = SteamUserStats.FindLeaderboard(leaderboardName); OnLeaderboardFindResultCallResult.Set(handle); }
static EResult DownloadLeaderboard(uint appid, string lbname) { Console.WriteLine($"Locating leaderboard {lbname} for appID {appid}..."); var findLeaderboardJob = steamUserStats.FindLeaderboard(appid, lbname); while (findLeaderboardJob.GetAwaiter().IsCompleted) { manager.RunWaitCallbacks(TimeSpan.FromSeconds(1)); if (!isRunning) { return(EResult.Fail); } } var leaderboardResult = findLeaderboardJob.GetAwaiter().GetResult(); if (leaderboardResult.Result != EResult.OK) { Console.Error.WriteLine($"Failed to locate leaderboard {lbname} for appID {appid}! Error code: {leaderboardResult.Result.ToString()}"); return(leaderboardResult.Result); } if (leaderboardResult.ID == 0) { Console.Error.WriteLine($"Failed to locate leaderboard {lbname} for appID {appid}! ID returned was 0"); return(EResult.Fail); } var firstEntry = 1; var lastEntry = leaderboardResult.EntryCount; var downloadEntryCount = lastEntry - firstEntry + 1; Console.WriteLine($"Found leaderboard {lbname}."); Console.WriteLine($"Preparing to download {downloadEntryCount} entries..."); var outputFilename = $"{leaderboardResult.ID}.csv"; try { using (var outputWriter = new StreamWriter(File.Open(outputFilename, FileMode.Create))) { outputWriter.WriteLine(lbname); for (int i = 0; i < downloadEntryCount / batchSize; ++i) { DownloadLeaderboardRange(appid, leaderboardResult.ID, i * batchSize + firstEntry, firstEntry + (i + 1) * batchSize - 1, downloadEntryCount, outputWriter); } if (downloadEntryCount % batchSize != 0) { DownloadLeaderboardRange(appid, leaderboardResult.ID, (downloadEntryCount / batchSize) * batchSize + firstEntry, lastEntry, downloadEntryCount, outputWriter); } Console.WriteLine($"Done! Results for {lbname} written to {outputFilename}"); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); return(EResult.Fail); } return(EResult.OK); }