diff options
author | Ryan Cao <70191398+ryanccn@users.noreply.github.com> | 2022-11-19 23:38:05 +0800 |
---|---|---|
committer | Ryan Cao <70191398+ryanccn@users.noreply.github.com> | 2022-11-19 23:38:05 +0800 |
commit | b1bdc6f745d607af4dc1bb592003a538ee03f058 (patch) | |
tree | 2e9bddf73a4c15ef526f0ad6c549366dfe76ca3f /launcher/Application.cpp | |
parent | 8dacbafc8ba45ae6c2b770da77cc0d3d632849ba (diff) | |
download | PrismLauncher-b1bdc6f745d607af4dc1bb592003a538ee03f058.tar.gz PrismLauncher-b1bdc6f745d607af4dc1bb592003a538ee03f058.tar.bz2 PrismLauncher-b1bdc6f745d607af4dc1bb592003a538ee03f058.zip |
fix resource packs and add support for texture packs
Signed-off-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com>
Diffstat (limited to 'launcher/Application.cpp')
-rw-r--r-- | launcher/Application.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 71cd009a..9258aec4 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -101,6 +101,9 @@ #include <minecraft/mod/ResourcePack.h> #include <minecraft/mod/ResourcePackFolderModel.h> #include <minecraft/mod/tasks/LocalResourcePackParseTask.h> +#include <minecraft/mod/TexturePack.h> +#include <minecraft/mod/TexturePackFolderModel.h> +#include <minecraft/mod/tasks/LocalTexturePackParseTask.h> #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<QApplicationStateChangeEvent*>(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<QFileOpenEvent*>(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<MinecraftInstance>(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<MinecraftInstance>(instance); + instanceButBuffed->texturePackList()->installResource(ev->file()); + } } else { m_mainWindow->droppedURLs({ ev->url() }); } |