diff --git a/CMakeLists.txt b/CMakeLists.txt index fdc61c06..b178462e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,9 @@ set(MultiMC_CHANLIST_URL "" CACHE STRING "URL for the channel list.") # Notification URL set(MultiMC_NOTIFICATION_URL "" CACHE STRING "URL for checking for notifications.") +# The metadata server +set(MultiMC_META_URL "https://meta.multimc.org/v1/" CACHE STRING "URL to fetch MultiMC's meta files from.") + # paste.ee API key set(MultiMC_PASTE_EE_API_KEY "utLvciUouSURFzfjPxLBf5W4ISsUX4pwBDF7N1AfZ" CACHE STRING "API key you can get from paste.ee when you register an account") @@ -264,6 +267,7 @@ add_subdirectory(libraries/classparser) # google analytics library ############################### Built Artifacts ############################### +add_subdirectory(buildconfig) add_subdirectory(api/logic) add_subdirectory(api/gui) diff --git a/api/gui/SkinUtils.cpp b/api/gui/SkinUtils.cpp index 9b6f63a4..e9618bd5 100644 --- a/api/gui/SkinUtils.cpp +++ b/api/gui/SkinUtils.cpp @@ -18,6 +18,7 @@ #include "Env.h" #include +#include #include #include #include @@ -35,10 +36,14 @@ QPixmap getFaceFromCache(QString username, int height, int width) if (fskin.exists()) { - QPixmap skin(fskin.fileName()); - if(!skin.isNull()) + QPixmap skinTexture(fskin.fileName()); + if(!skinTexture.isNull()) { - return skin.copy(8, 8, 8, 8).scaled(height, width, Qt::KeepAspectRatio); + QPixmap skin = QPixmap(8, 8); + QPainter painter(&skin); + painter.drawPixmap(0, 0, skinTexture.copy(8, 8, 8, 8)); + painter.drawPixmap(0, 0, skinTexture.copy(40, 8, 8, 8)); + return skin.scaled(height, width, Qt::KeepAspectRatio); } } diff --git a/api/logic/CMakeLists.txt b/api/logic/CMakeLists.txt index 50c2cb6e..50eff4ba 100644 --- a/api/logic/CMakeLists.txt +++ b/api/logic/CMakeLists.txt @@ -119,8 +119,6 @@ set(NET_SOURCES net/PasteUpload.cpp net/PasteUpload.h net/Sink.h - net/URLConstants.cpp - net/URLConstants.h net/Validator.h ) @@ -259,8 +257,8 @@ set(MINECRAFT_SOURCES minecraft/LaunchProfile.h minecraft/Component.cpp minecraft/Component.h - minecraft/ComponentList.cpp - minecraft/ComponentList.h + minecraft/PackProfile.cpp + minecraft/PackProfile.h minecraft/ComponentUpdateTask.cpp minecraft/ComponentUpdateTask.h minecraft/MinecraftLoadAndCheck.h @@ -491,7 +489,7 @@ set_target_properties(MultiMC_logic PROPERTIES CXX_VISIBILITY_PRESET hidden VISI generate_export_header(MultiMC_logic) # Link -target_link_libraries(MultiMC_logic systeminfo MultiMC_quazip MultiMC_classparser ${NBT_NAME} ${ZLIB_LIBRARIES}) +target_link_libraries(MultiMC_logic systeminfo MultiMC_quazip MultiMC_classparser ${NBT_NAME} ${ZLIB_LIBRARIES} BuildConfig) target_link_libraries(MultiMC_logic Qt5::Core Qt5::Xml Qt5::Network Qt5::Concurrent) # Mark and export headers diff --git a/api/logic/InstanceCreationTask.cpp b/api/logic/InstanceCreationTask.cpp index 978d4687..eafc5126 100644 --- a/api/logic/InstanceCreationTask.cpp +++ b/api/logic/InstanceCreationTask.cpp @@ -4,7 +4,7 @@ //FIXME: remove this #include "minecraft/MinecraftInstance.h" -#include "minecraft/ComponentList.h" +#include "minecraft/PackProfile.h" InstanceCreationTask::InstanceCreationTask(BaseVersionPtr version) { @@ -20,7 +20,7 @@ void InstanceCreationTask::executeTask() instanceSettings->registerSetting("InstanceType", "Legacy"); instanceSettings->set("InstanceType", "OneSix"); MinecraftInstance inst(m_globalSettings, instanceSettings, m_stagingPath); - auto components = inst.getComponentList(); + auto components = inst.getPackProfile(); components->buildingFromScratch(); components->setComponentVersion("net.minecraft", m_version->descriptor(), true); inst.setName(m_instName); diff --git a/api/logic/InstanceImportTask.cpp b/api/logic/InstanceImportTask.cpp index 1e93174c..e2187416 100644 --- a/api/logic/InstanceImportTask.cpp +++ b/api/logic/InstanceImportTask.cpp @@ -11,7 +11,7 @@ // FIXME: this does not belong here, it's Minecraft/Flame specific #include "minecraft/MinecraftInstance.h" -#include "minecraft/ComponentList.h" +#include "minecraft/PackProfile.h" #include "modplatform/flame/FileResolvingTask.h" #include "modplatform/flame/PackManifest.h" #include "Json.h" @@ -236,7 +236,7 @@ void InstanceImportTask::processFlame() mcVersion.remove(QRegExp("[.]+$")); logWarning(tr("Mysterious trailing dots removed from Minecraft version while importing pack.")); } - auto components = instance.getComponentList(); + auto components = instance.getPackProfile(); components->buildingFromScratch(); components->setComponentVersion("net.minecraft", mcVersion, true); if(!forgeVersion.isEmpty()) @@ -288,7 +288,7 @@ void InstanceImportTask::processFlame() qDebug() << info.fileName(); jarMods.push_back(info.absoluteFilePath()); } - auto profile = instance.getComponentList(); + auto profile = instance.getPackProfile(); profile->installJarMods(jarMods); // nuke the original files FS::deletePath(jarmodsPath); diff --git a/api/logic/meta/BaseEntity.cpp b/api/logic/meta/BaseEntity.cpp index ce0be859..31d79aa3 100644 --- a/api/logic/meta/BaseEntity.cpp +++ b/api/logic/meta/BaseEntity.cpp @@ -24,6 +24,8 @@ #include "Env.h" #include "Json.h" +#include "BuildConfig.h" + class ParsingValidator : public Net::Validator { public: /* con/des */ @@ -53,7 +55,9 @@ public: /* methods */ auto fname = m_entity->localFilename(); try { - m_entity->parse(Json::requireObject(Json::requireDocument(data, fname), fname)); + auto doc = Json::requireDocument(data, fname); + auto obj = Json::requireObject(doc, fname); + m_entity->parse(obj); return true; } catch (const Exception &e) @@ -74,7 +78,7 @@ Meta::BaseEntity::~BaseEntity() QUrl Meta::BaseEntity::url() const { - return QUrl("https://meta.multimc.org/v1/").resolved(localFilename()); + return QUrl(BuildConfig.META_URL).resolved(localFilename()); } bool Meta::BaseEntity::loadLocalFile() @@ -87,7 +91,9 @@ bool Meta::BaseEntity::loadLocalFile() // TODO: check if the file has the expected checksum try { - parse(Json::requireObject(Json::requireDocument(fname, fname), fname)); + auto doc = Json::requireDocument(fname, fname); + auto obj = Json::requireObject(doc, fname); + parse(obj); return true; } catch (const Exception &e) diff --git a/api/logic/meta/Version.cpp b/api/logic/meta/Version.cpp index ca889550..2bbe19a7 100644 --- a/api/logic/meta/Version.cpp +++ b/api/logic/meta/Version.cpp @@ -18,7 +18,7 @@ #include #include "JsonFormat.h" -#include "minecraft/ComponentList.h" +#include "minecraft/PackProfile.h" Meta::Version::Version(const QString &uid, const QString &version) : BaseVersion(), m_uid(uid), m_version(version) diff --git a/api/logic/minecraft/AssetsUtils.cpp b/api/logic/minecraft/AssetsUtils.cpp index f94f68b1..68089080 100644 --- a/api/logic/minecraft/AssetsUtils.cpp +++ b/api/logic/minecraft/AssetsUtils.cpp @@ -27,7 +27,7 @@ #include "FileSystem.h" #include "net/Download.h" #include "net/ChecksumValidator.h" -#include "net/URLConstants.h" +#include "BuildConfig.h" namespace { QSet collectPathsFromDir(QString dirPath) @@ -308,7 +308,7 @@ QString AssetObject::getLocalPath() QUrl AssetObject::getUrl() { - return URLConstants::RESOURCE_BASE + getRelPath(); + return BuildConfig.RESOURCE_BASE + getRelPath(); } QString AssetObject::getRelPath() diff --git a/api/logic/minecraft/Component.cpp b/api/logic/minecraft/Component.cpp index 51957d17..92821065 100644 --- a/api/logic/minecraft/Component.cpp +++ b/api/logic/minecraft/Component.cpp @@ -5,13 +5,13 @@ #include "meta/Version.h" #include "VersionFile.h" -#include "minecraft/ComponentList.h" +#include "minecraft/PackProfile.h" #include #include #include "OneSixVersionFormat.h" #include -Component::Component(ComponentList * parent, const QString& uid) +Component::Component(PackProfile * parent, const QString& uid) { assert(parent); m_parent = parent; @@ -19,7 +19,7 @@ Component::Component(ComponentList * parent, const QString& uid) m_uid = uid; } -Component::Component(ComponentList * parent, std::shared_ptr version) +Component::Component(PackProfile * parent, std::shared_ptr version) { assert(parent); m_parent = parent; @@ -31,7 +31,7 @@ Component::Component(ComponentList * parent, std::shared_ptr vers m_loaded = version->isLoaded(); } -Component::Component(ComponentList * parent, const QString& uid, std::shared_ptr file) +Component::Component(PackProfile * parent, const QString& uid, std::shared_ptr file) { assert(parent); m_parent = parent; diff --git a/api/logic/minecraft/Component.h b/api/logic/minecraft/Component.h index 6a0f86c8..cb202f7f 100644 --- a/api/logic/minecraft/Component.h +++ b/api/logic/minecraft/Component.h @@ -9,7 +9,7 @@ #include "QObjectPtr.h" #include "multimc_logic_export.h" -class ComponentList; +class PackProfile; class LaunchProfile; namespace Meta { @@ -22,11 +22,11 @@ class MULTIMC_LOGIC_EXPORT Component : public QObject, public ProblemProvider { Q_OBJECT public: - Component(ComponentList * parent, const QString &uid); + Component(PackProfile * parent, const QString &uid); // DEPRECATED: remove these constructors? - Component(ComponentList * parent, std::shared_ptr version); - Component(ComponentList * parent, const QString & uid, std::shared_ptr file); + Component(PackProfile * parent, std::shared_ptr version); + Component(PackProfile * parent, const QString & uid, std::shared_ptr file); virtual ~Component(){}; void applyTo(LaunchProfile *profile); @@ -73,7 +73,7 @@ signals: void dataChanged(); public: /* data */ - ComponentList * m_parent; + PackProfile * m_parent; // BEGIN: persistent component list properties /// ID of the component diff --git a/api/logic/minecraft/ComponentUpdateTask.cpp b/api/logic/minecraft/ComponentUpdateTask.cpp index 84c0474c..241d9a49 100644 --- a/api/logic/minecraft/ComponentUpdateTask.cpp +++ b/api/logic/minecraft/ComponentUpdateTask.cpp @@ -1,7 +1,7 @@ #include "ComponentUpdateTask.h" -#include "ComponentList_p.h" -#include "ComponentList.h" +#include "PackProfile_p.h" +#include "PackProfile.h" #include "Component.h" #include #include @@ -22,16 +22,16 @@ * Really, it should be a reactor/state machine that receives input from the application * and dynamically adapts to changing requirements... * - * The reactor should be the only entry into manipulating the ComponentList. + * The reactor should be the only entry into manipulating the PackProfile. * See: https://en.wikipedia.org/wiki/Reactor_pattern */ /* - * Or make this operate on a snapshot of the ComponentList state, then merge results in as long as the snapshot and ComponentList didn't change? + * Or make this operate on a snapshot of the PackProfile state, then merge results in as long as the snapshot and PackProfile didn't change? * If the component list changes, start over. */ -ComponentUpdateTask::ComponentUpdateTask(Mode mode, Net::Mode netmode, ComponentList* list, QObject* parent) +ComponentUpdateTask::ComponentUpdateTask(Mode mode, Net::Mode netmode, PackProfile* list, QObject* parent) : Task(parent) { d.reset(new ComponentUpdateTaskData); @@ -126,7 +126,7 @@ static LoadResult loadComponent(ComponentPtr component, shared_qobject_ptr // FIXME: dead code. determine if this can still be useful? /* -static LoadResult loadComponentList(ComponentPtr component, shared_qobject_ptr& loadTask, Net::Mode netmode) +static LoadResult loadPackProfile(ComponentPtr component, shared_qobject_ptr& loadTask, Net::Mode netmode) { if(component->m_loaded) { @@ -217,7 +217,7 @@ void ComponentUpdateTask::loadComponents() } case Mode::Resolution: { - singleResult = loadComponentList(component, loadTask, d->netmode); + singleResult = loadPackProfile(component, loadTask, d->netmode); loadType = RemoteLoadStatus::Type::List; break; } @@ -244,7 +244,7 @@ void ComponentUpdateTask::loadComponents() }); RemoteLoadStatus status; status.type = loadType; - status.componentListIndex = componentIndex; + status.PackProfileIndex = componentIndex; d->remoteLoadStatusList.append(status); taskIndex++; } @@ -495,7 +495,7 @@ static bool getTrivialComponentChanges(const ComponentIndex & index, const Requi } // FIXME, TODO: decouple dependency resolution from loading -// FIXME: This works directly with the ComponentList internals. It shouldn't! It needs richer data types than ComponentList uses. +// FIXME: This works directly with the PackProfile internals. It shouldn't! It needs richer data types than PackProfile uses. // FIXME: throw all this away and use a graph void ComponentUpdateTask::resolveDependencies(bool checkOnly) { @@ -648,7 +648,7 @@ void ComponentUpdateTask::remoteLoadSucceeded(size_t taskIndex) // update the cached data of the component from the downloaded version file. if (taskSlot.type == RemoteLoadStatus::Type::Version) { - auto component = d->m_list->getComponent(taskSlot.componentListIndex); + auto component = d->m_list->getComponent(taskSlot.PackProfileIndex); component->m_loaded = true; component->updateCachedData(); } diff --git a/api/logic/minecraft/ComponentUpdateTask.h b/api/logic/minecraft/ComponentUpdateTask.h index 4cb29a89..4274cabb 100644 --- a/api/logic/minecraft/ComponentUpdateTask.h +++ b/api/logic/minecraft/ComponentUpdateTask.h @@ -4,7 +4,7 @@ #include "net/Mode.h" #include -class ComponentList; +class PackProfile; struct ComponentUpdateTaskData; class ComponentUpdateTask : public Task @@ -18,7 +18,7 @@ public: }; public: - explicit ComponentUpdateTask(Mode mode, Net::Mode netmode, ComponentList * list, QObject *parent = 0); + explicit ComponentUpdateTask(Mode mode, Net::Mode netmode, PackProfile * list, QObject *parent = 0); virtual ~ComponentUpdateTask(); protected: diff --git a/api/logic/minecraft/ComponentUpdateTask_p.h b/api/logic/minecraft/ComponentUpdateTask_p.h index 5989cf07..5b02431b 100644 --- a/api/logic/minecraft/ComponentUpdateTask_p.h +++ b/api/logic/minecraft/ComponentUpdateTask_p.h @@ -5,7 +5,7 @@ #include #include "net/Mode.h" -class ComponentList; +class PackProfile; struct RemoteLoadStatus { @@ -15,7 +15,7 @@ struct RemoteLoadStatus List, Version } type = Type::Version; - size_t componentListIndex = 0; + size_t PackProfileIndex = 0; bool finished = false; bool succeeded = false; QString error; @@ -23,7 +23,7 @@ struct RemoteLoadStatus struct ComponentUpdateTaskData { - ComponentList * m_list = nullptr; + PackProfile * m_list = nullptr; QList remoteLoadStatusList; bool remoteLoadSuccessful = true; size_t remoteTasksInProgress = 0; diff --git a/api/logic/minecraft/Library.cpp b/api/logic/minecraft/Library.cpp index 9ff8dcdc..b3c7657c 100644 --- a/api/logic/minecraft/Library.cpp +++ b/api/logic/minecraft/Library.cpp @@ -5,6 +5,7 @@ #include #include #include +#include void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& native, QStringList& native32, @@ -171,7 +172,7 @@ QList< std::shared_ptr< NetAction > > Library::getDownloads( if (m_repositoryURL.isEmpty()) { - return URLConstants::LIBRARY_BASE + raw_storage; + return BuildConfig.LIBRARY_BASE + raw_storage; } if(m_repositoryURL.endsWith('/')) diff --git a/api/logic/minecraft/Library.h b/api/logic/minecraft/Library.h index 014f6745..acdd6c9c 100644 --- a/api/logic/minecraft/Library.h +++ b/api/logic/minecraft/Library.h @@ -12,7 +12,6 @@ #include "Rule.h" #include "minecraft/OpSys.h" #include "GradleSpecifier.h" -#include "net/URLConstants.h" #include "MojangDownloadInfo.h" #include "multimc_logic_export.h" diff --git a/api/logic/minecraft/MinecraftInstance.cpp b/api/logic/minecraft/MinecraftInstance.cpp index 912a3829..9b1a7dbc 100644 --- a/api/logic/minecraft/MinecraftInstance.cpp +++ b/api/logic/minecraft/MinecraftInstance.cpp @@ -33,7 +33,7 @@ #include "icons/IIconList.h" #include -#include "ComponentList.h" +#include "PackProfile.h" #include "AssetsUtils.h" #include "MinecraftUpdate.h" #include "MinecraftLoadAndCheck.h" @@ -106,7 +106,7 @@ MinecraftInstance::MinecraftInstance(SettingsObjectPtr globalSettings, SettingsO m_settings->registerSetting("ForgeVersion", ""); m_settings->registerSetting("LiteloaderVersion", ""); - m_components.reset(new ComponentList(this)); + m_components.reset(new PackProfile(this)); m_components->setOldConfigVersion("net.minecraft", m_settings->get("IntendedVersion").toString()); auto setting = m_settings->getSetting("LWJGLVersion"); m_components->setOldConfigVersion("org.lwjgl", m_settings->get("LWJGLVersion").toString()); @@ -124,14 +124,14 @@ QString MinecraftInstance::typeName() const return "Minecraft"; } -std::shared_ptr MinecraftInstance::getComponentList() const +std::shared_ptr MinecraftInstance::getPackProfile() const { return m_components; } QSet MinecraftInstance::traits() const { - auto components = getComponentList(); + auto components = getPackProfile(); if (!components) { return {"version-incomplete"}; @@ -265,7 +265,7 @@ QStringList MinecraftInstance::getNativeJars() const QStringList MinecraftInstance::extraArguments() const { auto list = BaseInstance::extraArguments(); - auto version = getComponentList(); + auto version = getPackProfile(); if (!version) return list; auto jarMods = getJarMods(); diff --git a/api/logic/minecraft/MinecraftInstance.h b/api/logic/minecraft/MinecraftInstance.h index a8f64109..985a8a76 100644 --- a/api/logic/minecraft/MinecraftInstance.h +++ b/api/logic/minecraft/MinecraftInstance.h @@ -10,7 +10,7 @@ class ModFolderModel; class WorldList; class GameOptions; class LaunchStep; -class ComponentList; +class PackProfile; class MULTIMC_LOGIC_EXPORT MinecraftInstance: public BaseInstance { @@ -64,7 +64,7 @@ public: ////// Profile management ////// - std::shared_ptr getComponentList() const; + std::shared_ptr getPackProfile() const; ////// Mod Lists ////// std::shared_ptr loaderModList() const; @@ -120,7 +120,7 @@ private: QString prettifyTimeDuration(int64_t duration); protected: // data - std::shared_ptr m_components; + std::shared_ptr m_components; mutable std::shared_ptr m_loader_mod_list; mutable std::shared_ptr m_core_mod_list; mutable std::shared_ptr m_resource_pack_list; diff --git a/api/logic/minecraft/MinecraftLoadAndCheck.cpp b/api/logic/minecraft/MinecraftLoadAndCheck.cpp index 593e2fc4..79b0c484 100644 --- a/api/logic/minecraft/MinecraftLoadAndCheck.cpp +++ b/api/logic/minecraft/MinecraftLoadAndCheck.cpp @@ -1,6 +1,6 @@ #include "MinecraftLoadAndCheck.h" #include "MinecraftInstance.h" -#include "ComponentList.h" +#include "PackProfile.h" MinecraftLoadAndCheck::MinecraftLoadAndCheck(MinecraftInstance *inst, QObject *parent) : Task(parent), m_inst(inst) { @@ -9,7 +9,7 @@ MinecraftLoadAndCheck::MinecraftLoadAndCheck(MinecraftInstance *inst, QObject *p void MinecraftLoadAndCheck::executeTask() { // add offline metadata load task - auto components = m_inst->getComponentList(); + auto components = m_inst->getPackProfile(); components->reload(Net::Mode::Offline); m_task = components->getCurrentTask(); diff --git a/api/logic/minecraft/MinecraftUpdate.cpp b/api/logic/minecraft/MinecraftUpdate.cpp index f9ff114d..68dd437d 100644 --- a/api/logic/minecraft/MinecraftUpdate.cpp +++ b/api/logic/minecraft/MinecraftUpdate.cpp @@ -23,9 +23,8 @@ #include #include "BaseInstance.h" -#include "minecraft/ComponentList.h" +#include "minecraft/PackProfile.h" #include "minecraft/Library.h" -#include "net/URLConstants.h" #include #include "update/FoldersTask.h" @@ -50,7 +49,7 @@ void MinecraftUpdate::executeTask() // add metadata update task if necessary { - auto components = m_inst->getComponentList(); + auto components = m_inst->getPackProfile(); components->reload(Net::Mode::Online); auto task = components->getCurrentTask(); if(task) diff --git a/api/logic/minecraft/OneSixVersionFormat.cpp b/api/logic/minecraft/OneSixVersionFormat.cpp index a0b6fd0e..7ac9e2db 100644 --- a/api/logic/minecraft/OneSixVersionFormat.cpp +++ b/api/logic/minecraft/OneSixVersionFormat.cpp @@ -198,7 +198,10 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc // FIXME: this will eventually break... else { - lib->setAbsoluteUrl(URLConstants::getLegacyJarUrl(out->minecraftVersion)); + out->addProblem( + ProblemSeverity::Error, + QObject::tr("URL for the main jar could not be determined - Mojang removed the server that we used as fallback.") + ); } out->mainJar = lib; } diff --git a/api/logic/minecraft/OneSixVersionFormat.h b/api/logic/minecraft/OneSixVersionFormat.h index 6bbebca0..14ae385c 100644 --- a/api/logic/minecraft/OneSixVersionFormat.h +++ b/api/logic/minecraft/OneSixVersionFormat.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include diff --git a/api/logic/minecraft/ComponentList.cpp b/api/logic/minecraft/PackProfile.cpp similarity index 89% rename from api/logic/minecraft/ComponentList.cpp rename to api/logic/minecraft/PackProfile.cpp index 51fe214d..15f2f55d 100644 --- a/api/logic/minecraft/ComponentList.cpp +++ b/api/logic/minecraft/PackProfile.cpp @@ -32,23 +32,23 @@ #include #include -#include "ComponentList.h" -#include "ComponentList_p.h" +#include "PackProfile.h" +#include "PackProfile_p.h" #include "ComponentUpdateTask.h" -ComponentList::ComponentList(MinecraftInstance * instance) +PackProfile::PackProfile(MinecraftInstance * instance) : QAbstractListModel() { - d.reset(new ComponentListData); + d.reset(new PackProfileData); d->m_instance = instance; d->m_saveTimer.setSingleShot(true); d->m_saveTimer.setInterval(5000); d->interactionDisabled = instance->isRunning(); - connect(d->m_instance, &BaseInstance::runningStatusChanged, this, &ComponentList::disableInteraction); - connect(&d->m_saveTimer, &QTimer::timeout, this, &ComponentList::save_internal); + connect(d->m_instance, &BaseInstance::runningStatusChanged, this, &PackProfile::disableInteraction); + connect(&d->m_saveTimer, &QTimer::timeout, this, &PackProfile::save_internal); } -ComponentList::~ComponentList() +PackProfile::~PackProfile() { saveNow(); } @@ -97,7 +97,7 @@ static QJsonObject componentToJsonV1(ComponentPtr component) return obj; } -static ComponentPtr componentFromJsonV1(ComponentList * parent, const QString & componentJsonPattern, const QJsonObject &obj) +static ComponentPtr componentFromJsonV1(PackProfile * parent, const QString & componentJsonPattern, const QJsonObject &obj) { // critical auto uid = Json::requireString(obj.value("uid")); @@ -120,7 +120,7 @@ static ComponentPtr componentFromJsonV1(ComponentList * parent, const QString & } // Save the given component container data to a file -static bool saveComponentList(const QString & filename, const ComponentContainer & container) +static bool savePackProfile(const QString & filename, const ComponentContainer & container) { QJsonObject obj; obj.insert("formatVersion", currentComponentsFileVersion); @@ -153,7 +153,7 @@ static bool saveComponentList(const QString & filename, const ComponentContainer } // Read the given file into component containers -static bool loadComponentList(ComponentList * parent, const QString & filename, const QString & componentJsonPattern, ComponentContainer & container) +static bool loadPackProfile(PackProfile * parent, const QString & filename, const QString & componentJsonPattern, ComponentContainer & container) { QFile componentsFile(filename); if (!componentsFile.exists()) @@ -210,7 +210,7 @@ static bool loadComponentList(ComponentList * parent, const QString & filename, // BEGIN: save/load logic -void ComponentList::saveNow() +void PackProfile::saveNow() { if(saveIsScheduled()) { @@ -219,18 +219,18 @@ void ComponentList::saveNow() } } -bool ComponentList::saveIsScheduled() const +bool PackProfile::saveIsScheduled() const { return d->dirty; } -void ComponentList::buildingFromScratch() +void PackProfile::buildingFromScratch() { d->loaded = true; d->dirty = true; } -void ComponentList::scheduleSave() +void PackProfile::scheduleSave() { if(!d->loaded) { @@ -245,30 +245,30 @@ void ComponentList::scheduleSave() d->m_saveTimer.start(); } -QString ComponentList::componentsFilePath() const +QString PackProfile::componentsFilePath() const { return FS::PathCombine(d->m_instance->instanceRoot(), "mmc-pack.json"); } -QString ComponentList::patchesPattern() const +QString PackProfile::patchesPattern() const { return FS::PathCombine(d->m_instance->instanceRoot(), "patches", "%1.json"); } -QString ComponentList::patchFilePathForUid(const QString& uid) const +QString PackProfile::patchFilePathForUid(const QString& uid) const { return patchesPattern().arg(uid); } -void ComponentList::save_internal() +void PackProfile::save_internal() { qDebug() << "Component list save performed now for" << d->m_instance->name(); auto filename = componentsFilePath(); - saveComponentList(filename, d->components); + savePackProfile(filename, d->components); d->dirty = false; } -bool ComponentList::load() +bool PackProfile::load() { auto filename = componentsFilePath(); QFile componentsFile(filename); @@ -286,7 +286,7 @@ bool ComponentList::load() // load the new component list and swap it with the current one... ComponentContainer newComponents; - if(!loadComponentList(this, filename, patchesPattern(), newComponents)) + if(!loadPackProfile(this, filename, patchesPattern(), newComponents)) { qCritical() << "Failed to load the component config for instance" << d->m_instance->name(); return false; @@ -298,7 +298,7 @@ bool ComponentList::load() // disconnect all the old components for(auto component: d->components) { - disconnect(component.get(), &Component::dataChanged, this, &ComponentList::componentDataChanged); + disconnect(component.get(), &Component::dataChanged, this, &PackProfile::componentDataChanged); } d->components.clear(); d->componentIndex.clear(); @@ -309,7 +309,7 @@ bool ComponentList::load() qWarning() << "Ignoring duplicate component entry" << component->m_uid; continue; } - connect(component.get(), &Component::dataChanged, this, &ComponentList::componentDataChanged); + connect(component.get(), &Component::dataChanged, this, &PackProfile::componentDataChanged); d->components.append(component); d->componentIndex[component->m_uid] = component; } @@ -319,7 +319,7 @@ bool ComponentList::load() } } -void ComponentList::reload(Net::Mode netmode) +void PackProfile::reload(Net::Mode netmode) { // Do not reload when the update/resolve task is running. It is in control. if(d->m_updateTask) @@ -339,29 +339,29 @@ void ComponentList::reload(Net::Mode netmode) } } -shared_qobject_ptr ComponentList::getCurrentTask() +shared_qobject_ptr PackProfile::getCurrentTask() { return d->m_updateTask; } -void ComponentList::resolve(Net::Mode netmode) +void PackProfile::resolve(Net::Mode netmode) { auto updateTask = new ComponentUpdateTask(ComponentUpdateTask::Mode::Resolution, netmode, this); d->m_updateTask.reset(updateTask); - connect(updateTask, &ComponentUpdateTask::succeeded, this, &ComponentList::updateSucceeded); - connect(updateTask, &ComponentUpdateTask::failed, this, &ComponentList::updateFailed); + connect(updateTask, &ComponentUpdateTask::succeeded, this, &PackProfile::updateSucceeded); + connect(updateTask, &ComponentUpdateTask::failed, this, &PackProfile::updateFailed); d->m_updateTask->start(); } -void ComponentList::updateSucceeded() +void PackProfile::updateSucceeded() { qDebug() << "Component list update/resolve task succeeded for" << d->m_instance->name(); d->m_updateTask.reset(); invalidateLaunchProfile(); } -void ComponentList::updateFailed(const QString& error) +void PackProfile::updateFailed(const QString& error) { qDebug() << "Component list update/resolve task failed for" << d->m_instance->name() << "Reason:" << error; d->m_updateTask.reset(); @@ -431,7 +431,7 @@ static void upgradeDeprecatedFiles(QString root, QString instanceName) * - Part is taken from the old order.json file. * - Part is loaded from loose json files in the instance's `patches` directory. */ -bool ComponentList::migratePreComponentConfig() +bool PackProfile::migratePreComponentConfig() { // upgrade the very old files from the beginnings of MultiMC 5 upgradeDeprecatedFiles(d->m_instance->instanceRoot(), d->m_instance->name()); @@ -598,17 +598,17 @@ bool ComponentList::migratePreComponentConfig() } } // new we have a complete list of components... - return saveComponentList(componentsFilePath(), components); + return savePackProfile(componentsFilePath(), components); } // END: save/load -void ComponentList::appendComponent(ComponentPtr component) +void PackProfile::appendComponent(ComponentPtr component) { insertComponent(d->components.size(), component); } -void ComponentList::insertComponent(size_t index, ComponentPtr component) +void PackProfile::insertComponent(size_t index, ComponentPtr component) { auto id = component->getID(); if(id.isEmpty()) @@ -625,16 +625,16 @@ void ComponentList::insertComponent(size_t index, ComponentPtr component) d->components.insert(index, component); d->componentIndex[id] = component; endInsertRows(); - connect(component.get(), &Component::dataChanged, this, &ComponentList::componentDataChanged); + connect(component.get(), &Component::dataChanged, this, &PackProfile::componentDataChanged); scheduleSave(); } -void ComponentList::componentDataChanged() +void PackProfile::componentDataChanged() { auto objPtr = qobject_cast(sender()); if(!objPtr) { - qWarning() << "ComponentList got dataChenged signal from a non-Component!"; + qWarning() << "PackProfile got dataChenged signal from a non-Component!"; return; } if(objPtr->getID() == "net.minecraft") { @@ -652,10 +652,10 @@ void ComponentList::componentDataChanged() } index++; } - qWarning() << "ComponentList got dataChenged signal from a Component which does not belong to it!"; + qWarning() << "PackProfile got dataChenged signal from a Component which does not belong to it!"; } -bool ComponentList::remove(const int index) +bool PackProfile::remove(const int index) { auto patch = getComponent(index); if (!patch->isRemovable()) @@ -679,7 +679,7 @@ bool ComponentList::remove(const int index) return true; } -bool ComponentList::remove(const QString id) +bool PackProfile::remove(const QString id) { int i = 0; for (auto patch : d->components) @@ -693,7 +693,7 @@ bool ComponentList::remove(const QString id) return false; } -bool ComponentList::customize(int index) +bool PackProfile::customize(int index) { auto patch = getComponent(index); if (!patch->isCustomizable()) @@ -711,7 +711,7 @@ bool ComponentList::customize(int index) return true; } -bool ComponentList::revertToBase(int index) +bool PackProfile::revertToBase(int index) { auto patch = getComponent(index); if (!patch->isRevertible()) @@ -729,7 +729,7 @@ bool ComponentList::revertToBase(int index) return true; } -Component * ComponentList::getComponent(const QString &id) +Component * PackProfile::getComponent(const QString &id) { auto iter = d->componentIndex.find(id); if (iter == d->componentIndex.end()) @@ -739,7 +739,7 @@ Component * ComponentList::getComponent(const QString &id) return (*iter).get(); } -Component * ComponentList::getComponent(int index) +Component * PackProfile::getComponent(int index) { if(index < 0 || index >= d->components.size()) { @@ -748,7 +748,7 @@ Component * ComponentList::getComponent(int index) return d->components[index].get(); } -QVariant ComponentList::data(const QModelIndex &index, int role) const +QVariant PackProfile::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); @@ -822,7 +822,7 @@ QVariant ComponentList::data(const QModelIndex &index, int role) const return QVariant(); } -bool ComponentList::setData(const QModelIndex& index, const QVariant& value, int role) +bool PackProfile::setData(const QModelIndex& index, const QVariant& value, int role) { if (!index.isValid() || index.row() < 0 || index.row() >= rowCount(index)) { @@ -840,7 +840,7 @@ bool ComponentList::setData(const QModelIndex& index, const QVariant& value, int return false; } -QVariant ComponentList::headerData(int section, Qt::Orientation orientation, int role) const +QVariant PackProfile::headerData(int section, Qt::Orientation orientation, int role) const { if (orientation == Qt::Horizontal) { @@ -861,7 +861,7 @@ QVariant ComponentList::headerData(int section, Qt::Orientation orientation, int } // FIXME: zero precision mess -Qt::ItemFlags ComponentList::flags(const QModelIndex &index) const +Qt::ItemFlags PackProfile::flags(const QModelIndex &index) const { if (!index.isValid()) { return Qt::NoItemFlags; @@ -884,17 +884,17 @@ Qt::ItemFlags ComponentList::flags(const QModelIndex &index) const return outFlags; } -int ComponentList::rowCount(const QModelIndex &parent) const +int PackProfile::rowCount(const QModelIndex &parent) const { return d->components.size(); } -int ComponentList::columnCount(const QModelIndex &parent) const +int PackProfile::columnCount(const QModelIndex &parent) const { return NUM_COLUMNS; } -void ComponentList::move(const int index, const MoveDirection direction) +void PackProfile::move(const int index, const MoveDirection direction) { int theirIndex; if (direction == MoveUp) @@ -930,22 +930,22 @@ void ComponentList::move(const int index, const MoveDirection direction) scheduleSave(); } -void ComponentList::invalidateLaunchProfile() +void PackProfile::invalidateLaunchProfile() { d->m_profile.reset(); } -void ComponentList::installJarMods(QStringList selectedFiles) +void PackProfile::installJarMods(QStringList selectedFiles) { installJarMods_internal(selectedFiles); } -void ComponentList::installCustomJar(QString selectedFile) +void PackProfile::installCustomJar(QString selectedFile) { installCustomJar_internal(selectedFile); } -bool ComponentList::installEmpty(const QString& uid, const QString& name) +bool PackProfile::installEmpty(const QString& uid, const QString& name) { QString patchDir = FS::PathCombine(d->m_instance->instanceRoot(), "patches"); if(!FS::ensureFolderPathExists(patchDir)) @@ -973,7 +973,7 @@ bool ComponentList::installEmpty(const QString& uid, const QString& name) return true; } -bool ComponentList::removeComponent_internal(ComponentPtr patch) +bool PackProfile::removeComponent_internal(ComponentPtr patch) { bool ok = true; // first, remove the patch file. this ensures it's not used anymore @@ -1023,7 +1023,7 @@ bool ComponentList::removeComponent_internal(ComponentPtr patch) return ok; } -bool ComponentList::installJarMods_internal(QStringList filepaths) +bool PackProfile::installJarMods_internal(QStringList filepaths) { QString patchDir = FS::PathCombine(d->m_instance->instanceRoot(), "patches"); if(!FS::ensureFolderPathExists(patchDir)) @@ -1085,7 +1085,7 @@ bool ComponentList::installJarMods_internal(QStringList filepaths) return true; } -bool ComponentList::installCustomJar_internal(QString filepath) +bool PackProfile::installCustomJar_internal(QString filepath) { QString patchDir = FS::PathCombine(d->m_instance->instanceRoot(), "patches"); if(!FS::ensureFolderPathExists(patchDir)) @@ -1146,7 +1146,7 @@ bool ComponentList::installCustomJar_internal(QString filepath) return true; } -std::shared_ptr ComponentList::getProfile() const +std::shared_ptr PackProfile::getProfile() const { if(!d->m_profile) { @@ -1168,7 +1168,7 @@ std::shared_ptr ComponentList::getProfile() const return d->m_profile; } -void ComponentList::setOldConfigVersion(const QString& uid, const QString& version) +void PackProfile::setOldConfigVersion(const QString& uid, const QString& version) { if(version.isEmpty()) { @@ -1177,7 +1177,7 @@ void ComponentList::setOldConfigVersion(const QString& uid, const QString& versi d->m_oldConfigVersions[uid] = version; } -bool ComponentList::setComponentVersion(const QString& uid, const QString& version, bool important) +bool PackProfile::setComponentVersion(const QString& uid, const QString& version, bool important) { auto iter = d->componentIndex.find(uid); if(iter != d->componentIndex.end()) @@ -1203,7 +1203,7 @@ bool ComponentList::setComponentVersion(const QString& uid, const QString& versi } } -QString ComponentList::getComponentVersion(const QString& uid) const +QString PackProfile::getComponentVersion(const QString& uid) const { const auto iter = d->componentIndex.find(uid); if (iter != d->componentIndex.end()) @@ -1213,7 +1213,7 @@ QString ComponentList::getComponentVersion(const QString& uid) const return QString(); } -void ComponentList::disableInteraction(bool disable) +void PackProfile::disableInteraction(bool disable) { if(d->interactionDisabled != disable) { d->interactionDisabled = disable; diff --git a/api/logic/minecraft/ComponentList.h b/api/logic/minecraft/PackProfile.h similarity index 95% rename from api/logic/minecraft/ComponentList.h rename to api/logic/minecraft/PackProfile.h index 7b5e1385..66cd5e3e 100644 --- a/api/logic/minecraft/ComponentList.h +++ b/api/logic/minecraft/PackProfile.h @@ -31,10 +31,10 @@ #include "net/Mode.h" class MinecraftInstance; -struct ComponentListData; +struct PackProfileData; class ComponentUpdateTask; -class MULTIMC_LOGIC_EXPORT ComponentList : public QAbstractListModel +class MULTIMC_LOGIC_EXPORT PackProfile : public QAbstractListModel { Q_OBJECT friend ComponentUpdateTask; @@ -46,8 +46,8 @@ public: NUM_COLUMNS }; - explicit ComponentList(MinecraftInstance * instance); - virtual ~ComponentList(); + explicit PackProfile(MinecraftInstance * instance); + virtual ~PackProfile(); virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; @@ -146,5 +146,5 @@ private: private: /* data */ - std::unique_ptr d; + std::unique_ptr d; }; diff --git a/api/logic/minecraft/ComponentList_p.h b/api/logic/minecraft/PackProfile_p.h similarity index 93% rename from api/logic/minecraft/ComponentList_p.h rename to api/logic/minecraft/PackProfile_p.h index 7a3d498b..6cd2a4e5 100644 --- a/api/logic/minecraft/ComponentList_p.h +++ b/api/logic/minecraft/PackProfile_p.h @@ -9,9 +9,8 @@ class MinecraftInstance; using ComponentContainer = QList; using ComponentIndex = QMap; -using ConnectionList = QList; -struct ComponentListData +struct PackProfileData { // the instance this belongs to MinecraftInstance *m_instance; diff --git a/api/logic/minecraft/VersionFile.cpp b/api/logic/minecraft/VersionFile.cpp index 5bad57e9..d0a1a507 100644 --- a/api/logic/minecraft/VersionFile.cpp +++ b/api/logic/minecraft/VersionFile.cpp @@ -5,7 +5,7 @@ #include "minecraft/VersionFile.h" #include "minecraft/Library.h" -#include "minecraft/ComponentList.h" +#include "minecraft/PackProfile.h" #include "ParseUtils.h" #include diff --git a/api/logic/minecraft/VersionFile.h b/api/logic/minecraft/VersionFile.h index 29ddd0bc..b79fcd4f 100644 --- a/api/logic/minecraft/VersionFile.h +++ b/api/logic/minecraft/VersionFile.h @@ -12,7 +12,7 @@ #include "Library.h" #include -class ComponentList; +class PackProfile; class VersionFile; class LaunchProfile; struct MojangDownloadInfo; diff --git a/api/logic/minecraft/auth/YggdrasilTask.cpp b/api/logic/minecraft/auth/YggdrasilTask.cpp index 71f5d950..570fe1ea 100644 --- a/api/logic/minecraft/auth/YggdrasilTask.cpp +++ b/api/logic/minecraft/auth/YggdrasilTask.cpp @@ -25,7 +25,7 @@ #include -#include +#include #include @@ -42,7 +42,7 @@ void YggdrasilTask::executeTask() // Get the content of the request we're going to send to the server. QJsonDocument doc(getRequestContent()); - QUrl reqUrl(URLConstants::AUTH_BASE + getEndpoint()); + QUrl reqUrl(BuildConfig.AUTH_BASE + getEndpoint()); QNetworkRequest netRequest(reqUrl); netRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); diff --git a/api/logic/minecraft/launch/ModMinecraftJar.cpp b/api/logic/minecraft/launch/ModMinecraftJar.cpp index ceaad175..ba43a68d 100644 --- a/api/logic/minecraft/launch/ModMinecraftJar.cpp +++ b/api/logic/minecraft/launch/ModMinecraftJar.cpp @@ -19,7 +19,7 @@ #include "minecraft/OpSys.h" #include "FileSystem.h" #include "minecraft/MinecraftInstance.h" -#include "minecraft/ComponentList.h" +#include "minecraft/PackProfile.h" void ModMinecraftJar::executeTask() { @@ -43,7 +43,7 @@ void ModMinecraftJar::executeTask() } // create temporary modded jar, if needed - auto components = m_inst->getComponentList(); + auto components = m_inst->getPackProfile(); auto profile = components->getProfile(); auto jarMods = m_inst->getJarMods(); if(jarMods.size()) diff --git a/api/logic/minecraft/launch/ReconstructAssets.cpp b/api/logic/minecraft/launch/ReconstructAssets.cpp index af9af127..3ac320bd 100644 --- a/api/logic/minecraft/launch/ReconstructAssets.cpp +++ b/api/logic/minecraft/launch/ReconstructAssets.cpp @@ -15,7 +15,7 @@ #include "ReconstructAssets.h" #include "minecraft/MinecraftInstance.h" -#include "minecraft/ComponentList.h" +#include "minecraft/PackProfile.h" #include "minecraft/AssetsUtils.h" #include "launch/LaunchTask.h" @@ -23,7 +23,7 @@ void ReconstructAssets::executeTask() { auto instance = m_parent->instance(); std::shared_ptr minecraftInstance = std::dynamic_pointer_cast(instance); - auto components = minecraftInstance->getComponentList(); + auto components = minecraftInstance->getPackProfile(); auto profile = components->getProfile(); auto assets = profile->getMinecraftAssets(); diff --git a/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp b/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp index 9d86a7b5..a4ea60cd 100644 --- a/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp +++ b/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp @@ -6,7 +6,7 @@ #include #include "LegacyInstance.h" #include "minecraft/MinecraftInstance.h" -#include "minecraft/ComponentList.h" +#include "minecraft/PackProfile.h" #include "LegacyModList.h" #include "classparser.h" @@ -84,7 +84,7 @@ void LegacyUpgradeTask::copyFinished() } } } - auto components = inst.getComponentList(); + auto components = inst.getPackProfile(); components->buildingFromScratch(); components->setComponentVersion("net.minecraft", preferredVersionNumber, true); diff --git a/api/logic/minecraft/update/AssetUpdateTask.cpp b/api/logic/minecraft/update/AssetUpdateTask.cpp index 051b1279..e26ab4ef 100644 --- a/api/logic/minecraft/update/AssetUpdateTask.cpp +++ b/api/logic/minecraft/update/AssetUpdateTask.cpp @@ -1,7 +1,7 @@ #include "Env.h" #include "AssetUpdateTask.h" #include "minecraft/MinecraftInstance.h" -#include "minecraft/ComponentList.h" +#include "minecraft/PackProfile.h" #include "net/ChecksumValidator.h" #include "minecraft/AssetsUtils.h" @@ -17,7 +17,7 @@ AssetUpdateTask::~AssetUpdateTask() void AssetUpdateTask::executeTask() { setStatus(tr("Updating assets index...")); - auto components = m_inst->getComponentList(); + auto components = m_inst->getPackProfile(); auto profile = components->getProfile(); auto assets = profile->getMinecraftAssets(); QUrl indexUrl = assets->url; @@ -54,7 +54,7 @@ void AssetUpdateTask::assetIndexFinished() AssetsIndex index; qDebug() << m_inst->name() << ": Finished asset index download"; - auto components = m_inst->getComponentList(); + auto components = m_inst->getPackProfile(); auto profile = components->getProfile(); auto assets = profile->getMinecraftAssets(); diff --git a/api/logic/minecraft/update/FMLLibrariesTask.cpp b/api/logic/minecraft/update/FMLLibrariesTask.cpp index 52a8375b..85993e81 100644 --- a/api/logic/minecraft/update/FMLLibrariesTask.cpp +++ b/api/logic/minecraft/update/FMLLibrariesTask.cpp @@ -3,7 +3,8 @@ #include #include "FMLLibrariesTask.h" #include "minecraft/MinecraftInstance.h" -#include "minecraft/ComponentList.h" +#include "minecraft/PackProfile.h" +#include "BuildConfig.h" FMLLibrariesTask::FMLLibrariesTask(MinecraftInstance * inst) { @@ -13,7 +14,7 @@ void FMLLibrariesTask::executeTask() { // Get the mod list MinecraftInstance *inst = (MinecraftInstance *)m_inst; - auto components = inst->getComponentList(); + auto components = inst->getPackProfile(); auto profile = components->getProfile(); if (!profile->hasTrait("legacyFML")) @@ -63,7 +64,7 @@ void FMLLibrariesTask::executeTask() for (auto &lib : fmlLibsToProcess) { auto entry = metacache->resolveEntry("fmllibs", lib.filename); - QString urlString = (lib.ours ? URLConstants::FMLLIBS_OUR_BASE_URL : URLConstants::FMLLIBS_FORGE_BASE_URL) + lib.filename; + QString urlString = (lib.ours ? BuildConfig.FMLLIBS_OUR_BASE_URL : BuildConfig.FMLLIBS_FORGE_BASE_URL) + lib.filename; dljob->addNetAction(Net::Download::makeCached(QUrl(urlString), entry)); } diff --git a/api/logic/minecraft/update/LibrariesTask.cpp b/api/logic/minecraft/update/LibrariesTask.cpp index a000f77f..7f66a651 100644 --- a/api/logic/minecraft/update/LibrariesTask.cpp +++ b/api/logic/minecraft/update/LibrariesTask.cpp @@ -1,7 +1,7 @@ #include "Env.h" #include "LibrariesTask.h" #include "minecraft/MinecraftInstance.h" -#include "minecraft/ComponentList.h" +#include "minecraft/PackProfile.h" LibrariesTask::LibrariesTask(MinecraftInstance * inst) { @@ -15,7 +15,7 @@ void LibrariesTask::executeTask() MinecraftInstance *inst = (MinecraftInstance *)m_inst; // Build a list of URLs that will need to be downloaded. - auto components = inst->getComponentList(); + auto components = inst->getPackProfile(); auto profile = components->getProfile(); auto job = new NetJob(tr("Libraries for instance %1").arg(inst->name())); diff --git a/api/logic/modplatform/legacy_ftb/PackFetchTask.cpp b/api/logic/modplatform/legacy_ftb/PackFetchTask.cpp index 43c1e6f8..c2ef6436 100644 --- a/api/logic/modplatform/legacy_ftb/PackFetchTask.cpp +++ b/api/logic/modplatform/legacy_ftb/PackFetchTask.cpp @@ -2,7 +2,7 @@ #include "PrivatePackManager.h" #include -#include "net/URLConstants.h" +#include namespace LegacyFTB { @@ -13,11 +13,11 @@ void PackFetchTask::fetch() NetJob *netJob = new NetJob("LegacyFTB::ModpackFetch"); - QUrl publicPacksUrl = QUrl(URLConstants::LEGACY_FTB_CDN_BASE_URL + "static/modpacks.xml"); + QUrl publicPacksUrl = QUrl(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/modpacks.xml"); qDebug() << "Downloading public version info from" << publicPacksUrl.toString(); netJob->addNetAction(Net::Download::makeByteArray(publicPacksUrl, &publicModpacksXmlFileData)); - QUrl thirdPartyUrl = QUrl(URLConstants::LEGACY_FTB_CDN_BASE_URL + "static/thirdparty.xml"); + QUrl thirdPartyUrl = QUrl(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/thirdparty.xml"); qDebug() << "Downloading thirdparty version info from" << thirdPartyUrl.toString(); netJob->addNetAction(Net::Download::makeByteArray(thirdPartyUrl, &thirdPartyModpacksXmlFileData)); @@ -30,7 +30,7 @@ void PackFetchTask::fetch() void PackFetchTask::fetchPrivate(const QStringList & toFetch) { - QString privatePackBaseUrl = URLConstants::LEGACY_FTB_CDN_BASE_URL + "static/%1.xml"; + QString privatePackBaseUrl = BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/%1.xml"; for (auto &packCode: toFetch) { diff --git a/api/logic/modplatform/legacy_ftb/PackInstallTask.cpp b/api/logic/modplatform/legacy_ftb/PackInstallTask.cpp index ea7e2c0c..9bf6c76a 100644 --- a/api/logic/modplatform/legacy_ftb/PackInstallTask.cpp +++ b/api/logic/modplatform/legacy_ftb/PackInstallTask.cpp @@ -7,9 +7,9 @@ #include "FileSystem.h" #include "settings/INISettingsObject.h" #include "minecraft/MinecraftInstance.h" -#include "minecraft/ComponentList.h" +#include "minecraft/PackProfile.h" #include "minecraft/GradleSpecifier.h" -#include "net/URLConstants.h" +#include "BuildConfig.h" #include @@ -38,11 +38,11 @@ void PackInstallTask::downloadPack() QString url; if(m_pack.type == PackType::Private) { - url = QString(URLConstants::LEGACY_FTB_CDN_BASE_URL + "privatepacks/%1").arg(packoffset); + url = QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "privatepacks/%1").arg(packoffset); } else { - url = QString(URLConstants::LEGACY_FTB_CDN_BASE_URL + "modpacks/%1").arg(packoffset); + url = QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "modpacks/%1").arg(packoffset); } job->addNetAction(Net::Download::makeCached(url, entry)); archivePath = entry->getFullPath(); @@ -125,7 +125,7 @@ void PackInstallTask::install() instanceSettings->set("InstanceType", "OneSix"); MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath); - auto components = instance.getComponentList(); + auto components = instance.getPackProfile(); components->buildingFromScratch(); components->setComponentVersion("net.minecraft", m_pack.mcVersion, true); @@ -210,4 +210,4 @@ bool PackInstallTask::abort() return false; } -} \ No newline at end of file +} diff --git a/api/logic/net/URLConstants.cpp b/api/logic/net/URLConstants.cpp deleted file mode 100644 index 9a4d920b..00000000 --- a/api/logic/net/URLConstants.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "URLConstants.h" - -namespace URLConstants { - -QString getLegacyJarUrl(QString version) -{ - return AWS_DOWNLOAD_VERSIONS + getJarPath(version); -} - -QString getJarPath(QString version) -{ - return version + "/" + version + ".jar"; -} - - -} diff --git a/api/logic/net/URLConstants.h b/api/logic/net/URLConstants.h deleted file mode 100644 index ebc495bb..00000000 --- a/api/logic/net/URLConstants.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright 2013-2019 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include - -namespace URLConstants -{ -const QString AWS_DOWNLOAD_VERSIONS("https://s3.amazonaws.com/Minecraft.Download/versions/"); -const QString RESOURCE_BASE("https://resources.download.minecraft.net/"); -const QString LIBRARY_BASE("https://libraries.minecraft.net/"); -const QString SKINS_BASE("https://crafatar.com/skins/"); -const QString AUTH_BASE("https://authserver.mojang.com/"); -const QString MOJANG_STATUS_URL("https://status.mojang.com/check"); -const QString IMGUR_BASE_URL("https://api.imgur.com/3/"); -const QString FMLLIBS_OUR_BASE_URL("https://files.multimc.org/fmllibs/"); -const QString FMLLIBS_FORGE_BASE_URL("https://files.minecraftforge.net/fmllibs/"); -const QString TRANSLATIONS_BASE_URL("https://files.multimc.org/translations/"); - -const QString LEGACY_FTB_CDN_BASE_URL("https://dist.creeper.host/FTB2/"); - -QString getJarPath(QString version); -QString getLegacyJarUrl(QString version); -} diff --git a/api/logic/screenshots/ImgurAlbumCreation.cpp b/api/logic/screenshots/ImgurAlbumCreation.cpp index 3d32f597..ff9ec6fd 100644 --- a/api/logic/screenshots/ImgurAlbumCreation.cpp +++ b/api/logic/screenshots/ImgurAlbumCreation.cpp @@ -6,13 +6,13 @@ #include #include -#include "net/URLConstants.h" +#include "BuildConfig.h" #include "Env.h" #include ImgurAlbumCreation::ImgurAlbumCreation(QList screenshots) : NetAction(), m_screenshots(screenshots) { - m_url = URLConstants::IMGUR_BASE_URL + "album.json"; + m_url = BuildConfig.IMGUR_BASE_URL + "album.json"; m_status = Job_NotStarted; } diff --git a/api/logic/screenshots/ImgurUpload.cpp b/api/logic/screenshots/ImgurUpload.cpp index 74165869..1585b061 100644 --- a/api/logic/screenshots/ImgurUpload.cpp +++ b/api/logic/screenshots/ImgurUpload.cpp @@ -8,13 +8,13 @@ #include #include -#include "net/URLConstants.h" +#include "BuildConfig.h" #include "Env.h" #include ImgurUpload::ImgurUpload(ScreenshotPtr shot) : NetAction(), m_shot(shot) { - m_url = URLConstants::IMGUR_BASE_URL + "upload.json"; + m_url = BuildConfig.IMGUR_BASE_URL + "upload.json"; m_status = Job_NotStarted; } diff --git a/api/logic/status/StatusChecker.cpp b/api/logic/status/StatusChecker.cpp index f18ed364..2a4091c6 100644 --- a/api/logic/status/StatusChecker.cpp +++ b/api/logic/status/StatusChecker.cpp @@ -15,12 +15,12 @@ #include "StatusChecker.h" -#include - #include #include +#include + StatusChecker::StatusChecker() { @@ -43,7 +43,7 @@ void StatusChecker::reloadStatus() // qDebug() << "Reloading status."; NetJob* job = new NetJob("Status JSON"); - job->addNetAction(Net::Download::makeByteArray(URLConstants::MOJANG_STATUS_URL, &dataSink)); + job->addNetAction(Net::Download::makeByteArray(BuildConfig.MOJANG_STATUS_URL, &dataSink)); QObject::connect(job, &NetJob::succeeded, this, &StatusChecker::statusDownloadFinished); QObject::connect(job, &NetJob::failed, this, &StatusChecker::statusDownloadFailed); m_statusNetJob.reset(job); diff --git a/api/logic/translations/TranslationsModel.cpp b/api/logic/translations/TranslationsModel.cpp index a5a4fb15..adb3fa98 100644 --- a/api/logic/translations/TranslationsModel.cpp +++ b/api/logic/translations/TranslationsModel.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include "Json.h" #include "POTranslator.h" @@ -184,7 +184,8 @@ void readIndex(const QString & path, QMap& languages) int index = 1; try { - auto doc = Json::requireObject(Json::requireDocument(data)); + auto toplevel_doc = Json::requireDocument(data); + auto doc = Json::requireObject(toplevel_doc); auto file_type = Json::requireString(doc, "file_type"); if(file_type != "MMC-TRANSLATION-INDEX") { @@ -605,7 +606,7 @@ void TranslationsModel::downloadTranslation(QString key) MetaEntryPtr entry = ENV.metacache()->resolveEntry("translations", "mmc_" + key + ".qm"); entry->setStale(true); - auto dl = Net::Download::makeCached(QUrl(URLConstants::TRANSLATIONS_BASE_URL + lang->file_name), entry); + auto dl = Net::Download::makeCached(QUrl(BuildConfig.TRANSLATIONS_BASE_URL + lang->file_name), entry); auto rawHash = QByteArray::fromHex(lang->file_sha1.toLatin1()); dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawHash)); dl->m_total_progress = lang->file_size; 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 #include #include -#include +#include #include #include #include @@ -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 #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 #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/instance/ModFolderPage.cpp b/application/pages/instance/ModFolderPage.cpp index ec4bf3c9..2981ea13 100644 --- a/application/pages/instance/ModFolderPage.cpp +++ b/application/pages/instance/ModFolderPage.cpp @@ -28,7 +28,7 @@ #include "minecraft/mod/ModFolderModel.h" #include "minecraft/mod/Mod.h" #include "minecraft/VersionFilterData.h" -#include "minecraft/ComponentList.h" +#include "minecraft/PackProfile.h" #include #include @@ -244,7 +244,7 @@ bool CoreModFolderPage::shouldDisplay() const auto inst = dynamic_cast(m_inst); if (!inst) return true; - auto version = inst->getComponentList(); + auto version = inst->getPackProfile(); if (!version) return true; if(!version->getComponent("net.minecraftforge")) diff --git a/application/pages/instance/VersionPage.cpp b/application/pages/instance/VersionPage.cpp index c7a8dc30..f2d19f25 100644 --- a/application/pages/instance/VersionPage.cpp +++ b/application/pages/instance/VersionPage.cpp @@ -37,7 +37,7 @@ #include #include -#include "minecraft/ComponentList.h" +#include "minecraft/PackProfile.h" #include "minecraft/auth/MojangAccountList.h" #include "minecraft/mod/Mod.h" #include "icons/IconList.h" @@ -114,9 +114,9 @@ VersionPage::VersionPage(MinecraftInstance *inst, QWidget *parent) ui->toolBar->insertSpacer(ui->actionReload); - m_profile = m_inst->getComponentList(); + m_profile = m_inst->getPackProfile(); - reloadComponentList(); + reloadPackProfile(); auto proxy = new IconProxy(ui->packageView); proxy->setSourceModel(m_profile.get()); @@ -129,7 +129,7 @@ VersionPage::VersionPage(MinecraftInstance *inst, QWidget *parent) auto smodel = ui->packageView->selectionModel(); connect(smodel, &QItemSelectionModel::currentChanged, this, &VersionPage::packageCurrent); - connect(m_profile.get(), &ComponentList::minecraftChanged, this, &VersionPage::updateVersionControls); + connect(m_profile.get(), &PackProfile::minecraftChanged, this, &VersionPage::updateVersionControls); controlsEnabled = !m_inst->isRunning(); updateVersionControls(); preselect(0); @@ -232,7 +232,7 @@ void VersionPage::updateButtons(int row) ui->actionAdd_to_Minecraft_jar->setEnabled(controlsEnabled); } -bool VersionPage::reloadComponentList() +bool VersionPage::reloadPackProfile() { try { @@ -255,7 +255,7 @@ bool VersionPage::reloadComponentList() void VersionPage::on_actionReload_triggered() { - reloadComponentList(); + reloadPackProfile(); m_container->refreshContainer(); } @@ -270,7 +270,7 @@ void VersionPage::on_actionRemove_triggered() } } updateButtons(); - reloadComponentList(); + reloadPackProfile(); m_container->refreshContainer(); } @@ -306,7 +306,7 @@ void VersionPage::on_actionMove_up_triggered() { try { - m_profile->move(currentRow(), ComponentList::MoveUp); + m_profile->move(currentRow(), PackProfile::MoveUp); } catch (const Exception &e) { @@ -319,7 +319,7 @@ void VersionPage::on_actionMove_down_triggered() { try { - m_profile->move(currentRow(), ComponentList::MoveDown); + m_profile->move(currentRow(), PackProfile::MoveDown); } catch (const Exception &e) { @@ -357,8 +357,8 @@ void VersionPage::on_actionChange_version_triggered() VersionSelectDialog vselect(list.get(), tr("Change %1 version").arg(name), this); if (uid == "net.fabricmc.intermediary") { - vselect.setEmptyString(tr("No Fabric Loader versions are currently available.")); - vselect.setEmptyErrorString(tr("Couldn't load or download the Fabric Loader version lists!")); + vselect.setEmptyString(tr("No intermediary mappings versions are currently available.")); + vselect.setEmptyErrorString(tr("Couldn't load or download the intermediary mappings version lists!")); vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft")); } auto currentVersion = patch->getVersion(); diff --git a/application/pages/instance/VersionPage.h b/application/pages/instance/VersionPage.h index 769fe997..c95a0084 100644 --- a/application/pages/instance/VersionPage.h +++ b/application/pages/instance/VersionPage.h @@ -18,7 +18,7 @@ #include #include "minecraft/MinecraftInstance.h" -#include "minecraft/ComponentList.h" +#include "minecraft/PackProfile.h" #include "pages/BasePage.h" namespace Ui @@ -82,11 +82,11 @@ protected: QMenu * createPopupMenu() override; /// FIXME: this shouldn't be necessary! - bool reloadComponentList(); + bool reloadPackProfile(); private: Ui::VersionPage *ui; - std::shared_ptr m_profile; + std::shared_ptr m_profile; MinecraftInstance *m_inst; int currentIdx = 0; bool controlsEnabled = false; 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 #include -#include "net/URLConstants.h" +#include 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 #include -#include "net/URLConstants.h" - namespace Twitch { ListModel::ListModel(QObject *parent) : QAbstractListModel(parent) diff --git a/application/pages/modplatform/twitch/TwitchPage.ui b/application/pages/modplatform/twitch/TwitchPage.ui index 29bdc727..c78d8ce0 100644 --- a/application/pages/modplatform/twitch/TwitchPage.ui +++ b/application/pages/modplatform/twitch/TwitchPage.ui @@ -21,37 +21,6 @@ - - - - Qt::ScrollBarAlwaysOff - - - true - - - - 48 - 48 - - - - false - - - true - - - false - - - true - - - false - - - @@ -68,6 +37,22 @@ + + + + Qt::ScrollBarAlwaysOff + + + true + + + + 48 + 48 + + + + diff --git a/application/BuildConfig.cpp.in b/buildconfig/BuildConfig.cpp.in similarity index 96% rename from application/BuildConfig.cpp.in rename to buildconfig/BuildConfig.cpp.in index a1d236b2..86ea83ee 100644 --- a/application/BuildConfig.cpp.in +++ b/buildconfig/BuildConfig.cpp.in @@ -1,7 +1,7 @@ #include "BuildConfig.h" #include -Config BuildConfig; +const Config BuildConfig; Config::Config() { @@ -33,6 +33,7 @@ Config::Config() VERSION_STR = "@MultiMC_VERSION_STRING@"; NEWS_RSS_URL = "@MultiMC_NEWS_RSS_URL@"; PASTE_EE_KEY = "@MultiMC_PASTE_EE_API_KEY@"; + META_URL = "@MultiMC_META_URL@"; } QString Config::printableVersionString() const diff --git a/application/BuildConfig.h b/buildconfig/BuildConfig.h similarity index 67% rename from application/BuildConfig.h rename to buildconfig/BuildConfig.h index 77c42dd4..a80af3d2 100644 --- a/application/BuildConfig.h +++ b/buildconfig/BuildConfig.h @@ -60,6 +60,23 @@ public: */ QString PASTE_EE_KEY; + /** + * MultiMC Metadata repository URL prefix + */ + QString META_URL; + + QString RESOURCE_BASE = "https://resources.download.minecraft.net/"; + QString LIBRARY_BASE = "https://libraries.minecraft.net/"; + QString SKINS_BASE = "https://crafatar.com/skins/"; + QString AUTH_BASE = "https://authserver.mojang.com/"; + QString MOJANG_STATUS_URL = "https://status.mojang.com/check"; + QString IMGUR_BASE_URL = "https://api.imgur.com/3/"; + QString FMLLIBS_OUR_BASE_URL = "https://files.multimc.org/fmllibs/"; + QString FMLLIBS_FORGE_BASE_URL = "https://files.minecraftforge.net/fmllibs/"; + QString TRANSLATIONS_BASE_URL = "https://files.multimc.org/translations/"; + + QString LEGACY_FTB_CDN_BASE_URL = "https://dist.creeper.host/FTB2/"; + /** * \brief Converts the Version to a string. * \return The version number in string format (major.minor.revision.build). @@ -67,4 +84,4 @@ public: QString printableVersionString() const; }; -extern Config BuildConfig; +extern const Config BuildConfig; diff --git a/buildconfig/CMakeLists.txt b/buildconfig/CMakeLists.txt new file mode 100644 index 00000000..de4fd350 --- /dev/null +++ b/buildconfig/CMakeLists.txt @@ -0,0 +1,11 @@ +######## Configure the file with build properties ######## + +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/BuildConfig.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/BuildConfig.cpp") + +add_library(BuildConfig STATIC + BuildConfig.h + ${CMAKE_CURRENT_BINARY_DIR}/BuildConfig.cpp +) + +target_link_libraries(BuildConfig Qt5::Core) +target_include_directories(BuildConfig PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/libraries/libnbtplusplus b/libraries/libnbtplusplus index 92f8d572..dc72a20b 160000 --- a/libraries/libnbtplusplus +++ b/libraries/libnbtplusplus @@ -1 +1 @@ -Subproject commit 92f8d57227feb94643378ecf595626c60c0f59b8 +Subproject commit dc72a20b7efd304d12af2025223fad07b4b78464