GH-1016 print list of mods, coremods and jarmods

Includes a change to jar mods, where they gain an 'originalName' attribute used only for display
This commit is contained in:
Petr Mrázek 2015-05-31 21:45:28 +02:00
parent 9920062003
commit 6fd18a5cce
5 changed files with 32 additions and 6 deletions

View File

@ -2,7 +2,7 @@
#include "MMCJson.h"
using namespace MMCJson;
JarmodPtr Jarmod::fromJson(const QJsonObject &libObj, const QString &filename)
JarmodPtr Jarmod::fromJson(const QJsonObject &libObj, const QString &filename, const QString &originalName)
{
JarmodPtr out(new Jarmod());
if (!libObj.contains("name"))
@ -11,6 +11,7 @@ JarmodPtr Jarmod::fromJson(const QJsonObject &libObj, const QString &filename)
"contains a jarmod that doesn't have a 'name' field");
}
out->name = libObj.value("name").toString();
out->originalName = libObj.value("originalName").toString();
return out;
}
@ -18,5 +19,9 @@ QJsonObject Jarmod::toJson()
{
QJsonObject out;
writeString(out, "name", name);
if(!originalName.isEmpty())
{
writeString(out, "originalName", originalName);
}
return out;
}

View File

@ -7,8 +7,10 @@ typedef std::shared_ptr<Jarmod> JarmodPtr;
class Jarmod
{
public: /* methods */
static JarmodPtr fromJson(const QJsonObject &libObj, const QString &filename);
static JarmodPtr fromJson(const QJsonObject &libObj, const QString &filename,
const QString &originalName);
QJsonObject toJson();
public: /* data */
QString name;
QString originalName;
};

View File

@ -136,17 +136,29 @@ BaseProcess *OneSixInstance::prepareForLaunch(AuthSessionPtr session)
for(auto & mod: loaderModList()->allMods())
{
launchScript += "mod " + mod.filename().absoluteFilePath() + "\n";;
if(!mod.enabled())
continue;
if(mod.type() == Mod::MOD_FOLDER)
continue;
// TODO: proper implementation would need to descend into folders.
launchScript += "mod " + mod.filename().completeBaseName() + "\n";;
}
for(auto & coremod: coreModList()->allMods())
{
launchScript += "coremod " + coremod.filename().absoluteFilePath() + "\n";;
if(!coremod.enabled())
continue;
if(coremod.type() == Mod::MOD_FOLDER)
continue;
// TODO: proper implementation would need to descend into folders.
launchScript += "coremod " + coremod.filename().completeBaseName() + "\n";;
}
for(auto & jarmod: m_version->jarMods)
{
launchScript += "jarmod " + jarmod->name + "\n";;
launchScript += "jarmod " + jarmod->originalName + " (" + jarmod->name + ")\n";
}
// libraries and class path.

View File

@ -368,6 +368,7 @@ bool OneSixProfileStrategy::installJarMods(QStringList filepaths)
auto f = std::make_shared<VersionFile>();
auto jarMod = std::make_shared<Jarmod>();
jarMod->name = target_filename;
jarMod->originalName = sourceInfo.completeBaseName();
f->jarMods.append(jarMod);
f->name = target_name;
f->fileId = target_id;

View File

@ -155,7 +155,13 @@ VersionFilePtr VersionFile::fromJson(const QJsonDocument &doc, const QString &fi
{
QJsonObject libObj = ensureObject(libVal);
// parse the jarmod
auto lib = Jarmod::fromJson(libObj, filename);
auto lib = Jarmod::fromJson(libObj, filename, out->name);
if(lib->originalName.isEmpty())
{
auto fixed = out->name;
fixed.remove(" (jar mod)");
lib->originalName = out->name;
}
// and add to jar mods
out->jarMods.append(lib);
}