GameList: Only use lookup achievements icons if logged in

In other words, you need a RetroAchievements account to get access to
the badges.
pull/3718/head
Stenzek 5 months ago
parent c9a7bf7420
commit fc017569bb
No known key found for this signature in database

@ -9,6 +9,7 @@
#include "bus.h"
#include "cheats.h"
#include "core.h"
#include "core_private.h"
#include "cpu_core.h"
#include "fullscreenui.h"
#include "fullscreenui_private.h"
@ -116,7 +117,6 @@ template<typename... T>
static void ReportRCError(int err, fmt::format_string<T...> fmt, T&&... args);
static void ClearGameInfo();
static void ClearGameHash();
static bool HasSavedCredentials();
static bool TryLoggingInWithToken();
static void EnableHardcoreMode(bool display_message, bool display_game_summary);
static void OnHardcoreModeChanged(bool enabled, bool display_message, bool display_game_summary);
@ -682,9 +682,11 @@ void Achievements::DestroyClient(std::unique_lock<std::recursive_mutex>& lock)
bool Achievements::HasSavedCredentials()
{
const TinyString username = Core::GetTinyStringSettingValue("Cheevos", "Username");
const TinyString api_token = Core::GetTinyStringSettingValue("Cheevos", "Token");
return (!username.empty() && !api_token.empty());
const auto lock = Core::GetSettingsLock();
const SettingsInterface* si = Core::GetBaseSettingsLayer();
std::string_view username, token;
return (si->LookupValue("Cheevos", "Username", &username) && !username.empty() &&
si->LookupValue("Cheevos", "Token", &token) && !token.empty());
}
bool Achievements::TryLoggingInWithToken()

@ -168,6 +168,9 @@ bool IsLoggedIn();
/// Returns true if the user has been successfully logged in, or the request is in progress.
bool IsLoggedInOrLoggingIn();
/// Returns true if credentials have been saved for login.
bool HasSavedCredentials();
/// Returns the logged-in user name.
const std::string& GetLoggedInUserName();

@ -2316,6 +2316,10 @@ std::string GameList::GetAchievementGameBadgeURL(u32 game_id)
{
LoadAchievementGameBadges();
// don't allow use of achievement badges if we're not logged in to achievements
if (!Achievements::HasSavedCredentials())
return {};
const auto iter =
std::lower_bound(s_state.achievement_game_id_badges.begin(), s_state.achievement_game_id_badges.end(), game_id,
[](const auto& entry, u32 search) { return entry.first < search; });

Loading…
Cancel
Save