diff options
| author | Petr Mrázek <peterix@gmail.com> | 2017-04-07 00:27:24 +0200 |
|---|---|---|
| committer | Petr Mrázek <peterix@gmail.com> | 2017-04-07 00:27:24 +0200 |
| commit | 795889d934e8f4ebe89be1a49a3417fd98e89be1 (patch) | |
| tree | c5b0d30d425003c4b88e84a2908e63eb5ed797b9 /application | |
| parent | 160b5033a79e6b5ee9f3e2a001b96c677f41ddcb (diff) | |
| parent | 8e58d61150b0bdbe9eb91065d36342f3004fe97b (diff) | |
| download | PrismLauncher-795889d934e8f4ebe89be1a49a3417fd98e89be1.tar.gz PrismLauncher-795889d934e8f4ebe89be1a49a3417fd98e89be1.tar.bz2 PrismLauncher-795889d934e8f4ebe89be1a49a3417fd98e89be1.zip | |
Merge branch 'feature/meta' into develop
Diffstat (limited to 'application')
25 files changed, 201 insertions, 1163 deletions
diff --git a/application/BuildConfig.cpp.in b/application/BuildConfig.cpp.in index 70bc93d3..99551867 100644 --- a/application/BuildConfig.cpp.in +++ b/application/BuildConfig.cpp.in @@ -33,7 +33,6 @@ Config::Config() VERSION_STR = "@MultiMC_VERSION_STRING@"; NEWS_RSS_URL = "@MultiMC_NEWS_RSS_URL@"; PASTE_EE_KEY = "@MultiMC_PASTE_EE_API_KEY@"; - WONKO_ROOT_URL = "@MultiMC_WONKO_ROOT_URL@"; } QString Config::printableVersionString() const diff --git a/application/BuildConfig.h b/application/BuildConfig.h index 75109b1c..1c9466ba 100644 --- a/application/BuildConfig.h +++ b/application/BuildConfig.h @@ -61,11 +61,6 @@ public: QString PASTE_EE_KEY; /** - * Root URL for wonko things. Other wonko URLs will be resolved relative to this. - */ - QString WONKO_ROOT_URL; - - /** * \brief Converts the Version to a string. * \return The version number in string format (major.minor.revision.build). */ diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt index 90fa1aca..f03225da 100644 --- a/application/CMakeLists.txt +++ b/application/CMakeLists.txt @@ -30,9 +30,6 @@ set(MultiMC_ANALYTICS_ID "" CACHE STRING "ID you can get from Google analytics") include(GetGitRevisionDescription) get_git_head_revision(MultiMC_GIT_REFSPEC MultiMC_GIT_COMMIT) -# Root URL for wonko files -set(MultiMC_WONKO_ROOT_URL "" CACHE STRING "Root URL for wonko stuff") - message(STATUS "Git commit: ${MultiMC_GIT_COMMIT}") message(STATUS "Git refspec: ${MultiMC_GIT_REFSPEC}") @@ -99,8 +96,6 @@ SET(MULTIMC_SOURCES VersionProxyModel.cpp ColorCache.h ColorCache.cpp - WonkoGui.h - WonkoGui.cpp # GUI - windows MainWindow.h @@ -189,8 +184,8 @@ SET(MULTIMC_SOURCES pages/global/ProxyPage.h pages/global/PasteEEPage.cpp pages/global/PasteEEPage.h - pages/global/WonkoPage.cpp - pages/global/WonkoPage.h + pages/global/PackagesPage.cpp + pages/global/PackagesPage.h # GUI - dialogs dialogs/AboutDialog.cpp @@ -289,7 +284,7 @@ SET(MULTIMC_UIS pages/global/MultiMCPage.ui pages/global/ProxyPage.ui pages/global/PasteEEPage.ui - pages/global/WonkoPage.ui + pages/global/PackagesPage.ui # Dialogs dialogs/CopyInstanceDialog.ui @@ -318,7 +313,6 @@ set(MULTIMC_QRCS resources/pe_blue/pe_blue.qrc resources/OSX/OSX.qrc resources/iOS/iOS.qrc - resources/versions/versions.qrc resources/certs/certs.qrc ) diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp index 3bdf540d..e0870d06 100644 --- a/application/MainWindow.cpp +++ b/application/MainWindow.cpp @@ -54,7 +54,6 @@ #include <java/JavaUtils.h> #include <java/JavaInstallList.h> #include <launch/LaunchTask.h> -#include <minecraft/MinecraftVersionList.h> #include <minecraft/legacy/LwjglVersionList.h> #include <minecraft/auth/MojangAccountList.h> #include <SkinUtils.h> @@ -555,19 +554,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow job->start(); } - // run the things that load and download other things... FIXME: this is NOT the place - // FIXME: invisible actions in the background = NOPE. + // load the news { - if (!MMC->minecraftlist()->isLoaded()) - { - m_versionLoadTask = MMC->minecraftlist()->getLoadTask(); - startTask(m_versionLoadTask); - } - if (!MMC->lwjgllist()->isLoaded()) - { - MMC->lwjgllist()->loadList(); - } - m_newsChecker->reloadNews(); updateNewsLabel(); } @@ -1014,18 +1002,6 @@ void MainWindow::setCatBackground(bool enabled) } } -// FIXME: eliminate, should not be needed -void MainWindow::waitForMinecraftVersions() -{ - if (!MMC->minecraftlist()->isLoaded() && m_versionLoadTask && m_versionLoadTask->isRunning()) - { - QEventLoop waitLoop; - waitLoop.connect(m_versionLoadTask, &Task::failed, &waitLoop, &QEventLoop::quit); - waitLoop.connect(m_versionLoadTask, &Task::succeeded, &waitLoop, &QEventLoop::quit); - waitLoop.exec(); - } -} - void MainWindow::runModalTask(Task *task) { connect(task, &Task::failed, [this](QString reason) @@ -1117,8 +1093,6 @@ void MainWindow::on_actionAddInstance_triggered() groupName = map["group"].toString(); } while(0); - waitForMinecraftVersions(); - if(groupName.isEmpty()) { groupName = MMC->settings()->get("LastUsedGroupForNewInstance").toString(); diff --git a/application/MainWindow.h b/application/MainWindow.h index 6b30c86e..a7ab9172 100644 --- a/application/MainWindow.h +++ b/application/MainWindow.h @@ -167,7 +167,6 @@ private: void updateInstanceToolIcon(QString new_icon); void setSelectedInstanceById(const QString &id); - void waitForMinecraftVersions(); void runModalTask(Task *task); void instanceFromVersion(QString instName, QString instGroup, QString instIcon, BaseVersionPtr version); void instanceFromZipPack(QString instName, QString instGroup, QString instIcon, QUrl url); diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index 081de41c..942b1d93 100644 --- a/application/MultiMC.cpp +++ b/application/MultiMC.cpp @@ -10,6 +10,7 @@ #include "pages/global/ExternalToolsPage.h" #include "pages/global/AccountListPage.h" #include "pages/global/PasteEEPage.h" +#include "pages/global/PackagesPage.h" #include "themes/ITheme.h" #include "themes/SystemTheme.h" @@ -41,9 +42,6 @@ #include "icons/IconList.h" //FIXME: get rid of this #include "minecraft/legacy/LwjglVersionList.h" -#include "minecraft/MinecraftVersionList.h" -#include "minecraft/liteloader/LiteLoaderVersionList.h" -#include "minecraft/forge/ForgeVersionList.h" #include "net/HttpMetaCache.h" #include "net/URLConstants.h" @@ -337,7 +335,6 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv) initIcons(); initThemes(); // make sure we have at least some minecraft versions before we init instances - minecraftlist(); initInstances(); initAccounts(); initNetwork(); @@ -842,6 +839,7 @@ void MultiMC::initGlobalSettings() m_globalSettingsProvider->addPage<MinecraftPage>(); m_globalSettingsProvider->addPage<JavaPage>(); m_globalSettingsProvider->addPage<ProxyPage>(); + m_globalSettingsProvider->addPage<PackagesPage>(); m_globalSettingsProvider->addPage<ExternalToolsPage>(); m_globalSettingsProvider->addPage<AccountListPage>(); m_globalSettingsProvider->addPage<PasteEEPage>(); @@ -868,36 +866,6 @@ std::shared_ptr<LWJGLVersionList> MultiMC::lwjgllist() return m_lwjgllist; } -std::shared_ptr<ForgeVersionList> MultiMC::forgelist() -{ - if (!m_forgelist) - { - m_forgelist.reset(new ForgeVersionList()); - ENV.registerVersionList("net.minecraftforge", m_forgelist); - } - return m_forgelist; -} - -std::shared_ptr<LiteLoaderVersionList> MultiMC::liteloaderlist() -{ - if (!m_liteloaderlist) - { - m_liteloaderlist.reset(new LiteLoaderVersionList()); - ENV.registerVersionList("com.mumfrey.liteloader", m_liteloaderlist); - } - return m_liteloaderlist; -} - -std::shared_ptr<MinecraftVersionList> MultiMC::minecraftlist() -{ - if (!m_minecraftlist) - { - m_minecraftlist.reset(new MinecraftVersionList()); - ENV.registerVersionList("net.minecraft", m_minecraftlist); - } - return m_minecraftlist; -} - std::shared_ptr<JavaInstallList> MultiMC::javalist() { if (!m_javalist) diff --git a/application/MultiMC.h b/application/MultiMC.h index d8062bb5..a9cbdec7 100644 --- a/application/MultiMC.h +++ b/application/MultiMC.h @@ -18,7 +18,6 @@ class SetupWizard; class FolderInstanceProvider; class GenericPageProvider; class QFile; -class MinecraftVersionList; class LWJGLVersionList; class HttpMetaCache; class SettingsObject; @@ -26,8 +25,6 @@ class InstanceList; class MojangAccountList; class IconList; class QNetworkAccessManager; -class ForgeVersionList; -class LiteLoaderVersionList; class JavaInstallList; class UpdateChecker; class BaseProfilerFactory; @@ -96,10 +93,7 @@ public: } std::shared_ptr<TranslationsModel> translations(); - std::shared_ptr<MinecraftVersionList> minecraftlist(); std::shared_ptr<LWJGLVersionList> lwjgllist(); - std::shared_ptr<ForgeVersionList> forgelist(); - std::shared_ptr<LiteLoaderVersionList> liteloaderlist(); std::shared_ptr<JavaInstallList> javalist(); std::shared_ptr<InstanceList> instances() const @@ -202,9 +196,6 @@ private: std::shared_ptr<UpdateChecker> m_updateChecker; std::shared_ptr<MojangAccountList> m_accounts; std::shared_ptr<LWJGLVersionList> m_lwjgllist; - std::shared_ptr<ForgeVersionList> m_forgelist; - std::shared_ptr<LiteLoaderVersionList> m_liteloaderlist; - std::shared_ptr<MinecraftVersionList> m_minecraftlist; std::shared_ptr<JavaInstallList> m_javalist; std::shared_ptr<TranslationsModel> m_translations; std::shared_ptr<GenericPageProvider> m_globalSettingsProvider; diff --git a/application/VersionProxyModel.cpp b/application/VersionProxyModel.cpp index 22df7e09..96bdc9ab 100644 --- a/application/VersionProxyModel.cpp +++ b/application/VersionProxyModel.cpp @@ -26,19 +26,9 @@ public: switch(role) { - case BaseVersionList::ParentGameVersionRole: + case BaseVersionList::ParentVersionRole: case BaseVersionList::VersionIdRole: - { - auto versionString = data.toString(); - if(it.value().exact) - { - return versionString == it.value().string; - } - else - { - return versionIsInInterval(versionString, it.value().string); - } - } + // TODO: work with metadata here. Previous implementation based on the Version class is not sufficient default: { auto match = data.toString(); @@ -146,7 +136,7 @@ QVariant VersionProxyModel::data(const QModelIndex &index, int role) const case Name: return sourceModel()->data(parentIndex, BaseVersionList::VersionRole); case ParentVersion: - return sourceModel()->data(parentIndex, BaseVersionList::ParentGameVersionRole); + return sourceModel()->data(parentIndex, BaseVersionList::ParentVersionRole); case Branch: return sourceModel()->data(parentIndex, BaseVersionList::BranchRole); case Type: @@ -313,9 +303,9 @@ void VersionProxyModel::setSourceModel(QAbstractItemModel *replacingRaw) auto replacing = dynamic_cast<BaseVersionList *>(replacingRaw); beginResetModel(); + m_columns.clear(); if(!replacing) { - m_columns.clear(); roles.clear(); filterModel->setSourceModel(replacing); return; @@ -327,7 +317,7 @@ void VersionProxyModel::setSourceModel(QAbstractItemModel *replacingRaw) m_columns.push_back(Name); } /* - if(roles.contains(BaseVersionList::ParentGameVersionRole)) + if(roles.contains(BaseVersionList::ParentVersionRole)) { m_columns.push_back(ParentVersion); } diff --git a/application/WonkoGui.cpp b/application/WonkoGui.cpp deleted file mode 100644 index 4d376fdc..00000000 --- a/application/WonkoGui.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "WonkoGui.h" - -#include "dialogs/ProgressDialog.h" -#include "wonko/WonkoIndex.h" -#include "wonko/WonkoVersionList.h" -#include "wonko/WonkoVersion.h" -#include "Env.h" - -WonkoIndexPtr Wonko::ensureIndexLoaded(QWidget *parent) -{ - if (!ENV.wonkoIndex()->isLocalLoaded()) - { - ProgressDialog(parent).execWithTask(ENV.wonkoIndex()->localUpdateTask()); - if (!ENV.wonkoIndex()->isRemoteLoaded() && ENV.wonkoIndex()->lists().size() == 0) - { - ProgressDialog(parent).execWithTask(ENV.wonkoIndex()->remoteUpdateTask()); - } - } - return ENV.wonkoIndex(); -} - -WonkoVersionListPtr Wonko::ensureVersionListExists(const QString &uid, QWidget *parent) -{ - ensureIndexLoaded(parent); - if (!ENV.wonkoIndex()->isRemoteLoaded() && !ENV.wonkoIndex()->hasUid(uid)) - { - ProgressDialog(parent).execWithTask(ENV.wonkoIndex()->remoteUpdateTask()); - } - return ENV.wonkoIndex()->getList(uid); -} -WonkoVersionListPtr Wonko::ensureVersionListLoaded(const QString &uid, QWidget *parent) -{ - WonkoVersionListPtr list = ensureVersionListExists(uid, parent); - if (!list) - { - return nullptr; - } - if (!list->isLocalLoaded()) - { - ProgressDialog(parent).execWithTask(list->localUpdateTask()); - if (!list->isLocalLoaded()) - { - ProgressDialog(parent).execWithTask(list->remoteUpdateTask()); - } - } - return list->isComplete() ? list : nullptr; -} - -WonkoVersionPtr Wonko::ensureVersionExists(const QString &uid, const QString &version, QWidget *parent) -{ - WonkoVersionListPtr list = ensureVersionListLoaded(uid, parent); - if (!list) - { - return nullptr; - } - return list->getVersion(version); -} -WonkoVersionPtr Wonko::ensureVersionLoaded(const QString &uid, const QString &version, QWidget *parent, const UpdateType update) -{ - WonkoVersionPtr vptr = ensureVersionExists(uid, version, parent); - if (!vptr) - { - return nullptr; - } - if (!vptr->isLocalLoaded() || update == AlwaysUpdate) - { - ProgressDialog(parent).execWithTask(vptr->localUpdateTask()); - if (!vptr->isLocalLoaded() || update == AlwaysUpdate) - { - ProgressDialog(parent).execWithTask(vptr->remoteUpdateTask()); - } - } - return vptr->isComplete() ? vptr : nullptr; -} diff --git a/application/WonkoGui.h b/application/WonkoGui.h deleted file mode 100644 index ad0bee89..00000000 --- a/application/WonkoGui.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include <memory> -#include "QObjectPtr.h" - -class QWidget; -class QString; - -using WonkoIndexPtr = shared_qobject_ptr<class WonkoIndex>; -using WonkoVersionListPtr = std::shared_ptr<class WonkoVersionList>; -using WonkoVersionPtr = std::shared_ptr<class WonkoVersion>; - -namespace Wonko -{ -enum UpdateType -{ - AlwaysUpdate, - UpdateIfNeeded -}; - -/// Ensures that the index has been loaded, either from the local cache or remotely -WonkoIndexPtr ensureIndexLoaded(QWidget *parent); -/// Ensures that the given uid exists. Returns a nullptr if it doesn't. -WonkoVersionListPtr ensureVersionListExists(const QString &uid, QWidget *parent); -/// Ensures that the given uid exists and is loaded, either from the local cache or remotely. Returns nullptr if it doesn't exist or couldn't be loaded. -WonkoVersionListPtr ensureVersionListLoaded(const QString &uid, QWidget *parent); -WonkoVersionPtr ensureVersionExists(const QString &uid, const QString &version, QWidget *parent); -WonkoVersionPtr ensureVersionLoaded(const QString &uid, const QString &version, QWidget *parent, const UpdateType update = UpdateIfNeeded); -} diff --git a/application/dialogs/NewInstanceDialog.cpp b/application/dialogs/NewInstanceDialog.cpp index d53e1959..8180aa27 100644 --- a/application/dialogs/NewInstanceDialog.cpp +++ b/application/dialogs/NewInstanceDialog.cpp @@ -19,7 +19,6 @@ #include <BaseVersion.h> #include <icons/IconList.h> -#include <minecraft/MinecraftVersionList.h> #include <tasks/Task.h> #include <InstanceList.h> @@ -32,6 +31,9 @@ #include <QFileDialog> #include <QValidator> +#include <meta/Index.h> +#include <meta/VersionList.h> + class UrlValidator : public QValidator { public: @@ -62,7 +64,25 @@ NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, QWidget *pare resize(minimumSizeHint()); layout()->setSizeConstraint(QLayout::SetFixedSize); - setSelectedVersion(MMC->minecraftlist()->getRecommended()); + auto vlist = ENV.metadataIndex()->get("net.minecraft"); + if(vlist->isLoaded()) + { + setSelectedVersion(vlist->getRecommended()); + } + else + { + vlist->load(); + auto task = vlist->getLoadTask(); + if(vlist->isLoaded()) + { + setSelectedVersion(vlist->getRecommended()); + } + if(task) + { + connect(task.get(), &Task::succeeded, this, &NewInstanceDialog::versionListUpdated); + } + } + InstIconKey = "default"; ui->iconButton->setIcon(MMC->icons()->getIcon(InstIconKey)); @@ -95,6 +115,15 @@ NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, QWidget *pare updateDialogState(); } +void NewInstanceDialog::versionListUpdated() +{ + if(!m_versionSetByUser) + { + auto vlist = ENV.metadataIndex()->get("net.minecraft"); + setSelectedVersion(vlist->getRecommended()); + } +} + NewInstanceDialog::~NewInstanceDialog() { delete ui; @@ -134,7 +163,7 @@ void NewInstanceDialog::setSelectedVersion(BaseVersionPtr version) if (m_selectedVersion) { - ui->versionTextBox->setText(version->name()); + ui->versionTextBox->setText(version->descriptor()); } else { @@ -192,14 +221,16 @@ BaseVersionPtr NewInstanceDialog::selectedVersion() const void NewInstanceDialog::on_btnChangeVersion_clicked() { - VersionSelectDialog vselect(MMC->minecraftlist().get(), tr("Change Minecraft version"), - this); + VersionSelectDialog vselect(ENV.metadataIndex()->get("net.minecraft").get(), tr("Change Minecraft version"), this); vselect.exec(); if (vselect.result() == QDialog::Accepted) { BaseVersionPtr version = vselect.selectedVersion(); if (version) + { + m_versionSetByUser = true; setSelectedVersion(version); + } } } diff --git a/application/dialogs/NewInstanceDialog.h b/application/dialogs/NewInstanceDialog.h index 1f7fadfb..1741dab8 100644 --- a/application/dialogs/NewInstanceDialog.h +++ b/application/dialogs/NewInstanceDialog.h @@ -36,8 +36,6 @@ public: void setSelectedVersion(BaseVersionPtr version); - void loadVersionList(); - QString instName() const; QString instGroup() const; QString iconKey() const; @@ -50,10 +48,12 @@ slots: void on_iconButton_clicked(); void on_modpackBtn_clicked(); void on_instNameTextBox_textChanged(const QString &arg1); + void versionListUpdated(); private: Ui::NewInstanceDialog *ui; + bool m_versionSetByUser = false; BaseVersionPtr m_selectedVersion; QString InstIconKey; QString originalPlaceholderText; diff --git a/application/main.cpp b/application/main.cpp index fde9e10d..0f258926 100644 --- a/application/main.cpp +++ b/application/main.cpp @@ -38,7 +38,6 @@ int main(int argc, char *argv[]) { Q_INIT_RESOURCE(multimc); Q_INIT_RESOURCE(backgrounds); - Q_INIT_RESOURCE(versions); Q_INIT_RESOURCE(pe_dark); Q_INIT_RESOURCE(pe_light); diff --git a/application/pages/VersionPage.cpp b/application/pages/VersionPage.cpp index 8decc649..8e8c3d5f 100644 --- a/application/pages/VersionPage.cpp +++ b/application/pages/VersionPage.cpp @@ -36,19 +36,16 @@ #include <QUrl> #include "minecraft/MinecraftProfile.h" -#include "minecraft/forge/ForgeVersionList.h" -#include "minecraft/forge/ForgeInstaller.h" -#include "minecraft/liteloader/LiteLoaderVersionList.h" -#include "minecraft/liteloader/LiteLoaderInstaller.h" #include "minecraft/auth/MojangAccountList.h" #include "minecraft/Mod.h" -#include "minecraft/MinecraftVersion.h" -#include "minecraft/MinecraftVersionList.h" #include "icons/IconList.h" #include "Exception.h" #include "MultiMC.h" +#include <meta/Index.h> +#include <meta/VersionList.h> + class IconProxy : public QIdentityProxyModel { Q_OBJECT @@ -155,14 +152,14 @@ void VersionPage::packageCurrent(const QModelIndex ¤t, const QModelIndex & auto severity = patch->getProblemSeverity(); switch(severity) { - case PROBLEM_WARNING: + case ProblemSeverity::Warning: ui->frame->setModText(tr("%1 possibly has issues.").arg(patch->getName())); break; - case PROBLEM_ERROR: + case ProblemSeverity::Error: ui->frame->setModText(tr("%1 has issues!").arg(patch->getName())); break; default: - case PROBLEM_NONE: + case ProblemSeverity::None: ui->frame->clear(); return; } @@ -171,11 +168,11 @@ void VersionPage::packageCurrent(const QModelIndex ¤t, const QModelIndex & QString problemOut; for (auto &problem: problems) { - if(problem.getSeverity() == PROBLEM_ERROR) + if(problem.getSeverity() == ProblemSeverity::Error) { problemOut += tr("Error: "); } - else if(problem.getSeverity() == PROBLEM_WARNING) + else if(problem.getSeverity() == ProblemSeverity::Warning) { problemOut += tr("Warning: "); } @@ -326,8 +323,20 @@ void VersionPage::on_moveDownBtn_clicked() void VersionPage::on_changeVersionBtn_clicked() { - VersionSelectDialog vselect(m_inst->versionList().get(), tr("Change Minecraft version"), - this); + auto versionRow = currentRow(); + if(versionRow == -1) + { + return; + } + auto patch = m_profile->versionPatch(versionRow); + auto name = patch->getName(); + auto list = patch->getVersionList(); + if(!list) + { + return; + } + auto uid = list->uid(); + VersionSelectDialog vselect(list.get(), tr("Change %1 version").arg(name), this); if (!vselect.exec() || !vselect.selectedVersion()) return; @@ -341,21 +350,25 @@ void VersionPage::on_changeVersionBtn_clicked() return; } - if (!m_profile->isVanilla()) + qDebug() << "Change" << uid << "to" << vselect.selectedVersion()->descriptor(); + if(uid == "net.minecraft") { - auto result = CustomMessageBox::selectable( - this, tr("Are you sure?"), - tr("This will remove any library/version customization you did previously. " - "This includes things like Forge install and similar."), - QMessageBox::Warning, QMessageBox::Ok | QMessageBox::Abort, - QMessageBox::Abort)->exec(); - - if (result != QMessageBox::Ok) - return; - m_profile->revertToVanilla(); - reloadMinecraftProfile(); + if (!m_profile->isVanilla()) + { + auto result = CustomMessageBox::selectable( + this, tr("Are you sure?"), + tr("This will remove any library/version customization you did previously. " + "This includes things like Forge install and similar."), + QMessageBox::Warning, QMessageBox::Ok | QMessageBox::Abort, + QMessageBox::Abort)->exec(); + + if (result != QMessageBox::Ok) + return; + m_profile->revertToVanilla(); + reloadMinecraftProfile(); + } } - m_inst->setIntendedVersionId(vselect.selectedVersion()->descriptor()); + m_inst->setComponentVersion(uid, vselect.selectedVersion()->descriptor()); doUpdate(); m_container->refreshContainer(); } @@ -377,16 +390,21 @@ int VersionPage::doUpdate() void VersionPage::on_forgeBtn_clicked() { - VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this); - vselect.setExactFilter(BaseVersionList::ParentGameVersionRole, m_inst->currentVersionId()); - vselect.setEmptyString(tr("No Forge versions are currently available for Minecraft ") + - m_inst->currentVersionId()); + auto vlist = ENV.metadataIndex()->get("net.minecraftforge"); + if(!vlist) + { + return; + } + VersionSelectDialog vselect(vlist.get(), tr("Select Forge version"), this); + vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_inst->currentVersionId()); + vselect.setEmptyString(tr("No Forge versions are currently available for Minecraft ") + m_inst->currentVersionId()); vselect.setEmptyErrorString(tr("Couldn't load or download the Forge version lists!")); if (vselect.exec() && vselect.selectedVersion()) { - ProgressDialog dialog(this); - dialog.execWithTask( - ForgeInstaller().createInstallTask(m_inst, vselect.selectedVersion(), this)); + auto vsn = vselect.selectedVersion(); + m_inst->setComponentVersion("net.minecraftforge", vsn->descriptor()); + m_profile->reload(); + // m_profile->installVersion(); preselect(m_profile->rowCount(QModelIndex())-1); m_container->refreshContainer(); } @@ -394,17 +412,21 @@ void VersionPage::on_forgeBtn_clicked() void VersionPage::on_liteloaderBtn_clicked() { - VersionSelectDialog vselect(MMC->liteloaderlist().get(), tr("Select LiteLoader version"), - this); - vselect.setExactFilter(BaseVersionList::ParentGameVersionRole, m_inst->currentVersionId()); - vselect.setEmptyString(tr("No LiteLoader versions are currently available for Minecraft ") + - m_inst->currentVersionId()); + auto vlist = ENV.metadataIndex()->get("com.mumfrey.liteloader"); + if(!vlist) + { + return; + } + VersionSelectDialog vselect(vlist.get(), tr("Select LiteLoader version"), this); + vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_inst->currentVersionId()); + vselect.setEmptyString(tr("No LiteLoader versions are currently available for Minecraft ") + m_inst->currentVersionId()); vselect.setEmptyErrorString(tr("Couldn't load or download the LiteLoader version lists!")); if (vselect.exec() && vselect.selectedVersion()) { - ProgressDialog dialog(this); - dialog.execWithTask( - LiteLoaderInstaller().createInstallTask(m_inst, vselect.selectedVersion(), this)); + auto vsn = vselect.selectedVersion(); + m_inst->setComponentVersion("com.mumfrey.liteloader", vsn->descriptor()); + m_profile->reload(); + // m_profile->installVersion(vselect.selectedVersion()); preselect(m_profile->rowCount(QModelIndex())-1); m_container->refreshContainer(); } @@ -456,8 +478,9 @@ void VersionPage::updateButtons(int row) ui->moveDownBtn->setEnabled(patch->isMoveable()); ui->moveUpBtn->setEnabled(patch->isMoveable()); ui->changeVersionBtn->setEnabled(patch->isVersionChangeable()); - ui->editBtn->setEnabled(patch->isEditable()); - ui->customizeBtn->setEnabled(patch->isCustomizable()); + ui->editBtn->setEnabled(patch->isCustom()); + // FIXME: temporarily disabled, bring it back when the new format is stable and ready to replace the 'OneSix' one... + ui->customizeBtn->setEnabled(false); // patch->isCustomizable() ui->revertBtn->setEnabled(patch->isRevertible()); } } @@ -489,20 +512,18 @@ int VersionPage::currentRow() void VersionPage::on_customizeBtn_clicked() { + // FIXME: temporarily disabled, bring it back when the new format is stable and ready to replace the 'OneSix' one... + return; auto version = currentRow(); if(version == -1) { return; } - //HACK HACK remove, this is dumb auto patch = m_profile->versionPatch(version); - auto mc = std::dynamic_pointer_cast<MinecraftVersion>(patch); - if(mc && mc->needsUpdate()) + if(!patch->getVersionFile()) { - if(!doUpdate()) - { - return; - } + // TODO: wait for the update task to finish here... + return; } if(!m_profile->customize(version)) { @@ -535,15 +556,6 @@ void VersionPage::on_revertBtn_clicked() { return; } - auto mcraw = MMC->minecraftlist()->findVersion(m_inst->intendedVersionId()); - auto mc = std::dynamic_pointer_cast<MinecraftVersion>(mcraw); - if(mc && mc->needsUpdate()) - { - if(!doUpdate()) - { - return; - } - } if(!m_profile->revertToBase(version)) { // TODO: some error box here diff --git a/application/pages/global/Wonk |
