aboutsummaryrefslogtreecommitdiff
path: root/launcher/minecraft/MinecraftInstance.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/minecraft/MinecraftInstance.cpp')
-rw-r--r--launcher/minecraft/MinecraftInstance.cpp48
1 files changed, 26 insertions, 22 deletions
diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp
index fa6535b0..c677b677 100644
--- a/launcher/minecraft/MinecraftInstance.cpp
+++ b/launcher/minecraft/MinecraftInstance.cpp
@@ -480,25 +480,25 @@ QProcessEnvironment MinecraftInstance::createLaunchEnvironment()
static QString replaceTokensIn(QString text, QMap<QString, QString> with)
{
+ // TODO: does this still work??
QString result;
- QRegExp token_regexp("\\$\\{(.+)\\}");
- token_regexp.setMinimal(true);
+ QRegularExpression token_regexp("\\$\\{(.+)\\}", QRegularExpression::InvertedGreedinessOption);
QStringList list;
- int tail = 0;
- int head = 0;
- while ((head = token_regexp.indexIn(text, head)) != -1)
+ QRegularExpressionMatchIterator i = token_regexp.globalMatch(text);
+ int lastCapturedEnd = 0;
+ while (i.hasNext())
{
- result.append(text.mid(tail, head - tail));
- QString key = token_regexp.cap(1);
+ QRegularExpressionMatch match = i.next();
+ result.append(text.mid(lastCapturedEnd, match.capturedStart()));
+ QString key = match.captured(1);
auto iter = with.find(key);
if (iter != with.end())
{
result.append(*iter);
}
- head += token_regexp.matchedLength();
- tail = head;
+ lastCapturedEnd = match.capturedEnd();
}
- result.append(text.mid(tail));
+ result.append(text.mid(lastCapturedEnd));
return result;
}
@@ -547,7 +547,11 @@ QStringList MinecraftInstance::processMinecraftArgs(
token_mapping["assets_root"] = absAssetsDir;
token_mapping["assets_index_name"] = assets->id;
+#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
+ QStringList parts = args_pattern.split(' ', Qt::SkipEmptyParts);
+#else
QStringList parts = args_pattern.split(' ', QString::SkipEmptyParts);
+#endif
for (int i = 0; i < parts.length(); i++)
{
parts[i] = replaceTokensIn(parts[i], token_mapping);
@@ -703,24 +707,24 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session, Minecr
{
out << QString("%1:").arg(label);
auto modList = model.allMods();
- std::sort(modList.begin(), modList.end(), [](Mod &a, Mod &b) {
- auto aName = a.fileinfo().completeBaseName();
- auto bName = b.fileinfo().completeBaseName();
+ std::sort(modList.begin(), modList.end(), [](Mod::Ptr a, Mod::Ptr b) {
+ auto aName = a->fileinfo().completeBaseName();
+ auto bName = b->fileinfo().completeBaseName();
return aName.localeAwareCompare(bName) < 0;
});
- for(auto & mod: modList)
+ for(auto mod: modList)
{
- if(mod.type() == Mod::MOD_FOLDER)
+ if(mod->type() == Mod::MOD_FOLDER)
{
- out << u8" [📁] " + mod.fileinfo().completeBaseName() + " (folder)";
+ out << u8" [🖿] " + mod->fileinfo().completeBaseName() + " (folder)";
continue;
}
- if(mod.enabled()) {
- out << u8" [✔️] " + mod.fileinfo().completeBaseName();
+ if(mod->enabled()) {
+ out << u8" [✔] " + mod->fileinfo().completeBaseName();
}
else {
- out << u8" [❌] " + mod.fileinfo().completeBaseName() + " (disabled)";
+ out << u8" [✘] " + mod->fileinfo().completeBaseName() + " (disabled)";
}
}
@@ -1139,16 +1143,16 @@ std::shared_ptr<GameOptions> MinecraftInstance::gameOptionsModel() const
return m_game_options;
}
-QList< Mod > MinecraftInstance::getJarMods() const
+QList<Mod*> MinecraftInstance::getJarMods() const
{
auto profile = m_components->getProfile();
- QList<Mod> mods;
+ QList<Mod*> mods;
for (auto jarmod : profile->getJarMods())
{
QStringList jar, temp1, temp2, temp3;
jarmod->getApplicableFiles(currentSystem, jar, temp1, temp2, temp3, jarmodsPath().absolutePath());
// QString filePath = jarmodsPath().absoluteFilePath(jarmod->filename(currentSystem));
- mods.push_back(Mod(QFileInfo(jar[0])));
+ mods.push_back(new Mod(QFileInfo(jar[0])));
}
return mods;
}