aboutsummaryrefslogtreecommitdiff
path: root/launcher/Application.cpp
diff options
context:
space:
mode:
authorRyan Cao <70191398+ryanccn@users.noreply.github.com>2022-11-19 23:04:26 +0800
committerRyan Cao <70191398+ryanccn@users.noreply.github.com>2022-11-19 23:14:57 +0800
commit8dacbafc8ba45ae6c2b770da77cc0d3d632849ba (patch)
treec0b850d2a4bea1c2a4d60e7280ef28b60726ee0e /launcher/Application.cpp
parent3482076a207444bbdd9a7667df40b80bce1c545c (diff)
downloadPrismLauncher-8dacbafc8ba45ae6c2b770da77cc0d3d632849ba.tar.gz
PrismLauncher-8dacbafc8ba45ae6c2b770da77cc0d3d632849ba.tar.bz2
PrismLauncher-8dacbafc8ba45ae6c2b770da77cc0d3d632849ba.zip
feat: initial support for smart resource pack parsing on file handler
Signed-off-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com>
Diffstat (limited to 'launcher/Application.cpp')
-rw-r--r--launcher/Application.cpp23
1 files changed, 22 insertions, 1 deletions
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 <minecraft/MinecraftInstance.h>
+#include <minecraft/mod/ResourcePack.h>
+#include <minecraft/mod/ResourcePackFolderModel.h>
+#include <minecraft/mod/tasks/LocalResourcePackParseTask.h>
#include "updater/UpdateChecker.h"
@@ -930,7 +935,23 @@ bool Application::event(QEvent* event) {
if (event->type() == QEvent::FileOpen) {
auto ev = static_cast<QFileOpenEvent*>(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<MinecraftInstance>(instance);
+ instanceButBuffed->resourcePackList()->installResource(ev->file());
+ }
+ } else {
+ m_mainWindow->droppedURLs({ ev->url() });
+ }
}
return QApplication::event(event);