void GoogleTalk::CheckLoginStatus() { if(fAuth && fRostered && fAgent && !fFullLogged) LoggedIn(); }
void Jabber::CheckLoginStatus() { if(fAuth && fRostered && fAgent && !fFullLogged) LoggedIn(); }
// This is still somewhat game-specific. (Because it assumes that your // leaderboards are tied to events.) TODO: clean this up further later. void GPGManager::ShowLeaderboards(const GPGIds *ids, size_t id_len) { #ifdef NO_GPG return; #endif if (!LoggedIn()) return; SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GPG: launching leaderboard UI"); // First, get all current event counts from GPG in one callback, // which allows us to conveniently update and show the leaderboards without // having to deal with multiple callbacks. game_services_->Events().FetchAll([id_len, ids, this]( const gpg::EventManager::FetchAllResponse &far) { for (auto it = far.data.begin(); it != far.data.end(); ++it) { // Look up leaderboard id from corresponding event id. const char *leaderboard_id = nullptr; for (size_t i = 0; i < id_len; i++) { if (ids[i].event == it->first) { leaderboard_id = ids[i].leaderboard; } } assert(leaderboard_id); if (leaderboard_id) { game_services_->Leaderboards().SubmitScore(leaderboard_id, it->second.Count()); SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GPG: submitted score %llu for id %s", it->second.Count(), leaderboard_id); } } game_services_->Leaderboards().ShowAllUI([](const gpg::UIStatus &status) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GPG: Leaderboards UI FAILED, UIStatus is: %d", status); }); }); }
void GPGManager::IncrementEvent(const char *event_id, uint64_t score) { #ifdef NO_GPG return; #endif if (!LoggedIn()) return; game_services_->Events().Increment(event_id, score); }
void GPGManager::ShowAchievements() { #ifdef NO_GPG return; #endif if (!LoggedIn()) return; SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GPG: launching achievement UI"); game_services_->Achievements().ShowAllUI([](const gpg::UIStatus &status) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GPG: Achievement UI FAILED, UIStatus is: %d", status); }); }
// Updates local player achievements with values from the server: void GPGManager::FetchAchievements() { if (!LoggedIn() || achievement_data_state_ == kPending) return; achievement_data_state_ = kPending; game_services_->Achievements().FetchAll( [this](const gpg::AchievementManager::FetchAllResponse &far) mutable { pthread_mutex_lock(&achievements_mutex_); if (IsSuccess(far.status)) { achievement_data_state_ = kComplete; achievement_data_initialized_ = true; } else { achievement_data_state_ = kFailed; } achievement_data_ = far.data; pthread_mutex_unlock(&achievements_mutex_); }); }
// Reveals a given achievement. void GPGManager::RevealAchievement(std::string achievement_id) { if (LoggedIn()) { game_services_->Achievements().Reveal(achievement_id); } }
// Increments an incremental achievement by an amount. void GPGManager::IncrementAchievement(std::string achievement_id, uint32_t steps) { if (LoggedIn()) { game_services_->Achievements().Increment(achievement_id, steps); } }
// Unlocks a given achievement. void GPGManager::UnlockAchievement(std::string achievement_id) { if (LoggedIn()) { game_services_->Achievements().Unlock(achievement_id); } }