Merge pull request #21845 from hrydgard/linux-work

Linux: Add workaround for RetroAchievement icons
This commit is contained in:
Henrik Rydgård
2026-06-18 12:36:02 +02:00
committed by GitHub
9 changed files with 26 additions and 16 deletions
+8 -4
View File
@@ -35,6 +35,7 @@
#include "Common/Log.h"
#include "Common/File/Path.h"
#include "Common/Net/HTTPRequest.h"
#include "Common/Net/HTTPClient.h"
#include "Common/System/OSD.h"
#include "Common/System/System.h"
#include "Common/System/NativeApp.h"
@@ -290,8 +291,9 @@ static void server_call_callback(const rc_api_request_t *request,
{
// If post data is provided, we need to make a POST request, otherwise, a GET request will suffice.
auto ac = GetI18NCategory(I18NCat::ACHIEVEMENTS);
std::string url = http::RemoveHttpsIfNeeded(request->url);
if (request->post_data) {
std::shared_ptr<http::Request> download = g_DownloadManager.AsyncPostWithCallback(std::string(request->url), std::string(request->post_data), "application/x-www-form-urlencoded", http::RequestFlags::ProgressBar | http::RequestFlags::ProgressBarDelayed,
std::shared_ptr<http::Request> download = g_DownloadManager.AsyncPostWithCallback(url, std::string(request->post_data), "application/x-www-form-urlencoded", http::RequestFlags::ProgressBar | http::RequestFlags::ProgressBarDelayed,
[callback, callback_data](http::Request &download) {
std::string buffer;
download.buffer().TakeAll(&buffer);
@@ -302,7 +304,7 @@ static void server_call_callback(const rc_api_request_t *request,
callback(&response, callback_data);
}, ac->T("Contacting RetroAchievements server..."));
} else {
std::shared_ptr<http::Request> download = g_DownloadManager.StartDownload(std::string(request->url), Path(), http::RequestFlags::ProgressBar | http::RequestFlags::ProgressBarDelayed, nullptr,
std::shared_ptr<http::Request> download = g_DownloadManager.StartDownload(url, Path(), http::RequestFlags::ProgressBar | http::RequestFlags::ProgressBarDelayed, nullptr,
ac->T("Contacting RetroAchievements server..."),
[callback, callback_data](http::Request &download) {
std::string buffer;
@@ -918,6 +920,7 @@ bool HasAchievementsOrLeaderboards() {
}
void DownloadImageIfMissing(std::string_view url) {
// On Linux for example, we currently have no way of doing a HTTPS request.
if (g_iconCache.MarkPending(url)) {
INFO_LOG(Log::Achievements, "Downloading image: %.*s", STR_VIEW(url));
g_DownloadManager.StartDownload(url, Path(), http::RequestFlags::Default, nullptr, "", [](http::Request &download) {
@@ -985,7 +988,8 @@ void identify_and_load_callback(int result, const char *error_message, rc_client
// Successful! Show a message that we're active.
const rc_client_game_t *gameInfo = rc_client_get_game_info(client);
DownloadImageIfMissing(gameInfo->badge_url);
std::string imageUrl = http::RemoveHttpsIfNeeded(gameInfo->badge_url);
DownloadImageIfMissing(imageUrl);
GameRegion region = DetectGameRegionFromID(g_paramSFO.GetDiscID());
auto ga = GetI18NCategory(I18NCat::GAME);
@@ -997,7 +1001,7 @@ void identify_and_load_callback(int result, const char *error_message, rc_client
title += ")";
}
// TODO: Detect current subset.
g_OSD.Show(OSDType::MESSAGE_INFO, title, GetGameAchievementSummary(0), gameInfo->badge_url, 5.0f);
g_OSD.Show(OSDType::MESSAGE_INFO, title, GetGameAchievementSummary(0), imageUrl, 5.0f);
break;
}
case RC_NO_GAME_LOADED:
+11 -6
View File
@@ -9,6 +9,7 @@
#include "Common/UI/PopupScreens.h"
#include "Common/UI/Notice.h"
#include "Common/StringUtils.h"
#include "Common/Net/HTTPClient.h"
#include "Core/Config.h"
#include "Core/RetroAchievements.h"
@@ -619,8 +620,9 @@ void RenderAchievement(UIContext &dc, const rc_client_achievement_t *achievement
// Download and display the image.
const char *url = iconState == RC_CLIENT_ACHIEVEMENT_STATE_UNLOCKED ? achievement->badge_url : achievement->badge_locked_url;
Achievements::DownloadImageIfMissing(url);
if (g_iconCache.BindIconTexture(&dc, url)) {
std::string imageUrl = http::RemoveHttpsIfNeeded(url);
Achievements::DownloadImageIfMissing(imageUrl);
if (g_iconCache.BindIconTexture(&dc, imageUrl)) {
dc.Draw()->DrawTexRect(Bounds(bounds.x + padding, bounds.y + padding, iconSpace, iconSpace), 0.0f, 0.0f, 1.0f, 1.0f, whiteAlpha(alpha));
}
dc.SetFontStyle(*GetTextStyle(dc, UI::TextSize::Normal));
@@ -668,8 +670,10 @@ static void RenderGameAchievementSummary(UIContext &dc, const Bounds &bounds, fl
dc.SetFontStyle(dc.GetTheme().uiFont);
dc.Flush();
Achievements::DownloadImageIfMissing(gameInfo->badge_url);
if (g_iconCache.BindIconTexture(&dc, gameInfo->badge_url)) {
std::string imageUrl = http::RemoveHttpsIfNeeded(gameInfo->badge_url);
Achievements::DownloadImageIfMissing(imageUrl);
if (g_iconCache.BindIconTexture(&dc, imageUrl)) {
dc.Draw()->DrawTexRect(Bounds(bounds.x, bounds.y + (bounds.h - iconSpace) * 0.5f, iconSpace, iconSpace), 0.0f, 0.0f, 1.0f, 1.0f, whiteAlpha(alpha));
}
@@ -765,8 +769,9 @@ static void RenderLeaderboardEntry(UIContext &dc, const rc_client_leaderboard_en
// Come up with a unique name for the icon entry.
char userImageUrl[512];
if (RC_OK == rc_client_leaderboard_entry_get_user_image_url(entry, userImageUrl, sizeof(userImageUrl))) {
Achievements::DownloadImageIfMissing(userImageUrl);
if (g_iconCache.BindIconTexture(&dc, userImageUrl)) {
std::string imageUrl = http::RemoveHttpsIfNeeded(userImageUrl);
Achievements::DownloadImageIfMissing(imageUrl);
if (g_iconCache.BindIconTexture(&dc, imageUrl)) {
dc.Draw()->DrawTexRect(Bounds(bounds.x + iconLeft, bounds.y + 4.0f, 64.0f, 64.0f), 0.0f, 0.0f, 1.0f, 1.0f, whiteAlpha(alpha));
}
}
+1
View File
@@ -219,6 +219,7 @@ void SystemInfoScreen::CreateDeviceInfoTab(UI::LinearLayout *deviceSpecs) {
build = si->T("Debug");
#endif
osInformation->Add(new InfoItem(si->T("PPSSPP build"), build));
osInformation->Add(new InfoItem(si->T("HTTPS supported"), System_GetPropertyBool(SYSPROP_SUPPORTS_HTTPS) ? di->T("Yes") : di->T("No")));
CollapsibleSection *displayInfo = deviceSpecs->Add(new CollapsibleSection(si->T("Display Information")));
#if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(UWP)
+1 -1
View File
@@ -833,7 +833,7 @@ Strict combo input order = Strict combo input order
You can press ESC to cancel. = ‎يمكنك ضغط علي زر الخروج للإلغاء.
[MainMenu]
About PPSSPP = &عن البرنامج...
About PPSSPP = ‎عن البرنامج...
Browse = ‎تصفح...
Buy PPSSPP Gold = الذهبي PPSSPP اشتر
Choose folder = اختر المجلد
+1 -1
View File
@@ -825,7 +825,7 @@ Strict combo input order = Qatı birləşik giriş sıralanışı
You can press ESC to cancel. = Dayandırmaq üçün Esc'i basın.
[MainMenu]
About PPSSPP = &PPSSPP ilə bağlı...
About PPSSPP = PPSSPP ilə bağlı...
Browse = Göz at...
Buy PPSSPP Gold = PPSSPP Gold al
Choose folder = Qovluq seç
+1 -1
View File
@@ -825,7 +825,7 @@ Strict combo input order = Strict combo input order
You can press ESC to cancel. = You can press Esc to cancel.
[MainMenu]
About PPSSPP = &Относно PPSSPP...
About PPSSPP = Относно PPSSPP...
Browse = Разгледай...
Buy PPSSPP Gold = Купете PPSSPP Gold
Choose folder = Изберете папка
+1 -1
View File
@@ -825,7 +825,7 @@ Strict combo input order = Strict combo input order
You can press ESC to cancel. = Podeu prémer ESC per cancel·lar.
[MainMenu]
About PPSSPP = &Quant a PPSSPP...
About PPSSPP = Quant a PPSSPP...
Browse = Cercar...
Buy PPSSPP Gold = Comprar PPSSPP Gold
Choose folder = Triar carpeta
+1 -1
View File
@@ -825,7 +825,7 @@ Strict combo input order = Strict combo input order
You can press ESC to cancel. = You can press Esc to cancel.
[MainMenu]
About PPSSPP = &O PPSSPP...
About PPSSPP = O PPSSPP...
Browse = Procházet...
Buy PPSSPP Gold = Buy PPSSPP Gold
Choose folder = Choose folder
+1 -1
View File
@@ -825,7 +825,7 @@ Strict combo input order = Strict combo input order
You can press ESC to cancel. = Du kan trykke Esc for at afbryde.
[MainMenu]
About PPSSPP = &Om PPSSPP...
About PPSSPP = Om PPSSPP...
Browse = Gennemse...
Buy PPSSPP Gold = Buy PPSSPP Gold
Choose folder = Choose folder