Skip to content

Commit 2d023db

Browse files
committed
try running tomb4.exe with wine as a better starting point
If you set Runner Type to wine, its supper primitive it will just try /usr/bin/wine tomb4.exe from trle level dirr
1 parent f2a22f1 commit 2d023db

File tree

8 files changed

+52
-26
lines changed

8 files changed

+52
-26
lines changed

src/FileManager.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -291,39 +291,43 @@ int FileManager::checkFileInfo(const QString& file, bool lookGameDir) {
291291
return status;
292292
}
293293

294-
bool FileManager::linkGameDir(const QString& levelDir, const QString& gameDir) {
295-
bool status = false;
294+
QString FileManager::getExtraPath(const QString& levelDir) {
296295
const QString levelPath = QString("%1%2")
297296
.arg(m_levelDir.absolutePath(), levelDir);
298-
const QString gamePath = QString("%1/%2")
299-
.arg(m_gameDir.absolutePath(), gameDir);
300-
301297
StaticTrees staticTrees;
302298
QDir dir(levelPath);
303-
GameFileTree test(dir);
304-
test.printTree(1);
299+
GameFileTree tree(dir);
300+
tree.printTree(1);
305301
QString extraPath;
306302

307-
for (const GameFileTree* tree : staticTrees.data) {
308-
extraPath = test.matchesFromAnyNode(tree);
303+
for (const GameFileTree* stree : staticTrees.data) {
304+
extraPath = tree.matchesFromAnyNode(stree);
309305
if ((extraPath != QString("\0")) && (!extraPath.isEmpty())) {
310306
QTextStream(stdout)
311307
<< "game tree matches: " << extraPath << Qt::endl;
312308
break;
313309
}
314310
}
311+
return levelPath + extraPath;
312+
}
313+
314+
bool FileManager::linkGameDir(const QString& levelDir, const QString& gameDir) {
315+
bool status = false;
316+
const QString gamePath = QString("%1/%2")
317+
.arg(m_gameDir.absolutePath(), gameDir);
315318

319+
const QString levelPath = getExtraPath(levelDir);
316320
qDebug() << "levelPath: " << levelPath;
317321
qDebug() << "gamePath: " << gamePath;
318322

319-
if (QFile::link(levelPath + extraPath, gamePath) == true) {
323+
if (QFile::link(levelPath, gamePath) == true) {
320324
qDebug() << "Symbolic link created successfully.";
321325
status = true;
322326
} else {
323327
QFileInfo fileInfo(gamePath);
324328
if (fileInfo.isSymLink() == true) {
325329
(void)QFile::remove(gamePath);
326-
if (QFile::link(levelPath + extraPath, gamePath) == true) {
330+
if (QFile::link(levelPath, gamePath) == true) {
327331
qDebug() << "Symbolic link created successfully.";
328332
status = true;
329333
} else {

src/FileManager.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class FileManager : public QObject {
5656
int cleanWorkingDir(const QString &levelDir);
5757
bool backupGameDir(const QString &gameDir);
5858
bool linkGameDir(const QString& levelDir, const QString& gameDir);
59+
QString getExtraPath(const QString& levelDir);
5960
bool ensureDirectoryExists(const QString& dirPath, const QDir& dir);
6061
bool setUpCamp(const QString& levelDir, const QString& gameDir);
6162

src/Model.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,20 @@ int Model::getItemState(int id) {
135135
return status;
136136
}
137137

138+
bool Model::runWine(const int id) {
139+
bool status = true;
140+
if (id < 0) { // we use original game id as negative number
141+
int orgId = (-1)*id;
142+
const QString s = QString("/Original.TR%1").arg(orgId);
143+
m_wineRunner.setWorkingDirectory(fileManager.getExtraPath(s));
144+
} else {
145+
const QString s = QString("/%1.TRLE").arg(id);
146+
m_wineRunner.setWorkingDirectory(fileManager.getExtraPath(s));
147+
}
148+
m_wineRunner.run();
149+
return status;
150+
}
151+
138152
bool Model::setLink(int id) {
139153
bool status = false;
140154
if (id < 0) { // we use original game id as negative number

src/Model.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "Data.hpp"
2424
#include "FileManager.hpp"
2525
#include "Network.hpp"
26+
#include "Runner.hpp"
2627

2728
class InstructionManager : public QObject {
2829
Q_OBJECT
@@ -61,6 +62,7 @@ class Model : public QObject {
6162
int checkLevelDirectory(int id);
6263
void getList(QVector<ListItemData>* list);
6364
int getItemState(int id);
65+
bool runWine(const int id);
6466
bool setLink(int id);
6567
QString getGameDirectory(int id);
6668
void setupGame(int id);
@@ -81,6 +83,7 @@ class Model : public QObject {
8183
const int id, const QString& md5sum, const QString& name);
8284
bool unpackLevel(const int id, const QString& name);
8385

86+
Runner m_wineRunner = Runner("/usr/bin/wine");
8487
QList<int> m_availableGames;
8588
Data& data = Data::getInstance();
8689
FileManager& fileManager = FileManager::getInstance();

src/Runner.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ Runner::Runner(const QString& cmd)
2828
m_command = cmd;
2929
}
3030

31+
void Runner::setWorkingDirectory(const QString& cwd) {
32+
m_process.setWorkingDirectory(cwd);
33+
}
34+
3135
void Runner::run() {
3236
// 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");
37+
m_process.start(m_command, QStringList() << "tomb4.exe");
3538
QObject::connect(&m_process, &QProcess::readyReadStandardOutput, [&]() {
3639
// Read and print the output to standard output
3740
QTextStream(stdout) << m_process.readAllStandardOutput();

src/Runner.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Runner : public QObject {
2929
int getStatus();
3030
int getCommand();
3131
bool setCommand(const QString& cmd);
32+
void setWorkingDirectory(const QString& cwd);
3233

3334
signals:
3435
void started();

src/TombRaiderLinuxLauncher.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -449,20 +449,22 @@ void TombRaiderLinuxLauncher::setOptionsClicked() {
449449
}
450450

451451
void TombRaiderLinuxLauncher::linkClicked() {
452-
// m_r.run();
453-
// test
454-
bool status = false;
455452
QListWidgetItem *selectedItem = ui->listWidgetModds->currentItem();
456453
int id = selectedItem->data(Qt::UserRole).toInt();
457-
if (id != 0) {
458-
status = controller.link(id);
459-
} else {
460-
qDebug() << "id error";
461-
}
462-
if (status == true) {
463-
QApplication::quit();
454+
if (m_settings.value(QString("level%1/RunnerType").arg(id)) == 2) {
455+
Model::getInstance().runWine(id);
464456
} else {
465-
qDebug() << "link error";
457+
bool status = false;
458+
if (id != 0) {
459+
status = controller.link(id);
460+
} else {
461+
qDebug() << "id error";
462+
}
463+
if (status == true) {
464+
QApplication::quit();
465+
} else {
466+
qDebug() << "link error";
467+
}
466468
}
467469
}
468470

src/TombRaiderLinuxLauncher.hpp

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

3029
#include "Controller.hpp"
3130

@@ -150,7 +149,6 @@ class TombRaiderLinuxLauncher : public QMainWindow {
150149
Controller& controller = Controller::getInstance();
151150
QSettings m_settings;
152151
Ui::TombRaiderLinuxLauncher *ui;
153-
Runner m_r = Runner("/usr/bin/wine");
154152
};
155153

156154
struct OriginalGameData {

0 commit comments

Comments
 (0)