mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Added a warning when trying to install tribunal after bloodmoon
This commit is contained in:
parent
2ccf4d6112
commit
5024f1bf77
10 changed files with 99 additions and 38 deletions
|
@ -1,7 +1,9 @@
|
|||
#include "componentselectionpage.hpp"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPushButton>
|
||||
#include <QAbstractButton>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "mainwizard.hpp"
|
||||
|
||||
|
@ -51,7 +53,7 @@ void Wizard::ComponentSelectionPage::initializePage()
|
|||
{
|
||||
componentsList->clear();
|
||||
|
||||
QString path = field("installation.path").toString();
|
||||
QString path(field("installation.path").toString());
|
||||
|
||||
QListWidgetItem *morrowindItem = new QListWidgetItem(QLatin1String("Morrowind"));
|
||||
QListWidgetItem *tribunalItem = new QListWidgetItem(QLatin1String("Tribunal"));
|
||||
|
@ -72,7 +74,7 @@ void Wizard::ComponentSelectionPage::initializePage()
|
|||
componentsList->addItem(bloodmoonItem);
|
||||
} else {
|
||||
|
||||
if (mWizard->mInstallations[path]->hasMorrowind == true) {
|
||||
if (mWizard->mInstallations[path]->hasMorrowind) {
|
||||
morrowindItem->setText(tr("Morrowind\t\t(installed)"));
|
||||
morrowindItem->setFlags(morrowindItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable);
|
||||
morrowindItem->setData(Qt::CheckStateRole, Qt::Unchecked);
|
||||
|
@ -83,7 +85,7 @@ void Wizard::ComponentSelectionPage::initializePage()
|
|||
|
||||
componentsList->addItem(morrowindItem);
|
||||
|
||||
if (mWizard->mInstallations[path]->hasTribunal == true) {
|
||||
if (mWizard->mInstallations[path]->hasTribunal) {
|
||||
tribunalItem->setText(tr("Tribunal\t\t(installed)"));
|
||||
tribunalItem->setFlags(tribunalItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable);
|
||||
tribunalItem->setData(Qt::CheckStateRole, Qt::Unchecked);
|
||||
|
@ -94,7 +96,7 @@ void Wizard::ComponentSelectionPage::initializePage()
|
|||
|
||||
componentsList->addItem(tribunalItem);
|
||||
|
||||
if (mWizard->mInstallations[path]->hasBloodmoon == true) {
|
||||
if (mWizard->mInstallations[path]->hasBloodmoon) {
|
||||
bloodmoonItem->setText(tr("Bloodmoon\t\t(installed)"));
|
||||
bloodmoonItem->setFlags(bloodmoonItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable);
|
||||
bloodmoonItem->setData(Qt::CheckStateRole, Qt::Unchecked);
|
||||
|
@ -107,10 +109,55 @@ void Wizard::ComponentSelectionPage::initializePage()
|
|||
}
|
||||
}
|
||||
|
||||
bool Wizard::ComponentSelectionPage::validatePage()
|
||||
{
|
||||
QStringList components(field("installation.components").toStringList());
|
||||
QString path(field("installation.path").toString());
|
||||
|
||||
qDebug() << components << path << mWizard->mInstallations[path];
|
||||
|
||||
if (field("installation.new").toBool() == false) {
|
||||
if (components.contains(QLatin1String("Tribunal")) && !components.contains(QLatin1String("Bloodmoon")))
|
||||
{
|
||||
if (mWizard->mInstallations[path]->hasBloodmoon)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("About to install Tribunal after Bloodmoon"));
|
||||
msgBox.setIcon(QMessageBox::Information);
|
||||
msgBox.setStandardButtons(QMessageBox::Cancel);
|
||||
msgBox.setText(tr("<html><head/><body><p><b>You are about to install Tribunal</b></p> \
|
||||
<p>Bloodmoon is already installed on your computer.</p> \
|
||||
<p>However, it is recommended that you install Tribunal before Bloodmoon.</p> \
|
||||
<p>Would you like to re-install Bloodmoon?</p></body></html>"));
|
||||
|
||||
QAbstractButton *reinstallButton = msgBox.addButton(tr("Re-install &Bloodmoon"), QMessageBox::ActionRole);
|
||||
msgBox.exec();
|
||||
|
||||
|
||||
if (msgBox.clickedButton() == reinstallButton) {
|
||||
// Force reinstallation
|
||||
mWizard->mInstallations[path]->hasBloodmoon = false;
|
||||
QList<QListWidgetItem*> items = componentsList->findItems(QLatin1String("Bloodmoon"), Qt::MatchStartsWith);
|
||||
|
||||
foreach (QListWidgetItem *item, items) {
|
||||
item->setText(QLatin1String("Bloodmoon"));
|
||||
item->setCheckState(Qt::Checked);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int Wizard::ComponentSelectionPage::nextId() const
|
||||
{
|
||||
if (isCommitPage())
|
||||
if (isCommitPage()) {
|
||||
return MainWizard::Page_Installation;
|
||||
|
||||
return MainWizard::Page_Import;
|
||||
} else {
|
||||
return MainWizard::Page_Import;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace Wizard
|
|||
ComponentSelectionPage(MainWizard *wizard);
|
||||
|
||||
int nextId() const;
|
||||
virtual bool validatePage();
|
||||
|
||||
private slots:
|
||||
void updateButton(QListWidgetItem *item);
|
||||
|
|
|
@ -57,7 +57,7 @@ void Wizard::ExistingInstallationPage::textChanged(const QString &text)
|
|||
// Set the installation path manually, as registerField doesn't work
|
||||
// Because it doesn't accept two widgets operating on a single field
|
||||
if (!text.isEmpty())
|
||||
mWizard->setField("installation.path", text);
|
||||
mWizard->setField(QLatin1String("installation.path"), text);
|
||||
}
|
||||
|
||||
void Wizard::ExistingInstallationPage::initializePage()
|
||||
|
@ -135,7 +135,7 @@ int Wizard::ExistingInstallationPage::nextId() const
|
|||
QString path(field("installation.path").toString());
|
||||
|
||||
if (path.isEmpty())
|
||||
return MainWizard::Page_ComponentSelection;
|
||||
return MainWizard::Page_LanguageSelection;
|
||||
|
||||
if (mWizard->mInstallations[path]->hasMorrowind == true &&
|
||||
mWizard->mInstallations[path]->hasTribunal == true &&
|
||||
|
@ -143,6 +143,6 @@ int Wizard::ExistingInstallationPage::nextId() const
|
|||
{
|
||||
return MainWizard::Page_Import;
|
||||
} else {
|
||||
return MainWizard::Page_ComponentSelection;
|
||||
return MainWizard::Page_LanguageSelection;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,9 +138,23 @@ void Wizard::InstallationPage::startInstallation()
|
|||
|
||||
void Wizard::InstallationPage::showFileDialog(Wizard::Component component)
|
||||
{
|
||||
QString name;
|
||||
switch (component) {
|
||||
|
||||
case Wizard::Component_Morrowind:
|
||||
name = QLatin1String("Morrowind");
|
||||
break;
|
||||
case Wizard::Component_Tribunal:
|
||||
name = QLatin1String("Tribunal");
|
||||
break;
|
||||
case Wizard::Component_Bloodmoon:
|
||||
name = QLatin1String("Bloodmoon");
|
||||
break;
|
||||
}
|
||||
|
||||
QString fileName = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr("Select installation file"),
|
||||
tr("Select %1 installation file").arg(name),
|
||||
QDir::rootPath(),
|
||||
tr("InstallShield header files (*.hdr)"));
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ void Wizard::InstallationTargetPage::on_browseButton_clicked()
|
|||
QString selectedPath = QFileDialog::getExistingDirectory(
|
||||
this,
|
||||
tr("Select where to install Morrowind"),
|
||||
QDir::currentPath(),
|
||||
QDir::homePath(),
|
||||
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
|
||||
qDebug() << selectedPath;
|
||||
|
@ -49,5 +49,5 @@ void Wizard::InstallationTargetPage::on_browseButton_clicked()
|
|||
|
||||
int Wizard::InstallationTargetPage::nextId() const
|
||||
{
|
||||
return MainWizard::Page_ComponentSelection;
|
||||
return MainWizard::Page_LanguageSelection;
|
||||
}
|
||||
|
|
|
@ -27,8 +27,5 @@ void Wizard::LanguageSelectionPage::initializePage()
|
|||
|
||||
int Wizard::LanguageSelectionPage::nextId() const
|
||||
{
|
||||
if (field("installation.new").toBool() == true)
|
||||
return MainWizard::Page_InstallationTarget;
|
||||
|
||||
return MainWizard::Page_ExistingInstallation;
|
||||
return MainWizard::Page_ComponentSelection;
|
||||
}
|
||||
|
|
|
@ -73,14 +73,10 @@ void Wizard::MainWizard::setupInstallations()
|
|||
file.close();
|
||||
}
|
||||
|
||||
// Check if the paths actually contain data files
|
||||
// Check if the paths actually contains a Morrowind installation
|
||||
foreach (const QString path, mGameSettings.getDataDirs()) {
|
||||
QDir dir(path);
|
||||
QStringList filters;
|
||||
filters << "*.esp" << "*.esm" << "*.omwgame" << "*.omwaddon";
|
||||
|
||||
// Add to Wizard installations
|
||||
if (!dir.entryList(filters).isEmpty())
|
||||
if (findFiles(QLatin1String("Morrowind"), path))
|
||||
addInstallation(path);
|
||||
}
|
||||
|
||||
|
@ -112,8 +108,10 @@ void Wizard::MainWizard::addInstallation(const QString &path)
|
|||
mInstallations.insert(QDir::toNativeSeparators(path), install);
|
||||
|
||||
// Add it to the openmw.cfg too
|
||||
mGameSettings.setMultiValue(QString("data"), path);
|
||||
mGameSettings.addDataDir(path);
|
||||
if (!mGameSettings.getDataDirs().contains(path)) {
|
||||
mGameSettings.setMultiValue(QString("data"), path);
|
||||
mGameSettings.addDataDir(path);
|
||||
}
|
||||
}
|
||||
|
||||
void Wizard::MainWizard::setupPages()
|
||||
|
@ -168,8 +166,7 @@ bool Wizard::MainWizard::findFiles(const QString &name, const QString &path)
|
|||
return false;
|
||||
|
||||
// TODO: add MIME handling to make sure the files are real
|
||||
if (dir.exists(name + QLatin1String(".esm")) && dir.exists(name + QLatin1String(".bsa")))
|
||||
{
|
||||
if (dir.exists(name + QLatin1String(".esm")) && dir.exists(name + QLatin1String(".bsa"))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
@ -13,5 +13,9 @@ Wizard::MethodSelectionPage::MethodSelectionPage(MainWizard *wizard) :
|
|||
|
||||
int Wizard::MethodSelectionPage::nextId() const
|
||||
{
|
||||
return MainWizard::Page_LanguageSelection;
|
||||
if (field("installation.new").toBool() == true) {
|
||||
return MainWizard::Page_InstallationTarget;
|
||||
} else {
|
||||
return MainWizard::Page_ExistingInstallation;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,15 +10,9 @@ ComponentListWidget::ComponentListWidget(QWidget *parent) :
|
|||
|
||||
connect(this, SIGNAL(itemChanged(QListWidgetItem *)),
|
||||
this, SLOT(updateCheckedItems(QListWidgetItem *)));
|
||||
}
|
||||
|
||||
void ComponentListWidget::addItem(QListWidgetItem *item)
|
||||
{
|
||||
// The model does not emit a dataChanged signal when items are added
|
||||
// So we need to update manually
|
||||
QListWidget::insertItem(count(), item);
|
||||
updateCheckedItems(item);
|
||||
|
||||
connect(model(), SIGNAL(rowsInserted(QModelIndex, int, int)),
|
||||
this, SLOT(updateCheckedItems(QModelIndex, int, int)));
|
||||
}
|
||||
|
||||
QStringList ComponentListWidget::checkedItems()
|
||||
|
@ -27,8 +21,16 @@ QStringList ComponentListWidget::checkedItems()
|
|||
return mCheckedItems;
|
||||
}
|
||||
|
||||
void ComponentListWidget::updateCheckedItems(const QModelIndex &index, int start, int end)
|
||||
{
|
||||
updateCheckedItems(item(start));
|
||||
}
|
||||
|
||||
void ComponentListWidget::updateCheckedItems(QListWidgetItem *item)
|
||||
{
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
QString text = item->text();
|
||||
|
||||
if (item->checkState() == Qt::Checked) {
|
||||
|
|
|
@ -15,13 +15,12 @@ public:
|
|||
QStringList mCheckedItems;
|
||||
QStringList checkedItems();
|
||||
|
||||
void addItem(QListWidgetItem *item);
|
||||
|
||||
signals:
|
||||
void checkedItemsChanged(const QStringList &items);
|
||||
|
||||
private slots:
|
||||
void updateCheckedItems(QListWidgetItem *item);
|
||||
void updateCheckedItems(const QModelIndex &index, int start, int end);
|
||||
};
|
||||
|
||||
#endif // COMPONENTLISTWIDGET_HPP
|
||||
|
|
Loading…
Reference in a new issue