Skip to content

Commit 87bce56

Browse files
authored
Fix all runners (#3)
* fix all runners - start * use 4 worker threads * run on the other thread and print the output bash work * Add back UMU and wine, better separation of concerns * dont clear systemEnvironment * fix just link * fix lutris and steam
1 parent e83cf8e commit 87bce56

23 files changed

+410
-286
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ if(NOT EXISTS "${CMAKE_SOURCE_DIR}/libs/LIEF/CMakeLists.txt")
4646
)
4747
endif()
4848
set(LIEF_INSTALL OFF CACHE BOOL "Disable installation of LIEF")
49+
set(LIEF_PYTHON_API OFF)
4950
set(LIEF_EXAMPLES OFF)
5051
set(LIEF_TESTS OFF)
5152
set(LIEF_DOC OFF)
@@ -137,6 +138,7 @@ set(SOURCES_MC
137138
src/binary.hpp
138139
src/binary.cpp
139140
src/gameFileTreeData.hpp
141+
src/globalTypes.hpp
140142
src/main.cpp
141143
src/staticData.hpp
142144
)

libs/LIEF

Submodule LIEF updated 1019 files

src/Controller.cpp

Lines changed: 58 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,25 @@
1515
#include <QMetaObject>
1616

1717
Controller::Controller() {
18-
threadA.reset(new QThread());
19-
threadB.reset(new QThread());
20-
workerA.reset(new QObject());
21-
workerB.reset(new QObject());
22-
23-
workerA->moveToThread(threadA.data());
24-
workerB->moveToThread(threadB.data());
25-
26-
threadA->start();
27-
threadB->start();
18+
threadDatabase.reset(new QThread());
19+
threadFile.reset(new QThread());
20+
threadScrape.reset(new QThread());
21+
threadRun.reset(new QThread());
22+
23+
workerDatabase.reset(new QObject());
24+
workerFile.reset(new QObject());
25+
workerScrape.reset(new QObject());
26+
workerRun.reset(new QObject());
27+
28+
workerDatabase->moveToThread(threadDatabase.data());
29+
workerFile->moveToThread(threadFile.data());
30+
workerScrape->moveToThread(threadScrape.data());
31+
workerRun->moveToThread(threadRun.data());
32+
33+
threadDatabase->start();
34+
threadFile->start();
35+
threadScrape->start();
36+
threadRun->start();
2837

2938
connect(&model, &Model::modelTickSignal,
3039
this, &Controller::controllerTickSignal,
@@ -53,48 +62,71 @@ Controller::Controller() {
5362
connect(&model, &Model::modelLoadingDoneSignal,
5463
this, &Controller::controllerLoadingDone,
5564
Qt::QueuedConnection);
65+
66+
connect(&model, &Model::modelRunningDoneSignal,
67+
this, &Controller::controllerRunningDone,
68+
Qt::QueuedConnection);
5669
}
5770

5871
Controller::~Controller() {
59-
threadA->quit();
60-
threadB->quit();
61-
threadA->wait();
62-
threadB->wait();
72+
threadDatabase->quit();
73+
threadFile->quit();
74+
threadScrape->quit();
75+
threadRun->quit();
76+
77+
threadDatabase->wait();
78+
threadFile->wait();
79+
threadScrape->wait();
80+
threadRun->wait();
6381
}
6482

65-
void Controller::runOnThreadA(std::function<void()> func) {
66-
QMetaObject::invokeMethod(
67-
workerA.data(), [func]() { func(); }, Qt::QueuedConnection);
83+
void Controller::runOnThreadDatabase(std::function<void()> func) {
84+
QMetaObject::invokeMethod(workerDatabase.data(),
85+
[func]() { func(); }, Qt::QueuedConnection);
6886
}
6987

70-
void Controller::runOnThreadB(std::function<void()> func) {
71-
QMetaObject::invokeMethod(
72-
workerB.data(), [func]() { func(); }, Qt::QueuedConnection);
88+
void Controller::runOnThreadFile(std::function<void()> func) {
89+
QMetaObject::invokeMethod(workerFile.data(),
90+
[func]() { func(); }, Qt::QueuedConnection);
91+
}
92+
93+
void Controller::runOnThreadScrape(std::function<void()> func) {
94+
QMetaObject::invokeMethod(workerScrape.data(),
95+
[func]() { func(); }, Qt::QueuedConnection);
96+
}
97+
98+
void Controller::runOnThreadRun(std::function<void()> func) {
99+
QMetaObject::invokeMethod(workerRun.data(),
100+
[func]() { func(); }, Qt::QueuedConnection);
73101
}
74102

75103
// Threaded work
76104
void Controller::setup() {
77-
runOnThreadA([=]() { model.setup(); });
105+
runOnThreadFile([=]() { model.setup(); });
78106
}
79107

80108
void Controller::setupGame(int id) {
81-
runOnThreadA([=]() { model.setupGame(id); });
109+
runOnThreadFile([=]() { model.setupGame(id); });
82110
}
83111

84112
void Controller::setupLevel(int id) {
85-
runOnThreadA([=]() { model.getLevel(id); });
113+
runOnThreadFile([=]() { model.getLevel(id); });
86114
}
87115

88116
void Controller::updateLevel(int id) {
89-
runOnThreadA([=]() { model.updateLevel(id); });
117+
runOnThreadScrape([=]() { model.updateLevel(id); });
90118
}
91119

92120
void Controller::syncLevels() {
93-
runOnThreadA([=]() { model.syncLevels(); });
121+
runOnThreadScrape([=]() { model.syncLevels(); });
94122
}
95123

96124
void Controller::getCoverList(QVector<QSharedPointer<ListItemData>> items) {
97-
runOnThreadB([=]() { model.getCoverList(items); });
125+
runOnThreadDatabase([=]() { model.getCoverList(items); });
126+
}
127+
128+
void Controller::run(RunnerOptions opptions) {
129+
runOnThreadRun([=]() { model.run(opptions); });
98130
}
99131

100132
// UI/main thread work

src/Controller.hpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define SRC_CONTROLLER_HPP_
1616
#include <QObject>
1717
#include <QThread>
18+
#include "../src/globalTypes.hpp"
1819
#include "../src/Model.hpp"
1920

2021
/**
@@ -37,6 +38,7 @@ class Controller : public QObject {
3738
void updateLevel(int id);
3839
void syncLevels();
3940
void getCoverList(QVector<QSharedPointer<ListItemData>> items);
41+
void run(RunnerOptions opptions);
4042

4143
int checkGameDirectory(int id);
4244
void getList(QVector<QSharedPointer<ListItemData>>* list);
@@ -51,19 +53,27 @@ class Controller : public QObject {
5153
void controllerDownloadError(int status);
5254
void controllerReloadLevelList();
5355
void controllerLoadingDone();
56+
void controllerRunningDone();
5457

5558
private:
5659
Controller();
5760
~Controller();
5861
void initThreads();
5962

60-
void runOnThreadA(std::function<void()> func);
61-
void runOnThreadB(std::function<void()> func);
63+
void runOnThreadDatabase(std::function<void()> func);
64+
void runOnThreadFile(std::function<void()> func);
65+
void runOnThreadScrape(std::function<void()> func);
66+
void runOnThreadRun(std::function<void()> func);
6267

63-
QScopedPointer<QThread> threadA;
64-
QScopedPointer<QThread> threadB;
65-
QScopedPointer<QObject> workerA;
66-
QScopedPointer<QObject> workerB;
68+
QScopedPointer<QThread> threadDatabase;
69+
QScopedPointer<QThread> threadFile;
70+
QScopedPointer<QThread> threadScrape;
71+
QScopedPointer<QThread> threadRun;
72+
73+
QScopedPointer<QObject> workerDatabase;
74+
QScopedPointer<QObject> workerFile;
75+
QScopedPointer<QObject> workerScrape;
76+
QScopedPointer<QObject> workerRun;
6777

6878
Data& data = Data::getInstance();
6979
FileManager& fileManager = FileManager::getInstance();

src/Data.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ struct SteamAppIds {
9191
{4, 224980},
9292
{5, 225000},
9393
{6, 225020},
94+
{7, 224960},
95+
{8, 225300},
96+
{9, 225320},
97+
{10, 224980},
9498
};
9599
};
96100

src/FileManager.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,14 @@ qint64 FileManager::removeFileOrDirectory(Path path) {
340340
}
341341
return status;
342342
}
343+
344+
void FileManager::addLevelDir(Path& path, quint64 id) {
345+
// we use original game id as negative number
346+
347+
if (id < 0) {
348+
int orgId = (-1)*id;
349+
path << QString("Original.TR%1").arg(orgId);
350+
} else {
351+
path << QString("%1.TRLE").arg(id);
352+
}
353+
}

src/FileManager.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ class FileManager : public QObject {
201201
*/
202202
qint64 removeFileOrDirectory(Path path);
203203

204+
void addLevelDir(Path& path, quint64 id);
205+
204206
signals:
205207
void fileWorkTickSignal();
206208

0 commit comments

Comments
 (0)