Skip to content

Commit dce5c7e

Browse files
committed
fix setup toggle and use Path instead of setupDirectories
1 parent adb9677 commit dce5c7e

16 files changed

+96
-183
lines changed

README.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,13 @@ compile with cmake -DTEST=on
119119
./TombRaiderLinuxLauncherTest -w tomb4.exe
120120
```
121121

122-
I was going to mix trle.net with trcustoms.org data, I have not made contacted with the site owner
123-
to ask if I can use the site for scraping for non commercial use. As this task turned out to be
124-
harder than I thought, to match data without creating doubles, I'm gonna wait until the basics
125-
and trle.net part is implemented.
122+
I was going to mix trle.net with trcustoms.org data, I have not made contacted with the site owner to ask if I can use the site for scraping for non commercial use. As this task turned out to be harder than I thought, to match data without creating doubles, I'm gonna wait until the basics and trle.net part is implemented.
126123

127124
## Screenshots
128125

129126
![screenshot1](https://raw.githubusercontent.com/noisecode3/TombRaiderLinuxLauncher/main/doc/screenshot1.jpg)
130-
![screenshot1](https://raw.githubusercontent.com/noisecode3/TombRaiderLinuxLauncher/main/doc/screenshot2.jpg)
127+
![screenshot2](https://raw.githubusercontent.com/noisecode3/TombRaiderLinuxLauncher/main/doc/screenshot2.jpg)
128+
![screenshot3](https://raw.githubusercontent.com/noisecode3/TombRaiderLinuxLauncher/main/doc/screenshot3.jpg)
131129

132130
## Guide
133131

@@ -141,8 +139,7 @@ I tested the original, unpatched Tomb Raider III on an i7-4800MQ using its integ
141139
WINEPREFIX="/home/noisecode3/.newtombprefix" PROTONPATH="/home/noisecode3/.steam/steam/compatibilitytools.d/GE-Proton10-10" GAMEID="225320" MESA_SHADER_CACHE="true"
142140
```
143141

144-
It ran nearly perfectly — only a tiny framedrop once per hour, or sometimes not at all. Timing jitter caused by Wine’s threading system is largely eliminated under NTSync.
145-
NTSync can help DDraw, DirectSound other I/O thread workers in wine. On Arch Linux (or other distros with a modular kernel), you’ll need to manually load the ntsync driver to enable proper synchronization support:
142+
It ran nearly perfectly — only a tiny framedrop once per hour, or sometimes not at all. Timing jitter caused by Wine’s threading system is largely eliminated under NTSync. NTSync can help DDraw, DirectSound other I/O thread workers in wine. On Arch Linux (or other distros with a modular kernel), you’ll need to manually load the ntsync driver to enable proper synchronization support:
146143

