Skip to content

Commit bdbeeca

Browse files
committed
feat(flame): move API key fetching to setup wizard
Signed-off-by: so5iso4ka <so5iso4ka@icloud.com>
1 parent 7c3c2dd commit bdbeeca

5 files changed

Lines changed: 121 additions & 13 deletions

File tree

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,11 @@ set(Launcher_MSA_CLIENT_ID "c36a9fb6-4f2a-41ff-90bd-ae7cc92031eb" CACHE STRING "
267267

268268
set(Launcher_ELYBY_CLIENT_ID "freesm-launcher" CACHE STRING "Client ID you can get from Ely.by Accounts for developers when you register an application")
269269

270-
set(Launcher_CURSEFORGE_API_KEY "" CACHE STRING "API key for the CurseForge platform")
270+
# By using this key in your builds you accept the terms and conditions laid down in
271+
# https://support.curseforge.com/en/support/solutions/articles/9000207405-curse-forge-3rd-party-api-terms-and-conditions
272+
# NOTE: CurseForge requires you to change this if you make any kind of derivative work.
273+
# This key was issued specifically for Prism Launcher
274+
set(Launcher_CURSEFORGE_API_KEY "$2a$10$wuAJuNZuted3NORVmpgUC.m8sI.pv1tOPKZyBgLFGjxFp/br0lZCC" CACHE STRING "API key for the CurseForge platform")
271275

272276
set(Launcher_COMPILER_NAME ${CMAKE_CXX_COMPILER_ID})
273277
set(Launcher_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION})

launcher/Application.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
#include "ui/pages/global/ProxyPage.h"
7272

