Skip to content

Commit

Permalink
fix icon picture and store extra functions that can be activated by id
Browse files Browse the repository at this point in the history
  • Loading branch information
noisecode3 committed Feb 12, 2024
1 parent 6323508 commit a3389fb
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 1 deletion.
35 changes: 35 additions & 0 deletions src/FileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,41 @@ bool FileManager::linkGameDir(const QString& levelDir ,const QString& gameDir)
}
}

bool FileManager::makeRelativeLink(const QString& levelDir ,const QString& from ,const QString& to)
{
const QString& l = levelDir_m.absolutePath() + levelDir;
const QString& f = l + from;
const QString& t = l + to;

if (QFile::link(f, t))
{
qDebug() << "Symbolic link created successfully.";
return 0;
}
else
{
QFileInfo i(t);
if (i.isSymLink())
{
QFile::remove(t);
if (QFile::link(f, t))
{
qDebug() << "Symbolic link created successfully.";
return 0;
}
else
{
qDebug() << "Failed to create symbolic link.";
return 1;
}
}
else
{
qDebug() << "Failed to create symbolic link.";
return 1;
}
}
}

int FileManager::removeFileOrDirectory(const QString &file, bool lookGameDir)
{
Expand Down
1 change: 1 addition & 0 deletions src/FileManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class FileManager : public QObject
int removeFileOrDirectory(const QString &file, bool lookGameDir);
int createDirectory(const QString &file, bool gameDir);
int copyFile(const QString &gameFile, const QString &levelFile, bool fromGameDir);
bool makeRelativeLink(const QString& levelDir ,const QString& from, const QString& to);
int cleanWorkingDir(const QString &levelDir);
bool backupGameDir(const QString &gameDir);
bool linkGameDir(const QString& levelDir ,const QString& gameDir);
Expand Down
1 change: 1 addition & 0 deletions src/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ bool Model::getGame(int id)
}
//fileManager.createDirectory(QString::number(id)+".TRLE", false);
fileManager.extractZip(zipData.name, QString::number(id)+".TRLE");
manager.executeInstruction(4);
}
return false;
}
Expand Down
34 changes: 33 additions & 1 deletion src/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,35 @@
#define MODEL_H

#include <QObject>
#include <QMap>
#include <QDebug>
#include "Data.h"
#include "FileManager.h"
#include "Network.h"

class InstructionManager : public QObject {
Q_OBJECT
public:
using Instruction = std::function<void(int id)>;

void addInstruction(int id, const Instruction& instruction) {
instructionsMap[id] = instruction;
}

public slots:
void executeInstruction(int id) {
auto it = instructionsMap.find(id);
if (it != instructionsMap.end()) {
it.value()(id);
} else {
qDebug() << "Invalid instruction ID";
}
}

private:
QMap<int, Instruction> instructionsMap;
};

class Model : public QObject
{
Q_OBJECT
Expand All @@ -30,9 +55,16 @@ class Model : public QObject
Data& data = Data::getInstance();
FileManager& fileManager = FileManager::getInstance();
Downloader& downloader = Downloader::getInstance();
Model(QObject *parent = nullptr) : QObject(parent) {};
Model(QObject *parent = nullptr) : QObject(parent) {
manager.addInstruction(4, [this](int id) {
qDebug() << "Perform Operation A";
const QString s = "/"+QString::number(id) + ".TRLE";
fileManager.makeRelativeLink(s,"/The Rescue.exe","/tomb4.exe");
});
};
~Model() {};

InstructionManager manager;
Q_DISABLE_COPY(Model)
};

Expand Down
Binary file modified src/pictures/Tomb_Raider_IIII.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions utils/data4.json

Large diffs are not rendered by default.

Binary file modified utils/tombll.db
Binary file not shown.

0 comments on commit a3389fb

Please sign in to comment.