diff --git a/CMakeLists.txt b/CMakeLists.txt index 82d99ca7bd..12eae712fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,24 +15,35 @@ project(citra LANGUAGES C CXX ASM) if (APPLE) enable_language(OBJC) + if (IOS) + # Enable searching CMAKE_PREFIX_PATH for bundled dependencies. + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) + endif() endif() option(ENABLE_LTO "Enable link time optimization" OFF) -option(ENABLE_SDL2 "Enable the SDL2 frontend" ON) +option(ENABLE_SDL2 "Enable using SDL2" ON) +CMAKE_DEPENDENT_OPTION(ENABLE_SDL2_FRONTEND "Enable the SDL2 frontend" ON "ENABLE_SDL2;NOT ANDROID AND NOT IOS" OFF) option(USE_SYSTEM_SDL2 "Use the system SDL2 lib (instead of the bundled one)" OFF) # Set bundled qt as dependent options. option(ENABLE_QT "Enable the Qt frontend" ON) option(ENABLE_QT_TRANSLATION "Enable translations for the Qt frontend" OFF) +CMAKE_DEPENDENT_OPTION(ENABLE_QT_UPDATER "Enable built-in updater for the Qt frontend" ON "NOT IOS" OFF) CMAKE_DEPENDENT_OPTION(CITRA_USE_BUNDLED_QT "Download bundled Qt binaries" ON "ENABLE_QT;MSVC OR APPLE" OFF) +CMAKE_DEPENDENT_OPTION(ENABLE_TESTS "Enable generating tests executable" ON "NOT IOS" OFF) +CMAKE_DEPENDENT_OPTION(ENABLE_DEDICATED_ROOM "Enable generating dedicated room executable" ON "NOT ANDROID AND NOT IOS" OFF) + option(ENABLE_WEB_SERVICE "Enable web services (telemetry, etc.)" ON) if (MSVC) set(OPENSSL_DLL_DIR "" CACHE PATH "Location of the Openssl dlls") endif() -option(ENABLE_CUBEB "Enables the cubeb audio backend" ON) +CMAKE_DEPENDENT_OPTION(ENABLE_CUBEB "Enables the cubeb audio backend" ON "NOT IOS" OFF) option(ENABLE_OPENAL "Enables the OpenAL audio backend" ON) CMAKE_DEPENDENT_OPTION(ENABLE_LIBUSB "Enable libusb for GameCube Adapter support" ON "NOT IOS" OFF) @@ -205,8 +216,7 @@ find_package(Threads REQUIRED) if (ENABLE_QT) if (CITRA_USE_BUNDLED_QT) - download_qt_external(6.5.0 QT_PREFIX) - list(APPEND CMAKE_PREFIX_PATH ${QT_PREFIX}) + download_qt_external(6.5.0) endif() find_package(Qt6 REQUIRED COMPONENTS Widgets Multimedia Concurrent) @@ -290,10 +300,14 @@ if (APPLE) find_library(MOLTENVK_LIBRARY MoltenVK REQUIRED) message(STATUS "Using MoltenVK at ${MOLTENVK_LIBRARY}.") - # Umbrella framework for everything GUI-related - find_library(COCOA_LIBRARY Cocoa REQUIRED) + if (NOT IOS) + # Umbrella framework for everything GUI-related + find_library(COCOA_LIBRARY Cocoa REQUIRED) + endif() + find_library(AVFOUNDATION_LIBRARY AVFoundation REQUIRED) - set(PLATFORM_LIBRARIES ${COCOA_LIBRARY} ${AVFOUNDATION_LIBRARY} ${MOLTENVK_LIBRARY}) + find_library(IOSURFACE_LIBRARY IOSurface REQUIRED) + set(PLATFORM_LIBRARIES ${COCOA_LIBRARY} ${AVFOUNDATION_LIBRARY} ${IOSURFACE_LIBRARY} ${MOLTENVK_LIBRARY}) elseif (WIN32) set(PLATFORM_LIBRARIES winmm ws2_32) if (MINGW) diff --git a/CMakeModules/DownloadExternals.cmake b/CMakeModules/DownloadExternals.cmake index 99bce5aeb9..ec9a524a7d 100644 --- a/CMakeModules/DownloadExternals.cmake +++ b/CMakeModules/DownloadExternals.cmake @@ -36,10 +36,11 @@ endfunction() # Params: # target: Qt dependency to install. Specify a version number to download Qt, or "tools_(name)" for a specific build tool. # prefix_var: Name of a variable which will be set with the path to the extracted contents. -function(download_qt_external target prefix_var) +function(download_qt_external target) # Determine installation parameters for OS, architecture, and compiler if (WIN32) set(host "windows") + set(type "desktop") if (MINGW) set(arch_path "mingw81") elseif ((MSVC_VERSION GREATER_EQUAL 1920 AND MSVC_VERSION LESS 1940) AND "x86_64" IN_LIST ARCHITECTURE) @@ -56,10 +57,19 @@ function(download_qt_external target prefix_var) set(arch "win64_${arch_path}") elseif (APPLE) set(host "mac") - set(arch "clang_64") - set(arch_path "macos") + if (IOS) + set(type "ios") + set(arch "ios") + set(arch_path "ios") + set(host_arch_path "macos") + else() + set(type "desktop") + set(arch "clang_64") + set(arch_path "macos") + endif() else() set(host "linux") + set(type "desktop") set(arch "gcc_64") set(arch_path "linux") endif() @@ -72,7 +82,11 @@ function(download_qt_external target prefix_var) set(install_args install-tool --outputdir ${base_path} ${host} desktop ${target}) else() set(prefix "${base_path}/${target}/${arch_path}") - set(install_args install-qt --outputdir ${base_path} ${host} desktop ${target} ${arch} -m qtmultimedia) + if (host_arch_path) + set(host_flag "--autodesktop") + set(host_prefix "${base_path}/${target}/${host_arch_path}") + endif() + set(install_args install-qt --outputdir ${base_path} ${host} ${type} ${target} ${arch} ${host_flag} -m qtmultimedia) endif() if (NOT EXISTS "${prefix}") @@ -97,7 +111,15 @@ function(download_qt_external target prefix_var) endif() message(STATUS "Using downloaded Qt binaries at ${prefix}") - set(${prefix_var} "${prefix}" PARENT_SCOPE) + + # Add the Qt prefix path so CMake can locate it. + list(APPEND CMAKE_PREFIX_PATH "${prefix}") + set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} PARENT_SCOPE) + + if (DEFINED host_prefix) + message(STATUS "Using downloaded host Qt binaries at ${host_prefix}") + set(QT_HOST_PATH "${host_prefix}" CACHE STRING "") + endif() endfunction() function(download_moltenvk) diff --git a/CMakeModules/GenerateBuildInfo.cmake b/CMakeModules/GenerateBuildInfo.cmake new file mode 100644 index 0000000000..4ef4725982 --- /dev/null +++ b/CMakeModules/GenerateBuildInfo.cmake @@ -0,0 +1,54 @@ +# Gets a UTC timstamp and sets the provided variable to it +function(get_timestamp _var) + string(TIMESTAMP timestamp UTC) + set(${_var} "${timestamp}" PARENT_SCOPE) +endfunction() + +list(APPEND CMAKE_MODULE_PATH "${SRC_DIR}/externals/cmake-modules") + +# Find the package here with the known path so that the GetGit commands can find it as well +find_package(Git QUIET PATHS "${GIT_EXECUTABLE}") + +# generate git/build information +include(GetGitRevisionDescription) +get_git_head_revision(GIT_REF_SPEC GIT_REV) +string(SUBSTRING "${GIT_REV}" 0 7 GIT_SHORT_REV) +git_describe(GIT_DESC --always --long --dirty) +git_branch_name(GIT_BRANCH) +get_timestamp(BUILD_DATE) + +# Generate cpp with Git revision from template +# Also if this is a CI build, add the build name (ie: Nightly, Canary) to the scm_rev file as well +set(REPO_NAME "") +set(BUILD_VERSION "0") +set(BUILD_FULLNAME "${GIT_SHORT_REV}") +if (DEFINED ENV{CI}) + if (DEFINED ENV{GITHUB_ACTIONS}) + set(BUILD_REPOSITORY $ENV{GITHUB_REPOSITORY}) + set(BUILD_TAG $ENV{GITHUB_REF_NAME}) + endif() + + # regex capture the string nightly or canary into CMAKE_MATCH_1 + string(REGEX MATCH "citra-emu/citra-?(.*)" OUTVAR ${BUILD_REPOSITORY}) + if ("${CMAKE_MATCH_COUNT}" GREATER 0) + # capitalize the first letter of each word in the repo name. + string(REPLACE "-" ";" REPO_NAME_LIST ${CMAKE_MATCH_1}) + foreach(WORD ${REPO_NAME_LIST}) + string(SUBSTRING ${WORD} 0 1 FIRST_LETTER) + string(SUBSTRING ${WORD} 1 -1 REMAINDER) + string(TOUPPER ${FIRST_LETTER} FIRST_LETTER) + set(REPO_NAME "${REPO_NAME}${FIRST_LETTER}${REMAINDER}") + endforeach() + string(REGEX MATCH "${CMAKE_MATCH_1}-([0-9]+)" OUTVAR ${BUILD_TAG}) + if (${CMAKE_MATCH_COUNT} GREATER 0) + set(BUILD_VERSION ${CMAKE_MATCH_1}) + endif() + if (BUILD_VERSION) + # This leaves a trailing space on the last word, but we actually want that + # because of how it's styled in the title bar. + set(BUILD_FULLNAME "${REPO_NAME} ${BUILD_VERSION} ") + else() + set(BUILD_FULLNAME "") + endif() + endif() +endif() diff --git a/CMakeModules/GenerateSCMRev.cmake b/CMakeModules/GenerateSCMRev.cmake index 2dc409881d..f0c8e7da63 100644 --- a/CMakeModules/GenerateSCMRev.cmake +++ b/CMakeModules/GenerateSCMRev.cmake @@ -1,55 +1,5 @@ -# Gets a UTC timstamp and sets the provided variable to it -function(get_timestamp _var) - string(TIMESTAMP timestamp UTC) - set(${_var} "${timestamp}" PARENT_SCOPE) -endfunction() - -list(APPEND CMAKE_MODULE_PATH "${SRC_DIR}/externals/cmake-modules") - -# Find the package here with the known path so that the GetGit commands can find it as well -find_package(Git QUIET PATHS "${GIT_EXECUTABLE}") - -# generate git/build information -include(GetGitRevisionDescription) -get_git_head_revision(GIT_REF_SPEC GIT_REV) -git_describe(GIT_DESC --always --long --dirty) -git_branch_name(GIT_BRANCH) -get_timestamp(BUILD_DATE) - -# Generate cpp with Git revision from template -# Also if this is a CI build, add the build name (ie: Nightly, Canary) to the scm_rev file as well -set(REPO_NAME "") -set(BUILD_VERSION "0") -if (DEFINED ENV{CI}) - if (DEFINED ENV{GITHUB_ACTIONS}) - set(BUILD_REPOSITORY $ENV{GITHUB_REPOSITORY}) - set(BUILD_TAG $ENV{GITHUB_REF_NAME}) - endif() - - # regex capture the string nightly or canary into CMAKE_MATCH_1 - string(REGEX MATCH "citra-emu/citra-?(.*)" OUTVAR ${BUILD_REPOSITORY}) - if ("${CMAKE_MATCH_COUNT}" GREATER 0) - # capitalize the first letter of each word in the repo name. - string(REPLACE "-" ";" REPO_NAME_LIST ${CMAKE_MATCH_1}) - foreach(WORD ${REPO_NAME_LIST}) - string(SUBSTRING ${WORD} 0 1 FIRST_LETTER) - string(SUBSTRING ${WORD} 1 -1 REMAINDER) - string(TOUPPER ${FIRST_LETTER} FIRST_LETTER) - set(REPO_NAME "${REPO_NAME}${FIRST_LETTER}${REMAINDER}") - endforeach() - string(REGEX MATCH "${CMAKE_MATCH_1}-([0-9]+)" OUTVAR ${BUILD_TAG}) - if (${CMAKE_MATCH_COUNT} GREATER 0) - set(BUILD_VERSION ${CMAKE_MATCH_1}) - endif() - if (BUILD_VERSION) - # This leaves a trailing space on the last word, but we actually want that - # because of how it's styled in the title bar. - set(BUILD_FULLNAME "${REPO_NAME} ${BUILD_VERSION} ") - else() - set(BUILD_FULLNAME "") - endif() - endif() -endif() +list(APPEND CMAKE_MODULE_PATH "${SRC_DIR}/CMakeModules") +include(GenerateBuildInfo) # The variable SRC_DIR must be passed into the script (since it uses the current build directory for all values of CMAKE_*_DIR) set(VIDEO_CORE "${SRC_DIR}/src/video_core") diff --git a/src/citra_qt/Info.plist b/dist/apple/Info.plist.in similarity index 65% rename from src/citra_qt/Info.plist rename to dist/apple/Info.plist.in index 5ab69f3d04..7eb5809257 100644 --- a/src/citra_qt/Info.plist +++ b/dist/apple/Info.plist.in @@ -2,45 +2,49 @@ - CFBundleDevelopmentRegion - English - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleGetInfoString - - CFBundleIconFile - citra.icns - CFBundleIdentifier - com.citra-emu.citra - CFBundleInfoDictionaryVersion - 6.0 - CFBundleLongVersionString - + CFBundleName - Citra - CFBundlePackageType - APPL - CFBundleShortVersionString - - CFBundleSignature - ???? + ${MACOSX_BUNDLE_BUNDLE_NAME} + CFBundleIdentifier + ${MACOSX_BUNDLE_GUI_IDENTIFIER} CFBundleVersion - - CSResourcesFileMapped - - LSRequiresCarbon - + ${MACOSX_BUNDLE_BUNDLE_VERSION} + CFBundleShortVersionString + ${MACOSX_BUNDLE_SHORT_VERSION_STRING} + CFBundleLongVersionString + ${MACOSX_BUNDLE_LONG_VERSION_STRING} + CFBundleExecutable + ${MACOSX_BUNDLE_EXECUTABLE_NAME} + CFBundleIconFile + ${MACOSX_BUNDLE_ICON_FILE} + CFBundleGetInfoString + ${MACOSX_BUNDLE_INFO_STRING} NSHumanReadableCopyright - - NSPrincipalClass - NSApplication - NSHighResolutionCapable - True + ${MACOSX_BUNDLE_COPYRIGHT} + + LSApplicationCategoryType + public.app-category.games NSCameraUsageDescription This app requires camera access to emulate the 3DS's cameras. NSMicrophoneUsageDescription This app requires microphone access to emulate the 3DS's microphone. - LSApplicationCategoryType - public.app-category.games + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + CFBundleDevelopmentRegion + English + CFBundleSignature + ???? + CSResourcesFileMapped + + LSSupportsOpeningDocumentsInPlace + + NSHighResolutionCapable + True + UIFileSharingEnabled + + UILaunchStoryboardName + LaunchScreen diff --git a/dist/apple/LaunchScreen.storyboard b/dist/apple/LaunchScreen.storyboard new file mode 100644 index 0000000000..56829a36f4 --- /dev/null +++ b/dist/apple/LaunchScreen.storyboard @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dist/citra.icns b/dist/apple/citra.icns similarity index 100% rename from dist/citra.icns rename to dist/apple/citra.icns diff --git a/dist/apple/launch_logo.png b/dist/apple/launch_logo.png new file mode 100644 index 0000000000..5217a1c27b Binary files /dev/null and b/dist/apple/launch_logo.png differ diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 90ba2f5685..e744dac8c3 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -148,6 +148,7 @@ target_include_directories(enet INTERFACE ./enet/include) # Cubeb if (ENABLE_CUBEB) set(BUILD_TESTS OFF CACHE BOOL "") + set(BUILD_TOOLS OFF CACHE BOOL "") add_subdirectory(cubeb EXCLUDE_FROM_ALL) endif() diff --git a/externals/libressl b/externals/libressl index 8929f818fd..dcf9a84aba 160000 --- a/externals/libressl +++ b/externals/libressl @@ -1 +1 @@ -Subproject commit 8929f818fd748fd31a34fec7c04558399e13014a +Subproject commit dcf9a84aba598f827f65d946d31c3c93af62790a diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9f976eedf7..f05f35ff0c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -143,9 +143,12 @@ add_subdirectory(video_core) add_subdirectory(audio_core) add_subdirectory(network) add_subdirectory(input_common) -add_subdirectory(tests) -if (ENABLE_SDL2) +if (ENABLE_TESTS) + add_subdirectory(tests) +endif() + +if (ENABLE_SDL2 AND ENABLE_SDL2_FRONTEND) add_subdirectory(citra) endif() @@ -153,11 +156,13 @@ if (ENABLE_QT) add_subdirectory(citra_qt) endif() +if (ENABLE_DEDICATED_ROOM) + add_subdirectory(dedicated_room) +endif() + if (ANDROID) add_subdirectory(android/app/src/main/jni) target_include_directories(citra-android PRIVATE android/app/src/main) -else() - add_subdirectory(dedicated_room) endif() if (ENABLE_WEB_SERVICE) diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index eebcca567e..18802c957b 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt @@ -8,7 +8,6 @@ if (POLICY CMP0071) endif() add_executable(citra-qt - Info.plist aboutdialog.cpp aboutdialog.h aboutdialog.ui @@ -169,9 +168,6 @@ add_executable(citra-qt uisettings.h qt_image_interface.cpp qt_image_interface.h - updater/updater.cpp - updater/updater.h - updater/updater_p.h util/clickable_label.cpp util/clickable_label.h util/sequence_dialog/sequence_dialog.cpp @@ -202,6 +198,15 @@ file(GLOB COMPAT_LIST file(GLOB_RECURSE ICONS ${PROJECT_SOURCE_DIR}/dist/icons/*) file(GLOB_RECURSE THEMES ${PROJECT_SOURCE_DIR}/dist/qt_themes/*) +if (ENABLE_QT_UPDATER) + target_sources(citra-qt PRIVATE + updater/updater.cpp + updater/updater.h + updater/updater_p.h + ) + target_compile_definitions(citra-qt PUBLIC ENABLE_QT_UPDATER) +endif() + if (ENABLE_QT_TRANSLATION) set(CITRA_QT_LANGUAGES "${PROJECT_SOURCE_DIR}/dist/languages" CACHE PATH "Path to the translation bundle for the Qt frontend") option(GENERATE_QT_TRANSLATION "Generate en.ts as the translation source file" OFF) @@ -248,17 +253,43 @@ target_sources(citra-qt ) if (APPLE) - set(MACOSX_ICON "../../dist/citra.icns") - set_source_files_properties(${MACOSX_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) + set(DIST_DIR "../../dist/apple") + set(APPLE_RESOURCES + "${DIST_DIR}/citra.icns" + "${DIST_DIR}/LaunchScreen.storyboard" + "${DIST_DIR}/launch_logo.png" + ) + target_sources(citra-qt PRIVATE - ${MACOSX_ICON} + ${APPLE_RESOURCES} macos_authorization.h macos_authorization.mm ) + + # Define app bundle metadata. + include(GenerateBuildInfo) set_target_properties(citra-qt PROPERTIES MACOSX_BUNDLE TRUE - MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist + MACOSX_BUNDLE_INFO_PLIST "${DIST_DIR}/Info.plist.in" + MACOSX_BUNDLE_BUNDLE_NAME "Citra" + MACOSX_BUNDLE_GUI_IDENTIFIER "com.citra-emu.citra" + MACOSX_BUNDLE_BUNDLE_VERSION "${BUILD_VERSION}" + MACOSX_BUNDLE_SHORT_VERSION_STRING "${BUILD_FULLNAME}" + MACOSX_BUNDLE_LONG_VERSION_STRING "${BUILD_FULLNAME}" + MACOSX_BUNDLE_ICON_FILE "citra.icns" + RESOURCE "${APPLE_RESOURCES}" ) + + if (IOS) + set_target_properties(citra-qt PROPERTIES + # Have Xcode copy and sign MoltenVK into app bundle. + XCODE_EMBED_FRAMEWORKS "${MOLTENVK_LIBRARY}" + XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY YES + XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/Frameworks" + # Support iPhone and iPad. + XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2" + ) + endif() elseif(WIN32) # compile as a win32 gui application instead of a console application target_link_libraries(citra-qt PRIVATE Qt6::EntryPointImplementation) diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index e99bfa42a5..e4f1e671b5 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -364,7 +364,7 @@ static Frontend::WindowSystemType GetWindowSystemType() { return Frontend::WindowSystemType::X11; else if (platform_name == QStringLiteral("wayland")) return Frontend::WindowSystemType::Wayland; - else if (platform_name == QStringLiteral("cocoa")) + else if (platform_name == QStringLiteral("cocoa") || platform_name == QStringLiteral("ios")) return Frontend::WindowSystemType::MacOS; LOG_CRITICAL(Frontend, "Unknown Qt platform!"); diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index c9d26ebc3f..5b218c6d42 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -223,7 +223,12 @@ GMainWindow::GMainWindow(Core::System& system_) InitializeRecentFileMenuActions(); InitializeSaveStateMenuActions(); InitializeHotkeys(); +#if ENABLE_QT_UPDATER ShowUpdaterWidgets(); +#else + ui->action_Check_For_Updates->setVisible(false); + ui->action_Open_Maintenance_Tool->setVisible(false); +#endif SetDefaultUIGeometry(); RestoreUIState(); @@ -268,9 +273,11 @@ GMainWindow::GMainWindow(Core::System& system_) connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor); connect(ui->menubar, &QMenuBar::hovered, this, &GMainWindow::OnMouseActivity); +#if ENABLE_QT_UPDATER if (UISettings::values.check_for_update_on_start) { CheckForUpdates(); } +#endif QStringList args = QApplication::arguments(); if (args.length() >= 2) { @@ -322,9 +329,11 @@ void GMainWindow::InitializeWidgets() { ui->action_Show_Room); multiplayer_state->setVisible(false); +#if ENABLE_QT_UPDATER // Setup updater updater = new Updater(this); UISettings::values.updater_found = updater->HasUpdater(); +#endif UpdateBootHomeMenuState(); @@ -655,13 +664,6 @@ void GMainWindow::InitializeHotkeys() { }); } -void GMainWindow::ShowUpdaterWidgets() { - ui->action_Check_For_Updates->setVisible(UISettings::values.updater_found); - ui->action_Open_Maintenance_Tool->setVisible(UISettings::values.updater_found); - - connect(updater, &Updater::CheckUpdatesDone, this, &GMainWindow::OnUpdateFound); -} - void GMainWindow::SetDefaultUIGeometry() { // geometry: 55% of the window contents are in the upper screen half, 45% in the lower half const QRect screenRect = screen()->geometry(); @@ -851,8 +853,11 @@ void GMainWindow::ConnectMenuEvents() { QDesktopServices::openUrl(QUrl(QStringLiteral("https://citra-emu.org/wiki/faq/"))); }); connect_menu(ui->action_About, &GMainWindow::OnMenuAboutCitra); + +#if ENABLE_QT_UPDATER connect_menu(ui->action_Check_For_Updates, &GMainWindow::OnCheckForUpdates); connect_menu(ui->action_Open_Maintenance_Tool, &GMainWindow::OnOpenUpdater); +#endif } void GMainWindow::UpdateMenuState() { @@ -904,6 +909,7 @@ void GMainWindow::OnDisplayTitleBars(bool show) { } } +#if ENABLE_QT_UPDATER void GMainWindow::OnCheckForUpdates() { explicit_update_check = true; CheckForUpdates(); @@ -970,6 +976,14 @@ void GMainWindow::OnOpenUpdater() { updater->LaunchUI(); } +void GMainWindow::ShowUpdaterWidgets() { + ui->action_Check_For_Updates->setVisible(UISettings::values.updater_found); + ui->action_Open_Maintenance_Tool->setVisible(UISettings::values.updater_found); + + connect(updater, &Updater::CheckUpdatesDone, this, &GMainWindow::OnUpdateFound); +} +#endif + #if defined(__unix__) && !defined(__APPLE__) static std::optional HoldWakeLockLinux(u32 window_id = 0) { if (!QDBusConnection::sessionBus().isConnected()) { @@ -1327,9 +1341,11 @@ void GMainWindow::ShutdownGame() { emulation_running = false; +#if ENABLE_QT_UDPATER if (defer_update_prompt) { ShowUpdatePrompt(); } +#endif game_title.clear(); UpdateWindowTitle(); diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h index ddc242543f..03b9f54a76 100644 --- a/src/citra_qt/main.h +++ b/src/citra_qt/main.h @@ -46,7 +46,9 @@ class QProgressBar; class QPushButton; class QSlider; class RegistersWidget; +#if ENABLE_QT_UPDATER class Updater; +#endif class WaitTreeWidget; namespace Camera { @@ -146,12 +148,15 @@ private: void ShutdownGame(); void ShowTelemetryCallout(); + void SetDiscordEnabled(bool state); + void LoadAmiibo(const QString& filename); + +#if ENABLE_QT_UPDATER void ShowUpdaterWidgets(); void ShowUpdatePrompt(); void ShowNoUpdatePrompt(); void CheckForUpdates(); - void SetDiscordEnabled(bool state); - void LoadAmiibo(const QString& filename); +#endif /** * Stores the filename in the recently loaded files list. @@ -244,9 +249,13 @@ private slots: void OnCoreError(Core::System::ResultStatus, std::string); /// Called whenever a user selects Help->About Citra void OnMenuAboutCitra(); + +#if ENABLE_QT_UPDATER void OnUpdateFound(bool found, bool error); void OnCheckForUpdates(); void OnOpenUpdater(); +#endif + void OnLanguageChanged(const QString& locale); void OnMouseActivity(); @@ -326,7 +335,9 @@ private: IPCRecorderWidget* ipcRecorderWidget; LLEServiceModulesWidget* lleServiceModulesWidget; WaitTreeWidget* waitTreeWidget; +#if ENABLE_QT_UPDATER Updater* updater; +#endif bool explicit_update_check = false; bool defer_update_prompt = false; diff --git a/src/common/common_paths.h b/src/common/common_paths.h index 6fe585fad3..da9c04f2f1 100644 --- a/src/common/common_paths.h +++ b/src/common/common_paths.h @@ -21,7 +21,12 @@ #ifdef _WIN32 #define EMU_DATA_DIR "Citra" #elif defined(__APPLE__) -#define MACOS_EMU_DATA_DIR "Library" DIR_SEP "Application Support" DIR_SEP "Citra" +#include +#if TARGET_OS_IPHONE +#define APPLE_EMU_DATA_DIR "Documents" DIR_SEP "Citra" +#else +#define APPLE_EMU_DATA_DIR "Library" DIR_SEP "Application Support" DIR_SEP "Citra" +#endif // For compatibility with XDG paths. #define EMU_DATA_DIR "citra-emu" #else diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index da4bcd6e03..af88a5e7b0 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -786,7 +786,7 @@ void SetUserPath(const std::string& path) { // paths. if (!FileUtil::Exists(data_dir) && !FileUtil::Exists(config_dir) && !FileUtil::Exists(cache_dir)) { - data_dir = GetHomeDirectory() + DIR_SEP MACOS_EMU_DATA_DIR DIR_SEP; + data_dir = GetHomeDirectory() + DIR_SEP APPLE_EMU_DATA_DIR DIR_SEP; config_dir = data_dir + CONFIG_DIR DIR_SEP; cache_dir = data_dir + CACHE_DIR DIR_SEP; }