diff --git a/src/constants.h b/src/constants.h index 51889aa..8551fed 100644 --- a/src/constants.h +++ b/src/constants.h @@ -6,6 +6,8 @@ const QString version = "v1.3.1"; +static QString gameName = ""; + const QString DSDALAUNCHER_URL = "https://github.com/Pedro-Beirao/dsda-launcher"; const QString DSDALAUNCHER_API_URL = "https://api.github.com/repos/Pedro-Beirao/dsda-launcher/releases/latest"; const QString DSDALAUNCHER_DOWNLOAD_URL = "https://github.com/Pedro-Beirao/dsda-launcher/releases/latest"; @@ -24,7 +26,7 @@ const QChar FOLDER_SEPARATOR = '/'; const QString dotfolder = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/.dsda-doom"; #endif -static QString execPath; +static QString launcherFolderPath = ""; const QStringList exmxIWADS = {"doom", "doom1", "doomu", "freedoom", "freedoom1", "bfgdoom", "bfgdoom1", diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2cda0c3..42ed438 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3,7 +3,7 @@ QSettings *settings; MainWindow *MainWindow::pMainWindow = nullptr; -void MainWindow::changeExeName(QString newName) { exeName = newName; } +void MainWindow::changeExeName(QString newName) { gameName = newName; } void MainWindow::showSSLDialog() { @@ -55,7 +55,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi ui->setupUi(this); MainWindow::pMainWindow = this; - execPath = QCoreApplication::applicationDirPath(); + launcherFolderPath = QCoreApplication::applicationDirPath(); // Allow files to be droped in the launcher (*.wad *.lmp *.deh *.bex) setAcceptDrops(true); @@ -207,8 +207,6 @@ void MainWindow::saveSelected() // Bottom settings->setValue("argumentText", ui->additionalArguments_textEdit->toPlainText()); - settings->setValue("exeName", exeName); - settings->setValue("version", version); settings->sync(); @@ -453,7 +451,7 @@ void MainWindow::started() { running = true; } void MainWindow::gameIsRunningDialog() { QMessageBox msgBox; - msgBox.setText(exeName + " is still running."); + msgBox.setText("dsda-doom is still running."); msgBox.addButton("Ok", QMessageBox::YesRole); msgBox.exec(); } @@ -644,7 +642,7 @@ void MainWindow::on_launchGame_pushButton_clicked(bool returnTooltip, QString ex QTextStream out(&file); #ifdef __APPLE__ - out << "\"" + execPath + "/../Resources/" + exeName + "\" -iwad \"" + ui->iwad_comboBox->itemData(ui->iwad_comboBox->currentIndex(), Qt::ToolTipRole).toString() + "\" " + argStrComplete; + out << "\"" + launcherFolderPath + "/../Resources/" + gameName + "\" -iwad \"" + ui->iwad_comboBox->itemData(ui->iwad_comboBox->currentIndex(), Qt::ToolTipRole).toString() + "\" " + argStrComplete; #elif __linux__ out << "\"" + execPath + "/" + exeName + "\" -iwad \"" + ui->iwad_comboBox->itemData(ui->iwad_comboBox->currentIndex(), Qt::ToolTipRole).toString() + "\" " + argStrComplete; #else @@ -657,7 +655,7 @@ void MainWindow::on_launchGame_pushButton_clicked(bool returnTooltip, QString ex } QMessageBox msgBox; - msgBox.setText("Executable: " + exeName + "\nIWAD: " + ui->iwad_comboBox->currentText() + "\nParameters: " + argStr); + msgBox.setText("Executable: " + gameName + "\nIWAD: " + ui->iwad_comboBox->currentText() + "\nParameters: " + argStr); msgBox.addButton(tr("Copy"), QMessageBox::NoRole); QPushButton *pButtonYes = msgBox.addButton(tr("Ok"), QMessageBox::YesRole); msgBox.setDefaultButton(pButtonYes); @@ -667,7 +665,7 @@ void MainWindow::on_launchGame_pushButton_clicked(bool returnTooltip, QString ex { QClipboard *clip = QApplication::clipboard(); #ifdef __APPLE__ - clip->setText("\"" + execPath + "/../Resources/" + exeName + "\" -iwad \"" + ui->iwad_comboBox->itemData(ui->iwad_comboBox->currentIndex(), Qt::ToolTipRole).toString() + "\" " + argStrComplete); + clip->setText("\"" + launcherFolderPath + "/../Resources/" + gameName + "\" -iwad \"" + ui->iwad_comboBox->itemData(ui->iwad_comboBox->currentIndex(), Qt::ToolTipRole).toString() + "\" " + argStrComplete); #elif __linux__ clip->setText("\"" + execPath + "/" + exeName + "\" -iwad \"" + ui->iwad_comboBox->itemData(ui->iwad_comboBox->currentIndex(), Qt::ToolTipRole).toString() + "\" " + argStrComplete); #else @@ -703,13 +701,13 @@ void MainWindow::Launch(QStringList arguments) } #ifdef __APPLE__ - QFile port = QFile(execPath + "/../Resources/" + exeName + ""); + QFile port = QFile(launcherFolderPath + "/../Resources/" + gameName + ""); if (port.exists()) { QString homePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); QProcess *process = new QProcess; process->setWorkingDirectory(homePath); - process->start(execPath + "/../Resources/" + exeName, arguments); + process->start(launcherFolderPath + "/../Resources/" + gameName, arguments); connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finished(int, QProcess::ExitStatus))); connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(readyReadStandardOutput())); connect(process, SIGNAL(readyReadStandardError()), this, SLOT(readyReadStandardError())); @@ -717,7 +715,7 @@ void MainWindow::Launch(QStringList arguments) } else { - QMessageBox::warning(this, "dsda-launcher", exeName + " was not found in dsda-launcher.app/Contents/Resources/" + exeName); + QMessageBox::warning(this, "dsda-launcher", gameName + " was not found in dsda-launcher.app/Contents/Resources/" + gameName); } #elif __LINUX__ QFile port = QFile(execPath + "/" + exeName); diff --git a/src/mainwindow.h b/src/mainwindow.h index 0e646d0..2929c20 100755 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -58,8 +58,6 @@ class MainWindow : public QMainWindow bool running = false; void gameIsRunningDialog(); - QString exeName = "dsda-doom"; - void enable_disable_skill_comboBox(); // Prevents launching the game twice if the button "Launch" is pressed twice quickly diff --git a/src/mainwindow_actions.cpp b/src/mainwindow_actions.cpp index 01d37e6..72778ff 100644 --- a/src/mainwindow_actions.cpp +++ b/src/mainwindow_actions.cpp @@ -90,11 +90,11 @@ void MainWindow::on_actionCheckForUpdatesDsdadoom_triggered() QString path; #ifdef __APPLE__ - path = execPath + "/../Resources/" + exeName; + path = launcherFolderPath + "/../Resources/" + gameName; #elif __linux__ - path = execPath + "/" + exeName; + path = execPath + "/" + gameName; #else - path = execPath + "/" + exeName + ".exe"; + path = execPath + "\\" + gameName + ".exe"; #endif QFile port = QFile(path); if (port.exists()) diff --git a/src/mainwindow_bottom.cpp b/src/mainwindow_bottom.cpp index 1cf6385..475aecc 100644 --- a/src/mainwindow_bottom.cpp +++ b/src/mainwindow_bottom.cpp @@ -15,11 +15,11 @@ void MainWindow::on_additionalArguments_pushButton_clicked() QString path; #ifdef __APPLE__ - path = execPath + "/../Resources/" + exeName; + path = launcherFolderPath + "/../Resources/" + gameName; #elif __linux__ - path = execPath + "/" + exeName; + path = execPath + "/" + gameName; #else - path = execPath + "/" + exeName + ".exe"; + path = execPath + "\\" + gameName + ".exe"; #endif QFile port = QFile(path); diff --git a/src/mainwindow_top.cpp b/src/mainwindow_top.cpp index 2c4fc6a..8bf9217 100644 --- a/src/mainwindow_top.cpp +++ b/src/mainwindow_top.cpp @@ -11,7 +11,7 @@ QFileInfoList MainWindow::findIwads_possibleFiles() // Copies dsda-doom.wad to the dotfolder #if defined(Q_OS_MAC) - QProcess::startDetached("cp", {execPath + "/../Resources/" + exeName + ".wad", dotfolder}); + QProcess::startDetached("cp", {launcherFolderPath + "/../Resources/" + gameName + ".wad", dotfolder}); #endif QDir directory(dotfolder); diff --git a/src/settings.cpp b/src/settings.cpp index e25549f..0aab0ed 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -21,7 +21,7 @@ Settings::Settings(QWidget *parent) : ui->PWADFolders_textBrowser->setVisible(false); ui->IWADFolders_textBrowser->setVisible(false); - if(settings->value("complevels").toString()=="") + if (settings->value("complevels").isNull()) { ui->minimalComplevels_radioButton->setChecked(true); ui->remember_checkBox->setChecked(true); @@ -407,7 +407,7 @@ void Settings::on_save_pushButton_clicked() MainWindow::pMainWindow->setToggles(ui->fastText_lineEdit->text(), ui->fastParam_lineEdit->text(), ui->nomoText_lineEdit->text(), ui->nomoParam_lineEdit->text(), ui->respawnText_lineEdit->text(), ui->respawnParam_lineEdit->text(), ui->solonetText_lineEdit->text(), ui->solonetParam_lineEdit->text()); - if (ui->executable_lineEdit->text()=="") + if (ui->executable_lineEdit->text().isEmpty()) { MainWindow::pMainWindow->changeExeName("dsda-doom"); } @@ -416,6 +416,8 @@ void Settings::on_save_pushButton_clicked() MainWindow::pMainWindow->changeExeName(ui->executable_lineEdit->text()); } + settings->setValue("exeName", ui->executable_lineEdit->text()); + settings->setValue("toggle1t", ui->fastText_lineEdit->text()); settings->setValue("toggle1a", ui->fastParam_lineEdit->text()); diff --git a/src/settings.ui b/src/settings.ui index b9ab9e4..dd8fdc7 100644 --- a/src/settings.ui +++ b/src/settings.ui @@ -56,7 +56,7 @@ QTabWidget::Rounded - 0 + 1 Qt::ElideNone @@ -210,6 +210,9 @@ font: 7px; <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css"> p, li { white-space: pre-wrap; } +hr { height: 1px; border-width: 0; } +li.unchecked::marker { content: "\2610"; } +li.checked::marker { content: "\2612"; } </style></head><body style=" font-family:'.AppleSystemUIFont'; font-size:7px; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:11pt;">When droping .lmp files into the launcher, it autoselects the correct IWAD, PWADs and complevel.</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:11pt;">For this to work, you need to add the folders you have your PWADs in, to the following container.</span></p></body></html> @@ -373,6 +376,9 @@ border-radius:3px <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css"> p, li { white-space: pre-wrap; } +hr { height: 1px; border-width: 0; } +li.unchecked::marker { content: "\2610"; } +li.checked::marker { content: "\2612"; } </style></head><body style=" font-family:'.AppleSystemUIFont'; font-size:13pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:11pt;">The launcher will search for IWADs on these folders.</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> @@ -515,7 +521,7 @@ when the Launcher exits - 440 + 450 205 71 32 @@ -974,7 +980,7 @@ color: rgb(255, 255, 255); - 310 + 320 212 131 16 @@ -990,9 +996,9 @@ color: rgb(255, 255, 255); - 100 - 205 - 121 + 90 + 208 + 141 24 @@ -1011,8 +1017,8 @@ border-radius:3px - 20 - 208 + 15 + 212 121 16 @@ -1027,7 +1033,7 @@ border-radius:3px - 390 + 400 212 131 16