Added a warning when trying to install tribunal after bloodmoon

loadfix
pvdk 11 years ago
parent 2ccf4d6112
commit 5024f1bf77

@ -1,7 +1,9 @@
#include "componentselectionpage.hpp" #include "componentselectionpage.hpp"
#include <QDebug> #include <QDebug>
#include <QPushButton>
#include <QAbstractButton> #include <QAbstractButton>
#include <QMessageBox>
#include "mainwizard.hpp" #include "mainwizard.hpp"
@ -51,7 +53,7 @@ void Wizard::ComponentSelectionPage::initializePage()
{ {
componentsList->clear(); componentsList->clear();
QString path = field("installation.path").toString(); QString path(field("installation.path").toString());
QListWidgetItem *morrowindItem = new QListWidgetItem(QLatin1String("Morrowind")); QListWidgetItem *morrowindItem = new QListWidgetItem(QLatin1String("Morrowind"));
QListWidgetItem *tribunalItem = new QListWidgetItem(QLatin1String("Tribunal")); QListWidgetItem *tribunalItem = new QListWidgetItem(QLatin1String("Tribunal"));
@ -72,7 +74,7 @@ void Wizard::ComponentSelectionPage::initializePage()
componentsList->addItem(bloodmoonItem); componentsList->addItem(bloodmoonItem);
} else { } else {
if (mWizard->mInstallations[path]->hasMorrowind == true) { if (mWizard->mInstallations[path]->hasMorrowind) {
morrowindItem->setText(tr("Morrowind\t\t(installed)")); morrowindItem->setText(tr("Morrowind\t\t(installed)"));
morrowindItem->setFlags(morrowindItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable); morrowindItem->setFlags(morrowindItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable);
morrowindItem->setData(Qt::CheckStateRole, Qt::Unchecked); morrowindItem->setData(Qt::CheckStateRole, Qt::Unchecked);
@ -83,7 +85,7 @@ void Wizard::ComponentSelectionPage::initializePage()
componentsList->addItem(morrowindItem); componentsList->addItem(morrowindItem);
if (mWizard->mInstallations[path]->hasTribunal == true) { if (mWizard->mInstallations[path]->hasTribunal) {
tribunalItem->setText(tr("Tribunal\t\t(installed)")); tribunalItem->setText(tr("Tribunal\t\t(installed)"));
tribunalItem->setFlags(tribunalItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable); tribunalItem->setFlags(tribunalItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable);
tribunalItem->setData(Qt::CheckStateRole, Qt::Unchecked); tribunalItem->setData(Qt::CheckStateRole, Qt::Unchecked);
@ -94,7 +96,7 @@ void Wizard::ComponentSelectionPage::initializePage()
componentsList->addItem(tribunalItem); componentsList->addItem(tribunalItem);
if (mWizard->mInstallations[path]->hasBloodmoon == true) { if (mWizard->mInstallations[path]->hasBloodmoon) {
bloodmoonItem->setText(tr("Bloodmoon\t\t(installed)")); bloodmoonItem->setText(tr("Bloodmoon\t\t(installed)"));
bloodmoonItem->setFlags(bloodmoonItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable); bloodmoonItem->setFlags(bloodmoonItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable);
bloodmoonItem->setData(Qt::CheckStateRole, Qt::Unchecked); 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 int Wizard::ComponentSelectionPage::nextId() const
{ {
if (isCommitPage()) if (isCommitPage()) {
return MainWizard::Page_Installation; return MainWizard::Page_Installation;
} else {
return MainWizard::Page_Import; return MainWizard::Page_Import;
}
} }

@ -16,6 +16,7 @@ namespace Wizard
ComponentSelectionPage(MainWizard *wizard); ComponentSelectionPage(MainWizard *wizard);
int nextId() const; int nextId() const;
virtual bool validatePage();
private slots: private slots:
void updateButton(QListWidgetItem *item); 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 // Set the installation path manually, as registerField doesn't work
// Because it doesn't accept two widgets operating on a single field // Because it doesn't accept two widgets operating on a single field
if (!text.isEmpty()) if (!text.isEmpty())
mWizard->setField("installation.path", text); mWizard->setField(QLatin1String("installation.path"), text);
} }
void Wizard::ExistingInstallationPage::initializePage() void Wizard::ExistingInstallationPage::initializePage()
@ -135,7 +135,7 @@ int Wizard::ExistingInstallationPage::nextId() const
QString path(field("installation.path").toString()); QString path(field("installation.path").toString());
if (path.isEmpty()) if (path.isEmpty())
return MainWizard::Page_ComponentSelection; return MainWizard::Page_LanguageSelection;
if (mWizard->mInstallations[path]->hasMorrowind == true && if (mWizard->mInstallations[path]->hasMorrowind == true &&
mWizard->mInstallations[path]->hasTribunal == true && mWizard->mInstallations[path]->hasTribunal == true &&
@ -143,6 +143,6 @@ int Wizard::ExistingInstallationPage::nextId() const
{ {
return MainWizard::Page_Import; return MainWizard::Page_Import;
} else { } else {
return MainWizard::Page_ComponentSelection; return MainWizard::Page_LanguageSelection;
} }
} }

@ -138,9 +138,23 @@ void Wizard::InstallationPage::startInstallation()
void Wizard::InstallationPage::showFileDialog(Wizard::Component component) 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( QString fileName = QFileDialog::getOpenFileName(
this, this,
tr("Select installation file"), tr("Select %1 installation file").arg(name),
QDir::rootPath(), QDir::rootPath(),
tr("InstallShield header files (*.hdr)")); tr("InstallShield header files (*.hdr)"));

@ -34,7 +34,7 @@ void Wizard::InstallationTargetPage::on_browseButton_clicked()
QString selectedPath = QFileDialog::getExistingDirectory( QString selectedPath = QFileDialog::getExistingDirectory(
this, this,
tr("Select where to install Morrowind"), tr("Select where to install Morrowind"),
QDir::currentPath(), QDir::homePath(),
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
qDebug() << selectedPath; qDebug() << selectedPath;
@ -49,5 +49,5 @@ void Wizard::InstallationTargetPage::on_browseButton_clicked()
int Wizard::InstallationTargetPage::nextId() const 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 int Wizard::LanguageSelectionPage::nextId() const
{ {
if (field("installation.new").toBool() == true) return MainWizard::Page_ComponentSelection;
return MainWizard::Page_InstallationTarget;
return MainWizard::Page_ExistingInstallation;
} }

@ -73,14 +73,10 @@ void Wizard::MainWizard::setupInstallations()
file.close(); 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()) { foreach (const QString path, mGameSettings.getDataDirs()) {
QDir dir(path);
QStringList filters;
filters << "*.esp" << "*.esm" << "*.omwgame" << "*.omwaddon";
// Add to Wizard installations if (findFiles(QLatin1String("Morrowind"), path))
if (!dir.entryList(filters).isEmpty())
addInstallation(path); addInstallation(path);
} }
@ -112,8 +108,10 @@ void Wizard::MainWizard::addInstallation(const QString &path)
mInstallations.insert(QDir::toNativeSeparators(path), install); mInstallations.insert(QDir::toNativeSeparators(path), install);
// Add it to the openmw.cfg too // Add it to the openmw.cfg too
mGameSettings.setMultiValue(QString("data"), path); if (!mGameSettings.getDataDirs().contains(path)) {
mGameSettings.addDataDir(path); mGameSettings.setMultiValue(QString("data"), path);
mGameSettings.addDataDir(path);
}
} }
void Wizard::MainWizard::setupPages() void Wizard::MainWizard::setupPages()
@ -168,8 +166,7 @@ bool Wizard::MainWizard::findFiles(const QString &name, const QString &path)
return false; return false;
// TODO: add MIME handling to make sure the files are real // 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; return true;
} else { } else {
return false; return false;

@ -13,5 +13,9 @@ Wizard::MethodSelectionPage::MethodSelectionPage(MainWizard *wizard) :
int Wizard::MethodSelectionPage::nextId() const 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 *)), connect(this, SIGNAL(itemChanged(QListWidgetItem *)),
this, SLOT(updateCheckedItems(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() QStringList ComponentListWidget::checkedItems()
@ -27,8 +21,16 @@ QStringList ComponentListWidget::checkedItems()
return mCheckedItems; return mCheckedItems;
} }
void ComponentListWidget::updateCheckedItems(const QModelIndex &index, int start, int end)
{
updateCheckedItems(item(start));
}
void ComponentListWidget::updateCheckedItems(QListWidgetItem *item) void ComponentListWidget::updateCheckedItems(QListWidgetItem *item)
{ {
if (!item)
return;
QString text = item->text(); QString text = item->text();
if (item->checkState() == Qt::Checked) { if (item->checkState() == Qt::Checked) {

@ -15,13 +15,12 @@ public:
QStringList mCheckedItems; QStringList mCheckedItems;
QStringList checkedItems(); QStringList checkedItems();
void addItem(QListWidgetItem *item);
signals: signals:
void checkedItemsChanged(const QStringList &items); void checkedItemsChanged(const QStringList &items);
private slots: private slots:
void updateCheckedItems(QListWidgetItem *item); void updateCheckedItems(QListWidgetItem *item);
void updateCheckedItems(const QModelIndex &index, int start, int end);
}; };
#endif // COMPONENTLISTWIDGET_HPP #endif // COMPONENTLISTWIDGET_HPP

Loading…
Cancel
Save