diff options
author | Ryan Cao <70191398+ryanccn@users.noreply.github.com> | 2022-11-20 00:28:35 +0800 |
---|---|---|
committer | Ryan Cao <70191398+ryanccn@users.noreply.github.com> | 2022-11-20 00:28:35 +0800 |
commit | e0e428ce38ff5662089036a6bbf017a3b39f478f (patch) | |
tree | 18f4c439179745ab8871d5dbfdf4d8938dcfc85b /launcher/ui | |
parent | a99cd16422bb577028a1caaa6e5bde300ac78372 (diff) | |
download | PrismLauncher-e0e428ce38ff5662089036a6bbf017a3b39f478f.tar.gz PrismLauncher-e0e428ce38ff5662089036a6bbf017a3b39f478f.tar.bz2 PrismLauncher-e0e428ce38ff5662089036a6bbf017a3b39f478f.zip |
fix: add support for CLI and drag and drop
Signed-off-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com>
Diffstat (limited to 'launcher/ui')
-rw-r--r-- | launcher/ui/MainWindow.cpp | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 929f2a85..ed61777e 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 <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 "UpdateController.h" #include "KonamiCode.h" @@ -1794,16 +1802,40 @@ void MainWindow::on_actionAddInstance_triggered() void MainWindow::droppedURLs(QList<QUrl> 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<MinecraftInstance>(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<MinecraftInstance>(instance); + instanceButBuffed->texturePackList()->installResource(localFileName); + } + } else { + addInstance(localFileName); + } + } else { addInstance(url.toString()); } + // Only process one dropped file... break; } |