aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yml2
-rw-r--r--CMakeLists.txt3
-rw-r--r--README.md2
-rw-r--r--launcher/Application.cpp2
-rw-r--r--launcher/minecraft/MojangVersionFormat.cpp17
-rw-r--r--launcher/minecraft/OneSixVersionFormat.cpp29
-rw-r--r--launcher/modplatform/flame/FlameInstanceCreationTask.cpp7
-rw-r--r--launcher/modplatform/modpacksch/FTBPackInstallTask.cpp11
-rw-r--r--launcher/ui/MainWindow.cpp56
-rw-r--r--launcher/ui/MainWindow.h2
-rw-r--r--launcher/ui/dialogs/BlockedModsDialog.cpp195
-rw-r--r--launcher/ui/dialogs/BlockedModsDialog.h19
-rw-r--r--launcher/ui/dialogs/BlockedModsDialog.ui67
m---------libraries/tomlplusplus0
14 files changed, 346 insertions, 66 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index df8aae39..20fe66dd 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -64,7 +64,7 @@ jobs:
qt_ver: 6
qt_host: windows
qt_arch: ''
- qt_version: '6.4.0'
+ qt_version: '6.4.1'
qt_modules: 'qt5compat qtimageformats'
qt_tools: ''
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0db05f98..8fc0d326 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -70,6 +70,9 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_NO_DEPRECATED_WARNINGS=Y")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_DISABLE_DEPRECATED_BEFORE=0x050C00")
+# Fix aarch64 build for toml++
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTOML_ENABLE_FLOAT16=0")
+
# set CXXFLAGS for build targets
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -D_FORTIFY_SOURCE=2 ${CMAKE_CXX_FLAGS_RELEASE}")
diff --git a/README.md b/README.md
index f8ea2e84..cb99f70f 100644
--- a/README.md
+++ b/README.md
@@ -29,7 +29,7 @@ Prebuilt Development builds are provided for **Linux**, **Windows** and **macOS*
For **Arch**, **Debian**, **Fedora**, **OpenSUSE (Tumbleweed)** and **Gentoo**, respectively, you can use these packages for the latest development versions:
-[![prismlauncher-git](https://img.shields.io/badge/aur-prismlauncher--git-1793D1?style=flat-square&logo=archlinux&logoColor=white)](https://aur.archlinux.org/packages/prismlauncher-qt5-git/) [![prismlauncher-git](https://img.shields.io/badge/aur-prismlauncher--qt5--git-1793D1?style=flat-square&logo=archlinux&logoColor=white)](https://aur.archlinux.org/packages/prismlauncher-git/) [![prismlauncher-git](https://img.shields.io/badge/mpr-prismlauncher--git-A80030?style=flat-square&logo=debian&logoColor=white)](https://mpr.makedeb.org/packages/prismlauncher-git) [![prismlauncher-nightly](https://img.shields.io/badge/copr-prismlauncher--nightly-51A2DA?style=flat-square&logo=fedora&logoColor=white)](https://copr.fedorainfracloud.org/coprs/g3tchoo/prismlauncher/) [![prismlauncher-nightly](https://img.shields.io/badge/OBS-prismlauncher--nightly-3AB6A9?style=flat-square&logo=opensuse&logoColor=white)](https://build.opensuse.org/project/show/home:getchoo) [![prismlauncher-9999](https://img.shields.io/badge/gentoo-prismlauncher--9999-4D4270?style=flat-square&logo=gentoo&logoColor=white)](https://packages.gentoo.org/packages/games-action/prismlauncher)
+[![prismlauncher-git](https://img.shields.io/badge/aur-prismlauncher--git-1793D1?style=flat-square&logo=archlinux&logoColor=white)](https://aur.archlinux.org/packages/prismlauncher-git/) [![prismlauncher-git](https://img.shields.io/badge/aur-prismlauncher--qt5--git-1793D1?style=flat-square&logo=archlinux&logoColor=white)](https://aur.archlinux.org/packages/prismlauncher-qt5-git/) [![prismlauncher-git](https://img.shields.io/badge/mpr-prismlauncher--git-A80030?style=flat-square&logo=debian&logoColor=white)](https://mpr.makedeb.org/packages/prismlauncher-git) [![prismlauncher-nightly](https://img.shields.io/badge/copr-prismlauncher--nightly-51A2DA?style=flat-square&logo=fedora&logoColor=white)](https://copr.fedorainfracloud.org/coprs/g3tchoo/prismlauncher/) [![prismlauncher-nightly](https://img.shields.io/badge/OBS-prismlauncher--nightly-3AB6A9?style=flat-square&logo=opensuse&logoColor=white)](https://build.opensuse.org/project/show/home:getchoo) [![prismlauncher-9999](https://img.shields.io/badge/gentoo-prismlauncher--9999-4D4270?style=flat-square&logo=gentoo&logoColor=white)](https://packages.gentoo.org/packages/games-action/prismlauncher)
## Community & Support
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index 45cd9422..883f8968 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -226,7 +226,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
setOrganizationDomain(BuildConfig.LAUNCHER_DOMAIN);
setApplicationName(BuildConfig.LAUNCHER_NAME);
setApplicationDisplayName(QString("%1 %2").arg(BuildConfig.LAUNCHER_DISPLAYNAME, BuildConfig.printableVersionString()));
- setApplicationVersion(BuildConfig.printableVersionString());
+ setApplicationVersion(BuildConfig.printableVersionString() + "\n" + BuildConfig.GIT_COMMIT);
setDesktopFileName(BuildConfig.LAUNCHER_DESKTOPFILENAME);
startTime = QDateTime::currentDateTime();
diff --git a/launcher/minecraft/MojangVersionFormat.cpp b/launcher/minecraft/MojangVersionFormat.cpp
index 9bbb4ada..623dcdfa 100644
--- a/launcher/minecraft/MojangVersionFormat.cpp
+++ b/launcher/minecraft/MojangVersionFormat.cpp
@@ -135,7 +135,7 @@ QJsonObject libDownloadInfoToJson(MojangLibraryDownloadInfo::Ptr libinfo)
{
out.insert("artifact", downloadInfoToJson(libinfo->artifact));
}
- if(libinfo->classifiers.size())
+ if(!libinfo->classifiers.isEmpty())
{
QJsonObject classifiersOut;
for(auto iter = libinfo->classifiers.begin(); iter != libinfo->classifiers.end(); iter++)
@@ -297,7 +297,7 @@ void MojangVersionFormat::writeVersionProperties(const VersionFile* in, QJsonObj
{
out.insert("assetIndex", assetIndexToJson(in->mojangAssetIndex));
}
- if(in->mojangDownloads.size())
+ if(!in->mojangDownloads.isEmpty())
{
QJsonObject downloadsOut;
for(auto iter = in->mojangDownloads.begin(); iter != in->mojangDownloads.end(); iter++)
@@ -306,6 +306,15 @@ void MojangVersionFormat::writeVersionProperties(const VersionFile* in, QJsonObj
}
out.insert("downloads", downloadsOut);
}
+ if(!in->compatibleJavaMajors.isEmpty())
+ {
+ QJsonArray compatibleJavaMajorsOut;
+ for(auto compatibleJavaMajor : in->compatibleJavaMajors)
+ {
+ compatibleJavaMajorsOut.append(compatibleJavaMajor);
+ }
+ out.insert("compatibleJavaMajors", compatibleJavaMajorsOut);
+ }
}
QJsonDocument MojangVersionFormat::versionFileToJson(const VersionFilePtr &patch)
@@ -396,7 +405,7 @@ QJsonObject MojangVersionFormat::libraryToJson(Library *library)
iter++;
}
libRoot.insert("natives", nativeList);
- if (library->m_extractExcludes.size())
+ if (!library->m_extractExcludes.isEmpty())
{
QJsonArray excludes;
QJsonObject extract;
@@ -408,7 +417,7 @@ QJsonObject MojangVersionFormat::libraryToJson(Library *library)
libRoot.insert("extract", extract);
}
}
- if (library->m_rules.size())
+ if (!library->m_rules.isEmpty())
{
QJsonArray allRules;
for (auto &rule : library->m_rules)
diff --git a/launcher/minecraft/OneSixVersionFormat.cpp b/launcher/minecraft/OneSixVersionFormat.cpp
index cec4a55b..280f6b26 100644
--- a/launcher/minecraft/OneSixVersionFormat.cpp
+++ b/launcher/minecraft/OneSixVersionFormat.cpp
@@ -63,13 +63,13 @@ LibraryPtr OneSixVersionFormat::libraryFromJson(ProblemContainer & problems, con
QJsonObject OneSixVersionFormat::libraryToJson(Library *library)
{
QJsonObject libRoot = MojangVersionFormat::libraryToJson(library);
- if (library->m_absoluteURL.size())
+ if (!library->m_absoluteURL.isEmpty())
libRoot.insert("MMC-absoluteUrl", library->m_absoluteURL);
- if (library->m_hint.size())
+ if (!library->m_hint.isEmpty())
libRoot.insert("MMC-hint", library->m_hint);
- if (library->m_filename.size())
+ if (!library->m_filename.isEmpty())
libRoot.insert("MMC-filename", library->m_filename);
- if (library->m_displayname.size())
+ if (!library->m_displayname.isEmpty())
libRoot.insert("MMC-displayname", library->m_displayname);
return libRoot;
}
@@ -225,11 +225,10 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
{
QJsonObject agentObj = requireObject(agentVal);
auto lib = libraryFromJson(*out, agentObj, filename);
+
QString arg = "";
- if (agentObj.contains("argument"))
- {
- readString(agentObj, "argument", arg);
- }
+ readString(agentObj, "argument", arg);
+
AgentPtr agent(new Agent(lib, arg));
out->agents.append(agent);
}
@@ -332,6 +331,20 @@ QJsonDocument OneSixVersionFormat::versionFileToJson(const VersionFilePtr &patch
writeString(root, "appletClass", patch->appletClass);
writeStringList(root, "+tweakers", patch->addTweakers);
writeStringList(root, "+traits", patch->traits.values());
+ writeStringList(root, "+jvmArgs", patch->addnJvmArguments);
+ if (!patch->agents.isEmpty())
+ {
+ QJsonArray array;
+ for (auto value: patch->agents)
+ {
+ QJsonObject agentOut = OneSixVersionFormat::libraryToJson(value->library().get());
+ if (!value->argument().isEmpty())
+ agentOut.insert("argument", value->argument());
+
+ array.append(agentOut);
+ }
+ root.insert("+agents", array);
+ }
if (!patch->libraries.isEmpty())
{
QJsonArray array;
diff --git a/launcher/modplatform/flame/FlameInstanceCreationTask.cpp b/launcher/modplatform/flame/FlameInstanceCreationTask.cpp
index f0fbdc96..91554b58 100644
--- a/launcher/modplatform/flame/FlameInstanceCreationTask.cpp
+++ b/launcher/modplatform/flame/FlameInstanceCreationTask.cpp
@@ -393,9 +393,10 @@ void FlameCreationTask::idResolverSucceeded(QEventLoop& loop)
qWarning() << "Blocked mods found, displaying mod list";
auto message_dialog = new BlockedModsDialog(m_parent, tr("Blocked mods found"),
- tr("The following mods were blocked on third party launchers.<br/>"
- "You will need to manually download them and add them to the modpack"),
- blocked_mods);
+ tr("The following files are not available for download in third party launchers.<br/>"
+ "You will need to manually download them and add them to the instance."),
+ blocked_mods);
+
message_dialog->setModal(true);
if (message_dialog->exec()) {
diff --git a/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp b/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp
index 40aee82b..4c7b7a4f 100644
--- a/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp
+++ b/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp
@@ -211,18 +211,17 @@ void PackInstallTask::onResolveModsSucceeded()
qDebug() << "Blocked files found, displaying file list";
auto message_dialog = new BlockedModsDialog(m_parent, tr("Blocked files found"),
- tr("The following files are not available for download in third party launchers.<br/>"
- "You will need to manually download them and add them to the instance."),
- m_blocked_mods);
+ tr("The following files are not available for download in third party launchers.<br/>"
+ "You will need to manually download them and add them to the instance."),
+ m_blocked_mods);
if (message_dialog->exec() == QDialog::Accepted) {
qDebug() << "Post dialog blocked mods list: " << m_blocked_mods;
createInstance();
- }
- else {
+ } else {
abort();
}
-
+
} else {
createInstance();
}
diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index e1ac9551..929f2a85 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -49,7 +49,7 @@
#include <QKeyEvent>
#include <QAction>
-
+#include <QActionGroup>
#include <QApplication>
#include <QButtonGroup>
#include <QHBoxLayout>
@@ -106,6 +106,7 @@
#include "ui/dialogs/UpdateDialog.h"
#include "ui/dialogs/EditAccountDialog.h"
#include "ui/dialogs/ExportInstanceDialog.h"
+#include "ui/themes/ITheme.h"
#include "UpdateController.h"
#include "KonamiCode.h"
@@ -268,6 +269,8 @@ public:
TranslatedAction actionLockToolbars;
+ TranslatedAction actionChangeTheme;
+
QVector<TranslatedToolButton *> all_toolbuttons;
QWidget *centralWidget = nullptr;
@@ -294,7 +297,6 @@ public:
actionAddInstance = TranslatedAction(MainWindow);
actionAddInstance->setObjectName(QStringLiteral("actionAddInstance"));
actionAddInstance->setIcon(APPLICATION->getThemedIcon("new"));
- actionAddInstance->setIconVisibleInMenu(false);
actionAddInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Add Instanc&e..."));
actionAddInstance.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Add a new instance."));
actionAddInstance->setShortcut(QKeySequence::New);
@@ -440,6 +442,11 @@ public:
actionLockToolbars.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Lock Toolbars"));
actionLockToolbars->setCheckable(true);
all_actions.append(&actionLockToolbars);
+
+ actionChangeTheme = TranslatedAction(MainWindow);
+ actionChangeTheme->setObjectName(QStringLiteral("actionChangeTheme"));
+ actionChangeTheme.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Themes"));
+ all_actions.append(&actionChangeTheme);
}
void createMainToolbar(QMainWindow *MainWindow)
@@ -525,8 +532,6 @@ public:
fileMenu->setSeparatorsCollapsible(false);
fileMenu->addAction(actionAddInstance);
fileMenu->addAction(actionLaunchInstance);
- fileMenu->addAction(actionLaunchInstanceOffline);
- fileMenu->addAction(actionLaunchInstanceDemo);
fileMenu->addAction(actionKillInstance);
fileMenu->addAction(actionCloseWindow);
fileMenu->addSeparator();
@@ -544,6 +549,8 @@ public:
viewMenu = menuBar->addMenu(tr("&View"));
viewMenu->setSeparatorsCollapsible(false);
+ viewMenu->addAction(actionChangeTheme);
+ viewMenu->addSeparator();
viewMenu->addAction(actionCAT);
viewMenu->addSeparator();
@@ -574,10 +581,11 @@ public:
helpMenu->addAction(actionDISCORD);
if (!BuildConfig.SUBREDDIT_URL.isEmpty())
helpMenu->addAction(actionREDDIT);
- helpMenu->addSeparator();
if(BuildConfig.UPDATER_ENABLED)
+ {
+ helpMenu->addSeparator();
helpMenu->addAction(actionCheckUpdate);
-
+ }
MainWindow->setMenuBar(menuBar);
}
@@ -595,6 +603,7 @@ public:
actionOpenWiki->setObjectName(QStringLiteral("actionOpenWiki"));
actionOpenWiki.setTextId(QT_TRANSLATE_NOOP("MainWindow", "%1 &Help"));
actionOpenWiki.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open the %1 wiki"));
+ actionOpenWiki->setIcon(APPLICATION->getThemedIcon("help"));
connect(actionOpenWiki, &QAction::triggered, MainWindow, &MainWindow::on_actionOpenWiki_triggered);
all_actions.append(&actionOpenWiki);
@@ -602,6 +611,7 @@ public:
actionNewsMenuBar->setObjectName(QStringLiteral("actionNewsMenuBar"));
actionNewsMenuBar.setTextId(QT_TRANSLATE_NOOP("MainWindow", "%1 &News"));
actionNewsMenuBar.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open the %1 wiki"));
+ actionNewsMenuBar->setIcon(APPLICATION->getThemedIcon("news"));
connect(actionNewsMenuBar, &QAction::triggered, MainWindow, &MainWindow::on_actionMoreNews_triggered);
all_actions.append(&actionNewsMenuBar);
}
@@ -841,6 +851,7 @@ public:
createInstanceToolbar(MainWindow);
MainWindow->updateToolsMenu();
+ MainWindow->updateThemeMenu();
retranslateUi(MainWindow);
@@ -1290,6 +1301,38 @@ void MainWindow::updateToolsMenu()
ui->actionLaunchInstance->setMenu(launchMenu);
}
+void MainWindow::updateThemeMenu()
+{
+ QMenu *themeMenu = ui->actionChangeTheme->menu();
+
+ if (themeMenu) {
+ themeMenu->clear();
+ } else {
+ themeMenu = new QMenu(this);
+ }
+
+ auto themes = APPLICATION->getValidApplicationThemes();
+
+ QActionGroup* themesGroup = new QActionGroup( this );
+
+ for (auto* theme : themes) {
+ QAction * themeAction = themeMenu->addAction(theme->name());
+
+ themeAction->setCheckable(true);
+ if (APPLICATION->settings()->get("ApplicationTheme").toString() == theme->id()) {
+ themeAction->setChecked(true);
+ }
+ themeAction->setActionGroup(themesGroup);
+
+ connect(themeAction, &QAction::triggered, [theme]() {
+ APPLICATION->setApplicationTheme(theme->id(),false);
+ APPLICATION->settings()->set("ApplicationTheme", theme->id());
+ });
+ }
+
+ ui->actionChangeTheme->setMenu(themeMenu);
+}
+
void MainWindow::repopulateAccountsMenu()
{
accountMenu->clear();
@@ -1920,6 +1963,7 @@ void MainWindow::globalSettingsClosed()
proxymodel->sort(0);
updateMainToolBar();
updateToolsMenu();
+ updateThemeMenu();
updateStatusCenter();
// This needs to be done to prevent UI elements disappearing in the event the config is changed
// but Prism Launcher exits abnormally, causing the window state to never be saved:
diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h
index 6aeeccca..0aa01ee2 100644
--- a/launcher/ui/MainWindow.h
+++ b/launcher/ui/MainWindow.h
@@ -174,6 +174,8 @@ private slots:
void updateToolsMenu();
+ void updateThemeMenu();
+
void instanceActivated(QModelIndex);
void instanceChanged(const QModelIndex &current, const QModelIndex &previous);
diff --git a/launcher/ui/dialogs/BlockedModsDialog.cpp b/launcher/ui/dialogs/BlockedModsDialog.cpp
index 2cf94250..edb4ff7d 100644
--- a/launcher/ui/dialogs/BlockedModsDialog.cpp
+++ b/launcher/ui/dialogs/BlockedModsDialog.cpp
@@ -6,28 +6,47 @@
#include "ui_BlockedModsDialog.h"
#include <QDebug>
+#include <QDragEnterEvent>
+#include <QFileDialog>
+#include <QFileInfo>
#include <QStandardPaths>
BlockedModsDialog::BlockedModsDialog(QWidget* parent, const QString& title, const QString& text, QList<BlockedMod>& mods)
- : QDialog(parent), ui(new Ui::BlockedModsDialog), mods(mods)
+ : QDialog(parent), ui(new Ui::BlockedModsDialog), m_mods(mods)
{
+ m_hashing_task = shared_qobject_ptr<ConcurrentTask>(new ConcurrentTask(this, "MakeHashesTask", 10));
+ connect(m_hashing_task.get(), &Task::finished, this, &BlockedModsDialog::hashTaskFinished);
+
ui->setupUi(this);
auto openAllButton = ui->buttonBox->addButton(tr("Open All"), QDialogButtonBox::ActionRole);
connect(openAllButton, &QPushButton::clicked, this, &BlockedModsDialog::openAll);
- connect(&watcher, &QFileSystemWatcher::directoryChanged, this, &BlockedModsDialog::directoryChanged);
+ auto downloadFolderButton = ui->buttonBox->addButton(tr("Add Download Folder"), QDialogButtonBox::ActionRole);
+ connect(downloadFolderButton, &QPushButton::clicked, this, &BlockedModsDialog::addDownloadFolder);
- hashing_task = shared_qobject_ptr<ConcurrentTask>(new ConcurrentTask(this, "MakeHashesTask", 10));
+ connect(&m_watcher, &QFileSystemWatcher::directoryChanged, this, &BlockedModsDialog::directoryChanged);
- qDebug() << "Mods List: " << mods;
+ qDebug() << "[Blocked Mods Dialog] Mods List: " << mods;
setupWatch();
scanPaths();
this->setWindowTitle(title);
- ui->label->setText(text);
- ui->labelModsFound->setText(tr("Please download the missing mods."));
+ ui->labelDescription->setText(text);
+ ui->labelExplain->setText(
+ QString(tr("Your configured global mods folder and default downloads folder "
+ "are automatically checked for the downloaded mods and they will be copied to the instance if found.<br/>"
+ "Optionally, you may drag and drop the downloaded mods onto this dialog or add a folder to watch "
+ "if you did not download the mods to a default location."))
+ .arg(APPLICATION->settings()->get("CentralModsDir").toString(),
+ QStandardPaths::writableLocation(QStandardPaths::DownloadLocation)));
+
+ // force all URL handeling as external
+ connect(ui->textBrowserWatched, &QTextBrowser::anchorClicked, this, [](const QUrl url) { QDesktopServices::openUrl(url); });
+
+ setAcceptDrops(true);
+
update();
}
@@ -36,20 +55,55 @@ BlockedModsDialog::~BlockedModsDialog()
delete ui;
}
+void BlockedModsDialog::dragEnterEvent(QDragEnterEvent* e)
+{
+ if (e->mimeData()->hasUrls()) {
+ e->acceptProposedAction();
+ }
+}
+
+void BlockedModsDialog::dropEvent(QDropEvent* e)
+{
+ for (const QUrl& url : e->mimeData()->urls()) {
+ QString filePath = url.toLocalFile();
+ qDebug() << "[Blocked Mods Dialog] Dropped file:" << filePath;
+ addHashTask(filePath);
+
+ // watch for changes
+ QFileInfo file = QFileInfo(filePath);
+ QString path = file.dir().absolutePath();
+ qDebug() << "[Blocked Mods Dialog] Adding watch path:" << path;
+ m_watcher.addPath(path);
+ }
+ scanPaths();
+ update();
+}
+
void BlockedModsDialog::openAll()
{
- for (auto& mod : mods) {
+ for (auto& mod : m_mods) {
QDesktopServices::openUrl(mod.websiteUrl);
}
}
+void BlockedModsDialog::addDownloadFolder()
+{
+ QString dir =
+ QFileDialog::getExistingDirectory(this, tr("Select directory where you downloaded the mods"),
+ QStandardPaths::writableLocation(QStandardPaths::DownloadLocation), QFileDialog::ShowDirsOnly);
+ qDebug() << "[Blocked Mods Dialog] Adding watch path:" << dir;
+ m_watcher.addPath(dir);
+ scanPath(dir, true);
+ update();
+}
+
/// @brief update UI with current status of the blocked mod detection
void BlockedModsDialog::update()
{
QString text;
QString span;
- for (auto& mod : mods) {
+ for (auto& mod : m_mods) {
if (mod.matched) {
// &#x2714; -> html for HEAVY CHECK MARK : ✔
span = QString(tr("<span style=\"color:green\"> &#x2714; Found at %1 </span>")).arg(mod.localPath);
@@ -60,10 +114,17 @@ void BlockedModsDialog::update()
text += QString(tr("%1: <a href='%2'>%2</a> <p>Hash: %3 %4</p> <br/>")).arg(mod.name, mod.websiteUrl, mod.hash, span);
}
- ui->textBrowser->setText(text);
+ ui->textBrowserModsListing->setText(text);
+
+ QString watching;
+ for (auto& dir : m_watcher.directories()) {
+ watching += QString("<a href=\"%1\">%1</a><br/>").arg(dir);
+ }
+
+ ui->textBrowserWatched->setText(watching);
if (allModsMatched()) {
- ui->labelModsFound->setText(tr("All mods found ✔"));
+ ui->labelModsFound->setText("<span style=\"color:green\">✔</span>" + tr("All mods found"));
} else {
ui->labelModsFound->setText(tr("Please download the missing mods."));
}
@@ -73,8 +134,9 @@ void BlockedModsDialog::update()
/// @param path the path to the changed directory
void BlockedModsDialog::directoryChanged(QString path)
{
- qDebug() << "Directory changed: " << path;
- scanPath(path);
+ qDebug() << "[Blocked Mods Dialog] Directory changed: " << path;
+ validateMatchedMods();
+ scanPath(path, true);
}
/// @brief add the user downloads folder and the global mods folder to the filesystem watcher
@@ -82,22 +144,23 @@ void BlockedModsDialog::setupWatch()
{
const QString downloadsFolder = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
const QString modsFolder = APPLICATION->settings()->get("CentralModsDir").toString();
- watcher.addPath(downloadsFolder);
- watcher.addPath(modsFolder);
+ m_watcher.addPath(downloadsFolder);
+ m_watcher.addPath(modsFolder);
}
/// @brief scan all watched folder
void BlockedModsDialog::scanPaths()
{
- for (auto& dir : watcher.directories()) {
- scanPath(dir);
+ for (auto& dir : m_watcher.directories()) {
+ scanPath(dir, false);
}
+ runHashTask();
}
/// @brief Scan the directory at path, skip paths that do not contain a file name
/// of a blocked mod we are looking for
/// @param path the directory to scan
-void BlockedModsDialog::scanPath(QString path)
+void BlockedModsDialog::scanPath(QString path, bool start_task)
{
QDir scan_dir(path);
QDirIterator scan_it(path, QDir::Filter::Files | QDir::Filter::Hidden, QDirIterator::NoIteratorFlags);
@@ -108,17 +171,35 @@ void BlockedModsDialog::scanPath(QString path)
continue;
}
- auto hash_task = Hashing::createBlockedModHasher(file, ModPlatform::Provider::FLAME, "sha1");
+ addHashTask(file);
+ }
- qDebug() << "Creating Hash task for path: " << file;
+ if (start_task) {
+ runHashTask();
+ }
+}
- connect(hash_task.get(), &Task::succeeded, [this, hash_task, file] { checkMatchHash(hash_task->getResult(), file); });
- connect(hash_task.get(), &Task::failed, [file] { qDebug() << "Failed to hash path: " << file; });
+/// @brief add a hashing task for the file located at path, add the path to the pending set if the hasing task is already running
+/// @param path the path to the local file being hashed
+void BlockedModsDialog::addHashTask(QString path)
+{
+ qDebug() << "[Blocked Mods Dialog] adding a Hash task for" << path << "to the pending set.";
+ m_pending_hash_paths.insert(path);
+}
- hashing_task->addTask(hash_task);
- }
+/// @brief add a hashing task for the file located at path and connect it to check that hash against
+/// our blocked mods list
+/// @param path the path to the local file being hashed
+void BlockedModsDialog::buildHashTask(QString path)
+{
+ auto hash_task = Hashing::createBlockedModHasher(path, ModPlatform::Provider::FLAME, "sha1");
+
+ qDebug() << "[Blocked Mods Dialog] Creating Hash task for path: " << path;
+
+ connect(hash_task.get(), &Task::succeeded, this, [this, hash_task, path] { checkMatchHash(hash_task->getResult(), path); });
+ connect(hash_task.get(), &Task::failed, this, [path] { qDebug() << "Failed to hash path: " << path; });
- hashing_task->start();
+ m_hashing_task->addTask(hash_task);
}
/// @brief check if the computed hash for the provided path matches a blocked
@@ -129,9 +210,9 @@ void BlockedModsDialog::checkMatchHash(QString hash, QString path)
{
bool match = false;
- qDebug() << "Checking for match on hash: " << hash << "| From path:" << path;
+ qDebug() << "[Blocked Mods Dialog] Checking for match on hash: " << hash << "| From path:" << path;
- for (auto& mod : mods) {
+ for (auto& mod : m_mods) {
if (mod.matched) {
continue;
}
@@ -140,7 +221,7 @@ void BlockedModsDialog::checkMatchHash(QString hash, QString path)
mod.localPath = path;
match = true;
- qDebug() << "Hash match found:" << mod.name << hash << "| From path:" << path;
+ qDebug() << "[Blocked Mods Dialog] Hash match found:" << mod.name << hash << "| From path:" << path;
break;
}
@@ -159,9 +240,9 @@ bool BlockedModsDialog::checkValidPath(QString path)
QFileInfo file = QFileInfo(path);
QString filename = file.fileName();
- for (auto& mod : mods) {
+ for (auto& mod : m_mods) {
if (mod.name.compare(filename, Qt::CaseInsensitive) == 0) {
- qDebug() << "Name match found:" << mod.name << "| From path:" << path;
+ qDebug() << "[Blocked Mods Dialog] Name match found:" << mod.name << "| From path:" << path;
return true;
}
}
@@ -171,7 +252,61 @@ bool BlockedModsDialog::checkValidPath(QString path)
bool BlockedModsDialog::allModsMatched()
{
- return std::all_of(mods.begin(), mods.end(), [](auto const& mod) { return mod.matched; });
+ return std::all_of(m_mods.begin(), m_mods.end(), [](auto const& mod) { return mod.matched; });
+}
+
+/// @brief ensure matched file paths still exist
+void BlockedModsDialog::validateMatchedMods()
+{
+ bool changed = false;
+ for (auto& mod : m_mods) {
+ if (mod.matched) {
+ QFileInfo file = QFileInfo(mod.localPath);
+ if (!file.exists() || !file.isFile()) {
+ qDebug() << "[Blocked Mods Dialog] File" << mod.localPath << "for mod" << mod.name
+ << "has vanshed! marking as not matched.";
+ mod.localPath = "";
+ mod.matched = false;
+ changed = true;
+ }
+ }
+ }
+ if (changed) {
+ update();
+ }
+}
+
+/// @brief run hash task or mark a pending run if it is already runing
+void BlockedModsDialog::runHashTask()
+{
+ if (!m_hashing_task->isRunning()) {
+ m_rehash_pending = false;
+
+ if (!m_pending_hash_paths.isEmpty()) {
+ qDebug() << "[Blocked Mods Dialog] there are pending hash tasks, building and running tasks";
+
+ auto path = m_pending_hash_paths.begin();
+ while (path != m_pending_hash_paths.end()) {
+ buildHashTask(*path);
+ path = m_pending_hash_paths.erase(path);
+ }
+
+ m_hashing_task->start();
+ }
+ } else {
+ qDebug() << "[Blocked Mods Dialog] queueing another run of the hashing task";
+ qDebug() << "[Blocked Mods Dialog] pending hash tasks:" << m_pending_hash_paths;
+ m_rehash_pending = true;
+ }
+}
+
+void BlockedModsDialog::hashTaskFinished()
+{
+ qDebug() << "[Blocked Mods Dialog] All hash tasks finished";
+ if (m_rehash_pending) {
+ qDebug() << "[Blocked Mods Dialog] task finished with a rehash pending, rerunning";
+ runHashTask();
+ }
}
/// qDebug print support for the BlockedMod struct
diff --git a/launcher/ui/dialogs/BlockedModsDialog.h b/launcher/ui/dialogs/BlockedModsDialog.h
index 0a5c90db..dac43cba 100644
--- a/launcher/ui/dialogs/BlockedModsDialog.h
+++ b/launcher/ui/dialogs/BlockedModsDialog.h
@@ -31,20 +31,31 @@ public:
~BlockedModsDialog() override;
+protected:
+ void dragEnterEvent(QDragEnterEvent *event) override;
+ void dropEvent(QDropEvent *event) override;
private:
Ui::BlockedModsDialog *ui;
- QList<BlockedMod> &mods;
- QFileSystemWatcher watcher;
- shared_qobject_ptr<ConcurrentTask> hashing_task;
+ QList<BlockedMod> &m_mods;
+ QFileSystemWatcher m_watcher;
+ shared_qobject_ptr<ConcurrentTask> m_hashing_task;
+ QSet<QString> m_pending_hash_paths;
+ bool m_rehash_pending;
void openAll();
+ void addDownloadFolder();
void update();
void directoryChanged(QString path);
void setupWatch();
void scanPaths();
- void scanPath(QString path);
+ void scanPath(QString path, bool start_task);
+ void addHashTask(QString path);
+ void buildHashTask(QString path);
void checkMatchHash(QString hash, QString path);
+ void validateMatchedMods();
+ void runHashTask();
+ void hashTaskFinished();
bool checkValidPath(QString path);
bool allModsMatched();
diff --git a/launcher/ui/dialogs/BlockedModsDialog.ui b/launcher/ui/dialogs/BlockedModsDialog.ui
index 371549cf..88105178 100644
--- a/launcher/ui/dialogs/BlockedModsDialog.ui
+++ b/launcher/ui/dialogs/BlockedModsDialog.ui
@@ -15,17 +15,39 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
- <widget class="QLabel" name="label">
+ <widget class="QLabel" name="labelDescription">
<property name="text">
<string notr="true"/>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
</widget>
</item>
<item>
- <widget class="QTextBrowser" name="textBrowser">
+ <widget class="QLabel" name="labelExplain">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ <property name="openExternalLinks">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTextBrowser" name="textBrowserModsListing">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>165</height>
+ </size>
+ </property>
<property name="acceptRichText">
<bool>true</bool>
</property>
@@ -35,6 +57,47 @@
</widget>
</item>
<item>
+ <widget class="QLabel" name="labelWatched">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>1</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Watched Folders:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTextBrowser" name="textBrowserWatched">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>16</height>
+ </size>
+ </property>
+ <property name="baseSize">
+ <size>
+ <width>0</width>
+ <height>12</height>
+ </size>
+ </property>
+ <property name="openExternalLinks">
+ <bool>true</bool>
+ </property>
+ <property name="openLinks">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
<layout class="QHBoxLayout" name="bottomBoxH">
<item>
<widget class="QLabel" name="labelModsFound">
diff --git a/libraries/tomlplusplus b/libraries/tomlplusplus
-Subproject cc741c9f5f2a62856a2a2e9e275f61eb0591c09
+Subproject 0a90913abf9390b9e08ab6d3b40ac11634553f3