SCRATCH remove remaining references to MultiMC.h and fix legacy LWJGL

This commit is contained in:
Petr Mrázek 2015-02-02 01:09:28 +01:00
parent 382ae78a0b
commit d313e9ab09
28 changed files with 209 additions and 121 deletions

View File

@ -392,7 +392,7 @@ void MultiMC::initGlobalSettings(bool test_mode)
} }
m_settings->registerSetting("ConsoleFontSize", defaultSize); m_settings->registerSetting("ConsoleFontSize", defaultSize);
FTBPlugin::initialize(); FTBPlugin::initialize(m_settings);
// Folders // Folders
m_settings->registerSetting("InstanceDir", "instances"); m_settings->registerSetting("InstanceDir", "instances");
@ -467,6 +467,7 @@ std::shared_ptr<LWJGLVersionList> MultiMC::lwjgllist()
if (!m_lwjgllist) if (!m_lwjgllist)
{ {
m_lwjgllist.reset(new LWJGLVersionList()); m_lwjgllist.reset(new LWJGLVersionList());
ENV.registerVersionList("org.lwjgl.legacy", m_lwjgllist);
} }
return m_lwjgllist; return m_lwjgllist;
} }
@ -476,6 +477,7 @@ std::shared_ptr<ForgeVersionList> MultiMC::forgelist()
if (!m_forgelist) if (!m_forgelist)
{ {
m_forgelist.reset(new ForgeVersionList()); m_forgelist.reset(new ForgeVersionList());
ENV.registerVersionList("net.minecraftforge", m_forgelist);
} }
return m_forgelist; return m_forgelist;
} }
@ -485,6 +487,7 @@ std::shared_ptr<LiteLoaderVersionList> MultiMC::liteloaderlist()
if (!m_liteloaderlist) if (!m_liteloaderlist)
{ {
m_liteloaderlist.reset(new LiteLoaderVersionList()); m_liteloaderlist.reset(new LiteLoaderVersionList());
ENV.registerVersionList("com.mumfrey.liteloader", m_liteloaderlist);
} }
return m_liteloaderlist; return m_liteloaderlist;
} }
@ -494,6 +497,7 @@ std::shared_ptr<MinecraftVersionList> MultiMC::minecraftlist()
if (!m_minecraftlist) if (!m_minecraftlist)
{ {
m_minecraftlist.reset(new MinecraftVersionList()); m_minecraftlist.reset(new MinecraftVersionList());
ENV.registerVersionList("net.minecraft", m_liteloaderlist);
} }
return m_minecraftlist; return m_minecraftlist;
} }
@ -503,6 +507,7 @@ std::shared_ptr<JavaVersionList> MultiMC::javalist()
if (!m_javalist) if (!m_javalist)
{ {
m_javalist.reset(new JavaVersionList()); m_javalist.reset(new JavaVersionList());
ENV.registerVersionList("com.java", m_liteloaderlist);
} }
return m_javalist; return m_javalist;
} }

View File

@ -61,8 +61,8 @@ public:
{ {
return m_settings; return m_settings;
} }
// InstanceList, OneSixUpdate, MinecraftInstance, OneSixProfileStrategy
std::shared_ptr<MinecraftVersionList> minecraftlist();
QIcon getThemedIcon(const QString& name); QIcon getThemedIcon(const QString& name);
@ -74,16 +74,10 @@ public:
return m_updateChecker; return m_updateChecker;
} }
// LegacyUpdate std::shared_ptr<MinecraftVersionList> minecraftlist();
std::shared_ptr<LWJGLVersionList> lwjgllist(); std::shared_ptr<LWJGLVersionList> lwjgllist();
// APPLICATION ONLY
std::shared_ptr<ForgeVersionList> forgelist(); std::shared_ptr<ForgeVersionList> forgelist();
// APPLICATION ONLY
std::shared_ptr<LiteLoaderVersionList> liteloaderlist(); std::shared_ptr<LiteLoaderVersionList> liteloaderlist();
// APPLICATION ONLY
std::shared_ptr<JavaVersionList> javalist(); std::shared_ptr<JavaVersionList> javalist();
// APPLICATION ONLY // APPLICATION ONLY

View File

@ -13,7 +13,6 @@
* limitations under the License. * limitations under the License.
*/ */
#include "MultiMC.h"
#include "BaseInstance.h" #include "BaseInstance.h"
#include <QFileInfo> #include <QFileInfo>

View File

