Skip to content

Commit

Permalink
Minor cleanups, add most translation strings to en_US.ini
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Jun 23, 2023
1 parent ee30ce5 commit 37a557c
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 38 deletions.
15 changes: 8 additions & 7 deletions UI/RetroAchievementScreens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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<std::string> parts;
SplitString(value, '\n', parts);
Expand All @@ -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());
}
Expand Down
58 changes: 28 additions & 30 deletions UI/RetroAchievements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
namespace Common {
class HTTPDownloader {
public:
static std::unique_ptr<HTTPDownloader> Create(const std::string &userAgent) {
static std::unique_ptr<HTTPDownloader> Create() {
return std::unique_ptr<HTTPDownloader>(new HTTPDownloader());
}
class Request {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()).
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
}
Expand All @@ -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;

Expand All @@ -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());
Expand Down Expand Up @@ -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<rc_api_fetch_game_data_request_t, rc_api_init_fetch_game_data_request> request;
request.username = s_username.c_str();
Expand Down Expand Up @@ -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);
Expand All @@ -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:
Expand Down Expand Up @@ -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)) {
Expand Down
30 changes: 29 additions & 1 deletion assets/lang/en_US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Unlocked achievements = Unlocked achievements
Unofficial = Unofficial

0 comments on commit 37a557c

Please sign in to comment.