Show a warning message on login failure

This commit is contained in:
Henrik Rydgård 2023-07-12 19:21:08 +02:00
parent af92430b18
commit 943bfb7329
4 changed files with 20 additions and 4 deletions

View File

@ -388,6 +388,7 @@ void Initialize() {
} }
static void login_password_callback(int result, const char *error_message, rc_client_t *client, void *userdata) { static void login_password_callback(int result, const char *error_message, rc_client_t *client, void *userdata) {
auto di = GetI18NCategory(I18NCat::DIALOG);
switch (result) { switch (result) {
case RC_OK: case RC_OK:
{ {
@ -396,16 +397,20 @@ static void login_password_callback(int result, const char *error_message, rc_cl
g_Config.sAchievementsUserName = user->username; g_Config.sAchievementsUserName = user->username;
NativeSaveSecret(RA_TOKEN_SECRET_NAME, std::string(user->token)); NativeSaveSecret(RA_TOKEN_SECRET_NAME, std::string(user->token));
OnAchievementsLoginStateChange(); OnAchievementsLoginStateChange();
g_OSD.Show(OSDType::MESSAGE_SUCCESS, di->T("Logged in!"));
break; break;
} }
case RC_INVALID_STATE: case RC_INVALID_STATE:
case RC_API_FAILURE: case RC_API_FAILURE:
case RC_MISSING_VALUE: case RC_MISSING_VALUE:
case RC_INVALID_JSON: case RC_INVALID_JSON:
ERROR_LOG(ACHIEVEMENTS, "Failure logging in via token: %d, %s", result, error_message); {
ERROR_LOG(ACHIEVEMENTS, "Failure logging in via password: %d, %s", result, error_message);
g_OSD.Show(OSDType::MESSAGE_WARNING, di->T("Failed to log in, check your username and password."));
OnAchievementsLoginStateChange(); OnAchievementsLoginStateChange();
break; break;
} }
}
OSDCloseBackgroundProgressDialog("cheevos_async_login"); OSDCloseBackgroundProgressDialog("cheevos_async_login");
} }

View File

@ -227,7 +227,6 @@ void RetroAchievementsSettingsScreen::CreateAccountTab(UI::ViewGroup *viewGroup)
return UI::EVENT_DONE; return UI::EVENT_DONE;
}); });
} else { } else {
// TODO: Add UI for platforms that don't support System_AskUsernamePassword.
if (System_GetPropertyBool(SYSPROP_HAS_LOGIN_DIALOG)) { if (System_GetPropertyBool(SYSPROP_HAS_LOGIN_DIALOG)) {
viewGroup->Add(new Choice(ac->T("Log in")))->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) { System_AskUsernamePassword(ac->T("Log in"), [](const std::string &value, int) {
@ -242,13 +241,18 @@ void RetroAchievementsSettingsScreen::CreateAccountTab(UI::ViewGroup *viewGroup)
} else { } else {
// Hack up a temporary quick login-form-ish-thing // Hack up a temporary quick login-form-ish-thing
viewGroup->Add(new PopupTextInputChoice(&username_, di->T("Username"), "", 128, screenManager())); viewGroup->Add(new PopupTextInputChoice(&username_, di->T("Username"), "", 128, screenManager()));
viewGroup->Add(new PopupTextInputChoice(&password_, di->T("Password"), "", 128, screenManager())); viewGroup->Add(new PopupTextInputChoice(&password_, di->T("Password"), "", 128, screenManager()))->SetPasswordDisplay();
viewGroup->Add(new Choice(di->T("Log in")))->OnClick.Add([=](UI::EventParams &) -> UI::EventReturn { Choice *loginButton = viewGroup->Add(new Choice(di->T("Log in")));
loginButton->OnClick.Add([=](UI::EventParams &) -> UI::EventReturn {
if (!username_.empty() && !password_.empty()) { if (!username_.empty() && !password_.empty()) {
Achievements::LoginAsync(username_.c_str(), password_.c_str()); Achievements::LoginAsync(username_.c_str(), password_.c_str());
password_.clear();
} }
return UI::EVENT_DONE; return UI::EVENT_DONE;
}); });
loginButton->SetEnabledFunc([&]() {
return !username_.empty() && !password_.empty();
});
} }
viewGroup->Add(new Choice(ac->T("Register on www.retroachievements.org")))->OnClick.Add([&](UI::EventParams &) -> UI::EventReturn { viewGroup->Add(new Choice(ac->T("Register on www.retroachievements.org")))->OnClick.Add([&](UI::EventParams &) -> UI::EventReturn {
System_LaunchUrl(LaunchUrlType::BROWSER_URL, "https://retroachievements.org/createaccount.php"); System_LaunchUrl(LaunchUrlType::BROWSER_URL, "https://retroachievements.org/createaccount.php");
@ -358,6 +362,7 @@ void RenderAchievement(UIContext &dc, const rc_client_achievement_t *achievement
float iconSpace = bounds.h - padding * 2.0f; float iconSpace = bounds.h - padding * 2.0f;
dc.Flush(); dc.Flush();
dc.RebindTexture(); dc.RebindTexture();
dc.PushScissor(bounds);
dc.Begin(); dc.Begin();
@ -423,6 +428,9 @@ void RenderAchievement(UIContext &dc, const rc_client_achievement_t *achievement
dc.Flush(); dc.Flush();
dc.RebindTexture(); dc.RebindTexture();
} }
dc.Flush();
dc.PopScissor();
} }
void RenderGameAchievementSummary(UIContext &dc, const Bounds &bounds, float alpha) { void RenderGameAchievementSummary(UIContext &dc, const Bounds &bounds, float alpha) {

View File

@ -360,6 +360,7 @@ Edit = Edit
Enable All = Enable all Enable All = Enable all
Enabled = Enabled Enabled = Enabled
Enter = Enter Enter = Enter
Failed to log in, check your username and password. = Failed to log in, check your username and password.
Filter = Filter Filter = Filter
Finish = Finish Finish = Finish
GE Frame Dumps = GE Frame Dumps GE Frame Dumps = GE Frame Dumps
@ -372,6 +373,7 @@ Loading = Loading\nPlease Wait...
LoadingFailed = Unable to load data. LoadingFailed = Unable to load data.
Log in = Log in Log in = Log in
Log out = Log out Log out = Log out
Logged in! = Logged in!
Move = Move Move = Move
Move Up = Move Up Move Up = Move Up
Move Down = Move Down Move Down = Move Down

View File

@ -8,6 +8,7 @@ Achievements = Achievements
Challenge Mode = Utmanings-läge Challenge Mode = Utmanings-läge
Challenge Mode (no savestates) = Utmanings-läge (inga sparade state) Challenge Mode (no savestates) = Utmanings-läge (inga sparade state)
Earned = Du har tjänat %d av %d achievements, och %d of %d poäng Earned = Du har tjänat %d av %d achievements, och %d of %d poäng
Failed to log in, check your username and password. = Misslyckades att logga in, kontrollera ditt användarnamn och lösenord.
How to use RetroAchievements = Hur man använder RetroAchievements How to use RetroAchievements = Hur man använder RetroAchievements
Leaderboard submission is enabled = Skickar in poäng till ledartabeller Leaderboard submission is enabled = Skickar in poäng till ledartabeller
Leaderboards = Leaderboards Leaderboards = Leaderboards