aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui
diff options
context:
space:
mode:
authorSefa Eyeoglu <contact@scrumplex.net>2023-08-02 19:27:48 +0200
committerGitHub <noreply@github.com>2023-08-02 19:27:48 +0200
commitfa2b784f7eb817e97d0af45fe78d205932ada193 (patch)
treef263bdc3fd2f945e6ecc75f9b59b55d009082cca /launcher/ui
parentb1aa9e584624a0732dd55fc6c459524a8abfe6ba (diff)
parent01e17806f67534140a6db6cf90191f4db4dd30ac (diff)
downloadPrismLauncher-fa2b784f7eb817e97d0af45fe78d205932ada193.tar.gz
PrismLauncher-fa2b784f7eb817e97d0af45fe78d205932ada193.tar.bz2
PrismLauncher-fa2b784f7eb817e97d0af45fe78d205932ada193.zip
Merge branch 'develop' into sparkle-disable
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
Diffstat (limited to 'launcher/ui')
-rw-r--r--launcher/ui/MainWindow.cpp14
-rw-r--r--launcher/ui/dialogs/AboutDialog.cpp2
-rw-r--r--launcher/ui/dialogs/ExportInstanceDialog.cpp2
-rw-r--r--launcher/ui/dialogs/ExportPackDialog.cpp2
-rw-r--r--launcher/ui/dialogs/NewInstanceDialog.cpp24
-rw-r--r--launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.cpp104
-rw-r--r--launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.h67
-rw-r--r--launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.ui28
-rw-r--r--launcher/ui/pages/modplatform/import_ftb/ListModel.cpp88
-rw-r--r--launcher/ui/pages/modplatform/import_ftb/ListModel.h46
10 files changed, 353 insertions, 24 deletions
diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index da572fc3..e342e833 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -1342,16 +1342,10 @@ void MainWindow::on_actionExportInstanceFlamePack_triggered()
if (m_selectedInstance) {
auto instance = dynamic_cast<MinecraftInstance*>(m_selectedInstance.get());
if (instance) {
- QString errorMsg;
- if (instance->getPackProfile()->getComponent("org.quiltmc.quilt-loader")) {
- errorMsg = tr("Quilt is currently not supported by CurseForge modpacks.");
- } else if (auto cmp = instance->getPackProfile()->getComponent("net.minecraft");
- cmp && cmp->getVersionFile() && cmp->getVersionFile()->type == "snapshot") {
- errorMsg = tr("Snapshots are currently not supported by CurseForge modpacks.");
- }
- if (!errorMsg.isEmpty()) {
- QMessageBox msgBox;
- msgBox.setText(errorMsg);
+ if (auto cmp = instance->getPackProfile()->getComponent("net.minecraft");
+ cmp && cmp->getVersionFile() && cmp->getVersionFile()->type == "snapshot") {
+ QMessageBox msgBox(this);
+ msgBox.setText("Snapshots are currently not supported by CurseForge modpacks.");
msgBox.exec();
return;
}
diff --git a/launcher/ui/dialogs/AboutDialog.cpp b/launcher/ui/dialogs/AboutDialog.cpp
index 88739463..b1734eff 100644
--- a/launcher/ui/dialogs/AboutDialog.cpp
+++ b/launcher/ui/dialogs/AboutDialog.cpp
@@ -170,7 +170,7 @@ AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AboutDia
QString urlText("<html><head/><body><p><a href=\"%1\">%1</a></p></body></html>");
ui->urlLabel->setText(urlText.arg(BuildConfig.LAUNCHER_GIT));
- QString copyText("© 2022 %1");
+ QString copyText("© 2022-2023 %1");
ui->copyLabel->setText(copyText.arg(BuildConfig.LAUNCHER_COPYRIGHT));
connect(ui->closeButton, SIGNAL(clicked()), SLOT(close()));
diff --git a/launcher/ui/dialogs/ExportInstanceDialog.cpp b/launcher/ui/dialogs/ExportInstanceDialog.cpp
index d1a69b93..d6a503cc 100644
--- a/launcher/ui/dialogs/ExportInstanceDialog.cpp
+++ b/launcher/ui/dialogs/ExportInstanceDialog.cpp
@@ -70,6 +70,8 @@ ExportInstanceDialog::ExportInstanceDialog(InstancePtr instance, QWidget* parent
auto prefix = QDir(instance->instanceRoot()).relativeFilePath(instance->gameRoot());
proxyModel->ignoreFilesWithPath().insert({ FS::PathCombine(prefix, "logs"), FS::PathCombine(prefix, "crash-reports") });
proxyModel->ignoreFilesWithName().append({ ".DS_Store", "thumbs.db", "Thumbs.db" });
+ proxyModel->ignoreFilesWithPath().insert(
+ { FS::PathCombine(prefix, ".cache"), FS::PathCombine(prefix, ".fabric"), FS::PathCombine(prefix, ".quilt") });
loadPackIgnore();
ui->treeView->setModel(proxyModel);
diff --git a/launcher/ui/dialogs/ExportPackDialog.cpp b/launcher/ui/dialogs/ExportPackDialog.cpp
index 2abe2805..ad8db5ff 100644
--- a/launcher/ui/dialogs/ExportPackDialog.cpp
+++ b/launcher/ui/dialogs/ExportPackDialog.cpp
@@ -61,7 +61,7 @@ ExportPackDialog::ExportPackDialog(InstancePtr instance, QWidget* parent, ModPla
// use the game root - everything outside cannot be exported
const QDir root(instance->gameRoot());
proxy = new FileIgnoreProxy(instance->gameRoot(), this);
- proxy->ignoreFilesWithPath().insert({ "logs", "crash-reports" });
+ proxy->ignoreFilesWithPath().insert({ "logs", "crash-reports", ".cache", ".fabric", ".quilt" });
proxy->ignoreFilesWithName().append({ ".DS_Store", "thumbs.db", "Thumbs.db" });
proxy->setSourceModel(model);
diff --git a/launcher/ui/dialogs/NewInstanceDialog.cpp b/launcher/ui/dialogs/NewInstanceDialog.cpp
index 7b9bb944..76b139fc 100644
--- a/launcher/ui/dialogs/NewInstanceDialog.cpp
+++ b/launcher/ui/dialogs/NewInstanceDialog.cpp
@@ -33,38 +33,37 @@
* limitations under the License.
*/
-#include "Application.h"
#include "NewInstanceDialog.h"
+#include "Application.h"
+#include "ui/pages/modplatform/import_ftb/ImportFTBPage.h"
#include "ui_NewInstanceDialog.h"
#include <BaseVersion.h>
+#include <InstanceList.h>
#include <icons/IconList.h>
#include <tasks/Task.h>
-#include <InstanceList.h>
-#include "VersionSelectDialog.h"
-#include "ProgressDialog.h"
#include "IconPickerDialog.h"
+#include "ProgressDialog.h"
+#include "VersionSelectDialog.h"
+#include <QDialogButtonBox>
+#include <QFileDialog>
#include <QLayout>
#include <QPushButton>
-#include <QFileDialog>
#include <QValidator>
-#include <QDialogButtonBox>
#include <utility>
-#include "ui/widgets/PageContainer.h"
#include "ui/pages/modplatform/CustomPage.h"
+#include "ui/pages/modplatform/ImportPage.h"
#include "ui/pages/modplatform/atlauncher/AtlPage.h"
-#include "ui/pages/modplatform/legacy_ftb/Page.h"
#include "ui/pages/modplatform/flame/FlamePage.h"
-#include "ui/pages/modplatform/ImportPage.h"
+#include "ui/pages/modplatform/legacy_ftb/Page.h"
#include "ui/pages/modplatform/modrinth/ModrinthPage.h"
#include "ui/pages/modplatform/technic/TechnicPage.h"
+#include "ui/widgets/PageContainer.h"
-
-
-NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, const QString & url, QWidget *parent)
+NewInstanceDialog::NewInstanceDialog(const QString& initialGroup, const QString& url, QWidget* parent)
: QDialog(parent), ui(new Ui::NewInstanceDialog)
{
ui->setupUi(this);
@@ -168,6 +167,7 @@ QList<BasePage *> NewInstanceDialog::getPages()
if (APPLICATION->capabilities() & Application::SupportsFlame)
pages.append(new FlamePage(this));
pages.append(new LegacyFTB::Page(this));
+ pages.append(new FTBImportAPP::ImportFTBPage(this));
pages.append(new ModrinthPage(this));
pages.append(new TechnicPage(this));
diff --git a/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.cpp b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.cpp
new file mode 100644
index 00000000..5c9ff63b
--- /dev/null
+++ b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.cpp
@@ -0,0 +1,104 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "ImportFTBPage.h"
+#include "ui_ImportFTBPage.h"
+
+#include <QWidget>
+#include "FileSystem.h"
+#include "ListModel.h"
+#include "modplatform/import_ftb/PackInstallTask.h"
+#include "ui/dialogs/NewInstanceDialog.h"
+
+namespace FTBImportAPP {
+
+ImportFTBPage::ImportFTBPage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), dialog(dialog), ui(new Ui::ImportFTBPage)
+{
+ ui->setupUi(this);
+
+ {
+ listModel = new ListModel(this);
+
+ ui->modpackList->setModel(listModel);
+ ui->modpackList->setSortingEnabled(true);
+ ui->modpackList->header()->hide();
+ ui->modpackList->setIndentation(0);
+ ui->modpackList->setIconSize(QSize(42, 42));
+ }
+
+ connect(ui->modpackList->selectionModel(), &QItemSelectionModel::currentChanged, this, &ImportFTBPage::onPublicPackSelectionChanged);
+
+ ui->modpackList->selectionModel()->reset();
+}
+
+ImportFTBPage::~ImportFTBPage()
+{
+ delete ui;
+}
+
+void ImportFTBPage::openedImpl()
+{
+ if (!initialized) {
+ listModel->update();
+ initialized = true;
+ }
+ suggestCurrent();
+}
+
+void ImportFTBPage::retranslate()
+{
+ ui->retranslateUi(this);
+}
+
+void ImportFTBPage::suggestCurrent()
+{
+ if (!isOpened)
+ return;
+
+ if (selected.path.isEmpty()) {
+ dialog->setSuggestedPack();
+ return;
+ }
+
+ dialog->setSuggestedPack(selected.name, new PackInstallTask(selected));
+ QString editedLogoName = QString("ftb_%1").arg(selected.id);
+ dialog->setSuggestedIconFromFile(FS::PathCombine(selected.path, "folder.jpg"), editedLogoName);
+}
+
+void ImportFTBPage::onPublicPackSelectionChanged(QModelIndex now, QModelIndex prev)
+{
+ if (!now.isValid()) {
+ onPackSelectionChanged();
+ return;
+ }
+ Modpack selectedPack = listModel->data(now, Qt::UserRole).value<Modpack>();
+ onPackSelectionChanged(&selectedPack);
+}
+
+void ImportFTBPage::onPackSelectionChanged(Modpack* pack)
+{
+ if (pack) {
+ selected = *pack;
+ suggestCurrent();
+ return;
+ }
+ if (isOpened)
+ dialog->setSuggestedPack();
+}
+
+} // namespace FTBImportAPP
diff --git a/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.h b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.h
new file mode 100644
index 00000000..54c49f7b
--- /dev/null
+++ b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.h
@@ -0,0 +1,67 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <QDialog>
+#include <QTextBrowser>
+#include <QTreeView>
+#include <QWidget>
+
+#include <Application.h>
+#include "modplatform/import_ftb/PackHelpers.h"
+#include "ui/pages/BasePage.h"
+#include "ui/pages/modplatform/import_ftb/ListModel.h"
+
+class NewInstanceDialog;
+
+namespace FTBImportAPP {
+namespace Ui {
+class ImportFTBPage;
+}
+
+class ImportFTBPage : public QWidget, public BasePage {
+ Q_OBJECT
+
+ public:
+ explicit ImportFTBPage(NewInstanceDialog* dialog, QWidget* parent = 0);
+ virtual ~ImportFTBPage();
+ QString displayName() const override { return tr("FTB App Import"); }
+ QIcon icon() const override { return APPLICATION->getThemedIcon("ftb_logo"); }
+ QString id() const override { return "import_ftb"; }
+ QString helpPage() const override { return "FTB-platform"; }
+ bool shouldDisplay() const override { return true; }
+ void openedImpl() override;
+ void retranslate() override;
+
+ private:
+ void suggestCurrent();
+ void onPackSelectionChanged(Modpack* pack = nullptr);
+ private slots:
+ void onPublicPackSelectionChanged(QModelIndex first, QModelIndex second);
+
+ private:
+ bool initialized = false;
+ Modpack selected;
+ ListModel* listModel = nullptr;
+
+ NewInstanceDialog* dialog = nullptr;
+ Ui::ImportFTBPage* ui = nullptr;
+};
+
+} // namespace FTBImportAPP
diff --git a/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.ui b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.ui
new file mode 100644
index 00000000..32d548b0
--- /dev/null
+++ b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.ui
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>FTBImportAPP::ImportFTBPage</class>
+ <widget class="QWidget" name="FTBImportAPP::ImportFTBPage">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>1461</width>
+ <height>1011</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTreeView" name="modpackList">
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/launcher/ui/pages/modplatform/import_ftb/ListModel.cpp b/launcher/ui/pages/modplatform/import_ftb/ListModel.cpp
new file mode 100644
index 00000000..dc78f451
--- /dev/null
+++ b/launcher/ui/pages/modplatform/import_ftb/ListModel.cpp
@@ -0,0 +1,88 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "ListModel.h"
+#include <QDir>
+#include <QDirIterator>
+#include <QFileInfo>
+#include <QIcon>
+#include <QProcessEnvironment>
+#include "FileSystem.h"
+#include "modplatform/import_ftb/PackHelpers.h"
+
+namespace FTBImportAPP {
+
+QString getPath()
+{
+ QString partialPath;
+#if defined(Q_OS_OSX)
+ partialPath = FS::PathCombine(QDir::homePath(), "Library/Application Support");
+#elif defined(Q_OS_WIN32)
+ partialPath = QProcessEnvironment::systemEnvironment().value("LOCALAPPDATA", "");
+#else
+ partialPath = QDir::homePath();
+#endif
+ return FS::PathCombine(partialPath, ".ftba");
+}
+
+const QString ListModel::FTB_APP_PATH = getPath();
+
+void ListModel::update()
+{
+ beginResetModel();
+ modpacks.clear();
+
+ QString instancesPath = FS::PathCombine(FTB_APP_PATH, "instances");
+ if (auto instancesInfo = QFileInfo(instancesPath); instancesInfo.exists() && instancesInfo.isDir()) {
+ QDirIterator directoryIterator(instancesPath, QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable | QDir::Hidden,
+ QDirIterator::FollowSymlinks);
+ while (directoryIterator.hasNext()) {
+ auto modpack = parseDirectory(directoryIterator.next());
+ if (!modpack.path.isEmpty())
+ modpacks.append(modpack);
+ }
+ } else {
+ qDebug() << "Couldn't find ftb instances folder: " << instancesPath;
+ }
+
+ endResetModel();
+}
+
+QVariant ListModel::data(const QModelIndex& index, int role) const
+{
+ int pos = index.row();
+ if (pos >= modpacks.size() || pos < 0 || !index.isValid()) {
+ return QVariant();
+ }
+
+ auto pack = modpacks.at(pos);
+ if (role == Qt::DisplayRole) {
+ return pack.name;
+ } else if (role == Qt::DecorationRole) {
+ return pack.icon;
+ } else if (role == Qt::UserRole) {
+ QVariant v;
+ v.setValue(pack);
+ return v;
+ } else if (role == Qt::ToolTipRole) {
+ return tr("Minecraft %1").arg(pack.mcVersion);
+ }
+
+ return QVariant();
+}
+} // namespace FTBImportAPP \ No newline at end of file
diff --git a/launcher/ui/pages/modplatform/import_ftb/ListModel.h b/launcher/ui/pages/modplatform/import_ftb/ListModel.h
new file mode 100644
index 00000000..c67aa896
--- /dev/null
+++ b/launcher/ui/pages/modplatform/import_ftb/ListModel.h
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <QAbstractListModel>
+#include <QIcon>
+#include <QVariant>
+#include "modplatform/import_ftb/PackHelpers.h"
+
+namespace FTBImportAPP {
+
+class ListModel : public QAbstractListModel {
+ Q_OBJECT
+
+ public:
+ ListModel(QObject* parent) : QAbstractListModel(parent) {}
+ virtual ~ListModel() = default;
+
+ int rowCount(const QModelIndex& parent) const { return modpacks.size(); }
+ int columnCount(const QModelIndex& parent) const { return 1; }
+ QVariant data(const QModelIndex& index, int role) const;
+
+ void update();
+
+ static const QString FTB_APP_PATH;
+
+ private:
+ ModpackList modpacks;
+};
+} // namespace FTBImportAPP \ No newline at end of file