From 9df2f1fa5c455e4e75caf3f5ae6dbe4c34b77d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 5 Apr 2015 22:00:32 +0200 Subject: NOISSUE fix legacy edit instance --- application/CMakeLists.txt | 6 + application/InstancePageProvider.h | 21 ++++ application/pages/LegacyJarModPage.cpp | 200 ++++++++++++++++++++++++++++++++ application/pages/LegacyJarModPage.h | 77 ++++++++++++ application/pages/LegacyJarModPage.ui | 172 +++++++++++++++++++++++++++ application/pages/LegacyUpgradePage.cpp | 25 ++++ application/pages/LegacyUpgradePage.h | 61 ++++++++++ application/pages/LegacyUpgradePage.ui | 58 +++++++++ 8 files changed, 620 insertions(+) create mode 100644 application/pages/LegacyJarModPage.cpp create mode 100644 application/pages/LegacyJarModPage.h create mode 100644 application/pages/LegacyJarModPage.ui create mode 100644 application/pages/LegacyUpgradePage.cpp create mode 100644 application/pages/LegacyUpgradePage.h create mode 100644 application/pages/LegacyUpgradePage.ui (limited to 'application') diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt index 9e94cdad..3643feee 100644 --- a/application/CMakeLists.txt +++ b/application/CMakeLists.txt @@ -177,6 +177,10 @@ SET(MULTIMC_SOURCES pages/ScreenshotsPage.h pages/OtherLogsPage.cpp pages/OtherLogsPage.h + pages/LegacyJarModPage.cpp + pages/LegacyJarModPage.h + pages/LegacyUpgradePage.cpp + pages/LegacyUpgradePage.h # GUI - global settings pages pages/global/AccountListPage.cpp @@ -266,6 +270,8 @@ SET(MULTIMC_UIS pages/NotesPage.ui pages/ScreenshotsPage.ui pages/OtherLogsPage.ui + pages/LegacyJarModPage.ui + pages/LegacyUpgradePage.ui # Global settings pages pages/global/AccountListPage.ui diff --git a/application/InstancePageProvider.h b/application/InstancePageProvider.h index a19e21c8..9cc97c4a 100644 --- a/application/InstancePageProvider.h +++ b/application/InstancePageProvider.h @@ -1,5 +1,6 @@ #pragma once #include "minecraft/OneSixInstance.h" +#include "minecraft/LegacyInstance.h" #include "pages/BasePage.h" #include "pages/VersionPage.h" #include "pages/ModFolderPage.h" @@ -10,8 +11,10 @@ #include "pages/InstanceSettingsPage.h" #include "pages/OtherLogsPage.h" #include "pages/BasePageProvider.h" +#include "pages/LegacyJarModPage.h" #include + class InstancePageProvider : public QObject, public BasePageProvider { Q_OBJECT @@ -40,6 +43,24 @@ public: values.append(new InstanceSettingsPage(onesix.get())); values.append(new OtherLogsPage(onesix->minecraftRoot())); } + std::shared_ptr legacy = std::dynamic_pointer_cast(inst); + if(legacy) + { + QList values; + // FIXME: actually implement the legacy instance upgrade, then enable this. + //values.append(new LegacyUpgradePage(this)); + values.append(new LegacyJarModPage(legacy.get())); + values.append(new ModFolderPage(legacy.get(), legacy->loaderModList(), "mods", "loadermods", tr("Loader mods"), + "Loader-mods")); + values.append(new ModFolderPage(legacy.get(), legacy->coreModList(), "coremods", "coremods", tr("Core mods"), + "Loader-mods")); + values.append(new TexturePackPage(legacy.get())); + values.append(new NotesPage(legacy.get())); + values.append(new ScreenshotsPage(PathCombine(legacy->minecraftRoot(), "screenshots"))); + values.append(new InstanceSettingsPage(legacy.get())); + values.append(new OtherLogsPage(legacy->minecraftRoot())); + return values; + } return values; } diff --git a/application/pages/LegacyJarModPage.cpp b/application/pages/LegacyJarModPage.cpp new file mode 100644 index 00000000..b403aa8a --- /dev/null +++ b/application/pages/LegacyJarModPage.cpp @@ -0,0 +1,200 @@ +/* Copyright 2013-2015 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. + */ + +#include "LegacyJarModPage.h" +#include "ui_LegacyJarModPage.h" + +#include +#include +#include + +#include + +#include "dialogs/VersionSelectDialog.h" +#include "dialogs/ProgressDialog.h" +#include "dialogs/ModEditDialogCommon.h" +#include "minecraft/ModList.h" +#include "minecraft/LegacyInstance.h" +#include "Env.h" +#include "MultiMC.h" + +LegacyJarModPage::LegacyJarModPage(LegacyInstance *inst, QWidget *parent) + : QWidget(parent), ui(new Ui::LegacyJarModPage), m_inst(inst) +{ + ui->setupUi(this); + ui->tabWidget->tabBar()->hide(); + + m_jarmods = m_inst->jarModList(); + ui->jarModsTreeView->setModel(m_jarmods.get()); + ui->jarModsTreeView->setDragDropMode(QAbstractItemView::DragDrop); + ui->jarModsTreeView->setSelectionMode(QAbstractItemView::SingleSelection); + ui->jarModsTreeView->installEventFilter(this); + m_jarmods->startWatching(); + auto smodel = ui->jarModsTreeView->selectionModel(); + connect(smodel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), + SLOT(jarCurrent(QModelIndex, QModelIndex))); +} + +LegacyJarModPage::~LegacyJarModPage() +{ + m_jarmods->stopWatching(); + delete ui; +} + +bool LegacyJarModPage::shouldDisplay() const +{ + return !m_inst->isRunning(); +} + +bool LegacyJarModPage::eventFilter(QObject *obj, QEvent *ev) +{ + if (ev->type() != QEvent::KeyPress || obj != ui->jarModsTreeView) + { + return QWidget::eventFilter(obj, ev); + } + + QKeyEvent *keyEvent = static_cast(ev); + switch (keyEvent->key()) + { + case Qt::Key_Up: + { + if (keyEvent->modifiers() & Qt::ControlModifier) + { + on_moveJarUpBtn_clicked(); + return true; + } + break; + } + case Qt::Key_Down: + { + if (keyEvent->modifiers() & Qt::ControlModifier) + { + on_moveJarDownBtn_clicked(); + return true; + } + break; + } + case Qt::Key_Delete: + on_rmJarBtn_clicked(); + return true; + case Qt::Key_Plus: + on_addJarBtn_clicked(); + return true; + default: + break; + } + return QWidget::eventFilter(obj, ev); +} + +void LegacyJarModPage::on_addForgeBtn_clicked() +{ + //FIXME: dead. clean up. + /* + VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this); + vselect.setExactFilter(1, m_inst->intendedVersionId()); + if (vselect.exec() && vselect.selectedVersion()) + { + ForgeVersionPtr forge = + std::dynamic_pointer_cast(vselect.selectedVersion()); + if (!forge) + return; + auto entry = Env::getInstance().metacache()->resolveEntry("minecraftforge", forge->filename()); + if (entry->stale) + { + NetJob *fjob = new NetJob("Forge download"); + auto cacheDl = CacheDownload::make(forge->universal_url, entry); + fjob->addNetAction(cacheDl); + ProgressDialog dlg(this); + dlg.exec(fjob); + if (dlg.result() == QDialog::Accepted) + { + m_jarmods->stopWatching(); + m_jarmods->installMod(QFileInfo(entry->getFullPath())); + m_jarmods->startWatching(); + } + else + { + // failed to download forge :/ + } + } + else + { + m_jarmods->stopWatching(); + m_jarmods->installMod(QFileInfo(entry->getFullPath())); + m_jarmods->startWatching(); + } + }*/ +} +void LegacyJarModPage::on_addJarBtn_clicked() +{ + //: Title of jar mod selection dialog + QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Jar Mods")); + for (auto filename : fileNames) + { + m_jarmods->stopWatching(); + m_jarmods->installMod(QFileInfo(filename)); + m_jarmods->startWatching(); + } +} + +void LegacyJarModPage::on_moveJarDownBtn_clicked() +{ + int first, last; + auto list = ui->jarModsTreeView->selectionModel()->selectedRows(); + + if (!lastfirst(list, first, last)) + return; + + m_jarmods->moveModsDown(first, last); +} + +void LegacyJarModPage::on_moveJarUpBtn_clicked() +{ + int first, last; + auto list = ui->jarModsTreeView->selectionModel()->selectedRows(); + + if (!lastfirst(list, first, last)) + return; + m_jarmods->moveModsUp(first, last); +} + +void LegacyJarModPage::on_rmJarBtn_clicked() +{ + int first, last; + auto list = ui->jarModsTreeView->selectionModel()->selectedRows(); + + if (!lastfirst(list, first, last)) + return; + m_jarmods->stopWatching(); + m_jarmods->deleteMods(first, last); + m_jarmods->startWatching(); +} + +void LegacyJarModPage::on_viewJarBtn_clicked() +{ + openDirInDefaultProgram(m_inst->jarModsDir(), true); +} + +void LegacyJarModPage::jarCurrent(QModelIndex current, QModelIndex previous) +{ + if (!current.isValid()) + { + ui->jarMIFrame->clear(); + return; + } + int row = current.row(); + Mod &m = m_jarmods->operator[](row); + ui->jarMIFrame->updateWithMod(m); +} diff --git a/application/pages/LegacyJarModPage.h b/application/pages/LegacyJarModPage.h new file mode 100644 index 00000000..d1e31a0c --- /dev/null +++ b/application/pages/LegacyJarModPage.h @@ -0,0 +1,77 @@ +/* Copyright 2013-2015 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 "net/NetJob.h" +#include "BasePage.h" +#include + +class ModList; +class LegacyInstance; +namespace Ui +{ +class LegacyJarModPage; +} + +class LegacyJarModPage : public QWidget, public BasePage +{ + Q_OBJECT + +public: + explicit LegacyJarModPage(LegacyInstance *inst, QWidget *parent = 0); + virtual ~LegacyJarModPage(); + + virtual QString displayName() const + { + return tr("Jar Mods"); + } + virtual QIcon icon() const + { + return MMC->getThemedIcon("jarmods"); + } + virtual QString id() const + { + return "jarmods"; + } + virtual QString helpPage() const override + { + return "Legacy-jar-mods"; + } + virtual bool shouldDisplay() const; + +private +slots: + + void on_addJarBtn_clicked(); + void on_rmJarBtn_clicked(); + void on_addForgeBtn_clicked(); + void on_moveJarUpBtn_clicked(); + void on_moveJarDownBtn_clicked(); + void on_viewJarBtn_clicked(); + + void jarCurrent(QModelIndex current, QModelIndex previous); + +protected: + virtual bool eventFilter(QObject *obj, QEvent *ev) override; + +private: + Ui::LegacyJarModPage *ui; + std::shared_ptr m_jarmods; + LegacyInstance *m_inst; + NetJobPtr forgeJob; +}; diff --git a/application/pages/LegacyJarModPage.ui b/application/pages/LegacyJarModPage.ui new file mode 100644 index 00000000..e99fac9a --- /dev/null +++ b/application/pages/LegacyJarModPage.ui @@ -0,0 +1,172 @@ + + + LegacyJarModPage + + + + 0 + 0 + 659 + 593 + + + + LegacyJarModPage + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 0 + + + + Tab 1 + + + + + + + + Qt::ScrollBarAlwaysOn + + + Qt::ScrollBarAlwaysOff + + + + + + + + + Selection + + + Qt::AlignCenter + + + + + + + &Remove + + + + + + + Move &Up + + + + + + + Move &Down + + + + + + + + + + Install + + + Qt::AlignCenter + + + + + + + &Add jar mod + + + + + + + Install Forge + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + &View Folder + + + + + + + + + + + + + + + + 0 + 0 + + + + + + + + + ModListView + QTreeView +
widgets/ModListView.h
+
+ + MCModInfoFrame + QFrame +
widgets/MCModInfoFrame.h
+ 1 +
+ + LineSeparator + QWidget +
widgets/LineSeparator.h
+ 1 +
+
+ + +
diff --git a/application/pages/LegacyUpgradePage.cpp b/application/pages/LegacyUpgradePage.cpp new file mode 100644 index 00000000..49998c50 --- /dev/null +++ b/application/pages/LegacyUpgradePage.cpp @@ -0,0 +1,25 @@ +#include "LegacyUpgradePage.h" +#include "ui_LegacyUpgradePage.h" + +#include "minecraft/LegacyInstance.h" + +LegacyUpgradePage::LegacyUpgradePage(LegacyInstance *inst, QWidget *parent) + : QWidget(parent), ui(new Ui::LegacyUpgradePage), m_inst(inst) +{ + ui->setupUi(this); +} + +LegacyUpgradePage::~LegacyUpgradePage() +{ + delete ui; +} + +void LegacyUpgradePage::on_upgradeButton_clicked() +{ + // now what? +} + +bool LegacyUpgradePage::shouldDisplay() const +{ + return !m_inst->isRunning(); +} diff --git a/application/pages/LegacyUpgradePage.h b/application/pages/LegacyUpgradePage.h new file mode 100644 index 00000000..108b1024 --- /dev/null +++ b/application/pages/LegacyUpgradePage.h @@ -0,0 +1,61 @@ +/* Copyright 2013-2015 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 "minecraft/OneSixInstance.h" +#include "net/NetJob.h" +#include "pages/BasePage.h" +#include + +namespace Ui +{ +class LegacyUpgradePage; +} + +class LegacyUpgradePage : public QWidget, public BasePage +{ + Q_OBJECT + +public: + explicit LegacyUpgradePage(LegacyInstance *inst, QWidget *parent = 0); + virtual ~LegacyUpgradePage(); + virtual QString displayName() const override + { + return tr("Upgrade"); + } + virtual QIcon icon() const override + { + return MMC->getThemedIcon("checkupdate"); + } + virtual QString id() const override + { + return "upgrade"; + } + virtual QString helpPage() const override + { + return "Legacy-upgrade"; + } + virtual bool shouldDisplay() const; +private +slots: + void on_upgradeButton_clicked(); + +private: + Ui::LegacyUpgradePage *ui; + LegacyInstance *m_inst; +}; diff --git a/application/pages/LegacyUpgradePage.ui b/application/pages/LegacyUpgradePage.ui new file mode 100644 index 00000000..8d676eae --- /dev/null +++ b/application/pages/LegacyUpgradePage.ui @@ -0,0 +1,58 @@ + + + LegacyUpgradePage + + + + 0 + 0 + 546 + 405 + + + + Upgrade + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Bitstream Vera Sans'; font-size:11pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> </p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:18pt; font-weight:600;">New format is available</span> </p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">MultiMC now supports old Minecraft versions in the new (OneSix) instance format. The old format won't be getting any new features and only the most critical bugfixes. As a consequence, you should upgrade this instance. </p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">The upgrade will create a new instance with the same contents as the current one, in the new format. The original instance will remain untouched, in case anything goes wrong in the process. </p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Please report any issues on our <a href="https://github.com/MultiMC/MultiMC5/issues"><img src=":/icons/multimc/22x22/bug.png" /></a><a href="https://github.com/MultiMC/MultiMC5/issues"><span style=" text-decoration: underline; color:#68a0df;">github issues page</span></a>.</p></body></html> + + + true + + + + + + + Start the upgrade! (Not Yet Implemented, Coming Soon™) + + + + + + + + -- cgit v1.2.3