aboutsummaryrefslogtreecommitdiff
path: root/application
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2020-07-18 16:18:02 +0200
committerPetr Mrázek <peterix@gmail.com>2020-07-18 16:22:05 +0200
commite7f373496ed51d30d87eb1b75410d4f02f0412ec (patch)
treedb040fd29b1a95968324ef0b52fbc48d228d9f25 /application
parent3158082b16009907e1abed0308498d10788f0f42 (diff)
downloadPrismLauncher-e7f373496ed51d30d87eb1b75410d4f02f0412ec.tar.gz
PrismLauncher-e7f373496ed51d30d87eb1b75410d4f02f0412ec.tar.bz2
PrismLauncher-e7f373496ed51d30d87eb1b75410d4f02f0412ec.zip
GH-3234 Add support for custom meta URLs at build time
This is not particularly interesting for non-developers. Also includes some internal restructuring of URL constants in general.
Diffstat (limited to 'application')
-rw-r--r--application/BuildConfig.cpp.in54
-rw-r--r--application/BuildConfig.h70
-rw-r--r--application/CMakeLists.txt5
-rw-r--r--application/MainWindow.cpp4
-rw-r--r--application/MultiMC.cpp1
-rw-r--r--application/pages/global/AccountListPage.cpp5
-rw-r--r--application/pages/modplatform/legacy_ftb/ListModel.cpp4
-rw-r--r--application/pages/modplatform/twitch/TwitchModel.cpp2
8 files changed, 7 insertions, 138 deletions
diff --git a/application/BuildConfig.cpp.in b/application/BuildConfig.cpp.in
deleted file mode 100644
index a1d236b2..00000000
--- a/application/BuildConfig.cpp.in
+++ /dev/null
@@ -1,54 +0,0 @@
-#include "BuildConfig.h"
-#include <QObject>
-
-Config BuildConfig;
-
-Config::Config()
-{
- // Version information
- VERSION_MAJOR = @MultiMC_VERSION_MAJOR@;
- VERSION_MINOR = @MultiMC_VERSION_MINOR@;
- VERSION_HOTFIX = @MultiMC_VERSION_HOTFIX@;
- VERSION_BUILD = @MultiMC_VERSION_BUILD@;
-
- BUILD_PLATFORM = "@MultiMC_BUILD_PLATFORM@";
- CHANLIST_URL = "@MultiMC_CHANLIST_URL@";
- ANALYTICS_ID = "@MultiMC_ANALYTICS_ID@";
- NOTIFICATION_URL = "@MultiMC_NOTIFICATION_URL@";
- FULL_VERSION_STR = "@MultiMC_VERSION_MAJOR@.@MultiMC_VERSION_MINOR@.@MultiMC_VERSION_BUILD@";
-
- GIT_COMMIT = "@MultiMC_GIT_COMMIT@";
- GIT_REFSPEC = "@MultiMC_GIT_REFSPEC@";
- if(GIT_REFSPEC.startsWith("refs/heads/") && !CHANLIST_URL.isEmpty() && VERSION_BUILD >= 0)
- {
- VERSION_CHANNEL = GIT_REFSPEC;
- VERSION_CHANNEL.remove("refs/heads/");
- UPDATER_ENABLED = true;
- }
- else
- {
- VERSION_CHANNEL = QObject::tr("custom");
- }
-
- VERSION_STR = "@MultiMC_VERSION_STRING@";
- NEWS_RSS_URL = "@MultiMC_NEWS_RSS_URL@";
- PASTE_EE_KEY = "@MultiMC_PASTE_EE_API_KEY@";
-}
-
-QString Config::printableVersionString() const
-{
- QString vstr = QString("%1.%2.%3").arg(QString::number(VERSION_MAJOR), QString::number(VERSION_MINOR), QString::number(VERSION_HOTFIX));
-
- // If the build is not a main release, append the channel
- if(VERSION_CHANNEL != "stable")
- {
- vstr += "-" + VERSION_CHANNEL;
- }
-
- // if a build number is set, also add it to the end
- if(VERSION_BUILD >= 0)
- {
- vstr += "-" + QString::number(VERSION_BUILD);
- }
- return vstr;
-}
diff --git a/application/BuildConfig.h b/application/BuildConfig.h
deleted file mode 100644
index 77c42dd4..00000000
--- a/application/BuildConfig.h
+++ /dev/null
@@ -1,70 +0,0 @@
-#pragma once
-#include <QString>
-
-/**
- * \brief The Config class holds all the build-time information passed from the build system.
- */
-class Config
-{
-public:
- Config();
- /// The major version number.
- int VERSION_MAJOR;
- /// The minor version number.
- int VERSION_MINOR;
- /// The hotfix number.
- int VERSION_HOTFIX;
- /// The build number.
- int VERSION_BUILD;
-
- /**
- * The version channel
- * This is used by the updater to determine what channel the current version came from.
- */
- QString VERSION_CHANNEL;
-
- bool UPDATER_ENABLED = false;
-
- /// A short string identifying this build's platform. For example, "lin64" or "win32".
- QString BUILD_PLATFORM;
-
- /// URL for the updater's channel
- QString CHANLIST_URL;
-
- /// Google analytics ID
- QString ANALYTICS_ID;
-
- /// URL for notifications
- QString NOTIFICATION_URL;
-
- /// Used for matching notifications
- QString FULL_VERSION_STR;
-
- /// The git commit hash of this build
- QString GIT_COMMIT;
-
- /// The git refspec of this build
- QString GIT_REFSPEC;
-
- /// This is printed on start to standard output
- QString VERSION_STR;
-
- /**
- * This is used to fetch the news RSS feed.
- * It defaults in CMakeLists.txt to "https://multimc.org/rss.xml"
- */
- QString NEWS_RSS_URL;
-
- /**
- * API key you can get from paste.ee when you register an account
- */
- QString PASTE_EE_KEY;
-
- /**
- * \brief Converts the Version to a string.
- * \return The version number in string format (major.minor.revision.build).
- */
- QString printableVersionString() const;
-};
-
-extern Config BuildConfig;
diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt
index 53c21866..1d5b8e04 100644
--- a/application/CMakeLists.txt
+++ b/application/CMakeLists.txt
@@ -1,8 +1,5 @@
project(application)
-######## Configure the file with build properties ########
-configure_file("${PROJECT_SOURCE_DIR}/BuildConfig.cpp.in" "${PROJECT_BINARY_DIR}/BuildConfig.cpp")
-
################################ FILES ################################
######## Sources and headers ########
@@ -11,8 +8,6 @@ SET(MULTIMC_SOURCES
main.cpp
MultiMC.h
MultiMC.cpp
- BuildConfig.h
- ${PROJECT_BINARY_DIR}/BuildConfig.cpp
UpdateController.cpp
UpdateController.h
diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp
index 48b9ed47..00c37084 100644
--- a/application/MainWindow.cpp
+++ b/application/MainWindow.cpp
@@ -56,7 +56,7 @@
#include <launch/LaunchTask.h>
#include <minecraft/auth/MojangAccountList.h>
#include <SkinUtils.h>
-#include <net/URLConstants.h>
+#include <BuildConfig.h>
#include <net/NetJob.h>
#include <net/Download.h>
#include <news/NewsChecker.h>
@@ -772,7 +772,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
for (auto profile : account->profiles())
{
auto meta = Env::getInstance().metacache()->resolveEntry("skins", profile.id + ".png");
- auto action = Net::Download::makeCached(QUrl(URLConstants::SKINS_BASE + profile.id + ".png"), meta);
+ auto action = Net::Download::makeCached(QUrl(BuildConfig.SKINS_BASE + profile.id + ".png"), meta);
skin_dls.append(action);
meta->setStale(true);
}
diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp
index a8d26498..eeab500e 100644
--- a/application/MultiMC.cpp
+++ b/application/MultiMC.cpp
@@ -45,7 +45,6 @@
#include <minecraft/auth/MojangAccountList.h>
#include "icons/IconList.h"
#include "net/HttpMetaCache.h"
-#include "net/URLConstants.h"
#include "Env.h"
#include "java/JavaUtils.h"
diff --git a/application/pages/global/AccountListPage.cpp b/application/pages/global/AccountListPage.cpp
index 0453ae00..3c900fab 100644
--- a/application/pages/global/AccountListPage.cpp
+++ b/application/pages/global/AccountListPage.cpp
@@ -22,7 +22,6 @@
#include <QDebug>
#include "net/NetJob.h"
-#include "net/URLConstants.h"
#include "Env.h"
#include "dialogs/ProgressDialog.h"
@@ -34,6 +33,8 @@
#include "MultiMC.h"
+#include "BuildConfig.h"
+
AccountListPage::AccountListPage(QWidget *parent)
: QMainWindow(parent), ui(new Ui::AccountListPage)
{
@@ -170,7 +171,7 @@ void AccountListPage::addAccount(const QString &errMsg)
for (AccountProfile profile : account->profiles())
{
auto meta = Env::getInstance().metacache()->resolveEntry("skins", profile.id + ".png");
- auto action = Net::Download::makeCached(QUrl(URLConstants::SKINS_BASE + profile.id + ".png"), meta);
+ auto action = Net::Download::makeCached(QUrl(BuildConfig.SKINS_BASE + profile.id + ".png"), meta);
job->addNetAction(action);
meta->setStale(true);
}
diff --git a/application/pages/modplatform/legacy_ftb/ListModel.cpp b/application/pages/modplatform/legacy_ftb/ListModel.cpp
index 105db25a..32596fb3 100644
--- a/application/pages/modplatform/legacy_ftb/ListModel.cpp
+++ b/application/pages/modplatform/legacy_ftb/ListModel.cpp
@@ -10,7 +10,7 @@
#include <RWStorage.h>
#include <Env.h>
-#include "net/URLConstants.h"
+#include <BuildConfig.h>
namespace LegacyFTB {
@@ -218,7 +218,7 @@ void ListModel::requestLogo(QString file)
MetaEntryPtr entry = ENV.metacache()->resolveEntry("FTBPacks", QString("logos/%1").arg(file.section(".", 0, 0)));
NetJob *job = new NetJob(QString("FTB Icon Download for %1").arg(file));
- job->addNetAction(Net::Download::makeCached(QUrl(QString(URLConstants::LEGACY_FTB_CDN_BASE_URL + "static/%1").arg(file)), entry));
+ job->addNetAction(Net::Download::makeCached(QUrl(QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/%1").arg(file)), entry));
auto fullPath = entry->getFullPath();
QObject::connect(job, &NetJob::finished, this, [this, file, fullPath]
diff --git a/application/pages/modplatform/twitch/TwitchModel.cpp b/application/pages/modplatform/twitch/TwitchModel.cpp
index d9358941..9e3c3ad2 100644
--- a/application/pages/modplatform/twitch/TwitchModel.cpp
+++ b/application/pages/modplatform/twitch/TwitchModel.cpp
@@ -10,8 +10,6 @@
#include <RWStorage.h>
#include <Env.h>
-#include "net/URLConstants.h"
-
namespace Twitch {
ListModel::ListModel(QObject *parent) : QAbstractListModel(parent)