Skip to content

Commit

Permalink
add Tomb Raider 2 + new map
Browse files Browse the repository at this point in the history
  • Loading branch information
noisecode3 committed Jul 17, 2024
1 parent 910d5b4 commit 49a3a74
Show file tree
Hide file tree
Showing 16 changed files with 431 additions and 155 deletions.
Binary file modified .gdb/qt5prettyprinters/__pycache__/qt.cpython-311.pyc
Binary file not shown.
11 changes: 6 additions & 5 deletions .gdb/qt5prettyprinters/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class QByteArrayPrinter:

def __init__(self, val):
self.val = val
self.size = self.val['d']['size']
# Qt4 has 'data', Qt5 doesn't
self.isQt4 = has_field(self.val['d'], 'data')
# Qt6 has d.ptr, Qt5 doesn't
Expand Down Expand Up @@ -78,11 +79,11 @@ def stringData(self):
return self.val['d'].cast(gdb.lookup_type("char").const().pointer()) + self.val['d']['offset']

def children(self):
return self._iterator(self.stringData(), self.val['d']['size'])
return self._iterator(self.stringData(), self.size)

def to_string(self):
#todo: handle charset correctly
return self.stringData()
return self.stringData().string(length = self.size)

def display_hint (self):
return 'string'
Expand Down Expand Up @@ -755,7 +756,7 @@ def build_dictionary ():
pretty_printers_dict[re.compile('^QByteArray$')] = lambda val: QByteArrayPrinter(val)
pretty_printers_dict[re.compile('^QList<.*>$')] = lambda val: QListPrinter(val, 'QList', None)
pretty_printers_dict[re.compile('^QStringList$')] = lambda val: QListPrinter(val, 'QStringList', 'QString')
pretty_printers_dict[re.compile('^QQueue')] = lambda val: QListPrinter(val, 'QQueue', None)
pretty_printers_dict[re.compile('^QQueue<.*>$')] = lambda val: QListPrinter(val, 'QQueue', None)
pretty_printers_dict[re.compile('^QVector<.*>$')] = lambda val: QVectorPrinter(val, 'QVector')
pretty_printers_dict[re.compile('^QStack<.*>$')] = lambda val: QVectorPrinter(val, 'QStack')
pretty_printers_dict[re.compile('^QLinkedList<.*>$')] = lambda val: QLinkedListPrinter(val)
Expand All @@ -769,8 +770,8 @@ def build_dictionary ():
pretty_printers_dict[re.compile('^QUrl$')] = lambda val: QUrlPrinter(val)
pretty_printers_dict[re.compile('^QSet<.*>$')] = lambda val: QSetPrinter(val)
pretty_printers_dict[re.compile('^QChar$')] = lambda val: QCharPrinter(val)
pretty_printers_dict[re.compile('^QUuid')] = lambda val: QUuidPrinter(val)
pretty_printers_dict[re.compile('^QVariant')] = lambda val: QVariantPrinter(val)
pretty_printers_dict[re.compile('^QUuid$')] = lambda val: QUuidPrinter(val)
pretty_printers_dict[re.compile('^QVariant$')] = lambda val: QVariantPrinter(val)