7373
#include "ui/setupwizard/AutoJavaWizardPage.h"
74+
#include "ui/setupwizard/FlameApiKeyWizardPage.h"
7475
#include "ui/setupwizard/JavaWizardPage.h"
7576
#include "ui/setupwizard/LanguageWizardPage.h"
7677
#include "ui/setupwizard/LoginWizardPage.h"
@@ -1265,8 +1266,10 @@ bool Application::createSetupWizard()
12651266
bool validWidgets = m_themeManager->isValidApplicationTheme(settings()->get("ApplicationTheme").toString());
12661267
bool validIcons = m_themeManager->isValidIconTheme(settings()->get("IconTheme").toString());
12671268
bool login = !m_accounts->anyAccountIsValid() && capabilities() & Application::SupportsMSA;
1269+
bool fetchFlameAPIKey = settings()->get("FlameKeyShouldBeFetchedOnStartup").toBool();
12681270
bool themeInterventionRequired = !validWidgets || !validIcons;
1269-
bool wizardRequired = javaRequired || languageRequired || pasteInterventionRequired || themeInterventionRequired || askjava || login;
1271+
bool wizardRequired =
1272+
javaRequired || languageRequired || pasteInterventionRequired || themeInterventionRequired || askjava || login || fetchFlameAPIKey;
12701273
if (wizardRequired) {
12711274
// set default theme after going into theme wizard
12721275
if (!validIcons)
@@ -1306,6 +1309,11 @@ bool Application::createSetupWizard()
13061309
if (login) {
13071310
m_setupWizard->addPage(new LoginWizardPage(m_setupWizard));
13081311
}
1312+
1313+
if (fetchFlameAPIKey) {
1314+
m_setupWizard->addPage(new FlameAPIKeyWizardPage(m_setupWizard));
1315+
}
1316+
13091317
connect(m_setupWizard, &QDialog::finished, this, &Application::setupWizardFinished);
13101318
m_setupWizard->show();
13111319
}
@@ -1402,17 +1410,6 @@ void Application::performMainStartupAction()
14021410
return;
14031411
}
14041412
}
1405-
{
1406-
bool shouldFetch = m_settings->get("FlameKeyShouldBeFetchedOnStartup").toBool();
1407-
if (shouldFetch && !(capabilities() & Capability::SupportsFlame)) {
1408-
const auto& apiKey = GuiUtil::fetchFlameKey();
1409-
if (!apiKey.isEmpty()) {
1410-
m_settings->set("FlameKeyOverride", apiKey);
1411-
updateCapabilities();
1412-
}
1413-
}
1414-
m_settings->set("FlameKeyShouldBeFetchedOnStartup", false);
1415-
}
14161413
if (!m_mainWindow) {
14171414
// normal main window
14181415
showMainWindow(false);

launcher/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,8 @@ SET(LAUNCHER_SOURCES
913913
ui/setupwizard/SetupWizard.h
914914
ui/setupwizard/SetupWizard.cpp
915915
ui/setupwizard/BaseWizardPage.h
916+
ui/setupwizard/FlameApiKeyWizardPage.cpp
917+
ui/setupwizard/FlameApiKeyWizardPage.h
916918
ui/setupwizard/JavaWizardPage.cpp
917919
ui/setupwizard/JavaWizardPage.h
918920
ui/setupwizard/LanguageWizardPage.cpp
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// SPDX-License-Identifier: GPL-3.0-only
2+
/*
3+
* Freesm Launcher - Minecraft Launcher
4+
* Copyright (C) 2026 so5iso4ka <so5iso4ka@icloud.com>
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, version 3.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
19+
#include <QLabel>
20+
#include <QPushButton>
21+
#include <QVBoxLayout>
22+
23+
#include "Application.h"
24+
#include "ui/GuiUtil.h"
25+
26+
#include "FlameApiKeyWizardPage.h"
27+
28+
FlameAPIKeyWizardPage::FlameAPIKeyWizardPage(QWidget* parent) : BaseWizardPage(parent)
29+
{
30+
auto layout = new QVBoxLayout{ this };
31+
m_titleLabel = new QLabel{ this };
32+
m_descriptionLabel = new QLabel{ this };
33+
m_descriptionLabel->setWordWrap(true);
34+
m_fetchButton = new QPushButton{ this };
35+
36+
connect(m_fetchButton, &QPushButton::clicked, this, [this] {
37+
const auto& apiKey = GuiUtil::fetchFlameKey(this);
38+
if (!apiKey.isEmpty()) {
39+
APPLICATION->settings()->set("FlameKeyOverride", apiKey);
40+
APPLICATION->updateCapabilities();
41+
}
42+
});
43+
44+
layout->addWidget(m_titleLabel);
45+
layout->addWidget(m_descriptionLabel);
46+
layout->addWidget(m_fetchButton);
47+
48+
setLayout(layout);
49+
50+
FlameAPIKeyWizardPage::retranslate();
51+
}
52+
53+
void FlameAPIKeyWizardPage::initializePage()
54+
{
55+
APPLICATION->settings()->set("FlameKeyShouldBeFetchedOnStartup", false);
56+
}
57+
58+
void FlameAPIKeyWizardPage::retranslate()
59+
{
60+
m_titleLabel->setText(
61+
tr(R"(<html><head/><body><p><span style="font-size:14pt; font-weight:600;">Fetch CurseForge API key</span></p></body></html>)"));
62+
m_descriptionLabel->setText(
63+
tr("Using the official CurseForge app's API key may break CurseForge's terms of service but should allow Freesm Launcher to "
64+
"download all mods in a modpack without you needing to download any of them manually. This can be done later in the settings."));
65+
m_fetchButton->setText(tr("Fetch Official Launcher's Key"));
66+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// SPDX-License-Identifier: GPL-3.0-only
2+
/*
3+
* Freesm Launcher - Minecraft Launcher
4+
* Copyright (C) 2026 so5iso4ka <so5iso4ka@icloud.com>
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, version 3.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
19+
#pragma once
20+
21+
class QLabel;
22+
class QPushButton;
23+
24+
#include "BaseWizardPage.h"
25+
26+
class FlameAPIKeyWizardPage : public BaseWizardPage {
27+
Q_OBJECT
28+
public:
29+
explicit FlameAPIKeyWizardPage(QWidget* parent = nullptr);
30+
31+
void initializePage() override;
32+
33+
void retranslate() override;
34+
35+
private:
36+
QLabel* m_titleLabel;
37+
QLabel* m_descriptionLabel;
38+
QPushButton* m_fetchButton;
39+
};

0 commit comments

Comments
 (0)