Launching the game now possible. Feature parity with master branch

This commit is contained in:
Zakhar Afonin
2021-05-30 16:03:22 +03:00
parent 431af1cd62
commit ffd5dd948c
3 changed files with 31 additions and 5 deletions

View File

@@ -145,6 +145,17 @@ QJsonObject MojangAccount::saveToJson() const
return json;
}
bool MojangAccount::setLoginType(const QString &loginType)
{
// TODO: Implement a cleaner validity check
if (loginType == "mojang" or loginType == "dummy")
{
m_loginType = loginType;
return true;
}
return false;
}
bool MojangAccount::setCurrentProfile(const QString &profileId)
{
for (int i = 0; i < m_profiles.length(); i++)
@@ -180,9 +191,12 @@ std::shared_ptr<YggdrasilTask> MojangAccount::login(AuthSessionPtr session, QStr
// Handling alternative account types
if (m_loginType == "dummy")
{
session->status = AuthSession::PlayableOffline;
session->auth_server_online = false;
fillSession(session);
if (session)
{
session->status = AuthSession::PlayableOnline;
session->auth_server_online = false;
fillSession(session);
}
return nullptr;
}
@@ -292,7 +306,7 @@ void MojangAccount::fillSession(AuthSessionPtr session)
}
else
{
session->player_name = "Player";
session->player_name = m_username;
session->session = "-";
}
session->u = user();

View File

@@ -85,6 +85,12 @@ public: /* construction */
public: /* manipulation */
/**
* Overrides the login type on the account.
* Accepts "mojang" and "dummy". Returns false if other.
*/
bool setLoginType(const QString &loginType);
/**
* Sets the currently selected profile to the profile with the given ID string.
* If profileId is not in the list of available profiles, the function will simply return
* false.

View File

@@ -43,13 +43,19 @@ void LoginDialog::accept()
// Setup the login task and start it
m_account = MojangAccount::createFromUsername(ui->userTextBox->text());
m_account->setLoginType("dummy"); // TODO: Add the login type selector
m_loginTask = m_account->login(nullptr, ui->passTextBox->text());
connect(m_loginTask.get(), &Task::failed, this, &LoginDialog::onTaskFailed);
connect(m_loginTask.get(), &Task::succeeded, this,
&LoginDialog::onTaskSucceeded);
connect(m_loginTask.get(), &Task::status, this, &LoginDialog::onTaskStatus);
connect(m_loginTask.get(), &Task::progress, this, &LoginDialog::onTaskProgress);
m_loginTask->start();
if (true)
{
onTaskSucceeded();
} else {
m_loginTask->start();
}
}
void LoginDialog::setUserInputsEnabled(bool enable)