Merge pull request #12763 from LillyJadeKatrin/retroachievements-welcome
Retooled Achievements Welcome Message
This commit is contained in:
commit
98f0f844fb
|
@ -215,14 +215,6 @@ void AchievementManager::DoFrame()
|
||||||
{
|
{
|
||||||
if (!IsGameLoaded() || !Core::IsCPUThread())
|
if (!IsGameLoaded() || !Core::IsCPUThread())
|
||||||
return;
|
return;
|
||||||
if (m_framecount == 0x200)
|
|
||||||
{
|
|
||||||
DisplayWelcomeMessage();
|
|
||||||
}
|
|
||||||
if (m_framecount <= 0x200)
|
|
||||||
{
|
|
||||||
m_framecount++;
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
std::lock_guard lg{m_lock};
|
std::lock_guard lg{m_lock};
|
||||||
rc_client_do_frame(m_client);
|
rc_client_do_frame(m_client);
|
||||||
|
@ -593,6 +585,8 @@ void AchievementManager::LoadGameCallback(int result, const char* error_message,
|
||||||
if (result != RC_OK)
|
if (result != RC_OK)
|
||||||
{
|
{
|
||||||
WARN_LOG_FMT(ACHIEVEMENTS, "Failed to load data for current game.");
|
WARN_LOG_FMT(ACHIEVEMENTS, "Failed to load data for current game.");
|
||||||
|
OSD::AddMessage("Achievements are not supported for this title.", OSD::Duration::VERY_LONG,
|
||||||
|
OSD::Color::RED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -600,10 +594,13 @@ void AchievementManager::LoadGameCallback(int result, const char* error_message,
|
||||||
if (!game)
|
if (!game)
|
||||||
{
|
{
|
||||||
ERROR_LOG_FMT(ACHIEVEMENTS, "Failed to retrieve game information from client.");
|
ERROR_LOG_FMT(ACHIEVEMENTS, "Failed to retrieve game information from client.");
|
||||||
|
OSD::AddMessage("Failed to load achievements for this title.", OSD::Duration::VERY_LONG,
|
||||||
|
OSD::Color::RED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
INFO_LOG_FMT(ACHIEVEMENTS, "Loaded data for game ID {}.", game->id);
|
INFO_LOG_FMT(ACHIEVEMENTS, "Loaded data for game ID {}.", game->id);
|
||||||
|
|
||||||
|
AchievementManager::GetInstance().m_display_welcome_message = true;
|
||||||
AchievementManager::GetInstance().FetchGameBadges();
|
AchievementManager::GetInstance().FetchGameBadges();
|
||||||
AchievementManager::GetInstance().m_system = &Core::System::GetInstance();
|
AchievementManager::GetInstance().m_system = &Core::System::GetInstance();
|
||||||
AchievementManager::GetInstance().m_update_callback({.all = true});
|
AchievementManager::GetInstance().m_update_callback({.all = true});
|
||||||
|
@ -634,9 +631,10 @@ void AchievementManager::ChangeMediaCallback(int result, const char* error_messa
|
||||||
void AchievementManager::DisplayWelcomeMessage()
|
void AchievementManager::DisplayWelcomeMessage()
|
||||||
{
|
{
|
||||||
std::lock_guard lg{m_lock};
|
std::lock_guard lg{m_lock};
|
||||||
|
m_display_welcome_message = false;
|
||||||
const u32 color =
|
const u32 color =
|
||||||
rc_client_get_hardcore_enabled(m_client) ? OSD::Color::YELLOW : OSD::Color::CYAN;
|
rc_client_get_hardcore_enabled(m_client) ? OSD::Color::YELLOW : OSD::Color::CYAN;
|
||||||
if (Config::Get(Config::RA_BADGES_ENABLED))
|
if (Config::Get(Config::RA_BADGES_ENABLED) && !m_game_badge.name.empty())
|
||||||
{
|
{
|
||||||
OSD::AddMessage("", OSD::Duration::VERY_LONG, OSD::Color::GREEN,
|
OSD::AddMessage("", OSD::Duration::VERY_LONG, OSD::Color::GREEN,
|
||||||
DecodeBadgeToOSDIcon(m_game_badge.badge));
|
DecodeBadgeToOSDIcon(m_game_badge.badge));
|
||||||
|
@ -882,11 +880,18 @@ void AchievementManager::FetchBadge(AchievementManager::BadgeStatus* badge, u32
|
||||||
if (!m_client || !HasAPIToken() || !Config::Get(Config::RA_BADGES_ENABLED))
|
if (!m_client || !HasAPIToken() || !Config::Get(Config::RA_BADGES_ENABLED))
|
||||||
{
|
{
|
||||||
m_update_callback(callback_data);
|
m_update_callback(callback_data);
|
||||||
|
if (m_display_welcome_message && badge_type == RC_IMAGE_TYPE_GAME)
|
||||||
|
DisplayWelcomeMessage();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_image_queue.EmplaceItem([this, badge, badge_type, function = std::move(function),
|
m_image_queue.EmplaceItem([this, badge, badge_type, function = std::move(function),
|
||||||
callback_data = std::move(callback_data)] {
|
callback_data = std::move(callback_data)] {
|
||||||
|
Common::ScopeGuard on_end_scope([&]() {
|
||||||
|
if (m_display_welcome_message && badge_type == RC_IMAGE_TYPE_GAME)
|
||||||
|
DisplayWelcomeMessage();
|
||||||
|
});
|
||||||
|
|
||||||
std::string name_to_fetch;
|
std::string name_to_fetch;
|
||||||
{
|
{
|
||||||
std::lock_guard lg{m_lock};
|
std::lock_guard lg{m_lock};
|
||||||
|
|
|
@ -192,8 +192,8 @@ private:
|
||||||
u32 m_game_id = 0;
|
u32 m_game_id = 0;
|
||||||
rc_api_fetch_game_data_response_t m_game_data{};
|
rc_api_fetch_game_data_response_t m_game_data{};
|
||||||
bool m_is_game_loaded = false;
|
bool m_is_game_loaded = false;
|
||||||
u32 m_framecount = 0;
|
|
||||||
BadgeStatus m_game_badge;
|
BadgeStatus m_game_badge;
|
||||||
|
bool m_display_welcome_message = false;
|
||||||
std::unordered_map<AchievementId, BadgeStatus> m_unlocked_badges;
|
std::unordered_map<AchievementId, BadgeStatus> m_unlocked_badges;
|
||||||
std::unordered_map<AchievementId, BadgeStatus> m_locked_badges;
|
std::unordered_map<AchievementId, BadgeStatus> m_locked_badges;
|
||||||
RichPresence m_rich_presence;
|
RichPresence m_rich_presence;
|
||||||
|
|
Loading…
Reference in New Issue