Merge pull request #12953 from LillyJadeKatrin/retroachievements-fail-messaging

Achievements Fail Messaging
This commit is contained in:
JMC47 2024-10-02 14:50:21 -04:00 committed by GitHub
commit 122bce08de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 36 additions and 4 deletions

View File

@ -749,6 +749,7 @@ void AchievementManager::LoginCallback(int result, const char* error_message, rc
{
WARN_LOG_FMT(ACHIEVEMENTS, "Failed to login {} to RetroAchievements server.",
Config::Get(Config::RA_USERNAME));
AchievementManager::GetInstance().m_update_callback({.failed_login_code = result});
return;
}
@ -760,6 +761,7 @@ void AchievementManager::LoginCallback(int result, const char* error_message, rc
if (!user)
{
WARN_LOG_FMT(ACHIEVEMENTS, "Failed to retrieve user information from client.");
AchievementManager::GetInstance().m_update_callback({.failed_login_code = RC_INVALID_STATE});
return;
}
@ -778,6 +780,7 @@ void AchievementManager::LoginCallback(int result, const char* error_message, rc
INFO_LOG_FMT(ACHIEVEMENTS, "Attempted to login prior user {}; current user is {}.",
user->username, Config::Get(Config::RA_USERNAME));
rc_client_logout(client);
AchievementManager::GetInstance().m_update_callback({.failed_login_code = RC_INVALID_STATE});
return;
}
}
@ -830,6 +833,15 @@ void AchievementManager::LoadGameCallback(int result, const char* error_message,
rc_client_t* client, void* userdata)
{
AchievementManager::GetInstance().m_loading_volume.reset(nullptr);
if (result == RC_API_FAILURE)
{
WARN_LOG_FMT(ACHIEVEMENTS, "Load data request rejected for old Dolphin version.");
OSD::AddMessage("RetroAchievements no longer supports this version of Dolphin.",
OSD::Duration::VERY_LONG, OSD::Color::RED);
OSD::AddMessage("Please update Dolphin to a newer version.", OSD::Duration::VERY_LONG,
OSD::Color::RED);
return;
}
if (result != RC_OK)
{
WARN_LOG_FMT(ACHIEVEMENTS, "Failed to load data for current game.");

View File

@ -98,6 +98,7 @@ public:
bool all_leaderboards = false;
std::set<AchievementId> leaderboards{};
bool rich_presence = false;
int failed_login_code = 0;
};
using UpdateCallback = std::function<void(const UpdatedItems&)>;

View File

@ -39,8 +39,24 @@ AchievementSettingsWidget::AchievementSettingsWidget(QWidget* parent) : QWidget(
ToggleHardcore();
}
void AchievementSettingsWidget::UpdateData()
void AchievementSettingsWidget::UpdateData(int login_failed_code)
{
if (login_failed_code != RC_OK)
{
switch (login_failed_code)
{
case RC_INVALID_CREDENTIALS:
m_common_login_failed->setText(tr("Login Failed - Invalid Username/Password"));
break;
case RC_NO_RESPONSE:
m_common_login_failed->setText(tr("Login Failed - No Internet Connection"));
break;
default:
m_common_login_failed->setText(tr("Login Failed - Server Error"));
break;
}
m_common_login_failed->setVisible(true);
}
LoadSettings();
}
@ -256,6 +272,7 @@ void AchievementSettingsWidget::ToggleRAIntegration()
void AchievementSettingsWidget::Login()
{
m_common_login_failed->setVisible(false);
Config::SetBaseOrCurrent(Config::RA_USERNAME, m_common_username_input->text().toStdString());
AchievementManager::GetInstance().Login(m_common_password_input->text().toStdString());
m_common_password_input->setText(QString());

View File

@ -18,7 +18,7 @@ class AchievementSettingsWidget final : public QWidget
Q_OBJECT
public:
explicit AchievementSettingsWidget(QWidget* parent);
void UpdateData();
void UpdateData(int login_failed_code);
private:
void OnControllerInterfaceConfigure();

View File

@ -6,6 +6,8 @@
#include <mutex>
#include <rcheevos/include/rc_error.h>
#include <QDialogButtonBox>
#include <QScrollArea>
#include <QScrollBar>
@ -36,7 +38,7 @@ AchievementsWindow::AchievementsWindow(QWidget* parent) : QDialog(parent)
});
});
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
[this] { m_settings_widget->UpdateData(); });
[this] { m_settings_widget->UpdateData(RC_OK); });
connect(&Settings::Instance(), &Settings::HardcoreStateChanged, this,
[this] { AchievementsWindow::UpdateData({.all = true}); });
}
@ -79,7 +81,7 @@ void AchievementsWindow::ConnectWidgets()
void AchievementsWindow::UpdateData(AchievementManager::UpdatedItems updated_items)
{
m_settings_widget->UpdateData();
m_settings_widget->UpdateData(updated_items.failed_login_code);
if (updated_items.all)
{
m_header_widget->UpdateData();