Skip to content

Commit

Permalink
Visual improvements, notify if game unknown to RetroAchievements
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Jun 22, 2023
1 parent 78d9bd1 commit ee30ce5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 9 additions & 7 deletions UI/RetroAchievementScreens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ void RenderAchievement(UIContext &dc, const Achievements::Achievement &achieveme
background.color = 0x706060;
}
background.color = colorAlpha(background.color, alpha);
uint32_t fgColor = colorAlpha(dc.theme->itemStyle.fgColor, alpha);

if (style == AchievementRenderStyle::UNLOCKED) {
float mixWhite = pow(Clamp((float)(1.0f - (time_s - startTime)), 0.0f, 1.0f), 3.0f);
Expand All @@ -168,23 +169,23 @@ void RenderAchievement(UIContext &dc, const Achievements::Achievement &achieveme
dc.SetFontStyle(dc.theme->uiFont);

dc.SetFontScale(1.0f, 1.0f);
dc.DrawTextRect(achievement.title.c_str(), bounds.Inset(iconSpace + 12.0f, 2.0f, 5.0f, 5.0f), dc.theme->itemStyle.fgColor, ALIGN_TOPLEFT);
dc.DrawTextRect(achievement.title.c_str(), bounds.Inset(iconSpace + 12.0f, 2.0f, 5.0f, 5.0f), fgColor, ALIGN_TOPLEFT);

dc.SetFontScale(0.66f, 0.66f);
dc.DrawTextRect(achievement.description.c_str(), bounds.Inset(iconSpace + 12.0f, 39.0f, 5.0f, 5.0f), dc.theme->itemStyle.fgColor, ALIGN_TOPLEFT);
dc.DrawTextRect(achievement.description.c_str(), bounds.Inset(iconSpace + 12.0f, 39.0f, 5.0f, 5.0f), fgColor, ALIGN_TOPLEFT);

char temp[64];
snprintf(temp, sizeof(temp), "%d", achievement.points);

dc.SetFontScale(1.5f, 1.5f);
dc.DrawTextRect(temp, bounds.Expand(-5.0f, -5.0f), dc.theme->itemStyle.fgColor, ALIGN_RIGHT | ALIGN_VCENTER);
dc.DrawTextRect(temp, bounds.Expand(-5.0f, -5.0f), fgColor, ALIGN_RIGHT | ALIGN_VCENTER);

dc.SetFontScale(1.0f, 1.0f);
dc.Flush();

std::string name = Achievements::GetAchievementBadgePath(achievement);
if (g_iconCache.BindIconTexture(&dc, name)) {
dc.Draw()->DrawTexRect(Bounds(bounds.x + 4.0f, bounds.y + 4.0f, iconSpace, iconSpace), 0.0f, 0.0f, 1.0f, 1.0f, 0xFFFFFFFF);
dc.Draw()->DrawTexRect(Bounds(bounds.x + 4.0f, bounds.y + 4.0f, iconSpace, iconSpace), 0.0f, 0.0f, 1.0f, 1.0f, whiteAlpha(alpha));
}

dc.Flush();
Expand All @@ -196,6 +197,7 @@ void RenderGameAchievementSummary(UIContext &dc, int gameID, const Bounds &bound
UI::Drawable background = dc.theme->itemStyle.background;

background.color = colorAlpha(background.color, alpha);
uint32_t fgColor = colorAlpha(dc.theme->itemStyle.fgColor, alpha);

float iconSpace = 64.0f;
dc.Flush();
Expand All @@ -206,20 +208,20 @@ void RenderGameAchievementSummary(UIContext &dc, int gameID, const Bounds &bound
dc.SetFontStyle(dc.theme->uiFont);

dc.SetFontScale(1.0f, 1.0f);
dc.DrawTextRect(Achievements::GetGameTitle().c_str(), bounds.Inset(iconSpace + 5.0f, 2.0f, 5.0f, 5.0f), dc.theme->itemStyle.fgColor, ALIGN_TOPLEFT);
dc.DrawTextRect(Achievements::GetGameTitle().c_str(), bounds.Inset(iconSpace + 5.0f, 2.0f, 5.0f, 5.0f), fgColor, ALIGN_TOPLEFT);

std::string description = Achievements::GetGameAchievementSummary();
std::string icon = Achievements::GetGameIcon();

dc.SetFontScale(0.66f, 0.66f);
dc.DrawTextRect(description.c_str(), bounds.Inset(iconSpace + 5.0f, 38.0f, 5.0f, 5.0f), dc.theme->itemStyle.fgColor, ALIGN_TOPLEFT);
dc.DrawTextRect(description.c_str(), bounds.Inset(iconSpace + 5.0f, 38.0f, 5.0f, 5.0f), fgColor, ALIGN_TOPLEFT);

dc.SetFontScale(1.0f, 1.0f);
dc.Flush();

std::string name = icon;
if (g_iconCache.BindIconTexture(&dc, name)) {
dc.Draw()->DrawTexRect(Bounds(bounds.x, bounds.y, iconSpace, iconSpace), 0.0f, 0.0f, 1.0f, 1.0f, 0xFFFFFFFF);
dc.Draw()->DrawTexRect(Bounds(bounds.x, bounds.y, iconSpace, iconSpace), 0.0f, 0.0f, 1.0f, 1.0f, whiteAlpha(alpha));
}

dc.Flush();
Expand Down
2 changes: 2 additions & 0 deletions UI/RetroAchievements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,9 @@ void Achievements::GetGameIdCallback(s32 status_code, std::string content_type,
NOTICE_LOG(ACHIEVEMENTS, "Server returned GameID %u", game_id);
if (game_id == 0)
{
auto ac = GetI18NCategory(I18NCat::ACHIEVEMENTS);
// We don't want to block saving/loading states when there's no achievements.
OSDAddNotification(4.0f, ac->T("RetroAchievements are not available for this game"), "", "");
DisableChallengeMode();
return;
}
Expand Down

0 comments on commit ee30ce5

Please sign in to comment.