summaryrefslogtreecommitdiffstats
path: root/logic
diff options
context:
space:
mode:
Diffstat (limited to 'logic')
-rw-r--r--logic/BaseInstance.cpp1
-rw-r--r--logic/Env.cpp92
-rw-r--r--logic/Env.h11
-rw-r--r--logic/InstanceList.cpp3
-rw-r--r--logic/LegacyInstance.cpp10
-rw-r--r--logic/LegacyInstance.h6
-rw-r--r--logic/LegacyUpdate.cpp7
-rw-r--r--logic/LwjglVersionList.cpp17
-rw-r--r--logic/LwjglVersionList.h42
-rw-r--r--logic/OneSixInstance.cpp1
-rw-r--r--logic/OneSixUpdate.cpp6
-rw-r--r--logic/ftb/FTBPlugin.cpp52
-rw-r--r--logic/ftb/FTBPlugin.h4
-rw-r--r--logic/ftb/FTBProfileStrategy.cpp2
-rw-r--r--logic/ftb/OneSixFTBInstance.cpp6
-rw-r--r--logic/ftb/OneSixFTBInstance.h2
-rw-r--r--logic/java/JavaChecker.cpp23
-rw-r--r--logic/java/JavaCheckerJob.cpp1
-rw-r--r--logic/java/JavaUtils.cpp2
-rw-r--r--logic/java/JavaVersionList.cpp1
-rw-r--r--logic/liteloader/LiteLoaderInstaller.cpp1
-rw-r--r--logic/minecraft/MinecraftInstance.cpp5
-rw-r--r--logic/minecraft/MinecraftProcess.cpp2
-rw-r--r--logic/minecraft/MinecraftVersion.cpp1
-rw-r--r--logic/minecraft/OneSixProfileStrategy.cpp6
-rw-r--r--logic/net/NetJob.cpp1
26 files changed, 197 insertions, 108 deletions
diff --git a/logic/BaseInstance.cpp b/logic/BaseInstance.cpp
index a5fb5f81..11b17bca 100644
--- a/logic/BaseInstance.cpp
+++ b/logic/BaseInstance.cpp
@@ -13,7 +13,6 @@
* limitations under the License.
*/
-#include "MultiMC.h"
#include "BaseInstance.h"
#include <QFileInfo>
diff --git a/logic/Env.cpp b/logic/Env.cpp
index f10f1951..7ca206f2 100644
--- a/logic/Env.cpp
+++ b/logic/Env.cpp
@@ -1,13 +1,19 @@
#include "Env.h"
#include "logic/net/HttpMetaCache.h"
#include "icons/IconList.h"
+#include "BaseVersion.h"
+#include "BaseVersionList.h"
#include <QDir>
#include <QNetworkProxy>
#include <QNetworkAccessManager>
#include "logger/QsLog.h"
-
+#include "logic/tasks/Task.h"
#include <QDebug>
+/*
+ * The *NEW* global rat nest of an object. Handle with care.
+ */
+
Env::Env()
{
m_qnam = std::make_shared<QNetworkAccessManager>();
@@ -17,6 +23,8 @@ void Env::destroy()
{
m_metacache.reset();
m_qnam.reset();
+ m_icons.reset();
+ m_versionLists.clear();
}
Env& Env::Env::getInstance()
@@ -41,6 +49,86 @@ std::shared_ptr<IconList> Env::icons()
Q_ASSERT(m_icons != nullptr);
return m_icons;
}
+/*
+class NullVersion : public BaseVersion
+{
+ Q_OBJECT
+public:
+ virtual QString name()
+ {
+ return "null";
+ }
+ virtual QString descriptor()
+ {
+ return "null";
+ }
+ virtual QString typeString() const
+ {
+ return "Null";
+ }
+};
+
+class NullTask: public Task
+{
+ Q_OBJECT
+public:
+ virtual void executeTask()
+ {
+ emitFailed(tr("Nothing to do."));
+ }
+};
+
+class NullVersionList: public BaseVersionList
+{
+ Q_OBJECT
+public:
+ virtual const BaseVersionPtr at(int i) const
+ {
+ return std::make_shared<NullVersion>();
+ }
+ virtual int count() const
+ {
+ return 0;
+ };
+ virtual Task* getLoadTask()
+ {
+ return new NullTask;
+ }
+ virtual bool isLoaded()
+ {
+ return false;
+ }
+ virtual void sort()
+ {
+ }
+ virtual void updateListData(QList< BaseVersionPtr >)
+ {
+ }
+};
+*/
+
+BaseVersionPtr Env::getVersion(QString component, QString version)
+{
+ auto list = getVersionList(component);
+ return list->findVersion(version);
+}
+
+std::shared_ptr< BaseVersionList > Env::getVersionList(QString component)
+{
+ auto iter = m_versionLists.find(component);
+ if(iter != m_versionLists.end())
+ {
+ return *iter;
+ }
+ //return std::make_shared<NullVersionList>();
+ return nullptr;
+}
+
+void Env::registerVersionList(QString name, std::shared_ptr< BaseVersionList > vlist)
+{
+ m_versionLists[name] = vlist;
+}
+
void Env::initHttpMetaCache(QString rootPath, QString staticDataPath)
{
@@ -121,3 +209,5 @@ void Env::updateProxySettings(QString proxyTypeStr, QString addr, int port, QStr
.arg(proxy.password());
QLOG_INFO() << proxyDesc;
}
+
+#include "Env.moc" \ No newline at end of file
diff --git a/logic/Env.h b/logic/Env.h
index ba2ea869..a53a62cb 100644
--- a/logic/Env.h
+++ b/logic/Env.h
@@ -2,10 +2,13 @@
#include <memory>
#include <QString>
+#include <QMap>
class IconList;
class QNetworkAccessManager;
class HttpMetaCache;
+class BaseVersionList;
+class BaseVersion;
#if defined(ENV)
#undef ENV
@@ -35,8 +38,16 @@ public:
/// Updates the application proxy settings from the settings object.
void updateProxySettings(QString proxyTypeStr, QString addr, int port, QString user, QString password);
+ /// get a version list by name
+ std::shared_ptr<BaseVersionList> getVersionList(QString component);
+
+ /// get a version by list name and version name
+ std::shared_ptr<BaseVersion> getVersion(QString component, QString version);
+
+ void registerVersionList(QString name, std::shared_ptr<BaseVersionList> vlist);
protected:
std::shared_ptr<QNetworkAccessManager> m_qnam;
std::shared_ptr<HttpMetaCache> m_metacache;
std::shared_ptr<IconList> m_icons;
+ QMap<QString, std::shared_ptr<BaseVersionList>> m_versionLists;
};
diff --git a/logic/InstanceList.cpp b/logic/InstanceList.cpp
index 4e275254..657fd5b4 100644
--- a/logic/InstanceList.cpp
+++ b/logic/InstanceList.cpp
@@ -26,7 +26,6 @@
#include <QRegularExpression>
#include <pathutils.h>
-#include "MultiMC.h"
#include "logic/InstanceList.h"
#include "logic/icons/IconList.h"
#include "logic/minecraft/MinecraftVersionList.h"
@@ -309,7 +308,7 @@ InstanceList::InstListError InstanceList::loadList()
}
// FIXME: generalize
- FTBPlugin::loadInstances(groupMap, tempList);
+ FTBPlugin::loadInstances(m_globalSettings, groupMap, tempList);
beginResetModel();
m_instances.clear();
diff --git a/logic/LegacyInstance.cpp b/logic/LegacyInstance.cpp
index ff1eed44..11566866 100644
--- a/logic/LegacyInstance.cpp
+++ b/logic/LegacyInstance.cpp
@@ -20,8 +20,6 @@
#include <pathutils.h>
#include <cmdutils.h>
-#include "MultiMC.h"
-
#include "LegacyInstance.h"
#include "logic/LegacyUpdate.h"
@@ -38,6 +36,7 @@
LegacyInstance::LegacyInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir)
: MinecraftInstance(globalSettings, settings, rootDir)
{
+ m_lwjglFolderSetting = globalSettings->getSetting("LWJGLDir");
settings->registerSetting("NeedsRebuild", true);
settings->registerSetting("ShouldUpdate", false);
settings->registerSetting("JarVersion", "Unknown");
@@ -142,7 +141,7 @@ BaseProcess *LegacyInstance::prepareForLaunch(AuthSessionPtr account)
.arg(settings().get("MinecraftWinWidth").toInt())
.arg(settings().get("MinecraftWinHeight").toInt());
- QString lwjgl = QDir(MMC->settings()->get("LWJGLDir").toString() + "/" + lwjglVersion())
+ QString lwjgl = QDir(m_lwjglFolderSetting->get().toString() + "/" + lwjglVersion())
.absolutePath();
launchScript += "userName " + account->player_name + "\n";
launchScript += "sessionId " + account->session + "\n";
@@ -340,3 +339,8 @@ QString LegacyInstance::getStatusbarDescription()
}
return tr("Legacy : %1").arg(intendedVersionId());
}
+
+QString LegacyInstance::lwjglFolder() const
+{
+ return m_lwjglFolderSetting->get().toString();
+}
diff --git a/logic/LegacyInstance.h b/logic/LegacyInstance.h
index 5c6581c8..353718c1 100644
--- a/logic/LegacyInstance.h
+++ b/logic/LegacyInstance.h
@@ -91,6 +91,10 @@ public:
//! The version of LWJGL that this instance uses.
QString lwjglVersion() const;
+
+ //! Where the lwjgl versions foor this instance can be found... HACK HACK HACK
+ QString lwjglFolder() const;
+
/// st the version of LWJGL libs this instance will use
void setLWJGLVersion(QString val);
@@ -116,7 +120,7 @@ protected:
mutable std::shared_ptr<ModList> core_mod_list;
mutable std::shared_ptr<ModList> loader_mod_list;
mutable std::shared_ptr<ModList> texture_pack_list;
-
+ std::shared_ptr<Setting> m_lwjglFolderSetting;
protected
slots:
virtual void jarModsChanged();
diff --git a/logic/LegacyUpdate.cpp b/logic/LegacyUpdate.cpp
index d955d456..e12556eb 100644
--- a/logic/LegacyUpdate.cpp
+++ b/logic/LegacyUpdate.cpp
@@ -31,7 +31,6 @@
#include "logger/QsLog.h"
#include "logic/net/URLConstants.h"
#include "JarUtils.h"
-#include "MultiMC.h"
LegacyUpdate::LegacyUpdate(BaseInstance *inst, QObject *parent) : Task(parent), m_inst(inst)
{
@@ -168,7 +167,7 @@ void LegacyUpdate::lwjglStart()
LegacyInstance *inst = (LegacyInstance *)m_inst;
lwjglVersion = inst->lwjglVersion();
- lwjglTargetPath = PathCombine(MMC->settings()->get("LWJGLDir").toString(), lwjglVersion);
+ lwjglTargetPath = PathCombine(inst->lwjglFolder(), lwjglVersion);
lwjglNativesPath = PathCombine(lwjglTargetPath, "natives");
// if the 'done' file exists, we don't have to download this again
@@ -179,7 +178,7 @@ void LegacyUpdate::lwjglStart()
return;
}
- auto list = MMC->lwjgllist();
+ auto list = std::dynamic_pointer_cast<LWJGLVersionList>(ENV.getVersionList("org.lwjgl.legacy"));
if (!list->isLoaded())
{
emitFailed("Too soon! Let the LWJGL list load :)");
@@ -187,7 +186,7 @@ void LegacyUpdate::lwjglStart()
}
setStatus(tr("Downloading new LWJGL..."));
- auto version = list->getVersion(lwjglVersion);
+ auto version = std::dynamic_pointer_cast<LWJGLVersion>(list->findVersion(lwjglVersion));
if (!version)
{
emitFailed("Game update failed: the selected LWJGL version is invalid.");
diff --git a/logic/LwjglVersionList.cpp b/logic/LwjglVersionList.cpp
index 77b7a05e..5bd9faa2 100644
--- a/logic/LwjglVersionList.cpp
+++ b/logic/LwjglVersionList.cpp
@@ -24,7 +24,7 @@
#define RSS_URL "http://sourceforge.net/projects/java-game-lib/rss"
-LWJGLVersionList::LWJGLVersionList(QObject *parent) : QAbstractListModel(parent)
+LWJGLVersionList::LWJGLVersionList(QObject *parent) : BaseVersionList(parent)
{
setLoading(false);
}
@@ -37,7 +37,7 @@ QVariant LWJGLVersionList::data(const QModelIndex &index, int role) const
if (index.row() > count())
return QVariant();
- const PtrLWJGLVersion version = at(index.row());
+ const PtrLWJGLVersion version = m_vlist.at(index.row());
switch (role)
{
@@ -151,7 +151,7 @@ void LWJGLVersionList::netRequestComplete()
continue;
}
QLOG_INFO() << "Discovered LWGL version" << name << "at" << link;
- tempList.append(LWJGLVersion::Create(name, link));
+ tempList.append(std::make_shared<LWJGLVersion>(name, link));
}
}
@@ -171,17 +171,6 @@ void LWJGLVersionList::netRequestComplete()
reply->deleteLater();
}
-const PtrLWJGLVersion LWJGLVersionList::getVersion(const QString &versionName)
-{
- for (int i = 0; i < count(); i++)
- {
- QString name = at(i)->name();
- if (name == versionName)
- return at(i);
- }
- return PtrLWJGLVersion();
-}
-
void LWJGLVersionList::failed(QString msg)
{
QLOG_ERROR() << msg;
diff --git a/logic/LwjglVersionList.h b/logic/LwjglVersionList.h
index 4ddad218..9205b964 100644
--- a/logic/LwjglVersionList.h
+++ b/logic/LwjglVersionList.h
@@ -21,32 +21,35 @@
#include <QNetworkReply>
#include <memory>
+#include "BaseVersion.h"
+#include "BaseVersionList.h"
class LWJGLVersion;
typedef std::shared_ptr<LWJGLVersion> PtrLWJGLVersion;
-class LWJGLVersion : public QObject
+class LWJGLVersion : public BaseVersion
{
- Q_OBJECT
-
- LWJGLVersion(const QString &name, const QString &url, QObject *parent = 0)
- : QObject(parent), m_name(name), m_url(url)
+public:
+ LWJGLVersion(const QString &name, const QString &url)
+ : m_name(name), m_url(url)
{
}
-public:
-
- static PtrLWJGLVersion Create(const QString &name, const QString &url, QObject *parent = 0)
+ virtual QString descriptor()
{
- return PtrLWJGLVersion(new LWJGLVersion(name, url, parent));
+ return m_name;
}
- ;
- QString name() const
+ virtual QString name()
{
return m_name;
}
+ virtual QString typeString() const
+ {
+ return QObject::tr("Upstream");
+ }
+
QString url() const
{
return m_url;
@@ -57,7 +60,7 @@ protected:
QString m_url;
};
-class LWJGLVersionList : public QAbstractListModel
+class LWJGLVersionList : public BaseVersionList
{
Q_OBJECT
public:
@@ -67,17 +70,20 @@ public:
{
return m_vlist.length() > 0;
}
-
- const PtrLWJGLVersion getVersion(const QString &versionName);
- PtrLWJGLVersion at(int index)
+ virtual const BaseVersionPtr at(int i) const override
{
- return m_vlist[index];
+ return m_vlist[i];
}
- const PtrLWJGLVersion at(int index) const
+
+ virtual Task* getLoadTask()
{
- return m_vlist[index];
+ return nullptr;
}
+ virtual void sort() {};
+
+ virtual void updateListData(QList< BaseVersionPtr > versions) {};
+
int count() const
{
return m_vlist.length();
diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp
index 20fb65bb..bdd47131 100644
--- a/logic/OneSixInstance.cpp
+++ b/logic/OneSixInstance.cpp
@@ -16,7 +16,6 @@
#include <QIcon>
#include <pathutils.h>
#include "logger/QsLog.h"
-#include "MultiMC.h"
#include "MMCError.h"
#include "logic/OneSixInstance.h"
diff --git a/logic/OneSixUpdate.cpp b/logic/OneSixUpdate.cpp
index 26a55cc9..38e9c0d7 100644
--- a/logic/OneSixUpdate.cpp
+++ b/logic/OneSixUpdate.cpp
@@ -13,7 +13,6 @@
* limitations under the License.
*/
-#include "MultiMC.h"
#include "logic/Env.h"
#include "OneSixUpdate.h"
@@ -52,7 +51,7 @@ void OneSixUpdate::executeTask()
// Get a pointer to the version object that corresponds to the instance's version.
targetVersion = std::dynamic_pointer_cast<MinecraftVersion>(
- MMC->minecraftlist()->findVersion(m_inst->intendedVersionId()));
+ ENV.getVersion("net.minecraft", m_inst->intendedVersionId()));
if (targetVersion == nullptr)
{
// don't do anything if it was invalid
@@ -65,7 +64,7 @@ void OneSixUpdate::executeTask()
jarlibStart();
return;
}
- versionUpdateTask = MMC->minecraftlist()->createUpdateTask(m_inst->intendedVersionId());
+ versionUpdateTask = std::dynamic_pointer_cast<MinecraftVersionList>(ENV.getVersionList("net.minecraft"))->createUpdateTask(m_inst->intendedVersionId());
if (!versionUpdateTask)
{
QLOG_DEBUG() << "Didn't spawn an update task.";
@@ -443,3 +442,4 @@ void OneSixUpdate::fmllibsFailed()
emitFailed("Game update failed: it was impossible to fetch the required FML libraries.");
return;
}
+
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;
};
diff --git a/logic/java/JavaChecker.cpp b/logic/java/JavaChecker.cpp
index dc0370e7..b62ddfbe 100644
--- a/logic/java/JavaChecker.cpp
+++ b/logic/java/JavaChecker.cpp
@@ -1,10 +1,11 @@
#include "JavaChecker.h"
-#include "MultiMC.h"
#include <pathutils.h>
#include <QFile>
#include <QProcess>
#include <QMap>
#include <QTemporaryFile>
+#include <QCoreApplication>
+#include <QDebug>
JavaChecker::JavaChecker(QObject *parent) : QObject(parent)
{
@@ -20,9 +21,9 @@ void JavaChecker::performCheck()
process->setArguments(args);
process->setProgram(path);
process->setProcessChannelMode(QProcess::SeparateChannels);
- QLOG_DEBUG() << "Running java checker!";
- QLOG_DEBUG() << "Java: " + path;
- QLOG_DEBUG() << "Args: {" + args.join("|") + "}";
+ qDebug() << "Running java checker!";
+ qDebug() << "Java: " + path;
+ qDebug() << "Args: {" + args.join("|") + "}";
connect(process.get(), SIGNAL(finished(int, QProcess::ExitStatus)), this,
SLOT(finished(int, QProcess::ExitStatus)));
@@ -45,18 +46,18 @@ void JavaChecker::finished(int exitcode, QProcess::ExitStatus status)
result.path = path;
result.id = id;
}
- QLOG_DEBUG() << "Java checker finished with status " << status << " exit code " << exitcode;
+ qDebug() << "Java checker finished with status " << status << " exit code " << exitcode;
if (status == QProcess::CrashExit || exitcode == 1)
{
- QLOG_DEBUG() << "Java checker failed!";
+ qDebug() << "Java checker failed!";
emit checkFinished(result);
return;
}
bool success = true;
QString p_stdout = _process->readAllStandardOutput();
- QLOG_DEBUG() << p_stdout;
+ qDebug() << p_stdout;
QMap<QString, QString> results;
QStringList lines = p_stdout.split("\n", QString::SkipEmptyParts);
@@ -77,7 +78,7 @@ void JavaChecker::finished(int exitcode, QProcess::ExitStatus status)
if(!results.contains("os.arch") || !results.contains("java.version") || !success)
{
- QLOG_DEBUG() << "Java checker failed - couldn't extract required information.";
+ qDebug() << "Java checker failed - couldn't extract required information.";
emit checkFinished(result);
return;
}
@@ -92,7 +93,7 @@ void JavaChecker::finished(int exitcode, QProcess::ExitStatus status)
result.mojangPlatform = is_64 ? "64" : "32";
result.realPlatform = os_arch;
result.javaVersion = java_version;
- QLOG_DEBUG() << "Java checker succeeded.";
+ qDebug() << "Java checker succeeded.";
emit checkFinished(result);
}
@@ -101,7 +102,7 @@ void JavaChecker::error(QProcess::ProcessError err)
if(err == QProcess::FailedToStart)
{
killTimer.stop();
- QLOG_DEBUG() << "Java checker has failed to start.";
+ qDebug() << "Java checker has failed to start.";
JavaCheckResult result;
{
result.path = path;
@@ -118,7 +119,7 @@ void JavaChecker::timeout()
// NO MERCY. NO ABUSE.
if(process)
{
- QLOG_DEBUG() << "Java checker has been killed by timeout.";
+ qDebug() << "Java checker has been killed by timeout.";
process->kill();
}
}
diff --git a/logic/java/JavaCheckerJob.cpp b/logic/java/JavaCheckerJob.cpp
index 75994ac9..8fd423c1 100644
--- a/logic/java/JavaCheckerJob.cpp
+++ b/logic/java/JavaCheckerJob.cpp
@@ -15,7 +15,6 @@
#include "JavaCheckerJob.h"
#include "pathutils.h"
-#include "MultiMC.h"
#include "logger/QsLog.h"
diff --git a/logic/java/JavaUtils.cpp b/logic/java/JavaUtils.cpp
index b506b045..a522f45c 100644
--- a/logic/java/JavaUtils.cpp
+++ b/logic/java/JavaUtils.cpp
@@ -21,8 +21,6 @@
#include <logic/settings/Setting.h>
#include <pathutils.h>
-#include "MultiMC.h"
-
#include "logger/QsLog.h"
#include "logic/java/JavaUtils.h"
#include "logic/java/JavaCheckerJob.h"
diff --git a/logic/java/JavaVersionList.cpp b/logic/java/JavaVersionList.cpp
index aeb7fcf5..73e8259a 100644
--- a/logic/java/JavaVersionList.cpp
+++ b/logic/java/JavaVersionList.cpp
@@ -17,7 +17,6 @@
#include <QtXml>
#include <QRegExp>
-#include "MultiMC.h"
#include "logger/QsLog.h"
#include "logic/java/JavaVersionList.h"
diff --git a/logic/liteloader/LiteLoaderInstaller.cpp b/logic/liteloader/LiteLoaderInstaller.cpp
index be1791ee..a2728499 100644
--- a/logic/liteloader/LiteLoaderInstaller.cpp
+++ b/logic/liteloader/LiteLoaderInstaller.cpp
@@ -23,7 +23,6 @@
#include "logic/minecraft/MinecraftProfile.h"
#include "logic/minecraft/OneSixLibrary.h"
#include "logic/OneSixInstance.h"
-#include "MultiMC.h"
#include "logic/liteloader/LiteLoaderVersionList.h"
LiteLoaderInstaller::LiteLoaderInstaller() : BaseInstaller()
diff --git a/logic/minecraft/MinecraftInstance.cpp b/logic/minecraft/MinecraftInstance.cpp
index c7edaf82..11a29f04 100644
--- a/logic/minecraft/MinecraftInstance.cpp
+++ b/logic/minecraft/MinecraftInstance.cpp
@@ -1,7 +1,7 @@
#include "MinecraftInstance.h"
-#include "MultiMC.h"
#include "logic/settings/SettingsObject.h"
#include <pathutils.h>
+#include "logic/Env.h"
#include "logic/minecraft/MinecraftVersionList.h"
MinecraftInstance::MinecraftInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir)
@@ -51,6 +51,5 @@ QString MinecraftInstance::minecraftRoot() const
std::shared_ptr< BaseVersionList > MinecraftInstance::versionList() const
{
- return std::dynamic_pointer_cast<BaseVersionList>(MMC->minecraftlist());
+ return ENV.getVersionList("net.minecraft");
}
-
diff --git a/logic/minecraft/MinecraftProcess.cpp b/logic/minecraft/MinecraftProcess.cpp
index 97eb8ee8..e8682a50 100644
--- a/logic/minecraft/MinecraftProcess.cpp
+++ b/logic/minecraft/MinecraftProcess.cpp
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "MultiMC.h"
#include "BuildConfig.h"
#include "logic/minecraft/MinecraftProcess.h"
@@ -26,6 +25,7 @@
#include <QProcessEnvironment>
#include <QRegularExpression>
#include <QStandardPaths>
+#include <QCoreApplication>
#include "osutils.h"
#include "pathutils.h"
diff --git a/logic/minecraft/MinecraftVersion.cpp b/logic/minecraft/MinecraftVersion.cpp
index 28afb5e7..0d484497 100644
--- a/logic/minecraft/MinecraftVersion.cpp
+++ b/logic/minecraft/MinecraftVersion.cpp
@@ -3,7 +3,6 @@
#include "VersionBuildError.h"
#include "VersionBuilder.h"
#include "ProfileUtils.h"
-#include "MultiMC.h"
#include "logic/settings/SettingsObject.h"
bool MinecraftVersion::usesLegacyLauncher()
diff --git a/logic/minecraft/OneSixProfileStrategy.cpp b/logic/minecraft/OneSixProfileStrategy.cpp
index 285e983c..5c0658d0 100644
--- a/logic/minecraft/OneSixProfileStrategy.cpp
+++ b/logic/minecraft/OneSixProfileStrategy.cpp
@@ -2,8 +2,7 @@
#include "logic/minecraft/VersionBuildError.h"
#include "logic/OneSixInstance.h"
#include "logic/minecraft/MinecraftVersionList.h"
-
-#include "MultiMC.h"
+#include "logic/Env.h"
#include <pathutils.h>
#include <QDir>
@@ -73,8 +72,7 @@ void OneSixProfileStrategy::loadDefaultBuiltinPatches()
}
else
{
- auto minecraftList = MMC->minecraftlist();
- auto mcversion = minecraftList->findVersion(m_instance->intendedVersionId());
+ auto mcversion = ENV.getVersion("net.minecraft", m_instance->intendedVersionId());
minecraftPatch = std::dynamic_pointer_cast<ProfilePatch>(mcversion);
}
if (!minecraftPatch)
diff --git a/logic/net/NetJob.cpp b/logic/net/NetJob.cpp
index 85892581..c5f93ae1 100644
--- a/logic/net/NetJob.cpp
+++ b/logic/net/NetJob.cpp
@@ -15,7 +15,6 @@
#include "NetJob.h"
#include "pathutils.h"
-#include "MultiMC.h"
#include "MD5EtagDownload.h"
#include "ByteArrayDownload.h"
#include "CacheDownload.h"