Skip to content

Commit 5bc0903

Browse files
committed
add Runner
1 parent 271e6b5 commit 5bc0903

File tree

5 files changed

+106
-9
lines changed

5 files changed

+106
-9
lines changed

CMakeLists.txt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,23 @@ set(SOURCES_TESTS
4545
)
4646

4747
set(SOURCES_MC
48-
src/main.cpp
49-
src/binary.hpp
50-
src/GameFileTree.hpp
51-
src/GameFileTree.cpp
52-
src/staticData.hpp
53-
src/Network.hpp
54-
src/Network.cpp
5548
src/Controller.hpp
5649
src/Controller.cpp
50+
src/Data.hpp
51+
src/Data.cpp
5752
src/FileManager.hpp
5853
src/FileManager.cpp
54+
src/GameFileTree.hpp
55+
src/GameFileTree.cpp
5956
src/Model.hpp
6057
src/Model.cpp
61-
src/Data.hpp
62-
src/Data.cpp
58+
src/Network.hpp
59+
src/Network.cpp
60+
src/Runner.cpp
61+
src/Runner.hpp
62+
src/binary.hpp
63+
src/main.cpp
64+
src/staticData.hpp
6365
)
6466

6567
set(SOURCES_VIEW

src/Runner.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* TombRaiderLinuxLauncher
2+
* Martin Bångens Copyright (C) 2024
3+
* This program is free software: you can redistribute it and/or modify
4+
* it under the terms of the GNU General Public License as published by
5+
* the Free Software Foundation, either version 3 of the License, or
6+
* (at your option) any later version.
7+
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*/
13+
14+
#include "Runner.hpp"
15+
16+
Runner::Runner() : m_env(QProcessEnvironment::systemEnvironment()) {
17+
m_status = 0;
18+
// You can modify the environment of the process if needed
19+
// m_env.insert("WINEPREFIX", "/path/to/wineprefix");
20+
// m_process.setProcessEnvironment(m_env);
21+
}
22+
23+
Runner::Runner(const QString& cmd)
24+
: m_env(QProcessEnvironment::systemEnvironment()) {
25+
m_env.insert("WINEDLLOVERRIDES", "winmm=n,b");
26+
m_process.setProcessEnvironment(m_env);
27+
m_status = 0;
28+
m_command = cmd;
29+
}
30+
31+
void Runner::run() {
32+
// Start Wine with the application as an argument
33+
m_process.setWorkingDirectory("/home/noisecode3/.local/share/TombRaiderLinuxLauncher/19.TRLE");
34+
m_process.start(m_command, QStringList() << "SabatuTR2.exe");
35+
QObject::connect(&m_process, &QProcess::readyReadStandardOutput, [&]() {
36+
// Read and print the output to standard output
37+
QTextStream(stdout) << m_process.readAllStandardOutput();
38+
});
39+
40+
if (m_process.waitForStarted() == true) {
41+
m_process.waitForFinished();
42+
m_status = 0;
43+
} else {
44+
m_status = 1;
45+
qWarning() << "Failed to start Wine process!";
46+
}
47+
}

src/Runner.hpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* TombRaiderLinuxLauncher
2+
* Martin Bångens Copyright (C) 2024
3+
* This program is free software: you can redistribute it and/or modify
4+
* it under the terms of the GNU General Public License as published by
5+
* the Free Software Foundation, either version 3 of the License, or
6+
* (at your option) any later version.
7+
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*/
13+
14+
#ifndef SRC_RUNNER_HPP_
15+
#define SRC_RUNNER_HPP_
16+
17+
#include <QProcess>
18+
#include <QProcessEnvironment>
19+
#include <QDebug>
20+
21+
22+
class Runner : public QObject {
23+
Q_OBJECT
24+
25+
public:
26+
Runner();
27+
explicit Runner(const QString& cmd);
28+
void run();
29+
int getStatus();
30+
int getCommand();
31+
bool setCommand(const QString& cmd);
32+
33+
signals:
34+
void started();
35+
void stopped();
36+
37+
private:
38+
QProcessEnvironment m_env;
39+
QProcess m_process;
40+
QString m_command;
41+
qint64 m_status;
42+
};
43+
44+
#endif // SRC_RUNNER_HPP_

src/TombRaiderLinuxLauncher.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,8 @@ void TombRaiderLinuxLauncher::setOptionsClicked() {
422422
}
423423

424424
void TombRaiderLinuxLauncher::linkClicked() {
425+
// m_r.run();
426+
// test
425427
bool status = false;
426428
QListWidgetItem *selectedItem = ui->listWidgetModds->currentItem();
427429
int id = selectedItem->data(Qt::UserRole).toInt();

src/TombRaiderLinuxLauncher.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <QDebug>
2626
#include <QVector>
2727
#include <QString>
28+
#include "Runner.hpp"
2829

2930
#include "Controller.hpp"
3031

@@ -144,6 +145,7 @@ class TombRaiderLinuxLauncher : public QMainWindow {
144145
Controller& controller = Controller::getInstance();
145146
QSettings m_settings;
146147
Ui::TombRaiderLinuxLauncher *ui;
148+
Runner m_r = Runner("/usr/bin/wine");
147149
};
148150

149151
struct OriginalGameData {

0 commit comments

Comments
 (0)