From 37a557c51ad68b74364a137b2e2be9309b7a84f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 23 Jun 2023 22:08:52 +0200 Subject: [PATCH] Minor cleanups, add most translation strings to en_US.ini --- UI/RetroAchievementScreens.cpp | 15 +++++---- UI/RetroAchievements.cpp | 58 ++++++++++++++++------------------ assets/lang/en_US.ini | 30 +++++++++++++++++- 3 files changed, 65 insertions(+), 38 deletions(-) diff --git a/UI/RetroAchievementScreens.cpp b/UI/RetroAchievementScreens.cpp index 2a8cb21c85c9..b41d25840b59 100644 --- a/UI/RetroAchievementScreens.cpp +++ b/UI/RetroAchievementScreens.cpp @@ -47,13 +47,14 @@ void RetroAchievementsListScreen::CreateTabs() { void RetroAchievementsSettingsScreen::CreateTabs() { auto ac = GetI18NCategory(I18NCat::ACHIEVEMENTS); + auto di = GetI18NCategory(I18NCat::DIALOG); using namespace UI; LinearLayout *account = AddTab("AchievementsAccount", ac->T("Account")); CreateAccountTab(account); - LinearLayout *settings = AddTab("AchievementsSettings", ac->T("Settings")); + LinearLayout *settings = AddTab("AchievementsSettings", di->T("Settings")); CreateSettingsTab(settings); } @@ -72,15 +73,15 @@ void RetroAchievementsSettingsScreen::CreateAccountTab(UI::ViewGroup *viewGroup) using namespace UI; if (Achievements::IsLoggedIn()) { - viewGroup->Add(new InfoItem(ac->T("User Name"), Achievements::GetUsername())); - viewGroup->Add(new Choice(ac->T("Log out")))->OnClick.Add([=](UI::EventParams &) -> UI::EventReturn { + viewGroup->Add(new InfoItem(ac->T("Username"), Achievements::GetUsername())); + viewGroup->Add(new Choice(di->T("Log out")))->OnClick.Add([=](UI::EventParams &) -> UI::EventReturn { Achievements::Logout(); return UI::EVENT_DONE; }); } else { // TODO: Add UI for platforms that don't support System_AskUsernamePassword. if (System_GetPropertyBool(SYSPROP_HAS_LOGIN_DIALOG)) { - viewGroup->Add(new Choice(ac->T("Log in to RetroAchievements")))->OnClick.Add([=](UI::EventParams &) -> UI::EventReturn { + viewGroup->Add(new Choice(ac->T("Log in")))->OnClick.Add([=](UI::EventParams &) -> UI::EventReturn { System_AskUsernamePassword(ac->T("Log in"), [](const std::string &value, int) { std::vector parts; SplitString(value, '\n', parts); @@ -92,9 +93,9 @@ void RetroAchievementsSettingsScreen::CreateAccountTab(UI::ViewGroup *viewGroup) }); } else { // Hack up a temporary quick login-form-ish-thing - viewGroup->Add(new PopupTextInputChoice(&username_, "Username", "", 128, screenManager())); - viewGroup->Add(new PopupTextInputChoice(&password_, "Password", "", 128, screenManager())); - viewGroup->Add(new Choice(ac->T("Log in")))->OnClick.Add([=](UI::EventParams &) -> UI::EventReturn { + viewGroup->Add(new PopupTextInputChoice(&username_, di->T("Username"), "", 128, screenManager())); + viewGroup->Add(new PopupTextInputChoice(&password_, di->T("Password"), "", 128, screenManager())); + viewGroup->Add(new Choice(di->T("Log in")))->OnClick.Add([=](UI::EventParams &) -> UI::EventReturn { if (!username_.empty() && !password_.empty()) { Achievements::LoginAsync(username_.c_str(), password_.c_str()); } diff --git a/UI/RetroAchievements.cpp b/UI/RetroAchievements.cpp index cc5bd71c62db..29185e858151 100644 --- a/UI/RetroAchievements.cpp +++ b/UI/RetroAchievements.cpp @@ -59,7 +59,7 @@ namespace Common { class HTTPDownloader { public: - static std::unique_ptr Create(const std::string &userAgent) { + static std::unique_ptr Create() { return std::unique_ptr(new HTTPDownloader()); } class Request { @@ -89,7 +89,7 @@ namespace Common { Request::Callback movedCallback = std::move(callback); std::string post_data_str(post_data); - NOTICE_LOG(ACHIEVEMENTS, "Request: post_data=%s", post_data); + INFO_LOG(ACHIEVEMENTS, "Request: post_data=%s", post_data); downloader_.AsyncPostWithCallback(url, post_data_str, "application/x-www-form-urlencoded", [=](http::Download &download) { std::string data; @@ -491,15 +491,6 @@ void Achievements::ClearGameHash() s_game_hash.clear(); } -std::string Achievements::GetUserAgent() -{ -#if 0 - return fmt::format("DuckStation for {} ({}) {}", SYSTEM_STR, CPU_ARCH_STR, g_scm_tag_str); -#else - return "DuckStation"; -#endif -} - bool Achievements::IsActive() { return s_active; @@ -563,7 +554,7 @@ void Achievements::Initialize() std::unique_lock lock(s_achievements_mutex); _assert_msg_(g_Config.bAchievementsEnable, "Achievements are enabled"); - s_http_downloader = Common::HTTPDownloader::Create(GetUserAgent().c_str()); + s_http_downloader = Common::HTTPDownloader::Create(); if (!s_http_downloader) { // TODO: Also report to user @@ -607,6 +598,9 @@ void Achievements::UpdateSettings() } /* + // TODO: We don't have an "old" config state. But we can probably maintain one right here + // in this file. + if (g_settings.achievements_challenge_mode != old_config.achievements_challenge_mode) { // Hardcore mode can only be enabled through reset (ResetChallengeMode()). @@ -700,8 +694,9 @@ void Achievements::SetChallengeMode(bool enabled) if (HasActiveGame()) { auto ac = GetI18NCategory(I18NCat::ACHIEVEMENTS); + auto di = GetI18NCategory(I18NCat::DIALOG); - System_Toast(enabled ? ac->T("Hardcore mode enabled.") : ac->T("Hardcore mode disabled.")); // 10.0f + OSDAddNotification(5.0f, std::string(ac->T("Challenge mode")) + ": " + di->T(enabled ? "Enabled" : "Disabled"), "", ""); } if (HasActiveGame() && !IsTestModeActive()) @@ -778,7 +773,7 @@ void Achievements::ResetRuntime() return; std::unique_lock lock(s_achievements_mutex); - DEBUG_LOG(ACHIEVEMENTS, "Resetting rcheevos state..."); + INFO_LOG(ACHIEVEMENTS, "Resetting rcheevos state..."); rc_runtime_reset(&s_rcheevos_runtime); } @@ -1082,15 +1077,11 @@ std::string Achievements::GetGameAchievementSummary() { auto ac = GetI18NCategory(I18NCat::ACHIEVEMENTS); std::string summary; - if (GetAchievementCount() > 0) { - summary = StringFromFormat(ac->T("Earned", "You have unlocked %d of %d achievements, earning %d of %d points"), - GetUnlockedAchiementCount(), GetAchievementCount(), GetCurrentPointsForGame(), GetMaximumPointsForGame()); - } else { - summary = ac->T("This game has no achievements"); - } - if (GetLeaderboardCount() > 0) { - if (LeaderboardsActive()) - summary.append("\nLeaderboard submission is enabled."); + summary = StringFromFormat(ac->T("Earned", "You have unlocked %d of %d achievements, earning %d of %d points"), + GetUnlockedAchiementCount(), GetAchievementCount(), GetCurrentPointsForGame(), GetMaximumPointsForGame()); + if (GetLeaderboardCount() > 0 && LeaderboardsActive()) { + summary.append("\n"); + summary.append(ac->T("Leaderboard submission is enabled")); } return summary; } @@ -1101,7 +1092,7 @@ void Achievements::DisplayAchievementSummary() std::string title; if (ChallengeModeActive()) - title = s_game_title + " " + ac->T("(Hardcore Mode)"); + title = s_game_title + " (" + ac->T("Challenge Mode") + ")"; else title = s_game_title; @@ -1114,12 +1105,14 @@ void Achievements::DisplayAchievementSummary() void Achievements::DisplayMasteredNotification() { + auto ac = GetI18NCategory(I18NCat::ACHIEVEMENTS); + if (!g_Config.bAchievementsNotifications) return; // TODO: Translation? - std::string title = "Mastered " + s_game_title; - std::string message = StringFromFormat("%d achievements, %d points", GetAchievementCount(), GetCurrentPointsForGame()); + std::string title = StringFromFormat(ac->T("Mastered %s"), s_game_title.c_str()); + std::string message = StringFromFormat(ac->T("%d achievements, %d points"), GetAchievementCount(), GetCurrentPointsForGame()); OSDAddNotification(20.0f, title, message, s_game_icon); NOTICE_LOG(ACHIEVEMENTS, "%s", message.c_str()); @@ -1382,7 +1375,9 @@ void Achievements::GetLbInfoCallback(s32 status_code, std::string content_type, void Achievements::GetPatches(u32 game_id) { - OSDOpenBackgroundProgressDialog("get_patches", "Downloading achievements data...", 0, 0, 0); + auto ac = GetI18NCategory(I18NCat::ACHIEVEMENTS); + + OSDOpenBackgroundProgressDialog("get_patches", ac->T("Syncing achievements data..."), 0, 0, 0); RAPIRequest request; request.username = s_username.c_str(); @@ -1858,6 +1853,8 @@ void Achievements::SubmitLeaderboardCallback(s32 status_code, std::string conten void Achievements::UnlockAchievement(u32 achievement_id, bool add_notification /* = true*/) { + auto ac = GetI18NCategory(I18NCat::ACHIEVEMENTS); + std::unique_lock lock(s_achievements_mutex); Achievement *achievement = GetMutableAchievementByID(achievement_id); @@ -1882,10 +1879,10 @@ void Achievements::UnlockAchievement(u32 achievement_id, bool add_notification / switch (achievement->category) { case AchievementCategory::Local: - title = achievement->title + " (Local)"; + title = achievement->title + " (" + ac->T("Local") + ")"; break; case AchievementCategory::Unofficial: - title = achievement->title + " (Unofficial)"; + title = achievement->title + " (" + ac->T("Unofficial") + ")"; break; case AchievementCategory::Core: default: @@ -2081,7 +2078,8 @@ void Achievements::CheevosEventHandler(const rc_runtime_event_t *runtime_event) } unsigned Achievements::PeekMemory(unsigned address, unsigned num_bytes, void *ud) { - // Unclear why achievements are defined with this offset, but they are and it can't be changed now, so we roll with it. + // Achievements are traditionally defined relative to the base of main memory of the emulated console. + // This is some kind of RetroArch-related legacy. In the PSP's case, this is simply a straight offset of 0x08000000. address += PSP_MEMORY_OFFSET; if (!Memory::IsValidAddress(address)) { diff --git a/assets/lang/en_US.ini b/assets/lang/en_US.ini index b248a98517e1..79077379feab 100644 --- a/assets/lang/en_US.ini +++ b/assets/lang/en_US.ini @@ -320,9 +320,11 @@ DeleteConfirmGameConfig = Do you really want to delete the settings for this gam DeleteFailed = Unable to delete data. Deleting = Deleting\nPlease wait... Disable All = Disable all +Disabled = Disabled Dumps = Dumps Edit = Edit Enable All = Enable all +Enabled = Enabled Enter = Enter Filter = Filter Finish = Finish @@ -334,6 +336,8 @@ Load = Load Load completed = Load completed. Loading = Loading\nPlease Wait... LoadingFailed = Unable to load data. +Log in = Log in +Log out = Log out Move = Move Move Up = Move Up Move Down = Move Down @@ -344,6 +348,7 @@ ObtainingIP = Obtaining IP address.\nPlease wait... OK = OK Old savedata detected = Old savedata detected Options = Options +Password = Password Remove = Remove Reset = Reset Resize = Resize @@ -355,6 +360,7 @@ SavingFailed = Unable to save data. Search = Search seconds, 0:off = seconds, 0 = off Select = Select +Settings = Settings Shift = Shift Skip = Skip Snap = Snap @@ -366,6 +372,7 @@ There is no data = There is no data. Toggle All = Toggle all Toggle List = Toggle list Unsupported = Unsupported +Username = Username When you save, it will load on a PSP, but not an older PPSSPP = When you save, it will load on a PSP, but not an older PPSSPP When you save, it will not work on outdated PSP Firmware anymore = When you save, it will not work on outdated PSP firmware anymore Yes = Yes @@ -1277,6 +1284,27 @@ VR camera = VR camera VR controllers = VR controllers [Achievements] +%d achievements, %d points = %d achievements, %d points +Account = Account +Achievements = Achievements +Challenge Mode = Challenge Mode Earned = You have earned %d of %d achievements, and %d of %d points +How to use RetroAchievements = How to use RetroAchievements +Leaderboard submission is enabled = Leaderboard submission is enabled +Links = Links +Local = Local +Locked achievements = Locked achievements +Log bad memory accesses = Log bad memory accesses +Mastered %s = Mastered %s +Register on www.retroachievements.org = Register on www.retroachievements.org +RetroAchievements are not available for this game = RetroAchievements are not available for this game +RetroAchievements website = RetroAchievements website +Rich Presence = Rich Presence +Sound Effects = Sound Effects +Submitted Score = Submitted Score +Submitted Score = Submitted score: %d (Best: %d)\nLeaderboard Position: %d of %d +Syncing achievements data... = Syncing achievements data... +Test Mode = Test Mode This game has no achievements = This game has no achievements -Submitted Score = Submitted score: %d (Best: %d)\nLeaderboard Position: %d of %d \ No newline at end of file +Unlocked achievements = Unlocked achievements +Unofficial = Unofficial \ No newline at end of file