From d313e9ab09639346526b75c92498188753cb5b87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 2 Feb 2015 01:09:28 +0100 Subject: SCRATCH remove remaining references to MultiMC.h and fix legacy LWJGL --- logic/ftb/FTBPlugin.cpp | 52 +++++++++++++++++++--------------------- logic/ftb/FTBPlugin.h | 4 ++-- logic/ftb/FTBProfileStrategy.cpp | 2 -- logic/ftb/OneSixFTBInstance.cpp | 6 ++--- logic/ftb/OneSixFTBInstance.h | 2 ++ 5 files changed, 32 insertions(+), 34 deletions(-) (limited to 'logic/ftb') diff --git a/logic/ftb/FTBPlugin.cpp b/logic/ftb/FTBPlugin.cpp index 1e9d9123..de04e485 100644 --- a/logic/ftb/FTBPlugin.cpp +++ b/logic/ftb/FTBPlugin.cpp @@ -7,7 +7,6 @@ #include #include #include -#include "MultiMC.h" #include #include "QDebug" #include @@ -33,11 +32,11 @@ inline uint qHash(FTBRecord record) return qHash(record.instanceDir); } -QSet discoverFTBInstances() +QSet discoverFTBInstances(SettingsObjectPtr globalSettings) { QSet records; - QDir dir = QDir(MMC->settings()->get("FTBLauncherDataRoot").toString()); - QDir dataDir = QDir(MMC->settings()->get("FTBRoot").toString()); + QDir dir = QDir(globalSettings->get("FTBLauncherDataRoot").toString()); + QDir dataDir = QDir(globalSettings->get("FTBRoot").toString()); if (!dataDir.exists()) { qDebug() << "The FTB directory specified does not exist. Please check your settings"; @@ -131,7 +130,7 @@ QSet discoverFTBInstances() return records; } -InstancePtr loadInstance(const QString &instDir) +InstancePtr loadInstance(SettingsObjectPtr globalSettings, const QString &instDir) { auto m_settings = std::make_shared(PathCombine(instDir, "instance.cfg")); @@ -143,17 +142,17 @@ InstancePtr loadInstance(const QString &instDir) if (inst_type == "LegacyFTB") { - inst.reset(new LegacyFTBInstance(MMC->settings(), m_settings, instDir)); + inst.reset(new LegacyFTBInstance(globalSettings, m_settings, instDir)); } else if (inst_type == "OneSixFTB") { - inst.reset(new OneSixFTBInstance(MMC->settings(), m_settings, instDir)); + inst.reset(new OneSixFTBInstance(globalSettings, m_settings, instDir)); } inst->init(); return inst; } -InstancePtr createInstance(MinecraftVersionPtr version, const QString &instDir) +InstancePtr createInstance(SettingsObjectPtr globalSettings, MinecraftVersionPtr version, const QString &instDir) { QDir rootDir(instDir); @@ -178,28 +177,28 @@ InstancePtr createInstance(MinecraftVersionPtr version, const QString &instDir) if (version->usesLegacyLauncher()) { m_settings->set("InstanceType", "LegacyFTB"); - inst.reset(new LegacyFTBInstance(MMC->settings(),m_settings, instDir)); + inst.reset(new LegacyFTBInstance(globalSettings, m_settings, instDir)); inst->setIntendedVersionId(version->descriptor()); } else { m_settings->set("InstanceType", "OneSixFTB"); - inst.reset(new OneSixFTBInstance(MMC->settings(),m_settings, instDir)); + inst.reset(new OneSixFTBInstance(globalSettings, m_settings, instDir)); inst->setIntendedVersionId(version->descriptor()); inst->init(); } return inst; } -void FTBPlugin::loadInstances(QMap &groupMap, QList &tempList) +void FTBPlugin::loadInstances(SettingsObjectPtr globalSettings, QMap &groupMap, QList &tempList) { // nothing to load when we don't have - if (MMC->settings()->get("TrackFTBInstances").toBool() != true) + if (globalSettings->get("TrackFTBInstances").toBool() != true) { return; } - auto records = discoverFTBInstances(); + auto records = discoverFTBInstances(globalSettings); if (!records.size()) { qDebug() << "No FTB instances to load."; @@ -218,7 +217,7 @@ void FTBPlugin::loadInstances(QMap &groupMap, QList(MMC->minecraftlist()->findVersion(record.mcVersion)); + auto mcVersion = std::dynamic_pointer_cast(ENV.getVersion("net.minecraft", record.mcVersion)); if (!mcVersion) { qCritical() << "Can't load instance " << record.instanceDir @@ -227,7 +226,7 @@ void FTBPlugin::loadInstances(QMap &groupMap, QList &groupMap, QList &groupMap, QListsettings(); // FTB - m_settings->registerSetting("TrackFTBInstances", false); + globalSettings->registerSetting("TrackFTBInstances", false); QString ftbDataDefault; #ifdef Q_OS_LINUX QString ftbDefault = ftbDataDefault = QDir::home().absoluteFilePath(".ftblauncher"); @@ -315,16 +313,16 @@ void FTBPlugin::initialize() QString ftbDefault = ftbDataDefault = PathCombine(QDir::homePath(), "Library/Application Support/ftblauncher"); #endif - m_settings->registerSetting("FTBLauncherDataRoot", ftbDataDefault); - m_settings->registerSetting("FTBLauncherRoot", ftbDefault); - qDebug() << "FTB Launcher paths:" << m_settings->get("FTBLauncherDataRoot").toString() - << "and" << m_settings->get("FTBLauncherRoot").toString(); + globalSettings->registerSetting("FTBLauncherDataRoot", ftbDataDefault); + globalSettings->registerSetting("FTBLauncherRoot", ftbDefault); + qDebug() << "FTB Launcher paths:" << globalSettings->get("FTBLauncherDataRoot").toString() + << "and" << globalSettings->get("FTBLauncherRoot").toString(); - m_settings->registerSetting("FTBRoot"); - if (m_settings->get("FTBRoot").isNull()) + globalSettings->registerSetting("FTBRoot"); + if (globalSettings->get("FTBRoot").isNull()) { QString ftbRoot; - QFile f(QDir(m_settings->get("FTBLauncherRoot").toString()) + QFile f(QDir(globalSettings->get("FTBLauncherRoot").toString()) .absoluteFilePath("ftblaunch.cfg")); qDebug() << "Attempting to read" << f.fileName(); if (f.open(QFile::ReadOnly)) @@ -348,7 +346,7 @@ void FTBPlugin::initialize() else { qDebug() << "FTB is installed at" << ftbRoot; - m_settings->set("FTBRoot", ftbRoot); + globalSettings->set("FTBRoot", ftbRoot); } } else diff --git a/logic/ftb/FTBPlugin.h b/logic/ftb/FTBPlugin.h index cb309355..8a38e2bb 100644 --- a/logic/ftb/FTBPlugin.h +++ b/logic/ftb/FTBPlugin.h @@ -6,6 +6,6 @@ class FTBPlugin { public: - static void initialize(); - static void loadInstances(QMap &groupMap, QList &tempList); + static void initialize(SettingsObjectPtr globalSettings); + static void loadInstances(SettingsObjectPtr globalSettings, QMap &groupMap, QList &tempList); }; diff --git a/logic/ftb/FTBProfileStrategy.cpp b/logic/ftb/FTBProfileStrategy.cpp index 20feba61..d5b3c90f 100644 --- a/logic/ftb/FTBProfileStrategy.cpp +++ b/logic/ftb/FTBProfileStrategy.cpp @@ -3,8 +3,6 @@ #include "logic/ftb/OneSixFTBInstance.h" #include "logic/minecraft/MinecraftVersionList.h" -#include "MultiMC.h" - #include #include #include diff --git a/logic/ftb/OneSixFTBInstance.cpp b/logic/ftb/OneSixFTBInstance.cpp index 8d290a94..4de2ce78 100644 --- a/logic/ftb/OneSixFTBInstance.cpp +++ b/logic/ftb/OneSixFTBInstance.cpp @@ -8,12 +8,12 @@ #include "logic/forge/ForgeInstaller.h" #include "logic/forge/ForgeVersionList.h" #include -#include "MultiMC.h" #include "pathutils.h" OneSixFTBInstance::OneSixFTBInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir) : OneSixInstance(globalSettings, settings, rootDir) { + m_globalSettings = globalSettings; } void OneSixFTBInstance::copy(const QDir &newDir) @@ -108,12 +108,12 @@ QString OneSixFTBInstance::id() const QDir OneSixFTBInstance::librariesPath() const { - return QDir(MMC->settings()->get("FTBRoot").toString() + "/libraries"); + return QDir(m_globalSettings->get("FTBRoot").toString() + "/libraries"); } QDir OneSixFTBInstance::versionsPath() const { - return QDir(MMC->settings()->get("FTBRoot").toString() + "/versions"); + return QDir(m_globalSettings->get("FTBRoot").toString() + "/versions"); } bool OneSixFTBInstance::providesVersionFile() const diff --git a/logic/ftb/OneSixFTBInstance.h b/logic/ftb/OneSixFTBInstance.h index 2b0e13d5..d5cdc362 100644 --- a/logic/ftb/OneSixFTBInstance.h +++ b/logic/ftb/OneSixFTBInstance.h @@ -24,4 +24,6 @@ public: QDir librariesPath() const override; QDir versionsPath() const override; bool providesVersionFile() const override; +private: + SettingsObjectPtr m_globalSettings; }; -- cgit v1.2.3