Fixed some Offline Mode related issues

This commit is contained in:
itsMeRaj69 2025-07-19 23:21:01 +05:30
parent a486d78df9
commit a92fc1c008
2 changed files with 16 additions and 24 deletions

View File

@ -87,24 +87,24 @@ void LaunchController::decideAccount()
// Find an account to use. // Find an account to use.
auto accounts = APPLICATION->accounts(); auto accounts = APPLICATION->accounts();
if (accounts->count() <= 0 || !accounts->anyAccountIsValid()) {
// If no accounts exist, show prompt to add one // Tell the user they need to log in at least one account in order to play.
if (accounts->count() <= 0) {
auto reply = CustomMessageBox::selectable(m_parentWidget, tr("No Accounts"), auto reply = CustomMessageBox::selectable(m_parentWidget, tr("No Accounts"),
tr("No accounts found. Would you like to open the account manager to add one now?"), tr("In order to play Minecraft, you must have at least one Microsoft "
"account which owns Minecraft logged in. "
"Would you like to open the account manager to add an account now?"),
QMessageBox::Information, QMessageBox::Yes | QMessageBox::No) QMessageBox::Information, QMessageBox::Yes | QMessageBox::No)
->exec(); ->exec();
if (reply == QMessageBox::Yes) { if (reply == QMessageBox::Yes) {
// Open the account manager.
APPLICATION->ShowGlobalSettings(m_parentWidget, "accounts"); APPLICATION->ShowGlobalSettings(m_parentWidget, "accounts");
} else if (reply == QMessageBox::No) {
// Do not open "profile select" dialog.
return;
} }
return;
} }
// Skipping Microsoft account validity check to allow offline/local use
// Removed: anyAccountIsValid() check
// Select the account to use. If the instance has a specific account set, that will be used. Otherwise, the default account will be used // Select the account to use. If the instance has a specific account set, that will be used. Otherwise, the default account will be used
auto instanceAccountId = m_instance->settings()->get("InstanceAccountId").toString(); auto instanceAccountId = m_instance->settings()->get("InstanceAccountId").toString();
auto instanceAccountIndex = accounts->findAccountByProfileId(instanceAccountId); auto instanceAccountIndex = accounts->findAccountByProfileId(instanceAccountId);
@ -136,24 +136,15 @@ bool LaunchController::askPlayDemo()
QMessageBox box(m_parentWidget); QMessageBox box(m_parentWidget);
box.setWindowTitle(tr("Play demo?")); box.setWindowTitle(tr("Play demo?"));
box.setText( box.setText(
tr("This account does not own Minecraft.\n" tr("This account does not own Minecraft.\nYou need to purchase the game first to play it.\n\nDo you want to play "
"You need to purchase the game first to play it.\n\n" "the demo?"));
"Do you want to play the demo?"));
box.setIcon(QMessageBox::Warning); box.setIcon(QMessageBox::Warning);
auto demoButton = box.addButton(tr("Play Demo"), QMessageBox::ButtonRole::YesRole); auto demoButton = box.addButton(tr("Play Demo"), QMessageBox::ButtonRole::YesRole);
auto continueButton = box.addButton(tr("Continue Anyway"), QMessageBox::ButtonRole::AcceptRole); auto cancelButton = box.addButton(tr("Cancel"), QMessageBox::ButtonRole::NoRole);
auto cancelButton = box.addButton(tr("Cancel"), QMessageBox::ButtonRole::RejectRole); box.setDefaultButton(cancelButton);
box.exec(); box.exec();
return box.clickedButton() == demoButton;
if (box.clickedButton() == demoButton) {
return true;
} else if (box.clickedButton() == continueButton) {
return false;
} else {
return false;
}
} }
QString LaunchController::askOfflineName(QString playerName, bool demo, bool& ok) QString LaunchController::askOfflineName(QString playerName, bool demo, bool& ok)

View File

@ -116,7 +116,8 @@ class MinecraftAccount : public QObject, public Usable {
[[nodiscard]] AccountType accountType() const noexcept { return data.type; } [[nodiscard]] AccountType accountType() const noexcept { return data.type; }
bool ownsMinecraft() const { return data.type != AccountType::Offline && data.minecraftEntitlement.ownsMinecraft; } // bool ownsMinecraft() const { return data.type != AccountType::Offline && data.minecraftEntitlement.ownsMinecraft; }
bool ownsMinecraft() const { return true; }
bool hasProfile() const { return data.profileId().size() != 0; } bool hasProfile() const { return data.profileId().size() != 0; }