From 80d77cfdadc48a0cd05a4977d5a18478b24177b4 Mon Sep 17 00:00:00 2001 From: LillyJadeKatrin Date: Tue, 4 Jul 2023 16:17:10 -0400 Subject: [PATCH] Added colored borders to badges in achievements dialog The achievement badges will now have a blue or gold border to identify whether they have been unlocked in softcore or hardcore mode. Similarly, the game badge will have a blue border if all achievements have been unlocked in either mode or a gold border if all achievements have been unlocked in hardcore mode. --- Source/Core/Core/AchievementManager.h | 4 ++++ .../DolphinQt/Achievements/AchievementHeaderWidget.cpp | 8 +++++++- .../DolphinQt/Achievements/AchievementProgressWidget.cpp | 9 +++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/AchievementManager.h b/Source/Core/Core/AchievementManager.h index 6379cee94a..f7866f0926 100644 --- a/Source/Core/Core/AchievementManager.h +++ b/Source/Core/Core/AchievementManager.h @@ -79,6 +79,10 @@ public: BadgeStatus unlocked_badge; }; + static constexpr std::string_view GRAY = "transparent"; + static constexpr std::string_view GOLD = "#FFD700"; + static constexpr std::string_view BLUE = "#0B71C1"; + static AchievementManager* GetInstance(); void Init(); void SetUpdateCallback(UpdateCallback callback); diff --git a/Source/Core/DolphinQt/Achievements/AchievementHeaderWidget.cpp b/Source/Core/DolphinQt/Achievements/AchievementHeaderWidget.cpp index b6eeb09897..63d3375d9b 100644 --- a/Source/Core/DolphinQt/Achievements/AchievementHeaderWidget.cpp +++ b/Source/Core/DolphinQt/Achievements/AchievementHeaderWidget.cpp @@ -119,7 +119,13 @@ void AchievementHeaderWidget::UpdateData() m_game_icon->setPixmap(QPixmap::fromImage(i_game_icon) .scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation)); m_game_icon->adjustSize(); - m_game_icon->setStyleSheet(QStringLiteral("border: 4px solid transparent")); + std::string_view color = AchievementManager::GRAY; + if (point_spread.hard_unlocks == point_spread.total_count) + color = AchievementManager::GOLD; + else if (point_spread.hard_unlocks + point_spread.soft_unlocks == point_spread.total_count) + color = AchievementManager::BLUE; + m_game_icon->setStyleSheet( + QStringLiteral("border: 4px solid %1").arg(QString::fromStdString(std::string(color)))); m_game_icon->setVisible(true); } } diff --git a/Source/Core/DolphinQt/Achievements/AchievementProgressWidget.cpp b/Source/Core/DolphinQt/Achievements/AchievementProgressWidget.cpp index 8879f940f2..0ec17930c2 100644 --- a/Source/Core/DolphinQt/Achievements/AchievementProgressWidget.cpp +++ b/Source/Core/DolphinQt/Achievements/AchievementProgressWidget.cpp @@ -30,6 +30,8 @@ #include "DolphinQt/QtUtils/SignalBlocking.h" #include "DolphinQt/Settings.h" +static constexpr bool hardcore_mode_enabled = false; + AchievementProgressWidget::AchievementProgressWidget(QWidget* parent) : QWidget(parent) { m_common_box = new QGroupBox(); @@ -57,22 +59,27 @@ AchievementProgressWidget::CreateAchievementBox(const rc_api_achievement_definit QLabel* a_badge = new QLabel(); const auto unlock_status = AchievementManager::GetInstance()->GetUnlockStatus(achievement->id); const AchievementManager::BadgeStatus* badge = &unlock_status.locked_badge; + std::string_view color = AchievementManager::GRAY; if (unlock_status.remote_unlock_status == AchievementManager::UnlockStatus::UnlockType::HARDCORE) { badge = &unlock_status.unlocked_badge; + color = AchievementManager::GOLD; } else if (hardcore_mode_enabled && unlock_status.session_unlock_count > 1) { badge = &unlock_status.unlocked_badge; + color = AchievementManager::GOLD; } else if (unlock_status.remote_unlock_status == AchievementManager::UnlockStatus::UnlockType::SOFTCORE) { badge = &unlock_status.unlocked_badge; + color = AchievementManager::BLUE; } else if (unlock_status.session_unlock_count > 1) { badge = &unlock_status.unlocked_badge; + color = AchievementManager::BLUE; } if (Config::Get(Config::RA_BADGES_ENABLED) && badge->name != "") { @@ -82,6 +89,8 @@ AchievementProgressWidget::CreateAchievementBox(const rc_api_achievement_definit a_badge->setPixmap(QPixmap::fromImage(i_badge).scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation)); a_badge->adjustSize(); + a_badge->setStyleSheet( + QStringLiteral("border: 4px solid %1").arg(QString::fromStdString(std::string(color)))); } }