Created
March 15, 2018 10:18
-
-
Save rdeioris/9e2ff348641485bfe88ade58adfe91e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define _CRT_SECURE_NO_WARNINGS | |
| #include <string> | |
| #include <iostream> | |
| #include <steam_api.h> | |
| class FollowerRetriever | |
| { | |
| public: | |
| void GetFollowersCount() | |
| { | |
| SteamAPICall_t handle = SteamFriends()->GetFollowerCount(SteamUser()->GetSteamID()); | |
| LocalCallback.Set(handle, this, &FollowerRetriever::OnRetrievedData); | |
| } | |
| void OnRetrievedData(FriendsGetFollowerCount_t *PCallback, bool bIOFailure) | |
| { | |
| std::cout << "followers: " << PCallback->m_nCount << std::endl; | |
| } | |
| protected: | |
| CCallResult<FollowerRetriever, FriendsGetFollowerCount_t> LocalCallback; | |
| }; | |
| struct AivScreenshot : public CCallbackImpl<sizeof(ScreenshotReady_t)> | |
| { | |
| void Run(void *params) | |
| { | |
| std::cout << "Raw callback" << std::endl; | |
| } | |
| }; | |
| class AivCallbacks | |
| { | |
| public: | |
| STEAM_CALLBACK(AivCallbacks, OnFriendsListBoh, PersonaStateChange_t); | |
| STEAM_CALLBACK(AivCallbacks, OnScreenshotDone, ScreenshotReady_t); | |
| STEAM_CALLBACK(AivCallbacks, OnOverlayActivated, GameOverlayActivated_t); | |
| }; | |
| void AivCallbacks::OnFriendsListBoh(PersonaStateChange_t *PCallback) | |
| { | |
| std::cout << "Friends Level list ready" << std::endl; | |
| } | |
| void AivCallbacks::OnScreenshotDone(ScreenshotReady_t *PCallback) | |
| { | |
| std::cout << "Screenshot return value: " << PCallback->m_eResult << std::endl; | |
| } | |
| void AivCallbacks::OnOverlayActivated(GameOverlayActivated_t *PCallback) | |
| { | |
| std::cout << "OVERLAY !!!" << std::endl; | |
| } | |
| int main(int argc, char **argv) | |
| { | |
| if (!SteamAPI_Init()) | |
| { | |
| std::cerr << "unable to initialize steam" << std::endl; | |
| } | |
| const char *MyName = SteamFriends()->GetPersonaName(); | |
| AivCallbacks aiv; | |
| AivScreenshot aivScreenshot; | |
| std::cout << MyName << std::endl; | |
| int FriendsCount = SteamFriends()->GetFriendCount(k_EFriendFlagAll); | |
| SteamAPI_RegisterCallback((CCallbackBase *)&aivScreenshot, ScreenshotReady_t::k_iCallback); | |
| for (int i = 0; i < FriendsCount; i++) | |
| { | |
| CSteamID SteamId = SteamFriends()->GetFriendByIndex(i, k_EFriendFlagAll); | |
| const char *FriendName = SteamFriends()->GetFriendPersonaName(SteamId); | |
| int FriendLevel = SteamFriends()->GetFriendSteamLevel(SteamId); | |
| std::cout << FriendName << " " << FriendLevel << std::endl; | |
| } | |
| FollowerRetriever retriever; | |
| retriever.GetFollowersCount(); | |
| int MyLevel = SteamUser()->GetPlayerSteamLevel(); | |
| std::cout << "Level: " << MyLevel << std::endl; | |
| if (SteamScreenshots()->AddScreenshotToLibrary("E:/boh.jpg", nullptr, 1440, 960) == INVALID_SCREENSHOT_HANDLE) | |
| { | |
| std::cout << "Cannot send screenshot" << std::endl; | |
| } | |
| for (;;) | |
| { | |
| SteamAPI_RunCallbacks(); | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment