UltimMC: Actually make profile for local accounts, fixes #334

This commit is contained in:
Neptune
2024-03-07 23:57:59 -05:00
parent 17a06d8eab
commit 0b4b9a1783
18 changed files with 305 additions and 57 deletions

View File

@@ -121,13 +121,89 @@ void LaunchController::login() {
m_session->wants_online = m_online;
m_accountToUse->fillSession(m_session);
if (m_accountToUse->typeString() == "local" || m_accountToUse->typeString() == "elyby") {
launchInstance();
return;
}
switch(m_accountToUse->accountState()) {
case AccountState::Offline: {
m_session->wants_online = false;
// NOTE: fallthrough is intentional
}
case AccountState::Online: {
launchInstance();
if(!m_session->wants_online) {
QString usedname;
if(m_offlineName.isEmpty()) {
// we ask the user for a player name
bool ok = false;
QString lastOfflinePlayerName = APPLICATION->settings()->get("LastOfflinePlayerName").toString();
usedname = lastOfflinePlayerName.isEmpty() ? m_session->player_name : lastOfflinePlayerName;
QString name = QInputDialog::getText(
m_parentWidget,
tr("Player name"),
tr("Choose your offline mode player name."),
QLineEdit::Normal,
usedname,
&ok
);
if (!ok)
{
tryagain = false;
break;
}
if (name.length())
{
usedname = name;
APPLICATION->settings()->set("LastOfflinePlayerName", usedname);
}
}
else {
usedname = m_offlineName;
}
m_session->MakeOffline(usedname);
// offline flavored game from here :3
}
if(m_accountToUse->ownsMinecraft()) {
if(!m_accountToUse->hasProfile()) {
// Now handle setting up a profile name here...
ProfileSetupDialog dialog(m_accountToUse, m_parentWidget);
if (dialog.exec() == QDialog::Accepted)
{
tryagain = true;
continue;
}
else
{
emitFailed(tr("Received undetermined session status during login."));
return;
}
}
// we own Minecraft, there is a profile, it's all ready to go!
launchInstance();
return;
}
else {
// play demo ?
QMessageBox box(m_parentWidget);
box.setWindowTitle(tr("Play demo?"));
box.setText(tr("This account does not own Minecraft.\nYou need to purchase the game first to play it.\n\nDo you want to play the demo?"));
box.setIcon(QMessageBox::Warning);
auto demoButton = box.addButton(tr("Play Demo"), QMessageBox::ButtonRole::YesRole);
auto cancelButton = box.addButton(tr("Cancel"), QMessageBox::ButtonRole::NoRole);
box.setDefaultButton(cancelButton);
box.exec();
if(box.clickedButton() == demoButton) {
// play demo here
m_session->MakeDemo();
launchInstance();
}
else {
emitFailed(tr("Launch cancelled - account does not own Minecraft."));
}
}
return;
}
case AccountState::Errored: