NOISSUE proper fix for missing profile + demo mode
This commit is contained in:
parent
3efcccf334
commit
94fdf13f4a
@ -16,6 +16,7 @@
|
|||||||
#include <QHostInfo>
|
#include <QHostInfo>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
#include "BuildConfig.h"
|
#include "BuildConfig.h"
|
||||||
#include "JavaCommon.h"
|
#include "JavaCommon.h"
|
||||||
@ -145,21 +146,8 @@ void LaunchController::login() {
|
|||||||
m_session->MakeOffline(usedname);
|
m_session->MakeOffline(usedname);
|
||||||
// offline flavored game from here :3
|
// offline flavored game from here :3
|
||||||
}
|
}
|
||||||
if(m_accountToUse->ownsMinecraft() && !m_accountToUse->hasProfile()) {
|
if(m_accountToUse->ownsMinecraft()) {
|
||||||
auto entitlement = m_accountToUse->accountData()->minecraftEntitlement;
|
if(!m_accountToUse->hasProfile()) {
|
||||||
QString errorString;
|
|
||||||
if(!entitlement.canPlayMinecraft) {
|
|
||||||
errorString = tr("The account does not own Minecraft. You need to purchase the game first to play it.");
|
|
||||||
QMessageBox::warning(
|
|
||||||
nullptr,
|
|
||||||
tr("Missing Minecraft profile"),
|
|
||||||
errorString,
|
|
||||||
QMessageBox::StandardButton::Ok,
|
|
||||||
QMessageBox::StandardButton::Ok
|
|
||||||
);
|
|
||||||
emitFailed(errorString);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Now handle setting up a profile name here...
|
// Now handle setting up a profile name here...
|
||||||
ProfileSetupDialog dialog(m_accountToUse, m_parentWidget);
|
ProfileSetupDialog dialog(m_accountToUse, m_parentWidget);
|
||||||
if (dialog.exec() == QDialog::Accepted)
|
if (dialog.exec() == QDialog::Accepted)
|
||||||
@ -173,8 +161,29 @@ void LaunchController::login() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
// we own Minecraft, there is a profile, it's all ready to go!
|
||||||
launchInstance();
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -431,8 +431,7 @@ QStringList MinecraftInstance::processMinecraftArgs(
|
|||||||
|
|
||||||
QMap<QString, QString> token_mapping;
|
QMap<QString, QString> token_mapping;
|
||||||
// yggdrasil!
|
// yggdrasil!
|
||||||
if(session)
|
if(session) {
|
||||||
{
|
|
||||||
// token_mapping["auth_username"] = session->username;
|
// token_mapping["auth_username"] = session->username;
|
||||||
token_mapping["auth_session"] = session->session;
|
token_mapping["auth_session"] = session->session;
|
||||||
token_mapping["auth_access_token"] = session->access_token;
|
token_mapping["auth_access_token"] = session->access_token;
|
||||||
@ -440,6 +439,9 @@ QStringList MinecraftInstance::processMinecraftArgs(
|
|||||||
token_mapping["auth_uuid"] = session->uuid;
|
token_mapping["auth_uuid"] = session->uuid;
|
||||||
token_mapping["user_properties"] = session->serializeUserProperties();
|
token_mapping["user_properties"] = session->serializeUserProperties();
|
||||||
token_mapping["user_type"] = session->user_type;
|
token_mapping["user_type"] = session->user_type;
|
||||||
|
if(session->demo) {
|
||||||
|
args_pattern += " --demo";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// blatant self-promotion.
|
// blatant self-promotion.
|
||||||
@ -872,7 +874,9 @@ shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPt
|
|||||||
// if we aren't in offline mode,.
|
// if we aren't in offline mode,.
|
||||||
if(session->status != AuthSession::PlayableOffline)
|
if(session->status != AuthSession::PlayableOffline)
|
||||||
{
|
{
|
||||||
|
if(!session->demo) {
|
||||||
process->appendStep(new ClaimAccount(pptr, session));
|
process->appendStep(new ClaimAccount(pptr, session));
|
||||||
|
}
|
||||||
process->appendStep(new Update(pptr, Net::Mode::Online));
|
process->appendStep(new Update(pptr, Net::Mode::Online));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -30,3 +30,8 @@ bool AuthSession::MakeOffline(QString offline_playername)
|
|||||||
status = PlayableOffline;
|
status = PlayableOffline;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AuthSession::MakeDemo() {
|
||||||
|
player_name = "Player";
|
||||||
|
demo = true;
|
||||||
|
}
|
||||||
|
@ -11,6 +11,7 @@ class QNetworkAccessManager;
|
|||||||
struct AuthSession
|
struct AuthSession
|
||||||
{
|
{
|
||||||
bool MakeOffline(QString offline_playername);
|
bool MakeOffline(QString offline_playername);
|
||||||
|
void MakeDemo();
|
||||||
|
|
||||||
QString serializeUserProperties();
|
QString serializeUserProperties();
|
||||||
|
|
||||||
@ -43,6 +44,9 @@ struct AuthSession
|
|||||||
bool auth_server_online = false;
|
bool auth_server_online = false;
|
||||||
// Did the user request online mode?
|
// Did the user request online mode?
|
||||||
bool wants_online = true;
|
bool wants_online = true;
|
||||||
|
|
||||||
|
//Is this a demo session?
|
||||||
|
bool demo = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::shared_ptr<AuthSession> AuthSessionPtr;
|
typedef std::shared_ptr<AuthSession> AuthSessionPtr;
|
||||||
|
@ -227,7 +227,7 @@ bool parseMinecraftEntitlements(QByteArray & data, MinecraftEntitlement &output)
|
|||||||
|
|
||||||
auto obj = doc.object();
|
auto obj = doc.object();
|
||||||
output.canPlayMinecraft = false;
|
output.canPlayMinecraft = false;
|
||||||
output.ownsMinecraft = true;
|
output.ownsMinecraft = false;
|
||||||
|
|
||||||
auto itemsArray = obj.value("items").toArray();
|
auto itemsArray = obj.value("items").toArray();
|
||||||
for(auto item: itemsArray) {
|
for(auto item: itemsArray) {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
ClaimAccount::ClaimAccount(LaunchTask* parent, AuthSessionPtr session): LaunchStep(parent)
|
ClaimAccount::ClaimAccount(LaunchTask* parent, AuthSessionPtr session): LaunchStep(parent)
|
||||||
{
|
{
|
||||||
if(session->status == AuthSession::Status::PlayableOnline)
|
if(session->status == AuthSession::Status::PlayableOnline && !session->demo)
|
||||||
{
|
{
|
||||||
auto accounts = APPLICATION->accounts();
|
auto accounts = APPLICATION->accounts();
|
||||||
m_account = accounts->getAccountByProfileName(session->player_name);
|
m_account = accounts->getAccountByProfileName(session->player_name);
|
||||||
|
Loading…
Reference in New Issue
Block a user