diff options
author | Petr Mrázek <peterix@gmail.com> | 2015-02-02 01:09:28 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2015-04-12 20:57:17 +0200 |
commit | d313e9ab09639346526b75c92498188753cb5b87 (patch) | |
tree | 1df78fb6150b77a705b48aa3af0a845131000309 /logic/ftb | |
parent | 382ae78a0bf75892827321b052c6afbd195476bc (diff) | |
download | MultiMC-d313e9ab09639346526b75c92498188753cb5b87.tar MultiMC-d313e9ab09639346526b75c92498188753cb5b87.tar.gz MultiMC-d313e9ab09639346526b75c92498188753cb5b87.tar.lz MultiMC-d313e9ab09639346526b75c92498188753cb5b87.tar.xz MultiMC-d313e9ab09639346526b75c92498188753cb5b87.zip |
SCRATCH remove remaining references to MultiMC.h and fix legacy LWJGL
Diffstat (limited to 'logic/ftb')
-rw-r--r-- | logic/ftb/FTBPlugin.cpp | 52 | ||||
-rw-r--r-- | logic/ftb/FTBPlugin.h | 4 | ||||
-rw-r--r-- | logic/ftb/FTBProfileStrategy.cpp | 2 | ||||
-rw-r--r-- | logic/ftb/OneSixFTBInstance.cpp | 6 | ||||
-rw-r--r-- | logic/ftb/OneSixFTBInstance.h | 2 |
5 files changed, 32 insertions, 34 deletions
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 <logic/InstanceList.h> #include <logic/minecraft/MinecraftVersionList.h> #include <logic/settings/INISettingsObject.h> -#include "MultiMC.h" #include <pathutils.h> #include "QDebug" #include <QXmlStreamReader> @@ -33,11 +32,11 @@ inline uint qHash(FTBRecord record) return qHash(record.instanceDir); } -QSet<FTBRecord> discoverFTBInstances() +QSet<FTBRecord> discoverFTBInstances(SettingsObjectPtr globalSettings) { QSet<FTBRecord> 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<FTBRecord> discoverFTBInstances() return records; } -InstancePtr loadInstance(const QString &instDir) +InstancePtr loadInstance(SettingsObjectPtr globalSettings, const QString &instDir) { auto m_settings = std::make_shared<INISettingsObject>(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<QString, QString> &groupMap, QList<InstancePtr> &tempList) +void FTBPlugin::loadInstances(SettingsObjectPtr globalSettings, QMap<QString, QString> &groupMap, QList<InstancePtr> &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<QString, QString> &groupMap, QList<InstancePt if (!QFileInfo(PathCombine(record.instanceDir, "instance.cfg")).exists()) { qDebug() << "Converting " << record.name << " as new."; - auto mcVersion = std::dynamic_pointer_cast<MinecraftVersion>(MMC->minecraftlist()->findVersion(record.mcVersion)); + auto mcVersion = std::dynamic_pointer_cast<MinecraftVersion>(ENV.getVersion("net.minecraft", record.mcVersion)); if (!mcVersion) { qCritical() << "Can't load instance " << record.instanceDir @@ -227,7 +226,7 @@ void FTBPlugin::loadInstances(QMap<QString, QString> &groupMap, QList<InstancePt continue; } - auto instPtr = createInstance(mcVersion, record.instanceDir); + auto instPtr = createInstance(globalSettings, mcVersion, record.instanceDir); if (!instPtr) { continue; @@ -245,7 +244,7 @@ void FTBPlugin::loadInstances(QMap<QString, QString> &groupMap, QList<InstancePt else { qDebug() << "Loading existing " << record.name; - auto instPtr = loadInstance(record.instanceDir); + auto instPtr = loadInstance(globalSettings, record.instanceDir); if (!instPtr) { continue; @@ -270,11 +269,10 @@ void FTBPlugin::loadInstances(QMap<QString, QString> &groupMap, QList<InstancePt static const int APPDATA_BUFFER_SIZE = 1024; #endif -void FTBPlugin::initialize() +void FTBPlugin::initialize(SettingsObjectPtr globalSettings) { - auto m_settings = MMC->settings(); // 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<QString, QString> &groupMap, QList<InstancePtr> &tempList); + static void initialize(SettingsObjectPtr globalSettings); + static void loadInstances(SettingsObjectPtr globalSettings, QMap<QString, QString> &groupMap, QList<InstancePtr> &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 <pathutils.h> #include <QDir> #include <QUuid> 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 <logic/settings/INISettingsObject.h> -#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; }; |