From 4c01983f470e25dfd4c997201370057bba64832e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 23 Jul 2017 19:20:21 +0200 Subject: [PATCH] NOISSUE remove FTB integration --- api/logic/CMakeLists.txt | 12 - .../minecraft/ftb/FTBInstanceProvider.cpp | 262 ------------------ api/logic/minecraft/ftb/FTBInstanceProvider.h | 45 --- api/logic/minecraft/ftb/FTBPlugin.cpp | 115 -------- api/logic/minecraft/ftb/FTBPlugin.h | 12 - .../minecraft/ftb/FTBProfileStrategy.cpp | 134 --------- api/logic/minecraft/ftb/FTBProfileStrategy.h | 22 -- api/logic/minecraft/ftb/LegacyFTBInstance.cpp | 24 -- api/logic/minecraft/ftb/LegacyFTBInstance.h | 17 -- api/logic/minecraft/ftb/OneSixFTBInstance.cpp | 135 --------- api/logic/minecraft/ftb/OneSixFTBInstance.h | 30 -- application/MultiMC.cpp | 6 - application/pages/global/MultiMCPage.cpp | 40 --- application/pages/global/MultiMCPage.h | 3 - application/pages/global/MultiMCPage.ui | 76 +---- 15 files changed, 1 insertion(+), 932 deletions(-) delete mode 100644 api/logic/minecraft/ftb/FTBInstanceProvider.cpp delete mode 100644 api/logic/minecraft/ftb/FTBInstanceProvider.h delete mode 100644 api/logic/minecraft/ftb/FTBPlugin.cpp delete mode 100644 api/logic/minecraft/ftb/FTBPlugin.h delete mode 100644 api/logic/minecraft/ftb/FTBProfileStrategy.cpp delete mode 100644 api/logic/minecraft/ftb/FTBProfileStrategy.h delete mode 100644 api/logic/minecraft/ftb/LegacyFTBInstance.cpp delete mode 100644 api/logic/minecraft/ftb/LegacyFTBInstance.h delete mode 100644 api/logic/minecraft/ftb/OneSixFTBInstance.cpp delete mode 100644 api/logic/minecraft/ftb/OneSixFTBInstance.h diff --git a/api/logic/CMakeLists.txt b/api/logic/CMakeLists.txt index bb999619..46fcbf81 100644 --- a/api/logic/CMakeLists.txt +++ b/api/logic/CMakeLists.txt @@ -278,18 +278,6 @@ set(MINECRAFT_SOURCES minecraft/WorldList.h minecraft/WorldList.cpp - # FTB - minecraft/ftb/OneSixFTBInstance.h - minecraft/ftb/OneSixFTBInstance.cpp - minecraft/ftb/LegacyFTBInstance.h - minecraft/ftb/LegacyFTBInstance.cpp - minecraft/ftb/FTBProfileStrategy.h - minecraft/ftb/FTBProfileStrategy.cpp - minecraft/ftb/FTBInstanceProvider.cpp - minecraft/ftb/FTBInstanceProvider.h - minecraft/ftb/FTBPlugin.h - minecraft/ftb/FTBPlugin.cpp - # Flame minecraft/flame/PackManifest.h minecraft/flame/PackManifest.cpp diff --git a/api/logic/minecraft/ftb/FTBInstanceProvider.cpp b/api/logic/minecraft/ftb/FTBInstanceProvider.cpp deleted file mode 100644 index fe23a84e..00000000 --- a/api/logic/minecraft/ftb/FTBInstanceProvider.cpp +++ /dev/null @@ -1,262 +0,0 @@ -#include "FTBInstanceProvider.h" - -#include -#include -#include -#include - -#include -#include - -#include "Env.h" - -#include "LegacyFTBInstance.h" -#include "OneSixFTBInstance.h" - -inline uint qHash(FTBRecord record) -{ - return qHash(record.instanceDir); -} - -FTBInstanceProvider::FTBInstanceProvider(SettingsObjectPtr settings) - : BaseInstanceProvider(settings) -{ - // nil -} - -QList FTBInstanceProvider::discoverInstances() -{ - // nothing to load when we don't have - if (m_globalSettings->get("TrackFTBInstances").toBool() != true) - { - return {}; - } - m_records.clear(); - discoverFTBEntries(); - return m_records.keys(); -} - -InstancePtr FTBInstanceProvider::loadInstance(const InstanceId& id) -{ - // process the records we acquired. - auto iter = m_records.find(id); - if(iter == m_records.end()) - { - qWarning() << "Cannot load instance" << id << "without a record"; - return nullptr; - } - auto & record = m_records[id]; - qDebug() << "Loading FTB instance from " << record.instanceDir; - QString iconKey = record.iconKey; - auto icons = ENV.icons(); - if(icons) - { - icons->addIcon(iconKey, iconKey, FS::PathCombine(record.templateDir, record.logo), IconType::Transient); - } - auto settingsFilePath = FS::PathCombine(record.instanceDir, "instance.cfg"); - qDebug() << "ICON get!"; - - if (QFileInfo(settingsFilePath).exists()) - { - auto instPtr = loadInstance(record); - if (!instPtr) - { - qWarning() << "Couldn't load instance config:" << settingsFilePath; - if(!QFile::remove(settingsFilePath)) - { - qWarning() << "Couldn't remove broken instance config!"; - return nullptr; - } - // failed to load, but removed the poisonous file - } - else - { - return InstancePtr(instPtr); - } - } - auto instPtr = createInstance(record); - if (!instPtr) - { - qWarning() << "Couldn't create FTB instance!"; - return nullptr; - } - return InstancePtr(instPtr); -} - -void FTBInstanceProvider::discoverFTBEntries() -{ - QDir dir = QDir(m_globalSettings->get("FTBLauncherLocal").toString()); - QDir dataDir = QDir(m_globalSettings->get("FTBRoot").toString()); - if (!dataDir.exists()) - { - qDebug() << "The FTB directory specified does not exist. Please check your settings"; - return; - } - else if (!dir.exists()) - { - qDebug() << "The FTB launcher data directory specified does not exist. Please check " - "your settings"; - return; - } - dir.cd("ModPacks"); - auto allFiles = dir.entryList(QDir::Readable | QDir::Files, QDir::Name); - for (auto filename : allFiles) - { - if (!filename.endsWith(".xml")) - continue; - auto fpath = dir.absoluteFilePath(filename); - QFile f(fpath); - qDebug() << "Discovering FTB instances -- " << fpath; - if (!f.open(QFile::ReadOnly)) - continue; - - // read the FTB packs XML. - QXmlStreamReader reader(&f); - while (!reader.atEnd()) - { - switch (reader.readNext()) - { - case QXmlStreamReader::StartElement: - { - if (reader.name() == "modpack") - { - QXmlStreamAttributes attrs = reader.attributes(); - FTBRecord record; - record.dirName = attrs.value("dir").toString(); - record.instanceDir = dataDir.absoluteFilePath(record.dirName); - record.templateDir = dir.absoluteFilePath(record.dirName); - QDir test(record.instanceDir); - qDebug() << dataDir.absolutePath() << record.instanceDir << record.dirName; - if (!test.exists()) - continue; - record.name = attrs.value("name").toString(); - record.logo = attrs.value("logo").toString(); - QString logo = record.logo; - record.iconKey = logo.remove(QRegularExpression("\\..*")); - auto customVersions = attrs.value("customMCVersions"); - if (!customVersions.isNull()) - { - QMap versionMatcher; - QString customVersionsStr = customVersions.toString(); - QStringList list = customVersionsStr.split(';'); - for (auto item : list) - { - auto segment = item.split('^'); - if (segment.size() != 2) - { - qCritical() << "FTB: Segment of size < 2 in " - << customVersionsStr; - continue; - } - versionMatcher[segment[0]] = segment[1]; - } - auto actualVersion = attrs.value("version").toString(); - if (versionMatcher.contains(actualVersion)) - { - record.mcVersion = versionMatcher[actualVersion]; - } - else - { - record.mcVersion = attrs.value("mcVersion").toString(); - } - } - else - { - record.mcVersion = attrs.value("mcVersion").toString(); - } - record.description = attrs.value("description").toString(); - auto id = "FTB/" + record.dirName; - m_records[id] = record; - } - break; - } - case QXmlStreamReader::EndElement: - break; - case QXmlStreamReader::Characters: - break; - default: - break; - } - } - f.close(); - } -} - -InstancePtr FTBInstanceProvider::loadInstance(const FTBRecord & record) const -{ - InstancePtr inst; - - auto m_settings = std::make_shared(FS::PathCombine(record.instanceDir, "instance.cfg")); - m_settings->registerSetting("InstanceType", "Legacy"); - - qDebug() << "Loading existing " << record.name; - - QString inst_type = m_settings->get("InstanceType").toString(); - if (inst_type == "LegacyFTB") - { - inst.reset(new LegacyFTBInstance(m_globalSettings, m_settings, record.instanceDir)); - } - else if (inst_type == "OneSixFTB") - { - inst.reset(new OneSixFTBInstance(m_globalSettings, m_settings, record.instanceDir)); - } - else - { - return nullptr; - } - qDebug() << "Construction " << record.instanceDir; - - SettingsObject::Lock lock(inst->settings()); - inst->init(); - qDebug() << "Init " << record.instanceDir; - inst->setGroupInitial("FTB"); - /** - * FIXME: this does not respect the user's preferences. BUT, it would work nicely with the planned pack support - * -> instead of changing the user values, change pack values (defaults you can look at and revert to) - */ - /* - inst->setName(record.name); - inst->setIconKey(record.iconKey); - inst->setNotes(record.description); - */ - if (inst->intendedVersionId() != record.mcVersion) - { - inst->setIntendedVersionId(record.mcVersion); - } - qDebug() << "Loaded instance " << inst->name() << " from " << inst->instanceRoot(); - return inst; -} - -InstancePtr FTBInstanceProvider::createInstance(const FTBRecord & record) const -{ - QDir rootDir(record.instanceDir); - - InstancePtr inst; - - qDebug() << "Converting " << record.name << " as new."; - - if (!rootDir.exists() && !rootDir.mkpath(".")) - { - qCritical() << "Can't create instance folder" << record.instanceDir; - return nullptr; - } - - auto m_settings = std::make_shared(FS::PathCombine(record.instanceDir, "instance.cfg")); - m_settings->registerSetting("InstanceType", "Legacy"); - - // all legacy versions are built in. therefore we can do this even if we don't have ALL the versions Mojang has on their servers. - m_settings->set("InstanceType", "OneSixFTB"); - inst.reset(new OneSixFTBInstance(m_globalSettings, m_settings, record.instanceDir)); - - // initialize - { - SettingsObject::Lock lock(inst->settings()); - inst->setIntendedVersionId(record.mcVersion); - inst->init(); - inst->setGroupInitial("FTB"); - inst->setName(record.name); - inst->setIconKey(record.iconKey); - inst->setNotes(record.description); - } - return inst; -} diff --git a/api/logic/minecraft/ftb/FTBInstanceProvider.h b/api/logic/minecraft/ftb/FTBInstanceProvider.h deleted file mode 100644 index fb3ecb6c..00000000 --- a/api/logic/minecraft/ftb/FTBInstanceProvider.h +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once - -#include "BaseInstanceProvider.h" -#include - -class QFileSystemWatcher; - -struct MULTIMC_LOGIC_EXPORT FTBRecord -{ - QString dirName; - QString name; - QString logo; - QString iconKey; - QString mcVersion; - QString description; - QString instanceDir; - QString templateDir; - bool operator==(const FTBRecord other) const - { - return instanceDir == other.instanceDir; - } -}; - -class MULTIMC_LOGIC_EXPORT FTBInstanceProvider : public BaseInstanceProvider -{ - Q_OBJECT - -public: - FTBInstanceProvider (SettingsObjectPtr settings); - -public: - QList discoverInstances() override; - InstancePtr loadInstance(const InstanceId& id) override; - void loadGroupList() override {}; - void saveGroupList() override {}; - -private: /* methods */ - void discoverFTBEntries(); - InstancePtr createInstance(const FTBRecord & record) const; - InstancePtr loadInstance(const FTBRecord & record) const; - - -private: - QMap m_records; -}; diff --git a/api/logic/minecraft/ftb/FTBPlugin.cpp b/api/logic/minecraft/ftb/FTBPlugin.cpp deleted file mode 100644 index 541879a1..00000000 --- a/api/logic/minecraft/ftb/FTBPlugin.cpp +++ /dev/null @@ -1,115 +0,0 @@ -#include "FTBPlugin.h" -#include -#include "LegacyFTBInstance.h" -#include "OneSixFTBInstance.h" -#include -#include -#include -#include - -#include -#include - -#ifdef Q_OS_WIN32 -#include -static const int APPDATA_BUFFER_SIZE = 1024; -#endif - -static QString getLocalCacheStorageLocation() -{ - QString ftbDefault; -#ifdef Q_OS_WIN32 - wchar_t buf[APPDATA_BUFFER_SIZE]; - if (GetEnvironmentVariableW(L"LOCALAPPDATA", buf, APPDATA_BUFFER_SIZE)) // local - { - ftbDefault = QDir(QString::fromWCharArray(buf)).absoluteFilePath("ftblauncher"); - } - else if (GetEnvironmentVariableW(L"APPDATA", buf, APPDATA_BUFFER_SIZE)) // roaming - { - ftbDefault = QDir(QString::fromWCharArray(buf)).absoluteFilePath("ftblauncher"); - } - else - { - qCritical() << "Your LOCALAPPDATA and APPDATA folders are missing!" - " If you are on windows, this means your system is broken."; - } -#elif defined(Q_OS_MAC) - ftbDefault = FS::PathCombine(QDir::homePath(), "Library/Application Support/ftblauncher"); -#else - ftbDefault = QDir::home().absoluteFilePath(".ftblauncher"); -#endif - return ftbDefault; -} - - -static QString getRoamingStorageLocation() -{ - QString ftbDefault; -#ifdef Q_OS_WIN32 - wchar_t buf[APPDATA_BUFFER_SIZE]; - QString cacheStorage; - if (GetEnvironmentVariableW(L"APPDATA", buf, APPDATA_BUFFER_SIZE)) - { - ftbDefault = QDir(QString::fromWCharArray(buf)).absoluteFilePath("ftblauncher"); - } - else - { - qCritical() << "Your APPDATA folder is missing! If you are on windows, this means your system is broken."; - } -#elif defined(Q_OS_MAC) - ftbDefault = FS::PathCombine(QDir::homePath(), "Library/Application Support/ftblauncher"); -#else - ftbDefault = QDir::home().absoluteFilePath(".ftblauncher"); -#endif - return ftbDefault; -} - -void FTBPlugin::initialize(SettingsObjectPtr globalSettings) -{ - // FTB - globalSettings->registerSetting("TrackFTBInstances", false); - QString ftbRoaming = getRoamingStorageLocation(); - QString ftbLocal = getLocalCacheStorageLocation(); - - globalSettings->registerSetting("FTBLauncherRoaming", ftbRoaming); - globalSettings->registerSetting("FTBLauncherLocal", ftbLocal); - qDebug() << "FTB Launcher paths:" << globalSettings->get("FTBLauncherRoaming").toString() - << "and" << globalSettings->get("FTBLauncherLocal").toString(); - - globalSettings->registerSetting("FTBRoot"); - if (globalSettings->get("FTBRoot").isNull()) - { - QString ftbRoot; - QFile f(QDir(globalSettings->get("FTBLauncherRoaming").toString()).absoluteFilePath("ftblaunch.cfg")); - qDebug() << "Attempting to read" << f.fileName(); - if (f.open(QFile::ReadOnly)) - { - const QString data = QString::fromLatin1(f.readAll()); - QRegularExpression exp("installPath=(.*)"); - ftbRoot = QDir::cleanPath(exp.match(data).captured(1)); -#ifdef Q_OS_WIN32 - if (!ftbRoot.isEmpty()) - { - if (ftbRoot.at(0).isLetter() && ftbRoot.size() > 1 && ftbRoot.at(1) == '/') - { - ftbRoot.remove(1, 1); - } - } -#endif - if (ftbRoot.isEmpty()) - { - qDebug() << "Failed to get FTB root path"; - } - else - { - qDebug() << "FTB is installed at" << ftbRoot; - globalSettings->set("FTBRoot", ftbRoot); - } - } - else - { - qWarning() << "Couldn't open" << f.fileName() << ":" << f.errorString(); - qWarning() << "This is perfectly normal if you don't have FTB installed"; - } - } -} diff --git a/api/logic/minecraft/ftb/FTBPlugin.h b/api/logic/minecraft/ftb/FTBPlugin.h deleted file mode 100644 index e1b56545..00000000 --- a/api/logic/minecraft/ftb/FTBPlugin.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include - -#include "multimc_logic_export.h" - -// Pseudo-plugin for FTB related things. Super derpy! -class MULTIMC_LOGIC_EXPORT FTBPlugin -{ -public: - static void initialize(SettingsObjectPtr globalSettings); -}; diff --git a/api/logic/minecraft/ftb/FTBProfileStrategy.cpp b/api/logic/minecraft/ftb/FTBProfileStrategy.cpp deleted file mode 100644 index d5df7848..00000000 --- a/api/logic/minecraft/ftb/FTBProfileStrategy.cpp +++ /dev/null @@ -1,134 +0,0 @@ -#include "FTBProfileStrategy.h" -#include "OneSixFTBInstance.h" - -#include - -#include -#include -#include -#include - -FTBProfileStrategy::FTBProfileStrategy(OneSixFTBInstance* instance) : OneSixProfileStrategy(instance) -{ -} - -void FTBProfileStrategy::loadDefaultBuiltinPatches() -{ - // FIXME: this should be here, but it needs us to be able to deal with multiple libraries paths - // OneSixProfileStrategy::loadDefaultBuiltinPatches(); - auto mcVersion = m_instance->intendedVersionId(); - auto nativeInstance = dynamic_cast(m_instance); - - ProfilePatchPtr minecraftPatch; - { - std::shared_ptr< VersionFile > file; - auto mcJson = m_instance->versionsPath().absoluteFilePath(mcVersion + "/" + mcVersion + ".json"); - // load up the base minecraft patch - if(QFile::exists(mcJson)) - { - file = ProfileUtils::parseJsonFile(QFileInfo(mcJson), false); - for(auto addLib: file->libraries) - { - addLib->setHint("local"); - addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath()); - } - } - else - { - file = std::make_shared(); - file->addProblem(ProblemSeverity::Error, QObject::tr("Minecraft version is missing in the FTB data.")); - } - file->uid = "net.minecraft"; - file->name = QObject::tr("Minecraft (tracked)"); - if(file->version.isEmpty()) - { - file->version = mcVersion; - } - minecraftPatch = std::make_shared(file); - minecraftPatch->setVanilla(true); - minecraftPatch->setOrder(-2); - } - profile->appendPatch(minecraftPatch); - - ProfilePatchPtr packPatch; - { - std::shared_ptr< VersionFile > file; - auto mcJson = m_instance->minecraftRoot() + "/pack.json"; - // load up the base minecraft patch, if it's there... - if(QFile::exists(mcJson)) - { - file = ProfileUtils::parseJsonFile(QFileInfo(mcJson), false); - // adapt the loaded file - the FTB patch file format is different than ours. - file->minecraftVersion.clear(); - file->mainJar = nullptr; - for(auto addLib: file->libraries) - { - addLib->setHint("local"); - addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath()); - } - } - else - { - file = std::make_shared(); - file->addProblem(ProblemSeverity::Error, QObject::tr("Modpack version file is missing.")); - } - file->uid = "org.multimc.ftb.pack"; - file->name = QObject::tr("%1 (FTB pack)").arg(m_instance->name()); - if(file->version.isEmpty()) - { - file->version = QObject::tr("Unknown"); - QFile versionFile (FS::PathCombine(m_instance->instanceRoot(), "version")); - if(versionFile.exists()) - { - if(versionFile.open(QIODevice::ReadOnly)) - { - // FIXME: just guessing the encoding/charset here. - auto version = QString::fromUtf8(versionFile.readAll()); - file->version = version; - } - } - } - packPatch = std::make_shared(file); - packPatch->setVanilla(true); - packPatch->setOrder(1); - } - profile->appendPatch(packPatch); -} - -void FTBProfileStrategy::load() -{ - profile->clearPatches(); - - loadDefaultBuiltinPatches(); - loadUserPatches(); -} - -bool FTBProfileStrategy::saveOrder(ProfileUtils::PatchOrder order) -{ - return false; -} - -bool FTBProfileStrategy::resetOrder() -{ - return false; -} - -bool FTBProfileStrategy::installJarMods(QStringList filepaths) -{ - return false; -} - -bool FTBProfileStrategy::installCustomJar(QString filepath) -{ - return false; -} - -bool FTBProfileStrategy::customizePatch(ProfilePatchPtr patch) -{ - return false; -} - -bool FTBProfileStrategy::revertPatch(ProfilePatchPtr patch) -{ - return false; -} diff --git a/api/logic/minecraft/ftb/FTBProfileStrategy.h b/api/logic/minecraft/ftb/FTBProfileStrategy.h deleted file mode 100644 index 4637d04b..00000000 --- a/api/logic/minecraft/ftb/FTBProfileStrategy.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include "minecraft/ProfileStrategy.h" -#include "minecraft/onesix/OneSixProfileStrategy.h" - -class OneSixFTBInstance; - -class FTBProfileStrategy : public OneSixProfileStrategy -{ -public: - FTBProfileStrategy(OneSixFTBInstance * instance); - virtual ~FTBProfileStrategy() {}; - void load() override; - bool resetOrder() override; - bool saveOrder(ProfileUtils::PatchOrder order) override; - bool installJarMods(QStringList filepaths) override; - bool installCustomJar(QString filepath) override; - bool customizePatch (ProfilePatchPtr patch) override; - bool revertPatch (ProfilePatchPtr patch) override; - -protected: - void loadDefaultBuiltinPatches() override; -}; diff --git a/api/logic/minecraft/ftb/LegacyFTBInstance.cpp b/api/logic/minecraft/ftb/LegacyFTBInstance.cpp deleted file mode 100644 index 63412a33..00000000 --- a/api/logic/minecraft/ftb/LegacyFTBInstance.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "LegacyFTBInstance.h" -#include -#include - -LegacyFTBInstance::LegacyFTBInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir) : - LegacyInstance(globalSettings, settings, rootDir) -{ -} - -QString LegacyFTBInstance::id() const -{ - return "FTB/" + BaseInstance::id(); -} - -void LegacyFTBInstance::copy(SettingsObjectPtr newSettings, const QDir& newDir) -{ - // set the target instance to be plain Legacy - newSettings->set("InstanceType", "Legacy"); -} - -QString LegacyFTBInstance::typeName() const -{ - return tr("Legacy FTB"); -} diff --git a/api/logic/minecraft/ftb/LegacyFTBInstance.h b/api/logic/minecraft/ftb/LegacyFTBInstance.h deleted file mode 100644 index 2f2e34a2..00000000 --- a/api/logic/minecraft/ftb/LegacyFTBInstance.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "minecraft/legacy/LegacyInstance.h" - -class LegacyFTBInstance : public LegacyInstance -{ - Q_OBJECT -public: - explicit LegacyFTBInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir); - QString id() const override; - void copy(SettingsObjectPtr newSettings, const QDir &newDir) override; - QString typeName() const override; - bool canExport() const override - { - return false; - } -}; diff --git a/api/logic/minecraft/ftb/OneSixFTBInstance.cpp b/api/logic/minecraft/ftb/OneSixFTBInstance.cpp deleted file mode 100644 index edf31eb7..00000000 --- a/api/logic/minecraft/ftb/OneSixFTBInstance.cpp +++ /dev/null @@ -1,135 +0,0 @@ -#include "OneSixFTBInstance.h" -#include "FTBProfileStrategy.h" - -#include "minecraft/MinecraftProfile.h" -#include "minecraft/GradleSpecifier.h" -#include "tasks/SequentialTask.h" -#include -#include - -#include - -OneSixFTBInstance::OneSixFTBInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir) : - OneSixInstance(globalSettings, settings, rootDir) -{ - m_globalSettings = globalSettings; -} - -void OneSixFTBInstance::copy(SettingsObjectPtr newSettings, const QDir &newDir) -{ - QStringList libraryNames; - // create patch file - { - qDebug()<< "Creating patch file for FTB instance..."; - QFile f(minecraftRoot() + "/pack.json"); - if (!f.open(QFile::ReadOnly)) - { - qCritical() << "Couldn't open" << f.fileName() << ":" << f.errorString(); - return; - } - QJsonObject root = QJsonDocument::fromJson(f.readAll()).object(); - QJsonArray libs = root.value("libraries").toArray(); - QJsonArray outLibs; - for (auto lib : libs) - { - QJsonObject libObj = lib.toObject(); - libObj.insert("MMC-hint", QString("local")); - libObj.insert("insert", QString("prepend")); - libraryNames.append(libObj.value("name").toString()); - outLibs.append(libObj); - } - root.remove("libraries"); - root.remove("id"); - - // HACK HACK HACK HACK - // A workaround for a problem in MultiMC, triggered by a historical problem in FTB, - // triggered by Mojang getting their library versions wrong in 1.7.10 - if(intendedVersionId() == "1.7.10") - { - auto insert = [&outLibs, &libraryNames](QString name) - { - QJsonObject libObj; - libObj.insert("insert", QString("replace")); - libObj.insert("name", name); - libraryNames.push_back(name); - outLibs.prepend(libObj); - }; - insert("com.google.guava:guava:16.0"); - insert("org.apache.commons:commons-lang3:3.2.1"); - } - root.insert("+libraries", outLibs); - root.insert("order", 1); - root.insert("fileId", QString("org.multimc.ftb.pack.json")); - root.insert("name", name()); - root.insert("mcVersion", intendedVersionId()); - root.insert("version", intendedVersionId()); - FS::ensureFilePathExists(newDir.absoluteFilePath("patches/ftb.json")); - QFile out(newDir.absoluteFilePath("patches/ftb.json")); - if (!out.open(QFile::WriteOnly | QFile::Truncate)) - { - qCritical() << "Couldn't open" << out.fileName() << ":" << out.errorString(); - return; - } - out.write(QJsonDocument(root).toJson()); - } - // copy libraries - { - qDebug() << "Copying FTB libraries"; - for (auto library : libraryNames) - { - GradleSpecifier lib(library); - const QString out = QDir::current().absoluteFilePath("libraries/" + lib.toPath()); - if (QFile::exists(out)) - { - continue; - } - if (!FS::ensureFilePathExists(out)) - { - qCritical() << "Couldn't create folder structure for" << out; - } - if (!QFile::copy(librariesPath().absoluteFilePath(lib.toPath()), out)) - { - qCritical() << "Couldn't copy" << QString(lib); - } - } - } - // now set the target instance to be plain OneSix - newSettings->set("InstanceType", "OneSix"); -} - -QString OneSixFTBInstance::id() const -{ - return "FTB/" + BaseInstance::id(); -} - -QDir OneSixFTBInstance::librariesPath() const -{ - return QDir(m_globalSettings->get("FTBRoot").toString() + "/libraries"); -} - -QDir OneSixFTBInstance::versionsPath() const -{ - return QDir(m_globalSettings->get("FTBRoot").toString() + "/versions"); -} - -bool OneSixFTBInstance::providesVersionFile() const -{ - return true; -} - -void OneSixFTBInstance::createProfile() -{ - m_profile.reset(new MinecraftProfile(new FTBProfileStrategy(this))); -} - -shared_qobject_ptr OneSixFTBInstance::createUpdateTask() -{ - return OneSixInstance::createUpdateTask(); -} - -QString OneSixFTBInstance::typeName() const -{ - return tr("OneSix FTB"); -} - -#include "OneSixFTBInstance.moc" diff --git a/api/logic/minecraft/ftb/OneSixFTBInstance.h b/api/logic/minecraft/ftb/OneSixFTBInstance.h deleted file mode 100644 index 640f609c..00000000 --- a/api/logic/minecraft/ftb/OneSixFTBInstance.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include "minecraft/onesix/OneSixInstance.h" - -class OneSixFTBInstance : public OneSixInstance -{ - Q_OBJECT -public: - explicit OneSixFTBInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir); - virtual ~OneSixFTBInstance(){}; - - void copy(SettingsObjectPtr newSettings, const QDir &newDir) override; - - virtual void createProfile() override; - - virtual shared_qobject_ptr createUpdateTask() override; - - virtual QString id() const override; - - QDir librariesPath() const override; - QDir versionsPath() const override; - bool providesVersionFile() const override; - virtual QString typeName() const override; - bool canExport() const override - { - return false; - } -private: - SettingsObjectPtr m_globalSettings; -}; diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index 4eec3927..6a01795d 100644 --- a/application/MultiMC.cpp +++ b/application/MultiMC.cpp @@ -36,7 +36,6 @@ #include "dialogs/CustomMessageBox.h" #include "InstanceList.h" #include "FolderInstanceProvider.h" -#include "minecraft/ftb/FTBInstanceProvider.h" #include #include "icons/IconList.h" @@ -58,8 +57,6 @@ #include "translations/TranslationsModel.h" -#include "minecraft/ftb/FTBPlugin.h" - #include #include #include @@ -427,8 +424,6 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv) m_settings->registerSetting("ConsoleMaxLines", 100000); m_settings->registerSetting("ConsoleOverflowStop", true); - FTBPlugin::initialize(m_settings); - // Folders m_settings->registerSetting("InstanceDir", "instances"); m_settings->registerSetting({"CentralModsDir", "ModsDir"}, "mods"); @@ -600,7 +595,6 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv) m_instanceFolder = new FolderInstanceProvider(m_settings, instDir); connect(InstDirSetting.get(), &Setting::SettingChanged, m_instanceFolder, &FolderInstanceProvider::on_InstFolderChanged); m_instances->addInstanceProvider(m_instanceFolder); - m_instances->addInstanceProvider(new FTBInstanceProvider(m_settings)); qDebug() << "Loading Instances..."; m_instances->loadList(true); qDebug() << "<> Instances loaded."; diff --git a/application/pages/global/MultiMCPage.cpp b/application/pages/global/MultiMCPage.cpp index 4073f6b7..29075778 100644 --- a/application/pages/global/MultiMCPage.cpp +++ b/application/pages/global/MultiMCPage.cpp @@ -21,7 +21,6 @@ #include #include -#include #include "updater/UpdateChecker.h" #include "settings/SettingsObject.h" @@ -49,10 +48,6 @@ MultiMCPage::MultiMCPage(QWidget *parent) : QWidget(parent), ui(new Ui::MultiMCP ui->sortingModeGroup->setId(ui->sortByNameBtn, Sort_Name); ui->sortingModeGroup->setId(ui->sortLastLaunchedBtn, Sort_LastLaunch); - auto resizer = new ColumnResizer(this); - resizer->addWidgetsFromLayout(ui->groupBox->layout(), 1); - resizer->addWidgetsFromLayout(ui->foldersBox->layout(), 1); - defaultFormat = new QTextCharFormat(ui->fontPreview->currentCharFormat()); m_languageModel = MMC->translations(); @@ -97,31 +92,6 @@ bool MultiMCPage::apply() return true; } -void MultiMCPage::on_ftbLauncherBrowseBtn_clicked() -{ - QString raw_dir = QFileDialog::getExistingDirectory(this, tr("FTB Launcher Folder"), - ui->ftbLauncherBox->text()); - QString cooked_dir = FS::NormalizePath(raw_dir); - - // do not allow current dir - it's dirty. Do not allow dirs that don't exist - if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists()) - { - ui->ftbLauncherBox->setText(cooked_dir); - } -} -void MultiMCPage::on_ftbBrowseBtn_clicked() -{ - QString raw_dir = - QFileDialog::getExistingDirectory(this, tr("FTB Folder"), ui->ftbBox->text()); - QString cooked_dir = FS::NormalizePath(raw_dir); - - // do not allow current dir - it's dirty. Do not allow dirs that don't exist - if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists()) - { - ui->ftbBox->setText(cooked_dir); - } -} - void MultiMCPage::on_instDirBrowseBtn_clicked() { QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Instance Folder"), @@ -346,11 +316,6 @@ void MultiMCPage::applySettings() s->set("ConsoleMaxLines", ui->lineLimitSpinBox->value()); s->set("ConsoleOverflowStop", ui->checkStopLogging->checkState() != Qt::Unchecked); - // FTB - s->set("TrackFTBInstances", ui->trackFtbBox->isChecked()); - s->set("FTBLauncherLocal", FS::NormalizePath(ui->ftbLauncherBox->text())); - s->set("FTBRoot", FS::NormalizePath(ui->ftbBox->text())); - // Folders // TODO: Offer to move instances to new instance folder. s->set("InstanceDir", ui->instDirTextBox->text()); @@ -457,11 +422,6 @@ void MultiMCPage::loadSettings() ui->lineLimitSpinBox->setValue(s->get("ConsoleMaxLines").toInt()); ui->checkStopLogging->setChecked(s->get("ConsoleOverflowStop").toBool()); - // FTB - ui->trackFtbBox->setChecked(s->get("TrackFTBInstances").toBool()); - ui->ftbLauncherBox->setText(s->get("FTBLauncherLocal").toString()); - ui->ftbBox->setText(s->get("FTBRoot").toString()); - // Folders ui->instDirTextBox->setText(s->get("InstanceDir").toString()); ui->modsDirTextBox->setText(s->get("CentralModsDir").toString()); diff --git a/application/pages/global/MultiMCPage.h b/application/pages/global/MultiMCPage.h index 98eb353d..d18d70d6 100644 --- a/application/pages/global/MultiMCPage.h +++ b/application/pages/global/MultiMCPage.h @@ -64,9 +64,6 @@ private: private slots: - void on_ftbLauncherBrowseBtn_clicked(); - void on_ftbBrowseBtn_clicked(); - void on_instDirBrowseBtn_clicked(); void on_modsDirBrowseBtn_clicked(); void on_lwjglDirBrowseBtn_clicked(); diff --git a/application/pages/global/MultiMCPage.ui b/application/pages/global/MultiMCPage.ui index 0b966876..cf434631 100644 --- a/application/pages/global/MultiMCPage.ui +++ b/application/pages/global/MultiMCPage.ui @@ -7,7 +7,7 @@ 0 0 467 - 614 + 629 @@ -88,75 +88,6 @@ - - - - FTB - - - - - - &Launcher: - - - ftbLauncherBox - - - - - - - false - - - - - - - - - - Files: - - - ftbBox - - - - - - - true - - - ... - - - - - - - false - - - Qt::TabFocus - - - ... - - - - - - - Track FTB instances - - - - - - @@ -645,11 +576,6 @@ tabWidget autoUpdateCheckBox updateChannelComboBox - trackFtbBox - ftbLauncherBox - ftbLauncherBrowseBtn - ftbBox - ftbBrowseBtn instDirTextBox instDirBrowseBtn modsDirTextBox