Skip to content

Commit 414ddf7

Browse files
committed
Achievements: Display warning for unsupported achievements
1 parent 95ccd7c commit 414ddf7

File tree

3 files changed

+98
-33
lines changed

3 files changed

+98
-33
lines changed

dep/imgui/include/IconsEmoji.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// List to use: https://www.freecodecamp.org/news/all-emojis-emoji-list-for-copy-and-paste/
88

99
#define ICON_EMOJI_WARNING "\xe2\x9a\xa0"
10+
#define ICON_EMOJI_CHECKMARK_BUTTON "\xe2\x9c\x85"
1011
#define ICON_EMOJI_OPTICAL_DISK "\xf0\x9f\x92\xbf"
1112
#define ICON_EMOJI_FLOPPY_DISK "\xf0\x9f\x92\xbe"
1213
#define ICON_EMOJI_INFORMATION "\xe2\x84\xb9"

src/core/achievements.cpp

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ static constexpr u32 LEADERBOARD_ALL_FETCH_SIZE = 20;
7777
static constexpr float LOGIN_NOTIFICATION_TIME = 5.0f;
7878
static constexpr float ACHIEVEMENT_SUMMARY_NOTIFICATION_TIME = 5.0f;
7979
static constexpr float ACHIEVEMENT_SUMMARY_NOTIFICATION_TIME_HC = 10.0f;
80+
static constexpr float ACHIEVEMENT_SUMMARY_UNSUPPORTED_TIME = 12.0f;
8081
static constexpr float GAME_COMPLETE_NOTIFICATION_TIME = 20.0f;
8182
static constexpr float LEADERBOARD_STARTED_NOTIFICATION_TIME = 3.0f;
8283
static constexpr float LEADERBOARD_FAILED_NOTIFICATION_TIME = 3.0f;
@@ -1385,9 +1386,24 @@ void Achievements::DisplayAchievementSummary()
13851386
if (!FullscreenUI::Initialize())
13861387
return;
13871388

1388-
ImGuiFullscreen::AddNotification("achievement_summary", time, std::move(title), std::move(summary),
1389+
ImGuiFullscreen::AddNotification("AchievementsSummary", time, std::move(title), std::move(summary),
13891390
std::move(icon));
13901391
});
1392+
1393+
if (s_state.game_summary.num_unsupported_achievements > 0)
1394+
{
1395+
GPUThread::RunOnThread([num_unsupported = s_state.game_summary.num_unsupported_achievements]() mutable {
1396+
if (!FullscreenUI::Initialize())
1397+
return;
1398+
1399+
ImGuiFullscreen::AddNotification("UnsupportedAchievements", ACHIEVEMENT_SUMMARY_UNSUPPORTED_TIME,
1400+
TRANSLATE_STR("Achievements", "Unsupported Achievements"),
1401+
TRANSLATE_PLURAL_STR("Achievements",
1402+
"%n achievements are not supported by DuckStation.",
1403+
"Achievement popup", num_unsupported),
1404+
"images/warning.svg");
1405+
});
1406+
}
13911407
}
13921408

13931409
// Technically not going through the resource API, but since we're passing this to something else, we can't.
@@ -2770,7 +2786,8 @@ void Achievements::DrawAchievementsWindow()
27702786
static constexpr float alpha = 0.8f;
27712787
static constexpr float heading_alpha = 0.95f;
27722788
const float heading_height_unscaled =
2773-
(s_state.game_summary.beaten_time > 0 || s_state.game_summary.completed_time) ? 122.0f : 102.0f;
2789+
((s_state.game_summary.beaten_time > 0 || s_state.game_summary.completed_time) ? 122.0f : 102.0f) +
2790+
((s_state.game_summary.num_unsupported_achievements > 0) ? 20.0f : 0.0f);
27742791

