FullscreenUI: Add achievement game icon download

This commit is contained in:
Stenzek
2025-12-06 15:11:35 +10:00
parent 3867c848b0
commit 42c872efff
3 changed files with 41 additions and 7 deletions

View File

@@ -98,6 +98,7 @@ static void DrawPatchesOrCheatsSettingsPage(bool cheats);
static void DrawCoverDownloaderWindow();
static void DrawAchievementsLoginWindow();
static void StartAchievementsGameIconDownload();
static bool ShouldShowAdvancedSettings();
static bool IsEditingGameSettings(SettingsInterface* bsi);
@@ -4782,6 +4783,12 @@ void FullscreenUI::DrawAchievementsSettingsPage(std::unique_lock<std::mutex>& se
});
}
if (MenuButton(FSUI_ICONVSTR(ICON_FA_DOWNLOAD, "Download Game Icons"),
FSUI_VSTR("Downloads icons for all games from RetroAchievements.")))
{
StartAchievementsGameIconDownload();
}
if (bsi->ContainsValue("Cheevos", "Token"))
{
const std::string ts_string = Host::FormatNumber(
@@ -4908,6 +4915,25 @@ void FullscreenUI::DrawAchievementsLoginWindow()
EndFixedPopupDialog();
}
void FullscreenUI::StartAchievementsGameIconDownload()
{
auto progress = OpenModalProgressDialog(FSUI_STR("Download Game Icons"));
System::QueueAsyncTask([progress = progress.release()]() {
Error error;
const bool result = Achievements::DownloadGameIcons(progress, &error);
Host::RunOnCPUThread([error = std::move(error), progress, result]() mutable {
GPUThread::RunOnThread([error = std::move(error), progress, result]() mutable {
delete progress;
if (result)
ShowToast(OSDMessageType::Info, {}, FSUI_STR("Game icons downloaded."));
else
FullscreenUI::OpenInfoMessageDialog(FSUI_STR("Download Game Icons"), error.TakeDescription());
});
});
});
}
void FullscreenUI::DrawAdvancedSettingsPage()
{
SettingsInterface* bsi = GetEditingSettingsInterface();

View File

@@ -276,7 +276,9 @@ TRANSLATE_NOOP("FullscreenUI", "Dithering");
TRANSLATE_NOOP("FullscreenUI", "Do you want to continue from the automatic save created at {}?");
TRANSLATE_NOOP("FullscreenUI", "Double-Click Toggles Fullscreen");
TRANSLATE_NOOP("FullscreenUI", "Download Covers");
TRANSLATE_NOOP("FullscreenUI", "Download Game Icons");
TRANSLATE_NOOP("FullscreenUI", "Downloads covers from a user-specified URL template.");
TRANSLATE_NOOP("FullscreenUI", "Downloads icons for all games from RetroAchievements.");
TRANSLATE_NOOP("FullscreenUI", "Downsamples the rendered image prior to displaying it. Can improve overall image quality in mixed 2D/3D games.");
TRANSLATE_NOOP("FullscreenUI", "Downsampling");
TRANSLATE_NOOP("FullscreenUI", "Downsampling Display Scale");
@@ -379,6 +381,7 @@ TRANSLATE_NOOP("FullscreenUI", "Game Properties");
TRANSLATE_NOOP("FullscreenUI", "Game Quick Save");
TRANSLATE_NOOP("FullscreenUI", "Game Slot {0}##game_slot_{0}");
TRANSLATE_NOOP("FullscreenUI", "Game compatibility rating copied to clipboard.");
TRANSLATE_NOOP("FullscreenUI", "Game icons downloaded.");
TRANSLATE_NOOP("FullscreenUI", "Game path copied to clipboard.");
TRANSLATE_NOOP("FullscreenUI", "Game region copied to clipboard.");
TRANSLATE_NOOP("FullscreenUI", "Game serial copied to clipboard.");

View File

@@ -3955,13 +3955,18 @@ FullscreenUI::ProgressDialog::ProgressCallbackImpl::ProgressCallbackImpl() = def
FullscreenUI::ProgressDialog::ProgressCallbackImpl::~ProgressCallbackImpl()
{
Host::RunOnCPUThread([]() mutable {
GPUThread::RunOnThread([]() mutable {
if (!s_state.progress_dialog.IsOpen())
return;
s_state.progress_dialog.StartClose();
});
});
static constexpr auto close_cb = []() {
if (!s_state.progress_dialog.IsOpen())
return;
s_state.progress_dialog.StartClose();
};
if (GPUThread::IsOnThread())
{
close_cb();
return;
}
Host::RunOnCPUThread([]() { GPUThread::RunOnThread(close_cb); });
}
void FullscreenUI::ProgressDialog::ProgressCallbackImpl::SetStatusText(std::string_view text)