diff options
-rw-r--r-- | application/CMakeLists.txt | 1 | ||||
-rw-r--r-- | application/MultiMC.cpp | 3 | ||||
-rw-r--r-- | application/pages/BasePage.h | 5 | ||||
-rw-r--r-- | application/pages/BasePageContainer.h | 8 | ||||
-rw-r--r-- | application/pages/VersionPage.cpp | 38 | ||||
-rw-r--r-- | application/pages/VersionPage.h | 4 | ||||
-rw-r--r-- | application/pages/VersionPage.ui | 23 | ||||
-rw-r--r-- | application/widgets/PageContainer.cpp | 12 | ||||
-rw-r--r-- | application/widgets/PageContainer.h | 5 |
9 files changed, 91 insertions, 8 deletions
diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt index bd7fc64e..b47e36ea 100644 --- a/application/CMakeLists.txt +++ b/application/CMakeLists.txt @@ -162,6 +162,7 @@ SET(MULTIMC_SOURCES # GUI - page dialog pages pages/BasePage.h + pages/BasePageContainer.h pages/VersionPage.cpp pages/VersionPage.h pages/TexturePackPage.h diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index baeb9de1..39cc8503 100644 --- a/application/MultiMC.cpp +++ b/application/MultiMC.cpp @@ -495,6 +495,9 @@ void MultiMC::initGlobalSettings(bool test_mode) m_settings->registerSetting("SettingsGeometry", ""); m_settings->registerSetting("PagedGeometry", ""); + + // Jar mod nag dialog in version page + m_settings->registerSetting("JarModNagSeen", false); } std::shared_ptr<LWJGLVersionList> MultiMC::lwjgllist() diff --git a/application/pages/BasePage.h b/application/pages/BasePage.h index ecf0692c..8b90358c 100644 --- a/application/pages/BasePage.h +++ b/application/pages/BasePage.h @@ -19,6 +19,8 @@ #include <QIcon> #include <memory> +#include "BasePageContainer.h" + class BasePage { public: @@ -31,6 +33,9 @@ public: virtual QString helpPage() const { return QString(); } virtual void opened() {} virtual void closed() {} + virtual void setParentContainer(BasePageContainer *) {}; + +public: int stackIndex = -1; int listIndex = -1; }; diff --git a/application/pages/BasePageContainer.h b/application/pages/BasePageContainer.h new file mode 100644 index 00000000..5982ad76 --- /dev/null +++ b/application/pages/BasePageContainer.h @@ -0,0 +1,8 @@ +#pragma once + +class BasePageContainer +{ +public: + virtual ~BasePageContainer(){}; + virtual bool selectPage(QString pageId) = 0; +}; diff --git a/application/pages/VersionPage.cpp b/application/pages/VersionPage.cpp index 831408f6..cbb5c107 100644 --- a/application/pages/VersionPage.cpp +++ b/application/pages/VersionPage.cpp @@ -58,6 +58,11 @@ bool VersionPage::shouldDisplay() const return !m_inst->isRunning(); } +void VersionPage::setParentContainer(BasePageContainer * container) +{ + m_container = container; +} + VersionPage::VersionPage(OneSixInstance *inst, QWidget *parent) : QWidget(parent), ui(new Ui::VersionPage), m_inst(inst) { @@ -145,12 +150,45 @@ void VersionPage::on_removeBtn_clicked() updateButtons(); } +void VersionPage::on_modBtn_clicked() +{ + if(m_container) + { + m_container->selectPage("mods"); + } +} + void VersionPage::on_jarmodBtn_clicked() { + bool nagShown = false; + auto traits = m_version->traits; + if (!traits.contains("legacyLaunch") && !traits.contains("alphaLaunch")) + { + // not legacy launch... nag + auto seenNag = MMC->settings()->get("JarModNagSeen").toBool(); + if(!seenNag) + { + auto result = QMessageBox::question(this, + tr("Are you sure?"), + tr("This will add mods directly to the Minecraft jar.\n" + "Unless you KNOW that this is what NEEDS to be done, you should just use the mods folder (Loader mods).\n" + "\n" + "Do you want to continue?"), + tr("I understand, continue."), tr("Cancel"), QString(), 1, 1 + ); + if(result != 0) + return; + nagShown = true; + } + } auto list = GuiUtil::BrowseForMods("jarmod", tr("Select jar mods"), tr("Minecraft.jar mods (*.zip *.jar)"), this->parentWidget()); if(!list.empty()) { m_version->installJarMods(list); + if(nagShown) + { + MMC->settings()->set("JarModNagSeen", QVariant(true)); + } } updateButtons(); } diff --git a/application/pages/VersionPage.h b/application/pages/VersionPage.h index 49837f80..bd22e140 100644 --- a/application/pages/VersionPage.h +++ b/application/pages/VersionPage.h @@ -47,6 +47,8 @@ public: } virtual bool shouldDisplay() const; + virtual void setParentContainer(BasePageContainer *); + private slots: void on_forgeBtn_clicked(); void on_liteloaderBtn_clicked(); @@ -58,6 +60,7 @@ private slots: void on_jarmodBtn_clicked(); void on_revertBtn_clicked(); void on_editBtn_clicked(); + void on_modBtn_clicked(); void on_customizeBtn_clicked(); void updateVersionControls(); @@ -80,6 +83,7 @@ private: std::shared_ptr<MinecraftProfile> m_version; OneSixInstance *m_inst; int currentIdx = 0; + BasePageContainer * m_container = nullptr; public slots: void versionCurrent(const QModelIndex ¤t, const QModelIndex &previous); diff --git a/application/pages/VersionPage.ui b/application/pages/VersionPage.ui index 1216229f..e1c23197 100644 --- a/application/pages/VersionPage.ui +++ b/application/pages/VersionPage.ui @@ -181,12 +181,12 @@ </widget> </item> <item> - <widget class="QPushButton" name="jarmodBtn"> + <widget class="QPushButton" name="modBtn"> <property name="toolTip"> - <string>Add a mod into the Minecraft jar file.</string> + <string>Install normal mods.</string> </property> <property name="text"> - <string>Add jar mod</string> + <string>Install mods</string> </property> </widget> </item> @@ -196,7 +196,7 @@ <item> <widget class="QLabel" name="label_5"> <property name="text"> - <string>List</string> + <string>Advanced</string> </property> <property name="alignment"> <set>Qt::AlignCenter</set> @@ -204,6 +204,16 @@ </widget> </item> <item> + <widget class="QPushButton" name="jarmodBtn"> + <property name="toolTip"> + <string>Add a mod into the Minecraft jar file.</string> + </property> + <property name="text"> + <string>Add jar mod</string> + </property> + </widget> + </item> + <item> <widget class="QPushButton" name="resetOrderBtn"> <property name="toolTip"> <string>Reset apply order of packages.</string> @@ -230,8 +240,8 @@ </property> <property name="sizeHint" stdset="0"> <size> - <width>20</width> - <height>40</height> + <width>111</width> + <height>13</height> </size> </property> </spacer> @@ -269,6 +279,7 @@ <tabstop>revertBtn</tabstop> <tabstop>forgeBtn</tabstop> <tabstop>liteloaderBtn</tabstop> + <tabstop>modBtn</tabstop> <tabstop>jarmodBtn</tabstop> <tabstop>resetOrderBtn</tabstop> <tabstop>reloadBtn</tabstop> diff --git a/application/widgets/PageContainer.cpp b/application/widgets/PageContainer.cpp index 679039a7..0fe4ea25 100644 --- a/application/widgets/PageContainer.cpp +++ b/application/widgets/PageContainer.cpp @@ -68,6 +68,7 @@ PageContainer::PageContainer(BasePageProviderPtr pageProvider, QString defaultId { page->stackIndex = m_pageStack->addWidget(dynamic_cast<QWidget *>(page)); page->listIndex = counter; + page->setParentContainer(this); counter++; if (firstIndex == -1) { @@ -87,8 +88,13 @@ PageContainer::PageContainer(BasePageProviderPtr pageProvider, QString defaultId this, SLOT(currentChanged(QModelIndex))); m_pageStack->setStackingMode(QStackedLayout::StackOne); m_pageList->setFocus(); + selectPage(defaultId); +} + +bool PageContainer::selectPage(QString pageId) +{ // now find what we want to have selected... - auto page = m_model->findPageEntryById(defaultId); + auto page = m_model->findPageEntryById(pageId); QModelIndex index; if (page) { @@ -99,7 +105,11 @@ PageContainer::PageContainer(BasePageProviderPtr pageProvider, QString defaultId index = m_proxyModel->index(0, 0); } if (index.isValid()) + { m_pageList->setCurrentIndex(index); + return true; + } + return false; } void PageContainer::createUI() diff --git a/application/widgets/PageContainer.h b/application/widgets/PageContainer.h index 3027af36..381e84e5 100644 --- a/application/widgets/PageContainer.h +++ b/application/widgets/PageContainer.h @@ -19,6 +19,7 @@ #include <QModelIndex> #include "pages/BasePageProvider.h" +#include "pages/BasePageContainer.h" class QLayout; class IconLabel; @@ -30,7 +31,7 @@ class QLineEdit; class QStackedLayout; class QGridLayout; -class PageContainer : public QWidget +class PageContainer : public QWidget, public BasePageContainer { Q_OBJECT public: @@ -42,6 +43,8 @@ public: void addButtons(QLayout * buttons); bool requestClose(QCloseEvent *event); + virtual bool selectPage(QString pageId) override; + private: void createUI(); private |