mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
feat: abort launch when there are libraries missing
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
70cbbf5b07
commit
d4817a5669
4 changed files with 87 additions and 10 deletions
|
|
@ -265,6 +265,8 @@ set(MINECRAFT_SOURCES
|
|||
minecraft/launch/ClaimAccount.h
|
||||
minecraft/launch/CreateGameFolders.cpp
|
||||
minecraft/launch/CreateGameFolders.h
|
||||
minecraft/launch/EnsureOfflineLibraries.cpp
|
||||
minecraft/launch/EnsureOfflineLibraries.h
|
||||
minecraft/launch/ModMinecraftJar.cpp
|
||||
minecraft/launch/ModMinecraftJar.h
|
||||
minecraft/launch/ExtractNatives.cpp
|
||||
|
|
|
|||
|
|
@ -94,6 +94,8 @@
|
|||
#include <QStandardPaths>
|
||||
#include <QWindow>
|
||||
|
||||
#include "launch/EnsureOfflineLibraries.h"
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#include "MangoHud.h"
|
||||
#endif
|
||||
|
|
@ -920,21 +922,13 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session, Minecr
|
|||
out << "Libraries:";
|
||||
QStringList jars, nativeJars;
|
||||
profile->getLibraryFiles(runtimeContext(), jars, nativeJars, getLocalLibraryPath(), binRoot());
|
||||
auto printLibFile = [&out](const QString& path) {
|
||||
QFileInfo info(path);
|
||||
if (info.exists()) {
|
||||
out << indent + path;
|
||||
} else {
|
||||
out << indent + path + " (missing)";
|
||||
}
|
||||
};
|
||||
for (auto file : jars) {
|
||||
printLibFile(file);
|
||||
out << indent + file;
|
||||
}
|
||||
out << emptyLine;
|
||||
out << "Native libraries:";
|
||||
for (auto file : nativeJars) {
|
||||
printLibFile(file);
|
||||
out << indent + file;
|
||||
}
|
||||
out << emptyLine;
|
||||
}
|
||||
|
|
@ -1184,6 +1178,8 @@ LaunchTask* MinecraftInstance::createLaunchTask(AuthSessionPtr session, Minecraf
|
|||
for (auto t : createUpdateTask()) {
|
||||
process->appendStep(makeShared<TaskStepWrapper>(pptr, t));
|
||||
}
|
||||
} else {
|
||||
process->appendStep(makeShared<EnsureOfflineLibraries>(pptr, this));
|
||||
}
|
||||
|
||||
// if there are any jar mods
|
||||
|
|
|
|||
43
launcher/minecraft/launch/EnsureOfflineLibraries.cpp
Normal file
43
launcher/minecraft/launch/EnsureOfflineLibraries.cpp
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (C) 2026 Octol1ttle <l1ttleofficial@outlook.com>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "EnsureOfflineLibraries.h"
|
||||
|
||||
#include "minecraft/PackProfile.h"
|
||||
|
||||
EnsureOfflineLibraries::EnsureOfflineLibraries(LaunchTask* parent, MinecraftInstance* instance) : LaunchStep(parent), m_instance(instance)
|
||||
{}
|
||||
|
||||
void EnsureOfflineLibraries::executeTask()
|
||||
{
|
||||
const auto profile = m_instance->getPackProfile()->getProfile();
|
||||
QStringList allJars;
|
||||
profile->getLibraryFiles(m_instance->runtimeContext(), allJars, allJars, m_instance->getLocalLibraryPath(), m_instance->binRoot());
|
||||
for (const auto& jar : allJars) {
|
||||
if (!QFileInfo::exists(jar)) {
|
||||
emit logLine(
|
||||
tr("This instance cannot be launched in offline mode because libraries have not been downloaded yet. Please try again in "
|
||||
"online mode with a working Internet connection"),
|
||||
MessageLevel::Fatal);
|
||||
emitFailed("Required libraries are missing");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
emitSucceeded();
|
||||
}
|
||||
36
launcher/minecraft/launch/EnsureOfflineLibraries.h
Normal file
36
launcher/minecraft/launch/EnsureOfflineLibraries.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (C) 2026 Octol1ttle <l1ttleofficial@outlook.com>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "launch/LaunchStep.h"
|
||||
#include "minecraft/MinecraftInstance.h"
|
||||
|
||||
class EnsureOfflineLibraries : public LaunchStep {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EnsureOfflineLibraries(LaunchTask* parent, MinecraftInstance* instance);
|
||||
~EnsureOfflineLibraries() override = default;
|
||||
|
||||
void executeTask() override;
|
||||
bool canAbort() const override { return false; }
|
||||
|
||||
private:
|
||||
MinecraftInstance* m_instance;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue