diff --git a/.github/actions/canary-ndk/action.yml b/.github/actions/canary-ndk/action.yml deleted file mode 100644 index 6454ad5..0000000 --- a/.github/actions/canary-ndk/action.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: "Setup canary ndk" -description: "Sets up canary ndk" -outputs: - ndk-path: - value: ${{ steps.path.outputs.path }} - description: "Output path of the ndk" - cache-hit: - value: ${{ steps.cache.outputs.cache-hit }} - description: "Whether a cache hit occurred for the ndk" -runs: - using: "composite" - steps: - - name: NDK cache - id: cache - uses: actions/cache@v3 - with: - path: ${HOME}/android-ndk-r27-canary/ - key: ${{ runner.os }}-ndk-r27-canary - - - name: Download canary ndk - if: ${{ !steps.cache.outputs.cache-hit }} - env: - CANARY_URL: https://github.com/QuestPackageManager/ndk-canary-archive/releases/download/27.0.1/android-ndk-10883340-linux-x86_64.zip - run: wget ${CANARY_URL} -O ${HOME}/ndk.zip - shell: bash - - - name: Unzip ndk - if: ${{ !steps.cache.outputs.cache-hit }} - run: 7z x "${HOME}/ndk.zip" -o"${HOME}/" - shell: bash - - - name: Set output - id: path - shell: bash - run: echo "path=${HOME}/android-ndk-r27-canary" >> ${GITHUB_OUTPUT} \ No newline at end of file diff --git a/.github/workflows/build-ndk.yml b/.github/workflows/build-ndk.yml index df4fdee..12c5fad 100644 --- a/.github/workflows/build-ndk.yml +++ b/.github/workflows/build-ndk.yml @@ -5,6 +5,7 @@ on: push: branches: - 'master' + - 'dev' paths-ignore: - '**.yml' - '!.github/workflows/build-ndk.yml' @@ -38,14 +39,9 @@ jobs: - uses: seanmiddleditch/gha-setup-ninja@v3 - # Use canary NDK to avoid lesser known compile bugs - - name: Setup canary NDK - id: setup-ndk - uses: ./.github/actions/canary-ndk - - name: Create ndkpath.txt run: | - echo ${{ steps.setup-ndk.outputs.ndk-path }} > ${GITHUB_WORKSPACE}/ndkpath.txt + echo $ANDROID_NDK_HOME > ${GITHUB_WORKSPACE}/ndkpath.txt cat ${GITHUB_WORKSPACE}/ndkpath.txt # get version from pushed tag @@ -79,21 +75,21 @@ jobs: echo "NAME=${files[0]}" >> $GITHUB_OUTPUT - name: Upload non-debug artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: ${{ steps.libname.outputs.NAME }} path: ./build/${{ steps.libname.outputs.NAME }} if-no-files-found: error - name: Upload debug artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: debug_${{ steps.libname.outputs.NAME }} path: ./build/debug/${{ steps.libname.outputs.NAME }} if-no-files-found: error - name: Upload qmod artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: ${{env.qmodName}}.qmod path: ./${{ env.qmodName }}.qmod diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e7f02b7..ef049f1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -22,14 +22,9 @@ jobs: - uses: seanmiddleditch/gha-setup-ninja@v3 - # Use canary NDK to avoid lesser known compile bugs - - name: Setup canary NDK - id: setup-ndk - uses: ./.github/actions/canary-ndk - - name: Create ndkpath.txt run: | - echo ${{ steps.setup-ndk.outputs.ndk-path }} > ${GITHUB_WORKSPACE}/ndkpath.txt + echo $ANDROID_NDK_HOME > ${GITHUB_WORKSPACE}/ndkpath.txt cat ${GITHUB_WORKSPACE}/ndkpath.txt # get version from pushed tag diff --git a/.gitignore b/.gitignore index 2e76105..9d7352d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .vs/ +.cache/ # Prerequisites *.d diff --git a/CMakeLists.txt b/CMakeLists.txt index 367bacd..4be1ac2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,13 @@ # include some defines automatically made by qpm include(qpm_defines.cmake) -include(${EXTERN_DIR}/includes/kaleb/shared/cmake/assets.cmake) -add_definitions(-DCP_SDK_BMBF) +cmake_minimum_required(VERSION 3.22) +project(${COMPILE_ID}) +include(${EXTERN_DIR}/includes/kaleb/shared/cmake/assets.cmake) -# override mod id -set(MOD_ID "QBeatSaberPlus-MenuMusic") +# c++ standard +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED 20) # Enable link time optimization # In my experience, this can be highly unstable but it nets a huge size optimization and likely performance @@ -13,25 +15,18 @@ set(MOD_ID "QBeatSaberPlus-MenuMusic") # As always, test thoroughly # - Fern # set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) - -cmake_minimum_required(VERSION 3.21) -project(${COMPILE_ID}) - # export compile commands for significantly better intellisense set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -# c++ standard -set(CMAKE_CXX_STANDARD 20) -set(CMAKE_CXX_STANDARD_REQUIRED 20) - # define that stores the actual source directory set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) set(SHARED_DIR ${CMAKE_CURRENT_SOURCE_DIR}/shared) +# stop symbol leaking +#add_link_options(-Wl,--exclude-libs,ALL) # compile options used -add_compile_options(-frtti -fexceptions) -add_compile_options(-O3) +add_compile_options(-frtti -fPIE -fPIC -fexceptions -fdeclspec -fvisibility=hidden -Wno-extra-qualification -O3) # get git info execute_process(COMMAND git config user.name OUTPUT_VARIABLE GIT_USER) @@ -49,69 +44,74 @@ message(STATUS "GIT_BRANCH: ${GIT_BRANCH}") message(STATUS "GIT_COMMIT: 0x${GIT_COMMIT}") message(STATUS "GIT_MODIFIED: ${GIT_MODIFIED}") -# set git defines -add_compile_definitions(GIT_USER=\"${GIT_USER}\") -add_compile_definitions(GIT_BRANCH=\"${GIT_BRANCH}\") -add_compile_definitions(GIT_COMMIT=0x${GIT_COMMIT}) -add_compile_definitions(GIT_MODIFIED=${GIT_MODIFIED}) + +# Check for file presence and read current contents +set(GIT_INFO_H_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include/git_info.h") +if(EXISTS "${GIT_INFO_H_PATH}") + file(READ "${GIT_INFO_H_PATH}" GIT_INFO_H_CURRENT) +else() + set(GIT_INFO_H_CURRENT "") +endif() + +# Define new git info content +set(GIT_INFO_H "#pragma once +#define GIT_USER \"${GIT_USER}\" +#define GIT_BRANCH \"${GIT_BRANCH}\" +#define GIT_COMMIT 0x${GIT_COMMIT} +#define GIT_MODIFIED ${GIT_MODIFIED} +") + +# Write git info to file if the contents have changed +if(NOT "${GIT_INFO_H}" STREQUAL "${GIT_INFO_H_CURRENT}") + file(WRITE "${GIT_INFO_H_PATH}" "${GIT_INFO_H}") +endif() + # compile definitions used add_compile_definitions(VERSION=\"${MOD_VERSION}\") add_compile_definitions(MOD_ID=\"${MOD_ID}\") +add_compile_definitions(UNITY_2021) +add_compile_definitions(CORDL_RUNTIME_FIELD_NULL_CHECKS) +add_compile_definitions(__USE_LARGEFILE64) + +# compile options used +add_compile_definitions(CP_SDK_BMBF) + +string(LENGTH "${CMAKE_CURRENT_LIST_DIR}/" FOLDER_LENGTH) +add_compile_definitions("PAPER_ROOT_FOLDER_LENGTH=${FOLDER_LENGTH}") # recursively get all src files -RECURSE_FILES(h_file_lista ${INCLUDE_DIR}/*.hpp) -RECURSE_FILES(h_file_listb ${SHARED_DIR}/*.hpp) -RECURSE_FILES(hpp_file_lista ${INCLUDE_DIR}/*.hpp) -RECURSE_FILES(hpp_file_listb ${SHARED_DIR}/*.hpp) -RECURSE_FILES(cpp_file_list ${SOURCE_DIR}/*.cpp) -RECURSE_FILES(c_file_list ${SOURCE_DIR}/*.c) +recurse_files(cpp_file_list ${SOURCE_DIR}/*.cpp) +recurse_files(c_file_list ${SOURCE_DIR}/*.c) + +recurse_files(inline_hook_c ${EXTERN_DIR}/includes/beatsaber-hook/shared/inline-hook/*.c) +recurse_files(inline_hook_cpp ${EXTERN_DIR}/includes/beatsaber-hook/shared/inline-hook/*.cpp) # add all src files to compile add_library( - ${COMPILE_ID} - SHARED - ${h_file_lista} - ${h_file_listb} - ${hpp_file_lista} - ${hpp_file_listb} - ${cpp_file_list} - ${c_file_list} + ${COMPILE_ID} SHARED ${cpp_file_list} ${c_file_list} ${inline_hook_c} ${inline_hook_cpp} ) -# Add any assets -add_assets(assets_${COMPILE_ID} STATIC ${CMAKE_CURRENT_LIST_DIR}/assets ${INCLUDE_DIR}/assets.hpp) - -# get the vcpkg dir from env variables -if(EXISTS $ENV{VCPKG_ROOT}) - set(VCPKG_ROOT $ENV{VCPKG_ROOT}) -else() - MESSAGE(ERROR "Please define the environment variable VCPKG_ROOT with the root to your vcpkg install!") -endif() - -target_include_directories(${COMPILE_ID} PRIVATE .) - # add src dir as include dir target_include_directories(${COMPILE_ID} PRIVATE ${SOURCE_DIR}) # add include dir as include dir target_include_directories(${COMPILE_ID} PRIVATE ${INCLUDE_DIR}) # add shared dir as include dir target_include_directories(${COMPILE_ID} PUBLIC ${SHARED_DIR}) -# codegen includes -target_include_directories(${COMPILE_ID} PRIVATE ${EXTERN_DIR}/includes/${CODEGEN_ID}/include) # chatplex-sdk-bs includes target_include_directories(${COMPILE_ID} PRIVATE ${EXTERN_DIR}/includes/chatplex-sdk-bs/shared) -target_link_libraries(${COMPILE_ID} PRIVATE -llog) -target_link_libraries(${COMPILE_ID} PRIVATE assets_${COMPILE_ID}) +# Add any assets +add_assets(${COMPILE_ID}-assets STATIC ${CMAKE_CURRENT_LIST_DIR}/assets ${INCLUDE_DIR}/assets.hpp) +target_link_libraries(${COMPILE_ID} PRIVATE -llog -lz ${COMPILE_ID}-assets) # add extern stuff like libs and other includes include(extern.cmake) add_custom_command(TARGET ${COMPILE_ID} POST_BUILD - COMMAND ${CMAKE_STRIP} -d --strip-all - "lib${COMPILE_ID}.so" -o "stripped_lib${COMPILE_ID}.so" - COMMENT "Strip debug symbols done on final binary.") + COMMAND ${CMAKE_STRIP} -g -S -d --strip-all + "lib${COMPILE_ID}.so" -o "stripped_lib${COMPILE_ID}.so" + COMMENT "Strip debug symbols done on final binary.") add_custom_command(TARGET ${COMPILE_ID} POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory debug @@ -119,32 +119,32 @@ add_custom_command(TARGET ${COMPILE_ID} POST_BUILD ) add_custom_command(TARGET ${COMPILE_ID} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E rename lib${COMPILE_ID}.so debug/lib${COMPILE_ID}.so - COMMENT "Rename the lib to debug_ since it has debug symbols" - ) + COMMAND ${CMAKE_COMMAND} -E rename lib${COMPILE_ID}.so debug/lib${COMPILE_ID}.so + COMMENT "Rename the lib to debug_ since it has debug symbols" + ) -# strip debug symbols from the .so and all dependencies add_custom_command(TARGET ${COMPILE_ID} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E rename stripped_lib${COMPILE_ID}.so lib${COMPILE_ID}.so - COMMENT "Rename the stripped lib to regular" - ) - foreach(so_file ${so_list}) - cmake_path(GET so_file FILENAME file) + COMMAND ${CMAKE_COMMAND} -E rename stripped_lib${COMPILE_ID}.so lib${COMPILE_ID}.so + COMMENT "Rename the stripped lib to regular" + ) - add_custom_command(TARGET ${COMPILE_ID} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${so_file} debug/${file} - COMMENT "Copy so files for ndk stack" - ) +foreach(so_file ${so_list}) + cmake_path(GET so_file FILENAME file) - add_custom_command(TARGET ${COMPILE_ID} POST_BUILD - COMMAND ${CMAKE_STRIP} -g -S -d --strip-all ${so_file} -o ${file} - COMMENT "Strip debug symbols from the dependencies") - endforeach() + add_custom_command(TARGET ${COMPILE_ID} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${so_file} debug/${file} + COMMENT "Copy so files for ndk stack" + ) - foreach(a_file ${a_list}) - cmake_path(GET a_file FILENAME file) + add_custom_command(TARGET ${COMPILE_ID} POST_BUILD + COMMAND ${CMAKE_STRIP} -g -S -d --strip-all ${so_file} -o ${file} + COMMENT "Strip debug symbols from the dependencies") +endforeach() - add_custom_command(TARGET ${COMPILE_ID} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${a_file} debug/${file} - COMMENT "Copy a files for ndk stack") - endforeach() \ No newline at end of file +foreach(a_file ${a_list}) +cmake_path(GET a_file FILENAME file) + +add_custom_command(TARGET ${COMPILE_ID} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${a_file} debug/${file} + COMMENT "Copy a files for ndk stack") +endforeach() diff --git a/include/git_info.h b/include/git_info.h new file mode 100644 index 0000000..7be4b05 --- /dev/null +++ b/include/git_info.h @@ -0,0 +1,5 @@ +#pragma once +#define GIT_USER "HardCPP" +#define GIT_BRANCH "dev" +#define GIT_COMMIT 0xe337f56 +#define GIT_MODIFIED 1 diff --git a/mod.json b/mod.json index dded15f..d0bf112 100644 --- a/mod.json +++ b/mod.json @@ -1,43 +1,47 @@ { + "$schema": "https://raw.githubusercontent.com/Lauriethefish/QuestPatcher.QMod/refs/heads/main/QuestPatcher.QMod/Resources/qmod.schema.json", "_QPVersion": "0.1.1", "name": "QBeatSaberPlus-MenuMusic", "id": "qbeatsaberplus-menumusic", "modloader": "Scotland2", "author": "HardCPP", - "version": "6.3.2", + "version": "6.4.0", "packageId": "com.beatgames.beatsaber", - "packageVersion": "1.37.0_9064817954", + "packageVersion": "1.40.4_5283", "description": "Feel good!", "coverImage": "cover.png", "dependencies": [ { - "version": "^0.17.8", + "version": "^6.4.1", + "id": "beatsaber-hook", + "downloadIfMissing": "https://github.com/QuestPackageManager/beatsaber-hook/releases/download/v6.4.1/beatsaber-hook.qmod" + }, + { + "version": "^0.18.2", "id": "custom-types", - "downloadIfMissing": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.17.10/CustomTypes.qmod" + "downloadIfMissing": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.18.2/CustomTypes.qmod" }, { - "version": "^1.1.12", + "version": "^1.1.20", "id": "songcore", - "downloadIfMissing": "https://github.com/raineio/Quest-SongCore/releases/download/v1.1.15/SongCore.qmod" + "downloadIfMissing": "https://github.com/raineaeternal/Quest-SongCore/releases/download/v1.1.20/SongCore.qmod" }, { - "version": "^3.6.3", - "id": "paper", - "downloadIfMissing": "https://github.com/Fernthedev/paperlog/releases/download/v3.6.4/paperlog.qmod" + "version": "^4.6.1", + "id": "paper2_scotland2", + "downloadIfMissing": "https://github.com/Fernthedev/paperlog/releases/download/v4.6.2/paper2_scotland2.qmod" }, { - "version": "^6.3.2", + "version": "^6.4.0", "id": "chatplex-sdk-bs", - "downloadIfMissing": "https://github.com/hardcpp/QuestChatPlexSDK-BS/releases/download/v6.3.2/ChatPlexSDK-BS.qmod" + "downloadIfMissing": "https://github.com/hardcpp/QuestChatPlexSDK-BS/releases/download/v6.4.0/ChatPlexSDK-BS.qmod" } ], - "modFiles": [], - "lateModFiles": [ + "modFiles": [ "libqbeatsaberplus-menumusic.so" ], - "libraryFiles": [ - "libbeatsaber-hook_5_1_9.so" - ], + "lateModFiles": [], + "libraryFiles": [], "fileCopies": [], "copyExtensions": [] } \ No newline at end of file diff --git a/mod.template.json b/mod.template.json index 2547f03..5af37ad 100644 --- a/mod.template.json +++ b/mod.template.json @@ -7,11 +7,11 @@ "author": "HardCPP", "version": "${version}", "packageId": "com.beatgames.beatsaber", - "packageVersion": "1.37.0_9064817954", + "packageVersion": "1.40.4_5283", "description": "Feel good!", "coverImage": "cover.png", "dependencies": [], - "modFiles": [], + "modFiles": ["${binary}"], "libraryFiles": [], "fileCopies": [], "copyExtensions": [] diff --git a/qpm.json b/qpm.json index 765450d..f425081 100644 --- a/qpm.json +++ b/qpm.json @@ -1,94 +1,101 @@ { - "version": "0.1.0", - "sharedDir": "shared", - "dependenciesDir": "extern", - "info": { - "name": "QBeatSaberPlus-MenuMusic", - "id": "qbeatsaberplus-menumusic", - "version": "6.3.2", - "url": "https://github.com/hardcpp/QBeatSaberPlus-MenuMusic", - "additionalData": { - "overrideSoName": "libqbeatsaberplus-menumusic.so", - "cmake": true - } - }, - "workspace": { - "scripts": { - "build": [ - "pwsh ./build.ps1" - ], - "clean": [ - "pwsh ./build.ps1 -clean" - ], - "copy": [ - "pwsh ./copy.ps1" - ], - "log": [ - "pwsh ./start-logging.ps1" - ], - "qmod": [ - "pwsh ./build.ps1 -clean", - "pwsh ./createqmod.ps1 -clean" - ], - "qmod_backup": [ - "pwsh ./build.ps1 -clean", - "qpm qmod build", - "pwsh ./createqmod.ps1 -clean" - ] - } - }, - "dependencies": [ - { - "id": "beatsaber-hook", - "versionRange": "^5.1.9", - "additionalData": {} - }, - { - "id": "bs-cordl", - "versionRange": "^3700.*", - "additionalData": {} - }, - { - "id": "custom-types", - "versionRange": "^0.17.8", - "additionalData": {} - }, - { - "id": "scotland2", - "versionRange": "^0.1.4", + "version": "0.4.0", + "sharedDir": "shared", + "dependenciesDir": "extern", + "info": { + "name": "QBeatSaberPlus-MenuMusic", + "id": "qbeatsaberplus-menumusic", + "version": "6.4.0", + "url": "https://github.com/hardcpp/QBeatSaberPlus-MenuMusic", "additionalData": { - "includeQmod": false, - "private": true + "overrideSoName": "libqbeatsaberplus-menumusic.so", + "cmake": true } }, - { - "id": "libil2cpp", - "versionRange": "^0.3.1", - "additionalData": {} - }, - { - "id": "songcore", - "versionRange": "^1.1.12", - "additionalData": { - "private": true - } - }, - { - "id": "paper", - "versionRange": "^3.6.3", - "additionalData": {} - }, - { - "id": "kaleb", - "versionRange": "^0.1.9", - "additionalData": {} + "workspace": { + "scripts": { + "build": [ + "pwsh ./build.ps1" + ], + "clean": [ + "pwsh ./build.ps1 -clean" + ], + "copy": [ + "pwsh ./copy.ps1" + ], + "log": [ + "pwsh ./start-logging.ps1" + ], + "qmod": [ + "pwsh ./build.ps1 -clean", + "pwsh ./createqmod.ps1 -clean" + ], + "qmod_backup": [ + "pwsh ./build.ps1 -clean", + "qpm qmod build", + "pwsh ./createqmod.ps1 -clean" + ] + }, + "ndk": "^27.2.12479018", + "qmodIncludeDirs": [ + "build", + "extern/libs" + ], + "qmodIncludeFiles": [], + "qmodOutput": "./QBeatSaberPlus-MenuMusic.qmod" }, - { - "id": "chatplex-sdk-bs", - "versionRange": "^6.3.2", - "additionalData": { - "private": true + "dependencies": [ + { + "id": "beatsaber-hook", + "versionRange": "^6.4.1", + "additionalData": {} + }, + { + "id": "bs-cordl", + "versionRange": "^4004.0.0", + "additionalData": {} + }, + { + "id": "custom-types", + "versionRange": "^0.18.2", + "additionalData": {} + }, + { + "id": "scotland2", + "versionRange": "^0.1.6", + "additionalData": { + "includeQmod": false, + "private": true + } + }, + { + "id": "libil2cpp", + "versionRange": "^0.4.0", + "additionalData": {} + }, + { + "id": "songcore", + "versionRange": "^1.1.20", + "additionalData": { + "private": true + } + }, + { + "id": "paper2_scotland2", + "versionRange": "^4.6.1", + "additionalData": {} + }, + { + "id": "kaleb", + "versionRange": "^0.1.9", + "additionalData": {} + }, + { + "id": "chatplex-sdk-bs", + "versionRange": "^6.4.0", + "additionalData": { + "private": true + } } - } - ] -} \ No newline at end of file + ] + } \ No newline at end of file diff --git a/qpm.shared.json b/qpm.shared.json index ff9af6b..7b6bf8f 100644 --- a/qpm.shared.json +++ b/qpm.shared.json @@ -1,12 +1,13 @@ { + "$schema": "https://raw.githubusercontent.com/QuestPackageManager/QPM.Package/refs/heads/main/qpm.shared.schema.json", "config": { - "version": "0.1.0", + "version": "0.4.0", "sharedDir": "shared", "dependenciesDir": "extern", "info": { "name": "QBeatSaberPlus-MenuMusic", "id": "qbeatsaberplus-menumusic", - "version": "6.3.2", + "version": "6.4.0", "url": "https://github.com/hardcpp/QBeatSaberPlus-MenuMusic", "additionalData": { "overrideSoName": "libqbeatsaberplus-menumusic.so", @@ -37,29 +38,33 @@ "pwsh ./createqmod.ps1 -clean" ] }, - "qmodIncludeDirs": [], + "ndk": "^27.2.12479018", + "qmodIncludeDirs": [ + "build", + "extern/libs" + ], "qmodIncludeFiles": [], - "qmodOutput": null + "qmodOutput": "./QBeatSaberPlus-MenuMusic.qmod" }, "dependencies": [ { "id": "beatsaber-hook", - "versionRange": "^5.1.9", + "versionRange": "^6.4.1", "additionalData": {} }, { "id": "bs-cordl", - "versionRange": "3700.*", + "versionRange": "^4004.0.0", "additionalData": {} }, { "id": "custom-types", - "versionRange": "^0.17.8", + "versionRange": "^0.18.2", "additionalData": {} }, { "id": "scotland2", - "versionRange": "^0.1.4", + "versionRange": "^0.1.6", "additionalData": { "includeQmod": false, "private": true @@ -67,19 +72,19 @@ }, { "id": "libil2cpp", - "versionRange": "^0.3.1", + "versionRange": "^0.4.0", "additionalData": {} }, { "id": "songcore", - "versionRange": "^1.1.12", + "versionRange": "^1.1.20", "additionalData": { "private": true } }, { - "id": "paper", - "versionRange": "^3.6.3", + "id": "paper2_scotland2", + "versionRange": "^4.6.1", "additionalData": {} }, { @@ -89,7 +94,7 @@ }, { "id": "chatplex-sdk-bs", - "versionRange": "^6.3.2", + "versionRange": "^6.4.0", "additionalData": { "private": true } @@ -99,77 +104,81 @@ "restoredDependencies": [ { "dependency": { - "id": "paper", - "versionRange": "=3.6.4", + "id": "kaleb", + "versionRange": "=0.1.9", "additionalData": { - "soLink": "https://github.com/Fernthedev/paperlog/releases/download/v3.6.4/libpaperlog.so", - "debugSoLink": "https://github.com/Fernthedev/paperlog/releases/download/v3.6.4/debug_libpaperlog.so", - "overrideSoName": "libpaperlog.so", - "modLink": "https://github.com/Fernthedev/paperlog/releases/download/v3.6.4/paperlog.qmod", - "branchName": "version/v3_6_4", + "headersOnly": true, + "branchName": "version/v0_1_9", "compileOptions": { - "systemIncludes": [ - "shared/utfcpp/source" + "cppFlags": [ + "-DKALEB_VERSION=\"0.1.9\"" ] }, "cmake": false } }, - "version": "3.6.4" + "version": "0.1.9" }, { "dependency": { - "id": "libil2cpp", - "versionRange": "=0.3.2", + "id": "paper2_scotland2", + "versionRange": "=4.6.2", "additionalData": { - "headersOnly": true, + "soLink": "https://github.com/Fernthedev/paperlog/releases/download/v4.6.2/libpaper2_scotland2.so", + "overrideSoName": "libpaper2_scotland2.so", + "modLink": "https://github.com/Fernthedev/paperlog/releases/download/v4.6.2/paper2_scotland2.qmod", + "branchName": "version/v4_6_2", + "compileOptions": { + "systemIncludes": [ + "shared/utfcpp/source" + ] + }, "cmake": false } }, - "version": "0.3.2" + "version": "4.6.2" }, { "dependency": { - "id": "kaleb", - "versionRange": "=0.1.9", + "id": "libil2cpp", + "versionRange": "=0.4.0", "additionalData": { "headersOnly": true, - "branchName": "version/v0_1_9", "compileOptions": { - "cppFlags": [ - "-DKALEB_VERSION=\"0.1.9\"" + "systemIncludes": [ + "il2cpp/external/baselib/Include", + "il2cpp/external/baselib/Platforms/Android/Include" ] - }, - "cmake": false + } } }, - "version": "0.1.9" + "version": "0.4.0" }, { "dependency": { "id": "chatplex-sdk-bs", - "versionRange": "=6.3.2", + "versionRange": "=6.4.0", "additionalData": { - "soLink": "https://github.com/hardcpp/QuestChatPlexSDK-BS/releases/download/v6.3.2/libchatplex-sdk-bs.so", - "debugSoLink": "https://github.com/hardcpp/QuestChatPlexSDK-BS/releases/download/v6.3.2/debug_libchatplex-sdk-bs.so", + "soLink": "https://github.com/hardcpp/QuestChatPlexSDK-BS/releases/download/v6.4.0/libchatplex-sdk-bs.so", + "debugSoLink": "https://github.com/hardcpp/QuestChatPlexSDK-BS/releases/download/v6.4.0/debug_libchatplex-sdk-bs.so", "overrideSoName": "libchatplex-sdk-bs.so", - "modLink": "https://github.com/hardcpp/QuestChatPlexSDK-BS/releases/download/v6.3.2/ChatPlexSDK-BS.qmod", - "branchName": "version/v6_3_2", + "modLink": "https://github.com/hardcpp/QuestChatPlexSDK-BS/releases/download/v6.4.0/ChatPlexSDK-BS.qmod", + "branchName": "version/v6_4_0", "cmake": true } }, - "version": "6.3.2" + "version": "6.4.0" }, { "dependency": { "id": "custom-types", - "versionRange": "=0.17.10", + "versionRange": "=0.18.2", "additionalData": { - "soLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.17.10/libcustom-types.so", - "debugSoLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.17.10/debug_libcustom-types.so", + "soLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.18.2/libcustom-types.so", + "debugSoLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.18.2/debug_libcustom-types.so", "overrideSoName": "libcustom-types.so", - "modLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.17.10/CustomTypes.qmod", - "branchName": "version/v0_17_10", + "modLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.18.2/CustomTypes.qmod", + "branchName": "version/v0_18_2", "compileOptions": { "cppFlags": [ "-Wno-invalid-offsetof" @@ -178,15 +187,15 @@ "cmake": true } }, - "version": "0.17.10" + "version": "0.18.2" }, { "dependency": { "id": "bs-cordl", - "versionRange": "=3700.0.0", + "versionRange": "=4004.0.0", "additionalData": { "headersOnly": true, - "branchName": "version/v3700_0_0", + "branchName": "version/v4004_0_0", "compileOptions": { "includePaths": [ "include" @@ -196,48 +205,51 @@ "-DNEED_UNSAFE_CSHARP", "-fdeclspec", "-DUNITY_2021", - "-DHAS_CODEGEN" + "-DHAS_CODEGEN", + "-Wno-invalid-offsetof" ] } } }, - "version": "3700.0.0" + "version": "4004.0.0" }, { "dependency": { "id": "songcore", - "versionRange": "=1.1.15", + "versionRange": "=1.1.20", "additionalData": { - "soLink": "https://github.com/raineio/Quest-SongCore/releases/download/v1.1.15/libsongcore.so", - "debugSoLink": "https://github.com/raineio/Quest-SongCore/releases/download/v1.1.15/debug_libsongcore.so", + "soLink": "https://github.com/raineaeternal/Quest-SongCore/releases/download/v1.1.20/libsongcore.so", + "debugSoLink": "https://github.com/raineaeternal/Quest-SongCore/releases/download/v1.1.20/debug_libsongcore.so", "overrideSoName": "libsongcore.so", - "modLink": "https://github.com/raineio/Quest-SongCore/releases/download/v1.1.15/SongCore.qmod", - "branchName": "version/v1_1_15", + "modLink": "https://github.com/raineaeternal/Quest-SongCore/releases/download/v1.1.20/SongCore.qmod", + "branchName": "version/v1_1_20", "cmake": true } }, - "version": "1.1.15" + "version": "1.1.20" }, { "dependency": { "id": "beatsaber-hook", - "versionRange": "=5.1.9", + "versionRange": "=6.4.1", "additionalData": { - "soLink": "https://github.com/QuestPackageManager/beatsaber-hook/releases/download/v5.1.9/libbeatsaber-hook_5_1_9.so", - "debugSoLink": "https://github.com/QuestPackageManager/beatsaber-hook/releases/download/v5.1.9/debug_libbeatsaber-hook_5_1_9.so", - "branchName": "version/v5_1_9", + "soLink": "https://github.com/QuestPackageManager/beatsaber-hook/releases/download/v6.4.1/libbeatsaber-hook.so", + "debugSoLink": "https://github.com/QuestPackageManager/beatsaber-hook/releases/download/v6.4.1/debug_libbeatsaber-hook.so", + "overrideSoName": "libbeatsaber-hook.so", + "modLink": "https://github.com/QuestPackageManager/beatsaber-hook/releases/download/v6.4.1/beatsaber-hook.qmod", + "branchName": "version/v6_4_1", "cmake": true } }, - "version": "5.1.9" + "version": "6.4.1" }, { "dependency": { "id": "fmt", - "versionRange": "=10.0.0", + "versionRange": "=11.0.2", "additionalData": { "headersOnly": true, - "branchName": "version/v10_0_0", + "branchName": "version/v11_0_2", "compileOptions": { "systemIncludes": [ "fmt/include/" @@ -248,20 +260,20 @@ } } }, - "version": "10.0.0" + "version": "11.0.2" }, { "dependency": { "id": "scotland2", - "versionRange": "=0.1.4", + "versionRange": "=0.1.6", "additionalData": { - "soLink": "https://github.com/sc2ad/scotland2/releases/download/v0.1.4/libsl2.so", - "debugSoLink": "https://github.com/sc2ad/scotland2/releases/download/v0.1.4/debug_libsl2.so", + "soLink": "https://github.com/sc2ad/scotland2/releases/download/v0.1.6/libsl2.so", + "debugSoLink": "https://github.com/sc2ad/scotland2/releases/download/v0.1.6/debug_libsl2.so", "overrideSoName": "libsl2.so", - "branchName": "version/v0_1_4" + "branchName": "version/v0_1_6" } }, - "version": "0.1.4" + "version": "0.1.6" } ] } \ No newline at end of file diff --git a/shared/ChatPlexMod_MenuMusic/MMConfig.hpp b/shared/ChatPlexMod_MenuMusic/MMConfig.hpp index 51ab4c5..4021352 100644 --- a/shared/ChatPlexMod_MenuMusic/MMConfig.hpp +++ b/shared/ChatPlexMod_MenuMusic/MMConfig.hpp @@ -3,6 +3,7 @@ #include "Data/EMusicProviderType.hpp" #include +#include namespace ChatPlexMod_MenuMusic { @@ -17,11 +18,12 @@ namespace ChatPlexMod_MenuMusic { bool ShowPlayer = true; - bool StartSongFromBeginning = false; - bool StartANewMusicOnSceneChange = true; - bool LoopCurrentMusic = false; - bool UseOnlyCustomMenuSongsFolder = false; - float PlaybackVolume = 0.5f; + bool StartSongFromBeginning = false; + bool StartANewMusicOnSceneChange = true; + bool LoopCurrentMusic = false; + bool UseOnlyCustomMenuSongsFolder = false; + float PlaybackVolume = 0.5f; + std::u16string LastPlayingSongPath = u""; protected: /// @brief Reset config to default diff --git a/shared/ChatPlexMod_MenuMusic/MenuMusic.hpp b/shared/ChatPlexMod_MenuMusic/MenuMusic.hpp index 09d2a71..caf572b 100644 --- a/shared/ChatPlexMod_MenuMusic/MenuMusic.hpp +++ b/shared/ChatPlexMod_MenuMusic/MenuMusic.hpp @@ -66,6 +66,9 @@ namespace ChatPlexMod_MenuMusic { CP_SDK::Utils::MonoPtr m_WaitUntillReadyCoroutine; CP_SDK::Misc::FastCancellationToken::Ptr m_FastCancellationToken; + CP_SDK::EGenericScene m_LastActiveScene; + bool m_LastPlayingRescue; + public: /// @brief Constructor MenuMusic(); @@ -89,7 +92,9 @@ namespace ChatPlexMod_MenuMusic { public: /// @brief Update the music provider - void UpdateMusicProvider(); + /// @param p_SkipIfAlreadySet Skip if a music provider already exist + /// @return bool True if a new music provider is set + bool UpdateMusicProvider(bool p_SkipIfAlreadySet = false); /// @brief Update playback volume /// @param p_FromConfig From config? void UpdatePlaybackVolume(bool p_FromConfig); diff --git a/src/ChatPlexMod_MenuMusic/MMConfig.cpp b/src/ChatPlexMod_MenuMusic/MMConfig.cpp index 2c178cc..8c272bd 100644 --- a/src/ChatPlexMod_MenuMusic/MMConfig.cpp +++ b/src/ChatPlexMod_MenuMusic/MMConfig.cpp @@ -38,6 +38,7 @@ namespace ChatPlexMod_MenuMusic { CP_SDK_JSON_SERIALIZE_BOOL(LoopCurrentMusic); CP_SDK_JSON_SERIALIZE_BOOL(UseOnlyCustomMenuSongsFolder); CP_SDK_JSON_SERIALIZE_FLOAT(PlaybackVolume); + CP_SDK_JSON_SERIALIZE_STRING(LastPlayingSongPath); } /// @brief Read the document /// @param p_Document Source @@ -51,6 +52,7 @@ namespace ChatPlexMod_MenuMusic { CP_SDK_JSON_UNSERIALIZE_BOOL(LoopCurrentMusic); CP_SDK_JSON_UNSERIALIZE_BOOL(UseOnlyCustomMenuSongsFolder); CP_SDK_JSON_UNSERIALIZE_FLOAT(PlaybackVolume); + CP_SDK_JSON_UNSERIALIZE_STRING(LastPlayingSongPath); } //////////////////////////////////////////////////////////////////////////// diff --git a/src/ChatPlexMod_MenuMusic/MenuMusic.cpp b/src/ChatPlexMod_MenuMusic/MenuMusic.cpp index 0177608..e9b29f4 100644 --- a/src/ChatPlexMod_MenuMusic/MenuMusic.cpp +++ b/src/ChatPlexMod_MenuMusic/MenuMusic.cpp @@ -41,6 +41,8 @@ namespace ChatPlexMod_MenuMusic { m_CurrentSongIndex = 0; m_FastCancellationToken = CP_SDK::Misc::FastCancellationToken::Make(); + + m_LastPlayingRescue = true; } //////////////////////////////////////////////////////////////////////////// @@ -63,11 +65,12 @@ namespace ChatPlexMod_MenuMusic { m_OriginalAmbientVolumeScale = m_PreviewPlayer->____ambientVolumeScale; } - UpdateMusicProvider(); - - /// Enable at start if in menu - if (CP_SDK::ChatPlexSDK::ActiveGenericScene() == CP_SDK::EGenericScene::Menu) - ChatPlexSDK_OnGenericSceneChange(CP_SDK::EGenericScene::Menu); + if (UpdateMusicProvider(true)) + { + /// Enable at start if in menu + if (CP_SDK::ChatPlexSDK::ActiveGenericScene() == CP_SDK::EGenericScene::Menu) + ChatPlexSDK_OnGenericSceneChange(CP_SDK::EGenericScene::Menu); + } } /// @brief Disable the Module void MenuMusic::OnDisable() @@ -126,6 +129,7 @@ namespace ChatPlexMod_MenuMusic { m_PreviewPlayer->____defaultAudioClip = m_OriginalMenuMusic.Ptr(false); DestroyFloatingPlayer(); + m_LastActiveScene = p_Scene; return; } @@ -137,10 +141,12 @@ namespace ChatPlexMod_MenuMusic { m_PreviewPlayer->____volumeScale = 0.0f; /// Start a new music - if (MMConfig::Instance()->StartANewMusicOnSceneChange) + if (p_Scene != m_LastActiveScene && MMConfig::Instance()->StartANewMusicOnSceneChange) StartNewMusic(false, true); else LoadNextMusic(true); + + m_LastActiveScene = p_Scene; } /// @brief Application wants to quit bool MenuMusic::Application_wantsToQuit() @@ -155,8 +161,13 @@ namespace ChatPlexMod_MenuMusic { //////////////////////////////////////////////////////////////////////////// /// @brief Update the music provider - void MenuMusic::UpdateMusicProvider() + /// @param p_SkipIfAlreadySet Skip if a music provider already exist + /// @return bool True if a new music provider is set + bool MenuMusic::UpdateMusicProvider(bool p_SkipIfAlreadySet) { + if (p_SkipIfAlreadySet && m_MusicProvider != nullptr) + return false; + switch (MMConfig::Instance()->MusicProvider) { case Data::MusicProviderType::E::CustomMusic: @@ -171,6 +182,7 @@ namespace ChatPlexMod_MenuMusic { } StartNewMusic(); + return true; } /// @brief Update playback volume /// @param p_FromConfig From config? @@ -371,6 +383,24 @@ namespace ChatPlexMod_MenuMusic { m_CurrentSongIndex++; + if (m_LastPlayingRescue) + { + auto l_SongIndex = -1; + for (auto l_I = 0; l_I < m_MusicProvider->Musics().size(); ++l_I) + { + if (m_MusicProvider->Musics()[l_I]->GetSongPath() != MMConfig::Instance()->LastPlayingSongPath) + continue; + + l_SongIndex = l_I; + break; + } + + if (l_SongIndex != -1) + m_CurrentSongIndex = l_SongIndex; + + m_LastPlayingRescue = false; + } + /// Load and play audio clip LoadNextMusic(p_OnSceneTransition); } @@ -411,6 +441,10 @@ namespace ChatPlexMod_MenuMusic { auto& l_MusicToLoad = m_MusicProvider->Musics()[m_CurrentSongIndex]; + /// Save + MMConfig::Instance()->LastPlayingSongPath = l_MusicToLoad->GetSongPath(); + MMConfig::Instance()->Save(); + m_FastCancellationToken->Cancel(); l_MusicToLoad->GetAudioAsync( m_FastCancellationToken, diff --git a/src/main.cpp b/src/main.cpp index 07693eb..7bc1158 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,3 +1,4 @@ +#include "git_info.h" #include "ChatPlexMod_MenuMusic/Logger.hpp" #include "ChatPlexMod_MenuMusic/MenuMusic.hpp" @@ -10,7 +11,7 @@ static modloader::ModInfo s_ModInfo{"QBeatSaberPlus-MenuMusic", VERSION, GIT_COMMIT}; // Called at the early stages of game loading -extern "C" void setup(CModInfo* p_ModInfo) +extern "C" __attribute__((visibility("default"))) void setup(CModInfo* p_ModInfo) { p_ModInfo->id = s_ModInfo.id.c_str(); p_ModInfo->version = s_ModInfo.version.c_str(); @@ -30,7 +31,7 @@ extern "C" void setup(CModInfo* p_ModInfo) //////////////////////////////////////////////////////////////////////////// // Called later on in the game loading - a good time to install function hooks -extern "C" void late_load() +extern "C" __attribute__((visibility("default"))) void late_load() { il2cpp_functions::Init(); diff --git a/start-logging.ps1 b/start-logging.ps1 index 6301a3c..46ea7bf 100644 --- a/start-logging.ps1 +++ b/start-logging.ps1 @@ -62,7 +62,7 @@ if ($all -eq $false) { $pattern += "$custom|" } if ($pattern -eq "(") { - $pattern = "(QuestHook|modloader|ChatPlexSDK-BS|" + $pattern = "(QuestHook|modloader|scotland2|ChatPlexSDK-BS|" } $pattern += "AndroidRuntime|CRASH)" $command += " | Select-String -pattern `"$pattern`""