From 8e44ab2338f4ca63d58de4b3329c384df9d6c053 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Mon, 19 Mar 2018 02:36:12 +0100 Subject: NOISSUE redo new instance dialog --- application/pages/modplatform/FTBPage.cpp | 152 ++++++++++++++++++++++++++ application/pages/modplatform/FTBPage.h | 86 +++++++++++++++ application/pages/modplatform/FTBPage.ui | 61 +++++++++++ application/pages/modplatform/ImportPage.cpp | 125 +++++++++++++++++++++ application/pages/modplatform/ImportPage.h | 70 ++++++++++++ application/pages/modplatform/ImportPage.ui | 52 +++++++++ application/pages/modplatform/TechnicPage.cpp | 29 +++++ application/pages/modplatform/TechnicPage.h | 61 +++++++++++ application/pages/modplatform/TechnicPage.ui | 48 ++++++++ application/pages/modplatform/TwitchPage.cpp | 29 +++++ application/pages/modplatform/TwitchPage.h | 61 +++++++++++ application/pages/modplatform/TwitchPage.ui | 48 ++++++++ application/pages/modplatform/VanillaPage.cpp | 114 +++++++++++++++++++ application/pages/modplatform/VanillaPage.h | 75 +++++++++++++ application/pages/modplatform/VanillaPage.ui | 149 +++++++++++++++++++++++++ 15 files changed, 1160 insertions(+) create mode 100644 application/pages/modplatform/FTBPage.cpp create mode 100644 application/pages/modplatform/FTBPage.h create mode 100644 application/pages/modplatform/FTBPage.ui create mode 100644 application/pages/modplatform/ImportPage.cpp create mode 100644 application/pages/modplatform/ImportPage.h create mode 100644 application/pages/modplatform/ImportPage.ui create mode 100644 application/pages/modplatform/TechnicPage.cpp create mode 100644 application/pages/modplatform/TechnicPage.h create mode 100644 application/pages/modplatform/TechnicPage.ui create mode 100644 application/pages/modplatform/TwitchPage.cpp create mode 100644 application/pages/modplatform/TwitchPage.h create mode 100644 application/pages/modplatform/TwitchPage.ui create mode 100644 application/pages/modplatform/VanillaPage.cpp create mode 100644 application/pages/modplatform/VanillaPage.h create mode 100644 application/pages/modplatform/VanillaPage.ui (limited to 'application/pages/modplatform') diff --git a/application/pages/modplatform/FTBPage.cpp b/application/pages/modplatform/FTBPage.cpp new file mode 100644 index 00000000..a8ec6577 --- /dev/null +++ b/application/pages/modplatform/FTBPage.cpp @@ -0,0 +1,152 @@ +#include "FTBPage.h" +#include "ui_FTBPage.h" + +#include "MultiMC.h" +#include "FolderInstanceProvider.h" +#include "dialogs/CustomMessageBox.h" +#include "dialogs/NewInstanceDialog.h" +#include "modplatform/ftb/FtbPackDownloader.h" +#include "modplatform/ftb/FtbPackInstallTask.h" +#include + +FTBPage::FTBPage(NewInstanceDialog* dialog, QWidget *parent) + : QWidget(parent), dialog(dialog), ui(new Ui::FTBPage) +{ + ui->setupUi(this); + ftbPackDownloader = new FtbPackDownloader(); + + connect(ftbPackDownloader, &FtbPackDownloader::ready, this, &FTBPage::ftbPackDataDownloadSuccessfully); + connect(ftbPackDownloader, &FtbPackDownloader::packFetchFailed, this, &FTBPage::ftbPackDataDownloadFailed); + + filterModel = new FtbFilterModel(this); + listModel = new FtbListModel(this); + filterModel->setSourceModel(listModel); + + ui->packList->setModel(filterModel); + ui->packList->setSortingEnabled(true); + ui->packList->header()->hide(); + ui->packList->setIndentation(0); + + filterModel->setSorting(FtbFilterModel::Sorting::ByName); + + for(int i = 0; i < filterModel->getAvailableSortings().size(); i++) + { + ui->sortByBox->addItem(filterModel->getAvailableSortings().keys().at(i)); + } + + ui->sortByBox->setCurrentText(filterModel->getAvailableSortings().key(filterModel->getCurrentSorting())); + + connect(ui->sortByBox, &QComboBox::currentTextChanged, this, &FTBPage::onSortingSelectionChanged); + connect(ui->packVersionSelection, &QComboBox::currentTextChanged, this, &FTBPage::onVersionSelectionItemChanged); + connect(ui->packList->selectionModel(), &QItemSelectionModel::currentChanged, this, &FTBPage::onPackSelectionChanged); + + ui->modpackInfo->setOpenExternalLinks(true); +} + +FTBPage::~FTBPage() +{ + delete ui; + if(ftbPackDownloader) + { + ftbPackDownloader->deleteLater(); + } +} + +bool FTBPage::shouldDisplay() const +{ + return true; +} + +void FTBPage::openedImpl() +{ + if(!initialized) + { + ftbPackDownloader->fetchModpacks(false); + initialized = true; + } + suggestCurrent(); +} + +void FTBPage::suggestCurrent() +{ + if(isOpened) + { + if(!selected.broken) + { + dialog->setSuggestedPack(selected.name, new FtbPackInstallTask(selected, selectedVersion)); + } + else + { + dialog->setSuggestedPack(); + } + } +} + +FtbPackDownloader *FTBPage::getFtbPackDownloader() +{ + return ftbPackDownloader; +} + +void FTBPage::ftbPackDataDownloadSuccessfully() +{ + listModel->fill(ftbPackDownloader->getModpacks()); +} + +void FTBPage::ftbPackDataDownloadFailed() +{ + qDebug() << "Stuff went missing while grabbing FTB pack list or something..."; +} + +void FTBPage::onPackSelectionChanged(QModelIndex now, QModelIndex prev) +{ + ui->packVersionSelection->clear(); + FtbModpack selectedPack = filterModel->data(now, Qt::UserRole).value(); + + ui->modpackInfo->setHtml("Pack by " + selectedPack.author + "" + "
Minecraft " + selectedPack.mcVersion + "
" + "
" + selectedPack.description + "
  • " + selectedPack.mods.replace(";", "
  • ") + "
