diff --git a/installwizard.cpp b/installwizard.cpp index 3b1be21..bb8dc2e 100644 --- a/installwizard.cpp +++ b/installwizard.cpp @@ -2,6 +2,8 @@ #include "ui_installwizard.h" #include "installwizard_installtype.h" #include "installwizard_locatepage.h" +#include "installwizard_patch.h" +#include "installwizard_finished.h" #include "settings.h" InstallWizard::InstallWizard(QWidget *parent, Settings *settings) : @@ -15,6 +17,9 @@ InstallWizard::InstallWizard(QWidget *parent, Settings *settings) : #ifdef Q_OS_WIN32 setPage(Page_Locate, new InstallWizard_LocatePage(this, settings)); #endif + + setPage(Page_Patch, new InstallWizard_Patch()); + setPage(Page_Finished, new InstallWizard_Finished()); } InstallWizard::~InstallWizard() diff --git a/installwizard.h b/installwizard.h index 5571dd3..772f7ca 100644 --- a/installwizard.h +++ b/installwizard.h @@ -20,7 +20,9 @@ public: enum { Page_InstallType, - Page_Locate + Page_Locate, + Page_Patch, + Page_Finished }; private slots: diff --git a/installwizard_finished.cpp b/installwizard_finished.cpp new file mode 100644 index 0000000..8a9fcbd --- /dev/null +++ b/installwizard_finished.cpp @@ -0,0 +1,14 @@ +#include "installwizard_finished.h" +#include "ui_installwizard_finished.h" + +InstallWizard_Finished::InstallWizard_Finished(QWidget *parent) : + QWizardPage(parent), + ui(new Ui::InstallWizard_Finished) +{ + ui->setupUi(this); +} + +InstallWizard_Finished::~InstallWizard_Finished() +{ + delete ui; +} diff --git a/installwizard_finished.h b/installwizard_finished.h new file mode 100644 index 0000000..be667cd --- /dev/null +++ b/installwizard_finished.h @@ -0,0 +1,22 @@ +#ifndef INSTALLWIZARD_FINISHED_H +#define INSTALLWIZARD_FINISHED_H + +#include + +namespace Ui { +class InstallWizard_Finished; +} + +class InstallWizard_Finished : public QWizardPage +{ + Q_OBJECT + +public: + explicit InstallWizard_Finished(QWidget *parent = 0); + ~InstallWizard_Finished(); + +private: + Ui::InstallWizard_Finished *ui; +}; + +#endif // INSTALLWIZARD_FINISHED_H diff --git a/installwizard_finished.ui b/installwizard_finished.ui new file mode 100644 index 0000000..1d033f3 --- /dev/null +++ b/installwizard_finished.ui @@ -0,0 +1,22 @@ + + + InstallWizard_Finished + + + + 0 + 0 + 400 + 300 + + + + WizardPage + + + Installation Complete + + + + + diff --git a/installwizard_locatepage.cpp b/installwizard_locatepage.cpp index 918cbb9..05e4390 100644 --- a/installwizard_locatepage.cpp +++ b/installwizard_locatepage.cpp @@ -1,13 +1,16 @@ +#include #include #include #include "installwizard_locatepage.h" #include "ui_installwizard_locatepage.h" +#include "installwizard.h" #include "settings.h" InstallWizard_LocatePage::InstallWizard_LocatePage(QWidget *parent, Settings *settings) : QWizardPage(parent), ui(new Ui::InstallWizard_LocatePage), - settings(settings) + settings(settings), + isQuake3PatchRequired(false) { ui->setupUi(this); registerField("quake3Path*", ui->txtLocation); @@ -46,5 +49,30 @@ bool InstallWizard_LocatePage::validatePage() return false; } + // Check if the Quake 3 installation needs patching. + const QString pakFilename(ui->txtLocation->text() + "/baseq3/pak1.pk3"); + QFile file(pakFilename); + + if (!file.open(QIODevice::ReadOnly)) + { + QMessageBox::warning(this, "Missing file", QString("Unable to open file '%1'").arg(pakFilename)); + return false; + } + + const QByteArray hash = QCryptographicHash::hash(file.readAll(), QCryptographicHash::Md5).toHex(); + isQuake3PatchRequired = (hash != "48911719d91be25adb957f2d325db4a0"); + return true; } + +int InstallWizard_LocatePage::nextId() const +{ + if (isQuake3PatchRequired) + { + return InstallWizard::Page_Patch; + } + else + { + return InstallWizard::Page_Finished; + } +} diff --git a/installwizard_locatepage.h b/installwizard_locatepage.h index fe52c84..c673354 100644 --- a/installwizard_locatepage.h +++ b/installwizard_locatepage.h @@ -23,10 +23,12 @@ private slots: protected: virtual bool validatePage(); + virtual int nextId() const; private: Ui::InstallWizard_LocatePage *ui; Settings *settings; + bool isQuake3PatchRequired; }; #endif // INSTALLWIZARD_LOCATEPAGE_H diff --git a/installwizard_patch.cpp b/installwizard_patch.cpp new file mode 100644 index 0000000..328c86f --- /dev/null +++ b/installwizard_patch.cpp @@ -0,0 +1,14 @@ +#include "installwizard_patch.h" +#include "ui_installwizard_patch.h" + +InstallWizard_Patch::InstallWizard_Patch(QWidget *parent) : + QWizardPage(parent), + ui(new Ui::InstallWizard_Patch) +{ + ui->setupUi(this); +} + +InstallWizard_Patch::~InstallWizard_Patch() +{ + delete ui; +} diff --git a/installwizard_patch.h b/installwizard_patch.h new file mode 100644 index 0000000..8c4e85f --- /dev/null +++ b/installwizard_patch.h @@ -0,0 +1,22 @@ +#ifndef INSTALLWIZARD_PATCH_H +#define INSTALLWIZARD_PATCH_H + +#include + +namespace Ui { +class InstallWizard_Patch; +} + +class InstallWizard_Patch : public QWizardPage +{ + Q_OBJECT + +public: + explicit InstallWizard_Patch(QWidget *parent = 0); + ~InstallWizard_Patch(); + +private: + Ui::InstallWizard_Patch *ui; +}; + +#endif // INSTALLWIZARD_PATCH_H diff --git a/installwizard_patch.ui b/installwizard_patch.ui new file mode 100644 index 0000000..8928c99 --- /dev/null +++ b/installwizard_patch.ui @@ -0,0 +1,22 @@ + + + InstallWizard_Patch + + + + 0 + 0 + 400 + 300 + + + + WizardPage + + + Installing Patch... + + + + + diff --git a/launch.pro b/launch.pro index dcba273..578d887 100644 --- a/launch.pro +++ b/launch.pro @@ -17,18 +17,24 @@ SOURCES += main.cpp\ settings.cpp \ installwizard.cpp \ installwizard_locatepage.cpp \ - installwizard_installtype.cpp + installwizard_installtype.cpp \ + installwizard_finished.cpp \ + installwizard_patch.cpp HEADERS += mainwindow.h \ settings.h \ installwizard.h \ installwizard_locatepage.h \ - installwizard_installtype.h + installwizard_installtype.h \ + installwizard_finished.h \ + installwizard_patch.h FORMS += mainwindow.ui \ installwizard.ui \ installwizard_locatepage.ui \ - installwizard_installtype.ui + installwizard_installtype.ui \ + installwizard_finished.ui \ + installwizard_patch.ui OTHER_FILES += \ README.md \