aboutsummaryrefslogtreecommitdiff
path: root/launcher/minecraft
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/minecraft')
-rw-r--r--launcher/minecraft/MinecraftInstance.cpp41
-rw-r--r--launcher/minecraft/MinecraftInstance.h4
-rw-r--r--launcher/minecraft/mod/ResourcePack.cpp7
-rw-r--r--launcher/minecraft/mod/ResourcePack.h2
-rw-r--r--launcher/minecraft/mod/TexturePack.cpp5
-rw-r--r--launcher/minecraft/mod/TexturePack.h2
-rw-r--r--launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp27
-rw-r--r--launcher/minecraft/mod/tasks/LocalResourcePackParseTask.h12
-rw-r--r--launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp27
-rw-r--r--launcher/minecraft/mod/tasks/LocalTexturePackParseTask.h12
10 files changed, 94 insertions, 45 deletions
diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp
index de22b365..a3adb268 100644
--- a/launcher/minecraft/MinecraftInstance.cpp
+++ b/launcher/minecraft/MinecraftInstance.cpp
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
* Copyright (C) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
+ * Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -436,6 +437,17 @@ QStringList MinecraftInstance::javaArguments()
return args;
}
+QString MinecraftInstance::getLauncher()
+{
+ auto profile = m_components->getProfile();
+
+ // use legacy launcher if the traits are set
+ if (profile->getTraits().contains("legacyLaunch") || profile->getTraits().contains("alphaLaunch"))
+ return "legacy";
+
+ return "standard";
+}
+
QMap<QString, QString> MinecraftInstance::getVariables()
{
QMap<QString, QString> out;
@@ -627,26 +639,13 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session, MinecraftS
launchScript += "sessionId " + session->session + "\n";
}
- // libraries and class path.
- {
- QStringList jars, nativeJars;
- profile->getLibraryFiles(runtimeContext(), jars, nativeJars, getLocalLibraryPath(), binRoot());
- for(auto file: jars)
- {
- launchScript += "cp " + file + "\n";
- }
- for(auto file: nativeJars)
- {
- launchScript += "ext " + file + "\n";
- }
- launchScript += "natives " + getNativePath() + "\n";
- }
-
for (auto trait : profile->getTraits())
{
launchScript += "traits " + trait + "\n";
}
- launchScript += "launcher onesix\n";
+
+ launchScript += "launcher " + getLauncher() + "\n";
+
// qDebug() << "Generated launch script:" << launchScript;
return launchScript;
}
@@ -782,6 +781,8 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session, Minecr
out << "Window size: " + QString::number(width) + " x " + QString::number(height);
}
out << "";
+ out << "Launcher: " + getLauncher();
+ out << "";
return out;
}
@@ -1109,8 +1110,6 @@ std::shared_ptr<ResourcePackFolderModel> MinecraftInstance::resourcePackList() c
if (!m_resource_pack_list)
{
m_resource_pack_list.reset(new ResourcePackFolderModel(resourcePacksDir()));
- m_resource_pack_list->enableInteraction(!isRunning());
- connect(this, &BaseInstance::runningStatusChanged, m_resource_pack_list.get(), &ResourcePackFolderModel::disableInteraction);
}
return m_resource_pack_list;
}
@@ -1120,8 +1119,6 @@ std::shared_ptr<TexturePackFolderModel> MinecraftInstance::texturePackList() con
if (!m_texture_pack_list)
{
m_texture_pack_list.reset(new TexturePackFolderModel(texturePacksDir()));
- m_texture_pack_list->disableInteraction(isRunning());
- connect(this, &BaseInstance::runningStatusChanged, m_texture_pack_list.get(), &ModFolderModel::disableInteraction);
}
return m_texture_pack_list;
}
@@ -1131,8 +1128,6 @@ std::shared_ptr<ShaderPackFolderModel> MinecraftInstance::shaderPackList() const
if (!m_shader_pack_list)
{
m_shader_pack_list.reset(new ShaderPackFolderModel(shaderPacksDir()));
- m_shader_pack_list->disableInteraction(isRunning());
- connect(this, &BaseInstance::runningStatusChanged, m_shader_pack_list.get(), &ModFolderModel::disableInteraction);
}
return m_shader_pack_list;
}
diff --git a/launcher/minecraft/MinecraftInstance.h b/launcher/minecraft/MinecraftInstance.h
index 1895d187..1bbd7b83 100644
--- a/launcher/minecraft/MinecraftInstance.h
+++ b/launcher/minecraft/MinecraftInstance.h
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
+ * Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -130,6 +131,7 @@ public:
QString createLaunchScript(AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin);
/// get arguments passed to java
QStringList javaArguments();
+ QString getLauncher();
/// get variables for launch command variable substitution/environment
QMap<QString, QString> getVariables() override;
diff --git a/launcher/minecraft/mod/ResourcePack.cpp b/launcher/minecraft/mod/ResourcePack.cpp
index 3fc10a2f..4a9ad21b 100644
--- a/launcher/minecraft/mod/ResourcePack.cpp
+++ b/launcher/minecraft/mod/ResourcePack.cpp
@@ -15,7 +15,7 @@ static const QMap<int, std::pair<Version, Version>> s_pack_format_versions = {
{ 3, { Version("1.11"), Version("1.12.2") } }, { 4, { Version("1.13"), Version("1.14.4") } },
{ 5, { Version("1.15"), Version("1.16.1") } }, { 6, { Version("1.16.2"), Version("1.16.5") } },
{ 7, { Version("1.17"), Version("1.17.1") } }, { 8, { Version("1.18"), Version("1.18.2") } },
- { 9, { Version("1.19"), Version("1.19.2") } },
+ { 9, { Version("1.19"), Version("1.19.2") } }, { 11, { Version("1.19.3"), Version("1.19.3") } },
};
void ResourcePack::setPackFormat(int new_format_id)
@@ -114,3 +114,8 @@ bool ResourcePack::applyFilter(QRegularExpression filter) const
return Resource::applyFilter(filter);
}
+
+bool ResourcePack::valid() const
+{
+ return m_pack_format != 0;
+}
diff --git a/launcher/minecraft/mod/ResourcePack.h b/launcher/minecraft/mod/ResourcePack.h
index 03121908..7cb414d8 100644
--- a/launcher/minecraft/mod/ResourcePack.h
+++ b/launcher/minecraft/mod/ResourcePack.h
@@ -42,6 +42,8 @@ class ResourcePack : public Resource {
/** Thread-safe. */
void setImage(QImage new_image);
+ bool valid() const override;
+
[[nodiscard]] auto compare(Resource const& other, SortType type) const -> std::pair<int, bool> override;
[[nodiscard]] bool applyFilter(QRegularExpression filter) const override;
diff --git a/launcher/minecraft/mod/TexturePack.cpp b/launcher/minecraft/mod/TexturePack.cpp
index 796eb69d..99d55584 100644
--- a/launcher/minecraft/mod/TexturePack.cpp
+++ b/launcher/minecraft/mod/TexturePack.cpp
@@ -62,3 +62,8 @@ QPixmap TexturePack::image(QSize size)
TexturePackUtils::process(*this);
return image(size);
}
+
+bool TexturePack::valid() const
+{
+ return m_description != nullptr;
+}
diff --git a/launcher/minecraft/mod/TexturePack.h b/launcher/minecraft/mod/TexturePack.h
index 6aa5e18e..81bd5c69 100644
--- a/launcher/minecraft/mod/TexturePack.h
+++ b/launcher/minecraft/mod/TexturePack.h
@@ -48,6 +48,8 @@ class TexturePack : public Resource {
/** Thread-safe. */
void setImage(QImage new_image);
+ bool valid() const override;
+
protected:
mutable QMutex m_data_lock;
diff --git a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp
index 4f87bc13..6fd4b024 100644
--- a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp
+++ b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp
@@ -28,14 +28,14 @@
namespace ResourcePackUtils {
-bool process(ResourcePack& pack)
+bool process(ResourcePack& pack, ProcessingLevel level)
{
switch (pack.type()) {
case ResourceType::FOLDER:
- ResourcePackUtils::processFolder(pack);
+ ResourcePackUtils::processFolder(pack, level);
return true;
case ResourceType::ZIPFILE:
- ResourcePackUtils::processZIP(pack);
+ ResourcePackUtils::processZIP(pack, level);
return true;
default:
qWarning() << "Invalid type for resource pack parse task!";
@@ -43,7 +43,7 @@ bool process(ResourcePack& pack)
}
}
-void processFolder(ResourcePack& pack)
+void processFolder(ResourcePack& pack, ProcessingLevel level)
{
Q_ASSERT(pack.type() == ResourceType::FOLDER);
@@ -60,6 +60,9 @@ void processFolder(ResourcePack& pack)
mcmeta_file.close();
}
+ if (level == ProcessingLevel::BasicInfoOnly)
+ return;
+
QFileInfo image_file_info(FS::PathCombine(pack.fileinfo().filePath(), "pack.png"));
if (image_file_info.isFile()) {
QFile mcmeta_file(image_file_info.filePath());
@@ -74,7 +77,7 @@ void processFolder(ResourcePack& pack)
}
}
-void processZIP(ResourcePack& pack)
+void processZIP(ResourcePack& pack, ProcessingLevel level)
{
Q_ASSERT(pack.type() == ResourceType::ZIPFILE);
@@ -98,6 +101,11 @@ void processZIP(ResourcePack& pack)
file.close();
}
+ if (level == ProcessingLevel::BasicInfoOnly) {
+ zip.close();
+ return;
+ }
+
if (zip.setCurrentFile("pack.png")) {
if (!file.open(QIODevice::ReadOnly)) {
qCritical() << "Failed to open file in zip.";
@@ -138,6 +146,13 @@ void processPackPNG(ResourcePack& pack, QByteArray&& raw_data)
qWarning() << "Failed to parse pack.png.";
}
}
+
+bool validate(QFileInfo file)
+{
+ ResourcePack rp{ file };
+ return ResourcePackUtils::process(rp, ProcessingLevel::BasicInfoOnly) && rp.valid();
+}
+
} // namespace ResourcePackUtils
LocalResourcePackParseTask::LocalResourcePackParseTask(int token, ResourcePack& rp)
@@ -152,8 +167,6 @@ bool LocalResourcePackParseTask::abort()
void LocalResourcePackParseTask::executeTask()
{
- Q_ASSERT(m_resource_pack.valid());
-
if (!ResourcePackUtils::process(m_resource_pack))
return;
diff --git a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.h b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.h
index d3c25464..69dbd6ad 100644
--- a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.h
+++ b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.h
@@ -26,13 +26,19 @@
#include "tasks/Task.h"
namespace ResourcePackUtils {
-bool process(ResourcePack& pack);
-void processZIP(ResourcePack& pack);
-void processFolder(ResourcePack& pack);
+enum class ProcessingLevel { Full, BasicInfoOnly };
+
+bool process(ResourcePack& pack, ProcessingLevel level = ProcessingLevel::Full);
+
+void processZIP(ResourcePack& pack, ProcessingLevel level = ProcessingLevel::Full);
+void processFolder(ResourcePack& pack, ProcessingLevel level = ProcessingLevel::Full);
void processMCMeta(ResourcePack& pack, QByteArray&& raw_data);
void processPackPNG(ResourcePack& pack, QByteArray&& raw_data);
+
+/** Checks whether a file is valid as a resource pack or not. */
+bool validate(QFileInfo file);
} // namespace ResourcePackUtils
class LocalResourcePackParseTask : public Task {
diff --git a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp
index bf1e308f..adb19aca 100644
--- a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp
+++ b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp
@@ -28,14 +28,14 @@
namespace TexturePackUtils {
-bool process(TexturePack& pack)
+bool process(TexturePack& pack, ProcessingLevel level)
{
switch (pack.type()) {
case ResourceType::FOLDER:
- TexturePackUtils::processFolder(pack);
+ TexturePackUtils::processFolder(pack, level);
return true;
case ResourceType::ZIPFILE:
- TexturePackUtils::processZIP(pack);
+ TexturePackUtils::processZIP(pack, level);
return true;
default:
qWarning() << "Invalid type for resource pack parse task!";
@@ -43,7 +43,7 @@ bool process(TexturePack& pack)
}
}
-void processFolder(TexturePack& pack)
+void processFolder(TexturePack& pack, ProcessingLevel level)
{
Q_ASSERT(pack.type() == ResourceType::FOLDER);
@@ -60,6 +60,9 @@ void processFolder(TexturePack& pack)
mcmeta_file.close();
}
+ if (level == ProcessingLevel::BasicInfoOnly)
+ return;
+
QFileInfo image_file_info(FS::PathCombine(pack.fileinfo().filePath(), "pack.png"));
if (image_file_info.isFile()) {
QFile mcmeta_file(image_file_info.filePath());
@@ -74,7 +77,7 @@ void processFolder(TexturePack& pack)
}
}
-void processZIP(TexturePack& pack)
+void processZIP(TexturePack& pack, ProcessingLevel level)
{
Q_ASSERT(pack.type() == ResourceType::ZIPFILE);
@@ -98,6 +101,11 @@ void processZIP(TexturePack& pack)
file.close();
}
+ if (level == ProcessingLevel::BasicInfoOnly) {
+ zip.close();
+ return;
+ }
+
if (zip.setCurrentFile("pack.png")) {
if (!file.open(QIODevice::ReadOnly)) {
qCritical() << "Failed to open file in zip.";
@@ -129,6 +137,13 @@ void processPackPNG(TexturePack& pack, QByteArray&& raw_data)
qWarning() << "Failed to parse pack.png.";
}
}
+
+bool validate(QFileInfo file)
+{
+ TexturePack rp{ file };
+ return TexturePackUtils::process(rp, ProcessingLevel::BasicInfoOnly) && rp.valid();
+}
+
} // namespace TexturePackUtils
LocalTexturePackParseTask::LocalTexturePackParseTask(int token, TexturePack& rp)
@@ -143,8 +158,6 @@ bool LocalTexturePackParseTask::abort()
void LocalTexturePackParseTask::executeTask()
{
- Q_ASSERT(m_texture_pack.valid());
-
if (!TexturePackUtils::process(m_texture_pack))
return;
diff --git a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.h b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.h
index cb0e404a..9f7aab75 100644
--- a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.h
+++ b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.h
@@ -27,13 +27,19 @@
#include "tasks/Task.h"
namespace TexturePackUtils {
-bool process(TexturePack& pack);
-void processZIP(TexturePack& pack);
-void processFolder(TexturePack& pack);
+enum class ProcessingLevel { Full, BasicInfoOnly };
+
+bool process(TexturePack& pack, ProcessingLevel level = ProcessingLevel::Full);
+
+void processZIP(TexturePack& pack, ProcessingLevel level = ProcessingLevel::Full);
+void processFolder(TexturePack& pack, ProcessingLevel level = ProcessingLevel::Full);
void processPackTXT(TexturePack& pack, QByteArray&& raw_data);
void processPackPNG(TexturePack& pack, QByteArray&& raw_data);
+
+/** Checks whether a file is valid as a texture pack or not. */
+bool validate(QFileInfo file);
} // namespace TexturePackUtils
class LocalTexturePackParseTask : public Task {