diff --git a/TombRaiderLinuxLauncher.pdf b/TombRaiderLinuxLauncher.pdf new file mode 100644 index 0000000..1ce0bd7 Binary files /dev/null and b/TombRaiderLinuxLauncher.pdf differ diff --git a/TombRaiderPWModder/3573.jpg b/TombRaiderPWModder/3573.jpg new file mode 100644 index 0000000..8d54243 Binary files /dev/null and b/TombRaiderPWModder/3573.jpg differ diff --git a/TombRaiderPWModder/TombRaiderPWModder b/TombRaiderPWModder/TombRaiderPWModder index fbd66cf..2a5ab11 100755 Binary files a/TombRaiderPWModder/TombRaiderPWModder and b/TombRaiderPWModder/TombRaiderPWModder differ diff --git a/TombRaiderPWModder/TombRaiderPWModder.pro b/TombRaiderPWModder/TombRaiderPWModder.pro index acf6819..0a1218f 100644 --- a/TombRaiderPWModder/TombRaiderPWModder.pro +++ b/TombRaiderPWModder/TombRaiderPWModder.pro @@ -1,8 +1,9 @@ -QT += core gui +QT += core gui widgets webenginewidgets greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++17 +LIBS += -lcurl -lzip -lssl -lcrypto # You can make your code fail to compile if it uses deprecated APIs. # In order to do so, uncomment the following line. @@ -10,10 +11,12 @@ CONFIG += c++17 SOURCES += \ main.cpp \ - tombraiderpwmodder.cpp + tombraiderpwmodder.cpp \ + networkTR3.cpp HEADERS += \ - tombraiderpwmodder.h + tombraiderpwmodder.h \ + leveldata.h FORMS += \ tombraiderpwmodder.ui diff --git a/TombRaiderPWModder/leveldata.h b/TombRaiderPWModder/leveldata.h new file mode 100644 index 0000000..07a5d2a --- /dev/null +++ b/TombRaiderPWModder/leveldata.h @@ -0,0 +1,84 @@ +#pragma once +#include +/* + * trle.net level info data + * The data needed for the offline part of the client + * I don't think we should bother the server and its faster + * It there will be to many pictures or over 10 games I can + * move the pictures to some other download, but they are for + * testing now. The id number will be used at end of every URL + * + */ +class leveldata +{ +private: + const int id; + const std::string zipMd5sum; +public: + leveldata(int& id, std::string& md5sum) + : id(id), zipMd5sum(md5sum) {} + const std::string& getZipMd5sum() const { return zipMd5sum; } + const int& getId() const { return id; } + + const std::string& getTitle() const { return title; } + void setTitle(const std::string& s) { title = s; } + + const std::string& getAuthor() const { return author; } + void setAuthor(const std::string& s) { author = s; } + + const std::string& getType() const { return type; } + void setType(const std::string& s) { type = s; } + + const std::string& getLevelclass() const { return levelclass; } + void setLevelclass(const std::string& s) { levelclass = s; } + + const std::string& getReleasedate() const { return releasedate; } + void setReleasedate(const std::string& s) { releasedate = s; } + + const std::string& getDifficulty() const { return difficulty; } + void setDifficulty(const std::string& s) { difficulty = s; } + + const std::string& getDuration() const { return duration; } + void setDuration(const std::string& s) { duration = s; } + + const std::string& getScreensLarge() const { return screensLarge; } + void setScreensLarge(const std::string& s) { screensLarge = s; } + + const std::string& getBody() const { return body; } + void setBody(const std::string& s) { body = s; } + + const std::string& getWalkthrough() const { return walkthrough; } + void setWalkthrough(const std::string& s) { walkthrough = s; } + + const float& getZipSize() const { return zipSize; } + void setZipSize(const float& s) { zipSize = s; } + + const std::string& getZipName() const { return zipName; } + void setZipName(const std::string& s) { zipName = s; } + +private: + std::string title; + std::string author; + std::string type; // like TR4 + std::string levelclass; + std::string releasedate; + std::string difficulty; + std::string duration; + std::string screen; + std::string screensLarge; // separated by , + std::string body; //html + std::string walkthrough; //html + float zipSize; + std::string zipName; +}; +/* + * + * + */ +class pool +{ + const std::string levelUrl = "https://www.trle.net/sc/levelfeatures.php?lid="; + const std::string walkthroughUrl = "https://www.trle.net/sc/Levelwalk.php?lid="; + const std::string screensUrl = "https://www.trle.net/screens/"; + const std::string screensLargeUrl = "https://www.trle.net/screens/large/"; +}; diff --git a/maps/TombRaider (III).Jonson-TheInfadaCult/Jonson-TheInfadaCult-tr3.cpp b/TombRaiderPWModder/networkTR3.cpp similarity index 82% rename from maps/TombRaider (III).Jonson-TheInfadaCult/Jonson-TheInfadaCult-tr3.cpp rename to TombRaiderPWModder/networkTR3.cpp index 86b9c24..615026d 100644 --- a/maps/TombRaider (III).Jonson-TheInfadaCult/Jonson-TheInfadaCult-tr3.cpp +++ b/TombRaiderPWModder/networkTR3.cpp @@ -21,62 +21,63 @@ static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream) { - size_t written = fwrite(ptr, size, nmemb, (FILE *)stream); - return written; + size_t written = fwrite(ptr, size, nmemb, (FILE *)stream); + return written; } -size_t downloadFile(const char* url, const char* filename) { - CURL *curl_handle; - static const char *pagefilename = filename; - FILE *pagefile; - - - curl_global_init(CURL_GLOBAL_ALL); - - /* init the curl session */ - curl_handle = curl_easy_init(); - - /* set URL to get here */ - curl_easy_setopt(curl_handle, CURLOPT_URL, url); +size_t downloadFile(const char* url, const char* filename) +{ + CURL *curl_handle; + static const char *pagefilename = filename; + FILE *pagefile; + if (filename[0] == '/') + { + curl_global_init(CURL_GLOBAL_ALL); - /* Switch on full protocol/debug output while testing */ - curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L); + /* init the curl session */ + curl_handle = curl_easy_init(); - /* disable progress meter, set to 0L to enable it */ - curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L); + /* set URL to get here */ + curl_easy_setopt(curl_handle, CURLOPT_URL, url); - /* send all data to this function */ - curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data); + /* Switch on full protocol/debug output while testing */ + curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L); - /* open the file */ - pagefile = fopen(pagefilename, "wb"); - if(pagefile) { + /* disable progress meter, set to 0L to enable it */ + curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L); - /* write the page body to this file handle */ - curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, pagefile); + /* send all data to this function */ + curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data); - /* get it! */ - curl_easy_perform(curl_handle); + /* open the file */ + pagefile = fopen(pagefilename, "wb"); + if(pagefile) { - /* close the header file */ - fclose(pagefile); - } + /* write the page body to this file handle */ + curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, pagefile); - /* cleanup curl stuff */ - curl_easy_cleanup(curl_handle); - curl_global_cleanup(); + /* get it! */ + curl_easy_perform(curl_handle); - return 0; + /* close the header file */ + fclose(pagefile); + } + /* cleanup curl stuff */ + curl_easy_cleanup(curl_handle); + curl_global_cleanup(); + } + return 0; } // Function to calculate MD5 checksum of a file -std::string calculateMD5(const char* filename) { +std::string calculateMD5(const char* filename) +{ FILE* file = fopen(filename, "rb"); - if (!file) { + if (!file) + { std::cerr << "Error opening file for reading." << std::endl; return ""; } - fseek(file, 0, SEEK_END); rewind(file); @@ -90,7 +91,8 @@ std::string calculateMD5(const char* filename) { char buffer[1024]; size_t bytesRead; - while ((bytesRead = fread(buffer, 1, sizeof(buffer), file)) > 0) { + while ((bytesRead = fread(buffer, 1, sizeof(buffer), file)) > 0) + { EVP_DigestUpdate(md5Context, buffer, bytesRead); } @@ -99,17 +101,20 @@ std::string calculateMD5(const char* filename) { fclose(file); std::stringstream md5string; - for (int i = 0; i < EVP_MD_size(md5Type); ++i) { + for (int i = 0; i < EVP_MD_size(md5Type); ++i) + { md5string << std::hex << std::setw(2) << std::setfill('0') << static_cast(md5sum[i]); } return md5string.str(); } -void extractZip(const char* zipFilename, const char* extractPath) { +void extractZip(const char* zipFilename, const char* extractPath) +{ zip_t* archive = zip_open(zipFilename, 0, NULL); - if (!archive) { + if (!archive) + { std::cerr << "Error opening ZIP file" << std::endl; return; } @@ -121,21 +126,25 @@ void extractZip(const char* zipFilename, const char* extractPath) { int numEntries = zip_get_num_entries(archive, 0); // Extract each entry in the ZIP file - for (int i = 0; i < numEntries; ++i) { - if (zip_stat_index(archive, i, 0, &zipStat) == 0) { + for (int i = 0; i < numEntries; ++i) + { + if (zip_stat_index(archive, i, 0, &zipStat) == 0) + { // Allocate memory for the data char* data = new char[zipStat.size]; // Create directories if they don't exist std::string filePath = extractPath + std::string("/") + zipStat.name; std::string directory = filePath.substr(0, filePath.find_last_of("/\\")); - if (!std::filesystem::exists(directory)) { + if (!std::filesystem::exists(directory)) + { std::filesystem::create_directories(directory); } // Open the file in the ZIP archive zip_file_t* zipFile = zip_fopen_index(archive, i, 0); - if (zipFile) { + if (zipFile) + { // Read the data from the file in the ZIP archive zip_fread(zipFile, data, zipStat.size); @@ -149,10 +158,14 @@ void extractZip(const char* zipFilename, const char* extractPath) { outFile.close(); delete[] data;// leak - } else { + } + else + { std::cerr << "Error opening file in ZIP archive" << std::endl; } - } else { + } + else + { std::cerr << "Error getting information for entry " << i << std::endl; } } @@ -160,7 +173,7 @@ void extractZip(const char* zipFilename, const char* extractPath) { zip_close(archive); } -int main() { +int test() { // We need a class for hanling map download link or local file. // Checking files checksum and or remove them // Change to the game's directory @@ -302,10 +315,12 @@ int main() { }; // Remove files and directories - for (const char* item : filesToRemove) { + for (const char* item : filesToRemove) + { remove(item); } - for (const char* item : directoriesToRemove) { + for (const char* item : directoriesToRemove) + { rmdir(item); } @@ -313,24 +328,28 @@ int main() { const char* url = "https://www.trle.net/levels/levels/2023/1123/Jonson-TheInfadaCult.zip"; const char* filename = "Jonson-TheInfadaCult.zip"; - if (!downloadFile(url, filename)) { + if (!downloadFile(url, filename)) + { // Check MD5sum const char* expectedMD5 = "152d33e5c28d7db6458975a5e53a3122"; std::string md5sum = calculateMD5(filename); std::cout << md5sum << std::endl; - if (md5sum == expectedMD5) { + if (md5sum == expectedMD5) + { // Extract the ZIP file const char* extractPath = "./"; extractZip(filename, extractPath); } - else { + else + { std::cerr << "Download problem" << std::endl; return 1; } } - else { + else + { std::cerr << "Download problem" << std::endl; return 1; } diff --git a/TombRaiderPWModder/tombraiderpwmodder.cpp b/TombRaiderPWModder/tombraiderpwmodder.cpp index ac4bb81..0c67936 100644 --- a/TombRaiderPWModder/tombraiderpwmodder.cpp +++ b/TombRaiderPWModder/tombraiderpwmodder.cpp @@ -4,7 +4,11 @@ #include #include #include -#include + +/* int currentIndex = stackedWidget->currentIndex(); + * int nextPage = (currentIndex + 1) % stackedWidget->count(); + * stackedWidget->setCurrentIndex(nextPage); + */ TombRaiderPWModder::TombRaiderPWModder(QWidget *parent) : QMainWindow(parent) @@ -44,6 +48,11 @@ TombRaiderPWModder::TombRaiderPWModder(QWidget *parent) std::cout << " does not exist\n"; //dpdf = opendir(ui->tableWidgetSetup->item(1, 0)->text().toStdString().data()); + ui->listWidgetModds->setIconSize(QSize(320, 240)); + QFont defaultFont = QApplication::font(); + int newSize = 22; + defaultFont.setPointSize(newSize); + ui->listWidgetModds->setFont(defaultFont); dpdf = opendir(path); if (dpdf != NULL) { @@ -60,11 +69,24 @@ TombRaiderPWModder::TombRaiderPWModder(QWidget *parent) } } if(keep) - ui->listWidgetModds->insertItem(0, QString(epdf->d_name)); + { + QString s(epdf->d_name + 17); + if(s == "Jonson-TheInfadaCult")//this is just a test to add picture + { + QIcon i("3573.jpg"); + QListWidgetItem *wi = new QListWidgetItem(i, s); + wi->setIcon(i); + ui->listWidgetModds->addItem(wi); + } + else + { + QListWidgetItem *wi = new QListWidgetItem(s); + ui->listWidgetModds->addItem(wi); + } + } } closedir(dpdf); } - } void TombRaiderPWModder::readNextCstring(int &index, char* cString, char* path) diff --git a/TombRaiderPWModder/tombraiderpwmodder.h b/TombRaiderPWModder/tombraiderpwmodder.h index 0e10896..2f3b418 100644 --- a/TombRaiderPWModder/tombraiderpwmodder.h +++ b/TombRaiderPWModder/tombraiderpwmodder.h @@ -3,7 +3,7 @@ #include #include -#include +#include "leveldata.h" QT_BEGIN_NAMESPACE namespace Ui { class TombRaiderPWModder; } diff --git a/TombRaiderPWModder/tombraiderpwmodder.ui b/TombRaiderPWModder/tombraiderpwmodder.ui index 7795720..27daf5e 100644 --- a/TombRaiderPWModder/tombraiderpwmodder.ui +++ b/TombRaiderPWModder/tombraiderpwmodder.ui @@ -6,8 +6,8 @@ 0 0 - 641 - 513 + 730 + 391 @@ -20,19 +20,191 @@ 0 - + - Modds + Levels - - - - - - - Link + + + + true + + + 0 + + + 0 + + + + + + 0 + + + + + + + + 0 + 42 + + + + + 16777215 + 42 + + + + + + + + 0 + 32 + + + + Link + + + + + + + + 0 + 32 + + + + Info + + + + + + + + 127 + 32 + + + + Download and install + + + + + + + + + + + + + + + about:blank + + + + + + + + + 0 + 42 + + + + + 16777215 + 42 + + + + + + + + 0 + 32 + + + + Back + + + + + + + + 0 + 32 + + + + Walkthrough + + + + + + + + + + + + + + + about:blank + + + + + + + + + 0 + 42 + + + + + 16777215 + 42 + + + + + + + + 0 + 32 + + + + Back + + + + + + + + @@ -43,7 +215,19 @@ - + + + 0 + + + + + + + + + + @@ -51,34 +235,46 @@ Setup - - - - - - GAMEDIR - - - - - RESOURCEDIR - - - - - Paths - - - - - ~/.steam/root/steamapps/common/TombRaider (III) - - - - - ~/.local/share/TombRaider3ModderGames - - + + + + + 0 + + + + + + + + GAMEDIR + + + + + RESOURCEDIR + + + + + Paths + + + + + ~/.steam/root/steamapps/common/TombRaider (III) + + + + + ~/.local/share/TombRaider3ModderGames + + + + + + + @@ -89,18 +285,30 @@ - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> + + + QFrame::NoFrame + + + QFrame::Raised + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell';">Hi this is my first official Qt program for fun</span></p> -<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Cantarell';"><br /></p> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell';">This program takes a Tomb Raider installation with cresponding Wine or Proton prefix and and modifies it. It will launch diffrent wine exe for modding and manage all you're Tomb Rader mods and maps from trle.net</span></p> -<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Cantarell';"><br /></p> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell';">It will move you're steam proton Tomb Raider (for now 3 and 4) installation and prefix and link to it with hard links. So you can easaly relink and launch you mod with steam without needing to move you directory into the game launch path. I will later try to move away from dependent wine modding aplications and implament the moding direktly into the program. For fun.I play tomb raider 3 and 4 mostly and with both lutris and steam proton and this will work for both lutris and steam proton. But no linking for lutris should be needed</span></p></body></html> - +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell'; font-size:10pt;">Hi this is my first official Qt program for fun</span></p> +<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Cantarell'; font-size:10pt;"><br /></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell'; font-size:10pt;">This program takes a Tomb Raider installation with cresponding Wine or Proton prefix and and modifies it. It will launch diffrent wine exe for modding and manage all you're Tomb Rader mods and maps from trle.net</span></p> +<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Cantarell'; font-size:10pt;"><br /></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell'; font-size:10pt;">It will move you're steam proton Tomb Raider (for now 3 and 4) installation and prefix and link to it with hard links. So you can easaly relink and launch you mod with steam without needing to move you directory into the game launch path. I will later try to move away from dependent wine modding aplications and implament the moding direktly into the program. For fun.I play tomb raider 3 and 4 mostly and with both lutris and steam proton and this will work for both lutris and steam proton. But no linking for lutris should be needed</span></p></body></html> + + + + @@ -110,6 +318,13 @@ p, li { white-space: pre-wrap; } + + + QWebEngineView + QWidget +
QtWebEngineWidgets/QWebEngineView
+
+
diff --git a/maps/TombRaider (III).Jonson-TheInfadaCult/.vscode/launch.json b/maps/TombRaider (III).Jonson-TheInfadaCult/.vscode/launch.json deleted file mode 100644 index 5fcd070..0000000 --- a/maps/TombRaider (III).Jonson-TheInfadaCult/.vscode/launch.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Downloader", - "request": "launch", - "type": "cppdbg", - "program": "${workspaceFolder}" - } - ] -} \ No newline at end of file diff --git a/maps/TombRaider (III).Jonson-TheInfadaCult/Makefile b/maps/TombRaider (III).Jonson-TheInfadaCult/Makefile deleted file mode 100644 index b765262..0000000 --- a/maps/TombRaider (III).Jonson-TheInfadaCult/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -CC = g++ -CFLAGS = -Wall -Wextra -std=c++17 -LIBS = -lcurl -lzip -lssl -lcrypto -TARGET = Downloader -SRC = Jonson-TheInfadaCult-tr3.cpp - -all: $(TARGET) - -$(TARGET): $(SRC) - $(CC) $(CFLAGS) -o $(TARGET) $(SRC) $(LIBS) - -clean: - rm -f $(TARGET) -