build_dictionary ()
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Makefile
build-Debug
build
.cache
.gdb/qt5prettyprinters/__pycache__
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ target_link_libraries(${PROJECT_NAME} PUBLIC
# ${CURL_LIBRARY}
#)

target_include_directories(${PROJECT_NAME} PRIVATE ${CURL_INCLUDE_DIR} libs/miniz )
target_include_directories(${PROJECT_NAME} PRIVATE ${CURL_INCLUDE_DIR} libs/miniz src )

set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 17
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ manipulation configuration files. Bash for launching with Steam or Lutris or jus
* checksums
* download maps/mods, and install them
* add a filter for html in database
* make sure the rest of the GUI still updates while downloading

# trle.net mods the launcher will download and play with wine-tkg that I tested
* [Calypsis Jungle - Part One](https://www.trle.net/sc/levelfeatures.php?lid=3500)
Expand All @@ -36,6 +37,19 @@ You need those, should be installed an desktop linux
* curl
* Qt5

To ensure that our application works properly right now, you need to download the
required certificates from Firefox and add them to your system’s certificate store.
Unfortunately, I cannot share these certificates directly.

```
/etc/ssl/certs/trle-net-chain.pem
/etc/ssl/certs/trle-net.pem
```
Something like that should work on you're system
```
sudo update-ca-certificates
```

```shell
cmake -DCMAKE_INSTALL_PREFIX=~/.local .
make install
Expand Down
67 changes: 33 additions & 34 deletions src/FileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,52 +440,51 @@ bool FileManager::moveFilesToDirectory(const QString& fromLevelDirectory, const

bool FileManager::moveFilesToParentDirectory(const QString& levelDirectory)
{
const QString& directoryPath = levelDir_m.absolutePath() + QDir::separator() + levelDirectory;
QRegExp regex("/[^/]+$"); // Matches the last component of the path starting with a slash
int indexOfRegex = regex.indexIn(levelDirectory);
QDir dir(levelDir_m.absolutePath() + QDir::separator() + levelDirectory);

QString tmp = levelDirectory;
if (indexOfRegex == -1) {
// Kontrollera om katalogen finns
if (!dir.exists()) {
qWarning() << "Directory does not exist:" << dir.absolutePath();
return false;
}
const QString& parentDirectory = tmp.remove(indexOfRegex, tmp.length() - indexOfRegex);
const QString& directoryParentPath = levelDir_m.absolutePath() + QDir::separator() + parentDirectory;

QDir dir(directoryPath);

if(!moveFilesToDirectory(levelDirectory, parentDirectory))
{
// Hämta föräldrakatalogen
QDir parentDir = dir;
if (!parentDir.cdUp()) {
qWarning() << "Failed to access parent directory of:" << dir.absolutePath();
return false;
}

// Get list of all entries (files and directories) excluding '.' and '..'
QStringList entryDirList = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
// Lista alla filer och kataloger (exklusive '.' och '..')
QFileInfoList fileList = dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);

//TODO: make it look recursively and delete empty dir
// Flytta alla filer och kataloger till föräldrakatalogen
for (const QFileInfo& fileInfo : fileList) {
QString srcPath = fileInfo.absoluteFilePath();
QString destPath = parentDir.absolutePath() + QDir::separator() + fileInfo.fileName();

// Move files and recursively move directories
for (const QString& entry : entryDirList)
{
QString entryPath = directoryPath + QDir::separator() + entry;
createDirectory(parentDirectory + QDir::separator() + entry, false);
if (!moveFilesToDirectory(levelDirectory + QDir::separator() + entry, parentDirectory + QDir::separator() + entry))
{
qWarning() << "Failed to move directory:" << entryPath;
return false;
if (fileInfo.isDir()) {
// Flytta katalogen rekursivt
QDir srcDir(srcPath);
if (!srcDir.rename(srcPath, destPath)) {
qWarning() << "Failed to move directory:" << srcPath;
return false;
}
} else {
// Flytta filen
if (!QFile::rename(srcPath, destPath)) {
qWarning() << "Failed to move file:" << srcPath;
return false;
}
}
}

// Remove the directory if it's not the root directory
/*
if (dir != levelDir_m)
{
if (!dir.rmdir("."))
{
qWarning() << "Failed to remove directory:" << directoryPath;
return false;
}

// Ta bort den ursprungliga (nu tomma) katalogen
if (!dir.rmdir(".")) {
qWarning() << "Failed to remove directory:" << dir.absolutePath();
return false;
}
*/

return true;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Model.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <QDebug>
#include "Model.h"

// Those lambda should be in another header file
Model::Model(QObject *parent) : QObject(parent)
{
instructionManager.addInstruction(4, [this](int id) {
Expand Down Expand Up @@ -111,7 +112,7 @@ bool Model::setUpOg(int id)
const size_t sm = list[1].size();
if (s!=sm)
{
qDebug() << "Corrupt List";
qDebug() << "Corrupt list, there seems to bee more or less checksums for the files\n";
return false;
}
const QString& sd = "/Original.TR" + QString::number(id) +"/";
Expand Down
17 changes: 17 additions & 0 deletions src/TombRaiderLinuxLauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ int TombRaiderLinuxLauncher::testallGames(int id){

void TombRaiderLinuxLauncher::checkCommonFiles()
{
testallGames(2);
testallGames(3);
testallGames(4);
generateList();
Expand All @@ -107,6 +108,22 @@ void TombRaiderLinuxLauncher::generateList()
foreach (const QFileInfo &file, enteryInfoList)
{
QString Ending = file.fileName().right(4);
if (Ending == ".TR2")
{
if(file.fileName() == "Original.TR2")
{
QListWidgetItem *wi = new QListWidgetItem(QIcon(pictures+"Tomb_Raider_II.jpg"),"Tomb Raider II Original");
wi->setData(Qt::UserRole, QVariant(-2));
ui->listWidgetModds->addItem(wi);
}
else
{
qDebug() << "No link or id implementation";
//read some json file
//QListWidgetItem *wi = new QListWidgetItem(QIcon(pictures+"Tomb_Raider_II_unkown.jpg"),file.fileName());
//ui->listWidgetModds->addItem(wi);
}
}
if (Ending == ".TR3")
{
if(file.fileName() == "Original.TR3")
Expand Down
Loading

0 comments on commit 49a3a74

Please sign in to comment.