diff options
| author | Jeremy Rimpo <jeremy.rimpo@servermonkey.com> | 2021-12-25 00:59:12 -0600 |
|---|---|---|
| committer | Jeremy Rimpo <jeremy.rimpo@servermonkey.com> | 2023-09-21 17:27:17 -0500 |
| commit | 8f31a1ceec7de25ef8fdfcb52c039ad85a9124b3 (patch) | |
| tree | 00aebe1e34c68ef4ad19f3255c204173cefd7eb2 /src/mainwindow.cpp | |
| parent | 3243101eed11febbf6f4e410af3f7db3169ba205 (diff) | |
Category setup dialog for new instances
Diffstat (limited to 'src/mainwindow.cpp')
| -rw-r--r-- | src/mainwindow.cpp | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 0521a17c..3005ab8f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -423,8 +423,6 @@ MainWindow::MainWindow(Settings& settings, OrganizerCore& organizerCore, connect(CategoryFactory::instance(), SIGNAL(requestNexusCategories()), this, SLOT(requestNexusCategories())); - connect(CategoryFactory::instance(), SIGNAL(requestNexusCategories()), this, SLOT(requestNexusCategories())); - connect( NexusInterface::instance(&pluginContainer)->getAccessManager(), SIGNAL(credentialsReceived(const APIUserAccount&)), @@ -1287,6 +1285,28 @@ void MainWindow::showEvent(QShowEvent* event) gameSupportTriggered(); } + QMessageBox newCatDialog; + newCatDialog.setWindowTitle("Import Categories"); + newCatDialog.setText(tr("Please choose how to handle the default category setup.\n\n" + "If you've already connected to Nexus, you can automatically import Nexus categories for this game (if applicable). Otherwise, use the old Mod Organizer default category structure, or leave the categories blank.")); + QPushButton importBtn(tr("&Import Nexus Categories")); + connect(&importBtn, &QPushButton::clicked, this, &MainWindow::importCategories); + QPushButton defaultBtn(tr("Use &Default Categories")); + QPushButton cancelBtn(tr("Do &Nothing")); + if (NexusInterface::instance().getAccessManager()->validated()) { + newCatDialog.addButton(&importBtn, QMessageBox::ButtonRole::AcceptRole); + } + newCatDialog.addButton(&defaultBtn, QMessageBox::ButtonRole::AcceptRole); + newCatDialog.addButton(&cancelBtn, QMessageBox::ButtonRole::RejectRole); + newCatDialog.exec(); + disconnect(&importBtn, &QPushButton::clicked, this, &MainWindow::importCategories); + if (newCatDialog.clickedButton() == &cancelBtn) { + m_CategoryFactory->reset(); + } else if (newCatDialog.clickedButton() == &defaultBtn) { + m_CategoryFactory->loadCategories(); + } + m_CategoryFactory->saveCategories(); + m_OrganizerCore.settings().setFirstStart(false); } @@ -2392,6 +2412,13 @@ void MainWindow::modInstalled(const QString& modName) {m_OrganizerCore.modList()->index(index, 0)}); } +void MainWindow::importCategories(bool) +{ + NexusInterface& nexus = NexusInterface::instance(); + nexus.setPluginContainer(&m_OrganizerCore.pluginContainer()); + nexus.requestGameInfo(Settings::instance().game().plugin()->gameShortName(), this, QVariant(), QString()); +} + void MainWindow::showMessage(const QString& message) { MessageDialog::showMessage(message, this); @@ -4517,6 +4544,29 @@ void MainWindow::nxmDownloadURLs(QString, int, int, QVariant, QVariant resultDat m_OrganizerCore.settings().network().updateServers(servers); } +void MainWindow::nxmGameInfoAvailable(QString gameName, QVariant, QVariant resultData, int) +{ + QVariantMap result = resultData.toMap(); + QVariantList categories = result["categories"].toList(); + CategoryFactory* catFactory = CategoryFactory::instance(); + catFactory->reset(); + for (auto category : categories) { + auto catMap = category.toMap(); + std::vector<CategoryFactory::NexusCategory> nexusCat; + nexusCat.push_back( + CategoryFactory::NexusCategory( + catMap["name"].toString(), + catMap["category_id"].toInt() + ) + ); + catFactory->addCategory( + catMap["name"].toString(), + nexusCat, + 0 + ); + } +} + void MainWindow::nxmRequestFailed(QString gameName, int modID, int, QVariant, int, int errorCode, const QString& errorString) { |
