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: 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 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'launcher/Application.cpp') diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 883f8968..71cd009a 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); -- cgit