mirror of
https://github.com/ioquake/launch.git
synced 2024-11-10 06:31:39 +00:00
Added a simple MD5 hash check to determine whether Q3A data is up to date. This determines how the install wizard selects the next page.
This commit is contained in:
parent
558d673ef0
commit
0e96fa145e
11 changed files with 164 additions and 5 deletions
|
@ -2,6 +2,8 @@
|
||||||
#include "ui_installwizard.h"
|
#include "ui_installwizard.h"
|
||||||
#include "installwizard_installtype.h"
|
#include "installwizard_installtype.h"
|
||||||
#include "installwizard_locatepage.h"
|
#include "installwizard_locatepage.h"
|
||||||
|
#include "installwizard_patch.h"
|
||||||
|
#include "installwizard_finished.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
InstallWizard::InstallWizard(QWidget *parent, Settings *settings) :
|
InstallWizard::InstallWizard(QWidget *parent, Settings *settings) :
|
||||||
|
@ -15,6 +17,9 @@ InstallWizard::InstallWizard(QWidget *parent, Settings *settings) :
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
setPage(Page_Locate, new InstallWizard_LocatePage(this, settings));
|
setPage(Page_Locate, new InstallWizard_LocatePage(this, settings));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
setPage(Page_Patch, new InstallWizard_Patch());
|
||||||
|
setPage(Page_Finished, new InstallWizard_Finished());
|
||||||
}
|
}
|
||||||
|
|
||||||
InstallWizard::~InstallWizard()
|
InstallWizard::~InstallWizard()
|
||||||
|
|
|
@ -20,7 +20,9 @@ public:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
Page_InstallType,
|
Page_InstallType,
|
||||||
Page_Locate
|
Page_Locate,
|
||||||
|
Page_Patch,
|
||||||
|
Page_Finished
|
||||||
};
|
};
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
14
installwizard_finished.cpp
Normal file
14
installwizard_finished.cpp
Normal file
|
@ -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;
|
||||||
|
}
|
22
installwizard_finished.h
Normal file
22
installwizard_finished.h
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef INSTALLWIZARD_FINISHED_H
|
||||||
|
#define INSTALLWIZARD_FINISHED_H
|
||||||
|
|
||||||
|
#include <QWizardPage>
|
||||||
|
|
||||||
|
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
|
22
installwizard_finished.ui
Normal file
22
installwizard_finished.ui
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>InstallWizard_Finished</class>
|
||||||
|
<widget class="QWizardPage" name="InstallWizard_Finished">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>WizardPage</string>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Installation Complete</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -1,13 +1,16 @@
|
||||||
|
#include <QCryptographicHash>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include "installwizard_locatepage.h"
|
#include "installwizard_locatepage.h"
|
||||||
#include "ui_installwizard_locatepage.h"
|
#include "ui_installwizard_locatepage.h"
|
||||||
|
#include "installwizard.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
InstallWizard_LocatePage::InstallWizard_LocatePage(QWidget *parent, Settings *settings) :
|
InstallWizard_LocatePage::InstallWizard_LocatePage(QWidget *parent, Settings *settings) :
|
||||||
QWizardPage(parent),
|
QWizardPage(parent),
|
||||||
ui(new Ui::InstallWizard_LocatePage),
|
ui(new Ui::InstallWizard_LocatePage),
|
||||||
settings(settings)
|
settings(settings),
|
||||||
|
isQuake3PatchRequired(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
registerField("quake3Path*", ui->txtLocation);
|
registerField("quake3Path*", ui->txtLocation);
|
||||||
|
@ -46,5 +49,30 @@ bool InstallWizard_LocatePage::validatePage()
|
||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int InstallWizard_LocatePage::nextId() const
|
||||||
|
{
|
||||||
|
if (isQuake3PatchRequired)
|
||||||
|
{
|
||||||
|
return InstallWizard::Page_Patch;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return InstallWizard::Page_Finished;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -23,10 +23,12 @@ private slots:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool validatePage();
|
virtual bool validatePage();
|
||||||
|
virtual int nextId() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::InstallWizard_LocatePage *ui;
|
Ui::InstallWizard_LocatePage *ui;
|
||||||
Settings *settings;
|
Settings *settings;
|
||||||
|
bool isQuake3PatchRequired;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INSTALLWIZARD_LOCATEPAGE_H
|
#endif // INSTALLWIZARD_LOCATEPAGE_H
|
||||||
|
|
14
installwizard_patch.cpp
Normal file
14
installwizard_patch.cpp
Normal file
|
@ -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;
|
||||||
|
}
|
22
installwizard_patch.h
Normal file
22
installwizard_patch.h
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef INSTALLWIZARD_PATCH_H
|
||||||
|
#define INSTALLWIZARD_PATCH_H
|
||||||
|
|
||||||
|
#include <QWizardPage>
|
||||||
|
|
||||||
|
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
|
22
installwizard_patch.ui
Normal file
22
installwizard_patch.ui
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>InstallWizard_Patch</class>
|
||||||
|
<widget class="QWizardPage" name="InstallWizard_Patch">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>WizardPage</string>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Installing Patch...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
12
launch.pro
12
launch.pro
|
@ -17,18 +17,24 @@ SOURCES += main.cpp\
|
||||||
settings.cpp \
|
settings.cpp \
|
||||||
installwizard.cpp \
|
installwizard.cpp \
|
||||||
installwizard_locatepage.cpp \
|
installwizard_locatepage.cpp \
|
||||||
installwizard_installtype.cpp
|
installwizard_installtype.cpp \
|
||||||
|
installwizard_finished.cpp \
|
||||||
|
installwizard_patch.cpp
|
||||||
|
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += mainwindow.h \
|
||||||
settings.h \
|
settings.h \
|
||||||
installwizard.h \
|
installwizard.h \
|
||||||
installwizard_locatepage.h \
|
installwizard_locatepage.h \
|
||||||
installwizard_installtype.h
|
installwizard_installtype.h \
|
||||||
|
installwizard_finished.h \
|
||||||
|
installwizard_patch.h
|
||||||
|
|
||||||
FORMS += mainwindow.ui \
|
FORMS += mainwindow.ui \
|
||||||
installwizard.ui \
|
installwizard.ui \
|
||||||
installwizard_locatepage.ui \
|
installwizard_locatepage.ui \
|
||||||
installwizard_installtype.ui
|
installwizard_installtype.ui \
|
||||||
|
installwizard_finished.ui \
|
||||||
|
installwizard_patch.ui
|
||||||
|
|
||||||
OTHER_FILES += \
|
OTHER_FILES += \
|
||||||
README.md \
|
README.md \
|
||||||
|
|
Loading…
Reference in a new issue