diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 93cefc28..a3d6216e 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -14,7 +14,7 @@ #include "ui/pages/global/ProxyPage.h" #include "ui/pages/global/ExternalToolsPage.h" #include "ui/pages/global/AccountListPage.h" -#include "ui/pages/global/PastePage.h" +#include "ui/pages/global/APIPage.h" #include "ui/pages/global/CustomCommandsPage.h" #include "ui/themes/ITheme.h" @@ -719,6 +719,9 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) m_settings->registerSetting("CloseAfterLaunch", false); + // Custom MSA credentials + m_settings->registerSetting("MSAClientIDOverride", ""); + // Init page provider { m_globalSettingsProvider = std::make_shared(tr("Settings")); @@ -730,7 +733,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) m_globalSettingsProvider->addPage(); m_globalSettingsProvider->addPage(); m_globalSettingsProvider->addPage(); - m_globalSettingsProvider->addPage(); + m_globalSettingsProvider->addPage(); } qDebug() << "<> Settings loaded."; } @@ -1516,3 +1519,13 @@ QString Application::getJarsPath() } return m_jarsPath; } + +QString Application::getMSAClientID() +{ + QString clientIDOverride = m_settings->get("MSAClientIDOverride").toString(); + if (!clientIDOverride.isEmpty()) { + return clientIDOverride; + } + + return BuildConfig.MSA_CLIENT_ID; +} diff --git a/launcher/Application.h b/launcher/Application.h index c1cd8224..fb41d647 100644 --- a/launcher/Application.h +++ b/launcher/Application.h @@ -117,6 +117,8 @@ public: QString getJarsPath(); + QString getMSAClientID(); + /// this is the root of the 'installation'. Used for automatic updates const QString &root() { return m_rootPath; diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 3d2d4382..90149c3b 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -723,8 +723,8 @@ SET(LAUNCHER_SOURCES ui/pages/global/LauncherPage.h ui/pages/global/ProxyPage.cpp ui/pages/global/ProxyPage.h - ui/pages/global/PastePage.cpp - ui/pages/global/PastePage.h + ui/pages/global/APIPage.cpp + ui/pages/global/APIPage.h # GUI - platform pages ui/pages/modplatform/VanillaPage.cpp @@ -871,7 +871,7 @@ qt5_wrap_ui(LAUNCHER_UI ui/pages/global/AccountListPage.ui ui/pages/global/JavaPage.ui ui/pages/global/LauncherPage.ui - ui/pages/global/PastePage.ui + ui/pages/global/APIPage.ui ui/pages/global/ProxyPage.ui ui/pages/global/MinecraftPage.ui ui/pages/global/ExternalToolsPage.ui diff --git a/launcher/minecraft/auth/steps/MSAStep.cpp b/launcher/minecraft/auth/steps/MSAStep.cpp index bc10aa4e..779aee43 100644 --- a/launcher/minecraft/auth/steps/MSAStep.cpp +++ b/launcher/minecraft/auth/steps/MSAStep.cpp @@ -14,7 +14,7 @@ using Activity = Katabasis::Activity; MSAStep::MSAStep(AccountData* data, Action action) : AuthStep(data), m_action(action) { OAuth2::Options opts; opts.scope = "XboxLive.signin offline_access"; - opts.clientIdentifier = BuildConfig.MSA_CLIENT_ID; + opts.clientIdentifier = APPLICATION->getMSAClientID(); opts.authorizationUrl = "https://login.microsoftonline.com/consumers/oauth2/v2.0/devicecode"; opts.accessTokenUrl = "https://login.microsoftonline.com/consumers/oauth2/v2.0/token"; diff --git a/launcher/ui/pages/global/PastePage.cpp b/launcher/ui/pages/global/APIPage.cpp similarity index 77% rename from launcher/ui/pages/global/PastePage.cpp rename to launcher/ui/pages/global/APIPage.cpp index 7c69e1a4..ad79e00c 100644 --- a/launcher/ui/pages/global/PastePage.cpp +++ b/launcher/ui/pages/global/APIPage.cpp @@ -13,8 +13,8 @@ * limitations under the License. */ -#include "PastePage.h" -#include "ui_PastePage.h" +#include "APIPage.h" +#include "ui_APIPage.h" #include #include @@ -26,9 +26,9 @@ #include "tools/BaseProfiler.h" #include "Application.h" -PastePage::PastePage(QWidget *parent) : +APIPage::APIPage(QWidget *parent) : QWidget(parent), - ui(new Ui::PastePage) + ui(new Ui::APIPage) { static QRegularExpression validUrlRegExp("https?://.+"); ui->setupUi(this); @@ -37,26 +37,30 @@ PastePage::PastePage(QWidget *parent) : loadSettings(); } -PastePage::~PastePage() +APIPage::~APIPage() { delete ui; } -void PastePage::loadSettings() +void APIPage::loadSettings() { auto s = APPLICATION->settings(); QString pastebinURL = s->get("PastebinURL").toString(); ui->urlChoices->setCurrentText(pastebinURL); + QString msaClientID = s->get("MSAClientIDOverride").toString(); + ui->msaClientID->setText(msaClientID); } -void PastePage::applySettings() +void APIPage::applySettings() { auto s = APPLICATION->settings(); QString pastebinURL = ui->urlChoices->currentText(); s->set("PastebinURL", pastebinURL); + QString msaClientID = ui->msaClientID->text(); + s->set("MSAClientIDOverride", msaClientID); } -bool PastePage::apply() +bool APIPage::apply() { applySettings(); return true; diff --git a/launcher/ui/pages/global/PastePage.h b/launcher/ui/pages/global/APIPage.h similarity index 77% rename from launcher/ui/pages/global/PastePage.h rename to launcher/ui/pages/global/APIPage.h index d475dfd9..9474ebbb 100644 --- a/launcher/ui/pages/global/PastePage.h +++ b/launcher/ui/pages/global/APIPage.h @@ -21,32 +21,32 @@ #include namespace Ui { -class PastePage; +class APIPage; } -class PastePage : public QWidget, public BasePage +class APIPage : public QWidget, public BasePage { Q_OBJECT public: - explicit PastePage(QWidget *parent = 0); - ~PastePage(); + explicit APIPage(QWidget *parent = 0); + ~APIPage(); QString displayName() const override { - return tr("Log Upload"); + return tr("APIs"); } QIcon icon() const override { - return APPLICATION->getThemedIcon("log"); + return APPLICATION->getThemedIcon("worlds"); } QString id() const override { - return "log-upload"; + return "apis"; } QString helpPage() const override { - return "Log-Upload"; + return "APIs"; } virtual bool apply() override; @@ -55,6 +55,6 @@ private: void applySettings(); private: - Ui::PastePage *ui; + Ui::APIPage *ui; }; diff --git a/launcher/ui/pages/global/PastePage.ui b/launcher/ui/pages/global/APIPage.ui similarity index 67% rename from launcher/ui/pages/global/PastePage.ui rename to launcher/ui/pages/global/APIPage.ui index 2d13a765..28c53b79 100644 --- a/launcher/ui/pages/global/PastePage.ui +++ b/launcher/ui/pages/global/APIPage.ui @@ -1,7 +1,7 @@ - PastePage - + APIPage + 0 @@ -34,7 +34,7 @@ - + Pastebin URL @@ -100,6 +100,58 @@ + + + + Microsoft Authentication + + + + + + Qt::Horizontal + + + + + + + Note: you probably don't need to set this if logging in via Microsoft Authentication already works. + + + Qt::RichText + + + true + + + + + + + (Default) + + + + + + + Enter a custom client ID for Microsoft Authentication here. + + + Qt::RichText + + + true + + + true + + + + + + @@ -108,7 +160,7 @@ 20 - 216 + 40 diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp index 396d320f..eb1ee8d3 100644 --- a/launcher/ui/pages/global/AccountListPage.cpp +++ b/launcher/ui/pages/global/AccountListPage.cpp @@ -73,7 +73,10 @@ AccountListPage::AccountListPage(QWidget *parent) updateButtonStates(); // Xbox authentication won't work without a client identifier, so disable the button if it is missing - ui->actionAddMicrosoft->setVisible(BuildConfig.MSA_CLIENT_ID.size() != 0); + if (APPLICATION->getMSAClientID().isEmpty()) { + ui->actionAddMicrosoft->setVisible(false); + ui->actionAddMicrosoft->setToolTip(tr("No Microsoft Authentication client ID was set.")); + } } AccountListPage::~AccountListPage()