From ff06489fed081ed34af63c6ffbdd61e6f917dd3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 10 Jul 2014 00:47:08 +0200 Subject: Do not show core mods page for minecraft newer than 1.5.2. --- gui/pages/ModFolderPage.cpp | 26 ++++++++++++++++++++++++++ gui/pages/ModFolderPage.h | 10 ++++++++++ logic/OneSixInstance.cpp | 8 ++++---- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/gui/pages/ModFolderPage.cpp b/gui/pages/ModFolderPage.cpp index 7e0eea52..7702dbdd 100644 --- a/gui/pages/ModFolderPage.cpp +++ b/gui/pages/ModFolderPage.cpp @@ -31,6 +31,7 @@ #include "logic/ModList.h" #include "logic/Mod.h" +#include QString ModFolderPage::displayName() { @@ -66,6 +67,13 @@ ModFolderPage::ModFolderPage(BaseInstance * inst, std::shared_ptr mods, SLOT(modCurrent(QModelIndex, QModelIndex))); } +CoreModFolderPage::CoreModFolderPage(BaseInstance *inst, std::shared_ptr mods, + QString id, QString iconName, QString displayName, + QString helpPage, QWidget *parent) + : ModFolderPage(inst, mods, id, iconName, displayName, helpPage, parent) +{ +} + ModFolderPage::~ModFolderPage() { m_mods->stopWatching(); @@ -79,6 +87,24 @@ bool ModFolderPage::shouldDisplay() return true; } +bool CoreModFolderPage::shouldDisplay() +{ + if (ModFolderPage::shouldDisplay()) + { + auto inst = dynamic_cast(m_inst); + if(!inst) + return true; + auto version = inst->getFullVersion(); + if(!version) + return true; + if(version->m_releaseTime < g_VersionFilterData.legacyCutoffDate) + { + return true; + } + } + return false; +} + bool ModFolderPage::modListFilter(QKeyEvent *keyEvent) { switch (keyEvent->key()) diff --git a/gui/pages/ModFolderPage.h b/gui/pages/ModFolderPage.h index c193f4c1..13ae97f5 100644 --- a/gui/pages/ModFolderPage.h +++ b/gui/pages/ModFolderPage.h @@ -61,3 +61,13 @@ private slots: void on_rmModBtn_clicked(); void on_viewModBtn_clicked(); }; + +class CoreModFolderPage : public ModFolderPage +{ +public: + explicit CoreModFolderPage(BaseInstance *inst, std::shared_ptr mods, QString id, + QString iconName, QString displayName, QString helpPage = "", + QWidget *parent = 0); + virtual ~CoreModFolderPage(){}; + virtual bool shouldDisplay(); +}; diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp index 7bac3424..3eb817a5 100644 --- a/logic/OneSixInstance.cpp +++ b/logic/OneSixInstance.cpp @@ -63,10 +63,10 @@ QList OneSixInstance::getPages() { QList values; values.append(new VersionPage(this)); - values.append(new ModFolderPage(this, loaderModList(), "mods", "plugin-blue", tr("Loader mods"), - "Loader-mods")); - values.append(new ModFolderPage(this, coreModList(), "coremods", "plugin-green", tr("Core mods"), - "Core-mods")); + values.append(new ModFolderPage(this, loaderModList(), "mods", "plugin-blue", + tr("Loader mods"), "Loader-mods")); + values.append(new CoreModFolderPage(this, coreModList(), "coremods", "plugin-green", + tr("Core mods"), "Core-mods")); values.append(new ResourcePackPage(this)); values.append(new TexturePackPage(this)); values.append(new NotesPage(this)); -- cgit v1.2.3