diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/ConsoleWindow.cpp | 18 | ||||
-rw-r--r-- | gui/ConsoleWindow.h | 6 | ||||
-rw-r--r-- | gui/MainWindow.cpp | 273 | ||||
-rw-r--r-- | gui/MainWindow.h | 8 | ||||
-rw-r--r-- | gui/dialogs/AboutDialog.cpp | 2 | ||||
-rw-r--r-- | gui/pages/LogPage.cpp | 4 | ||||
-rw-r--r-- | gui/pages/LogPage.h | 6 | ||||
-rw-r--r-- | gui/pages/ModFolderPage.cpp | 4 | ||||
-rw-r--r-- | gui/pages/OtherLogsPage.cpp | 14 | ||||
-rw-r--r-- | gui/pages/OtherLogsPage.h | 6 | ||||
-rw-r--r-- | gui/pages/ResourcePackPage.h | 2 | ||||
-rw-r--r-- | gui/pages/ScreenshotsPage.cpp | 4 | ||||
-rw-r--r-- | gui/pages/ScreenshotsPage.h | 2 | ||||
-rw-r--r-- | gui/pages/TexturePackPage.h | 2 | ||||
-rw-r--r-- | gui/pages/VersionPage.cpp | 70 | ||||
-rw-r--r-- | gui/pages/VersionPage.h | 4 |
16 files changed, 193 insertions, 232 deletions
diff --git a/gui/ConsoleWindow.cpp b/gui/ConsoleWindow.cpp index 4ee0d487..ad3c2636 100644 --- a/gui/ConsoleWindow.cpp +++ b/gui/ConsoleWindow.cpp @@ -52,8 +52,8 @@ private: BasePage * m_log_page; }; -ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) - : QMainWindow(parent), m_proc(mcproc) +ConsoleWindow::ConsoleWindow(BaseProcess *process, QWidget *parent) + : QMainWindow(parent), m_proc(process) { MultiMCPlatform::fixWM_CLASS(this); setAttribute(Qt::WA_DeleteOnClose); @@ -120,23 +120,23 @@ ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) { m_trayIcon = new QSystemTrayIcon(icon, this); m_trayIcon->setToolTip(windowTitle); - + connect(m_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); m_trayIcon->show(); } // Set up signal connections - connect(mcproc, SIGNAL(ended(InstancePtr, int, QProcess::ExitStatus)), this, + connect(m_proc, SIGNAL(ended(InstancePtr, int, QProcess::ExitStatus)), this, SLOT(onEnded(InstancePtr, int, QProcess::ExitStatus))); - connect(mcproc, SIGNAL(prelaunch_failed(InstancePtr, int, QProcess::ExitStatus)), this, + connect(m_proc, SIGNAL(prelaunch_failed(InstancePtr, int, QProcess::ExitStatus)), this, SLOT(onEnded(InstancePtr, int, QProcess::ExitStatus))); - connect(mcproc, SIGNAL(launch_failed(InstancePtr)), this, + connect(m_proc, SIGNAL(launch_failed(InstancePtr)), this, SLOT(onLaunchFailed(InstancePtr))); setMayClose(false); - if (mcproc->instance()->settings().get("ShowConsole").toBool()) + if (m_proc->instance()->settings().get("ShowConsole").toBool()) { show(); } @@ -213,7 +213,7 @@ void ConsoleWindow::on_btnKillMinecraft_clicked() "is frozen for some reason"), QMessageBox::Question, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)->exec(); if (response == QMessageBox::Yes) - m_proc->killMinecraft(); + m_proc->killProcess(); else m_killButton->setEnabled(true); } @@ -254,5 +254,5 @@ void ConsoleWindow::onLaunchFailed(InstancePtr instance) } ConsoleWindow::~ConsoleWindow() { - + } diff --git a/gui/ConsoleWindow.h b/gui/ConsoleWindow.h index 1ad0f760..a14cd2fc 100644 --- a/gui/ConsoleWindow.h +++ b/gui/ConsoleWindow.h @@ -17,7 +17,7 @@ #include <QMainWindow> #include <QSystemTrayIcon> -#include "logic/MinecraftProcess.h" +#include "logic/BaseProcess.h" class QPushButton; class PageContainer; @@ -26,7 +26,7 @@ class ConsoleWindow : public QMainWindow Q_OBJECT public: - explicit ConsoleWindow(MinecraftProcess *proc, QWidget *parent = 0); + explicit ConsoleWindow(BaseProcess *proc, QWidget *parent = 0); virtual ~ConsoleWindow(); /** @@ -56,7 +56,7 @@ protected: void closeEvent(QCloseEvent *); private: - MinecraftProcess *m_proc = nullptr; + BaseProcess *m_proc = nullptr; bool m_mayclose = true; QSystemTrayIcon *m_trayIcon = nullptr; PageContainer *m_container = nullptr; diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index b28d2d9b..5ef4c09a 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -381,7 +381,7 @@ namespace Ui { #include "logic/BaseInstance.h" #include "logic/OneSixInstance.h" #include "logic/InstanceFactory.h" -#include "logic/MinecraftProcess.h" +#include "logic/BaseProcess.h" #include "logic/OneSixUpdate.h" #include "logic/java/JavaUtils.h" #include "logic/NagUtils.h" @@ -403,6 +403,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); + // initialize the news checker + m_newsChecker.reset(new NewsChecker(BuildConfig.NEWS_RSS_URL)); + QString winTitle = QString("MultiMC 5 - Version %1").arg(BuildConfig.printableVersionString()); if (!BuildConfig.BUILD_PLATFORM.isEmpty()) @@ -443,7 +446,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi ui->newsToolBar->insertWidget(ui->actionMoreNews, newsLabel); QObject::connect(newsLabel, &QAbstractButton::clicked, this, &MainWindow::newsButtonClicked); - QObject::connect(MMC->newsChecker().get(), &NewsChecker::newsLoaded, this, + QObject::connect(m_newsChecker.get(), &NewsChecker::newsLoaded, this, &MainWindow::updateNewsLabel); updateNewsLabel(); } @@ -606,7 +609,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi MMC->lwjgllist()->loadList(); } - MMC->newsChecker()->reloadNews(); + m_newsChecker->reloadNews(); updateNewsLabel(); // set up the updater object. @@ -888,15 +891,14 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *ev) void MainWindow::updateNewsLabel() { - auto newsChecker = MMC->newsChecker(); - if (newsChecker->isLoadingNews()) + if (m_newsChecker->isLoadingNews()) { newsLabel->setText(tr("Loading news...")); newsLabel->setEnabled(false); } else { - QList<NewsEntryPtr> entries = newsChecker->getNewsEntries(); + QList<NewsEntryPtr> entries = m_newsChecker->getNewsEntries(); if (entries.length() > 0) { newsLabel->setText(entries[0]->title); @@ -1041,7 +1043,9 @@ static QFileInfo findRecursive(const QString &dir, const QString &name) } return QFileInfo(); } -void MainWindow::on_actionAddInstance_triggered() + +// FIXME: eliminate, should not be needed +void MainWindow::waitForMinecraftVersions() { if (!MMC->minecraftlist()->isLoaded() && m_versionLoadTask && m_versionLoadTask->isRunning()) @@ -1051,121 +1055,130 @@ void MainWindow::on_actionAddInstance_triggered() waitLoop.connect(m_versionLoadTask, SIGNAL(succeeded()), SLOT(quit())); waitLoop.exec(); } +} - NewInstanceDialog newInstDlg(this); - if (!newInstDlg.exec()) - return; - - MMC->settings()->set("LastUsedGroupForNewInstance", newInstDlg.instGroup()); - +void MainWindow::instanceFromZipPack(QString instName, QString instGroup, QString instIcon, QUrl url) +{ InstancePtr newInstance; QString instancesDir = MMC->settings()->get("InstanceDir").toString(); - QString instDirName = DirNameFromString(newInstDlg.instName(), instancesDir); + QString instDirName = DirNameFromString(instName, instancesDir); QString instDir = PathCombine(instancesDir, instDirName); auto &loader = InstanceFactory::get(); - - const QUrl modpackUrl = newInstDlg.modpackUrl(); - if (modpackUrl.isValid()) + QString archivePath; + if (url.isLocalFile()) { - QString archivePath; - if (modpackUrl.isLocalFile()) - { - archivePath = modpackUrl.toLocalFile(); - } - else - { - const QString path = modpackUrl.host() + '/' + modpackUrl.path(); - auto entry = MMC->metacache()->resolveEntry("general", path); - CacheDownloadPtr dl = CacheDownload::make(modpackUrl, entry); - NetJob job(tr("Modpack download")); - job.addNetAction(dl); - - // FIXME: possibly causes endless loop problems - ProgressDialog dlDialog(this); - if (dlDialog.exec(&job) != QDialog::Accepted) - { - return; - } - - archivePath = entry->getFullPath(); - } - + archivePath = url.toLocalFile(); + } + else + { + const QString path = url.host() + '/' + url.path(); + auto entry = MMC->metacache()->resolveEntry("general", path); + CacheDownloadPtr dl = CacheDownload::make(url, entry); + NetJob job(tr("Modpack download")); + job.addNetAction(dl); - QTemporaryDir extractTmpDir; - QDir extractDir(extractTmpDir.path()); - QLOG_INFO() << "Attempting to create instance from" << archivePath; - if (JlCompress::extractDir(archivePath, extractDir.absolutePath()).isEmpty()) - { - CustomMessageBox::selectable(this, tr("Error"), - tr("Failed to extract modpack"), QMessageBox::Warning)->show(); - return; - } - const QFileInfo instanceCfgFile = findRecursive(extractDir.absolutePath(), "instance.cfg"); - if (!instanceCfgFile.isFile() || !instanceCfgFile.exists()) + // FIXME: possibly causes endless loop problems + ProgressDialog dlDialog(this); + if (dlDialog.exec(&job) != QDialog::Accepted) { - CustomMessageBox::selectable(this, tr("Error"), tr("Archive does not contain instance.cfg"))->show(); - return; - } - if (!copyPath(instanceCfgFile.absoluteDir().absolutePath(), instDir)) - { - CustomMessageBox::selectable(this, tr("Error"), tr("Unable to copy instance"))->show(); return; } + archivePath = entry->getFullPath(); + } - auto error = loader.loadInstance(newInstance, instDir); - QString errorMsg = tr("Failed to load instance %1: ").arg(instDirName); - switch (error) - { - case InstanceFactory::UnknownLoadError: - errorMsg += tr("Unkown error"); - CustomMessageBox::selectable(this, tr("Error"), errorMsg, QMessageBox::Warning)->show(); - return; - case InstanceFactory::NotAnInstance: - errorMsg += tr("Not an instance"); - CustomMessageBox::selectable(this, tr("Error"), errorMsg, QMessageBox::Warning)->show(); - return; - } + QTemporaryDir extractTmpDir; + QDir extractDir(extractTmpDir.path()); + QLOG_INFO() << "Attempting to create instance from" << archivePath; + if (JlCompress::extractDir(archivePath, extractDir.absolutePath()).isEmpty()) + { + CustomMessageBox::selectable(this, tr("Error"), + tr("Failed to extract modpack"), QMessageBox::Warning)->show(); + return; } - else + const QFileInfo instanceCfgFile = findRecursive(extractDir.absolutePath(), "instance.cfg"); + if (!instanceCfgFile.isFile() || !instanceCfgFile.exists()) { - auto error = loader.createInstance(newInstance, newInstDlg.selectedVersion(), instDir); - QString errorMsg = tr("Failed to create instance %1: ").arg(instDirName); - switch (error) - { - case InstanceFactory::NoCreateError: break; - case InstanceFactory::InstExists: - { - errorMsg += tr("An instance with the given directory name already exists."); - CustomMessageBox::selectable(this, tr("Error"), errorMsg, QMessageBox::Warning)->show(); - return; - } + CustomMessageBox::selectable(this, tr("Error"), tr("Archive does not contain instance.cfg"))->show(); + return; + } + if (!copyPath(instanceCfgFile.absoluteDir().absolutePath(), instDir)) + { + CustomMessageBox::selectable(this, tr("Error"), tr("Unable to copy instance"))->show(); + return; + } - case InstanceFactory::CantCreateDir: - { - errorMsg += tr("Failed to create the instance directory."); - CustomMessageBox::selectable(this, tr("Error"), errorMsg, QMessageBox::Warning)->show(); - return; - } + auto error = loader.loadInstance(newInstance, instDir); + QString errorMsg = tr("Failed to load instance %1: ").arg(instDirName); + switch (error) + { + case InstanceFactory::UnknownLoadError: + errorMsg += tr("Unkown error"); + CustomMessageBox::selectable(this, tr("Error"), errorMsg, QMessageBox::Warning)->show(); + return; + case InstanceFactory::NotAnInstance: + errorMsg += tr("Not an instance"); + CustomMessageBox::selectable(this, tr("Error"), errorMsg, QMessageBox::Warning)->show(); + return; + } - default: - { - errorMsg += tr("Unknown instance loader error %1").arg(error); - CustomMessageBox::selectable(this, tr("Error"), errorMsg, QMessageBox::Warning)->show(); - return; - } - } + newInstance->setName(instName); + newInstance->setIconKey(instIcon); + newInstance->setGroupInitial(instGroup); + MMC->instances()->add(InstancePtr(newInstance)); + MMC->instances()->saveGroupList(); + + finalizeInstance(newInstance); +} + +void MainWindow::instanceFromVersion(QString instName, QString instGroup, QString instIcon, BaseVersionPtr version) +{ + InstancePtr newInstance; + + QString instancesDir = MMC->settings()->get("InstanceDir").toString(); + QString instDirName = DirNameFromString(instName, instancesDir); + QString instDir = PathCombine(instancesDir, instDirName); + auto &loader = InstanceFactory::get(); + auto error = loader.createInstance(newInstance, version, instDir); + QString errorMsg = tr("Failed to create instance %1: ").arg(instDirName); + switch (error) + { + case InstanceFactory::NoCreateError: break; + case InstanceFactory::InstExists: + { + errorMsg += tr("An instance with the given directory name already exists."); + CustomMessageBox::selectable(this, tr("Error"), errorMsg, QMessageBox::Warning)->show(); + return; + } + + case InstanceFactory::CantCreateDir: + { + errorMsg += tr("Failed to create the instance directory."); + CustomMessageBox::selectable(this, tr("Error"), errorMsg, QMessageBox::Warning)->show(); + return; } - newInstance->setName(newInstDlg.instName()); - newInstance->setIconKey(newInstDlg.iconKey()); - newInstance->setGroupInitial(newInstDlg.instGroup()); + default: + { + errorMsg += tr("Unknown instance loader error %1").arg(error); + CustomMessageBox::selectable(this, tr("Error"), errorMsg, QMessageBox::Warning)->show(); + return; + } + } + newInstance->setName(instName); + newInstance->setIconKey(instIcon); + newInstance->setGroupInitial(instGroup); MMC->instances()->add(InstancePtr(newInstance)); + MMC->instances()->saveGroupList(); + finalizeInstance(newInstance); +} +void MainWindow::finalizeInstance(InstancePtr inst) +{ if (MMC->accounts()->anyAccountIsValid()) { ProgressDialog loadDialog(this); - auto update = newInstance->doUpdate(); + auto update = inst->doUpdate(); connect(update.get(), &Task::failed, [this](QString reason) { QString error = QString("Instance load failed: %1").arg(reason); @@ -1184,6 +1197,30 @@ void MainWindow::on_actionAddInstance_triggered() } } + +void MainWindow::on_actionAddInstance_triggered() +{ + waitForMinecraftVersions(); + + NewInstanceDialog newInstDlg(this); + if (!newInstDlg.exec()) + return; + + MMC->settings()->set("LastUsedGroupForNewInstance", newInstDlg.instGroup()); + + const QUrl modpackUrl = newInstDlg.modpackUrl(); + + + if (modpackUrl.isValid()) + { + instanceFromZipPack(newInstDlg.instName(), newInstDlg.instGroup(), newInstDlg.iconKey(), modpackUrl); + } + else + { + instanceFromVersion(newInstDlg.instName(), newInstDlg.instGroup(), newInstDlg.iconKey(), newInstDlg.selectedVersion()); + } +} + void MainWindow::on_actionCopyInstance_triggered() { if (!m_selectedInstance) @@ -1389,7 +1426,7 @@ void MainWindow::on_actionMoreNews_triggered() void MainWindow::newsButtonClicked() { - QList<NewsEntryPtr> entries = MMC->newsChecker()->getNewsEntries(); + QList<NewsEntryPtr> entries = m_newsChecker->getNewsEntries(); if (entries.count() > 0) openWebPage(QUrl(entries[0]->link)); else @@ -1686,19 +1723,15 @@ void MainWindow::launchInstance(InstancePtr instance, AuthSessionPtr session, QString launchScript; - if (!instance->prepareForLaunch(session, launchScript)) + BaseProcess *proc = instance->prepareForLaunch(session); + if (!proc) return; - MinecraftProcess *proc = new MinecraftProcess(instance); - proc->setLaunchScript(launchScript); - proc->setWorkdir(instance->minecraftRoot()); - this->hide(); console = new ConsoleWindow(proc); connect(console, SIGNAL(isClosing()), this, SLOT(instanceEnded())); - proc->setLogin(session); proc->arm(); if (profiler) @@ -1725,7 +1758,7 @@ void MainWindow::launchInstance(InstancePtr instance, AuthSessionPtr session, { dialog.accept(); QMessageBox msg; - msg.setText(tr("The launch of Minecraft itself is delayed until you press the " + msg.setText(tr("The game launch is delayed until you press the " "button. This is the right time to setup the profiler, as the " "profiler server is running now.\n\n%1").arg(message)); msg.setWindowTitle(tr("Waiting")); @@ -1837,32 +1870,6 @@ void MainWindow::instanceEnded() this->show(); } -void MainWindow::checkMigrateLegacyAssets() -{ - int legacyAssets = AssetsUtils::findLegacyAssets(); - if (legacyAssets > 0) - { - ProgressDialog migrateDlg(this); - AssetsMigrateTask migrateTask(legacyAssets, &migrateDlg); - { - ThreadTask threadTask(&migrateTask); - - if (migrateDlg.exec(&threadTask)) - { - QLOG_INFO() << "Assets migration task completed successfully"; - } - else - { - QLOG_INFO() << "Assets migration task reported failure"; - } - } - } - else - { - QLOG_INFO() << "Didn't find any legacy assets to migrate"; - } -} - void MainWindow::checkSetDefaultJava() { const QString javaHack = "IntelHack"; diff --git a/gui/MainWindow.h b/gui/MainWindow.h index 4d417f15..4e8e8f35 100644 --- a/gui/MainWindow.h +++ b/gui/MainWindow.h @@ -24,6 +24,7 @@ #include "logic/auth/MojangAccount.h" #include "logic/net/NetJob.h" +class NewsChecker; class QToolButton; class LabeledToolButton; class QLabel; @@ -51,7 +52,6 @@ public: void openWebPage(QUrl url); void checkSetDefaultJava(); - void checkMigrateLegacyAssets(); void checkInstancePathForProblems(); private @@ -182,6 +182,11 @@ protected: void setSelectedInstanceById(const QString &id); + void waitForMinecraftVersions(); + void instanceFromVersion(QString instName, QString instGroup, QString instIcon, BaseVersionPtr version); + void instanceFromZipPack(QString instName, QString instGroup, QString instIcon, QUrl url); + void finalizeInstance(InstancePtr inst); + private: Ui::MainWindow *ui; class GroupView *view; @@ -194,6 +199,7 @@ private: QToolButton *newsLabel; std::shared_ptr<GenericPageProvider> m_globalSettingsProvider; + std::shared_ptr<NewsChecker> m_newsChecker; InstancePtr m_selectedInstance; QString m_currentInstIcon; diff --git a/gui/dialogs/AboutDialog.cpp b/gui/dialogs/AboutDialog.cpp index e15da142..ee08beea 100644 --- a/gui/dialogs/AboutDialog.cpp +++ b/gui/dialogs/AboutDialog.cpp @@ -99,7 +99,7 @@ AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AboutDia connect(ui->closeButton, SIGNAL(clicked()), SLOT(close())); - MMC->connect(ui->aboutQt, SIGNAL(clicked()), SLOT(aboutQt())); + connect(ui->aboutQt, &QPushButton::clicked, &QApplication::aboutQt); loadPatronList(); } diff --git a/gui/pages/LogPage.cpp b/gui/pages/LogPage.cpp index 957c2f72..4e9e4f52 100644 --- a/gui/pages/LogPage.cpp +++ b/gui/pages/LogPage.cpp @@ -7,10 +7,10 @@ #include <QScrollBar> #include <QShortcut> -#include "logic/MinecraftProcess.h" +#include "logic/BaseProcess.h" #include "gui/GuiUtil.h" -LogPage::LogPage(MinecraftProcess *proc, QWidget *parent) +LogPage::LogPage(BaseProcess *proc, QWidget *parent) : QWidget(parent), ui(new Ui::LogPage), m_process(proc) { ui->setupUi(this); diff --git a/gui/pages/LogPage.h b/gui/pages/LogPage.h index 7d073a53..3d5580dc 100644 --- a/gui/pages/LogPage.h +++ b/gui/pages/LogPage.h @@ -19,7 +19,7 @@ #include "logic/BaseInstance.h" #include "logic/net/NetJob.h" -#include "logic/MinecraftProcess.h" +#include "logic/BaseProcess.h" #include "BasePage.h" #include <MultiMC.h> @@ -36,7 +36,7 @@ class LogPage : public QWidget, public BasePage Q_OBJECT public: - explicit LogPage(MinecraftProcess *proc, QWidget *parent = 0); + explicit LogPage(BaseProcess *proc, QWidget *parent = 0); virtual ~LogPage(); virtual QString displayName() const override { @@ -78,7 +78,7 @@ private slots: private: Ui::LogPage *ui; - MinecraftProcess *m_process; + BaseProcess *m_process; int m_last_scroll_value = 0; bool m_scroll_active = true; int m_saved_offset = 0; diff --git a/gui/pages/ModFolderPage.cpp b/gui/pages/ModFolderPage.cpp index 5172aa1e..938ec421 100644 --- a/gui/pages/ModFolderPage.cpp +++ b/gui/pages/ModFolderPage.cpp @@ -30,7 +30,7 @@ #include "gui/dialogs/ModEditDialogCommon.h" #include "logic/ModList.h" #include "logic/Mod.h" -#include "logic/VersionFilterData.h" +#include "logic/minecraft/VersionFilterData.h" ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr<ModList> mods, QString id, QString iconName, QString displayName, QString helpPage, @@ -80,7 +80,7 @@ bool CoreModFolderPage::shouldDisplay() const auto inst = dynamic_cast<OneSixInstance *>(m_inst); if (!inst) return true; - auto version = inst->getFullVersion(); + auto version = inst->getMinecraftProfile(); if (!version) return true; if (version->m_releaseTime < g_VersionFilterData.legacyCutoffDate) diff --git a/gui/pages/OtherLogsPage.cpp b/gui/pages/OtherLogsPage.cpp index f12ff8a3..c9b0aa51 100644 --- a/gui/pages/OtherLogsPage.cpp +++ b/gui/pages/OtherLogsPage.cpp @@ -21,17 +21,17 @@ #include "gui/GuiUtil.h" #include "logic/RecursiveFileSystemWatcher.h" -#include "logic/BaseInstance.h" +#include <pathutils.h> -OtherLogsPage::OtherLogsPage(BaseInstance *instance, QWidget *parent) - : QWidget(parent), ui(new Ui::OtherLogsPage), m_instance(instance), +OtherLogsPage::OtherLogsPage(QString path, QWidget *parent) + : QWidget(parent), ui(new Ui::OtherLogsPage), m_path(path), m_watcher(new RecursiveFileSystemWatcher(this)) { ui->setupUi(this); ui->tabWidget->tabBar()->hide(); m_watcher->setFileExpression("(.*\\.log(\\.[0-9]*)?$)|(crash-.*\\.txt)"); - m_watcher->setRootDir(QDir::current().absoluteFilePath(m_instance->minecraftRoot())); + m_watcher->setRootDir(QDir::current().absoluteFilePath(m_path)); connect(m_watcher, &RecursiveFileSystemWatcher::filesChanged, this, &OtherLogsPage::populateSelectLogBox); @@ -76,7 +76,7 @@ void OtherLogsPage::on_selectLogBox_currentIndexChanged(const int index) file = ui->selectLogBox->itemText(index); } - if (file.isEmpty() || !QFile::exists(m_instance->minecraftRoot() + "/" + file)) + if (file.isEmpty() || !QFile::exists(PathCombine(m_path, file))) { m_currentFile = QString(); ui->text->clear(); @@ -92,7 +92,7 @@ void OtherLogsPage::on_selectLogBox_currentIndexChanged(const int index) void OtherLogsPage::on_btnReload_clicked() { - QFile file(m_instance->minecraftRoot() + "/" + m_currentFile); + QFile file(PathCombine(m_path, m_currentFile)); if (!file.open(QFile::ReadOnly)) { setControlsEnabled(false); @@ -132,7 +132,7 @@ void OtherLogsPage::on_btnDelete_clicked() { return; } - QFile file(m_instance->minecraftRoot() + "/" + m_currentFile); + QFile file(PathCombine(m_path, m_currentFile)); if (!file.remove()) { QMessageBox::critical(this, tr("Error"), tr("Unable to delete %1: %2") diff --git a/gui/pages/OtherLogsPage.h b/gui/pages/OtherLogsPage.h index 5777cb83..d6e4ec9f 100644 --- a/gui/pages/OtherLogsPage.h +++ b/gui/pages/OtherLogsPage.h @@ -27,14 +27,12 @@ class OtherLogsPage; class RecursiveFileSystemWatcher; -class BaseInstance; - class OtherLogsPage : public QWidget, public BasePage { Q_OBJECT public: - explicit OtherLogsPage(BaseInstance *instance, QWidget *parent = 0); + explicit OtherLogsPage(QString path, QWidget *parent = 0); ~OtherLogsPage(); QString id() const override @@ -66,7 +64,7 @@ private slots: private: Ui::OtherLogsPage *ui; - BaseInstance *m_instance; + QString m_path; RecursiveFileSystemWatcher *m_watcher; QString m_currentFile; diff --git a/gui/pages/ResourcePackPage.h b/gui/pages/ResourcePackPage.h index 1a9039ff..d79590df 100644 --- a/gui/pages/ResourcePackPage.h +++ b/gui/pages/ResourcePackPage.h @@ -4,7 +4,7 @@ class ResourcePackPage : public ModFolderPage { public: - explicit ResourcePackPage(BaseInstance *instance, QWidget *parent = 0) + explicit ResourcePackPage(MinecraftInstance *instance, QWidget *parent = 0) : ModFolderPage(instance, instance->resourcePackList(), "resourcepacks", "resourcepacks", tr("Resource packs"), "Resource-packs", parent) { diff --git a/gui/pages/ScreenshotsPage.cpp b/gui/pages/ScreenshotsPage.cpp index 1771a118..219a47ae 100644 --- a/gui/pages/ScreenshotsPage.cpp +++ b/gui/pages/ScreenshotsPage.cpp @@ -209,7 +209,7 @@ public: } }; -ScreenshotsPage::ScreenshotsPage(BaseInstance *instance, QWidget *parent) +ScreenshotsPage::ScreenshotsPage(QString path, QWidget *parent) : QWidget(parent), ui(new Ui::ScreenshotsPage) { m_model.reset(new QFileSystemModel()); @@ -219,7 +219,7 @@ ScreenshotsPage::ScreenshotsPage(BaseInstance *instance, QWidget *parent) m_model->setReadOnly(false); m_model->setNameFilters({"*.png"}); m_model->setNameFilterDisables(false); - m_folder = PathCombine(instance->minecraftRoot(), "screenshots"); + m_folder = path; m_valid = ensureFolderPathExists(m_folder); ui->setupUi(this); diff --git a/gui/pages/ScreenshotsPage.h b/gui/pages/ScreenshotsPage.h index 6be2a26d..08ffbf26 100644 --- a/gui/pages/ScreenshotsPage.h +++ b/gui/pages/ScreenshotsPage.h @@ -37,7 +37,7 @@ class ScreenshotsPage : public QWidget, public BasePage Q_OBJECT public: - explicit ScreenshotsPage(BaseInstance *instance, QWidget *parent = 0); + explicit ScreenshotsPage(QString path, QWidget *parent = 0); virtual ~ScreenshotsPage(); virtual void opened() override; diff --git a/gui/pages/TexturePackPage.h b/gui/pages/TexturePackPage.h index 7e663789..3c5c27d7 100644 --- a/gui/pages/TexturePackPage.h +++ b/gui/pages/TexturePackPage.h @@ -4,7 +4,7 @@ class TexturePackPage : public ModFolderPage { public: - explicit TexturePackPage(BaseInstance *instance, QWidget *parent = 0) + explicit TexturePackPage(MinecraftInstance *instance, QWidget *parent = 0) : ModFolderPage(instance, instance->texturePackList(), "texturepacks", "resourcepacks", tr("Texture packs"), "Texture-packs", parent) { diff --git a/gui/pages/VersionPage.cpp b/gui/pages/VersionPage.cpp index 554bf8a4..17869589 100644 --- a/gui/pages/VersionPage.cpp +++ b/gui/pages/VersionPage.cpp @@ -38,7 +38,7 @@ #include <QUrl> #include "logic/ModList.h" -#include "logic/minecraft/InstanceVersion.h" +#include "logic/minecraft/MinecraftProfile.h" #include "logic/EnabledItemFilter.h" #include "logic/forge/ForgeVersionList.h" #include "logic/forge/ForgeInstaller.h" @@ -65,7 +65,7 @@ VersionPage::VersionPage(OneSixInstance *inst, QWidget *parent) ui->setupUi(this); ui->tabWidget->tabBar()->hide(); - m_version = m_inst->getFullVersion(); + m_version = m_inst->getMinecraftProfile(); if (m_version) { main_model = new EnabledItemFilter(this); @@ -109,11 +109,11 @@ void VersionPage::disableVersionControls() ui->removeLibraryBtn->setEnabled(false); } -bool VersionPage::reloadInstanceVersion() +bool VersionPage::reloadMinecraftProfile() { try { - m_inst->reloadVersion(); + m_inst->reloadProfile(); return true; } catch (MMCError &e) @@ -132,7 +132,7 @@ bool VersionPage::reloadInstanceVersion() void VersionPage::on_reloadLibrariesBtn_clicked() { - reloadInstanceVersion(); + reloadMinecraftProfile(); } void VersionPage::on_removeLibraryBtn_clicked() @@ -202,7 +202,7 @@ void VersionPage::on_moveLibraryUpBtn_clicked() try { const int row = ui->libraryTreeView->selectionModel()->selectedRows().first().row(); - m_version->move(row, InstanceVersion::MoveUp); + m_version->move(row, MinecraftProfile::MoveUp); } catch (MMCError &e) { @@ -219,7 +219,7 @@ void VersionPage::on_moveLibraryDownBtn_clicked() try { const int row = ui->libraryTreeView->selectionModel()->selectedRows().first().row(); - m_version->move(row, InstanceVersion::MoveDown); + m_version->move(row, MinecraftProfile::MoveDown); } catch (MMCError &e) { @@ -244,7 +244,7 @@ void VersionPage::on_changeMCVersionBtn_clicked() return; } - if (m_inst->versionIsCustom()) + if (!m_version->isVanilla()) { auto result = CustomMessageBox::selectable( this, tr("Are you sure?"), @@ -256,7 +256,7 @@ void VersionPage::on_changeMCVersionBtn_clicked() if (result != QMessageBox::Ok) return; m_version->revertToVanilla(); - reloadInstanceVersion(); + reloadMinecraftProfile(); } m_inst->setIntendedVersionId(vselect.selectedVersion()->descriptor()); @@ -272,31 +272,6 @@ void VersionPage::on_changeMCVersionBtn_clicked() void VersionPage::on_forgeBtn_clicked() { - // FIXME: use actual model, not reloading. Move logic to model. - if (m_version->hasFtbPack()) - { - if (QMessageBox::question( - this, tr("Revert?"), - tr("This action will remove the FTB pack version patch. Continue?")) != - QMessageBox::Yes) - { - return; - } - m_version->removeFtbPack(); - reloadInstanceVersion(); - } - if (m_version->hasDeprecatedVersionFiles()) - { - if (QMessageBox::question(this, tr("Revert?"), - tr("This action will remove deprecated version files " - "(custom.json and version.json). Continue?")) != - QMessageBox::Yes) - { - return; - } - m_version->removeDeprecatedVersionFiles(); - reloadInstanceVersion(); - } VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this); vselect.setExactFilter(1, m_inst->currentVersionId()); vselect.setEmptyString(tr("No Forge versions are currently available for Minecraft ") + @@ -311,30 +286,6 @@ void VersionPage::on_forgeBtn_clicked() void VersionPage::on_liteloaderBtn_clicked() { - if (m_version->hasFtbPack()) - { - if (QMessageBox::question( - this, tr("Revert?"), - tr("This action will remove the FTB pack version patch. Continue?")) != - QMessageBox::Yes) - { - return; - } - m_version->removeFtbPack(); - reloadInstanceVersion(); - } - if (m_version->hasDeprecatedVersionFiles()) - { - if (QMessageBox::question(this, tr("Revert?"), - tr("This action will remove deprecated version files " - "(custom.json and version.json). Continue?")) != - QMessageBox::Yes) - { - return; - } - m_version->removeDeprecatedVersionFiles(); - reloadInstanceVersion(); - } VersionSelectDialog vselect(MMC->liteloaderlist().get(), tr("Select LiteLoader version"), this); vselect.setExactFilter(1, m_inst->currentVersionId()); @@ -364,8 +315,7 @@ void VersionPage::versionCurrent(const QModelIndex ¤t, const QModelIndex & ui->moveLibraryUpBtn->setEnabled(enabled); } QString selectedId = m_version->versionFileId(current.row()); - if (selectedId == "net.minecraft" || selectedId == "org.multimc.custom.json" || - selectedId == "org.multimc.version.json") + if (selectedId == "net.minecraft") { ui->changeMCVersionBtn->setEnabled(true); } diff --git a/gui/pages/VersionPage.h b/gui/pages/VersionPage.h index 1249f47e..f1b98dbe 100644 --- a/gui/pages/VersionPage.h +++ b/gui/pages/VersionPage.h @@ -67,11 +67,11 @@ slots: protected: /// FIXME: this shouldn't be necessary! - bool reloadInstanceVersion(); + bool reloadMinecraftProfile(); private: Ui::VersionPage *ui; - std::shared_ptr<InstanceVersion> m_version; + std::shared_ptr<MinecraftProfile> m_version; EnabledItemFilter *main_model; OneSixInstance *m_inst; NetJobPtr forgeJob; |