Split parsing/applying. Better error logging. Fix crash.
This commit is contained in:
parent
966f9d1206
commit
f9ea3dbfde
@ -162,7 +162,7 @@ void OneSixModEditDialog::on_forgeBtn_clicked()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_inst->reloadFullVersion(this);
|
m_inst->reloadVersion(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneSixModEditDialog::on_liteloaderBtn_clicked()
|
void OneSixModEditDialog::on_liteloaderBtn_clicked()
|
||||||
@ -184,7 +184,7 @@ void OneSixModEditDialog::on_liteloaderBtn_clicked()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_inst->reloadFullVersion(this);
|
m_inst->reloadVersion(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#include <quazipfile.h>
|
#include <quazipfile.h>
|
||||||
#include <pathutils.h>
|
#include <pathutils.h>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include <QRegularExpressionMatch>
|
||||||
#include "MultiMC.h"
|
#include "MultiMC.h"
|
||||||
#include "OneSixInstance.h"
|
#include "OneSixInstance.h"
|
||||||
|
|
||||||
@ -146,36 +148,71 @@ bool ForgeInstaller::add(OneSixInstance *to)
|
|||||||
QJsonObject libObj = lib->toJson();
|
QJsonObject libObj = lib->toJson();
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
bool equals = false;
|
||||||
// find an entry that matches this one
|
// find an entry that matches this one
|
||||||
for (auto tolib : to->getFullVersion()->libraries)
|
for (auto tolib : to->getNonCustomVersion()->libraries)
|
||||||
{
|
{
|
||||||
if (tolib->name() != libName)
|
if (tolib->name() != libName)
|
||||||
continue;
|
continue;
|
||||||
found = true;
|
found = true;
|
||||||
|
if (tolib->toJson() == libObj)
|
||||||
|
{
|
||||||
|
equals = true;
|
||||||
|
}
|
||||||
// replace lib
|
// replace lib
|
||||||
libObj.insert("insert", QString("apply"));
|
libObj.insert("insert", QString("apply"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (equals)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
// add lib
|
// add lib
|
||||||
QJsonObject insertObj;
|
QJsonObject insertObj;
|
||||||
insertObj.insert("before", to->getFullVersion()->libraries.at(sliding_insert_window)->rawName());
|
insertObj.insert(
|
||||||
|
"before",
|
||||||
|
to->getFullVersion()->libraries.at(sliding_insert_window + 1)->rawName());
|
||||||
libObj.insert("insert", insertObj);
|
libObj.insert("insert", insertObj);
|
||||||
sliding_insert_window++;
|
sliding_insert_window++;
|
||||||
}
|
}
|
||||||
librariesPlus.append(libObj);
|
librariesPlus.prepend(libObj);
|
||||||
}
|
}
|
||||||
obj.insert("+libraries", librariesPlus);
|
obj.insert("+libraries", librariesPlus);
|
||||||
obj.insert("mainClass", m_forge_version->mainClass);
|
obj.insert("mainClass", m_forge_version->mainClass);
|
||||||
obj.insert("minecraftArguments", m_forge_version->minecraftArguments);
|
QString args = m_forge_version->minecraftArguments;
|
||||||
obj.insert("processArguments", m_forge_version->processArguments);
|
QStringList tweakers;
|
||||||
|
{
|
||||||
|
QRegularExpression expression("--tweakClass ([a-zA-Z0-9\\.]*)");
|
||||||
|
QRegularExpressionMatch match = expression.match(args);
|
||||||
|
while (match.hasMatch())
|
||||||
|
{
|
||||||
|
tweakers.append(match.captured(1));
|
||||||
|
args.remove(match.capturedStart(), match.capturedLength());
|
||||||
|
match = expression.match(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!args.isEmpty() && args != to->getNonCustomVersion()->minecraftArguments)
|
||||||
|
{
|
||||||
|
obj.insert("minecraftArguments", args);
|
||||||
|
}
|
||||||
|
if (!tweakers.isEmpty())
|
||||||
|
{
|
||||||
|
obj.insert("+tweakers", QJsonArray::fromStringList(tweakers));
|
||||||
|
}
|
||||||
|
if (!m_forge_version->processArguments.isEmpty() &&
|
||||||
|
m_forge_version->processArguments != to->getNonCustomVersion()->processArguments)
|
||||||
|
{
|
||||||
|
obj.insert("processArguments", m_forge_version->processArguments);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile file(filename(to->instanceRoot()));
|
QFile file(filename(to->instanceRoot()));
|
||||||
if (!file.open(QFile::WriteOnly))
|
if (!file.open(QFile::WriteOnly))
|
||||||
{
|
{
|
||||||
QLOG_ERROR() << "Error opening" << file.fileName() << "for reading:" << file.errorString();
|
QLOG_ERROR() << "Error opening" << file.fileName()
|
||||||
|
<< "for reading:" << file.errorString();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
file.write(QJsonDocument(obj).toJson());
|
file.write(QJsonDocument(obj).toJson());
|
||||||
|
@ -55,7 +55,7 @@ slots:
|
|||||||
setStatus(tr("Installing Forge..."));
|
setStatus(tr("Installing Forge..."));
|
||||||
QString forgePath = entry->getFullPath();
|
QString forgePath = entry->getFullPath();
|
||||||
ForgeInstaller forge(forgePath, forgeVersion->universal_url);
|
ForgeInstaller forge(forgePath, forgeVersion->universal_url);
|
||||||
if (!instance->reloadFullVersion())
|
if (!instance->reloadVersion())
|
||||||
{
|
{
|
||||||
emitFailed(tr("Couldn't load the version config"));
|
emitFailed(tr("Couldn't load the version config"));
|
||||||
return;
|
return;
|
||||||
|
@ -35,13 +35,14 @@ OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *settings,
|
|||||||
d->m_settings->registerSetting("IntendedVersion", "");
|
d->m_settings->registerSetting("IntendedVersion", "");
|
||||||
d->m_settings->registerSetting("ShouldUpdate", false);
|
d->m_settings->registerSetting("ShouldUpdate", false);
|
||||||
d->version.reset(new OneSixVersion(this, this));
|
d->version.reset(new OneSixVersion(this, this));
|
||||||
|
d->nonCustomVersion.reset(new OneSixVersion(this, this));
|
||||||
if (QDir(instanceRoot()).exists("version.json"))
|
if (QDir(instanceRoot()).exists("version.json"))
|
||||||
{
|
{
|
||||||
reloadFullVersion();
|
reloadVersion();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
clearFullVersion();
|
clearVersion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,6 +140,10 @@ QStringList OneSixInstance::processMinecraftArgs(MojangAccountPtr account)
|
|||||||
I_D(OneSixInstance);
|
I_D(OneSixInstance);
|
||||||
auto version = d->version;
|
auto version = d->version;
|
||||||
QString args_pattern = version->minecraftArguments;
|
QString args_pattern = version->minecraftArguments;
|
||||||
|
for (auto tweaker : version->tweakers)
|
||||||
|
{
|
||||||
|
args_pattern += " --tweakClass " + tweaker;
|
||||||
|
}
|
||||||
|
|
||||||
QMap<QString, QString> token_mapping;
|
QMap<QString, QString> token_mapping;
|
||||||
// yggdrasil!
|
// yggdrasil!
|
||||||
@ -287,7 +292,7 @@ bool OneSixInstance::setIntendedVersionId(QString version)
|
|||||||
settings().set("IntendedVersion", version);
|
settings().set("IntendedVersion", version);
|
||||||
setShouldUpdate(true);
|
setShouldUpdate(true);
|
||||||
QFile::remove(PathCombine(instanceRoot(), "version.json"));
|
QFile::remove(PathCombine(instanceRoot(), "version.json"));
|
||||||
clearFullVersion();
|
clearVersion();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,28 +328,39 @@ QString OneSixInstance::currentVersionId() const
|
|||||||
return intendedVersionId();
|
return intendedVersionId();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OneSixInstance::reloadFullVersion(QWidget *widgetParent)
|
bool OneSixInstance::reloadVersion(QWidget *widgetParent)
|
||||||
{
|
{
|
||||||
I_D(OneSixInstance);
|
I_D(OneSixInstance);
|
||||||
|
|
||||||
bool ret = d->version->reload(widgetParent);
|
bool ret = d->version->reload(widgetParent);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
ret = d->nonCustomVersion->reload(widgetParent, true);
|
||||||
|
}
|
||||||
emit versionReloaded();
|
emit versionReloaded();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneSixInstance::clearFullVersion()
|
void OneSixInstance::clearVersion()
|
||||||
{
|
{
|
||||||
I_D(OneSixInstance);
|
I_D(OneSixInstance);
|
||||||
d->version->clear();
|
d->version->clear();
|
||||||
|
d->nonCustomVersion->clear();
|
||||||
emit versionReloaded();
|
emit versionReloaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<OneSixVersion> OneSixInstance::getFullVersion()
|
std::shared_ptr<OneSixVersion> OneSixInstance::getFullVersion() const
|
||||||
{
|
{
|
||||||
I_D(OneSixInstance);
|
I_D(const OneSixInstance);
|
||||||
return d->version;
|
return d->version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<OneSixVersion> OneSixInstance::getNonCustomVersion() const
|
||||||
|
{
|
||||||
|
I_D(const OneSixInstance);
|
||||||
|
return d->nonCustomVersion;
|
||||||
|
}
|
||||||
|
|
||||||
QString OneSixInstance::defaultBaseJar() const
|
QString OneSixInstance::defaultBaseJar() const
|
||||||
{
|
{
|
||||||
return "versions/" + intendedVersionId() + "/" + intendedVersionId() + ".jar";
|
return "versions/" + intendedVersionId() + "/" + intendedVersionId() + ".jar";
|
||||||
|
@ -52,11 +52,13 @@ public:
|
|||||||
virtual QDialog *createModEditDialog(QWidget *parent) override;
|
virtual QDialog *createModEditDialog(QWidget *parent) override;
|
||||||
|
|
||||||
/// reload the full version json files. return true on success!
|
/// reload the full version json files. return true on success!
|
||||||
bool reloadFullVersion(QWidget *widgetParent = 0);
|
bool reloadVersion(QWidget *widgetParent = 0);
|
||||||
/// clears all version information in preparation for an update
|
/// clears all version information in preparation for an update
|
||||||
void clearFullVersion();
|
void clearVersion();
|
||||||
/// get the current full version info
|
/// get the current full version info
|
||||||
std::shared_ptr<OneSixVersion> getFullVersion();
|
std::shared_ptr<OneSixVersion> getFullVersion() const;
|
||||||
|
/// gets the current version info, excluding custom.json
|
||||||
|
std::shared_ptr<OneSixVersion> getNonCustomVersion() const;
|
||||||
/// is the current version original, or custom?
|
/// is the current version original, or custom?
|
||||||
virtual bool versionIsCustom() override;
|
virtual bool versionIsCustom() override;
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
struct OneSixInstancePrivate : public BaseInstancePrivate
|
struct OneSixInstancePrivate : public BaseInstancePrivate
|
||||||
{
|
{
|
||||||
std::shared_ptr<OneSixVersion> version;
|
std::shared_ptr<OneSixVersion> version;
|
||||||
|
std::shared_ptr<OneSixVersion> nonCustomVersion;
|
||||||
std::shared_ptr<ModList> loader_mod_list;
|
std::shared_ptr<ModList> loader_mod_list;
|
||||||
std::shared_ptr<ModList> resource_pack_list;
|
std::shared_ptr<ModList> resource_pack_list;
|
||||||
};
|
};
|
||||||
|
@ -93,6 +93,10 @@ void OneSixLibrary::addNative(OpSys os, const QString &suffix)
|
|||||||
m_is_native = true;
|
m_is_native = true;
|
||||||
m_native_suffixes[os] = suffix;
|
m_native_suffixes[os] = suffix;
|
||||||
}
|
}
|
||||||
|
void OneSixLibrary::clearSuffixes()
|
||||||
|
{
|
||||||
|
m_native_suffixes.clear();
|
||||||
|
}
|
||||||
void OneSixLibrary::setRules(QList<std::shared_ptr<Rule>> rules)
|
void OneSixLibrary::setRules(QList<std::shared_ptr<Rule>> rules)
|
||||||
{
|
{
|
||||||
m_rules = rules;
|
m_rules = rules;
|
||||||
@ -176,7 +180,7 @@ bool OneSixLibrary::extractTo(QString target_dir)
|
|||||||
cooked_storage.replace("${arch}", "32");
|
cooked_storage.replace("${arch}", "32");
|
||||||
QString origin = PathCombine("libraries", cooked_storage);
|
QString origin = PathCombine("libraries", cooked_storage);
|
||||||
QString target_dir_cooked = PathCombine(target_dir, "32");
|
QString target_dir_cooked = PathCombine(target_dir, "32");
|
||||||
if(!ensureFolderPathExists(target_dir_cooked))
|
if (!ensureFolderPathExists(target_dir_cooked))
|
||||||
{
|
{
|
||||||
QLOG_ERROR() << "Couldn't create folder " + target_dir_cooked;
|
QLOG_ERROR() << "Couldn't create folder " + target_dir_cooked;
|
||||||
return false;
|
return false;
|
||||||
@ -191,7 +195,7 @@ bool OneSixLibrary::extractTo(QString target_dir)
|
|||||||
cooked_storage.replace("${arch}", "64");
|
cooked_storage.replace("${arch}", "64");
|
||||||
origin = PathCombine("libraries", cooked_storage);
|
origin = PathCombine("libraries", cooked_storage);
|
||||||
target_dir_cooked = PathCombine(target_dir, "64");
|
target_dir_cooked = PathCombine(target_dir, "64");
|
||||||
if(!ensureFolderPathExists(target_dir_cooked))
|
if (!ensureFolderPathExists(target_dir_cooked))
|
||||||
{
|
{
|
||||||
QLOG_ERROR() << "Couldn't create folder " + target_dir_cooked;
|
QLOG_ERROR() << "Couldn't create folder " + target_dir_cooked;
|
||||||
return false;
|
return false;
|
||||||
@ -205,7 +209,7 @@ bool OneSixLibrary::extractTo(QString target_dir)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!ensureFolderPathExists(target_dir))
|
if (!ensureFolderPathExists(target_dir))
|
||||||
{
|
{
|
||||||
QLOG_ERROR() << "Couldn't create folder " + target_dir;
|
QLOG_ERROR() << "Couldn't create folder " + target_dir;
|
||||||
return false;
|
return false;
|
||||||
@ -230,8 +234,10 @@ QJsonObject OneSixLibrary::toJson()
|
|||||||
libRoot.insert("MMC-hint", m_hint);
|
libRoot.insert("MMC-hint", m_hint);
|
||||||
if (m_base_url != "http://" + URLConstants::AWS_DOWNLOAD_LIBRARIES &&
|
if (m_base_url != "http://" + URLConstants::AWS_DOWNLOAD_LIBRARIES &&
|
||||||
m_base_url != "https://" + URLConstants::AWS_DOWNLOAD_LIBRARIES &&
|
m_base_url != "https://" + URLConstants::AWS_DOWNLOAD_LIBRARIES &&
|
||||||
m_base_url != "https://" + URLConstants::LIBRARY_BASE)
|
m_base_url != "https://" + URLConstants::LIBRARY_BASE && !m_base_url.isEmpty())
|
||||||
|
{
|
||||||
libRoot.insert("url", m_base_url);
|
libRoot.insert("url", m_base_url);
|
||||||
|
}
|
||||||
if (isNative() && m_native_suffixes.size())
|
if (isNative() && m_native_suffixes.size())
|
||||||
{
|
{
|
||||||
QJsonObject nativeList;
|
QJsonObject nativeList;
|
||||||
|
@ -107,6 +107,8 @@ public:
|
|||||||
void setIsNative();
|
void setIsNative();
|
||||||
/// Attach a name suffix to the specified OS native
|
/// Attach a name suffix to the specified OS native
|
||||||
void addNative(OpSys os, const QString &suffix);
|
void addNative(OpSys os, const QString &suffix);
|
||||||
|
/// Clears all suffixes
|
||||||
|
void clearSuffixes();
|
||||||
/// Set the load rules
|
/// Set the load rules
|
||||||
void setRules(QList<std::shared_ptr<Rule>> rules);
|
void setRules(QList<std::shared_ptr<Rule>> rules);
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ void OneSixUpdate::versionFileFinished()
|
|||||||
{
|
{
|
||||||
finfo.remove();
|
finfo.remove();
|
||||||
}
|
}
|
||||||
inst->reloadFullVersion();
|
inst->reloadVersion();
|
||||||
|
|
||||||
jarlibStart();
|
jarlibStart();
|
||||||
}
|
}
|
||||||
@ -235,7 +235,7 @@ void OneSixUpdate::jarlibStart()
|
|||||||
setStatus(tr("Getting the library files from Mojang..."));
|
setStatus(tr("Getting the library files from Mojang..."));
|
||||||
QLOG_INFO() << m_inst->name() << ": downloading libraries";
|
QLOG_INFO() << m_inst->name() << ": downloading libraries";
|
||||||
OneSixInstance *inst = (OneSixInstance *)m_inst;
|
OneSixInstance *inst = (OneSixInstance *)m_inst;
|
||||||
bool successful = inst->reloadFullVersion();
|
bool successful = inst->reloadVersion();
|
||||||
if (!successful)
|
if (!successful)
|
||||||
{
|
{
|
||||||
emitFailed("Failed to load the version description file. It might be "
|
emitFailed("Failed to load the version description file. It might be "
|
||||||
|
@ -25,9 +25,9 @@ OneSixVersion::OneSixVersion(OneSixInstance *instance, QObject *parent)
|
|||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OneSixVersion::reload(QWidget *widgetParent)
|
bool OneSixVersion::reload(QWidget *widgetParent, const bool excludeCustom)
|
||||||
{
|
{
|
||||||
return OneSixVersionBuilder::build(this, m_instance, widgetParent);
|
return OneSixVersionBuilder::build(this, m_instance, widgetParent, excludeCustom);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneSixVersion::clear()
|
void OneSixVersion::clear()
|
||||||
@ -42,6 +42,7 @@ void OneSixVersion::clear()
|
|||||||
minimumLauncherVersion = 0xDEADBEAF;
|
minimumLauncherVersion = 0xDEADBEAF;
|
||||||
mainClass.clear();
|
mainClass.clear();
|
||||||
libraries.clear();
|
libraries.clear();
|
||||||
|
tweakers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneSixVersion::dump() const
|
void OneSixVersion::dump() const
|
||||||
|
@ -38,7 +38,7 @@ public:
|
|||||||
virtual int columnCount(const QModelIndex &parent) const;
|
virtual int columnCount(const QModelIndex &parent) const;
|
||||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
|
|
||||||
bool reload(QWidget *widgetParent);
|
bool reload(QWidget *widgetParent, const bool excludeCustom = false);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void dump() const;
|
void dump() const;
|
||||||
@ -78,6 +78,10 @@ public:
|
|||||||
* writing)
|
* writing)
|
||||||
*/
|
*/
|
||||||
int minimumLauncherVersion = 0xDEADBEEF;
|
int minimumLauncherVersion = 0xDEADBEEF;
|
||||||
|
/**
|
||||||
|
* A list of all tweaker classes
|
||||||
|
*/
|
||||||
|
QStringList tweakers;
|
||||||
/**
|
/**
|
||||||
* The main class to load first
|
* The main class to load first
|
||||||
*/
|
*/
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -22,12 +22,13 @@ class OneSixInstance;
|
|||||||
class QWidget;
|
class QWidget;
|
||||||
class QJsonObject;
|
class QJsonObject;
|
||||||
class QFileInfo;
|
class QFileInfo;
|
||||||
|
class VersionFile;
|
||||||
|
|
||||||
class OneSixVersionBuilder
|
class OneSixVersionBuilder
|
||||||
{
|
{
|
||||||
OneSixVersionBuilder();
|
OneSixVersionBuilder();
|
||||||
public:
|
public:
|
||||||
static bool build(OneSixVersion *version, OneSixInstance *instance, QWidget *widgetParent);
|
static bool build(OneSixVersion *version, OneSixInstance *instance, QWidget *widgetParent, const bool excludeCustom);
|
||||||
static bool read(OneSixVersion *version, const QJsonObject &obj);
|
static bool read(OneSixVersion *version, const QJsonObject &obj);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -35,19 +36,8 @@ private:
|
|||||||
OneSixInstance *m_instance;
|
OneSixInstance *m_instance;
|
||||||
QWidget *m_widgetParent;
|
QWidget *m_widgetParent;
|
||||||
|
|
||||||
enum Type
|
bool build(const bool excludeCustom);
|
||||||
{
|
|
||||||
Override,
|
|
||||||
Add,
|
|
||||||
Remove
|
|
||||||
};
|
|
||||||
|
|
||||||
bool build();
|
|
||||||
bool read(const QJsonObject &obj);
|
bool read(const QJsonObject &obj);
|
||||||
|
|
||||||
void clear();
|
bool read(const QFileInfo &fileInfo, const bool requireOrder, VersionFile *out);
|
||||||
bool apply(const QJsonObject &object);
|
|
||||||
bool applyLibrary(const QJsonObject &lib, const Type type);
|
|
||||||
|
|
||||||
bool read(const QFileInfo &fileInfo, QJsonObject *out);
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user