Skip to content

Commit

Permalink
A few renames of variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro-Beirao committed May 23, 2024
1 parent 2cd6595 commit 1e4839f
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 32 deletions.
4 changes: 3 additions & 1 deletion src/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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",

Expand Down
20 changes: 9 additions & 11 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -703,21 +701,21 @@ 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()));
connect(process, SIGNAL(started()), this, SLOT(started()));
}
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);
Expand Down
2 changes: 0 additions & 2 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/mainwindow_actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
6 changes: 3 additions & 3 deletions src/mainwindow_bottom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/mainwindow_top.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
}
Expand All @@ -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());

Expand Down
24 changes: 15 additions & 9 deletions src/settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<property name="elideMode">
<enum>Qt::ElideNone</enum>
Expand Down Expand Up @@ -210,6 +210,9 @@ font: 7px;</string>
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
hr { height: 1px; border-width: 0; }
li.unchecked::marker { content: &quot;\2610&quot;; }
li.checked::marker { content: &quot;\2612&quot;; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'.AppleSystemUIFont'; font-size:7px; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:11pt;&quot;&gt;When droping .lmp files into the launcher, it autoselects the correct IWAD, PWADs and complevel.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:11pt;&quot;&gt;For this to work, you need to add the folders you have your PWADs in, to the following container.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
Expand Down Expand Up @@ -373,6 +376,9 @@ border-radius:3px</string>
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
hr { height: 1px; border-width: 0; }
li.unchecked::marker { content: &quot;\2610&quot;; }
li.checked::marker { content: &quot;\2612&quot;; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'.AppleSystemUIFont'; font-size:13pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:11pt;&quot;&gt;The launcher will search for IWADs on these folders.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
Expand Down Expand Up @@ -515,7 +521,7 @@ when the Launcher exits</string>
<widget class="QPushButton" name="save_pushButton">
<property name="geometry">
<rect>
<x>440</x>
<x>450</x>
<y>205</y>
<width>71</width>
<height>32</height>
Expand Down Expand Up @@ -974,7 +980,7 @@ color: rgb(255, 255, 255);</string>
</property>
<property name="geometry">
<rect>
<x>310</x>
<x>320</x>
<y>212</y>
<width>131</width>
<height>16</height>
Expand All @@ -990,9 +996,9 @@ color: rgb(255, 255, 255);</string>
<widget class="QLineEdit" name="executable_lineEdit">
<property name="geometry">
<rect>
<x>100</x>
<y>205</y>
<width>121</width>
<x>90</x>
<y>208</y>
<width>141</width>
<height>24</height>
</rect>
</property>
Expand All @@ -1011,8 +1017,8 @@ border-radius:3px</string>
<widget class="QLabel" name="executable_label">
<property name="geometry">
<rect>
<x>20</x>
<y>208</y>
<x>15</x>
<y>212</y>
<width>121</width>
<height>16</height>
</rect>
Expand All @@ -1027,7 +1033,7 @@ border-radius:3px</string>
</property>
<property name="geometry">
<rect>
<x>390</x>
<x>400</x>
<y>212</y>
<width>131</width>
<height>16</height>
Expand Down

0 comments on commit 1e4839f

Please sign in to comment.