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.
This commit is contained in:
@ -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;
|
||||
}
|
@ -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;
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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]
|
||||
|
@ -10,8 +10,6 @@
|
||||
#include <RWStorage.h>
|
||||
#include <Env.h>
|
||||
|
||||
#include "net/URLConstants.h"
|
||||
|
||||
namespace Twitch {
|
||||
|
||||
ListModel::ListModel(QObject *parent) : QAbstractListModel(parent)
|
||||
|
Reference in New Issue
Block a user