diff options
author | flow <flowlnlnln@gmail.com> | 2022-11-20 11:04:10 -0300 |
---|---|---|
committer | flow <flowlnlnln@gmail.com> | 2022-11-20 11:10:26 -0300 |
commit | df0f9259c0bf79e10b27ad5b429b53559ffd15f0 (patch) | |
tree | 0f0d061fb8cc8017de86403e61e2abdcaf732c42 /launcher/ui | |
parent | d92ae530d7c585eb859d852ba1877230a82d867e (diff) | |
download | PrismLauncher-df0f9259c0bf79e10b27ad5b429b53559ffd15f0.tar.gz PrismLauncher-df0f9259c0bf79e10b27ad5b429b53559ffd15f0.tar.bz2 PrismLauncher-df0f9259c0bf79e10b27ad5b429b53559ffd15f0.zip |
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 <flowlnlnln@gmail.com>
Diffstat (limited to 'launcher/ui')
-rw-r--r-- | launcher/ui/MainWindow.cpp | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 98fd79be..5d2a07f3 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 <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> @@ -1806,32 +1804,30 @@ void MainWindow::droppedURLs(QList<QUrl> 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 (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); - } + 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<MinecraftInstance>(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<MinecraftInstance>(instance); + instanceButBuffed->texturePackList()->installResource(localFileName); + } } else { - addInstance(localFileName); + addInstance(localFileName); } } else { addInstance(url.toString()); |