From 6cee50eac6c25796eb3642239385b0c58860cd58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Wed, 1 Aug 2018 20:05:18 +0200 Subject: [PATCH] NOISSUE gate new mods page behind cheat code --- api/logic/Env.cpp | 28 ++++++++++++++++++++++++++++ api/logic/Env.h | 6 ++++++ application/InstancePageProvider.h | 22 ++++++++++++++-------- application/MainWindow.cpp | 1 + 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/api/logic/Env.cpp b/api/logic/Env.cpp index 73cad2e9..77546bbc 100644 --- a/api/logic/Env.cpp +++ b/api/logic/Env.cpp @@ -20,6 +20,7 @@ struct Env::Private std::shared_ptr m_iconlist; shared_qobject_ptr m_metadataIndex; QString m_jarsPath; + QSet m_features; }; static Env * instance; @@ -179,3 +180,30 @@ void Env::setJarsPath(const QString& path) { d->m_jarsPath = path; } + +void Env::enableFeature(const QString& featureName, bool state) +{ + if(state) + { + d->m_features.insert(featureName); + } + else + { + d->m_features.remove(featureName); + } +} + +bool Env::isFeatureEnabled(const QString& featureName) const +{ + return d->m_features.contains(featureName); +} + +void Env::getEnabledFeatures(QSet& features) const +{ + features = d->m_features; +} + +void Env::setEnabledFeatures(const QSet& features) const +{ + d->m_features = features; +} diff --git a/api/logic/Env.h b/api/logic/Env.h index 4d9ec139..8b9b827e 100644 --- a/api/logic/Env.h +++ b/api/logic/Env.h @@ -54,6 +54,12 @@ public: QString getJarsPath(); void setJarsPath(const QString & path); + + bool isFeatureEnabled(const QString & featureName) const; + void enableFeature(const QString & featureName, bool state = true); + void getEnabledFeatures(QSet & features) const; + void setEnabledFeatures(const QSet & features) const; + protected: Private * d; }; diff --git a/application/InstancePageProvider.h b/application/InstancePageProvider.h index 94013101..ae279d94 100644 --- a/application/InstancePageProvider.h +++ b/application/InstancePageProvider.h @@ -18,6 +18,7 @@ #include "pages/instance/WorldListPage.h" #include "pages/instance/ServersPage.h" +#include "Env.h" class InstancePageProvider : public QObject, public BasePageProvider { @@ -37,14 +38,19 @@ public: if(onesix) { values.append(new VersionPage(onesix.get())); - auto modsPage = new ModFolderPage(onesix.get(), onesix->loaderModList(), "mods", "loadermods", tr("Loader mods"), "Loader-mods"); - modsPage->setFilter("%1 (*.zip *.jar *.litemod)"); - values.append(modsPage); - /* - auto modsPage2 = new NewModFolderPage(onesix.get(), onesix->modsModel(), "mods", "mods", tr("Mods"), "Mods"); - modsPage2->setFilter("%1 (*.zip *.jar *.litemod)"); - values.append(modsPage2); - */ + if(ENV.isFeatureEnabled("NewModsPage")) + { + auto modsPage = new NewModFolderPage(onesix.get(), onesix->modsModel(), "mods", "loadermods", tr("Mods"), "Mods-page"); + modsPage->setFilter("%1 (*.zip *.jar *.litemod)"); + values.append(modsPage); + } + else + { + auto modsPage = new ModFolderPage(onesix.get(), onesix->loaderModList(), "mods", "loadermods", tr("Loader mods"), "Loader-mods"); + modsPage->setFilter("%1 (*.zip *.jar *.litemod)"); + values.append(modsPage); + } + values.append(new CoreModFolderPage(onesix.get(), onesix->coreModList(), "coremods", "coremods", tr("Core mods"), "Core-mods")); values.append(new ResourcePackPage(onesix.get())); values.append(new TexturePackPage(onesix.get())); diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp index 883b38f9..4085f2bc 100644 --- a/application/MainWindow.cpp +++ b/application/MainWindow.cpp @@ -823,6 +823,7 @@ MainWindow::~MainWindow() void MainWindow::konamiTriggered() { + ENV.enableFeature("NewModsPage"); qDebug() << "Super Secret Mode ACTIVATED!"; }