27752792
const ImVec4 background = ImGuiFullscreen::ModAlpha(UIStyle.BackgroundColor, alpha);
27762793
const ImVec4 heading_background = ImGuiFullscreen::ModAlpha(UIStyle.BackgroundColor, heading_alpha);
@@ -2821,22 +2838,23 @@ void Achievements::DrawAchievementsWindow()
28212838
const ImRect summary_bb(ImVec2(left, top), ImVec2(right, top + UIStyle.MediumFontSize));
28222839
if (s_state.game_summary.num_core_achievements > 0)
28232840
{
2841+
text.assign(ICON_EMOJI_UNLOCKED " ");
28242842
if (s_state.game_summary.num_unlocked_achievements == s_state.game_summary.num_core_achievements)
28252843
{
2826-
text = TRANSLATE_PLURAL_SSTR("Achievements", "You have unlocked all achievements and earned %n points!",
2827-
"Point count", s_state.game_summary.points_unlocked);
2844+
text.append(TRANSLATE_PLURAL_SSTR("Achievements", "You have unlocked all achievements and earned %n points!",
2845+
"Point count", s_state.game_summary.points_unlocked));
28282846
}
28292847
else
28302848
{
2831-
text.format(TRANSLATE_FS("Achievements",
2849+
text.append_format(TRANSLATE_FS("Achievements",
28322850
"You have unlocked {0} of {1} achievements, earning {2} of {3} possible points."),
28332851
s_state.game_summary.num_unlocked_achievements, s_state.game_summary.num_core_achievements,
28342852
s_state.game_summary.points_unlocked, s_state.game_summary.points_core);
28352853
}
28362854
}
28372855
else
28382856
{
2839-
text.assign(TRANSLATE_SV("Achievements", "This game has no achievements."));
2857+
text.format(ICON_FA_BAN " {}", TRANSLATE_SV("Achievements", "This game has no achievements."));
28402858
}
28412859

28422860
top += UIStyle.MediumFontSize + spacing;
@@ -2846,9 +2864,26 @@ void Achievements::DrawAchievementsWindow()
28462864
ImGui::GetColorU32(ImGuiFullscreen::DarkerColor(ImGui::GetStyle().Colors[ImGuiCol_Text])),
28472865
text, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
28482866

2867+
if (s_state.game_summary.num_unsupported_achievements)
2868+
{
2869+
text.format("{} {}", ICON_EMOJI_WARNING,
2870+
TRANSLATE_PLURAL_SSTR(
2871+
"Achievements", "%n achievements are not supported by DuckStation and cannot be unlocked.",
2872+
"Unsupported achievement count", s_state.game_summary.num_unsupported_achievements));
2873+
2874+
const ImRect unsupported_bb(ImVec2(left, top), ImVec2(right, top + UIStyle.MediumFontSize));
2875+
RenderShadowedTextClipped(
2876+
UIStyle.Font, UIStyle.MediumFontSize, UIStyle.BoldFontWeight, unsupported_bb.Min, unsupported_bb.Max,
2877+
ImGui::GetColorU32(ImGuiFullscreen::DarkerColor(ImGui::GetStyle().Colors[ImGuiCol_Text])), text, nullptr,
2878+
ImVec2(0.0f, 0.0f), 0.0f, &unsupported_bb);
2879+
2880+
top += UIStyle.MediumFontSize + spacing;
2881+
}
2882+
28492883
if (s_state.game_summary.beaten_time > 0 || s_state.game_summary.completed_time > 0)
28502884
{
2851-
text.clear();
2885+
text.assign(ICON_EMOJI_CHECKMARK_BUTTON " ");
2886+
28522887
if (s_state.game_summary.beaten_time > 0)
28532888
{
28542889
const std::string beaten_time =
@@ -2857,19 +2892,19 @@ void Achievements::DrawAchievementsWindow()
28572892
{
28582893
const std::string completion_time =
28592894
Host::FormatNumber(Host::NumberFormatType::ShortDate, static_cast<s64>(s_state.game_summary.beaten_time));
2860-
text.format(TRANSLATE_FS("Achievements", "Game was beaten on {0}, and completed on {1}."), beaten_time,
2861-
completion_time);
2895+
text.append_format(TRANSLATE_FS("Achievements", "Game was beaten on {0}, and completed on {1}."), beaten_time,
2896+
completion_time);
28622897
}
28632898
else
28642899
{
2865-
text.format(TRANSLATE_FS("Achievements", "Game was beaten on {0}."), beaten_time);
2900+
text.append_format(TRANSLATE_FS("Achievements", "Game was beaten on {0}."), beaten_time);
28662901
}
28672902
}
28682903
else
28692904
{
28702905
const std::string completion_time =
28712906
Host::FormatNumber(Host::NumberFormatType::ShortDate, static_cast<s64>(s_state.game_summary.completed_time));
2872-
text.format(TRANSLATE_FS("Achievements", "Game was completed on {0}."), completion_time);
2907+
text.append_format(TRANSLATE_FS("Achievements", "Game was completed on {0}."), completion_time);
28732908
}
28742909

28752910
const ImRect beaten_bb(ImVec2(left, top), ImVec2(right, top + UIStyle.MediumFontSize));

src/duckstation-qt/translations/duckstation-qt_en.ts

Lines changed: 51 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<context>
55
<name>AchievementSettingsWidget</name>
66
<message numerus="yes">
7-
<location filename="../achievementsettingswidget.cpp" line="160"/>
8-
<location filename="../achievementsettingswidget.cpp" line="167"/>
7+
<location filename="../achievementsettingswidget.cpp" line="198"/>
8+
<location filename="../achievementsettingswidget.cpp" line="205"/>
99
<source>%n seconds</source>
1010
<translation>
1111
<numerusform>%n second</numerusform>
@@ -16,7 +16,7 @@
1616
<context>
1717
<name>Achievements</name>
1818
<message numerus="yes">
19-
<location filename="../../core/achievements.cpp" line="1401"/>
19+
<location filename="../../core/achievements.cpp" line="1360"/>
2020
<source>You have unlocked {} of %n achievements</source>
2121
<comment>Achievement popup</comment>
2222
<translation>
@@ -25,7 +25,7 @@
2525
</translation>
2626
</message>
2727
<message numerus="yes">
28-
<location filename="../../core/achievements.cpp" line="1404"/>
28+
<location filename="../../core/achievements.cpp" line="1363"/>
2929
<source>and earned {} of %n points</source>
3030
<comment>Achievement popup</comment>
3131
<translation>
@@ -34,7 +34,17 @@
3434
</translation>
3535
</message>
3636
<message numerus="yes">
37-
<location filename="../../core/achievements.cpp" line="1504"/>
37+
<location filename="../../core/achievements.cpp" line="1401"/>
38+
<source>%n achievements are not supported by DuckStation.</source>
39+
<comment>Achievement popup</comment>
40+
<translation>
41+
<numerusform>%n achievement is not supported by DuckStation.</numerusform>
42+
<numerusform>%n achievements are not supported by DuckStation.</numerusform>
43+
</translation>
44+
</message>
45+
<message numerus="yes">
46+
<location filename="../../core/achievements.cpp" line="1476"/>
47+
<location filename="../../core/achievements.cpp" line="1513"/>
3848
<source>%n achievements</source>
3949
<comment>Mastery popup</comment>
4050
<translation>
@@ -43,8 +53,9 @@
4353
</translation>
4454
</message>
4555
<message numerus="yes">
46-
<location filename="../../core/achievements.cpp" line="1506"/>
47-
<location filename="../../core/achievements.cpp" line="3067"/>
56+
<location filename="../../core/achievements.cpp" line="1478"/>
57+
<location filename="../../core/achievements.cpp" line="1515"/>
58+
<location filename="../../core/achievements.cpp" line="3083"/>
4859
<source>%n points</source>
4960
<comment>Achievement points</comment>
5061
<translation>
@@ -53,7 +64,7 @@
5364
</translation>
5465
</message>
5566
<message numerus="yes">
56-
<location filename="../../core/achievements.cpp" line="2711"/>
67+
<location filename="../../core/achievements.cpp" line="2669"/>
5768
<source>%n unlocks have not been confirmed by the server.</source>
5869
<comment>Pause Menu</comment>
5970
<translation>
@@ -62,7 +73,7 @@
6273
</translation>
6374
</message>
6475
<message numerus="yes">
65-
<location filename="../../core/achievements.cpp" line="2876"/>
76+
<location filename="../../core/achievements.cpp" line="2844"/>
6677
<source>You have unlocked all achievements and earned %n points!</source>
6778
<comment>Point count</comment>
6879
<translation>
@@ -71,7 +82,16 @@
7182
</translation>
7283
</message>
7384
<message numerus="yes">
74-
<location filename="../../core/achievements.cpp" line="3321"/>
85+
<location filename="../../core/achievements.cpp" line="2870"/>
86+
<source>%n achievements are not supported by DuckStation and cannot be unlocked.</source>
87+
<comment>Unsupported achievement count</comment>
88+
<translation>
89+
<numerusform>%n achievement is not supported by DuckStation and cannot be unlocked.</numerusform>
90+
<numerusform>%n achievements are not supported by DuckStation and cannot be unlocked.</numerusform>
91+
</translation>
92+
</message>
93+
<message numerus="yes">
94+
<location filename="../../core/achievements.cpp" line="3331"/>
7595
<source>This game has %n leaderboards.</source>
7696
<comment>Leaderboard count</comment>
7797
<translation>
@@ -83,7 +103,7 @@
83103
<context>
84104
<name>Cheats</name>
85105
<message numerus="yes">
86-
<location filename="../../core/cheats.cpp" line="1014"/>
106+
<location filename="../../core/cheats.cpp" line="1020"/>
87107
<source>%n game patches are active.</source>
88108
<comment>OSD Message</comment>
89109
<translation>
@@ -92,7 +112,7 @@
92112
</translation>
93113
</message>
94114
<message numerus="yes">
95-
<location filename="../../core/cheats.cpp" line="1021"/>
115+
<location filename="../../core/cheats.cpp" line="1027"/>
96116
<source>%n cheats are enabled. This may crash games.</source>
97117
<comment>OSD Message</comment>
98118
<translation>
@@ -101,7 +121,7 @@
101121
</translation>
102122
</message>
103123
<message numerus="yes">
104-
<location filename="../../core/cheats.cpp" line="1048"/>
124+
<location filename="../../core/cheats.cpp" line="1054"/>
105125
<source>%n cheats</source>
106126
<comment>Cheats blocked by hardcore mode</comment>
107127
<translation>
@@ -110,7 +130,7 @@
110130
</translation>
111131
</message>
112132
<message numerus="yes">
113-
<location filename="../../core/cheats.cpp" line="1050"/>
133+
<location filename="../../core/cheats.cpp" line="1056"/>
114134
<source>%n patches</source>
115135
<comment>Patches blocked by hardcore mode</comment>
116136
<translation>
@@ -122,7 +142,7 @@
122142
<context>
123143
<name>EmulationSettingsWidget</name>
124144
<message numerus="yes">
125-
<location filename="../emulationsettingswidget.cpp" line="252"/>
145+
<location filename="../emulationsettingswidget.cpp" line="255"/>
126146
<source>Rewind for %n frame(s), lasting %1 second(s) will require up to %2MB of RAM and %3MB of VRAM.</source>
127147
<translation>
128148
<numerusform>Rewind for %n frame, lasting %1 second(s) will require up to %2MB of RAM and %3MB of VRAM.</numerusform>
@@ -133,7 +153,7 @@
133153
<context>
134154
<name>GPU_HW</name>
135155
<message numerus="yes">
136-
<location filename="../../core/gpu_hw_texture_cache.cpp" line="3636"/>
156+
<location filename="../../core/gpu_hw_texture_cache.cpp" line="3706"/>
137157
<source>%n replacement textures found.</source>
138158
<comment>Replacement texture count</comment>
139159
<translation>
@@ -145,17 +165,26 @@
145165
<context>
146166
<name>GameList</name>
147167
<message numerus="yes">
148-
<location filename="../gamelistwidget.cpp" line="345"/>
149-
<location filename="../../core/game_list.cpp" line="1551"/>
168+
<location filename="../gamelistwidget.cpp" line="1699"/>
169+
<location filename="../../core/game_list.cpp" line="1609"/>
170+
<source>%n seconds</source>
171+
<translation>
172+
<numerusform>%n second</numerusform>
173+
<numerusform>%n seconds</numerusform>
174+
</translation>
175+
</message>
176+
<message numerus="yes">
177+
<location filename="../gamelistwidget.cpp" line="1701"/>
178+
<location filename="../../core/game_list.cpp" line="1605"/>
150179
<source>%n hours</source>
151180
<translation>
152181
<numerusform>%n hour</numerusform>
153182
<numerusform>%n hours</numerusform>
154183
</translation>
155184
</message>
156185
<message numerus="yes">
157-
<location filename="../gamelistwidget.cpp" line="347"/>
158-
<location filename="../../core/game_list.cpp" line="1553"/>
186+
<location filename="../gamelistwidget.cpp" line="1700"/>
187+
<location filename="../../core/game_list.cpp" line="1607"/>
159188
<source>%n minutes</source>
160189
<translation>
161190
<numerusform>%n minute</numerusform>
@@ -166,7 +195,7 @@
166195
<context>
167196
<name>InputBindingWidget</name>
168197
<message numerus="yes">
169-
<location filename="../inputbindingwidgets.cpp" line="76"/>
198+
<location filename="../inputbindingwidgets.cpp" line="77"/>
170199
<source>%n bindings</source>
171200
<translation>
172201
<numerusform>%n binding</numerusform>
@@ -177,7 +206,7 @@
177206
<context>
178207
<name>MemoryCardEditorWindow</name>
179208
<message numerus="yes">
180-
<location filename="../memorycardeditorwindow.cpp" line="317"/>
209+
<location filename="../memorycardeditorwindow.cpp" line="318"/>
181210
<source>%n block(s) free%1</source>
182211
<translation>
183212
<numerusform>%n block free%1</numerusform>

0 commit comments

Comments
 (0)