@ -1,13 +1,19 @@
#include "Env.h" #include "Env.h"
#include "logic/net/HttpMetaCache.h" #include "logic/net/HttpMetaCache.h"
#include "icons/IconList.h" #include "icons/IconList.h"
#include "BaseVersion.h"
#include "BaseVersionList.h"
#include <QDir> #include <QDir>
#include <QNetworkProxy> #include <QNetworkProxy>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include "logger/QsLog.h" #include "logger/QsLog.h"
#include "logic/tasks/Task.h"
#include <QDebug> #include <QDebug>
/*
* The *NEW* global rat nest of an object. Handle with care.
*/
Env::Env() Env::Env()
{ {
m_qnam = std::make_shared<QNetworkAccessManager>(); m_qnam = std::make_shared<QNetworkAccessManager>();
@ -17,6 +23,8 @@ void Env::destroy()
{ {
m_metacache.reset(); m_metacache.reset();
m_qnam.reset(); m_qnam.reset();
m_icons.reset();
m_versionLists.clear();
} }
Env& Env::Env::getInstance() Env& Env::Env::getInstance()
@ -41,6 +49,86 @@ std::shared_ptr<IconList> Env::icons()
Q_ASSERT(m_icons != nullptr); Q_ASSERT(m_icons != nullptr);
return m_icons; 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) void Env::initHttpMetaCache(QString rootPath, QString staticDataPath)
{ {
@ -121,3 +209,5 @@ void Env::updateProxySettings(QString proxyTypeStr, QString addr, int port, QStr
.arg(proxy.password()); .arg(proxy.password());
QLOG_INFO() << proxyDesc; QLOG_INFO() << proxyDesc;
} }
#include "Env.moc"

View File

@ -2,10 +2,13 @@
#include <memory> #include <memory>
#include <QString> #include <QString>
#include <QMap>
class IconList; class IconList;
class QNetworkAccessManager; class QNetworkAccessManager;
class HttpMetaCache; class HttpMetaCache;
class BaseVersionList;
class BaseVersion;
#if defined(ENV) #if defined(ENV)
#undef ENV #undef ENV
@ -35,8 +38,16 @@ public:
/// Updates the application proxy settings from the settings object. /// Updates the application proxy settings from the settings object.
void updateProxySettings(QString proxyTypeStr, QString addr, int port, QString user, QString password); 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: protected:
std::shared_ptr<QNetworkAccessManager> m_qnam; std::shared_ptr<QNetworkAccessManager> m_qnam;
std::shared_ptr<HttpMetaCache> m_metacache; std::shared_ptr<HttpMetaCache> m_metacache;
std::shared_ptr<IconList> m_icons; std::shared_ptr<IconList> m_icons;
QMap<QString, std::shared_ptr<BaseVersionList>> m_versionLists;
}; };

View File

@ -26,7 +26,6 @@
#include <QRegularExpression> #include <QRegularExpression>
#include <pathutils.h> #include <pathutils.h>
#include "MultiMC.h"
#include "logic/InstanceList.h" #include "logic/InstanceList.h"
#include "logic/icons/IconList.h" #include "logic/icons/IconList.h"
#include "logic/minecraft/MinecraftVersionList.h" #include "logic/minecraft/MinecraftVersionList.h"
@ -309,7 +308,7 @@ InstanceList::InstListError InstanceList::loadList()
} }
// FIXME: generalize // FIXME: generalize
FTBPlugin::loadInstances(groupMap, tempList); FTBPlugin::loadInstances(m_globalSettings, groupMap, tempList);
beginResetModel(); beginResetModel();
m_instances.clear(); m_instances.clear();

View File

@ -20,8 +20,6 @@
#include <pathutils.h> #include <pathutils.h>
#include <cmdutils.h> #include <cmdutils.h>
#include "MultiMC.h"
#include "LegacyInstance.h" #include "LegacyInstance.h"
#include "logic/LegacyUpdate.h" #include "logic/LegacyUpdate.h"
@ -38,6 +36,7 @@
LegacyInstance::LegacyInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir) LegacyInstance::LegacyInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir)
: MinecraftInstance(globalSettings, settings, rootDir) : MinecraftInstance(globalSettings, settings, rootDir)
{ {
m_lwjglFolderSetting = globalSettings->getSetting("LWJGLDir");
settings->registerSetting("NeedsRebuild", true); settings->registerSetting("NeedsRebuild", true);
settings->registerSetting("ShouldUpdate", false); settings->registerSetting("ShouldUpdate", false);
settings->registerSetting("JarVersion", "Unknown"); settings->registerSetting("JarVersion", "Unknown");
@ -142,7 +141,7 @@ BaseProcess *LegacyInstance::prepareForLaunch(AuthSessionPtr account)
.arg(settings().get("MinecraftWinWidth").toInt()) .arg(settings().get("MinecraftWinWidth").toInt())
.arg(settings().get("MinecraftWinHeight").toInt()); .arg(settings().get("MinecraftWinHeight").toInt());
QString lwjgl = QDir(MMC->settings()->get("LWJGLDir").toString() + "/" + lwjglVersion()) QString lwjgl = QDir(m_lwjglFolderSetting->get().toString() + "/" + lwjglVersion())
.absolutePath(); .absolutePath();
launchScript += "userName " + account->player_name + "\n"; launchScript += "userName " + account->player_name + "\n";
launchScript += "sessionId " + account->session + "\n"; launchScript += "sessionId " + account->session + "\n";
@ -340,3 +339,8 @@ QString LegacyInstance::getStatusbarDescription()
} }
return tr("Legacy : %1").arg(intendedVersionId()); return tr("Legacy : %1").arg(intendedVersionId());
} }
QString LegacyInstance::lwjglFolder() const
{
return m_lwjglFolderSetting->get().toString();
}

