1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

Merge pull request #3668 from kambala-decapitator/fix-ios

make iOS work again
This commit is contained in:
Ivan Savenko
2024-03-25 15:03:01 +02:00
committed by GitHub
12 changed files with 66 additions and 51 deletions

View File

@@ -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)

View File

@@ -215,10 +215,10 @@ using TLockGuardRec = std::lock_guard<std::recursive_mutex>;
/* ---------------------------------------------------------------------------- */
// 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

View File

@@ -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()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -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");
}
}

View File

@@ -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();
};
}

View File

@@ -10,11 +10,13 @@
#include "StdInc.h"
#include "main.h"
#include "mainwindow_moc.h"
#include "launcherdirs.h"
#include "../lib/VCMIDirs.h"
#include <QApplication>
#include <QProcess>
#include <QMessageBox>
#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
}

View File

@@ -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;

View File

@@ -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
{

View File

@@ -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;
}

View File

@@ -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()