From acea53b81df44232527d7ed0ee9b0cd263175161 Mon Sep 17 00:00:00 2001 From: EnderdracheLP Date: Sat, 12 Mar 2022 01:41:13 +0100 Subject: [PATCH] Update for 1.19.1 and 1.20.0 --- .github/workflows/Pre-Release.yml | 24 +-- .github/workflows/Release.yml | 165 +++++++++++--------- .github/workflows/buildMod.yml | 126 ++++++++++------ .gitignore | 6 +- Android.mk | 2 +- Android_Template.mk | 71 --------- CMakeLists.txt | 78 ++++++++++ build.ps1 | 63 ++++++-- buildQMOD.ps1 | 138 ++++++++++++----- mod.json | 34 +++-- mod_Template.json => mod.template.json | 19 +-- qpm.json | 18 ++- src/ClockUpdater.cpp | 12 +- src/ClockViewContoller.cpp | 15 +- src/main.cpp | 201 +++++-------------------- 15 files changed, 517 insertions(+), 455 deletions(-) delete mode 100644 Android_Template.mk create mode 100644 CMakeLists.txt rename mod_Template.json => mod.template.json (50%) diff --git a/.github/workflows/Pre-Release.yml b/.github/workflows/Pre-Release.yml index 44a8907..09fd4be 100644 --- a/.github/workflows/Pre-Release.yml +++ b/.github/workflows/Pre-Release.yml @@ -1,14 +1,12 @@ +name: Pre-Release Mod + on: workflow_dispatch: -name: Pre-Release Mod env: - module_id: clockmod - version: 1.5.1-rc.1 - BSVersion: 1.17.1 - bs_hook: 2_3_0 - codegen: 0_14_0 - ndkname: android-ndk-r23 + module_id: ClockMod + version: 1.5.3-rc.1 + ndkname: android-ndk-r24 jobs: @@ -63,7 +61,7 @@ jobs: cache-name: cache-qpm-deps with: path: QPM_Temp - key: ${{ runner.os }}-${{ env.cache-name }} + key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('qpm_${{ env.BSVersion }}.json', '.github/BuildMod.yml') }} restore-keys: | ${{ runner.os }}-${{ env.cache-name }}- ${{ runner.os }}-${{ env.cache-name }} @@ -81,13 +79,17 @@ jobs: echo "Checking QPM_Temp Folders" ls -lh QPM_Temp/ echo "" + echo "Listing beatsaber-hook folder" + ls QPM_Temp/beatsaber-hook/ + echo "" echo "Listing all .so files in QPM_Temp" find QPM_Temp -type f -name "*.so" -# continue-on-error: true - name: Build run: | cd ${GITHUB_WORKSPACE} + ./QPM/qpm-rust package edit --version ${{ env.version }} + ./QPM/qpm-rust qmod build pwsh -Command ./build.ps1 --actions - name: Get Library Name id: libname @@ -99,7 +101,7 @@ jobs: - name: Package QMOD run: | cd ${GITHUB_WORKSPACE} - pwsh -Command ./buildQMOD.ps1 --package + pwsh -Command ./buildQMOD.ps1 -package - name: Create Release id: create_pre-release uses: actions/create-release@v1 @@ -108,7 +110,7 @@ jobs: with: tag_name: ${{ env.version }} release_name: ${{ env.module_id }} ${{ env.version }} for Beat Saber ${{ env.BSVersion }} - body_path: ./pre-rl-notes + body_path: ./pre-rl-notes.md draft: false prerelease: true - name: Upload QMOD Pre-Release Asset diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 4d46a60..e9ab717 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -1,15 +1,16 @@ +name: Release Mod + on: workflow_dispatch: + push: + # Sequence of patterns matched against refs/tags + tags: + - '*' # Push events with tag - env: - module_id: clockmod - version: 1.5.1 - BSVersion: 1.17.1 - bs_hook: 2_3_0 - codegen: 0_14_0 - ndkname: android-ndk-r23 - -name: Release Mod +env: + module_id: ClockMod + BSVersion: 1.19.1 + ndkname: android-ndk-r24 jobs: build: @@ -21,104 +22,132 @@ jobs: with: submodules: true lfs: true - - name: Install Powershell - run: sudo apt-get install -y powershell - - name: Cache Android NDK - id: cache-ndk - uses: actions/cache@v2 - env: - cache-name: cache-ndk - ndkname: android-ndk-r22 - with: - path: ndk - key: ${{ runner.os }}-${{ env.cache-name }}-${{ env.ndkname }} - restore-keys: | - ${{ runner.os }}-${{ env.cache-name }}-${{ env.ndkname }} + - uses: seanmiddleditch/gha-setup-ninja@v3 + + #- name: Install Powershell + # run: sudo apt-get install -y powershell + + - name: Get the tag name + run: echo "version=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + + #- name: Cache Android NDK + # id: cache-ndk + # uses: actions/cache@v2 + # env: + # cache-name: cache-ndk + # with: + # path: ndk + # key: ${{ runner.os }}-${{ env.cache-name }}-${{ env.ndkname }} + # restore-keys: | + # ${{ runner.os }}-${{ env.cache-name }}-${{ env.ndkname }} - - name: Install Android NDK - if: steps.cache-ndk.outputs.cache-hit != 'true' - run: | - wget -q -O ndk.zip https://dl.google.com/android/repository/${ndkname}-linux-x86_64.zip - unzip -q ndk.zip - mv ${ndkname} ndk + #- name: Install Android NDK + # if: steps.cache-ndk.outputs.cache-hit != 'true' + # run: | + # wget -q -O ndk.zip https://dl.google.com/android/repository/${ndkname}-linux-x86_64.zip + # unzip -q ndk.zip + # mv ${ndkname} ndk + #- name: Create ndkpath.txt + # run: | + # cd ndk + # pwd > ${GITHUB_WORKSPACE}/ndkpath.txt + - name: Create ndkpath.txt run: | - cd ndk - pwd > ${GITHUB_WORKSPACE}/ndkpath.txt + echo "$ANDROID_NDK_LATEST_HOME" > ${GITHUB_WORKSPACE}/ndkpath.txt + - name: Get QPM -# if: steps.cache-qpm.outputs.cache-hit != 'true' + if: steps.cache-qpm.outputs.cache-hit != 'true' uses: dawidd6/action-download-artifact@v2 with: github_token: ${{secrets.GITHUB_TOKEN}} - workflow: main.yml - name: QPM-ubuntu-x64 + workflow: cargo-build.yml + name: linux-qpm-rust path: QPM - repo: sc2ad/QuestPackageManager - + repo: RedBrumbler/QuestPackageManager-Rust + + - name: QPM Collapse + run: | + chmod +x ./QPM/qpm-rust + ./QPM/qpm-rust collapse + - name: QPM Dependencies Cache id: cache-qpm-deps uses: actions/cache@v2 env: cache-name: cache-qpm-deps with: - path: QPM_Temp - key: ${{ runner.os }}-${{ env.cache-name }} + path: /home/runner/.local/share/QPM-Rust/cache + key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('qpm.json', '.github/BuildQSounds.yml') }} restore-keys: | ${{ runner.os }}-${{ env.cache-name }}- ${{ runner.os }}-${{ env.cache-name }} - name: QPM Restore run: | - chmod +x ./QPM/QPM - ./QPM/QPM restore + ./QPM/qpm-rust restore - name: Check dependency Folders run: | - echo "Checking extern Folder" - ls -lh ${GITHUB_WORKSPACE}/extern/ + echo "Checking extern includes" + ls -lh ${GITHUB_WORKSPACE}/extern/includes + echo "" + echo "Checking libs" + ls -lh ${GITHUB_WORKSPACE}/extern/libs echo "" - echo "Checking QPM_Temp Folders" - ls -lh QPM_Temp/ + echo "Checking QPM-Rust/cache Folder" + ls -lh $HOME/.local/share/QPM-Rust/cache echo "" - echo "Listing all .so files in QPM_Temp" - find QPM_Temp -type f -name "*.so" -# continue-on-error: true - name: Build run: | cd ${GITHUB_WORKSPACE} + ./QPM/qpm-rust package edit --version ${{ env.version }} + ./QPM/qpm-rust qmod build pwsh -Command ./build.ps1 --actions + - name: Get Library Name id: libname run: | - cd ./libs/arm64-v8a/ + cd ./build/ pattern="lib${module_id}*.so" files=( $pattern ) echo ::set-output name=NAME::"${files[0]}" + - name: Package QMOD run: | cd ${GITHUB_WORKSPACE} - pwsh -Command ./buildQMOD.ps1 --package - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ env.version }} - release_name: ${{ env.module_id }} ${{ env.version }} for Beat Saber ${{ env.BSVersion }} - body_path: ./rl-notes - draft: false - prerelease: false - - name: Upload QMOD Release Asset - id: upload-release-QMOD - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + pwsh -Command ./buildQMOD.ps1 -package + + - name: Release + uses: softprops/action-gh-release@v1 with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./${{ env.module_id }}.qmod - asset_name: ${{ env.module_id }}.qmod - asset_content_type: application/qmod \ No newline at end of file + name: ${{ env.module_id }} ${{ env.version }} for Beat Saber ${{ env.BSVersion }} + files: | + ./${{ env.module_id }}.qmod + body_path: ./rl-notes.md + draft: true + + #- name: Create Release + # id: create_release + # uses: actions/create-release@v1 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # with: + # tag_name: ${{ github.ref }} + # release_name: ${{ env.module_id }} ${{ github.ref }} for Beat Saber ${{ env.BSVersion }} + # body_path: ./rl-notes.md + # draft: true + # prerelease: false + #- name: Upload QMOD Release Asset + # id: upload-release-QMOD + # uses: actions/upload-release-asset@v1 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # with: + # upload_url: ${{ steps.create_release.outputs.upload_url }} + # asset_path: ./${{ env.module_id }}.qmod + # asset_name: ${{ env.module_id }}.qmod + # asset_content_type: application/qmod \ No newline at end of file diff --git a/.github/workflows/buildMod.yml b/.github/workflows/buildMod.yml index 50f062c..161c077 100644 --- a/.github/workflows/buildMod.yml +++ b/.github/workflows/buildMod.yml @@ -3,16 +3,27 @@ name: NDK build on: workflow_dispatch: push: - branches: [ main, dev ] + branches: [ master, dev ] + paths-ignore: + - '**.yml' + - '!.github/workflows/BuildMod.yml' + - '**.json' + - '!qpm.json' + - '**.ps1' + - '!build.ps1' + - '!buildQMOD.ps1' + - '**.md' + - '.gitignore' + - '**.ogg' + - '**.zip' pull_request: - branches: [ main, dev ] + branches: [ master, dev ] env: - module_id: clockmod - version: 1.5.1-Dev.${{ github.run_number }} - BSVersion: 1.17.1 - bs_hook: 2_3_0 - codegen: 0_14_0 + module_id: ClockMod + version: 1.5.2-Dev.${{ github.run_number }} + BSVersion: 1.19.1 +# ndkname: android-ndk-r24 jobs: build: @@ -25,76 +36,92 @@ jobs: submodules: true lfs: true + - uses: seanmiddleditch/gha-setup-ninja@v3 + +# - name: Install Powershell +# run: sudo apt-get install -y powershell + +# - name: Cache Android NDK +# id: cache-ndk +# uses: actions/cache@v2 +# env: +# cache-name: cache-ndk +# with: +# path: ndk +# key: ${{ runner.os }}-${{ env.cache-name }}-${{ env.ndkname }} +# restore-keys: | +# ${{ runner.os }}-${{ env.cache-name }}-${{ env.ndkname }} + +# - name: Install Android NDK +# if: steps.cache-ndk.outputs.cache-hit != 'true' +# run: | +# wget -q -O ndk.zip https://dl.google.com/android/repository/${ndkname}-linux-x86_64.zip +# unzip -q ndk.zip +# mv ${ndkname} ndk + +# - name: Create ndkpath.txt +# run: | +# cd ndk +# pwd > ${GITHUB_WORKSPACE}/ndkpath.txt + - name: Create ndkpath.txt run: | echo "$ANDROID_NDK_LATEST_HOME" > ${GITHUB_WORKSPACE}/ndkpath.txt - cat ${GITHUB_WORKSPACE}/ndkpath.txt - -# - name: Cache QPM -# id: cache-qpm -# uses: actions/cache@v2 -# env: -# cache-name: cache-qpm -# with: -# path: QPM -# key: ${{ runner.os }}-${{ env.cache-name }}-1 -# restore-keys: | -# ${{ runner.os }}-${{ env.cache-name }}-1 - name: Get QPM -# if: steps.cache-qpm.outputs.cache-hit != 'true' + if: steps.cache-qpm.outputs.cache-hit != 'true' uses: dawidd6/action-download-artifact@v2 with: github_token: ${{secrets.GITHUB_TOKEN}} - workflow: main.yml - name: QPM-ubuntu-x64 + workflow: cargo-build.yml + name: linux-qpm-rust path: QPM - repo: sc2ad/QuestPackageManager - + repo: RedBrumbler/QuestPackageManager-Rust + + - name: QPM Collapse + run: | + chmod +x ./QPM/qpm-rust + ./QPM/qpm-rust collapse + - name: QPM Dependencies Cache id: cache-qpm-deps uses: actions/cache@v2 env: cache-name: cache-qpm-deps with: - path: QPM_Temp - key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('qpm.json', '.github/buildMod.yml') }} + path: /home/runner/.local/share/QPM-Rust/cache + key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('qpm.json', '.github/BuildQSounds.yml') }} restore-keys: | ${{ runner.os }}-${{ env.cache-name }}- ${{ runner.os }}-${{ env.cache-name }} - name: QPM Restore run: | - chmod +x ./QPM/QPM - ./QPM/QPM restore + ./QPM/qpm-rust restore - name: Check dependency Folders run: | - echo "Checking extern Folder" - ls -lh ${GITHUB_WORKSPACE}/extern/ - echo "" - echo "Checking QPM_Temp Folders" - ls -lh QPM_Temp/ + echo "Checking extern includes" + ls -lh ${GITHUB_WORKSPACE}/extern/includes echo "" - echo "Listing beatsaber-hook folder" - ls QPM_Temp/beatsaber-hook/ + echo "Checking libs" + ls -lh ${GITHUB_WORKSPACE}/extern/libs echo "" - echo "Listing codegen folder" - ls QPM_Temp/codegen/ + echo "Checking QPM-Rust/cache Folder" + ls -lh $HOME/.local/share/QPM-Rust/cache echo "" - echo "Listing all .so files in QPM_Temp" - find QPM_Temp -type f -name "*.so" -# continue-on-error: true - name: Build run: | cd ${GITHUB_WORKSPACE} + ./QPM/qpm-rust package edit --version ${{ env.version }} + ./QPM/qpm-rust qmod build pwsh -Command ./build.ps1 --actions - name: Get Library Name id: libname run: | - cd ./libs/arm64-v8a/ + cd ./build/ pattern="lib${module_id}*.so" files=( $pattern ) echo ::set-output name=NAME::"${files[0]}" @@ -102,23 +129,28 @@ jobs: - name: Package QMOD run: | cd ${GITHUB_WORKSPACE} - pwsh -Command ./buildQMOD.ps1 --package + pwsh -Command ./buildQMOD.ps1 -package + - name: Upload non-debug artifact uses: actions/upload-artifact@v2 with: name: ${{ steps.libname.outputs.NAME }} - path: ./libs/arm64-v8a/${{ steps.libname.outputs.NAME }} + path: ./build/${{ steps.libname.outputs.NAME }} if-no-files-found: error + + - name: Upload debug artifact uses: actions/upload-artifact@v2 with: name: debug_${{ steps.libname.outputs.NAME }} - path: ./obj/local/arm64-v8a/${{ steps.libname.outputs.NAME }} + path: ./build/debug/${{ steps.libname.outputs.NAME }} if-no-files-found: error + + - name: Upload QMOD uses: actions/upload-artifact@v2 with: - name: ${{ env.module_id }}-(UNZIP-for-QMOD) - path: ./${{ env.module_id }}.qmod - if-no-files-found: warn + name: ${{ env.module_id }}-(UNZIP-for-QMOD).qmod + path: ./${{ env.module_id }}_${{ env.version }}.qmod + if-no-files-found: warn \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5a379a8..0e02eca 100644 --- a/.gitignore +++ b/.gitignore @@ -46,9 +46,11 @@ out/ [Oo]bjs/ ndkpath.txt *.zip -*.txt extern/ qpm.shared.json Android.mk.backup *.qmod -*.prolog \ No newline at end of file +*.prolog +*.cmake +/CMakeSettings.json +/build diff --git a/Android.mk b/Android.mk index ffa3861..e1a5436 100644 --- a/Android.mk +++ b/Android.mk @@ -65,7 +65,7 @@ LOCAL_SHARED_LIBRARIES += codegen LOCAL_SHARED_LIBRARIES += custom-types LOCAL_SHARED_LIBRARIES += questui LOCAL_LDLIBS += -llog -LOCAL_CFLAGS += -I'extern/libil2cpp/il2cpp/libil2cpp' -DID='"clockmod"' -DVERSION='"1.5.1-Dev"' -I'./shared' -I'./extern' -isystem'extern/codegen/include' -Ofast +LOCAL_CFLAGS += -I'extern/libil2cpp/il2cpp/libil2cpp' -DID='"clockmod"' -DVERSION='"1.5.1"' -I'./shared' -I'./extern' -isystem'extern/codegen/include' -Ofast LOCAL_CPPFLAGS += -std=c++2a -Ofast LOCAL_C_INCLUDES += ./include ./src include $(BUILD_SHARED_LIBRARY) diff --git a/Android_Template.mk b/Android_Template.mk deleted file mode 100644 index 5a120c2..0000000 --- a/Android_Template.mk +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright (C) 2009 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -LOCAL_PATH := $(call my-dir) -TARGET_ARCH_ABI := $(APP_ABI) - -rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)) - -# Build the modloader shared library -include $(CLEAR_VARS) -LOCAL_MODULE := -include $(CLEAR_VARS) -# Creating prebuilt for dependency: beatsaber-hook - version: 1.3.3 -include $(CLEAR_VARS) -LOCAL_MODULE := beatsaber-hook_{BS_Hook} -LOCAL_EXPORT_C_INCLUDES := extern/beatsaber-hook -LOCAL_SRC_FILES := extern/libbeatsaber-hook_{BS_Hook}.so -LOCAL_CPP_FEATURES += exceptions -include $(PREBUILT_SHARED_LIBRARY) -# Creating prebuilt for dependency: codegen - version: 0.14.0 -include $(CLEAR_VARS) -LOCAL_MODULE := codegen -LOCAL_EXPORT_C_INCLUDES := extern/codegen -LOCAL_SRC_FILES := extern/libcodegen.so -include $(PREBUILT_SHARED_LIBRARY) -# Creating prebuilt for dependency: custom-types - version: 0.8.3 -include $(CLEAR_VARS) -LOCAL_MODULE := custom-types -LOCAL_EXPORT_C_INCLUDES := extern/custom-types -LOCAL_SRC_FILES := extern/libcustom-types.so -include $(PREBUILT_SHARED_LIBRARY) -# Creating prebuilt for dependency: modloader - version: 1.1.0 -include $(CLEAR_VARS) -LOCAL_MODULE := modloader -LOCAL_EXPORT_C_INCLUDES := extern/modloader -LOCAL_SRC_FILES := extern/libmodloader.so -include $(PREBUILT_SHARED_LIBRARY) -# Creating prebuilt for dependency: questui - version: 0.6.11 -include $(CLEAR_VARS) -LOCAL_MODULE := questui -LOCAL_EXPORT_C_INCLUDES := extern/questui -LOCAL_SRC_FILES := extern/libquestui.so -include $(PREBUILT_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := clockmod -LOCAL_SRC_FILES += $(call rwildcard,src/,*.cpp) -LOCAL_SRC_FILES += $(call rwildcard,extern/beatsaber-hook/src/inline-hook,*.cpp) -LOCAL_SRC_FILES += $(call rwildcard,extern/beatsaber-hook/src/inline-hook,*.c) -LOCAL_SHARED_LIBRARIES += modloader -LOCAL_SHARED_LIBRARIES += beatsaber-hook_{BS_Hook} -LOCAL_SHARED_LIBRARIES += codegen -LOCAL_SHARED_LIBRARIES += custom-types -LOCAL_SHARED_LIBRARIES += questui -LOCAL_LDLIBS += -llog -LOCAL_CFLAGS += -I'extern/libil2cpp/il2cpp/libil2cpp' -DID='"clockmod"' -DVERSION='"{VERSION}"' -I'./shared' -I'./extern' -isystem'extern/codegen/include' -Ofast -LOCAL_CPPFLAGS += -std=c++2a -Ofast -LOCAL_C_INCLUDES += ./include ./src -include $(BUILD_SHARED_LIBRARY) diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..1d0ef07 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,78 @@ +# include some defines automatically made by qpm +include(qpm_defines.cmake) + +# override mod id +# set(MOD_ID "Streamer-Tools") + +# Enable link time optimization +# In my experience, this can be highly unstable but it nets a huge size optimization and likely performance +# However, the instability was seen using Android.mk/ndk-build builds. With Ninja + CMake, this problem seems to have been solved. +# As always, test thoroughly +# - Fern +# set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) + +cmake_minimum_required(VERSION 3.21) +project(${COMPILE_ID}) + +# 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) + +# compile options used +add_compile_options(-frtti -fexceptions) +add_compile_options(-O3) +# compile definitions used +add_compile_definitions(VERSION=\"${MOD_VERSION}\") +add_compile_definitions(ID=\"${MOD_ID}\") +add_compile_definitions(MOD_ID=\"${MOD_ID}\") + +# recursively get all src files +RECURSE_FILES(cpp_file_list ${SOURCE_DIR}/*.cpp) +RECURSE_FILES(c_file_list ${SOURCE_DIR}/*.c) + +# add all src files to compile +add_library( + ${COMPILE_ID} + SHARED + ${cpp_file_list} + ${c_file_list} +) + +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) + +target_link_libraries(${COMPILE_ID} PRIVATE -llog) +# 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.") + +add_custom_command(TARGET ${COMPILE_ID} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory debug + COMMENT "Make directory for debug symbols" + ) + +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" + ) + +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" + ) \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index c21626e..deb29e3 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,28 +1,59 @@ $NDKPath = Get-Content $PSScriptRoot/ndkpath.txt -if ($args.Count -eq 0 -or $args[0] -eq "--release") { -$ModID = "clockmod" -$VERSION = "1.5.1" -if ($args[0] -ne "--release") { - $VERSION += "-Dev" +for ($i = 0; $i -le $args.Length-1; $i++) { +echo "Arg $($i) is $($args[$i])" + if ($args[$i] -eq "--actions") { $actions = $true } + elseif ($args[$i] -eq "--release") { $release = $true } } -$BSHook = "2_3_0" +if ($args.Count -eq 0 -or $actions -ne $true) { +$ModID = "ClockMod" +$VERSION = "1.5.2" + if ($release -ne $true) { + $VERSION += "-Dev" + } } -if ($args[0] -eq "--actions") { + +if ($actions -eq $true) { $ModID = $env:module_id $BSHook = $env:bs_hook $VERSION = $env:version + $codegen_ver = $env:codegen +} else { + & qpm-rust package edit --version $VERSION +} +if ((Test-Path "./extern/includes/beatsaber-hook/src/inline-hook/And64InlineHook.cpp", "./extern/includes/beatsaber-hook/src/inline-hook/inlineHook.c", "./extern/includes/beatsaber-hook/src/inline-hook/relocate.c") -contains $false) { + Write-Host "Critical: Missing inline-hook" + if (!(Test-Path "./extern/includes/beatsaber-hook/src/inline-hook/And64InlineHook.cpp")) { + Write-Host "./extern/includes/beatsaber-hook/src/inline-hook/And64InlineHook.cpp" + } + if (!(Test-Path "./extern/includes/beatsaber-hook/src/inline-hook/inlineHook.c")) { + Write-Host "./extern/includes/beatsaber-hook/src/inline-hook/inlineHook.c" + } + if (!(Test-Path "./extern/includes/beatsaber-hook/inline-hook/src/relocate.c")) { + Write-Host "./extern/includes/beatsaber-hook/src/inline-hook/relocate.c" + } + Write-Host "Task Failed" + exit 1; } -echo "Building mod with ModID: $ModID version: $VERSION, BS-Hook version: $BSHook" -Copy-Item "./Android_Template.mk" "./Android.mk" -Force -(Get-Content "./Android.mk").replace('{BS_Hook}', "$BSHook") | Set-Content "./Android.mk" -(Get-Content "./Android.mk").replace('{VERSION}', "$VERSION") | Set-Content "./Android.mk" +echo "Building mod with ModID: $ModID version: $VERSION" -$buildScript = "$NDKPath/build/ndk-build" -if (-not ($PSVersionTable.PSEdition -eq "Core")) { - $buildScript += ".cmd" +if ($clean.IsPresent) +{ + if (Test-Path -Path "build") + { + remove-item build -R + } } -& $buildScript NDK_PROJECT_PATH=$PSScriptRoot APP_BUILD_SCRIPT=$PSScriptRoot/Android.mk NDK_APPLICATION_MK=$PSScriptRoot/Application.mk -j 4 --output-sync=none +if (($clean.IsPresent) -or (-not (Test-Path -Path "build"))) +{ + $out = new-item -Path build -ItemType Directory +} -echo Done +cd build +& cmake -G "Ninja" -DCMAKE_BUILD_TYPE="RelWithDebInfo" ../ +& cmake --build . -j 6 +$ExitCode = $LastExitCode +cd .. +exit $ExitCode +echo Done \ No newline at end of file diff --git a/buildQMOD.ps1 b/buildQMOD.ps1 index 5fc35fe..d422285 100644 --- a/buildQMOD.ps1 +++ b/buildQMOD.ps1 @@ -1,40 +1,102 @@ -# Builds a .qmod file for loading with QP -if ($args.Count -eq 0 -or $args[0] -eq "--dev") { -$ModID = "clockmod" -$VERSION = "1.5.1" -if ($args[0] -eq "--dev") { - $VERSION += "-Dev" -} -$BSHook = "2_3_0" -$BS_Version = "1.17.1" -echo "Compiling Mod" -if ($args[0] -eq "--dev") { - & $PSScriptRoot/build.ps1 -} -else { - & $PSScriptRoot/build.ps1 --release -} -} - - Copy-Item "./mod_Template.json" "./mod.json" -Force -# TODO: Get the below working with Github Actions variables. -if ($args[0] -eq "--package") { - $ModID = $env:module_id - $BSHook = $env:bs_hook - $BS_Version = $env:BSVersion -echo "Actions: Packaging QMod with ModID: $ModID and BS-Hook version: $BSHook" - (Get-Content "./mod.json").replace('{VERSION_NUMBER_PLACEHOLDER}', "$env:version") | Set-Content "./mod.json" - (Get-Content "./mod.json").replace('{BS_Hook}', "$BSHook") | Set-Content "./mod.json" - (Get-Content "./mod.json").replace('{BS_Version}', "$BS_Version") | Set-Content "./mod.json" - Compress-Archive -Path "./libs/arm64-v8a/lib$ModID.so", "./libs/arm64-v8a/libbeatsaber-hook_$BSHook.so", ".\mod.json", ".\Cover.jpg" -DestinationPath "./Temp$ModID.zip" -Update - Move-Item "./Temp$ModID.zip" "./$ModID.qmod" -Force -} -if ($? -And $args.Count -eq 0 -or $args[0] -eq "--dev") { -echo "Packaging QMod with ModID: $ModID and version: $VERSION" - (Get-Content "./mod.json").replace('{VERSION_NUMBER_PLACEHOLDER}', "$VERSION") | Set-Content "./mod.json" - (Get-Content "./mod.json").replace('{BS_Hook}', "$BSHook") | Set-Content "./mod.json" - (Get-Content "./mod.json").replace('{BS_Version}', "$BS_Version") | Set-Content "./mod.json" - Compress-Archive -Path "./libs/arm64-v8a/lib$ModID.so", "./libs/arm64-v8a/libbeatsaber-hook_$BSHook.so", ".\mod.json", ".\Cover.jpg" -DestinationPath "./Temp$ModID.zip" -Update - Move-Item "./Temp$ModID.zip" "./$ModID.qmod" -Force +Param( + [Parameter(Mandatory=$false, HelpMessage="The name the output qmod file should have")][String] $qmodname="ClockMod", + + [Parameter(Mandatory=$false, HelpMessage="Switch to create a clean compilation")] + [Alias("rebuild")] + [Switch] $clean, + + [Parameter(Mandatory=$false, HelpMessage="Prints the help instructions")] + [Switch] $help, + + [Parameter(Mandatory=$false, HelpMessage="Tells the script to not compile and only package the existing files")] + [Alias("actions", "pack")] + [Switch] $package +) + +# Builds a .qmod file for loading with QP or BMBF + + +if ($help -eq $true) { + echo "`"BuildQmod `" - Copiles your mod into a `".so`" or a `".a`" library" + echo "`n-- Parameters --`n" + echo "qmodName `t The file name of your qmod" + + echo "`n-- Arguments --`n" + + echo "-clean `t`t Performs a clean build on both your library and the qmod" + echo "-help `t`t Prints this" + echo "-package `t Only packages existing files, without recompiling`n" + + exit +} + +if ($qmodName -eq "") +{ + echo "Give a proper qmod name and try again" + exit +} + +if ($package -eq $true) { + $qmodName = "$($env:module_id)_$($env:version)" + echo "Actions: Packaging QMod $qmodName" +} +if (($args.Count -eq 0) -And $package -eq $false) { +echo "Creating QMod $qmodName" + & $PSScriptRoot/build.ps1 -clean:$clean + + if ($LASTEXITCODE -ne 0) { + echo "Failed to build, exiting..." + exit $LASTEXITCODE + } + + qpm-rust qmod build +} + +echo "Creating qmod from mod.json" + +$mod = "./mod.json" +$modJson = Get-Content $mod -Raw | ConvertFrom-Json + +$filelist = @($mod) + +$cover = "./" + $modJson.coverImage +if ((-not ($cover -eq "./")) -and (Test-Path $cover)) +{ + $filelist += ,$cover +} else { + echo "No cover Image found" +} + +foreach ($mod in $modJson.modFiles) +{ + $path = "./build/" + $mod + if (-not (Test-Path $path)) + { + $path = "./extern/libs/" + $mod + } + $filelist += $path } + +foreach ($lib in $modJson.libraryFiles) +{ + $path = "./extern/libs/" + $lib + if (-not (Test-Path $path)) + { + $path = "./build/" + $lib + } + $filelist += $path +} + +$zip = $qmodName + ".zip" +$qmod = $qmodName + ".qmod" + +if ((-not ($clean.IsPresent)) -and (Test-Path $qmod)) +{ + echo "Making Clean Qmod" + Move-Item $qmod $zip -Force +} + +Compress-Archive -Path $filelist -DestinationPath $zip -Update +Move-Item $zip $qmod -Force + echo "Task Completed" \ No newline at end of file diff --git a/mod.json b/mod.json index 497b4ea..c411a16 100644 --- a/mod.json +++ b/mod.json @@ -1,19 +1,35 @@ { "_QPVersion": "0.1.1", - "id": "clockmod", "name": "Clock Mod", - "version": "1.5.1", + "id": "ClockMod", "author": "BoopetyDoopety, EnderdracheLP", + "version": "1.5.2", "packageId": "com.beatgames.beatsaber", - "packageVersion": "1.17.1", + "packageVersion": "1.19.1", "description": "Displays the time in game. Alternatively also the Battery Percentage", - "coverImage": "Cover.jpg", + "dependencies": [ + { + "version": "^0.15.7", + "id": "custom-types", + "downloadIfMissing": "https://github.com/sc2ad/Il2CppQuestTypePatching/releases/download/v0.15.8/CustomTypes.qmod" + }, + { + "version": "^0.21.0", + "id": "codegen", + "downloadIfMissing": "https://github.com/sc2ad/BeatSaber-Quest-Codegen/releases/download/v0.21.0/Codegen.qmod" + }, + { + "version": "^0.13.2", + "id": "questui", + "downloadIfMissing": "https://github.com/darknight1050/questui/releases/download/v0.13.3/QuestUI.qmod" + } + ], "modFiles": [ - "libclockmod.so" + "libClockMod.so" ], "libraryFiles": [ - "libbeatsaber-hook_2_3_0.so" + "libbeatsaber-hook_3_6_8.so" ], - "dependencies": [], - "fileCopies": [] -} + "fileCopies": [], + "copyExtensions": [] +} \ No newline at end of file diff --git a/mod_Template.json b/mod.template.json similarity index 50% rename from mod_Template.json rename to mod.template.json index 230c7da..d68f08b 100644 --- a/mod_Template.json +++ b/mod.template.json @@ -1,19 +1,16 @@ { "_QPVersion": "0.1.1", - "id": "clockmod", - "name": "Clock Mod", - "version": "{VERSION_NUMBER_PLACEHOLDER}", + "name": "${mod_name}", + "id": "${mod_id}", "author": "BoopetyDoopety, EnderdracheLP", + "version": "${version}", "packageId": "com.beatgames.beatsaber", - "packageVersion": "{BS_Version}", + "packageVersion": "1.19.1", "description": "Displays the time in game. Alternatively also the Battery Percentage", "coverImage": "Cover.jpg", - "modFiles": [ - "libclockmod.so" - ], - "libraryFiles": [ - "libbeatsaber-hook_{BS_Hook}.so" - ], "dependencies": [], - "fileCopies": [] + "modFiles": [], + "libraryFiles": [], + "fileCopies": [], + "copyExtensions": [] } \ No newline at end of file diff --git a/qpm.json b/qpm.json index b8df8b0..809e8ed 100644 --- a/qpm.json +++ b/qpm.json @@ -3,15 +3,17 @@ "dependenciesDir": "extern", "info": { "name": "Clock Mod", - "id": "clockmod", - "version": "1.4.0", + "id": "ClockMod", + "version": "1.5.2", "url": null, - "additionalData": {} + "additionalData": { + "overrideSoName": "libClockMod.so" + } }, "dependencies": [ { "id": "beatsaber-hook", - "versionRange": "^2.3.0", + "versionRange": "^3.6.8", "additionalData": { "extraFiles": [ "src/inline-hook" @@ -20,22 +22,22 @@ }, { "id": "codegen", - "versionRange": "^0.14.0", + "versionRange": "^0.20.0", "additionalData": {} }, { "id": "questui", - "versionRange": "^0.11.0", + "versionRange": "^0.13.2", "additionalData": {} }, { "id": "custom-types", - "versionRange": "^0.12.7", + "versionRange": "^0.15.7", "additionalData": {} }, { "id": "config-utils", - "versionRange": "^0.6.0", + "versionRange": "*", "additionalData": {} } ], diff --git a/src/ClockUpdater.cpp b/src/ClockUpdater.cpp index 6eb6319..407cec4 100644 --- a/src/ClockUpdater.cpp +++ b/src/ClockUpdater.cpp @@ -13,14 +13,14 @@ using namespace UnityEngine; using namespace TMPro; -#ifndef REGISTER_FUNCTION -DEFINE_TYPE(ClockMod, ClockUpdater); -#elif defined(DEFINE_TYPE) -DEFINE_TYPE(ClockMod::ClockUpdater); -#elif defined(DEFINE_CLASS) -DEFINE_CLASS(ClockMod::ClockUpdater); +#if defined(REGISTER_FUNCTION) || defined(DEFINE_CLASS) +#error Outdated custom-types +#elif !defined(DEFINE_TYPE) +#error Custom-types macro missing, make sure you have ran: 'qpm-rust restore' and that you have a compatible version of custom-types #endif +DEFINE_TYPE(ClockMod, ClockUpdater); + namespace ClockMod { std::string ClockUpdater::getTimeFormat() { std::string TFormat; diff --git a/src/ClockViewContoller.cpp b/src/ClockViewContoller.cpp index d4d054b..342dba9 100644 --- a/src/ClockViewContoller.cpp +++ b/src/ClockViewContoller.cpp @@ -29,14 +29,15 @@ using namespace QuestUI; using namespace UnityEngine; using namespace HMUI; -#ifndef REGISTER_FUNCTION -DEFINE_TYPE(ClockMod, ClockViewController); -#elif defined(DEFINE_TYPE) -DEFINE_TYPE(ClockMod::ClockViewController); -#elif defined(DEFINE_CLASS) -DEFINE_CLASS(ClockMod::ClockViewController); +#if defined(REGISTER_FUNCTION) || defined(DEFINE_CLASS) +#error Outdated custom-types +#elif !defined(DEFINE_TYPE) +#error Custom-types macro missing, make sure you have ran: 'qpm-rust restore' and that you have a compatible version of custom-types #endif +DEFINE_TYPE(ClockMod, ClockViewController); + + namespace ClockMod { custom_types::Helpers::Coroutine ClockViewController::UpdateTimeText() { @@ -111,7 +112,7 @@ namespace ClockMod { ); } - StartCoroutine(reinterpret_cast(custom_types::Helpers::CoroutineHelper::New(UpdateTimeText()))); + StartCoroutine(custom_types::Helpers::CoroutineHelper::New(UpdateTimeText())); } void ClockViewController::DidDeactivate(bool removedFromHierarchy, bool systemScreenDisabling) { SettingsOpen = false; diff --git a/src/main.cpp b/src/main.cpp index e18bcc3..08ef5df 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,11 +12,7 @@ #include "GlobalNamespace/BeatmapCharacteristicSO.hpp" // For checking the characteristic 360/90. #include "GlobalNamespace/GameplayCoreInstaller.hpp" // Also part of the check. #include "GlobalNamespace/MultiplayerLobbyController.hpp" -//#include "GlobalNamespace/HostLobbySetupViewController.hpp" -//#include "GlobalNamespace/ClientLobbySetupViewController.hpp" -//#include "GlobalNamespace/QuickPlaySetupViewController.hpp" #include "GlobalNamespace/LobbySetupViewController.hpp" // NEW: For 1.16.4 -#include "GlobalNamespace/BeatmapObjectCallbackController.hpp" // For checking characteristic #include "GlobalNamespace/IReadonlyBeatmapData.hpp" // To read the BeatmapData #include "GlobalNamespace/FlyingGameHUDRotation.hpp" // Take rotation from this instead lol #include "GlobalNamespace/PlayerDataModel.hpp" // For checking if noTextandHUDs is enabled @@ -71,14 +67,10 @@ Config_t Config; // Clock Positions ClockPos_t ClockPos; -#if defined(MAKE_HOOK_OFFSETLESS) && !defined(MAKE_HOOK_MATCH) -#define CM_MAKE_HOOK(name, mPtr, retval, ...) MAKE_HOOK_OFFSETLESS(name, retval, __VA_ARGS__) -#define CM_INSTALL_HOOK(logger, name, methodInfo) INSTALL_HOOK_OFFSETLESS(logger, name, methodInfo) -#elif defined(MAKE_HOOK_MATCH) -#define CM_MAKE_HOOK(name, mPtr, retval, ...) MAKE_HOOK_MATCH(name, mPtr, retval, __VA_ARGS__) -#define CM_INSTALL_HOOK(logger, name, methodInfo) INSTALL_HOOK(logger, name) -#else -#error No Compatible HOOK macro found +#if defined(MAKE_HOOK_OFFSETLESS) +#error Outdated bs-hook +#elif !defined(MAKE_HOOK_MATCH) +#error No supported HOOK macro found, make sure that you have ran: 'qpm-rust restore' and that you have a compatible version of bs-hook #endif ModInfo modInfo; // Stores the ID and version of our mod, and is sent to the modloader upon startup @@ -106,7 +98,7 @@ void MPLobbyClockPos(float MLobbyVCPosY) { layout->get_gameObject()->get_transform()->GetParent()->set_eulerAngles(UnityEngine::Vector3(0, 0, 0)); } -CM_MAKE_HOOK(MainMenuViewController_DidActivate, &MainMenuViewController::DidActivate, void, MainMenuViewController* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { +MAKE_HOOK_MATCH(MainMenuViewController_DidActivate, &MainMenuViewController::DidActivate, void, MainMenuViewController* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { MainMenuViewController_DidActivate(self, firstActivation, addedToHierarchy, screenSystemEnabling); if (firstActivation && ClockModInit) { @@ -183,9 +175,9 @@ void SetClockPos(UnityEngine::Vector3 Pos, UnityEngine::Vector3 Angle, float Sca } // TODO: Use a different hook, this one is too small and causes issues -CM_MAKE_HOOK(AudioTimeSyncController_StartSong, &AudioTimeSyncController::StartSong, void, AudioTimeSyncController* self, float startTimeOffset) { +MAKE_HOOK_MATCH(AudioTimeSyncController_StartSong, &AudioTimeSyncController::StartSong, void, AudioTimeSyncController* self, float startTimeOffset) { // Instance of PlayerDataModel the noTextAndHUDs variable specifically - Config.noTextAndHUD = UnityEngine::Object::FindObjectOfType()->playerData->playerSpecificSettings->noTextsAndHuds; + Config.noTextAndHUD = UnityEngine::Object::FindObjectOfType()->dyn__playerData()->get_playerSpecificSettings()->dyn__noTextsAndHuds(); //float LayoutClockPosX = layout->get_transform()->get_position().x; //float LayoutClockPosY = layout->get_transform()->get_position().y; @@ -249,7 +241,7 @@ CM_MAKE_HOOK(AudioTimeSyncController_StartSong, &AudioTimeSyncController::StartS } } -//CM_MAKE_HOOK(SceneManager_Internal_ActiveSceneChanged, &UnityEngine::SceneManagement::SceneManager::Internal_ActiveSceneChanged, void, UnityEngine::SceneManagement::Scene prevScene, UnityEngine::SceneManagement::Scene nextScene) { +//MAKE_HOOK_MATCH(SceneManager_Internal_ActiveSceneChanged, &UnityEngine::SceneManagement::SceneManager::Internal_ActiveSceneChanged, void, UnityEngine::SceneManagement::Scene prevScene, UnityEngine::SceneManagement::Scene nextScene) { // SceneManager_Internal_ActiveSceneChanged(prevScene, nextScene); // if (nextScene.IsValid()) { // std::string sceneName = to_utf8(csstrtostr(nextScene.get_name())); @@ -320,13 +312,13 @@ CM_MAKE_HOOK(AudioTimeSyncController_StartSong, &AudioTimeSyncController::StartS // } //} -//CM_MAKE_HOOK(AudioTimeSyncController_StopSong, &AudioTimeSyncController::StopSong, void, AudioTimeSyncController* self) { +//MAKE_HOOK_MATCH(AudioTimeSyncController_StopSong, &AudioTimeSyncController::StopSong, void, AudioTimeSyncController* self) { // AudioTimeSyncController_StopSong(self); // Config.IsInSong = false; // layout->get_transform()->set_position(UnityEngine::Vector3(0, Config.ClockY, Config.ClockZ)); //} -CM_MAKE_HOOK(CampaignFlowCoordinator_DidActivate, &CampaignFlowCoordinator::DidActivate, void, CampaignFlowCoordinator* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { +MAKE_HOOK_MATCH(CampaignFlowCoordinator_DidActivate, &CampaignFlowCoordinator::DidActivate, void, CampaignFlowCoordinator* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { CampaignFlowCoordinator_DidActivate(self, firstActivation, addedToHierarchy, screenSystemEnabling); if (!getModConfig().InSong.GetValue() || Config.noTextAndHUD) { @@ -344,7 +336,7 @@ CM_MAKE_HOOK(CampaignFlowCoordinator_DidActivate, &CampaignFlowCoordinator::DidA layout->get_transform()->set_localEulerAngles(UnityEngine::Vector3(0, 0, 0)); } -CM_MAKE_HOOK(PartyFreePlayFlowCoordinator_SinglePlayerLevelSelectionFlowCoordinatorDidActivate, &PartyFreePlayFlowCoordinator::SinglePlayerLevelSelectionFlowCoordinatorDidActivate, void, PartyFreePlayFlowCoordinator* self, bool firstActivation, bool addedToHierarchy) { +MAKE_HOOK_MATCH(PartyFreePlayFlowCoordinator_SinglePlayerLevelSelectionFlowCoordinatorDidActivate, &PartyFreePlayFlowCoordinator::SinglePlayerLevelSelectionFlowCoordinatorDidActivate, void, PartyFreePlayFlowCoordinator* self, bool firstActivation, bool addedToHierarchy) { PartyFreePlayFlowCoordinator_SinglePlayerLevelSelectionFlowCoordinatorDidActivate(self, firstActivation, addedToHierarchy); if (!getModConfig().InSong.GetValue() || Config.noTextAndHUD) { @@ -362,7 +354,7 @@ CM_MAKE_HOOK(PartyFreePlayFlowCoordinator_SinglePlayerLevelSelectionFlowCoordina layout->get_transform()->set_localEulerAngles(UnityEngine::Vector3(0, 0, 0)); } -CM_MAKE_HOOK(SoloFreePlayFlowCoordinator_SinglePlayerLevelSelectionFlowCoordinatorDidActivate, &SoloFreePlayFlowCoordinator::SinglePlayerLevelSelectionFlowCoordinatorDidActivate, void, SoloFreePlayFlowCoordinator* self, bool firstActivation, bool addedToHierarchy) { +MAKE_HOOK_MATCH(SoloFreePlayFlowCoordinator_SinglePlayerLevelSelectionFlowCoordinatorDidActivate, &SoloFreePlayFlowCoordinator::SinglePlayerLevelSelectionFlowCoordinatorDidActivate, void, SoloFreePlayFlowCoordinator* self, bool firstActivation, bool addedToHierarchy) { SoloFreePlayFlowCoordinator_SinglePlayerLevelSelectionFlowCoordinatorDidActivate(self, firstActivation, addedToHierarchy); if (!getModConfig().InSong.GetValue() || Config.noTextAndHUD) { @@ -380,38 +372,35 @@ CM_MAKE_HOOK(SoloFreePlayFlowCoordinator_SinglePlayerLevelSelectionFlowCoordinat layout->get_transform()->set_localEulerAngles(UnityEngine::Vector3(0, 0, 0)); } -CM_MAKE_HOOK(PauseMenuManager_ShowMenu, &PauseMenuManager::ShowMenu, void, PauseMenuManager* self) { +MAKE_HOOK_MATCH(PauseMenuManager_ShowMenu, &PauseMenuManager::ShowMenu, void, PauseMenuManager* self) { PauseMenuManager_ShowMenu(self); if (!getModConfig().InSong.GetValue() || Config.noTextAndHUD) { canvas->get_gameObject()->SetActive(true); logger().info("SetActive true PauseMenu"); } - //if (Config.noTextAndHUD) { - // canvas->get_gameObject()->SetActive(false); - // logger().info("SetActive false (NoTextAndHUD)"); - //} -// layout->get_transform()->set_position(UnityEngine::Vector3(0, Config.ClockY, Config.ClockZ)); -// Config.IsInSong = false; } -CM_MAKE_HOOK(PauseMenuManager_StartResumeAnimation, &PauseMenuManager::StartResumeAnimation, void, PauseMenuManager* self) { +MAKE_HOOK_MATCH(PauseMenuManager_StartResumeAnimation, &PauseMenuManager::StartResumeAnimation, void, PauseMenuManager* self) { PauseMenuManager_StartResumeAnimation(self); if (!getModConfig().InSong.GetValue() || Config.noTextAndHUD) { canvas->get_gameObject()->SetActive(false); logger().info("SetActive false PauseMenu"); } -// if (Config.InRotationMap) { -// layout->get_transform()->set_position(UnityEngine::Vector3(0, Config.ClockY+2, Config.ClockZ+5)); -// } -// Config.IsInSong = true; } // TODO: Use the below information wisely // Check if it there are RotationEvents within the map, and if there are, declare it a 360/90 Map. -CM_MAKE_HOOK(BeatmapObjectCallbackController_SetNewBeatmapData, &BeatmapObjectCallbackController::SetNewBeatmapData, void, BeatmapObjectCallbackController* self, IReadonlyBeatmapData* beatmapData) { - BeatmapObjectCallbackController_SetNewBeatmapData(self, beatmapData); +#if __has_include("GlobalNamespace/BeatmapObjectCallbackController.hpp") +#include "GlobalNamespace/BeatmapObjectCallbackController.hpp" // For checking characteristic +MAKE_HOOK_MATCH(BeatmapDataCallback, &BeatmapObjectCallbackController::SetNewBeatmapData, void, BeatmapObjectCallbackController* self, IReadonlyBeatmapData* beatmapData) { + BeatmapDataCallback(self, beatmapData); +#else +#include "GlobalNamespace/BeatmapCallbacksController_InitData.hpp" +MAKE_HOOK_FIND_INSTANCE(BeatmapDataCallback, classof(BeatmapCallbacksController::InitData*), ".ctor", void, BeatmapCallbacksController::InitData* self, IReadonlyBeatmapData* beatmapData, float startFilterTime) { + BeatmapDataCallback(self, beatmapData, startFilterTime); +#endif if (beatmapData) { int RotationEvents = beatmapData->get_spawnRotationEventsCount(); if (RotationEvents > 0) { @@ -425,91 +414,13 @@ CM_MAKE_HOOK(BeatmapObjectCallbackController_SetNewBeatmapData, &BeatmapObjectCa } } -CM_MAKE_HOOK(FlyingGameHUDRotation_FixedUpdate, &FlyingGameHUDRotation::FixedUpdate, void, GlobalNamespace::FlyingGameHUDRotation* self) { - //float YAngle = self->yAngle; - //if (getModConfig().ClockPosition.GetValue()) { - // layout->get_gameObject()->get_transform()->GetParent()->set_eulerAngles(UnityEngine::Vector3(ClockPos.RotateSongRotationDownX, self->yAngle, 0)); - //} else layout->get_gameObject()->get_transform()->GetParent()->set_eulerAngles(UnityEngine::Vector3(ClockPos.RotateSongRotationTopX, self->yAngle, 0)); - layout->get_gameObject()->get_transform()->GetParent()->set_eulerAngles(UnityEngine::Vector3(0, self->yAngle, 0)); +MAKE_HOOK_MATCH(FlyingGameHUDRotation_FixedUpdate, &FlyingGameHUDRotation::FixedUpdate, void, GlobalNamespace::FlyingGameHUDRotation* self) { + layout->get_gameObject()->get_transform()->GetParent()->set_eulerAngles(UnityEngine::Vector3(0, self->dyn__yAngle(), 0)); FlyingGameHUDRotation_FixedUpdate(self); } -//MAKE_HOOK_OFFSETLESS(CoreGameHUDController_Start, void, GlobalNamespace::CoreGameHUDController* self) { -// CoreGameHUDController_Start(self); -//} - -// Multiplayer Lobby Specific Code -//MAKE_HOOK_OFFSETLESS(MultiplayerLobbyController_ActivateMultiplayerLobby, void, MultiplayerLobbyController* self) { -// MultiplayerLobbyController_ActivateMultiplayerLobby(self); -// - // layout->get_transform()->set_position(UnityEngine::Vector3(0, -0.05, 1.62)); - // layout->get_transform()->set_localScale(UnityEngine::Vector3(0.35, 0.35, 0.35)); -//} - -// TODO: figure out why, the results screen causes problems with the clock - -//CM_MAKE_HOOK(QuickPlaySetupViewController_DidActivate, &QuickPlaySetupViewController::DidActivate, void, QuickPlaySetupViewController* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { -// QuickPlaySetupViewController_DidActivate(self, firstActivation, addedToHierarchy, screenSystemEnabling); -// -// if (!getModConfig().InSong.GetValue() || Config.noTextAndHUD) { -// canvas->get_gameObject()->SetActive(true); -// logger().info("SetActive true QuickPlayLobby"); -// } -// layout->get_transform()->set_localEulerAngles(UnityEngine::Vector3(0, 0, 0)); -// -// auto MLobbyVCPosY = self->get_transform()->get_position().y; -// Config.InMPLobby = true; -// Config.IsInSong = false; -// Config.InMP = true; -// Config.InRotationMap = false; -//// logger().debug("%g", MLobbyVCPosY); -// MPLobbyClockPos(MLobbyVCPosY); -// if (Config.InMP == true) { logger().debug("QLobby, InMP is True"); } -//} -// -//CM_MAKE_HOOK(ClientLobbySetupViewController_DidActivate, &ClientLobbySetupViewController::DidActivate, void, ClientLobbySetupViewController* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { -// -// if (!getModConfig().InSong.GetValue() || Config.noTextAndHUD) { -// canvas->get_gameObject()->SetActive(true); -// logger().info("SetActive true ClientLobby"); -// } -// layout->get_transform()->set_localEulerAngles(UnityEngine::Vector3(0, 0, 0)); -// -// auto MLobbyVCPosY = self->get_transform()->get_position().y; -// Config.InMPLobby = true; -// Config.IsInSong = false; -// Config.InMP = true; -// Config.InRotationMap = false; -//// logger().debug("%g", MLobbyVCPosY); -// MPLobbyClockPos(MLobbyVCPosY); -// if (Config.InMP == true) { logger().debug("CLobby, InMP is True"); } -// -// ClientLobbySetupViewController_DidActivate(self, firstActivation, addedToHierarchy, screenSystemEnabling); -//} -// -//CM_MAKE_HOOK(HostLobbySetupViewController_DidActivate, &HostLobbySetupViewController::DidActivate, void, HostLobbySetupViewController* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { -// -// if (!getModConfig().InSong.GetValue() || Config.noTextAndHUD) { -// canvas->get_gameObject()->SetActive(true); -// logger().info("SetActive true HostLobby"); -// } -// layout->get_transform()->set_localEulerAngles(UnityEngine::Vector3(0, 0, 0)); -// -// auto MLobbyVCPosY = self->get_transform()->get_position().y; -// Config.InMPLobby = true; -// Config.IsInSong = false; -// Config.InMP = true; -// Config.InRotationMap = false; -// // logger().debug("%g", MLobbyVCPosY); -// MPLobbyClockPos(MLobbyVCPosY); -// if (Config.InMP == true) { logger().debug("HLobby, InMP is True"); } -// -// HostLobbySetupViewController_DidActivate(self, firstActivation, addedToHierarchy, screenSystemEnabling); -//} - - -CM_MAKE_HOOK(LobbySetupViewController_DidActivate, &LobbySetupViewController::DidActivate, void, LobbySetupViewController* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { +MAKE_HOOK_MATCH(LobbySetupViewController_DidActivate, &LobbySetupViewController::DidActivate, void, LobbySetupViewController* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { if (!getModConfig().InSong.GetValue() || Config.noTextAndHUD) { canvas->get_gameObject()->SetActive(true); @@ -529,7 +440,7 @@ CM_MAKE_HOOK(LobbySetupViewController_DidActivate, &LobbySetupViewController::Di LobbySetupViewController_DidActivate(self, firstActivation, addedToHierarchy, screenSystemEnabling); } -CM_MAKE_HOOK(MultiplayerResultsViewController_DidActivate, &MultiplayerResultsViewController::DidActivate, void, MultiplayerResultsViewController* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { +MAKE_HOOK_MATCH(MultiplayerResultsViewController_DidActivate, &MultiplayerResultsViewController::DidActivate, void, MultiplayerResultsViewController* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { if (!getModConfig().InSong.GetValue() || Config.noTextAndHUD) { canvas->get_gameObject()->SetActive(true); @@ -549,7 +460,7 @@ CM_MAKE_HOOK(MultiplayerResultsViewController_DidActivate, &MultiplayerResultsVi MultiplayerResultsViewController_DidActivate(self, firstActivation, addedToHierarchy, screenSystemEnabling); } -CM_MAKE_HOOK(MultiplayerLobbyController_DeactivateMultiplayerLobby, &MultiplayerLobbyController::DeactivateMultiplayerLobby, void, MultiplayerLobbyController* self) { +MAKE_HOOK_MATCH(MultiplayerLobbyController_DeactivateMultiplayerLobby, &MultiplayerLobbyController::DeactivateMultiplayerLobby, void, MultiplayerLobbyController* self) { MultiplayerLobbyController_DeactivateMultiplayerLobby(self); Config.InMPLobby = false; @@ -561,18 +472,10 @@ CM_MAKE_HOOK(MultiplayerLobbyController_DeactivateMultiplayerLobby, &Multiplayer layout->get_transform()->set_localEulerAngles(UnityEngine::Vector3(0, 0, 0)); } -/* -// Multiplayer song starting taken from QDRPC, probably a better way of figuring this out -MAKE_HOOK_OFFSETLESS(MultiplayerLevelScenesTransitionSetupDataSO_Init, void, MultiplayerLevelScenesTransitionSetupDataSO* self, Il2CppString* gameMode, GlobalNamespace::IPreviewBeatmapLevel* previewBeatmapLevel, GlobalNamespace::BeatmapDifficulty beatmapDifficulty, GlobalNamespace::BeatmapCharacteristicSO* beatmapCharacteristic, GlobalNamespace::IDifficultyBeatmap* difficultyBeatmap, GlobalNamespace::ColorScheme* overrideColorScheme, GlobalNamespace::GameplayModifiers* gameplayModifiers, GlobalNamespace::PlayerSpecificSettings* playerSpecificSettings, GlobalNamespace::PracticeSettings* practiceSettings, bool useTestNoteCutSoundEffects) { - logger().info("Multiplayer Song Started"); - Config.InMPSong = true; - MultiplayerLevelScenesTransitionSetupDataSO_Init(self, gameMode, previewBeatmapLevel, beatmapDifficulty, beatmapCharacteristic, difficultyBeatmap, overrideColorScheme, gameplayModifiers, playerSpecificSettings, practiceSettings, useTestNoteCutSoundEffects); -} -*/ // Called at the early stages of game loading extern "C" void setup(ModInfo & info) { - info.id = "clockmod"; + info.id = MOD_ID; info.version = VERSION; modInfo = info; @@ -601,42 +504,20 @@ extern "C" void load() { Logger& hkLog = logger(); -#ifndef REGISTER_FUNCTION custom_types::Register::AutoRegister(); -#else - custom_types::Register::RegisterType(); - //custom_types::Register::RegisterType(); - custom_types::Register::RegisterType(); -#endif QuestUI::Register::RegisterModSettingsViewController(modInfo); - CM_INSTALL_HOOK(hkLog, MainMenuViewController_DidActivate, il2cpp_utils::FindMethodUnsafe("", "MainMenuViewController", "DidActivate", 3)); - CM_INSTALL_HOOK(hkLog, CampaignFlowCoordinator_DidActivate, il2cpp_utils::FindMethodUnsafe("", "CampaignFlowCoordinator", "DidActivate", 3)); - CM_INSTALL_HOOK(hkLog, AudioTimeSyncController_StartSong, il2cpp_utils::FindMethodUnsafe("", "AudioTimeSyncController", "StartSong", 1)); - //INSTALL_HOOK_OFFSETLESS(hkLog, SceneManager_Internal_ActiveSceneChanged, il2cpp_utils::FindMethodUnsafe("UnityEngine.SceneManagement", "SceneManager", "Internal_ActiveSceneChanged", 2)); - // Third attempt at clock rotation -// INSTALL_HOOK_OFFSETLESS(hkLog, BeatmapObjectManager_SpawnBasicNote, il2cpp_utils::FindMethodUnsafe("", "BeatmapObjectManager", "SpawnBasicNote", 4)); -// INSTALL_HOOK_OFFSETLESS(hkLog, NoteController_Update, il2cpp_utils::FindMethodUnsafe("", "NoteController", "Update", 0)); - //INSTALL_HOOK_OFFSETLESS(hkLog, AudioTimeSyncController_StopSong, il2cpp_utils::FindMethodUnsafe("", "AudioTimeSyncController", "StopSong", 0)); - CM_INSTALL_HOOK(hkLog, SoloFreePlayFlowCoordinator_SinglePlayerLevelSelectionFlowCoordinatorDidActivate, il2cpp_utils::FindMethodUnsafe("", "SoloFreePlayFlowCoordinator", "SinglePlayerLevelSelectionFlowCoordinatorDidActivate", 2)); - // Added by ELP - CM_INSTALL_HOOK(hkLog, FlyingGameHUDRotation_FixedUpdate, il2cpp_utils::FindMethodUnsafe("", "FlyingGameHUDRotation", "FixedUpdate", 0)); - CM_INSTALL_HOOK(hkLog, PartyFreePlayFlowCoordinator_SinglePlayerLevelSelectionFlowCoordinatorDidActivate, il2cpp_utils::FindMethodUnsafe("", "PartyFreePlayFlowCoordinator", "SinglePlayerLevelSelectionFlowCoordinatorDidActivate", 2)); - CM_INSTALL_HOOK(hkLog, PauseMenuManager_ShowMenu, il2cpp_utils::FindMethodUnsafe("", "PauseMenuManager", "ShowMenu", 0)); - CM_INSTALL_HOOK(hkLog, PauseMenuManager_StartResumeAnimation, il2cpp_utils::FindMethodUnsafe("", "PauseMenuManager", "StartResumeAnimation", 0)); - CM_INSTALL_HOOK(hkLog, BeatmapObjectCallbackController_SetNewBeatmapData, il2cpp_utils::FindMethodUnsafe("", "BeatmapObjectCallbackController", "SetNewBeatmapData", 1)); -// INSTALL_HOOK_OFFSETLESS(hkLog, CoreGameHUDController_Start, il2cpp_utils::FindMethodUnsafe("", "CoreGameHUDController", "Start", 0)); -// INSTALL_HOOK_OFFSETLESS(hookLogger, MultiplayerLobbyController_ActivateMultiplayerLobby, il2cpp_utils::FindMethodUnsafe("", "MultiplayerLobbyController", "ActivateMultiplayerLobby", 0)); - // Multiplayer specific Hooks - //CM_INSTALL_HOOK(hkLog, HostLobbySetupViewController_DidActivate, il2cpp_utils::FindMethodUnsafe("", "HostLobbySetupViewController", "DidActivate", 3)); - //CM_INSTALL_HOOK(hkLog, ClientLobbySetupViewController_DidActivate, il2cpp_utils::FindMethodUnsafe("", "ClientLobbySetupViewController", "DidActivate", 3)); - //CM_INSTALL_HOOK(hkLog, QuickPlaySetupViewController_DidActivate, il2cpp_utils::FindMethodUnsafe("", "QuickPlaySetupViewController", "DidActivate", 3)); - - CM_INSTALL_HOOK(hkLog, LobbySetupViewController_DidActivate, nullptr); - CM_INSTALL_HOOK(hkLog, MultiplayerLobbyController_DeactivateMultiplayerLobby, il2cpp_utils::FindMethodUnsafe("", "MultiplayerLobbyController", "DeactivateMultiplayerLobby", 0)); - CM_INSTALL_HOOK(hkLog, MultiplayerResultsViewController_DidActivate, il2cpp_utils::FindMethodUnsafe("", "MultiplayerResultsViewController", "DidActivate", 3)); - - //INSTALL_HOOK_OFFSETLESS(hkLog, MultiplayerLevelScenesTransitionSetupDataSO_Init, il2cpp_utils::FindMethodUnsafe("", "MultiplayerLevelScenesTransitionSetupDataSO", "Init", 10)); - + INSTALL_HOOK(hkLog, MainMenuViewController_DidActivate); + INSTALL_HOOK(hkLog, CampaignFlowCoordinator_DidActivate); + INSTALL_HOOK(hkLog, AudioTimeSyncController_StartSong); + INSTALL_HOOK(hkLog, SoloFreePlayFlowCoordinator_SinglePlayerLevelSelectionFlowCoordinatorDidActivate); + INSTALL_HOOK(hkLog, FlyingGameHUDRotation_FixedUpdate); + INSTALL_HOOK(hkLog, PartyFreePlayFlowCoordinator_SinglePlayerLevelSelectionFlowCoordinatorDidActivate); + INSTALL_HOOK(hkLog, PauseMenuManager_ShowMenu); + INSTALL_HOOK(hkLog, PauseMenuManager_StartResumeAnimation); + INSTALL_HOOK(hkLog, BeatmapDataCallback); + INSTALL_HOOK(hkLog, LobbySetupViewController_DidActivate); + INSTALL_HOOK(hkLog, MultiplayerLobbyController_DeactivateMultiplayerLobby); + INSTALL_HOOK(hkLog, MultiplayerResultsViewController_DidActivate); logger().info("Installed all ClockMod hooks!"); } \ No newline at end of file