"); + + bool currentAdded = false; + + for(int i = 0; i < selectedPack.oldVersions.size(); i++) + { + if(selectedPack.currentVersion == selectedPack.oldVersions.at(i)) + { + currentAdded = true; + } + ui->packVersionSelection->addItem(selectedPack.oldVersions.at(i)); + } + + if(!currentAdded) + { + ui->packVersionSelection->addItem(selectedPack.currentVersion); + } + + selected = selectedPack; + suggestCurrent(); +} + +void FTBPage::onVersionSelectionItemChanged(QString data) +{ + if(data.isNull() || data.isEmpty()) + { + selectedVersion = ""; + return; + } + + selectedVersion = data; +} + +FtbModpack FTBPage::getSelectedModpack() +{ + return selected; +} + +QString FTBPage::getSelectedVersion() +{ + return selectedVersion; +} + +void FTBPage::onSortingSelectionChanged(QString data) +{ + filterModel->setSorting(filterModel->getAvailableSortings().value(data)); +} diff --git a/application/pages/modplatform/FTBPage.h b/application/pages/modplatform/FTBPage.h new file mode 100644 index 00000000..f7d6ca8b --- /dev/null +++ b/application/pages/modplatform/FTBPage.h @@ -0,0 +1,86 @@ +/* Copyright 2013-2018 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include "pages/BasePage.h" +#include +#include "tasks/Task.h" +#include "modplatform/ftb/PackHelpers.h" + +namespace Ui +{ +class FTBPage; +} + +class FtbListModel; +class FtbFilterModel; +class FtbPackDownloader; +class NewInstanceDialog; + +class FTBPage : public QWidget, public BasePage +{ + Q_OBJECT + +public: + explicit FTBPage(NewInstanceDialog * dialog, QWidget *parent = 0); + virtual ~FTBPage(); + QString displayName() const override + { + return tr("FTB Legacy"); + } + QIcon icon() const override + { + return MMC->getThemedIcon("ftb_logo"); + } + QString id() const override + { + return "ftb"; + } + QString helpPage() const override + { + return "FTB-platform"; + } + bool shouldDisplay() const override; + void openedImpl() override; + + FtbPackDownloader* getFtbPackDownloader(); + FtbModpack getSelectedModpack(); + QString getSelectedVersion(); + +private: + void suggestCurrent(); + +private slots: + void ftbPackDataDownloadSuccessfully(); + void ftbPackDataDownloadFailed(); + void onSortingSelectionChanged(QString data); + void onVersionSelectionItemChanged(QString data); + void onPackSelectionChanged(QModelIndex first, QModelIndex second); + +private: + bool initialized = false; + FtbPackDownloader* ftbPackDownloader = nullptr; + FtbModpack selectedPack; + FtbModpack selected; + QString selectedVersion; + FtbListModel* listModel = nullptr; + FtbFilterModel* filterModel = nullptr; + NewInstanceDialog* dialog = nullptr; + + Ui::FTBPage *ui = nullptr; +}; diff --git a/application/pages/modplatform/FTBPage.ui b/application/pages/modplatform/FTBPage.ui new file mode 100644 index 00000000..c54fc392 --- /dev/null +++ b/application/pages/modplatform/FTBPage.ui @@ -0,0 +1,61 @@ + + + FTBPage + + + + 0 + 0 + 801 + 674 + + + + + + + + 0 + 0 + + + + + + + + + + + + 0 + 0 + + + + + + + + Version selected: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + + + diff --git a/application/pages/modplatform/ImportPage.cpp b/application/pages/modplatform/ImportPage.cpp new file mode 100644 index 00000000..545ca38d --- /dev/null +++ b/application/pages/modplatform/ImportPage.cpp @@ -0,0 +1,125 @@ +#include "ImportPage.h" +#include "ui_ImportPage.h" + +#include "MultiMC.h" +#include "FolderInstanceProvider.h" +#include "dialogs/CustomMessageBox.h" +#include "dialogs/ProgressDialog.h" +#include "dialogs/NewInstanceDialog.h" +#include +#include + +class UrlValidator : public QValidator +{ +public: + using QValidator::QValidator; + + State validate(QString &in, int &pos) const + { + const QUrl url(in); + if (url.isValid() && !url.isRelative() && !url.isEmpty()) + { + return Acceptable; + } + else if (QFile::exists(in)) + { + return Acceptable; + } + else + { + return Intermediate; + } + } +}; + +ImportPage::ImportPage(NewInstanceDialog* dialog, QWidget *parent) + : QWidget(parent), ui(new Ui::ImportPage), dialog(dialog) +{ + ui->setupUi(this); + ui->modpackEdit->setValidator(new UrlValidator(ui->modpackEdit)); + connect(ui->modpackEdit, &QLineEdit::textChanged, this, &ImportPage::updateState); +} + +ImportPage::~ImportPage() +{ + delete ui; +} + +bool ImportPage::shouldDisplay() const +{ + return true; +} + +void ImportPage::openedImpl() +{ + updateState(); +} + +void ImportPage::updateState() +{ + if(!isOpened) + { + return; + } + if(ui->modpackEdit->hasAcceptableInput()) + { + QString input = ui->modpackEdit->text(); + auto url = QUrl::fromUserInput(input); + if(url.isLocalFile()) + { + // FIXME: actually do some validation of what's inside here... this is fake AF + QFileInfo fi(input); + if(fi.exists() && fi.suffix() == "zip") + { + QFileInfo fi(url.fileName()); + dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url)); + } + } + else + { + // hook, line and sinker. + QFileInfo fi(url.fileName()); + dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url)); + } + } + else + { + dialog->setSuggestedPack(); + } +} + +void ImportPage::setUrl(const QString& url) +{ + ui->modpackEdit->setText(url); + updateState(); +} + +void ImportPage::on_modpackBtn_clicked() +{ + const QUrl url = QFileDialog::getOpenFileUrl(this, tr("Choose modpack"), modpackUrl(), tr("Zip (*.zip)")); + if (url.isValid()) + { + if (url.isLocalFile()) + { + ui->modpackEdit->setText(url.toLocalFile()); + } + else + { + ui->modpackEdit->setText(url.toString()); + } + } +} + + +QUrl ImportPage::modpackUrl() const +{ + const QUrl url(ui->modpackEdit->text()); + if (url.isValid() && !url.isRelative() && !url.host().isEmpty()) + { + return url; + } + else + { + return QUrl::fromLocalFile(ui->modpackEdit->text()); + } +} diff --git a/application/pages/modplatform/ImportPage.h b/application/pages/modplatform/ImportPage.h new file mode 100644 index 00000000..8f62e6b1 --- /dev/null +++ b/application/pages/modplatform/ImportPage.h @@ -0,0 +1,70 @@ +/* Copyright 2013-2018 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include "pages/BasePage.h" +#include +#include "tasks/Task.h" + +namespace Ui +{ +class ImportPage; +} + +class NewInstanceDialog; + +class ImportPage : public QWidget, public BasePage +{ + Q_OBJECT + +public: + explicit ImportPage(NewInstanceDialog* dialog, QWidget *parent = 0); + virtual ~ImportPage(); + virtual QString displayName() const override + { + return tr("Import from zip"); + } + virtual QIcon icon() const override + { + return MMC->getThemedIcon("viewfolder"); + } + virtual QString id() const override + { + return "import"; + } + virtual QString helpPage() const override + { + return "Zip-import"; + } + virtual bool shouldDisplay() const override; + + void setUrl(const QString & url); + void openedImpl() override; + +private slots: + void on_modpackBtn_clicked(); + void updateState(); + +private: + QUrl modpackUrl() const; + +private: + Ui::ImportPage *ui = nullptr; + NewInstanceDialog* dialog = nullptr; +}; + diff --git a/application/pages/modplatform/ImportPage.ui b/application/pages/modplatform/ImportPage.ui new file mode 100644 index 00000000..eb63cbe9 --- /dev/null +++ b/application/pages/modplatform/ImportPage.ui @@ -0,0 +1,52 @@ + + + ImportPage + + + + 0 + 0 + 546 + 405 + + + + + + + Browse + + + + + + + http:// + + + + + + + Local file or link to a direct download: + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/application/pages/modplatform/TechnicPage.cpp b/application/pages/modplatform/TechnicPage.cpp new file mode 100644 index 00000000..c0f4faa5 --- /dev/null +++ b/application/pages/modplatform/TechnicPage.cpp @@ -0,0 +1,29 @@ +#include "TechnicPage.h" +#include "ui_TechnicPage.h" + +#include "MultiMC.h" +#include "FolderInstanceProvider.h" +#include "dialogs/CustomMessageBox.h" +#include "dialogs/ProgressDialog.h" +#include "dialogs/NewInstanceDialog.h" + +TechnicPage::TechnicPage(NewInstanceDialog* dialog, QWidget *parent) + : QWidget(parent), ui(new Ui::TechnicPage), dialog(dialog) +{ + ui->setupUi(this); +} + +TechnicPage::~TechnicPage() +{ + delete ui; +} + +bool TechnicPage::shouldDisplay() const +{ + return true; +} + +void TechnicPage::openedImpl() +{ + dialog->setSuggestedPack(); +} diff --git a/application/pages/modplatform/TechnicPage.h b/application/pages/modplatform/TechnicPage.h new file mode 100644 index 00000000..5b0f16a6 --- /dev/null +++ b/application/pages/modplatform/TechnicPage.h @@ -0,0 +1,61 @@ +/* Copyright 2013-2018 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include "pages/BasePage.h" +#include +#include "tasks/Task.h" + +namespace Ui +{ +class TechnicPage; +} + +class NewInstanceDialog; + +class TechnicPage : public QWidget, public BasePage +{ + Q_OBJECT + +public: + explicit TechnicPage(NewInstanceDialog* dialog, QWidget *parent = 0); + virtual ~TechnicPage(); + virtual QString displayName() const override + { + return tr("Technic"); + } + virtual QIcon icon() const override + { + return MMC->getThemedIcon("technic"); + } + virtual QString id() const override + { + return "technic"; + } + virtual QString helpPage() const override + { + return "Technic-platform"; + } + virtual bool shouldDisplay() const override; + + void openedImpl() override; + +private: + Ui::TechnicPage *ui = nullptr; + NewInstanceDialog* dialog = nullptr; +}; diff --git a/application/pages/modplatform/TechnicPage.ui b/application/pages/modplatform/TechnicPage.ui new file mode 100644 index 00000000..6bb6e9e0 --- /dev/null +++ b/application/pages/modplatform/TechnicPage.ui @@ -0,0 +1,48 @@ + + + TechnicPage + + + + 0 + 0 + 546 + 405 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 40 + + + + ¯\_(ツ)_/¯ + + + Qt::PlainText + + + Qt::AlignCenter + + + + + + + + diff --git a/application/pages/modplatform/TwitchPage.cpp b/application/pages/modplatform/TwitchPage.cpp new file mode 100644 index 00000000..a264c2f7 --- /dev/null +++ b/application/pages/modplatform/TwitchPage.cpp @@ -0,0 +1,29 @@ +#include "TwitchPage.h" +#include "ui_TwitchPage.h" + +#include "MultiMC.h" +#include "FolderInstanceProvider.h" +#include "dialogs/CustomMessageBox.h" +#include "dialogs/ProgressDialog.h" +#include "dialogs/NewInstanceDialog.h" + +TwitchPage::TwitchPage(NewInstanceDialog* dialog, QWidget *parent) + : QWidget(parent), ui(new Ui::TwitchPage), dialog(dialog) +{ + ui->setupUi(this); +} + +TwitchPage::~TwitchPage() +{ + delete ui; +} + +bool TwitchPage::shouldDisplay() const +{ + return true; +} + +void TwitchPage::openedImpl() +{ + dialog->setSuggestedPack(); +} diff --git a/application/pages/modplatform/TwitchPage.h b/application/pages/modplatform/TwitchPage.h new file mode 100644 index 00000000..8e072917 --- /dev/null +++ b/application/pages/modplatform/TwitchPage.h @@ -0,0 +1,61 @@ +/* Copyright 2013-2018 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include "pages/BasePage.h" +#include +#include "tasks/Task.h" + +namespace Ui +{ +class TwitchPage; +} + +class NewInstanceDialog; + +class TwitchPage : public QWidget, public BasePage +{ + Q_OBJECT + +public: + explicit TwitchPage(NewInstanceDialog* dialog, QWidget *parent = 0); + virtual ~TwitchPage(); + virtual QString displayName() const override + { + return tr("Twitch"); + } + virtual QIcon icon() const override + { + return MMC->getThemedIcon("twitch"); + } + virtual QString id() const override + { + return "twitch"; + } + virtual QString helpPage() const override + { + return "Twitch-platform"; + } + virtual bool shouldDisplay() const override; + + void openedImpl() override; + +private: + Ui::TwitchPage *ui = nullptr; + NewInstanceDialog* dialog = nullptr; +}; diff --git a/application/pages/modplatform/TwitchPage.ui b/application/pages/modplatform/TwitchPage.ui new file mode 100644 index 00000000..19178505 --- /dev/null +++ b/application/pages/modplatform/TwitchPage.ui @@ -0,0 +1,48 @@ + + + TwitchPage + + + + 0 + 0 + 546 + 405 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 40 + + + + ¯\_(ツ)_/¯ + + + Qt::PlainText + + + Qt::AlignCenter + + + + + + + + diff --git a/application/pages/modplatform/VanillaPage.cpp b/application/pages/modplatform/VanillaPage.cpp new file mode 100644 index 00000000..013ca426 --- /dev/null +++ b/application/pages/modplatform/VanillaPage.cpp @@ -0,0 +1,114 @@ +#include "VanillaPage.h" +#include "ui_VanillaPage.h" + +#include "MultiMC.h" +#include "FolderInstanceProvider.h" +#include "dialogs/CustomMessageBox.h" +#include "dialogs/ProgressDialog.h" + +#include +#include +#include +#include +#include +#include + +VanillaPage::VanillaPage(NewInstanceDialog *dialog, QWidget *parent) + : QWidget(parent), dialog(dialog), ui(new Ui::VanillaPage) +{ + ui->setupUi(this); + ui->tabWidget->tabBar()->hide(); + connect(ui->versionList, &VersionSelectWidget::selectedVersionChanged, this, &VanillaPage::setSelectedVersion); + filterChanged(); + connect(ui->alphaFilter, &QCheckBox::stateChanged, this, &VanillaPage::filterChanged); + connect(ui->betaFilter, &QCheckBox::stateChanged, this, &VanillaPage::filterChanged); + connect(ui->snapshotFilter, &QCheckBox::stateChanged, this, &VanillaPage::filterChanged); + connect(ui->oldSnapshotFilter, &QCheckBox::stateChanged, this, &VanillaPage::filterChanged); + connect(ui->releaseFilter, &QCheckBox::stateChanged, this, &VanillaPage::filterChanged); +} + +void VanillaPage::openedImpl() +{ + if(!initialized) + { + auto vlist = ENV.metadataIndex()->get("net.minecraft"); + ui->versionList->initialize(vlist.get()); + if(vlist->isLoaded()) + { + setSelectedVersion(vlist->getRecommended()); + } + else + { + vlist->load(Net::Mode::Online); + auto task = vlist->getLoadTask(); + if(vlist->isLoaded()) + { + setSelectedVersion(vlist->getRecommended()); + } + if(task) + { + connect(task.get(), &Task::succeeded, this, &VanillaPage::versionListUpdated); + } + } + initialized = true; + } + else + { + suggestCurrent(); + } +} + +void VanillaPage::filterChanged() +{ + QStringList out; + if(ui->alphaFilter->isChecked()) + out << "(old_alpha)"; + if(ui->betaFilter->isChecked()) + out << "(old_beta)"; + if(ui->snapshotFilter->isChecked()) + out << "(snapshot)"; + if(ui->oldSnapshotFilter->isChecked()) + out << "(old_snapshot)"; + if(ui->releaseFilter->isChecked()) + out << "(release)"; + auto regexp = out.join('|'); + ui->versionList->setFilter(BaseVersionList::TypeRole, new RegexpFilter(regexp, false)); +} + +VanillaPage::~VanillaPage() +{ + delete ui; +} + +bool VanillaPage::shouldDisplay() const +{ + return true; +} + +BaseVersionPtr VanillaPage::selectedVersion() const +{ + return m_selectedVersion; +} + +void VanillaPage::versionListUpdated() +{ + if(!m_versionSetByUser) + { + auto vlist = ENV.metadataIndex()->get("net.minecraft"); + setSelectedVersion(vlist->getRecommended()); + } +} + +void VanillaPage::suggestCurrent() +{ + if(m_selectedVersion && isOpened) + { + dialog->setSuggestedPack(m_selectedVersion->descriptor(), new InstanceCreationTask(m_selectedVersion)); + } +} + +void VanillaPage::setSelectedVersion(BaseVersionPtr version) +{ + m_selectedVersion = version; + suggestCurrent(); +} diff --git a/application/pages/modplatform/VanillaPage.h b/application/pages/modplatform/VanillaPage.h new file mode 100644 index 00000000..3f9d20ec --- /dev/null +++ b/application/pages/modplatform/VanillaPage.h @@ -0,0 +1,75 @@ +/* Copyright 2013-2018 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include "pages/BasePage.h" +#include +#include "tasks/Task.h" + +namespace Ui +{ +class VanillaPage; +} + +class NewInstanceDialog; + +class VanillaPage : public QWidget, public BasePage +{ + Q_OBJECT + +public: + explicit VanillaPage(NewInstanceDialog *dialog, QWidget *parent = 0); + virtual ~VanillaPage(); + virtual QString displayName() const override + { + return tr("Vanilla"); + } + virtual QIcon icon() const override + { + return MMC->getThemedIcon("minecraft"); + } + virtual QString id() const override + { + return "vanilla"; + } + virtual QString helpPage() const override + { + return "Vanilla-platform"; + } + virtual bool shouldDisplay() const override; + void openedImpl() override; + + BaseVersionPtr selectedVersion() const; + +public slots: + void setSelectedVersion(BaseVersionPtr version); + +private slots: + void versionListUpdated(); + void filterChanged(); + +private: + void suggestCurrent(); + +private: + bool initialized = false; + NewInstanceDialog *dialog = nullptr; + Ui::VanillaPage *ui = nullptr; + bool m_versionSetByUser = false; + BaseVersionPtr m_selectedVersion; +}; diff --git a/application/pages/modplatform/VanillaPage.ui b/application/pages/modplatform/VanillaPage.ui new file mode 100644 index 00000000..713d04a0 --- /dev/null +++ b/application/pages/modplatform/VanillaPage.ui @@ -0,0 +1,149 @@ + + + VanillaPage + + + + 0 + 0 + 815 + 607 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 0 + + + + Tab 1 + + + + + + + + Filter + + + Qt::AlignCenter + + + + + + + Releases + + + true + + + true + + + + + + + Snapshots + + + true + + + + + + + Old Snapshots + + + true + + + + + + + Betas + + + true + + + + + + + Alphas + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Refresh + + + + + + + + + + 0 + 0 + + + + + + + + + + + + + VersionSelectWidget + QWidget +
widgets/VersionSelectWidget.h
+ 1 +
+
+ + +
-- cgit