Compare commits
467 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b1d4804c07 | |||
| 91290b9be4 | |||
| 820f113d9e | |||
| 373a1ff2ce | |||
| 4d6b6ba76c | |||
| 4aa713e861 | |||
| 9e9aed41be | |||
| 3d268b8480 | |||
| ad7445d4cc | |||
| 3a30271219 | |||
| bb5196aaae | |||
| d3070cafa7 | |||
| 5cd3b6f58c | |||
| bedc758fe7 | |||
| 76701185ad | |||
| f1cb14eb54 | |||
| f4f4a469a9 | |||
| 9e5b4052ed | |||
| 234867b84d | |||
| 61e8c5f798 | |||
| 4b60aec190 | |||
| ecfba79d98 | |||
| 310834aea2 | |||
| 6a1fa9bb17 | |||
| db8a601cf8 | |||
| 1bb76201e6 | |||
| 372bca5945 | |||
| 93c19a40bf | |||
| d0a75580da | |||
| 345ec25532 | |||
| a94721fde0 | |||
| 816c7a8d1f | |||
| efe52db690 | |||
| d61df0f400 | |||
| b14547b8b6 | |||
| 97ad3e7530 | |||
| 0589a32f75 | |||
| 617dc0f822 | |||
| fcfa8b680b | |||
| 94244437de | |||
| 53956a2990 | |||
| a7731abb72 | |||
| 50fd029eaa | |||
| a2b567dfd6 | |||
| b770f6a985 | |||
| 797e8fdbc3 | |||
| b8c5027686 | |||
| 65e646eeba | |||
| fba3fa705d | |||
| 09e8fb75ce | |||
| 6ca530a721 | |||
| e01c535178 | |||
| 7239547ead | |||
| 7fc06260d1 | |||
| e357896674 | |||
| 225f4f40cb | |||
| 927be75616 | |||
| 00965e6c34 | |||
| 4bf1f217ae | |||
| fcc85abe27 | |||
| 6851e93296 | |||
| 67660972c9 | |||
| ffbba74c91 | |||
| 2b0cf73bf0 | |||
| a093f3d47a | |||
| 4f600f746a | |||
| 360418f1a1 | |||
| 3bc7575c47 | |||
| fde8dc1652 | |||
| b8f83aa4bf | |||
| 85b1e17df6 | |||
| 4144c517a5 | |||
| 8ad5f2c506 | |||
| 2a3f84aaf2 | |||
| 030e6b3980 | |||
| e8ad603cd9 | |||
| b560ade663 | |||
| d10464de30 | |||
| 64f68e9635 | |||
| 462ba1b360 | |||
| 4a86a55174 | |||
| 86d26914a2 | |||
| 6ae4177b25 | |||
| f6bf8b3ed3 | |||
| 345fb6b226 | |||
| 87a9dc9489 | |||
| 6c6e8b8de0 | |||
| 5acffe75df | |||
| ac222ceba2 | |||
| f9d4827102 | |||
| 7ea7c72dde | |||
| 809230f634 | |||
| 698c854d5b | |||
| ca5b135ddf | |||
| dbddc627d4 | |||
| 62fc386bb4 | |||
| f2eb3c579f | |||
| 2fce812026 | |||
| e975f3cde9 | |||
| 6b5fb2063f | |||
| 70c3d36536 | |||
| d590cfb9d0 | |||
| ded419ef2b | |||
| 4c3f898789 | |||
| 46c259bb20 | |||
| adc3079613 | |||
| 15bebf1695 | |||
| 5c840334b8 | |||
| a05c242429 | |||
| bd59934350 | |||
| 11b123ba01 | |||
| 24e7ace876 | |||
| 62586c1676 | |||
| 108737fcc6 | |||
| abfebe5cc4 | |||
| a22a025c5b | |||
| a529ef4c09 | |||
| 875568bb3e | |||
| 988e557ec8 | |||
| 6d2af32f29 | |||
| 8f9d5c3143 | |||
| dc0fb56f3a | |||
| 7ba4a8f4a3 | |||
| 8ef1fdafa2 | |||
| d597383ab2 | |||
| 5feda37688 | |||
| 34e4012998 | |||
| c1924951ad | |||
| 5646e313a0 | |||
| f447996080 | |||
| 42b34a0dc5 | |||
| fe5e4bd846 | |||
| a53cd2854e | |||
| 1d731dd1ff | |||
| 8225ac004e | |||
| 52e6b8a2d3 | |||
| 13131e602f | |||
| 7761f29892 | |||
| e92b10f971 | |||
| 9268f265a1 | |||
| e445ef9d60 | |||
| 40bb176c39 | |||
| 8a79dd2d6c | |||
| d5de9402ee | |||
| 4cd3f9f4f9 | |||
| 167efb2d2b | |||
| 8e0e066c3f | |||
| f0ee3e29cb | |||
| 5d4da07943 | |||
| 45c87c7e6e | |||
| 90e87c40e8 | |||
| 6b7dc587cf | |||
| f05cb69d4f | |||
| 382cf087a0 | |||
| 0751488727 | |||
| 4bc932261b | |||
| 5fb1a83e4c | |||
| 6da8301773 | |||
| fedeff7a89 | |||
| 9de99839bd | |||
| 69529a748c | |||
| 0ed292568f | |||
| 7fb6fbcd87 | |||
| 82ac3003a6 | |||
| 45b6161582 | |||
| 345ea568ba | |||
| 08be9cff0f | |||
| e9a43bae6f | |||
| 01d3e250ab | |||
| 270d290e65 | |||
| d74dd4faf9 | |||
| e40a2d2fd2 | |||
| f6fdacd935 | |||
| 1c21d6c2c2 | |||
| 7dd78e8dcc | |||
| e7dd968ac4 | |||
| 3c45ba1c22 | |||
| d2bb9e9729 | |||
| 127bfb81d5 | |||
| 3a12fe5d13 | |||
| 5345ab40eb | |||
| 57a391e71d | |||
| 8f62e8e63f | |||
| df96caec79 | |||
| 4a3abba16d | |||
| d21305c2e7 | |||
| 9dc9aaf4af | |||
| 5eec980a2d | |||
| aded28f276 | |||
| 80c4743754 | |||
| 498159d719 | |||
| 91ad6b7098 | |||
| df49795bcb | |||
| 337e37f91d | |||
| 992ca8c358 | |||
| 340548aba7 | |||
| 7dddf5cb3c | |||
| b8f66c9412 | |||
| fd29227bc4 | |||
| e21f96ffde | |||
| c7649a0cdb | |||
| 5a96c525e3 | |||
| db1d32485e | |||
| 1d11fe00a3 | |||
| a76a8fb5fe | |||
| 7c1cb5e8c9 | |||
| 15f35b8657 | |||
| 7482e03c77 | |||
| f21340f7aa | |||
| e0c894408a | |||
| 257a1c884d | |||
| c100d7e802 | |||
| 281eb020ea | |||
| 4ce6762945 | |||
| fe3702223f | |||
| 83aa66b17d | |||
| 8d7a55be5b | |||
| de58618421 | |||
| e6847c65a8 | |||
| ac11f6e4c5 | |||
| 40644d43f7 | |||
| dfa56765d6 | |||
| b5bde8451c | |||
| 090ea0281c | |||
| bc4818b058 | |||
| 2993d3bb49 | |||
| 6432508740 | |||
| 5a9ffa81a6 | |||
| 9ff8d0f3e6 | |||
| d040b27a35 | |||
| cf534f5149 | |||
| 20de0ddf1f | |||
| 1cde01c8c8 | |||
| f542a3bb7a | |||
| 3ec3cca4d8 | |||
| c37b5f431f | |||
| 263b7a44f9 | |||
| 6de2edcca1 | |||
| 8fab363237 | |||
| 9f91ba1f73 | |||
| 4838837620 | |||
| 2e02efbdd0 | |||
| 15331c2a60 | |||
| f2a8409083 | |||
| 5938a9582a | |||
| 4766baddf3 | |||
| 448d4815de | |||
| 29e7d79a86 | |||
| 20011dfeb8 | |||
| 5a182f4e7c | |||
| f61cf14646 | |||
| 2d4e7c8264 | |||
| dee792937f | |||
| 4a278b69b1 | |||
| 02a0b41a15 | |||
| 093eb075a6 | |||
| 0b766e4523 | |||
| 453fd47030 | |||
| dda187d300 | |||
| 0b8218d8eb | |||
| 91c12db070 | |||
| d8f380961e | |||
| b088a448cd | |||
| c4f6c3b00b | |||
| 1654b8f9e0 | |||
| 14398a1cbb | |||
| cddb28cf26 | |||
| 538e137bca | |||
| e69118042f | |||
| a6b8d85b34 | |||
| f3fe362c93 | |||
| eedecaef96 | |||
| e637ec0c38 | |||
| e744c06f61 | |||
| ac522db857 | |||
| aa20311969 | |||
| da14c7b8e4 | |||
| e7878e3cf8 | |||
| cff2d0e19e | |||
| 8da5bd27e9 | |||
| 0216aa55b4 | |||
| 0298c2cc5d | |||
| 00dcf69ce8 | |||
| 1ea0890a36 | |||
| a77feca086 | |||
| 99a8f7fb72 | |||
| 8ae26df15c | |||
| 82a4a67f6b | |||
| a595ed499d | |||
| 8e93a9a9ef | |||
| 23c1f7c72f | |||
| d3ed771f39 | |||
| 12fba361bd | |||
| 6bcde572dd | |||
| cb004d1ba1 | |||
| 20a17607ae | |||
| 473caaff5b | |||
| 787552f832 | |||
| 5f945e2fcd | |||
| c08da2d6ad | |||
| 4458920799 | |||
| 61fed8a3a6 | |||
| efb3165e3d | |||
| a493ba76b4 | |||
| ae60a5657e | |||
| feb60de5c3 | |||
| c67644f1da | |||
| 9343b81afd | |||
| 71f53b4218 | |||
| f131b0faeb | |||
| 6c64d5aff2 | |||
| de594995da | |||
| 4c16a1a26f | |||
| 862e66202c | |||
| 4055a476aa | |||
| 2136a46ab7 | |||
| b9c7e5c2c8 | |||
| d86e88a622 | |||
| 7eac28e410 | |||
| ea4c92f734 | |||
| c9cd938dfd | |||
| 4c5e3d5f7a | |||
| e2be180136 | |||
| c9437e5244 | |||
| 24548b1f5c | |||
| be0ecae108 | |||
| fcd54c6479 | |||
| 08296f151e | |||
| a134e924ff | |||
| 31ed6bae11 | |||
| 9a5ef835cc | |||
| df0d3698ae | |||
| 51fc608f68 | |||
| b30e19ba24 | |||
| ec6b67d862 | |||
| 4d0b7f8496 | |||
| e3b510a4b4 | |||
| 247d66a680 | |||
| 0047d8a01e | |||
| efc0187537 | |||
| b6fe8a0b3f | |||
| ecaa038b4d | |||
| 4aac971864 | |||
| 6c93cdffb1 | |||
| 470714e2d1 | |||
| 6b888b0fa8 | |||
| 1a1393dad7 | |||
| 55412962c0 | |||
| 50bcfa5fb9 | |||
| efc50485b8 | |||
| d920da2631 | |||
| ff72bf2cb2 | |||
| 4efb9763d9 | |||
| c600bc8652 | |||
| f1806d237f | |||
| ae57a99d7d | |||
| 767c4b5a99 | |||
| 904d03b01f | |||
| 9f1c9599a2 | |||
| 5f6666a7cd | |||
| 1906e2724f | |||
| 0c032d3f2f | |||
| a6735cba5f | |||
| 3b872b89d1 | |||
| 40d4e9543b | |||
| e588f341ed | |||
| 875246f5b2 | |||
| b16fefa106 | |||
| 2a255b2d61 | |||
| 9e331f9957 | |||
| 9169cbf728 | |||
| 2f9487cd38 | |||
| 1d03a0fa75 | |||
| 09f993899e | |||
| c9038af29e | |||
| f3053920bf | |||
| c7b31d24b9 | |||
| cb3559539a | |||
| 71cdfa6ad5 | |||
| edce713fc9 | |||
| 8d0d0e1c7a | |||
| f75363177e | |||
| 4c6217f09b | |||
| c95f35ea85 | |||
| 40357098a2 | |||
| e7f4110791 | |||
| ca1dd1862b | |||
| 737d1cea62 | |||
| 2f8e237ab7 | |||
| 5191465b0a | |||
| 50c604f37f | |||
| dfbc22c291 | |||
| a5a3167eba | |||
| a423e0f9e0 | |||
| 511c1f0c8b | |||
| 8369fcd71a | |||
| 626916e9a4 | |||
| 507f360a81 | |||
| 5323d9f6b3 | |||
| 770d4b0b72 | |||
| e5fed31009 | |||
| 4b8b223db2 | |||
| 728aca7703 | |||
| f07484bc64 | |||
| 78b9956a04 | |||
| 90aa937593 | |||
| 940618a64d | |||
| 409fa5dda2 | |||
| 211b67668d | |||
| f0cd02b9bd | |||
| 34101d8c5e | |||
| bf8d7bc0da | |||
| 9543adf072 | |||
| 036d2686af | |||
| a80e0e7da5 | |||
| 9631dedea9 | |||
| 75de0cadcf | |||
| 4b321c003c | |||
| 0a83047368 | |||
| 9bb8ac7cb6 | |||
| d6e6ab11b1 | |||
| a294beb116 | |||
| 75c5be55af | |||
| 735612c9b3 | |||
| 7d34800531 | |||
| 6a7123826a | |||
| a872030a35 | |||
| 79e7d7f4ba | |||
| 6513a356f0 | |||
| 65d4a16afd | |||
| 7f62a48ab5 | |||
| b5415b6872 | |||
| ca75c58f43 | |||
| 723df0f368 | |||
| 94b7ac50bb | |||
| 18450ebd78 | |||
| efdb2e8f3d | |||
| 7a84a1a974 | |||
| 789d9c8af9 | |||
| 4df063209b | |||
| 6256e3ca8e | |||
| b76a1d987f | |||
| ae2130470e | |||
| ac6290bea7 | |||
| 4051bbbed7 | |||
| 2a7edda70a | |||
| 59b6ada7b7 | |||
| 9908434c14 | |||
| 668a10f9b9 | |||
| fc4b45ebd3 | |||
| 1afe6d51ee | |||
| 1ae0f0f3f6 | |||
| de0b35b974 | |||
| ae88d01d8d | |||
| d759de9f96 | |||
| 89d3e81be8 | |||
| 71f264c498 | |||
| 26417da5d3 | |||
| b3b458edf9 | |||
| 74961d4dfb | |||
| 9ffa1801c7 | |||
| 4d4fe69223 | |||
| 0a75519ab5 | |||
| 3062a35eb1 | |||
| d1c878fb41 | |||
| 9b112107e2 | |||
| 48b87d64de |
+1
-1
@@ -3,4 +3,4 @@
|
||||
|
||||
[codespell]
|
||||
skip = ./.git,./build,./dist,./Doxyfile,./externals,./LICENSES,./src/android/app/src/main/res
|
||||
ignore-words-list = aci,allright,ba,canonicalizations,deques,froms,hda,inout,lod,masia,nam,nax,nd,optin,pullrequests,pullrequest,te,transfered,unstall,uscaled,vas,zink
|
||||
ignore-words-list = aci,allright,ba,canonicalizations,deques,fpr,froms,hda,inout,lod,masia,nam,nax,nce,nd,optin,pullrequests,pullrequest,te,transfered,unstall,uscaled,vas,zink
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
# SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
# CRLF -> LF
|
||||
90aa937593e53a5d5e070fb623b228578b0b225f
|
||||
@@ -40,11 +40,11 @@ jobs:
|
||||
sudo apt-get install -y ccache apksigner glslang-dev glslang-tools
|
||||
- name: Build
|
||||
run: ./.ci/scripts/android/build.sh
|
||||
- name: Copy and sign artifacts
|
||||
env:
|
||||
ANDROID_KEYSTORE_B64: ${{ secrets.ANDROID_KEYSTORE_B64 }}
|
||||
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
|
||||
ANDROID_KEYSTORE_PASS: ${{ secrets.ANDROID_KEYSTORE_PASS }}
|
||||
- name: Copy artifacts
|
||||
run: ./.ci/scripts/android/upload.sh
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v3
|
||||
|
||||
@@ -68,6 +68,26 @@ jobs:
|
||||
with:
|
||||
name: ${{ matrix.type }}
|
||||
path: artifacts/
|
||||
build-mac:
|
||||
name: 'test build (macos)'
|
||||
needs: format
|
||||
runs-on: macos-13
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
# workaround for https://github.com/actions/setup-python/issues/577
|
||||
brew install autoconf automake boost@1.83 ccache ffmpeg fmt glslang hidapi libtool libusb lz4 ninja nlohmann-json openssl pkg-config qt@5 sdl2 speexdsp zlib zlib zstd || brew link --overwrite python@3.12
|
||||
- name: Build
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
export Qt5_DIR="/usr/local/opt/qt@5/lib/cmake"
|
||||
cmake .. -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DYUZU_USE_BUNDLED_VCPKG=OFF -DYUZU_TESTS=OFF -DENABLE_WEB_SERVICE=OFF -DENABLE_LIBUSB=OFF
|
||||
ninja
|
||||
build-msvc:
|
||||
name: 'test build (windows, msvc)'
|
||||
needs: format
|
||||
|
||||
+6
-3
@@ -4,9 +4,6 @@
|
||||
[submodule "enet"]
|
||||
path = externals/enet
|
||||
url = https://github.com/lsalzman/enet.git
|
||||
[submodule "inih"]
|
||||
path = externals/inih/inih
|
||||
url = https://github.com/benhoyt/inih.git
|
||||
[submodule "cubeb"]
|
||||
path = externals/cubeb
|
||||
url = https://github.com/mozilla/cubeb.git
|
||||
@@ -61,3 +58,9 @@
|
||||
[submodule "breakpad"]
|
||||
path = externals/breakpad
|
||||
url = https://github.com/yuzu-emu/breakpad.git
|
||||
[submodule "simpleini"]
|
||||
path = externals/simpleini
|
||||
url = https://github.com/brofield/simpleini.git
|
||||
[submodule "oaknut"]
|
||||
path = externals/oaknut
|
||||
url = https://github.com/merryhime/oaknut
|
||||
|
||||
@@ -151,3 +151,7 @@ License: GPL-3.0-or-later
|
||||
Files: externals/stb/*
|
||||
Copyright: Sean Barrett
|
||||
License: MIT
|
||||
|
||||
Files: externals/gamemode/*
|
||||
Copyright: Copyright 2017-2019 Feral Interactive
|
||||
License: BSD-3-Clause
|
||||
|
||||
+14
-2
@@ -142,6 +142,9 @@ if (YUZU_USE_BUNDLED_VCPKG)
|
||||
if (ENABLE_WEB_SERVICE)
|
||||
list(APPEND VCPKG_MANIFEST_FEATURES "web-service")
|
||||
endif()
|
||||
if (ANDROID)
|
||||
list(APPEND VCPKG_MANIFEST_FEATURES "android")
|
||||
endif()
|
||||
|
||||
include(${CMAKE_SOURCE_DIR}/externals/vcpkg/scripts/buildsystems/vcpkg.cmake)
|
||||
elseif(NOT "$ENV{VCPKG_TOOLCHAIN_FILE}" STREQUAL "")
|
||||
@@ -260,6 +263,11 @@ if (UNIX)
|
||||
add_definitions(-DYUZU_UNIX=1)
|
||||
endif()
|
||||
|
||||
if (ARCHITECTURE_arm64 AND (ANDROID OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux"))
|
||||
set(HAS_NCE 1)
|
||||
add_definitions(-DHAS_NCE=1)
|
||||
endif()
|
||||
|
||||
# Configure C++ standard
|
||||
# ===========================
|
||||
|
||||
@@ -285,19 +293,19 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
|
||||
find_package(Boost 1.79.0 REQUIRED context)
|
||||
find_package(enet 1.3 MODULE)
|
||||
find_package(fmt 9 REQUIRED)
|
||||
find_package(inih 52 MODULE COMPONENTS INIReader)
|
||||
find_package(LLVM 17.0.2 MODULE COMPONENTS Demangle)
|
||||
find_package(lz4 REQUIRED)
|
||||
find_package(nlohmann_json 3.8 REQUIRED)
|
||||
find_package(Opus 1.3 MODULE)
|
||||
find_package(RenderDoc MODULE)
|
||||
find_package(SimpleIni MODULE)
|
||||
find_package(stb MODULE)
|
||||
find_package(VulkanMemoryAllocator CONFIG)
|
||||
find_package(ZLIB 1.2 REQUIRED)
|
||||
find_package(zstd 1.5 REQUIRED)
|
||||
|
||||
if (NOT YUZU_USE_EXTERNAL_VULKAN_HEADERS)
|
||||
find_package(Vulkan 1.3.256 REQUIRED)
|
||||
find_package(Vulkan 1.3.274 REQUIRED)
|
||||
endif()
|
||||
|
||||
if (ENABLE_LIBUSB)
|
||||
@@ -338,6 +346,10 @@ if(ENABLE_OPENSSL)
|
||||
find_package(OpenSSL 1.1.1 REQUIRED)
|
||||
endif()
|
||||
|
||||
if (UNIX AND NOT APPLE)
|
||||
find_package(gamemode 1.7 MODULE)
|
||||
endif()
|
||||
|
||||
# Please consider this as a stub
|
||||
if(ENABLE_QT6 AND Qt6_LOCATION)
|
||||
list(APPEND CMAKE_PREFIX_PATH "${Qt6_LOCATION}")
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# SPDX-FileCopyrightText: 2023 Alexandre Bouvier <contact@amb.tf>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
find_path(SimpleIni_INCLUDE_DIR SimpleIni.h)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(SimpleIni
|
||||
REQUIRED_VARS SimpleIni_INCLUDE_DIR
|
||||
)
|
||||
|
||||
if (SimpleIni_FOUND AND NOT TARGET SimpleIni::SimpleIni)
|
||||
add_library(SimpleIni::SimpleIni INTERFACE IMPORTED)
|
||||
set_target_properties(SimpleIni::SimpleIni PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SimpleIni_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
||||
mark_as_advanced(SimpleIni_INCLUDE_DIR)
|
||||
@@ -0,0 +1,15 @@
|
||||
# SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_search_module(GAMEMODE QUIET IMPORTED_TARGET gamemode)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(gamemode
|
||||
REQUIRED_VARS GAMEMODE_INCLUDEDIR
|
||||
VERSION_VAR GAMEMODE_VERSION
|
||||
)
|
||||
|
||||
if (gamemode_FOUND AND NOT TARGET gamemode::headers)
|
||||
add_library(gamemode::headers ALIAS PkgConfig::GAMEMODE)
|
||||
endif()
|
||||
@@ -1,27 +0,0 @@
|
||||
# SPDX-FileCopyrightText: 2022 Alexandre Bouvier <contact@amb.tf>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_search_module(INIH QUIET IMPORTED_TARGET inih)
|
||||
if (INIReader IN_LIST inih_FIND_COMPONENTS)
|
||||
pkg_search_module(INIREADER QUIET IMPORTED_TARGET INIReader)
|
||||
if (INIREADER_FOUND)
|
||||
set(inih_INIReader_FOUND TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(inih
|
||||
REQUIRED_VARS INIH_LINK_LIBRARIES
|
||||
VERSION_VAR INIH_VERSION
|
||||
HANDLE_COMPONENTS
|
||||
)
|
||||
|
||||
if (inih_FOUND AND NOT TARGET inih::inih)
|
||||
add_library(inih::inih ALIAS PkgConfig::INIH)
|
||||
endif()
|
||||
|
||||
if (inih_FOUND AND inih_INIReader_FOUND AND NOT TARGET inih::INIReader)
|
||||
add_library(inih::INIReader ALIAS PkgConfig::INIREADER)
|
||||
endif()
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
# SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
# Allow systemd-logind to manage user access to hidraw with this file
|
||||
# On most systems, this file should be installed to /etc/udev/rules.d/72-yuzu-input.rules
|
||||
# Consult your distro if this is not the case
|
||||
|
||||
# Switch Pro Controller (USB/Bluetooth)
|
||||
KERNEL=="hidraw*", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="2009", MODE="0660", TAG+="uaccess"
|
||||
KERNEL=="hidraw*", KERNELS=="*057e:2009*", MODE="0660", TAG+="uaccess"
|
||||
|
||||
# Joy-Con L (Bluetooth)
|
||||
KERNEL=="hidraw*", KERNELS=="*057e:2006*", MODE="0660", TAG+="uaccess"
|
||||
|
||||
# Joy-Con R (Bluetooth)
|
||||
KERNEL=="hidraw*", KERNELS=="*057e:2007*", MODE="0660", TAG+="uaccess"
|
||||
|
||||
# Joy-Con Charging Grip (USB)
|
||||
KERNEL=="hidraw*", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="200e", MODE="0660", TAG+="uaccess"
|
||||
Vendored
+5
@@ -6,3 +6,8 @@ file_filter = <lang>.ts
|
||||
source_file = en.ts
|
||||
source_lang = en
|
||||
type = QT
|
||||
|
||||
[o:yuzu-emulator:p:yuzu:r:yuzu-android]
|
||||
file_filter = ../../src/android/app/src/main/res/values-<lang>/strings.xml
|
||||
source_file = ../../src/android/app/src/main/res/values/strings.xml
|
||||
type = ANDROID
|
||||
|
||||
Vendored
+1973
-892
File diff suppressed because it is too large
Load Diff
Vendored
+1991
-901
File diff suppressed because it is too large
Load Diff
Vendored
+1860
-779
File diff suppressed because it is too large
Load Diff
Vendored
+1860
-779
File diff suppressed because it is too large
Load Diff
Vendored
+1877
-791
File diff suppressed because it is too large
Load Diff
Vendored
+1860
-779
File diff suppressed because it is too large
Load Diff
Vendored
+1866
-782
File diff suppressed because it is too large
Load Diff
Vendored
+1868
-781
File diff suppressed because it is too large
Load Diff
Vendored
+1941
-852
File diff suppressed because it is too large
Load Diff
Vendored
+1860
-779
File diff suppressed because it is too large
Load Diff
Vendored
+1890
-805
File diff suppressed because it is too large
Load Diff
Vendored
+1942
-858
File diff suppressed because it is too large
Load Diff
Vendored
+1863
-779
File diff suppressed because it is too large
Load Diff
Vendored
+1863
-779
File diff suppressed because it is too large
Load Diff
Vendored
+1863
-779
File diff suppressed because it is too large
Load Diff
Vendored
+1860
-779
File diff suppressed because it is too large
Load Diff
Vendored
+1861
-780
File diff suppressed because it is too large
Load Diff
Vendored
+1861
-780
File diff suppressed because it is too large
Load Diff
Vendored
+1863
-779
File diff suppressed because it is too large
Load Diff
Vendored
+1860
-779
File diff suppressed because it is too large
Load Diff
Vendored
+1860
-779
File diff suppressed because it is too large
Load Diff
Vendored
+1863
-779
File diff suppressed because it is too large
Load Diff
Vendored
+1863
-779
File diff suppressed because it is too large
Load Diff
Vendored
+1863
-779
File diff suppressed because it is too large
Load Diff
Vendored
+1858
-772
File diff suppressed because it is too large
Load Diff
Vendored
+2025
-939
File diff suppressed because it is too large
Load Diff
Vendored
+15
-5
@@ -20,6 +20,10 @@ if ((ARCHITECTURE_x86 OR ARCHITECTURE_x86_64) AND NOT TARGET xbyak::xbyak)
|
||||
endif()
|
||||
|
||||
# Dynarmic
|
||||
if (ARCHITECTURE_arm64 AND NOT TARGET merry::oaknut)
|
||||
add_subdirectory(oaknut)
|
||||
endif()
|
||||
|
||||
if ((ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64) AND NOT TARGET dynarmic::dynarmic)
|
||||
set(DYNARMIC_IGNORE_ASSERTS ON)
|
||||
add_subdirectory(dynarmic)
|
||||
@@ -34,11 +38,6 @@ endif()
|
||||
# Glad
|
||||
add_subdirectory(glad)
|
||||
|
||||
# inih
|
||||
if (NOT TARGET inih::INIReader)
|
||||
add_subdirectory(inih)
|
||||
endif()
|
||||
|
||||
# mbedtls
|
||||
add_subdirectory(mbedtls)
|
||||
target_include_directories(mbedtls PUBLIC ./mbedtls/include)
|
||||
@@ -194,6 +193,12 @@ if (ANDROID)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (UNIX AND NOT APPLE AND NOT TARGET gamemode::headers)
|
||||
add_library(gamemode INTERFACE)
|
||||
target_include_directories(gamemode INTERFACE gamemode)
|
||||
add_library(gamemode::headers ALIAS gamemode)
|
||||
endif()
|
||||
|
||||
# Breakpad
|
||||
# https://github.com/microsoft/vcpkg/blob/master/ports/breakpad/CMakeLists.txt
|
||||
if (YUZU_CRASH_DUMPS AND NOT TARGET libbreakpad_client)
|
||||
@@ -295,3 +300,8 @@ if (YUZU_CRASH_DUMPS AND NOT TARGET libbreakpad_client)
|
||||
target_link_libraries(dump_syms PRIVATE libbreakpad_client ZLIB::ZLIB)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# SimpleIni
|
||||
if (NOT TARGET SimpleIni::SimpleIni)
|
||||
add_subdirectory(simpleini)
|
||||
endif()
|
||||
|
||||
Vendored
+1
-1
Submodule externals/Vulkan-Headers updated: df60f03168...80207f9da8
Vendored
+376
@@ -0,0 +1,376 @@
|
||||
/*
|
||||
|
||||
Copyright (c) 2017-2019, Feral Interactive
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Feral Interactive nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
#ifndef CLIENT_GAMEMODE_H
|
||||
#define CLIENT_GAMEMODE_H
|
||||
/*
|
||||
* GameMode supports the following client functions
|
||||
* Requests are refcounted in the daemon
|
||||
*
|
||||
* int gamemode_request_start() - Request gamemode starts
|
||||
* 0 if the request was sent successfully
|
||||
* -1 if the request failed
|
||||
*
|
||||
* int gamemode_request_end() - Request gamemode ends
|
||||
* 0 if the request was sent successfully
|
||||
* -1 if the request failed
|
||||
*
|
||||
* GAMEMODE_AUTO can be defined to make the above two functions apply during static init and
|
||||
* destruction, as appropriate. In this configuration, errors will be printed to stderr
|
||||
*
|
||||
* int gamemode_query_status() - Query the current status of gamemode
|
||||
* 0 if gamemode is inactive
|
||||
* 1 if gamemode is active
|
||||
* 2 if gamemode is active and this client is registered
|
||||
* -1 if the query failed
|
||||
*
|
||||
* int gamemode_request_start_for(pid_t pid) - Request gamemode starts for another process
|
||||
* 0 if the request was sent successfully
|
||||
* -1 if the request failed
|
||||
* -2 if the request was rejected
|
||||
*
|
||||
* int gamemode_request_end_for(pid_t pid) - Request gamemode ends for another process
|
||||
* 0 if the request was sent successfully
|
||||
* -1 if the request failed
|
||||
* -2 if the request was rejected
|
||||
*
|
||||
* int gamemode_query_status_for(pid_t pid) - Query status of gamemode for another process
|
||||
* 0 if gamemode is inactive
|
||||
* 1 if gamemode is active
|
||||
* 2 if gamemode is active and this client is registered
|
||||
* -1 if the query failed
|
||||
*
|
||||
* const char* gamemode_error_string() - Get an error string
|
||||
* returns a string describing any of the above errors
|
||||
*
|
||||
* Note: All the above requests can be blocking - dbus requests can and will block while the daemon
|
||||
* handles the request. It is not recommended to make these calls in performance critical code
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
static char internal_gamemode_client_error_string[512] = { 0 };
|
||||
|
||||
/**
|
||||
* Load libgamemode dynamically to dislodge us from most dependencies.
|
||||
* This allows clients to link and/or use this regardless of runtime.
|
||||
* See SDL2 for an example of the reasoning behind this in terms of
|
||||
* dynamic versioning as well.
|
||||
*/
|
||||
static volatile int internal_libgamemode_loaded = 1;
|
||||
|
||||
/* Typedefs for the functions to load */
|
||||
typedef int (*api_call_return_int)(void);
|
||||
typedef const char *(*api_call_return_cstring)(void);
|
||||
typedef int (*api_call_pid_return_int)(pid_t);
|
||||
|
||||
/* Storage for functors */
|
||||
static api_call_return_int REAL_internal_gamemode_request_start = NULL;
|
||||
static api_call_return_int REAL_internal_gamemode_request_end = NULL;
|
||||
static api_call_return_int REAL_internal_gamemode_query_status = NULL;
|
||||
static api_call_return_cstring REAL_internal_gamemode_error_string = NULL;
|
||||
static api_call_pid_return_int REAL_internal_gamemode_request_start_for = NULL;
|
||||
static api_call_pid_return_int REAL_internal_gamemode_request_end_for = NULL;
|
||||
static api_call_pid_return_int REAL_internal_gamemode_query_status_for = NULL;
|
||||
|
||||
/**
|
||||
* Internal helper to perform the symbol binding safely.
|
||||
*
|
||||
* Returns 0 on success and -1 on failure
|
||||
*/
|
||||
__attribute__((always_inline)) static inline int internal_bind_libgamemode_symbol(
|
||||
void *handle, const char *name, void **out_func, size_t func_size, bool required)
|
||||
{
|
||||
void *symbol_lookup = NULL;
|
||||
char *dl_error = NULL;
|
||||
|
||||
/* Safely look up the symbol */
|
||||
symbol_lookup = dlsym(handle, name);
|
||||
dl_error = dlerror();
|
||||
if (required && (dl_error || !symbol_lookup)) {
|
||||
snprintf(internal_gamemode_client_error_string,
|
||||
sizeof(internal_gamemode_client_error_string),
|
||||
"dlsym failed - %s",
|
||||
dl_error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Have the symbol correctly, copy it to make it usable */
|
||||
memcpy(out_func, &symbol_lookup, func_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads libgamemode and needed functions
|
||||
*
|
||||
* Returns 0 on success and -1 on failure
|
||||
*/
|
||||
__attribute__((always_inline)) static inline int internal_load_libgamemode(void)
|
||||
{
|
||||
/* We start at 1, 0 is a success and -1 is a fail */
|
||||
if (internal_libgamemode_loaded != 1) {
|
||||
return internal_libgamemode_loaded;
|
||||
}
|
||||
|
||||
/* Anonymous struct type to define our bindings */
|
||||
struct binding {
|
||||
const char *name;
|
||||
void **functor;
|
||||
size_t func_size;
|
||||
bool required;
|
||||
} bindings[] = {
|
||||
{ "real_gamemode_request_start",
|
||||
(void **)&REAL_internal_gamemode_request_start,
|
||||
sizeof(REAL_internal_gamemode_request_start),
|
||||
true },
|
||||
{ "real_gamemode_request_end",
|
||||
(void **)&REAL_internal_gamemode_request_end,
|
||||
sizeof(REAL_internal_gamemode_request_end),
|
||||
true },
|
||||
{ "real_gamemode_query_status",
|
||||
(void **)&REAL_internal_gamemode_query_status,
|
||||
sizeof(REAL_internal_gamemode_query_status),
|
||||
false },
|
||||
{ "real_gamemode_error_string",
|
||||
(void **)&REAL_internal_gamemode_error_string,
|
||||
sizeof(REAL_internal_gamemode_error_string),
|
||||
true },
|
||||
{ "real_gamemode_request_start_for",
|
||||
(void **)&REAL_internal_gamemode_request_start_for,
|
||||
sizeof(REAL_internal_gamemode_request_start_for),
|
||||
false },
|
||||
{ "real_gamemode_request_end_for",
|
||||
(void **)&REAL_internal_gamemode_request_end_for,
|
||||
sizeof(REAL_internal_gamemode_request_end_for),
|
||||
false },
|
||||
{ "real_gamemode_query_status_for",
|
||||
(void **)&REAL_internal_gamemode_query_status_for,
|
||||
sizeof(REAL_internal_gamemode_query_status_for),
|
||||
false },
|
||||
};
|
||||
|
||||
void *libgamemode = NULL;
|
||||
|
||||
/* Try and load libgamemode */
|
||||
libgamemode = dlopen("libgamemode.so.0", RTLD_NOW);
|
||||
if (!libgamemode) {
|
||||
/* Attempt to load unversioned library for compatibility with older
|
||||
* versions (as of writing, there are no ABI changes between the two -
|
||||
* this may need to change if ever ABI-breaking changes are made) */
|
||||
libgamemode = dlopen("libgamemode.so", RTLD_NOW);
|
||||
if (!libgamemode) {
|
||||
snprintf(internal_gamemode_client_error_string,
|
||||
sizeof(internal_gamemode_client_error_string),
|
||||
"dlopen failed - %s",
|
||||
dlerror());
|
||||
internal_libgamemode_loaded = -1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Attempt to bind all symbols */
|
||||
for (size_t i = 0; i < sizeof(bindings) / sizeof(bindings[0]); i++) {
|
||||
struct binding *binder = &bindings[i];
|
||||
|
||||
if (internal_bind_libgamemode_symbol(libgamemode,
|
||||
binder->name,
|
||||
binder->functor,
|
||||
binder->func_size,
|
||||
binder->required)) {
|
||||
internal_libgamemode_loaded = -1;
|
||||
return -1;
|
||||
};
|
||||
}
|
||||
|
||||
/* Success */
|
||||
internal_libgamemode_loaded = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to the real libgamemode
|
||||
*/
|
||||
__attribute__((always_inline)) static inline const char *gamemode_error_string(void)
|
||||
{
|
||||
/* If we fail to load the system gamemode, or we have an error string already, return our error
|
||||
* string instead of diverting to the system version */
|
||||
if (internal_load_libgamemode() < 0 || internal_gamemode_client_error_string[0] != '\0') {
|
||||
return internal_gamemode_client_error_string;
|
||||
}
|
||||
|
||||
/* Assert for static analyser that the function is not NULL */
|
||||
assert(REAL_internal_gamemode_error_string != NULL);
|
||||
|
||||
return REAL_internal_gamemode_error_string();
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to the real libgamemode
|
||||
* Allow automatically requesting game mode
|
||||
* Also prints errors as they happen.
|
||||
*/
|
||||
#ifdef GAMEMODE_AUTO
|
||||
__attribute__((constructor))
|
||||
#else
|
||||
__attribute__((always_inline)) static inline
|
||||
#endif
|
||||
int gamemode_request_start(void)
|
||||
{
|
||||
/* Need to load gamemode */
|
||||
if (internal_load_libgamemode() < 0) {
|
||||
#ifdef GAMEMODE_AUTO
|
||||
fprintf(stderr, "gamemodeauto: %s\n", gamemode_error_string());
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Assert for static analyser that the function is not NULL */
|
||||
assert(REAL_internal_gamemode_request_start != NULL);
|
||||
|
||||
if (REAL_internal_gamemode_request_start() < 0) {
|
||||
#ifdef GAMEMODE_AUTO
|
||||
fprintf(stderr, "gamemodeauto: %s\n", gamemode_error_string());
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Redirect to the real libgamemode */
|
||||
#ifdef GAMEMODE_AUTO
|
||||
__attribute__((destructor))
|
||||
#else
|
||||
__attribute__((always_inline)) static inline
|
||||
#endif
|
||||
int gamemode_request_end(void)
|
||||
{
|
||||
/* Need to load gamemode */
|
||||
if (internal_load_libgamemode() < 0) {
|
||||
#ifdef GAMEMODE_AUTO
|
||||
fprintf(stderr, "gamemodeauto: %s\n", gamemode_error_string());
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Assert for static analyser that the function is not NULL */
|
||||
assert(REAL_internal_gamemode_request_end != NULL);
|
||||
|
||||
if (REAL_internal_gamemode_request_end() < 0) {
|
||||
#ifdef GAMEMODE_AUTO
|
||||
fprintf(stderr, "gamemodeauto: %s\n", gamemode_error_string());
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Redirect to the real libgamemode */
|
||||
__attribute__((always_inline)) static inline int gamemode_query_status(void)
|
||||
{
|
||||
/* Need to load gamemode */
|
||||
if (internal_load_libgamemode() < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (REAL_internal_gamemode_query_status == NULL) {
|
||||
snprintf(internal_gamemode_client_error_string,
|
||||
sizeof(internal_gamemode_client_error_string),
|
||||
"gamemode_query_status missing (older host?)");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return REAL_internal_gamemode_query_status();
|
||||
}
|
||||
|
||||
/* Redirect to the real libgamemode */
|
||||
__attribute__((always_inline)) static inline int gamemode_request_start_for(pid_t pid)
|
||||
{
|
||||
/* Need to load gamemode */
|
||||
if (internal_load_libgamemode() < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (REAL_internal_gamemode_request_start_for == NULL) {
|
||||
snprintf(internal_gamemode_client_error_string,
|
||||
sizeof(internal_gamemode_client_error_string),
|
||||
"gamemode_request_start_for missing (older host?)");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return REAL_internal_gamemode_request_start_for(pid);
|
||||
}
|
||||
|
||||
/* Redirect to the real libgamemode */
|
||||
__attribute__((always_inline)) static inline int gamemode_request_end_for(pid_t pid)
|
||||
{
|
||||
/* Need to load gamemode */
|
||||
if (internal_load_libgamemode() < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (REAL_internal_gamemode_request_end_for == NULL) {
|
||||
snprintf(internal_gamemode_client_error_string,
|
||||
sizeof(internal_gamemode_client_error_string),
|
||||
"gamemode_request_end_for missing (older host?)");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return REAL_internal_gamemode_request_end_for(pid);
|
||||
}
|
||||
|
||||
/* Redirect to the real libgamemode */
|
||||
__attribute__((always_inline)) static inline int gamemode_query_status_for(pid_t pid)
|
||||
{
|
||||
/* Need to load gamemode */
|
||||
if (internal_load_libgamemode() < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (REAL_internal_gamemode_query_status_for == NULL) {
|
||||
snprintf(internal_gamemode_client_error_string,
|
||||
sizeof(internal_gamemode_client_error_string),
|
||||
"gamemode_query_status_for missing (older host?)");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return REAL_internal_gamemode_query_status_for(pid);
|
||||
}
|
||||
|
||||
#endif // CLIENT_GAMEMODE_H
|
||||
Vendored
-13
@@ -1,13 +0,0 @@
|
||||
# SPDX-FileCopyrightText: 2014 Gui Andrade <admin@archshift.com>
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
add_library(inih
|
||||
inih/ini.c
|
||||
inih/ini.h
|
||||
inih/cpp/INIReader.cpp
|
||||
inih/cpp/INIReader.h
|
||||
)
|
||||
|
||||
create_target_directory_groups(inih)
|
||||
target_include_directories(inih INTERFACE inih/cpp)
|
||||
add_library(inih::INIReader ALIAS inih)
|
||||
Vendored
-1
Submodule externals/inih/inih deleted from 9cecf0643d
Vendored
+1
-1
Submodule externals/nx_tzdb/tzdb_to_nx updated: 0d17dd066d...f6680093bc
+1
Submodule externals/oaknut added at 918bd94f02
+1
Submodule externals/simpleini added at 382ddbb4b9
Vendored
+1
-1
Submodule externals/vcpkg updated: ef2eef1734...a42af01b72
+4
-3
@@ -21,7 +21,7 @@ if (MSVC)
|
||||
# Avoid windows.h from including some usually unused libs like winsocks.h, since this might cause some redefinition errors.
|
||||
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||
|
||||
# Ensure that projects build with Unicode support.
|
||||
# Ensure that projects are built with Unicode support.
|
||||
add_definitions(-DUNICODE -D_UNICODE)
|
||||
|
||||
# /W4 - Level 4 warnings
|
||||
@@ -54,11 +54,11 @@ if (MSVC)
|
||||
/GT
|
||||
|
||||
# Modules
|
||||
/experimental:module- # Disable module support explicitly due to conflicts with precompiled headers
|
||||
/experimental:module- # Explicitly disable module support due to conflicts with precompiled headers.
|
||||
|
||||
# External headers diagnostics
|
||||
/external:anglebrackets # Treats all headers included by #include <header>, where the header file is enclosed in angle brackets (< >), as external headers
|
||||
/external:W0 # Sets the default warning level to 0 for external headers, effectively turning off warnings for external headers
|
||||
/external:W0 # Sets the default warning level to 0 for external headers, effectively disabling warnings for them.
|
||||
|
||||
# Warnings
|
||||
/W4
|
||||
@@ -187,6 +187,7 @@ add_subdirectory(audio_core)
|
||||
add_subdirectory(video_core)
|
||||
add_subdirectory(network)
|
||||
add_subdirectory(input_common)
|
||||
add_subdirectory(frontend_common)
|
||||
add_subdirectory(shader_recompiler)
|
||||
|
||||
if (YUZU_ROOM)
|
||||
|
||||
@@ -174,7 +174,8 @@ android {
|
||||
"-DANDROID_ARM_NEON=true", // cryptopp requires Neon to work
|
||||
"-DYUZU_USE_BUNDLED_VCPKG=ON",
|
||||
"-DYUZU_USE_BUNDLED_FFMPEG=ON",
|
||||
"-DYUZU_ENABLE_LTO=ON"
|
||||
"-DYUZU_ENABLE_LTO=ON",
|
||||
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
|
||||
)
|
||||
|
||||
abiFilters("arm64-v8a", "x86_64")
|
||||
@@ -219,7 +220,6 @@ dependencies {
|
||||
implementation("io.coil-kt:coil:2.2.2")
|
||||
implementation("androidx.core:core-splashscreen:1.0.1")
|
||||
implementation("androidx.window:window:1.2.0-beta03")
|
||||
implementation("org.ini4j:ini4j:0.5.4")
|
||||
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
|
||||
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
|
||||
implementation("androidx.navigation:navigation-fragment-ktx:2.7.4")
|
||||
|
||||
@@ -230,10 +230,6 @@ object NativeLibrary {
|
||||
*/
|
||||
external fun onTouchReleased(finger_id: Int)
|
||||
|
||||
external fun reloadSettings()
|
||||
|
||||
external fun initGameIni(gameID: String?)
|
||||
|
||||
external fun setAppDirectory(directory: String)
|
||||
|
||||
/**
|
||||
@@ -243,6 +239,8 @@ object NativeLibrary {
|
||||
*/
|
||||
external fun installFileToNand(filename: String, extension: String): Int
|
||||
|
||||
external fun doesUpdateMatchProgram(programId: String, updatePath: String): Boolean
|
||||
|
||||
external fun initializeGpuDriver(
|
||||
hookLibDir: String?,
|
||||
customDriverDir: String?,
|
||||
@@ -252,20 +250,13 @@ object NativeLibrary {
|
||||
|
||||
external fun reloadKeys(): Boolean
|
||||
|
||||
external fun initializeSystem()
|
||||
|
||||
external fun defaultCPUCore(): Int
|
||||
external fun initializeSystem(reload: Boolean)
|
||||
|
||||
/**
|
||||
* Begins emulation.
|
||||
*/
|
||||
external fun run(path: String?)
|
||||
|
||||
/**
|
||||
* Begins emulation from the specified savestate.
|
||||
*/
|
||||
external fun run(path: String?, savestatePath: String?, deleteSavestate: Boolean)
|
||||
|
||||
// Surface Handling
|
||||
external fun surfaceChanged(surf: Surface?)
|
||||
|
||||
@@ -302,9 +293,13 @@ object NativeLibrary {
|
||||
external fun getPerfStats(): DoubleArray
|
||||
|
||||
/**
|
||||
* Notifies the core emulation that the orientation has changed.
|
||||
* Returns the current CPU backend.
|
||||
*/
|
||||
external fun notifyOrientationChange(layout_option: Int, rotation: Int)
|
||||
external fun getCpuBackend(): String
|
||||
|
||||
external fun applySettings()
|
||||
|
||||
external fun logSettings()
|
||||
|
||||
enum class CoreError {
|
||||
ErrorSystemFiles,
|
||||
@@ -535,6 +530,35 @@ object NativeLibrary {
|
||||
*/
|
||||
external fun isFirmwareAvailable(): Boolean
|
||||
|
||||
/**
|
||||
* Checks the PatchManager for any addons that are available
|
||||
*
|
||||
* @param path Path to game file. Can be a [Uri].
|
||||
* @param programId String representation of a game's program ID
|
||||
* @return Array of pairs where the first value is the name of an addon and the second is the version
|
||||
*/
|
||||
external fun getAddonsForFile(path: String, programId: String): Array<Pair<String, String>>?
|
||||
|
||||
/**
|
||||
* Gets the save location for a specific game
|
||||
*
|
||||
* @param programId String representation of a game's program ID
|
||||
* @return Save data path that may not exist yet
|
||||
*/
|
||||
external fun getSavePath(programId: String): String
|
||||
|
||||
/**
|
||||
* Adds a file to the manual filesystem provider in our EmulationSession instance
|
||||
* @param path Path to the file we're adding. Can be a string representation of a [Uri] or
|
||||
* a normal path
|
||||
*/
|
||||
external fun addFileToFilesystemProvider(path: String)
|
||||
|
||||
/**
|
||||
* Clears all files added to the manual filesystem provider in our EmulationSession instance
|
||||
*/
|
||||
external fun clearFilesystemProvider()
|
||||
|
||||
/**
|
||||
* Button type for use in onTouchEvent
|
||||
*/
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.io.File
|
||||
import org.yuzu.yuzu_emu.utils.DirectoryInitialization
|
||||
import org.yuzu.yuzu_emu.utils.DocumentsTree
|
||||
import org.yuzu.yuzu_emu.utils.GpuDriverHelper
|
||||
import org.yuzu.yuzu_emu.utils.Log
|
||||
|
||||
fun Context.getPublicFilesDir(): File = getExternalFilesDir(null) ?: filesDir
|
||||
|
||||
@@ -49,6 +50,7 @@ class YuzuApplication : Application() {
|
||||
DirectoryInitialization.start()
|
||||
GpuDriverHelper.initializeDriverParameters()
|
||||
NativeLibrary.logDeviceInfo()
|
||||
Log.logDeviceInfo()
|
||||
|
||||
createNotificationChannels()
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||
|
||||
val preferences = PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext)
|
||||
if (!preferences.getBoolean(Settings.PREF_MEMORY_WARNING_SHOWN, false)) {
|
||||
if (MemoryUtil.isLessThan(MemoryUtil.REQUIRED_MEMORY, MemoryUtil.Gb)) {
|
||||
if (MemoryUtil.isLessThan(MemoryUtil.REQUIRED_MEMORY, MemoryUtil.totalMemory)) {
|
||||
Toast.makeText(
|
||||
this,
|
||||
getString(
|
||||
@@ -172,7 +172,7 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||
|
||||
override fun onUserLeaveHint() {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
|
||||
if (BooleanSetting.PICTURE_IN_PICTURE.boolean && !isInPictureInPictureMode) {
|
||||
if (BooleanSetting.PICTURE_IN_PICTURE.getBoolean() && !isInPictureInPictureMode) {
|
||||
val pictureInPictureParamsBuilder = PictureInPictureParams.Builder()
|
||||
.getPictureInPictureActionsBuilder().getPictureInPictureAspectBuilder()
|
||||
enterPictureInPictureMode(pictureInPictureParamsBuilder.build())
|
||||
@@ -284,7 +284,7 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||
|
||||
private fun PictureInPictureParams.Builder.getPictureInPictureAspectBuilder():
|
||||
PictureInPictureParams.Builder {
|
||||
val aspectRatio = when (IntSetting.RENDERER_ASPECT_RATIO.int) {
|
||||
val aspectRatio = when (IntSetting.RENDERER_ASPECT_RATIO.getInt()) {
|
||||
0 -> Rational(16, 9)
|
||||
1 -> Rational(4, 3)
|
||||
2 -> Rational(21, 9)
|
||||
@@ -331,7 +331,7 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||
pictureInPictureActions.add(pauseRemoteAction)
|
||||
}
|
||||
|
||||
if (BooleanSetting.AUDIO_MUTED.boolean) {
|
||||
if (BooleanSetting.AUDIO_MUTED.getBoolean()) {
|
||||
val unmuteIcon = Icon.createWithResource(
|
||||
this@EmulationActivity,
|
||||
R.drawable.ic_pip_unmute
|
||||
@@ -373,8 +373,10 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||
val pictureInPictureParamsBuilder = PictureInPictureParams.Builder()
|
||||
.getPictureInPictureActionsBuilder().getPictureInPictureAspectBuilder()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
val isEmulationActive = emulationViewModel.emulationStarted.value &&
|
||||
!emulationViewModel.isEmulationStopping.value
|
||||
pictureInPictureParamsBuilder.setAutoEnterEnabled(
|
||||
BooleanSetting.PICTURE_IN_PICTURE.boolean
|
||||
BooleanSetting.PICTURE_IN_PICTURE.getBoolean() && isEmulationActive
|
||||
)
|
||||
}
|
||||
setPictureInPictureParams(pictureInPictureParamsBuilder.build())
|
||||
@@ -388,9 +390,13 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||
if (!NativeLibrary.isPaused()) NativeLibrary.pauseEmulation()
|
||||
}
|
||||
if (intent.action == actionUnmute) {
|
||||
if (BooleanSetting.AUDIO_MUTED.boolean) BooleanSetting.AUDIO_MUTED.setBoolean(false)
|
||||
if (BooleanSetting.AUDIO_MUTED.getBoolean()) {
|
||||
BooleanSetting.AUDIO_MUTED.setBoolean(false)
|
||||
}
|
||||
} else if (intent.action == actionMute) {
|
||||
if (!BooleanSetting.AUDIO_MUTED.boolean) BooleanSetting.AUDIO_MUTED.setBoolean(true)
|
||||
if (!BooleanSetting.AUDIO_MUTED.getBoolean()) {
|
||||
BooleanSetting.AUDIO_MUTED.setBoolean(true)
|
||||
}
|
||||
}
|
||||
buildPictureInPictureParams()
|
||||
}
|
||||
@@ -421,7 +427,9 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
// Always resume audio, since there is no UI button
|
||||
if (BooleanSetting.AUDIO_MUTED.boolean) BooleanSetting.AUDIO_MUTED.setBoolean(false)
|
||||
if (BooleanSetting.AUDIO_MUTED.getBoolean()) {
|
||||
BooleanSetting.AUDIO_MUTED.setBoolean(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.yuzu.yuzu_emu.adapters
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.AsyncDifferConfig
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.yuzu.yuzu_emu.databinding.ListItemAddonBinding
|
||||
import org.yuzu.yuzu_emu.model.Addon
|
||||
|
||||
class AddonAdapter : ListAdapter<Addon, AddonAdapter.AddonViewHolder>(
|
||||
AsyncDifferConfig.Builder(DiffCallback()).build()
|
||||
) {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AddonViewHolder {
|
||||
ListItemAddonBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
.also { return AddonViewHolder(it) }
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = currentList.size
|
||||
|
||||
override fun onBindViewHolder(holder: AddonViewHolder, position: Int) =
|
||||
holder.bind(currentList[position])
|
||||
|
||||
inner class AddonViewHolder(val binding: ListItemAddonBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
fun bind(addon: Addon) {
|
||||
binding.root.setOnClickListener {
|
||||
binding.addonSwitch.isChecked = !binding.addonSwitch.isChecked
|
||||
}
|
||||
binding.title.text = addon.title
|
||||
binding.version.text = addon.version
|
||||
binding.addonSwitch.setOnCheckedChangeListener { _, checked ->
|
||||
addon.enabled = checked
|
||||
}
|
||||
binding.addonSwitch.isChecked = addon.enabled
|
||||
}
|
||||
}
|
||||
|
||||
private class DiffCallback : DiffUtil.ItemCallback<Addon>() {
|
||||
override fun areItemsTheSame(oldItem: Addon, newItem: Addon): Boolean {
|
||||
return oldItem == newItem
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(oldItem: Addon, newItem: Addon): Boolean {
|
||||
return oldItem == newItem
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import org.yuzu.yuzu_emu.HomeNavigationDirections
|
||||
import org.yuzu.yuzu_emu.NativeLibrary
|
||||
import org.yuzu.yuzu_emu.R
|
||||
import org.yuzu.yuzu_emu.YuzuApplication
|
||||
import org.yuzu.yuzu_emu.databinding.CardAppletOptionBinding
|
||||
import org.yuzu.yuzu_emu.databinding.CardSimpleOutlinedBinding
|
||||
import org.yuzu.yuzu_emu.model.Applet
|
||||
import org.yuzu.yuzu_emu.model.AppletInfo
|
||||
import org.yuzu.yuzu_emu.model.Game
|
||||
@@ -28,7 +28,7 @@ class AppletAdapter(val activity: FragmentActivity, var applets: List<Applet>) :
|
||||
parent: ViewGroup,
|
||||
viewType: Int
|
||||
): AppletAdapter.AppletViewHolder {
|
||||
CardAppletOptionBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
CardSimpleOutlinedBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
.apply { root.setOnClickListener(this@AppletAdapter) }
|
||||
.also { return AppletViewHolder(it) }
|
||||
}
|
||||
@@ -65,7 +65,7 @@ class AppletAdapter(val activity: FragmentActivity, var applets: List<Applet>) :
|
||||
view.findNavController().navigate(action)
|
||||
}
|
||||
|
||||
inner class AppletViewHolder(val binding: CardAppletOptionBinding) :
|
||||
inner class AppletViewHolder(val binding: CardSimpleOutlinedBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
lateinit var applet: Applet
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class DriverAdapter(private val driverViewModel: DriverViewModel) :
|
||||
if (driverViewModel.selectedDriver > position) {
|
||||
driverViewModel.setSelectedDriverIndex(driverViewModel.selectedDriver - 1)
|
||||
}
|
||||
if (GpuDriverHelper.customDriverData == driverData.second) {
|
||||
if (GpuDriverHelper.customDriverSettingData == driverData.second) {
|
||||
driverViewModel.setSelectedDriverIndex(0)
|
||||
}
|
||||
driverViewModel.driversToDelete.add(driverData.first)
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.yuzu.yuzu_emu.adapters
|
||||
|
||||
import android.net.Uri
|
||||
import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.recyclerview.widget.AsyncDifferConfig
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.yuzu.yuzu_emu.databinding.CardFolderBinding
|
||||
import org.yuzu.yuzu_emu.fragments.GameFolderPropertiesDialogFragment
|
||||
import org.yuzu.yuzu_emu.model.GameDir
|
||||
import org.yuzu.yuzu_emu.model.GamesViewModel
|
||||
|
||||
class FolderAdapter(val activity: FragmentActivity, val gamesViewModel: GamesViewModel) :
|
||||
ListAdapter<GameDir, FolderAdapter.FolderViewHolder>(
|
||||
AsyncDifferConfig.Builder(DiffCallback()).build()
|
||||
) {
|
||||
override fun onCreateViewHolder(
|
||||
parent: ViewGroup,
|
||||
viewType: Int
|
||||
): FolderAdapter.FolderViewHolder {
|
||||
CardFolderBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
.also { return FolderViewHolder(it) }
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: FolderAdapter.FolderViewHolder, position: Int) =
|
||||
holder.bind(currentList[position])
|
||||
|
||||
inner class FolderViewHolder(val binding: CardFolderBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
private lateinit var gameDir: GameDir
|
||||
|
||||
fun bind(gameDir: GameDir) {
|
||||
this.gameDir = gameDir
|
||||
|
||||
binding.apply {
|
||||
path.text = Uri.parse(gameDir.uriString).path
|
||||
path.postDelayed(
|
||||
{
|
||||
path.isSelected = true
|
||||
path.ellipsize = TextUtils.TruncateAt.MARQUEE
|
||||
},
|
||||
3000
|
||||
)
|
||||
|
||||
buttonEdit.setOnClickListener {
|
||||
GameFolderPropertiesDialogFragment.newInstance(this@FolderViewHolder.gameDir)
|
||||
.show(
|
||||
activity.supportFragmentManager,
|
||||
GameFolderPropertiesDialogFragment.TAG
|
||||
)
|
||||
}
|
||||
|
||||
buttonDelete.setOnClickListener {
|
||||
gamesViewModel.removeFolder(this@FolderViewHolder.gameDir)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class DiffCallback : DiffUtil.ItemCallback<GameDir>() {
|
||||
override fun areItemsTheSame(oldItem: GameDir, newItem: GameDir): Boolean {
|
||||
return oldItem == newItem
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(oldItem: GameDir, newItem: GameDir): Boolean {
|
||||
return oldItem == newItem
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,12 +22,16 @@ import androidx.core.graphics.drawable.toBitmap
|
||||
import androidx.core.graphics.drawable.toDrawable
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.recyclerview.widget.AsyncDifferConfig
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.yuzu.yuzu_emu.HomeNavigationDirections
|
||||
import org.yuzu.yuzu_emu.R
|
||||
import org.yuzu.yuzu_emu.YuzuApplication
|
||||
@@ -40,19 +44,20 @@ import org.yuzu.yuzu_emu.utils.GameIconUtils
|
||||
|
||||
class GameAdapter(private val activity: AppCompatActivity) :
|
||||
ListAdapter<Game, GameViewHolder>(AsyncDifferConfig.Builder(DiffCallback()).build()),
|
||||
View.OnClickListener {
|
||||
View.OnClickListener,
|
||||
View.OnLongClickListener {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): GameViewHolder {
|
||||
// Create a new view.
|
||||
val binding = CardGameBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
binding.cardGame.setOnClickListener(this)
|
||||
binding.cardGame.setOnLongClickListener(this)
|
||||
|
||||
// Use that view to create a ViewHolder.
|
||||
return GameViewHolder(binding)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: GameViewHolder, position: Int) {
|
||||
override fun onBindViewHolder(holder: GameViewHolder, position: Int) =
|
||||
holder.bind(currentList[position])
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = currentList.size
|
||||
|
||||
@@ -92,33 +97,46 @@ class GameAdapter(private val activity: AppCompatActivity) :
|
||||
data = Uri.parse(holder.game.path)
|
||||
}
|
||||
|
||||
val layerDrawable = ResourcesCompat.getDrawable(
|
||||
YuzuApplication.appContext.resources,
|
||||
R.drawable.shortcut,
|
||||
null
|
||||
) as LayerDrawable
|
||||
layerDrawable.setDrawableByLayerId(
|
||||
R.id.shortcut_foreground,
|
||||
GameIconUtils.getGameIcon(holder.game).toDrawable(YuzuApplication.appContext.resources)
|
||||
)
|
||||
val inset = YuzuApplication.appContext.resources
|
||||
.getDimensionPixelSize(R.dimen.icon_inset)
|
||||
layerDrawable.setLayerInset(1, inset, inset, inset, inset)
|
||||
val shortcut = ShortcutInfoCompat.Builder(YuzuApplication.appContext, holder.game.path)
|
||||
.setShortLabel(holder.game.title)
|
||||
.setIcon(
|
||||
IconCompat.createWithAdaptiveBitmap(
|
||||
layerDrawable.toBitmap(config = Bitmap.Config.ARGB_8888)
|
||||
activity.lifecycleScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
val layerDrawable = ResourcesCompat.getDrawable(
|
||||
YuzuApplication.appContext.resources,
|
||||
R.drawable.shortcut,
|
||||
null
|
||||
) as LayerDrawable
|
||||
layerDrawable.setDrawableByLayerId(
|
||||
R.id.shortcut_foreground,
|
||||
GameIconUtils.getGameIcon(activity, holder.game)
|
||||
.toDrawable(YuzuApplication.appContext.resources)
|
||||
)
|
||||
)
|
||||
.setIntent(openIntent)
|
||||
.build()
|
||||
ShortcutManagerCompat.pushDynamicShortcut(YuzuApplication.appContext, shortcut)
|
||||
val inset = YuzuApplication.appContext.resources
|
||||
.getDimensionPixelSize(R.dimen.icon_inset)
|
||||
layerDrawable.setLayerInset(1, inset, inset, inset, inset)
|
||||
val shortcut =
|
||||
ShortcutInfoCompat.Builder(YuzuApplication.appContext, holder.game.path)
|
||||
.setShortLabel(holder.game.title)
|
||||
.setIcon(
|
||||
IconCompat.createWithAdaptiveBitmap(
|
||||
layerDrawable.toBitmap(config = Bitmap.Config.ARGB_8888)
|
||||
)
|
||||
)
|
||||
.setIntent(openIntent)
|
||||
.build()
|
||||
ShortcutManagerCompat.pushDynamicShortcut(YuzuApplication.appContext, shortcut)
|
||||
}
|
||||
}
|
||||
|
||||
val action = HomeNavigationDirections.actionGlobalEmulationActivity(holder.game)
|
||||
val action = HomeNavigationDirections.actionGlobalEmulationActivity(holder.game, true)
|
||||
view.findNavController().navigate(action)
|
||||
}
|
||||
|
||||
override fun onLongClick(view: View): Boolean {
|
||||
val holder = view.tag as GameViewHolder
|
||||
val action = HomeNavigationDirections.actionGlobalPerGamePropertiesFragment(holder.game)
|
||||
view.findNavController().navigate(action)
|
||||
return true
|
||||
}
|
||||
|
||||
inner class GameViewHolder(val binding: CardGameBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
lateinit var game: Game
|
||||
@@ -147,7 +165,7 @@ class GameAdapter(private val activity: AppCompatActivity) :
|
||||
|
||||
private class DiffCallback : DiffUtil.ItemCallback<Game>() {
|
||||
override fun areItemsTheSame(oldItem: Game, newItem: Game): Boolean {
|
||||
return oldItem.programId == newItem.programId
|
||||
return oldItem == newItem
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(oldItem: Game, newItem: Game): Boolean {
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.yuzu.yuzu_emu.adapters
|
||||
|
||||
import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlinx.coroutines.launch
|
||||
import org.yuzu.yuzu_emu.databinding.CardInstallableIconBinding
|
||||
import org.yuzu.yuzu_emu.databinding.CardSimpleOutlinedBinding
|
||||
import org.yuzu.yuzu_emu.model.GameProperty
|
||||
import org.yuzu.yuzu_emu.model.InstallableProperty
|
||||
import org.yuzu.yuzu_emu.model.SubmenuProperty
|
||||
|
||||
class GamePropertiesAdapter(
|
||||
private val viewLifecycle: LifecycleOwner,
|
||||
private var properties: List<GameProperty>
|
||||
) :
|
||||
RecyclerView.Adapter<GamePropertiesAdapter.GamePropertyViewHolder>() {
|
||||
override fun onCreateViewHolder(
|
||||
parent: ViewGroup,
|
||||
viewType: Int
|
||||
): GamePropertyViewHolder {
|
||||
val inflater = LayoutInflater.from(parent.context)
|
||||
return when (viewType) {
|
||||
PropertyType.Submenu.ordinal -> {
|
||||
SubmenuPropertyViewHolder(
|
||||
CardSimpleOutlinedBinding.inflate(
|
||||
inflater,
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
else -> InstallablePropertyViewHolder(
|
||||
CardInstallableIconBinding.inflate(
|
||||
inflater,
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = properties.size
|
||||
|
||||
override fun onBindViewHolder(holder: GamePropertyViewHolder, position: Int) =
|
||||
holder.bind(properties[position])
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return when (properties[position]) {
|
||||
is SubmenuProperty -> PropertyType.Submenu.ordinal
|
||||
else -> PropertyType.Installable.ordinal
|
||||
}
|
||||
}
|
||||
|
||||
sealed class GamePropertyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
abstract fun bind(property: GameProperty)
|
||||
}
|
||||
|
||||
inner class SubmenuPropertyViewHolder(val binding: CardSimpleOutlinedBinding) :
|
||||
GamePropertyViewHolder(binding.root) {
|
||||
override fun bind(property: GameProperty) {
|
||||
val submenuProperty = property as SubmenuProperty
|
||||
|
||||
binding.root.setOnClickListener {
|
||||
submenuProperty.action.invoke()
|
||||
}
|
||||
|
||||
binding.title.setText(submenuProperty.titleId)
|
||||
binding.description.setText(submenuProperty.descriptionId)
|
||||
binding.icon.setImageDrawable(
|
||||
ResourcesCompat.getDrawable(
|
||||
binding.icon.context.resources,
|
||||
submenuProperty.iconId,
|
||||
binding.icon.context.theme
|
||||
)
|
||||
)
|
||||
|
||||
binding.details.postDelayed({
|
||||
binding.details.isSelected = true
|
||||
binding.details.ellipsize = TextUtils.TruncateAt.MARQUEE
|
||||
}, 3000)
|
||||
|
||||
if (submenuProperty.details != null) {
|
||||
binding.details.visibility = View.VISIBLE
|
||||
binding.details.text = submenuProperty.details.invoke()
|
||||
} else if (submenuProperty.detailsFlow != null) {
|
||||
binding.details.visibility = View.VISIBLE
|
||||
viewLifecycle.lifecycleScope.launch {
|
||||
viewLifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||
submenuProperty.detailsFlow.collect { binding.details.text = it }
|
||||
}
|
||||
}
|
||||
} else {
|
||||
binding.details.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inner class InstallablePropertyViewHolder(val binding: CardInstallableIconBinding) :
|
||||
GamePropertyViewHolder(binding.root) {
|
||||
override fun bind(property: GameProperty) {
|
||||
val installableProperty = property as InstallableProperty
|
||||
|
||||
binding.title.setText(installableProperty.titleId)
|
||||
binding.description.setText(installableProperty.descriptionId)
|
||||
binding.icon.setImageDrawable(
|
||||
ResourcesCompat.getDrawable(
|
||||
binding.icon.context.resources,
|
||||
installableProperty.iconId,
|
||||
binding.icon.context.theme
|
||||
)
|
||||
)
|
||||
|
||||
if (installableProperty.install != null) {
|
||||
binding.buttonInstall.visibility = View.VISIBLE
|
||||
binding.buttonInstall.setOnClickListener { installableProperty.install.invoke() }
|
||||
}
|
||||
if (installableProperty.export != null) {
|
||||
binding.buttonExport.visibility = View.VISIBLE
|
||||
binding.buttonExport.setOnClickListener { installableProperty.export.invoke() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum class PropertyType {
|
||||
Submenu,
|
||||
Installable
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -4,7 +4,6 @@
|
||||
package org.yuzu.yuzu_emu.features.settings.model
|
||||
|
||||
interface AbstractBooleanSetting : AbstractSetting {
|
||||
val boolean: Boolean
|
||||
|
||||
fun getBoolean(needsGlobal: Boolean = false): Boolean
|
||||
fun setBoolean(value: Boolean)
|
||||
}
|
||||
|
||||
+1
-2
@@ -4,7 +4,6 @@
|
||||
package org.yuzu.yuzu_emu.features.settings.model
|
||||
|
||||
interface AbstractByteSetting : AbstractSetting {
|
||||
val byte: Byte
|
||||
|
||||
fun getByte(needsGlobal: Boolean = false): Byte
|
||||
fun setByte(value: Byte)
|
||||
}
|
||||
|
||||
+1
-2
@@ -4,7 +4,6 @@
|
||||
package org.yuzu.yuzu_emu.features.settings.model
|
||||
|
||||
interface AbstractFloatSetting : AbstractSetting {
|
||||
val float: Float
|
||||
|
||||
fun getFloat(needsGlobal: Boolean = false): Float
|
||||
fun setFloat(value: Float)
|
||||
}
|
||||
|
||||
+1
-2
@@ -4,7 +4,6 @@
|
||||
package org.yuzu.yuzu_emu.features.settings.model
|
||||
|
||||
interface AbstractIntSetting : AbstractSetting {
|
||||
val int: Int
|
||||
|
||||
fun getInt(needsGlobal: Boolean = false): Int
|
||||
fun setInt(value: Int)
|
||||
}
|
||||
|
||||
+1
-2
@@ -4,7 +4,6 @@
|
||||
package org.yuzu.yuzu_emu.features.settings.model
|
||||
|
||||
interface AbstractLongSetting : AbstractSetting {
|
||||
val long: Long
|
||||
|
||||
fun getLong(needsGlobal: Boolean = false): Long
|
||||
fun setLong(value: Long)
|
||||
}
|
||||
|
||||
+12
-5
@@ -7,12 +7,7 @@ import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||
|
||||
interface AbstractSetting {
|
||||
val key: String
|
||||
val category: Settings.Category
|
||||
val defaultValue: Any
|
||||
val androidDefault: Any?
|
||||
get() = null
|
||||
val valueAsString: String
|
||||
get() = ""
|
||||
|
||||
val isRuntimeModifiable: Boolean
|
||||
get() = NativeConfig.getIsRuntimeModifiable(key)
|
||||
@@ -20,5 +15,17 @@ interface AbstractSetting {
|
||||
val pairedSettingKey: String
|
||||
get() = NativeConfig.getPairedSettingKey(key)
|
||||
|
||||
val isSwitchable: Boolean
|
||||
get() = NativeConfig.getIsSwitchable(key)
|
||||
|
||||
var global: Boolean
|
||||
get() = NativeConfig.usingGlobal(key)
|
||||
set(value) = NativeConfig.setGlobal(key, value)
|
||||
|
||||
val isSaveable: Boolean
|
||||
get() = NativeConfig.getIsSaveable(key)
|
||||
|
||||
fun getValueAsString(needsGlobal: Boolean = false): String
|
||||
|
||||
fun reset()
|
||||
}
|
||||
|
||||
+1
-2
@@ -4,7 +4,6 @@
|
||||
package org.yuzu.yuzu_emu.features.settings.model
|
||||
|
||||
interface AbstractShortSetting : AbstractSetting {
|
||||
val short: Short
|
||||
|
||||
fun getShort(needsGlobal: Boolean = false): Short
|
||||
fun setShort(value: Short)
|
||||
}
|
||||
|
||||
+1
-2
@@ -4,7 +4,6 @@
|
||||
package org.yuzu.yuzu_emu.features.settings.model
|
||||
|
||||
interface AbstractStringSetting : AbstractSetting {
|
||||
val string: String
|
||||
|
||||
fun getString(needsGlobal: Boolean = false): String
|
||||
fun setString(value: String)
|
||||
}
|
||||
|
||||
+24
-26
@@ -5,36 +5,34 @@ package org.yuzu.yuzu_emu.features.settings.model
|
||||
|
||||
import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||
|
||||
enum class BooleanSetting(
|
||||
override val key: String,
|
||||
override val category: Settings.Category,
|
||||
override val androidDefault: Boolean? = null
|
||||
) : AbstractBooleanSetting {
|
||||
AUDIO_MUTED("audio_muted", Settings.Category.Audio),
|
||||
CPU_DEBUG_MODE("cpu_debug_mode", Settings.Category.Cpu),
|
||||
FASTMEM("cpuopt_fastmem", Settings.Category.Cpu),
|
||||
FASTMEM_EXCLUSIVES("cpuopt_fastmem_exclusives", Settings.Category.Cpu),
|
||||
RENDERER_USE_SPEED_LIMIT("use_speed_limit", Settings.Category.Core),
|
||||
USE_DOCKED_MODE("use_docked_mode", Settings.Category.System, false),
|
||||
RENDERER_USE_DISK_SHADER_CACHE("use_disk_shader_cache", Settings.Category.Renderer),
|
||||
RENDERER_FORCE_MAX_CLOCK("force_max_clock", Settings.Category.Renderer),
|
||||
RENDERER_ASYNCHRONOUS_SHADERS("use_asynchronous_shaders", Settings.Category.Renderer),
|
||||
RENDERER_REACTIVE_FLUSHING("use_reactive_flushing", Settings.Category.Renderer, false),
|
||||
RENDERER_DEBUG("debug", Settings.Category.Renderer),
|
||||
PICTURE_IN_PICTURE("picture_in_picture", Settings.Category.Android),
|
||||
USE_CUSTOM_RTC("custom_rtc_enabled", Settings.Category.System);
|
||||
enum class BooleanSetting(override val key: String) : AbstractBooleanSetting {
|
||||
AUDIO_MUTED("audio_muted"),
|
||||
CPU_DEBUG_MODE("cpu_debug_mode"),
|
||||
FASTMEM("cpuopt_fastmem"),
|
||||
FASTMEM_EXCLUSIVES("cpuopt_fastmem_exclusives"),
|
||||
RENDERER_USE_SPEED_LIMIT("use_speed_limit"),
|
||||
USE_DOCKED_MODE("use_docked_mode"),
|
||||
RENDERER_USE_DISK_SHADER_CACHE("use_disk_shader_cache"),
|
||||
RENDERER_FORCE_MAX_CLOCK("force_max_clock"),
|
||||
RENDERER_ASYNCHRONOUS_SHADERS("use_asynchronous_shaders"),
|
||||
RENDERER_REACTIVE_FLUSHING("use_reactive_flushing"),
|
||||
RENDERER_DEBUG("debug"),
|
||||
PICTURE_IN_PICTURE("picture_in_picture"),
|
||||
USE_CUSTOM_RTC("custom_rtc_enabled");
|
||||
|
||||
override val boolean: Boolean
|
||||
get() = NativeConfig.getBoolean(key, false)
|
||||
override fun getBoolean(needsGlobal: Boolean): Boolean =
|
||||
NativeConfig.getBoolean(key, needsGlobal)
|
||||
|
||||
override fun setBoolean(value: Boolean) = NativeConfig.setBoolean(key, value)
|
||||
|
||||
override val defaultValue: Boolean by lazy {
|
||||
androidDefault ?: NativeConfig.getBoolean(key, true)
|
||||
override fun setBoolean(value: Boolean) {
|
||||
if (NativeConfig.isPerGameConfigLoaded()) {
|
||||
global = false
|
||||
}
|
||||
NativeConfig.setBoolean(key, value)
|
||||
}
|
||||
|
||||
override val valueAsString: String
|
||||
get() = if (boolean) "1" else "0"
|
||||
override val defaultValue: Boolean by lazy { NativeConfig.getDefaultToString(key).toBoolean() }
|
||||
|
||||
override fun getValueAsString(needsGlobal: Boolean): String = getBoolean(needsGlobal).toString()
|
||||
|
||||
override fun reset() = NativeConfig.setBoolean(key, defaultValue)
|
||||
}
|
||||
|
||||
+11
-11
@@ -5,21 +5,21 @@ package org.yuzu.yuzu_emu.features.settings.model
|
||||
|
||||
import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||
|
||||
enum class ByteSetting(
|
||||
override val key: String,
|
||||
override val category: Settings.Category
|
||||
) : AbstractByteSetting {
|
||||
AUDIO_VOLUME("volume", Settings.Category.Audio);
|
||||
enum class ByteSetting(override val key: String) : AbstractByteSetting {
|
||||
AUDIO_VOLUME("volume");
|
||||
|
||||
override val byte: Byte
|
||||
get() = NativeConfig.getByte(key, false)
|
||||
override fun getByte(needsGlobal: Boolean): Byte = NativeConfig.getByte(key, needsGlobal)
|
||||
|
||||
override fun setByte(value: Byte) = NativeConfig.setByte(key, value)
|
||||
override fun setByte(value: Byte) {
|
||||
if (NativeConfig.isPerGameConfigLoaded()) {
|
||||
global = false
|
||||
}
|
||||
NativeConfig.setByte(key, value)
|
||||
}
|
||||
|
||||
override val defaultValue: Byte by lazy { NativeConfig.getByte(key, true) }
|
||||
override val defaultValue: Byte by lazy { NativeConfig.getDefaultToString(key).toByte() }
|
||||
|
||||
override val valueAsString: String
|
||||
get() = byte.toString()
|
||||
override fun getValueAsString(needsGlobal: Boolean): String = getByte(needsGlobal).toString()
|
||||
|
||||
override fun reset() = NativeConfig.setByte(key, defaultValue)
|
||||
}
|
||||
|
||||
+11
-11
@@ -5,22 +5,22 @@ package org.yuzu.yuzu_emu.features.settings.model
|
||||
|
||||
import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||
|
||||
enum class FloatSetting(
|
||||
override val key: String,
|
||||
override val category: Settings.Category
|
||||
) : AbstractFloatSetting {
|
||||
enum class FloatSetting(override val key: String) : AbstractFloatSetting {
|
||||
// No float settings currently exist
|
||||
EMPTY_SETTING("", Settings.Category.UiGeneral);
|
||||
EMPTY_SETTING("");
|
||||
|
||||
override val float: Float
|
||||
get() = NativeConfig.getFloat(key, false)
|
||||
override fun getFloat(needsGlobal: Boolean): Float = NativeConfig.getFloat(key, false)
|
||||
|
||||
override fun setFloat(value: Float) = NativeConfig.setFloat(key, value)
|
||||
override fun setFloat(value: Float) {
|
||||
if (NativeConfig.isPerGameConfigLoaded()) {
|
||||
global = false
|
||||
}
|
||||
NativeConfig.setFloat(key, value)
|
||||
}
|
||||
|
||||
override val defaultValue: Float by lazy { NativeConfig.getFloat(key, true) }
|
||||
override val defaultValue: Float by lazy { NativeConfig.getDefaultToString(key).toFloat() }
|
||||
|
||||
override val valueAsString: String
|
||||
get() = float.toString()
|
||||
override fun getValueAsString(needsGlobal: Boolean): String = getFloat(needsGlobal).toString()
|
||||
|
||||
override fun reset() = NativeConfig.setFloat(key, defaultValue)
|
||||
}
|
||||
|
||||
+23
-25
@@ -5,35 +5,33 @@ package org.yuzu.yuzu_emu.features.settings.model
|
||||
|
||||
import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||
|
||||
enum class IntSetting(
|
||||
override val key: String,
|
||||
override val category: Settings.Category,
|
||||
override val androidDefault: Int? = null
|
||||
) : AbstractIntSetting {
|
||||
CPU_ACCURACY("cpu_accuracy", Settings.Category.Cpu),
|
||||
REGION_INDEX("region_index", Settings.Category.System),
|
||||
LANGUAGE_INDEX("language_index", Settings.Category.System),
|
||||
RENDERER_BACKEND("backend", Settings.Category.Renderer),
|
||||
RENDERER_ACCURACY("gpu_accuracy", Settings.Category.Renderer, 0),
|
||||
RENDERER_RESOLUTION("resolution_setup", Settings.Category.Renderer),
|
||||
RENDERER_VSYNC("use_vsync", Settings.Category.Renderer),
|
||||
RENDERER_SCALING_FILTER("scaling_filter", Settings.Category.Renderer),
|
||||
RENDERER_ANTI_ALIASING("anti_aliasing", Settings.Category.Renderer),
|
||||
RENDERER_SCREEN_LAYOUT("screen_layout", Settings.Category.Android),
|
||||
RENDERER_ASPECT_RATIO("aspect_ratio", Settings.Category.Renderer),
|
||||
AUDIO_OUTPUT_ENGINE("output_engine", Settings.Category.Audio);
|
||||
enum class IntSetting(override val key: String) : AbstractIntSetting {
|
||||
CPU_BACKEND("cpu_backend"),
|
||||
CPU_ACCURACY("cpu_accuracy"),
|
||||
REGION_INDEX("region_index"),
|
||||
LANGUAGE_INDEX("language_index"),
|
||||
RENDERER_BACKEND("backend"),
|
||||
RENDERER_ACCURACY("gpu_accuracy"),
|
||||
RENDERER_RESOLUTION("resolution_setup"),
|
||||
RENDERER_VSYNC("use_vsync"),
|
||||
RENDERER_SCALING_FILTER("scaling_filter"),
|
||||
RENDERER_ANTI_ALIASING("anti_aliasing"),
|
||||
RENDERER_SCREEN_LAYOUT("screen_layout"),
|
||||
RENDERER_ASPECT_RATIO("aspect_ratio"),
|
||||
AUDIO_OUTPUT_ENGINE("output_engine");
|
||||
|
||||
override val int: Int
|
||||
get() = NativeConfig.getInt(key, false)
|
||||
override fun getInt(needsGlobal: Boolean): Int = NativeConfig.getInt(key, needsGlobal)
|
||||
|
||||
override fun setInt(value: Int) = NativeConfig.setInt(key, value)
|
||||
|
||||
override val defaultValue: Int by lazy {
|
||||
androidDefault ?: NativeConfig.getInt(key, true)
|
||||
override fun setInt(value: Int) {
|
||||
if (NativeConfig.isPerGameConfigLoaded()) {
|
||||
global = false
|
||||
}
|
||||
NativeConfig.setInt(key, value)
|
||||
}
|
||||
|
||||
override val valueAsString: String
|
||||
get() = int.toString()
|
||||
override val defaultValue: Int by lazy { NativeConfig.getDefaultToString(key).toInt() }
|
||||
|
||||
override fun getValueAsString(needsGlobal: Boolean): String = getInt(needsGlobal).toString()
|
||||
|
||||
override fun reset() = NativeConfig.setInt(key, defaultValue)
|
||||
}
|
||||
|
||||
+11
-11
@@ -5,21 +5,21 @@ package org.yuzu.yuzu_emu.features.settings.model
|
||||
|
||||
import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||
|
||||
enum class LongSetting(
|
||||
override val key: String,
|
||||
override val category: Settings.Category
|
||||
) : AbstractLongSetting {
|
||||
CUSTOM_RTC("custom_rtc", Settings.Category.System);
|
||||
enum class LongSetting(override val key: String) : AbstractLongSetting {
|
||||
CUSTOM_RTC("custom_rtc");
|
||||
|
||||
override val long: Long
|
||||
get() = NativeConfig.getLong(key, false)
|
||||
override fun getLong(needsGlobal: Boolean): Long = NativeConfig.getLong(key, needsGlobal)
|
||||
|
||||
override fun setLong(value: Long) = NativeConfig.setLong(key, value)
|
||||
override fun setLong(value: Long) {
|
||||
if (NativeConfig.isPerGameConfigLoaded()) {
|
||||
global = false
|
||||
}
|
||||
NativeConfig.setLong(key, value)
|
||||
}
|
||||
|
||||
override val defaultValue: Long by lazy { NativeConfig.getLong(key, true) }
|
||||
override val defaultValue: Long by lazy { NativeConfig.getDefaultToString(key).toLong() }
|
||||
|
||||
override val valueAsString: String
|
||||
get() = long.toString()
|
||||
override fun getValueAsString(needsGlobal: Boolean): String = getLong(needsGlobal).toString()
|
||||
|
||||
override fun reset() = NativeConfig.setLong(key, defaultValue)
|
||||
}
|
||||
|
||||
@@ -3,90 +3,14 @@
|
||||
|
||||
package org.yuzu.yuzu_emu.features.settings.model
|
||||
|
||||
import android.text.TextUtils
|
||||
import android.widget.Toast
|
||||
import org.yuzu.yuzu_emu.R
|
||||
import org.yuzu.yuzu_emu.YuzuApplication
|
||||
import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile
|
||||
|
||||
object Settings {
|
||||
private val context get() = YuzuApplication.appContext
|
||||
|
||||
fun saveSettings(gameId: String = "") {
|
||||
if (TextUtils.isEmpty(gameId)) {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.ini_saved),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
SettingsFile.saveFile(SettingsFile.FILE_NAME_CONFIG)
|
||||
} else {
|
||||
// TODO: Save custom game settings
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.gameid_saved, gameId),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
enum class Category {
|
||||
Android,
|
||||
Audio,
|
||||
Core,
|
||||
Cpu,
|
||||
CpuDebug,
|
||||
CpuUnsafe,
|
||||
Renderer,
|
||||
RendererAdvanced,
|
||||
RendererDebug,
|
||||
System,
|
||||
SystemAudio,
|
||||
DataStorage,
|
||||
Debugging,
|
||||
DebuggingGraphics,
|
||||
Miscellaneous,
|
||||
Network,
|
||||
WebService,
|
||||
AddOns,
|
||||
Controls,
|
||||
Ui,
|
||||
UiGeneral,
|
||||
UiLayout,
|
||||
UiGameList,
|
||||
Screenshots,
|
||||
Shortcuts,
|
||||
Multiplayer,
|
||||
Services,
|
||||
Paths,
|
||||
MaxEnum
|
||||
}
|
||||
|
||||
val settingsList = listOf<AbstractSetting>(
|
||||
*BooleanSetting.values(),
|
||||
*ByteSetting.values(),
|
||||
*ShortSetting.values(),
|
||||
*IntSetting.values(),
|
||||
*FloatSetting.values(),
|
||||
*LongSetting.values(),
|
||||
*StringSetting.values()
|
||||
)
|
||||
|
||||
const val SECTION_GENERAL = "General"
|
||||
const val SECTION_SYSTEM = "System"
|
||||
const val SECTION_RENDERER = "Renderer"
|
||||
const val SECTION_AUDIO = "Audio"
|
||||
const val SECTION_CPU = "Cpu"
|
||||
const val SECTION_THEME = "Theme"
|
||||
const val SECTION_DEBUG = "Debug"
|
||||
|
||||
enum class MenuTag(val titleId: Int) {
|
||||
SECTION_ROOT(R.string.advanced_settings),
|
||||
SECTION_GENERAL(R.string.preferences_general),
|
||||
SECTION_SYSTEM(R.string.preferences_system),
|
||||
SECTION_RENDERER(R.string.preferences_graphics),
|
||||
SECTION_AUDIO(R.string.preferences_audio),
|
||||
SECTION_CPU(R.string.cpu),
|
||||
SECTION_THEME(R.string.preferences_theme),
|
||||
SECTION_DEBUG(R.string.preferences_debug);
|
||||
}
|
||||
|
||||
+11
-11
@@ -5,21 +5,21 @@ package org.yuzu.yuzu_emu.features.settings.model
|
||||
|
||||
import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||
|
||||
enum class ShortSetting(
|
||||
override val key: String,
|
||||
override val category: Settings.Category
|
||||
) : AbstractShortSetting {
|
||||
RENDERER_SPEED_LIMIT("speed_limit", Settings.Category.Core);
|
||||
enum class ShortSetting(override val key: String) : AbstractShortSetting {
|
||||
RENDERER_SPEED_LIMIT("speed_limit");
|
||||
|
||||
override val short: Short
|
||||
get() = NativeConfig.getShort(key, false)
|
||||
override fun getShort(needsGlobal: Boolean): Short = NativeConfig.getShort(key, needsGlobal)
|
||||
|
||||
override fun setShort(value: Short) = NativeConfig.setShort(key, value)
|
||||
override fun setShort(value: Short) {
|
||||
if (NativeConfig.isPerGameConfigLoaded()) {
|
||||
global = false
|
||||
}
|
||||
NativeConfig.setShort(key, value)
|
||||
}
|
||||
|
||||
override val defaultValue: Short by lazy { NativeConfig.getShort(key, true) }
|
||||
override val defaultValue: Short by lazy { NativeConfig.getDefaultToString(key).toShort() }
|
||||
|
||||
override val valueAsString: String
|
||||
get() = short.toString()
|
||||
override fun getValueAsString(needsGlobal: Boolean): String = getShort(needsGlobal).toString()
|
||||
|
||||
override fun reset() = NativeConfig.setShort(key, defaultValue)
|
||||
}
|
||||
|
||||
+11
-12
@@ -5,22 +5,21 @@ package org.yuzu.yuzu_emu.features.settings.model
|
||||
|
||||
import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||
|
||||
enum class StringSetting(
|
||||
override val key: String,
|
||||
override val category: Settings.Category
|
||||
) : AbstractStringSetting {
|
||||
// No string settings currently exist
|
||||
EMPTY_SETTING("", Settings.Category.UiGeneral);
|
||||
enum class StringSetting(override val key: String) : AbstractStringSetting {
|
||||
DRIVER_PATH("driver_path");
|
||||
|
||||
override val string: String
|
||||
get() = NativeConfig.getString(key, false)
|
||||
override fun getString(needsGlobal: Boolean): String = NativeConfig.getString(key, needsGlobal)
|
||||
|
||||
override fun setString(value: String) = NativeConfig.setString(key, value)
|
||||
override fun setString(value: String) {
|
||||
if (NativeConfig.isPerGameConfigLoaded()) {
|
||||
global = false
|
||||
}
|
||||
NativeConfig.setString(key, value)
|
||||
}
|
||||
|
||||
override val defaultValue: String by lazy { NativeConfig.getString(key, true) }
|
||||
override val defaultValue: String by lazy { NativeConfig.getDefaultToString(key) }
|
||||
|
||||
override val valueAsString: String
|
||||
get() = string
|
||||
override fun getValueAsString(needsGlobal: Boolean): String = getString(needsGlobal)
|
||||
|
||||
override fun reset() = NativeConfig.setString(key, defaultValue)
|
||||
}
|
||||
|
||||
+2
-3
@@ -12,7 +12,6 @@ class DateTimeSetting(
|
||||
) : SettingsItem(longSetting, titleId, descriptionId) {
|
||||
override val type = TYPE_DATETIME_SETTING
|
||||
|
||||
var value: Long
|
||||
get() = longSetting.long
|
||||
set(value) = (setting as AbstractLongSetting).setLong(value)
|
||||
fun getValue(needsGlobal: Boolean = false): Long = longSetting.getLong(needsGlobal)
|
||||
fun setValue(value: Long) = (setting as AbstractLongSetting).setLong(value)
|
||||
}
|
||||
|
||||
+3
@@ -3,10 +3,13 @@
|
||||
|
||||
package org.yuzu.yuzu_emu.features.settings.model.view
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
|
||||
class RunnableSetting(
|
||||
titleId: Int,
|
||||
descriptionId: Int,
|
||||
val isRuntimeRunnable: Boolean,
|
||||
@DrawableRes val iconId: Int = 0,
|
||||
val runnable: () -> Unit
|
||||
) : SettingsItem(emptySetting, titleId, descriptionId) {
|
||||
override val type = TYPE_RUNNABLE
|
||||
|
||||
+48
-7
@@ -11,8 +11,8 @@ import org.yuzu.yuzu_emu.features.settings.model.BooleanSetting
|
||||
import org.yuzu.yuzu_emu.features.settings.model.ByteSetting
|
||||
import org.yuzu.yuzu_emu.features.settings.model.IntSetting
|
||||
import org.yuzu.yuzu_emu.features.settings.model.LongSetting
|
||||
import org.yuzu.yuzu_emu.features.settings.model.Settings
|
||||
import org.yuzu.yuzu_emu.features.settings.model.ShortSetting
|
||||
import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||
|
||||
/**
|
||||
* ViewModel abstraction for an Item in the RecyclerView powering SettingsFragments.
|
||||
@@ -30,10 +30,26 @@ abstract class SettingsItem(
|
||||
|
||||
val isEditable: Boolean
|
||||
get() {
|
||||
// Can't edit settings that aren't saveable in per-game config even if they are switchable
|
||||
if (NativeConfig.isPerGameConfigLoaded() && !setting.isSaveable) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (!NativeLibrary.isRunning()) return true
|
||||
|
||||
// Prevent editing settings that were modified in per-game config while editing global
|
||||
// config
|
||||
if (!NativeConfig.isPerGameConfigLoaded() && !setting.global) {
|
||||
return false
|
||||
}
|
||||
|
||||
return setting.isRuntimeModifiable
|
||||
}
|
||||
|
||||
val needsRuntimeGlobal: Boolean
|
||||
get() = NativeLibrary.isRunning() && !setting.global &&
|
||||
!NativeConfig.isPerGameConfigLoaded()
|
||||
|
||||
companion object {
|
||||
const val TYPE_HEADER = 0
|
||||
const val TYPE_SWITCH = 1
|
||||
@@ -48,8 +64,9 @@ abstract class SettingsItem(
|
||||
|
||||
val emptySetting = object : AbstractSetting {
|
||||
override val key: String = ""
|
||||
override val category: Settings.Category = Settings.Category.Ui
|
||||
override val defaultValue: Any = false
|
||||
override val isSaveable = true
|
||||
override fun getValueAsString(needsGlobal: Boolean): String = ""
|
||||
override fun reset() {}
|
||||
}
|
||||
|
||||
@@ -73,10 +90,19 @@ abstract class SettingsItem(
|
||||
R.string.frame_limit_slider,
|
||||
R.string.frame_limit_slider_description,
|
||||
1,
|
||||
200,
|
||||
400,
|
||||
"%"
|
||||
)
|
||||
)
|
||||
put(
|
||||
SingleChoiceSetting(
|
||||
IntSetting.CPU_BACKEND,
|
||||
R.string.cpu_backend,
|
||||
0,
|
||||
R.array.cpuBackendArm64Names,
|
||||
R.array.cpuBackendArm64Values
|
||||
)
|
||||
)
|
||||
put(
|
||||
SingleChoiceSetting(
|
||||
IntSetting.CPU_ACCURACY,
|
||||
@@ -261,9 +287,9 @@ abstract class SettingsItem(
|
||||
)
|
||||
|
||||
val fastmem = object : AbstractBooleanSetting {
|
||||
override val boolean: Boolean
|
||||
get() =
|
||||
BooleanSetting.FASTMEM.boolean && BooleanSetting.FASTMEM_EXCLUSIVES.boolean
|
||||
override fun getBoolean(needsGlobal: Boolean): Boolean =
|
||||
BooleanSetting.FASTMEM.getBoolean() &&
|
||||
BooleanSetting.FASTMEM_EXCLUSIVES.getBoolean()
|
||||
|
||||
override fun setBoolean(value: Boolean) {
|
||||
BooleanSetting.FASTMEM.setBoolean(value)
|
||||
@@ -271,9 +297,24 @@ abstract class SettingsItem(
|
||||
}
|
||||
|
||||
override val key: String = FASTMEM_COMBINED
|
||||
override val category = Settings.Category.Cpu
|
||||
override val isRuntimeModifiable: Boolean = false
|
||||
override val defaultValue: Boolean = true
|
||||
override val isSwitchable: Boolean = true
|
||||
override var global: Boolean
|
||||
get() {
|
||||
return BooleanSetting.FASTMEM.global &&
|
||||
BooleanSetting.FASTMEM_EXCLUSIVES.global
|
||||
}
|
||||
set(value) {
|
||||
BooleanSetting.FASTMEM.global = value
|
||||
BooleanSetting.FASTMEM_EXCLUSIVES.global = value
|
||||
}
|
||||
|
||||
override val isSaveable = true
|
||||
|
||||
override fun getValueAsString(needsGlobal: Boolean): String =
|
||||
getBoolean().toString()
|
||||
|
||||
override fun reset() = setBoolean(defaultValue)
|
||||
}
|
||||
put(SwitchSetting(fastmem, R.string.fastmem, 0))
|
||||
|
||||
+6
-11
@@ -15,16 +15,11 @@ class SingleChoiceSetting(
|
||||
) : SettingsItem(setting, titleId, descriptionId) {
|
||||
override val type = TYPE_SINGLE_CHOICE
|
||||
|
||||
var selectedValue: Int
|
||||
get() {
|
||||
return when (setting) {
|
||||
is AbstractIntSetting -> setting.int
|
||||
else -> -1
|
||||
}
|
||||
}
|
||||
set(value) {
|
||||
when (setting) {
|
||||
is AbstractIntSetting -> setting.setInt(value)
|
||||
}
|
||||
fun getSelectedValue(needsGlobal: Boolean = false) =
|
||||
when (setting) {
|
||||
is AbstractIntSetting -> setting.getInt(needsGlobal)
|
||||
else -> -1
|
||||
}
|
||||
|
||||
fun setSelectedValue(value: Int) = (setting as AbstractIntSetting).setInt(value)
|
||||
}
|
||||
|
||||
+14
-16
@@ -20,22 +20,20 @@ class SliderSetting(
|
||||
) : SettingsItem(setting, titleId, descriptionId) {
|
||||
override val type = TYPE_SLIDER
|
||||
|
||||
var selectedValue: Int
|
||||
get() {
|
||||
return when (setting) {
|
||||
is AbstractByteSetting -> setting.byte.toInt()
|
||||
is AbstractShortSetting -> setting.short.toInt()
|
||||
is AbstractIntSetting -> setting.int
|
||||
is AbstractFloatSetting -> setting.float.roundToInt()
|
||||
else -> -1
|
||||
}
|
||||
fun getSelectedValue(needsGlobal: Boolean = false) =
|
||||
when (setting) {
|
||||
is AbstractByteSetting -> setting.getByte(needsGlobal).toInt()
|
||||
is AbstractShortSetting -> setting.getShort(needsGlobal).toInt()
|
||||
is AbstractIntSetting -> setting.getInt(needsGlobal)
|
||||
is AbstractFloatSetting -> setting.getFloat(needsGlobal).roundToInt()
|
||||
else -> -1
|
||||
}
|
||||
set(value) {
|
||||
when (setting) {
|
||||
is AbstractByteSetting -> setting.setByte(value.toByte())
|
||||
is AbstractShortSetting -> setting.setShort(value.toShort())
|
||||
is AbstractIntSetting -> setting.setInt(value)
|
||||
is AbstractFloatSetting -> setting.setFloat(value.toFloat())
|
||||
}
|
||||
|
||||
fun setSelectedValue(value: Int) =
|
||||
when (setting) {
|
||||
is AbstractByteSetting -> setting.setByte(value.toByte())
|
||||
is AbstractShortSetting -> setting.setShort(value.toShort())
|
||||
is AbstractFloatSetting -> setting.setFloat(value.toFloat())
|
||||
else -> (setting as AbstractIntSetting).setInt(value)
|
||||
}
|
||||
}
|
||||
|
||||
+3
-4
@@ -17,14 +17,13 @@ class StringSingleChoiceSetting(
|
||||
fun getValueAt(index: Int): String =
|
||||
if (index >= 0 && index < values.size) values[index] else ""
|
||||
|
||||
var selectedValue: String
|
||||
get() = stringSetting.string
|
||||
set(value) = stringSetting.setString(value)
|
||||
fun getSelectedValue(needsGlobal: Boolean = false) = stringSetting.getString(needsGlobal)
|
||||
fun setSelectedValue(value: String) = stringSetting.setString(value)
|
||||
|
||||
val selectValueIndex: Int
|
||||
get() {
|
||||
for (i in values.indices) {
|
||||
if (values[i] == selectedValue) {
|
||||
if (values[i] == getSelectedValue()) {
|
||||
return i
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -3,11 +3,14 @@
|
||||
|
||||
package org.yuzu.yuzu_emu.features.settings.model.view
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import org.yuzu.yuzu_emu.features.settings.model.Settings
|
||||
|
||||
class SubmenuSetting(
|
||||
titleId: Int,
|
||||
descriptionId: Int,
|
||||
@StringRes titleId: Int,
|
||||
@StringRes descriptionId: Int,
|
||||
@DrawableRes val iconId: Int,
|
||||
val menuKey: Settings.MenuTag
|
||||
) : SettingsItem(emptySetting, titleId, descriptionId) {
|
||||
override val type = TYPE_SUBMENU
|
||||
|
||||
+12
-12
@@ -14,18 +14,18 @@ class SwitchSetting(
|
||||
) : SettingsItem(setting, titleId, descriptionId) {
|
||||
override val type = TYPE_SWITCH
|
||||
|
||||
var checked: Boolean
|
||||
get() {
|
||||
return when (setting) {
|
||||
is AbstractIntSetting -> setting.int == 1
|
||||
is AbstractBooleanSetting -> setting.boolean
|
||||
else -> false
|
||||
}
|
||||
fun getIsChecked(needsGlobal: Boolean = false): Boolean {
|
||||
return when (setting) {
|
||||
is AbstractIntSetting -> setting.getInt(needsGlobal) == 1
|
||||
is AbstractBooleanSetting -> setting.getBoolean(needsGlobal)
|
||||
else -> false
|
||||
}
|
||||
set(value) {
|
||||
when (setting) {
|
||||
is AbstractIntSetting -> setting.setInt(if (value) 1 else 0)
|
||||
is AbstractBooleanSetting -> setting.setBoolean(value)
|
||||
}
|
||||
}
|
||||
|
||||
fun setChecked(value: Boolean) {
|
||||
when (setting) {
|
||||
is AbstractIntSetting -> setting.setInt(if (value) 1 else 0)
|
||||
is AbstractBooleanSetting -> setting.setBoolean(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+26
-36
@@ -25,7 +25,6 @@ import org.yuzu.yuzu_emu.NativeLibrary
|
||||
import java.io.IOException
|
||||
import org.yuzu.yuzu_emu.R
|
||||
import org.yuzu.yuzu_emu.databinding.ActivitySettingsBinding
|
||||
import org.yuzu.yuzu_emu.features.settings.model.Settings
|
||||
import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile
|
||||
import org.yuzu.yuzu_emu.fragments.ResetSettingsDialogFragment
|
||||
import org.yuzu.yuzu_emu.model.SettingsViewModel
|
||||
@@ -46,6 +45,9 @@ class SettingsActivity : AppCompatActivity() {
|
||||
binding = ActivitySettingsBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
if (!NativeConfig.isPerGameConfigLoaded() && args.game != null) {
|
||||
SettingsFile.loadCustomConfig(args.game!!)
|
||||
}
|
||||
settingsViewModel.game = args.game
|
||||
|
||||
val navHostFragment =
|
||||
@@ -54,10 +56,6 @@ class SettingsActivity : AppCompatActivity() {
|
||||
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
settingsViewModel.shouldSave = savedInstanceState.getBoolean(KEY_SHOULD_SAVE)
|
||||
}
|
||||
|
||||
if (InsetsHelper.getSystemGestureType(applicationContext) !=
|
||||
InsetsHelper.GESTURE_NAVIGATION
|
||||
) {
|
||||
@@ -128,48 +126,44 @@ class SettingsActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
// Critical: If super method is not called, rotations will be busted.
|
||||
super.onSaveInstanceState(outState)
|
||||
outState.putBoolean(KEY_SHOULD_SAVE, settingsViewModel.shouldSave)
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
// TODO: Load custom settings contextually
|
||||
if (!DirectoryInitialization.areDirectoriesReady) {
|
||||
DirectoryInitialization.start()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is called, the user has left the settings screen (potentially through the
|
||||
* home button) and will expect their changes to be persisted. So we kick off an
|
||||
* IntentService which will do so on a background thread.
|
||||
*/
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
if (isFinishing && settingsViewModel.shouldSave) {
|
||||
Log.debug("[SettingsActivity] Settings activity stopping. Saving settings to INI...")
|
||||
Settings.saveSettings()
|
||||
Log.info("[SettingsActivity] Settings activity stopping. Saving settings to INI...")
|
||||
if (isFinishing) {
|
||||
NativeLibrary.applySettings()
|
||||
if (args.game == null) {
|
||||
NativeConfig.saveGlobalConfig()
|
||||
} else if (NativeConfig.isPerGameConfigLoaded()) {
|
||||
NativeLibrary.logSettings()
|
||||
NativeConfig.savePerGameConfig()
|
||||
NativeConfig.unloadPerGameConfig()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
settingsViewModel.clear()
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
fun onSettingsReset() {
|
||||
// Prevents saving to a non-existent settings file
|
||||
settingsViewModel.shouldSave = false
|
||||
|
||||
// Delete settings file because the user may have changed values that do not exist in the UI
|
||||
val settingsFile = SettingsFile.getSettingsFile(SettingsFile.FILE_NAME_CONFIG)
|
||||
if (!settingsFile.delete()) {
|
||||
throw IOException("Failed to delete $settingsFile")
|
||||
if (args.game == null) {
|
||||
NativeConfig.unloadGlobalConfig()
|
||||
val settingsFile = SettingsFile.getSettingsFile(SettingsFile.FILE_NAME_CONFIG)
|
||||
if (!settingsFile.delete()) {
|
||||
throw IOException("Failed to delete $settingsFile")
|
||||
}
|
||||
NativeConfig.initializeGlobalConfig()
|
||||
} else {
|
||||
NativeConfig.unloadPerGameConfig()
|
||||
val settingsFile = SettingsFile.getCustomSettingsFile(args.game!!)
|
||||
if (!settingsFile.delete()) {
|
||||
throw IOException("Failed to delete $settingsFile")
|
||||
}
|
||||
}
|
||||
NativeLibrary.reloadSettings()
|
||||
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
@@ -194,8 +188,4 @@ class SettingsActivity : AppCompatActivity() {
|
||||
windowInsets
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val KEY_SHOULD_SAVE = "should_save"
|
||||
}
|
||||
}
|
||||
|
||||
+12
-7
@@ -102,10 +102,10 @@ class SettingsAdapter(
|
||||
return currentList[position].type
|
||||
}
|
||||
|
||||
fun onBooleanClick(item: SwitchSetting, checked: Boolean) {
|
||||
item.checked = checked
|
||||
fun onBooleanClick(item: SwitchSetting, checked: Boolean, position: Int) {
|
||||
item.setChecked(checked)
|
||||
notifyItemChanged(position)
|
||||
settingsViewModel.setShouldReloadSettingsList(true)
|
||||
settingsViewModel.shouldSave = true
|
||||
}
|
||||
|
||||
fun onSingleChoiceClick(item: SingleChoiceSetting, position: Int) {
|
||||
@@ -127,7 +127,7 @@ class SettingsAdapter(
|
||||
}
|
||||
|
||||
fun onDateTimeClick(item: DateTimeSetting, position: Int) {
|
||||
val storedTime = item.value * 1000
|
||||
val storedTime = item.getValue() * 1000
|
||||
|
||||
// Helper to extract hour and minute from epoch time
|
||||
val calendar: Calendar = Calendar.getInstance()
|
||||
@@ -160,10 +160,9 @@ class SettingsAdapter(
|
||||
var epochTime: Long = datePicker.selection!! / 1000
|
||||
epochTime += timePicker.hour.toLong() * 60 * 60
|
||||
epochTime += timePicker.minute.toLong() * 60
|
||||
if (item.value != epochTime) {
|
||||
settingsViewModel.shouldSave = true
|
||||
if (item.getValue() != epochTime) {
|
||||
notifyItemChanged(position)
|
||||
item.value = epochTime
|
||||
item.setValue(epochTime)
|
||||
}
|
||||
}
|
||||
datePicker.show(
|
||||
@@ -197,6 +196,12 @@ class SettingsAdapter(
|
||||
return true
|
||||
}
|
||||
|
||||
fun onClearClick(item: SettingsItem, position: Int) {
|
||||
item.setting.global = true
|
||||
notifyItemChanged(position)
|
||||
settingsViewModel.setShouldReloadSettingsList(true)
|
||||
}
|
||||
|
||||
private class DiffCallback : DiffUtil.ItemCallback<SettingsItem>() {
|
||||
override fun areItemsTheSame(oldItem: SettingsItem, newItem: SettingsItem): Boolean {
|
||||
return oldItem.setting.key == newItem.setting.key
|
||||
|
||||
+9
-29
@@ -20,7 +20,6 @@ import androidx.lifecycle.repeatOnLifecycle
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.google.android.material.divider.MaterialDividerItemDecoration
|
||||
import com.google.android.material.transition.MaterialSharedAxis
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -67,16 +66,16 @@ class SettingsFragment : Fragment() {
|
||||
args.menuTag
|
||||
)
|
||||
|
||||
binding.toolbarSettingsLayout.title = getString(args.menuTag.titleId)
|
||||
val dividerDecoration = MaterialDividerItemDecoration(
|
||||
requireContext(),
|
||||
LinearLayoutManager.VERTICAL
|
||||
)
|
||||
dividerDecoration.isLastItemDecorated = false
|
||||
binding.toolbarSettingsLayout.title = if (args.menuTag == Settings.MenuTag.SECTION_ROOT &&
|
||||
args.game != null
|
||||
) {
|
||||
args.game!!.title
|
||||
} else {
|
||||
getString(args.menuTag.titleId)
|
||||
}
|
||||
binding.listSettings.apply {
|
||||
adapter = settingsAdapter
|
||||
layoutManager = LinearLayoutManager(requireContext())
|
||||
addItemDecoration(dividerDecoration)
|
||||
}
|
||||
|
||||
binding.toolbarSettings.setNavigationOnClickListener {
|
||||
@@ -94,17 +93,6 @@ class SettingsFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
}
|
||||
launch {
|
||||
settingsViewModel.isUsingSearch.collectLatest {
|
||||
if (it) {
|
||||
reenterTransition = MaterialSharedAxis(MaterialSharedAxis.Z, true)
|
||||
exitTransition = MaterialSharedAxis(MaterialSharedAxis.Z, false)
|
||||
} else {
|
||||
reenterTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
|
||||
exitTransition = MaterialSharedAxis(MaterialSharedAxis.X, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (args.menuTag == Settings.MenuTag.SECTION_ROOT) {
|
||||
@@ -112,8 +100,6 @@ class SettingsFragment : Fragment() {
|
||||
binding.toolbarSettings.setOnMenuItemClickListener {
|
||||
when (it.itemId) {
|
||||
R.id.action_search -> {
|
||||
reenterTransition = MaterialSharedAxis(MaterialSharedAxis.Z, true)
|
||||
exitTransition = MaterialSharedAxis(MaterialSharedAxis.Z, false)
|
||||
view.findNavController()
|
||||
.navigate(R.id.action_settingsFragment_to_settingsSearchFragment)
|
||||
true
|
||||
@@ -129,11 +115,6 @@ class SettingsFragment : Fragment() {
|
||||
setInsets()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
settingsViewModel.setIsUsingSearch(false)
|
||||
}
|
||||
|
||||
private fun setInsets() {
|
||||
ViewCompat.setOnApplyWindowInsetsListener(
|
||||
binding.root
|
||||
@@ -144,10 +125,9 @@ class SettingsFragment : Fragment() {
|
||||
val leftInsets = barInsets.left + cutoutInsets.left
|
||||
val rightInsets = barInsets.right + cutoutInsets.right
|
||||
|
||||
val sideMargin = resources.getDimensionPixelSize(R.dimen.spacing_medlarge)
|
||||
val mlpSettingsList = binding.listSettings.layoutParams as MarginLayoutParams
|
||||
mlpSettingsList.leftMargin = sideMargin + leftInsets
|
||||
mlpSettingsList.rightMargin = sideMargin + rightInsets
|
||||
mlpSettingsList.leftMargin = leftInsets
|
||||
mlpSettingsList.rightMargin = rightInsets
|
||||
binding.listSettings.layoutParams = mlpSettingsList
|
||||
binding.listSettings.updatePadding(
|
||||
bottom = barInsets.bottom
|
||||
|
||||
+72
-32
@@ -3,11 +3,11 @@
|
||||
|
||||
package org.yuzu.yuzu_emu.features.settings.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Build
|
||||
import android.widget.Toast
|
||||
import androidx.preference.PreferenceManager
|
||||
import org.yuzu.yuzu_emu.NativeLibrary
|
||||
import org.yuzu.yuzu_emu.R
|
||||
import org.yuzu.yuzu_emu.YuzuApplication
|
||||
import org.yuzu.yuzu_emu.features.settings.model.AbstractBooleanSetting
|
||||
@@ -32,14 +32,27 @@ class SettingsFragmentPresenter(
|
||||
private val preferences: SharedPreferences
|
||||
get() = PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext)
|
||||
|
||||
private val context: Context get() = YuzuApplication.appContext
|
||||
|
||||
// Extension for populating settings list based on paired settings
|
||||
// Extension for altering settings list based on each setting's properties
|
||||
fun ArrayList<SettingsItem>.add(key: String) {
|
||||
val item = SettingsItem.settingsItems[key]!!
|
||||
if (settingsViewModel.game != null && !item.setting.isSwitchable) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!NativeConfig.isPerGameConfigLoaded() && !NativeLibrary.isRunning()) {
|
||||
item.setting.global = true
|
||||
}
|
||||
|
||||
val pairedSettingKey = item.setting.pairedSettingKey
|
||||
if (pairedSettingKey.isNotEmpty()) {
|
||||
val pairedSettingValue = NativeConfig.getBoolean(pairedSettingKey, false)
|
||||
val pairedSettingValue = NativeConfig.getBoolean(
|
||||
pairedSettingKey,
|
||||
if (NativeLibrary.isRunning() && !NativeConfig.isPerGameConfigLoaded()) {
|
||||
!NativeConfig.usingGlobal(pairedSettingKey)
|
||||
} else {
|
||||
NativeConfig.usingGlobal(pairedSettingKey)
|
||||
}
|
||||
)
|
||||
if (!pairedSettingValue) return
|
||||
}
|
||||
add(item)
|
||||
@@ -53,7 +66,6 @@ class SettingsFragmentPresenter(
|
||||
val sl = ArrayList<SettingsItem>()
|
||||
when (menuTag) {
|
||||
Settings.MenuTag.SECTION_ROOT -> addConfigSettings(sl)
|
||||
Settings.MenuTag.SECTION_GENERAL -> addGeneralSettings(sl)
|
||||
Settings.MenuTag.SECTION_SYSTEM -> addSystemSettings(sl)
|
||||
Settings.MenuTag.SECTION_RENDERER -> addGraphicsSettings(sl)
|
||||
Settings.MenuTag.SECTION_AUDIO -> addAudioSettings(sl)
|
||||
@@ -75,30 +87,53 @@ class SettingsFragmentPresenter(
|
||||
|
||||
private fun addConfigSettings(sl: ArrayList<SettingsItem>) {
|
||||
sl.apply {
|
||||
add(SubmenuSetting(R.string.preferences_general, 0, Settings.MenuTag.SECTION_GENERAL))
|
||||
add(SubmenuSetting(R.string.preferences_system, 0, Settings.MenuTag.SECTION_SYSTEM))
|
||||
add(SubmenuSetting(R.string.preferences_graphics, 0, Settings.MenuTag.SECTION_RENDERER))
|
||||
add(SubmenuSetting(R.string.preferences_audio, 0, Settings.MenuTag.SECTION_AUDIO))
|
||||
add(SubmenuSetting(R.string.preferences_debug, 0, Settings.MenuTag.SECTION_DEBUG))
|
||||
add(
|
||||
RunnableSetting(R.string.reset_to_default, 0, false) {
|
||||
settingsViewModel.setShouldShowResetSettingsDialog(true)
|
||||
}
|
||||
SubmenuSetting(
|
||||
R.string.preferences_system,
|
||||
R.string.preferences_system_description,
|
||||
R.drawable.ic_system_settings,
|
||||
Settings.MenuTag.SECTION_SYSTEM
|
||||
)
|
||||
)
|
||||
add(
|
||||
SubmenuSetting(
|
||||
R.string.preferences_graphics,
|
||||
R.string.preferences_graphics_description,
|
||||
R.drawable.ic_graphics,
|
||||
Settings.MenuTag.SECTION_RENDERER
|
||||
)
|
||||
)
|
||||
add(
|
||||
SubmenuSetting(
|
||||
R.string.preferences_audio,
|
||||
R.string.preferences_audio_description,
|
||||
R.drawable.ic_audio,
|
||||
Settings.MenuTag.SECTION_AUDIO
|
||||
)
|
||||
)
|
||||
add(
|
||||
SubmenuSetting(
|
||||
R.string.preferences_debug,
|
||||
R.string.preferences_debug_description,
|
||||
R.drawable.ic_code,
|
||||
Settings.MenuTag.SECTION_DEBUG
|
||||
)
|
||||
)
|
||||
add(
|
||||
RunnableSetting(
|
||||
R.string.reset_to_default,
|
||||
R.string.reset_to_default_description,
|
||||
false,
|
||||
R.drawable.ic_restore
|
||||
) { settingsViewModel.setShouldShowResetSettingsDialog(true) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun addGeneralSettings(sl: ArrayList<SettingsItem>) {
|
||||
sl.apply {
|
||||
add(BooleanSetting.RENDERER_USE_SPEED_LIMIT.key)
|
||||
add(ShortSetting.RENDERER_SPEED_LIMIT.key)
|
||||
add(IntSetting.CPU_ACCURACY.key)
|
||||
add(BooleanSetting.PICTURE_IN_PICTURE.key)
|
||||
}
|
||||
}
|
||||
|
||||
private fun addSystemSettings(sl: ArrayList<SettingsItem>) {
|
||||
sl.apply {
|
||||
add(BooleanSetting.RENDERER_USE_SPEED_LIMIT.key)
|
||||
add(ShortSetting.RENDERER_SPEED_LIMIT.key)
|
||||
add(BooleanSetting.USE_DOCKED_MODE.key)
|
||||
add(IntSetting.REGION_INDEX.key)
|
||||
add(IntSetting.LANGUAGE_INDEX.key)
|
||||
@@ -116,6 +151,7 @@ class SettingsFragmentPresenter(
|
||||
add(IntSetting.RENDERER_ANTI_ALIASING.key)
|
||||
add(IntSetting.RENDERER_SCREEN_LAYOUT.key)
|
||||
add(IntSetting.RENDERER_ASPECT_RATIO.key)
|
||||
add(BooleanSetting.PICTURE_IN_PICTURE.key)
|
||||
add(BooleanSetting.RENDERER_USE_DISK_SHADER_CACHE.key)
|
||||
add(BooleanSetting.RENDERER_FORCE_MAX_CLOCK.key)
|
||||
add(BooleanSetting.RENDERER_ASYNCHRONOUS_SHADERS.key)
|
||||
@@ -133,8 +169,8 @@ class SettingsFragmentPresenter(
|
||||
private fun addThemeSettings(sl: ArrayList<SettingsItem>) {
|
||||
sl.apply {
|
||||
val theme: AbstractIntSetting = object : AbstractIntSetting {
|
||||
override val int: Int
|
||||
get() = preferences.getInt(Settings.PREF_THEME, 0)
|
||||
override fun getInt(needsGlobal: Boolean): Int =
|
||||
preferences.getInt(Settings.PREF_THEME, 0)
|
||||
|
||||
override fun setInt(value: Int) {
|
||||
preferences.edit()
|
||||
@@ -144,8 +180,8 @@ class SettingsFragmentPresenter(
|
||||
}
|
||||
|
||||
override val key: String = Settings.PREF_THEME
|
||||
override val category = Settings.Category.UiGeneral
|
||||
override val isRuntimeModifiable: Boolean = false
|
||||
override fun getValueAsString(needsGlobal: Boolean): String = getInt().toString()
|
||||
override val defaultValue: Int = 0
|
||||
override fun reset() {
|
||||
preferences.edit()
|
||||
@@ -177,8 +213,8 @@ class SettingsFragmentPresenter(
|
||||
}
|
||||
|
||||
val themeMode: AbstractIntSetting = object : AbstractIntSetting {
|
||||
override val int: Int
|
||||
get() = preferences.getInt(Settings.PREF_THEME_MODE, -1)
|
||||
override fun getInt(needsGlobal: Boolean): Int =
|
||||
preferences.getInt(Settings.PREF_THEME_MODE, -1)
|
||||
|
||||
override fun setInt(value: Int) {
|
||||
preferences.edit()
|
||||
@@ -188,8 +224,8 @@ class SettingsFragmentPresenter(
|
||||
}
|
||||
|
||||
override val key: String = Settings.PREF_THEME_MODE
|
||||
override val category = Settings.Category.UiGeneral
|
||||
override val isRuntimeModifiable: Boolean = false
|
||||
override fun getValueAsString(needsGlobal: Boolean): String = getInt().toString()
|
||||
override val defaultValue: Int = -1
|
||||
override fun reset() {
|
||||
preferences.edit()
|
||||
@@ -210,8 +246,8 @@ class SettingsFragmentPresenter(
|
||||
)
|
||||
|
||||
val blackBackgrounds: AbstractBooleanSetting = object : AbstractBooleanSetting {
|
||||
override val boolean: Boolean
|
||||
get() = preferences.getBoolean(Settings.PREF_BLACK_BACKGROUNDS, false)
|
||||
override fun getBoolean(needsGlobal: Boolean): Boolean =
|
||||
preferences.getBoolean(Settings.PREF_BLACK_BACKGROUNDS, false)
|
||||
|
||||
override fun setBoolean(value: Boolean) {
|
||||
preferences.edit()
|
||||
@@ -221,8 +257,10 @@ class SettingsFragmentPresenter(
|
||||
}
|
||||
|
||||
override val key: String = Settings.PREF_BLACK_BACKGROUNDS
|
||||
override val category = Settings.Category.UiGeneral
|
||||
override val isRuntimeModifiable: Boolean = false
|
||||
override fun getValueAsString(needsGlobal: Boolean): String =
|
||||
getBoolean().toString()
|
||||
|
||||
override val defaultValue: Boolean = false
|
||||
override fun reset() {
|
||||
preferences.edit()
|
||||
@@ -249,6 +287,8 @@ class SettingsFragmentPresenter(
|
||||
add(BooleanSetting.RENDERER_DEBUG.key)
|
||||
|
||||
add(HeaderSetting(R.string.cpu))
|
||||
add(IntSetting.CPU_BACKEND.key)
|
||||
add(IntSetting.CPU_ACCURACY.key)
|
||||
add(BooleanSetting.CPU_DEBUG_MODE.key)
|
||||
add(SettingsItem.FASTMEM_COMBINED)
|
||||
}
|
||||
|
||||
+13
-1
@@ -13,6 +13,7 @@ import org.yuzu.yuzu_emu.databinding.ListItemSettingBinding
|
||||
import org.yuzu.yuzu_emu.features.settings.model.view.DateTimeSetting
|
||||
import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem
|
||||
import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter
|
||||
import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||
|
||||
class DateTimeViewHolder(val binding: ListItemSettingBinding, adapter: SettingsAdapter) :
|
||||
SettingViewHolder(binding.root, adapter) {
|
||||
@@ -29,12 +30,23 @@ class DateTimeViewHolder(val binding: ListItemSettingBinding, adapter: SettingsA
|
||||
}
|
||||
|
||||
binding.textSettingValue.visibility = View.VISIBLE
|
||||
val epochTime = setting.value
|
||||
val epochTime = setting.getValue()
|
||||
val instant = Instant.ofEpochMilli(epochTime * 1000)
|
||||
val zonedTime = ZonedDateTime.ofInstant(instant, ZoneId.of("UTC"))
|
||||
val dateFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM)
|
||||
binding.textSettingValue.text = dateFormatter.format(zonedTime)
|
||||
|
||||
binding.buttonClear.visibility = if (setting.setting.global ||
|
||||
!NativeConfig.isPerGameConfigLoaded()
|
||||
) {
|
||||
View.GONE
|
||||
} else {
|
||||
View.VISIBLE
|
||||
}
|
||||
binding.buttonClear.setOnClickListener {
|
||||
adapter.onClearClick(setting, bindingAdapterPosition)
|
||||
}
|
||||
|
||||
setStyle(setting.isEditable, binding)
|
||||
}
|
||||
|
||||
|
||||
+15
@@ -4,6 +4,7 @@
|
||||
package org.yuzu.yuzu_emu.features.settings.ui.viewholder
|
||||
|
||||
import android.view.View
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import org.yuzu.yuzu_emu.NativeLibrary
|
||||
import org.yuzu.yuzu_emu.databinding.ListItemSettingBinding
|
||||
import org.yuzu.yuzu_emu.features.settings.model.view.RunnableSetting
|
||||
@@ -16,6 +17,19 @@ class RunnableViewHolder(val binding: ListItemSettingBinding, adapter: SettingsA
|
||||
|
||||
override fun bind(item: SettingsItem) {
|
||||
setting = item as RunnableSetting
|
||||
if (item.iconId != 0) {
|
||||
binding.icon.visibility = View.VISIBLE
|
||||
binding.icon.setImageDrawable(
|
||||
ResourcesCompat.getDrawable(
|
||||
binding.icon.resources,
|
||||
item.iconId,
|
||||
binding.icon.context.theme
|
||||
)
|
||||
)
|
||||
} else {
|
||||
binding.icon.visibility = View.GONE
|
||||
}
|
||||
|
||||
binding.textSettingName.setText(item.nameId)
|
||||
if (item.descriptionId != 0) {
|
||||
binding.textSettingDescription.setText(item.descriptionId)
|
||||
@@ -24,6 +38,7 @@ class RunnableViewHolder(val binding: ListItemSettingBinding, adapter: SettingsA
|
||||
binding.textSettingDescription.visibility = View.GONE
|
||||
}
|
||||
binding.textSettingValue.visibility = View.GONE
|
||||
binding.buttonClear.visibility = View.GONE
|
||||
|
||||
setStyle(setting.isEditable, binding)
|
||||
}
|
||||
|
||||
+2
@@ -41,6 +41,7 @@ abstract class SettingViewHolder(itemView: View, protected val adapter: Settings
|
||||
binding.textSettingName.alpha = opacity
|
||||
binding.textSettingDescription.alpha = opacity
|
||||
binding.textSettingValue.alpha = opacity
|
||||
binding.buttonClear.isEnabled = isEditable
|
||||
}
|
||||
|
||||
fun setStyle(isEditable: Boolean, binding: ListItemSettingSwitchBinding) {
|
||||
@@ -48,5 +49,6 @@ abstract class SettingViewHolder(itemView: View, protected val adapter: Settings
|
||||
val opacity = if (isEditable) 1.0f else 0.5f
|
||||
binding.textSettingName.alpha = opacity
|
||||
binding.textSettingDescription.alpha = opacity
|
||||
binding.buttonClear.isEnabled = isEditable
|
||||
}
|
||||
}
|
||||
|
||||
+14
-2
@@ -9,6 +9,7 @@ import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem
|
||||
import org.yuzu.yuzu_emu.features.settings.model.view.SingleChoiceSetting
|
||||
import org.yuzu.yuzu_emu.features.settings.model.view.StringSingleChoiceSetting
|
||||
import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter
|
||||
import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||
|
||||
class SingleChoiceViewHolder(val binding: ListItemSettingBinding, adapter: SettingsAdapter) :
|
||||
SettingViewHolder(binding.root, adapter) {
|
||||
@@ -29,20 +30,31 @@ class SingleChoiceViewHolder(val binding: ListItemSettingBinding, adapter: Setti
|
||||
val resMgr = binding.textSettingValue.context.resources
|
||||
val values = resMgr.getIntArray(item.valuesId)
|
||||
for (i in values.indices) {
|
||||
if (values[i] == item.selectedValue) {
|
||||
if (values[i] == item.getSelectedValue()) {
|
||||
binding.textSettingValue.text = resMgr.getStringArray(item.choicesId)[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
} else if (item is StringSingleChoiceSetting) {
|
||||
for (i in item.values.indices) {
|
||||
if (item.values[i] == item.selectedValue) {
|
||||
if (item.values[i] == item.getSelectedValue()) {
|
||||
binding.textSettingValue.text = item.choices[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
binding.buttonClear.visibility = if (setting.setting.global ||
|
||||
!NativeConfig.isPerGameConfigLoaded()
|
||||
) {
|
||||
View.GONE
|
||||
} else {
|
||||
View.VISIBLE
|
||||
}
|
||||
binding.buttonClear.setOnClickListener {
|
||||
adapter.onClearClick(setting, bindingAdapterPosition)
|
||||
}
|
||||
|
||||
setStyle(setting.isEditable, binding)
|
||||
}
|
||||
|
||||
|
||||
+13
-1
@@ -9,6 +9,7 @@ import org.yuzu.yuzu_emu.databinding.ListItemSettingBinding
|
||||
import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem
|
||||
import org.yuzu.yuzu_emu.features.settings.model.view.SliderSetting
|
||||
import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter
|
||||
import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||
|
||||
class SliderViewHolder(val binding: ListItemSettingBinding, adapter: SettingsAdapter) :
|
||||
SettingViewHolder(binding.root, adapter) {
|
||||
@@ -26,10 +27,21 @@ class SliderViewHolder(val binding: ListItemSettingBinding, adapter: SettingsAda
|
||||
binding.textSettingValue.visibility = View.VISIBLE
|
||||
binding.textSettingValue.text = String.format(
|
||||
binding.textSettingValue.context.getString(R.string.value_with_units),
|
||||
setting.selectedValue,
|
||||
setting.getSelectedValue(),
|
||||
setting.units
|
||||
)
|
||||
|
||||
binding.buttonClear.visibility = if (setting.setting.global ||
|
||||
!NativeConfig.isPerGameConfigLoaded()
|
||||
) {
|
||||
View.GONE
|
||||
} else {
|
||||
View.VISIBLE
|
||||
}
|
||||
binding.buttonClear.setOnClickListener {
|
||||
adapter.onClearClick(setting, bindingAdapterPosition)
|
||||
}
|
||||
|
||||
setStyle(setting.isEditable, binding)
|
||||
}
|
||||
|
||||
|
||||
+15
@@ -4,6 +4,7 @@
|
||||
package org.yuzu.yuzu_emu.features.settings.ui.viewholder
|
||||
|
||||
import android.view.View
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import org.yuzu.yuzu_emu.databinding.ListItemSettingBinding
|
||||
import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem
|
||||
import org.yuzu.yuzu_emu.features.settings.model.view.SubmenuSetting
|
||||
@@ -15,6 +16,19 @@ class SubmenuViewHolder(val binding: ListItemSettingBinding, adapter: SettingsAd
|
||||
|
||||
override fun bind(item: SettingsItem) {
|
||||
this.item = item as SubmenuSetting
|
||||
if (item.iconId != 0) {
|
||||
binding.icon.visibility = View.VISIBLE
|
||||
binding.icon.setImageDrawable(
|
||||
ResourcesCompat.getDrawable(
|
||||
binding.icon.resources,
|
||||
item.iconId,
|
||||
binding.icon.context.theme
|
||||
)
|
||||
)
|
||||
} else {
|
||||
binding.icon.visibility = View.GONE
|
||||
}
|
||||
|
||||
binding.textSettingName.setText(item.nameId)
|
||||
if (item.descriptionId != 0) {
|
||||
binding.textSettingDescription.setText(item.descriptionId)
|
||||
@@ -23,6 +37,7 @@ class SubmenuViewHolder(val binding: ListItemSettingBinding, adapter: SettingsAd
|
||||
binding.textSettingDescription.visibility = View.GONE
|
||||
}
|
||||
binding.textSettingValue.visibility = View.GONE
|
||||
binding.buttonClear.visibility = View.GONE
|
||||
}
|
||||
|
||||
override fun onClick(clicked: View) {
|
||||
|
||||
+14
-2
@@ -9,6 +9,7 @@ import org.yuzu.yuzu_emu.databinding.ListItemSettingSwitchBinding
|
||||
import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem
|
||||
import org.yuzu.yuzu_emu.features.settings.model.view.SwitchSetting
|
||||
import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter
|
||||
import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||
|
||||
class SwitchSettingViewHolder(val binding: ListItemSettingSwitchBinding, adapter: SettingsAdapter) :
|
||||
SettingViewHolder(binding.root, adapter) {
|
||||
@@ -27,9 +28,20 @@ class SwitchSettingViewHolder(val binding: ListItemSettingSwitchBinding, adapter
|
||||
}
|
||||
|
||||
binding.switchWidget.setOnCheckedChangeListener(null)
|
||||
binding.switchWidget.isChecked = setting.checked
|
||||
binding.switchWidget.isChecked = setting.getIsChecked(setting.needsRuntimeGlobal)
|
||||
binding.switchWidget.setOnCheckedChangeListener { _: CompoundButton, _: Boolean ->
|
||||
adapter.onBooleanClick(item, binding.switchWidget.isChecked)
|
||||
adapter.onBooleanClick(item, binding.switchWidget.isChecked, bindingAdapterPosition)
|
||||
}
|
||||
|
||||
binding.buttonClear.visibility = if (setting.setting.global ||
|
||||
!NativeConfig.isPerGameConfigLoaded()
|
||||
) {
|
||||
View.GONE
|
||||
} else {
|
||||
View.VISIBLE
|
||||
}
|
||||
binding.buttonClear.setOnClickListener {
|
||||
adapter.onClearClick(setting, bindingAdapterPosition)
|
||||
}
|
||||
|
||||
setStyle(setting.isEditable, binding)
|
||||
|
||||
+13
-43
@@ -3,57 +3,27 @@
|
||||
|
||||
package org.yuzu.yuzu_emu.features.settings.utils
|
||||
|
||||
import android.widget.Toast
|
||||
import android.net.Uri
|
||||
import org.yuzu.yuzu_emu.model.Game
|
||||
import java.io.*
|
||||
import org.ini4j.Wini
|
||||
import org.yuzu.yuzu_emu.R
|
||||
import org.yuzu.yuzu_emu.YuzuApplication
|
||||
import org.yuzu.yuzu_emu.features.settings.model.*
|
||||
import org.yuzu.yuzu_emu.utils.DirectoryInitialization
|
||||
import org.yuzu.yuzu_emu.utils.Log
|
||||
import org.yuzu.yuzu_emu.utils.FileUtil
|
||||
import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||
|
||||
/**
|
||||
* Contains static methods for interacting with .ini files in which settings are stored.
|
||||
*/
|
||||
object SettingsFile {
|
||||
const val FILE_NAME_CONFIG = "config"
|
||||
|
||||
/**
|
||||
* Saves a Settings HashMap to a given .ini file on disk. If unsuccessful, outputs an error
|
||||
* telling why it failed.
|
||||
*
|
||||
* @param fileName The target filename without a path or extension.
|
||||
*/
|
||||
fun saveFile(fileName: String) {
|
||||
val ini = getSettingsFile(fileName)
|
||||
try {
|
||||
val wini = Wini(ini)
|
||||
for (specificCategory in Settings.Category.values()) {
|
||||
val categoryHeader = NativeConfig.getConfigHeader(specificCategory.ordinal)
|
||||
for (setting in Settings.settingsList) {
|
||||
if (setting.key!!.isEmpty()) continue
|
||||
|
||||
val settingCategoryHeader =
|
||||
NativeConfig.getConfigHeader(setting.category.ordinal)
|
||||
val iniSetting: String? = wini.get(categoryHeader, setting.key)
|
||||
if (iniSetting != null || settingCategoryHeader == categoryHeader) {
|
||||
wini.put(settingCategoryHeader, setting.key, setting.valueAsString)
|
||||
}
|
||||
}
|
||||
}
|
||||
wini.store()
|
||||
} catch (e: IOException) {
|
||||
Log.error("[SettingsFile] File not found: " + fileName + ".ini: " + e.message)
|
||||
val context = YuzuApplication.appContext
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.error_saving, fileName, e.message),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
const val FILE_NAME_CONFIG = "config.ini"
|
||||
|
||||
fun getSettingsFile(fileName: String): File =
|
||||
File(DirectoryInitialization.userDirectory + "/config/" + fileName + ".ini")
|
||||
File(DirectoryInitialization.userDirectory + "/config/" + fileName)
|
||||
|
||||
fun getCustomSettingsFile(game: Game): File =
|
||||
File(DirectoryInitialization.userDirectory + "/config/custom/" + game.settingsName + ".ini")
|
||||
|
||||
fun loadCustomConfig(game: Game) {
|
||||
val fileName = FileUtil.getFilename(Uri.parse(game.path))
|
||||
NativeConfig.initializePerGameConfig(game.programId, fileName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,10 +114,10 @@ class AboutFragment : Fragment() {
|
||||
val leftInsets = barInsets.left + cutoutInsets.left
|
||||
val rightInsets = barInsets.right + cutoutInsets.right
|
||||
|
||||
val mlpAppBar = binding.appbarAbout.layoutParams as MarginLayoutParams
|
||||
mlpAppBar.leftMargin = leftInsets
|
||||
mlpAppBar.rightMargin = rightInsets
|
||||
binding.appbarAbout.layoutParams = mlpAppBar
|
||||
val mlpToolbar = binding.toolbarAbout.layoutParams as MarginLayoutParams
|
||||
mlpToolbar.leftMargin = leftInsets
|
||||
mlpToolbar.rightMargin = rightInsets
|
||||
binding.toolbarAbout.layoutParams = mlpToolbar
|
||||
|
||||
val mlpScrollAbout = binding.scrollAbout.layoutParams as MarginLayoutParams
|
||||
mlpScrollAbout.leftMargin = leftInsets
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.yuzu.yuzu_emu.fragments
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.DialogInterface
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import org.yuzu.yuzu_emu.R
|
||||
import org.yuzu.yuzu_emu.databinding.DialogAddFolderBinding
|
||||
import org.yuzu.yuzu_emu.model.GameDir
|
||||
import org.yuzu.yuzu_emu.model.GamesViewModel
|
||||
import org.yuzu.yuzu_emu.model.HomeViewModel
|
||||
|
||||
class AddGameFolderDialogFragment : DialogFragment() {
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
private val gamesViewModel: GamesViewModel by activityViewModels()
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val binding = DialogAddFolderBinding.inflate(layoutInflater)
|
||||
val folderUriString = requireArguments().getString(FOLDER_URI_STRING)
|
||||
if (folderUriString == null) {
|
||||
dismiss()
|
||||
}
|
||||
binding.path.text = Uri.parse(folderUriString).path
|
||||
|
||||
return MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(R.string.add_game_folder)
|
||||
.setPositiveButton(android.R.string.ok) { _: DialogInterface, _: Int ->
|
||||
val newGameDir = GameDir(folderUriString!!, binding.deepScanSwitch.isChecked)
|
||||
homeViewModel.setGamesDirSelected(true)
|
||||
gamesViewModel.addFolder(newGameDir)
|
||||
}
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setView(binding.root)
|
||||
.show()
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG = "AddGameFolderDialogFragment"
|
||||
|
||||
private const val FOLDER_URI_STRING = "FolderUriString"
|
||||
|
||||
fun newInstance(folderUriString: String): AddGameFolderDialogFragment {
|
||||
val args = Bundle()
|
||||
args.putString(FOLDER_URI_STRING, folderUriString)
|
||||
val fragment = AddGameFolderDialogFragment()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.yuzu.yuzu_emu.fragments
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.updatePadding
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.google.android.material.transition.MaterialSharedAxis
|
||||
import kotlinx.coroutines.launch
|
||||
import org.yuzu.yuzu_emu.R
|
||||
import org.yuzu.yuzu_emu.adapters.AddonAdapter
|
||||
import org.yuzu.yuzu_emu.databinding.FragmentAddonsBinding
|
||||
import org.yuzu.yuzu_emu.model.AddonViewModel
|
||||
import org.yuzu.yuzu_emu.model.HomeViewModel
|
||||
import org.yuzu.yuzu_emu.utils.AddonUtil
|
||||
import org.yuzu.yuzu_emu.utils.FileUtil.copyFilesTo
|
||||
import java.io.File
|
||||
|
||||
class AddonsFragment : Fragment() {
|
||||
private var _binding: FragmentAddonsBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
private val addonViewModel: AddonViewModel by activityViewModels()
|
||||
|
||||
private val args by navArgs<AddonsFragmentArgs>()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
addonViewModel.onOpenAddons(args.game)
|
||||
enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true)
|
||||
returnTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
|
||||
reenterTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = FragmentAddonsBinding.inflate(inflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
// This is using the correct scope, lint is just acting up
|
||||
@SuppressLint("UnsafeRepeatOnLifecycleDetector")
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
homeViewModel.setNavigationVisibility(visible = false, animated = false)
|
||||
homeViewModel.setStatusBarShadeVisibility(false)
|
||||
|
||||
binding.toolbarAddons.setNavigationOnClickListener {
|
||||
binding.root.findNavController().popBackStack()
|
||||
}
|
||||
|
||||
binding.toolbarAddons.title = getString(R.string.addons_game, args.game.title)
|
||||
|
||||
binding.listAddons.apply {
|
||||
layoutManager = LinearLayoutManager(requireContext())
|
||||
adapter = AddonAdapter()
|
||||
}
|
||||
|
||||
viewLifecycleOwner.lifecycleScope.apply {
|
||||
launch {
|
||||
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||
addonViewModel.addonList.collect {
|
||||
(binding.listAddons.adapter as AddonAdapter).submitList(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
launch {
|
||||
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||
addonViewModel.showModInstallPicker.collect {
|
||||
if (it) {
|
||||
installAddon.launch(Intent(Intent.ACTION_OPEN_DOCUMENT_TREE).data)
|
||||
addonViewModel.showModInstallPicker(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
launch {
|
||||
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||
addonViewModel.showModNoticeDialog.collect {
|
||||
if (it) {
|
||||
MessageDialogFragment.newInstance(
|
||||
requireActivity(),
|
||||
titleId = R.string.addon_notice,
|
||||
descriptionId = R.string.addon_notice_description,
|
||||
positiveAction = { addonViewModel.showModInstallPicker(true) }
|
||||
).show(parentFragmentManager, MessageDialogFragment.TAG)
|
||||
addonViewModel.showModNoticeDialog(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
binding.buttonInstall.setOnClickListener {
|
||||
ContentTypeSelectionDialogFragment().show(
|
||||
parentFragmentManager,
|
||||
ContentTypeSelectionDialogFragment.TAG
|
||||
)
|
||||
}
|
||||
|
||||
setInsets()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
addonViewModel.refreshAddons()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
addonViewModel.onCloseAddons()
|
||||
}
|
||||
|
||||
val installAddon =
|
||||
registerForActivityResult(ActivityResultContracts.OpenDocumentTree()) { result ->
|
||||
if (result == null) {
|
||||
return@registerForActivityResult
|
||||
}
|
||||
|
||||
val externalAddonDirectory = DocumentFile.fromTreeUri(requireContext(), result)
|
||||
if (externalAddonDirectory == null) {
|
||||
MessageDialogFragment.newInstance(
|
||||
requireActivity(),
|
||||
titleId = R.string.invalid_directory,
|
||||
descriptionId = R.string.invalid_directory_description
|
||||
).show(parentFragmentManager, MessageDialogFragment.TAG)
|
||||
return@registerForActivityResult
|
||||
}
|
||||
|
||||
val isValid = externalAddonDirectory.listFiles()
|
||||
.any { AddonUtil.validAddonDirectories.contains(it.name) }
|
||||
val errorMessage = MessageDialogFragment.newInstance(
|
||||
requireActivity(),
|
||||
titleId = R.string.invalid_directory,
|
||||
descriptionId = R.string.invalid_directory_description
|
||||
)
|
||||
if (isValid) {
|
||||
IndeterminateProgressDialogFragment.newInstance(
|
||||
requireActivity(),
|
||||
R.string.installing_game_content,
|
||||
false
|
||||
) {
|
||||
val parentDirectoryName = externalAddonDirectory.name
|
||||
val internalAddonDirectory =
|
||||
File(args.game.addonDir + parentDirectoryName)
|
||||
try {
|
||||
externalAddonDirectory.copyFilesTo(internalAddonDirectory)
|
||||
} catch (_: Exception) {
|
||||
return@newInstance errorMessage
|
||||
}
|
||||
addonViewModel.refreshAddons()
|
||||
return@newInstance getString(R.string.addon_installed_successfully)
|
||||
}.show(parentFragmentManager, IndeterminateProgressDialogFragment.TAG)
|
||||
} else {
|
||||
errorMessage.show(parentFragmentManager, MessageDialogFragment.TAG)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setInsets() =
|
||||
ViewCompat.setOnApplyWindowInsetsListener(
|
||||
binding.root
|
||||
) { _: View, windowInsets: WindowInsetsCompat ->
|
||||
val barInsets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
val cutoutInsets = windowInsets.getInsets(WindowInsetsCompat.Type.displayCutout())
|
||||
|
||||
val leftInsets = barInsets.left + cutoutInsets.left
|
||||
val rightInsets = barInsets.right + cutoutInsets.right
|
||||
|
||||
val mlpToolbar = binding.toolbarAddons.layoutParams as ViewGroup.MarginLayoutParams
|
||||
mlpToolbar.leftMargin = leftInsets
|
||||
mlpToolbar.rightMargin = rightInsets
|
||||
binding.toolbarAddons.layoutParams = mlpToolbar
|
||||
|
||||
val mlpAddonsList = binding.listAddons.layoutParams as ViewGroup.MarginLayoutParams
|
||||
mlpAddonsList.leftMargin = leftInsets
|
||||
mlpAddonsList.rightMargin = rightInsets
|
||||
binding.listAddons.layoutParams = mlpAddonsList
|
||||
binding.listAddons.updatePadding(
|
||||
bottom = barInsets.bottom +
|
||||
resources.getDimensionPixelSize(R.dimen.spacing_bottom_list_fab)
|
||||
)
|
||||
|
||||
val fabSpacing = resources.getDimensionPixelSize(R.dimen.spacing_fab)
|
||||
val mlpFab =
|
||||
binding.buttonInstall.layoutParams as ViewGroup.MarginLayoutParams
|
||||
mlpFab.leftMargin = leftInsets + fabSpacing
|
||||
mlpFab.rightMargin = rightInsets + fabSpacing
|
||||
mlpFab.bottomMargin = barInsets.bottom + fabSpacing
|
||||
binding.buttonInstall.layoutParams = mlpFab
|
||||
|
||||
windowInsets
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.yuzu.yuzu_emu.fragments
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.DialogInterface
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import org.yuzu.yuzu_emu.R
|
||||
import org.yuzu.yuzu_emu.YuzuApplication
|
||||
import org.yuzu.yuzu_emu.model.AddonViewModel
|
||||
import org.yuzu.yuzu_emu.ui.main.MainActivity
|
||||
|
||||
class ContentTypeSelectionDialogFragment : DialogFragment() {
|
||||
private val addonViewModel: AddonViewModel by activityViewModels()
|
||||
|
||||
private val preferences get() =
|
||||
PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext)
|
||||
|
||||
private var selectedItem = 0
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val launchOptions =
|
||||
arrayOf(getString(R.string.updates_and_dlc), getString(R.string.mods_and_cheats))
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
selectedItem = savedInstanceState.getInt(SELECTED_ITEM)
|
||||
}
|
||||
|
||||
val mainActivity = requireActivity() as MainActivity
|
||||
return MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(R.string.select_content_type)
|
||||
.setPositiveButton(android.R.string.ok) { _: DialogInterface, _: Int ->
|
||||
when (selectedItem) {
|
||||
0 -> mainActivity.installGameUpdate.launch(arrayOf("*/*"))
|
||||
else -> {
|
||||
if (!preferences.getBoolean(MOD_NOTICE_SEEN, false)) {
|
||||
preferences.edit().putBoolean(MOD_NOTICE_SEEN, true).apply()
|
||||
addonViewModel.showModNoticeDialog(true)
|
||||
return@setPositiveButton
|
||||
}
|
||||
addonViewModel.showModInstallPicker(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
.setSingleChoiceItems(launchOptions, 0) { _: DialogInterface, i: Int ->
|
||||
selectedItem = i
|
||||
}
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.show()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
outState.putInt(SELECTED_ITEM, selectedItem)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG = "ContentTypeSelectionDialogFragment"
|
||||
|
||||
private const val SELECTED_ITEM = "SelectedItem"
|
||||
private const val MOD_NOTICE_SEEN = "ModNoticeSeen"
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.google.android.material.transition.MaterialSharedAxis
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
@@ -36,6 +37,8 @@ class DriverManagerFragment : Fragment() {
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
private val driverViewModel: DriverViewModel by activityViewModels()
|
||||
|
||||
private val args by navArgs<DriverManagerFragmentArgs>()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true)
|
||||
@@ -57,7 +60,9 @@ class DriverManagerFragment : Fragment() {
|
||||
homeViewModel.setNavigationVisibility(visible = false, animated = true)
|
||||
homeViewModel.setStatusBarShadeVisibility(visible = false)
|
||||
|
||||
if (!driverViewModel.isInteractionAllowed) {
|
||||
driverViewModel.onOpenDriverManager(args.game)
|
||||
|
||||
if (!driverViewModel.isInteractionAllowed.value) {
|
||||
DriversLoadingDialogFragment().show(
|
||||
childFragmentManager,
|
||||
DriversLoadingDialogFragment.TAG
|
||||
@@ -102,10 +107,9 @@ class DriverManagerFragment : Fragment() {
|
||||
setInsets()
|
||||
}
|
||||
|
||||
// Start installing requested driver
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
driverViewModel.onCloseDriverManager()
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
driverViewModel.onCloseDriverManager(args.game)
|
||||
}
|
||||
|
||||
private fun setInsets() =
|
||||
|
||||
+1
-17
@@ -47,25 +47,9 @@ class DriversLoadingDialogFragment : DialogFragment() {
|
||||
viewLifecycleOwner.lifecycleScope.apply {
|
||||
launch {
|
||||
repeatOnLifecycle(Lifecycle.State.RESUMED) {
|
||||
driverViewModel.areDriversLoading.collect { checkForDismiss() }
|
||||
driverViewModel.isInteractionAllowed.collect { if (it) dismiss() }
|
||||
}
|
||||
}
|
||||
launch {
|
||||
repeatOnLifecycle(Lifecycle.State.RESUMED) {
|
||||
driverViewModel.isDriverReady.collect { checkForDismiss() }
|
||||
}
|
||||
}
|
||||
launch {
|
||||
repeatOnLifecycle(Lifecycle.State.RESUMED) {
|
||||
driverViewModel.isDeletingDrivers.collect { checkForDismiss() }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkForDismiss() {
|
||||
if (driverViewModel.isInteractionAllowed) {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user