From 8786c41440b7e132cdfd12ad8932ceeb28f08a93 Mon Sep 17 00:00:00 2001 From: Victor Popovici Date: Wed, 13 Nov 2013 16:42:01 +0100 Subject: [PATCH] [fixed] local installation bugs --- gameprocess.cpp | 2 +- installfromswg.cpp | 26 ++++++++++++++++---------- mainwindow.cpp | 22 ++++++++++++---------- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/gameprocess.cpp b/gameprocess.cpp index a8b21a1..60173f3 100644 --- a/gameprocess.cpp +++ b/gameprocess.cpp @@ -56,7 +56,7 @@ bool GameProcess::start(const QString& folder, const QString& executable, const connect(process, SIGNAL(started()), this, SLOT(started())); QStringList env = process->environment(); - env.append("SWGCLIENT_MEMORY_SIZE_MB=4096"); + //env.append("SWGCLIENT_MEMORY_SIZE_MB=4096"); qDebug() << "env:" << env; process->setEnvironment(env); diff --git a/installfromswg.cpp b/installfromswg.cpp index db41185..fe07be3 100644 --- a/installfromswg.cpp +++ b/installfromswg.cpp @@ -49,6 +49,8 @@ void InstallFromSWG::copyFinished() { } void InstallFromSWG::closeEvent(QCloseEvent* event) { + qDebug() << "close event"; + cancelThreads = true; if (copyWatcher.isRunning()) { @@ -56,6 +58,8 @@ void InstallFromSWG::closeEvent(QCloseEvent* event) { copyWatcher.waitForFinished(); } + done(2); + QDialog::closeEvent(event); } @@ -68,12 +72,12 @@ int InstallFromSWG::copyFiles() { //if (QDir(file)) if (file.first.contains("/")) { - QString dir = emuFolder + "\\" + file.first.mid(0, file.first.lastIndexOf("/")); + QString dir = emuFolder + file.first.mid(0, file.first.lastIndexOf("/")); QDir(dir).mkpath("."); } - bool result = QFile::copy(swgfolder + "\\" + file.first, emuFolder + "\\" + file.first); + bool result = QFile::copy(swgfolder + "\\" + file.first, emuFolder + file.first); //bool result = true; //QTimer::singleShot(0, this, SLOT(fileCopied(file.first, result))); @@ -89,15 +93,9 @@ int InstallFromSWG::copyFiles() { void InstallFromSWG::fileCopied(const QString& file, bool success) { if (success) { ui->label->setText(file + " successfully installed"); - - ui->progressBar->setValue(ui->progressBar->value()+ 1); - } else { - //ui->label->setPalette(QPalette(Qt::red)); - ui->label->setText("Unable to copy file: " + file); - - ui->progressBar->setValue(ui->progressBar->maximum()); } + ui->progressBar->setValue(ui->progressBar->value() + 1); } int InstallFromSWG::checkSWGFolder() { @@ -142,12 +140,20 @@ int InstallFromSWG::installFiles() { QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); - if (!QDir(emuFolder).exists()) { + if (!QDir(emuFolder).exists() || emuFolder.isEmpty()) { QMessageBox::warning(this, "Folder", "The swgemu folder you selected isnt a valid directory"); return 1; } + //qDebug() << emuFolder; + emuFolder = emuFolder + "/SWGEmu/"; + + if (QDir(emuFolder).exists()) { + if (QMessageBox::question(this, "Warning", "SWGEmu folder already exists, do you want to overwrite?") != QMessageBox::Yes) + return 3; + } + QVector > requiredFiles = MainWindow::getRequiredFiles(); ui->progressBar->setValue(0); diff --git a/mainwindow.cpp b/mainwindow.cpp index 13e9954..6f200bc 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -24,7 +24,7 @@ QString MainWindow::patchUrl = "http://www.launchpad2.net/SWGEmu/"; QString MainWindow::newsUrl = "http://www.swgemu.com/forums/index.php#bd"; QString MainWindow::gameExecutable = "SWGEmu.exe"; QString MainWindow::selfUpdateUrl = "http://launchpad2.net/setup.cfg"; -const QString MainWindow::version = "0.12"; +const QString MainWindow::version = "0.13"; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), @@ -275,12 +275,12 @@ int MainWindow::loadAndBasicCheckFiles(QString swgFolder) { QFile* MainWindow::getRequiredFilesFile() { QSettings settings; - QString folder = settings.value("swg_folder").toString(); + //QString folder = settings.value("swg_folder").toString(); QFile* file = NULL; - if (QDir(folder).exists()) { - file = new QFile(folder + "/required2.txt"); + //if (QDir(folder).exists()) { + file = new QFile("required2.txt"); if (file->exists()) { if (file->open(QIODevice::ReadOnly | QIODevice::Text)) { @@ -290,7 +290,7 @@ QFile* MainWindow::getRequiredFilesFile() { } else { delete file; } - } + //} file = new QFile(":/files/required2.txt"); file->open(QIODevice::ReadOnly | QIODevice::Text); @@ -558,10 +558,10 @@ void MainWindow::requiredFileDownloadFileFinished(QNetworkReply* reply) { // qDebug() << data; QSettings settings; - QString folder = settings.value("swg_folder").toString(); + // QString folder = settings.value("swg_folder").toString(); - if (QDir(folder).exists()) { - QFile file(folder + "/" + "required2.txt"); + // if (QDir(folder).exists()) { + QFile file("required2.txt"); if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { QTextStream stream(&file); @@ -572,7 +572,7 @@ void MainWindow::requiredFileDownloadFileFinished(QNetworkReply* reply) { return; } - } + //} startLoadBasicCheck(); @@ -625,7 +625,9 @@ void MainWindow::startFullScan(bool forceConfigRestore) { QSettings settings; QString folder = settings.value("swg_folder").toString(); - if (!QDir(folder).exists() || folder.isEmpty()) { + QDir checkDir(folder); + + if (!checkDir.exists() || folder.isEmpty() || checkDir.count() < 5) { QMessageBox::warning(this, "ERROR", "Invalid game folder!"); return;