diff --git a/CMakeLists.txt b/CMakeLists.txt index ceadb6fd3..78122eb06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,11 +5,6 @@ cmake_minimum_required(VERSION 3.16.0) project(VCMI) # TODO -# macOS: -# - There is problem with running fixup_bundle in main project after subdirectories. -# Cmake put them after all install code of main CMakelists in cmake_install.cmake -# Currently I just added extra add_subdirectory and CMakeLists.txt in osx directory to bypass that. -# # Vckpg: # - Improve install code once there is better way to deploy DLLs and Qt plugins # @@ -23,7 +18,7 @@ project(VCMI) # - Make FindFuzzyLite check for the right version and disable FORCE_BUNDLED_FL by default if(APPLE) - if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") set(APPLE_MACOS 1) else() set(APPLE_IOS 1) diff --git a/Global.h b/Global.h index 2b6b66be5..5fa4eae5a 100644 --- a/Global.h +++ b/Global.h @@ -215,10 +215,10 @@ using TLockGuardRec = std::lock_guard; /* ---------------------------------------------------------------------------- */ // Import + Export macro declarations #ifdef VCMI_WINDOWS -#ifdef VCMI_DLL_STATIC +# ifdef VCMI_DLL_STATIC # define DLL_IMPORT # define DLL_EXPORT -#elif defined(__GNUC__) +# elif defined(__GNUC__) # define DLL_IMPORT __attribute__((dllimport)) # define DLL_EXPORT __attribute__((dllexport)) # else diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 561dd0201..3f3bd22b3 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -507,16 +507,18 @@ endif() #install icons and desktop file on Linux if(NOT WIN32 AND NOT APPLE AND NOT ANDROID) #FIXME: move to client makefile? - install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.16x16.png" DESTINATION share/icons/hicolor/16x16/apps RENAME vcmiclient.png) - install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.22x22.png" DESTINATION share/icons/hicolor/22x22/apps RENAME vcmiclient.png) - install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.32x32.png" DESTINATION share/icons/hicolor/32x32/apps RENAME vcmiclient.png) - install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.48x48.png" DESTINATION share/icons/hicolor/48x48/apps RENAME vcmiclient.png) - install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.64x64.png" DESTINATION share/icons/hicolor/64x64/apps RENAME vcmiclient.png) - install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.128x128.png" DESTINATION share/icons/hicolor/128x128/apps RENAME vcmiclient.png) - install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.256x256.png" DESTINATION share/icons/hicolor/256x256/apps RENAME vcmiclient.png) - install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.512x512.png" DESTINATION share/icons/hicolor/512x512/apps RENAME vcmiclient.png) - install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.1024x1024.png" DESTINATION share/icons/hicolor/1024x1024/apps RENAME vcmiclient.png) - install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.2048x2048.png" DESTINATION share/icons/hicolor/2048x2048/apps RENAME vcmiclient.png) - install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.svg" DESTINATION share/icons/hicolor/scalable/apps RENAME vcmiclient.svg) - install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.desktop" DESTINATION share/applications) + foreach(iconSize 16 22 32 48 64 128 256 512 1024 2048) + install(FILES "icons/vcmiclient.${iconSize}x${iconSize}.png" + DESTINATION "share/icons/hicolor/${iconSize}x${iconSize}/apps" + RENAME vcmiclient.png + ) + endforeach() + + install(FILES icons/vcmiclient.svg + DESTINATION share/icons/hicolor/scalable/apps + RENAME vcmiclient.svg + ) + install(FILES icons/vcmiclient.desktop + DESTINATION share/applications + ) endif() diff --git a/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-60x60@1x.png b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-60x60@1x.png deleted file mode 100644 index caaf8bc5c..000000000 Binary files a/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-60x60@1x.png and /dev/null differ diff --git a/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png index 572699c5f..c69552323 100644 Binary files a/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png and b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/launcher/launcherdirs.cpp b/launcher/launcherdirs.cpp index 81e474f94..84ff32a66 100644 --- a/launcher/launcherdirs.cpp +++ b/launcher/launcherdirs.cpp @@ -12,30 +12,26 @@ #include "../lib/VCMIDirs.h" -static CLauncherDirs launcherDirsGlobal; - -CLauncherDirs::CLauncherDirs() +namespace CLauncherDirs { - QDir().mkdir(downloadsPath()); - QDir().mkdir(modsPath()); +void prepare() +{ + for(auto path : {downloadsPath(), modsPath(), mapsPath()}) + QDir{}.mkdir(path); } -CLauncherDirs & CLauncherDirs::get() -{ - return launcherDirsGlobal; -} - -QString CLauncherDirs::downloadsPath() +QString downloadsPath() { return pathToQString(VCMIDirs::get().userCachePath() / "downloads"); } -QString CLauncherDirs::modsPath() +QString modsPath() { return pathToQString(VCMIDirs::get().userDataPath() / "Mods"); } -QString CLauncherDirs::mapsPath() +QString mapsPath() { return pathToQString(VCMIDirs::get().userDataPath() / "Maps"); } +} diff --git a/launcher/launcherdirs.h b/launcher/launcherdirs.h index e549fb218..a8b5ea1c4 100644 --- a/launcher/launcherdirs.h +++ b/launcher/launcherdirs.h @@ -10,14 +10,11 @@ #pragma once /// similar to lib/VCMIDirs, controls where all launcher-related data will be stored -class CLauncherDirs +namespace CLauncherDirs { -public: - CLauncherDirs(); - - static CLauncherDirs & get(); + void prepare(); QString downloadsPath(); QString modsPath(); QString mapsPath(); -}; +} diff --git a/launcher/main.cpp b/launcher/main.cpp index cb0b38ac1..7b4323cfe 100644 --- a/launcher/main.cpp +++ b/launcher/main.cpp @@ -10,11 +10,13 @@ #include "StdInc.h" #include "main.h" #include "mainwindow_moc.h" +#include "launcherdirs.h" + +#include "../lib/VCMIDirs.h" #include #include #include -#include "../lib/VCMIDirs.h" // Conan workaround https://github.com/conan-io/conan-center-index/issues/13332 #ifdef VCMI_IOS @@ -33,8 +35,11 @@ int main(int argc, char * argv[]) #endif QApplication vcmilauncher(argc, argv); + CLauncherDirs::prepare(); + MainWindow mainWindow; mainWindow.show(); + result = vcmilauncher.exec(); #ifdef VCMI_IOS } diff --git a/launcher/modManager/cdownloadmanager_moc.cpp b/launcher/modManager/cdownloadmanager_moc.cpp index 563ce0b7e..c7960dc8e 100644 --- a/launcher/modManager/cdownloadmanager_moc.cpp +++ b/launcher/modManager/cdownloadmanager_moc.cpp @@ -22,7 +22,7 @@ void CDownloadManager::downloadFile(const QUrl & url, const QString & file, qint { QNetworkRequest request(url); FileEntry entry; - entry.file.reset(new QFile(CLauncherDirs::get().downloadsPath() + '/' + file)); + entry.file.reset(new QFile(QString{QLatin1String{"%1/%2"}}.arg(CLauncherDirs::downloadsPath(), file))); entry.bytesReceived = 0; entry.totalSize = bytesTotal; entry.filename = file; diff --git a/launcher/modManager/cmodlistview_moc.cpp b/launcher/modManager/cmodlistview_moc.cpp index 528c448cc..347091803 100644 --- a/launcher/modManager/cmodlistview_moc.cpp +++ b/launcher/modManager/cmodlistview_moc.cpp @@ -841,7 +841,7 @@ void CModListView::installMods(QStringList archives) void CModListView::installMaps(QStringList maps) { - QString destDir = CLauncherDirs::get().mapsPath() + "/"; + const auto destDir = CLauncherDirs::mapsPath() + QChar{'/'}; for(QString map : maps) { @@ -890,18 +890,18 @@ void CModListView::loadScreenshots() QString modName = ui->allModsView->currentIndex().data(ModRoles::ModNameRole).toString(); assert(modModel->hasMod(modName)); //should be filtered out by check above - for(QString & url : modModel->getMod(modName).getValue("screenshots").toStringList()) + for(QString url : modModel->getMod(modName).getValue("screenshots").toStringList()) { // URL must be encoded to something else to get rid of symbols illegal in file names - auto hashed = QCryptographicHash::hash(url.toUtf8(), QCryptographicHash::Md5); - auto hashedStr = QString::fromUtf8(hashed.toHex()); + const auto hashed = QCryptographicHash::hash(url.toUtf8(), QCryptographicHash::Md5); + const auto fileName = QString{QLatin1String{"%1.png"}}.arg(QLatin1String{hashed.toHex()}); - QString fullPath = CLauncherDirs::get().downloadsPath() + '/' + hashedStr + ".png"; + const auto fullPath = QString{QLatin1String{"%1/%2"}}.arg(CLauncherDirs::downloadsPath(), fileName); QPixmap pixmap(fullPath); if(pixmap.isNull()) { // image file not exists or corrupted - try to redownload - downloadFile(hashedStr + ".png", url, "screenshots"); + downloadFile(fileName, url, "screenshots"); } else { diff --git a/launcher/modManager/cmodmanager.cpp b/launcher/modManager/cmodmanager.cpp index 959a429c5..d50747e73 100644 --- a/launcher/modManager/cmodmanager.cpp +++ b/launcher/modManager/cmodmanager.cpp @@ -271,7 +271,7 @@ bool CModManager::doEnableMod(QString mod, bool on) bool CModManager::doInstallMod(QString modname, QString archivePath) { - QString destDir = CLauncherDirs::get().modsPath() + "/"; + const auto destDir = CLauncherDirs::modsPath() + QChar{'/'}; if(!QFile(archivePath).exists()) return addError(modname, "Mod archive is missing"); @@ -288,10 +288,11 @@ bool CModManager::doInstallMod(QString modname, QString archivePath) auto futureExtract = std::async(std::launch::async, [&archivePath, &destDir, &filesCounter, &filesToExtract]() { + const auto destDirFsPath = qstringToPath(destDir); ZipArchive archive(qstringToPath(archivePath)); for (auto const & file : filesToExtract) { - if (!archive.extract(qstringToPath(destDir), file)) + if (!archive.extract(destDirFsPath, file)) return false; ++filesCounter; } diff --git a/lib/network/NetworkConnection.cpp b/lib/network/NetworkConnection.cpp index 7b31ca04b..fe10bd6f3 100644 --- a/lib/network/NetworkConnection.cpp +++ b/lib/network/NetworkConnection.cpp @@ -17,8 +17,27 @@ NetworkConnection::NetworkConnection(INetworkConnectionListener & listener, cons , listener(listener) { socket->set_option(boost::asio::ip::tcp::no_delay(true)); - socket->set_option(boost::asio::socket_base::send_buffer_size(4194304)); - socket->set_option(boost::asio::socket_base::receive_buffer_size(4194304)); + + // iOS throws exception on attempt to set buffer size + constexpr auto bufferSize = 4 * 1024 * 1024; + + try + { + socket->set_option(boost::asio::socket_base::send_buffer_size{bufferSize}); + } + catch(const boost::system::system_error & e) + { + logNetwork->error("error setting 'send buffer size' socket option: %s", e.what()); + } + + try + { + socket->set_option(boost::asio::socket_base::receive_buffer_size{bufferSize}); + } + catch(const boost::system::system_error & e) + { + logNetwork->error("error setting 'receive buffer size' socket option: %s", e.what()); + } } void NetworkConnection::start()