diff options
author | flow <flowlnlnln@gmail.com> | 2022-12-16 20:26:10 -0300 |
---|---|---|
committer | flow <flowlnlnln@gmail.com> | 2023-02-05 17:02:52 -0300 |
commit | c3ea303a3742c886aae9e05d2e5f5fbb497260a1 (patch) | |
tree | a6d0d45d75b3761c8b92194d167b7128352efb09 /launcher/ui/dialogs | |
parent | e89a10945c683a1212fa6aa7824173f4f20cdee6 (diff) | |
download | PrismLauncher-c3ea303a3742c886aae9e05d2e5f5fbb497260a1.tar.gz PrismLauncher-c3ea303a3742c886aae9e05d2e5f5fbb497260a1.tar.bz2 PrismLauncher-c3ea303a3742c886aae9e05d2e5f5fbb497260a1.zip |
feat(RD): add resource pack downloader
Signed-off-by: flow <flowlnlnln@gmail.com>
Diffstat (limited to 'launcher/ui/dialogs')
-rw-r--r-- | launcher/ui/dialogs/ResourceDownloadDialog.cpp | 27 | ||||
-rw-r--r-- | launcher/ui/dialogs/ResourceDownloadDialog.h | 20 |
2 files changed, 47 insertions, 0 deletions
diff --git a/launcher/ui/dialogs/ResourceDownloadDialog.cpp b/launcher/ui/dialogs/ResourceDownloadDialog.cpp index fa829bfb..edcd642e 100644 --- a/launcher/ui/dialogs/ResourceDownloadDialog.cpp +++ b/launcher/ui/dialogs/ResourceDownloadDialog.cpp @@ -25,6 +25,7 @@ #include "ResourceDownloadTask.h" #include "minecraft/mod/ModFolderModel.h" +#include "minecraft/mod/ResourcePackFolderModel.h" #include "ui/dialogs/ReviewMessageBox.h" @@ -229,4 +230,30 @@ QList<BasePage*> ModDownloadDialog::getPages() return pages; } + +ResourcePackDownloadDialog::ResourcePackDownloadDialog(QWidget* parent, + const std::shared_ptr<ResourcePackFolderModel>& resource_packs, + BaseInstance* instance) + : ResourceDownloadDialog(parent, resource_packs), m_instance(instance) +{ + setWindowTitle(dialogTitle()); + + initializeContainer(); + connectButtons(); + + if (!geometrySaveKey().isEmpty()) + restoreGeometry(QByteArray::fromBase64(APPLICATION->settings()->get(geometrySaveKey()).toByteArray())); +} + +QList<BasePage*> ResourcePackDownloadDialog::getPages() +{ + QList<BasePage*> pages; + + pages.append(ModrinthResourcePackPage::create(this, *m_instance)); + if (APPLICATION->capabilities() & Application::SupportsFlame) + pages.append(FlameResourcePackPage::create(this, *m_instance)); + + return pages; +} + } // namespace ResourceDownload diff --git a/launcher/ui/dialogs/ResourceDownloadDialog.h b/launcher/ui/dialogs/ResourceDownloadDialog.h index 19843532..f534cccc 100644 --- a/launcher/ui/dialogs/ResourceDownloadDialog.h +++ b/launcher/ui/dialogs/ResourceDownloadDialog.h @@ -35,6 +35,7 @@ class QVBoxLayout; class QDialogButtonBox; class ResourceDownloadTask; class ResourceFolderModel; +class ResourcePackFolderModel; namespace ResourceDownload { @@ -108,4 +109,23 @@ class ModDownloadDialog final : public ResourceDownloadDialog { BaseInstance* m_instance; }; +class ResourcePackDownloadDialog final : public ResourceDownloadDialog { + Q_OBJECT + + public: + explicit ResourcePackDownloadDialog(QWidget* parent, + const std::shared_ptr<ResourcePackFolderModel>& resource_packs, + BaseInstance* instance); + ~ResourcePackDownloadDialog() override = default; + + //: String that gets appended to the resource pack download dialog title ("Download " + resourcesString()) + [[nodiscard]] QString resourcesString() const override { return tr("resource packs"); } + [[nodiscard]] QString geometrySaveKey() const override { return "RPDownloadGeometry"; } + + QList<BasePage*> getPages() override; + + private: + BaseInstance* m_instance; +}; + } // namespace ResourceDownload |