Skip to content

Commit de85a7b

Browse files
authored
Merge pull request #21845 from hrydgard/linux-work
Linux: Add workaround for RetroAchievement icons
2 parents ebdf89d + 05018fb commit de85a7b

9 files changed

Lines changed: 26 additions & 16 deletions

File tree

Core/RetroAchievements.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "Common/Log.h"
3636
#include "Common/File/Path.h"
3737
#include "Common/Net/HTTPRequest.h"
38+
#include "Common/Net/HTTPClient.h"
3839
#include "Common/System/OSD.h"
3940
#include "Common/System/System.h"
4041
#include "Common/System/NativeApp.h"
@@ -290,8 +291,9 @@ static void server_call_callback(const rc_api_request_t *request,
290291
{
291292
// If post data is provided, we need to make a POST request, otherwise, a GET request will suffice.
292293
auto ac = GetI18NCategory(I18NCat::ACHIEVEMENTS);
294+
std::string url = http::RemoveHttpsIfNeeded(request->url);
293295
if (request->post_data) {
294-
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,
296+
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,
295297
[callback, callback_data](http::Request &download) {
296298
std::string buffer;
297299
download.buffer().TakeAll(&buffer);
@@ -302,7 +304,7 @@ static void server_call_callback(const rc_api_request_t *request,
302304
callback(&response, callback_data);
303305
}, ac->T("Contacting RetroAchievements server..."));
304306
} else {
305-
std::shared_ptr<http::Request> download = g_DownloadManager.StartDownload(std::string(request->url), Path(), http::RequestFlags::ProgressBar | http::RequestFlags::ProgressBarDelayed, nullptr,
307+
std::shared_ptr<http::Request> download = g_DownloadManager.StartDownload(url, Path(), http::RequestFlags::ProgressBar | http::RequestFlags::ProgressBarDelayed, nullptr,
306308
ac->T("Contacting RetroAchievements server..."),
307309
[callback, callback_data](http::Request &download) {
308310
std::string buffer;
@@ -918,6 +920,7 @@ bool HasAchievementsOrLeaderboards() {
918920
}
919921

920922
void DownloadImageIfMissing(std::string_view url) {
923+
// On Linux for example, we currently have no way of doing a HTTPS request.
921924
if (g_iconCache.MarkPending(url)) {
922925
INFO_LOG(Log::Achievements, "Downloading image: %.*s", STR_VIEW(url));
923926
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
985988
// Successful! Show a message that we're active.
986989
const rc_client_game_t *gameInfo = rc_client_get_game_info(client);
987990

988-
DownloadImageIfMissing(gameInfo->badge_url);
991+
std::string imageUrl = http::RemoveHttpsIfNeeded(gameInfo->badge_url);
992+
DownloadImageIfMissing(imageUrl);
989993

990994
GameRegion region = DetectGameRegionFromID(g_paramSFO.GetDiscID());
991995
auto ga = GetI18NCategory(I18NCat::GAME);
@@ -997,7 +1001,7 @@ void identify_and_load_callback(int result, const char *error_message, rc_client
9971001
title += ")";
9981002
}
9991003
// TODO: Detect current subset.
1000-
g_OSD.Show(OSDType::MESSAGE_INFO, title, GetGameAchievementSummary(0), gameInfo->badge_url, 5.0f);
1004+
g_OSD.Show(OSDType::MESSAGE_INFO, title, GetGameAchievementSummary(0), imageUrl, 5.0f);
10011005
break;
10021006
}
10031007
case RC_NO_GAME_LOADED:

UI/RetroAchievementScreens.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "Common/UI/PopupScreens.h"
1010
#include "Common/UI/Notice.h"
1111
#include "Common/StringUtils.h"
12+
#include "Common/Net/HTTPClient.h"
1213

1314
#include "Core/Config.h"
1415
#include "Core/RetroAchievements.h"
@@ -619,8 +620,9 @@ void RenderAchievement(UIContext &dc, const rc_client_achievement_t *achievement
619620

620621
// Download and display the image.
621622
const char *url = iconState == RC_CLIENT_ACHIEVEMENT_STATE_UNLOCKED ? achievement->badge_url : achievement->badge_locked_url;
622-
Achievements::DownloadImageIfMissing(url);
623-
if (g_iconCache.BindIconTexture(&dc, url)) {
623+
std::string imageUrl = http::RemoveHttpsIfNeeded(url);
624+
Achievements::DownloadImageIfMissing(imageUrl);
625+
if (g_iconCache.BindIconTexture(&dc, imageUrl)) {
624626
dc.Draw()->DrawTexRect(Bounds(bounds.x + padding, bounds.y + padding, iconSpace, iconSpace), 0.0f, 0.0f, 1.0f, 1.0f, whiteAlpha(alpha));
625627
}
626628
dc.SetFontStyle(*GetTextStyle(dc, UI::TextSize::Normal));
@@ -668,8 +670,10 @@ static void RenderGameAchievementSummary(UIContext &dc, const Bounds &bounds, fl
668670
dc.SetFontStyle(dc.GetTheme().uiFont);
669671
dc.Flush();
670672

671-
Achievements::DownloadImageIfMissing(gameInfo->badge_url);
672-
if (g_iconCache.BindIconTexture(&dc, gameInfo->badge_url)) {
673+
std::string imageUrl = http::RemoveHttpsIfNeeded(gameInfo->badge_url);
674+
675+
Achievements::DownloadImageIfMissing(imageUrl);
676+
if (g_iconCache.BindIconTexture(&dc, imageUrl)) {
673677
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));
674678
}
675679

@@ -765,8 +769,9 @@ static void RenderLeaderboardEntry(UIContext &dc, const rc_client_leaderboard_en
765769
// Come up with a unique name for the icon entry.
766770
char userImageUrl[512];
767771
if (RC_OK == rc_client_leaderboard_entry_get_user_image_url(entry, userImageUrl, sizeof(userImageUrl))) {
768-
Achievements::DownloadImageIfMissing(userImageUrl);
769-
if (g_iconCache.BindIconTexture(&dc, userImageUrl)) {
772+
std::string imageUrl = http::RemoveHttpsIfNeeded(userImageUrl);
773+
Achievements::DownloadImageIfMissing(imageUrl);
774+
if (g_iconCache.BindIconTexture(&dc, imageUrl)) {
770775
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));
771776
}
772777
}

UI/SystemInfoScreen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ void SystemInfoScreen::CreateDeviceInfoTab(UI::LinearLayout *deviceSpecs) {
219219
build = si->T("Debug");
220220
#endif
221221
osInformation->Add(new InfoItem(si->T("PPSSPP build"), build));
222+
osInformation->Add(new InfoItem(si->T("HTTPS supported"), System_GetPropertyBool(SYSPROP_SUPPORTS_HTTPS) ? di->T("Yes") : di->T("No")));
222223

223224
CollapsibleSection *displayInfo = deviceSpecs->Add(new CollapsibleSection(si->T("Display Information")));
224225
#if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(UWP)

assets/lang/ar_AE.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ Strict combo input order = Strict combo input order
833833
You can press ESC to cancel. = ‎يمكنك ضغط علي زر الخروج للإلغاء.
834834

835835
[MainMenu]
836-
About PPSSPP = ‎&عن البرنامج...
836+
About PPSSPP = ‎عن البرنامج...
837837
Browse = ‎تصفح...
838838
Buy PPSSPP Gold = الذهبي PPSSPP اشتر
839839
Choose folder = اختر المجلد

assets/lang/az_AZ.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ Strict combo input order = Qatı birləşik giriş sıralanışı
825825
You can press ESC to cancel. = Dayandırmaq üçün Esc'i basın.
826826

827827
[MainMenu]
828-
About PPSSPP = &PPSSPP ilə bağlı...
828+
About PPSSPP = PPSSPP ilə bağlı...
829829
Browse = Göz at...
830830
Buy PPSSPP Gold = PPSSPP Gold al
831831
Choose folder = Qovluq seç

assets/lang/bg_BG.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ Strict combo input order = Strict combo input order
825825
You can press ESC to cancel. = You can press Esc to cancel.
826826

827827
[MainMenu]
828-
About PPSSPP = &Относно PPSSPP...
828+
About PPSSPP = Относно PPSSPP...
829829
Browse = Разгледай...
830830
Buy PPSSPP Gold = Купете PPSSPP Gold
831831
Choose folder = Изберете папка

assets/lang/ca_ES.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ Strict combo input order = Strict combo input order
825825
You can press ESC to cancel. = Podeu prémer ESC per cancel·lar.
826826

827827
[MainMenu]
828-
About PPSSPP = &Quant a PPSSPP...
828+
About PPSSPP = Quant a PPSSPP...
829829
Browse = Cercar...
830830
Buy PPSSPP Gold = Comprar PPSSPP Gold
831831
Choose folder = Triar carpeta

assets/lang/cz_CZ.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ Strict combo input order = Strict combo input order
825825
You can press ESC to cancel. = You can press Esc to cancel.
826826
827827
[MainMenu]
828-
About PPSSPP = &O PPSSPP...
828+
About PPSSPP = O PPSSPP...
829829
Browse = Procházet...
830830
Buy PPSSPP Gold = Buy PPSSPP Gold
831831
Choose folder = Choose folder

assets/lang/da_DK.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ Strict combo input order = Strict combo input order
825825
You can press ESC to cancel. = Du kan trykke Esc for at afbryde.
826826

827827
[MainMenu]
828-
About PPSSPP = &Om PPSSPP...
828+
About PPSSPP = Om PPSSPP...
829829
Browse = Gennemse...
830830
Buy PPSSPP Gold = Buy PPSSPP Gold
831831
Choose folder = Choose folder

0 commit comments

Comments
 (0)