mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
Merge pull request #12935 from AdmiralCurtiss/achievements-default-badges
AchievementManager: Improve player/game badge handling and fix crash when no badge is loaded
This commit is contained in:
commit
505fe5cc0e
@ -440,7 +440,7 @@ u32 AchievementManager::GetPlayerScore() const
|
||||
|
||||
const AchievementManager::Badge& AchievementManager::GetPlayerBadge() const
|
||||
{
|
||||
return m_player_badge;
|
||||
return m_player_badge.data.empty() ? m_default_player_badge : m_player_badge;
|
||||
}
|
||||
|
||||
std::string_view AchievementManager::GetGameDisplayName() const
|
||||
@ -460,7 +460,7 @@ rc_api_fetch_game_data_response_t* AchievementManager::GetGameData()
|
||||
|
||||
const AchievementManager::Badge& AchievementManager::GetGameBadge() const
|
||||
{
|
||||
return m_game_badge;
|
||||
return m_game_badge.data.empty() ? m_default_game_badge : m_game_badge;
|
||||
}
|
||||
|
||||
const AchievementManager::Badge& AchievementManager::GetAchievementBadge(AchievementId id,
|
||||
@ -696,7 +696,6 @@ void AchievementManager::LoadDefaultBadges()
|
||||
DEFAULT_PLAYER_BADGE_FILENAME);
|
||||
}
|
||||
}
|
||||
m_player_badge = m_default_player_badge;
|
||||
|
||||
if (m_default_game_badge.data.empty())
|
||||
{
|
||||
@ -707,7 +706,6 @@ void AchievementManager::LoadDefaultBadges()
|
||||
DEFAULT_GAME_BADGE_FILENAME);
|
||||
}
|
||||
}
|
||||
m_game_badge = m_default_game_badge;
|
||||
|
||||
if (m_default_unlocked_badge.data.empty())
|
||||
{
|
||||
@ -888,7 +886,7 @@ void AchievementManager::DisplayWelcomeMessage()
|
||||
const u32 color =
|
||||
rc_client_get_hardcore_enabled(m_client) ? OSD::Color::YELLOW : OSD::Color::CYAN;
|
||||
|
||||
OSD::AddMessage("", OSD::Duration::VERY_LONG, OSD::Color::GREEN, &m_game_badge);
|
||||
OSD::AddMessage("", OSD::Duration::VERY_LONG, OSD::Color::GREEN, &GetGameBadge());
|
||||
auto info = rc_client_get_game_info(m_client);
|
||||
if (!info)
|
||||
{
|
||||
@ -1033,7 +1031,7 @@ void AchievementManager::HandleGameCompletedEvent(const rc_client_event_t* clien
|
||||
OSD::AddMessage(fmt::format("Congratulations! {} has {} {}", user_info->display_name,
|
||||
hardcore ? "mastered" : "completed", game_info->title),
|
||||
OSD::Duration::VERY_LONG, hardcore ? OSD::Color::YELLOW : OSD::Color::CYAN,
|
||||
&AchievementManager::GetInstance().m_game_badge);
|
||||
&AchievementManager::GetInstance().GetGameBadge());
|
||||
}
|
||||
|
||||
void AchievementManager::HandleResetEvent(const rc_client_event_t* client_event)
|
||||
|
@ -84,10 +84,13 @@ void AchievementHeaderWidget::UpdateData()
|
||||
m_user_icon->setVisible(false);
|
||||
m_user_icon->clear();
|
||||
m_user_icon->setText({});
|
||||
QImage i_user_icon(&player_badge.data.front(), player_badge.width, player_badge.height,
|
||||
if (!player_badge.data.empty())
|
||||
{
|
||||
QImage i_user_icon(player_badge.data.data(), player_badge.width, player_badge.height,
|
||||
QImage::Format_RGBA8888);
|
||||
m_user_icon->setPixmap(QPixmap::fromImage(i_user_icon)
|
||||
.scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||
}
|
||||
m_user_icon->adjustSize();
|
||||
m_user_icon->setStyleSheet(QStringLiteral("border: 4px solid transparent"));
|
||||
m_user_icon->setVisible(true);
|
||||
@ -100,10 +103,13 @@ void AchievementHeaderWidget::UpdateData()
|
||||
{
|
||||
rc_client_user_game_summary_t game_summary;
|
||||
rc_client_get_user_game_summary(instance.GetClient(), &game_summary);
|
||||
QImage i_game_icon(&game_badge.data.front(), game_badge.width, game_badge.height,
|
||||
if (game_badge.data.empty())
|
||||
{
|
||||
QImage i_game_icon(game_badge.data.data(), game_badge.width, game_badge.height,
|
||||
QImage::Format_RGBA8888);
|
||||
m_game_icon->setPixmap(QPixmap::fromImage(i_game_icon)
|
||||
.scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||
}
|
||||
m_game_icon->adjustSize();
|
||||
std::string_view color = AchievementManager::GRAY;
|
||||
if (game_summary.num_core_achievements == game_summary.num_unlocked_achievements)
|
||||
|
Loading…
Reference in New Issue
Block a user