147144
```shell
148145
sudo modprobe ntsync
@@ -173,9 +170,8 @@ I listed some open source modes that work well with Proton/Wine.
173170

174171
## Targets
175172

176-
I program mostly on Slackware-current and Arch, I gonna try target and test SteamOS for second release.
177-
I don't use Windows but it should build on both Windows and Linux with MinGw.
178-
It's recommended as a standard to use Arch Linux or MSYS2 on Windows, with qt-creator.
173+
I program mostly on Slackware-current and Arch, I gonna try target and test SteamOS for second release. I don't use Windows but it should build on both Windows and Linux with MinGw. It's recommended as a standard to use Arch Linux or MSYS2 on Windows, with qt-creator. I use neovim and qt-creator at the same time. You can have qt-creator open and configured to build in build/Desktop-Debug while you have neovim using the build directory. I find qt-creator useful for its debugger.
174+
![screenshot4](https://raw.githubusercontent.com/noisecode3/TombRaiderLinuxLauncher/main/doc/screenshot4.jpg)
179175

180176
## License
181177

doc/screenshot3.jpg

919 KB
Loading

doc/screenshot4.jpg

1.22 MB
Loading

src/Controller.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ void Controller::runOnThreadB(std::function<void()> func) {
7373
}
7474

7575
// Threaded work
76-
void Controller::setup(const QString& level, const QString& game) {
77-
runOnThreadA([=]() { model.setup(level, game); });
76+
void Controller::setup() {
77+
runOnThreadA([=]() { model.setup(); });
7878
}
7979

8080
void Controller::setupGame(int id) {

src/Controller.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Controller : public QObject {
3131
return instance;
3232
}
3333

34-
void setup(const QString& level, const QString& game);
34+
void setup();
3535
void setupGame(int id);
3636
void setupLevel(int id);
3737
void updateLevel(int id);

src/Data.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <QSqlQuery>
2727

2828
#include "../src/assert.hpp"
29+
#include "Path.hpp"
2930

3031
/**
3132
* @struct FileListItem
@@ -440,19 +441,19 @@ class Data : public QObject {
440441
*
441442
* @param path Full path to the datbase without the file name.
442443
*/
443-
bool initializeDatabase(const QString& path) {
444+
bool initializeDatabase() {
444445
bool status = false;
445-
const QString filePath = QString("%1/%2").arg(path, "tombll.db");
446-
QFileInfo fileInfo(filePath);
446+
Path path = Path(Path::resource);
447+
path << "tombll.db";
447448

448449
// Open the file
449-
if (!fileInfo.exists() || !fileInfo.isFile()) {
450+
if (!path.exists() || !path.isFile()) {
450451
qCritical()
451-
<< "Error: The database path is not a regular file: " << path;
452+
<< "Error: The database path is not a regular file: " << path.get();
452453
status = false;
453454
} else {
454455
db = QSqlDatabase::addDatabase("QSQLITE");
455-
db.setDatabaseName(QString("%1/tombll.db").arg(path));
456+
db.setDatabaseName(path.get());
456457
if (db.open() == true) { // flawfinder: ignore
457458
status = true;
458459
} else {

src/FileManager.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -340,26 +340,3 @@ qint64 FileManager::removeFileOrDirectory(Path path) {
340340
}
341341
return status;
342342
}
343-
344-
bool FileManager::setUpCamp(const QString& levelDir, const QString& gameDir) {
345-
bool status = true;
346-
347-
QDir levelDirPath(levelDir);
348-
if (!levelDirPath.exists() && !levelDirPath.mkpath(levelDir)) {
349-
qWarning() << "Failed to create level directory:" << levelDir;
350-
status = false;
351-
} else {
352-
m_levelDir.setPath(levelDir);
353-
}
354-
355-
QDir gameDirPath(gameDir);
356-
if (!gameDirPath.exists() && !gameDirPath.mkpath(gameDir)) {
357-
qWarning() << "Failed to create game directory:" << gameDir;
358-
status = false;
359-
} else {
360-
m_gameDir.setPath(gameDir);
361-
}
362-
363-
return status;
364-
}
365-

src/FileManager.hpp

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

204-
/**
205-
* @brief Sets the game launch directory and level directory.
206-
*
207-
* This function ensures that all file operations are contained within two directories:
208-
* - One for installed game files, similar to "Program Files (x86)".
209-
* - One for program files and downloaded levels.
210-
*
211-
* If the directories do not exist, it attempts to create them.
212-
*
213-
* @param levelDir The path to the level directory.
214-
* @param gameDir The path to the game directory.
215-
* @return `true` if both directories exist or were successfully created, `false` otherwise.
216-
*/
217-
bool setUpCamp(const QString& levelDir, const QString& gameDir);
218-
219204
signals:
220205
void fileWorkTickSignal();
221206

@@ -227,8 +212,6 @@ class FileManager : public QObject {
227212
return path.startsWith(QDir::homePath());
228213
}
229214

230-
QDir m_levelDir;
231-
QDir m_gameDir;
232215
const QString m_sep;
233216
Q_DISABLE_COPY(FileManager)
234217
};

src/Model.cpp

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,20 @@
1717
#include "../src/assert.hpp"
1818
#include <QtGlobal>
1919

20-
Model::Model() {}
21-
Model::~Model() {}
22-
23-
bool Model::setupDirectories(const QString& level, const QString& game) {
24-
bool status = false;
25-
26-
if (fileManager.setUpCamp(level, game) &&
27-
data.initializeDatabase(level) &&
28-
m_pyRunner.setUpCamp(level)) {
29-
#ifndef TEST
30-
Path::setProgramFilesPath();
31-
Path::setResourcePath();
32-
#endif
33-
status = true;
34-
}
35-
return status;
20+
Model::Model() :
21+
data(Data::getInstance()),
22+
fileManager(FileManager::getInstance()),
23+
downloader(Downloader::getInstance()) {
3624
}
3725

38-
void Model::setup(const QString& level, const QString& game) {
39-
if (setupDirectories(level, game) == true) {
26+
Model::~Model() {}
27+
28+
void Model::setup() {
29+
#ifndef TEST
30+
Path::setProgramFilesPath();
31+
Path::setResourcePath();
32+
#endif
33+
if(data.initializeDatabase()) {
4034
QList<int> commonFiles;
4135
checkCommonFiles(&commonFiles);
4236
// Iterate backward to avoid index shifting
@@ -58,8 +52,6 @@ void Model::setup(const QString& level, const QString& game) {
5852
emit generateListSignal(commonFiles);
5953
QCoreApplication::processEvents();
6054
} else {
61-
// send signal to gui with error about setup fail
62-
qDebug() << "setupDirectories setup failed";
6355
}
6456
}
6557

src/Model.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ class Model : public QObject {
8787
const InfoData getInfo(int id);
8888
const int getType(int id);
8989
const QString getWalkthrough(int id);
90-
bool setupDirectories(const QString& level, const QString& game);
91-
void setup(const QString& level, const QString& game);
90+
void setup();
9291
void updateLevel(const int id);
9392
void syncLevels();
9493

@@ -111,9 +110,9 @@ class Model : public QObject {
111110
Runner m_bashRunner = Runner("bash");
112111

113112
PyRunner m_pyRunner;
114-
Data& data = Data::getInstance();
115-
FileManager& fileManager = FileManager::getInstance();
116-
Downloader& downloader = Downloader::getInstance();
113+
Data& data;
114+
FileManager& fileManager;
115+
Downloader& downloader;
117116

118117
Model();
119118
~Model();

0 commit comments

Comments
 (0)