From 8dacbafc8ba45ae6c2b770da77cc0d3d632849ba Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Sat, 19 Nov 2022 23:04:26 +0800 Subject: [PATCH 01/15] feat: initial support for smart resource pack parsing on file handler Signed-off-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com> --- launcher/Application.cpp | 23 ++++++- launcher/CMakeLists.txt | 3 + .../ui/dialogs/ImportResourcePackDialog.cpp | 61 +++++++++++++++++ .../ui/dialogs/ImportResourcePackDialog.h | 24 +++++++ .../ui/dialogs/ImportResourcePackDialog.ui | 67 +++++++++++++++++++ 5 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 launcher/ui/dialogs/ImportResourcePackDialog.cpp create mode 100644 launcher/ui/dialogs/ImportResourcePackDialog.h create mode 100644 launcher/ui/dialogs/ImportResourcePackDialog.ui diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 883f8968b..71cd009a5 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -66,6 +66,7 @@ #include "ui/setupwizard/PasteWizardPage.h" #include "ui/dialogs/CustomMessageBox.h" +#include "ui/dialogs/ImportResourcePackDialog.h" #include "ui/pagedialog/PageDialog.h" @@ -96,6 +97,10 @@ #include "net/HttpMetaCache.h" #include "java/JavaUtils.h" +#include +#include +#include +#include #include "updater/UpdateChecker.h" @@ -930,7 +935,23 @@ bool Application::event(QEvent* event) { if (event->type() == QEvent::FileOpen) { auto ev = static_cast(event); - m_mainWindow->droppedURLs({ ev->url() }); + + ResourcePack pack{ QFileInfo(ev->file()) }; + + ResourcePackUtils::process(pack); + // + + if (pack.valid()) { + ImportResourcePackDialog dlg(APPLICATION->m_mainWindow); + dlg.exec(); + if (dlg.result() == QDialog::Accepted) { + auto instance = APPLICATION->instances()->getInstanceById(dlg.selectedInstanceKey); + auto instanceButBuffed = std::dynamic_pointer_cast(instance); + instanceButBuffed->resourcePackList()->installResource(ev->file()); + } + } else { + m_mainWindow->droppedURLs({ ev->url() }); + } } return QApplication::event(event); diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 8db934298..58d5d9648 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -791,6 +791,8 @@ SET(LAUNCHER_SOURCES ui/dialogs/ExportInstanceDialog.h ui/dialogs/IconPickerDialog.cpp ui/dialogs/IconPickerDialog.h + ui/dialogs/ImportResourcePackDialog.cpp + ui/dialogs/ImportResourcePackDialog.h ui/dialogs/LoginDialog.cpp ui/dialogs/LoginDialog.h ui/dialogs/MSALoginDialog.cpp @@ -939,6 +941,7 @@ qt_wrap_ui(LAUNCHER_UI ui/dialogs/SkinUploadDialog.ui ui/dialogs/ExportInstanceDialog.ui ui/dialogs/IconPickerDialog.ui + ui/dialogs/ImportResourcePackDialog.ui ui/dialogs/MSALoginDialog.ui ui/dialogs/OfflineLoginDialog.ui ui/dialogs/AboutDialog.ui diff --git a/launcher/ui/dialogs/ImportResourcePackDialog.cpp b/launcher/ui/dialogs/ImportResourcePackDialog.cpp new file mode 100644 index 000000000..ef76445cf --- /dev/null +++ b/launcher/ui/dialogs/ImportResourcePackDialog.cpp @@ -0,0 +1,61 @@ +#include "ImportResourcePackDialog.h" +#include "ui_ImportResourcePackDialog.h" + +#include +#include + +#include "Application.h" +#include "InstanceList.h" + +#include "ui/instanceview/InstanceDelegate.h" + +ImportResourcePackDialog::ImportResourcePackDialog(QWidget* parent) : QDialog(parent), ui(new Ui::ImportResourcePackDialog) +{ + ui->setupUi(this); + setWindowModality(Qt::WindowModal); + + auto contentsWidget = ui->instanceView; + contentsWidget->setViewMode(QListView::ListMode); + contentsWidget->setFlow(QListView::LeftToRight); + contentsWidget->setIconSize(QSize(48, 48)); + contentsWidget->setMovement(QListView::Static); + contentsWidget->setResizeMode(QListView::Adjust); + contentsWidget->setSelectionMode(QAbstractItemView::SingleSelection); + contentsWidget->setSpacing(5); + contentsWidget->setWordWrap(false); + contentsWidget->setWrapping(true); + contentsWidget->setUniformItemSizes(true); + contentsWidget->setTextElideMode(Qt::ElideRight); + contentsWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); + contentsWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + contentsWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + contentsWidget->setItemDelegate(new ListViewDelegate()); + + contentsWidget->setModel(APPLICATION->instances().get()); + + connect(contentsWidget, SIGNAL(doubleClicked(QModelIndex)), SLOT(activated(QModelIndex))); + connect(contentsWidget->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), + SLOT(selectionChanged(QItemSelection, QItemSelection))); +} + +void ImportResourcePackDialog::activated(QModelIndex index) +{ + selectedInstanceKey = index.data(Qt::UserRole).toString(); + accept(); +} + +void ImportResourcePackDialog::selectionChanged(QItemSelection selected, QItemSelection deselected) +{ + if (selected.empty()) + return; + + QString key = selected.first().indexes().first().data(Qt::UserRole).toString(); + if (!key.isEmpty()) { + selectedInstanceKey = key; + } +} + +ImportResourcePackDialog::~ImportResourcePackDialog() +{ + delete ui; +} diff --git a/launcher/ui/dialogs/ImportResourcePackDialog.h b/launcher/ui/dialogs/ImportResourcePackDialog.h new file mode 100644 index 000000000..b077a811b --- /dev/null +++ b/launcher/ui/dialogs/ImportResourcePackDialog.h @@ -0,0 +1,24 @@ +#pragma once + +#include +#include + +namespace Ui { +class ImportResourcePackDialog; +} + +class ImportResourcePackDialog : public QDialog { + Q_OBJECT + + public: + explicit ImportResourcePackDialog(QWidget* parent = 0); + ~ImportResourcePackDialog(); + QString selectedInstanceKey; + + private: + Ui::ImportResourcePackDialog* ui; + + private slots: + void selectionChanged(QItemSelection, QItemSelection); + void activated(QModelIndex); +}; diff --git a/launcher/ui/dialogs/ImportResourcePackDialog.ui b/launcher/ui/dialogs/ImportResourcePackDialog.ui new file mode 100644 index 000000000..2a1de0f9b --- /dev/null +++ b/launcher/ui/dialogs/ImportResourcePackDialog.ui @@ -0,0 +1,67 @@ + + + ImportResourcePackDialog + + + + 0 + 0 + 676 + 555 + + + + Pick icon + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + ImportResourcePackDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + ImportResourcePackDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + From b1bdc6f745d607af4dc1bb592003a538ee03f058 Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Sat, 19 Nov 2022 23:38:05 +0800 Subject: [PATCH 02/15] fix resource packs and add support for texture packs Signed-off-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com> --- launcher/Application.cpp | 29 ++++++++++++++++++------- launcher/minecraft/mod/ResourcePack.cpp | 5 +++++ launcher/minecraft/mod/ResourcePack.h | 2 ++ launcher/minecraft/mod/TexturePack.cpp | 5 +++++ launcher/minecraft/mod/TexturePack.h | 2 ++ 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 71cd009a5..9258aec48 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -101,6 +101,9 @@ #include #include #include +#include +#include +#include #include "updater/UpdateChecker.h" @@ -920,13 +923,13 @@ bool Application::createSetupWizard() return false; } -bool Application::event(QEvent* event) { +bool Application::event(QEvent* event) +{ #ifdef Q_OS_MACOS if (event->type() == QEvent::ApplicationStateChange) { auto ev = static_cast(event); - if (m_prevAppState == Qt::ApplicationActive - && ev->applicationState() == Qt::ApplicationActive) { + if (m_prevAppState == Qt::ApplicationActive && ev->applicationState() == Qt::ApplicationActive) { emit clickedOnDock(); } m_prevAppState = ev->applicationState(); @@ -936,19 +939,29 @@ bool Application::event(QEvent* event) { if (event->type() == QEvent::FileOpen) { auto ev = static_cast(event); - ResourcePack pack{ QFileInfo(ev->file()) }; + ResourcePack rp{ QFileInfo(ev->file()) }; + TexturePack tp{ QFileInfo(ev->file()) }; - ResourcePackUtils::process(pack); - // + ImportResourcePackDialog dlg(APPLICATION->m_mainWindow); - if (pack.valid()) { - ImportResourcePackDialog dlg(APPLICATION->m_mainWindow); + if (ResourcePackUtils::process(rp) && rp.valid()) { dlg.exec(); + if (dlg.result() == QDialog::Accepted) { + qDebug() << "Selected instance to import resource pack into: " << dlg.selectedInstanceKey; auto instance = APPLICATION->instances()->getInstanceById(dlg.selectedInstanceKey); auto instanceButBuffed = std::dynamic_pointer_cast(instance); instanceButBuffed->resourcePackList()->installResource(ev->file()); } + } else if (TexturePackUtils::process(tp) && tp.valid()) { + dlg.exec(); + + if (dlg.result() == QDialog::Accepted) { + qDebug() << "Selected instance to import texture pack into: " << dlg.selectedInstanceKey; + auto instance = APPLICATION->instances()->getInstanceById(dlg.selectedInstanceKey); + auto instanceButBuffed = std::dynamic_pointer_cast(instance); + instanceButBuffed->texturePackList()->installResource(ev->file()); + } } else { m_mainWindow->droppedURLs({ ev->url() }); } diff --git a/launcher/minecraft/mod/ResourcePack.cpp b/launcher/minecraft/mod/ResourcePack.cpp index 3fc10a2fd..9f46cd2c3 100644 --- a/launcher/minecraft/mod/ResourcePack.cpp +++ b/launcher/minecraft/mod/ResourcePack.cpp @@ -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 031219081..7cb414d83 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 override; [[nodiscard]] bool applyFilter(QRegularExpression filter) const override; diff --git a/launcher/minecraft/mod/TexturePack.cpp b/launcher/minecraft/mod/TexturePack.cpp index 796eb69d0..99d555843 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 6aa5e18ef..81bd5c699 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; From f527958cb35b976d88e7037bda62762c1ffe6e13 Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Sat, 19 Nov 2022 23:42:56 +0800 Subject: [PATCH 03/15] fix: check if packFormat is valid for resourcepack parsing Signed-off-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com> --- launcher/minecraft/mod/ResourcePack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/minecraft/mod/ResourcePack.cpp b/launcher/minecraft/mod/ResourcePack.cpp index 9f46cd2c3..1e9db5969 100644 --- a/launcher/minecraft/mod/ResourcePack.cpp +++ b/launcher/minecraft/mod/ResourcePack.cpp @@ -117,5 +117,5 @@ bool ResourcePack::applyFilter(QRegularExpression filter) const bool ResourcePack::valid() const { - return m_pack_format != 0; + return s_pack_format_versions.contains(m_pack_format); } From a33b8049238329fa97545c0b2db5bb8c2f7545c6 Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Sat, 19 Nov 2022 23:47:47 +0800 Subject: [PATCH 04/15] fix: add resource pack format for 1.19.3 Co-authored-by: Rachel Powers <508861+Ryex@users.noreply.github.com> Signed-off-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com> --- launcher/minecraft/mod/ResourcePack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/minecraft/mod/ResourcePack.cpp b/launcher/minecraft/mod/ResourcePack.cpp index 1e9db5969..ef0370d02 100644 --- a/launcher/minecraft/mod/ResourcePack.cpp +++ b/launcher/minecraft/mod/ResourcePack.cpp @@ -15,7 +15,7 @@ static const QMap> 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) From 1f6b8f9d2bddd73e6cfd9d430ef9e37d1910adff Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Sat, 19 Nov 2022 23:59:30 +0800 Subject: [PATCH 05/15] fix instance IDs and resource pack imports Signed-off-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com> --- launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp | 2 +- launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp | 2 +- launcher/ui/dialogs/ImportResourcePackDialog.cpp | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp index 4f87bc130..d744c5350 100644 --- a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp +++ b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp @@ -152,7 +152,7 @@ bool LocalResourcePackParseTask::abort() void LocalResourcePackParseTask::executeTask() { - Q_ASSERT(m_resource_pack.valid()); + // Q_ASSERT(m_resource_pack.valid()); if (!ResourcePackUtils::process(m_resource_pack)) return; diff --git a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp index bf1e308fd..f23117ee2 100644 --- a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp +++ b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp @@ -143,7 +143,7 @@ bool LocalTexturePackParseTask::abort() void LocalTexturePackParseTask::executeTask() { - Q_ASSERT(m_texture_pack.valid()); + // Q_ASSERT(m_texture_pack.valid()); if (!TexturePackUtils::process(m_texture_pack)) return; diff --git a/launcher/ui/dialogs/ImportResourcePackDialog.cpp b/launcher/ui/dialogs/ImportResourcePackDialog.cpp index ef76445cf..4fe28540b 100644 --- a/launcher/ui/dialogs/ImportResourcePackDialog.cpp +++ b/launcher/ui/dialogs/ImportResourcePackDialog.cpp @@ -7,6 +7,7 @@ #include "Application.h" #include "InstanceList.h" +#include #include "ui/instanceview/InstanceDelegate.h" ImportResourcePackDialog::ImportResourcePackDialog(QWidget* parent) : QDialog(parent), ui(new Ui::ImportResourcePackDialog) @@ -40,7 +41,7 @@ ImportResourcePackDialog::ImportResourcePackDialog(QWidget* parent) : QDialog(pa void ImportResourcePackDialog::activated(QModelIndex index) { - selectedInstanceKey = index.data(Qt::UserRole).toString(); + selectedInstanceKey = index.data(InstanceList::InstanceIDRole).toString(); accept(); } @@ -49,7 +50,7 @@ void ImportResourcePackDialog::selectionChanged(QItemSelection selected, QItemSe if (selected.empty()) return; - QString key = selected.first().indexes().first().data(Qt::UserRole).toString(); + QString key = selected.first().indexes().first().data(InstanceList::InstanceIDRole).toString(); if (!key.isEmpty()) { selectedInstanceKey = key; } From a99cd16422bb577028a1caaa6e5bde300ac78372 Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Sun, 20 Nov 2022 00:14:16 +0800 Subject: [PATCH 06/15] fix: resource pack import dialog icons and add message Signed-off-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com> --- launcher/ui/dialogs/ImportResourcePackDialog.cpp | 6 +++++- launcher/ui/dialogs/ImportResourcePackDialog.h | 3 +++ launcher/ui/dialogs/ImportResourcePackDialog.ui | 9 ++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/launcher/ui/dialogs/ImportResourcePackDialog.cpp b/launcher/ui/dialogs/ImportResourcePackDialog.cpp index 4fe28540b..2b7466052 100644 --- a/launcher/ui/dialogs/ImportResourcePackDialog.cpp +++ b/launcher/ui/dialogs/ImportResourcePackDialog.cpp @@ -8,6 +8,7 @@ #include "InstanceList.h" #include +#include "ui/instanceview/InstanceProxyModel.h" #include "ui/instanceview/InstanceDelegate.h" ImportResourcePackDialog::ImportResourcePackDialog(QWidget* parent) : QDialog(parent), ui(new Ui::ImportResourcePackDialog) @@ -32,7 +33,10 @@ ImportResourcePackDialog::ImportResourcePackDialog(QWidget* parent) : QDialog(pa contentsWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); contentsWidget->setItemDelegate(new ListViewDelegate()); - contentsWidget->setModel(APPLICATION->instances().get()); + proxyModel = new InstanceProxyModel(this); + proxyModel->setSourceModel(APPLICATION->instances().get()); + proxyModel->sort(0); + contentsWidget->setModel(proxyModel); connect(contentsWidget, SIGNAL(doubleClicked(QModelIndex)), SLOT(activated(QModelIndex))); connect(contentsWidget->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), diff --git a/launcher/ui/dialogs/ImportResourcePackDialog.h b/launcher/ui/dialogs/ImportResourcePackDialog.h index b077a811b..8356f204f 100644 --- a/launcher/ui/dialogs/ImportResourcePackDialog.h +++ b/launcher/ui/dialogs/ImportResourcePackDialog.h @@ -3,6 +3,8 @@ #include #include +#include "ui/instanceview/InstanceProxyModel.h" + namespace Ui { class ImportResourcePackDialog; } @@ -13,6 +15,7 @@ class ImportResourcePackDialog : public QDialog { public: explicit ImportResourcePackDialog(QWidget* parent = 0); ~ImportResourcePackDialog(); + InstanceProxyModel* proxyModel; QString selectedInstanceKey; private: diff --git a/launcher/ui/dialogs/ImportResourcePackDialog.ui b/launcher/ui/dialogs/ImportResourcePackDialog.ui index 2a1de0f9b..20cb91770 100644 --- a/launcher/ui/dialogs/ImportResourcePackDialog.ui +++ b/launcher/ui/dialogs/ImportResourcePackDialog.ui @@ -11,9 +11,16 @@ - Pick icon + Choose instance to import + + + + Choose the instance you would like to import this resource pack to. + + + From e0e428ce38ff5662089036a6bbf017a3b39f478f Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Sun, 20 Nov 2022 00:28:35 +0800 Subject: [PATCH 07/15] fix: add support for CLI and drag and drop Signed-off-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com> --- launcher/Application.cpp | 35 +-------------------------- launcher/ui/MainWindow.cpp | 48 +++++++++++++++++++++++++++++++------- 2 files changed, 41 insertions(+), 42 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 9258aec48..0fbe4ae2c 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -66,7 +66,6 @@ #include "ui/setupwizard/PasteWizardPage.h" #include "ui/dialogs/CustomMessageBox.h" -#include "ui/dialogs/ImportResourcePackDialog.h" #include "ui/pagedialog/PageDialog.h" @@ -98,12 +97,6 @@ #include "java/JavaUtils.h" #include -#include -#include -#include -#include -#include -#include #include "updater/UpdateChecker.h" @@ -938,33 +931,7 @@ bool Application::event(QEvent* event) if (event->type() == QEvent::FileOpen) { auto ev = static_cast(event); - - ResourcePack rp{ QFileInfo(ev->file()) }; - TexturePack tp{ QFileInfo(ev->file()) }; - - ImportResourcePackDialog dlg(APPLICATION->m_mainWindow); - - if (ResourcePackUtils::process(rp) && rp.valid()) { - dlg.exec(); - - if (dlg.result() == QDialog::Accepted) { - qDebug() << "Selected instance to import resource pack into: " << dlg.selectedInstanceKey; - auto instance = APPLICATION->instances()->getInstanceById(dlg.selectedInstanceKey); - auto instanceButBuffed = std::dynamic_pointer_cast(instance); - instanceButBuffed->resourcePackList()->installResource(ev->file()); - } - } else if (TexturePackUtils::process(tp) && tp.valid()) { - dlg.exec(); - - if (dlg.result() == QDialog::Accepted) { - qDebug() << "Selected instance to import texture pack into: " << dlg.selectedInstanceKey; - auto instance = APPLICATION->instances()->getInstanceById(dlg.selectedInstanceKey); - auto instanceButBuffed = std::dynamic_pointer_cast(instance); - instanceButBuffed->texturePackList()->installResource(ev->file()); - } - } else { - m_mainWindow->droppedURLs({ ev->url() }); - } + m_mainWindow->droppedURLs({ ev->url() }); } return QApplication::event(event); diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 929f2a85c..ed61777e5 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -106,8 +106,16 @@ #include "ui/dialogs/UpdateDialog.h" #include "ui/dialogs/EditAccountDialog.h" #include "ui/dialogs/ExportInstanceDialog.h" +#include "ui/dialogs/ImportResourcePackDialog.h" #include "ui/themes/ITheme.h" +#include +#include +#include +#include +#include +#include + #include "UpdateController.h" #include "KonamiCode.h" @@ -1794,16 +1802,40 @@ void MainWindow::on_actionAddInstance_triggered() void MainWindow::droppedURLs(QList urls) { - for(auto & url:urls) - { - if(url.isLocalFile()) - { - addInstance(url.toLocalFile()); - } - else - { + for (auto& url : urls) { + if (url.isLocalFile()) { + auto localFileName = url.toLocalFile(); + + ResourcePack rp{ QFileInfo(localFileName) }; + TexturePack tp{ QFileInfo(localFileName) }; + + ImportResourcePackDialog dlg(this); + + if (ResourcePackUtils::process(rp) && rp.valid()) { + dlg.exec(); + + if (dlg.result() == QDialog::Accepted) { + qDebug() << "Selected instance to import resource pack into: " << dlg.selectedInstanceKey; + auto instance = APPLICATION->instances()->getInstanceById(dlg.selectedInstanceKey); + auto instanceButBuffed = std::dynamic_pointer_cast(instance); + instanceButBuffed->resourcePackList()->installResource(localFileName); + } + } else if (TexturePackUtils::process(tp) && tp.valid()) { + dlg.exec(); + + if (dlg.result() == QDialog::Accepted) { + qDebug() << "Selected instance to import texture pack into: " << dlg.selectedInstanceKey; + auto instance = APPLICATION->instances()->getInstanceById(dlg.selectedInstanceKey); + auto instanceButBuffed = std::dynamic_pointer_cast(instance); + instanceButBuffed->texturePackList()->installResource(localFileName); + } + } else { + addInstance(localFileName); + } + } else { addInstance(url.toString()); } + // Only process one dropped file... break; } From d92ae530d7c585eb859d852ba1877230a82d867e Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Sun, 20 Nov 2022 00:31:58 +0800 Subject: [PATCH 08/15] fix: stray include Signed-off-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com> --- launcher/Application.cpp | 1 - launcher/ui/MainWindow.cpp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 0fbe4ae2c..c5594b215 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -96,7 +96,6 @@ #include "net/HttpMetaCache.h" #include "java/JavaUtils.h" -#include #include "updater/UpdateChecker.h" diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index ed61777e5..98fd79be0 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -71,6 +71,7 @@ #include #include +#include #include #include #include From df0f9259c0bf79e10b27ad5b429b53559ffd15f0 Mon Sep 17 00:00:00 2001 From: flow Date: Sun, 20 Nov 2022 11:04:10 -0300 Subject: [PATCH 09/15] refactor: move RP/TP validation to their respective utils This makes it easier to validate individual resources, and allows the logic to be used in other places in the future, if we need to. Signed-off-by: flow --- .../mod/tasks/LocalResourcePackParseTask.cpp | 25 +++++++++--- .../mod/tasks/LocalResourcePackParseTask.h | 12 ++++-- .../mod/tasks/LocalTexturePackParseTask.cpp | 25 +++++++++--- .../mod/tasks/LocalTexturePackParseTask.h | 12 ++++-- launcher/ui/MainWindow.cpp | 40 +++++++++---------- 5 files changed, 76 insertions(+), 38 deletions(-) diff --git a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp index d744c5350..f58a0620b 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) diff --git a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.h b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.h index d3c254645..69dbd6ad6 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 f23117ee2..8da366c1b 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) diff --git a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.h b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.h index cb0e404a7..9f7aab75f 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 { diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 98fd79be0..5d2a07f32 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -110,10 +110,8 @@ #include "ui/dialogs/ImportResourcePackDialog.h" #include "ui/themes/ITheme.h" -#include #include #include -#include #include #include @@ -1806,32 +1804,30 @@ void MainWindow::droppedURLs(QList urls) for (auto& url : urls) { if (url.isLocalFile()) { auto localFileName = url.toLocalFile(); - - ResourcePack rp{ QFileInfo(localFileName) }; - TexturePack tp{ QFileInfo(localFileName) }; + QFileInfo localFileInfo(localFileName); ImportResourcePackDialog dlg(this); - if (ResourcePackUtils::process(rp) && rp.valid()) { - dlg.exec(); + if (ResourcePackUtils::validate(localFileInfo)) { + dlg.exec(); - if (dlg.result() == QDialog::Accepted) { - qDebug() << "Selected instance to import resource pack into: " << dlg.selectedInstanceKey; - auto instance = APPLICATION->instances()->getInstanceById(dlg.selectedInstanceKey); - auto instanceButBuffed = std::dynamic_pointer_cast(instance); - instanceButBuffed->resourcePackList()->installResource(localFileName); - } - } else if (TexturePackUtils::process(tp) && tp.valid()) { - dlg.exec(); + if (dlg.result() == QDialog::Accepted) { + qDebug() << "Selected instance to import resource pack into: " << dlg.selectedInstanceKey; + auto instance = APPLICATION->instances()->getInstanceById(dlg.selectedInstanceKey); + auto instanceButBuffed = std::dynamic_pointer_cast(instance); + instanceButBuffed->resourcePackList()->installResource(localFileName); + } + } else if (TexturePackUtils::validate(localFileInfo)) { + dlg.exec(); - if (dlg.result() == QDialog::Accepted) { - qDebug() << "Selected instance to import texture pack into: " << dlg.selectedInstanceKey; - auto instance = APPLICATION->instances()->getInstanceById(dlg.selectedInstanceKey); - auto instanceButBuffed = std::dynamic_pointer_cast(instance); - instanceButBuffed->texturePackList()->installResource(localFileName); - } + if (dlg.result() == QDialog::Accepted) { + qDebug() << "Selected instance to import texture pack into: " << dlg.selectedInstanceKey; + auto instance = APPLICATION->instances()->getInstanceById(dlg.selectedInstanceKey); + auto instanceButBuffed = std::dynamic_pointer_cast(instance); + instanceButBuffed->texturePackList()->installResource(localFileName); + } } else { - addInstance(localFileName); + addInstance(localFileName); } } else { addInstance(url.toString()); From f55fc51e9b372e00ada739cfa679387079ffca2a Mon Sep 17 00:00:00 2001 From: flow Date: Sun, 20 Nov 2022 11:09:24 -0300 Subject: [PATCH 10/15] fix: remove commented-out assertions They may not hold true at all times, and that's fine. Signed-off-by: flow --- launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp | 2 -- launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp | 2 -- 2 files changed, 4 deletions(-) diff --git a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp index f58a0620b..6fd4b0245 100644 --- a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp +++ b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp @@ -167,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/LocalTexturePackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp index 8da366c1b..adb19aca9 100644 --- a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp +++ b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp @@ -158,8 +158,6 @@ bool LocalTexturePackParseTask::abort() void LocalTexturePackParseTask::executeTask() { - // Q_ASSERT(m_texture_pack.valid()); - if (!TexturePackUtils::process(m_texture_pack)) return; From 7096f02b88e982df6c770113146a07874a1e9d0f Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Mon, 21 Nov 2022 18:15:03 +0800 Subject: [PATCH 11/15] fix: text wrapping Signed-off-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com> --- launcher/ui/dialogs/ImportResourcePackDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/ui/dialogs/ImportResourcePackDialog.cpp b/launcher/ui/dialogs/ImportResourcePackDialog.cpp index 2b7466052..7a2152b71 100644 --- a/launcher/ui/dialogs/ImportResourcePackDialog.cpp +++ b/launcher/ui/dialogs/ImportResourcePackDialog.cpp @@ -27,7 +27,7 @@ ImportResourcePackDialog::ImportResourcePackDialog(QWidget* parent) : QDialog(pa contentsWidget->setWordWrap(false); contentsWidget->setWrapping(true); contentsWidget->setUniformItemSizes(true); - contentsWidget->setTextElideMode(Qt::ElideRight); + contentsWidget->setWordWrap(true); contentsWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); contentsWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); contentsWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); From bae0a0530bd5334a2f41ed234a20a064b5245232 Mon Sep 17 00:00:00 2001 From: flow Date: Fri, 25 Nov 2022 11:51:08 -0300 Subject: [PATCH 12/15] fix(RPImportDialog): allow changing item size to accomodate wrapped text Signed-off-by: flow --- launcher/ui/dialogs/ImportResourcePackDialog.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/launcher/ui/dialogs/ImportResourcePackDialog.cpp b/launcher/ui/dialogs/ImportResourcePackDialog.cpp index 7a2152b71..e807e9265 100644 --- a/launcher/ui/dialogs/ImportResourcePackDialog.cpp +++ b/launcher/ui/dialogs/ImportResourcePackDialog.cpp @@ -24,10 +24,10 @@ ImportResourcePackDialog::ImportResourcePackDialog(QWidget* parent) : QDialog(pa contentsWidget->setResizeMode(QListView::Adjust); contentsWidget->setSelectionMode(QAbstractItemView::SingleSelection); contentsWidget->setSpacing(5); - contentsWidget->setWordWrap(false); - contentsWidget->setWrapping(true); - contentsWidget->setUniformItemSizes(true); contentsWidget->setWordWrap(true); + contentsWidget->setWrapping(true); + // NOTE: We can't have uniform sizes because the text may wrap if it's too long. If we set this, it will cut off the wrapped text. + contentsWidget->setUniformItemSizes(false); contentsWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); contentsWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); contentsWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); From 236c196e681dcbf0547677260d141a7e48047b43 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sun, 27 Nov 2022 18:38:56 +0100 Subject: [PATCH 13/15] fix: improve code readability Signed-off-by: Sefa Eyeoglu --- launcher/ui/MainWindow.cpp | 56 ++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 5d2a07f32..c3c4d10f9 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -1801,39 +1801,37 @@ void MainWindow::on_actionAddInstance_triggered() void MainWindow::droppedURLs(QList urls) { + // NOTE: This loop only processes one dropped file! for (auto& url : urls) { - if (url.isLocalFile()) { - auto localFileName = url.toLocalFile(); - QFileInfo localFileInfo(localFileName); - - ImportResourcePackDialog dlg(this); - - if (ResourcePackUtils::validate(localFileInfo)) { - dlg.exec(); - - if (dlg.result() == QDialog::Accepted) { - qDebug() << "Selected instance to import resource pack into: " << dlg.selectedInstanceKey; - auto instance = APPLICATION->instances()->getInstanceById(dlg.selectedInstanceKey); - auto instanceButBuffed = std::dynamic_pointer_cast(instance); - instanceButBuffed->resourcePackList()->installResource(localFileName); - } - } else if (TexturePackUtils::validate(localFileInfo)) { - dlg.exec(); - - if (dlg.result() == QDialog::Accepted) { - qDebug() << "Selected instance to import texture pack into: " << dlg.selectedInstanceKey; - auto instance = APPLICATION->instances()->getInstanceById(dlg.selectedInstanceKey); - auto instanceButBuffed = std::dynamic_pointer_cast(instance); - instanceButBuffed->texturePackList()->installResource(localFileName); - } - } else { - addInstance(localFileName); - } - } else { + if (!url.isLocalFile()) { // probably instance/modpack addInstance(url.toString()); + break; } - // Only process one dropped file... + auto localFileName = url.toLocalFile(); + QFileInfo localFileInfo(localFileName); + + bool isResourcePack = ResourcePackUtils::validate(localFileInfo); + bool isTexturePack = TexturePackUtils::validate(localFileInfo); + + if (!isResourcePack && !isTexturePack) { // probably instance/modpack + addInstance(localFileName); + break; + } + + ImportResourcePackDialog dlg(this); + + if (dlg.exec() != QDialog::Accepted) + break; + + qDebug() << "Adding resource/texture pack" << localFileName << "to" << dlg.selectedInstanceKey; + + auto inst = APPLICATION->instances()->getInstanceById(dlg.selectedInstanceKey); + auto minecraftInst = std::dynamic_pointer_cast(inst); + if (isResourcePack) + minecraftInst->resourcePackList()->installResource(localFileName); + else if (isTexturePack) + minecraftInst->texturePackList()->installResource(localFileName); break; } } From 8cac61f0bea17036346438761728c3b7bef4fbeb Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sun, 27 Nov 2022 18:41:52 +0100 Subject: [PATCH 14/15] fix: check resource pack validity solely using pack format Signed-off-by: Sefa Eyeoglu --- launcher/minecraft/mod/ResourcePack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/minecraft/mod/ResourcePack.cpp b/launcher/minecraft/mod/ResourcePack.cpp index ef0370d02..4a9ad21bf 100644 --- a/launcher/minecraft/mod/ResourcePack.cpp +++ b/launcher/minecraft/mod/ResourcePack.cpp @@ -117,5 +117,5 @@ bool ResourcePack::applyFilter(QRegularExpression filter) const bool ResourcePack::valid() const { - return s_pack_format_versions.contains(m_pack_format); + return m_pack_format != 0; } From 3cc987a5b4afdc0b8df5be420fc6d1e2a19fbe66 Mon Sep 17 00:00:00 2001 From: flow Date: Thu, 1 Dec 2022 22:54:03 -0300 Subject: [PATCH 15/15] fix: explicitly set scheme for local file in -I argument Otherwise isLocalFile() will return false for local files without the file:// thingy. Signed-off-by: flow --- launcher/ui/MainWindow.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index e2fb10954..b626bbae5 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -1817,6 +1817,10 @@ void MainWindow::droppedURLs(QList urls) { // NOTE: This loop only processes one dropped file! for (auto& url : urls) { + // The isLocalFile() check below doesn't work as intended without an explicit scheme. + if (url.scheme().isEmpty()) + url.setScheme("file"); + if (!url.isLocalFile()) { // probably instance/modpack addInstance(url.toString()); break;