feat: auto install modpack & choise nickname
Some checks failed
CodeQL Code Scanning / CodeQL (push) Has been cancelled
Build Application / Build Debug (push) Has been cancelled
Nix / Build (${{ matrix.system }}) (macos-13, x86_64-darwin) (push) Has been cancelled
Nix / Build (${{ matrix.system }}) (macos-14, aarch64-darwin) (push) Has been cancelled
Nix / Build (${{ matrix.system }}) (ubuntu-22.04, x86_64-linux) (push) Has been cancelled
Nix / Build (${{ matrix.system }}) (ubuntu-22.04-arm, aarch64-linux) (push) Has been cancelled
Update Flake Lockfile / update-flake (push) Has been cancelled

This commit is contained in:
Reider745 2025-04-15 11:13:45 +03:00
parent 67bca78946
commit 60234a550b
1607 changed files with 11250 additions and 624 deletions

25
launcher/Application.cpp Normal file → Executable file
View File

@ -160,13 +160,14 @@
#if defined Q_OS_WIN32
#include <windows.h>
#include <QStyleHints>
#include "WindowsConsole.h"
#endif
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#include "onimai.h"
static const QLatin1String liveCheckFile("live.check");
PixmapCache* PixmapCache::s_instance = nullptr;
@ -232,7 +233,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
setApplicationDisplayName(QString("%1 %2").arg(BuildConfig.LAUNCHER_DISPLAYNAME, BuildConfig.printableVersionString()));
setApplicationVersion(BuildConfig.printableVersionString() + "\n" + BuildConfig.GIT_COMMIT);
setDesktopFileName(BuildConfig.LAUNCHER_DESKTOPFILENAME);
m_startTime = QDateTime::currentDateTime();
startTime = QDateTime::currentDateTime();
// Don't quit on hiding the last window
this->setQuitOnLastWindowClosed(false);
@ -933,6 +934,8 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
connect(this, &Application::clickedOnDock, [this]() { this->showMainWindow(); });
#endif
onimaiLoadLauncher(this);
connect(this, &Application::aboutToQuit, [this]() {
if (m_instances) {
// save any remaining instance state
@ -1125,16 +1128,8 @@ bool Application::createSetupWizard()
// set default theme after going into theme wizard
if (!validIcons)
settings()->set("IconTheme", QString("pe_colored"));
if (!validWidgets) {
#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
const QString style =
QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark ? QStringLiteral("dark") : QStringLiteral("bright");
#else
const QString style = QStringLiteral("system");
#endif
settings()->set("ApplicationTheme", style);
}
if (!validWidgets)
settings()->set("ApplicationTheme", QString("system"));
m_themeManager->applyCurrentlySelectedTheme(true);
@ -1201,9 +1196,6 @@ bool Application::event(QEvent* event)
#endif
if (event->type() == QEvent::FileOpen) {
if (!m_mainWindow) {
showMainWindow(false);
}
auto ev = static_cast<QFileOpenEvent*>(event);
m_mainWindow->processURLs({ ev->url() });
}
@ -1362,9 +1354,6 @@ void Application::messageReceived(const QByteArray& message)
qWarning() << "Received" << command << "message without a zip path/URL.";
return;
}
if (!m_mainWindow) {
showMainWindow(false);
}
m_mainWindow->processURLs({ normalizeImportUrl(url) });
} else if (command == "launch") {
QString id = received.args["id"];

4
launcher/Application.h Normal file → Executable file
View File

@ -112,7 +112,7 @@ class Application : public QApplication {
std::shared_ptr<SettingsObject> settings() const { return m_settings; }
qint64 timeSinceStart() const { return m_startTime.msecsTo(QDateTime::currentDateTime()); }
qint64 timeSinceStart() const { return startTime.msecsTo(QDateTime::currentDateTime()); }
QIcon getThemedIcon(const QString& name);
@ -236,7 +236,7 @@ class Application : public QApplication {
bool shouldExitNow() const;
private:
QDateTime m_startTime;
QDateTime startTime;
shared_qobject_ptr<QNetworkAccessManager> m_network;

0
launcher/ApplicationMessage.cpp Normal file → Executable file
View File

0
launcher/ApplicationMessage.h Normal file → Executable file
View File

0
launcher/BaseInstaller.cpp Normal file → Executable file
View File

0
launcher/BaseInstaller.h Normal file → Executable file
View File

2
launcher/BaseInstance.cpp Normal file → Executable file
View File

@ -58,6 +58,8 @@ BaseInstance::BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr s
m_global_settings = globalSettings;
m_rootDir = rootDir;
qDebug() << "BaseInstance: " << rootDir;
m_settings->registerSetting("name", "Unnamed Instance");
m_settings->registerSetting("iconKey", "default");
m_settings->registerSetting("notes", "");

0
launcher/BaseInstance.h Normal file → Executable file
View File

0
launcher/BaseVersion.h Normal file → Executable file
View File

0
launcher/BaseVersionList.cpp Normal file → Executable file
View File

0
launcher/BaseVersionList.h Normal file → Executable file
View File

10
launcher/CMakeLists.txt Normal file → Executable file
View File

@ -5,6 +5,7 @@ project(application)
######## Sources and headers ########
set(CORE_SOURCES
onimai.cpp
# LOGIC - Base classes and infrastructure
BaseInstaller.h
BaseInstaller.cpp
@ -238,8 +239,6 @@ set(MINECRAFT_SOURCES
minecraft/auth/AuthFlow.cpp
minecraft/auth/AuthFlow.h
minecraft/auth/steps/AuthlibInjectorMetadataStep.cpp
minecraft/auth/steps/AuthlibInjectorMetadataStep.h
minecraft/auth/steps/EntitlementsStep.cpp
minecraft/auth/steps/EntitlementsStep.h
minecraft/auth/steps/GetSkinStep.cpp
@ -387,10 +386,6 @@ set(MINECRAFT_SOURCES
minecraft/AssetsUtils.cpp
# Minecraft skins
minecraft/skins/AuthlibInjectorTextureDelete.cpp
minecraft/skins/AuthlibInjectorTextureDelete.h
minecraft/skins/AuthlibInjectorTextureUpload.cpp
minecraft/skins/AuthlibInjectorTextureUpload.h
minecraft/skins/CapeChange.cpp
minecraft/skins/CapeChange.h
minecraft/skins/SkinUpload.cpp
@ -1066,6 +1061,8 @@ SET(LAUNCHER_SOURCES
ui/dialogs/CopyInstanceDialog.h
ui/dialogs/CustomMessageBox.cpp
ui/dialogs/CustomMessageBox.h
ui/dialogs/EditAccountDialog.cpp
ui/dialogs/EditAccountDialog.h
ui/dialogs/ExportInstanceDialog.cpp
ui/dialogs/ExportInstanceDialog.h
ui/dialogs/ExportPackDialog.cpp
@ -1255,6 +1252,7 @@ qt_wrap_ui(LAUNCHER_UI
ui/dialogs/OfflineLoginDialog.ui
ui/dialogs/AuthlibInjectorLoginDialog.ui
ui/dialogs/AboutDialog.ui
ui/dialogs/EditAccountDialog.ui
ui/dialogs/ReviewMessageBox.ui
ui/dialogs/ScrollMessageBox.ui
ui/dialogs/BlockedModsDialog.ui

0
launcher/Commandline.cpp Normal file → Executable file
View File

0
launcher/Commandline.h Normal file → Executable file
View File

0
launcher/DataMigrationTask.cpp Normal file → Executable file
View File

0
launcher/DataMigrationTask.h Normal file → Executable file
View File

0
launcher/DefaultVariable.h Normal file → Executable file
View File

0
launcher/DesktopServices.cpp Normal file → Executable file
View File

0
launcher/DesktopServices.h Normal file → Executable file
View File

0
launcher/Exception.h Normal file → Executable file
View File

0
launcher/ExponentialSeries.h Normal file → Executable file
View File

0
launcher/FastFileIconProvider.cpp Normal file → Executable file
View File

0
launcher/FastFileIconProvider.h Normal file → Executable file
View File

0
launcher/FileIgnoreProxy.cpp Normal file → Executable file
View File

0
launcher/FileIgnoreProxy.h Normal file → Executable file
View File

0
launcher/FileSystem.cpp Normal file → Executable file
View File

0
launcher/FileSystem.h Normal file → Executable file
View File

0
launcher/Filter.cpp Normal file → Executable file
View File

0
launcher/Filter.h Normal file → Executable file
View File

0
launcher/GZip.cpp Normal file → Executable file
View File

0
launcher/GZip.h Normal file → Executable file
View File

3
launcher/GetAuthlibInjectorApiLocation.cpp Normal file → Executable file
View File

@ -72,8 +72,7 @@ auto GetAuthlibInjectorApiLocation::Sink::finalize(QNetworkReply& reply) -> Task
qDebug() << "X-Authlib-Injector-API-Location header not found!";
}
const auto& encodedUrl = url.toEncoded(QUrl::FullyEncoded);
m_outer.m_account.reset(MinecraftAccount::createFromUsernameAuthlibInjector(m_outer.m_username, encodedUrl));
m_outer.m_account.reset(MinecraftAccount::createFromUsernameAuthlibInjector(m_outer.m_username, url.toString()));
return Task::State::Succeeded;
}

0
launcher/GetAuthlibInjectorApiLocation.h Normal file → Executable file
View File

0
launcher/InstanceCopyPrefs.cpp Normal file → Executable file
View File

0
launcher/InstanceCopyPrefs.h Normal file → Executable file
View File

0
launcher/InstanceCopyTask.cpp Normal file → Executable file
View File

0
launcher/InstanceCopyTask.h Normal file → Executable file
View File

0
launcher/InstanceCreationTask.cpp Normal file → Executable file
View File

0
launcher/InstanceCreationTask.h Normal file → Executable file
View File

8
launcher/InstanceImportTask.cpp Normal file → Executable file
View File

@ -159,7 +159,7 @@ void InstanceImportTask::processZipPack()
}
QuaZipDir packZipDir(packZip.get());
qDebug() << "Attempting to determine instance type";
qDebug() << "Attempting to determine instance type ";
QString root;
@ -244,6 +244,8 @@ void InstanceImportTask::extractFinished()
}
}
qDebug() << "extractFinished " << static_cast<int>(m_modpackType);
switch (m_modpackType) {
case ModpackType::MultiMC:
processMultiMC();
@ -326,6 +328,8 @@ void InstanceImportTask::processMultiMC()
QString configPath = FS::PathCombine(m_stagingPath, "instance.cfg");
auto instanceSettings = std::make_shared<INISettingsObject>(configPath);
qDebug() << "processMultiMC: " << m_stagingPath;
NullInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
// reset time played on import... because packs.
@ -334,6 +338,8 @@ void InstanceImportTask::processMultiMC()
// set a new nice name
instance.setName(name());
qDebug() << "processMultiMC2 " << instance.instanceRoot() << name();
// if the icon was specified by user, use that. otherwise pull icon from the pack
if (m_instIcon != "default") {
instance.setIconKey(m_instIcon);

0
launcher/InstanceImportTask.h Normal file → Executable file
View File

5
launcher/InstanceList.cpp Normal file → Executable file
View File

@ -449,6 +449,7 @@ QList<InstanceId> InstanceList::discoverInstances()
out.append(id);
qDebug() << "Found instance ID" << id;
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
instanceSet = QSet<QString>(out.begin(), out.end());
#else
@ -977,6 +978,7 @@ QString InstanceList::getStagedInstancePath()
#ifdef Q_OS_WIN32
SetFileAttributesA(tempRoot.toStdString().c_str(), FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED);
#endif
qDebug() << "get Debug" << result;
return result;
}
@ -994,7 +996,7 @@ bool InstanceList::commitStagedInstance(const QString& path,
auto should_override = commiting.shouldOverride();
if (should_override) {
instID = commiting.originalInstanceID();
instID = instanceName.modifiedName();
} else {
instID = FS::DirNameFromString(instanceName.modifiedName(), m_instDir);
}
@ -1010,6 +1012,7 @@ bool InstanceList::commitStagedInstance(const QString& path,
qWarning() << "Failed to override" << path << "to" << destination;
return false;
}
FS::deletePath(path);
} else {
if (!FS::move(path, destination)) {
qWarning() << "Failed to move" << path << "to" << destination;

0
launcher/InstanceList.h Normal file → Executable file
View File

0
launcher/InstancePageProvider.h Normal file → Executable file
View File

0
launcher/InstanceTask.cpp Normal file → Executable file
View File

31
launcher/InstanceTask.h Normal file → Executable file
View File

@ -30,26 +30,31 @@ struct InstanceName {
};
class InstanceTask : public Task, public InstanceName {
Q_OBJECT
public:
InstanceTask();
~InstanceTask() override = default;
Q_OBJECT
public:
InstanceTask();
~InstanceTask() override = default;
void setParentSettings(SettingsObjectPtr settings) { m_globalSettings = settings; }
void setParentSettings(SettingsObjectPtr settings) { m_globalSettings = settings; }
void setStagingPath(const QString& stagingPath) { m_stagingPath = stagingPath; }
void setStagingPath(const QString& stagingPath) { m_stagingPath = stagingPath; }
void setIcon(const QString& icon) { m_instIcon = icon; }
void setIcon(const QString& icon) { m_instIcon = icon; }
void setGroup(const QString& group) { m_instGroup = group; }
QString group() const { return m_instGroup; }
void setGroup(const QString& group) { m_instGroup = group; }
QString group() const { return m_instGroup; }
[[nodiscard]] bool shouldConfirmUpdate() const { return m_confirm_update; }
void setConfirmUpdate(bool confirm) { m_confirm_update = confirm; }
[[nodiscard]] bool shouldConfirmUpdate() const { return m_confirm_update; }
void setConfirmUpdate(bool confirm) { m_confirm_update = confirm; }
bool shouldOverride() const { return m_override_existing; }
bool shouldOverride() const { return m_override_existing; }
[[nodiscard]] QString originalInstanceID() const { return m_original_instance_id; };
[[nodiscard]] QString originalInstanceID() const { return m_original_instance_id; };
void setShouldOverride(bool should)
{
m_override_existing = should;
}
protected:
void setOverride(bool override, QString instance_id_to_override = {})

0
launcher/JavaCommon.cpp Normal file → Executable file
View File

0
launcher/JavaCommon.h Normal file → Executable file
View File

0
launcher/Json.cpp Normal file → Executable file
View File

0
launcher/Json.h Normal file → Executable file
View File

0
launcher/KonamiCode.cpp Normal file → Executable file
View File

0
launcher/KonamiCode.h Normal file → Executable file
View File

0
launcher/LaunchController.cpp Normal file → Executable file
View File

0
launcher/LaunchController.h Normal file → Executable file
View File

0
launcher/LoggedProcess.cpp Normal file → Executable file
View File

0
launcher/LoggedProcess.h Normal file → Executable file
View File

7
launcher/Logging.cpp Normal file
View File

@ -0,0 +1,7 @@
// This file was generated by ecm_qt_declare_logging_category(): DO NOT EDIT!
#include "Logging.h"
Q_LOGGING_CATEGORY(authCredentials, "launcher.auth.credentials", QtWarningMsg)

11
launcher/Logging.h Normal file
View File

@ -0,0 +1,11 @@
// This file was generated by ecm_qt_declare_logging_category(): DO NOT EDIT!
#ifndef ECM_QLOGGINGCATEGORY_AUTHCREDENTIALS_LOGGING_H
#define ECM_QLOGGINGCATEGORY_AUTHCREDENTIALS_LOGGING_H
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(authCredentials)
#endif

0
launcher/MMCTime.cpp Normal file → Executable file
View File

0
launcher/MMCTime.h Normal file → Executable file
View File

0
launcher/MMCZip.cpp Normal file → Executable file
View File

0
launcher/MMCZip.h Normal file → Executable file
View File

0
launcher/MTPixmapCache.h Normal file → Executable file
View File

10388
launcher/Makefile Executable file

File diff suppressed because it is too large Load Diff

0
launcher/MangoHud.cpp Normal file → Executable file
View File

0
launcher/MangoHud.h Normal file → Executable file
View File

0
launcher/Manifest.cpp Normal file → Executable file
View File

0
launcher/Manifest.h Normal file → Executable file
View File

0
launcher/Markdown.cpp Normal file → Executable file
View File

0
launcher/Markdown.h Normal file → Executable file
View File

0
launcher/MessageLevel.cpp Normal file → Executable file
View File

0
launcher/MessageLevel.h Normal file → Executable file
View File

0
launcher/NullInstance.h Normal file → Executable file
View File

0
launcher/PSaveFile.h Normal file → Executable file
View File

0
launcher/ProblemProvider.h Normal file → Executable file
View File

0
launcher/QObjectPtr.h Normal file → Executable file
View File

0
launcher/QVariantUtils.h Normal file → Executable file
View File

0
launcher/RWStorage.h Normal file → Executable file
View File

0
launcher/RecursiveFileSystemWatcher.cpp Normal file → Executable file
View File

0
launcher/RecursiveFileSystemWatcher.h Normal file → Executable file
View File

0
launcher/ResourceDownloadTask.cpp Normal file → Executable file
View File

0
launcher/ResourceDownloadTask.h Normal file → Executable file
View File

0
launcher/RuntimeContext.h Normal file → Executable file
View File

0
launcher/SeparatorPrefixTree.h Normal file → Executable file
View File

0
launcher/StringUtils.cpp Normal file → Executable file
View File

0
launcher/StringUtils.h Normal file → Executable file
View File

0
launcher/SysInfo.cpp Normal file → Executable file
View File

0
launcher/SysInfo.h Normal file → Executable file
View File

0
launcher/Untar.cpp Normal file → Executable file
View File

0
launcher/Untar.h Normal file → Executable file
View File

0
launcher/Usable.h Normal file → Executable file
View File

0
launcher/Version.cpp Normal file → Executable file
View File

0
launcher/Version.h Normal file → Executable file
View File

1
launcher/VersionProxyModel.cpp Normal file → Executable file
View File

@ -307,7 +307,6 @@ void VersionProxyModel::setSourceModel(QAbstractItemModel* replacingRaw)
if (!replacing) {
roles.clear();
filterModel->setSourceModel(replacing);
endResetModel();
return;
}

0
launcher/VersionProxyModel.h Normal file → Executable file
View File

0
launcher/WatchLock.h Normal file → Executable file
View File

0
launcher/WindowsConsole.cpp Normal file → Executable file
View File

0
launcher/WindowsConsole.h Normal file → Executable file
View File

0
launcher/filelink/FileLink.cpp Normal file → Executable file
View File

0
launcher/filelink/FileLink.h Normal file → Executable file
View File

Some files were not shown because too many files have changed in this diff Show More