View File

@ -91,6 +91,10 @@ public:
//! The version of LWJGL that this instance uses. //! The version of LWJGL that this instance uses.
QString lwjglVersion() const; 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 /// st the version of LWJGL libs this instance will use
void setLWJGLVersion(QString val); void setLWJGLVersion(QString val);
@ -116,7 +120,7 @@ protected:
mutable std::shared_ptr<ModList> core_mod_list; mutable std::shared_ptr<ModList> core_mod_list;
mutable std::shared_ptr<ModList> loader_mod_list; mutable std::shared_ptr<ModList> loader_mod_list;
mutable std::shared_ptr<ModList> texture_pack_list; mutable std::shared_ptr<ModList> texture_pack_list;
std::shared_ptr<Setting> m_lwjglFolderSetting;
protected protected
slots: slots:
virtual void jarModsChanged(); virtual void jarModsChanged();

View File

@ -31,7 +31,6 @@
#include "logger/QsLog.h" #include "logger/QsLog.h"
#include "logic/net/URLConstants.h" #include "logic/net/URLConstants.h"
#include "JarUtils.h" #include "JarUtils.h"
#include "MultiMC.h"
LegacyUpdate::LegacyUpdate(BaseInstance *inst, QObject *parent) : Task(parent), m_inst(inst) LegacyUpdate::LegacyUpdate(BaseInstance *inst, QObject *parent) : Task(parent), m_inst(inst)
{ {
@ -168,7 +167,7 @@ void LegacyUpdate::lwjglStart()
LegacyInstance *inst = (LegacyInstance *)m_inst; LegacyInstance *inst = (LegacyInstance *)m_inst;
lwjglVersion = inst->lwjglVersion(); lwjglVersion = inst->lwjglVersion();
lwjglTargetPath = PathCombine(MMC->settings()->get("LWJGLDir").toString(), lwjglVersion); lwjglTargetPath = PathCombine(inst->lwjglFolder(), lwjglVersion);
lwjglNativesPath = PathCombine(lwjglTargetPath, "natives"); lwjglNativesPath = PathCombine(lwjglTargetPath, "natives");
// if the 'done' file exists, we don't have to download this again // if the 'done' file exists, we don't have to download this again
@ -179,7 +178,7 @@ void LegacyUpdate::lwjglStart()
return; return;
} }
auto list = MMC->lwjgllist(); auto list = std::dynamic_pointer_cast<LWJGLVersionList>(ENV.getVersionList("org.lwjgl.legacy"));
if (!list->isLoaded()) if (!list->isLoaded())
{ {
emitFailed("Too soon! Let the LWJGL list load :)"); emitFailed("Too soon! Let the LWJGL list load :)");
@ -187,7 +186,7 @@ void LegacyUpdate::lwjglStart()
} }
setStatus(tr("Downloading new LWJGL...")); setStatus(tr("Downloading new LWJGL..."));
auto version = list->getVersion(lwjglVersion); auto version = std::dynamic_pointer_cast<LWJGLVersion>(list->findVersion(lwjglVersion));
if (!version) if (!version)
{ {
emitFailed("Game update failed: the selected LWJGL version is invalid."); emitFailed("Game update failed: the selected LWJGL version is invalid.");

View File

@ -24,7 +24,7 @@
#define RSS_URL "http://sourceforge.net/projects/java-game-lib/rss" #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); setLoading(false);
} }
@ -37,7 +37,7 @@ QVariant LWJGLVersionList::data(const QModelIndex &index, int role) const
if (index.row() > count()) if (index.row() > count())
return QVariant(); return QVariant();
const PtrLWJGLVersion version = at(index.row()); const PtrLWJGLVersion version = m_vlist.at(index.row());
switch (role) switch (role)
{ {
@ -151,7 +151,7 @@ void LWJGLVersionList::netRequestComplete()
continue; continue;
} }
QLOG_INFO() << "Discovered LWGL version" << name << "at" << link; 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(); 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) void LWJGLVersionList::failed(QString msg)
{ {
QLOG_ERROR() << msg; QLOG_ERROR() << msg;

View File

@ -21,32 +21,35 @@
#include <QNetworkReply> #include <QNetworkReply>
#include <memory> #include <memory>
#include "BaseVersion.h"
#include "BaseVersionList.h"
class LWJGLVersion; class LWJGLVersion;
typedef std::shared_ptr<LWJGLVersion> PtrLWJGLVersion; 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: public:
LWJGLVersion(const QString &name, const QString &url)
static PtrLWJGLVersion Create(const QString &name, const QString &url, QObject *parent = 0) : m_name(name), m_url(url)
{ {
return PtrLWJGLVersion(new LWJGLVersion(name, url, parent));
} }
;
QString name() const virtual QString descriptor()
{ {
return m_name; return m_name;
} }
virtual QString name()
{
return m_name;
}
virtual QString typeString() const
{
return QObject::tr("Upstream");
}
QString url() const QString url() const
{ {
return m_url; return m_url;
@ -57,7 +60,7 @@ protected:
QString m_url; QString m_url;
}; };
class LWJGLVersionList : public QAbstractListModel class LWJGLVersionList : public BaseVersionList
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -67,17 +70,20 @@ public:
{ {
return m_vlist.length() > 0; return m_vlist.length() > 0;
} }
virtual const BaseVersionPtr at(int i) const override
{
return m_vlist[i];
}
const PtrLWJGLVersion getVersion(const QString &versionName); virtual Task* getLoadTask()
PtrLWJGLVersion at(int index)
{ {
return m_vlist[index]; return nullptr;
}
const PtrLWJGLVersion at(int index) const
{
return m_vlist[index];
} }
virtual void sort() {};
virtual void updateListData(QList< BaseVersionPtr > versions) {};
int count() const int count() const
{ {
return m_vlist.length(); return m_vlist.length();

View File

@ -16,7 +16,6 @@
#include <QIcon> #include <QIcon>
#include <pathutils.h> #include <pathutils.h>
#include "logger/QsLog.h" #include "logger/QsLog.h"
#include "MultiMC.h"
#include "MMCError.h" #include "MMCError.h"
#include "logic/OneSixInstance.h" #include "logic/OneSixInstance.h"

View File

@ -13,7 +13,6 @@
* limitations under the License. * limitations under the License.
*/ */
#include "MultiMC.h"
#include "logic/Env.h" #include "logic/Env.h"
#include "OneSixUpdate.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. // Get a pointer to the version object that corresponds to the instance's version.
targetVersion = std::dynamic_pointer_cast<MinecraftVersion>( targetVersion = std::dynamic_pointer_cast<MinecraftVersion>(
MMC->minecraftlist()->findVersion(m_inst->intendedVersionId())); ENV.getVersion("net.minecraft", m_inst->intendedVersionId()));
if (targetVersion == nullptr) if (targetVersion == nullptr)
{ {
// don't do anything if it was invalid // don't do anything if it was invalid
@ -65,7 +64,7 @@ void OneSixUpdate::executeTask()
jarlibStart(); jarlibStart();
return; return;
} }
versionUpdateTask = MMC->minecraftlist()->createUpdateTask(m_inst->intendedVersionId()); versionUpdateTask = std::dynamic_pointer_cast<MinecraftVersionList>(ENV.getVersionList("net.minecraft"))->createUpdateTask(m_inst->intendedVersionId());
if (!versionUpdateTask) if (!versionUpdateTask)
{ {
QLOG_DEBUG() << "Didn't spawn an update task."; 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."); emitFailed("Game update failed: it was impossible to fetch the required FML libraries.");
return; return;
} }

View File

@ -7,7 +7,6 @@
#include <logic/InstanceList.h> #include <logic/InstanceList.h>
#include <logic/minecraft/MinecraftVersionList.h> #include <logic/minecraft/MinecraftVersionList.h>
#include <logic/settings/INISettingsObject.h> #include <logic/settings/INISettingsObject.h>
#include "MultiMC.h"
#include <pathutils.h> #include <pathutils.h>
#include "QDebug" #include "QDebug"
#include <QXmlStreamReader> #include <QXmlStreamReader>
@ -33,11 +32,11 @@ inline uint qHash(FTBRecord record)
return qHash(record.instanceDir); return qHash(record.instanceDir);
} }
QSet<FTBRecord> discoverFTBInstances() QSet<FTBRecord> discoverFTBInstances(SettingsObjectPtr globalSettings)
{ {
QSet<FTBRecord> records; QSet<FTBRecord> records;
QDir dir = QDir(MMC->settings()->get("FTBLauncherDataRoot").toString()); QDir dir = QDir(globalSettings->get("FTBLauncherDataRoot").toString());
QDir dataDir = QDir(MMC->settings()->get("FTBRoot").toString()); QDir dataDir = QDir(globalSettings->get("FTBRoot").toString());
if (!dataDir.exists()) if (!dataDir.exists())
{ {
qDebug() << "The FTB directory specified does not exist. Please check your settings"; qDebug() << "The FTB directory specified does not exist. Please check your settings";
@ -131,7 +130,7 @@ QSet<FTBRecord> discoverFTBInstances()
return records; 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")); auto m_settings = std::make_shared<INISettingsObject>(PathCombine(instDir, "instance.cfg"));
@ -143,17 +142,17 @@ InstancePtr loadInstance(const QString &instDir)
if (inst_type == "LegacyFTB") 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") else if (inst_type == "OneSixFTB")
{ {
inst.reset(new OneSixFTBInstance(MMC->settings(), m_settings, instDir)); inst.reset(new OneSixFTBInstance(globalSettings, m_settings, instDir));
} }
inst->init(); inst->init();
return inst; return inst;
} }
InstancePtr createInstance(MinecraftVersionPtr version, const QString &instDir) InstancePtr createInstance(SettingsObjectPtr globalSettings, MinecraftVersionPtr version, const QString &instDir)
{ {
QDir rootDir(instDir); QDir rootDir(instDir);
@ -178,28 +177,28 @@ InstancePtr createInstance(MinecraftVersionPtr version, const QString &instDir)
if (version->usesLegacyLauncher()) if (version->usesLegacyLauncher())
{ {
m_settings->set("InstanceType", "LegacyFTB"); 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()); inst->setIntendedVersionId(version->descriptor());
} }
else else
{ {
m_settings->set("InstanceType", "OneSixFTB"); 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->setIntendedVersionId(version->descriptor());
inst->init(); inst->init();
} }
return inst; 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 // nothing to load when we don't have
if (MMC->settings()->get("TrackFTBInstances").toBool() != true) if (globalSettings->get("TrackFTBInstances").toBool() != true)
{ {
return; return;
} }
auto records = discoverFTBInstances(); auto records = discoverFTBInstances(globalSettings);
if (!records.size()) if (!records.size())
{ {
qDebug() << "No FTB instances to load."; 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()) if (!QFileInfo(PathCombine(record.instanceDir, "instance.cfg")).exists())
{ {
qDebug() << "Converting " << record.name << " as new."; 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) if (!mcVersion)
{ {
qCritical() << "Can't load instance " << record.instanceDir qCritical() << "Can't load instance " << record.instanceDir
@ -227,7 +226,7 @@ void FTBPlugin::loadInstances(QMap<QString, QString> &groupMap, QList<InstancePt
continue; continue;
} }
auto instPtr = createInstance(mcVersion, record.instanceDir); auto instPtr = createInstance(globalSettings, mcVersion, record.instanceDir);
if (!instPtr) if (!instPtr)
{ {
continue; continue;
@ -245,7 +244,7 @@ void FTBPlugin::loadInstances(QMap<QString, QString> &groupMap, QList<InstancePt
else else
{ {
qDebug() << "Loading existing " << record.name; qDebug() << "Loading existing " << record.name;
auto instPtr = loadInstance(record.instanceDir); auto instPtr = loadInstance(globalSettings, record.instanceDir);
if (!instPtr) if (!instPtr)
{ {
continue; continue;
@ -270,11 +269,10 @@ void FTBPlugin::loadInstances(QMap<QString, QString> &groupMap, QList<InstancePt
static const int APPDATA_BUFFER_SIZE = 1024; static const int APPDATA_BUFFER_SIZE = 1024;
#endif #endif
void FTBPlugin::initialize() void FTBPlugin::initialize(SettingsObjectPtr globalSettings)
{ {
auto m_settings = MMC->settings();
// FTB // FTB
m_settings->registerSetting("TrackFTBInstances", false); globalSettings->registerSetting("TrackFTBInstances", false);
QString ftbDataDefault; QString ftbDataDefault;
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
QString ftbDefault = ftbDataDefault = QDir::home().absoluteFilePath(".ftblauncher"); QString ftbDefault = ftbDataDefault = QDir::home().absoluteFilePath(".ftblauncher");
@ -315,16 +313,16 @@ void FTBPlugin::initialize()
QString ftbDefault = ftbDataDefault = QString ftbDefault = ftbDataDefault =
PathCombine(QDir::homePath(), "Library/Application Support/ftblauncher"); PathCombine(QDir::homePath(), "Library/Application Support/ftblauncher");
#endif #endif
m_settings->registerSetting("FTBLauncherDataRoot", ftbDataDefault); globalSettings->registerSetting("FTBLauncherDataRoot", ftbDataDefault);
m_settings->registerSetting("FTBLauncherRoot", ftbDefault); globalSettings->registerSetting("FTBLauncherRoot", ftbDefault);
qDebug() << "FTB Launcher paths:" << m_settings->get("FTBLauncherDataRoot").toString() qDebug() << "FTB Launcher paths:" << globalSettings->get("FTBLauncherDataRoot").toString()
<< "and" << m_settings->get("FTBLauncherRoot").toString(); << "and" << globalSettings->get("FTBLauncherRoot").toString();
m_settings->registerSetting("FTBRoot"); globalSettings->registerSetting("FTBRoot");
if (m_settings->get("FTBRoot").isNull()) if (globalSettings->get("FTBRoot").isNull())
{ {
QString ftbRoot; QString ftbRoot;
QFile f(QDir(m_settings->get("FTBLauncherRoot").toString()) QFile f(QDir(globalSettings->get("FTBLauncherRoot").toString())
.absoluteFilePath("ftblaunch.cfg")); .absoluteFilePath("ftblaunch.cfg"));
qDebug() << "Attempting to read" << f.fileName(); qDebug() << "Attempting to read" << f.fileName();
if (f.open(QFile::ReadOnly)) if (f.open(QFile::ReadOnly))
@ -348,7 +346,7 @@ void FTBPlugin::initialize()
else else
{ {
qDebug() << "FTB is installed at" << ftbRoot; qDebug() << "FTB is installed at" << ftbRoot;
m_settings->set("FTBRoot", ftbRoot); globalSettings->set("FTBRoot", ftbRoot);
} }
} }
else else

View File

@ -6,6 +6,6 @@
class FTBPlugin class FTBPlugin
{ {
public: public:
static void initialize(); static void initialize(SettingsObjectPtr globalSettings);
static void loadInstances(QMap<QString, QString> &groupMap, QList<InstancePtr> &tempList); static void loadInstances(SettingsObjectPtr globalSettings, QMap<QString, QString> &groupMap, QList<InstancePtr> &tempList);
}; };

View File

@ -3,8 +3,6 @@
#include "logic/ftb/OneSixFTBInstance.h" #include "logic/ftb/OneSixFTBInstance.h"
#include "logic/minecraft/MinecraftVersionList.h" #include "logic/minecraft/MinecraftVersionList.h"
#include "MultiMC.h"
#include <pathutils.h> #include <pathutils.h>
#include <QDir> #include <QDir>
#include <QUuid> #include <QUuid>

View File

@ -8,12 +8,12 @@
#include "logic/forge/ForgeInstaller.h" #include "logic/forge/ForgeInstaller.h"
#include "logic/forge/ForgeVersionList.h" #include "logic/forge/ForgeVersionList.h"
#include <logic/settings/INISettingsObject.h> #include <logic/settings/INISettingsObject.h>
#include "MultiMC.h"
#include "pathutils.h" #include "pathutils.h"
OneSixFTBInstance::OneSixFTBInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir) : OneSixFTBInstance::OneSixFTBInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir) :
OneSixInstance(globalSettings, settings, rootDir) OneSixInstance(globalSettings, settings, rootDir)
{ {
m_globalSettings = globalSettings;
} }
void OneSixFTBInstance::copy(const QDir &newDir) void OneSixFTBInstance::copy(const QDir &newDir)
@ -108,12 +108,12 @@ QString OneSixFTBInstance::id() const
QDir OneSixFTBInstance::librariesPath() 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 QDir OneSixFTBInstance::versionsPath() const
{ {
return QDir(MMC->settings()->get("FTBRoot").toString() + "/versions"); return QDir(m_globalSettings->get("FTBRoot").toString() + "/versions");
} }
bool OneSixFTBInstance::providesVersionFile() const bool OneSixFTBInstance::providesVersionFile() const

View File

@ -24,4 +24,6 @@ public:
QDir librariesPath() const override; QDir librariesPath() const override;
QDir versionsPath() const override; QDir versionsPath() const override;
bool providesVersionFile() const override; bool providesVersionFile() const override;
private:
SettingsObjectPtr m_globalSettings;
}; };

View File

@ -1,10 +1,11 @@
#include "JavaChecker.h" #include "JavaChecker.h"
#include "MultiMC.h"
#include <pathutils.h> #include <pathutils.h>
#include <QFile> #include <QFile>
#include <QProcess> #include <QProcess>
#include <QMap> #include <QMap>
#include <QTemporaryFile> #include <QTemporaryFile>
#include <QCoreApplication>
#include <QDebug>
JavaChecker::JavaChecker(QObject *parent) : QObject(parent) JavaChecker::JavaChecker(QObject *parent) : QObject(parent)
{ {
@ -20,9 +21,9 @@ void JavaChecker::performCheck()
process->setArguments(args); process->setArguments(args);
process->setProgram(path); process->setProgram(path);
process->setProcessChannelMode(QProcess::SeparateChannels); process->setProcessChannelMode(QProcess::SeparateChannels);
QLOG_DEBUG() << "Running java checker!"; qDebug() << "Running java checker!";
QLOG_DEBUG() << "Java: " + path; qDebug() << "Java: " + path;
QLOG_DEBUG() << "Args: {" + args.join("|") + "}"; qDebug() << "Args: {" + args.join("|") + "}";
connect(process.get(), SIGNAL(finished(int, QProcess::ExitStatus)), this, connect(process.get(), SIGNAL(finished(int, QProcess::ExitStatus)), this,
SLOT(finished(int, QProcess::ExitStatus))); SLOT(finished(int, QProcess::ExitStatus)));
@ -45,18 +46,18 @@ void JavaChecker::finished(int exitcode, QProcess::ExitStatus status)
result.path = path; result.path = path;
result.id = id; 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) if (status == QProcess::CrashExit || exitcode == 1)
{ {
QLOG_DEBUG() << "Java checker failed!"; qDebug() << "Java checker failed!";
emit checkFinished(result); emit checkFinished(result);
return; return;
} }
bool success = true; bool success = true;
QString p_stdout = _process->readAllStandardOutput(); QString p_stdout = _process->readAllStandardOutput();
QLOG_DEBUG() << p_stdout; qDebug() << p_stdout;
QMap<QString, QString> results; QMap<QString, QString> results;
QStringList lines = p_stdout.split("\n", QString::SkipEmptyParts); 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) 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); emit checkFinished(result);
return; return;
} }
@ -92,7 +93,7 @@ void JavaChecker::finished(int exitcode, QProcess::ExitStatus status)
result.mojangPlatform = is_64 ? "64" : "32"; result.mojangPlatform = is_64 ? "64" : "32";
result.realPlatform = os_arch; result.realPlatform = os_arch;
result.javaVersion = java_version; result.javaVersion = java_version;
QLOG_DEBUG() << "Java checker succeeded."; qDebug() << "Java checker succeeded.";
emit checkFinished(result); emit checkFinished(result);
} }
@ -101,7 +102,7 @@ void JavaChecker::error(QProcess::ProcessError err)
if(err == QProcess::FailedToStart) if(err == QProcess::FailedToStart)
{ {
killTimer.stop(); killTimer.stop();
QLOG_DEBUG() << "Java checker has failed to start."; qDebug() << "Java checker has failed to start.";
JavaCheckResult result; JavaCheckResult result;
{ {
result.path = path; result.path = path;
@ -118,7 +119,7 @@ void JavaChecker::timeout()
// NO MERCY. NO ABUSE. // NO MERCY. NO ABUSE.
if(process) if(process)
{ {
QLOG_DEBUG() << "Java checker has been killed by timeout."; qDebug() << "Java checker has been killed by timeout.";
process->kill(); process->kill();
} }
} }

View File

@ -15,7 +15,6 @@
#include "JavaCheckerJob.h" #include "JavaCheckerJob.h"
#include "pathutils.h" #include "pathutils.h"
#include "MultiMC.h"
#include "logger/QsLog.h" #include "logger/QsLog.h"

View File

@ -21,8 +21,6 @@
#include <logic/settings/Setting.h> #include <logic/settings/Setting.h>
#include <pathutils.h> #include <pathutils.h>
#include "MultiMC.h"
#include "logger/QsLog.h" #include "logger/QsLog.h"
#include "logic/java/JavaUtils.h" #include "logic/java/JavaUtils.h"
#include "logic/java/JavaCheckerJob.h" #include "logic/java/JavaCheckerJob.h"

View File

@ -17,7 +17,6 @@
#include <QtXml> #include <QtXml>
#include <QRegExp> #include <QRegExp>
#include "MultiMC.h"
#include "logger/QsLog.h" #include "logger/QsLog.h"
#include "logic/java/JavaVersionList.h" #include "logic/java/JavaVersionList.h"

View File

@ -23,7 +23,6 @@
#include "logic/minecraft/MinecraftProfile.h" #include "logic/minecraft/MinecraftProfile.h"
#include "logic/minecraft/OneSixLibrary.h" #include "logic/minecraft/OneSixLibrary.h"
#include "logic/OneSixInstance.h" #include "logic/OneSixInstance.h"
#include "MultiMC.h"
#include "logic/liteloader/LiteLoaderVersionList.h" #include "logic/liteloader/LiteLoaderVersionList.h"
LiteLoaderInstaller::LiteLoaderInstaller() : BaseInstaller() LiteLoaderInstaller::LiteLoaderInstaller() : BaseInstaller()

View File

@ -1,7 +1,7 @@
#include "MinecraftInstance.h" #include "MinecraftInstance.h"
#include "MultiMC.h"
#include "logic/settings/SettingsObject.h" #include "logic/settings/SettingsObject.h"
#include <pathutils.h> #include <pathutils.h>
#include "logic/Env.h"
#include "logic/minecraft/MinecraftVersionList.h" #include "logic/minecraft/MinecraftVersionList.h"
MinecraftInstance::MinecraftInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir) MinecraftInstance::MinecraftInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir)
@ -51,6 +51,5 @@ QString MinecraftInstance::minecraftRoot() const
std::shared_ptr< BaseVersionList > MinecraftInstance::versionList() const std::shared_ptr< BaseVersionList > MinecraftInstance::versionList() const
{ {
return std::dynamic_pointer_cast<BaseVersionList>(MMC->minecraftlist()); return ENV.getVersionList("net.minecraft");
} }

View File

@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "MultiMC.h"
#include "BuildConfig.h" #include "BuildConfig.h"
#include "logic/minecraft/MinecraftProcess.h" #include "logic/minecraft/MinecraftProcess.h"
@ -26,6 +25,7 @@
#include <QProcessEnvironment> #include <QProcessEnvironment>
#include <QRegularExpression> #include <QRegularExpression>
#include <QStandardPaths> #include <QStandardPaths>
#include <QCoreApplication>
#include "osutils.h" #include "osutils.h"
#include "pathutils.h" #include "pathutils.h"

View File

@ -3,7 +3,6 @@
#include "VersionBuildError.h" #include "VersionBuildError.h"
#include "VersionBuilder.h" #include "VersionBuilder.h"
#include "ProfileUtils.h" #include "ProfileUtils.h"
#include "MultiMC.h"
#include "logic/settings/SettingsObject.h" #include "logic/settings/SettingsObject.h"
bool MinecraftVersion::usesLegacyLauncher() bool MinecraftVersion::usesLegacyLauncher()

View File

@ -2,8 +2,7 @@
#include "logic/minecraft/VersionBuildError.h" #include "logic/minecraft/VersionBuildError.h"
#include "logic/OneSixInstance.h" #include "logic/OneSixInstance.h"
#include "logic/minecraft/MinecraftVersionList.h" #include "logic/minecraft/MinecraftVersionList.h"
#include "logic/Env.h"
#include "MultiMC.h"
#include <pathutils.h> #include <pathutils.h>
#include <QDir> #include <QDir>
@ -73,8 +72,7 @@ void OneSixProfileStrategy::loadDefaultBuiltinPatches()
} }
else else
{ {
auto minecraftList = MMC->minecraftlist(); auto mcversion = ENV.getVersion("net.minecraft", m_instance->intendedVersionId());
auto mcversion = minecraftList->findVersion(m_instance->intendedVersionId());
minecraftPatch = std::dynamic_pointer_cast<ProfilePatch>(mcversion); minecraftPatch = std::dynamic_pointer_cast<ProfilePatch>(mcversion);
} }
if (!minecraftPatch) if (!minecraftPatch)

View File

@ -15,7 +15,6 @@
#include "NetJob.h" #include "NetJob.h"
#include "pathutils.h" #include "pathutils.h"
#include "MultiMC.h"
#include "MD5EtagDownload.h" #include "MD5EtagDownload.h"
#include "ByteArrayDownload.h" #include "ByteArrayDownload.h"
#include "CacheDownload.h" #include "CacheDownload.h"