forked from teamnwah/openmw-tes3coop
Work in progress commit, working on data1.hdr autodetection
This commit is contained in:
parent
8fe837ae6e
commit
b2156351d8
8 changed files with 315 additions and 166 deletions
|
@ -61,7 +61,6 @@ void Wizard::ExistingInstallationPage::textChanged(const QString &text)
|
||||||
|
|
||||||
void Wizard::ExistingInstallationPage::initializePage()
|
void Wizard::ExistingInstallationPage::initializePage()
|
||||||
{
|
{
|
||||||
|
|
||||||
QStringList paths(mWizard->mInstallations.keys());
|
QStringList paths(mWizard->mInstallations.keys());
|
||||||
|
|
||||||
if (paths.isEmpty())
|
if (paths.isEmpty())
|
||||||
|
|
|
@ -66,7 +66,7 @@ bool Wizard::IniSettings::readFile(QTextStream &stream)
|
||||||
if (!currentSection.isEmpty())
|
if (!currentSection.isEmpty())
|
||||||
key = currentSection + QLatin1Char('/') + key;
|
key = currentSection + QLatin1Char('/') + key;
|
||||||
|
|
||||||
qDebug() << "adding: " << key << value;
|
//qDebug() << "adding: " << key << value;
|
||||||
mSettings[key] = QVariant(value);
|
mSettings[key] = QVariant(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,8 @@ void Wizard::InstallationPage::initializePage()
|
||||||
installProgressBar->setMaximum(installProgressBar->maximum() + 100);
|
installProgressBar->setMaximum(installProgressBar->maximum() + 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle when cancel is clicked
|
||||||
|
|
||||||
startInstallation();
|
startInstallation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,6 @@ namespace Wizard
|
||||||
protected:
|
protected:
|
||||||
void initializePage();
|
void initializePage();
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,6 +224,19 @@ void Wizard::MainWizard::accept()
|
||||||
QWizard::accept();
|
QWizard::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Wizard::MainWizard::reject()
|
||||||
|
{
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setWindowTitle(tr("Quit Wizard"));
|
||||||
|
msgBox.setIcon(QMessageBox::Question);
|
||||||
|
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||||
|
msgBox.setText(tr("Are you sure you want to exit the Wizard?"));
|
||||||
|
|
||||||
|
if (msgBox.exec() == QMessageBox::Yes) {
|
||||||
|
QWizard::reject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Wizard::MainWizard::writeSettings()
|
void Wizard::MainWizard::writeSettings()
|
||||||
{
|
{
|
||||||
QString path(field(QLatin1String("installation.path")).toString());
|
QString path(field(QLatin1String("installation.path")).toString());
|
||||||
|
|
|
@ -59,6 +59,7 @@ namespace Wizard
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void accept();
|
void accept();
|
||||||
|
void reject();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -319,19 +319,43 @@ bool Wizard::UnshieldWorker::moveDirectory(const QString &source, const QString
|
||||||
return copyDirectory(source, destination, false);
|
return copyDirectory(source, destination, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wizard::UnshieldWorker::installDirectories(const QString &source)
|
bool Wizard::UnshieldWorker::installFile(const QString &fileName, const QString &path)
|
||||||
{
|
{
|
||||||
QDir dir(source);
|
qDebug() << "Attempting to find file: " << fileName << " in: " << path;
|
||||||
|
|
||||||
|
bool result = true;
|
||||||
|
QDir dir(path);
|
||||||
|
|
||||||
if (!dir.exists())
|
if (!dir.exists())
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
QStringList directories;
|
QFileInfoList list(dir.entryInfoList(QDir::NoDotAndDotDot |
|
||||||
directories << QLatin1String("Fonts")
|
QDir::System | QDir::Hidden |
|
||||||
<< QLatin1String("Music")
|
QDir::AllDirs | QDir::Files, QDir::DirsFirst));
|
||||||
<< QLatin1String("Sound")
|
foreach(QFileInfo info, list) {
|
||||||
<< QLatin1String("Splash")
|
if (info.isDir()) {
|
||||||
<< QLatin1String("Video");
|
result = installFile(fileName, info.absoluteFilePath());
|
||||||
|
} else {
|
||||||
|
if (info.fileName() == fileName) {
|
||||||
|
qDebug() << "File found at: " << info.absoluteFilePath();
|
||||||
|
|
||||||
|
emit textChanged(tr("Installing: %1").arg(info.fileName()));
|
||||||
|
return moveFile(info.absoluteFilePath(), getPath() + QDir::separator() + info.fileName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Wizard::UnshieldWorker::installDirectory(const QString &dirName, const QString &path, bool recursive)
|
||||||
|
{
|
||||||
|
qDebug() << "Attempting to find: " << dirName << " in: " << path;
|
||||||
|
bool result = true;
|
||||||
|
QDir dir(path);
|
||||||
|
|
||||||
|
if (!dir.exists())
|
||||||
|
return false;
|
||||||
|
|
||||||
QFileInfoList list(dir.entryInfoList(QDir::NoDotAndDotDot |
|
QFileInfoList list(dir.entryInfoList(QDir::NoDotAndDotDot |
|
||||||
QDir::System | QDir::Hidden |
|
QDir::System | QDir::Hidden |
|
||||||
|
@ -340,123 +364,126 @@ void Wizard::UnshieldWorker::installDirectories(const QString &source)
|
||||||
if (info.isSymLink())
|
if (info.isSymLink())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (directories.contains(info.fileName())) {
|
if (info.isDir()) {
|
||||||
qDebug() << "found " << info.fileName();
|
if (info.fileName() == dirName) {
|
||||||
emit textChanged(tr("Extracting: %1 directory").arg(info.fileName()));
|
qDebug() << "Directory found at: " << info.absoluteFilePath();
|
||||||
copyDirectory(info.absoluteFilePath(), getPath() + QDir::separator() + info.fileName());
|
emit textChanged(tr("Installing: %1 directory").arg(info.fileName()));
|
||||||
|
return copyDirectory(info.absoluteFilePath(), getPath() + QDir::separator() + info.fileName());
|
||||||
|
} else {
|
||||||
|
if (recursive)
|
||||||
|
result = installDirectory(dirName, info.absoluteFilePath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the Data Files dir too, but only the subdirectories
|
return result;
|
||||||
QFileInfo info(dir.absoluteFilePath("Data Files"));
|
|
||||||
if (info.exists()) {
|
|
||||||
emit textChanged(tr("Extracting: Data Files directory"));
|
|
||||||
copyDirectory(info.absoluteFilePath(), getPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wizard::UnshieldWorker::extract()
|
void Wizard::UnshieldWorker::extract()
|
||||||
{
|
{
|
||||||
qDebug() << "extract!";
|
qDebug() << "extract!";
|
||||||
QDir disk;
|
|
||||||
|
|
||||||
if (getInstallComponent(Wizard::Component_Morrowind))
|
qDebug() << findFiles(QLatin1String("data1.hdr"), QLatin1String("/mnt/cdrom"));
|
||||||
{
|
// QDir disk;
|
||||||
while (!getComponentDone(Wizard::Component_Morrowind))
|
|
||||||
{
|
|
||||||
if (getComponentPath(Wizard::Component_Morrowind).isEmpty()) {
|
|
||||||
qDebug() << "request file dialog";
|
|
||||||
QReadLocker readLock(&mLock);
|
|
||||||
emit requestFileDialog(Wizard::Component_Morrowind);
|
|
||||||
mWait.wait(&mLock);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!getComponentPath(Wizard::Component_Morrowind).isEmpty()) {
|
// if (getInstallComponent(Wizard::Component_Morrowind))
|
||||||
disk.setPath(getComponentPath(Wizard::Component_Morrowind));
|
// {
|
||||||
|
// if (!getComponentDone(Wizard::Component_Morrowind))
|
||||||
|
// {
|
||||||
|
// if (getComponentPath(Wizard::Component_Morrowind).isEmpty()) {
|
||||||
|
// qDebug() << "request file dialog";
|
||||||
|
// QReadLocker readLock(&mLock);
|
||||||
|
// emit requestFileDialog(Wizard::Component_Morrowind);
|
||||||
|
// mWait.wait(&mLock);
|
||||||
|
// }
|
||||||
|
|
||||||
if (!findFile(disk.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Morrowind.bsa"))
|
// if (!getComponentPath(Wizard::Component_Morrowind).isEmpty()) {
|
||||||
| findFile(disk.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Tribunal.bsa"))
|
// disk.setPath(getComponentPath(Wizard::Component_Morrowind));
|
||||||
| findFile(disk.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Bloodmoon.bsa")))
|
|
||||||
{
|
|
||||||
QReadLocker readLock(&mLock);
|
|
||||||
emit requestFileDialog(Wizard::Component_Morrowind);
|
|
||||||
mWait.wait(&mLock);
|
|
||||||
} else {
|
|
||||||
if (installComponent(Wizard::Component_Morrowind)) {
|
|
||||||
setComponentDone(Wizard::Component_Morrowind, true);
|
|
||||||
} else {
|
|
||||||
qDebug() << "Erorr installing Morrowind";
|
|
||||||
|
|
||||||
return;
|
// if (!findInCab(disk.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Morrowind.bsa")))
|
||||||
}
|
// {
|
||||||
}
|
// QReadLocker readLock(&mLock);
|
||||||
}
|
// emit requestFileDialog(Wizard::Component_Morrowind);
|
||||||
}
|
// mWait.wait(&mLock);
|
||||||
}
|
// } else {
|
||||||
|
// if (installComponent(Wizard::Component_Morrowind)) {
|
||||||
|
// setComponentDone(Wizard::Component_Morrowind, true);
|
||||||
|
// } else {
|
||||||
|
// qDebug() << "Erorr installing Morrowind";
|
||||||
|
|
||||||
if (getInstallComponent(Wizard::Component_Tribunal))
|
// return;
|
||||||
{
|
// }
|
||||||
setupAddon(Wizard::Component_Tribunal);
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
if (getInstallComponent(Wizard::Component_Bloodmoon))
|
// if (getInstallComponent(Wizard::Component_Tribunal))
|
||||||
{
|
// {
|
||||||
setupAddon(Wizard::Component_Bloodmoon);
|
// setupAddon(Wizard::Component_Tribunal);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Update Morrowind configuration
|
// if (getInstallComponent(Wizard::Component_Bloodmoon))
|
||||||
if (getInstallComponent(Wizard::Component_Tribunal))
|
// {
|
||||||
{
|
// setupAddon(Wizard::Component_Bloodmoon);
|
||||||
mIniSettings.setValue(QLatin1String("Archives/Archive0"), QVariant(QString("Tribunal.bsa")));
|
// }
|
||||||
mIniSettings.setValue(QLatin1String("Game Files/Game File1"), QVariant(QString("Tribunal.esm")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getInstallComponent(Wizard::Component_Bloodmoon))
|
// // Update Morrowind configuration
|
||||||
{
|
// if (getInstallComponent(Wizard::Component_Tribunal))
|
||||||
mIniSettings.setValue(QLatin1String("Archives/Archive0"), QVariant(QString("Bloodmoon.bsa")));
|
// {
|
||||||
mIniSettings.setValue(QLatin1String("Game Files/Game File1"), QVariant(QString("Bloodmoon.esm")));
|
// mIniSettings.setValue(QLatin1String("Archives/Archive0"), QVariant(QString("Tribunal.bsa")));
|
||||||
}
|
// mIniSettings.setValue(QLatin1String("Game Files/Game File1"), QVariant(QString("Tribunal.esm")));
|
||||||
|
// }
|
||||||
|
|
||||||
if (getInstallComponent(Wizard::Component_Tribunal) &&
|
// if (getInstallComponent(Wizard::Component_Bloodmoon))
|
||||||
getInstallComponent(Wizard::Component_Bloodmoon))
|
// {
|
||||||
{
|
// mIniSettings.setValue(QLatin1String("Archives/Archive0"), QVariant(QString("Bloodmoon.bsa")));
|
||||||
mIniSettings.setValue(QLatin1String("Archives/Archive0"), QVariant(QString("Tribunal.bsa")));
|
// mIniSettings.setValue(QLatin1String("Game Files/Game File1"), QVariant(QString("Bloodmoon.esm")));
|
||||||
mIniSettings.setValue(QLatin1String("Archives/Archive1"), QVariant(QString("Bloodmoon.bsa")));
|
// }
|
||||||
mIniSettings.setValue(QLatin1String("Game Files/Game File1"), QVariant(QString("Tribunal.esm")));
|
|
||||||
mIniSettings.setValue(QLatin1String("Game Files/Game File2"), QVariant(QString("Bloodmoon.esm")));
|
// if (getInstallComponent(Wizard::Component_Tribunal) &&
|
||||||
}
|
// getInstallComponent(Wizard::Component_Bloodmoon))
|
||||||
|
// {
|
||||||
|
// mIniSettings.setValue(QLatin1String("Archives/Archive0"), QVariant(QString("Tribunal.bsa")));
|
||||||
|
// mIniSettings.setValue(QLatin1String("Archives/Archive1"), QVariant(QString("Bloodmoon.bsa")));
|
||||||
|
// mIniSettings.setValue(QLatin1String("Game Files/Game File1"), QVariant(QString("Tribunal.esm")));
|
||||||
|
// mIniSettings.setValue(QLatin1String("Game Files/Game File2"), QVariant(QString("Bloodmoon.esm")));
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
// Write the settings to the Morrowind config file
|
// // Write the settings to the Morrowind config file
|
||||||
writeSettings();
|
// writeSettings();
|
||||||
|
|
||||||
// Remove the temporary directory
|
// // Remove the temporary directory
|
||||||
removeDirectory(getPath() + 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 (getInstallComponent(Wizard::Component_Morrowind))
|
// if (getInstallComponent(Wizard::Component_Morrowind))
|
||||||
total = 100;
|
// total = 100;
|
||||||
|
|
||||||
if (getInstallComponent(Wizard::Component_Tribunal))
|
// if (getInstallComponent(Wizard::Component_Tribunal))
|
||||||
total = total + 100;
|
// total = total + 100;
|
||||||
|
|
||||||
if (getInstallComponent(Wizard::Component_Bloodmoon))
|
// if (getInstallComponent(Wizard::Component_Bloodmoon))
|
||||||
total = total + 100;
|
// total = total + 100;
|
||||||
|
|
||||||
emit textChanged(tr("Installation finished!"));
|
// emit textChanged(tr("Installation finished!"));
|
||||||
emit progressChanged(total);
|
// emit progressChanged(total);
|
||||||
emit finished();
|
// emit finished();
|
||||||
|
|
||||||
qDebug() << "installation finished!";
|
// qDebug() << "installation finished!";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wizard::UnshieldWorker::setupAddon(Component component)
|
void Wizard::UnshieldWorker::setupAddon(Component component)
|
||||||
{
|
{
|
||||||
while (!getComponentDone(component))
|
qDebug() << "SetupAddon!" << getComponentPath(component) << getComponentPath(Wizard::Component_Morrowind);
|
||||||
|
|
||||||
|
if (!getComponentDone(component))
|
||||||
{
|
{
|
||||||
|
qDebug() << "Component not done!";
|
||||||
|
|
||||||
QDir disk(getComponentPath(Wizard::Component_Morrowind));
|
QDir disk(getComponentPath(Wizard::Component_Morrowind));
|
||||||
QString name;
|
QString name;
|
||||||
if (component == Wizard::Component_Tribunal)
|
if (component == Wizard::Component_Tribunal)
|
||||||
|
@ -470,6 +497,11 @@ void Wizard::UnshieldWorker::setupAddon(Component component)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug() << "Determine if file is in current data1.hdr: " << name;
|
||||||
|
|
||||||
|
if (!disk.isEmpty()) {
|
||||||
|
if (!findInCab(disk.absoluteFilePath(QLatin1String("data1.hdr")), name + QLatin1String(".bsa")))
|
||||||
|
{
|
||||||
if (!disk.cd(name)) {
|
if (!disk.cd(name)) {
|
||||||
qDebug() << "not found on cd!";
|
qDebug() << "not found on cd!";
|
||||||
QReadLocker locker(&mLock);
|
QReadLocker locker(&mLock);
|
||||||
|
@ -477,36 +509,60 @@ void Wizard::UnshieldWorker::setupAddon(Component component)
|
||||||
mWait.wait(&mLock);
|
mWait.wait(&mLock);
|
||||||
|
|
||||||
} else if (disk.exists(QLatin1String("data1.hdr"))) {
|
} else if (disk.exists(QLatin1String("data1.hdr"))) {
|
||||||
setComponentPath(component, disk.absolutePath());
|
if (!findInCab(disk.absoluteFilePath(QLatin1String("data1.hdr")), name + QLatin1String(".bsa")))
|
||||||
}
|
|
||||||
|
|
||||||
if (getComponentPath(component).isEmpty()) {
|
|
||||||
qDebug() << "request file dialog";
|
|
||||||
QReadLocker locker(&mLock);
|
|
||||||
emit requestFileDialog(Wizard::Component_Tribunal);
|
|
||||||
mWait.wait(&mLock);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure the dir is up-to-date
|
|
||||||
disk.setPath(getComponentPath(component));
|
|
||||||
|
|
||||||
if (!getComponentPath(component).isEmpty()) {
|
|
||||||
|
|
||||||
if (!findFile(disk.absoluteFilePath(QLatin1String("data1.hdr")), name + QLatin1String(".bsa")))
|
|
||||||
{
|
{
|
||||||
QReadLocker locker(&mLock);
|
QReadLocker locker(&mLock);
|
||||||
emit requestFileDialog(component);
|
emit requestFileDialog(component);
|
||||||
mWait.wait(&mLock);
|
mWait.wait(&mLock);
|
||||||
} else {
|
} else {
|
||||||
|
setComponentPath(component, disk.absolutePath());
|
||||||
|
disk.setPath(getComponentPath(component));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
QReadLocker locker(&mLock);
|
||||||
|
emit requestFileDialog(component);
|
||||||
|
mWait.wait(&mLock);
|
||||||
|
}
|
||||||
|
|
||||||
|
disk.setPath(getComponentPath(component));
|
||||||
|
|
||||||
|
if (!findInCab(disk.absoluteFilePath(QLatin1String("data1.hdr")), name + QLatin1String(".bsa")))
|
||||||
|
{
|
||||||
|
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"))) {
|
||||||
|
if (!findInCab(disk.absoluteFilePath(QLatin1String("data1.hdr")), name + QLatin1String(".bsa")))
|
||||||
|
{
|
||||||
|
QReadLocker locker(&mLock);
|
||||||
|
emit requestFileDialog(component);
|
||||||
|
mWait.wait(&mLock);
|
||||||
|
} else {
|
||||||
|
setComponentPath(component, disk.absolutePath());
|
||||||
|
disk.setPath(getComponentPath(component));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure the dir is up-to-date
|
||||||
|
//disk.setPath(getComponentPath(component));
|
||||||
|
}
|
||||||
|
|
||||||
// Now do the actual installing
|
// Now do the actual installing
|
||||||
|
|
||||||
if (installComponent(component)) {
|
if (installComponent(component)) {
|
||||||
setComponentDone(component, true);
|
setComponentDone(component, true);
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Error installing " << name;
|
qDebug() << "Error installing " << name;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,40 +629,60 @@ bool Wizard::UnshieldWorker::installComponent(Component component)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// 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"));
|
||||||
|
// if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), getPath())) {
|
||||||
|
// qDebug() << "failed to move files!";
|
||||||
|
// emit error(tr("Moving extracted files failed!"),
|
||||||
|
// tr("Failed to move files from %1 to %2.").arg(temp.absoluteFilePath(QLatin1String("Data Files")),
|
||||||
|
// getPath()));
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
emit textChanged(tr("Moving installation files"));
|
emit textChanged(tr("Moving installation files"));
|
||||||
if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), getPath())) {
|
|
||||||
qDebug() << "failed to move files!";
|
// Install extracted directories
|
||||||
emit error(tr("Moving extracted files failed!"),
|
QStringList directories;
|
||||||
tr("Failed to move files from %1 to %2.").arg(temp.absoluteFilePath(QLatin1String("Data Files")),
|
directories << QLatin1String("BookArt")
|
||||||
getPath()));
|
<< QLatin1String("Fonts")
|
||||||
return false;
|
<< QLatin1String("Icons")
|
||||||
|
<< QLatin1String("Meshes")
|
||||||
|
<< QLatin1String("Music")
|
||||||
|
<< QLatin1String("Sound")
|
||||||
|
<< QLatin1String("Splash")
|
||||||
|
<< QLatin1String("Textures")
|
||||||
|
<< QLatin1String("Video");
|
||||||
|
|
||||||
|
foreach (const QString &dir, directories) {
|
||||||
|
installDirectory(dir, temp.absolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Install files outside of cab archives
|
// Install directories from disk
|
||||||
installDirectories(disk.absolutePath());
|
foreach (const QString &dir, directories) {
|
||||||
|
qDebug() << "\n\nDISK DIRS!";
|
||||||
|
installDirectory(dir, disk.absolutePath(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
QFileInfo info(disk.absoluteFilePath("Data Files"));
|
||||||
|
if (info.exists()) {
|
||||||
|
emit textChanged(tr("Installing: Data Files directory"));
|
||||||
|
copyDirectory(info.absoluteFilePath(), getPath());
|
||||||
|
}
|
||||||
|
|
||||||
if (component == Wizard::Component_Morrowind)
|
if (component == Wizard::Component_Morrowind)
|
||||||
{
|
{
|
||||||
// Some installations have a separate Splash directory
|
QStringList files;
|
||||||
QFileInfo splash(temp.absoluteFilePath(QLatin1String("Splash")));
|
files << QLatin1String("Morrowind.esm")
|
||||||
|
<< QLatin1String("Morrowin.bsa");
|
||||||
|
|
||||||
if (splash.exists()) {
|
foreach (const QString &file, files) {
|
||||||
emit textChanged(tr("Extracting: Splash directory"));
|
if (!installFile(file, temp.absolutePath())) {
|
||||||
copyDirectory(splash.absoluteFilePath(), getPath() + QDir::separator() + QLatin1String("Splash"));
|
emit error(tr("Could not find Morrowind data file!"), tr("Failed to find %1.").arg(file));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy Morrowind configuration file
|
// Copy Morrowind configuration file
|
||||||
QString iniPath(temp.absoluteFilePath(QLatin1String("App Executables")));
|
if (!installFile(QLatin1String("Morrowind.ini"), temp.absolutePath())) {
|
||||||
iniPath.append(QDir::separator() + QLatin1String("Morrowind.ini"));
|
emit error(tr("Could not find Morrowind configuration file!"), tr("Failed to find %1.").arg(QLatin1String("Morrowind.ini")));
|
||||||
|
|
||||||
QFileInfo info(iniPath);
|
|
||||||
|
|
||||||
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!";
|
|
||||||
emit error(tr("Could not find Morrowind configuration file!"), tr("Failed to find %1.").arg(iniPath));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -620,23 +696,43 @@ bool Wizard::UnshieldWorker::installComponent(Component component)
|
||||||
QFileInfo sounds(temp.absoluteFilePath(QLatin1String("Sounds")));
|
QFileInfo sounds(temp.absoluteFilePath(QLatin1String("Sounds")));
|
||||||
|
|
||||||
if (sounds.exists()) {
|
if (sounds.exists()) {
|
||||||
emit textChanged(tr("Extracting: Sound directory"));
|
emit textChanged(tr("Installing: Sound directory"));
|
||||||
copyDirectory(sounds.absoluteFilePath(), getPath() + QDir::separator() + QLatin1String("Sound"));
|
copyDirectory(sounds.absoluteFilePath(), getPath() + QDir::separator() + QLatin1String("Sound"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList files;
|
||||||
|
files << QLatin1String("Tribunal.esm")
|
||||||
|
<< QLatin1String("Tribunal.bsa");
|
||||||
|
|
||||||
|
foreach (const QString &file, files) {
|
||||||
|
if (!installFile(file, temp.absolutePath())) {
|
||||||
|
emit error(tr("Could not find Tribunal data file!"), tr("Failed to find %1.").arg(file));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component == Wizard::Component_Bloodmoon)
|
if (component == Wizard::Component_Bloodmoon)
|
||||||
{
|
{
|
||||||
QFileInfo patch(temp.absoluteFilePath(QLatin1String("Tribunal Patch") + QDir::separator() + QLatin1String("Tribunal.esm")));
|
|
||||||
QFileInfo original(getPath() + QDir::separator() + QLatin1String("Tribunal.esm"));
|
QFileInfo original(getPath() + QDir::separator() + QLatin1String("Tribunal.esm"));
|
||||||
|
|
||||||
// Look for the patch in other places too, it's not always in "Tribunal Patch"
|
if (original.exists()) {
|
||||||
if (!patch.exists())
|
if (!installFile(QLatin1String("Tribunal.esm"), temp.absolutePath())) {
|
||||||
patch = QFileInfo(temp.absoluteFilePath(QLatin1String("Tribunal") + QDir::separator() + QLatin1String("Tribunal.esm")));
|
emit error(tr("Could not find Tribunal patch file!"), tr("Failed to find %1.").arg(QLatin1String("Tribunal.esm")));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (original.exists() && patch.exists()) {
|
QStringList files;
|
||||||
emit textChanged(tr("Extracting: Tribunal patch"));
|
files << QLatin1String("Bloodmoon.esm")
|
||||||
copyFile(patch.absoluteFilePath(), original.absoluteFilePath());
|
<< QLatin1String("Bloodmoon.bsa");
|
||||||
|
|
||||||
|
foreach (const QString &file, files) {
|
||||||
|
if (!installFile(file, temp.absolutePath())) {
|
||||||
|
emit error(tr("Could not find Bloodmoon data file!"), tr("Failed to find %1.").arg(file));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load Morrowind configuration settings from the setup script
|
// Load Morrowind configuration settings from the setup script
|
||||||
|
@ -655,10 +751,10 @@ bool Wizard::UnshieldWorker::installComponent(Component component)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Wizard::UnshieldWorker::extractFile(Unshield *unshield, const QString &outputDir, const QString &prefix, int index, int counter)
|
bool Wizard::UnshieldWorker::extractFile(Unshield *unshield, const QString &destination, const QString &prefix, int index, int counter)
|
||||||
{
|
{
|
||||||
bool success;
|
bool success;
|
||||||
QString path(outputDir);
|
QString path(destination);
|
||||||
path.append(QDir::separator());
|
path.append(QDir::separator());
|
||||||
|
|
||||||
int directory = unshield_file_directory(unshield, index);
|
int directory = unshield_file_directory(unshield, index);
|
||||||
|
@ -703,7 +799,42 @@ bool Wizard::UnshieldWorker::extractFile(Unshield *unshield, const QString &outp
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Wizard::UnshieldWorker::findFile(const QString &cabFile, const QString &fileName)
|
QString Wizard::UnshieldWorker::findFile(const QString &fileName, const QString &path)
|
||||||
|
{
|
||||||
|
return findFiles(fileName, path).first();
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList Wizard::UnshieldWorker::findFiles(const QString &fileName, const QString &path)
|
||||||
|
{
|
||||||
|
QStringList result;
|
||||||
|
QDir dir(source);
|
||||||
|
|
||||||
|
if (!dir.exists())
|
||||||
|
return QStringList();
|
||||||
|
|
||||||
|
QFileInfoList list(dir.entryInfoList(QDir::NoDotAndDotDot |
|
||||||
|
QDir::System | QDir::Hidden |
|
||||||
|
QDir::AllDirs | QDir::Files, QDir::DirsFirst));
|
||||||
|
foreach(QFileInfo info, list) {
|
||||||
|
|
||||||
|
if (info.isSymLink())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (info.isDir()) {
|
||||||
|
result = findFiles(file, info.absoluteFilePath());
|
||||||
|
} else {
|
||||||
|
if (info.fileName() == fileName) {
|
||||||
|
qDebug() << "File found at: " << info.absoluteFilePath();
|
||||||
|
result.append(info.absoluteFilePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Wizard::UnshieldWorker::findInCab(const QString &cabFile, const QString &fileName)
|
||||||
{
|
{
|
||||||
QByteArray array(cabFile.toUtf8());
|
QByteArray array(cabFile.toUtf8());
|
||||||
|
|
||||||
|
@ -724,7 +855,7 @@ bool Wizard::UnshieldWorker::findFile(const QString &cabFile, const QString &fil
|
||||||
|
|
||||||
if (unshield_file_is_valid(unshield, j)) {
|
if (unshield_file_is_valid(unshield, j)) {
|
||||||
QString current(QString::fromUtf8(unshield_file_name(unshield, j)));
|
QString current(QString::fromUtf8(unshield_file_name(unshield, j)));
|
||||||
|
qDebug() << "Current is: " << current;
|
||||||
if (current.toLower() == fileName.toLower())
|
if (current.toLower() == fileName.toLower())
|
||||||
return true; // File is found!
|
return true; // File is found!
|
||||||
}
|
}
|
||||||
|
@ -735,7 +866,7 @@ bool Wizard::UnshieldWorker::findFile(const QString &cabFile, const QString &fil
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Wizard::UnshieldWorker::extractCab(const QString &cabFile, const QString &outputDir)
|
bool Wizard::UnshieldWorker::extractCab(const QString &cabFile, const QString &destination)
|
||||||
{
|
{
|
||||||
bool success;
|
bool success;
|
||||||
|
|
||||||
|
@ -758,7 +889,7 @@ bool Wizard::UnshieldWorker::extractCab(const QString &cabFile, const QString &o
|
||||||
for (size_t j=group->first_file; j<=group->last_file; ++j)
|
for (size_t j=group->first_file; j<=group->last_file; ++j)
|
||||||
{
|
{
|
||||||
if (unshield_file_is_valid(unshield, j)) {
|
if (unshield_file_is_valid(unshield, j)) {
|
||||||
success = extractFile(unshield, outputDir, group->name, j, counter);
|
success = extractFile(unshield, destination, group->name, j, counter);
|
||||||
++counter;
|
++counter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,11 +62,15 @@ namespace Wizard
|
||||||
bool moveFile(const QString &source, const QString &destination);
|
bool moveFile(const QString &source, const QString &destination);
|
||||||
bool moveDirectory(const QString &source, const QString &destination);
|
bool moveDirectory(const QString &source, const QString &destination);
|
||||||
|
|
||||||
bool extractCab(const QString &cabFile, const QString &outputDir);
|
bool extractCab(const QString &cabFile, const QString &destination);
|
||||||
bool extractFile(Unshield *unshield, const QString &outputDir, const QString &prefix, int index, int counter);
|
bool extractFile(Unshield *unshield, const QString &destination, const QString &prefix, int index, int counter);
|
||||||
bool findFile(const QString &cabFile, const QString &fileName);
|
bool findInCab(const QString &cabFile, const QString &fileName);
|
||||||
|
|
||||||
void installDirectories(const QString &source);
|
QString findFile(const QString &fileName, const QString &path);
|
||||||
|
QStringList findFiles(const QString &fileName, const QString &path);
|
||||||
|
|
||||||
|
bool installFile(const QString &fileName, const QString &path);
|
||||||
|
bool installDirectory(const QString &dirName, const QString &path, bool recursive = true);
|
||||||
|
|
||||||
bool installMorrowind();
|
bool installMorrowind();
|
||||||
bool installTribunal();
|
bool installTribunal();
|
||||||
|
|
Loading…
Reference in a new issue