diff --git a/CMakeLists.txt b/CMakeLists.txt index 283a099..1bc67b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.14) -project(Serious-Runner VERSION 1.0) +project(Serious-Runner VERSION 1.1) set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -11,6 +11,58 @@ set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +if(POLICY CMP0074) + cmake_policy(SET CMP0074 NEW) #3.12.0 `find_package()`` uses ``_ROOT`` variables. +endif() + +OPTION(ENABLE_LZMA "Enable the use of the system LZMA library if found" ON) +OPTION(ENABLE_ZLIB "Enable the use of the system ZLIB library if found" ON) +OPTION(ENABLE_BZip2 "Enable the use of the system BZip2 library if found" ON) + +IF(MINGW) + ADD_DEFINITIONS(-D__USE_MINGW_ANSI_STDIO) + ADD_DEFINITIONS(-D__MINGW_USE_VC2005_COMPAT) +ENDIF() + +IF(WIN32) + SET(LOCAL_INSTALL TRUE) +ENDIF() + +# +# Check compress/decompress libraries +# +IF(WIN32 AND NOT CMAKE_CL_64 AND NOT CYGWIN) + # GnuWin32 is only for Win32, not Win64. + SET(__GNUWIN32PATH "C:/Program Files/GnuWin32") +ENDIF(WIN32 AND NOT CMAKE_CL_64 AND NOT CYGWIN) +IF(DEFINED __GNUWIN32PATH AND EXISTS "${__GNUWIN32PATH}") + # You have to add a path available DLL file into PATH environment variable. + # Maybe DLL path is "C:/Program Files/GnuWin32/bin". + # The zlib and the bzip2 Setup program have installed programs and DLLs into + # "C:/Program Files/GnuWin32" by default. + # This is convenience setting for Windows. + SET(CMAKE_PREFIX_PATH ${__GNUWIN32PATH} $(CMAKE_PREFIX_PATH)) + # + # If you didn't use Setup program or installed into nonstandard path, + # cmake cannot find out your zlib or bzip2 libraries and include files, + # you should execute cmake with -DCMAKE_PREFIX_PATH option. + # e.g. + # cmake -DCMAKE_PREFIX_PATH= + # + # If compiling error occurred in zconf.h, You may need patch to zconf.h. + #--- zconf.h.orig 2005-07-21 00:40:26.000000000 + #+++ zconf.h 2009-01-19 11:39:10.093750000 + #@@ -286,7 +286,7 @@ + # + # #if 1 /* HAVE_UNISTD_H -- this line is updated by ./configure */ + # # include /* for off_t */ + #-# include /* for SEEK_* and off_t */ + #+# include /* for SEEK_* and off_t */ + # # ifdef VMS + # # include /* for off_t */ + # # endif +ENDIF(DEFINED __GNUWIN32PATH AND EXISTS "${__GNUWIN32PATH}") + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") include(CheckCXXCompilerFlag) @@ -151,6 +203,14 @@ if (LINUX) endif (DEBIAN_FOUND) endif (LINUX) +if(WIN32) + set(CMAKE_OS_NAME "Windows") + add_definitions(-DPLATFORM_WIN32=1) + add_definitions(-DPRAGMA_ONCE=1) + add_definitions(-D_CRT_SECURE_NO_WARNINGS=1) + add_definitions(-D_CRT_SECURE_NO_DEPRECATE=1) +endif() + message(STATUS "Operating system name: ${CMAKE_OS_NAME}") if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "AppleClang") @@ -266,7 +326,23 @@ else() message(FATAL_ERROR "Unsupported compiler") endif() -set(PROJECT_SOURCES +if(WIN32) + set(PROJECT_SOURCES + Resources.qrc + Main.cpp + MainWindow.cpp + MainWindow.h + MainWindow.ui + Classes/Downloader.cpp + Classes/Downloader.h + Classes/Unpacker.cpp + Classes/Unpacker.h + Classes/CopyDir.cpp + Classes/CopyDir.h + Classes/Types.h +) +else() + set(PROJECT_SOURCES Resources.qrc Main.cpp MainWindow.cpp @@ -282,6 +358,7 @@ set(PROJECT_SOURCES Classes/CopyDir.h Classes/Types.h ) +endif() if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) qt_add_executable(Serious-Runner @@ -299,14 +376,23 @@ else() ) # Define properties for Android with Qt 5 after find_package() calls as: # set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") + elseif(WIN32) + set(APP_ICON_RESOURCE_WINDOWS "${CMAKE_CURRENT_SOURCE_DIR}/seriousrunner.rc") + add_executable(Serious-Runner + ${PROJECT_SOURCES} ${APP_ICON_RESOURCE_WINDOWS} + ) else() add_executable(Serious-Runner ${PROJECT_SOURCES} - ) + ) endif() endif() # Link libraries. +if(WIN32) + # uncoment this for static link + # set_target_properties(Serious-Runner PROPERTIES LINK_FLAGS "-static") +endif() target_link_libraries(Serious-Runner PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt5::Sql Qt5::Network LibArchive::LibArchive LibLZMA::LibLZMA BZip2::BZip2 ZLIB::ZLIB) diff --git a/Classes/Downloader.cpp b/Classes/Downloader.cpp index 1493831..d68c43a 100644 --- a/Classes/Downloader.cpp +++ b/Classes/Downloader.cpp @@ -66,6 +66,11 @@ bool Downloader::GetLevel(const QString &strTargetFolder, const QUrl &urlLevel) bool Downloader::GetMod(const QString &strTargetFolder, const QString &strTargetGame, const QUrl &urlModBin, const QUrl &urlModData) { +#ifdef PLATFORM_UNIX + QString strTMPDirPath = "/tmp"; +#else + QString strTMPDirPath = QDir::homePath() +"/AppData/Local/Temp"; +#endif bool bResult; // Save Taeget folders and urls strFirstTargetFolder = strTargetFolder; @@ -79,20 +84,25 @@ bool Downloader::GetMod(const QString &strTargetFolder, const QString &strTarget bGameUnpack = false; iPassCount = 0; // Download - bResult = GetMain( "/tmp" , urlModData, true); + bResult = GetMain( strTMPDirPath , urlModData, true); } else { // Set type of download bModUnpack = true; bGameUnpack = false; iPassCount = 1; // Download - bResult = GetMain( "/tmp" , urlModBin, true); + bResult = GetMain( strTMPDirPath , urlModBin, true); } return bResult; } bool Downloader::GetGameSettings(const QString &strTargetFolder, const QUrl &urlGameBin, const QUrl &urlGameSettings) { +#ifdef PLATFORM_UNIX + QString strTMPDirPath = "/tmp"; +#else + QString strTMPDirPath = QDir::homePath() +"/AppData/Local/Temp"; +#endif // Save Taeget folders and urls strFirstTargetFolder = strTargetFolder; strFirstTargetUrl = urlGameBin; @@ -103,7 +113,7 @@ bool Downloader::GetGameSettings(const QString &strTargetFolder, const QUrl &url bGameUnpack = true; iPassCount = 1; // Download - bool bResult = GetMain( "/tmp", urlGameBin, true); + bool bResult = GetMain( strTMPDirPath, urlGameBin, true); return bResult; } @@ -185,29 +195,34 @@ void Downloader::slotOnReply(QNetworkReply* netReply) m_file = nullptr; netReply->deleteLater(); +#ifdef PLATFORM_UNIX + QString strTMPDirPath = "/tmp/"; +#else + QString strTMPDirPath = QDir::homePath() +"/AppData/Local/Temp/"; +#endif // Download Progres End if(bGameUnpack || bModUnpack){ if (bGameUnpack && iPassCount == 1){ - m_unpack.Extract("/tmp/" + strFirstTargetUrl.fileName(), "/tmp/", 1, 0); - m_copydir.CopyAndReplaceFolderContents("/tmp/x64", strFirstTargetFolder, false); + m_unpack.Extract(strTMPDirPath + strFirstTargetUrl.fileName(), strTMPDirPath, 1, 0); + m_copydir.CopyAndReplaceFolderContents( strTMPDirPath + "x64", strFirstTargetFolder, false); iPassCount = 0; - GetMain("/tmp/", strSecondTargetUrl, false); + GetMain(strTMPDirPath, strSecondTargetUrl, false); } else if (bGameUnpack && iPassCount == 0){ - m_unpack.Extract("/tmp/" + strSecondTargetUrl.fileName(), strSecondTargetFolder + "/", 1, 0); + m_unpack.Extract(strTMPDirPath + strSecondTargetUrl.fileName(), strSecondTargetFolder + "/", 1, 0); bGameUnpack = bModUnpack = false; emit signalDownloadProgressEnd(); emit signalTestGameInstall(); locked_action = false; } if (bModUnpack && iPassCount == 1){ - m_unpack.Extract("/tmp/" + strFirstTargetUrl.fileName(), "/tmp/", 1, 0); - m_copydir.CopyAndReplaceFolderContents("/tmp/x64",strFirstTargetFolder, false); + m_unpack.Extract(strTMPDirPath + strFirstTargetUrl.fileName(), strTMPDirPath, 1, 0); + m_copydir.CopyAndReplaceFolderContents( strTMPDirPath + "x64",strFirstTargetFolder, false); iPassCount = 0; - GetMain("/tmp/", strSecondTargetUrl, false); + GetMain(strTMPDirPath, strSecondTargetUrl, false); } else if (bModUnpack && iPassCount == 0){ - m_unpack.Extract("/tmp/" + strSecondTargetUrl.fileName(), strSecondTargetFolder + "/", 1, 0); + m_unpack.Extract(strTMPDirPath + strSecondTargetUrl.fileName(), strSecondTargetFolder + "/", 1, 0); bGameUnpack = bModUnpack = false; emit signalDownloadProgressEnd(); locked_action = false; diff --git a/Classes/Types.h b/Classes/Types.h index 26ca69d..d835103 100644 --- a/Classes/Types.h +++ b/Classes/Types.h @@ -6,7 +6,7 @@ enum MESSAGETYPE { INFO, WARN, - ERROR + ERR }; enum DOWNLOADTYPE { @@ -40,8 +40,8 @@ enum SE_TABLES { }; enum BOOLTYPES { - FALSE, - TRUE + BOOLFALSE, + BOOLTRUE }; enum PROGRESSBARINDEX { @@ -71,7 +71,8 @@ enum DISTROFLAG { FREEBSD, ALPINE, LINUX, - OTHER + OTHER, + WINDOWS }; enum APPTHEMES { diff --git a/Classes/Unpacker.cpp b/Classes/Unpacker.cpp index b2adc3d..f1686b1 100644 --- a/Classes/Unpacker.cpp +++ b/Classes/Unpacker.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include #include #include @@ -45,7 +46,8 @@ void Unpacker::Extract(QString strFileName, QString strPath, int iDoExtract, int archive_read_support_format_zip(a); archive_read_support_filter_compress(a); archive_read_support_format_tar(a); - archive_read_support_format_cpio(a); + archive_read_support_format_cpio(a); + archive_read_support_format_7zip(a); archive_write_disk_set_standard_lookup(ext); QByteArray ba1 = strFileName.toLocal8Bit(); @@ -130,7 +132,7 @@ void Unpacker::MsgBox(int type, QString strMessage) case WARN: msgBox.setIconPixmap(QPixmap(":/Images/warning.png")); break; - case ERROR: + case 2: msgBox.setIconPixmap(QPixmap(":/Images/error.png")); break; default: diff --git a/GnuWin/GnuWin.zip b/GnuWin/GnuWin.zip new file mode 100644 index 0000000..4117ee5 Binary files /dev/null and b/GnuWin/GnuWin.zip differ diff --git a/Icons/seriousrunner.ico b/Icons/seriousrunner.ico new file mode 100644 index 0000000..1d74968 Binary files /dev/null and b/Icons/seriousrunner.ico differ diff --git a/MainWindow.cpp b/MainWindow.cpp index 6fac6fc..a176655 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -43,10 +43,12 @@ MainWindow::MainWindow(QWidget *parent) connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(slotIconActivated(QSystemTrayIcon::ActivationReason))); +#ifdef PLATFORM_UNIX // Splash Screen QPixmap pixmap(":/Images/runner-splash.png"); QSplashScreen splash(pixmap, Qt::WindowStaysOnTopHint); splash.show(); +#endif SleepMSecs(100); // Program initialization @@ -58,7 +60,9 @@ MainWindow::MainWindow(QWidget *parent) slotTestGameInstall(); slotTestGameDataInstall(); ReScanLocalDB(); +#ifdef PLATFORM_UNIX splash.close(); +#endif // Downloader connect connect(&m_downloader, &Downloader::signalUpdateDownloadProgress, this, &MainWindow::slotOnUpdateProgressBar); @@ -130,17 +134,22 @@ void MainWindow::slotCloseFromTray(){ void MainWindow::SetVars(){ // Get paths strHomeDirPath = QDir::homePath(); - strExecDirPath = QCoreApplication::applicationFilePath(); // Set pathd - strRunnerDirPath = strHomeDirPath + strRunnerDirPathSuffix; +#ifdef PLATFORM_UNIX strEngineDirPath = strHomeDirPath + strEngineDirPathSuffix; + //strExecDirPath = QCoreApplication::applicationFilePath(); +#endif + strExecDirPath = QDir::currentPath(); + strRunnerDirPath = strHomeDirPath + strRunnerDirPathSuffix; strGameDirFEpath = strRunnerDirPath + "/SamTFE"; strGameDirSEpath = strRunnerDirPath + "/SamTSE"; strRunnerDBPath = strRunnerDirPath + "/DB/seriousrunner.db"; +#ifdef PLATFORM_UNIX // Test system install if(strExecDirPath.contains("/usr/bin")) { bUseSystemPath = true; } +#endif if(QFile(strGameDirFEpath + "/Mods/XPLUS/XPlus_All.gro").exists()) { bFE_XPLUSInstallOk = true; } @@ -173,6 +182,7 @@ void MainWindow::SetVars(){ // Get Disto name and set flag for SQl download table void MainWindow::GetDistroFlag() { +#ifdef PLATFORM_UNIX QString strOS=exec("cat /etc/*release|grep NAME"); // MsgBox(INFO, strOS); // For Debug @@ -186,7 +196,10 @@ void MainWindow::GetDistroFlag() }else{ iDistoFlag = OTHER; } - // MsgBox(INFO, QString::number(iDistoFlag)); // For Debug +#else + iDistoFlag = WINDOWS; +#endif + //MsgBox(INFO, QString::number(iDistoFlag)); // For Debug } // Set combo box text on center, because on Arch linux we have bug with text on combobox @@ -261,6 +274,7 @@ bool MainWindow::SearchDB(){ } QString strDBpath; QString strDBfilename = "seriousrunner.db"; +#ifdef PLATFORM_UNIX if (bUseSystemPath){ strDBpath = "/usr/share/seriousrunner/DB"; } else { @@ -288,6 +302,27 @@ bool MainWindow::SearchDB(){ } } bFirstRun = true; +#else + QString strDBpathWithFile = strExecDirPath + "/DB/" + strDBfilename; + //MsgBox(INFO,strDBpathWithFile); // For Debug + if (!QFile(strDBpathWithFile).exists()){ + QMessageBox::critical(nullptr, "Serious Runner", "Serious Runner did not find the database seriousrunner.db\n" + "Please place file seriousrunner.db in your directory and restart the program."); + slotCloseFromTray(); + return false; + } else { + if(!QFile::copy(strDBpathWithFile, strRunnerDBPath)){ + QMessageBox::critical(nullptr, "Serious Runner", "Serious Runner was unable to copy the database to the home directory.\n" + "Please place file seriousrunner.db in '" + strRunnerDBPath + "' and restart the program."); + return false; + } else { + QMessageBox::information(nullptr, "Serious Runner", "Install Serious Runner DB Done!"); + QPixmap pixmap(":/Images/ok.png"); + ui->label_db_status_image->setPixmap(pixmap); + } + } + bFirstRun = true; +#endif } else { QPixmap pixmap(":/Images/ok.png"); ui->label_db_status_image->setPixmap(pixmap); @@ -338,7 +373,7 @@ void MainWindow::ReScanLocalDB() QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(strRunnerDBPath); if(!db.open()){ - MsgBox(ERROR, "Error: Open SQL databese Failed!"); + MsgBox(ERR, "Error: Open SQL databese Failed!"); return; } QSqlQuery qry(db); @@ -348,7 +383,7 @@ void MainWindow::ReScanLocalDB() for(int i = 0; i < 7; i++){ qry.prepare("SELECT COUNT(*) FROM " + strDBTablesForScan[i]); if (!qry.exec()){ - MsgBox(ERROR, "Error: " + qry.lastError().text()); + MsgBox(ERR, "Error: " + qry.lastError().text()); db.close(); return; } @@ -366,7 +401,7 @@ void MainWindow::ReScanLocalDB() qry.prepare("Select " + strSelect + " FROM " + strDBTablesForScan[i] + " WHERE " + strIndex + " = :index_num"); qry.bindValue(":index_num", j); if (!qry.exec()){ - MsgBox(ERROR, "Error: " + qry.lastError().text()); + MsgBox(ERR, "Error: " + qry.lastError().text()); } qint64 iSizeInDB = 0; QString strTestFile, strStatus, strMD5sum; @@ -398,7 +433,7 @@ void MainWindow::ReScanLocalDB() qry.bindValue(":index_num", j); qry.bindValue(":Status", strStatus); if (!qry.exec()){ - MsgBox(ERROR, "Error: " + qry.lastError().text()); + MsgBox(ERR, "Error: " + qry.lastError().text()); db.close(); return; } @@ -533,9 +568,15 @@ void MainWindow::slotSetDownloadLabel(QString strLabel) void MainWindow::slotTestGameInstall() { bInstallGameOk = true; +#ifdef PLATFORM_UNIX if(!QFile().exists(strGameDirFEpath + "/Bin/libEngine.so") || !QFile().exists(strGameDirSEpath + "/Bin/libEngineMP.so")){ bInstallGameOk = false; } +#else + if(!QFile().exists(strGameDirFEpath + "/Bin/Engine.dll") || !QFile().exists(strGameDirSEpath + "/Bin/Engine.dll")){ + bInstallGameOk = false; + } +#endif if(!QFile().exists(strGameDirFEpath + "/VirtualTrees/BasicVirtualTree.vrt") || !QFile().exists(strGameDirSEpath + "/VirtualTrees/BasicVirtualTree.vrt")){ bInstallGameOk = false; } @@ -612,7 +653,7 @@ void MainWindow::on_pushButton_install_clicked() QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(strRunnerDBPath); if(!db.open()){ - MsgBox(ERROR, "Error: Open SQL databese Failed!"); + MsgBox(ERR, "Error: Open SQL databese Failed!"); return; } QSqlQuery qry(db); @@ -620,7 +661,7 @@ void MainWindow::on_pushButton_install_clicked() qry.prepare("Select download_link_bin,distro FROM game_bin WHERE os_num = :os_num"); qry.bindValue(":os_num", iDistoFlag + 1); if (!qry.exec()){ - MsgBox(ERROR, "Error: " + qry.lastError().text()); + MsgBox(ERR, "Error: " + qry.lastError().text()); db.close(); return; } @@ -654,10 +695,26 @@ void MainWindow::on_pushButton_install_gamedata_clicked() iProgressBarIndex = INSTALL_PBAR; iUnpackProgressIndex = INSTALL_UNPACKPROGRESS; iCopyDirProgressIndex = INSTALL_COPYPROGRESS; - - QString strPathFE = m_findinhome.FindFileInHomeDir(strFEfiles[4]); - QString strPathSE = m_findinhome.FindFileInHomeDir(strSEfiles[5]); - + QString strPathFE; + QString strPathSE; +#ifdef PLATFORM_UNIX + strPathFE = m_findinhome.FindFileInHomeDir(strFEfiles[4]); + strPathSE = m_findinhome.FindFileInHomeDir(strSEfiles[5]); +#else + strPathFE = QFileDialog::getExistingDirectory(this, tr("Choose Serious Sam The First Encounter Directory"), + "C:/", + QFileDialog::ShowDirsOnly + | QFileDialog::DontResolveSymlinks); + strPathSE = QFileDialog::getExistingDirectory(this, tr("Choose Serious Sam The Second Encounter Directory"), + "C:/", + QFileDialog::ShowDirsOnly + | QFileDialog::DontResolveSymlinks); + + if(!QFile().exists(strPathFE + "/1_00_music.gro") || !QFile().exists(strPathSE + "/SE1_00_Levels.gro")){ + MsgBox(WARN, "You specified the path to the game data incorrectly. Try again!"); + return; + } +#endif // Copy game data from found directory after search m_copydir.CopyAndReplaceFolderContents(strPathFE + "/Help", strRunnerDirPath + "/SamTFE/Help", false); m_copydir.CopyAndReplaceFolderContents(strPathFE + "/Levels", strRunnerDirPath + "/SamTFE/Levels", false); @@ -670,7 +727,7 @@ void MainWindow::on_pushButton_install_gamedata_clicked() QFile::copy(strPathFE + "/" + strFEfiles[i], strRunnerDirPath + "/SamTFE/" + strFEfiles[i]); } else { ui->label_progress->setText(""); - MsgBox(ERROR, "File: " + strPathFE + "/" + strFEfiles[i] + " not found!"); + MsgBox(ERR, "File: " + strPathFE + "/" + strFEfiles[i] + " not found!"); return; } } @@ -679,7 +736,7 @@ void MainWindow::on_pushButton_install_gamedata_clicked() QFile::copy(strPathSE + "/" + strSEfiles[i], strRunnerDirPath + "/SamTSE/" + strSEfiles[i]); } else { ui->label_progress->setText(""); - MsgBox(ERROR, "File: " + strPathSE + "/" + strSEfiles[i] + " not found!"); + MsgBox(ERR, "File: " + strPathSE + "/" + strSEfiles[i] + " not found!"); return; } } @@ -752,7 +809,7 @@ void MainWindow::SetImagesFromSql(QString strSqlTable,QString strLabelImg1,QStri QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(strRunnerDBPath); if(!db.open()){ - MsgBox(ERROR, "Open SQL databese Failed!"); + MsgBox(ERR, "Open SQL databese Failed!"); return; } QSqlQuery qry(db); @@ -764,7 +821,7 @@ void MainWindow::SetImagesFromSql(QString strSqlTable,QString strLabelImg1,QStri } qry.bindValue(":index_num", iTableRowIndex); if (!qry.exec()){ - MsgBox(ERROR, "Error: " + qry.lastError().text()); + MsgBox(ERR, "Error: " + qry.lastError().text()); db.close(); return; } @@ -901,7 +958,7 @@ void MainWindow::FillTable(QString strSqlTable, QString strTableView) QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(strRunnerDBPath); if(!db.open()){ - MsgBox(ERROR, "Error: Open SQL databese Failed!"); + MsgBox(ERR, "Error: Open SQL databese Failed!"); return; } QSqlQuery qry(db); @@ -953,7 +1010,7 @@ void MainWindow::StartLevel(QString strSqlTable, int iXPLUS, int iDifficulty) QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(strRunnerDBPath); if(!db.open()){ - MsgBox(ERROR, "Error: Open SQL databese Failed!"); + MsgBox(ERR, "Error: Open SQL databese Failed!"); return; } QSqlQuery qry(db); @@ -961,7 +1018,7 @@ void MainWindow::StartLevel(QString strSqlTable, int iXPLUS, int iDifficulty) qry.prepare("Select level_file,Status FROM " + strSqlTable + " WHERE level_num = :level_num"); qry.bindValue(":level_num", iTableRowIndex); if (!qry.exec()){ - MsgBox(ERROR, "Error: " + qry.lastError().text()); + MsgBox(ERR, "Error: " + qry.lastError().text()); db.close(); return; } @@ -977,21 +1034,29 @@ void MainWindow::StartLevel(QString strSqlTable, int iXPLUS, int iDifficulty) return; } +#ifdef PLATFORM_UNIX + QString strGameSuffix = "/Bin/SeriousSam"; +#else + QString strGameSuffix = "/Bin/SeriousSam.exe"; +#endif QString strProgram; QStringList arguments; if(strSqlTable.contains("fe_")) { - strProgram = strGameDirFEpath + "/Bin/SeriousSam"; + strProgram = strGameDirFEpath + strGameSuffix; MakeDifficultyScript(iDifficulty, strGameDirFEpath + "/Scripts/Game_difficulty.ini"); if(iXPLUS) { arguments << "+game" << "XPLUS"; } } else { MakeDifficultyScript(iDifficulty, strGameDirSEpath + "/Scripts/Game_difficulty.ini"); - strProgram = strGameDirSEpath + "/Bin/SeriousSam"; + strProgram = strGameDirSEpath + strGameSuffix; if(iXPLUS) { arguments << "+game" << "XPLUS"; } } +#ifdef PLATFORM_WIN32 + strLevelFile = QDir::toNativeSeparators(strLevelFile); +#endif arguments << "+level" << strLevelFile; arguments << "+script" << "Scripts/Game_difficulty.ini"; @@ -1050,7 +1115,7 @@ void MainWindow::StartMod(QString strSqlTable, int iDifficulty) QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(strRunnerDBPath); if(!db.open()){ - MsgBox(ERROR, "Error: Open SQL databese Failed!"); + MsgBox(ERR, "Error: Open SQL databese Failed!"); return; } QSqlQuery qry(db); @@ -1058,7 +1123,7 @@ void MainWindow::StartMod(QString strSqlTable, int iDifficulty) qry.prepare("Select mod_internal_name,Status,start_level FROM " + strSqlTable + " WHERE mod_num = :index_num"); qry.bindValue(":index_num", iTableRowIndex); if (!qry.exec()){ - MsgBox(ERROR, "Error: " + qry.lastError().text()); + MsgBox(ERR, "Error: " + qry.lastError().text()); db.close(); return; } @@ -1075,12 +1140,17 @@ void MainWindow::StartMod(QString strSqlTable, int iDifficulty) return; } +#ifdef PLATFORM_UNIX + QString strGameSuffix = "/Bin/SeriousSam"; +#else + QString strGameSuffix = "/Bin/SeriousSam.exe"; +#endif QString strProgram; if(strSqlTable.contains("fe_")) { - strProgram = strGameDirFEpath + "/Bin/SeriousSam"; + strProgram = strGameDirFEpath + strGameSuffix; MakeDifficultyScript(iDifficulty, strGameDirFEpath + "/Scripts/Game_difficulty.ini"); } else { - strProgram = strGameDirSEpath + "/Bin/SeriousSam"; + strProgram = strGameDirSEpath + strGameSuffix; MakeDifficultyScript(iDifficulty, strGameDirSEpath + "/Scripts/Game_difficulty.ini"); } QStringList arguments; @@ -1118,7 +1188,7 @@ void MainWindow::DownloadLevel(QString strSqlTable, QString strGameDirPath) QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(strRunnerDBPath); if(!db.open()){ - MsgBox(ERROR, "Error: Open SQL databese Failed!"); + MsgBox(ERR, "Error: Open SQL databese Failed!"); return; } QSqlQuery qry(db); @@ -1126,7 +1196,7 @@ void MainWindow::DownloadLevel(QString strSqlTable, QString strGameDirPath) qry.prepare("Select level_download_link,Status FROM " + strSqlTable + " WHERE level_num = :level_num"); qry.bindValue(":level_num", iTableRowIndex); if (!qry.exec()){ - MsgBox(ERROR, "Error: " + qry.lastError().text()); + MsgBox(ERR, "Error: " + qry.lastError().text()); db.close(); return; } @@ -1204,6 +1274,7 @@ void MainWindow::DownloadMod(QString strSqlTable) // Choose distro QString strSqlUrlBin; +#ifdef PLATFORM_UNIX switch(iDistoFlag ) { case FREEBSD: @@ -1222,12 +1293,14 @@ void MainWindow::DownloadMod(QString strSqlTable) strSqlUrlBin = "mod_download_link_lnx_bin"; break; } - +#else + strSqlUrlBin = "mod_download_link_win_bin"; +#endif // Get download link from sql QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(strRunnerDBPath); if(!db.open()){ - MsgBox(ERROR, "Error: Open SQL databese Failed!"); + MsgBox(ERR, "Error: Open SQL databese Failed!"); return; } QSqlQuery qry(db); @@ -1235,7 +1308,7 @@ void MainWindow::DownloadMod(QString strSqlTable) qry.prepare("Select " + strSqlUrlBin + ",mod_download_link_data,Status FROM " + strSqlTable + " WHERE mod_num = :mod_num"); qry.bindValue(":mod_num", iTableRowIndex); if (!qry.exec()){ - MsgBox(ERROR, "Error: " + qry.lastError().text()); + MsgBox(ERR, "Error: " + qry.lastError().text()); db.close(); return; } @@ -1394,9 +1467,9 @@ void MainWindow::FE_UseXPLUS(int arg, int iTable, bool bInstalled) MsgBox(INFO,"You can download XPLUS Mod before using!"); } if(!arg){ - iFE_StartWithXplus[iTable] = FALSE; + iFE_StartWithXplus[iTable] = BOOLFALSE; } else { - iFE_StartWithXplus[iTable] = TRUE; + iFE_StartWithXplus[iTable] = BOOLTRUE; } } @@ -1406,9 +1479,9 @@ void MainWindow::SE_UseXPLUS(int arg, int iTable, bool bInstalled) MsgBox(INFO,"You can download XPLUS Mod before using!"); } if(!arg){ - iSE_StartWithXplus[iTable] = FALSE; + iSE_StartWithXplus[iTable] = BOOLFALSE; } else { - iSE_StartWithXplus[iTable] = TRUE; + iSE_StartWithXplus[iTable] = BOOLTRUE; } } void MainWindow::on_checkBox_fe_official_use_xplus_stateChanged(int arg) @@ -1528,7 +1601,7 @@ void MainWindow::MsgBox(int iType, QString strMessage) case WARN: msgBox->setIconPixmap(QPixmap(":/Images/warning.png")); break; - case ERROR: + case ERR: msgBox->setIconPixmap(QPixmap(":/Images/error.png")); break; default: diff --git a/MainWindow.h b/MainWindow.h index e7843b9..c9d69c2 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -193,7 +193,9 @@ private slots: // Used classes and vars Downloader m_downloader; // download class +#ifdef PLATFORM_UNIX FindInHomeDir m_findinhome; +#endif CopyDir m_copydir; QProcess *process; QMessageBox *msgBox; @@ -209,8 +211,12 @@ private slots: QString strEngineDirPath; // Path's suffix - QString strEngineDirPathSuffix = "/.local/share/Serious-Engine"; +#ifdef PLATFORM_WIN32 + QString strRunnerDirPathSuffix = + "/AppData/Local/Serious-Runner"; +#else QString strRunnerDirPathSuffix = "/.local/share/Serious-Runner"; + QString strEngineDirPathSuffix = "/.local/share/Serious-Engine"; +#endif // Flags bool bUseSystemPath = false; diff --git a/seriousrunner.rc b/seriousrunner.rc new file mode 100644 index 0000000..09a032e --- /dev/null +++ b/seriousrunner.rc @@ -0,0 +1,43 @@ +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +IDI_APPICON ICON DISCARDABLE "Icons/seriousrunner.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,1,0,0 + PRODUCTVERSION 1,1,0,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904b0" + BEGIN + VALUE "FileDescription", "Serious Runner program that loads and runs content created by users.\0" + VALUE "FileVersion", "1.1.0.0\0" + VALUE "InternalName", "Serious-Runner\0" + VALUE "License", "GPLv2\0" + VALUE "OriginalFilename", "Serious-Runner.exe\0" + VALUE "ProductName", "Serious-Runner Application\0" + VALUE "ProductVersion", "1.1.0.0\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x809, 1200 + END +END