From 7fcad905b9b0b74220f0d4cb620e7c323b5ebc62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20B=C3=A5ngens?= Date: Sat, 23 Dec 2023 22:04:59 +0100 Subject: [PATCH] make a first time setup --- TombRaiderPWModder/files.h | 25 +- TombRaiderPWModder/main.cpp | 2 +- TombRaiderPWModder/networkTR3.cpp | 177 +------- TombRaiderPWModder/originalFileList.h | 1 - TombRaiderPWModder/tombraiderpwmodder.cpp | 529 ++++++++++++++++++---- TombRaiderPWModder/tombraiderpwmodder.h | 32 +- TombRaiderPWModder/tombraiderpwmodder.ui | 21 +- 7 files changed, 510 insertions(+), 277 deletions(-) diff --git a/TombRaiderPWModder/files.h b/TombRaiderPWModder/files.h index c87dc27..a932ca0 100644 --- a/TombRaiderPWModder/files.h +++ b/TombRaiderPWModder/files.h @@ -1,23 +1,24 @@ #pragma once -#include +#include #include #include class file { public: - file(const std::string path, const std::string md5sum) - : path(path), md5sum(md5sum) {} - const std::string& getPath() const { return path; } - const std::string& getMd5sum() const { return md5sum; } + file(const QString md5sum, const QString path) + : md5sum(md5sum), path(path) {} + const QString& getPath() const { return path; } + const QString& getMd5sum() const { return md5sum; } private: - const std::string path; //path + name - const std::string md5sum; + const QString md5sum; + const QString path; //path + name }; + class gameFileList { public: - gameFileList(const std::string name) : name(name) {} - const std::string getMd5sum(std::string& path) + gameFileList(const QString name) : name(name) {} + const QString getMd5sum(QString& path) { auto it = std::find_if(list.begin(), list.end(), [&path](const file& obj) { return obj.getPath() == path; }); @@ -25,7 +26,7 @@ class gameFileList return it->getMd5sum(); return ""; } - size_t getIndex(std::string path) + size_t getIndex(QString path) { auto it = std::find_if(list.begin(), list.end(), [&path](const file& obj) { return obj.getPath() == path; }); @@ -38,7 +39,7 @@ class gameFileList { return list.size(); } - void addFile(const std::string path, const std::string md5sum) + void addFile(const QString path, const QString md5sum) { list.push_back(file(path,md5sum)); } @@ -47,6 +48,6 @@ class gameFileList return list.at(index); } private: - const std::string name; + const QString name; std::vector list; }; diff --git a/TombRaiderPWModder/main.cpp b/TombRaiderPWModder/main.cpp index 324ff66..6e90e99 100644 --- a/TombRaiderPWModder/main.cpp +++ b/TombRaiderPWModder/main.cpp @@ -10,7 +10,7 @@ int main(int argc, char *argv[]) QApplication::setApplicationName("TombRaiderLinuxLauncher"); // Construct the QSettings object - TombRaiderPWModder w; + TombRaiderLinuxLauncher w; w.show(); return a.exec(); } diff --git a/TombRaiderPWModder/networkTR3.cpp b/TombRaiderPWModder/networkTR3.cpp index 615026d..9740777 100644 --- a/TombRaiderPWModder/networkTR3.cpp +++ b/TombRaiderPWModder/networkTR3.cpp @@ -1,178 +1,4 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include //depend -#include //depend -#include -#include -#include -#include - -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 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); - - /* init the curl session */ - curl_handle = curl_easy_init(); - - /* set URL to get here */ - curl_easy_setopt(curl_handle, CURLOPT_URL, url); - - /* Switch on full protocol/debug output while testing */ - curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L); - - /* disable progress meter, set to 0L to enable it */ - curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L); - - /* send all data to this function */ - curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data); - - /* open the file */ - pagefile = fopen(pagefilename, "wb"); - if(pagefile) { - - /* write the page body to this file handle */ - curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, pagefile); - - /* get it! */ - curl_easy_perform(curl_handle); - - /* 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) -{ - FILE* file = fopen(filename, "rb"); - if (!file) - { - std::cerr << "Error opening file for reading." << std::endl; - return ""; - } - fseek(file, 0, SEEK_END); - rewind(file); - - unsigned char md5sum[EVP_MAX_MD_SIZE]; - EVP_MD_CTX* md5Context; - const EVP_MD* md5Type = EVP_md5(); - - md5Context = EVP_MD_CTX_new(); - EVP_DigestInit_ex(md5Context, md5Type, NULL); - - char buffer[1024]; - size_t bytesRead; - - while ((bytesRead = fread(buffer, 1, sizeof(buffer), file)) > 0) - { - EVP_DigestUpdate(md5Context, buffer, bytesRead); - } - - EVP_DigestFinal_ex(md5Context, md5sum, NULL); - EVP_MD_CTX_free(md5Context); - fclose(file); - - std::stringstream md5string; - 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) -{ - zip_t* archive = zip_open(zipFilename, 0, NULL); - - if (!archive) - { - std::cerr << "Error opening ZIP file" << std::endl; - return; - } - - struct zip_stat zipStat; - zip_stat_init(&zipStat); - - // Get the number of entries in the ZIP file - 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) - { - // 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)) - { - std::filesystem::create_directories(directory); - } - - // Open the file in the ZIP archive - zip_file_t* zipFile = zip_fopen_index(archive, i, 0); - - if (zipFile) - { - // Read the data from the file in the ZIP archive - zip_fread(zipFile, data, zipStat.size); - - // Close the file in the ZIP archive - zip_fclose(zipFile); - - // Create a new file on disk and write the data - std::string filePath = extractPath + std::string("/") + zipStat.name; - std::ofstream outFile(filePath, std::ios::binary); - outFile.write(data, zipStat.size); - outFile.close(); - - delete[] data;// leak - } - else - { - std::cerr << "Error opening file in ZIP archive" << std::endl; - } - } - else - { - std::cerr << "Error getting information for entry " << i << std::endl; - } - } - // Close the ZIP archive - zip_close(archive); -} - +/* int test() { // We need a class for hanling map download link or local file. // Checking files checksum and or remove them @@ -359,3 +185,4 @@ int test() { return 0; } +*/ diff --git a/TombRaiderPWModder/originalFileList.h b/TombRaiderPWModder/originalFileList.h index 7401209..d53c5ba 100644 --- a/TombRaiderPWModder/originalFileList.h +++ b/TombRaiderPWModder/originalFileList.h @@ -5,7 +5,6 @@ gameFileList TR3FileList ("TR3.Original"); void work() { - TR3FileList.addFile("acc750411877527f118028aee957a854", "installscript.vdf"); TR3FileList.addFile("61f1377c2123f1c971cbfbf9c7ce8faf", "DATA.TAG"); TR3FileList.addFile("d09677d10864caa509ab2ffbd7ad37e7", "DEC130.DLL"); TR3FileList.addFile("4ee5d4026f15c967ed3ae599885018b0", "WINPLAY.DLL"); diff --git a/TombRaiderPWModder/tombraiderpwmodder.cpp b/TombRaiderPWModder/tombraiderpwmodder.cpp index 335d428..770d2fa 100644 --- a/TombRaiderPWModder/tombraiderpwmodder.cpp +++ b/TombRaiderPWModder/tombraiderpwmodder.cpp @@ -1,125 +1,376 @@ -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include "tombraiderpwmodder.h" #include "ui_tombraiderpwmodder.h" #include "originalFileList.h" + + #include +#include +#include +#include #include -#include +#include +#include +#include +#include +#include #include -/* int currentIndex = stackedWidget->currentIndex(); - * int nextPage = (currentIndex + 1) % stackedWidget->count(); - * stackedWidget->setCurrentIndex(nextPage); - */ +#include //depend +#include //depend +#include +#include +#include +#include -TombRaiderPWModder::TombRaiderPWModder(QWidget *parent) +/* + * + * + * + * + */ +TombRaiderLinuxLauncher::TombRaiderLinuxLauncher(QWidget *parent) : QMainWindow(parent) - , ui(new Ui::TombRaiderPWModder) + , ui(new Ui::TombRaiderLinuxLauncher) { ui->setupUi(this); connect(ui->pushButtonLink, SIGNAL (clicked()), this, SLOT (linkClicked())); + connect(ui->setOptions, SIGNAL (clicked()), this, SLOT (setOptionsClicked())); - // Construct the QSettings object - QSettings settings; + // Read settings + QString value = settings.value("setup").toString(); + //settings.setValue("setup" , "no"); + if (value != "yes") + setup(); + else + readSavedSettings(); - DIR *dpdf; - struct dirent *epdf; - const int prefixSize = 18; - char prefix[prefixSize] ="TombRaider (III)."; - char path[256] = "/home/"; - char gamedir[256] = "/.local/share/TombRaider3ModderGames"; - char* readnext = getlogin(); - int i=6; - readNextCstring(i, readnext, path); - readnext = gamedir; - readNextCstring(i, readnext, path); +} +/* + * 0 Game dose not exist. + * 1 The path is a symbolic link. + * 2 The path is not a symbolic link. + * 3 value 3:The path is not a directory. + */ +int TombRaiderLinuxLauncher::checkGameDirectory(int game) +{ + struct folderNames folder; + QString name; + switch (game) + { + case TR1: + name = folder.TR1; + break; + case TR2: + name = folder.TR2; + break; + case TR3: + name = folder.TR3; + break; + case TR4: + name = folder.TR4; + break; + case TR5: + name = folder.TR5; + break; + default: + qDebug() << game << " is not a game."; + return 0; + break; + } + QString filePath = settings.value("gamePath").toString() + name; + QFileInfo fileInfo(filePath); + if (fileInfo.isDir()) + { + qDebug() << "The path is a directory."; + if (fileInfo.isSymLink()) + { + qDebug() << "return value 1:The path is a symbolic link."; + return 1; + } + else + { + qDebug() << "return value 2:The path is not a symbolic link."; + return 2; + } + } + else + { + qDebug() << "value 3:The path is not a directory."; + qDebug() << "filePath " << filePath; + return 3; + } +} +/* + * + * + * + * + */ +void TombRaiderLinuxLauncher::packOriginalGame(int game) +{ + work(); + struct folderNames folder; + const QString folderPath = settings.value("gamePath").toString() + folder.TR3; + const size_t s = TR3FileList.getSize(); - char game[256] ="TombRaider (III)"; - char path2[256] = "/home/"; - char steamdir[256] = "/.steam/root/steamapps/common/"; - readnext = getlogin(); - i=6; + QString directoryPath = settings.value("levelPath").toString() + "/Original.TR3"; - readNextCstring(i, readnext,path2); - readnext = steamdir; - readNextCstring(i, readnext,path2); - readnext = game; - readNextCstring(i, readnext,path2); + // Create the directory if it doesn't exist + if (!QDir(directoryPath).exists()) { + if (QDir().mkpath(directoryPath)) { + qDebug() << "Directory created successfully."; + } else { + qDebug() << "Error creating directory."; + return; + } + } else { + qDebug() << "Directory already exists."; + } + + for (size_t i = 0; i < s; i++) + { + file f(TR3FileList.getFile(i)); + const QString sourcePath = folderPath + "/" + f.getPath(); + const QString destinationPath = directoryPath + "/" + f.getPath(); + + if(f.getMd5sum() == calculateMD5(sourcePath)) + { + // Ensure the destination directory exists + const QFileInfo destinationFileInfo(destinationPath); + QDir destinationDir(destinationFileInfo.absolutePath()); + if (!destinationDir.exists()) { + if (!QDir().mkpath(destinationDir.absolutePath())) { + qDebug() << "Error creating destination directory."; + return; + } + } + + // Copy the file + if (QFile::copy(sourcePath, destinationPath)) + { + qDebug() << "File copy successfully."; + } + else + { + if(QFile::exists(destinationPath)) + { + if(f.getMd5sum() == calculateMD5(destinationPath)) + qDebug() << "File exist"; + } + else + { + qDebug() << "Failed to copy file " << f.getPath() << Qt::endl; + return; + } + } + } + else { + qDebug() << "Original file was modified" << Qt::endl; + return; + } + } + QDir directory(folderPath); + + if (directory.exists()) { + // Remove the directory and its contents recursively + if (directory.removeRecursively()) { + qDebug() << "Directory removed successfully."; + } else { + qDebug() << "Error removing directory."; + } + } else { + qDebug() << "Directory does not exist."; + } + + // Create a symbolic link + if (QFile::link(directoryPath, folderPath)) + { + qDebug() << "Symbolic link created successfully."; + } + else + { + qDebug() << "Failed to create symbolic link."; + } + +} +void TombRaiderLinuxLauncher::checkCommonFiles() +{ + int dirStaus = checkGameDirectory(TR3); // we only setup tr3 for now + if (dirStaus) + { + if(dirStaus == 1)// The path is a symbolic link. + { + //its in use + // pass for now + } + else if(dirStaus == 2)// The path is not a symbolic link. + { + //this means we backup the game to levelPath IF that is whats inside + QMessageBox msgBox; + msgBox.setWindowTitle("Confirmation"); + msgBox.setText("TombRaider III found, you want to proceed?\nThis will erase saved games and is only for testing"); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::No); + int result = msgBox.exec(); + if (result == QMessageBox::Yes) { + qDebug() << "User clicked Yes."; + packOriginalGame(3); + } else { + qDebug() << "User clicked No or closed the dialog."; + } + } + else if(dirStaus == 3)// The path is not a directory. + { + //it has been replaced by a file from somewhere else or the user + } + generateList(); + } +} +/* + * + * + * + * + */ - std::filesystem::path p(path2); - std::filesystem::exists(p) ? - std::filesystem::is_symlink(p) ? - std::cout << std::filesystem::read_symlink(p) << '\n' : //TODO SET SECLECTED - std::cout << " exists but it is not a symlink\n" : - std::cout << " does not exist\n"; - //dpdf = opendir(ui->tableWidgetSetup->item(1, 0)->text().toStdString().data()); +void TombRaiderLinuxLauncher::generateList() +{ 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) + QString directoryPath = settings.value("levelPath").toString(); + QString pictures = directoryPath + "/pictures/"; + QDir info(directoryPath); + QFileInfoList enteryInfoList = info.entryInfoList(); + + foreach (const QFileInfo &file, enteryInfoList) { - while ( (epdf = readdir(dpdf)) ) + QString ending = file.fileName().right(3); + if (ending == "TR3") { - - bool keep = 1; - for (int i=0; i<(prefixSize-1); i++) - { - if (epdf->d_name[i] != prefix[i] && epdf->d_name[i] == 0) + qDebug() << "The last three characters are 'TR3'."; + if(file.fileName() == "Original.TR3") { - keep = 0; - break; - } - } - if(keep) - { - 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); + QListWidgetItem *wi = new QListWidgetItem(QIcon(pictures+"Tomb_Raider_III.jpg"),"Tomb Raider III Original"); ui->listWidgetModds->addItem(wi); } else { - QListWidgetItem *wi = new QListWidgetItem(s); + QListWidgetItem *wi = new QListWidgetItem(file.fileName()); ui->listWidgetModds->addItem(wi); } - } } - closedir(dpdf); + else + { + qDebug() << "The last three characters are not 'TR3'."; + } + } } -void readSavedSettings() +/* + * + * + * + * + */ +void TombRaiderLinuxLauncher::readSavedSettings() { - - // Save a setting - //settings.setValue("exampleKey", "exampleValue"); - // Read a setting - //QString value = settings.value("exampleKey").toString(); - //qDebug() << "Read value:" << value; + QString gamePathValue = settings.value("gamePath").toString(); + qDebug() << "Read game path value:" << gamePathValue; + QString levelPathValue = settings.value("levelPath").toString(); + qDebug() << "Read level path value:" << levelPathValue; + checkCommonFiles(); } -void setup() +/* + * + * + * + * + */ +void TombRaiderLinuxLauncher::setup() { - //make qt save changes + ui->Tabs->setCurrentIndex(ui->Tabs->indexOf(ui->Tabs->findChild("Setup"))); + ui->setupStackedWidget->setCurrentWidget(ui->setupStackedWidget->findChild("firstTime")); + ui->Tabs->setTabEnabled(ui->Tabs->indexOf(ui->Tabs->findChild("Levels")), false); + ui->Tabs->setTabEnabled(ui->Tabs->indexOf(ui->Tabs->findChild("Modding")), false); + + qDebug() << "Entering setup" << Qt::endl; + QString homeDir = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); + qDebug() << "Home Directory:" << homeDir; + QString s = "/.steam/root/steamapps/common/"; + QString l = "/.local/share/TombRaiderLinuxLauncher"; + ui->gamePathEdit->setText(homeDir + s); + ui->levelPathEdit->setText(homeDir + l); } +/* + * + * + * + * + */ +void TombRaiderLinuxLauncher::setOptionsClicked() +{ + QString gamePath = ui->gamePathEdit->text(); + QString levelPath = ui->levelPathEdit->text(); + settings.setValue("gamePath" , gamePath); + settings.setValue("levelPath" , levelPath); + settings.setValue("setup" , "yes"); -void TombRaiderPWModder::readNextCstring(int &index, char* cString, char* path) + ui->tableWidgetSetup->item(0,0)->setText(gamePath); + ui->tableWidgetSetup->item(1,0)->setText(levelPath); + ui->Tabs->setTabEnabled(ui->Tabs->indexOf(ui->Tabs->findChild("Levels")), true); + ui->Tabs->setTabEnabled(ui->Tabs->indexOf(ui->Tabs->findChild("Modding")), true); + ui->Tabs->show(); + ui->Tabs->setCurrentIndex(ui->Tabs->indexOf(ui->Tabs->findChild("Levels"))); + ui->setupStackedWidget->setCurrentWidget(ui->setupStackedWidget->findChild("settings")); + + readSavedSettings(); +} +/* + * + * + * + * + */ +const QString TombRaiderLinuxLauncher::calculateMD5(const QString& filename) { - for (; *cString !=0; cString++) + QFile file(filename); + if (!file.open(QIODevice::ReadOnly)) + { + qDebug() << "Error opening file for reading: " << file.errorString(); + return ""; + } + + QCryptographicHash md5(QCryptographicHash::Md5); + + char buffer[1024]; + qint64 bytesRead; + + while ((bytesRead = file.read(buffer, sizeof(buffer))) > 0) { - path[index] = *cString; - index+=1; + md5.addData(buffer, static_cast(bytesRead)); } + + file.close(); + + return QString(md5.result().toHex()); } -void TombRaiderPWModder::linkClicked() +void TombRaiderLinuxLauncher::linkClicked() { + /* QList list = ui->listWidgetModds->selectedItems(); //std::cout << list.at(0)->text().toStdString() << "\n"; @@ -148,9 +399,133 @@ void TombRaiderPWModder::linkClicked() std::filesystem::create_symlink(path1 + list.at(0)->text().toStdString(), path2); QApplication::quit(); + */ } -TombRaiderPWModder::~TombRaiderPWModder() + + +static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream) { - delete ui; + 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; + if (filename[0] == '/') + { + 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); + + /* Switch on full protocol/debug output while testing */ + curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L); + + /* disable progress meter, set to 0L to enable it */ + curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L); + + /* send all data to this function */ + curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data); + + /* open the file */ + pagefile = fopen(pagefilename, "wb"); + if(pagefile) { + + /* write the page body to this file handle */ + curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, pagefile); + + /* get it! */ + curl_easy_perform(curl_handle); + + /* close the header file */ + fclose(pagefile); + } + /* cleanup curl stuff */ + curl_easy_cleanup(curl_handle); + curl_global_cleanup(); + } + return 0; +} + + +void extractZip(const char* zipFilename, const char* extractPath) +{ + zip_t* archive = zip_open(zipFilename, 0, NULL); + + if (!archive) + { + std::cerr << "Error opening ZIP file" << std::endl; + return; + } + + struct zip_stat zipStat; + zip_stat_init(&zipStat); + + // Get the number of entries in the ZIP file + 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) + { + // 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)) + { + std::filesystem::create_directories(directory); + } + + // Open the file in the ZIP archive + zip_file_t* zipFile = zip_fopen_index(archive, i, 0); + + if (zipFile) + { + // Read the data from the file in the ZIP archive + zip_fread(zipFile, data, zipStat.size); + + // Close the file in the ZIP archive + zip_fclose(zipFile); + + // Create a new file on disk and write the data + std::string filePath = extractPath + std::string("/") + zipStat.name; + std::ofstream outFile(filePath, std::ios::binary); + outFile.write(data, zipStat.size); + outFile.close(); + + delete[] data;// leak + } + else + { + std::cerr << "Error opening file in ZIP archive" << std::endl; + } + } + else + { + std::cerr << "Error getting information for entry " << i << std::endl; + } + } + // Close the ZIP archive + zip_close(archive); } + + + + + + + +TombRaiderLinuxLauncher::~TombRaiderLinuxLauncher() +{ + delete ui; +} diff --git a/TombRaiderPWModder/tombraiderpwmodder.h b/TombRaiderPWModder/tombraiderpwmodder.h index c63cf6a..1791130 100644 --- a/TombRaiderPWModder/tombraiderpwmodder.h +++ b/TombRaiderPWModder/tombraiderpwmodder.h @@ -2,26 +2,44 @@ #define TOMBRAIDERPWMODDER_H #include -#include +#include #include "leveldata.h" QT_BEGIN_NAMESPACE -namespace Ui { class TombRaiderPWModder; } +namespace Ui { class TombRaiderLinuxLauncher; } QT_END_NAMESPACE -class TombRaiderPWModder : public QMainWindow +class TombRaiderLinuxLauncher : public QMainWindow { Q_OBJECT public: - TombRaiderPWModder(QWidget *parent = nullptr); - ~TombRaiderPWModder(); + TombRaiderLinuxLauncher(QWidget *parent = nullptr); + ~TombRaiderLinuxLauncher(); public slots: void linkClicked(); + void setOptionsClicked(); private: void setup(); - void readNextCstring(int &index, char* cString, char* path); - Ui::TombRaiderPWModder *ui; + void readSavedSettings(); + void checkCommonFiles(); + void generateList(); + + const QString calculateMD5(const QString &filename); + int checkGameDirectory(int game); + void packOriginalGame(int game); + QString selected; + QSettings settings; + Ui::TombRaiderLinuxLauncher *ui; + enum TRVER {TR1=1,TR2,TR3,TR4,TR5}; + struct folderNames + { + QString TR1 = "/Tomb Raider (I)"; + QString TR2 = "/Tomb Raider (II)"; + QString TR3 = "/TombRaider (III)"; + QString TR4 = "/Tomb Raider (IV) The Last Revelation"; + QString TR5 = "/Tomb Raider (V) Chronicles"; + }; }; #endif // TOMBRAIDERPWMODDER_H diff --git a/TombRaiderPWModder/tombraiderpwmodder.ui b/TombRaiderPWModder/tombraiderpwmodder.ui index c7e7155..44c6d86 100644 --- a/TombRaiderPWModder/tombraiderpwmodder.ui +++ b/TombRaiderPWModder/tombraiderpwmodder.ui @@ -1,7 +1,7 @@ - TombRaiderPWModder - + TombRaiderLinuxLauncher + 0 @@ -237,7 +237,7 @@ - + 0 @@ -245,6 +245,12 @@ + + true + + + 500 + GAMEDIR @@ -274,7 +280,7 @@ - + @@ -353,6 +359,13 @@ li.checked::marker { content: "\2612"; } + + + + set options + + +