diff --git a/.ci/patch/0001-quazip-strict.patch b/.ci/patch/0001-quazip-strict.patch deleted file mode 100644 index 8283497230..0000000000 --- a/.ci/patch/0001-quazip-strict.patch +++ /dev/null @@ -1,80 +0,0 @@ -diff --git a/quazip/quazipdir.cpp b/quazip/quazipdir.cpp -index d43f1c1..eb24bf1 100644 ---- a/quazip/quazipdir.cpp -+++ b/quazip/quazipdir.cpp -@@ -293,8 +293,8 @@ bool QuaZipDirComparator::operator()(const QuaZipFileInfo64 &info1, - } - - template --bool QuaZipDirPrivate::entryInfoList(QStringList nameFilters, -- QDir::Filters filter, QDir::SortFlags sort, TFileInfoList &result) const -+bool QuaZipDirPrivate::entryInfoList(QStringList _nameFilters, -+ QDir::Filters _filter, QDir::SortFlags sort, TFileInfoList &result) const - { - QString basePath = simplePath(); - if (!basePath.isEmpty()) -@@ -305,12 +305,12 @@ bool QuaZipDirPrivate::entryInfoList(QStringList nameFilters, - if (!zip->goToFirstFile()) { - return zip->getZipError() == UNZ_OK; - } -- QDir::Filters fltr = filter; -+ QDir::Filters fltr = _filter; - if (fltr == QDir::NoFilter) - fltr = this->filter; - if (fltr == QDir::NoFilter) - fltr = QDir::AllEntries; -- QStringList nmfltr = nameFilters; -+ QStringList nmfltr = _nameFilters; - if (nmfltr.isEmpty()) - nmfltr = this->nameFilters; - QSet dirsFound; -diff --git a/quazip/quazipfile.cpp b/quazip/quazipfile.cpp -index 4a5f2f9..f7865f5 100644 ---- a/quazip/quazipfile.cpp -+++ b/quazip/quazipfile.cpp -@@ -241,14 +241,14 @@ void QuaZipFile::setFileName(const QString& fileName, QuaZip::CaseSensitivity cs - p->caseSensitivity=cs; - } - --void QuaZipFilePrivate::setZipError(int zipError) const -+void QuaZipFilePrivate::setZipError(int _zipError) const - { - QuaZipFilePrivate *fakeThis = const_cast(this); // non-const -- fakeThis->zipError=zipError; -- if(zipError==UNZ_OK) -+ fakeThis->zipError = _zipError; -+ if(_zipError == UNZ_OK) - q->setErrorString(QString()); - else -- q->setErrorString(QuaZipFile::tr("ZIP/UNZIP API error %1").arg(zipError)); -+ q->setErrorString(QuaZipFile::tr("ZIP/UNZIP API error %1").arg(_zipError)); - } - - bool QuaZipFile::open(OpenMode mode) -diff --git a/quazip/unzip.c b/quazip/unzip.c -index a39365d..ee7b487 100644 ---- a/quazip/unzip.c -+++ b/quazip/unzip.c -@@ -1054,7 +1054,7 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file, - /* ZIP64 extra fields */ - if (headerId == 0x0001) - { -- uLong uL; -+ uLong _uL; - - if(file_info.uncompressed_size == (ZPOS64_T)0xFFFFFFFFu) - { -@@ -1078,7 +1078,7 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file, - if(file_info.disk_num_start == 0xFFFFFFFFu) - { - /* Disk Start Number */ -- if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) -+ if (unz64local_getLong(&s->z_filefunc, s->filestream, &_uL) != UNZ_OK) - err=UNZ_ERRNO; - } - -@@ -2151,3 +2151,4 @@ int ZEXPORT unzClearFlags(unzFile file, unsigned flags) - s->flags &= ~flags; - return UNZ_OK; - } -+ diff --git a/.ci/patch/0002-quazip-fetchcontent.patch b/.ci/patch/0002-quazip-fetchcontent.patch deleted file mode 100644 index 3554b7dbb6..0000000000 --- a/.ci/patch/0002-quazip-fetchcontent.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/cmake/clone-repo.cmake b/cmake/clone-repo.cmake -index 2ffb4b2..77974dc 100644 ---- a/cmake/clone-repo.cmake -+++ b/cmake/clone-repo.cmake -@@ -26,7 +26,7 @@ macro(clone_repo name url) - FetchContent_GetProperties(${name} POPULATED ${name_lower}_POPULATED) - - if(NOT ${name_lower}_POPULATED) -- FetchContent_Populate(${name}) -+ FetchContent_MakeAvailable(${name}) - endif() - - set(${name_upper}_SOURCE_DIR ${${name_lower}_SOURCE_DIR}) diff --git a/CMakeLists.txt b/CMakeLists.txt index f8e8516dbc..1006717a90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,7 @@ option(ENABLE_QT_UPDATE_CHECKER "Enable update checker for the Qt frontend" OFF) CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_QT "Download bundled Qt binaries" "${MSVC}" "ENABLE_QT" OFF) option(ENABLE_WEB_SERVICE "Enable web services (telemetry, etc.)" ON) +option(ENABLE_WIFI_SCAN "Enable WiFi scanning" OFF) if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") option(YUZU_USE_BUNDLED_FFMPEG "Download/Build bundled FFmpeg" OFF) @@ -416,6 +417,10 @@ if (UNIX AND NOT APPLE) find_package(gamemode 1.7 MODULE) endif() +if (ENABLE_QT) + find_package(libzip CONFIG REQUIRED) +endif() + # find SDL2 exports a bunch of variables that are needed, so its easier to do this outside of the YUZU_find_package if (ENABLE_SDL2) if (YUZU_USE_BUNDLED_SDL2) @@ -458,19 +463,22 @@ if (ENABLE_QT) if (YUZU_USE_BUNDLED_QT) download_qt(6.8.3) else() - message(STATUS "Using system Qt") if (NOT Qt6_DIR) set(Qt6_DIR "" CACHE PATH "Additional path to search for Qt6 libraries like C:/Qt/6.8.3/msvc2022_64/lib/cmake/Qt6") endif() list(APPEND CMAKE_PREFIX_PATH "${Qt6_DIR}") endif() + find_package(Qt6 REQUIRED COMPONENTS Widgets Concurrent) + + if (Qt6_FOUND) + message(STATUS "Found Qt6: ${Qt6_DIR}") + endif() + # QT6 Multimedia pulls in unneeded audio systems (ALSA, Pulseaudio) for FreeBSD # ALSA is the default sound system on Linux, but FreeBSD uses OSS which works well enough - if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") - find_package(Qt6 REQUIRED COMPONENTS Widgets Concurrent) - else() - find_package(Qt6 REQUIRED COMPONENTS Widgets Multimedia Concurrent) + if (YUZU_USE_QT_MULTIMEDIA) + find_package(Qt6 REQUIRED COMPONENTS Multimedia) endif() if (UNIX AND NOT APPLE) diff --git a/CMakeModules/DownloadExternals.cmake b/CMakeModules/DownloadExternals.cmake index a82d1d72a3..996cb41cce 100644 --- a/CMakeModules/DownloadExternals.cmake +++ b/CMakeModules/DownloadExternals.cmake @@ -91,11 +91,11 @@ function(determine_qt_parameters target host_out type_out arch_out arch_path_out set(type "desktop") set(arch "clang_64") set(arch_path "macos") - else() + elseif (LINUX) set(host "linux") set(type "desktop") - set(arch "gcc_64") - set(arch_path "linux") + set(arch "linux_gcc_64") + set(arch_path "gcc_64") endif() set(${host_out} "${host}" PARENT_SCOPE) @@ -129,16 +129,29 @@ function(download_qt_configuration prefix_out target host type arch arch_path ba set(install_args -c "${CURRENT_MODULE_DIR}/aqt_config.ini") if (tool) - set(prefix "${base_path}/Tools") + set(prefix "${base_path}/tools") set(install_args ${install_args} install-tool --outputdir ${base_path} ${host} desktop ${target}) else() set(prefix "${base_path}/${target}/${arch_path}") - set(install_args ${install_args} install-qt --outputdir ${base_path} ${host} ${type} ${target} ${arch} -m qt3d qt5compat qtactiveqt qtcharts qtconnectivity qtdatavis3d qtgraphs qtgrpc qthttpserver qtimageformats qtlanguageserver qtlocation qtlottie qtmultimedia qtnetworkauth qtpdf qtpositioning qtquick3d qtquick3dphysics qtquickeffectmaker qtquicktimeline qtremoteobjects qtscxml qtsensors qtserialbus qtserialport qtshadertools qtspeech qtvirtualkeyboard qtwebchannel qtwebengine qtwebsockets qtwebview) + set(install_args ${install_args} install-qt --outputdir ${base_path} ${host} ${type} ${target} ${arch} -m qt_base) + + if (YUZU_USE_QT_MULTIMEDIA) + set(install_args ${install_args} qtmultimedia) + endif() + + if (YUZU_USE_QT_WEB_ENGINE) + set(install_args ${install_args} qtpositioning qtwebchannel qtwebengine) + endif() + + if (NOT ${YUZU_QT_MIRROR} STREQUAL "") + message(STATUS "Using Qt mirror ${YUZU_QT_MIRROR}") + set(install_args ${install_args} -b ${YUZU_QT_MIRROR}) + endif() endif() if (NOT EXISTS "${prefix}") message(STATUS "Downloading Qt binaries for ${target}:${host}:${type}:${arch}:${arch_path}") - set(AQT_PREBUILD_BASE_URL "https://github.com/miurahr/aqtinstall/releases/download/v3.2.1") + set(AQT_PREBUILD_BASE_URL "https://github.com/miurahr/aqtinstall/releases/download/v3.3.0") if (WIN32) set(aqt_path "${base_path}/aqt.exe") if (NOT EXISTS "${aqt_path}") @@ -158,14 +171,28 @@ function(download_qt_configuration prefix_out target host type arch arch_path ba execute_process(COMMAND chmod +x ${aqt_path}) execute_process(COMMAND ${aqt_path} ${install_args} WORKING_DIRECTORY ${base_path}) - else() + elseif (LINUX) set(aqt_install_path "${base_path}/aqt") file(MAKE_DIRECTORY "${aqt_install_path}") - execute_process(COMMAND python3 -m pip install --target=${aqt_install_path} aqtinstall - WORKING_DIRECTORY ${base_path}) - execute_process(COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${aqt_install_path} python3 -m aqt ${install_args} - WORKING_DIRECTORY ${base_path}) + find_package(Python3 COMPONENTS Interpreter) + execute_process( + COMMAND ${Python3_EXECUTABLE} -m venv .venv + WORKING_DIRECTORY ${base_path} + ) + set(ENV{VIRTUAL_ENV} "${base_path}/.venv") + set(Python3_FIND_VIRTUALENV FIRST) + unset(Python3_EXECUTABLE) + find_package(Python3 COMPONENTS Interpreter) + + execute_process( + COMMAND ${Python3_EXECUTABLE} -m pip install aqtinstall + WORKING_DIRECTORY ${base_path} + ) + execute_process( + COMMAND ${Python3_EXECUTABLE} -m aqt ${install_args} + WORKING_DIRECTORY ${base_path} + ) endif() message(STATUS "Downloaded Qt binaries for ${target}:${host}:${type}:${arch}:${arch_path} to ${prefix}") diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index d830cc381d..267ad5a915 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1150,18 +1150,19 @@ add_library(core STATIC tools/renderdoc.h ) -if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") +if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND ENABLE_WIFI_SCAN) # find_package(libiw REQUIRED) + target_compile_definitions(core PRIVATE -DENABLE_WIFI_SCAN) target_link_libraries(core PRIVATE iw) endif() if (WIN32) target_compile_definitions(core PRIVATE _WIN32_WINNT=0x0A00 WINVER=0x0A00) - if(TARGET iw) - target_link_libraries(core PRIVATE iw) - message(STATUS "Linking 'core' with iw on Linux.") - endif() + # if(TARGET iw) + # target_link_libraries(core PRIVATE iw) + # message(STATUS "Linking 'core' with iw on Linux.") + # endif() endif() if (MSVC) diff --git a/src/core/internal_network/wifi_scanner.cpp b/src/core/internal_network/wifi_scanner.cpp index df9bc92910..152791ac5a 100644 --- a/src/core/internal_network/wifi_scanner.cpp +++ b/src/core/internal_network/wifi_scanner.cpp @@ -20,6 +20,7 @@ using namespace std::chrono_literals; namespace Network { +#ifdef ENABLE_WIFI_SCAN #ifdef _WIN32 static u8 QualityToPercent(DWORD q) { return static_cast(q); @@ -95,8 +96,7 @@ static u8 QualityToPercent(const iwrange& r, const wireless_scan* ws) { return static_cast(std::clamp(100 * lvl / max, 0, 100)); } -static int wifi_callback(int skfd, char* ifname, char* args[], int count) -{ +static int wifi_callback(int skfd, char* ifname, char* args[], int count) { iwrange range; int res = iw_get_range_info(skfd, ifname, &range); @@ -123,7 +123,7 @@ static std::vector ScanWifiLinux(std::chrono::milliseconds de } char ifname[IFNAMSIZ] = {0}; - char *args[1] = {ifname}; + char* args[1] = {ifname}; iw_enum_devices(sock, &wifi_callback, args, 0); @@ -173,16 +173,20 @@ static std::vector ScanWifiLinux(std::chrono::milliseconds de return out; } #endif /* linux */ +#endif std::vector ScanWifiNetworks(std::chrono::milliseconds deadline) { +#ifdef ENABLE_WIFI_SCAN #ifdef _WIN32 return ScanWifiWin(deadline); #elif defined(__linux__) && !defined(ANDROID) return ScanWifiLinux(deadline); #else - std::this_thread::sleep_for(deadline); return {}; // unsupported host, pretend no results #endif +#else + return {}; +#endif } } // namespace Network diff --git a/src/core/internal_network/wifi_scanner.h b/src/core/internal_network/wifi_scanner.h index adf2fe2de3..5df42c5854 100644 --- a/src/core/internal_network/wifi_scanner.h +++ b/src/core/internal_network/wifi_scanner.h @@ -19,4 +19,4 @@ struct ScanData { static_assert(sizeof(ScanData) <= 0x2C, "ScanData layout changed – update conversions!"); std::vector ScanWifiNetworks(std::chrono::milliseconds deadline); -} +} // namespace Network diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index bab6a6c4f5..3755fe0c84 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -494,8 +494,6 @@ if (YUZU_ROOM) target_link_libraries(yuzu PRIVATE yuzu-room) endif() -# Extra deps -add_subdirectory(externals) -target_link_libraries(yuzu PRIVATE QuaZip::QuaZip) +target_link_libraries(yuzu PRIVATE libzip::zip) create_target_directory_groups(yuzu) diff --git a/src/yuzu/externals/CMakeLists.txt b/src/yuzu/externals/CMakeLists.txt deleted file mode 100644 index ac17308e09..0000000000 --- a/src/yuzu/externals/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -# Disable tests in all externals supporting the standard option name -set(BUILD_TESTING OFF) - -# Build only static externals -set(BUILD_SHARED_LIBS OFF) - -# QuaZip -set(QUAZIP_QT_MAJOR_VERSION 6) -set(QUAZIP_BZIP2 OFF) - -include(CPM) -set(CPM_SOURCE_CACHE ${CMAKE_SOURCE_DIR}/.cache/cpm) -set(CPM_USE_LOCAL_PACKAGES ON) - -CPMAddPackage( - NAME QuaZip-Qt6 - VERSION 1.3 - GIT_REPOSITORY "https://github.com/stachenov/quazip.git" - GIT_TAG v1.5 - PATCHES - ${CMAKE_SOURCE_DIR}/.ci/patch/0001-quazip-strict.patch - ${CMAKE_SOURCE_DIR}/.ci/patch/0002-quazip-fetchcontent.patch -) - -if (NOT MSVC AND NOT "QuaZip-Qt6" IN_LIST CPM_PACKAGES) - message(STATUS "QUAZIP DIR: ${CPM_PACKAGES}") - target_compile_options(QuaZip PRIVATE - -Wno-error=shadow - -Wno-error=missing-declarations - ) -endif() diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 6a575cfa87..9947f7d2fa 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -12,7 +12,7 @@ #include "core/tools/renderdoc.h" #include "frontend_common/firmware_manager.h" -#include +#include "zip.h" #ifdef __APPLE__ #include // for chdir @@ -37,8 +37,8 @@ #include "configuration/configure_input.h" #include "configuration/configure_per_game.h" #include "configuration/configure_tas.h" -#include "core/file_sys/romfs_factory.h" #include "core/core_timing.h" +#include "core/file_sys/romfs_factory.h" #include "core/file_sys/vfs/vfs.h" #include "core/file_sys/vfs/vfs_real.h" #include "core/frontend/applets/cabinet.h" @@ -66,7 +66,7 @@ // These are wrappers to avoid the calls to CreateDirectory and CreateFile because of the Windows // defines. static FileSys::VirtualDir VfsFilesystemCreateDirectoryWrapper( - const FileSys::VirtualFilesystem& vfs, const std::string& path, FileSys::OpenMode mode) { + const FileSys::VirtualFilesystem& vfs, const std::string& path, FileSys::OpenMode mode) { return vfs->CreateDirectory(path, mode); } @@ -215,7 +215,7 @@ enum class CalloutFlag : uint32_t { * so this tracks which games are bad in this regard. */ constexpr std::array bad_update_games{ - 0x0100F2C0115B6000 // Tears of the Kingdom + 0x0100F2C0115B6000 // Tears of the Kingdom }; const int GMainWindow::max_recent_files_item; @@ -267,21 +267,21 @@ static QString PrettyProductName() { // After Windows 10 Version 2004, Microsoft decided to switch to a different notation: 20H2 // With that notation change they changed the registry key used to denote the current version QSettings windows_registry( - QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), - QSettings::NativeFormat); + QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), + QSettings::NativeFormat); const QString release_id = windows_registry.value(QStringLiteral("ReleaseId")).toString(); if (release_id == QStringLiteral("2009")) { const u32 current_build = windows_registry.value(QStringLiteral("CurrentBuild")).toUInt(); const QString display_version = - windows_registry.value(QStringLiteral("DisplayVersion")).toString(); + windows_registry.value(QStringLiteral("DisplayVersion")).toString(); const u32 ubr = windows_registry.value(QStringLiteral("UBR")).toUInt(); u32 version = 10; if (current_build >= 22000) { version = 11; } return QStringLiteral("Windows %1 Version %2 (Build %3.%4)") - .arg(QString::number(version), display_version, QString::number(current_build), - QString::number(ubr)); + .arg(QString::number(version), display_version, QString::number(current_build), + QString::number(ubr)); } #endif return QSysInfo::prettyProductName(); @@ -313,8 +313,7 @@ bool GMainWindow::CheckDarkMode() { GMainWindow::GMainWindow(bool has_broken_vulkan) : ui{std::make_unique()}, system{std::make_unique()}, - input_subsystem{std::make_shared()}, - user_data_migrator{this}, + input_subsystem{std::make_shared()}, user_data_migrator{this}, vfs{std::make_shared()}, provider{std::make_unique()} { Common::FS::CreateEdenPaths(); @@ -322,18 +321,19 @@ GMainWindow::GMainWindow(bool has_broken_vulkan) if (user_data_migrator.migrated) { // Sort-of hack whereby we only move the old dir if it's a subfolder of the user dir - #define MIGRATE_DIR(type) std::string type##path = Common::FS::GetEdenPathString(Common::FS::EdenPath::type##Dir); \ - if (type##path.starts_with(user_data_migrator.selected_emu.get_user_dir())) { \ - boost::replace_all(type##path, user_data_migrator.selected_emu.lower_name(), "eden"); \ - Common::FS::SetEdenPath(Common::FS::EdenPath::type##Dir, type##path); \ - } +#define MIGRATE_DIR(type) \ + std::string type##path = Common::FS::GetEdenPathString(Common::FS::EdenPath::type##Dir); \ + if (type##path.starts_with(user_data_migrator.selected_emu.get_user_dir())) { \ + boost::replace_all(type##path, user_data_migrator.selected_emu.lower_name(), "eden"); \ + Common::FS::SetEdenPath(Common::FS::EdenPath::type##Dir, type##path); \ + } MIGRATE_DIR(NAND) MIGRATE_DIR(SDMC) MIGRATE_DIR(Dump) MIGRATE_DIR(Load) - #undef MIGRATE_DIR +#undef MIGRATE_DIR } #ifdef __unix__ @@ -392,7 +392,7 @@ GMainWindow::GMainWindow(bool has_broken_vulkan) const auto yuzu_build = fmt::format("eden Development Build | {}-{}", branch_name, description); const auto override_build = - fmt::format(fmt::runtime(std::string(Common::g_title_bar_format_idle)), build_id); + fmt::format(fmt::runtime(std::string(Common::g_title_bar_format_idle)), build_id); const auto yuzu_build_version = override_build.empty() ? yuzu_build : override_build; const auto processor_count = std::thread::hardware_concurrency(); @@ -426,7 +426,7 @@ GMainWindow::GMainWindow(bool has_broken_vulkan) LOG_INFO(Frontend, "Host Timer Resolution: {:.4f} ms", std::chrono::duration_cast>( Common::Windows::SetCurrentTimerResolutionToMaximum()) - .count()); + .count()); system->CoreTiming().SetTimerResolutionNs(Common::Windows::GetCurrentTimerResolution()); #endif UpdateWindowTitle(); @@ -436,13 +436,12 @@ GMainWindow::GMainWindow(bool has_broken_vulkan) #ifdef ENABLE_QT_UPDATE_CHECKER if (UISettings::values.check_for_updates) { update_future = QtConcurrent::run([]() -> QString { - const bool is_prerelease = - ((strstr(Common::g_build_version, "pre-alpha") != NULL) || - (strstr(Common::g_build_version, "alpha") != NULL) || - (strstr(Common::g_build_version, "beta") != NULL) || - (strstr(Common::g_build_version, "rc") != NULL)); + const bool is_prerelease = ((strstr(Common::g_build_version, "pre-alpha") != NULL) || + (strstr(Common::g_build_version, "alpha") != NULL) || + (strstr(Common::g_build_version, "beta") != NULL) || + (strstr(Common::g_build_version, "rc") != NULL)); const std::optional latest_release_tag = - UpdateChecker::GetLatestRelease(is_prerelease); + UpdateChecker::GetLatestRelease(is_prerelease); if (latest_release_tag && latest_release_tag.value() != Common::g_build_version) { return QString::fromStdString(latest_release_tag.value()); } @@ -676,26 +675,26 @@ void GMainWindow::RegisterMetaTypes() { // Cabinet Applet qRegisterMetaType("Core::Frontend::CabinetParameters"); qRegisterMetaType>( - "std::shared_ptr"); + "std::shared_ptr"); // Controller Applet qRegisterMetaType("Core::Frontend::ControllerParameters"); // Profile Select Applet qRegisterMetaType( - "Core::Frontend::ProfileSelectParameters"); + "Core::Frontend::ProfileSelectParameters"); // Software Keyboard Applet qRegisterMetaType( - "Core::Frontend::KeyboardInitializeParameters"); + "Core::Frontend::KeyboardInitializeParameters"); qRegisterMetaType( - "Core::Frontend::InlineAppearParameters"); + "Core::Frontend::InlineAppearParameters"); qRegisterMetaType("Core::Frontend::InlineTextParameters"); qRegisterMetaType("Service::AM::Frontend::SwkbdResult"); qRegisterMetaType( - "Service::AM::Frontend::SwkbdTextCheckResult"); + "Service::AM::Frontend::SwkbdTextCheckResult"); qRegisterMetaType( - "Service::AM::Frontend::SwkbdReplyType"); + "Service::AM::Frontend::SwkbdReplyType"); // Web Browser Applet qRegisterMetaType("Service::AM::Frontend::WebExitReason"); @@ -707,7 +706,7 @@ void GMainWindow::RegisterMetaTypes() { void GMainWindow::AmiiboSettingsShowDialog(const Core::Frontend::CabinetParameters& parameters, std::shared_ptr nfp_device) { cabinet_applet = - new QtAmiiboSettingsDialog(this, parameters, input_subsystem.get(), nfp_device); + new QtAmiiboSettingsDialog(this, parameters, input_subsystem.get(), nfp_device); SCOPE_EXIT { cabinet_applet->deleteLater(); cabinet_applet = nullptr; @@ -732,9 +731,9 @@ void GMainWindow::AmiiboSettingsRequestExit() { } void GMainWindow::ControllerSelectorReconfigureControllers( - const Core::Frontend::ControllerParameters& parameters) { + const Core::Frontend::ControllerParameters& parameters) { controller_applet = - new QtControllerSelectorDialog(this, parameters, input_subsystem.get(), *system); + new QtControllerSelectorDialog(this, parameters, input_subsystem.get(), *system); SCOPE_EXIT { controller_applet->deleteLater(); controller_applet = nullptr; @@ -763,7 +762,7 @@ void GMainWindow::ControllerSelectorRequestExit() { } void GMainWindow::ProfileSelectorSelectProfile( - const Core::Frontend::ProfileSelectParameters& parameters) { + const Core::Frontend::ProfileSelectParameters& parameters) { profile_select_applet = new QtProfileSelectionDialog(*system, this, parameters); SCOPE_EXIT { profile_select_applet->deleteLater(); @@ -780,7 +779,7 @@ void GMainWindow::ProfileSelectorSelectProfile( } const auto uuid = system->GetProfileManager().GetUser( - static_cast(profile_select_applet->GetIndex())); + static_cast(profile_select_applet->GetIndex())); if (!uuid.has_value()) { emit ProfileSelectorFinishedSelection(std::nullopt); return; @@ -796,7 +795,7 @@ void GMainWindow::ProfileSelectorRequestExit() { } void GMainWindow::SoftwareKeyboardInitialize( - bool is_inline, Core::Frontend::KeyboardInitializeParameters initialize_parameters) { + bool is_inline, Core::Frontend::KeyboardInitializeParameters initialize_parameters) { if (software_keyboard) { LOG_ERROR(Frontend, "The software keyboard is already initialized!"); return; @@ -807,20 +806,20 @@ void GMainWindow::SoftwareKeyboardInitialize( if (is_inline) { connect( - software_keyboard, &QtSoftwareKeyboardDialog::SubmitInlineText, this, - [this](Service::AM::Frontend::SwkbdReplyType reply_type, std::u16string submitted_text, - s32 cursor_position) { - emit SoftwareKeyboardSubmitInlineText(reply_type, submitted_text, cursor_position); - }, - Qt::QueuedConnection); + software_keyboard, &QtSoftwareKeyboardDialog::SubmitInlineText, this, + [this](Service::AM::Frontend::SwkbdReplyType reply_type, std::u16string submitted_text, + s32 cursor_position) { + emit SoftwareKeyboardSubmitInlineText(reply_type, submitted_text, cursor_position); + }, + Qt::QueuedConnection); } else { connect( - software_keyboard, &QtSoftwareKeyboardDialog::SubmitNormalText, this, - [this](Service::AM::Frontend::SwkbdResult result, std::u16string submitted_text, - bool confirmed) { - emit SoftwareKeyboardSubmitNormalText(result, submitted_text, confirmed); - }, - Qt::QueuedConnection); + software_keyboard, &QtSoftwareKeyboardDialog::SubmitNormalText, this, + [this](Service::AM::Frontend::SwkbdResult result, std::u16string submitted_text, + bool confirmed) { + emit SoftwareKeyboardSubmitNormalText(result, submitted_text, confirmed); + }, + Qt::QueuedConnection); } } @@ -843,8 +842,8 @@ void GMainWindow::SoftwareKeyboardShowNormal() { } void GMainWindow::SoftwareKeyboardShowTextCheck( - Service::AM::Frontend::SwkbdTextCheckResult text_check_result, - std::u16string text_check_message) { + Service::AM::Frontend::SwkbdTextCheckResult text_check_result, + std::u16string text_check_message) { if (!software_keyboard) { LOG_ERROR(Frontend, "The software keyboard is not initialized!"); return; @@ -854,7 +853,7 @@ void GMainWindow::SoftwareKeyboardShowTextCheck( } void GMainWindow::SoftwareKeyboardShowInline( - Core::Frontend::InlineAppearParameters appear_parameters) { + Core::Frontend::InlineAppearParameters appear_parameters) { if (!software_keyboard) { LOG_ERROR(Frontend, "The software keyboard is not initialized!"); return; @@ -863,13 +862,13 @@ void GMainWindow::SoftwareKeyboardShowInline( const auto& layout = render_window->GetFramebufferLayout(); const auto x = - static_cast(layout.screen.left + (0.5f * layout.screen.GetWidth() * - ((2.0f * appear_parameters.key_top_translate_x) + - (1.0f - appear_parameters.key_top_scale_x)))); + static_cast(layout.screen.left + (0.5f * layout.screen.GetWidth() * + ((2.0f * appear_parameters.key_top_translate_x) + + (1.0f - appear_parameters.key_top_scale_x)))); const auto y = - static_cast(layout.screen.top + (layout.screen.GetHeight() * - ((2.0f * appear_parameters.key_top_translate_y) + - (1.0f - appear_parameters.key_top_scale_y)))); + static_cast(layout.screen.top + (layout.screen.GetHeight() * + ((2.0f * appear_parameters.key_top_translate_y) + + (1.0f - appear_parameters.key_top_scale_y)))); const auto w = static_cast(layout.screen.GetWidth() * appear_parameters.key_top_scale_x); const auto h = static_cast(layout.screen.GetHeight() * appear_parameters.key_top_scale_y); const auto scale_ratio = devicePixelRatioF(); @@ -889,7 +888,7 @@ void GMainWindow::SoftwareKeyboardHideInline() { } void GMainWindow::SoftwareKeyboardInlineTextChanged( - Core::Frontend::InlineTextParameters text_parameters) { + Core::Frontend::InlineTextParameters text_parameters) { if (!software_keyboard) { LOG_ERROR(Frontend, "The software keyboard is not initialized!"); return; @@ -980,11 +979,11 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url, QAction* exit_action = new QAction(tr("Disable Web Applet"), this); connect(exit_action, &QAction::triggered, this, [this] { const auto result = QMessageBox::warning( - this, tr("Disable Web Applet"), - tr("Disabling the web applet can lead to undefined behavior and should only be used " - "with Super Mario 3D All-Stars. Are you sure you want to disable the web " - "applet?\n(This can be re-enabled in the Debug settings.)"), - QMessageBox::Yes | QMessageBox::No); + this, tr("Disable Web Applet"), + tr("Disabling the web applet can lead to undefined behavior and should only be used " + "with Super Mario 3D All-Stars. Are you sure you want to disable the web " + "applet?\n(This can be re-enabled in the Debug settings.)"), + QMessageBox::Yes | QMessageBox::No); if (result == QMessageBox::Yes) { UISettings::values.disable_web_applet = true; web_applet->SetFinished(true); @@ -997,14 +996,14 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url, if (!exit_check) { web_applet->page()->runJavaScript( - QStringLiteral("end_applet;"), [&](const QVariant& variant) { - exit_check = false; - if (variant.toBool()) { - web_applet->SetFinished(true); - web_applet->SetExitReason( - Service::AM::Frontend::WebExitReason::EndButtonPressed); - } - }); + QStringLiteral("end_applet;"), [&](const QVariant& variant) { + exit_check = false; + if (variant.toBool()) { + web_applet->SetFinished(true); + web_applet->SetExitReason( + Service::AM::Frontend::WebExitReason::EndButtonPressed); + } + }); exit_check = true; } @@ -1102,18 +1101,18 @@ void GMainWindow::InitializeWidgets() { res_scale_label->setToolTip(tr("The current selected resolution scaling multiplier.")); emu_speed_label = new QLabel(); emu_speed_label->setToolTip( - tr("Current emulation speed. Values higher or lower than 100% " - "indicate emulation is running faster or slower than a Switch.")); + tr("Current emulation speed. Values higher or lower than 100% " + "indicate emulation is running faster or slower than a Switch.")); game_fps_label = new QLabel(); game_fps_label->setToolTip(tr("How many frames per second the game is currently displaying. " "This will vary from game to game and scene to scene.")); emu_frametime_label = new QLabel(); emu_frametime_label->setToolTip( - tr("Time taken to emulate a Switch frame, not counting framelimiting or v-sync. For " - "full-speed emulation this should be at most 16.67 ms.")); + tr("Time taken to emulate a Switch frame, not counting framelimiting or v-sync. For " + "full-speed emulation this should be at most 16.67 ms.")); for (auto& label : {shader_building_label, res_scale_label, emu_speed_label, game_fps_label, - emu_frametime_label}) { + emu_frametime_label}) { label->setVisible(false); label->setFrameStyle(QFrame::NoFrame); label->setContentsMargins(4, 0, 4, 0); @@ -1167,21 +1166,21 @@ void GMainWindow::InitializeWidgets() { volume_button->setContextMenuPolicy(Qt::CustomContextMenu); connect(volume_button, &QPushButton::customContextMenuRequested, [this](const QPoint& menu_location) { - QMenu context_menu; - context_menu.addAction( + QMenu context_menu; + context_menu.addAction( Settings::values.audio_muted ? tr("Unmute") : tr("Mute"), [this] { - Settings::values.audio_muted = !Settings::values.audio_muted; - UpdateVolumeUI(); - }); + Settings::values.audio_muted = !Settings::values.audio_muted; + UpdateVolumeUI(); + }); - context_menu.addAction(tr("Reset Volume"), [this] { - Settings::values.volume.SetValue(100); - UpdateVolumeUI(); - }); + context_menu.addAction(tr("Reset Volume"), [this] { + Settings::values.volume.SetValue(100); + UpdateVolumeUI(); + }); - context_menu.exec(volume_button->mapToGlobal(menu_location)); - volume_button->repaint(); - }); + context_menu.exec(volume_button->mapToGlobal(menu_location)); + volume_button->repaint(); + }); connect(volume_button, &VolumeButton::VolumeChanged, this, &GMainWindow::UpdateVolumeUI); statusBar()->insertPermanentWidget(0, volume_button); @@ -1206,16 +1205,16 @@ void GMainWindow::InitializeWidgets() { aa_status_button->setContextMenuPolicy(Qt::CustomContextMenu); connect(aa_status_button, &QPushButton::customContextMenuRequested, [this](const QPoint& menu_location) { - QMenu context_menu; - for (auto const& aa_text_pair : ConfigurationShared::anti_aliasing_texts_map) { - context_menu.addAction(aa_text_pair.second, [this, aa_text_pair] { - Settings::values.anti_aliasing.SetValue(aa_text_pair.first); - UpdateAAText(); + QMenu context_menu; + for (auto const& aa_text_pair : ConfigurationShared::anti_aliasing_texts_map) { + context_menu.addAction(aa_text_pair.second, [this, aa_text_pair] { + Settings::values.anti_aliasing.SetValue(aa_text_pair.first); + UpdateAAText(); + }); + } + context_menu.exec(aa_status_button->mapToGlobal(menu_location)); + aa_status_button->repaint(); }); - } - context_menu.exec(aa_status_button->mapToGlobal(menu_location)); - aa_status_button->repaint(); - }); statusBar()->insertPermanentWidget(0, aa_status_button); // Setup Filter button @@ -1230,16 +1229,16 @@ void GMainWindow::InitializeWidgets() { filter_status_button->setContextMenuPolicy(Qt::CustomContextMenu); connect(filter_status_button, &QPushButton::customContextMenuRequested, [this](const QPoint& menu_location) { - QMenu context_menu; - for (auto const& filter_text_pair : ConfigurationShared::scaling_filter_texts_map) { - context_menu.addAction(filter_text_pair.second, [this, filter_text_pair] { - Settings::values.scaling_filter.SetValue(filter_text_pair.first); - UpdateFilterText(); + QMenu context_menu; + for (auto const& filter_text_pair : ConfigurationShared::scaling_filter_texts_map) { + context_menu.addAction(filter_text_pair.second, [this, filter_text_pair] { + Settings::values.scaling_filter.SetValue(filter_text_pair.first); + UpdateFilterText(); + }); + } + context_menu.exec(filter_status_button->mapToGlobal(menu_location)); + filter_status_button->repaint(); }); - } - context_menu.exec(filter_status_button->mapToGlobal(menu_location)); - filter_status_button->repaint(); - }); statusBar()->insertPermanentWidget(0, filter_status_button); // Setup Dock button @@ -1252,18 +1251,18 @@ void GMainWindow::InitializeWidgets() { dock_status_button->setContextMenuPolicy(Qt::CustomContextMenu); connect(dock_status_button, &QPushButton::customContextMenuRequested, [this](const QPoint& menu_location) { - QMenu context_menu; + QMenu context_menu; - for (auto const& pair : ConfigurationShared::use_docked_mode_texts_map) { - context_menu.addAction(pair.second, [this, &pair] { - if (pair.first != Settings::values.use_docked_mode.GetValue()) { - OnToggleDockedMode(); + for (auto const& pair : ConfigurationShared::use_docked_mode_texts_map) { + context_menu.addAction(pair.second, [this, &pair] { + if (pair.first != Settings::values.use_docked_mode.GetValue()) { + OnToggleDockedMode(); + } + }); } + context_menu.exec(dock_status_button->mapToGlobal(menu_location)); + dock_status_button->repaint(); }); - } - context_menu.exec(dock_status_button->mapToGlobal(menu_location)); - dock_status_button->repaint(); - }); statusBar()->insertPermanentWidget(0, dock_status_button); // Setup GPU Accuracy button @@ -1276,20 +1275,20 @@ void GMainWindow::InitializeWidgets() { gpu_accuracy_button->setContextMenuPolicy(Qt::CustomContextMenu); connect(gpu_accuracy_button, &QPushButton::customContextMenuRequested, [this](const QPoint& menu_location) { - QMenu context_menu; + QMenu context_menu; - for (auto const& gpu_accuracy_pair : ConfigurationShared::gpu_accuracy_texts_map) { - if (gpu_accuracy_pair.first == Settings::GpuAccuracy::Extreme) { - continue; - } - context_menu.addAction(gpu_accuracy_pair.second, [this, gpu_accuracy_pair] { - Settings::values.gpu_accuracy.SetValue(gpu_accuracy_pair.first); - UpdateGPUAccuracyButton(); + for (auto const& gpu_accuracy_pair : ConfigurationShared::gpu_accuracy_texts_map) { + if (gpu_accuracy_pair.first == Settings::GpuAccuracy::Extreme) { + continue; + } + context_menu.addAction(gpu_accuracy_pair.second, [this, gpu_accuracy_pair] { + Settings::values.gpu_accuracy.SetValue(gpu_accuracy_pair.first); + UpdateGPUAccuracyButton(); + }); + } + context_menu.exec(gpu_accuracy_button->mapToGlobal(menu_location)); + gpu_accuracy_button->repaint(); }); - } - context_menu.exec(gpu_accuracy_button->mapToGlobal(menu_location)); - gpu_accuracy_button->repaint(); - }); statusBar()->insertPermanentWidget(0, gpu_accuracy_button); // Setup Renderer API button @@ -1305,22 +1304,22 @@ void GMainWindow::InitializeWidgets() { renderer_status_button->setContextMenuPolicy(Qt::CustomContextMenu); connect(renderer_status_button, &QPushButton::customContextMenuRequested, [this](const QPoint& menu_location) { - QMenu context_menu; + QMenu context_menu; - for (auto const& renderer_backend_pair : - ConfigurationShared::renderer_backend_texts_map) { - if (renderer_backend_pair.first == Settings::RendererBackend::Null) { - continue; - } - context_menu.addAction( + for (auto const& renderer_backend_pair : + ConfigurationShared::renderer_backend_texts_map) { + if (renderer_backend_pair.first == Settings::RendererBackend::Null) { + continue; + } + context_menu.addAction( renderer_backend_pair.second, [this, renderer_backend_pair] { - Settings::values.renderer_backend.SetValue(renderer_backend_pair.first); - UpdateAPIText(); + Settings::values.renderer_backend.SetValue(renderer_backend_pair.first); + UpdateAPIText(); + }); + } + context_menu.exec(renderer_status_button->mapToGlobal(menu_location)); + renderer_status_button->repaint(); }); - } - context_menu.exec(renderer_status_button->mapToGlobal(menu_location)); - renderer_status_button->repaint(); - }); statusBar()->insertPermanentWidget(0, renderer_status_button); // Setup Refresh Button @@ -1385,24 +1384,24 @@ void GMainWindow::LinkActionShortcut(QAction* action, const QString& action_name static const auto main_window = std::string("Main Window"); action->setShortcut(hotkey_registry.GetKeySequence(main_window, action_name.toStdString())); action->setShortcutContext( - hotkey_registry.GetShortcutContext(main_window, action_name.toStdString())); + hotkey_registry.GetShortcutContext(main_window, action_name.toStdString())); action->setAutoRepeat(false); this->addAction(action); auto* controller = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); const auto* controller_hotkey = - hotkey_registry.GetControllerHotkey(main_window, action_name.toStdString(), controller); + hotkey_registry.GetControllerHotkey(main_window, action_name.toStdString(), controller); connect( - controller_hotkey, &ControllerShortcut::Activated, this, - [action, tas_allowed, this] { - auto [tas_status, current_tas_frame, total_tas_frames] = + controller_hotkey, &ControllerShortcut::Activated, this, + [action, tas_allowed, this] { + auto [tas_status, current_tas_frame, total_tas_frames] = input_subsystem->GetTas()->GetStatus(); - if (tas_allowed || tas_status == InputCommon::TasInput::TasState::Stopped) { - action->trigger(); - } - }, - Qt::QueuedConnection); + if (tas_allowed || tas_status == InputCommon::TasInput::TasState::Stopped) { + action->trigger(); + } + }, + Qt::QueuedConnection); } void GMainWindow::InitializeHotkeys() { @@ -1433,15 +1432,15 @@ void GMainWindow::InitializeHotkeys() { static const QString main_window = QStringLiteral("Main Window"); const auto connect_shortcut = [&](const QString& action_name, const Fn& function) { - const auto* hotkey = + const auto* hotkey = hotkey_registry.GetHotkey(main_window.toStdString(), action_name.toStdString(), this); - auto* controller = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); - const auto* controller_hotkey = hotkey_registry.GetControllerHotkey( - main_window.toStdString(), action_name.toStdString(), controller); - connect(hotkey, &QShortcut::activated, this, function); - connect(controller_hotkey, &ControllerShortcut::Activated, this, function, - Qt::QueuedConnection); -}; + auto* controller = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); + const auto* controller_hotkey = hotkey_registry.GetControllerHotkey( + main_window.toStdString(), action_name.toStdString(), controller); + connect(hotkey, &QShortcut::activated, this, function); + connect(controller_hotkey, &ControllerShortcut::Activated, this, function, + Qt::QueuedConnection); + }; connect_shortcut(QStringLiteral("Exit Fullscreen"), [&] { if (emulation_running && ui->action_Fullscreen->isChecked()) { @@ -1508,7 +1507,7 @@ void GMainWindow::RestoreUIState() { ui->action_Fullscreen->setChecked(UISettings::values.fullscreen.GetValue()); ui->action_Display_Dock_Widget_Headers->setChecked( - UISettings::values.display_titlebar.GetValue()); + UISettings::values.display_titlebar.GetValue()); OnDisplayTitleBars(ui->action_Display_Dock_Widget_Headers->isChecked()); ui->action_Show_Filter_Bar->setChecked(UISettings::values.show_filter_bar.GetValue()); @@ -1521,7 +1520,7 @@ void GMainWindow::RestoreUIState() { void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) { if (state != Qt::ApplicationHidden && state != Qt::ApplicationInactive && - state != Qt::ApplicationActive) { + state != Qt::ApplicationActive) { LOG_DEBUG(Frontend, "ApplicationState unusual flag: {} ", state); } if (!emulation_running) { @@ -1529,7 +1528,7 @@ void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) { } if (UISettings::values.pause_when_in_background) { if (emu_thread->IsRunning() && - (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { + (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { auto_paused = true; OnPauseGame(); } else if (!emu_thread->IsRunning() && auto_paused && state == Qt::ApplicationActive) { @@ -1539,7 +1538,7 @@ void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) { } if (UISettings::values.mute_when_in_background) { if (!Settings::values.audio_muted && - (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { + (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { Settings::values.audio_muted = true; auto_muted = true; } else if (auto_muted && state == Qt::ApplicationActive) { @@ -1600,12 +1599,12 @@ void GMainWindow::ConnectWidgetEvents() { void GMainWindow::ConnectMenuEvents() { const auto connect_menu = [&](QAction* action, const Fn& event_fn) { - connect(action, &QAction::triggered, this, event_fn); - // Add actions to this window so that hiding menus in fullscreen won't disable them - addAction(action); - // Add actions to the render window so that they work outside of single window mode - render_window->addAction(action); -}; + connect(action, &QAction::triggered, this, event_fn); + // Add actions to this window so that hiding menus in fullscreen won't disable them + addAction(action); + // Add actions to the render window so that they work outside of single window mode + render_window->addAction(action); + }; // File connect_menu(ui->action_Load_File, &GMainWindow::OnMenuLoadFile); @@ -1667,7 +1666,8 @@ void GMainWindow::ConnectMenuEvents() { connect_menu(ui->action_Load_Home_Menu, &GMainWindow::OnHomeMenu); connect_menu(ui->action_Open_Setup, &GMainWindow::OnInitialSetup); connect_menu(ui->action_Desktop, &GMainWindow::OnCreateHomeMenuDesktopShortcut); - connect_menu(ui->action_Application_Menu, &GMainWindow::OnCreateHomeMenuApplicationMenuShortcut); + connect_menu(ui->action_Application_Menu, + &GMainWindow::OnCreateHomeMenuApplicationMenuShortcut); connect_menu(ui->action_Capture_Screenshot, &GMainWindow::OnCaptureScreenshot); // TAS @@ -1697,21 +1697,21 @@ void GMainWindow::UpdateMenuState() { const std::array running_actions{ ui->action_Stop, - ui->action_Restart, - ui->action_Configure_Current_Game, - ui->action_Report_Compatibility, - ui->action_Load_Amiibo, - ui->action_Pause, + ui->action_Restart, + ui->action_Configure_Current_Game, + ui->action_Report_Compatibility, + ui->action_Load_Amiibo, + ui->action_Pause, }; const std::array applet_actions{ui->action_Load_Album, - ui->action_Load_Cabinet_Nickname_Owner, - ui->action_Load_Cabinet_Eraser, - ui->action_Load_Cabinet_Restorer, - ui->action_Load_Cabinet_Formatter, - ui->action_Load_Mii_Edit, - ui->action_Load_Home_Menu, - ui->action_Open_Controller_Menu}; + ui->action_Load_Cabinet_Nickname_Owner, + ui->action_Load_Cabinet_Eraser, + ui->action_Load_Cabinet_Restorer, + ui->action_Load_Cabinet_Formatter, + ui->action_Load_Mii_Edit, + ui->action_Load_Home_Menu, + ui->action_Open_Controller_Menu}; for (QAction* action : running_actions) { action->setEnabled(emulation_running); @@ -1761,9 +1761,9 @@ void GMainWindow::SetupPrepareForSleep() { auto bus = QDBusConnection::systemBus(); if (bus.isConnected()) { const bool success = bus.connect( - QStringLiteral("org.freedesktop.login1"), QStringLiteral("/org/freedesktop/login1"), - QStringLiteral("org.freedesktop.login1.Manager"), QStringLiteral("PrepareForSleep"), - QStringLiteral("b"), this, SLOT(OnPrepareForSleep(bool))); + QStringLiteral("org.freedesktop.login1"), QStringLiteral("/org/freedesktop/login1"), + QStringLiteral("org.freedesktop.login1.Manager"), QStringLiteral("PrepareForSleep"), + QStringLiteral("b"), this, SLOT(OnPrepareForSleep(bool))); if (!success) { LOG_WARNING(Frontend, "Couldn't register PrepareForSleep signal"); @@ -1872,21 +1872,20 @@ bool GMainWindow::LoadROM(const QString& filename, Service::AM::FrontendAppletPa system->GetUserChannel().clear(); } - system->SetFrontendAppletSet({ - std::make_unique(*this), // Amiibo Settings - (UISettings::values.controller_applet_disabled.GetValue() == true) - ? nullptr - : std::make_unique(*this), // Controller Selector - std::make_unique(*this), // Error Display - nullptr, // Mii Editor - nullptr, // Parental Controls - nullptr, // Photo Viewer - std::make_unique(*this), // Profile Selector - std::make_unique(*this), // Software Keyboard - std::make_unique(*this), // Web Browser - nullptr, // Net Connect - }); + std::make_unique(*this), // Amiibo Settings + (UISettings::values.controller_applet_disabled.GetValue() == true) + ? nullptr + : std::make_unique(*this), // Controller Selector + std::make_unique(*this), // Error Display + nullptr, // Mii Editor + nullptr, // Parental Controls + nullptr, // Photo Viewer + std::make_unique(*this), // Profile Selector + std::make_unique(*this), // Software Keyboard + std::make_unique(*this), // Web Browser + nullptr, // Net Connect + }); /** Game Updates check */ @@ -1894,26 +1893,29 @@ bool GMainWindow::LoadROM(const QString& filename, Service::AM::FrontendAppletPa QSettings settings; QStringList currentIgnored = settings.value("ignoredBadUpdates", {}).toStringList(); - if (std::find(bad_update_games.begin(), bad_update_games.end(), params.program_id) != bad_update_games.end() - && !currentIgnored.contains(QString::number(params.program_id))) { - QMessageBox *msg = new QMessageBox(this); + if (std::find(bad_update_games.begin(), bad_update_games.end(), params.program_id) != + bad_update_games.end() && + !currentIgnored.contains(QString::number(params.program_id))) { + QMessageBox* msg = new QMessageBox(this); msg->setWindowTitle(tr("Game Updates Warning")); msg->setIcon(QMessageBox::Warning); - msg->setText(tr("The game you are trying to launch is known to have performance or booting " - "issues when updates are applied. Please try increasing the memory layout to " - "6GB or 8GB if any issues occur.

Press \"OK\" to continue launching, or " - "\"Cancel\" to cancel the launch.")); + msg->setText( + tr("The game you are trying to launch is known to have performance or booting " + "issues when updates are applied. Please try increasing the memory layout to " + "6GB or 8GB if any issues occur.

Press \"OK\" to continue launching, or " + "\"Cancel\" to cancel the launch.")); msg->setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - QCheckBox *dontShowAgain = new QCheckBox(msg); + QCheckBox* dontShowAgain = new QCheckBox(msg); dontShowAgain->setText(tr("Don't show again for this game")); msg->setCheckBox(dontShowAgain); int result = msg->exec(); // wtf - QMessageBox::ButtonRole role = msg->buttonRole(msg->button((QMessageBox::StandardButton) result)); + QMessageBox::ButtonRole role = + msg->buttonRole(msg->button((QMessageBox::StandardButton)result)); switch (role) { case QMessageBox::RejectRole: @@ -1929,19 +1931,22 @@ bool GMainWindow::LoadROM(const QString& filename, Service::AM::FrontendAppletPa } } - if (FirmwareManager::GameRequiresFirmware(params.program_id) && !FirmwareManager::CheckFirmwarePresence(*system)) { - QMessageBox *msg = new QMessageBox(this); + if (FirmwareManager::GameRequiresFirmware(params.program_id) && + !FirmwareManager::CheckFirmwarePresence(*system)) { + QMessageBox* msg = new QMessageBox(this); msg->setWindowTitle(tr("Game Requires Firmware")); msg->setIcon(QMessageBox::Warning); - msg->setText(tr("The game you are trying to launch requires firmware to boot or to get past the " - "opening menu. Please " - "dump and install firmware, or press \"OK\" to launch anyways.")); + msg->setText( + tr("The game you are trying to launch requires firmware to boot or to get past the " + "opening menu. Please " + "dump and install firmware, or press \"OK\" to launch anyways.")); msg->setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); int exec_result = msg->exec(); - QMessageBox::ButtonRole role = msg->buttonRole(msg->button((QMessageBox::StandardButton) exec_result)); + QMessageBox::ButtonRole role = + msg->buttonRole(msg->button((QMessageBox::StandardButton)exec_result)); switch (role) { case QMessageBox::RejectRole: @@ -1960,18 +1965,19 @@ bool GMainWindow::LoadROM(const QString& filename, Service::AM::FrontendAppletPa static_cast(CalloutFlag::DRDDeprecation)) == 0; if (result == Core::SystemResultStatus::Success && - system->GetAppLoader().GetFileType() == Loader::FileType::DeconstructedRomDirectory && - drd_callout) { + system->GetAppLoader().GetFileType() == Loader::FileType::DeconstructedRomDirectory && + drd_callout) { UISettings::values.callout_flags = UISettings::values.callout_flags.GetValue() | - static_cast(CalloutFlag::DRDDeprecation); + static_cast(CalloutFlag::DRDDeprecation); QMessageBox::warning( - this, tr("Warning: Outdated Game Format"), - tr("You are using the deconstructed ROM directory format for this game, which is an " - "outdated format that has been superseded by others such as NCA, NAX, XCI, or " - "NSP. Deconstructed ROM directories lack icons, metadata, and update " - "support.

For an explanation of the various Switch formats eden supports, check out our " - "wiki. This message will not be shown again.")); + this, tr("Warning: Outdated Game Format"), + tr("You are using the deconstructed ROM directory format for this game, which is an " + "outdated format that has been superseded by others such as NCA, NAX, XCI, or " + "NSP. Deconstructed ROM directories lack icons, metadata, and update " + "support.

For an explanation of the various Switch formats eden supports, check " + "out our " + "wiki. This message will not be shown again.")); } if (result != Core::SystemResultStatus::Success) { @@ -1983,13 +1989,13 @@ bool GMainWindow::LoadROM(const QString& filename, Service::AM::FrontendAppletPa break; case Core::SystemResultStatus::ErrorVideoCore: QMessageBox::critical( - this, tr("An error occurred initializing the video core."), - tr("eden has encountered an error while running the video core. " - "This is usually caused by outdated GPU drivers, including integrated ones. " - "Please see the log for more details. " - "For more information on accessing the log, please see the following page: " - "" - "How to Upload the Log File. ")); + this, tr("An error occurred initializing the video core."), + tr("eden has encountered an error while running the video core. " + "This is usually caused by outdated GPU drivers, including integrated ones. " + "Please see the log for more details. " + "For more information on accessing the log, please see the following page: " + "" + "How to Upload the Log File. ")); break; default: if (result > Core::SystemResultStatus::ErrorLoader) { @@ -1999,19 +2005,19 @@ bool GMainWindow::LoadROM(const QString& filename, Service::AM::FrontendAppletPa LOG_CRITICAL(Frontend, "Failed to load ROM! {}", error_code); const auto title = - tr("Error while loading ROM! %1", "%1 signifies a numeric error code.") + tr("Error while loading ROM! %1", "%1 signifies a numeric error code.") .arg(QString::fromStdString(error_code)); const auto description = - tr("%1
Please redump your files or ask on Discord for help.", - "%1 signifies an error string.") + tr("%1
Please redump your files or ask on Discord for help.", + "%1 signifies an error string.") .arg(QString::fromStdString( - GetResultStatusString(static_cast(error_id)))); + GetResultStatusString(static_cast(error_id)))); QMessageBox::critical(this, title, description); } else { QMessageBox::critical( - this, tr("Error while loading ROM!"), - tr("An unknown error occurred. Please see the log for more details.")); + this, tr("Error while loading ROM!"), + tr("An unknown error occurred. Please see the log for more details.")); } break; } @@ -2023,7 +2029,7 @@ bool GMainWindow::LoadROM(const QString& filename, Service::AM::FrontendAppletPa } bool GMainWindow::SelectAndSetCurrentUser( - const Core::Frontend::ProfileSelectParameters& parameters) { + const Core::Frontend::ProfileSelectParameters& parameters) { QtProfileSelectionDialog dialog(*system, this, parameters); dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); @@ -2063,8 +2069,8 @@ void GMainWindow::ConfigureFilesystemProvider(const std::string& filepath) { } else if (res2 == Loader::ResultStatus::Success && (file_type == Loader::FileType::XCI || file_type == Loader::FileType::NSP)) { const auto nsp = file_type == Loader::FileType::NSP - ? std::make_shared(file) - : FileSys::XCI{file}.GetSecurePartitionNSP(); + ? std::make_shared(file) + : FileSys::XCI{file}.GetSecurePartitionNSP(); for (const auto& title : nsp->GetNCAs()) { for (const auto& entry : title.second) { provider->AddEntry(entry.first.first, entry.first.second, title.first, @@ -2079,7 +2085,7 @@ void GMainWindow::BootGame(const QString& filename, Service::AM::FrontendAppletP LOG_INFO(Frontend, "eden starting..."); if (params.program_id == 0 || - params.program_id > static_cast(Service::AM::AppletProgramId::MaxProgramId)) { + params.program_id > static_cast(Service::AM::AppletProgramId::MaxProgramId)) { StoreRecentFile(filename); // Put the filename on top of the list } @@ -2097,13 +2103,13 @@ void GMainWindow::BootGame(const QString& filename, Service::AM::FrontendAppletP const auto loader = Loader::GetLoader(*system, v_file, params.program_id, params.program_index); if (loader != nullptr && loader->ReadProgramId(title_id) == Loader::ResultStatus::Success && - type == StartGameType::Normal) { + type == StartGameType::Normal) { // Load per game settings const auto file_path = - std::filesystem::path{Common::U16StringFromBuffer(filename.utf16(), filename.size())}; + std::filesystem::path{Common::U16StringFromBuffer(filename.utf16(), filename.size())}; const auto config_file_name = title_id == 0 - ? Common::FS::PathToUTF8String(file_path.filename()) - : fmt::format("{:016X}", title_id); + ? Common::FS::PathToUTF8String(file_path.filename()) + : fmt::format("{:016X}", title_id); QtConfig per_game_config(config_file_name, Config::ConfigType::PerGameConfig); system->HIDCore().ReloadInputDevices(); system->ApplySettings(); @@ -2114,9 +2120,9 @@ void GMainWindow::BootGame(const QString& filename, Service::AM::FrontendAppletP if (UISettings::values.select_user_on_boot && !user_flag_cmd_line) { const Core::Frontend::ProfileSelectParameters parameters{ .mode = Service::AM::Frontend::UiMode::UserSelector, - .invalid_uid_list = {}, - .display_options = {}, - .purpose = Service::AM::Frontend::UserSelectionPurpose::General, + .invalid_uid_list = {}, + .display_options = {}, + .purpose = Service::AM::Frontend::UserSelectionPurpose::General, }; if (SelectAndSetCurrentUser(parameters) == false) { return; @@ -2142,7 +2148,7 @@ void GMainWindow::BootGame(const QString& filename, Service::AM::FrontendAppletP // Register an ExecuteProgram callback such that Core can execute a sub-program system->RegisterExecuteProgramCallback( - [this](std::size_t program_index_) { render_window->ExecuteProgram(program_index_); }); + [this](std::size_t program_index_) { render_window->ExecuteProgram(program_index_); }); system->RegisterExitCallback([this] { emu_thread->ForceStop(); @@ -2197,14 +2203,14 @@ void GMainWindow::BootGame(const QString& filename, Service::AM::FrontendAppletP } if (res != Loader::ResultStatus::Success || title_name.empty()) { title_name = Common::FS::PathToUTF8String( - std::filesystem::path{Common::U16StringFromBuffer(filename.utf16(), filename.size())} - .filename()); + std::filesystem::path{Common::U16StringFromBuffer(filename.utf16(), filename.size())} + .filename()); } const bool is_64bit = system->Kernel().ApplicationProcess()->Is64Bit(); const auto instruction_set_suffix = is_64bit ? tr("(64-bit)") : tr("(32-bit)"); title_name = tr("%1 %2", "%1 is the title name. %2 indicates if the title is 64-bit or 32-bit") - .arg(QString::fromStdString(title_name), instruction_set_suffix) - .toStdString(); + .arg(QString::fromStdString(title_name), instruction_set_suffix) + .toStdString(); LOG_INFO(Frontend, "Booting game: {:016X} | {} | {}", title_id, title_name, title_version); const auto gpu_vendor = system->GPU().Renderer().GetDeviceVendor(); UpdateWindowTitle(title_name, title_version, gpu_vendor); @@ -2384,11 +2390,11 @@ void GMainWindow::StoreRecentFile(const QString& filename) { void GMainWindow::UpdateRecentFiles() { const int num_recent_files = - std::min(static_cast(UISettings::values.recent_files.size()), max_recent_files_item); + std::min(static_cast(UISettings::values.recent_files.size()), max_recent_files_item); for (int i = 0; i < num_recent_files; i++) { const QString text = QStringLiteral("&%1. %2").arg(i + 1).arg( - QFileInfo(UISettings::values.recent_files[i]).fileName()); + QFileInfo(UISettings::values.recent_files[i]).fileName()); actions_recent_files[i]->setText(text); actions_recent_files[i]->setData(UISettings::values.recent_files[i]); actions_recent_files[i]->setToolTip(UISettings::values.recent_files[i]); @@ -2417,7 +2423,7 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target const auto [user_save_size, device_save_size] = [this, &game_path, &program_id] { const FileSys::PatchManager pm{program_id, system->GetFileSystemController(), - system->GetContentProvider()}; + system->GetContentProvider()}; const auto control = pm.GetControlMetadata().first; if (control != nullptr) { return std::make_pair(control->GetDefaultNormalSaveSize(), @@ -2443,16 +2449,16 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target open_target = tr("Save Data"); const auto nand_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::NANDDir); auto vfs_nand_dir = - vfs->OpenDirectory(Common::FS::PathToUTF8String(nand_dir), FileSys::OpenMode::Read); + vfs->OpenDirectory(Common::FS::PathToUTF8String(nand_dir), FileSys::OpenMode::Read); if (has_user_save) { // User save data const auto select_profile = [this] { const Core::Frontend::ProfileSelectParameters parameters{ .mode = Service::AM::Frontend::UiMode::UserSelector, - .invalid_uid_list = {}, - .display_options = {}, - .purpose = Service::AM::Frontend::UserSelectionPurpose::General, + .invalid_uid_list = {}, + .display_options = {}, + .purpose = Service::AM::Frontend::UserSelectionPurpose::General, }; QtProfileSelectionDialog dialog(*system, this, parameters); dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | @@ -2472,19 +2478,19 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target } const auto user_id = - system->GetProfileManager().GetUser(static_cast(index)); + system->GetProfileManager().GetUser(static_cast(index)); ASSERT(user_id); const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( - {}, vfs_nand_dir, FileSys::SaveDataSpaceId::User, FileSys::SaveDataType::Account, - program_id, user_id->AsU128(), 0); + {}, vfs_nand_dir, FileSys::SaveDataSpaceId::User, FileSys::SaveDataType::Account, + program_id, user_id->AsU128(), 0); path = Common::FS::ConcatPathSafe(nand_dir, user_save_data_path); } else { // Device save data const auto device_save_data_path = FileSys::SaveDataFactory::GetFullPath( - {}, vfs_nand_dir, FileSys::SaveDataSpaceId::User, FileSys::SaveDataType::Account, - program_id, {}, 0); + {}, vfs_nand_dir, FileSys::SaveDataSpaceId::User, FileSys::SaveDataType::Account, + program_id, {}, 0); path = Common::FS::ConcatPathSafe(nand_dir, device_save_data_path); } @@ -2498,7 +2504,7 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target case GameListOpenTarget::ModData: { open_target = tr("Mod Data"); path = Common::FS::GetEdenPath(Common::FS::EdenPath::LoadDir) / - fmt::format("{:016X}", program_id); + fmt::format("{:016X}", program_id); break; } default: @@ -2543,7 +2549,7 @@ static bool RomFSRawCopy(size_t total_size, size_t& read_size, QProgressDialog& auto last_timestamp = std::chrono::steady_clock::now(); const auto QtRawCopy = [&](const FileSys::VirtualFile& src_file, - const FileSys::VirtualFile& dest_file) { + const FileSys::VirtualFile& dest_file) { if (src_file == nullptr || dest_file == nullptr) { return false; } @@ -2563,7 +2569,7 @@ static bool RomFSRawCopy(size_t total_size, size_t& read_size, QProgressDialog& if ((new_timestamp - last_timestamp) > 33ms) { last_timestamp = new_timestamp; dialog.setValue( - static_cast(std::min(read_size, total_size) * 100 / total_size)); + static_cast(std::min(read_size, total_size) * 100 / total_size)); QCoreApplication::processEvents(); } @@ -2645,14 +2651,14 @@ void GMainWindow::OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryT void GMainWindow::RemoveBaseContent(u64 program_id, InstalledEntryType type) { const auto res = - ContentManager::RemoveBaseContent(system->GetFileSystemController(), program_id); + ContentManager::RemoveBaseContent(system->GetFileSystemController(), program_id); if (res) { QMessageBox::information(this, tr("Successfully Removed"), tr("Successfully removed the installed base game.")); } else { QMessageBox::warning( - this, GetGameListErrorRemoving(type), - tr("The base game is not installed in the NAND and cannot be removed.")); + this, GetGameListErrorRemoving(type), + tr("The base game is not installed in the NAND and cannot be removed.")); } } @@ -2799,10 +2805,10 @@ void GMainWindow::RemoveAllTransferableShaderCaches(u64 program_id) { void GMainWindow::RemoveCustomConfiguration(u64 program_id, const std::string& game_path) { const auto file_path = std::filesystem::path(Common::FS::ToU8String(game_path)); const auto config_file_name = - program_id == 0 ? Common::FS::PathToUTF8String(file_path.filename()).append(".ini") - : fmt::format("{:016X}.ini", program_id); + program_id == 0 ? Common::FS::PathToUTF8String(file_path.filename()).append(".ini") + : fmt::format("{:016X}.ini", program_id); const auto custom_config_file_path = - Common::FS::GetEdenPath(Common::FS::EdenPath::ConfigDir) / "custom" / config_file_name; + Common::FS::GetEdenPath(Common::FS::EdenPath::ConfigDir) / "custom" / config_file_name; if (!Common::FS::Exists(custom_config_file_path)) { QMessageBox::warning(this, tr("Error Removing Custom Configuration"), @@ -2822,11 +2828,11 @@ void GMainWindow::RemoveCustomConfiguration(u64 program_id, const std::string& g void GMainWindow::RemoveCacheStorage(u64 program_id) { const auto nand_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::NANDDir); auto vfs_nand_dir = - vfs->OpenDirectory(Common::FS::PathToUTF8String(nand_dir), FileSys::OpenMode::Read); + vfs->OpenDirectory(Common::FS::PathToUTF8String(nand_dir), FileSys::OpenMode::Read); const auto cache_storage_path = FileSys::SaveDataFactory::GetFullPath( - {}, vfs_nand_dir, FileSys::SaveDataSpaceId::User, FileSys::SaveDataType::Cache, - 0 /* program_id */, {}, 0); + {}, vfs_nand_dir, FileSys::SaveDataSpaceId::User, FileSys::SaveDataType::Cache, + 0 /* program_id */, {}, 0); const auto path = Common::FS::ConcatPathSafe(nand_dir, cache_storage_path); @@ -2843,7 +2849,7 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa }; const auto loader = - Loader::GetLoader(*system, vfs->OpenFile(game_path, FileSys::OpenMode::Read)); + Loader::GetLoader(*system, vfs->OpenFile(game_path, FileSys::OpenMode::Read)); if (loader == nullptr) { failed(); return; @@ -2870,14 +2876,14 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa const FileSys::NCA update_nca{packed_update_raw, nullptr}; if (type != FileSys::ContentRecordType::Program || - update_nca.GetStatus() != Loader::ResultStatus::ErrorMissingBKTRBaseRomFS || - update_nca.GetTitleId() != FileSys::GetUpdateTitleID(title_id)) { + update_nca.GetStatus() != Loader::ResultStatus::ErrorMissingBKTRBaseRomFS || + update_nca.GetTitleId() != FileSys::GetUpdateTitleID(title_id)) { packed_update_raw = {}; } const auto base_romfs = base_nca->GetRomFS(); const auto dump_dir = - target == DumpRomFSTarget::Normal + target == DumpRomFSTarget::Normal ? Common::FS::GetEdenPath(Common::FS::EdenPath::DumpDir) : Common::FS::GetEdenPath(Common::FS::EdenPath::SDMCDir) / "atmosphere" / "contents"; const auto romfs_dir = fmt::format("{:016X}/romfs", title_id); @@ -2898,11 +2904,11 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa bool ok = false; const QStringList selections{tr("Full"), tr("Skeleton")}; const auto res = QInputDialog::getItem( - this, tr("Select RomFS Dump Mode"), - tr("Please select the how you would like the RomFS dumped.
Full will copy all of the " - "files into the new directory while
skeleton will only create the directory " - "structure."), - selections, 0, false, &ok); + this, tr("Select RomFS Dump Mode"), + tr("Please select the how you would like the RomFS dumped.
Full will copy all of the " + "files into the new directory while
skeleton will only create the directory " + "structure."), + selections, 0, false, &ok); if (!ok) { failed(); vfs->DeleteDirectory(path); @@ -2925,7 +2931,7 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa tr("There is not enough free space at %1 to extract the RomFS. Please " "free up space or select a different dump directory at " "Emulation > Configure > System > Filesystem > Dump Root") - .arg(QString::fromStdString(path))); + .arg(QString::fromStdString(path))); return; } @@ -2996,7 +3002,8 @@ void GMainWindow::OnGameListNavigateToGamedbEntry(u64 program_id, directory = it->second.second; } - QDesktopServices::openUrl(QUrl(QStringLiteral("https://eden-emulator.github.io/game/") + directory)); + QDesktopServices::openUrl( + QUrl(QStringLiteral("https://eden-emulator.github.io/game/") + directory)); } bool GMainWindow::CreateShortcutLink(const std::filesystem::path& shortcut_path, @@ -3109,8 +3116,8 @@ bool GMainWindow::CreateShortcutMessagesGUI(QWidget* parent, int imsg, const QSt case GMainWindow::CREATE_SHORTCUT_MSGBOX_FULLSCREEN_YES: buttons = QMessageBox::Yes | QMessageBox::No; result = - QMessageBox::information(parent, tr("Create Shortcut"), - tr("Do you want to launch the game in fullscreen?"), buttons); + QMessageBox::information(parent, tr("Create Shortcut"), + tr("Do you want to launch the game in fullscreen?"), buttons); return result == QMessageBox::Yes; case GMainWindow::CREATE_SHORTCUT_MSGBOX_SUCCESS: QMessageBox::information(parent, tr("Create Shortcut"), @@ -3119,10 +3126,10 @@ bool GMainWindow::CreateShortcutMessagesGUI(QWidget* parent, int imsg, const QSt case GMainWindow::CREATE_SHORTCUT_MSGBOX_APPVOLATILE_WARNING: buttons = QMessageBox::StandardButton::Ok | QMessageBox::StandardButton::Cancel; result = - QMessageBox::warning(this, tr("Create Shortcut"), - tr("This will create a shortcut to the current AppImage. This may " - "not work well if you update. Continue?"), - buttons); + QMessageBox::warning(this, tr("Create Shortcut"), + tr("This will create a shortcut to the current AppImage. This may " + "not work well if you update. Continue?"), + buttons); return result == QMessageBox::Ok; default: buttons = QMessageBox::Ok; @@ -3145,10 +3152,10 @@ bool GMainWindow::MakeShortcutIcoPath(const u64 program_id, const std::string_vi // Create icons directory if it doesn't exist if (!Common::FS::CreateDirs(out_icon_path)) { QMessageBox::critical( - this, tr("Create Icon"), - tr("Cannot create icon file. Path \"%1\" does not exist and cannot be created.") - .arg(QString::fromStdString(out_icon_path.string())), - QMessageBox::StandardButton::Ok); + this, tr("Create Icon"), + tr("Cannot create icon file. Path \"%1\" does not exist and cannot be created.") + .arg(QString::fromStdString(out_icon_path.string())), + QMessageBox::StandardButton::Ok); out_icon_path.clear(); return false; } @@ -3171,13 +3178,13 @@ void GMainWindow::OnGameListOpenDirectory(const QString& directory) { std::filesystem::path fs_path; if (directory == QStringLiteral("SDMC")) { fs_path = - Common::FS::GetEdenPath(Common::FS::EdenPath::SDMCDir) / "Nintendo/Contents/registered"; + Common::FS::GetEdenPath(Common::FS::EdenPath::SDMCDir) / "Nintendo/Contents/registered"; } else if (directory == QStringLiteral("UserNAND")) { fs_path = - Common::FS::GetEdenPath(Common::FS::EdenPath::NANDDir) / "user/Contents/registered"; + Common::FS::GetEdenPath(Common::FS::EdenPath::NANDDir) / "user/Contents/registered"; } else if (directory == QStringLiteral("SysNAND")) { fs_path = - Common::FS::GetEdenPath(Common::FS::EdenPath::NANDDir) / "system/Contents/registered"; + Common::FS::GetEdenPath(Common::FS::EdenPath::NANDDir) / "system/Contents/registered"; } else { fs_path = directory.toStdString(); } @@ -3238,14 +3245,14 @@ void GMainWindow::OnMenuLoadFile() { is_load_file_select_active = true; const QString extensions = - QStringLiteral("*.") + QStringLiteral("*.") .append(GameList::supported_file_extensions.join(QStringLiteral(" *."))) .append(QStringLiteral(" main")); const QString file_filter = tr("Switch Executable (%1);;All Files (*.*)", "%1 is an identifier for the Switch executable file extensions.") - .arg(extensions); + .arg(extensions); const QString filename = QFileDialog::getOpenFileName( - this, tr("Load File"), QString::fromStdString(UISettings::values.roms_path), file_filter); + this, tr("Load File"), QString::fromStdString(UISettings::values.roms_path), file_filter); is_load_file_select_active = false; if (filename.isEmpty()) { @@ -3258,7 +3265,7 @@ void GMainWindow::OnMenuLoadFile() { void GMainWindow::OnMenuLoadFolder() { const QString dir_path = - QFileDialog::getExistingDirectory(this, tr("Open Extracted ROM Directory")); + QFileDialog::getExistingDirectory(this, tr("Open Extracted ROM Directory")); if (dir_path.isNull()) { return; @@ -3280,13 +3287,13 @@ void GMainWindow::IncrementInstallProgress() { void GMainWindow::OnMenuInstallToNAND() { const QString file_filter = - tr("Installable Switch File (*.nca *.nsp *.xci);;Nintendo Content Archive " - "(*.nca);;Nintendo Submission Package (*.nsp);;NX Cartridge " - "Image (*.xci)"); + tr("Installable Switch File (*.nca *.nsp *.xci);;Nintendo Content Archive " + "(*.nca);;Nintendo Submission Package (*.nsp);;NX Cartridge " + "Image (*.xci)"); QStringList filenames = QFileDialog::getOpenFileNames( - this, tr("Install Files"), QString::fromStdString(UISettings::values.roms_path), - file_filter); + this, tr("Install Files"), QString::fromStdString(UISettings::values.roms_path), + file_filter); if (filenames.isEmpty()) { return; @@ -3334,7 +3341,7 @@ void GMainWindow::OnMenuInstallToNAND() { for (const QString& file : files) { install_progress->setWindowTitle(tr("%n file(s) remaining", "", remaining)); install_progress->setLabelText( - tr("Installing file \"%1\"...").arg(QFileInfo(file).fileName())); + tr("Installing file \"%1\"...").arg(QFileInfo(file).fileName())); QFuture future; ContentManager::InstallResult result; @@ -3388,19 +3395,19 @@ void GMainWindow::OnMenuInstallToNAND() { if (detected_base_install) { QMessageBox::warning( - this, tr("Install Results"), - tr("To avoid possible conflicts, we discourage users from installing base games to the " - "NAND.\nPlease, only use this feature to install updates and DLC.")); + this, tr("Install Results"), + tr("To avoid possible conflicts, we discourage users from installing base games to the " + "NAND.\nPlease, only use this feature to install updates and DLC.")); } const QString install_results = - (new_files.isEmpty() ? QString{} - : tr("%n file(s) were newly installed\n", "", new_files.size())) + - (overwritten_files.isEmpty() + (new_files.isEmpty() ? QString{} + : tr("%n file(s) were newly installed\n", "", new_files.size())) + + (overwritten_files.isEmpty() ? QString{} : tr("%n file(s) were overwritten\n", "", overwritten_files.size())) + - (failed_files.isEmpty() ? QString{} - : tr("%n file(s) failed to install\n", "", failed_files.size())); + (failed_files.isEmpty() ? QString{} + : tr("%n file(s) failed to install\n", "", failed_files.size())); QMessageBox::information(this, tr("Install Results"), install_results); Common::FS::RemoveDirRecursively(Common::FS::GetEdenPath(Common::FS::EdenPath::CacheDir) / @@ -3411,20 +3418,20 @@ void GMainWindow::OnMenuInstallToNAND() { ContentManager::InstallResult GMainWindow::InstallNCA(const QString& filename) { const QStringList tt_options{tr("System Application"), - tr("System Archive"), - tr("System Application Update"), - tr("Firmware Package (Type A)"), - tr("Firmware Package (Type B)"), - tr("Game"), - tr("Game Update"), - tr("Game DLC"), - tr("Delta Title")}; + tr("System Archive"), + tr("System Application Update"), + tr("Firmware Package (Type A)"), + tr("Firmware Package (Type B)"), + tr("Game"), + tr("Game Update"), + tr("Game DLC"), + tr("Delta Title")}; bool ok; const auto item = QInputDialog::getItem( - this, tr("Select NCA Install Type..."), - tr("Please select the type of title you would like to install this NCA as:\n(In " - "most instances, the default 'Game' is fine.)"), - tt_options, 5, false, &ok); + this, tr("Select NCA Install Type..."), + tr("Please select the type of title you would like to install this NCA as:\n(In " + "most instances, the default 'Game' is fine.)"), + tt_options, 5, false, &ok); auto index = tt_options.indexOf(item); if (!ok || index == -1) { @@ -3436,7 +3443,7 @@ ContentManager::InstallResult GMainWindow::InstallNCA(const QString& filename) { // If index is equal to or past Game, add the jump in TitleType. if (index >= 5) { index += static_cast(FileSys::TitleType::Application) - - static_cast(FileSys::TitleType::FirmwarePackageB); + static_cast(FileSys::TitleType::FirmwarePackageB); } const bool is_application = index >= static_cast(FileSys::TitleType::Application); @@ -3551,7 +3558,7 @@ bool GMainWindow::ConfirmShutdownGame() { } else { if (UISettings::values.confirm_before_stopping.GetValue() == ConfirmStop::Ask_Based_On_Game && - system->GetExitLocked()) { + system->GetExitLocked()) { if (!ConfirmForceLockedExit()) { return false; } @@ -3617,14 +3624,14 @@ void GMainWindow::OnMenuReportCompatibility() { } if (!Settings::values.eden_token.GetValue().empty() && - !Settings::values.eden_username.GetValue().empty()) { + !Settings::values.eden_username.GetValue().empty()) { } else { QMessageBox::critical( - this, tr("Missing yuzu Account"), - tr("In order to submit a game compatibility test case, you must link your eden " - "account.

To link your eden account, go to Emulation > Configuration " - "> " - "Web.")); + this, tr("Missing yuzu Account"), + tr("In order to submit a game compatibility test case, you must link your eden " + "account.

To link your eden account, go to Emulation > Configuration " + "> " + "Web.")); } #else QMessageBox::critical(this, tr("Hardware requirements not met"), @@ -3653,8 +3660,7 @@ void GMainWindow::OnOpenFAQ() { OpenURL(QUrl(QStringLiteral("https://eden-emulator.github.io/"))); } -void GMainWindow::OnOpenDiscord() -{ +void GMainWindow::OnOpenDiscord() { OpenURL(QUrl(QStringLiteral("https://discord.gg/edenemu"))); } @@ -3673,18 +3679,18 @@ void GMainWindow::ToggleFullscreen() { static QScreen* GuessCurrentScreen(QWidget* window) { const QList screens = QGuiApplication::screens(); return *std::max_element( - screens.cbegin(), screens.cend(), [window](const QScreen* left, const QScreen* right) { - const QSize left_size = left->geometry().intersected(window->geometry()).size(); - const QSize right_size = right->geometry().intersected(window->geometry()).size(); - return (left_size.height() * left_size.width()) < - (right_size.height() * right_size.width()); - }); + screens.cbegin(), screens.cend(), [window](const QScreen* left, const QScreen* right) { + const QSize left_size = left->geometry().intersected(window->geometry()).size(); + const QSize right_size = right->geometry().intersected(window->geometry()).size(); + return (left_size.height() * left_size.width()) < + (right_size.height() * right_size.width()); + }); } bool GMainWindow::UsingExclusiveFullscreen() { return Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive || - QGuiApplication::platformName() == QStringLiteral("wayland") || - QGuiApplication::platformName() == QStringLiteral("wayland-egl"); + QGuiApplication::platformName() == QStringLiteral("wayland") || + QGuiApplication::platformName() == QStringLiteral("wayland-egl"); } void GMainWindow::ShowFullscreen() { @@ -3771,8 +3777,8 @@ void GMainWindow::ToggleWindowMode() { void GMainWindow::ResetWindowSize(u32 width, u32 height) { const auto aspect_ratio = Layout::EmulationAspectRatio( - static_cast(Settings::values.aspect_ratio.GetValue()), - static_cast(height) / width); + static_cast(Settings::values.aspect_ratio.GetValue()), + static_cast(height) / width); if (!ui->action_Single_Window_Mode->isChecked()) { render_window->resize(height / aspect_ratio, height); } else { @@ -3811,7 +3817,7 @@ void GMainWindow::OnConfigure() { const auto result = configure_dialog.exec(); if (result != QDialog::Accepted && !UISettings::values.configuration_applied && - !UISettings::values.reset_to_defaults) { + !UISettings::values.reset_to_defaults) { // Runs if the user hit Cancel or closed the window, and did not ever press the Apply button // or `Reset to Defaults` button return; @@ -3826,11 +3832,11 @@ void GMainWindow::OnConfigure() { LOG_WARNING(Frontend, "Failed to remove configuration file"); } if (!Common::FS::RemoveDirContentsRecursively( - Common::FS::GetEdenPath(Common::FS::EdenPath::ConfigDir) / "custom")) { + Common::FS::GetEdenPath(Common::FS::EdenPath::ConfigDir) / "custom")) { LOG_WARNING(Frontend, "Failed to remove custom configuration files"); } if (!Common::FS::RemoveDirRecursively( - Common::FS::GetEdenPath(Common::FS::EdenPath::CacheDir) / "game_list")) { + Common::FS::GetEdenPath(Common::FS::EdenPath::CacheDir) / "game_list")) { LOG_WARNING(Frontend, "Failed to remove game metadata cache files"); } @@ -4144,12 +4150,12 @@ bool GMainWindow::question(QWidget* parent, const QString& title, const QString& box_dialog->setDefaultButton(defaultButton); ControllerNavigation* controller_navigation = - new ControllerNavigation(system->HIDCore(), box_dialog); + new ControllerNavigation(system->HIDCore(), box_dialog); connect(controller_navigation, &ControllerNavigation::TriggerKeyboardEvent, [box_dialog](Qt::Key key) { - QKeyEvent* event = new QKeyEvent(QEvent::KeyPress, key, Qt::NoModifier); - QCoreApplication::postEvent(box_dialog, event); - }); + QKeyEvent* event = new QKeyEvent(QEvent::KeyPress, key, Qt::NoModifier); + QCoreApplication::postEvent(box_dialog, event); + }); int res = box_dialog->exec(); controller_navigation->UnloadController(); @@ -4185,32 +4191,28 @@ void GMainWindow::LoadAmiibo(const QString& filename) { } void GMainWindow::OnOpenRootDataFolder() { - QDesktopServices::openUrl(QUrl( - QString::fromStdString(Common::FS::GetEdenPathString(Common::FS::EdenPath::EdenDir)))); + QDesktopServices::openUrl( + QUrl(QString::fromStdString(Common::FS::GetEdenPathString(Common::FS::EdenPath::EdenDir)))); } -void GMainWindow::OnOpenNANDFolder() -{ +void GMainWindow::OnOpenNANDFolder() { QDesktopServices::openUrl(QUrl::fromLocalFile( - QString::fromStdString(Common::FS::GetEdenPathString(Common::FS::EdenPath::NANDDir)))); + QString::fromStdString(Common::FS::GetEdenPathString(Common::FS::EdenPath::NANDDir)))); } -void GMainWindow::OnOpenSDMCFolder() -{ +void GMainWindow::OnOpenSDMCFolder() { QDesktopServices::openUrl(QUrl::fromLocalFile( - QString::fromStdString(Common::FS::GetEdenPathString(Common::FS::EdenPath::SDMCDir)))); + QString::fromStdString(Common::FS::GetEdenPathString(Common::FS::EdenPath::SDMCDir)))); } -void GMainWindow::OnOpenModFolder() -{ +void GMainWindow::OnOpenModFolder() { QDesktopServices::openUrl(QUrl::fromLocalFile( - QString::fromStdString(Common::FS::GetEdenPathString(Common::FS::EdenPath::LoadDir)))); + QString::fromStdString(Common::FS::GetEdenPathString(Common::FS::EdenPath::LoadDir)))); } -void GMainWindow::OnOpenLogFolder() -{ +void GMainWindow::OnOpenLogFolder() { QDesktopServices::openUrl(QUrl::fromLocalFile( - QString::fromStdString(Common::FS::GetEdenPathString(Common::FS::EdenPath::LogDir)))); + QString::fromStdString(Common::FS::GetEdenPathString(Common::FS::EdenPath::LogDir)))); } void GMainWindow::OnVerifyInstalledContents() { @@ -4228,7 +4230,7 @@ void GMainWindow::OnVerifyInstalledContents() { }; const std::vector result = - ContentManager::VerifyInstalledContents(*system, *provider, QtProgressCallback); + ContentManager::VerifyInstalledContents(*system, *provider, QtProgressCallback); progress.close(); if (result.empty()) { @@ -4236,15 +4238,14 @@ void GMainWindow::OnVerifyInstalledContents() { tr("The operation completed successfully.")); } else { const auto failed_names = - QString::fromStdString(fmt::format("{}", fmt::join(result, "\n"))); + QString::fromStdString(fmt::format("{}", fmt::join(result, "\n"))); QMessageBox::critical( - this, tr("Integrity verification failed!"), - tr("Verification failed for the following files:\n\n%1").arg(failed_names)); + this, tr("Integrity verification failed!"), + tr("Verification failed for the following files:\n\n%1").arg(failed_names)); } } -void GMainWindow::InstallFirmware(const QString &location, bool recursive) -{ +void GMainWindow::InstallFirmware(const QString& location, bool recursive) { QProgressDialog progress(tr("Installing Firmware..."), tr("Cancel"), 0, 100, this); progress.setWindowModality(Qt::WindowModal); progress.setMinimumDuration(100); @@ -4270,20 +4271,22 @@ void GMainWindow::InstallFirmware(const QString &location, bool recursive) std::vector out; const Common::FS::DirEntryCallable callback = - [&out](const std::filesystem::directory_entry& entry) { - if (entry.path().has_extension() && entry.path().extension() == ".nca") { - out.emplace_back(entry.path()); - } + [&out](const std::filesystem::directory_entry& entry) { + if (entry.path().has_extension() && entry.path().extension() == ".nca") { + out.emplace_back(entry.path()); + } - return true; - }; + return true; + }; QtProgressCallback(100, 10); if (recursive) { - Common::FS::IterateDirEntriesRecursively(firmware_source_path, callback, Common::FS::DirEntryFilter::File); + Common::FS::IterateDirEntriesRecursively(firmware_source_path, callback, + Common::FS::DirEntryFilter::File); } else { - Common::FS::IterateDirEntries(firmware_source_path, callback, Common::FS::DirEntryFilter::File); + Common::FS::IterateDirEntries(firmware_source_path, callback, + Common::FS::DirEntryFilter::File); } if (out.size() <= 0) { @@ -4314,9 +4317,9 @@ void GMainWindow::InstallFirmware(const QString &location, bool recursive) for (const auto& firmware_src_path : out) { i++; auto firmware_src_vfile = - vfs->OpenFile(firmware_src_path.generic_string(), FileSys::OpenMode::Read); + vfs->OpenFile(firmware_src_path.generic_string(), FileSys::OpenMode::Read); auto firmware_dst_vfile = - firmware_vdir->CreateFileRelative(firmware_src_path.filename().string()); + firmware_vdir->CreateFileRelative(firmware_src_path.filename().string()); if (!VfsRawCopy(firmware_src_vfile, firmware_dst_vfile)) { LOG_ERROR(Frontend, "Failed to copy firmware file {} to {} in registered folder!", @@ -4325,12 +4328,12 @@ void GMainWindow::InstallFirmware(const QString &location, bool recursive) } if (QtProgressCallback( - 100, 20 + static_cast(((i) / static_cast(out.size())) * 70.0))) { + 100, 20 + static_cast(((i) / static_cast(out.size())) * 70.0))) { progress.close(); QMessageBox::warning( - this, tr("Firmware install failed"), - tr("Firmware installation cancelled, firmware may be in a bad state or corrupted. " - "Restart Eden or re-install firmware.")); + this, tr("Firmware install failed"), + tr("Firmware installation cancelled, firmware may be in a bad state or corrupted. " + "Restart Eden or re-install firmware.")); return; } } @@ -4351,15 +4354,15 @@ void GMainWindow::InstallFirmware(const QString &location, bool recursive) }; auto result = - ContentManager::VerifyInstalledContents(*system, *provider, VerifyFirmwareCallback, true); + ContentManager::VerifyInstalledContents(*system, *provider, VerifyFirmwareCallback, true); if (result.size() > 0) { const auto failed_names = - QString::fromStdString(fmt::format("{}", fmt::join(result, "\n"))); + QString::fromStdString(fmt::format("{}", fmt::join(result, "\n"))); progress.close(); QMessageBox::critical( - this, tr("Firmware integrity verification failed!"), - tr("Verification failed for the following files:\n\n%1").arg(failed_names)); + this, tr("Firmware integrity verification failed!"), + tr("Verification failed for the following files:\n\n%1").arg(failed_names)); return; } @@ -4377,13 +4380,13 @@ void GMainWindow::OnInstallFirmware() { // Check for installed keys, error out, suggest restart? if (!ContentManager::AreKeysPresent()) { QMessageBox::information( - this, tr("Keys not installed"), - tr("Install decryption keys and restart Eden before attempting to install firmware.")); + this, tr("Keys not installed"), + tr("Install decryption keys and restart Eden before attempting to install firmware.")); return; } const QString firmware_source_location = QFileDialog::getExistingDirectory( - this, tr("Select Dumped Firmware Source Location"), {}, QFileDialog::ShowDirsOnly); + this, tr("Select Dumped Firmware Source Location"), {}, QFileDialog::ShowDirsOnly); if (firmware_source_location.isEmpty()) { return; } @@ -4391,8 +4394,7 @@ void GMainWindow::OnInstallFirmware() { InstallFirmware(firmware_source_location); } -void GMainWindow::OnInstallFirmwareFromZIP() -{ +void GMainWindow::OnInstallFirmwareFromZIP() { // Don't do this while emulation is running, that'd probably be a bad idea. if (emu_thread != nullptr && emu_thread->IsRunning()) { return; @@ -4401,58 +4403,93 @@ void GMainWindow::OnInstallFirmwareFromZIP() // Check for installed keys, error out, suggest restart? if (!ContentManager::AreKeysPresent()) { QMessageBox::information( - this, tr("Keys not installed"), - tr("Install decryption keys and restart Eden before attempting to install firmware.")); + this, tr("Keys not installed"), + tr("Install decryption keys and restart Eden before attempting to install firmware.")); return; } const QString firmware_zip_location = QFileDialog::getOpenFileName( - this, tr("Select Dumped Firmware ZIP"), {}, tr("Zipped Archives (*.zip)")); + this, tr("Select Dumped Firmware ZIP"), {}, tr("Zipped Archives (*.zip)")); if (firmware_zip_location.isEmpty()) { return; } namespace fs = std::filesystem; - fs::path tmp{std::filesystem::temp_directory_path()}; - - if (!std::filesystem::create_directories(tmp / "eden" / "firmware")) { - goto unzipFailed; - } + fs::path tmp = std::filesystem::temp_directory_path() / "eden" / "firmware"; + QString cache_dir = QString::fromStdString(tmp.string()); { - tmp /= "eden"; - tmp /= "firmware"; - - QString qCacheDir = QString::fromStdString(tmp.string()); - - QFile zip(firmware_zip_location); - - QStringList result = JlCompress::extractDir(&zip, qCacheDir); - if (result.isEmpty()) { - goto unzipFailed; + if (!QDir().mkpath(cache_dir)) { + QMessageBox::critical( + this, tr("Firmware unzip failed"), + tr("Failed to create temp directory.\n" + "Check write permissions in the system temp directory and try again.")); + return; } + int err = 0; + zip_t* zip = zip_open(firmware_zip_location.toUtf8(), 0, &err); + if (zip == nullptr) { + QMessageBox::critical( + this, tr("Firmware unzip failed"), + tr("Failed to open the firmware zip file.\n" + "Check file format and avoid special characters in file path.")); + return; + } + + zip_int64_t num_entries = zip_get_num_entries(zip, 0); + for (zip_int64_t i = 0; i < num_entries; i++) { + const char* name = zip_get_name(zip, i, 0); + if (!name) { + continue; + } + + zip_file_t* zip_file = zip_fopen_index(zip, i, 0); + if (!zip_file) { + continue; + } + + QString file_path = QString::fromStdString(tmp / name); + QFileInfo file_info(file_path); + + QDir().mkpath(file_info.path()); + QFile file(file_path); + + if (!file.open(QIODevice::WriteOnly)) { + zip_fclose(zip_file); + continue; + } + + zip_stat_t sb; + zip_stat_index(zip, i, 0, &sb); + char* contents = new char[sb.size]; + zip_fread(zip_file, contents, sb.size); + file.write(contents, sb.size); + delete[] contents; + + file.close(); + zip_fclose(zip_file); + } + + zip_close(zip); + // In this case, it has to be done recursively, since sometimes people // will pack it into a subdirectory after dumping - InstallFirmware(qCacheDir, true); + InstallFirmware(cache_dir, true); std::error_code ec; std::filesystem::remove_all(tmp, ec); if (ec) { - QMessageBox::warning(this, tr("Firmware cleanup failed"), - tr("Failed to clean up extracted firmware cache.\n" - "Check write permissions in the system temp directory and try again.\nOS reported error: %1") + QMessageBox::warning(this, tr("Firmware cleanup failed"), + tr("Failed to clean up extracted firmware cache.\n" + "Check write permissions in the system temp directory and try " + "again.\nOS reported error: %1") .arg(QString::fromStdString(ec.message()))); } return; } -unzipFailed: - QMessageBox::critical(this, tr("Firmware unzip failed"), - tr("Check write permissions in the system temp directory and try again.")); - return; - } void GMainWindow::OnInstallDecryptionKeys() { @@ -4462,13 +4499,14 @@ void GMainWindow::OnInstallDecryptionKeys() { } const QString key_source_location = QFileDialog::getOpenFileName( - this, tr("Select Dumped Keys Location"), {}, QStringLiteral("Decryption Keys (*.keys)"), {}, - QFileDialog::ReadOnly); + this, tr("Select Dumped Keys Location"), {}, QStringLiteral("Decryption Keys (*.keys)"), {}, + QFileDialog::ReadOnly); if (key_source_location.isEmpty()) { return; } - FirmwareManager::KeyInstallResult result = FirmwareManager::InstallKeys(key_source_location.toStdString(), "keys"); + FirmwareManager::KeyInstallResult result = + FirmwareManager::InstallKeys(key_source_location.toStdString(), "keys"); system->GetFileSystemController().CreateFactories(*vfs); game_list->PopulateAsync(UISettings::values.game_dirs); @@ -4479,9 +4517,8 @@ void GMainWindow::OnInstallDecryptionKeys() { tr("Decryption Keys were successfully installed")); break; default: - QMessageBox::critical( - this, tr("Decryption Keys install failed"), - tr(FirmwareManager::GetKeyInstallResultString(result))); + QMessageBox::critical(this, tr("Decryption Keys install failed"), + tr(FirmwareManager::GetKeyInstallResultString(result))); break; } @@ -4507,8 +4544,7 @@ void GMainWindow::OnToggleStatusBar() { statusBar()->setVisible(ui->action_Show_Status_Bar->isChecked()); } -void GMainWindow::OnGameListRefresh() -{ +void GMainWindow::OnGameListRefresh() { // force reload add-ons etc game_list->ForceRefreshGameDirectory(); } @@ -4593,7 +4629,7 @@ void GMainWindow::OnOpenControllerMenu() { } auto controller_applet_nca = - bis_system->GetEntry(ControllerAppletId, FileSys::ContentRecordType::Program); + bis_system->GetEntry(ControllerAppletId, FileSys::ContentRecordType::Program); if (!controller_applet_nca) { QMessageBox::warning(this, tr("Controller Applet"), tr("Controller Menu is not available. Please reinstall firmware.")); @@ -4631,8 +4667,7 @@ void GMainWindow::OnHomeMenu() { BootGame(filename, LibraryAppletParameters(QLaunchId, Service::AM::AppletId::QLaunch)); } -void GMainWindow::OnInitialSetup() -{ +void GMainWindow::OnInitialSetup() { constexpr u64 Starter = static_cast(Service::AM::AppletProgramId::Starter); auto bis_system = system->GetFileSystemController().GetSystemNANDContents(); if (!bis_system) { @@ -4655,18 +4690,15 @@ void GMainWindow::OnInitialSetup() BootGame(filename, LibraryAppletParameters(Starter, Service::AM::AppletId::Starter)); } -void GMainWindow::OnCreateHomeMenuDesktopShortcut() -{ +void GMainWindow::OnCreateHomeMenuDesktopShortcut() { OnCreateHomeMenuShortcut(GameListShortcutTarget::Desktop); } -void GMainWindow::OnCreateHomeMenuApplicationMenuShortcut() -{ +void GMainWindow::OnCreateHomeMenuApplicationMenuShortcut() { OnCreateHomeMenuShortcut(GameListShortcutTarget::Applications); } -std::filesystem::path GMainWindow::GetEdenCommand() -{ +std::filesystem::path GMainWindow::GetEdenCommand() { std::filesystem::path command; QString appimage = QString::fromLocal8Bit(getenv("APPIMAGE")); @@ -4685,21 +4717,22 @@ std::filesystem::path GMainWindow::GetEdenCommand() return command; } -std::filesystem::path GMainWindow::GetShortcutPath(GameListShortcutTarget target) -{ +std::filesystem::path GMainWindow::GetShortcutPath(GameListShortcutTarget target) { std::filesystem::path shortcut_path{}; if (target == GameListShortcutTarget::Desktop) { shortcut_path = - QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).toStdString(); + QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).toStdString(); } else if (target == GameListShortcutTarget::Applications) { shortcut_path = - QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation).toStdString(); + QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation).toStdString(); } return shortcut_path; } -void GMainWindow::CreateShortcut(const std::string &game_path, const u64 program_id, const std::string& game_title_, GameListShortcutTarget target, std::string arguments_, const bool needs_title) { +void GMainWindow::CreateShortcut(const std::string& game_path, const u64 program_id, + const std::string& game_title_, GameListShortcutTarget target, + std::string arguments_, const bool needs_title) { // Get path to yuzu executable std::filesystem::path command = GetEdenCommand(); @@ -4708,17 +4741,17 @@ void GMainWindow::CreateShortcut(const std::string &game_path, const u64 program if (!std::filesystem::exists(shortcut_path)) { GMainWindow::CreateShortcutMessagesGUI( - this, GMainWindow::CREATE_SHORTCUT_MSGBOX_ERROR, - QString::fromStdString(shortcut_path.generic_string())); + this, GMainWindow::CREATE_SHORTCUT_MSGBOX_ERROR, + QString::fromStdString(shortcut_path.generic_string())); LOG_ERROR(Frontend, "Invalid shortcut target {}", shortcut_path.generic_string()); return; } const FileSys::PatchManager pm{program_id, system->GetFileSystemController(), - system->GetContentProvider()}; + system->GetContentProvider()}; const auto control = pm.GetControlMetadata(); const auto loader = - Loader::GetLoader(*system, vfs->OpenFile(game_path, FileSys::OpenMode::Read)); + Loader::GetLoader(*system, vfs->OpenFile(game_path, FileSys::OpenMode::Read)); std::string game_title{game_title_}; @@ -4750,7 +4783,7 @@ void GMainWindow::CreateShortcut(const std::string &game_path, const u64 program } QImage icon_data = - QImage::fromData(icon_image_file.data(), static_cast(icon_image_file.size())); + QImage::fromData(icon_image_file.data(), static_cast(icon_image_file.size())); std::filesystem::path out_icon_path; if (GMainWindow::MakeShortcutIcoPath(program_id, game_title, out_icon_path)) { if (!SaveIconToFile(out_icon_path, icon_data)) { @@ -4763,7 +4796,7 @@ void GMainWindow::CreateShortcut(const std::string &game_path, const u64 program // Warn once if we are making a shortcut to a volatile AppImage if (command.string().ends_with(".AppImage") && !UISettings::values.shortcut_already_warned) { if (!GMainWindow::CreateShortcutMessagesGUI( - this, GMainWindow::CREATE_SHORTCUT_MSGBOX_APPVOLATILE_WARNING, qgame_title)) { + this, GMainWindow::CREATE_SHORTCUT_MSGBOX_APPVOLATILE_WARNING, qgame_title)) { return; } UISettings::values.shortcut_already_warned = true; @@ -4773,15 +4806,15 @@ void GMainWindow::CreateShortcut(const std::string &game_path, const u64 program // Create shortcut std::string arguments{arguments_}; if (GMainWindow::CreateShortcutMessagesGUI( - this, GMainWindow::CREATE_SHORTCUT_MSGBOX_FULLSCREEN_YES, qgame_title)) { + this, GMainWindow::CREATE_SHORTCUT_MSGBOX_FULLSCREEN_YES, qgame_title)) { arguments = "-f " + arguments; } const std::string comment = fmt::format("Start {:s} with the eden Emulator", game_title); const std::string categories = "Game;Emulator;Qt;"; const std::string keywords = "Switch;Nintendo;"; - if (GMainWindow::CreateShortcutLink(shortcut_path, comment, out_icon_path, command, - arguments, categories, keywords, game_title)) { + if (GMainWindow::CreateShortcutLink(shortcut_path, comment, out_icon_path, command, arguments, + categories, keywords, game_title)) { GMainWindow::CreateShortcutMessagesGUI(this, GMainWindow::CREATE_SHORTCUT_MSGBOX_SUCCESS, qgame_title); return; @@ -4790,8 +4823,7 @@ void GMainWindow::CreateShortcut(const std::string &game_path, const u64 program qgame_title); } -void GMainWindow::OnCreateHomeMenuShortcut(GameListShortcutTarget target) -{ +void GMainWindow::OnCreateHomeMenuShortcut(GameListShortcutTarget target) { constexpr u64 QLaunchId = static_cast(Service::AM::AppletProgramId::QLaunch); auto bis_system = system->GetFileSystemController().GetSystemNANDContents(); if (!bis_system) { @@ -4820,13 +4852,13 @@ void GMainWindow::OnCaptureScreenshot() { const u64 title_id = system->GetApplicationProcessProgramID(); const auto screenshot_path = - QString::fromStdString(Common::FS::GetEdenPathString(Common::FS::EdenPath::ScreenshotsDir)); + QString::fromStdString(Common::FS::GetEdenPathString(Common::FS::EdenPath::ScreenshotsDir)); const auto date = - QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd_hh-mm-ss-zzz")); + QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd_hh-mm-ss-zzz")); QString filename = QStringLiteral("%1/%2_%3.png") - .arg(screenshot_path) - .arg(title_id, 16, 16, QLatin1Char{'0'}) - .arg(date); + .arg(screenshot_path) + .arg(title_id, 16, 16, QLatin1Char{'0'}) + .arg(date); if (!Common::FS::CreateDir(screenshot_path.toStdString())) { return; @@ -4850,7 +4882,7 @@ void GMainWindow::OnCaptureScreenshot() { void GMainWindow::MigrateConfigFiles() { const auto config_dir_fs_path = Common::FS::GetEdenPath(Common::FS::EdenPath::ConfigDir); const QDir config_dir = - QDir(QString::fromStdString(Common::FS::PathToUTF8String(config_dir_fs_path))); + QDir(QString::fromStdString(Common::FS::PathToUTF8String(config_dir_fs_path))); const QStringList config_dir_list = config_dir.entryList(QStringList(QStringLiteral("*.ini"))); if (!Common::FS::CreateDirs(config_dir_fs_path / "custom")) { @@ -4884,13 +4916,13 @@ void GMainWindow::OnEmulatorUpdateAvailable() { update_prompt.setIcon(QMessageBox::Information); update_prompt.addButton(QMessageBox::Yes); update_prompt.addButton(QMessageBox::Ignore); - update_prompt.setText(tr("Update %1 for Eden is available.\nWould you like to download it?") - .arg(version_string)); + update_prompt.setText( + tr("Update %1 for Eden is available.\nWould you like to download it?").arg(version_string)); update_prompt.exec(); if (update_prompt.button(QMessageBox::Yes) == update_prompt.clickedButton()) { QDesktopServices::openUrl( - QUrl(QString::fromStdString("https://github.com/eden-emulator/Releases/releases/tag/") + - version_string)); + QUrl(QString::fromStdString("https://github.com/eden-emulator/Releases/releases/tag/") + + version_string)); } } #endif @@ -4908,7 +4940,7 @@ void GMainWindow::UpdateWindowTitle(std::string_view title_name, std::string_vie } const auto override_title = - fmt::format(fmt::runtime(std::string(Common::g_title_bar_format_idle)), build_id); + fmt::format(fmt::runtime(std::string(Common::g_title_bar_format_idle)), build_id); const auto window_title = override_title.empty() ? yuzu_title : override_title; if (title_name.empty()) { @@ -4926,7 +4958,7 @@ void GMainWindow::UpdateWindowTitle(std::string_view title_name, std::string_vie } std::string GMainWindow::CreateTASFramesString( - std::array frames) const { + std::array frames) const { std::string string = ""; size_t maxPlayerIndex = 0; for (size_t i = 0; i < frames.size(); i++) { @@ -4947,14 +4979,14 @@ QString GMainWindow::GetTasStateDescription() const { switch (tas_status) { case InputCommon::TasInput::TasState::Running: return tr("TAS state: Running %1/%2") - .arg(current_tas_frame) - .arg(QString::fromStdString(tas_frames_string)); + .arg(current_tas_frame) + .arg(QString::fromStdString(tas_frames_string)); case InputCommon::TasInput::TasState::Recording: return tr("TAS state: Recording %1").arg(total_tas_frames[0]); case InputCommon::TasInput::TasState::Stopped: return tr("TAS state: Idle %1/%2") - .arg(current_tas_frame) - .arg(QString::fromStdString(tas_frames_string)); + .arg(current_tas_frame) + .arg(QString::fromStdString(tas_frames_string)); default: return tr("TAS State: Invalid"); } @@ -4965,7 +4997,7 @@ void GMainWindow::OnTasStateChanged() { bool is_recording = false; if (emulation_running) { const InputCommon::TasInput::TasState tas_status = - std::get<0>(input_subsystem->GetTas()->GetStatus()); + std::get<0>(input_subsystem->GetTas()->GetStatus()); is_running = tas_status == InputCommon::TasInput::TasState::Running; is_recording = tas_status == InputCommon::TasInput::TasState::Recording; } @@ -5004,18 +5036,19 @@ void GMainWindow::UpdateStatusBar() { const auto res_info = Settings::values.resolution_info; const auto res_scale = res_info.up_factor; res_scale_label->setText( - tr("Scale: %1x", "%1 is the resolution scaling factor").arg(res_scale)); + tr("Scale: %1x", "%1 is the resolution scaling factor").arg(res_scale)); if (Settings::values.use_speed_limit.GetValue()) { emu_speed_label->setText(tr("Speed: %1% / %2%") - .arg(results.emulation_speed * 100.0, 0, 'f', 0) - .arg(Settings::values.speed_limit.GetValue())); + .arg(results.emulation_speed * 100.0, 0, 'f', 0) + .arg(Settings::values.speed_limit.GetValue())); } else { emu_speed_label->setText(tr("Speed: %1%").arg(results.emulation_speed * 100.0, 0, 'f', 0)); } game_fps_label->setText( - tr("Game: %1 FPS").arg(std::round(results.average_game_fps), 0, 'f', 0) + tr(Settings::values.use_speed_limit ? "" : " (Unlocked)")); + tr("Game: %1 FPS").arg(std::round(results.average_game_fps), 0, 'f', 0) + + tr(Settings::values.use_speed_limit ? "" : " (Unlocked)")); emu_frametime_label->setText(tr("Frame: %1 ms").arg(results.frametime * 1000.0, 0, 'f', 2)); @@ -5029,7 +5062,7 @@ void GMainWindow::UpdateStatusBar() { void GMainWindow::UpdateGPUAccuracyButton() { const auto gpu_accuracy = Settings::values.gpu_accuracy.GetValue(); const auto gpu_accuracy_text = - ConfigurationShared::gpu_accuracy_texts_map.find(gpu_accuracy)->second; + ConfigurationShared::gpu_accuracy_texts_map.find(gpu_accuracy)->second; gpu_accuracy_button->setText(gpu_accuracy_text.toUpper()); gpu_accuracy_button->setChecked(gpu_accuracy != Settings::GpuAccuracy::Normal); } @@ -5038,20 +5071,20 @@ void GMainWindow::UpdateDockedButton() { const auto console_mode = Settings::values.use_docked_mode.GetValue(); dock_status_button->setChecked(Settings::IsDockedMode()); dock_status_button->setText( - ConfigurationShared::use_docked_mode_texts_map.find(console_mode)->second.toUpper()); + ConfigurationShared::use_docked_mode_texts_map.find(console_mode)->second.toUpper()); } void GMainWindow::UpdateAPIText() { const auto api = Settings::values.renderer_backend.GetValue(); const auto renderer_status_text = - ConfigurationShared::renderer_backend_texts_map.find(api)->second; + ConfigurationShared::renderer_backend_texts_map.find(api)->second; renderer_status_button->setText( - api == Settings::RendererBackend::OpenGL - ? tr("%1 %2").arg(renderer_status_text.toUpper(), - ConfigurationShared::shader_backend_texts_map + api == Settings::RendererBackend::OpenGL + ? tr("%1 %2").arg(renderer_status_text.toUpper(), + ConfigurationShared::shader_backend_texts_map .find(Settings::values.shader_backend.GetValue()) ->second) - : renderer_status_text.toUpper()); + : renderer_status_text.toUpper()); } void GMainWindow::UpdateFilterText() { @@ -5065,8 +5098,8 @@ void GMainWindow::UpdateAAText() { const auto aa_mode = Settings::values.anti_aliasing.GetValue(); const auto aa_text = ConfigurationShared::anti_aliasing_texts_map.find(aa_mode)->second; aa_status_button->setText(aa_mode == Settings::AntiAliasing::None - ? QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "NO AA")) - : aa_text.toUpper()); + ? QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "NO AA")) + : aa_text.toUpper()); } void GMainWindow::UpdateVolumeUI() { @@ -5142,25 +5175,22 @@ void GMainWindow::OnMouseActivity() { void GMainWindow::OnCheckFirmwareDecryption() { system->GetFileSystemController().CreateFactories(*vfs); if (!ContentManager::AreKeysPresent()) { - QMessageBox::warning( - this, tr("Derivation Components Missing"), - tr("Encryption keys are missing.")); + QMessageBox::warning(this, tr("Derivation Components Missing"), + tr("Encryption keys are missing.")); } SetFirmwareVersion(); UpdateMenuState(); } -void GMainWindow::OnCheckFirmware() -{ +void GMainWindow::OnCheckFirmware() { auto result = FirmwareManager::VerifyFirmware(*system.get()); switch (result) { - case FirmwareManager::FirmwareGood: + case FirmwareManager::FirmwareGood: break; default: - QMessageBox::warning( - this, tr("Firmware Read Error"), - tr(FirmwareManager::GetFirmwareCheckString(result))); + QMessageBox::warning(this, tr("Firmware Read Error"), + tr(FirmwareManager::GetFirmwareCheckString(result))); break; } } @@ -5197,11 +5227,11 @@ bool GMainWindow::SelectRomFSDumpTarget(const FileSys::ContentProvider& installe boost::container::flat_set available_title_ids; const auto RetrieveEntries = [&](FileSys::TitleType title_type, - FileSys::ContentRecordType record_type) { + FileSys::ContentRecordType record_type) { const auto entries = installed.ListEntriesFilter(title_type, record_type); for (const auto& entry : entries) { if (FileSys::GetBaseTitleID(entry.title_id) == program_id && - installed.GetEntry(entry)->GetStatus() == Loader::ResultStatus::Success) { + installed.GetEntry(entry)->GetStatus() == Loader::ResultStatus::Success) { available_title_ids.insert({entry.title_id, title_type, record_type}); } } @@ -5230,14 +5260,14 @@ bool GMainWindow::SelectRomFSDumpTarget(const FileSys::ContentProvider& installe list.push_back(QStringLiteral("Legal information [%1]").arg(hex_title_id)); } else { list.push_back( - QStringLiteral("DLC %1 [%2]").arg(title_id & 0x7FF).arg(hex_title_id)); + QStringLiteral("DLC %1 [%2]").arg(title_id & 0x7FF).arg(hex_title_id)); } } bool ok; const auto res = QInputDialog::getItem( - this, tr("Select RomFS Dump Target"), - tr("Please select which RomFS you would like to dump."), list, 0, false, &ok); + this, tr("Select RomFS Dump Target"), + tr("Please select which RomFS you would like to dump."), list, 0, false, &ok); if (!ok) { return false; } @@ -5253,11 +5283,11 @@ bool GMainWindow::SelectRomFSDumpTarget(const FileSys::ContentProvider& installe bool GMainWindow::ConfirmClose() { if (emu_thread == nullptr || - UISettings::values.confirm_before_stopping.GetValue() == ConfirmStop::Ask_Never) { + UISettings::values.confirm_before_stopping.GetValue() == ConfirmStop::Ask_Never) { return true; } if (!system->GetExitLocked() && - UISettings::values.confirm_before_stopping.GetValue() == ConfirmStop::Ask_Based_On_Game) { + UISettings::values.confirm_before_stopping.GetValue() == ConfirmStop::Ask_Based_On_Game) { return true; } const auto text = tr("Are you sure you want to close eden?"); @@ -5341,9 +5371,9 @@ bool GMainWindow::ConfirmChangeGame() { // Use custom question to link controller navigation return question( - this, tr("eden"), - tr("Are you sure you want to stop the emulation? Any unsaved progress will be lost."), - QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); + this, tr("eden"), + tr("Are you sure you want to stop the emulation? Any unsaved progress will be lost."), + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); } bool GMainWindow::ConfirmForceLockedExit() { @@ -5384,7 +5414,7 @@ static void AdjustLinkColor() { void GMainWindow::UpdateUITheme() { const QString default_theme = QString::fromUtf8( - UISettings::themes[static_cast(UISettings::default_theme)].second); + UISettings::themes[static_cast(UISettings::default_theme)].second); QString current_theme = QString::fromStdString(UISettings::values.theme); if (current_theme.isEmpty()) { @@ -5507,16 +5537,16 @@ void GMainWindow::changeEvent(QEvent* event) { Service::AM::FrontendAppletParameters GMainWindow::ApplicationAppletParameters() { return Service::AM::FrontendAppletParameters{ .applet_id = Service::AM::AppletId::Application, - .applet_type = Service::AM::AppletType::Application, + .applet_type = Service::AM::AppletType::Application, }; } Service::AM::FrontendAppletParameters GMainWindow::LibraryAppletParameters( - u64 program_id, Service::AM::AppletId applet_id) { + u64 program_id, Service::AM::AppletId applet_id) { return Service::AM::FrontendAppletParameters{ .program_id = program_id, - .applet_id = applet_id, - .applet_type = Service::AM::AppletType::LibraryApplet, + .applet_id = applet_id, + .applet_type = Service::AM::AppletType::LibraryApplet, }; } @@ -5529,10 +5559,10 @@ void VolumeButton::wheelEvent(QWheelEvent* event) { if (num_steps > 0) { Settings::values.volume.SetValue( - std::min(200, Settings::values.volume.GetValue() + num_steps)); + std::min(200, Settings::values.volume.GetValue() + num_steps)); } else { Settings::values.volume.SetValue( - std::max(0, Settings::values.volume.GetValue() + num_steps)); + std::max(0, Settings::values.volume.GetValue() + num_steps)); } scroll_multiplier = std::min(MaxMultiplier, scroll_multiplier * 2); @@ -5584,15 +5614,15 @@ static void SetHighDPIAttributes() { if (max_ratio > real_ratio) { QApplication::setHighDpiScaleFactorRoundingPolicy( - Qt::HighDpiScaleFactorRoundingPolicy::Round); + Qt::HighDpiScaleFactorRoundingPolicy::Round); } else { QApplication::setHighDpiScaleFactorRoundingPolicy( - Qt::HighDpiScaleFactorRoundingPolicy::Floor); + Qt::HighDpiScaleFactorRoundingPolicy::Floor); } #else // Other OSes should be better than Windows at fractional scaling. QApplication::setHighDpiScaleFactorRoundingPolicy( - Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); + Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); #endif }