diff --git a/.clang-format b/.clang-format index 3f6e6ef..aa0779e 100644 --- a/.clang-format +++ b/.clang-format @@ -31,4 +31,3 @@ AllowShortFunctionsOnASingleLine: 'Empty' AllowShortLambdasOnASingleLine: 'Empty' AllowShortLoopsOnASingleLine: 'false' SeparateDefinitionBlocks : 'Always' -... \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c9bc5c..7f42178 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,30 +10,30 @@ option(ENABLE_WATCHDOG "Build with Tesseract support (needed for Watchdog)" OFF) option(USE_OWN_LIBRARIES "Build with own libraries" OFF) option(BUILD_FLATPAK "Build with Flatpak support in mind" OFF) -if(ENABLE_WATCHDOG) +if (ENABLE_WATCHDOG) find_package(PkgConfig REQUIRED) pkg_search_module(TESSERACT REQUIRED tesseract) pkg_search_module(LEPTONICA REQUIRED lept) -endif() +endif () include(FetchContent) -if(NOT USE_OWN_LIBRARIES) +if (NOT USE_OWN_LIBRARIES) find_package(Qt5Keychain QUIET) -endif() +endif () -if(TARGET Qt5Keychain::Qt5Keychain) +if (TARGET Qt5Keychain::Qt5Keychain) message("Using system library for Qt5 Keychain") set(LIBRARIES Qt5Keychain::Qt5Keychain ${LIBRARIES}) set(KEYCHAIN_INCLUDE_DIRS ${QTKEYCHAIN_INCLUDE_DIRS}/qt5keychain) # this is to be consistent with the built-in lib? -else() +else () message("Using downloaded qtkeychain") FetchContent_Declare( qtkeychain GIT_REPOSITORY https://github.com/frankosterfeld/qtkeychain.git - GIT_TAG v0.12.0 + GIT_TAG v0.12.0 ) set(BUILD_WITH_QT6 OFF CACHE BOOL "" FORCE) @@ -45,23 +45,23 @@ else() set(KEYCHAIN_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/_deps/qtkeychain-src ${CMAKE_BINARY_DIR}/_deps/qtkeychain-build) -endif() +endif () -if(NOT USE_OWN_LIBRARIES) +if (NOT USE_OWN_LIBRARIES) find_package(QuaZip-Qt5 QUIET) -endif() +endif () -if(TARGET QuaZip::QuaZip) +if (TARGET QuaZip::QuaZip) message("Using system library for Quazip") set(LIBRARIES QuaZip::QuaZip ${LIBRARIES}) -else() +else () message("Using downloaded quazip") FetchContent_Declare( quazip GIT_REPOSITORY https://github.com/stachenov/quazip.git - GIT_TAG v1.2 + GIT_TAG v1.2 ) set(QUAZIP_USE_QT_ZLIB ON CACHE BOOL "" FORCE) @@ -71,23 +71,23 @@ else() set(LIBRARIES QuaZip ${LIBRARIES}) set(QUAZIP_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/_deps/quazip-src/quazip) -endif() +endif () -if(NOT USE_OWN_LIBRARIES) +if (NOT USE_OWN_LIBRARIES) find_package(fmt QUIET) -endif() +endif () -if(TARGET fmt::fmt) +if (TARGET fmt::fmt) message("Using system library for fmt") set(LIBRARIES fmt::fmt ${LIBRARIES}) -else() +else () message("Using downloaded fmt") FetchContent_Declare( fmt GIT_REPOSITORY https://github.com/fmtlib/fmt - GIT_TAG master + GIT_TAG master ) set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) @@ -95,25 +95,25 @@ else() FetchContent_MakeAvailable(fmt) set(LIBRARIES fmt::fmt ${LIBRARIES}) -endif() +endif () add_subdirectory(external) -if(ENABLE_WATCHDOG) +if (ENABLE_WATCHDOG) set(LIBRARIES ${LIBRARIES} ${TESSERACT_LIBRARIES} ${LEPTONICA_LIBRARIES}) set(SRC ${SRC} - include/watchdog.h - src/watchdog.cpp - include/gameparser.h - src/gameparser.cpp) -endif() + include/watchdog.h + src/watchdog.cpp + include/gameparser.h + src/gameparser.cpp) +endif () -if(ENABLE_WATCHDOG) +if (ENABLE_WATCHDOG) set(LIBRARIES ${LIBRARIES} X11 Xcomposite Xrender) -endif() +endif () add_subdirectory(launcher) \ No newline at end of file diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 193f9a3..fb14a89 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -23,14 +23,14 @@ STRING(REPLACE "\"" "\"\"" LICENSE_TXT ${LICENSE_TXT}) configure_file(${CMAKE_CURRENT_LIST_DIR}/../cmake/license.h.in ${CMAKE_BINARY_DIR}/license.h) -if(BUILD_FLATPAK) +if (BUILD_FLATPAK) target_compile_definitions(astra PRIVATE FLATPAK) -endif() +endif () install(TARGETS astra DESTINATION "${INSTALL_BIN_PATH}") -if(WIN32) +if (WIN32) get_target_property(QMAKE_EXE Qt5::qmake IMPORTED_LOCATION) get_filename_component(QT_BIN_DIR "${QMAKE_EXE}" DIRECTORY) @@ -42,4 +42,4 @@ if(WIN32) POST_BUILD COMMAND "${WINDEPLOYQT_ENV_SETUP}" && "${WINDEPLOYQT_EXECUTABLE}" \"$\" ) -endif() +endif () diff --git a/launcher/cli/include/cmdinterface.h b/launcher/cli/include/cmdinterface.h index 857c3bc..f093f83 100644 --- a/launcher/cli/include/cmdinterface.h +++ b/launcher/cli/include/cmdinterface.h @@ -1,7 +1,7 @@ #pragma once -#include #include "launchercore.h" +#include /* * The CLI interface for Astra, driven primarily by the command-line. @@ -13,6 +13,11 @@ public: bool parse(QCommandLineParser& parser, LauncherCore& core); private: - QCommandLineOption profileOption = {"default-profile", "Profile to use for default profile and autologin.", "profile"}; - QCommandLineOption autologinOption = {"autologin", "Auto-login with the default profile. This requires the profile to have remember username/password enabled!"}; + QCommandLineOption profileOption = { + "default-profile", + "Profile to use for default profile and autologin.", + "profile"}; + QCommandLineOption autologinOption = { + "autologin", + "Auto-login with the default profile. This requires the profile to have remember username/password enabled!"}; }; \ No newline at end of file diff --git a/launcher/cli/src/cmdinterface.cpp b/launcher/cli/src/cmdinterface.cpp index 5f1ea74..993e637 100644 --- a/launcher/cli/src/cmdinterface.cpp +++ b/launcher/cli/src/cmdinterface.cpp @@ -1,27 +1,27 @@ -#include #include "cmdinterface.h" -#include "squareboot.h" #include "sapphirelauncher.h" +#include "squareboot.h" +#include -CMDInterface::CMDInterface(QCommandLineParser &parser) { +CMDInterface::CMDInterface(QCommandLineParser& parser) { parser.addOption(autologinOption); parser.addOption(profileOption); } -bool CMDInterface::parse(QCommandLineParser &parser, LauncherCore &core) { - if(parser.isSet(profileOption)) { +bool CMDInterface::parse(QCommandLineParser& parser, LauncherCore& core) { + if (parser.isSet(profileOption)) { core.defaultProfileIndex = core.getProfileIndex(parser.value(profileOption)); - if(core.defaultProfileIndex == -1) { + if (core.defaultProfileIndex == -1) { qInfo() << "The profile \"" << parser.value(profileOption) << "\" does not exist!"; return false; } } - if(parser.isSet(autologinOption)) { + if (parser.isSet(autologinOption)) { auto& profile = core.getProfile(core.defaultProfileIndex); - if(!profile.rememberUsername || !profile.rememberPassword) { + if (!profile.rememberUsername || !profile.rememberPassword) { qInfo() << "Profile does not have a username and/or password saved, autologin disabled."; return false; @@ -34,10 +34,11 @@ bool CMDInterface::parse(QCommandLineParser &parser, LauncherCore &core) { usernameJob->setKey(profile.name + "-username"); usernameJob->start(); - core.connect(usernameJob, &QKeychain::ReadPasswordJob::finished, [loop, usernameJob, &username](QKeychain::Job* j) { - username = usernameJob->textData(); - loop->quit(); - }); + core.connect( + usernameJob, &QKeychain::ReadPasswordJob::finished, [loop, usernameJob, &username](QKeychain::Job* j) { + username = usernameJob->textData(); + loop->quit(); + }); loop->exec(); @@ -45,10 +46,11 @@ bool CMDInterface::parse(QCommandLineParser &parser, LauncherCore &core) { passwordJob->setKey(profile.name + "-password"); passwordJob->start(); - core.connect(passwordJob, &QKeychain::ReadPasswordJob::finished, [loop, passwordJob, &password](QKeychain::Job* j) { - password = passwordJob->textData(); - loop->quit(); - }); + core.connect( + passwordJob, &QKeychain::ReadPasswordJob::finished, [loop, passwordJob, &password](QKeychain::Job* j) { + password = passwordJob->textData(); + loop->quit(); + }); loop->exec(); @@ -57,7 +59,7 @@ bool CMDInterface::parse(QCommandLineParser &parser, LauncherCore &core) { info->username = username; info->password = password; - if(profile.isSapphire) { + if (profile.isSapphire) { core.sapphireLauncher->login(profile.lobbyURL, *info); } else { core.squareBoot->bootCheck(*info); diff --git a/launcher/core/CMakeLists.txt b/launcher/core/CMakeLists.txt index 4133e59..0eef15d 100644 --- a/launcher/core/CMakeLists.txt +++ b/launcher/core/CMakeLists.txt @@ -21,7 +21,7 @@ set(SRC src/squarelauncher.cpp src/patcher.cpp) -if(ENABLE_WATCHDOG) +if (ENABLE_WATCHDOG) set(HEADERS ${HEADERS} include/gameparser.h include/watchdog.h) @@ -29,7 +29,7 @@ if(ENABLE_WATCHDOG) set(SRC ${SRC} src/gameparser.cpp src/watchdog.cpp) -endif() +endif () add_library(astra_core STATIC ${HEADERS} ${SRC}) target_include_directories(astra_core PUBLIC @@ -48,8 +48,8 @@ target_link_libraries(astra_core PUBLIC PRIVATE astra_desktop) # desktop is currently required by the core, to be fixed/removed later -if(ENABLE_WATCHDOG) +if (ENABLE_WATCHDOG) target_include_directories(astra_core PUBLIC ${TESSERACT_INCLUDE_DIRS} ${LEPTONICA_INCLUDE_DIRS}) target_compile_definitions(astra_core PUBLIC ENABLE_WATCHDOG) -endif() +endif () diff --git a/launcher/core/include/encryptedarg.h b/launcher/core/include/encryptedarg.h index ec91413..80f607b 100644 --- a/launcher/core/include/encryptedarg.h +++ b/launcher/core/include/encryptedarg.h @@ -4,10 +4,7 @@ #include // from xivdev -static char ChecksumTable[] = { - 'f', 'X', '1', 'p', 'G', 't', 'd', 'S', - '5', 'C', 'A', 'P', '4', '_', 'V', 'L' -}; +static char ChecksumTable[] = {'f', 'X', '1', 'p', 'G', 't', 'd', 'S', '5', 'C', 'A', 'P', '4', '_', 'V', 'L'}; inline char GetChecksum(unsigned int key) { auto value = key & 0x000F0000; @@ -31,13 +28,13 @@ inline QString encryptGameArg(QString arg) { QByteArray toEncrypt = (QString(" /T =%1").arg(ticks) + arg).toUtf8(); - physis_blowfish_encrypt(blowfish, - reinterpret_cast(toEncrypt.data()), toEncrypt.size(), &out_data, &out_size); + physis_blowfish_encrypt( + blowfish, reinterpret_cast(toEncrypt.data()), toEncrypt.size(), &out_data, &out_size); - QByteArray encryptedArg = QByteArray::fromRawData( - reinterpret_cast(out_data), out_size); + QByteArray encryptedArg = QByteArray::fromRawData(reinterpret_cast(out_data), out_size); - QString base64 = encryptedArg.toBase64(QByteArray::Base64Option::Base64UrlEncoding | QByteArray::Base64Option::OmitTrailingEquals); + QString base64 = encryptedArg.toBase64( + QByteArray::Base64Option::Base64UrlEncoding | QByteArray::Base64Option::OmitTrailingEquals); char checksum = GetChecksum(key); return QString("//**sqex0003%1%2**//").arg(base64, QString(checksum)); diff --git a/launcher/core/include/gameparser.h b/launcher/core/include/gameparser.h index 03d619e..5bfc7e1 100644 --- a/launcher/core/include/gameparser.h +++ b/launcher/core/include/gameparser.h @@ -1,8 +1,8 @@ #pragma once #include -#include #include +#include enum class ScreenState { Splash, diff --git a/launcher/core/include/headline.h b/launcher/core/include/headline.h index 4b8d37d..a889683 100644 --- a/launcher/core/include/headline.h +++ b/launcher/core/include/headline.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include struct News { QDateTime date; diff --git a/launcher/core/include/launchercore.h b/launcher/core/include/launchercore.h index 77d80a2..4d4ea4e 100755 --- a/launcher/core/include/launchercore.h +++ b/launcher/core/include/launchercore.h @@ -1,12 +1,12 @@ #pragma once -#include -#include #include +#include +#include +#include +#include #include #include -#include -#include #include #include "squareboot.h" @@ -162,7 +162,12 @@ public: /* * This just wraps it in wine if needed. */ - void launchExecutable(const ProfileSettings& settings, QProcess* process, QStringList args, bool isGame, bool needsRegistrySetup); + void launchExecutable( + const ProfileSettings& settings, + QProcess* process, + QStringList args, + bool isGame, + bool needsRegistrySetup); /* * Launches an external tool. Gamescope for example is intentionally excluded. diff --git a/launcher/core/include/patcher.h b/launcher/core/include/patcher.h index 049664c..021aea4 100644 --- a/launcher/core/include/patcher.h +++ b/launcher/core/include/patcher.h @@ -1,8 +1,8 @@ #pragma once -#include -#include #include +#include +#include #include // General-purpose patcher routine. It opens a nice dialog box, handles downloading diff --git a/launcher/core/include/watchdog.h b/launcher/core/include/watchdog.h index a011a09..4be4386 100644 --- a/launcher/core/include/watchdog.h +++ b/launcher/core/include/watchdog.h @@ -5,7 +5,7 @@ #include "launchercore.h" #if defined(Q_OS_LINUX) -#include "gameparser.h" + #include "gameparser.h" #endif #include diff --git a/launcher/core/src/dxvkinstaller.cpp b/launcher/core/src/dxvkinstaller.cpp index fdf86ed..e5aec1b 100644 --- a/launcher/core/src/dxvkinstaller.cpp +++ b/launcher/core/src/dxvkinstaller.cpp @@ -2,6 +2,4 @@ #include "launchercore.h" -void installDXVK(LauncherCore& launcher, ProfileSettings& profile, std::function returnFunc) { - -} \ No newline at end of file +void installDXVK(LauncherCore& launcher, ProfileSettings& profile, std::function returnFunc) {} \ No newline at end of file diff --git a/launcher/core/src/encryptedarg.cpp b/launcher/core/src/encryptedarg.cpp index e7a018c..dfef2d0 100644 --- a/launcher/core/src/encryptedarg.cpp +++ b/launcher/core/src/encryptedarg.cpp @@ -1,12 +1,12 @@ #include "encryptedarg.h" #if defined(Q_OS_MAC) -#include -#include + #include + #include #endif #if defined(Q_OS_WIN) -#include + #include #endif #if defined(Q_OS_MAC) @@ -16,7 +16,7 @@ uint32_t TickCount() { mach_timebase_info(&timebase); auto machtime = mach_continuous_time(); - auto numer = uint64_t (timebase.numer); + auto numer = uint64_t(timebase.numer); auto denom = uint64_t(timebase.denom); auto monotonic_time = machtime * numer / denom / 100; return monotonic_time / 10000; diff --git a/launcher/core/src/gameinstaller.cpp b/launcher/core/src/gameinstaller.cpp index 80ea66a..964f779 100644 --- a/launcher/core/src/gameinstaller.cpp +++ b/launcher/core/src/gameinstaller.cpp @@ -1,8 +1,8 @@ #include "gameinstaller.h" +#include #include #include -#include #include #include "launchercore.h" @@ -17,15 +17,15 @@ void installGame(LauncherCore& launcher, ProfileSettings& profile, std::function auto reply = launcher.mgr->get(request); launcher.connect(reply, &QNetworkReply::finished, [reply, installDirectory, returnFunc] { - QString dataDir = - QStandardPaths::writableLocation(QStandardPaths::TempLocation); + QString dataDir = QStandardPaths::writableLocation(QStandardPaths::TempLocation); QFile file(dataDir + "/ffxivsetup.exe"); file.open(QIODevice::WriteOnly); file.write(reply->readAll()); file.close(); - physis_install_game(installDirectory.toStdString().c_str(), (dataDir + "/ffxivsetup.exe").toStdString().c_str()); + physis_install_game( + installDirectory.toStdString().c_str(), (dataDir + "/ffxivsetup.exe").toStdString().c_str()); qDebug() << "Done installing to " << installDirectory << "!"; diff --git a/launcher/core/src/gameparser.cpp b/launcher/core/src/gameparser.cpp index 605a119..eb38cc8 100644 --- a/launcher/core/src/gameparser.cpp +++ b/launcher/core/src/gameparser.cpp @@ -1,8 +1,8 @@ #include "gameparser.h" +#include #include #include -#include GameParser::GameParser() { api = new tesseract::TessBaseAPI(); @@ -25,7 +25,7 @@ GameParseResult GameParser::parseImage(QImage img) { img = img.convertToFormat(QImage::Format_Grayscale8); img.save(&buf, "PNG", 100); - Pix* image = pixReadMem((const l_uint8 *) buf.data().data(), buf.size()); + Pix* image = pixReadMem((const l_uint8*)buf.data().data(), buf.size()); api->SetImage(image); api->SetSourceResolution(300); @@ -38,35 +38,35 @@ GameParseResult GameParser::parseImage(QImage img) { const bool hasConnectingToData = text.contains("Connecting to data center"); const bool worldTotallyFull = text.contains("3001"); - if(hasLobbyErrorText) { + if (hasLobbyErrorText) { qDebug() << "LOBBY ERROR"; return {ScreenState::LobbyError, -1}; } else { - if(worldTotallyFull) { + if (worldTotallyFull) { qDebug() << "TOTALLY FULL WORLD (CLOSED BY SQENIX)"; return {ScreenState::WorldFull, -1}; } else { - if(hasConnectingToData) { + if (hasConnectingToData) { qDebug() << "CONNECTING TO DATA CENTER"; return {ScreenState::ConnectingToDataCenter, -1}; } else { - if(hasWorldFullText) { + if (hasWorldFullText) { qDebug() << "FULL WORLD"; // attempt to extract number of players in queue QRegularExpression exp("(?:Players in queue: )([\\d|,]*)"); auto match = exp.match(text); - if(match.isValid()) { + if (match.isValid()) { return {ScreenState::InLoginQueue, match.captured(1).remove(',').toInt()}; } return {ScreenState::InLoginQueue, -1}; } else { - if(hasCONFIGURATIONText) { + if (hasCONFIGURATIONText) { qDebug() << "TITLE SCREEN"; return {ScreenState::EnteredTitleScreen, -1}; } diff --git a/launcher/core/src/headline.cpp b/launcher/core/src/headline.cpp index 59c5bc7..0d9fd19 100644 --- a/launcher/core/src/headline.cpp +++ b/launcher/core/src/headline.cpp @@ -1,12 +1,12 @@ #include "headline.h" -#include -#include #include -#include +#include #include #include -#include +#include +#include +#include #include "launchercore.h" @@ -21,7 +21,8 @@ void getHeadline(LauncherCore& core, std::function return_func) url.setPath("/news/headline.json"); url.setQuery(query); - auto request = QNetworkRequest(QString("%1&%2").arg(url.toString(), QString::number(QDateTime::currentMSecsSinceEpoch()))); + auto request = + QNetworkRequest(QString("%1&%2").arg(url.toString(), QString::number(QDateTime::currentMSecsSinceEpoch()))); // TODO: really? core.buildRequest(core.getProfile(core.defaultProfileIndex), request); @@ -29,7 +30,11 @@ void getHeadline(LauncherCore& core, std::function return_func) qInfo() << request.url(); request.setRawHeader("Accept", "application/json, text/plain, */*"); request.setRawHeader("Origin", "https://launcher.finalfantasyxiv.com"); - request.setRawHeader("Referer", QString("https://launcher.finalfantasyxiv.com/v600/index.html?rc_lang=%1&time=%2").arg("en-us", QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd-HH")).toUtf8()); + request.setRawHeader( + "Referer", + QString("https://launcher.finalfantasyxiv.com/v600/index.html?rc_lang=%1&time=%2") + .arg("en-us", QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd-HH")) + .toUtf8()); auto reply = core.mgr->get(request); core.connect(reply, &QNetworkReply::finished, [=] { @@ -44,7 +49,7 @@ void getHeadline(LauncherCore& core, std::function return_func) news.tag = object["tag"].toString(); news.title = object["title"].toString(); - if(object["url"].toString().isEmpty()) { + if (object["url"].toString().isEmpty()) { news.url = QUrl(QString("https://na.finalfantasyxiv.com/lodestone/news/detail/%1").arg(news.id)); } else { news.url = QUrl(object["url"].toString()); @@ -53,7 +58,7 @@ void getHeadline(LauncherCore& core, std::function return_func) return news; }; - for(auto bannerObject : document.object()["banner"].toArray()) { + for (auto bannerObject : document.object()["banner"].toArray()) { Banner banner; banner.link = QUrl(bannerObject.toObject()["link"].toString()); banner.bannerImage = QUrl(bannerObject.toObject()["lsb_banner"].toString()); @@ -61,17 +66,17 @@ void getHeadline(LauncherCore& core, std::function return_func) headline.banner.push_back(banner); } - for(auto newsObject : document.object()["news"].toArray()) { + for (auto newsObject : document.object()["news"].toArray()) { auto news = parseNews(newsObject.toObject()); headline.news.push_back(news); } - for(auto pinnedObject : document.object()["pinned"].toArray()) { + for (auto pinnedObject : document.object()["pinned"].toArray()) { auto pinned = parseNews(pinnedObject.toObject()); headline.pinned.push_back(pinned); } - for(auto pinnedObject : document.object()["topics"].toArray()) { + for (auto pinnedObject : document.object()["topics"].toArray()) { auto pinned = parseNews(pinnedObject.toObject()); headline.topics.push_back(pinned); } diff --git a/launcher/core/src/launchercore.cpp b/launcher/core/src/launchercore.cpp index e63c927..28924ed 100755 --- a/launcher/core/src/launchercore.cpp +++ b/launcher/core/src/launchercore.cpp @@ -1,35 +1,35 @@ -#include -#include -#include -#include -#include +#include +#include +#include #include #include -#include -#include -#include -#include #include -#include -#include -#include +#include +#include #include -#include -#include +#include +#include +#include +#include +#include +#include #include -#include +#include #include +#include +#include +#include -#include "launchercore.h" -#include "sapphirelauncher.h" -#include "squarelauncher.h" -#include "squareboot.h" -#include "settingswindow.h" #include "assetupdater.h" #include "encryptedarg.h" +#include "launchercore.h" +#include "sapphirelauncher.h" +#include "settingswindow.h" +#include "squareboot.h" +#include "squarelauncher.h" #ifdef ENABLE_WATCHDOG -#include "watchdog.h" + #include "watchdog.h" #endif void LauncherCore::setSSL(QNetworkRequest& request) { @@ -43,15 +43,18 @@ void LauncherCore::setSSL(QNetworkRequest& request) { void LauncherCore::buildRequest(const ProfileSettings& settings, QNetworkRequest& request) { setSSL(request); - if(settings.license == GameLicense::macOS) { + if (settings.license == GameLicense::macOS) { request.setHeader(QNetworkRequest::UserAgentHeader, "macSQEXAuthor/2.0.0(MacOSX; ja-jp)"); } else { - request.setHeader(QNetworkRequest::UserAgentHeader, - QString("SQEXAuthor/2.0.0(Windows 6.2; ja-jp; %1)").arg(QString(QSysInfo::bootUniqueId()))); + request.setHeader( + QNetworkRequest::UserAgentHeader, + QString("SQEXAuthor/2.0.0(Windows 6.2; ja-jp; %1)").arg(QString(QSysInfo::bootUniqueId()))); } - request.setRawHeader("Accept", - "image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/xaml+xml, application/x-ms-xbap, */*"); + request.setRawHeader( + "Accept", + "image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/xaml+xml, " + "application/x-ms-xbap, */*"); request.setRawHeader("Accept-Encoding", "gzip, deflate"); request.setRawHeader("Accept-Language", "en-us"); } @@ -61,13 +64,13 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au QString dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); - if(profile.dalamud.enabled) { + if (profile.dalamud.enabled) { arguments.push_back(dataDir + "/NativeLauncher.exe"); arguments.push_back("5248"); // TODO: make port configurable/random } // now for the actual game... - if(profile.useDX9) { + if (profile.useDX9) { arguments.push_back(profile.gamePath + "\\game\\ffxiv.exe"); } else { arguments.push_back(profile.gamePath + "\\game\\ffxiv_dx11.exe"); @@ -87,9 +90,9 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au gameArgs.push_back({"language", QString::number(profile.language)}); gameArgs.push_back({"ver", profile.repositories.repositories[0].version}); - if(!auth.lobbyhost.isEmpty()) { + if (!auth.lobbyhost.isEmpty()) { gameArgs.push_back({"DEV.GMServerHost", auth.frontierHost}); - for(int i = 1; i < 9; i++) { + for (int i = 1; i < 9; i++) { gameArgs.push_back({QString("DEV.LobbyHost0%1").arg(QString::number(i)), auth.lobbyhost}); gameArgs.push_back({QString("DEV.LobbyPort0%1").arg(QString::number(i)), QString::number(54994)}); } @@ -99,16 +102,15 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - if(profile.license == GameLicense::WindowsSteam) { + if (profile.license == GameLicense::WindowsSteam) { gameArgs.push_back({"IsSteam", "1"}); env.insert("IS_FFXIV_LAUNCH_FROM_STEAM", QString::number(1)); } - if(profile.dalamud.enabled) { + if (profile.dalamud.enabled) { // TODO: this depends on the default wine Z: path existing, which may not // always the case. - env.insert("DALAMUD_RUNTIME", - "Z:" + dataDir.replace('/', '\\') + "\\DalamudRuntime"); + env.insert("DALAMUD_RUNTIME", "Z:" + dataDir.replace('/', '\\') + "\\DalamudRuntime"); } gameProcess->setProcessEnvironment(env); @@ -118,17 +120,17 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au const QString argFormat = profile.encryptArguments ? " /%1 =%2" : " %1=%2"; QString argJoined; - for(const auto& arg : gameArgs) { + for (const auto& arg : gameArgs) { argJoined += argFormat.arg(arg.key, arg.value); } - if(profile.encryptArguments) { + if (profile.encryptArguments) { arguments.append(encryptGameArg(argJoined)); } else { arguments.append(argJoined); } - if(profile.dalamud.enabled) { + if (profile.dalamud.enabled) { auto socket = new QTcpServer(); connect(socket, &QTcpServer::newConnection, [this, &profile, socket] { @@ -139,7 +141,7 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au bool success; int exitCode = output.toInt(&success, 10); - if(exitCode != -1 && success) { + if (exitCode != -1 && success) { QString dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); dataDir = "Z:" + dataDir.replace('/', '\\'); @@ -169,7 +171,12 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au auto list = dalamudProcess->processEnvironment().toStringList(); - launchExecutable(profile, dalamudProcess, {dataDir + "/Dalamud/" + "Dalamud.Injector.exe", QString::number(exitCode), argsEncoded}, false, true); + launchExecutable( + profile, + dalamudProcess, + {dataDir + "/Dalamud/" + "Dalamud.Injector.exe", QString::number(exitCode), argsEncoded}, + false, + true); connection->close(); socket->close(); @@ -180,9 +187,13 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au socket->listen(QHostAddress::Any, 5248); } - connect(gameProcess, qOverload(&QProcess::finished), this, [this](int code, QProcess::ExitStatus status) { - gameClosed(); - }); + connect( + gameProcess, + qOverload(&QProcess::finished), + this, + [this](int code, QProcess::ExitStatus status) { + gameClosed(); + }); launchGameExecutable(profile, gameProcess, arguments); @@ -209,13 +220,18 @@ void LauncherCore::launchGameExecutable(const ProfileSettings& profile, QProcess launchExecutable(profile, process, arguments, true, true); } -void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* process, const QStringList args, bool isGame, bool needsRegistrySetup) { +void LauncherCore::launchExecutable( + const ProfileSettings& profile, + QProcess* process, + const QStringList args, + bool isGame, + bool needsRegistrySetup) { QList arguments; auto env = process->processEnvironment(); - if(needsRegistrySetup) { + if (needsRegistrySetup) { #if defined(Q_OS_LINUX) || defined(Q_OS_MAC) - if(profile.license == GameLicense::macOS) { + if (profile.license == GameLicense::macOS) { addRegistryKey(profile, "HKEY_CURRENT_USER\\Software\\Wine", "HideWineExports", "0"); } else { addRegistryKey(profile, "HKEY_CURRENT_USER\\Software\\Wine", "HideWineExports", "1"); @@ -235,16 +251,13 @@ void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* pr arguments.push_back("-b"); if (profile.gamescope.width > 0) - arguments.push_back("-w " + - QString::number(profile.gamescope.width)); + arguments.push_back("-w " + QString::number(profile.gamescope.width)); if (profile.gamescope.height > 0) - arguments.push_back("-h " + - QString::number(profile.gamescope.height)); + arguments.push_back("-h " + QString::number(profile.gamescope.height)); if (profile.gamescope.refreshRate > 0) - arguments.push_back( - "-r " + QString::number(profile.gamescope.refreshRate)); + arguments.push_back("-r " + QString::number(profile.gamescope.refreshRate)); } if (profile.useGamemode) @@ -253,7 +266,7 @@ void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* pr #endif #if defined(Q_OS_LINUX) - if(profile.useEsync) { + if (profile.useEsync) { env.insert("WINEESYNC", QString::number(1)); env.insert("WINEFSYNC", QString::number(1)); env.insert("WINEFSYNC_FUTEX2", QString::number(1)); @@ -264,9 +277,10 @@ void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* pr env.insert("WINEPREFIX", profile.winePrefixPath); // XIV on Mac bundle their own Wine install directory, complete with libs etc - if(profile.wineType == WineType::XIVOnMac) { + if (profile.wineType == WineType::XIVOnMac) { // TODO: don't hardcode this - QString xivLibPath = "/Applications/XIV on Mac.app/Contents/Resources/wine/lib:/Applications/XIV on Mac.app/Contents/Resources/MoltenVK/modern"; + QString xivLibPath = "/Applications/XIV on Mac.app/Contents/Resources/wine/lib:/Applications/XIV on " + "Mac.app/Contents/Resources/MoltenVK/modern"; env.insert("DYLD_FALLBACK_LIBRARY_PATH", xivLibPath); env.insert("DYLD_VERSIONED_LIBRARY_PATH", xivLibPath); @@ -276,10 +290,10 @@ void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* pr env.insert("MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS", "1"); } -#if defined(FLATPAK) + #if defined(FLATPAK) arguments.push_back("flatpak-spawn"); arguments.push_back("--host"); -#endif + #endif arguments.push_back(profile.winePath); #endif @@ -317,8 +331,7 @@ void LauncherCore::readInitialInformation() { gamescopeAvailable = checkIfInPath("gamescope"); gamemodeAvailable = checkIfInPath("gamemoderun"); - const QString dataDir = - QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); + const QString dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); const bool hasDalamud = QFile::exists(dataDir + "/Dalamud"); if (hasDalamud) { @@ -328,33 +341,25 @@ void LauncherCore::readInitialInformation() { QJsonDocument doc = QJsonDocument::fromJson(depsJson.readAll()); QString versionString; - if(doc["targets"].toObject().contains(".NETCoreApp,Version=v5.0")) { + if (doc["targets"].toObject().contains(".NETCoreApp,Version=v5.0")) { versionString = - doc["targets"] - .toObject()[".NETCoreApp,Version=v5.0"] - .toObject() - .keys() - .filter("Dalamud")[0]; + doc["targets"].toObject()[".NETCoreApp,Version=v5.0"].toObject().keys().filter("Dalamud")[0]; } else { versionString = - doc["targets"] - .toObject()[".NETCoreApp,Version=v6.0"] - .toObject() - .keys() - .filter("Dalamud")[0]; + doc["targets"].toObject()[".NETCoreApp,Version=v6.0"].toObject().keys().filter("Dalamud")[0]; } dalamudVersion = versionString.remove("Dalamud/"); } - if(QFile::exists(dataDir + "/DalamudAssets/asset.ver")) { + if (QFile::exists(dataDir + "/DalamudAssets/asset.ver")) { QFile assetJson(dataDir + "/DalamudAssets/asset.ver"); assetJson.open(QFile::ReadOnly | QFile::Text); dalamudAssetVersion = QString(assetJson.readAll()).toInt(); } - if(QFile::exists(dataDir + "/DalamudRuntime/runtime.ver")) { + if (QFile::exists(dataDir + "/DalamudRuntime/runtime.ver")) { QFile runtimeVer(dataDir + "/DalamudRuntime/runtime.ver"); runtimeVer.open(QFile::ReadOnly | QFile::Text); @@ -362,7 +367,7 @@ void LauncherCore::readInitialInformation() { } } - if(QFile::exists(dataDir + "/nativelauncher.ver")) { + if (QFile::exists(dataDir + "/nativelauncher.ver")) { QFile nativeVer(dataDir + "/nativelauncher.ver"); nativeVer.open(QFile::ReadOnly | QFile::Text); @@ -372,12 +377,12 @@ void LauncherCore::readInitialInformation() { auto profiles = settings.childGroups(); // create the Default profile if it doesnt exist - if(profiles.empty()) + if (profiles.empty()) profiles.append(QUuid::createUuid().toString(QUuid::StringFormat::WithoutBraces)); profileSettings.resize(profiles.size()); - for(const auto& uuid : profiles) { + for (const auto& uuid : profiles) { ProfileSettings* profile = new ProfileSettings(); profile->uuid = QUuid(uuid); @@ -385,19 +390,22 @@ void LauncherCore::readInitialInformation() { profile->name = settings.value("name", "Default").toString(); - if(settings.contains("gamePath") && settings.value("gamePath").canConvert() && !settings.value("gamePath").toString().isEmpty()) { + if (settings.contains("gamePath") && settings.value("gamePath").canConvert() && + !settings.value("gamePath").toString().isEmpty()) { profile->gamePath = settings.value("gamePath").toString(); } else { profile->gamePath = getDefaultGamePath(); } - if(settings.contains("winePrefixPath") && settings.value("winePrefixPath").canConvert() && !settings.value("winePrefixPath").toString().isEmpty()) { + if (settings.contains("winePrefixPath") && settings.value("winePrefixPath").canConvert() && + !settings.value("winePrefixPath").toString().isEmpty()) { profile->winePrefixPath = settings.value("winePrefixPath").toString(); } else { profile->winePrefixPath = getDefaultWinePrefixPath(); } - if(settings.contains("winePath") && settings.value("winePath").canConvert() && !settings.value("winePath").toString().isEmpty()) { + if (settings.contains("winePath") && settings.value("winePath").canConvert() && + !settings.value("winePath").toString().isEmpty()) { profile->winePath = settings.value("winePath").toString(); } @@ -421,10 +429,10 @@ void LauncherCore::readInitialInformation() { readWineInfo(*profile); - if(gamescopeAvailable) + if (gamescopeAvailable) profile->useGamescope = settings.value("useGamescope", defaultSettings.useGamescope).toBool(); - if(gamemodeAvailable) + if (gamemodeAvailable) profile->useGamemode = settings.value("useGamemode", defaultSettings.useGamemode).toBool(); profile->enableDXVKhud = settings.value("enableDXVKhud", defaultSettings.enableDXVKhud).toBool(); @@ -432,14 +440,18 @@ void LauncherCore::readInitialInformation() { profile->enableWatchdog = settings.value("enableWatchdog", defaultSettings.enableWatchdog).toBool(); // gamescope - profile->gamescope.borderless = settings.value("gamescopeBorderless", defaultSettings.gamescope.borderless).toBool(); + profile->gamescope.borderless = + settings.value("gamescopeBorderless", defaultSettings.gamescope.borderless).toBool(); profile->gamescope.width = settings.value("gamescopeWidth", defaultSettings.gamescope.width).toInt(); profile->gamescope.height = settings.value("gamescopeHeight", defaultSettings.gamescope.height).toInt(); - profile->gamescope.refreshRate = settings.value("gamescopeRefreshRate", defaultSettings.gamescope.refreshRate).toInt(); + profile->gamescope.refreshRate = + settings.value("gamescopeRefreshRate", defaultSettings.gamescope.refreshRate).toInt(); profile->dalamud.enabled = settings.value("enableDalamud", defaultSettings.dalamud.enabled).toBool(); - profile->dalamud.optOutOfMbCollection = settings.value("dalamudOptOut", defaultSettings.dalamud.optOutOfMbCollection).toBool(); - profile->dalamud.channel = (DalamudChannel)settings.value("dalamudChannel", (int)defaultSettings.dalamud.channel).toInt(); + profile->dalamud.optOutOfMbCollection = + settings.value("dalamudOptOut", defaultSettings.dalamud.optOutOfMbCollection).toBool(); + profile->dalamud.channel = + (DalamudChannel)settings.value("dalamudChannel", (int)defaultSettings.dalamud.channel).toInt(); profileSettings[settings.value("index").toInt()] = profile; @@ -451,7 +463,7 @@ void LauncherCore::readInitialInformation() { void LauncherCore::readWineInfo(ProfileSettings& profile) { #if defined(Q_OS_MAC) - switch(profile.wineType) { + switch (profile.wineType) { case WineType::System: // system wine profile.winePath = "/usr/local/bin/wine64"; break; @@ -459,7 +471,8 @@ void LauncherCore::readWineInfo(ProfileSettings& profile) { profile.winePath = profile.winePath; break; case WineType::Builtin: // ffxiv built-in (for mac users) - profile.winePath = "/Applications/FINAL FANTASY XIV ONLINE.app/Contents/SharedSupport/finalfantasyxiv/FINAL FANTASY XIV ONLINE/wine"; + profile.winePath = "/Applications/FINAL FANTASY XIV " + "ONLINE.app/Contents/SharedSupport/finalfantasyxiv/FINAL FANTASY XIV ONLINE/wine"; break; case WineType::XIVOnMac: profile.winePath = "/Applications/XIV on Mac.app/Contents/Resources/wine/bin/wine64"; @@ -468,14 +481,14 @@ void LauncherCore::readWineInfo(ProfileSettings& profile) { #endif #if defined(Q_OS_LINUX) - switch(profile.wineType) { - case WineType::System: // system wine (should be in $PATH) - profile.winePath = "/usr/bin/wine"; - break; - case WineType::Custom: // custom pth - profile.winePath = profile.winePath; - break; - } + switch (profile.wineType) { + case WineType::System: // system wine (should be in $PATH) + profile.winePath = "/usr/bin/wine"; + break; + case WineType::Custom: // custom pth + profile.winePath = profile.winePath; + break; + } #endif #if defined(Q_OS_LINUX) || defined(Q_OS_MAC) @@ -493,7 +506,7 @@ void LauncherCore::readWineInfo(ProfileSettings& profile) { } void LauncherCore::readGameVersion() { - for(auto& profile : profileSettings) { + for (auto& profile : profileSettings) { profile->gameData = physis_gamedata_initialize((profile->gamePath + "/game").toStdString().c_str()); profile->bootData = physis_bootdata_initialize((profile->gamePath + "/boot").toStdString().c_str()); @@ -504,7 +517,8 @@ void LauncherCore::readGameVersion() { } } -LauncherCore::LauncherCore() : settings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::applicationName()) { +LauncherCore::LauncherCore() + : settings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::applicationName()) { mgr = new QNetworkAccessManager(); sapphireLauncher = new SapphireLauncher(*this); squareLauncher = new SquareLauncher(*this); @@ -523,8 +537,8 @@ ProfileSettings& LauncherCore::getProfile(int index) { } int LauncherCore::getProfileIndex(QString name) { - for(int i = 0; i < profileSettings.size(); i++) { - if(profileSettings[i]->name == name) + for (int i = 0; i < profileSettings.size(); i++) { + if (profileSettings[i]->name == name) return i; } @@ -533,7 +547,7 @@ int LauncherCore::getProfileIndex(QString name) { QList LauncherCore::profileList() const { QList list; - for(auto profile : profileSettings) { + for (auto profile : profileSettings) { list.append(profile->name); } @@ -559,8 +573,8 @@ int LauncherCore::addProfile() { int LauncherCore::deleteProfile(QString name) { int index = 0; - for(int i = 0; i < profileSettings.size(); i++) { - if(profileSettings[i]->name == name) + for (int i = 0; i < profileSettings.size(); i++) { + if (profileSettings[i]->name == name) index = i; } @@ -580,7 +594,7 @@ void LauncherCore::saveSettings() { settings.setValue("showBanners", appSettings.showBanners); settings.setValue("showNewsList", appSettings.showNewsList); - for(int i = 0; i < profileSettings.size(); i++) { + for (int i = 0; i < profileSettings.size(); i++) { const auto& profile = profileSettings[i]; settings.beginGroup(profile->uuid.toString(QUuid::StringFormat::WithoutBraces)); @@ -663,7 +677,9 @@ QString LauncherCore::getDefaultGamePath() { #endif #if defined(Q_OS_MAC) - return QDir::homePath() + "/Library/Application Support/FINAL FANTASY XIV ONLINE/Bottles/published_Final_Fantasy/drive_c/Program Files (x86)/SquareEnix/FINAL FANTASY XIV - A Realm Reborn"; + return QDir::homePath() + + "/Library/Application Support/FINAL FANTASY XIV ONLINE/Bottles/published_Final_Fantasy/drive_c/Program " + "Files (x86)/SquareEnix/FINAL FANTASY XIV - A Realm Reborn"; #endif #if defined(Q_OS_LINUX) @@ -671,19 +687,18 @@ QString LauncherCore::getDefaultGamePath() { #endif } -void LauncherCore::addRegistryKey(const ProfileSettings& settings, - QString key, QString value, QString data) { +void LauncherCore::addRegistryKey(const ProfileSettings& settings, QString key, QString value, QString data) { auto process = new QProcess(this); process->setProcessEnvironment(QProcessEnvironment::systemEnvironment()); - launchExecutable(settings, process, {"reg", "add", key, "/v", value, "/d", data, "/f" }, false, false); + launchExecutable(settings, process, {"reg", "add", key, "/v", value, "/d", data, "/f"}, false, false); } void LauncherCore::readGameData(ProfileSettings& profile) { EXH* exh = physis_gamedata_read_excel_sheet_header(profile.gameData, "ExVersion"); - if(exh != nullptr) { + if (exh != nullptr) { physis_EXD exd = physis_gamedata_read_excel_sheet(profile.gameData, "ExVersion", exh, Language::English, 0); - for(int i = 0; i < exd.row_count; i++) { + for (int i = 0; i < exd.row_count; i++) { expansionNames.push_back(exd.row_data[i].column_data[0].string._0); } diff --git a/launcher/core/src/patcher.cpp b/launcher/core/src/patcher.cpp index dca2728..83bd6f3 100644 --- a/launcher/core/src/patcher.cpp +++ b/launcher/core/src/patcher.cpp @@ -1,10 +1,10 @@ #include "patcher.h" +#include #include #include #include #include #include -#include Patcher::Patcher(QString baseDirectory, BootData* boot_data) : boot_data(boot_data), baseDirectory(baseDirectory) { dialog = new QProgressDialog(); @@ -21,12 +21,12 @@ Patcher::Patcher(QString baseDirectory, GameData* game_data) : game_data(game_da } void Patcher::processPatchList(QNetworkAccessManager& mgr, QString patchList) { - if(patchList.isEmpty()) { + if (patchList.isEmpty()) { dialog->hide(); emit done(); } else { - if(isBoot()) { + if (isBoot()) { dialog->setLabelText("Updating the FINAL FANTASY XIV Updater/Launcher version."); } else { dialog->setLabelText("Updating the FINAL FANTASY XIV Game version."); @@ -36,7 +36,7 @@ void Patcher::processPatchList(QNetworkAccessManager& mgr, QString patchList) { remainingPatches = parts.size() - 7; - for(int i = 5; i < parts.size() - 2; i++) { + for (int i = 5; i < parts.size() - 2; i++) { const QStringList patchParts = parts[i].split("\t"); const int length = patchParts[0].toInt(); @@ -56,10 +56,12 @@ void Patcher::processPatchList(QNetworkAccessManager& mgr, QString patchList) { auto url_parts = url.split('/'); repository = url_parts[url_parts.size() - 3]; - if(isBoot()) { - dialog->setLabelText("Updating the FINAL FANTASY XIV Updater/Launcher version.\nDownloading ffxivboot - " + version); + if (isBoot()) { + dialog->setLabelText( + "Updating the FINAL FANTASY XIV Updater/Launcher version.\nDownloading ffxivboot - " + version); } else { - dialog->setLabelText("Updating the FINAL FANTASY XIV Game version.\nDownloading " + repository + " - " + version); + dialog->setLabelText( + "Updating the FINAL FANTASY XIV Game version.\nDownloading " + repository + " - " + version); } dialog->setMinimum(0); @@ -68,10 +70,10 @@ void Patcher::processPatchList(QNetworkAccessManager& mgr, QString patchList) { const QString patchesDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/patches/" + repository; - if(!QDir().exists(patchesDir)) + if (!QDir().exists(patchesDir)) QDir().mkdir(patchesDir); - if(!QFile::exists(patchesDir + "/" + name + ".patch")) { + if (!QFile::exists(patchesDir + "/" + name + ".patch")) { QNetworkRequest patchRequest(url); auto patchReply = mgr.get(patchRequest); connect(patchReply, &QNetworkReply::downloadProgress, [=](int recieved, int total) { @@ -86,7 +88,7 @@ void Patcher::processPatchList(QNetworkAccessManager& mgr, QString patchList) { auto patch_path = patchesDir + "/" + name + ".patch"; - patchQueue.push_back({name, repository, version, patch_path}); + patchQueue.push_back({name, repository, version, patch_path}); remainingPatches--; checkIfDone(); @@ -102,7 +104,7 @@ void Patcher::processPatchList(QNetworkAccessManager& mgr, QString patchList) { } void Patcher::checkIfDone() { - if(remainingPatches <= 0) { + if (remainingPatches <= 0) { for (auto patch : patchQueue) { processPatch(patch); } @@ -116,17 +118,17 @@ void Patcher::checkIfDone() { } void Patcher::processPatch(QueuedPatch patch) { - if(isBoot()) { + if (isBoot()) { physis_bootdata_apply_patch(boot_data, patch.path.toStdString().c_str()); } else { physis_gamedata_apply_patch(game_data, patch.path.toStdString().c_str()); } QString verFilePath; - if(isBoot()) { + if (isBoot()) { verFilePath = baseDirectory + "/ffxivboot.ver"; } else { - if(patch.repository == "game") { + if (patch.repository == "game") { verFilePath = baseDirectory + "/ffxivgame.ver"; } else { verFilePath = baseDirectory + "/sqpack/" + patch.repository + "/" + patch.repository + ".ver"; diff --git a/launcher/core/src/sapphirelauncher.cpp b/launcher/core/src/sapphirelauncher.cpp index 6d81670..25fc92e 100644 --- a/launcher/core/src/sapphirelauncher.cpp +++ b/launcher/core/src/sapphirelauncher.cpp @@ -1,19 +1,14 @@ #include "sapphirelauncher.h" -#include #include +#include #include #include -SapphireLauncher::SapphireLauncher(LauncherCore& window) : window(window), QObject(&window) { - -} +SapphireLauncher::SapphireLauncher(LauncherCore& window) : window(window), QObject(&window) {} void SapphireLauncher::login(QString lobbyUrl, const LoginInformation& info) { - QJsonObject data { - {"username", info.username}, - {"pass", info.password} - }; + QJsonObject data{{"username", info.username}, {"pass", info.password}}; QUrl url; url.setScheme("http"); @@ -21,12 +16,12 @@ void SapphireLauncher::login(QString lobbyUrl, const LoginInformation& info) { url.setPath("/sapphire-api/lobby/login"); QNetworkRequest request(url); - request.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded"); + request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); auto reply = window.mgr->post(request, QJsonDocument(data).toJson(QJsonDocument::JsonFormat::Compact)); connect(reply, &QNetworkReply::finished, [&] { QJsonDocument document = QJsonDocument::fromJson(reply->readAll()); - if(!document.isEmpty()) { + if (!document.isEmpty()) { LoginAuth auth; auth.SID = document["sId"].toString(); auth.lobbyhost = document["lobbyHost"].toString(); @@ -35,24 +30,22 @@ void SapphireLauncher::login(QString lobbyUrl, const LoginInformation& info) { window.launchGame(*info.settings, auth); } else { - auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Invalid username/password."); + auto messageBox = + new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Invalid username/password."); messageBox->show(); } }); } void SapphireLauncher::registerAccount(QString lobbyUrl, const LoginInformation& info) { - QJsonObject data { - {"username", info.username}, - {"pass", info.password} - }; + QJsonObject data{{"username", info.username}, {"pass", info.password}}; QUrl url; url.setScheme("http"); url.setHost(lobbyUrl); url.setPath("/sapphire-api/lobby/createAccount"); QNetworkRequest request(url); - request.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded"); + request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); auto reply = window.mgr->post(request, QJsonDocument(data).toJson(QJsonDocument::JsonFormat::Compact)); connect(reply, &QNetworkReply::finished, [&] { diff --git a/launcher/core/src/squareboot.cpp b/launcher/core/src/squareboot.cpp index 008a6d8..3fd0227 100644 --- a/launcher/core/src/squareboot.cpp +++ b/launcher/core/src/squareboot.cpp @@ -1,20 +1,19 @@ #include "squareboot.h" -#include -#include -#include -#include -#include #include -#include #include #include +#include +#include +#include +#include +#include +#include #include "squarelauncher.h" -SquareBoot::SquareBoot(LauncherCore& window, SquareLauncher& launcher) : window(window), launcher(launcher), QObject(&window) { - -} +SquareBoot::SquareBoot(LauncherCore& window, SquareLauncher& launcher) + : window(window), launcher(launcher), QObject(&window) {} void SquareBoot::bootCheck(const LoginInformation& info) { patcher = new Patcher(info.settings->gamePath + "/boot", info.settings->bootData); @@ -34,7 +33,7 @@ void SquareBoot::bootCheck(const LoginInformation& info) { url.setQuery(query); auto request = QNetworkRequest(url); - if(info.settings->license == GameLicense::macOS) { + if (info.settings->license == GameLicense::macOS) { request.setRawHeader("User-Agent", "FFXIV-MAC PATCH CLIENT"); } else { request.setRawHeader("User-Agent", "FFXIV PATCH CLIENT"); @@ -69,21 +68,23 @@ void SquareBoot::checkGateStatus(LoginInformation* info) { // I happen to run into this issue often, if I start the launcher really quickly after bootup // it's possible to actually check this quicker than the network is actually available, // causing the launcher to be stuck in "maintenace mode". so if that happens, we try to rerun this logic. - // TODO: this selection of errors is currently guesswork, i'm assuming one of these will fit the bill of "internet is unavailable" in - // some way. - if(reply->error() == QNetworkReply::HostNotFoundError || reply->error() == QNetworkReply::TimeoutError || reply->error() == QNetworkReply::UnknownServerError) + // TODO: this selection of errors is currently guesswork, i'm assuming one of these will fit the bill of + // "internet is unavailable" in some way. + if (reply->error() == QNetworkReply::HostNotFoundError || reply->error() == QNetworkReply::TimeoutError || + reply->error() == QNetworkReply::UnknownServerError) checkGateStatus(info); QJsonDocument document = QJsonDocument::fromJson(reply->readAll()); const bool isGateOpen = !document.isEmpty() && document.object()["status"].toInt() != 0; - if(isGateOpen) { + if (isGateOpen) { bootCheck(*info); } else { - auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, - "Failed to Login", - "The login gate is closed, the game may be under maintenance."); + auto messageBox = new QMessageBox( + QMessageBox::Icon::Critical, + "Failed to Login", + "The login gate is closed, the game may be under maintenance."); messageBox->show(); } diff --git a/launcher/core/src/squarelauncher.cpp b/launcher/core/src/squarelauncher.cpp index 563194a..91e8ccf 100644 --- a/launcher/core/src/squarelauncher.cpp +++ b/launcher/core/src/squarelauncher.cpp @@ -1,24 +1,22 @@ #include "squarelauncher.h" +#include #include -#include -#include -#include -#include #include #include +#include +#include #include -#include +#include +#include #include "launchercore.h" #ifdef ENABLE_WATCHDOG -#include "watchdog.h" + #include "watchdog.h" #endif -SquareLauncher::SquareLauncher(LauncherCore& window) : window(window), QObject(&window) { - -} +SquareLauncher::SquareLauncher(LauncherCore& window) : window(window), QObject(&window) {} QString getFileHash(QString file) { auto f = QFile(file); @@ -42,7 +40,7 @@ void SquareLauncher::getStored(const LoginInformation& info) { query.addQueryItem("isnew", "1"); query.addQueryItem("launchver", "3"); - if(info.settings->license == GameLicense::WindowsSteam) { + if (info.settings->license == GameLicense::WindowsSteam) { query.addQueryItem("issteam", "1"); // TODO: get steam ticket information from steam api @@ -62,14 +60,17 @@ void SquareLauncher::getStored(const LoginInformation& info) { auto str = QString(reply->readAll()); // fetches Steam username - if(info.settings->license == GameLicense::WindowsSteam) { + if (info.settings->license == GameLicense::WindowsSteam) { QRegularExpression re(R"lit(.*)""\/>)lit"); QRegularExpressionMatch match = re.match(str); - if(match.hasMatch()) { + if (match.hasMatch()) { username = match.captured(1); } else { - auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Could not get Steam username, have you attached your account?"); + auto messageBox = new QMessageBox( + QMessageBox::Icon::Critical, + "Failed to Login", + "Could not get Steam username, have you attached your account?"); messageBox->show(); } } else { @@ -82,7 +83,10 @@ void SquareLauncher::getStored(const LoginInformation& info) { stored = match.captured(1); login(info, url); } else { - auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Failed to contact SE servers. They may be in maintenance."); + auto messageBox = new QMessageBox( + QMessageBox::Icon::Critical, + "Failed to Login", + "Failed to contact SE servers. They may be in maintenance."); messageBox->show(); } }); @@ -97,7 +101,7 @@ void SquareLauncher::login(const LoginInformation& info, const QUrl referer) { QNetworkRequest request(QUrl("https://ffxiv-login.square-enix.com/oauth/ffxivarr/login/login.send")); window.buildRequest(*info.settings, request); - request.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded"); + request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); request.setRawHeader("Referer", referer.toEncoded()); request.setRawHeader("Cache-Control", "no-cache"); @@ -107,14 +111,18 @@ void SquareLauncher::login(const LoginInformation& info, const QUrl referer) { QRegularExpression re(R"lit(window.external.user\("login=auth,ok,(?.*)\);)lit"); QRegularExpressionMatch match = re.match(str); - if(match.hasMatch()) { + if (match.hasMatch()) { const auto parts = match.captured(1).split(','); const bool terms = parts[3] == "1"; const bool playable = parts[9] == "1"; - if(!playable) { - auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Your game is unplayable. Please check that you have the right license selected, and a subscription to play."); + if (!playable) { + auto messageBox = new QMessageBox( + QMessageBox::Icon::Critical, + "Failed to Login", + "Your game is unplayable. Please check that you have the right license selected, and a " + "subscription to play."); auto launcherButton = messageBox->addButton("Open Mog Station", QMessageBox::HelpRole); connect(launcherButton, &QPushButton::clicked, [=] { @@ -128,8 +136,11 @@ void SquareLauncher::login(const LoginInformation& info, const QUrl referer) { return; } - if(!terms) { - auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Your game is unplayable. You need to accept the terms of service from the official launcher."); + if (!terms) { + auto messageBox = new QMessageBox( + QMessageBox::Icon::Critical, + "Failed to Login", + "Your game is unplayable. You need to accept the terms of service from the official launcher."); window.addUpdateButtons(*info.settings, *messageBox); messageBox->show(); @@ -161,20 +172,21 @@ void SquareLauncher::registerSession(const LoginInformation& info) { QUrl url; url.setScheme("https"); url.setHost("patch-gamever.ffxiv.com"); - url.setPath(QString("/http/win32/ffxivneo_release_game/%1/%2").arg(info.settings->repositories.repositories[0].version, SID)); + url.setPath(QString("/http/win32/ffxivneo_release_game/%1/%2") + .arg(info.settings->repositories.repositories[0].version, SID)); auto request = QNetworkRequest(url); window.setSSL(request); request.setRawHeader("X-Hash-Check", "enabled"); request.setRawHeader("User-Agent", "FFXIV PATCH CLIENT"); - request.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded"); + request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); QString report = QString("%1=%2").arg(info.settings->bootVersion, getBootHash(info)); - for(int i = 1; i < auth.maxExpansion + 1; i++) { - if(i <= info.settings->repositories.repositories_count) { - report += QString("\nex%1\t%2") - .arg(QString::number(i), info.settings->repositories.repositories[i].version); + for (int i = 1; i < auth.maxExpansion + 1; i++) { + if (i <= info.settings->repositories.repositories_count) { + report += + QString("\nex%1\t%2").arg(QString::number(i), info.settings->repositories.repositories[i].version); } else { report += QString("\nex%1\t2012.01.01.0000.0000").arg(QString::number(i)); } @@ -182,7 +194,7 @@ void SquareLauncher::registerSession(const LoginInformation& info) { auto reply = window.mgr->post(request, report.toUtf8()); connect(reply, &QNetworkReply::finished, [=, &info] { - if(reply->rawHeaderList().contains("X-Patch-Unique-Id")) { + if (reply->rawHeaderList().contains("X-Patch-Unique-Id")) { QString body = reply->readAll(); patcher = new Patcher(info.settings->gamePath + "/game", info.settings->gameData); @@ -192,7 +204,7 @@ void SquareLauncher::registerSession(const LoginInformation& info) { auth.SID = reply->rawHeader("X-Patch-Unique-Id"); #ifdef ENABLE_WATCHDOG - if(info.settings->enableWatchdog) { + if (info.settings->enableWatchdog) { window.watchdog->launchGame(*info.settings, auth); } else { window.launchGame(*info.settings, auth); @@ -204,7 +216,10 @@ void SquareLauncher::registerSession(const LoginInformation& info) { patcher->processPatchList(*window.mgr, body); } else { - auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Failed the anti-tamper check. Please restore your game to the original state or update the game."); + auto messageBox = new QMessageBox( + QMessageBox::Icon::Critical, + "Failed to Login", + "Failed the anti-tamper check. Please restore your game to the original state or update the game."); window.addUpdateButtons(*info.settings, *messageBox); messageBox->show(); @@ -213,15 +228,13 @@ void SquareLauncher::registerSession(const LoginInformation& info) { } QString SquareLauncher::getBootHash(const LoginInformation& info) { - const QList fileList = - { - "ffxivboot.exe", - "ffxivboot64.exe", - "ffxivlauncher.exe", - "ffxivlauncher64.exe", - "ffxivupdater.exe", - "ffxivupdater64.exe" - }; + const QList fileList = { + "ffxivboot.exe", + "ffxivboot64.exe", + "ffxivlauncher.exe", + "ffxivlauncher64.exe", + "ffxivupdater.exe", + "ffxivupdater64.exe"}; QString result; for (int i = 0; i < fileList.count(); i++) { diff --git a/launcher/core/src/watchdog.cpp b/launcher/core/src/watchdog.cpp index 5700210..010fc8d 100644 --- a/launcher/core/src/watchdog.cpp +++ b/launcher/core/src/watchdog.cpp @@ -1,9 +1,9 @@ #include "watchdog.h" -#include -#include #include #include +#include +#include #include #include @@ -13,34 +13,33 @@ // from https://github.com/adobe/webkit/blob/master/Source/WebCore/plugins/qt/QtX11ImageConversion.cpp // code is licensed under GPLv2 // Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) -QImage qimageFromXImage(XImage *xi) { +QImage qimageFromXImage(XImage* xi) { QImage::Format format = QImage::Format_ARGB32_Premultiplied; if (xi->depth == 24) format = QImage::Format_RGB32; else if (xi->depth == 16) format = QImage::Format_RGB16; - QImage image = QImage(reinterpret_cast(xi->data), xi->width, xi->height, xi->bytes_per_line, - format).copy(); + QImage image = QImage(reinterpret_cast(xi->data), xi->width, xi->height, xi->bytes_per_line, format).copy(); // we may have to swap the byte order - if ((QSysInfo::ByteOrder == QSysInfo::LittleEndian && xi->byte_order == MSBFirst) - || (QSysInfo::ByteOrder == QSysInfo::BigEndian && xi->byte_order == LSBFirst)) { + if ((QSysInfo::ByteOrder == QSysInfo::LittleEndian && xi->byte_order == MSBFirst) || + (QSysInfo::ByteOrder == QSysInfo::BigEndian && xi->byte_order == LSBFirst)) { for (int i = 0; i < image.height(); i++) { if (xi->depth == 16) { - ushort *p = reinterpret_cast(image.scanLine(i)); - ushort *end = p + image.width(); + ushort* p = reinterpret_cast(image.scanLine(i)); + ushort* end = p + image.width(); while (p < end) { *p = ((*p << 8) & 0xff00) | ((*p >> 8) & 0x00ff); p++; } } else { - uint *p = reinterpret_cast(image.scanLine(i)); - uint *end = p + image.width(); + uint* p = reinterpret_cast(image.scanLine(i)); + uint* end = p + image.width(); while (p < end) { - *p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000) - | ((*p >> 8) & 0x0000ff00) | ((*p >> 24) & 0x000000ff); + *p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000) | ((*p >> 8) & 0x0000ff00) | + ((*p >> 24) & 0x000000ff); p++; } } @@ -49,7 +48,7 @@ QImage qimageFromXImage(XImage *xi) { // fix-up alpha channel if (format == QImage::Format_RGB32) { - QRgb *p = reinterpret_cast(image.bits()); + QRgb* p = reinterpret_cast(image.bits()); for (int y = 0; y < xi->height; ++y) { for (int x = 0; x < xi->width; ++x) p[x] |= 0xff000000; @@ -60,8 +59,8 @@ QImage qimageFromXImage(XImage *xi) { return image; } -void Watchdog::launchGame(const ProfileSettings &settings, LoginAuth auth) { - if(icon == nullptr) { +void Watchdog::launchGame(const ProfileSettings& settings, LoginAuth auth) { + if (icon == nullptr) { icon = new QSystemTrayIcon(); } @@ -84,7 +83,7 @@ void Watchdog::launchGame(const ProfileSettings &settings, LoginAuth auth) { core.launchGame(settings, auth); - if(parser == nullptr) { + if (parser == nullptr) { parser = std::make_unique(); } @@ -92,13 +91,15 @@ void Watchdog::launchGame(const ProfileSettings &settings, LoginAuth auth) { if (processWindowId == -1) { auto xdoProcess = new QProcess(); - connect(xdoProcess, static_cast(&QProcess::finished), - [=](int, QProcess::ExitStatus) { - QString output = xdoProcess->readAllStandardOutput(); - qDebug() << "Found XIV Window: " << output.toInt(); + connect( + xdoProcess, + static_cast(&QProcess::finished), + [=](int, QProcess::ExitStatus) { + QString output = xdoProcess->readAllStandardOutput(); + qDebug() << "Found XIV Window: " << output.toInt(); - processWindowId = output.toInt(); - }); + processWindowId = output.toInt(); + }); // TODO: don't use xdotool for this, find a better way to xdoProcess->start("bash", {"-c", "xdotool search --name \"FINAL FANTASY XIV\""}); @@ -123,8 +124,7 @@ void Watchdog::launchGame(const ProfileSettings &settings, LoginAuth auth) { XRenderPictureAttributes pa; pa.subwindow_mode = IncludeInferiors; - Picture picture = XRenderCreatePicture(display, processWindowId, format, - CPSubwindowMode, &pa); + Picture picture = XRenderCreatePicture(display, processWindowId, format, CPSubwindowMode, &pa); XFlush(display); // TODO: does this actually make a difference? XImage* image = XGetImage(display, processWindowId, 0, 0, attr.width, attr.height, AllPlanes, ZPixmap); @@ -134,33 +134,30 @@ void Watchdog::launchGame(const ProfileSettings &settings, LoginAuth auth) { auto result = parser->parseImage(qimageFromXImage(image)); if (result != lastResult) { // skip OCR errors (TODO: should be handled by GameParser itself) - if(result.state == ScreenState::InLoginQueue && result.playersInQueue == 0) + if (result.state == ScreenState::InLoginQueue && result.playersInQueue == 0) return; switch (result.state) { case ScreenState::InLoginQueue: { - icon->showMessage("Watchdog", - QString("You are now at position %1 (moved %2 spots)").arg( - result.playersInQueue).arg( - lastResult.playersInQueue - result.playersInQueue)); + icon->showMessage( + "Watchdog", + QString("You are now at position %1 (moved %2 spots)") + .arg(result.playersInQueue) + .arg(lastResult.playersInQueue - result.playersInQueue)); icon->setToolTip(QString("Queue Status (%1)").arg(result.playersInQueue)); - } - break; + } break; case ScreenState::LobbyError: { // TODO: kill game? icon->showMessage("Watchdog", "You have been disconnected due to a lobby error."); - } - break; + } break; case ScreenState::ConnectingToDataCenter: { - icon->showMessage("Watchdog", - "You are in the process of being connected to the data center."); - } - break; + icon->showMessage( + "Watchdog", "You are in the process of being connected to the data center."); + } break; case ScreenState::WorldFull: { icon->showMessage("Watchdog", "You have been disconnected due to a lobby error."); - } - break; + } break; } lastResult = result; diff --git a/launcher/desktop/include/assetupdater.h b/launcher/desktop/include/assetupdater.h index d11ac2f..b3ec538 100644 --- a/launcher/desktop/include/assetupdater.h +++ b/launcher/desktop/include/assetupdater.h @@ -1,9 +1,9 @@ #pragma once -#include -#include -#include #include +#include +#include +#include #include "launchercore.h" diff --git a/launcher/desktop/include/bannerwidget.h b/launcher/desktop/include/bannerwidget.h index c9f4044..2bafa9d 100644 --- a/launcher/desktop/include/bannerwidget.h +++ b/launcher/desktop/include/bannerwidget.h @@ -10,8 +10,8 @@ public: void setUrl(QUrl url); protected: - void mousePressEvent(QMouseEvent *event) override; + void mousePressEvent(QMouseEvent* event) override; - private: +private: QUrl url; }; \ No newline at end of file diff --git a/launcher/desktop/include/gamescopesettingswindow.h b/launcher/desktop/include/gamescopesettingswindow.h index 7a96f30..1d85bce 100644 --- a/launcher/desktop/include/gamescopesettingswindow.h +++ b/launcher/desktop/include/gamescopesettingswindow.h @@ -1,11 +1,11 @@ #pragma once -#include -#include -#include -#include #include +#include +#include #include +#include +#include #include class LauncherCore; diff --git a/launcher/desktop/include/launcherwindow.h b/launcher/desktop/include/launcherwindow.h index 63be5e8..6f899e8 100644 --- a/launcher/desktop/include/launcherwindow.h +++ b/launcher/desktop/include/launcherwindow.h @@ -1,16 +1,16 @@ #pragma once -#include -#include #include -#include -#include -#include +#include #include +#include +#include +#include #include +#include -#include "launchercore.h" #include "headline.h" +#include "launchercore.h" class LauncherWindow : public QMainWindow { Q_OBJECT @@ -51,10 +51,10 @@ private: QAction* openGameDir; QComboBox* profileSelect; - QLineEdit* usernameEdit, *passwordEdit; + QLineEdit *usernameEdit, *passwordEdit; QLineEdit* otpEdit; - QCheckBox* rememberUsernameBox, *rememberPasswordBox; - QPushButton* loginButton, *registerButton; + QCheckBox *rememberUsernameBox, *rememberPasswordBox; + QPushButton *loginButton, *registerButton; #if defined(Q_OS_MAC) || defined(Q_OS_LINUX) QAction* wineCfg; diff --git a/launcher/desktop/include/settingswindow.h b/launcher/desktop/include/settingswindow.h index d33a5c0..ff5dddf 100644 --- a/launcher/desktop/include/settingswindow.h +++ b/launcher/desktop/include/settingswindow.h @@ -1,13 +1,13 @@ #pragma once -#include -#include -#include -#include #include -#include -#include +#include +#include #include +#include +#include +#include +#include class LauncherCore; class LauncherWindow; @@ -54,14 +54,14 @@ private: QPushButton* configureGamescopeButton; QLabel* wineVersionLabel; - QCheckBox* useGamescope, *useEsync, *useGamemode; + QCheckBox *useGamescope, *useEsync, *useGamemode; QCheckBox* enableWatchdog; // login QCheckBox* encryptArgumentsBox = nullptr; QComboBox* serverType = nullptr; QLineEdit* lobbyServerURL = nullptr; - QCheckBox* rememberUsernameBox = nullptr, *rememberPasswordBox = nullptr; + QCheckBox *rememberUsernameBox = nullptr, *rememberPasswordBox = nullptr; QComboBox* gameLicenseBox = nullptr; QCheckBox* freeTrialBox = nullptr; QCheckBox* useOneTimePassword = nullptr; diff --git a/launcher/desktop/src/aboutwindow.cpp b/launcher/desktop/src/aboutwindow.cpp index 0f7217f..fdac03f 100644 --- a/launcher/desktop/src/aboutwindow.cpp +++ b/launcher/desktop/src/aboutwindow.cpp @@ -1,12 +1,12 @@ #include "aboutwindow.h" -#include -#include #include #include +#include +#include -#include "license.h" #include "config.h" +#include "license.h" AboutWindow::AboutWindow(QWidget* widget) : QDialog(widget) { setWindowTitle("About"); diff --git a/launcher/desktop/src/assetupdater.cpp b/launcher/desktop/src/assetupdater.cpp index 49d5722..09e4055 100644 --- a/launcher/desktop/src/assetupdater.cpp +++ b/launcher/desktop/src/assetupdater.cpp @@ -1,11 +1,11 @@ #include "assetupdater.h" #include +#include #include #include #include #include -#include #include @@ -20,10 +20,8 @@ const QString dalamudVersionManifestURL = baseDalamudDistribution + "%1version"; const QString baseDalamudAssetDistribution = baseGoatDomain + "/DalamudAssets"; const QString dalamudAssetManifestURL = baseDalamudAssetDistribution + "/asset.json"; -const QString baseNativeLauncherDistribution = - "https://xiv.zone/astra-distrib/nativelauncher"; -const QString nativeLauncherLatestPackageURL = - baseNativeLauncherDistribution + "/NativeLauncher.exe"; +const QString baseNativeLauncherDistribution = "https://xiv.zone/astra-distrib/nativelauncher"; +const QString nativeLauncherLatestPackageURL = baseNativeLauncherDistribution + "/NativeLauncher.exe"; const QString nativeLauncherVersionManifestURL = baseNativeLauncherDistribution + "/version"; const QString dotnetRuntimePackageURL = @@ -34,22 +32,20 @@ const QString dotnetDesktopPackageURL = QMap channelToDistribPrefix = { {DalamudChannel::Stable, "/"}, {DalamudChannel::Staging, "stg/"}, - {DalamudChannel::Net5, "net5/"} -}; + {DalamudChannel::Net5, "net5/"}}; AssetUpdater::AssetUpdater(LauncherCore& launcher) : launcher(launcher), QObject(&launcher) { launcher.mgr->setRedirectPolicy(QNetworkRequest::NoLessSafeRedirectPolicy); - dataDir = - QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); + dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); - if(!QDir().exists(dataDir)) + if (!QDir().exists(dataDir)) QDir().mkdir(dataDir); } void AssetUpdater::update(const ProfileSettings& profile) { // non-dalamud users can bypass this process since it's not needed - if(!profile.dalamud.enabled) { + if (!profile.dalamud.enabled) { finishedUpdating(); return; } @@ -146,12 +142,10 @@ void AssetUpdater::update(const ProfileSettings& profile) { } void AssetUpdater::beginInstall() { - if(needsDalamudInstall) { - bool success = !JlCompress::extractDir(tempDir.path() + "/latest.zip", - dataDir + "/Dalamud") - .empty(); + if (needsDalamudInstall) { + bool success = !JlCompress::extractDir(tempDir.path() + "/latest.zip", dataDir + "/Dalamud").empty(); - if(!success) { + if (!success) { // TODO: handle failure here qInfo() << "Failed to install Dalamud!"; } else { @@ -159,16 +153,15 @@ void AssetUpdater::beginInstall() { } } - if(needsNativeInstall) { + if (needsNativeInstall) { qInfo() << "Installing native launcher..."; - if(QFile::exists(dataDir + "/NativeLauncher.exe")) + if (QFile::exists(dataDir + "/NativeLauncher.exe")) QFile::remove(dataDir + "/NativeLauncher.exe"); - bool success = QFile::copy(tempDir.path() + "/NativeLauncher.exe", - dataDir + "/NativeLauncher.exe"); + bool success = QFile::copy(tempDir.path() + "/NativeLauncher.exe", dataDir + "/NativeLauncher.exe"); - if(!success) { + if (!success) { qInfo() << "Failed to install native launcher!"; } else { QFile file(dataDir + "/nativelauncher.ver"); @@ -180,16 +173,13 @@ void AssetUpdater::beginInstall() { } } - if(needsRuntimeInstall) { - bool success = !JlCompress::extractDir(tempDir.path() + "/dotnet-core.zip", - dataDir + "/DalamudRuntime") - .empty(); + if (needsRuntimeInstall) { + bool success = + !JlCompress::extractDir(tempDir.path() + "/dotnet-core.zip", dataDir + "/DalamudRuntime").empty(); - success |= !JlCompress::extractDir(tempDir.path() + "/dotnet-desktop.zip", - dataDir + "/DalamudRuntime") - .empty(); + success |= !JlCompress::extractDir(tempDir.path() + "/dotnet-desktop.zip", dataDir + "/DalamudRuntime").empty(); - if(!success) { + if (!success) { qInfo() << "Failed to install dotnet!"; } else { QFile file(dataDir + "/DalamudRuntime/runtime.ver"); @@ -205,10 +195,10 @@ void AssetUpdater::beginInstall() { } void AssetUpdater::checkIfDalamudAssetsDone() { - if(dialog->wasCanceled()) + if (dialog->wasCanceled()) return; - if(dalamudAssetNeededFilenames.empty()) { + if (dalamudAssetNeededFilenames.empty()) { qInfo() << "Finished downloading Dalamud assets."; launcher.dalamudAssetVersion = remoteDalamudAssetVersion; @@ -223,14 +213,11 @@ void AssetUpdater::checkIfDalamudAssetsDone() { } void AssetUpdater::checkIfFinished() { - if(dialog->wasCanceled()) + if (dialog->wasCanceled()) return; - if (doneDownloadingDalamud && - doneDownloadingNativelauncher && - doneDownloadingRuntimeCore && - doneDownloadingRuntimeDesktop && - dalamudAssetNeededFilenames.empty()) { + if (doneDownloadingDalamud && doneDownloadingNativelauncher && doneDownloadingRuntimeCore && + doneDownloadingRuntimeDesktop && dalamudAssetNeededFilenames.empty()) { if (needsRuntimeInstall || needsNativeInstall || needsDalamudInstall) { beginInstall(); } else { @@ -243,10 +230,11 @@ void AssetUpdater::checkIfFinished() { } void AssetUpdater::checkIfCheckingIsDone() { - if(dialog->wasCanceled()) + if (dialog->wasCanceled()) return; - if(remoteDalamudVersion.isEmpty() || remoteRuntimeVersion.isEmpty() || remoteDalamudAssetVersion == -1 || remoteNativeLauncherVersion.isEmpty()) { + if (remoteDalamudVersion.isEmpty() || remoteRuntimeVersion.isEmpty() || remoteDalamudAssetVersion == -1 || + remoteNativeLauncherVersion.isEmpty()) { return; } @@ -256,7 +244,7 @@ void AssetUpdater::checkIfCheckingIsDone() { dialog->setLabelText("Starting update..."); // dalamud injector / net runtime - if(launcher.runtimeVersion != remoteRuntimeVersion) { + if (launcher.runtimeVersion != remoteRuntimeVersion) { needsRuntimeInstall = true; // core @@ -308,7 +296,7 @@ void AssetUpdater::checkIfCheckingIsDone() { checkIfFinished(); } - if(remoteDalamudVersion != launcher.dalamudVersion) { + if (remoteDalamudVersion != launcher.dalamudVersion) { qInfo() << "Downloading Dalamud..."; needsDalamudInstall = true; @@ -342,14 +330,14 @@ void AssetUpdater::checkIfCheckingIsDone() { } // dalamud assets - if(remoteDalamudAssetVersion != launcher.dalamudAssetVersion) { + if (remoteDalamudAssetVersion != launcher.dalamudAssetVersion) { qInfo() << "Dalamud assets out of date."; dialog->setLabelText("Updating Dalamud assets..."); dalamudAssetNeededFilenames.clear(); - for(auto assetObject : remoteDalamudAssetArray) { + for (auto assetObject : remoteDalamudAssetArray) { { dalamudAssetNeededFilenames.append(assetObject.toObject()["FileName"].toString()); @@ -364,7 +352,7 @@ void AssetUpdater::checkIfCheckingIsDone() { const QList dirPath = fileName.left(fileName.lastIndexOf("/")).split('/'); QString build = dataDir + "/DalamudAssets/"; - for(auto dir : dirPath) { + for (auto dir : dirPath) { if (!QDir().exists(build + dir)) QDir().mkdir(build + dir); @@ -389,7 +377,7 @@ void AssetUpdater::checkIfCheckingIsDone() { checkIfFinished(); } - if(remoteNativeLauncherVersion != launcher.nativeLauncherVersion) { + if (remoteNativeLauncherVersion != launcher.nativeLauncherVersion) { qInfo() << "Native launcher out of date."; dialog->setLabelText("Updating native launcher..."); diff --git a/launcher/desktop/src/desktopinterface.cpp b/launcher/desktop/src/desktopinterface.cpp index 8835fc4..dae19ec 100644 --- a/launcher/desktop/src/desktopinterface.cpp +++ b/launcher/desktop/src/desktopinterface.cpp @@ -7,14 +7,16 @@ DesktopInterface::DesktopInterface(LauncherCore& core) { auto& defaultProfile = core.getProfile(core.defaultProfileIndex); - if(!defaultProfile.isGameInstalled()) { + if (!defaultProfile.isGameInstalled()) { auto messageBox = new QMessageBox(window); messageBox->setIcon(QMessageBox::Icon::Question); messageBox->setText("No Game Found"); messageBox->setInformativeText("FFXIV is not installed. Would you like to install it now?"); - QString detailedText = QString("Astra will install FFXIV for you at '%1'").arg(core.getProfile(core.defaultProfileIndex).gamePath); - detailedText.append("\n\nIf you do not wish to install it to this location, please set it in your default profile first."); + QString detailedText = + QString("Astra will install FFXIV for you at '%1'").arg(core.getProfile(core.defaultProfileIndex).gamePath); + detailedText.append( + "\n\nIf you do not wish to install it to this location, please set it in your default profile first."); messageBox->setDetailedText(detailedText); messageBox->setWindowModality(Qt::WindowModal); @@ -35,7 +37,7 @@ DesktopInterface::DesktopInterface(LauncherCore& core) { } #if defined(Q_OS_LINUX) || defined(Q_OS_MAC) - if(!defaultProfile.isWineInstalled()) { + if (!defaultProfile.isWineInstalled()) { auto messageBox = new QMessageBox(window); messageBox->setIcon(QMessageBox::Icon::Critical); messageBox->setText("No Wine Found"); diff --git a/launcher/desktop/src/gamescopesettingswindow.cpp b/launcher/desktop/src/gamescopesettingswindow.cpp index 0c5fb58..350bfb7 100644 --- a/launcher/desktop/src/gamescopesettingswindow.cpp +++ b/launcher/desktop/src/gamescopesettingswindow.cpp @@ -1,22 +1,23 @@ #include "gamescopesettingswindow.h" -#include -#include -#include -#include -#include #include +#include +#include +#include +#include #include +#include #include #include -#include -#include +#include #include +#include #include "launchercore.h" #include "launcherwindow.h" -GamescopeSettingsWindow::GamescopeSettingsWindow(ProfileSettings& settings, LauncherCore& core, QWidget* parent) : QDialog(parent) { +GamescopeSettingsWindow::GamescopeSettingsWindow(ProfileSettings& settings, LauncherCore& core, QWidget* parent) + : QDialog(parent) { setWindowTitle("Gamescope Settings"); setWindowModality(Qt::WindowModality::ApplicationModal); diff --git a/launcher/desktop/src/launcherwindow.cpp b/launcher/desktop/src/launcherwindow.cpp index e35ebb0..c1d8679 100644 --- a/launcher/desktop/src/launcherwindow.cpp +++ b/launcher/desktop/src/launcherwindow.cpp @@ -1,28 +1,28 @@ #include "launcherwindow.h" -#include -#include -#include #include #include -#include -#include -#include #include -#include +#include +#include +#include +#include #include +#include +#include +#include +#include "aboutwindow.h" +#include "assetupdater.h" +#include "bannerwidget.h" +#include "config.h" +#include "encryptedarg.h" +#include "gameinstaller.h" +#include "headline.h" +#include "sapphirelauncher.h" #include "settingswindow.h" #include "squareboot.h" #include "squarelauncher.h" -#include "sapphirelauncher.h" -#include "assetupdater.h" -#include "headline.h" -#include "config.h" -#include "aboutwindow.h" -#include "gameinstaller.h" -#include "bannerwidget.h" -#include "encryptedarg.h" LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindow(parent), core(core) { setWindowTitle("Astra"); @@ -66,23 +66,26 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo QString fileName = fi.fileName(); // FIXME: is there no easier way to filter out these in Qt? - if(fi.fileName() != "Public" && fi.fileName() != "." && fi.fileName() != "..") { + if (fi.fileName() != "Public" && fi.fileName() != "." && fi.fileName() != "..") { userPath = fileName; } } - arguments.push_back({"UserPath", QString(R"(C:\Users\%1\Documents\My Games\FINAL FANTASY XIV - A Realm Reborn)").arg(userPath)}); + arguments.push_back( + {"UserPath", + QString(R"(C:\Users\%1\Documents\My Games\FINAL FANTASY XIV - A Realm Reborn)").arg(userPath)}); const QString argFormat = " /%1 =%2"; QString argJoined; - for(auto& arg : arguments) { + for (auto& arg : arguments) { argJoined += argFormat.arg(arg.key, arg.value.replace(" ", " ")); } QString finalArg = encryptGameArg(argJoined); - this->core.launchExecutable(currentProfile(), {currentProfile().gamePath + "/boot/ffxivlauncher64.exe", finalArg}); + this->core.launchExecutable( + currentProfile(), {currentProfile().gamePath + "/boot/ffxivlauncher64.exe", finalArg}); }); launchSysInfo = toolsMenu->addAction("Open System Info..."); @@ -116,7 +119,8 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo messageBox->setInformativeText("FFXIV will be installed to your selected game directory."); QString detailedText = QString("Astra will install FFXIV for you at '%1'").arg(this->currentProfile().gamePath); - detailedText.append("\n\nIf you do not wish to install it to this location, please change your profile settings."); + detailedText.append( + "\n\nIf you do not wish to install it to this location, please change your profile settings."); messageBox->setDetailedText(detailedText); messageBox->setWindowModality(Qt::WindowModal); @@ -127,7 +131,6 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo this->core.readGameVersion(); messageBox->close(); - }); }); @@ -212,7 +215,7 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo layout->addLayout(loginLayout, 0, 1, 1, 1); profileSelect = new QComboBox(); - connect(profileSelect, static_cast(&QComboBox::currentIndexChanged), [=](int index) { + connect(profileSelect, static_cast(&QComboBox::currentIndexChanged), [=](int index) { reloadControls(); }); @@ -244,12 +247,12 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo registerButton = new QPushButton("Register"); connect(otpEdit, &QLineEdit::returnPressed, [this] { - if(loginButton->isEnabled()) + if (loginButton->isEnabled()) this->core.assetUpdater->update(currentProfile()); }); connect(passwordEdit, &QLineEdit::returnPressed, [this] { - if(loginButton->isEnabled()) + if (loginButton->isEnabled()) this->core.assetUpdater->update(currentProfile()); }); @@ -267,7 +270,7 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo info->oneTimePassword = otpEdit->text(); #ifndef QT_DEBUG - if(currentProfile().rememberUsername) { + if (currentProfile().rememberUsername) { auto job = new QKeychain::WritePasswordJob("LauncherWindow"); job->setTextData(usernameEdit->text()); job->setKey(currentProfile().name + "-username"); @@ -276,7 +279,7 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo #endif #ifndef QT_DEBUG - if(currentProfile().rememberPassword) { + if (currentProfile().rememberPassword) { auto job = new QKeychain::WritePasswordJob("LauncherWindow"); job->setTextData(passwordEdit->text()); job->setKey(currentProfile().name + "-password"); @@ -284,7 +287,7 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo } #endif - if(currentProfile().isSapphire) { + if (currentProfile().isSapphire) { this->core.sapphireLauncher->login(currentProfile().lobbyURL, *info); } else { this->core.squareBoot->checkGateStatus(info); @@ -297,7 +300,7 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo }); connect(registerButton, &QPushButton::released, [=] { - if(currentProfile().isSapphire) { + if (currentProfile().isSapphire) { auto& profile = currentProfile(); LoginInformation info; @@ -311,16 +314,16 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo }); connect(&core, &LauncherCore::successfulLaunch, [&] { - if(core.appSettings.closeWhenLaunched) + if (core.appSettings.closeWhenLaunched) hide(); }); connect(&core, &LauncherCore::gameClosed, [&] { - if(core.appSettings.closeWhenLaunched) + if (core.appSettings.closeWhenLaunched) QCoreApplication::quit(); }); - getHeadline(core,[&](Headline headline) { + getHeadline(core, [&](Headline headline) { this->headline = headline; reloadNews(); }); @@ -333,7 +336,7 @@ ProfileSettings& LauncherWindow::currentProfile() { } void LauncherWindow::reloadControls() { - if(currentlyReloadingControls) + if (currentlyReloadingControls) return; currentlyReloadingControls = true; @@ -342,19 +345,19 @@ void LauncherWindow::reloadControls() { profileSelect->clear(); - for(const auto& profile : core.profileList()) { + for (const auto& profile : core.profileList()) { profileSelect->addItem(profile); } profileSelect->setCurrentIndex(oldIndex); - if(profileSelect->currentIndex() == -1) { + if (profileSelect->currentIndex() == -1) { profileSelect->setCurrentIndex(core.defaultProfileIndex); } rememberUsernameBox->setChecked(currentProfile().rememberUsername); #ifndef QT_DEBUG - if(currentProfile().rememberUsername) { + if (currentProfile().rememberUsername) { auto job = new QKeychain::ReadPasswordJob("LauncherWindow"); job->setKey(currentProfile().name + "-username"); job->start(); @@ -367,7 +370,7 @@ void LauncherWindow::reloadControls() { rememberPasswordBox->setChecked(currentProfile().rememberPassword); #ifndef QT_DEBUG - if(currentProfile().rememberPassword) { + if (currentProfile().rememberPassword) { auto job = new QKeychain::ReadPasswordJob("LauncherWindow"); job->setKey(currentProfile().name + "-password"); job->start(); @@ -379,25 +382,25 @@ void LauncherWindow::reloadControls() { #endif bool canLogin = true; - if(currentProfile().isSapphire) { - if(currentProfile().lobbyURL.isEmpty()) { + if (currentProfile().isSapphire) { + if (currentProfile().lobbyURL.isEmpty()) { loginButton->setText("Login (Lobby URL is invalid)"); canLogin = false; } } #if defined(Q_OS_LINUX) || defined(Q_OS_MAC) - if(!currentProfile().isWineInstalled()) { + if (!currentProfile().isWineInstalled()) { loginButton->setText("Login (Wine is not installed)"); canLogin = false; } #endif - if(!currentProfile().isGameInstalled()) { + if (!currentProfile().isGameInstalled()) { loginButton->setText("Login (Game is not installed)"); canLogin = false; } - if(canLogin) + if (canLogin) loginButton->setText("Login"); launchOfficial->setEnabled(currentProfile().isGameInstalled()); @@ -415,13 +418,13 @@ void LauncherWindow::reloadControls() { newsListView->hide(); auto field = loginLayout->labelForField(otpEdit); - if(field != nullptr) + if (field != nullptr) field->deleteLater(); loginLayout->takeRow(otpEdit); otpEdit->hide(); - if(currentProfile().useOneTimePassword && !currentProfile().isSapphire) { + if (currentProfile().useOneTimePassword && !currentProfile().isSapphire) { loginLayout->addRow("One-Time Password", otpEdit); otpEdit->show(); } @@ -434,7 +437,7 @@ void LauncherWindow::reloadControls() { loginLayout->takeRow(registerButton); registerButton->hide(); - if(currentProfile().isSapphire) { + if (currentProfile().isSapphire) { loginLayout->addRow(registerButton); registerButton->show(); } @@ -445,20 +448,20 @@ void LauncherWindow::reloadControls() { } void LauncherWindow::reloadNews() { - if(core.appSettings.showBanners || core.appSettings.showNewsList) { - for(auto widget : bannerWidgets) { + if (core.appSettings.showBanners || core.appSettings.showNewsList) { + for (auto widget : bannerWidgets) { bannerLayout->removeWidget(widget); } bannerWidgets.clear(); int totalRow = 0; - if(core.appSettings.showBanners) { + if (core.appSettings.showBanners) { bannerScrollArea->show(); layout->addWidget(bannerScrollArea, totalRow++, 0); } - if(core.appSettings.showNewsList) { + if (core.appSettings.showNewsList) { newsListView->show(); layout->addWidget(newsListView, totalRow++, 0); } @@ -466,8 +469,8 @@ void LauncherWindow::reloadNews() { newsListView->clear(); if (!headline.banner.empty()) { - if(core.appSettings.showBanners) { - for(auto banner : headline.banner) { + if (core.appSettings.showBanners) { + for (auto banner : headline.banner) { auto request = QNetworkRequest(banner.bannerImage); core.buildRequest(currentProfile(), request); @@ -485,68 +488,58 @@ void LauncherWindow::reloadNews() { }); } - if(bannerTimer == nullptr) { + if (bannerTimer == nullptr) { bannerTimer = new QTimer(); connect(bannerTimer, &QTimer::timeout, this, [=] { if (currentBanner >= headline.banner.size()) currentBanner = 0; - bannerScrollArea->ensureVisible( - 640 * (currentBanner + 1), 0, 0, 0); + bannerScrollArea->ensureVisible(640 * (currentBanner + 1), 0, 0, 0); currentBanner++; }); bannerTimer->start(5000); } } else { - if(bannerTimer != nullptr) { + if (bannerTimer != nullptr) { bannerTimer->stop(); bannerTimer->deleteLater(); bannerTimer = nullptr; } } - if(core.appSettings.showNewsList) { - QTreeWidgetItem* newsItem = new QTreeWidgetItem( - (QTreeWidgetItem*)nullptr, QStringList("News")); + if (core.appSettings.showNewsList) { + QTreeWidgetItem* newsItem = new QTreeWidgetItem((QTreeWidgetItem*)nullptr, QStringList("News")); for (auto news : headline.news) { QTreeWidgetItem* item = new QTreeWidgetItem(); item->setText(0, news.title); - item->setText(1, QLocale().toString( - news.date, QLocale::ShortFormat)); + item->setText(1, QLocale().toString(news.date, QLocale::ShortFormat)); item->setData(0, Qt::UserRole, news.url); newsItem->addChild(item); } - QTreeWidgetItem* pinnedItem = new QTreeWidgetItem( - (QTreeWidgetItem*)nullptr, QStringList("Pinned")); + QTreeWidgetItem* pinnedItem = new QTreeWidgetItem((QTreeWidgetItem*)nullptr, QStringList("Pinned")); for (auto pinned : headline.pinned) { QTreeWidgetItem* item = new QTreeWidgetItem(); item->setText(0, pinned.title); - item->setText(1, - QLocale().toString(pinned.date, - QLocale::ShortFormat)); + item->setText(1, QLocale().toString(pinned.date, QLocale::ShortFormat)); item->setData(0, Qt::UserRole, pinned.url); pinnedItem->addChild(item); } - QTreeWidgetItem* topicsItem = new QTreeWidgetItem( - (QTreeWidgetItem*)nullptr, QStringList("Topics")); + QTreeWidgetItem* topicsItem = new QTreeWidgetItem((QTreeWidgetItem*)nullptr, QStringList("Topics")); for (auto news : headline.topics) { QTreeWidgetItem* item = new QTreeWidgetItem(); item->setText(0, news.title); - item->setText(1, QLocale().toString( - news.date, QLocale::ShortFormat)); + item->setText(1, QLocale().toString(news.date, QLocale::ShortFormat)); item->setData(0, Qt::UserRole, news.url); topicsItem->addChild(item); } - newsListView->insertTopLevelItems( - 0, QList( - {newsItem, pinnedItem, topicsItem})); + newsListView->insertTopLevelItems(0, QList({newsItem, pinnedItem, topicsItem})); for (int i = 0; i < 3; i++) { newsListView->expandItem(newsListView->topLevelItem(i)); diff --git a/launcher/desktop/src/settingswindow.cpp b/launcher/desktop/src/settingswindow.cpp index 32fccee..24cc753 100644 --- a/launcher/desktop/src/settingswindow.cpp +++ b/launcher/desktop/src/settingswindow.cpp @@ -1,22 +1,23 @@ #include "settingswindow.h" -#include -#include -#include -#include -#include #include +#include +#include +#include +#include #include +#include #include #include -#include +#include #include +#include "gamescopesettingswindow.h" #include "launchercore.h" #include "launcherwindow.h" -#include "gamescopesettingswindow.h" -SettingsWindow::SettingsWindow(int defaultTab, LauncherWindow& window, LauncherCore& core, QWidget* parent) : core(core), window(window), QDialog(parent) { +SettingsWindow::SettingsWindow(int defaultTab, LauncherWindow& window, LauncherCore& core, QWidget* parent) + : core(core), window(window), QDialog(parent) { setWindowTitle("Settings"); setWindowModality(Qt::WindowModality::ApplicationModal); @@ -76,8 +77,7 @@ SettingsWindow::SettingsWindow(int defaultTab, LauncherWindow& window, LauncherC profileWidget->addItem("INVALID *DEBUG*"); profileWidget->setCurrentRow(0); - connect(profileWidget, &QListWidget::currentRowChanged, this, - &SettingsWindow::reloadControls); + connect(profileWidget, &QListWidget::currentRowChanged, this, &SettingsWindow::reloadControls); profileLayout->addWidget(profileWidget, 0, 0, 3, 1); @@ -91,8 +91,7 @@ SettingsWindow::SettingsWindow(int defaultTab, LauncherWindow& window, LauncherC deleteProfileButton = new QPushButton("Delete Profile"); connect(deleteProfileButton, &QPushButton::pressed, [=] { - profileWidget->setCurrentRow( - this->core.deleteProfile(getCurrentProfile().name)); + profileWidget->setCurrentRow(this->core.deleteProfile(getCurrentProfile().name)); this->core.saveSettings(); }); @@ -168,7 +167,7 @@ SettingsWindow::SettingsWindow(int defaultTab, LauncherWindow& window, LauncherC } void SettingsWindow::reloadControls() { - if(currentlyReloadingControls) + if (currentlyReloadingControls) return; currentlyReloadingControls = true; @@ -177,7 +176,7 @@ void SettingsWindow::reloadControls() { profileWidget->clear(); - for(const auto& profile : core.profileList()) { + for (const auto& profile : core.profileList()) { profileWidget->addItem(profile); } profileWidget->setCurrentRow(oldRow); @@ -196,7 +195,7 @@ void SettingsWindow::reloadControls() { directXCombo->setCurrentIndex(profile.useDX9 ? 1 : 0); currentGameDirectory->setText(profile.gamePath); - if(!profile.isGameInstalled()) { + if (!profile.isGameInstalled()) { expansionVersionLabel->setText("No game installed."); } else { QString expacString; @@ -204,9 +203,9 @@ void SettingsWindow::reloadControls() { expacString += "Boot"; expacString += QString(" (%1)\n").arg(profile.bootVersion); - for(int i = 0; i < profile.repositories.repositories_count; i++) { + for (int i = 0; i < profile.repositories.repositories_count; i++) { QString expansionName = "Unknown Expansion"; - if(i < core.expansionNames.size()) { + if (i < core.expansionNames.size()) { expansionName = core.expansionNames[i]; } @@ -219,7 +218,7 @@ void SettingsWindow::reloadControls() { // wine #if defined(Q_OS_LINUX) || defined(Q_OS_MAC) - if(!profile.isWineInstalled()) { + if (!profile.isWineInstalled()) { wineVersionLabel->setText("Wine is not installed."); } else { wineVersionLabel->setText(profile.wineVersion); @@ -250,7 +249,7 @@ void SettingsWindow::reloadControls() { encryptArgumentsBox->setChecked(profile.encryptArguments); serverType->setCurrentIndex(profile.isSapphire ? 1 : 0); lobbyServerURL->setEnabled(profile.isSapphire); - if(profile.isSapphire) { + if (profile.isSapphire) { lobbyServerURL->setText(profile.lobbyURL); lobbyServerURL->setPlaceholderText("Required..."); } else { @@ -260,7 +259,7 @@ void SettingsWindow::reloadControls() { rememberPasswordBox->setChecked(profile.rememberPassword); useOneTimePassword->setChecked(profile.useOneTimePassword); useOneTimePassword->setEnabled(!profile.isSapphire); - if(!useOneTimePassword->isEnabled()) { + if (!useOneTimePassword->isEnabled()) { useOneTimePassword->setToolTip("OTP is not supported by Sapphire servers."); } else { useOneTimePassword->setToolTip(""); @@ -268,7 +267,7 @@ void SettingsWindow::reloadControls() { gameLicenseBox->setCurrentIndex((int)profile.license); gameLicenseBox->setEnabled(!profile.isSapphire); - if(!gameLicenseBox->isEnabled()) { + if (!gameLicenseBox->isEnabled()) { gameLicenseBox->setToolTip("Game licenses only matter when logging into the official Square Enix servers."); } else { gameLicenseBox->setToolTip(""); @@ -278,19 +277,19 @@ void SettingsWindow::reloadControls() { // dalamud enableDalamudBox->setChecked(profile.dalamud.enabled); - if(core.dalamudVersion.isEmpty()) { + if (core.dalamudVersion.isEmpty()) { dalamudVersionLabel->setText("Dalamud is not installed."); } else { dalamudVersionLabel->setText(core.dalamudVersion); } - if(core.dalamudAssetVersion == -1) { + if (core.dalamudAssetVersion == -1) { dalamudAssetVersionLabel->setText("Dalamud assets are not installed."); } else { dalamudAssetVersionLabel->setText(QString::number(core.dalamudAssetVersion)); } - if(core.nativeLauncherVersion.isEmpty()) { + if (core.nativeLauncherVersion.isEmpty()) { nativeLauncherVersionLabel->setText("Native launcher is not installed."); } else { nativeLauncherVersionLabel->setText(core.nativeLauncherVersion); @@ -314,14 +313,10 @@ void SettingsWindow::setupGameTab(QFormLayout& layout) { directXCombo->addItem("DirectX 9"); layout.addRow("DirectX Version", directXCombo); - connect(directXCombo, - static_cast( - &QComboBox::currentIndexChanged), - [=](int index) { - getCurrentProfile().useDX9 = - directXCombo->currentIndex() == 1; - this->core.saveSettings(); - }); + connect(directXCombo, static_cast(&QComboBox::currentIndexChanged), [=](int index) { + getCurrentProfile().useDX9 = directXCombo->currentIndex() == 1; + this->core.saveSettings(); + }); currentGameDirectory = new QLabel(); currentGameDirectory->setTextInteractionFlags(Qt::TextInteractionFlag::TextSelectableByMouse); @@ -334,8 +329,7 @@ void SettingsWindow::setupGameTab(QFormLayout& layout) { auto selectDirectoryButton = new QPushButton("Select Game Directory"); connect(selectDirectoryButton, &QPushButton::pressed, [this] { - getCurrentProfile().gamePath = - QFileDialog::getExistingDirectory(this, "Open Game Directory"); + getCurrentProfile().gamePath = QFileDialog::getExistingDirectory(this, "Open Game Directory"); this->reloadControls(); this->core.saveSettings(); @@ -345,8 +339,9 @@ void SettingsWindow::setupGameTab(QFormLayout& layout) { gameDirButtonLayout->addWidget(selectDirectoryButton); gameDirectoryButton = new QPushButton("Open Game Directory"); - connect(gameDirectoryButton, &QPushButton::pressed, - [this] { window.openPath(getCurrentProfile().gamePath); }); + connect(gameDirectoryButton, &QPushButton::pressed, [this] { + window.openPath(getCurrentProfile().gamePath); + }); gameDirButtonLayout->addWidget(gameDirectoryButton); #ifdef ENABLE_WATCHDOG @@ -370,8 +365,7 @@ void SettingsWindow::setupGameTab(QFormLayout& layout) { void SettingsWindow::setupLoginTab(QFormLayout& layout) { encryptArgumentsBox = new QCheckBox(); connect(encryptArgumentsBox, &QCheckBox::stateChanged, [=](int) { - getCurrentProfile().encryptArguments = - encryptArgumentsBox->isChecked(); + getCurrentProfile().encryptArguments = encryptArgumentsBox->isChecked(); this->core.saveSettings(); }); @@ -381,15 +375,12 @@ void SettingsWindow::setupLoginTab(QFormLayout& layout) { serverType->insertItem(0, "Square Enix"); serverType->insertItem(1, "Sapphire"); - connect(serverType, - static_cast( - &QComboBox::currentIndexChanged), - [=](int index) { - getCurrentProfile().isSapphire = index == 1; + connect(serverType, static_cast(&QComboBox::currentIndexChanged), [=](int index) { + getCurrentProfile().isSapphire = index == 1; - reloadControls(); - this->core.saveSettings(); - }); + reloadControls(); + this->core.saveSettings(); + }); layout.addRow("Server Lobby", serverType); @@ -405,21 +396,17 @@ void SettingsWindow::setupLoginTab(QFormLayout& layout) { gameLicenseBox->insertItem(1, "Windows (Steam)"); gameLicenseBox->insertItem(2, "macOS"); - connect(gameLicenseBox, - static_cast( - &QComboBox::currentIndexChanged), - [=](int index) { - getCurrentProfile().license = (GameLicense)index; + connect(gameLicenseBox, static_cast(&QComboBox::currentIndexChanged), [=](int index) { + getCurrentProfile().license = (GameLicense)index; - this->core.saveSettings(); - }); + this->core.saveSettings(); + }); layout.addRow("Game License", gameLicenseBox); freeTrialBox = new QCheckBox(); connect(freeTrialBox, &QCheckBox::stateChanged, [=](int) { - getCurrentProfile().isFreeTrial = - freeTrialBox->isChecked(); + getCurrentProfile().isFreeTrial = freeTrialBox->isChecked(); this->core.saveSettings(); }); @@ -427,8 +414,7 @@ void SettingsWindow::setupLoginTab(QFormLayout& layout) { rememberUsernameBox = new QCheckBox(); connect(rememberUsernameBox, &QCheckBox::stateChanged, [=](int) { - getCurrentProfile().rememberUsername = - rememberUsernameBox->isChecked(); + getCurrentProfile().rememberUsername = rememberUsernameBox->isChecked(); this->core.saveSettings(); }); @@ -436,8 +422,7 @@ void SettingsWindow::setupLoginTab(QFormLayout& layout) { rememberPasswordBox = new QCheckBox(); connect(rememberPasswordBox, &QCheckBox::stateChanged, [=](int) { - getCurrentProfile().rememberPassword = - rememberPasswordBox->isChecked(); + getCurrentProfile().rememberPassword = rememberPasswordBox->isChecked(); this->core.saveSettings(); }); @@ -445,8 +430,7 @@ void SettingsWindow::setupLoginTab(QFormLayout& layout) { useOneTimePassword = new QCheckBox(); connect(useOneTimePassword, &QCheckBox::stateChanged, [=](int) { - getCurrentProfile().useOneTimePassword = - useOneTimePassword->isChecked(); + getCurrentProfile().useOneTimePassword = useOneTimePassword->isChecked(); this->core.saveSettings(); this->window.reloadControls(); @@ -462,40 +446,36 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) { wineTypeCombo = new QComboBox(); -#if defined(Q_OS_MAC) + #if defined(Q_OS_MAC) wineTypeCombo->insertItem(2, "FFXIV for Mac (Official)"); wineTypeCombo->insertItem(3, "XIV on Mac"); -#endif + #endif wineTypeCombo->insertItem(0, "System Wine"); // custom wine selection is broken under flatpak -#ifndef FLATPAK + #ifndef FLATPAK wineTypeCombo->insertItem(1, "Custom Wine"); -#endif + #endif layout.addWidget(wineTypeCombo); selectWineButton = new QPushButton("Select Wine Executable"); -#ifndef FLATPAK + #ifndef FLATPAK layout.addWidget(selectWineButton); -#endif + #endif - connect(wineTypeCombo, - static_cast( - &QComboBox::currentIndexChanged), - [this](int index) { - getCurrentProfile().wineType = (WineType)index; + connect(wineTypeCombo, static_cast(&QComboBox::currentIndexChanged), [this](int index) { + getCurrentProfile().wineType = (WineType)index; - this->core.readWineInfo(getCurrentProfile()); - this->core.saveSettings(); - this->reloadControls(); - }); + this->core.readWineInfo(getCurrentProfile()); + this->core.saveSettings(); + this->reloadControls(); + }); connect(selectWineButton, &QPushButton::pressed, [this] { - getCurrentProfile().winePath = - QFileDialog::getOpenFileName(this, "Open Wine Executable"); + getCurrentProfile().winePath = QFileDialog::getOpenFileName(this, "Open Wine Executable"); this->core.saveSettings(); this->reloadControls(); @@ -503,10 +483,10 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) { // wine version is reported incorrectly under flatpak too wineVersionLabel = new QLabel(); -#ifndef FLATPAK + #ifndef FLATPAK wineVersionLabel->setTextInteractionFlags(Qt::TextInteractionFlag::TextSelectableByMouse); layout.addRow("Wine Version", wineVersionLabel); -#endif + #endif winePrefixDirectory = new QLabel(); winePrefixDirectory->setTextInteractionFlags(Qt::TextInteractionFlag::TextSelectableByMouse); @@ -519,8 +499,7 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) { auto selectPrefixButton = new QPushButton("Select Wine Prefix"); connect(selectPrefixButton, &QPushButton::pressed, [this] { - getCurrentProfile().winePrefixPath = - QFileDialog::getExistingDirectory(this, "Open Wine Prefix"); + getCurrentProfile().winePrefixPath = QFileDialog::getExistingDirectory(this, "Open Wine Prefix"); this->core.saveSettings(); this->reloadControls(); @@ -528,8 +507,9 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) { winePrefixButtonLayout->addWidget(selectPrefixButton); auto openPrefixButton = new QPushButton("Open Wine Prefix"); - connect(openPrefixButton, &QPushButton::pressed, - [this] { window.openPath(getCurrentProfile().winePrefixPath); }); + connect(openPrefixButton, &QPushButton::pressed, [this] { + window.openPath(getCurrentProfile().winePrefixPath); + }); winePrefixButtonLayout->addWidget(openPrefixButton); auto enableDXVKhud = new QCheckBox("Enable DXVK HUD"); @@ -537,17 +517,16 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) { connect(enableDXVKhud, &QCheckBox::stateChanged, [this](int state) { getCurrentProfile().enableDXVKhud = state; - this->core.settings.setValue("enableDXVKhud", - static_cast(state)); + this->core.settings.setValue("enableDXVKhud", static_cast(state)); }); #endif #if defined(Q_OS_LINUX) - useEsync = new QCheckBox( - "Use Better Sync Primitives (Esync, Fsync, and Futex2)"); + useEsync = new QCheckBox("Use Better Sync Primitives (Esync, Fsync, and Futex2)"); layout.addWidget(useEsync); - useEsync->setToolTip("This may improve game performance, but requires a Wine and kernel with the patches included."); + useEsync->setToolTip( + "This may improve game performance, but requires a Wine and kernel with the patches included."); connect(useEsync, &QCheckBox::stateChanged, [this](int state) { getCurrentProfile().useEsync = state; @@ -558,7 +537,9 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) { useGamescope = new QCheckBox("Use Gamescope"); layout.addWidget(useGamescope); - useGamescope->setToolTip("Use the micro-compositor compositor that uses Wayland and XWayland to create a nested session.\nIf you primarily use fullscreen mode, this may improve input handling especially on Wayland."); + useGamescope->setToolTip( + "Use the micro-compositor compositor that uses Wayland and XWayland to create a nested session.\nIf you " + "primarily use fullscreen mode, this may improve input handling especially on Wayland."); auto gamescopeButtonLayout = new QHBoxLayout(); auto gamescopeButtonContainer = new QWidget(); @@ -567,8 +548,7 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) { configureGamescopeButton = new QPushButton("Configure..."); connect(configureGamescopeButton, &QPushButton::pressed, [&] { - auto gamescopeSettingsWindow = new GamescopeSettingsWindow( - getCurrentProfile(), this->core, this); + auto gamescopeSettingsWindow = new GamescopeSettingsWindow(getCurrentProfile(), this->core, this); gamescopeSettingsWindow->show(); }); gamescopeButtonLayout->addWidget(configureGamescopeButton); @@ -583,7 +563,8 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) { useGamemode = new QCheckBox("Use GameMode"); layout.addWidget(useGamemode); - useGamemode->setToolTip("A special game performance enhancer, which automatically tunes your CPU scheduler among other things. This may improve game performance."); + useGamemode->setToolTip("A special game performance enhancer, which automatically tunes your CPU scheduler among " + "other things. This may improve game performance."); connect(useGamemode, &QCheckBox::stateChanged, [this](int state) { getCurrentProfile().useGamemode = state; @@ -615,14 +596,11 @@ void SettingsWindow::setupDalamudTab(QFormLayout& layout) { dalamudChannel->insertItem(1, "Staging"); dalamudChannel->insertItem(2, ".NET 5"); - connect(dalamudChannel, - static_cast( - &QComboBox::currentIndexChanged), - [=](int index) { - getCurrentProfile().dalamud.channel = (DalamudChannel)index; + connect(dalamudChannel, static_cast(&QComboBox::currentIndexChanged), [=](int index) { + getCurrentProfile().dalamud.channel = (DalamudChannel)index; - this->core.saveSettings(); - }); + this->core.saveSettings(); + }); layout.addRow("Dalamud Update Channel", dalamudChannel); @@ -639,6 +617,4 @@ void SettingsWindow::setupDalamudTab(QFormLayout& layout) { layout.addRow("Native Launcher Version", nativeLauncherVersionLabel); } -void SettingsWindow::setupAccountsTab(QFormLayout& layout) { - -} +void SettingsWindow::setupAccountsTab(QFormLayout& layout) {} diff --git a/launcher/main.cpp b/launcher/main.cpp index a8c12ca..0848ba1 100755 --- a/launcher/main.cpp +++ b/launcher/main.cpp @@ -3,8 +3,8 @@ #include #include -#include #include +#include #include #include "../launcher/tablet/include/tabletinterface.h" @@ -53,19 +53,19 @@ int main(int argc, char* argv[]) { parser.process(app); - if(parser.isSet(versionOption)) { + if (parser.isSet(versionOption)) { parser.showVersion(); } - if(parser.isSet(helpOption)) { + if (parser.isSet(helpOption)) { parser.showHelp(); } LauncherCore c; - if(parser.isSet(tabletOption)) { + if (parser.isSet(tabletOption)) { std::make_unique(c); - } else if(parser.isSet(cliOption)) { - if(!cmd->parse(parser, c)) + } else if (parser.isSet(cliOption)) { + if (!cmd->parse(parser, c)) return -1; } else { std::make_unique(c); diff --git a/launcher/tablet/src/tabletinterface.cpp b/launcher/tablet/src/tabletinterface.cpp index 1e503ff..a3a7fa8 100644 --- a/launcher/tablet/src/tabletinterface.cpp +++ b/launcher/tablet/src/tabletinterface.cpp @@ -1,9 +1,9 @@ #include "tabletinterface.h" -#include #include +#include -TabletInterface::TabletInterface(LauncherCore &core) { +TabletInterface::TabletInterface(LauncherCore& core) { qmlRegisterType("Astra", 1, 0, "ProfileSettings"); qmlRegisterType("Astra", 1, 0, "LoginInformation");