|
|
@ -14,8 +14,6 @@
|
|
|
|
#include <QDir>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QDirIterator>
|
|
|
|
#include <QDirIterator>
|
|
|
|
|
|
|
|
|
|
|
|
#include <qmath.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Wizard::UnshieldWorker::UnshieldWorker(QObject *parent) :
|
|
|
|
Wizard::UnshieldWorker::UnshieldWorker(QObject *parent) :
|
|
|
|
QObject(parent),
|
|
|
|
QObject(parent),
|
|
|
|
mIniSettings()
|
|
|
|
mIniSettings()
|
|
|
@ -46,81 +44,106 @@ Wizard::UnshieldWorker::~UnshieldWorker()
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Wizard::UnshieldWorker::setInstallMorrowind(bool install)
|
|
|
|
void Wizard::UnshieldWorker::setInstallComponent(Wizard::Component component, bool install)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QWriteLocker writeLock(&mLock);
|
|
|
|
QWriteLocker writeLock(&mLock);
|
|
|
|
mInstallMorrowind = install;
|
|
|
|
switch (component) {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Wizard::UnshieldWorker::setInstallTribunal(bool install)
|
|
|
|
case Wizard::Component_Morrowind:
|
|
|
|
{
|
|
|
|
mInstallMorrowind = install;
|
|
|
|
QWriteLocker writeLock(&mLock);
|
|
|
|
break;
|
|
|
|
mInstallTribunal = install;
|
|
|
|
case Wizard::Component_Tribunal:
|
|
|
|
}
|
|
|
|
mInstallTribunal = install;
|
|
|
|
|
|
|
|
break;
|
|
|
|
void Wizard::UnshieldWorker::setInstallBloodmoon(bool install)
|
|
|
|
case Wizard::Component_Bloodmoon:
|
|
|
|
{
|
|
|
|
mInstallBloodmoon = install;
|
|
|
|
QWriteLocker writeLock(&mLock);
|
|
|
|
break;
|
|
|
|
mInstallBloodmoon = install;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Wizard::UnshieldWorker::getInstallMorrowind()
|
|
|
|
bool Wizard::UnshieldWorker::getInstallComponent(Component component)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QReadLocker readLock(&mLock);
|
|
|
|
QReadLocker readLock(&mLock);
|
|
|
|
return mInstallMorrowind;
|
|
|
|
switch (component) {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Wizard::UnshieldWorker::getInstallTribunal()
|
|
|
|
case Wizard::Component_Morrowind:
|
|
|
|
{
|
|
|
|
return mInstallMorrowind;
|
|
|
|
QReadLocker readLock(&mLock);
|
|
|
|
case Wizard::Component_Tribunal:
|
|
|
|
return mInstallTribunal;
|
|
|
|
return mInstallTribunal;
|
|
|
|
}
|
|
|
|
case Wizard::Component_Bloodmoon:
|
|
|
|
|
|
|
|
return mInstallBloodmoon;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Wizard::UnshieldWorker::getInstallBloodmoon()
|
|
|
|
return false;
|
|
|
|
{
|
|
|
|
|
|
|
|
QReadLocker readLock(&mLock);
|
|
|
|
|
|
|
|
return mInstallBloodmoon;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Wizard::UnshieldWorker::setMorrowindPath(const QString &path)
|
|
|
|
void Wizard::UnshieldWorker::setComponentPath(Wizard::Component component, const QString &path)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QWriteLocker writeLock(&mLock);
|
|
|
|
QWriteLocker writeLock(&mLock);
|
|
|
|
mMorrowindPath = path;
|
|
|
|
switch (component) {
|
|
|
|
mWait.wakeAll();
|
|
|
|
|
|
|
|
|
|
|
|
case Wizard::Component_Morrowind:
|
|
|
|
|
|
|
|
mMorrowindPath = path;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Wizard::Component_Tribunal:
|
|
|
|
|
|
|
|
mTribunalPath = path;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Wizard::Component_Bloodmoon:
|
|
|
|
|
|
|
|
mBloodmoonPath = path;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mWait.wakeAll();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Wizard::UnshieldWorker::setTribunalPath(const QString &path)
|
|
|
|
QString Wizard::UnshieldWorker::getComponentPath(Component component)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QWriteLocker writeLock(&mLock);
|
|
|
|
QReadLocker readLock(&mLock);
|
|
|
|
mTribunalPath = path;
|
|
|
|
switch (component) {
|
|
|
|
mWait.wakeAll();
|
|
|
|
|
|
|
|
|
|
|
|
case Wizard::Component_Morrowind:
|
|
|
|
|
|
|
|
return mMorrowindPath;
|
|
|
|
|
|
|
|
case Wizard::Component_Tribunal:
|
|
|
|
|
|
|
|
return mTribunalPath;
|
|
|
|
|
|
|
|
case Wizard::Component_Bloodmoon:
|
|
|
|
|
|
|
|
return mBloodmoonPath;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Wizard::UnshieldWorker::setBloodmoonPath(const QString &path)
|
|
|
|
void Wizard::UnshieldWorker::setComponentDone(Component component, bool done)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QWriteLocker writeLock(&mLock);
|
|
|
|
QWriteLocker writeLock(&mLock);
|
|
|
|
mBloodmoonPath = path;
|
|
|
|
switch (component) {
|
|
|
|
mWait.wakeAll();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case Wizard::Component_Morrowind:
|
|
|
|
|
|
|
|
mMorrowindDone = done;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Wizard::Component_Tribunal:
|
|
|
|
|
|
|
|
mTribunalDone = done;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Wizard::Component_Bloodmoon:
|
|
|
|
|
|
|
|
mBloodmoonDone = done;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString Wizard::UnshieldWorker::getMorrowindPath()
|
|
|
|
bool Wizard::UnshieldWorker::getComponentDone(Component component)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QReadLocker readLock(&mLock);
|
|
|
|
QReadLocker readLock(&mLock);
|
|
|
|
return mMorrowindPath;
|
|
|
|
switch (component)
|
|
|
|
}
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
QString Wizard::UnshieldWorker::getTribunalPath()
|
|
|
|
case Wizard::Component_Morrowind:
|
|
|
|
{
|
|
|
|
return mMorrowindDone;
|
|
|
|
QReadLocker readLock(&mLock);
|
|
|
|
case Wizard::Component_Tribunal:
|
|
|
|
return mTribunalPath;
|
|
|
|
return mTribunalDone;
|
|
|
|
}
|
|
|
|
case Wizard::Component_Bloodmoon:
|
|
|
|
|
|
|
|
return mBloodmoonDone;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString Wizard::UnshieldWorker::getBloodmoonPath()
|
|
|
|
return false;
|
|
|
|
{
|
|
|
|
|
|
|
|
QReadLocker readLock(&mLock);
|
|
|
|
|
|
|
|
return mBloodmoonPath;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Wizard::UnshieldWorker::setPath(const QString &path)
|
|
|
|
void Wizard::UnshieldWorker::setPath(const QString &path)
|
|
|
@ -153,42 +176,6 @@ void Wizard::UnshieldWorker::setIniCodec(QTextCodec *codec)
|
|
|
|
mIniCodec = codec;
|
|
|
|
mIniCodec = codec;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Wizard::UnshieldWorker::setMorrowindDone(bool done)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QWriteLocker writeLock(&mLock);
|
|
|
|
|
|
|
|
mMorrowindDone = done;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Wizard::UnshieldWorker::setTribunalDone(bool done)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QWriteLocker writeLock(&mLock);
|
|
|
|
|
|
|
|
mTribunalDone = done;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Wizard::UnshieldWorker::setBloodmoonDone(bool done)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QWriteLocker writeLock(&mLock);
|
|
|
|
|
|
|
|
mBloodmoonDone = done;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Wizard::UnshieldWorker::getMorrowindDone()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QReadLocker readLock(&mLock);
|
|
|
|
|
|
|
|
return mMorrowindDone;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Wizard::UnshieldWorker::getTribunalDone()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QReadLocker readLock(&mLock);
|
|
|
|
|
|
|
|
return mTribunalDone;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Wizard::UnshieldWorker::getBloodmoonDone()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QReadLocker readLock(&mLock);
|
|
|
|
|
|
|
|
return mBloodmoonDone;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Wizard::UnshieldWorker::setupSettings()
|
|
|
|
void Wizard::UnshieldWorker::setupSettings()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Create Morrowind.ini settings map
|
|
|
|
// Create Morrowind.ini settings map
|
|
|
@ -287,8 +274,7 @@ bool Wizard::UnshieldWorker::copyDirectory(const QString &source, const QString
|
|
|
|
if (info.isDir()) {
|
|
|
|
if (info.isDir()) {
|
|
|
|
result = moveDirectory(info.absoluteFilePath(), destDir.absolutePath() + relativePath);
|
|
|
|
result = moveDirectory(info.absoluteFilePath(), destDir.absolutePath() + relativePath);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
qDebug() << "moving: " << info.absoluteFilePath() << " to: " << destDir.absolutePath() + relativePath;
|
|
|
|
// qDebug() << "moving: " << info.absoluteFilePath() << " to: " << destDir.absolutePath() + relativePath;
|
|
|
|
|
|
|
|
|
|
|
|
result = moveFile(info.absoluteFilePath(), destDir.absolutePath() + relativePath);
|
|
|
|
result = moveFile(info.absoluteFilePath(), destDir.absolutePath() + relativePath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -346,36 +332,35 @@ void Wizard::UnshieldWorker::installDirectories(const QString &source)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Wizard::UnshieldWorker::extract()
|
|
|
|
void Wizard::UnshieldWorker::extract()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
qDebug() << "extract!";
|
|
|
|
qDebug() << "extract!";
|
|
|
|
QDir disk;
|
|
|
|
QDir disk;
|
|
|
|
|
|
|
|
|
|
|
|
if (getInstallMorrowind())
|
|
|
|
if (getInstallComponent(Wizard::Component_Morrowind))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
while (!getMorrowindDone())
|
|
|
|
while (!getComponentDone(Wizard::Component_Morrowind))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (getMorrowindPath().isEmpty()) {
|
|
|
|
if (getComponentPath(Wizard::Component_Morrowind).isEmpty()) {
|
|
|
|
qDebug() << "request file dialog";
|
|
|
|
qDebug() << "request file dialog";
|
|
|
|
QReadLocker readLock(&mLock);
|
|
|
|
QReadLocker readLock(&mLock);
|
|
|
|
emit requestFileDialog(QLatin1String("Morrowind"));
|
|
|
|
emit requestFileDialog(Wizard::Component_Morrowind);
|
|
|
|
mWait.wait(&mLock);
|
|
|
|
mWait.wait(&mLock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!getMorrowindPath().isEmpty()) {
|
|
|
|
if (!getComponentPath(Wizard::Component_Morrowind).isEmpty()) {
|
|
|
|
disk.setPath(getMorrowindPath());
|
|
|
|
disk.setPath(getComponentPath(Wizard::Component_Morrowind));
|
|
|
|
|
|
|
|
|
|
|
|
if (!findFile(disk.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Morrowind.bsa"))
|
|
|
|
if (!findFile(disk.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Morrowind.bsa"))
|
|
|
|
| findFile(disk.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Tribunal.bsa"))
|
|
|
|
| findFile(disk.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Tribunal.bsa"))
|
|
|
|
| findFile(disk.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Bloodmoon.bsa")))
|
|
|
|
| findFile(disk.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Bloodmoon.bsa")))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QReadLocker readLock(&mLock);
|
|
|
|
QReadLocker readLock(&mLock);
|
|
|
|
emit requestFileDialog(QLatin1String("Morrowind"));
|
|
|
|
emit requestFileDialog(Wizard::Component_Morrowind);
|
|
|
|
mWait.wait(&mLock);
|
|
|
|
mWait.wait(&mLock);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (installMorrowind()) {
|
|
|
|
if (installComponent(Wizard::Component_Morrowind)) {
|
|
|
|
setMorrowindDone(true);
|
|
|
|
setComponentDone(Wizard::Component_Morrowind, true);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
qDebug() << "Erorr installing Morrowind";
|
|
|
|
qDebug() << "Erorr installing Morrowind";
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -385,111 +370,29 @@ void Wizard::UnshieldWorker::extract()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (getInstallTribunal())
|
|
|
|
if (getInstallComponent(Wizard::Component_Tribunal))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
while (!getTribunalDone())
|
|
|
|
setupAddon(Wizard::Component_Tribunal);
|
|
|
|
{
|
|
|
|
|
|
|
|
QDir tribunal(disk);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!tribunal.cd(QLatin1String("Tribunal"))) {
|
|
|
|
|
|
|
|
qDebug() << "not found on cd!";
|
|
|
|
|
|
|
|
QReadLocker locker(&mLock);
|
|
|
|
|
|
|
|
emit requestFileDialog(QLatin1String("Tribunal"));
|
|
|
|
|
|
|
|
mWait.wait(&mLock);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (tribunal.exists(QLatin1String("data1.hdr"))) {
|
|
|
|
|
|
|
|
qDebug() << "Exists! " << tribunal.absolutePath();
|
|
|
|
|
|
|
|
setTribunalPath(tribunal.absolutePath());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (getTribunalPath().isEmpty()) {
|
|
|
|
|
|
|
|
qDebug() << "request file dialog";
|
|
|
|
|
|
|
|
QReadLocker locker(&mLock);
|
|
|
|
|
|
|
|
emit requestFileDialog(QLatin1String("Tribunal"));
|
|
|
|
|
|
|
|
mWait.wait(&mLock);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Make sure the dir is up-to-date
|
|
|
|
|
|
|
|
tribunal.setPath(getTribunalPath());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!getTribunalPath().isEmpty()) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!findFile(tribunal.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Tribunal.bsa")))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
qDebug() << "found";
|
|
|
|
|
|
|
|
QReadLocker locker(&mLock);
|
|
|
|
|
|
|
|
emit requestFileDialog(QLatin1String("Tribunal"));
|
|
|
|
|
|
|
|
mWait.wait(&mLock);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (installTribunal()) {
|
|
|
|
|
|
|
|
setTribunalDone(true);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
qDebug() << "Erorr installing Tribunal";
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (getInstallBloodmoon())
|
|
|
|
if (getInstallComponent(Wizard::Component_Bloodmoon))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
while (!getBloodmoonDone())
|
|
|
|
setupAddon(Wizard::Component_Bloodmoon);
|
|
|
|
{
|
|
|
|
|
|
|
|
QDir bloodmoon(disk);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qDebug() << "Test!: " << bloodmoon.absolutePath();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!bloodmoon.cd(QLatin1String("Bloodmoon"))) {
|
|
|
|
|
|
|
|
qDebug() << "not found on cd!";
|
|
|
|
|
|
|
|
QReadLocker locker(&mLock);
|
|
|
|
|
|
|
|
emit requestFileDialog(QLatin1String("Bloodmoon"));
|
|
|
|
|
|
|
|
mWait.wait(&mLock);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (bloodmoon.exists(QLatin1String("data1.hdr"))) {
|
|
|
|
|
|
|
|
qDebug() << "Exists! " << bloodmoon.absolutePath();
|
|
|
|
|
|
|
|
setBloodmoonPath(bloodmoon.absolutePath());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (getBloodmoonPath().isEmpty()) {
|
|
|
|
|
|
|
|
qDebug() << "request file dialog";
|
|
|
|
|
|
|
|
QReadLocker locker(&mLock);
|
|
|
|
|
|
|
|
emit requestFileDialog(QLatin1String("Bloodmoon"));
|
|
|
|
|
|
|
|
mWait.wait(&mLock);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Make sure the dir is up-to-date
|
|
|
|
|
|
|
|
bloodmoon.setPath(getBloodmoonPath());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!findFile(bloodmoon.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Bloodmoon.bsa")))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QReadLocker locker(&mLock);
|
|
|
|
|
|
|
|
emit requestFileDialog(QLatin1String("Bloodmoon"));
|
|
|
|
|
|
|
|
mWait.wait(&mLock);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (installBloodmoon()) {
|
|
|
|
|
|
|
|
setBloodmoonDone(true);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
qDebug() << "Erorr installing Bloodmoon";
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Remove the temporary directory
|
|
|
|
// Remove the temporary directory
|
|
|
|
removeDirectory(mPath + QDir::separator() + QLatin1String("extract-temp"));
|
|
|
|
removeDirectory(getPath() + QDir::separator() + QLatin1String("extract-temp"));
|
|
|
|
|
|
|
|
|
|
|
|
// Fill the progress bar
|
|
|
|
// Fill the progress bar
|
|
|
|
int total = 0;
|
|
|
|
int total = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (getInstallMorrowind())
|
|
|
|
if (getInstallComponent(Wizard::Component_Morrowind))
|
|
|
|
total = 100;
|
|
|
|
total = 100;
|
|
|
|
|
|
|
|
|
|
|
|
if (getInstallTribunal())
|
|
|
|
if (getInstallComponent(Wizard::Component_Tribunal))
|
|
|
|
total = total + 100;
|
|
|
|
total = total + 100;
|
|
|
|
|
|
|
|
|
|
|
|
if (getInstallBloodmoon())
|
|
|
|
if (getInstallComponent(Wizard::Component_Bloodmoon))
|
|
|
|
total = total + 100;
|
|
|
|
total = total + 100;
|
|
|
|
|
|
|
|
|
|
|
|
emit textChanged(tr("Installation finished!"));
|
|
|
|
emit textChanged(tr("Installation finished!"));
|
|
|
@ -499,83 +402,87 @@ void Wizard::UnshieldWorker::extract()
|
|
|
|
qDebug() << "installation finished!";
|
|
|
|
qDebug() << "installation finished!";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Wizard::UnshieldWorker::installMorrowind()
|
|
|
|
void Wizard::UnshieldWorker::setupAddon(Component component)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
qDebug() << "install morrowind!";
|
|
|
|
while (!getComponentDone(component))
|
|
|
|
emit textChanged(QLatin1String("Installing Morrowind"));
|
|
|
|
{
|
|
|
|
|
|
|
|
QDir disk(getComponentPath(Wizard::Component_Morrowind));
|
|
|
|
QDir disk(getMorrowindPath());
|
|
|
|
QString name;
|
|
|
|
|
|
|
|
if (component == Wizard::Component_Tribunal)
|
|
|
|
|
|
|
|
name = QLatin1String("Tribunal");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (component == Wizard::Component_Bloodmoon)
|
|
|
|
|
|
|
|
name = QLatin1String("Bloodmoon");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (name.isEmpty())
|
|
|
|
|
|
|
|
return; // Not a valid addon
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!disk.cd(name)) {
|
|
|
|
|
|
|
|
qDebug() << "not found on cd!";
|
|
|
|
|
|
|
|
QReadLocker locker(&mLock);
|
|
|
|
|
|
|
|
emit requestFileDialog(component);
|
|
|
|
|
|
|
|
mWait.wait(&mLock);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (disk.exists(QLatin1String("data1.hdr"))) {
|
|
|
|
|
|
|
|
qDebug() << "Exists! " << disk.absolutePath();
|
|
|
|
|
|
|
|
setComponentPath(component, disk.absolutePath());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!disk.exists()) {
|
|
|
|
if (getComponentPath(component).isEmpty()) {
|
|
|
|
qDebug() << "getMorrowindPath: " << getMorrowindPath();
|
|
|
|
qDebug() << "request file dialog";
|
|
|
|
return false;
|
|
|
|
QReadLocker locker(&mLock);
|
|
|
|
}
|
|
|
|
emit requestFileDialog(Wizard::Component_Tribunal);
|
|
|
|
|
|
|
|
mWait.wait(&mLock);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Create temporary extract directory
|
|
|
|
// Make sure the dir is up-to-date
|
|
|
|
// TODO: Use QTemporaryDir in Qt 5.0
|
|
|
|
disk.setPath(getComponentPath(component));
|
|
|
|
QString tempPath(getPath() + QDir::separator() + QLatin1String("extract-temp"));
|
|
|
|
|
|
|
|
QDir temp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Make sure the temporary folder is empty
|
|
|
|
if (!getComponentPath(component).isEmpty()) {
|
|
|
|
removeDirectory(tempPath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!temp.mkpath(tempPath)) {
|
|
|
|
if (!findFile(disk.absoluteFilePath(QLatin1String("data1.hdr")), name + QLatin1String(".bsa")))
|
|
|
|
qDebug() << "Can't make path";
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
QReadLocker locker(&mLock);
|
|
|
|
|
|
|
|
emit requestFileDialog(component);
|
|
|
|
|
|
|
|
mWait.wait(&mLock);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Now do the actual installing
|
|
|
|
|
|
|
|
if (installComponent(component)) {
|
|
|
|
|
|
|
|
setComponentDone(component, true);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
qDebug() << "Error installing " << name;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
temp.setPath(tempPath);
|
|
|
|
bool Wizard::UnshieldWorker::installComponent(Component component)
|
|
|
|
|
|
|
|
{
|
|
|
|
if (!temp.mkdir(QLatin1String("morrowind"))) {
|
|
|
|
QString name;
|
|
|
|
qDebug() << "Can't make dir";
|
|
|
|
switch (component) {
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!temp.cd(QLatin1String("morrowind"))) {
|
|
|
|
case Wizard::Component_Morrowind:
|
|
|
|
qDebug() << "Can't cd to dir";
|
|
|
|
name = QLatin1String("Morrowind");
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Wizard::Component_Tribunal:
|
|
|
|
|
|
|
|
name = QLatin1String("Tribunal");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Wizard::Component_Bloodmoon:
|
|
|
|
|
|
|
|
name = QLatin1String("Bloodmoon");
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Extract the installation files
|
|
|
|
if (name.isEmpty())
|
|
|
|
extractCab(disk.absoluteFilePath(QLatin1String("data1.hdr")), temp.absolutePath());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Throw error;
|
|
|
|
|
|
|
|
// Move the files from the temporary path to the destination folder
|
|
|
|
|
|
|
|
emit textChanged(tr("Moving installation files"));
|
|
|
|
|
|
|
|
if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), getPath())) {
|
|
|
|
|
|
|
|
qDebug() << "failed to move files!";
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Install files outside of cab archives
|
|
|
|
|
|
|
|
installDirectories(disk.absolutePath());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Copy Morrowind configuration file
|
|
|
|
emit textChanged(tr("Installing %0").arg(name));
|
|
|
|
QString iniPath(temp.absoluteFilePath(QLatin1String("App Executables")));
|
|
|
|
|
|
|
|
iniPath.append(QDir::separator() + QLatin1String("Morrowind.ini"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QFileInfo info(iniPath);
|
|
|
|
QDir disk(getComponentPath(component));
|
|
|
|
|
|
|
|
|
|
|
|
if (info.exists()) {
|
|
|
|
|
|
|
|
emit textChanged(tr("Extracting: Morrowind.ini"));
|
|
|
|
|
|
|
|
moveFile(info.absoluteFilePath(), getPath() + QDir::separator() + QLatin1String("Morrowind.ini"));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
qDebug() << "Could not find ini file!";
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emit textChanged(tr("Morrowind installation finished!"));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Wizard::UnshieldWorker::installTribunal()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
emit textChanged(QLatin1String("Installing Tribunal"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QDir disk(getTribunalPath());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!disk.exists()) {
|
|
|
|
if (!disk.exists()) {
|
|
|
|
qDebug() << "disk does not exist! " << disk.absolutePath() << getTribunalPath();
|
|
|
|
qDebug() << "Component path not set: " << getComponentPath(Wizard::Component_Morrowind);
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -594,12 +501,12 @@ bool Wizard::UnshieldWorker::installTribunal()
|
|
|
|
|
|
|
|
|
|
|
|
temp.setPath(tempPath);
|
|
|
|
temp.setPath(tempPath);
|
|
|
|
|
|
|
|
|
|
|
|
if (!temp.mkdir(QLatin1String("tribunal"))) {
|
|
|
|
if (!temp.mkdir(name)) {
|
|
|
|
qDebug() << "Can't make dir";
|
|
|
|
qDebug() << "Can't make dir";
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!temp.cd(QLatin1String("tribunal"))) {
|
|
|
|
if (!temp.cd(name)) {
|
|
|
|
qDebug() << "Can't cd to dir";
|
|
|
|
qDebug() << "Can't cd to dir";
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -610,8 +517,7 @@ bool Wizard::UnshieldWorker::installTribunal()
|
|
|
|
// TODO: Throw error;
|
|
|
|
// TODO: Throw error;
|
|
|
|
// Move the files from the temporary path to the destination folder
|
|
|
|
// Move the files from the temporary path to the destination folder
|
|
|
|
emit textChanged(tr("Moving installation files"));
|
|
|
|
emit textChanged(tr("Moving installation files"));
|
|
|
|
if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), getPath()))
|
|
|
|
if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), getPath())) {
|
|
|
|
{
|
|
|
|
|
|
|
|
qDebug() << "failed to move files!";
|
|
|
|
qDebug() << "failed to move files!";
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -619,71 +525,39 @@ bool Wizard::UnshieldWorker::installTribunal()
|
|
|
|
// Install files outside of cab archives
|
|
|
|
// Install files outside of cab archives
|
|
|
|
installDirectories(disk.absolutePath());
|
|
|
|
installDirectories(disk.absolutePath());
|
|
|
|
|
|
|
|
|
|
|
|
emit textChanged(tr("Tribunal installation finished!"));
|
|
|
|
if (component == Wizard::Component_Morrowind)
|
|
|
|
return true;
|
|
|
|
{
|
|
|
|
}
|
|
|
|
// Copy Morrowind configuration file
|
|
|
|
|
|
|
|
QString iniPath(temp.absoluteFilePath(QLatin1String("App Executables")));
|
|
|
|
bool Wizard::UnshieldWorker::installBloodmoon()
|
|
|
|
iniPath.append(QDir::separator() + QLatin1String("Morrowind.ini"));
|
|
|
|
{
|
|
|
|
|
|
|
|
emit textChanged(QLatin1String("Installing Bloodmoon"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QDir disk(getBloodmoonPath());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!disk.exists()) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create temporary extract directory
|
|
|
|
|
|
|
|
// TODO: Use QTemporaryDir in Qt 5.0
|
|
|
|
|
|
|
|
QString tempPath(getPath() + QDir::separator() + QLatin1String("extract-temp"));
|
|
|
|
|
|
|
|
QDir temp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Make sure the temporary folder is empty
|
|
|
|
|
|
|
|
removeDirectory(tempPath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!temp.mkpath(tempPath)) {
|
|
|
|
|
|
|
|
qDebug() << "Can't make path";
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
temp.setPath(tempPath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!temp.mkdir(QLatin1String("bloodmoon"))) {
|
|
|
|
|
|
|
|
qDebug() << "Can't make dir";
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!temp.cd(QLatin1String("bloodmoon"))) {
|
|
|
|
|
|
|
|
qDebug() << "Can't cd to dir";
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Extract the installation files
|
|
|
|
QFileInfo info(iniPath);
|
|
|
|
extractCab(disk.absoluteFilePath(QLatin1String("data1.hdr")), temp.absolutePath());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Throw error;
|
|
|
|
if (info.exists()) {
|
|
|
|
// Move the files from the temporary path to the destination folder
|
|
|
|
emit textChanged(tr("Extracting: Morrowind.ini"));
|
|
|
|
emit textChanged(tr("Moving installation files"));
|
|
|
|
moveFile(info.absoluteFilePath(), getPath() + QDir::separator() + QLatin1String("Morrowind.ini"));
|
|
|
|
if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), getPath())) {
|
|
|
|
} else {
|
|
|
|
qDebug() << "failed to move files!";
|
|
|
|
qDebug() << "Could not find ini file!";
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Install files outside of cab archives
|
|
|
|
if (component == Wizard::Component_Bloodmoon)
|
|
|
|
installDirectories(disk.absolutePath());
|
|
|
|
{
|
|
|
|
|
|
|
|
QFileInfo patch(temp.absoluteFilePath(QLatin1String("Tribunal Patch") + QDir::separator() + QLatin1String("Tribunal.esm")));
|
|
|
|
|
|
|
|
QFileInfo original(getPath() + QDir::separator() + QLatin1String("Tribunal.esm"));
|
|
|
|
|
|
|
|
|
|
|
|
QFileInfo patch(temp.absoluteFilePath(QLatin1String("Tribunal Patch") + QDir::separator() + QLatin1String("Tribunal.esm")));
|
|
|
|
if (original.exists() && patch.exists()) {
|
|
|
|
QFileInfo original(getPath() + QDir::separator() + QLatin1String("Tribunal.esm"));
|
|
|
|
emit textChanged(tr("Extracting: Tribunal patch"));
|
|
|
|
|
|
|
|
copyFile(patch.absoluteFilePath(), original.absoluteFilePath());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (original.exists() && patch.exists()) {
|
|
|
|
|
|
|
|
emit textChanged(tr("Extracting: Tribunal patch"));
|
|
|
|
|
|
|
|
copyFile(patch.absoluteFilePath(), original.absoluteFilePath());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
emit textChanged(tr("Bloodmoon installation finished!"));
|
|
|
|
emit textChanged(tr("%0 installation finished!").arg(name));
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Wizard::UnshieldWorker::extractFile(Unshield *unshield, const QString &outputDir, const QString &prefix, int index, int counter)
|
|
|
|
bool Wizard::UnshieldWorker::extractFile(Unshield *unshield, const QString &outputDir, const QString &prefix, int index, int counter)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -713,10 +587,10 @@ bool Wizard::UnshieldWorker::extractFile(Unshield *unshield, const QString &outp
|
|
|
|
// Calculate the percentage done
|
|
|
|
// Calculate the percentage done
|
|
|
|
int progress = (((float) counter / (float) unshield_file_count(unshield)) * 100);
|
|
|
|
int progress = (((float) counter / (float) unshield_file_count(unshield)) * 100);
|
|
|
|
|
|
|
|
|
|
|
|
if (getMorrowindDone())
|
|
|
|
if (getComponentDone(Wizard::Component_Morrowind))
|
|
|
|
progress = progress + 100;
|
|
|
|
progress = progress + 100;
|
|
|
|
|
|
|
|
|
|
|
|
if (getTribunalDone())
|
|
|
|
if (getComponentDone(Wizard::Component_Tribunal))
|
|
|
|
progress = progress + 100;
|
|
|
|
progress = progress + 100;
|
|
|
|
|
|
|
|
|
|
|
|
emit textChanged(tr("Extracting: %1").arg(QString::fromLatin1(unshield_file_name(unshield, index))));
|
|
|
|
emit textChanged(tr("Extracting: %1").arg(QString::fromLatin1(unshield_file_name(unshield, index))));
|
|
|
|