NOISSUE Split MultiMC app object into MultiMC and Env

This commit is contained in:
Petr Mrázek
2015-01-31 16:59:03 +01:00
parent e508728246
commit 6f3aa65bd6
44 changed files with 343 additions and 325 deletions

View File

@ -21,6 +21,7 @@
#include "logic/OneSixInstance.h"
#include "logic/forge/ForgeVersionList.h"
#include "logic/minecraft/VersionFilterData.h"
#include "logic/Env.h"
#include <quazip.h>
#include <quazipfile.h>
@ -28,7 +29,7 @@
#include <QStringList>
#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include "MultiMC.h"
#include <QJsonDocument>
#include <QJsonArray>
#include <QSaveFile>
@ -86,7 +87,7 @@ void ForgeInstaller::prepare(const QString &filename, const QString &universalUr
// where do we put the library? decode the mojang path
OneSixLibrary lib(libraryName);
auto cacheentry = MMC->metacache()->resolveEntry("libraries", lib.storagePath());
auto cacheentry = ENV.metacache()->resolveEntry("libraries", lib.storagePath());
finalPath = "libraries/" + lib.storagePath();
if (!ensureFilePathExists(finalPath))
return;
@ -110,7 +111,7 @@ void ForgeInstaller::prepare(const QString &filename, const QString &universalUr
cacheentry->stale = false;
cacheentry->md5sum = md5sum.result().toHex().constData();
MMC->metacache()->updateEntry(cacheentry);
ENV.metacache()->updateEntry(cacheentry);
}
file.close();
@ -275,7 +276,7 @@ bool ForgeInstaller::addLegacy(OneSixInstance *to)
{
return false;
}
auto entry = MMC->metacache()->resolveEntry("minecraftforge", m_forge_version->filename());
auto entry = ENV.metacache()->resolveEntry("minecraftforge", m_forge_version->filename());
finalPath = PathCombine(to->jarModsDir(), m_forge_version->filename());
if (!ensureFilePathExists(finalPath))
{
@ -346,7 +347,7 @@ protected:
}
void prepare(ForgeVersionPtr forgeVersion)
{
auto entry = MMC->metacache()->resolveEntry("minecraftforge", forgeVersion->filename());
auto entry = ENV.metacache()->resolveEntry("minecraftforge", forgeVersion->filename());
auto installFunction = [this, entry, forgeVersion]()
{
if (!install(entry, forgeVersion))

View File

@ -1,4 +1,4 @@
#include "MultiMC.h"
#include "logic/Env.h"
#include "ForgeMirrors.h"
#include "logger/QsLog.h"
#include <algorithm>
@ -18,7 +18,7 @@ void ForgeMirrors::start()
QLOG_INFO() << "Downloading " << m_url.toString();
QNetworkRequest request(m_url);
request.setHeader(QNetworkRequest::UserAgentHeader, "MultiMC/5.0 (Uncached)");
auto worker = MMC->qnam();
auto worker = ENV.qnam();
QNetworkReply *rep = worker->get(request);
m_reply = std::shared_ptr<QNetworkReply>(rep);

View File

@ -17,7 +17,7 @@
#include "logic/forge/ForgeVersion.h"
#include "logic/net/NetJob.h"
#include "logic/net/URLConstants.h"
#include "MultiMC.h"
#include "logic/Env.h"
#include <QtNetwork>
#include <QtXml>
@ -162,8 +162,8 @@ void ForgeListLoadTask::executeTask()
setStatus(tr("Fetching Forge version lists..."));
auto job = new NetJob("Version index");
// we do not care if the version is stale or not.
auto forgeListEntry = MMC->metacache()->resolveEntry("minecraftforge", "list.json");
auto gradleForgeListEntry = MMC->metacache()->resolveEntry("minecraftforge", "json");
auto forgeListEntry = ENV.metacache()->resolveEntry("minecraftforge", "list.json");
auto gradleForgeListEntry = ENV.metacache()->resolveEntry("minecraftforge", "json");
// verify by poking the server.
forgeListEntry->stale = true;

View File

@ -13,7 +13,7 @@
* limitations under the License.
*/
#include "MultiMC.h"
#include "logic/Env.h"
#include "ForgeXzDownload.h"
#include <pathutils.h>
@ -67,7 +67,7 @@ void ForgeXzDownload::start()
request.setRawHeader(QString("If-None-Match").toLatin1(), m_entry->etag.toLatin1());
request.setHeader(QNetworkRequest::UserAgentHeader, "MultiMC/5.0 (Cached)");
auto worker = MMC->qnam();
auto worker = ENV.qnam();
QNetworkReply *rep = worker->get(request);
m_reply = std::shared_ptr<QNetworkReply>(rep);
@ -382,7 +382,7 @@ void ForgeXzDownload::decompressAndInstall()
m_entry->local_changed_timestamp =
output_file_info.lastModified().toUTC().toMSecsSinceEpoch();
m_entry->stale = false;
MMC->metacache()->updateEntry(m_entry);
ENV.metacache()->updateEntry(m_entry);
m_reply.reset();
emit succeeded(m_index_within_job);