diff --git a/.github/workflows/BuildQSounds.yml b/.github/workflows/BuildQSounds.yml
index 350860c..50fd5cd 100644
--- a/.github/workflows/BuildQSounds.yml
+++ b/.github/workflows/BuildQSounds.yml
@@ -21,48 +21,31 @@ on:
env:
module_id: QuestSounds
- version: 1.4.1-Dev.${{ github.run_number }}
- BSVersion: 1.28.0_4124311467
-# ndkname: android-ndk-r24
+ #version: 1.4.1-Dev.${{ github.run_number }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v4
name: Checkout
with:
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: Get Version
+ shell: pwsh
+ run: |
+ $branchParts = '${{ github.ref_name }}'.Split('/'); $branchMain = $branchParts[0]; if ($branchParts[0] -match "^\d+$") { $branchMain = 'pr'; $branchSub = "$($branchParts[0])." } elseif ($branchParts.Length -eq 2) { $branchSub = "$($branchParts[1].Replace('.', '-'))." }; echo "version=$((Get-Content ./qpm.shared.json -Raw | ConvertFrom-Json).config.info.version.Split('-')[0])-$($branchMain).${{ github.run_number }}+$($branchSub)ra${{ github.run_attempt }}.$($env:GITHUB_SHA.Substring(0, 7))" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
+
+ # Not sure this is used in this workflow
+ - name: Get BSVersion
+ shell: pwsh
+ run: |
+ echo "BSVersion=$((Get-Content ./mod.template.json -Raw | ConvertFrom-Json).packageVersion)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
+
+ - uses: seanmiddleditch/gha-setup-ninja@v5
- name: Create ndkpath.txt
run: |
@@ -74,14 +57,14 @@ jobs:
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: cargo-build.yml
- name: linux-qpm-rust
+ name: linux-qpm
path: QPM
- repo: RedBrumbler/QuestPackageManager-Rust
+ repo: QuestPackageManager/QPM.CLI
- name: QPM Collapse
run: |
- chmod +x ./QPM/qpm-rust
- ./QPM/qpm-rust collapse
+ chmod +x ./QPM/qpm
+ ./QPM/qpm collapse
- name: QPM Dependencies Cache
id: cache-qpm-deps
@@ -89,15 +72,16 @@ jobs:
env:
cache-name: cache-qpm-deps
with:
- path: /home/runner/.local/share/QPM-Rust/cache
- key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('qpm.json', '.github/BuildQSounds.yml') }}
+ path: /home/runner/.local/share/QPM-RS/cache
+ key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('qpm.shared.json') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
${{ runner.os }}-${{ env.cache-name }}
- - name: QPM Restore
+ - name: QPM Set Version & Restore
run: |
- ./QPM/qpm-rust restore
+ ./QPM/qpm package edit --version ${{ env.version }}
+ ./QPM/qpm restore
- name: Check dependency Folders
run: |
@@ -107,15 +91,13 @@ jobs:
echo "Checking libs"
ls -lh ${GITHUB_WORKSPACE}/extern/libs
echo ""
- echo "Checking QPM-Rust/cache Folder"
- ls -lh $HOME/.local/share/QPM-Rust/cache
+ echo "Checking QPM/cache Folder"
+ ls -lh $HOME/.local/share/QPM-RS/cache
echo ""
- 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
@@ -124,16 +106,16 @@ jobs:
cd ./build/
pattern="lib${module_id}*.so"
files=( $pattern )
- echo ::set-output name=NAME::"${files[0]}"
+ echo "NAME=${files[0]}" >> $GITHUB_OUTPUT
- name: Package QMOD
run: |
cd ${GITHUB_WORKSPACE}
- pwsh -Command ./buildQMOD.ps1 -package
+ ./QPM/qpm qmod zip -i ./build/ -i ./extern/libs/ -f ./Cover.jpg -i ./Examples/ ${module_id}_${version}.qmod
- 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 }}
@@ -141,7 +123,7 @@ jobs:
- 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 }}
@@ -149,7 +131,7 @@ jobs:
- name: Upload QMOD
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v4
with:
name: ${{ env.module_id }}-(UNZIP-for-QMOD).qmod
path: ./${{ env.module_id }}_${{ env.version }}.qmod
diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml
index abf0576..e944662 100644
--- a/.github/workflows/Release.yml
+++ b/.github/workflows/Release.yml
@@ -9,69 +9,46 @@ on:
env:
module_id: QuestSounds
- BSVersion: 1.28.0_4124311467
- ndkname: android-ndk-r24
jobs:
build:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v4
name: Checkout
with:
submodules: true
lfs: true
- - uses: seanmiddleditch/gha-setup-ninja@v3
-
- #- name: Install Powershell
- # run: sudo apt-get install -y powershell
+ - uses: seanmiddleditch/gha-setup-ninja@v5
- 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: Create ndkpath.txt
- # run: |
- # cd ndk
- # pwd > ${GITHUB_WORKSPACE}/ndkpath.txt
+ - name: Get BSVersion
+ shell: pwsh
+ run: |
+ echo "BSVersion=$((Get-Content ./mod.template.json -Raw | ConvertFrom-Json).packageVersion)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Create ndkpath.txt
run: |
echo "$ANDROID_NDK_LATEST_HOME" > ${GITHUB_WORKSPACE}/ndkpath.txt
- - name: Get QPM
- if: steps.cache-qpm.outputs.cache-hit != 'true'
- uses: dawidd6/action-download-artifact@v2
- with:
- github_token: ${{secrets.GITHUB_TOKEN}}
- workflow: cargo-build.yml
- name: linux-qpm-rust
- path: QPM
- repo: RedBrumbler/QuestPackageManager-Rust
-
+ - name: Get QPM
+ if: steps.cache-qpm.outputs.cache-hit != 'true'
+ uses: dawidd6/action-download-artifact@v2
+ with:
+ github_token: ${{secrets.GITHUB_TOKEN}}
+ workflow: cargo-build.yml
+ name: linux-qpm
+ path: QPM
+ repo: QuestPackageManager/QPM.CLI
+
- name: QPM Collapse
run: |
- chmod +x ./QPM/qpm-rust
- ./QPM/qpm-rust collapse
+ chmod +x ./QPM/qpm
+ ./QPM/qpm collapse
- name: QPM Dependencies Cache
id: cache-qpm-deps
@@ -79,15 +56,17 @@ jobs:
env:
cache-name: cache-qpm-deps
with:
- path: /home/runner/.local/share/QPM-Rust/cache
- key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('qpm.json', '.github/BuildQSounds.yml') }}
+ path: /home/runner/.local/share/QPM-RS/cache
+ key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('qpm.shared.json') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
${{ runner.os }}-${{ env.cache-name }}
- - name: QPM Restore
+ - name: QPM Set Version & Restore
run: |
- ./QPM/qpm-rust restore
+ ./QPM/qpm package edit --version ${{ env.version }}
+ ./QPM/qpm restore
+
- name: Check dependency Folders
run: |
@@ -98,14 +77,12 @@ jobs:
ls -lh ${GITHUB_WORKSPACE}/extern/libs
echo ""
echo "Checking QPM-Rust/cache Folder"
- ls -lh $HOME/.local/share/QPM-Rust/cache
+ ls -lh $HOME/.local/share/QPM-RS/cache
echo ""
- 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
@@ -114,40 +91,18 @@ jobs:
cd ./build/
pattern="lib${module_id}*.so"
files=( $pattern )
- echo ::set-output name=NAME::"${files[0]}"
+ echo "NAME=${files[0]}" >> $GITHUB_OUTPUT
- name: Package QMOD
run: |
cd ${GITHUB_WORKSPACE}
- pwsh -Command ./buildQMOD.ps1 -package -release
+ ./QPM/qpm qmod zip -i ./build/ -i ./extern/libs/ -f ./Cover.jpg -i ./Examples/ ${module_id}_${version}.qmod
- name: Release
uses: softprops/action-gh-release@v1
with:
name: ${{ env.module_id }} ${{ env.version }} for Beat Saber ${{ env.BSVersion }}
files: |
- ./${{ env.module_id }}.qmod
+ ./${{ env.module_id }}_${{ env.version }}.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/.gitignore b/.gitignore
index 59fd1a2..d1133ff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -52,9 +52,6 @@ ndkpath.txt
# Other files
extern/
-
-qpm.shared.json
-extern/
*.backup
*.log
diff --git a/Android.mk b/Android.mk
deleted file mode 100644
index 2a24bc9..0000000
--- a/Android.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_3_4_4
-LOCAL_EXPORT_C_INCLUDES := extern/beatsaber-hook
-LOCAL_SRC_FILES := extern/libbeatsaber-hook_3_4_4.so
-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.2
-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.5
-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 := QuestSounds
-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_3_4_4
-LOCAL_SHARED_LIBRARIES += codegen
-LOCAL_SHARED_LIBRARIES += custom-types
-LOCAL_SHARED_LIBRARIES += questui
-LOCAL_LDLIBS += -llog
-LOCAL_CFLAGS += -I'extern/libil2cpp/il2cpp/libil2cpp' -DID='"QuestSounds"' -DVERSION='"$(VERSION)"' -DBS__1_16=1 -I'./shared' -I'./extern' -isystem'extern/codegen/include' -Ofast
-LOCAL_CPP_FEATURES += rtti exceptions
-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 4cf731b..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
-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.2
-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.5
-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 := QuestSounds
-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='"QuestSounds"' -DVERSION='"$(VERSION)"' -DBS__1_16=1 -I'./shared' -I'./extern' -isystem'extern/codegen/include' -Ofast
-LOCAL_CPP_FEATURES += rtti exceptions
-LOCAL_CPPFLAGS += -std=c++2a -Ofast
-LOCAL_C_INCLUDES += ./include ./src
-include $(BUILD_SHARED_LIBRARY)
diff --git a/Application.mk b/Application.mk
deleted file mode 100644
index d7e70ca..0000000
--- a/Application.mk
+++ /dev/null
@@ -1,6 +0,0 @@
-APP_ABI := arm64-v8a
-# 25
-APP_PLATFORM := android-24
-APP_PIE:= true
-APP_STL := c++_static
-APP_CPPFLAGS := -std=c++2a
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0379af1..975d67b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,8 +1,6 @@
# include some defines automatically made by qpm
include(qpm_defines.cmake)
-# override mod id
-# set(MOD_ID "QuestSounds")
# Enable link time optimization
# In my experience, this can be highly unstable but it nets a huge size optimization and likely performance
@@ -13,6 +11,7 @@ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
cmake_minimum_required(VERSION 3.21)
project(${COMPILE_ID})
+include(${EXTERN_DIR}/includes/kaleb/shared/cmake/assets.cmake)
# c++ standard
set(CMAKE_CXX_STANDARD 20)
@@ -27,7 +26,6 @@ add_compile_options(-frtti -fexceptions)
add_compile_options(-Ofast)
# 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
@@ -42,10 +40,6 @@ add_library(
${c_file_list}
)
-target_include_directories(${COMPILE_ID} PRIVATE .)
-
-target_include_directories(${COMPILE_ID} PRIVATE extern/includes/questui_components)
-
# add src dir as include dir
target_include_directories(${COMPILE_ID} PRIVATE ${SOURCE_DIR})
# add include dir as include dir
@@ -55,7 +49,9 @@ 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)
+# Kaleb include 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)
diff --git a/Examples/BombHitExplosion.ogg b/Examples/BombHitExplosion.ogg
new file mode 100644
index 0000000..0655b25
Binary files /dev/null and b/Examples/BombHitExplosion.ogg differ
diff --git a/assets/ConfigMenuSelectionViewController.bsml b/assets/ConfigMenuSelectionViewController.bsml
new file mode 100644
index 0000000..7422bb2
--- /dev/null
+++ b/assets/ConfigMenuSelectionViewController.bsml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/assets/SoundSettingsViewController.bsml b/assets/SoundSettingsViewController.bsml
new file mode 100644
index 0000000..a45c621
--- /dev/null
+++ b/assets/SoundSettingsViewController.bsml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/bmbfmod.json b/bmbfmod.json
deleted file mode 100644
index a383a5e..0000000
--- a/bmbfmod.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "id": "QuestSounds",
- "name": "QuestSounds",
- "author": "Rugtveit, EnderdracheLP",
- "description": [
-
- "Allows users to change their sfx sounds easily!"
-
- ],
- "category": "Gameplay",
- "gameVersion": "1.13.2",
- "version": "1.0.0-InDev",
- "platform": "Quest",
- "components": [
- {
- "type": "HookMod",
- "installAction": {
- "installLibraryFile": "libquestsounds.so"
- },
- "uninstallAction": {
- "removeLibraryFile": "libquestsounds.so"
- }
- }
- ]
-}
diff --git a/build.ps1 b/build.ps1
index b6e26d3..b4ed6dc 100644
--- a/build.ps1
+++ b/build.ps1
@@ -19,14 +19,14 @@ $NDKPath = Get-Content $PSScriptRoot/ndkpath.txt
# elseif ($args[$i] -eq "--release") { $release = $true }
# }
-$qpm = "./qpm.json"
+$qpm = "./qpm.shared.json"
$qpmJson = Get-Content $qpm -Raw | ConvertFrom-Json
if ($args.Count -eq 0 -or $actions -ne $true) {
-$ModID = $qpmJson.info.id
-$VERSION = $qpmJson.info.version
+ $ModID = $qpmJson.config.info.id
+ $VERSION = $qpmJson.config.info.version
if ($release -ne $true) {
- $VERSION += "-Dev"
+ # $VERSION += "-Dev"
} elseif ($release -eq $true -and $VERSION.Contains("-Dev")) {
$VERSION.Replace("-Dev", "")
}
@@ -36,19 +36,24 @@ $VERSION = $qpmJson.info.version
if ($actions -eq $true) {
$ModID = $env:module_id
$VERSION = $env:version
+ if ([string]::IsNullOrEmpty($VERSION)) {
+ $qpmsharedJson = Get-Content $qpmshared -Raw | ConvertFrom-Json
+ $VERSION = $qpmsharedJson.config.info.version.replace("-Dev", "")
+ }
} else {
- & qpm-rust package edit --version $VERSION
+ & qpm 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) {
+
+if ((Test-Path "./extern/includes/beatsaber-hook/shared/inline-hook/And64InlineHook.cpp", "./extern/includes/beatsaber-hook/shared/inline-hook/inlineHook.c", "./extern/includes/beatsaber-hook/shared/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/shared/inline-hook/And64InlineHook.cpp")) {
+ Write-Host "./extern/includes/beatsaber-hook/shared/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/shared/inline-hook/inlineHook.c")) {
+ Write-Host "./extern/includes/beatsaber-hook/shared/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"
+ if (!(Test-Path "./extern/includes/beatsaber-hook/inline-hook/shared/relocate.c")) {
+ Write-Host "./extern/includes/beatsaber-hook/shared/inline-hook/relocate.c"
}
Write-Host "Task Failed"
exit 1;
@@ -70,7 +75,7 @@ if (($clean.IsPresent) -or (-not (Test-Path -Path "build")))
cd build
& cmake -G "Ninja" -DCMAKE_BUILD_TYPE="RelWithDebInfo" ../
-& cmake --build . -j 6
+& cmake --build .
$ExitCode = $LastExitCode
cd ..
exit $ExitCode
diff --git a/buildQMOD.ps1 b/buildQMOD.ps1
index 4ceeb68..6e7294e 100644
--- a/buildQMOD.ps1
+++ b/buildQMOD.ps1
@@ -40,83 +40,35 @@ if ($qmodName -eq "")
}
if (($args.Count -eq 0 -or $dev -eq $true) -And $package -eq $false) {
-echo "Packaging QMod $qmodName"
+ echo "Packaging QMod $qmodName"
& $PSScriptRoot/build.ps1 -clean:$clean -release:$release
if ($LASTEXITCODE -ne 0) {
echo "Failed to build, exiting..."
exit $LASTEXITCODE
}
-
- qpm-rust qmod build
- # Compress-Archive -Path "./libs/arm64-v8a/lib$ModID.so", "./libs/arm64-v8a/libbeatsaber-hook_$BSHook.so", ".\Cover.jpg", ".\mod.json" -DestinationPath "./Temp$ModID.zip" -Update
- # Move-Item "./Temp$ModID.zip" "./$ModID.qmod" -Force
}
-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"
-}
+$qpmsharedJson = Get-Content "./qpm.shared.json" -Raw | ConvertFrom-Json
-if ($package -eq $true -And $env:version.Contains('-Dev') -Or $release -eq $false) {
+if ($package -eq $true) {
$qmodName = "$($env:module_id)_$($env:version)"
-echo "Actions: Packaging QMod $qmodName"
- # Compress-Archive -Path "./libs/arm64-v8a/lib$ModID.so", "./libs/arm64-v8a/libbeatsaber-hook_$BSHook.so", ".\Cover.jpg", ".\mod.json" -DestinationPath "./Temp$ModID.zip" -Update
- # Move-Item "./Temp$ModID.zip" "./$ModID.qmod" -Force
-} elseif ($package -eq $true) {
- $qmodName = "$($env:module_id)"
-echo "Actions: Packaging QMod $qmodName"
+ echo "Actions: Packaging QMod $qmodName"
} else {
- $qmodName += "_$($modJson.version)"
-}
-
-
-foreach ($mod in $modJson.modFiles)
-{
- $path = "./build/" + $mod
- if (-not (Test-Path $path))
- {
- $path = "./extern/libs/" + $mod
- }
- $filelist += $path
+ $qmodName += "_$($qpmsharedJson.config.info.version)"
}
-foreach ($lib in $modJson.libraryFiles)
-{
- $path = "./extern/libs/" + $lib
- if (-not (Test-Path $path))
- {
- $path = "./build/" + $lib
- }
- $filelist += $path
-}
-
-foreach ($file in $modJson.fileCopies)
-{
- $path = "./Examples/" + $file.name
- $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
-}
+# if ((-not ($clean.IsPresent)) -and (Test-Path $qmod))
+# {
+# echo "Making Clean Qmod"
+# Move-Item $qmod $zip -Force
+# }
+
+qpm qmod zip -i ./build/ -i ./extern/libs/ -f ./Cover.jpg -i ./Examples/ $qmod
-Compress-Archive -Path $filelist -DestinationPath $zip -Update
-Move-Item $zip $qmod -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/include/AudioClips.hpp b/include/AudioClips.hpp
index 1a65175..9909338 100644
--- a/include/AudioClips.hpp
+++ b/include/AudioClips.hpp
@@ -1,26 +1,28 @@
#pragma once
-//#include "main.hpp"
-//#include "audiocliploader.hpp"
-#include "Utils/AsyncAudiocliploader.hpp"
+
+#include "Utils/AsyncAudioClipLoader.hpp"
namespace QuestSounds::AudioClips {
- //extern audioClipLoader::loader
- extern AsyncAudioClipLoader::loader hitSoundLoader, // hitSound
+
+ extern QuestSounds::Utils::AsyncAudioClipLoader hitSoundLoader, // hitSound
badHitSoundLoader, // badHitSound
noteMissedSoundLoader,
+ bombExplosionSoundLoader,
menuMusicLoader, // menuMusic
menuClickLoader,
fireworkSoundLoader,
levelClearedLoader,
levelFailedLoader,
lobbyAmbienceLoader; // Added for LobbyMusic
- extern Array * hitSoundArr, // hitSoundArray
- * badHitSoundArr, // badHitSoundArray
- * menuClickArr,
- * fireworkSoundArr;
- extern Array * origMenuClickArr;
+ extern ::ArrayW<::UnityW<::UnityEngine::AudioClip>> hitSoundArr, // hitSoundArray
+ badHitSoundArr, // badHitSoundArray
+ bombExplosionSoundLoaderArr,
+ menuClickArr,
+ fireworkSoundArr;
+
+ extern ::ArrayW<::UnityW<::UnityEngine::AudioClip>> origMenuClickArr;
extern void loadAudioClips();
- extern Array* createAudioClipArray(AsyncAudioClipLoader::loader clipLoader, bool GetOriginalClip = false);
+ extern ::ArrayW<::UnityW<::UnityEngine::AudioClip>> createAudioClipArray(QuestSounds::Utils::AsyncAudioClipLoader clipLoader, bool GetOriginalClip = false);
}
diff --git a/include/Config.hpp b/include/Config.hpp
new file mode 100644
index 0000000..c1b003b
--- /dev/null
+++ b/include/Config.hpp
@@ -0,0 +1,124 @@
+#pragma once
+
+#include "scotland2/shared/loader.hpp"
+#include "rapidjson-macros/shared/macros.hpp"
+
+#define SOUND_PATH_FORMAT "/sdcard/ModData/{}/Mods/QuestSounds/"
+// #define CONFIG_VERSION "SoundsConfig_v3"
+// #define CONFIG_VERSION_PRE_1_20 "SoundsConfig_v2"
+// #define CONFIG_VERSION_PRE_R "SoundsConfig_v1"
+// #define CONFIG_VERSION_LEGACY "Sounds"
+
+#define SOUND_VALUE(name, folder, ...) VALUE_DEFAULT(Sound, name, Sound(#name, soundPath + folder + "/", soundPath + folder + "/" + #name + ".ogg", __VA_ARGS__))
+#define SOUND_VALUE_SIMPLE(name, folder) VALUE_DEFAULT(Sound, name, Sound(#name, soundPath + folder + "/", soundPath + folder + "/" + #name + ".ogg"))
+
+// define an automatically serialized / deserialized instance variable with a custom name in the json file and a default value
+#pragma region NAMED_VALUE_CUSTOM(type, name, default, jsonName)
+#define NAMED_VALUE_CUSTOM(type, name, def, jsonName) \
+type name = def; \
+class _JSONValueAdder_##name { \
+ _JSONValueAdder_##name() { \
+ serializers().emplace_back([](const SelfType* self, rapidjson::Value& jsonObject, rapidjson::Document::AllocatorType& allocator) { \
+ rapidjson_macros_auto::Serialize(self->name, jsonName, jsonObject, allocator); \
+ }); \
+ deserializers().emplace_back([](SelfType* self, rapidjson::Value& jsonValue) { \
+ rapidjson_macros_auto::Deserialize(self->name, jsonName, self->def, jsonValue); \
+ }); \
+ } \
+ friend class rapidjson_macros_types::ConstructorRunner<_JSONValueAdder_##name>; \
+ static inline rapidjson_macros_types::ConstructorRunner<_JSONValueAdder_##name> _##name##_JSONValueAdderInstance; \
+};
+#pragma endregion
+
+namespace QuestSounds {
+ inline modloader::ModInfo modInfo = {MOD_ID, VERSION, 0};
+
+ static const std::string soundPath = fmt::format(SOUND_PATH_FORMAT, modloader::get_application_id().c_str());
+
+ DECLARE_JSON_CLASS(Sound,
+ std::string Name;
+ std::string FolderPath;
+ std::string DefaultFilePath;
+ NAMED_VALUE_DEFAULT(bool, Active, true, "activated");
+ NAMED_VALUE_CUSTOM(std::string, FilePath, DefaultFilePath, "filepath");
+ NAMED_VALUE_OPTIONAL(float, VolumeOffset, "audioVolumeOffset");
+ NAMED_VALUE_OPTIONAL(float, BeatOffset, "beatOffSet");
+ Sound(std::string name, std::string folderPath, std::string defaultFilePath, std::optional volumeOffset = std::nullopt, std::optional beatOffset = std::nullopt) : Name(name), FolderPath(folderPath), DefaultFilePath(defaultFilePath), VolumeOffset(volumeOffset), BeatOffset(beatOffset) {}
+ )
+
+ DECLARE_JSON_CLASS(
+ Sounds,
+ SOUND_VALUE(HitSound, "HitSounds", 0, 0.185f);
+ SOUND_VALUE(BadHitSound, "BadHitSounds", 0);
+ SOUND_VALUE(NoteMissedSound, "NoteMissedSounds", 0);
+ SOUND_VALUE_SIMPLE(MenuMusic, "MenuMusic");
+ SOUND_VALUE_SIMPLE(MenuClick, "MenuClicks");
+ SOUND_VALUE_SIMPLE(Firework, "Fireworks");
+ SOUND_VALUE_SIMPLE(LevelCleared, "LevelCleared");
+ SOUND_VALUE(LevelFailed, "LevelFailed", 0);
+ SOUND_VALUE_SIMPLE(LobbyMusic, "LobbyMusic");
+ SOUND_VALUE(BombExplosionSound, "BombExplosionSounds", 0);
+ )
+
+ DECLARE_JSON_CLASS(
+ SoundsConfig,
+ VALUE_DEFAULT(std::string, ConfigVersion, "3.1.0");
+ NAMED_VALUE(Sounds, Sounds, NAME_OPTS("SoundsConfig_v3", "SoundsConfig_v2", "SoundsConfig_v1", "Sounds"));
+ )
+ extern SoundsConfig Config;
+
+ extern std::string& GetConfigPath();
+}
+
+
+
+// #define CONFIG_SOUND(name, folderpath, active, ...) {name, SoundConfig(name, folderpath, active, __VA_ARGS__)}
+
+// namespace QuestSounds {
+// struct SoundConfig {
+// SoundConfig() = default;
+// SoundConfig(std::string name, std::string folderpath, bool active, std::optional volumeOffset = std::nullopt, std::optional beatOffset = std::nullopt) : FolderPath(folderpath), FilePath(folderpath + name + ".ogg"), Active(active), VolumeOffset(volumeOffset), BeatOffset(beatOffset) {}
+
+// bool Active = true;
+// std::string FilePath;
+// std::string FolderPath;
+// std::optional VolumeOffset;
+// std::optional BeatOffset;
+// };
+
+// static const std::string soundPath = fmt::format(SOUND_PATH_FORMAT, modloader::get_application_id().c_str());
+
+// struct Config {
+// std::map Sounds = {
+// CONFIG_SOUND("MenuMusic", soundPath + "MenuMusic/", true),
+// CONFIG_SOUND("HitSound", soundPath + "HitSounds/", true, 0, 0.185f),
+// CONFIG_SOUND("BadHitSound", soundPath + "BadHitSounds/", true),
+// CONFIG_SOUND("NoteMissedSound", soundPath + "NoteMissedSounds/", true),
+// CONFIG_SOUND("MenuClickSound", soundPath + "MenuClicks/", true),
+// CONFIG_SOUND("FireworkSound", soundPath + "Fireworks/", true),
+// CONFIG_SOUND("LevelClearedSound", soundPath + "LevelCleared/", true),
+// CONFIG_SOUND("LevelFailedSound", soundPath + "LevelFailed/", true),
+// CONFIG_SOUND("LobbyAmbience", soundPath + "LobbyMusic/", true)
+// };
+// // SoundConfig menuMusic = SoundConfig("MenuMusic", soundPath + "MenuMusic/", true, 0, 0);
+// // SoundConfig hitSound = SoundConfig("HitSound", soundPath + "HitSounds/", true, 0, 0);
+// // SoundConfig badHitSound = SoundConfig("BadHitSound", soundPath + "BadHitSounds/", true, 0, 0);
+// // SoundConfig noteMissedSound = SoundConfig("NoteMissedSound", soundPath + "NoteMissedSounds/", true, 0, 0);
+// // SoundConfig menuClickSound = SoundConfig("MenuClickSound", soundPath + "MenuClicks/", true, 0, 0);
+// // SoundConfig fireworkSound = SoundConfig("FireworkSound", soundPath + "Fireworks/", true, 0, 0);
+// // SoundConfig levelClearedSound = SoundConfig("LevelClearedSound", soundPath + "LevelCleared/", true, 0, 0);
+// // SoundConfig levelFailedSound = SoundConfig("LevelFailedSound", soundPath + "LevelFailed/", true, 0, 0);
+// // SoundConfig lobbyAmbience = SoundConfig("LobbyAmbience", soundPath + "LobbyMusic/", true, 0, 0);
+// bool LegacyConfig = false;
+// };
+
+// extern Config config;
+// }
+
+
+
+#undef NAMED_VALUE_CUSTOM
+#undef SOUND_PATH_FORMAT
+#undef SOUND_VALUE_SIMPLE
+#undef SOUND_VALUE
+// #undef CONFIG_SOUND
\ No newline at end of file
diff --git a/include/ObjectInstances.hpp b/include/ObjectInstances.hpp
index cb62b1b..f5b86e8 100644
--- a/include/ObjectInstances.hpp
+++ b/include/ObjectInstances.hpp
@@ -1,17 +1,13 @@
#pragma once
#include "main.hpp"
-#include "QSoundsFlowCoordinator.hpp"
+// #include "QSoundsFlowCoordinator.hpp"
-//#include "GlobalNamespace/ResultsViewController.hpp"
#include "GlobalNamespace/SongPreviewPlayer.hpp"
-//#include "GlobalNamespace/NoteCutSoundEffectManager.hpp"
-//#include "GlobalNamespace/NoteCutSoundEffect.hpp"
-//#include "GlobalNamespace/BasicUIAudioManager.hpp"
-//#include "GlobalNamespace/FireworkItemController.hpp"
-//#include "GlobalNamespace/GameServerLobbyFlowCoordinator.hpp"
-//#include "GlobalNamespace/MultiplayerModeSelectionFlowCoordinator.hpp"
+#include "GlobalNamespace/BasicUIAudioManager.hpp"
+// TODO: See if I can get rid of this header also possibly just forward delcare SongPreviewPlayer to make this more tidy
namespace QuestSounds::ObjectInstances {
extern GlobalNamespace::SongPreviewPlayer* SPP;
+ extern GlobalNamespace::BasicUIAudioManager* BUIAM;
}
\ No newline at end of file
diff --git a/include/QSoundsConfig.hpp b/include/QSoundsConfig.hpp
deleted file mode 100644
index c030782..0000000
--- a/include/QSoundsConfig.hpp
+++ /dev/null
@@ -1,74 +0,0 @@
-#pragma once
-#include "main.hpp"
-#define RAPIDJSON_HAS_STDSTRING 1
-#define SOUND_PATH_FORMAT "/sdcard/ModData/%s/Mods/QuestSounds/"
-#define CONFIG_VERSION "SoundsConfig_v3"
-#define CONFIG_VERSION_PRE_1_20 "SoundsConfig_v2"
-#define CONFIG_VERSION_PRE_R "SoundsConfig_v1"
-#define CONFIG_VERSION_LEGACY "Sounds"
-#include "UnityEngine/UI/Toggle.hpp"
-#include "questui/shared/BeatSaberUI.hpp"
-
-namespace QSoundsConfig {
- static std::string soundPath = string_format(SOUND_PATH_FORMAT, Modloader::getApplicationId().c_str());;
-
- static std::string MenuMusicPath = soundPath + "MenuMusic/";
- static std::string HitSoundPath = soundPath + "HitSounds/";
- static std::string BadHitSoundPath = soundPath + "BadHitSounds/";
- static std::string NoteMissedSoundPath = soundPath + "NoteMissedSounds/";
- static std::string MenuClickPath = soundPath + "MenuClicks/";
- static std::string FireworkSoundPath = soundPath + "Fireworks/";
- static std::string LevelClearedPath = soundPath + "LevelCleared/";
- static std::string LevelFailedPath = soundPath + "LevelFailed/";
-#ifndef BS__1_13_2
- static std::string LobbyMusicPath = soundPath + "LobbyMusic/";
-#endif
-
- extern bool LegacyConfig;
-
- //static const ConfigValue soundsConfigParent = getConfig().config[CONFIG_VERSION].GetObject();
- //Config stuff
- struct Config_t
- {
- bool hitSound_Active = true;
- bool badHitSound_Active = true;
- bool noteMissedSound_Active = true;
- bool menuMusic_Active = true;
- bool menuClick_Active = true;
- bool firework_Active = true;
- bool levelCleared_Active = true;
- bool levelFailed_Active = true;
- bool lobbyAmbience_Active = true;
-
- std::string hitSound_filepath = HitSoundPath + "HitSound.ogg";
- std::string badHitSound_filepath = BadHitSoundPath + "BadHitSound.ogg";
- std::string noteMissedSound_filepath = NoteMissedSoundPath + "NoteMissedSound.ogg";
- std::string menuMusic_filepath = MenuMusicPath + "MenuMusic.ogg";
- std::string menuClick_filepath = MenuClickPath + "MenuClick.ogg";
- std::string firework_filepath = FireworkSoundPath + "Firework.ogg";
- std::string levelCleared_filepath = LevelClearedPath + "LevelCleared.ogg";
- std::string levelFailed_filepath = LevelFailedPath + "LevelFailed.ogg";
- std::string lobbyAmbience_filepath = LobbyMusicPath + "LobbyMusic.ogg";
-
- float hitSound_audioVolumeOffset = 0;
- float badHitSound_audioVolumeOffset = 0;
- float noteMissedSound_audioVolumeOffset = 0;
- //float menuMusic_audioVolumeOffset = 0;
- //float menuClick_audioVolumeOffset = 0;
- //float firework_audioVolumeOffset = 0;
- //float levelCleared_audioVolumeOffset = 0;
- float levelFailed_audioVolumeOffset = 0;
- //float lobbyAmbience_audioVolumeOffset = 0;
-
- float hitSound_beatOffSet = 0.185f;
- };
- extern Config_t Config;
-
- void AddChildSound(ConfigValue& parent, std::string_view soundName, bool active, std::string filePath, ConfigDocument::AllocatorType& allocator);
- void AddChildSound(ConfigValue& parent, std::string_view soundName, bool active, std::string filePath, float beatOffSet, ConfigDocument::AllocatorType& allocator);
- bool ParseSound(bool& active, std::string& filepath, ConfigValue& parent, std::string_view soundName);
- bool ParseSound(bool& active, std::string& filepath, float& beatOffSet, ConfigValue& parent, std::string_view soundName);
-
- void SaveConfig();
- bool LoadConfig();
-}
diff --git a/include/QSoundsFlowCoordinator.hpp b/include/QSoundsFlowCoordinator.hpp
deleted file mode 100644
index 9f4d3ae..0000000
--- a/include/QSoundsFlowCoordinator.hpp
+++ /dev/null
@@ -1,50 +0,0 @@
-#pragma once
-#include "custom-types/shared/macros.hpp"
-#include "HMUI/FlowCoordinator.hpp"
-#include "HMUI/ViewController.hpp"
-
-#include "ViewControllers/ConfigViewController.hpp"
-
-DECLARE_CLASS_CODEGEN(QuestSounds, QSoundsFlowCoordinator, HMUI::FlowCoordinator,
-
- DECLARE_INSTANCE_FIELD_DEFAULT(QuestSounds::ViewControllers::ConfigViewController*, QSConfigViewController, nullptr);
- DECLARE_OVERRIDE_METHOD(void, DidActivate, il2cpp_utils::FindMethodUnsafe("HMUI", "FlowCoordinator", "DidActivate", 3), bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling);
- DECLARE_OVERRIDE_METHOD(void, BackButtonWasPressed, il2cpp_utils::FindMethodUnsafe("HMUI", "FlowCoordinator", "BackButtonWasPressed", 1), HMUI::ViewController* topViewController);
-
- DECLARE_INSTANCE_FIELD(HMUI::ViewController*, QSConfigView);
- DECLARE_INSTANCE_FIELD(HMUI::ViewController*, QSMenuSoundListView);
- DECLARE_INSTANCE_FIELD(HMUI::ViewController*, QSHitSoundListView);
- DECLARE_INSTANCE_FIELD(HMUI::ViewController*, QSMenuClickSoundListView);
- DECLARE_INSTANCE_FIELD(HMUI::ViewController*, QSBadHitSoundListView);
- DECLARE_INSTANCE_FIELD(HMUI::ViewController*, QSNoteMissedSoundListView);
- DECLARE_INSTANCE_FIELD(HMUI::ViewController*, QSFireworkSoundListView);
- DECLARE_INSTANCE_FIELD(HMUI::ViewController*, QSLevelClearedSoundListView);
- DECLARE_INSTANCE_FIELD(HMUI::ViewController*, QSLevelFailedSoundListView);
-#ifndef BS__1_13_2
- DECLARE_INSTANCE_FIELD(HMUI::ViewController*, QSLobbyMusicSoundListView);
-#endif
-
-
- public:
- void SubMenuButtonWasPressed(int VCtype);
-
-#if defined(BS__1_16) && defined(REGISTER_FUNCTION)
- REGISTER_FUNCTION(
-#elif defined(BS__1_13_2)
- REGISTER_FUNCTION(QSoundsFlowCoordinator,
-#endif
-#if defined(REGISTER_METHOD)
- REGISTER_FIELD(QSConfigViewController);
- REGISTER_FIELD(QSConfigView);
- REGISTER_METHOD(QSMenuSoundListView);
- REGISTER_METHOD(QSHitSoundListView);
- REGISTER_METHOD(QSMenuClickSoundListView);
- REGISTER_METHOD(QSBadHitSoundListView);
- REGISTER_METHOD(QSFireworkSoundListView);
- REGISTER_METHOD(QSLevelClearedSoundListView);
- REGISTER_METHOD(QSLevelFailedSoundListView);
- REGISTER_METHOD(DidActivate);
- REGISTER_METHOD(BackButtonWasPressed);
- )
-#endif
-);
\ No newline at end of file
diff --git a/include/UI/ConfigMenuSelectionViewController.hpp b/include/UI/ConfigMenuSelectionViewController.hpp
new file mode 100644
index 0000000..fc5acc1
--- /dev/null
+++ b/include/UI/ConfigMenuSelectionViewController.hpp
@@ -0,0 +1,31 @@
+#pragma once
+
+#include "custom-types/shared/macros.hpp"
+#include "bsml/shared/macros.hpp"
+
+#include "HMUI/ViewController.hpp"
+
+DECLARE_CLASS_CODEGEN(QuestSounds::UI, ConfigMenuSelectionViewController, HMUI::ViewController,
+ // DECLARE_INSTANCE_FIELD(ListW, _menus);
+ // DECLARE_INSTANCE_FIELD(BSML::CustomListTableData*, menuList);
+
+ DECLARE_OVERRIDE_METHOD_MATCH(void, DidActivate, &HMUI::ViewController::DidActivate, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling);
+ // DECLARE_OVERRIDE_METHOD_MATCH(void, DidDeactivate, &HMUI::ViewController::DidDeactivate, bool removedFromHierarchy, bool screenSystemDisabling);
+
+ DECLARE_INSTANCE_METHOD(void, MenuMusicButtonPressed);
+ DECLARE_INSTANCE_METHOD(void, LobbyMusicButtonPressed);
+ DECLARE_INSTANCE_METHOD(void, MenuClickButtonPressed);
+ DECLARE_INSTANCE_METHOD(void, HitSoundButtonPressed);
+ DECLARE_INSTANCE_METHOD(void, BadHitSoundButtonPressed);
+ DECLARE_INSTANCE_METHOD(void, MissSoundButtonPressed);
+ DECLARE_INSTANCE_METHOD(void, LevelClearedButtonPressed);
+ DECLARE_INSTANCE_METHOD(void, LevelFailedButtonPressed);
+ DECLARE_INSTANCE_METHOD(void, FireworkButtonPressed);
+ DECLARE_INSTANCE_METHOD(void, BombExplosionSoundButtonPressed);
+
+ DECLARE_CTOR(ctor);
+
+public:
+ void set_selectCallback(std::function callback);
+ std::function callback;
+)
\ No newline at end of file
diff --git a/include/UI/CustomSoundFileCell.hpp b/include/UI/CustomSoundFileCell.hpp
new file mode 100644
index 0000000..302e271
--- /dev/null
+++ b/include/UI/CustomSoundFileCell.hpp
@@ -0,0 +1,11 @@
+#include "bsml/shared/BSML/Components/CustomListTableData.hpp"
+
+DECLARE_CLASS_CUSTOM(QuestSounds::UI, CustomSoundFileCell, BSML::CustomCellInfo,
+public:
+ std::filesystem::path FilePath;
+
+ DECLARE_DEFAULT_CTOR();
+public:
+ static CustomSoundFileCell* construct(StringW text, StringW subText, std::filesystem::path filePath, UnityEngine::Sprite* icon = nullptr);
+ static CustomSoundFileCell* construct(StringW text, std::filesystem::path filePath, UnityEngine::Sprite* icon = nullptr);
+)
\ No newline at end of file
diff --git a/include/UI/QuestSoundsFlowCoordinator.hpp b/include/UI/QuestSoundsFlowCoordinator.hpp
new file mode 100644
index 0000000..60366f8
--- /dev/null
+++ b/include/UI/QuestSoundsFlowCoordinator.hpp
@@ -0,0 +1,28 @@
+#pragma once
+
+#include "custom-types/shared/macros.hpp"
+#include "bsml/shared/macros.hpp"
+
+#include "HMUI/FlowCoordinator.hpp"
+
+#include "UI/ConfigMenuSelectionViewController.hpp"
+#include "UI/SoundSettingsViewController.hpp"
+
+#include "GlobalNamespace/MainFlowCoordinator.hpp"
+
+#include "Zenject/IInitializable.hpp"
+
+DECLARE_CLASS_CODEGEN(QuestSounds::UI, QuestSoundsFlowCoordinator, HMUI::FlowCoordinator,
+
+ DECLARE_INSTANCE_FIELD(QuestSounds::UI::ConfigMenuSelectionViewController*, configMenuSelectionViewController);
+ DECLARE_INSTANCE_FIELD(QuestSounds::UI::SoundSettingsViewController*, soundSettingsViewController);
+
+ DECLARE_INSTANCE_METHOD(void, Awake);
+ DECLARE_OVERRIDE_METHOD_MATCH(void, DidActivate, &HMUI::FlowCoordinator::DidActivate, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling);
+ DECLARE_OVERRIDE_METHOD_MATCH(void, DidDeactivate, &HMUI::FlowCoordinator::DidDeactivate, bool removedFromHierarchy, bool screenSystemDisabling);
+ DECLARE_OVERRIDE_METHOD_MATCH(void, BackButtonWasPressed, &HMUI::FlowCoordinator::BackButtonWasPressed, HMUI::ViewController* topViewController);
+
+ DECLARE_INSTANCE_METHOD(void, SubMenuButtonPressed, int index);
+
+ DECLARE_DEFAULT_CTOR();
+)
\ No newline at end of file
diff --git a/include/UI/SoundSettingsViewController.hpp b/include/UI/SoundSettingsViewController.hpp
new file mode 100644
index 0000000..a643a9f
--- /dev/null
+++ b/include/UI/SoundSettingsViewController.hpp
@@ -0,0 +1,56 @@
+#pragma once
+
+#include "custom-types/shared/macros.hpp"
+#include "bsml/shared/macros.hpp"
+#include "bsml/shared/BSML/Components/Settings/ToggleSetting.hpp"
+#include "bsml/shared/BSML/Components/Settings/IncrementSetting.hpp"
+#include "bsml/shared/BSML/Components/Settings/SliderSetting.hpp"
+#include "bsml/shared/BSML/Components/CustomListTableData.hpp"
+
+#include "Config.hpp"
+#include "Utils/AsyncAudioClipLoader.hpp"
+
+#include "UI/CustomSoundFileCell.hpp"
+
+#include "UnityEngine/UI/HorizontalLayoutGroup.hpp"
+
+#include "HMUI/ViewController.hpp"
+
+DECLARE_CLASS_CODEGEN(QuestSounds::UI, SoundSettingsViewController, HMUI::ViewController,
+ std::string Name;
+ QuestSounds::Sound* Sound;
+ QuestSounds::Utils::AsyncAudioClipLoader* Loader;
+
+ std::optional> OnSoundChanged;
+
+ DECLARE_BSML_PROPERTY(bool, Active);
+ DECLARE_BSML_PROPERTY(float, VolumeOffset);
+ DECLARE_BSML_PROPERTY(float, BeatOffset);
+ DECLARE_BSML_PROPERTY(bool, HasSoundFiles);
+ DECLARE_BSML_PROPERTY(bool, IsSetup);
+
+ DECLARE_INSTANCE_FIELD(ListW, _Sounds);
+ DECLARE_INSTANCE_METHOD(ListW, get_Sounds);
+ DECLARE_INSTANCE_FIELD(BSML::CustomListTableData*, SoundList);
+ DECLARE_INSTANCE_FIELD(UnityEngine::UI::HorizontalLayoutGroup*, NoSoundsFoundHorizontal);
+
+ DECLARE_INSTANCE_FIELD(BSML::ToggleSetting*, SoundEnabled);
+ DECLARE_INSTANCE_FIELD(BSML::SliderSetting*, SoundVolumeOffset);
+ DECLARE_INSTANCE_FIELD(BSML::SliderSetting*, SoundBeatOffset);
+ DECLARE_INSTANCE_FIELD(UnityEngine::UI::HorizontalLayoutGroup*, NotSetupHorizontal);
+
+ DECLARE_INSTANCE_FIELD(bool, showSoundVolumeOffset);
+ DECLARE_INSTANCE_FIELD(bool, showSoundBeatOffset);
+
+ DECLARE_OVERRIDE_METHOD_MATCH(void, DidActivate, &HMUI::ViewController::DidActivate, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling);
+ DECLARE_OVERRIDE_METHOD_MATCH(void, DidDeactivate, &HMUI::ViewController::DidDeactivate, bool removedFromHierarchy, bool screenSystemDisabling);
+
+ DECLARE_INSTANCE_METHOD(void, SoundSelected, HMUI::TableView* table, int cellIdx);
+
+ DECLARE_CTOR(ctor);
+
+public:
+ void Setup(std::string name, QuestSounds::Sound* sound, QuestSounds::Utils::AsyncAudioClipLoader* loader, std::optional> onSoundChanged = std::nullopt);
+
+ custom_types::Helpers::Coroutine PreviewSelection();
+)
\ No newline at end of file
diff --git a/include/Utils/AsyncAudiocliploader.hpp b/include/Utils/AsyncAudioClipLoader.hpp
similarity index 60%
rename from include/Utils/AsyncAudiocliploader.hpp
rename to include/Utils/AsyncAudioClipLoader.hpp
index ff54071..b21e53f 100644
--- a/include/Utils/AsyncAudiocliploader.hpp
+++ b/include/Utils/AsyncAudioClipLoader.hpp
@@ -3,6 +3,7 @@
#include "UnityEngine/AudioClip.hpp"
#include "UnityEngine/GameObject.hpp"
+#include "System/Type.hpp"
#include "System/Threading/Tasks/Task.hpp"
#include "GlobalNamespace/MediaAsyncLoader.hpp"
@@ -12,32 +13,42 @@
#include "UnityEngine/Networking/UnityWebRequestMultimedia.hpp"
#include "UnityEngine/Networking/UnityWebRequest.hpp"
-//#include "custom-types/shared/coroutine.hpp"
+#include "custom-types/shared/coroutine.hpp"
-namespace AsyncAudioClipLoader
+namespace QuestSounds::Utils
{
- class loader : public Il2CppObject
+ // TODO: Cleanup this class
+ class AsyncAudioClipLoader
{
public:
- //static Logger logger;
std::string filePath;
int audioType = 14;
UnityEngine::AudioSource* audioSource;
UnityEngine::AudioClip* getClip(); //Audioclip
+ bool streamAudio = true;
bool loaded = false;
bool load();
void set_OriginalClip(UnityEngine::AudioClip* OriginalAudioClip); //Audioclip
UnityEngine::AudioClip* get_OriginalClip(); //Audioclip
UnityEngine::AudioSource* OriginalAudioSource = nullptr;
private:
+ custom_types::Helpers::Coroutine LoadAudioClip();
+ StringW loadPath;
UnityEngine::GameObject* audioClipGO;
- static void audioClipCompleted(loader* obj, Il2CppObject* asyncOp);
- Il2CppString* path;
- bool UsesUWR = false;
- System::Threading::Tasks::Task_1* audioClipTask;
+ void audioClipCompleted(::UnityW audioClip);
+ System::Threading::Tasks::Task_1<::UnityW>* audioClipTask;
UnityEngine::Networking::UnityWebRequestAsyncOperation* audioClipAsync;
UnityEngine::Networking::UnityWebRequest* audioClipRequest;
};
+
+ struct EnumHelper {
+ template
+ static StringW GetEnumName(T value)
+ {
+ auto enumType = (System::Type*)csTypeOf(T);
+ return enumType->GetEnumName((System::Object*)il2cpp_functions::value_box(classof(T), &value));
+ }
+ };
}
\ No newline at end of file
diff --git a/include/ViewControllers/BadHitSdListViewController.hpp b/include/ViewControllers/BadHitSdListViewController.hpp
deleted file mode 100644
index ccd8324..0000000
--- a/include/ViewControllers/BadHitSdListViewController.hpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#pragma once
-#include "questui/shared/BeatSaberUI.hpp"
-#include "custom-types/shared/macros.hpp"
-#include "HMUI/ViewController.hpp"
-
-DECLARE_CLASS_CODEGEN(QuestSounds::ViewControllers, BadHitSdListViewController, HMUI::ViewController,
- DECLARE_INSTANCE_FIELD(UnityEngine::UI::VerticalLayoutGroup*, QSconfigcontainer);
- DECLARE_INSTANCE_FIELD(UnityEngine::UI::HorizontalLayoutGroup*, listtxtgroup);
- DECLARE_INSTANCE_FIELD(UnityEngine::GameObject*, SDlistscroll);
-
- DECLARE_OVERRIDE_METHOD(void, DidActivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidActivate", 3), bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling);
- DECLARE_OVERRIDE_METHOD(void, DidDeactivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidDeactivate", 2), bool removedFromHierarchy, bool systemScreenDisabling);
-#if defined(REGISTER_FUNCTION) && defined(BS__1_16)
- REGISTER_FUNCTION(
-#elif defined(REGISTER_FUNCTION) && defined(BS__1_13_2)
- REGISTER_FUNCTION(BadHitSdListViewController,
-#endif
-#if defined(REGISTER_METHOD)
- REGISTER_METHOD(DidActivate);
- REGISTER_METHOD(DidDeactivate);
- )
-#endif
-);
\ No newline at end of file
diff --git a/include/ViewControllers/ConfigViewController.hpp b/include/ViewControllers/ConfigViewController.hpp
deleted file mode 100644
index bd7ac1a..0000000
--- a/include/ViewControllers/ConfigViewController.hpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#pragma once
-#include "custom-types/shared/macros.hpp"
-#include "HMUI/ViewController.hpp"
-
-// ViewController for the settings UI
-DECLARE_CLASS_CODEGEN(QuestSounds::ViewControllers, ConfigViewController, HMUI::ViewController,
- DECLARE_OVERRIDE_METHOD(void, DidActivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidActivate", 3), bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling);
- //DECLARE_OVERRIDE_METHOD(void, DidDeactivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidDeactivate", 2), bool removedFromHierarchy, bool systemScreenDisabling);
-
- public:
- void set_selectCallback(std::function callback);
- std::function callback;
-
-#if defined(BS__1_16) && defined(REGISTER_FUNCTION)
- REGISTER_FUNCTION(
-#elif defined(BS__1_13_2)
- REGISTER_FUNCTION(ConfigViewController,
-#endif
-#if defined(REGISTER_METHOD)
- REGISTER_METHOD(DidActivate);
- //REGISTER_METHOD(DidDeactivate);
- )
-#endif
-);
-
-
diff --git a/include/ViewControllers/FireworkSdListViewController.hpp b/include/ViewControllers/FireworkSdListViewController.hpp
deleted file mode 100644
index ffc4a4a..0000000
--- a/include/ViewControllers/FireworkSdListViewController.hpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#pragma once
-#include "questui/shared/BeatSaberUI.hpp"
-#include "custom-types/shared/macros.hpp"
-#include "HMUI/ViewController.hpp"
-
-DECLARE_CLASS_CODEGEN(QuestSounds::ViewControllers, FireworkSdListViewController, HMUI::ViewController,
- DECLARE_INSTANCE_FIELD(UnityEngine::UI::VerticalLayoutGroup*, QSconfigcontainer);
- DECLARE_INSTANCE_FIELD(UnityEngine::UI::HorizontalLayoutGroup*, listtxtgroup);
- DECLARE_INSTANCE_FIELD(UnityEngine::GameObject*, SDlistscroll);
-
- DECLARE_OVERRIDE_METHOD(void, DidActivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidActivate", 3), bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling);
- DECLARE_OVERRIDE_METHOD(void, DidDeactivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidDeactivate", 2), bool removedFromHierarchy, bool systemScreenDisabling);
-#if defined(REGISTER_FUNCTION) && defined(BS__1_16)
- REGISTER_FUNCTION(
-#elif defined(REGISTER_FUNCTION) && defined(BS__1_13_2)
- REGISTER_FUNCTION(FireworkSdListViewController,
-#endif
-#if defined(REGISTER_METHOD)
- REGISTER_METHOD(DidActivate);
- REGISTER_METHOD(DidDeactivate);
- )
-#endif
-);
\ No newline at end of file
diff --git a/include/ViewControllers/HitSdListViewController.hpp b/include/ViewControllers/HitSdListViewController.hpp
deleted file mode 100644
index 2523397..0000000
--- a/include/ViewControllers/HitSdListViewController.hpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#pragma once
-#include "questui/shared/BeatSaberUI.hpp"
-#include "custom-types/shared/macros.hpp"
-#include "HMUI/ViewController.hpp"
-
-DECLARE_CLASS_CODEGEN(QuestSounds::ViewControllers, HitSdListViewController, HMUI::ViewController,
- DECLARE_INSTANCE_FIELD(UnityEngine::UI::VerticalLayoutGroup*, QSconfigcontainer);
- DECLARE_INSTANCE_FIELD(UnityEngine::UI::HorizontalLayoutGroup*, listtxtgroup);
- DECLARE_INSTANCE_FIELD(UnityEngine::GameObject*, SDlistscroll);
-
- DECLARE_OVERRIDE_METHOD(void, DidActivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidActivate", 3), bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling);
- DECLARE_OVERRIDE_METHOD(void, DidDeactivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidDeactivate", 2), bool removedFromHierarchy, bool systemScreenDisabling);
-#if defined(REGISTER_FUNCTION) && defined(BS__1_16)
- REGISTER_FUNCTION(
-#elif defined(REGISTER_FUNCTION) && defined(BS__1_13_2)
- REGISTER_FUNCTION(HitSdListViewController,
-#endif
-#if defined(REGISTER_METHOD)
- REGISTER_METHOD(DidActivate);
- REGISTER_METHOD(DidDeactivate);
- )
-#endif
-);
\ No newline at end of file
diff --git a/include/ViewControllers/LevelClearedSdListViewController.hpp b/include/ViewControllers/LevelClearedSdListViewController.hpp
deleted file mode 100644
index 782e2e8..0000000
--- a/include/ViewControllers/LevelClearedSdListViewController.hpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#pragma once
-#include "questui/shared/BeatSaberUI.hpp"
-#include "custom-types/shared/macros.hpp"
-#include "HMUI/ViewController.hpp"
-
-DECLARE_CLASS_CODEGEN(QuestSounds::ViewControllers, LevelClearedSdListViewController, HMUI::ViewController,
- DECLARE_INSTANCE_FIELD(UnityEngine::UI::VerticalLayoutGroup*, QSconfigcontainer);
- DECLARE_INSTANCE_FIELD(UnityEngine::UI::HorizontalLayoutGroup*, listtxtgroup);
- DECLARE_INSTANCE_FIELD(UnityEngine::GameObject*, SDlistscroll);
-
- DECLARE_OVERRIDE_METHOD(void, DidActivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidActivate", 3), bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling);
- DECLARE_OVERRIDE_METHOD(void, DidDeactivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidDeactivate", 2), bool removedFromHierarchy, bool systemScreenDisabling);
-#if defined(REGISTER_FUNCTION) && defined(BS__1_16)
- REGISTER_FUNCTION(
-#elif defined(REGISTER_FUNCTION) && defined(BS__1_13_2)
- REGISTER_FUNCTION(LevelClearedSdListViewController,
-#endif
-#if defined(REGISTER_METHOD)
- REGISTER_METHOD(DidActivate);
- REGISTER_METHOD(DidDeactivate);
- )
-#endif
-);
\ No newline at end of file
diff --git a/include/ViewControllers/LevelFailedSdListViewController.hpp b/include/ViewControllers/LevelFailedSdListViewController.hpp
deleted file mode 100644
index f90fa02..0000000
--- a/include/ViewControllers/LevelFailedSdListViewController.hpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#pragma once
-#include "questui/shared/BeatSaberUI.hpp"
-#include "custom-types/shared/macros.hpp"
-#include "HMUI/ViewController.hpp"
-
-DECLARE_CLASS_CODEGEN(QuestSounds::ViewControllers, LevelFailedSdListViewController, HMUI::ViewController,
- DECLARE_INSTANCE_FIELD(UnityEngine::UI::VerticalLayoutGroup*, QSconfigcontainer);
- DECLARE_INSTANCE_FIELD(UnityEngine::UI::HorizontalLayoutGroup*, listtxtgroup);
- DECLARE_INSTANCE_FIELD(UnityEngine::GameObject*, SDlistscroll);
-
- DECLARE_OVERRIDE_METHOD(void, DidActivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidActivate", 3), bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling);
- DECLARE_OVERRIDE_METHOD(void, DidDeactivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidDeactivate", 2), bool removedFromHierarchy, bool systemScreenDisabling);
-#if defined(REGISTER_FUNCTION) && defined(BS__1_16)
- REGISTER_FUNCTION(
-#elif defined(REGISTER_FUNCTION) && defined(BS__1_13_2)
- REGISTER_FUNCTION(LevelClearedSdListViewController,
-#endif
-#if defined(REGISTER_METHOD)
- REGISTER_METHOD(DidActivate);
- REGISTER_METHOD(DidDeactivate);
- )
-#endif
-);
\ No newline at end of file
diff --git a/include/ViewControllers/LobbyMusicSdListViewController.hpp b/include/ViewControllers/LobbyMusicSdListViewController.hpp
deleted file mode 100644
index a62d890..0000000
--- a/include/ViewControllers/LobbyMusicSdListViewController.hpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#pragma once
-#include "questui/shared/BeatSaberUI.hpp"
-#include "custom-types/shared/macros.hpp"
-#include "HMUI/ViewController.hpp"
-
-DECLARE_CLASS_CODEGEN(QuestSounds::ViewControllers, LobbyMusicSdListViewController, HMUI::ViewController,
- DECLARE_INSTANCE_FIELD(UnityEngine::UI::VerticalLayoutGroup*, QSconfigcontainer);
- DECLARE_INSTANCE_FIELD(UnityEngine::UI::HorizontalLayoutGroup*, listtxtgroup);
- DECLARE_INSTANCE_FIELD(UnityEngine::GameObject*, SDlistscroll);
-
- DECLARE_OVERRIDE_METHOD(void, DidActivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidActivate", 3), bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling);
- DECLARE_OVERRIDE_METHOD(void, DidDeactivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidDeactivate", 2), bool removedFromHierarchy, bool systemScreenDisabling);
-#if defined(REGISTER_FUNCTION) && defined(BS__1_16)
- REGISTER_FUNCTION(
-#elif defined(REGISTER_FUNCTION) && defined(BS__1_13_2)
- REGISTER_FUNCTION(LobbyMusicSdListViewController,
-#endif
-#if defined(REGISTER_METHOD)
- REGISTER_METHOD(DidActivate);
- REGISTER_METHOD(DidDeactivate);
- )
-#endif
-);
\ No newline at end of file
diff --git a/include/ViewControllers/MenuClickSdListViewController.hpp b/include/ViewControllers/MenuClickSdListViewController.hpp
deleted file mode 100644
index 99a9218..0000000
--- a/include/ViewControllers/MenuClickSdListViewController.hpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#include "questui/shared/BeatSaberUI.hpp"
-#include "custom-types/shared/macros.hpp"
-#include "HMUI/ViewController.hpp"
-
-DECLARE_CLASS_CODEGEN(QuestSounds::ViewControllers, MenuClickSdListViewController, HMUI::ViewController,
- DECLARE_INSTANCE_FIELD(UnityEngine::UI::VerticalLayoutGroup*, QSconfigcontainer);
- DECLARE_INSTANCE_FIELD(UnityEngine::UI::HorizontalLayoutGroup*, listtxtgroup);
- DECLARE_INSTANCE_FIELD(UnityEngine::GameObject*, SDlistscroll);
-
- DECLARE_OVERRIDE_METHOD(void, DidActivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidActivate", 3), bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling);
- DECLARE_OVERRIDE_METHOD(void, DidDeactivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidDeactivate", 2), bool removedFromHierarchy, bool systemScreenDisabling);
-
-#if defined(REGISTER_FUNCTION) && defined(BS__1_16)
- REGISTER_FUNCTION(
-#elif defined(REGISTER_FUNCTION) && defined(BS__1_13_2)
- REGISTER_FUNCTION(MenuClickSdListViewController,
-#endif
-#if defined(REGISTER_METHOD)
- REGISTER_METHOD(DidActivate);
- REGISTER_METHOD(DidDeactivate);
- )
-#endif
-);
\ No newline at end of file
diff --git a/include/ViewControllers/MenuSdListViewController.hpp b/include/ViewControllers/MenuSdListViewController.hpp
deleted file mode 100644
index 6ccc96c..0000000
--- a/include/ViewControllers/MenuSdListViewController.hpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "questui/shared/BeatSaberUI.hpp"
-#include "custom-types/shared/macros.hpp"
-#include "HMUI/ViewController.hpp"
-#include "HMUI/ModalView.hpp"
-
-DECLARE_CLASS_CODEGEN(QuestSounds::ViewControllers, MenuSdListViewController, HMUI::ViewController,
- DECLARE_INSTANCE_FIELD(UnityEngine::UI::VerticalLayoutGroup*, QSconfigcontainer);
- DECLARE_INSTANCE_FIELD(UnityEngine::UI::HorizontalLayoutGroup*, listtxtgroup);
- DECLARE_INSTANCE_FIELD(UnityEngine::GameObject*, SDlistscroll);
-
- DECLARE_OVERRIDE_METHOD(void, DidActivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidActivate", 3), bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling);
- DECLARE_OVERRIDE_METHOD(void, DidDeactivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidDeactivate", 2), bool removedFromHierarchy, bool systemScreenDisabling);
-
- DECLARE_INSTANCE_FIELD(HMUI::ModalView*, modal);
-
-#if defined(REGISTER_FUNCTION) && defined(BS__1_16)
- REGISTER_FUNCTION(
-#elif defined(REGISTER_FUNCTION) && defined(BS__1_13_2)
- REGISTER_FUNCTION(MenuSdListViewController,
-#endif
-#if defined(REGISTER_METHOD)
- REGISTER_METHOD(DidActivate);
- REGISTER_METHOD(DidDeactivate);
- )
-#endif
-);
\ No newline at end of file
diff --git a/include/ViewControllers/NoteMissedSdListViewController.hpp b/include/ViewControllers/NoteMissedSdListViewController.hpp
deleted file mode 100644
index eae3c8c..0000000
--- a/include/ViewControllers/NoteMissedSdListViewController.hpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#pragma once
-#include "questui/shared/BeatSaberUI.hpp"
-#include "custom-types/shared/macros.hpp"
-#include "HMUI/ViewController.hpp"
-
-DECLARE_CLASS_CODEGEN(QuestSounds::ViewControllers, NoteMissedSdListViewController, HMUI::ViewController,
- DECLARE_INSTANCE_FIELD(UnityEngine::UI::VerticalLayoutGroup*, QSconfigcontainer);
- DECLARE_INSTANCE_FIELD(UnityEngine::UI::HorizontalLayoutGroup*, listtxtgroup);
- DECLARE_INSTANCE_FIELD(UnityEngine::GameObject*, SDlistscroll);
-
- DECLARE_OVERRIDE_METHOD(void, DidActivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidActivate", 3), bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling);
- DECLARE_OVERRIDE_METHOD(void, DidDeactivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidDeactivate", 2), bool removedFromHierarchy, bool systemScreenDisabling);
-#if defined(REGISTER_FUNCTION) && defined(BS__1_16)
- REGISTER_FUNCTION(
-#elif defined(REGISTER_FUNCTION) && defined(BS__1_13_2)
- REGISTER_FUNCTION(BadHitSdListViewController,
-#endif
-#if defined(REGISTER_METHOD)
- REGISTER_METHOD(DidActivate);
- REGISTER_METHOD(DidDeactivate);
- )
-#endif
-);
\ No newline at end of file
diff --git a/include/_config.h b/include/_config.h
new file mode 100644
index 0000000..97c5fec
--- /dev/null
+++ b/include/_config.h
@@ -0,0 +1,7 @@
+#define QS_EXPORT __attribute__((visibility("default")))
+
+#ifdef __cplusplus
+#define QS_EXPORT_FUNC extern "C" QS_EXPORT
+#else
+#define QS_EXPORT_FUNC QS_EXPORT
+#endif
\ No newline at end of file
diff --git a/include/assets.hpp b/include/assets.hpp
new file mode 100644
index 0000000..93df0c6
--- /dev/null
+++ b/include/assets.hpp
@@ -0,0 +1,5 @@
+#pragma once
+#include "kaleb/shared/kaleb.hpp"
+
+DECLARE_FILE(_binary_ConfigMenuSelectionViewController_bsml, Assets, ConfigMenuSelectionViewController_bsml);
+DECLARE_FILE(_binary_SoundSettingsViewController_bsml, Assets, SoundSettingsViewController_bsml);
diff --git a/include/hooking.hpp b/include/hooking.hpp
new file mode 100644
index 0000000..2bc1086
--- /dev/null
+++ b/include/hooking.hpp
@@ -0,0 +1,107 @@
+#pragma once
+
+#include "beatsaber-hook/shared/utils/hooking.hpp"
+#include "beatsaber-hook/shared/utils/logging.hpp"
+#include
+
+namespace QuestSounds {
+ class Hooking {
+ private:
+ inline static std::vector installFuncs;
+
+ public:
+ static void AddInstallFunc(void (*installFunc)()) {
+ installFuncs.push_back(installFunc);
+ }
+
+ static inline void InstallHooks() {
+ for (auto& func : installFuncs) func();
+ }
+ };
+
+ template
+ concept has_metadata = requires() {
+ { ::il2cpp_utils::il2cpp_type_check::MetadataGetter::methodInfo() } -> std::same_as;
+ };
+
+ template
+ requires(has_metadata)
+ using Metadata = ::il2cpp_utils::il2cpp_type_check::MetadataGetter;
+
+ /// @brief checks whether the function is match hookable, which requires the function to be at least 5 (5 * 4 = 20 bytes) instructions and not have an address of 0 (abstract/virtual funcs)
+ template
+ concept match_hookable = has_metadata && Metadata::size >= (0x5 * sizeof(int32_t)) && Metadata::addrs != 0x0;
+}
+
+#define AUTO_INSTALL_PATCH(name_) \
+ struct Auto_Patch_##name_ { \
+ Auto_Patch_##name_() { \
+ ::QuestSounds::Hooking::AddInstallFunc(Patch_##name_); \
+ } \
+ }; \
+ static Auto_Patch_##name_ Auto_Patch_Instance_##name_
+
+#define HOOK_AUTO_INSTALL_ORIG(name_) \
+ struct Auto_Hook_##name_ { \
+ static void Auto_Hook_##name_##_Install() { \
+ static constexpr auto logger = Paper::ConstLoggerContext(MOD_ID "_Install_" #name_); \
+ ::Hooking::InstallOrigHook(logger); \
+ } \
+ Auto_Hook_##name_() { ::QuestSounds::Hooking::AddInstallFunc(Auto_Hook_##name_##_Install); } \
+ }; \
+ static Auto_Hook_##name_ Auto_Hook_Instance_##name_
+
+#define HOOK_AUTO_INSTALL(name_) \
+ struct Auto_Hook_##name_ { \
+ static void Auto_Hook_##name_##_Install() { \
+ static constexpr auto logger = Paper::ConstLoggerContext(MOD_ID "_Install_" #name_); \
+ ::Hooking::InstallHook(logger); \
+ } \
+ Auto_Hook_##name_() { ::QuestSounds::Hooking::AddInstallFunc(Auto_Hook_##name_##_Install); } \
+ }; \
+ static Auto_Hook_##name_ Auto_Hook_Instance_##name_
+
+#define MAKE_AUTO_HOOK_MATCH(name_, mPtr, retval, ...) \
+ struct Hook_##name_ \
+ { \
+ using funcType = retval (*)(__VA_ARGS__); \
+ static_assert(QuestSounds::match_hookable); \
+ static_assert(std::is_same_v::funcType>, "Hook method signature does not match!"); \
+ constexpr static const char* name() { return #name_; } \
+ static const MethodInfo* getInfo() { return ::il2cpp_utils::il2cpp_type_check::MetadataGetter::methodInfo(); } \
+ static funcType* trampoline() { return &name_; } \
+ static inline retval (*name_)(__VA_ARGS__) = nullptr; \
+ static funcType hook() { return &::Hooking::HookCatchWrapper<&hook_##name_, funcType>::wrapper; } \
+ static retval hook_##name_(__VA_ARGS__); \
+ }; \
+ HOOK_AUTO_INSTALL(name_); \
+ retval Hook_##name_::hook_##name_(__VA_ARGS__)
+
+#define MAKE_AUTO_HOOK_FIND_VERBOSE(name_, infoGet, retval, ...) \
+ struct Hook_##name_ { \
+ constexpr static const char* name() { return #name_; } \
+ static const MethodInfo* getInfo() { return infoGet; } \
+ using funcType = retval (*)(__VA_ARGS__); \
+ static funcType* trampoline() { return &name_; } \
+ static inline retval (*name_)(__VA_ARGS__) = nullptr; \
+ static funcType hook() { return &::Hooking::HookCatchWrapper<&hook_##name_, funcType>::wrapper; } \
+ static retval hook_##name_(__VA_ARGS__); \
+ }; \
+ HOOK_AUTO_INSTALL_ORIG(name_); \
+ retval Hook_##name_::hook_##name_(__VA_ARGS__)
+
+#define MAKE_AUTO_HOOK_ORIG_MATCH(name_, mPtr, retval, ...) \
+ struct Hook_##name_ \
+ { \
+ using funcType = retval (*)(__VA_ARGS__); \
+ static_assert(QuestSounds::match_hookable); \
+ static_assert(std::is_same_v::funcType>, "Hook method signature does not match!"); \
+ constexpr static const char* name() { return #name_; } \
+ static const MethodInfo* getInfo() { return ::il2cpp_utils::il2cpp_type_check::MetadataGetter::methodInfo(); } \
+ static funcType* trampoline() { return &name_; } \
+ static inline retval (*name_)(__VA_ARGS__) = nullptr; \
+ static funcType hook() { return &::Hooking::HookCatchWrapper<&hook_##name_, funcType>::wrapper; } \
+ static retval hook_##name_(__VA_ARGS__); \
+ }; \
+ HOOK_AUTO_INSTALL_ORIG(name_); \
+ retval Hook_##name_::hook_##name_(__VA_ARGS__)
diff --git a/include/logging.hpp b/include/logging.hpp
new file mode 100644
index 0000000..4ae506f
--- /dev/null
+++ b/include/logging.hpp
@@ -0,0 +1,6 @@
+// Logging
+#include "paper/shared/logger.hpp"
+
+Paper::ConstLoggerContext<12UL>& getLogger();
+
+// TODO: Proper paper logging macros
\ No newline at end of file
diff --git a/include/main.hpp b/include/main.hpp
index 0279153..9a35754 100644
--- a/include/main.hpp
+++ b/include/main.hpp
@@ -1,23 +1,13 @@
#pragma once
+// TODO: Cleanup this file
+
// Include the modloader header, which allows us to tell the modloader which mod this is, and the version etc.
-#include "modloader/shared/modloader.hpp"
+#include "scotland2/shared/loader.hpp"
// beatsaber-hook is a modding framework that lets us call functions and fetch field values from in the game
// It also allows creating objects, configuration, and importantly, hooking methods to modify their values
-//#include "beatsaber-hook/shared/utils/utils.h"
#include "beatsaber-hook/shared/utils/logging.hpp"
-//#include "beatsaber-hook/shared/utils/typedefs.h"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-functions.hpp"
-#include "beatsaber-hook/shared/config/config-utils.hpp"
-#if !defined(MAKE_HOOK_OFFSETLESS)
#include "beatsaber-hook/shared/utils/hooking.hpp"
-#endif
-
-#include "System/Collections/IEnumerator.hpp"
-#include "custom-types/shared/coroutine.hpp"
-
-// Define these functions here so that we can easily read configuration and log information from other files
-Configuration& getConfig();
-Logger& getLogger();
\ No newline at end of file
diff --git a/mod.bak.json b/mod.bak.json
deleted file mode 100644
index 33f3524..0000000
--- a/mod.bak.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "_QPVersion": "0.1.1",
- "id": "QuestSounds",
- "name": "Quest Sounds",
- "version": "1.0.4-Dev",
- "author": "Rugtveit, EnderdracheLP",
- "packageId": "com.beatgames.beatsaber",
- "packageVersion": "1.19.0",
- "description": "Allows users to change their sfx sounds and in-game music easily!",
- "coverImage": "Cover.jpg",
- "modFiles": [
- "libQuestSounds.so"
- ],
- "libraryFiles": [
- "libbeatsaber-hook_3_4_4.so"
- ],
- "dependencies": [],
- "fileCopies": []
-}
diff --git a/mod.template.json b/mod.template.json
index 3a51953..0ecb4b9 100644
--- a/mod.template.json
+++ b/mod.template.json
@@ -5,7 +5,7 @@
"author": "Rugtveit, EnderdracheLP",
"version": "${version}",
"packageId": "com.beatgames.beatsaber",
- "packageVersion": "1.28.0_4124311467",
+ "packageVersion": "1.37.0_9064817954",
"description": "Allows users to change their sfx sounds and in-game music easily!",
"coverImage": "Cover.jpg",
"dependencies": [],
@@ -59,6 +59,10 @@
{
"name": "OsuMiss.ogg",
"destination": "/sdcard/ModData/com.beatgames.beatsaber/Mods/QuestSounds/BadHitSounds/Osu Miss.ogg"
+ },
+ {
+ "name": "BombHitExplosion.ogg",
+ "destination": "/sdcard/ModData/com.beatgames.beatsaber/Mods/QuestSounds/BombExplosionSounds/BombHitExplosion.ogg"
}
],
"copyExtensions": []
diff --git a/qpm.json b/qpm.json
index db810b2..e6a61c4 100644
--- a/qpm.json
+++ b/qpm.json
@@ -1,45 +1,70 @@
{
+ "version": "0.1.0",
"sharedDir": "shared",
"dependenciesDir": "extern",
"info": {
"name": "QuestSounds",
"id": "QuestSounds",
- "version": "1.4.1",
+ "version": "1.5.0-Dev",
"url": null,
"additionalData": {
"overrideSoName": "libQuestSounds.so"
}
},
+ "workspace": {
+ "scripts": {},
+ "qmodIncludeDirs": [],
+ "qmodIncludeFiles": [],
+ "qmodOutput": null
+ },
"dependencies": [
{
"id": "beatsaber-hook",
- "versionRange": "^3.14.0",
+ "versionRange": "^5.1.9",
+ "additionalData": {}
+ },
+ {
+ "id": "scotland2",
+ "versionRange": "^0.1.4",
"additionalData": {
- "extraFiles": [
- "src/inline-hook"
- ]
+ "includeQmod": false,
+ "private": true
}
},
{
- "id": "questui",
- "versionRange": "^0.17.11",
+ "id": "bs-cordl",
+ "versionRange": "^3700.0.0",
"additionalData": {}
},
{
- "id": "codegen",
- "versionRange": "^0.33.0",
+ "id": "custom-types",
+ "versionRange": "^0.17.10",
"additionalData": {}
},
{
- "id": "custom-types",
- "versionRange": "^0.15.23",
+ "id": "bsml",
+ "versionRange": "^0.4.43",
+ "additionalData": {}
+ },
+ {
+ "id": "config-utils",
+ "versionRange": "^1.4.2",
+ "additionalData": {}
+ },
+ {
+ "id": "paper",
+ "versionRange": "^3.6.4",
+ "additionalData": {}
+ },
+ {
+ "id": "rapidjson-macros",
+ "versionRange": "^1.2.1",
"additionalData": {}
},
{
- "id": "modloader",
- "versionRange": "^1.2.3",
+ "id": "kaleb",
+ "versionRange": "^0.1.9",
"additionalData": {}
}
- ],
- "additionalData": {}
+ ]
}
\ No newline at end of file
diff --git a/qpm.shared.json b/qpm.shared.json
new file mode 100644
index 0000000..3cfa3cb
--- /dev/null
+++ b/qpm.shared.json
@@ -0,0 +1,266 @@
+{
+ "config": {
+ "version": "0.1.0",
+ "sharedDir": "shared",
+ "dependenciesDir": "extern",
+ "info": {
+ "name": "QuestSounds",
+ "id": "QuestSounds",
+ "version": "1.5.0-Dev",
+ "url": null,
+ "additionalData": {
+ "overrideSoName": "libQuestSounds.so"
+ }
+ },
+ "workspace": {
+ "scripts": {},
+ "qmodIncludeDirs": [],
+ "qmodIncludeFiles": [],
+ "qmodOutput": null
+ },
+ "dependencies": [
+ {
+ "id": "beatsaber-hook",
+ "versionRange": "^5.1.9",
+ "additionalData": {}
+ },
+ {
+ "id": "scotland2",
+ "versionRange": "^0.1.4",
+ "additionalData": {
+ "includeQmod": false,
+ "private": true
+ }
+ },
+ {
+ "id": "bs-cordl",
+ "versionRange": "^3700.0.0",
+ "additionalData": {}
+ },
+ {
+ "id": "custom-types",
+ "versionRange": "^0.17.10",
+ "additionalData": {}
+ },
+ {
+ "id": "bsml",
+ "versionRange": "^0.4.43",
+ "additionalData": {}
+ },
+ {
+ "id": "config-utils",
+ "versionRange": "^1.4.2",
+ "additionalData": {}
+ },
+ {
+ "id": "paper",
+ "versionRange": "^3.6.4",
+ "additionalData": {}
+ },
+ {
+ "id": "rapidjson-macros",
+ "versionRange": "^1.2.1",
+ "additionalData": {}
+ },
+ {
+ "id": "kaleb",
+ "versionRange": "^0.1.9",
+ "additionalData": {}
+ }
+ ]
+ },
+ "restoredDependencies": [
+ {
+ "dependency": {
+ "id": "paper",
+ "versionRange": "=3.6.4",
+ "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",
+ "compileOptions": {
+ "systemIncludes": [
+ "shared/utfcpp/source"
+ ]
+ },
+ "cmake": false
+ }
+ },
+ "version": "3.6.4"
+ },
+ {
+ "dependency": {
+ "id": "rapidjson-macros",
+ "versionRange": "=1.2.1",
+ "additionalData": {
+ "headersOnly": true,
+ "branchName": "version/v1_2_1",
+ "cmake": true
+ }
+ },
+ "version": "1.2.1"
+ },
+ {
+ "dependency": {
+ "id": "bsml",
+ "versionRange": "=0.4.43",
+ "additionalData": {
+ "soLink": "https://github.com/RedBrumbler/Quest-BSML/releases/download/v0.4.43/libbsml.so",
+ "debugSoLink": "https://github.com/RedBrumbler/Quest-BSML/releases/download/v0.4.43/debug_libbsml.so",
+ "overrideSoName": "libbsml.so",
+ "modLink": "https://github.com/RedBrumbler/Quest-BSML/releases/download/v0.4.43/BSML.qmod",
+ "branchName": "version/v0_4_43",
+ "cmake": true
+ }
+ },
+ "version": "0.4.43"
+ },
+ {
+ "dependency": {
+ "id": "config-utils",
+ "versionRange": "=1.4.2",
+ "additionalData": {
+ "headersOnly": true,
+ "soLink": "https://github.com/darknight1050/config-utils/releases/download/v1.4.2/libconfig-utils_test.so",
+ "overrideSoName": "libconfig-utils_test.so",
+ "branchName": "version/v1_4_2",
+ "cmake": true
+ }
+ },
+ "version": "1.4.2"
+ },
+ {
+ "dependency": {
+ "id": "custom-types",
+ "versionRange": "=0.17.10",
+ "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",
+ "overrideSoName": "libcustom-types.so",
+ "modLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.17.10/CustomTypes.qmod",
+ "branchName": "version/v0_17_10",
+ "compileOptions": {
+ "cppFlags": [
+ "-Wno-invalid-offsetof"
+ ]
+ },
+ "cmake": true
+ }
+ },
+ "version": "0.17.10"
+ },
+ {
+ "dependency": {
+ "id": "libil2cpp",
+ "versionRange": "=0.3.2",
+ "additionalData": {
+ "headersOnly": true,
+ "cmake": false
+ }
+ },
+ "version": "0.3.2"
+ },
+ {
+ "dependency": {
+ "id": "kaleb",
+ "versionRange": "=0.1.9",
+ "additionalData": {
+ "headersOnly": true,
+ "branchName": "version/v0_1_9",
+ "compileOptions": {
+ "cppFlags": [
+ "-DKALEB_VERSION=\"0.1.9\""
+ ]
+ },
+ "cmake": false
+ }
+ },
+ "version": "0.1.9"
+ },
+ {
+ "dependency": {
+ "id": "bs-cordl",
+ "versionRange": "=3700.0.0",
+ "additionalData": {
+ "headersOnly": true,
+ "branchName": "version/v3700_0_0",
+ "compileOptions": {
+ "includePaths": [
+ "include"
+ ],
+ "cppFeatures": [],
+ "cppFlags": [
+ "-DNEED_UNSAFE_CSHARP",
+ "-fdeclspec",
+ "-DUNITY_2021",
+ "-DHAS_CODEGEN"
+ ]
+ }
+ }
+ },
+ "version": "3700.0.0"
+ },
+ {
+ "dependency": {
+ "id": "beatsaber-hook",
+ "versionRange": "=5.1.9",
+ "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",
+ "cmake": true
+ }
+ },
+ "version": "5.1.9"
+ },
+ {
+ "dependency": {
+ "id": "scotland2",
+ "versionRange": "=0.1.4",
+ "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",
+ "overrideSoName": "libsl2.so",
+ "branchName": "version/v0_1_4"
+ }
+ },
+ "version": "0.1.4"
+ },
+ {
+ "dependency": {
+ "id": "tinyxml2",
+ "versionRange": "=10.0.0",
+ "additionalData": {
+ "soLink": "https://github.com/MillzyDev/NDK-tinyxml2/releases/download/v10.0.0/libtinyxml2.so",
+ "debugSoLink": "https://github.com/MillzyDev/NDK-tinyxml2/releases/download/v10.0.0/debug_libtinyxml2.so",
+ "overrideSoName": "libtinyxml2.so",
+ "modLink": "https://github.com/MillzyDev/NDK-tinyxml2/releases/download/v10.0.0/tinyxml2.qmod",
+ "branchName": "version/v10_0_0",
+ "cmake": true
+ }
+ },
+ "version": "10.0.0"
+ },
+ {
+ "dependency": {
+ "id": "fmt",
+ "versionRange": "=10.0.0",
+ "additionalData": {
+ "headersOnly": true,
+ "branchName": "version/v10_0_0",
+ "compileOptions": {
+ "systemIncludes": [
+ "fmt/include/"
+ ],
+ "cppFlags": [
+ "-DFMT_HEADER_ONLY"
+ ]
+ }
+ }
+ },
+ "version": "10.0.0"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/rl-notes.md b/rl-notes.md
index 842f6a0..233980c 100644
--- a/rl-notes.md
+++ b/rl-notes.md
@@ -1,27 +1,30 @@
-**READ ENTIRE POST BEFORE OPENING AN ISSUE**
-Description:
+## READ ENTIRE POST BEFORE OPENING AN ISSUE
+### Description:
QuestSounds or short QSounds allows you to add Custom Hit Sounds and other sounds as well as adding new sounds,
just drop them into the folder and select them in-game!
__**Changelog:**__
-- Updated for Beat Saber version 1.28.0_4124311467
+- Updated for Beat Saber version 1.37.0_9064817954
+- Rewritten UI from scratch
+- **NEW Feature:** Added support for BombExplosionSounds
+- Internal changes to improve performance and stability
+- Fixed freezing on loading with MP3 and MP2 files by streaming audio (except for HitSounds)
-Features:
+### Features:
In-Game Menu for selecting sound files and enabling/disabling custom sounds.
Support for OGG, MP3, WAV, MP2 and AIFF/AIF file formats!
- Creates QuestSounds folder at /sdcard/ModData/com.beatgames.beatsaber/Mods/
+ Creates QuestSounds folder at **/sdcard/ModData/com.beatgames.beatsaber/Mods/**
which contains the sub-folders for the sounds.
AFTER YOU HAVE RAN THE MOD ONCE
- **Avoid using any files that use MPEG format like MP3 or MP2 unless you don't mind brief freezing upon loading**
-
Sounds you can change and their default folder Path:
-- HitSounds: sdcard/ModData/com.beatgames.beatsaber/Mods/QuestSounds/HitSounds/
-- BadHitSounds: sdcard/ModData/com.beatgames.beatsaber/Mods/QuestSounds/BadHitSounds/
-- NoteMissedSounds: sdcard/ModData/com.beatgames.beatsaber/Mods/QuestSounds/NoteMissedSounds/
-- MenuMusic: sdcard/ModData/com.beatgames.beatsaber/Mods/QuestSounds/MenuMusic/
-- MenuClicks: sdcard/ModData/com.beatgames.beatsaber/Mods/QuestSounds/MenuClicks/
-- Firework: sdcard/ModData/com.beatgames.beatsaber/Mods/QuestSounds/Fireworks/
-- LevelCleared: sdcard/ModData/com.beatgames.beatsaber/Mods/QuestSounds/LevelCleared/
-- LevelFailed: sdcard/ModData/com.beatgames.beatsaber/Mods/QuestSounds/LevelFailed/
-- LobbyMusic: sdcard/ModData/com.beatgames.beatsaber/Mods/QuestSounds/LobbyMusic/
\ No newline at end of file
+- **MenuMusic**: sdcard/ModData/com.beatgames.beatsaber/Mods/QuestSounds/MenuMusic/
+- **LobbyMusic**: sdcard/ModData/com.beatgames.beatsaber/Mods/QuestSounds/LobbyMusic/
+- **MenuClicks**: sdcard/ModData/com.beatgames.beatsaber/Mods/QuestSounds/MenuClicks/
+- **HitSounds**: sdcard/ModData/com.beatgames.beatsaber/Mods/QuestSounds/HitSounds/
+- **BadHitSounds**: sdcard/ModData/com.beatgames.beatsaber/Mods/QuestSounds/BadHitSounds/
+- **NoteMissedSounds**: sdcard/ModData/com.beatgames.beatsaber/Mods/QuestSounds/NoteMissedSounds/
+- ***NEW:*** **BombExplosionSounds**: sdcard/ModData/com.beatgames.beatsaber/Mods/QuestSounds/BombExplosionSounds/
+- **LevelCleared**: sdcard/ModData/com.beatgames.beatsaber/Mods/QuestSounds/LevelCleared/
+- **LevelFailed**: sdcard/ModData/com.beatgames.beatsaber/Mods/QuestSounds/LevelFailed/
+- **Firework**: sdcard/ModData/com.beatgames.beatsaber/Mods/QuestSounds/Fireworks/
\ No newline at end of file
diff --git a/src/Config.cpp b/src/Config.cpp
new file mode 100644
index 0000000..dd4b600
--- /dev/null
+++ b/src/Config.cpp
@@ -0,0 +1,11 @@
+#include "Config.hpp"
+#include "beatsaber-hook/shared/config/config-utils.hpp"
+// TODO: See if I need this cpp file at all
+namespace QuestSounds {
+ SoundsConfig Config;
+
+ std::string& GetConfigPath() {
+ static std::string configPath = Configuration::getConfigFilePath(modInfo);
+ return configPath;
+ }
+}
\ No newline at end of file
diff --git a/src/Hooks/BackgroundMusicHooks.cpp b/src/Hooks/BackgroundMusicHooks.cpp
new file mode 100644
index 0000000..beae828
--- /dev/null
+++ b/src/Hooks/BackgroundMusicHooks.cpp
@@ -0,0 +1,99 @@
+#include "hooking.hpp"
+#include "logging.hpp"
+#include "Config.hpp"
+using namespace QuestSounds;
+
+// TODO: I'd like to get rid of this header
+#include "AudioClips.hpp"
+using namespace QuestSounds::AudioClips;
+
+#include "ObjectInstances.hpp"
+
+#include "GlobalNamespace/SongPreviewPlayer.hpp"
+#include "GlobalNamespace/GameServerLobbyFlowCoordinator.hpp"
+#include "GlobalNamespace/MultiplayerModeSelectionFlowCoordinator.hpp"
+using namespace GlobalNamespace;
+
+namespace QuestSounds::ObjectInstances {
+ GlobalNamespace::SongPreviewPlayer* SPP;
+}
+
+MAKE_AUTO_HOOK_MATCH(SongPreviewPlayer_OnEnable, &SongPreviewPlayer::OnEnable, void, SongPreviewPlayer* self) {
+ getLogger().info("is it true: %i", menuMusicLoader.loaded);
+ QuestSounds::ObjectInstances::SPP = self;
+
+ if (!menuMusicLoader.OriginalAudioSource) {
+ menuMusicLoader.set_OriginalClip(self->_defaultAudioClip);
+ }
+
+ if (menuMusicLoader.loaded && Config.Sounds.MenuMusic.Active)
+ {
+ getLogger().debug("Overriding MenuMusic Audio");
+ UnityEngine::AudioClip* audioClip = menuMusicLoader.getClip();
+ if (audioClip != nullptr)
+ self->_defaultAudioClip = audioClip;
+ }
+ else {
+ getLogger().debug("Loading MenuMusic Audio normally: isLoaded='{}' isActive='{}'", menuMusicLoader.loaded, Config.Sounds.MenuMusic.Active);
+ self->_defaultAudioClip = menuMusicLoader.get_OriginalClip();
+ }
+ SongPreviewPlayer_OnEnable(self);
+}
+
+MAKE_AUTO_HOOK_MATCH(GameServerLobbyFlowCoordinator_DidActivate, &GameServerLobbyFlowCoordinator::DidActivate, void, GameServerLobbyFlowCoordinator* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
+{
+ getLogger().debug("GameServerLobbyFlowCoordinator_DidActivate");
+ if (!lobbyAmbienceLoader.OriginalAudioSource) lobbyAmbienceLoader.set_OriginalClip(self->_ambienceAudioClip);
+
+ if (lobbyAmbienceLoader.loaded && Config.Sounds.LobbyMusic.Active)
+ {
+ getLogger().debug("Overwriting LobbyAmbience Audio");
+ self->_ambienceAudioClip = lobbyAmbienceLoader.getClip();
+ }
+ else {
+ self->_ambienceAudioClip = lobbyAmbienceLoader.get_OriginalClip();
+ }
+ GameServerLobbyFlowCoordinator_DidActivate(self, firstActivation, addedToHierarchy, screenSystemEnabling);
+}
+
+MAKE_AUTO_HOOK_MATCH(GameServerLobbyFlowCoordinator_DidDeactivate, &GameServerLobbyFlowCoordinator::DidDeactivate, void, GameServerLobbyFlowCoordinator* self, bool removedFromHierarchy, bool screenSystemDisabling)
+{
+ getLogger().debug("GameServerLobbyFlowCoordinator_DidActivate");
+ if (menuMusicLoader.loaded && Config.Sounds.MenuMusic.Active && removedFromHierarchy)
+ {
+ getLogger().debug("Switching LobbyMusic to MenuMusic Audio");
+ self->_ambienceAudioClip = menuMusicLoader.getClip();
+ }
+ else {
+ self->_ambienceAudioClip = menuMusicLoader.get_OriginalClip();
+ }
+ GameServerLobbyFlowCoordinator_DidDeactivate(self, removedFromHierarchy, screenSystemDisabling);
+}
+
+MAKE_AUTO_HOOK_MATCH(MultiplayerModeSelectionFlowCoordinator_DidActivate, &MultiplayerModeSelectionFlowCoordinator::DidActivate, void, MultiplayerModeSelectionFlowCoordinator* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
+{
+ getLogger().debug("MultiplayerModeSelectionFlowCoordinator_DidActivate");
+ if (menuMusicLoader.loaded && Config.Sounds.MenuMusic.Active)
+ {
+ getLogger().debug("Switching LobbyMusic to MenuMusic Audio");
+ self->_ambienceAudioClip = menuMusicLoader.getClip();
+ }
+ else {
+ self->_ambienceAudioClip = menuMusicLoader.get_OriginalClip();
+ }
+ MultiplayerModeSelectionFlowCoordinator_DidActivate(self, firstActivation, addedToHierarchy, screenSystemEnabling); // This has to be ran last, otherwise it will not work correctly
+}
+
+MAKE_AUTO_HOOK_MATCH(MultiplayerModeSelectionFlowCoordinator_DidDeactivate, &MultiplayerModeSelectionFlowCoordinator::DidDeactivate, void, MultiplayerModeSelectionFlowCoordinator* self, bool removedFromHierarchy, bool screenSystemDisabling)
+{
+ getLogger().debug("MultiplayerModeSelectionFlowCoordinator_DidDeactivate");
+ if (menuMusicLoader.loaded && Config.Sounds.MenuMusic.Active && removedFromHierarchy)
+ {
+ self->_ambienceAudioClip = menuMusicLoader.getClip();
+ }
+ else {
+ self->_ambienceAudioClip = menuMusicLoader.get_OriginalClip();
+ }
+
+ MultiplayerModeSelectionFlowCoordinator_DidDeactivate(self, removedFromHierarchy, screenSystemDisabling);
+}
\ No newline at end of file
diff --git a/src/Hooks/LevelResultSoundHooks.cpp b/src/Hooks/LevelResultSoundHooks.cpp
new file mode 100644
index 0000000..3ca3a6c
--- /dev/null
+++ b/src/Hooks/LevelResultSoundHooks.cpp
@@ -0,0 +1,77 @@
+#include "hooking.hpp"
+#include "logging.hpp"
+#include "Config.hpp"
+using namespace QuestSounds;
+
+// TODO: I'd like to get rid of this header
+#include "AudioClips.hpp"
+using namespace QuestSounds::AudioClips;
+
+#include "GlobalNamespace/ResultsViewController.hpp"
+#include "GlobalNamespace/LevelCompletionResults.hpp"
+#include "GlobalNamespace/SongPreviewPlayer.hpp"
+#include "GlobalNamespace/FireworkItemController.hpp"
+using namespace GlobalNamespace;
+
+#pragma region LevelResultSound
+MAKE_AUTO_HOOK_MATCH(ResultsViewController_DidActivate, &ResultsViewController::DidActivate, void, ResultsViewController* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) {
+ if (firstActivation && addedToHierarchy && !levelClearedLoader.OriginalAudioSource) {
+ levelClearedLoader.set_OriginalClip(self->_levelClearedAudioClip);
+ }
+ if (self->_levelCompletionResults->levelEndStateType == LevelCompletionResults::LevelEndStateType::Failed) {
+ self->_songPreviewPlayer->StopAllCoroutines();
+ if (levelFailedLoader.loaded && addedToHierarchy && Config.Sounds.LevelFailed.Active) {
+ UnityEngine::AudioClip* FailedSound = levelFailedLoader.getClip();
+ float length = FailedSound->get_length();
+ getLogger().debug("Duration of LevelFailed Sound: {}", length);
+ if (length > 7.0f) {
+ getLogger().info("Long LevelFailedSound");
+ self->_songPreviewPlayer->CrossfadeTo(FailedSound, -4.0f, 0.0f, length, nullptr);
+ }
+ else {
+ getLogger().info("Short LevelFailedSound");
+ self->_songPreviewPlayer->FadeOut(0.1f);
+ self->_songPreviewPlayer->_fadeSpeed = self->_songPreviewPlayer->_fadeInSpeed;
+ getLogger().debug("volume: {}", self->_songPreviewPlayer->_volume);
+ getLogger().debug("AmbientVolume: {}", self->_songPreviewPlayer->_ambientVolumeScale);
+ getLogger().debug("Set Volume: {}", self->_songPreviewPlayer->_volume * self->_songPreviewPlayer->_ambientVolumeScale);
+
+ levelFailedLoader.audioSource->set_volume(self->_songPreviewPlayer->_volume * self->_songPreviewPlayer->_ambientVolumeScale);
+ self->_songPreviewPlayer->StartCoroutine(self->_songPreviewPlayer->CrossFadeAfterDelayCoroutine(length - 1.2f));
+ levelFailedLoader.audioSource->Play();
+ }
+ }
+ }
+ else {
+ if (levelClearedLoader.loaded && addedToHierarchy && Config.Sounds.LevelCleared.Active)
+ {
+ UnityEngine::AudioClip* audioClip = levelClearedLoader.getClip();
+ self->_levelClearedAudioClip = audioClip;
+ }
+ else {
+ self->_levelClearedAudioClip = levelClearedLoader.get_OriginalClip();
+ }
+ }
+ ResultsViewController_DidActivate(self, firstActivation, addedToHierarchy, screenSystemEnabling);
+}
+
+MAKE_AUTO_HOOK_MATCH(ResultsViewController_RestartButtonPressed, &ResultsViewController::RestartButtonPressed, void, ResultsViewController* self) {
+ if (levelFailedLoader.loaded && levelFailedLoader.audioSource->get_isPlaying()) {
+ levelFailedLoader.audioSource->Stop();
+ }
+ ResultsViewController_RestartButtonPressed(self);
+}
+#pragma endregion
+
+#pragma region FireworkSound
+// Replacing the function here, as replacing the AudioClips proves to be difficult
+MAKE_AUTO_HOOK_MATCH(FireworkItemController_PlayExplosionSound, &FireworkItemController::PlayExplosionSound, void, FireworkItemController* self) {
+ if (fireworkSoundLoader.loaded && Config.Sounds.Firework.Active) {
+ self->_audioSource->set_clip(fireworkSoundLoader.getClip());
+ float pitch = 1.2f + (((float)rand()) / (float)RAND_MAX) * (0.8f - 1.2f);
+ self->_audioSource->set_pitch(pitch);
+ self->_audioSource->Play();
+ }
+ else FireworkItemController_PlayExplosionSound(self);
+}
+#pragma endregion
\ No newline at end of file
diff --git a/src/Hooks/NoteSoundHook.cpp b/src/Hooks/NoteSoundHook.cpp
new file mode 100644
index 0000000..81aad77
--- /dev/null
+++ b/src/Hooks/NoteSoundHook.cpp
@@ -0,0 +1,95 @@
+#include "hooking.hpp"
+#include "logging.hpp"
+#include "Config.hpp"
+using namespace QuestSounds;
+
+// TODO: I'd like to get rid of this header
+#include "AudioClips.hpp"
+using namespace QuestSounds::AudioClips;
+
+#include "GlobalNamespace/NoteCutSoundEffectManager.hpp"
+#include "GlobalNamespace/NoteCutSoundEffect.hpp"
+#include "GlobalNamespace/BombCutSoundEffectManager.hpp"
+#include "GlobalNamespace/BeatmapObjectManager.hpp"
+#include "GlobalNamespace/NoteController.hpp"
+#include "GlobalNamespace/NoteData.hpp"
+#include "GlobalNamespace/PauseMenuManager.hpp"
+using namespace GlobalNamespace;
+
+
+#pragma region HitSounds
+
+MAKE_AUTO_HOOK_MATCH(NoteCutSoundEffectManager_Start, &NoteCutSoundEffectManager::Start, void, NoteCutSoundEffectManager* self) {
+ if(hitSoundLoader.loaded && Config.Sounds.HitSound.Active)
+ {
+ hitSoundArr = createAudioClipArray(hitSoundLoader);
+ self->_longCutEffectsAudioClips = hitSoundArr;
+ self->_shortCutEffectsAudioClips = hitSoundArr;
+ getLogger().debug("NoteCutSoundEffectManager_Start: Loaded hitSoundArray");
+ }
+ else {
+ getLogger().debug("NoteCutSoundEffectManager_Start: Loading normally");
+ }
+ getLogger().debug("audioSamplesBeatAlignOffset was: {}", self->_audioSamplesBeatAlignOffset);
+ if (Config.Sounds.HitSound.BeatOffset.has_value())
+ self->_audioSamplesBeatAlignOffset = Config.Sounds.HitSound.BeatOffset.value();
+ getLogger().debug("audioSamplesBeatAlignOffset changed to: {}", self->_audioSamplesBeatAlignOffset);
+ NoteCutSoundEffectManager_Start(self);
+ getLogger().debug("Beatalign offset is: {}", self->_beatAlignOffset);
+}
+
+#pragma endregion
+
+#pragma region HitSoundsAndBadHitSounds
+
+MAKE_AUTO_HOOK_MATCH(NoteCutSoundEffect_Awake, &NoteCutSoundEffect::Awake, void, NoteCutSoundEffect* self) {
+ if (hitSoundLoader.loaded && Config.Sounds.HitSound.Active) {
+ self->_goodCutVolume += Config.Sounds.HitSound.VolumeOffset.value_or(0.0f);
+ }
+
+ if(badHitSoundLoader.loaded && Config.Sounds.BadHitSound.Active)
+ {
+ badHitSoundArr = createAudioClipArray(badHitSoundLoader);
+ self->_badCutSoundEffectAudioClips = badHitSoundArr;
+ self->_badCutVolume += Config.Sounds.BadHitSound.VolumeOffset.value_or(0.0f);
+ }
+ NoteCutSoundEffect_Awake(self);
+}
+
+#pragma endregion
+
+#pragma region NoteMissedSounds
+
+MAKE_AUTO_HOOK_MATCH(BeatmapObjectManager_HandleNoteWasMissed, &BeatmapObjectManager::HandleNoteControllerNoteWasMissed, void, BeatmapObjectManager* self, NoteController* noteController) {
+ BeatmapObjectManager_HandleNoteWasMissed(self, noteController);
+ if (noteMissedSoundLoader.loaded &&
+ Config.Sounds.NoteMissedSound.Active &&
+ noteController->get_noteData()->get_scoringType() != NoteData::ScoringType::Ignore &&
+ noteController->get_noteData()->get_gameplayType() != NoteData::GameplayType::Bomb) {
+ noteMissedSoundLoader.audioSource->set_volume(0.5f + Config.Sounds.NoteMissedSound.VolumeOffset.value_or(0.0f));
+ noteMissedSoundLoader.audioSource->Play();
+ }
+}
+
+MAKE_AUTO_HOOK_MATCH(PauseMenuManager_MenuButtonPressed, &PauseMenuManager::MenuButtonPressed, void, PauseMenuManager* self) {
+ if (noteMissedSoundLoader.loaded &&
+ Config.Sounds.NoteMissedSound.Active) {
+ if (noteMissedSoundLoader.audioSource) noteMissedSoundLoader.audioSource->Stop();
+ }
+ PauseMenuManager_MenuButtonPressed(self);
+}
+
+#pragma endregion
+
+#pragma region BombHitSounds
+
+MAKE_AUTO_HOOK_MATCH(BombCutSoundEffectManager_Start, &BombCutSoundEffectManager::Start, void, BombCutSoundEffectManager* self) {
+ if (bombExplosionSoundLoader.loaded && Config.Sounds.BombExplosionSound.Active) {
+ bombExplosionSoundLoaderArr = createAudioClipArray(bombExplosionSoundLoader);
+ self->_bombExplosionAudioClips = bombExplosionSoundLoaderArr;
+ self->_volume += Config.Sounds.BombExplosionSound.VolumeOffset.value_or(0.0f);
+ }
+ BombCutSoundEffectManager_Start(self);
+}
+
+#pragma endregion
\ No newline at end of file
diff --git a/src/QSoundsConfig.cpp b/src/QSoundsConfig.cpp
deleted file mode 100644
index c4db12b..0000000
--- a/src/QSoundsConfig.cpp
+++ /dev/null
@@ -1,283 +0,0 @@
-//#include "audiocliploader.hpp"
-//#include "AsyncAudiocliploader.hpp"
-#include "QSoundsConfig.hpp"
-
-namespace QSoundsConfig {
-
- //std::string soundPath = string_format(SOUND_PATH_FORMAT, Modloader::getApplicationId().c_str());
-
- Config_t Config;
-
- bool LegacyConfig = false;
-
- void AddChildSound(ConfigValue& parent, std::string_view soundName, bool active, std::string filePath, ConfigDocument::AllocatorType& allocator)
- {
- ConfigValue value(rapidjson::kObjectType);
- value.AddMember("activated", active, allocator);
- std::string data(filePath);
- value.AddMember("filepath", data, allocator);
- parent.AddMember((ConfigValue::StringRefType)soundName.data(), value, allocator);
- }
-
-
- void AddChildSound(ConfigValue& parent, std::string_view soundName, bool active, std::string filePath, float audioVolumeOffset, ConfigDocument::AllocatorType& allocator)
- {
- ConfigValue value(rapidjson::kObjectType);
- value.AddMember("activated", active, allocator);
- std::string data(filePath);
- value.AddMember("filepath", data, allocator);
- value.AddMember("audioVolumeOffset", audioVolumeOffset, allocator);
- parent.AddMember((ConfigValue::StringRefType)soundName.data(), value, allocator);
- }
-
- void AddChildSound(ConfigValue& parent, std::string_view soundName, bool active, std::string filePath, float beatOffSet, float audioVolumeOffset, ConfigDocument::AllocatorType& allocator)
- {
- ConfigValue value(rapidjson::kObjectType);
- value.AddMember("activated", active, allocator);
- std::string data(filePath);
- value.AddMember("filepath", data, allocator);
- value.AddMember("beatOffSet", beatOffSet, allocator);
- value.AddMember("audioVolumeOffset", audioVolumeOffset, allocator);
- parent.AddMember((ConfigValue::StringRefType)soundName.data(), value, allocator);
- }
-
-
- // Edited ParseVector made by Darknight1050
- namespace Legacy {
- bool TryParseSound(bool& active, std::string& filepath, float& beatOffSet, ConfigValue& parent, std::string_view soundName)
- {
- if (!parent.HasMember(soundName.data()) || !parent[soundName.data()].IsObject()) {
- getLogger().error("ERROR: Parsing, %s, parent HasMember bool: %d, Member IsObject bool: %d", soundName.data(), parent.HasMember(soundName.data()), parent[soundName.data()].IsObject());
- return false;
- }
- ConfigValue value = static_cast(parent[soundName.data()].GetObject());
- bool success = true;
- if (value.HasMember("activated") && value["activated"].IsBool()) {
- active = value["activated"].GetBool();
- }
- else {
- getLogger().warning("WARNING: Member missing.\nWhile Parsing %s, does activated exist '%s' and is it a float '%s'",
- soundName.data(),
- value.HasMember("activated") ? "true" : "false", value.HasMember("activated") ? value["activated"].IsBool() ? "true" : "false" : "unknown");
- success = false;
- }
- if (value.HasMember("beatOffSet") && value["beatOffSet"].IsFloat()) {
- beatOffSet = value["beatOffSet"].GetFloat();
- }
- else {
- getLogger().warning("WARNING: Member missing.\nWhile Parsing %s, does beatOffSet exist '%s' and is it a float '%s'",
- soundName.data(),
- value.HasMember("beatOffSet") ? "true" : "false", value.HasMember("beatOffSet") ? value["beatOffSet"].IsFloat() ? "true" : "false" : "unknown");
- success = false;
- }
- if (!(value.HasMember("filepath") && value["filepath"].IsString())) {
- getLogger().error("ERROR: important members missing skipping sound.\nWhile Parsing: '%s', does filepath exist: '%s' is it a string: '%s'",
- soundName.data(),
- value.HasMember("filepath") ? "true" : "false", value.HasMember("filepath") ? value["filepath"].IsString() ? "true" : "false" : "unknown");
- return false;
- }
- filepath = value["filepath"].GetString();
- return success;
- }
- }
-
- bool TryParseSound(bool& active, std::string& filepath, float& beatOffSet, float& audioVolumeOffset, ConfigValue& parent, std::string_view soundName)
- {
- if (!parent.HasMember(soundName.data()) || !parent[soundName.data()].IsObject()) {
- getLogger().error("ERROR: Parsing, %s, parent HasMember bool: %d, Member IsObject bool: %d", soundName.data(), parent.HasMember(soundName.data()), parent[soundName.data()].IsObject());
- return false;
- }
- ConfigValue value = static_cast(parent[soundName.data()].GetObject());
- bool success = true;
- if (value.HasMember("activated") && value["activated"].IsBool()) {
- active = value["activated"].GetBool();
- }
- else {
- getLogger().warning("WARNING: Member missing.\nWhile Parsing %s, does activated exist '%s' and is it a float '%s'",
- soundName.data(),
- value.HasMember("activated") ? "true" : "false", value.HasMember("activated") ? value["activated"].IsBool() ? "true" : "false" : "unknown");
- success = false;
- }
- if (value.HasMember("beatOffSet") && value["beatOffSet"].IsFloat()) {
- beatOffSet = value["beatOffSet"].GetFloat();
- }
- else {
- getLogger().warning("WARNING: Member missing.\nWhile Parsing %s, does beatOffSet exist '%s' and is it a float '%s'",
- soundName.data(),
- value.HasMember("beatOffSet") ? "true" : "false", value.HasMember("beatOffSet") ? value["beatOffSet"].IsFloat() ? "true" : "false" : "unknown");
- success = false;
- }
- if (value.HasMember("audioVolumeOffset") && value["audioVolumeOffset"].IsFloat()) {
- audioVolumeOffset = value["audioVolumeOffset"].GetFloat();
- }
- else {
- getLogger().warning("WARNING: Member missing.\nWhile Parsing %s, does audioVolumeOffset exist '%s' and is it a float '%s'",
- soundName.data(),
- value.HasMember("audioVolumeOffset") ? "true" : "false", value.HasMember("audioVolumeOffset") ? value["audioVolumeOffset"].IsFloat() ? "true" : "false" : "unknown");
- success = false;
- }
- if (!(value.HasMember("filepath") && value["filepath"].IsString())) {
- getLogger().error("ERROR: important members missing skipping sound.\nWhile Parsing: '%s', does filepath exist: '%s' is it a string: '%s'",
- soundName.data(),
- value.HasMember("filepath") ? "true" : "false", value.HasMember("filepath") ? value["filepath"].IsString() ? "true" : "false" : "unknown");
- return false;
- }
- filepath = value["filepath"].GetString();
- return success;
- }
-
- bool TryParseSound(bool& active, std::string& filepath, float& audioVolumeOffset, ConfigValue& parent, std::string_view soundName)
- {
- if (!parent.HasMember(soundName.data()) || !parent[soundName.data()].IsObject()) {
- getLogger().error("ERROR: Parsing, %s, parent HasMember bool: %d, Member IsObject bool: %d", soundName.data(), parent.HasMember(soundName.data()), parent[soundName.data()].IsObject());
- return false;
- }
- ConfigValue value = static_cast(parent[soundName.data()].GetObject());
- bool success = true;
- if (value.HasMember("activated") && value["activated"].IsBool()) {
- active = value["activated"].GetBool();
- }
- else {
- getLogger().warning("WARNING: Member missing.\nWhile Parsing %s, does activated exist '%s' and is it a bool '%s'",
- soundName.data(),
- value.HasMember("activated") ? "true" : "false", value.HasMember("activated") ? value["activated"].IsBool() ? "true" : "false" : "unknown");
- success = false;
- }
- if (value.HasMember("audioVolumeOffset") && value["audioVolumeOffset"].IsFloat()) {
- audioVolumeOffset = value["audioVolumeOffset"].GetFloat();
- }
- else {
- getLogger().warning("WARNING: Member missing.\nWhile Parsing %s, does audioVolumeOffset exist '%s' and is it a float '%s'",
- soundName.data(),
- value.HasMember("audioVolumeOffset") ? "true" : "false", value.HasMember("audioVolumeOffset") ? value["audioVolumeOffset"].IsFloat() ? "true" : "false" : "unknown");
- success = false;
- }
- if (!(value.HasMember("filepath") && value["filepath"].IsString())) {
- getLogger().error("ERROR: important members missing skipping sound.\nWhile Parsing: '%s', does filepath exist: '%s' is it a string: '%s'",
- soundName.data(),
- value.HasMember("filepath") ? "true" : "false", value.HasMember("filepath") ? value["filepath"].IsString() ? "true" : "false" : "unknown");
- return false;
- }
- filepath = value["filepath"].GetString();
- return success;
- }
-
- bool TryParseSound(bool& active, std::string& filepath, ConfigValue& parent, std::string_view soundName)
- {
- if (!parent.HasMember(soundName.data()) || !parent[soundName.data()].IsObject()) {
- getLogger().error("ERROR: Parsing, %s, parent HasMember bool: %d, Member IsObject bool: %d", soundName.data(), parent.HasMember(soundName.data()), parent[soundName.data()].IsObject());
- return false;
- }
- ConfigValue value = static_cast(parent[soundName.data()].GetObject());
- bool success = true;
- if (value.HasMember("activated") && value["activated"].IsBool()) {
- active = value["activated"].GetBool();
- }
- else {
- getLogger().warning("WARNING: Member missing.\nWhile Parsing %s, does activated exist '%s' and is it a bool '%s'",
- soundName.data(),
- value.HasMember("activated") ? "true" : "false", value.HasMember("activated") ? value["activated"].IsBool() ? "true" : "false" : "unknown");
- success = false;
- }
- if (!(value.HasMember("filepath") && value["filepath"].IsString())) {
- getLogger().error("ERROR: important members missing skipping sound.\nWhile Parsing: '%s', does filepath exist: '%s' is it a string: '%s'",
- soundName.data(),
- value.HasMember("filepath") ? "true" : "false", value.HasMember("filepath") ? value["filepath"].IsString() ? "true" : "false" : "unknown");
- return false;
- }
- filepath = value["filepath"].GetString();
- return success;
- }
-
-
- void SaveConfig()
- {
- getLogger().debug("Save config run");
- getConfig().config.RemoveAllMembers();
- getConfig().config.SetObject();
- auto& allocator = getConfig().config.GetAllocator();
-
- ConfigValue soundsValue(rapidjson::kObjectType);
- AddChildSound(soundsValue, "HitSound", Config.hitSound_Active, Config.hitSound_filepath , Config.hitSound_beatOffSet, Config.hitSound_audioVolumeOffset, allocator);
- AddChildSound(soundsValue, "BadHitSound", Config.badHitSound_Active, Config.badHitSound_filepath, Config.badHitSound_audioVolumeOffset, allocator);
- AddChildSound(soundsValue, "NoteMissedSound", Config.noteMissedSound_Active, Config.noteMissedSound_filepath, Config.noteMissedSound_audioVolumeOffset, allocator);
- AddChildSound(soundsValue, "MenuMusic", Config.menuMusic_Active, Config.menuMusic_filepath, allocator);
- AddChildSound(soundsValue, "MenuClick", Config.menuClick_Active, Config.menuClick_filepath, allocator);
- AddChildSound(soundsValue, "Firework", Config.firework_Active, Config.firework_filepath, allocator);
- AddChildSound(soundsValue, "LevelCleared", Config.levelCleared_Active, Config.levelCleared_filepath, allocator);
- AddChildSound(soundsValue, "LevelFailed", Config.levelFailed_Active, Config.levelFailed_filepath, Config.levelFailed_audioVolumeOffset, allocator);
- AddChildSound(soundsValue, "LobbyMusic", Config.lobbyAmbience_Active, Config.lobbyAmbience_filepath, allocator);
- getConfig().config.AddMember(CONFIG_VERSION, soundsValue, allocator);
- getConfig().Write();
- LegacyConfig = false;
- }
-
- bool LoadConfig()
- {
- getConfig().Load();
-
- bool parseError = false;
- getLogger().debug("PreCheck: parseError currentValue: %d will be returned as: %d", parseError, !parseError);
- if (getConfig().config.HasMember(CONFIG_VERSION) && getConfig().config[CONFIG_VERSION].IsObject())
- {
- ConfigValue soundsValue = static_cast(getConfig().config[CONFIG_VERSION].GetObject());
- parseError |= !TryParseSound(Config.hitSound_Active, Config.hitSound_filepath, Config.hitSound_beatOffSet, Config.hitSound_audioVolumeOffset, soundsValue, "HitSound");
- parseError |= !TryParseSound(Config.badHitSound_Active, Config.badHitSound_filepath, Config.badHitSound_audioVolumeOffset, soundsValue, "BadHitSound");
- parseError |= !TryParseSound(Config.noteMissedSound_Active, Config.noteMissedSound_filepath, Config.noteMissedSound_audioVolumeOffset, soundsValue, "NoteMissedSound");
- parseError |= !TryParseSound(Config.menuMusic_Active, Config.menuMusic_filepath, soundsValue, "MenuMusic");
- parseError |= !TryParseSound(Config.menuClick_Active, Config.menuClick_filepath, soundsValue, "MenuClick");
- parseError |= !TryParseSound(Config.firework_Active, Config.firework_filepath, soundsValue, "Firework");
- parseError |= !TryParseSound(Config.levelCleared_Active, Config.levelCleared_filepath, soundsValue, "LevelCleared");
- parseError |= !TryParseSound(Config.levelFailed_Active, Config.levelFailed_filepath, Config.levelFailed_audioVolumeOffset, soundsValue, "LevelFailed");
- parseError |= !TryParseSound(Config.lobbyAmbience_Active, Config.lobbyAmbience_filepath, soundsValue, "LobbyMusic");
- getLogger().debug("PostCheck: parseError currentValue: %d will be returned as: %d", parseError, !parseError);
- getLogger().debug("Config Loaded OK");
- return !parseError;
- }
- else if (getConfig().config.HasMember(CONFIG_VERSION_PRE_1_20) && getConfig().config[CONFIG_VERSION_PRE_1_20].IsObject())
- {
- ConfigValue soundsValue = static_cast(getConfig().config[CONFIG_VERSION_PRE_1_20].GetObject());
- parseError |= !Legacy::TryParseSound(Config.hitSound_Active, Config.hitSound_filepath, Config.hitSound_beatOffSet, soundsValue, "HitSound");
- parseError |= !TryParseSound(Config.badHitSound_Active, Config.badHitSound_filepath, soundsValue, "BadHitSound");
- parseError |= !TryParseSound(Config.menuMusic_Active, Config.menuMusic_filepath, soundsValue, "MenuMusic");
- parseError |= !TryParseSound(Config.menuClick_Active, Config.menuClick_filepath, soundsValue, "MenuClick");
- parseError |= !TryParseSound(Config.firework_Active, Config.firework_filepath, soundsValue, "Firework");
- parseError |= !TryParseSound(Config.levelCleared_Active, Config.levelCleared_filepath, soundsValue, "LevelCleared");
- parseError |= !TryParseSound(Config.levelFailed_Active, Config.levelFailed_filepath, soundsValue, "LevelFailed");
- parseError |= !TryParseSound(Config.lobbyAmbience_Active, Config.lobbyAmbience_filepath, soundsValue, "LobbyMusic");
- }
- else if (getConfig().config.HasMember(CONFIG_VERSION_LEGACY) && getConfig().config[CONFIG_VERSION_LEGACY].IsObject()) {
- ConfigValue soundsValue = static_cast(getConfig().config[CONFIG_VERSION_LEGACY].GetObject());
- parseError |= !TryParseSound(Config.hitSound_Active, Config.hitSound_filepath, soundsValue, "HitSound");
- parseError |= !TryParseSound(Config.badHitSound_Active, Config.badHitSound_filepath, soundsValue, "BadHitSound");
- parseError |= !TryParseSound(Config.menuMusic_Active, Config.menuMusic_filepath, soundsValue, "MenuMusic");
- parseError |= !TryParseSound(Config.menuClick_Active, Config.menuClick_filepath, soundsValue, "MenuClick");
- parseError |= !TryParseSound(Config.firework_Active, Config.firework_filepath, soundsValue, "Firework");
- parseError |= !TryParseSound(Config.levelCleared_Active, Config.levelCleared_filepath, soundsValue, "LevelCleared");
- LegacyConfig = true;
- }
- else if (getConfig().config.HasMember(CONFIG_VERSION_PRE_R) && getConfig().config[CONFIG_VERSION_PRE_R].IsObject()) {
- ConfigValue soundsValue = static_cast(getConfig().config[CONFIG_VERSION_PRE_R].GetObject());
- parseError |= !TryParseSound(Config.hitSound_Active, Config.hitSound_filepath, soundsValue, "HitSound");
- parseError |= !TryParseSound(Config.badHitSound_Active, Config.badHitSound_filepath, soundsValue, "BadHitSound");
- parseError |= !TryParseSound(Config.menuMusic_Active, Config.menuMusic_filepath, soundsValue, "MenuMusic");
- parseError |= !TryParseSound(Config.menuClick_Active, Config.menuClick_filepath, soundsValue, "MenuClick");
- parseError |= !TryParseSound(Config.firework_Active, Config.firework_filepath, soundsValue, "Firework");
- parseError |= !TryParseSound(Config.levelCleared_Active, Config.levelCleared_filepath, soundsValue, "LevelCleared");
- parseError |= !TryParseSound(Config.lobbyAmbience_Active, Config.lobbyAmbience_filepath, soundsValue, "LobbyMusic");
- LegacyConfig = true;
- }
- else {
- getLogger().debug("Config Mismatch");
- return false;
- }
- if (!parseError) {
- getLogger().debug("Config Loaded OK");
- }
- else {
- getLogger().debug("Config Loaded with errors");
- }
- getLogger().debug("PostCheck: parseError currentValue: %d will be returned as: %d", parseError, !parseError);
- return !parseError;
- }
-}
\ No newline at end of file
diff --git a/src/UI/ConfigMenuSelectionViewController.cpp b/src/UI/ConfigMenuSelectionViewController.cpp
new file mode 100644
index 0000000..74dd7ff
--- /dev/null
+++ b/src/UI/ConfigMenuSelectionViewController.cpp
@@ -0,0 +1,99 @@
+#include "UI/ConfigMenuSelectionViewController.hpp"
+#include "assets.hpp"
+#include "logging.hpp"
+
+#include "bsml/shared/BSML.hpp"
+
+DEFINE_TYPE(QuestSounds::UI, ConfigMenuSelectionViewController);
+
+namespace QuestSounds::UI {
+ void ConfigMenuSelectionViewController::ctor() {
+ // _menus = ListW();
+ getLogger().info("ctor");
+ return;
+ }
+
+ void ConfigMenuSelectionViewController::DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) {
+ getLogger().info("DidActivate");
+ if (firstActivation) {
+ getLogger().info("DidActivate firstActivation");
+ BSML::parse_and_construct(Assets::ConfigMenuSelectionViewController_bsml, get_transform(), this);
+ }
+ return;
+ }
+
+ void ConfigMenuSelectionViewController::set_selectCallback(std::function callback) {
+ getLogger().info("Setting selectCallback");
+ this->callback = callback;
+ }
+
+ void ConfigMenuSelectionViewController::MenuMusicButtonPressed() {
+ getLogger().info("MenuMusicButtonPressed");
+ if (callback) {
+ callback(0);
+ }
+ }
+
+ void ConfigMenuSelectionViewController::LobbyMusicButtonPressed() {
+ getLogger().info("LobbyMusicButtonPressed");
+ if (callback) {
+ callback(1);
+ }
+ }
+
+ void ConfigMenuSelectionViewController::MenuClickButtonPressed() {
+ getLogger().info("MenuClickButtonPressed");
+ if (callback) {
+ callback(2);
+ }
+ }
+
+ void ConfigMenuSelectionViewController::HitSoundButtonPressed() {
+ getLogger().info("HitSoundButtonPressed");
+ if (callback) {
+ callback(3);
+ }
+ }
+
+ void ConfigMenuSelectionViewController::BadHitSoundButtonPressed() {
+ getLogger().info("BadHitSoundButtonPressed");
+ if (callback) {
+ callback(4);
+ }
+ }
+
+ void ConfigMenuSelectionViewController::MissSoundButtonPressed() {
+ getLogger().info("MissSoundButtonPressed");
+ if (callback) {
+ callback(5);
+ }
+ }
+
+ void ConfigMenuSelectionViewController::LevelClearedButtonPressed() {
+ getLogger().info("LevelClearedButtonPressed");
+ if (callback) {
+ callback(6);
+ }
+ }
+
+ void ConfigMenuSelectionViewController::LevelFailedButtonPressed() {
+ getLogger().info("LevelFailedButtonPressed");
+ if (callback) {
+ callback(7);
+ }
+ }
+
+ void ConfigMenuSelectionViewController::FireworkButtonPressed() {
+ getLogger().info("FireworkButtonPressed");
+ if (callback) {
+ callback(8);
+ }
+ }
+
+ void ConfigMenuSelectionViewController::BombExplosionSoundButtonPressed() {
+ getLogger().info("BombExplosionSoundButtonPressed");
+ if (callback) {
+ callback(9);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/UI/CustomSoundFileCell.cpp b/src/UI/CustomSoundFileCell.cpp
new file mode 100644
index 0000000..156b1d9
--- /dev/null
+++ b/src/UI/CustomSoundFileCell.cpp
@@ -0,0 +1,17 @@
+#include "UI/CustomSoundFileCell.hpp"
+
+DEFINE_TYPE(QuestSounds::UI, CustomSoundFileCell);
+
+namespace QuestSounds::UI {
+ CustomSoundFileCell* CustomSoundFileCell::construct(StringW text, StringW subText, std::filesystem::path filePath, UnityEngine::Sprite* icon) {
+ CustomSoundFileCell* cell = CustomSoundFileCell::New_ctor();
+ cell->FilePath = filePath;
+ cell->text = text;
+ cell->subText = subText;
+ return cell;
+ }
+
+ CustomSoundFileCell* CustomSoundFileCell::construct(StringW text, std::filesystem::path filePath, UnityEngine::Sprite* icon) {
+ return CustomSoundFileCell::construct(text, StringW(), filePath, icon);
+ }
+}
\ No newline at end of file
diff --git a/src/UI/QSoundsFlowCoordinator.cpp b/src/UI/QSoundsFlowCoordinator.cpp
deleted file mode 100644
index 5d318aa..0000000
--- a/src/UI/QSoundsFlowCoordinator.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-#include "main.hpp"
-#include "QSoundsFlowCoordinator.hpp"
-#include "ViewControllers/MenuSdListViewController.hpp"
-#include "ViewControllers/HitSdListViewController.hpp"
-#include "ViewControllers/MenuClickSdListViewController.hpp"
-#include "ViewControllers/BadHitSdListViewController.hpp"
-#include "ViewControllers/NoteMissedSdListViewController.hpp"
-#include "ViewControllers/FireworkSdListViewController.hpp"
-#include "ViewControllers/LevelClearedSdListViewController.hpp"
-#include "ViewControllers/LevelFailedSdListViewController.hpp"
-#ifndef BS__1_13_2
-#include "ViewControllers/LobbyMusicSdListViewController.hpp"
-#endif
-#include "ViewControllers/ConfigViewController.hpp"
-#include "QSoundsConfig.hpp"
-//#include "audiocliploader.hpp"
-#include "AudioClips.hpp"
-#include "ObjectInstances.hpp"
-
-#include "questui/shared/BeatSaberUI.hpp"
-#include "questui/shared/QuestUI.hpp"
-
-#include "HMUI/ViewController.hpp"
-#include "HMUI/ViewController_AnimationType.hpp"
-#include "HMUI/ViewController_AnimationDirection.hpp"
-#include "HMUI/FlowCoordinator.hpp"
-using namespace QuestSounds;
-using namespace QuestSounds::ViewControllers;
-
-#ifndef REGISTER_FUNCTION
-DEFINE_TYPE(QuestSounds, QSoundsFlowCoordinator);
-#elif defined(DEFINE_TYPE)
-DEFINE_TYPE(QSoundsFlowCoordinator);
-#elif defined(DEFINE_CLASS)
-DEFINE_CLASS(QSoundsFlowCoordinator);
-#else
-#error Unsupported Custom-Types version!
-#endif
-
-//void FindViewControllers(QuestSounds::QSoundsFlowCoordinator* self)
-//{
-// //self->QSMenuSoundListView = UnityUtils::GetFirstObjectOfType();
-//
-// //self->QSHitSoundListView = UnityUtils::GetFirstObjectOfType();
-//
-// //self->WallSwitcherViewController = UnityUtils::GetFirstObjectOfType();
-//
-// //self->QosmeticsViewController = UnityUtils::GetFirstObjectOfType();
-//}
-
-int CurrentActive;
-
-void QSoundsFlowCoordinator::DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
-{
- CurrentActive = 1;
- if (firstActivation)
- {
- this->SetTitle(il2cpp_utils::newcsstr("QuestSounds MenuMusic"), HMUI::ViewController::AnimationDirection::Vertical);
- this->showBackButton = true;
-
- if (!this->QSConfigView) this->QSConfigView = QuestUI::BeatSaberUI::CreateViewController();
- if (!this->QSMenuSoundListView) this->QSMenuSoundListView = QuestUI::BeatSaberUI::CreateViewController();
- if (!this->QSHitSoundListView) this->QSHitSoundListView = QuestUI::BeatSaberUI::CreateViewController();
- if (!this->QSBadHitSoundListView) this->QSBadHitSoundListView = QuestUI::BeatSaberUI::CreateViewController();
- if (!this->QSNoteMissedSoundListView) this->QSNoteMissedSoundListView = QuestUI::BeatSaberUI::CreateViewController();
- if (!this->QSMenuClickSoundListView) this->QSMenuClickSoundListView = QuestUI::BeatSaberUI::CreateViewController();
- if (!this->QSFireworkSoundListView) this->QSFireworkSoundListView = QuestUI::BeatSaberUI::CreateViewController();
- if (!this->QSLevelClearedSoundListView) this->QSLevelClearedSoundListView = QuestUI::BeatSaberUI::CreateViewController();
- if (!this->QSLevelFailedSoundListView) this->QSLevelFailedSoundListView = QuestUI::BeatSaberUI::CreateViewController();
-#ifndef BS__1_13_2
- if (!this->QSLobbyMusicSoundListView) this->QSLobbyMusicSoundListView = QuestUI::BeatSaberUI::CreateViewController();
-#endif
-
- QSConfigViewController = reinterpret_cast(QSConfigView);
-
- std::function func = std::bind(&QSoundsFlowCoordinator::SubMenuButtonWasPressed, this, std::placeholders::_1);
- QSConfigViewController->set_selectCallback(func);
-
- QSoundsFlowCoordinator::ProvideInitialViewControllers(QSMenuSoundListView, QSConfigViewController, nullptr, nullptr, nullptr);
- }
-}
-
-void QSoundsFlowCoordinator::SubMenuButtonWasPressed(int VCtype) {
- if (!VCtype) return;
- //FindViewControllers(self);
- if (CurrentActive == VCtype) return;
- switch (VCtype)
- {
- case 1:
- if (!this->QSMenuSoundListView) this->QSMenuSoundListView = QuestUI::BeatSaberUI::CreateViewController();
- if (!this->QSMenuSoundListView) break;
- this->SetTitle("Menu Music", HMUI::ViewController::AnimationType::In);
- this->ReplaceTopViewController(this->QSMenuSoundListView, this, this, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
- CurrentActive = VCtype;
- break;
- case 2:
- if (!this->QSHitSoundListView) this->QSHitSoundListView = QuestUI::BeatSaberUI::CreateViewController();
- if (!this->QSHitSoundListView) break;
- this->SetTitle("Hit Sounds", HMUI::ViewController::AnimationType::In);
- this->ReplaceTopViewController(this->QSHitSoundListView, this, this, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
- CurrentActive = VCtype;
- break;
- case 3:
- if (!this->QSMenuClickSoundListView) this->QSMenuClickSoundListView = QuestUI::BeatSaberUI::CreateViewController();
- if (!this->QSMenuClickSoundListView || this->providedMainViewController == this->QSMenuClickSoundListView) break;
- this->SetTitle("Menu Clicks", HMUI::ViewController::AnimationType::In);
- this->ReplaceTopViewController(this->QSMenuClickSoundListView, this, this, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
- CurrentActive = VCtype;
- break;
- case 4:
- if (!this->QSBadHitSoundListView) this->QSBadHitSoundListView = QuestUI::BeatSaberUI::CreateViewController();
- if (!this->QSBadHitSoundListView || this->providedMainViewController == this->QSBadHitSoundListView) break;
- this->SetTitle("Bad Hit Sounds", HMUI::ViewController::AnimationType::In);
- this->ReplaceTopViewController(this->QSBadHitSoundListView, this, this, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
- CurrentActive = VCtype;
- break;
- case 5:
- if (!this->QSNoteMissedSoundListView) this->QSNoteMissedSoundListView = QuestUI::BeatSaberUI::CreateViewController();
- if (!this->QSNoteMissedSoundListView || this->providedMainViewController == this->QSNoteMissedSoundListView) break;
- this->SetTitle("Note Missed Sounds", HMUI::ViewController::AnimationType::In);
- this->ReplaceTopViewController(this->QSNoteMissedSoundListView, this, this, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
- CurrentActive = VCtype;
- break;
- case 6:
- if (!this->QSFireworkSoundListView) this->QSFireworkSoundListView = QuestUI::BeatSaberUI::CreateViewController();
- if (!this->QSFireworkSoundListView || this->providedMainViewController == this->QSFireworkSoundListView) break;
- this->SetTitle("Firework Sounds", HMUI::ViewController::AnimationType::In);
- this->ReplaceTopViewController(this->QSFireworkSoundListView, this, this, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
- CurrentActive = VCtype;
- break;
- case 7:
- if (!this->QSLevelClearedSoundListView) this->QSLevelClearedSoundListView = QuestUI::BeatSaberUI::CreateViewController();
- if (!this->QSLevelClearedSoundListView || this->providedMainViewController == this->QSLevelClearedSoundListView) break;
- this->SetTitle("Level Cleared Sounds", HMUI::ViewController::AnimationType::In);
- this->ReplaceTopViewController(this->QSLevelClearedSoundListView, this, this, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
- CurrentActive = VCtype;
- break;
- case 8:
- if (!this->QSLevelFailedSoundListView) this->QSLevelFailedSoundListView = QuestUI::BeatSaberUI::CreateViewController();
- if (!this->QSLevelFailedSoundListView || this->providedMainViewController == this->QSLevelFailedSoundListView) break;
- this->SetTitle("Level Failed Sounds", HMUI::ViewController::AnimationType::In);
- this->ReplaceTopViewController(this->QSLevelFailedSoundListView, this, this, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
- CurrentActive = VCtype;
- break;
-#ifndef BS__1_13_2
- case 9:
- if (!this->QSLobbyMusicSoundListView) this->QSLobbyMusicSoundListView = QuestUI::BeatSaberUI::CreateViewController();
- if (!this->QSLobbyMusicSoundListView || this->providedMainViewController == this->QSLobbyMusicSoundListView) break;
- this->SetTitle("LobbyMusic", HMUI::ViewController::AnimationType::In);
- this->ReplaceTopViewController(this->QSLobbyMusicSoundListView, this, this, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
- CurrentActive = VCtype;
- break;
-#endif
- default:
- getLogger().debug("switch default");
- break;
- }
-}
-
-
-void QSoundsFlowCoordinator::BackButtonWasPressed(HMUI::ViewController* topView)
-{
- QSoundsConfig::SaveConfig();
- //QuestSounds::AudioClips::loadAudioClips();
- this->parentFlowCoordinator->DismissFlowCoordinator(this, HMUI::ViewController::AnimationDirection::Horizontal, nullptr, false);
-}
\ No newline at end of file
diff --git a/src/UI/QuestSoundsFlowCoordinator.cpp b/src/UI/QuestSoundsFlowCoordinator.cpp
new file mode 100644
index 0000000..b9b9e9d
--- /dev/null
+++ b/src/UI/QuestSoundsFlowCoordinator.cpp
@@ -0,0 +1,147 @@
+#include "UI/QuestSoundsFlowCoordinator.hpp"
+#include "Config.hpp"
+#include "logging.hpp"
+#include "AudioClips.hpp"
+
+#include "ObjectInstances.hpp"
+
+#include "GlobalNamespace/RandomObjectPicker_1.hpp"
+
+#include "bsml/shared/Helpers/creation.hpp"
+
+DEFINE_TYPE(QuestSounds::UI, QuestSoundsFlowCoordinator);
+
+namespace QuestSounds::UI {
+ void QuestSoundsFlowCoordinator::Awake() {
+ getLogger().info("Awake");
+ if (!configMenuSelectionViewController) {
+ getLogger().info("Awake ViewController null, Creating ConfigMenuSelectionViewController");
+ configMenuSelectionViewController = BSML::Helpers::CreateViewController();
+ configMenuSelectionViewController->set_selectCallback(std::bind(&QuestSoundsFlowCoordinator::SubMenuButtonPressed, this, std::placeholders::_1));
+ }
+
+ if (!soundSettingsViewController) {
+ getLogger().info("Awake ViewController null, Creating SoundSettingsViewController");
+ soundSettingsViewController = BSML::Helpers::CreateViewController();
+ // TODO: Implement iteration through all sounds in the Config and switching between them also possible use some sort of safeptr for the config and loader
+ // Testing using HitSounds for now
+ // soundSettingsViewController->Setup("HitSound", &QuestSounds::Config.Sounds.HitSound, &QuestSounds::AudioClips::hitSoundLoader);
+ }
+ }
+
+ void QuestSoundsFlowCoordinator::DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) {
+ getLogger().info("DidActivate");
+ if (firstActivation) {
+ ProvideInitialViewControllers(soundSettingsViewController, configMenuSelectionViewController, nullptr, nullptr, nullptr);
+ }
+ SetTitle("QuestSounds", HMUI::ViewController::AnimationType::In);
+ showBackButton = true;
+
+ // Disable BGM Music
+ if (QuestSounds::ObjectInstances::SPP)
+ QuestSounds::ObjectInstances::SPP->PauseCurrentChannel();
+ }
+
+ void QuestSoundsFlowCoordinator::DidDeactivate(bool removedFromHierarchy, bool screenSystemDisabling) {
+ getLogger().info("DidDeactivate");
+ if (QuestSounds::ObjectInstances::SPP)
+ QuestSounds::ObjectInstances::SPP->UnPauseCurrentChannel();
+
+ WriteToFile(QuestSounds::GetConfigPath(), QuestSounds::Config, true);
+ }
+
+ void QuestSoundsFlowCoordinator::BackButtonWasPressed(HMUI::ViewController* topViewController) {
+ getLogger().info("BackButtonWasPressed");
+ _parentFlowCoordinator->DismissFlowCoordinator(this, HMUI::ViewController::AnimationDirection::Horizontal, nullptr, false);
+ // Ensure MenuMusic is playing after leaving the settings menu, for some reason it breaks with .ogg files when we pause the channel
+ if (QuestSounds::ObjectInstances::SPP && QuestSounds::Config.Sounds.MenuMusic.Active && QuestSounds::AudioClips::menuMusicLoader.loaded) {
+ QuestSounds::ObjectInstances::SPP->CrossfadeToNewDefault(QuestSounds::AudioClips::menuMusicLoader.getClip());
+ } else if (QuestSounds::ObjectInstances::SPP) {
+ QuestSounds::ObjectInstances::SPP->CrossfadeToNewDefault(QuestSounds::AudioClips::menuMusicLoader.get_OriginalClip());
+ }
+ }
+
+ void QuestSoundsFlowCoordinator::SubMenuButtonPressed(int index) {
+ getLogger().info("SubMenuButtonPressed");
+ getLogger().info("Index: {}", index);
+
+ switch (index) {
+ case 0:
+ getLogger().info("MenuMusicButtonPressed");
+ soundSettingsViewController->Setup("MenuMusic", &QuestSounds::Config.Sounds.MenuMusic, &QuestSounds::AudioClips::menuMusicLoader);
+ SetTitle("Menu Music", HMUI::ViewController::AnimationType::In);
+ // ReplaceTopViewController(soundSettingsViewController, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
+ break;
+ case 1:
+ getLogger().info("LobbyMusicButtonPressed");
+ soundSettingsViewController->Setup("LobbyMusic", &QuestSounds::Config.Sounds.LobbyMusic, &QuestSounds::AudioClips::lobbyAmbienceLoader);
+ SetTitle("Lobby Music", HMUI::ViewController::AnimationType::In);
+ // ReplaceTopViewController(soundSettingsViewController, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
+ break;
+ case 2:
+ getLogger().info("MenuClickButtonPressed");
+ soundSettingsViewController->Setup("MenuClicks", &QuestSounds::Config.Sounds.MenuClick, &QuestSounds::AudioClips::menuClickLoader, std::function(
+ [this]() {
+ if (QuestSounds::ObjectInstances::BUIAM && QuestSounds::Config.Sounds.MenuClick.Active) {
+ QuestSounds::AudioClips::menuClickArr = QuestSounds::AudioClips::createAudioClipArray(QuestSounds::AudioClips::menuClickLoader);
+ QuestSounds::ObjectInstances::BUIAM->_randomSoundPicker->_objects = QuestSounds::AudioClips::menuClickArr;
+ } else if (QuestSounds::ObjectInstances::BUIAM) {
+ QuestSounds::ObjectInstances::BUIAM->_randomSoundPicker->_objects = QuestSounds::AudioClips::origMenuClickArr;
+ }
+ else
+ getLogger().error("BUIAM is null");
+ }
+ ));
+ SetTitle("Menu Clicks", HMUI::ViewController::AnimationType::In);
+ // ReplaceTopViewController(soundSettingsViewController, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
+ break;
+ case 3:
+ getLogger().info("HitSoundButtonPressed");
+ soundSettingsViewController->Setup("HitSounds", &QuestSounds::Config.Sounds.HitSound, &QuestSounds::AudioClips::hitSoundLoader);
+ SetTitle("Hit Sounds", HMUI::ViewController::AnimationType::In);
+ // ReplaceTopViewController(soundSettingsViewController, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
+ break;
+ case 4:
+ getLogger().info("BadHitSoundButtonPressed");
+ soundSettingsViewController->Setup("BadHitSounds", &QuestSounds::Config.Sounds.BadHitSound, &QuestSounds::AudioClips::badHitSoundLoader);
+ SetTitle("Bad Hit Sounds", HMUI::ViewController::AnimationType::In);
+ // ReplaceTopViewController(soundSettingsViewController, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
+ break;
+ case 5:
+ getLogger().info("MissSoundButtonPressed");
+ soundSettingsViewController->Setup("NoteMissedSound", &QuestSounds::Config.Sounds.NoteMissedSound, &QuestSounds::AudioClips::noteMissedSoundLoader);
+ SetTitle("Note Miss Sound", HMUI::ViewController::AnimationType::In);
+ // ReplaceTopViewController(soundSettingsViewController, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
+ break;
+ case 6:
+ getLogger().info("LevelClearedButtonPressed");
+ soundSettingsViewController->Setup("LevelCleared", &QuestSounds::Config.Sounds.LevelCleared, &QuestSounds::AudioClips::levelClearedLoader);
+ SetTitle("Level Cleared", HMUI::ViewController::AnimationType::In);
+ // ReplaceTopViewController(soundSettingsViewController, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
+ break;
+ case 7:
+ getLogger().info("LevelFailedButtonPressed");
+ soundSettingsViewController->Setup("LevelFailed", &QuestSounds::Config.Sounds.LevelFailed, &QuestSounds::AudioClips::levelFailedLoader);
+ SetTitle("Level Failed", HMUI::ViewController::AnimationType::In);
+ // ReplaceTopViewController(soundSettingsViewController, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
+ break;
+ case 8:
+ getLogger().info("FireworkButtonPressed");
+ soundSettingsViewController->Setup("Firework", &QuestSounds::Config.Sounds.Firework, &QuestSounds::AudioClips::fireworkSoundLoader);
+ SetTitle("Firework", HMUI::ViewController::AnimationType::In);
+ // ReplaceTopViewController(soundSettingsViewController, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
+ break;
+ case 9:
+ getLogger().info("BombExplosionSoundButtonPressed");
+ soundSettingsViewController->Setup("BombExplosionSounds", &QuestSounds::Config.Sounds.BombExplosionSound, &QuestSounds::AudioClips::bombExplosionSoundLoader);
+ SetTitle("Bomb Explosion Sound", HMUI::ViewController::AnimationType::In);
+ // ReplaceTopViewController(soundSettingsViewController, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
+ break;
+ default:
+ getLogger().error("Invalid index");
+ SetTitle("QuestSounds", HMUI::ViewController::AnimationType::In);
+ // ReplaceTopViewController(soundSettingsViewController, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
+ break;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/UI/SoundSettingsViewController.cpp b/src/UI/SoundSettingsViewController.cpp
new file mode 100644
index 0000000..0c0e0f2
--- /dev/null
+++ b/src/UI/SoundSettingsViewController.cpp
@@ -0,0 +1,233 @@
+#include "UI/SoundSettingsViewController.hpp"
+#include "UI/QuestSoundsFlowCoordinator.hpp"
+#include "logging.hpp"
+#include "assets.hpp"
+
+#include "bsml/shared/BSML.hpp"
+#include "bsml/shared/BSML-Lite.hpp"
+
+#include "UnityEngine/WaitForSeconds.hpp"
+
+#include
+
+DEFINE_TYPE(QuestSounds::UI, SoundSettingsViewController);
+
+namespace QuestSounds::UI {
+ void SoundSettingsViewController::ctor() {
+ _Sounds = ListW::New();
+ getLogger().info("ctor");
+ }
+
+ void SoundSettingsViewController::DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) {
+ if (firstActivation) {
+ getLogger().info("DidActivate firstActivation");
+ BSML::parse_and_construct(Assets::SoundSettingsViewController_bsml, get_transform(), this);
+ }
+ if (SoundEnabled) {
+ SoundEnabled->set_Value(Sound->Active);
+ }
+ if (SoundVolumeOffset) {
+ getLogger().info("DidActivate SoundVolumeOffset");
+ SoundVolumeOffset->gameObject->SetActive(showSoundVolumeOffset);
+ if (showSoundVolumeOffset)
+ SoundVolumeOffset->set_Value(Sound->VolumeOffset.value());
+ }
+ if (SoundBeatOffset) {
+ getLogger().info("DidActivate SoundBeatOffset");
+ SoundBeatOffset->gameObject->SetActive(showSoundBeatOffset);
+ if (showSoundBeatOffset)
+ SoundBeatOffset->set_Value(Sound->BeatOffset.value());
+ }
+
+ if (_Sounds->Count <= 0)
+ {
+ getLogger().info("No sound files found for sound: '{}'", name);
+ // set_HasSoundFiles(false);
+ if (NoSoundsFoundHorizontal) NoSoundsFoundHorizontal->gameObject->SetActive(true);
+ if (SoundList) SoundList->gameObject->SetActive(false);
+ }
+ else
+ {
+ getLogger().info("Sound files found for sound: '{}'", name);
+ // set_HasSoundFiles(true);
+ if (NoSoundsFoundHorizontal) NoSoundsFoundHorizontal->gameObject->SetActive(false);
+ if (SoundList) {
+ SoundList->gameObject->SetActive(true);
+ SoundList->tableView->ReloadData();
+ for (int i = 0; i < _Sounds->Count; i++) {
+ auto cell = il2cpp_utils::cast(_Sounds[i]);
+ if (cell->FilePath == Sound->FilePath) {
+ SoundList->tableView->SelectCellWithIdx(i, false);
+ break;
+ }
+ }
+ }
+ }
+ getLogger().info("DidActivate");
+ }
+
+ void SoundSettingsViewController::DidDeactivate(bool removedFromHierarchy, bool screenSystemDisabling) {
+ getLogger().info("DidDeactivate");
+
+ if (Loader && Loader->audioSource && Loader->audioSource->isPlaying) {
+ Loader->audioSource->Stop();
+ }
+ }
+
+ void SoundSettingsViewController::Setup(std::string name, QuestSounds::Sound* sound, QuestSounds::Utils::AsyncAudioClipLoader* loader, std::optional> onSoundChanged) {
+ getLogger().info("Setup for sound: '{}' cfg values: active='{}', filepath='{}' FolderPath='{}'", name, sound->Active, sound->FilePath, sound->FolderPath);
+ // Make sure any previous audio is stopped
+ if (Loader && Loader->audioSource && Loader->audioSource->isPlaying) {
+ Loader->audioSource->Stop();
+ }
+
+ Name = name;
+ Sound = sound;
+ Loader = loader;
+ OnSoundChanged = onSoundChanged;
+
+ showSoundVolumeOffset = Sound->VolumeOffset.has_value();
+ showSoundBeatOffset = Sound->BeatOffset.has_value();
+
+ // Load list of available Sound Files in the folder
+ if (_Sounds) {
+ _Sounds->Clear();
+ for (const auto& entry : std::filesystem::directory_iterator(Sound->FolderPath)) {
+ if (entry.is_regular_file() && std::regex_search(entry.path().extension().string(), std::regex("ogg|mp3|mp2|wav|aiff|aif"))) {
+ getLogger().info("Found sound file: '{}'", entry.path().string());
+ CustomSoundFileCell* cell = CustomSoundFileCell::construct(entry.path().stem().string(), entry.path(), nullptr);
+ _Sounds->Add(cell);
+ }
+ }
+
+ // if (_Sounds->Count <= 0)
+ // {
+ // getLogger().info("No sound files found for sound: '{}'", name);
+ // // set_HasSoundFiles(false);
+ // if (NoSoundsFoundHorizontal) NoSoundsFoundHorizontal->gameObject->SetActive(true);
+ // if (SoundList) SoundList->gameObject->SetActive(false);
+ // }
+ // else
+ // {
+ // getLogger().info("Sound files found for sound: '{}'", name);
+ // // set_HasSoundFiles(true);
+ // if (NoSoundsFoundHorizontal) NoSoundsFoundHorizontal->gameObject->SetActive(false);
+ // if (SoundList) {
+ // SoundList->gameObject->SetActive(true);
+ // SoundList->tableView->ReloadData();
+ // }
+ // }
+ }
+
+ if (wasActivatedBefore && !_IsSetup) {
+ set_IsSetup(true);
+ getLogger().info("Disabling NotSetupHorizontal");
+ NotSetupHorizontal->gameObject->SetActive(false);
+ // // Destroying UI
+ // auto t = get_transform();
+ // int childCount = t->get_childCount();
+ // for (int i = 0; i < childCount; i++)
+ // Object::DestroyImmediate(t->GetChild(0)->get_gameObject());
+
+ // Recreating UI
+ getLogger().info("Recreating UI");
+ DidActivate(true, false, false);
+ } else {
+ DidActivate(false, false, false);
+ }
+ }
+
+ void SoundSettingsViewController::set_Active(bool value) {
+ getLogger().info("Setting Active for sound: '{}' to '{}'", Name, value);
+ _Active = value;
+ Sound->Active = value;
+
+ if (Loader && Loader->audioSource && Loader->audioSource->isPlaying) {
+ Loader->audioSource->Stop();
+ }
+ }
+
+ bool SoundSettingsViewController::get_Active() {
+ getLogger().info("Getting Active for sound: '{}' as '{}'", Name, Sound->Active);
+ return Sound->Active;
+ }
+
+ void SoundSettingsViewController::set_VolumeOffset(float value) {
+ getLogger().info("Setting VolumeOffset for sound: '{}' to '{}'", Name, value);
+ _VolumeOffset = value;
+ Sound->VolumeOffset = value;
+ }
+
+ float SoundSettingsViewController::get_VolumeOffset() {
+ getLogger().info("Getting VolumeOffset for sound: '{}' as '{}'", Name, Sound->VolumeOffset.value_or(0));
+ return Sound->VolumeOffset.value_or(0);
+ }
+
+ void SoundSettingsViewController::set_BeatOffset(float value) {
+ getLogger().info("Setting BeatOffset for sound: '{}' to '{}'", Name, value);
+ _BeatOffset = value;
+ Sound->BeatOffset = value;
+ }
+
+ float SoundSettingsViewController::get_BeatOffset() {
+ getLogger().info("Getting BeatOffset for sound: '{}' as '{}'", Name, Sound->BeatOffset.value_or(0.185f));
+ return Sound->BeatOffset.value_or(0.185f);
+ }
+
+ void SoundSettingsViewController::set_HasSoundFiles(bool value) {
+ getLogger().info("Setting HasSoundFiles for sound: '{}' to '{}'", Name, value);
+ _HasSoundFiles = value;
+ }
+
+ bool SoundSettingsViewController::get_HasSoundFiles() {
+ getLogger().info("Getting HasSoundFiles for sound: '{}' as '{}'", Name, _HasSoundFiles);
+ return _HasSoundFiles;
+ }
+
+ void SoundSettingsViewController::set_IsSetup(bool value) {
+ getLogger().info("Setting IsSetup for sound: '{}' to '{}'", Name, value);
+ _IsSetup = value;
+ }
+
+ bool SoundSettingsViewController::get_IsSetup() {
+ getLogger().info("Getting IsSetup for sound: '{}' as '{}'", Name, _IsSetup);
+ return _IsSetup;
+ }
+
+ ListW SoundSettingsViewController::get_Sounds() {
+ getLogger().info("Getting Sound Files for sound: '{}'", Name);
+ return _Sounds;
+ }
+
+ custom_types::Helpers::Coroutine SoundSettingsViewController::PreviewSelection() {
+ while (!Loader->loaded) {
+ co_yield reinterpret_cast(UnityEngine::WaitForSeconds::New_ctor(0.1f));
+ }
+
+ if (Loader->loaded && Loader->audioSource) {
+ getLogger().info("PreviewSelection for sound: '{}'", Name);
+ Loader->audioSource->set_volume(0.6f);
+ Loader->audioSource->Play();
+
+ if (OnSoundChanged.has_value()) {
+ OnSoundChanged.value()();
+ } else getLogger().info("OnSoundChanged is not set for sound: '{}'", Name);
+ } else getLogger().error("PreviewSelection failed for sound: '{}'", Name);
+ }
+
+ void SoundSettingsViewController::SoundSelected(HMUI::TableView* table, int cellIdx) {
+ getLogger().info("SoundSelected for sound: '{}' at index: '{}'", Name, cellIdx);
+ if (cellIdx < 0 || cellIdx > _Sounds->Count) return;
+ auto cell = il2cpp_utils::cast(_Sounds[cellIdx]);
+ getLogger().info("Selected Sound: '{}'", cell->text);
+ Sound->FilePath = cell->FilePath.string();
+ StopAllCoroutines();
+ Loader->filePath = Sound->FilePath;
+ if (Loader->audioSource && Loader->audioSource->isPlaying) {
+ Loader->audioSource->Stop();
+ }
+ Loader->loaded = false;
+ Loader->load();
+ StartCoroutine(custom_types::Helpers::CoroutineHelper::New(PreviewSelection()));
+ }
+}
\ No newline at end of file
diff --git a/src/UI/ViewControllers/BadHitSdListViewController.cpp b/src/UI/ViewControllers/BadHitSdListViewController.cpp
deleted file mode 100644
index d113584..0000000
--- a/src/UI/ViewControllers/BadHitSdListViewController.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-#include "main.hpp"
-#include "QSoundsConfig.hpp"
-#include "ViewControllers/BadHitSdListViewController.hpp"
-#include "AudioClips.hpp"
-
-#include
-#include
-#include
-
-#include "questui/shared/BeatSaberUI.hpp"
-#include "questui/shared/CustomTypes/Components/ExternalComponents.hpp"
-
-#include "UnityEngine/Object.hpp"
-#include "UnityEngine/GameObject.hpp"
-#include "UnityEngine/Transform.hpp"
-#include "UnityEngine/RectTransform.hpp"
-#include "UnityEngine/UI/Button.hpp"
-#include "UnityEngine/UI/LayoutElement.hpp"
-#include "UnityEngine/UI/VerticalLayoutGroup.hpp"
-#include "UnityEngine/UI/HorizontalLayoutGroup.hpp"
-#include "UnityEngine/Events/UnityAction.hpp"
-#include "TMPro/TextMeshProUGUI.hpp"
-
-using namespace QuestSounds;
-
-#ifndef REGISTER_FUNCTION
-DEFINE_TYPE(QuestSounds::ViewControllers, BadHitSdListViewController);
-#elif defined(DEFINE_TYPE)
-DEFINE_TYPE(QuestSounds::ViewControllers::BadHitSdListViewController);
-#elif defined(DEFINE_CLASS)
-DEFINE_CLASS(QuestSounds::ViewControllers::BadHitSdListViewController);
-#endif
-
-namespace QuestSounds::ViewControllers {
-
- BadHitSdListViewController* BadHitListView;
- std::list BadHitQSlist = {};
-
- void BadHitSelectSound()
- {
- for (UnityEngine::UI::Button* button : BadHitQSlist)
- {
- if (button->get_hasSelection())
- {
- std::string filename = to_utf8(csstrtostr(button->GetComponentInChildren()->get_text()));
- QSoundsConfig::Config.badHitSound_filepath = QSoundsConfig::BadHitSoundPath + filename;
- AudioClips::badHitSoundLoader.filePath = QSoundsConfig::Config.badHitSound_filepath;
- if (AudioClips::badHitSoundLoader.audioSource != nullptr) AudioClips::badHitSoundLoader.audioSource->Stop();
- AudioClips::badHitSoundLoader.load();
- std::thread PlayAudio([&]() {
- while (!AudioClips::badHitSoundLoader.loaded && QSoundsConfig::Config.badHitSound_Active) {
- usleep(100);
- }
- if (!QSoundsConfig::Config.badHitSound_Active) {
- return;
- }
- if (AudioClips::badHitSoundLoader.audioSource != nullptr) {
- AudioClips::badHitSoundLoader.audioSource->set_volume(0.6f + QSoundsConfig::Config.badHitSound_audioVolumeOffset);
- return AudioClips::badHitSoundLoader.audioSource->Play();
- }
- });
- PlayAudio.detach();
- getLogger().debug("Selected Sound Path %s", QSoundsConfig::Config.badHitSound_filepath.c_str());
- }
- }
- }
-
- void BadHitRefreshList()
- {
- if (BadHitListView->listtxtgroup && BadHitListView->listtxtgroup->m_CachedPtr.m_value) UnityEngine::GameObject::Destroy(BadHitListView->listtxtgroup->get_gameObject());
- for (UnityEngine::UI::Button* button : BadHitQSlist) UnityEngine::Object::Destroy(button->get_transform()->get_parent()->get_gameObject());
- BadHitQSlist = {};
- DIR* sounddir = opendir(QSoundsConfig::BadHitSoundPath.c_str());
- dirent* fileent;
- while ((fileent = readdir(sounddir)) != NULL)
- {
- std::string filename = fileent->d_name;
- for (char& ch : filename) ch = tolower(ch);
-
- if (std::regex_search(filename, std::regex(".ogg|.mp3|.mp2|.wav|.aiff|.aif")))
- {
- UnityEngine::UI::HorizontalLayoutGroup* rowgroup = QuestUI::BeatSaberUI::CreateHorizontalLayoutGroup(BadHitListView->SDlistscroll->get_transform());
- UnityEngine::UI::Button* button = QuestUI::BeatSaberUI::CreateUIButton(rowgroup->get_rectTransform(), fileent->d_name, BadHitSelectSound);
- button->get_gameObject()->GetComponentInChildren()->set_fontStyle(2);
- BadHitQSlist.push_back(button);
- }
- }
- if (BadHitQSlist.size() < 1)
- {
- BadHitListView->listtxtgroup = QuestUI::BeatSaberUI::CreateHorizontalLayoutGroup(BadHitListView->SDlistscroll->get_transform());
- QuestUI::BeatSaberUI::CreateText(BadHitListView->listtxtgroup->get_rectTransform(), "No sound files were found!\nPlease add a sound file into\n"+ QSoundsConfig::BadHitSoundPath +"\nto continue.", false)->set_enableWordWrapping(true);
- }
- (void)closedir(sounddir);
- }
-
- void BadHitSdListViewController::DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
- {
- BadHitListView = this;
- if (firstActivation && addedToHierarchy)
- {
- UnityEngine::UI::VerticalLayoutGroup* container = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(get_rectTransform());
- container->set_spacing(0.4f);
- container->GetComponent()->set_minWidth(125.0);
-
- // Bool settings
- this->QSconfigcontainer = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(container->get_rectTransform());
- QSconfigcontainer->set_childAlignment(UnityEngine::TextAnchor::UpperCenter);
- QSconfigcontainer->set_childForceExpandHeight(false);
- QSconfigcontainer->set_childControlHeight(true);
-
- // Enable or Disable BadHitSounds
- //QSoundsConfig::QSAddConfigValueToggle(QSconfigcontainer->get_rectTransform(), "Custom BadHitSounds", &QSoundsConfig::Config.badHitSound_Active, this, "Activates or deactivates Custom BadHitSounds");
- auto object = ::QuestUI::BeatSaberUI::CreateToggle(QSconfigcontainer->get_rectTransform(), "Custom Bad Hit Sounds", QSoundsConfig::Config.badHitSound_Active,
- [&](bool value) {
- if (value) BadHitRefreshList();
- QSoundsConfig::Config.badHitSound_Active = value;
- this->SDlistscroll->get_gameObject()->SetActive(value);
- if (AudioClips::badHitSoundLoader.audioSource != nullptr) AudioClips::badHitSoundLoader.audioSource->Stop();
- });
- ::QuestUI::BeatSaberUI::AddHoverHint(object->get_gameObject(), "Activates or deactivates Custom Bad Hit Sounds");
-
- // AudioVolumeOffset Slider
- QuestUI::SliderSetting* volumeSlider = ::QuestUI::BeatSaberUI::CreateSliderSetting(QSconfigcontainer->get_rectTransform(), "Volume Offset", 0.01f, QSoundsConfig::Config.badHitSound_audioVolumeOffset, -1.0f, 1.0f, 0.5f, [](float volume) {
- // Checks for safety
- QSoundsConfig::Config.badHitSound_audioVolumeOffset = volume;
- if (AudioClips::badHitSoundLoader.loaded) {
- if (AudioClips::badHitSoundLoader.audioSource->get_isPlaying()) AudioClips::badHitSoundLoader.audioSource->Stop();
- AudioClips::badHitSoundLoader.audioSource->set_volume(1.0f + volume);
- AudioClips::badHitSoundLoader.audioSource->Play();
- }
- //std::thread PlayAudio([&]() {
- // usleep(100);
- //});
- });
- QuestUI::BeatSaberUI::AddHoverHint(volumeSlider->get_gameObject(), "Lets you select a Volume Offset that is applied to the sound (Preview volume does not necessarily match volume played in-map)");
-
- // Sound List (recursively adds buttons as ListView isn't an easy type to deal with)
- this->SDlistscroll = QuestUI::BeatSaberUI::CreateScrollView(container->get_rectTransform());
- SDlistscroll->GetComponent()->Get()->set_minHeight(56.0);
- auto* SDlistcontainer = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(SDlistscroll->get_transform());
- SDlistcontainer->set_childAlignment(UnityEngine::TextAnchor::UpperCenter);
- SDlistcontainer->set_childForceExpandHeight(false);
- SDlistcontainer->set_childControlHeight(true);
-
- this->SDlistscroll->get_gameObject()->SetActive(QSoundsConfig::Config.badHitSound_Active);
- }
- BadHitRefreshList();
- }
-
- void BadHitSdListViewController::DidDeactivate(bool removedFromHierarchy, bool systemScreenDisabling)
- {
- //QSoundsConfig::SaveConfig();
- for (UnityEngine::UI::Button* button : BadHitQSlist) UnityEngine::Object::Destroy(button->get_transform()->get_parent()->get_gameObject());
- BadHitQSlist = {};
- }
-}
diff --git a/src/UI/ViewControllers/ConfigViewController.cpp b/src/UI/ViewControllers/ConfigViewController.cpp
deleted file mode 100644
index 99a0fbd..0000000
--- a/src/UI/ViewControllers/ConfigViewController.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-#include "QSoundsConfig.hpp"
-#include "QSoundsFlowCoordinator.hpp"
-#include "ViewControllers/ConfigViewController.hpp"
-#include "main.hpp"
-
-#include "questui/shared/BeatSaberUI.hpp"
-#include "questui/shared/CustomTypes/Components/Backgroundable.hpp"
-#include "questui/shared/QuestUI.hpp"
-
-#include "UnityEngine/RectOffset.hpp"
-
-#include "UnityEngine/Object.hpp"
-#include "UnityEngine/UI/VerticalLayoutGroup.hpp"
-#include "UnityEngine/UI/Button.hpp"
-#include "UnityEngine/Events/UnityAction_1.hpp"
-#include "UnityEngine/GameObject.hpp"
-#include "HMUI/Touchable.hpp"
-#include "HMUI/ScrollView.hpp"
-using namespace QuestUI;
-using namespace UnityEngine::UI;
-using namespace UnityEngine;
-using namespace HMUI;
-using namespace QSoundsConfig;
-
-#ifndef REGISTER_FUNCTION
-DEFINE_TYPE(QuestSounds::ViewControllers, ConfigViewController);
-#elif defined(DEFINE_TYPE)
-DEFINE_TYPE(QuestSounds::ViewControllers::ConfigViewController);
-#elif defined(DEFINE_CLASS)
-DEFINE_CLASS(QuestSounds::ViewControllers::ConfigViewController);
-#endif
-
-//ConfigValue SoundValue;
-//ConfigValue HitSoundValue;
-//ConfigValue HitSoundString = HitSoundValue["filepath"];
-
-//void HitSoundToggle(QuestSounds::QSoundsConfigViewController* parent, bool newValue) {
-// //HitSoundValue["activated"].SetBool(newValue);
-// Config.hitSound_Active = newValue;
-// getConfig().Write();
-//}
-//void HitSoundVolume(QuestSounds::QSoundsViewController* parent, float newValue) {
-// HitSoundValue["Volume"].SetFloat(newValue);
-// getConfig().Write();
-//}
-namespace QuestSounds::ViewControllers {
-
- void ConfigViewController::DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) {
- if (firstActivation) {
- get_gameObject()->AddComponent();
-
- GameObject* mainLayout = GameObject::New_ctor();
- RectTransform* parent = mainLayout->AddComponent();
- parent->SetParent(get_transform(), false);
- parent->set_localPosition({38.0f, 3.0f, 0.0f });
-
- VerticalLayoutGroup* settingsLayout = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(parent);
- RectTransform* settingsLayoutTransform = settingsLayout->GetComponent();
- settingsLayout->get_gameObject()->AddComponent()->ApplyBackground(il2cpp_utils::newcsstr("round-rect-panel"));
- settingsLayout->set_spacing(1.2f);
- settingsLayout->set_padding(UnityEngine::RectOffset::New_ctor(3, 3, 2, 2));
-
- ContentSizeFitter* contentSizeFitter = settingsLayout->get_gameObject()->AddComponent();
- contentSizeFitter->set_horizontalFit(ContentSizeFitter::FitMode::PreferredSize);
- contentSizeFitter->set_verticalFit(ContentSizeFitter::FitMode::PreferredSize);
-
- QuestUI::BeatSaberUI::CreateText(settingsLayoutTransform, "Quest Sounds", false)->set_alignment(TMPro::TextAlignmentOptions::Center);
-
- BeatSaberUI::CreateUIButton(settingsLayoutTransform, "Menu Music",
- [&]() {
- getLogger().debug("MenuMusic Button pressed!");
- this->callback(1);
- })->get_transform()->GetParent()->GetComponent()->set_preferredWidth(50.0f);
-
- BeatSaberUI::CreateUIButton(settingsLayoutTransform, "Menu Click Sounds",
- [&]() {
- getLogger().debug("MenuClickSounds Button pressed!");
- this->callback(3);
- })->get_transform()->GetParent()->GetComponent()->set_preferredWidth(50.0f);
-
-
- BeatSaberUI::CreateUIButton(settingsLayoutTransform, "Hit Sounds",
- [&]() {
- getLogger().debug("HitSounds Button pressed!");
- this->callback(2);
- })->get_transform()->GetParent()->GetComponent()->set_preferredWidth(50.0f);
-
- BeatSaberUI::CreateUIButton(settingsLayoutTransform, "Bad Hit Sounds",
- [&]() {
- getLogger().debug("BadHitSounds Button pressed!");
- this->callback(4);
- })->get_transform()->GetParent()->GetComponent()->set_preferredWidth(50.0f);
-
- BeatSaberUI::CreateUIButton(settingsLayoutTransform, "Note Missed Sounds",
- [&]() {
- getLogger().debug("NoteMissedSounds Button pressed!");
- this->callback(5);
- })->get_transform()->GetParent()->GetComponent()->set_preferredWidth(50.0f);
-
- BeatSaberUI::CreateUIButton(settingsLayoutTransform, "Firework Sounds",
- [&]() {
- getLogger().debug("FireworkSounds Button pressed!");
- this->callback(6);
- })->get_transform()->GetParent()->GetComponent()->set_preferredWidth(50.0f);
-
- BeatSaberUI::CreateUIButton(settingsLayoutTransform, "Level Cleared Sounds",
- [&]() {
- getLogger().debug("LevelClearedSounds Button pressed!");
- this->callback(7);
- })->get_transform()->GetParent()->GetComponent()->set_preferredWidth(50.0f);
-
- BeatSaberUI::CreateUIButton(settingsLayoutTransform, "Level Failed Sounds",
- [&]() {
- getLogger().debug("LevelFailedSounds Button pressed!");
- this->callback(8);
- })->get_transform()->GetParent()->GetComponent()->set_preferredWidth(50.0f);
- BeatSaberUI::CreateUIButton(settingsLayoutTransform, "Lobby Music",
- [&]() {
- getLogger().debug("LobbyMusic Button pressed!");
- this->callback(9);
- })->get_transform()->GetParent()->GetComponent()->set_preferredWidth(50.0f);
- }
- }
-
- void ConfigViewController::set_selectCallback(std::function callback)
- {
- this->callback = callback;
- }
-}
diff --git a/src/UI/ViewControllers/FireworkSdListViewController.cpp b/src/UI/ViewControllers/FireworkSdListViewController.cpp
deleted file mode 100644
index c8877d4..0000000
--- a/src/UI/ViewControllers/FireworkSdListViewController.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-#include "main.hpp"
-#include "QSoundsConfig.hpp"
-#include "ViewControllers/FireworkSdListViewController.hpp"
-#include "AudioClips.hpp"
-
-#include
-#include
-#include
-
-#include "questui/shared/BeatSaberUI.hpp"
-#include "questui/shared/CustomTypes/Components/ExternalComponents.hpp"
-
-#include "UnityEngine/Object.hpp"
-#include "UnityEngine/GameObject.hpp"
-#include "UnityEngine/Transform.hpp"
-#include "UnityEngine/RectTransform.hpp"
-#include "UnityEngine/UI/Button.hpp"
-#include "UnityEngine/UI/LayoutElement.hpp"
-#include "UnityEngine/UI/VerticalLayoutGroup.hpp"
-#include "UnityEngine/UI/HorizontalLayoutGroup.hpp"
-#include "UnityEngine/Events/UnityAction.hpp"
-#include "TMPro/TextMeshProUGUI.hpp"
-
-//#include "GlobalNamespace/FireworkItemController.hpp"
-//#include "GlobalNamespace/RandomObjectPicker_1.hpp"
-
-using namespace QuestSounds;
-
-#ifndef REGISTER_FUNCTION
-DEFINE_TYPE(QuestSounds::ViewControllers, FireworkSdListViewController);
-#elif defined(DEFINE_TYPE)
-DEFINE_TYPE(QuestSounds::ViewControllers::FireworkSdListViewController);
-#elif defined(DEFINE_CLASS)
-DEFINE_CLASS(QuestSounds::ViewControllers::FireworkSdListViewController);
-#endif
-
-namespace QuestSounds::ViewControllers {
-
- bool FireworkSelectionChanged = false;
- //GlobalNamespace::FireworkItemController* FIC;
-
- FireworkSdListViewController* FireworkListView;
- std::list FireworkQSlist = {};
-
- void FireworkSelectSound()
- {
- for (UnityEngine::UI::Button* button : FireworkQSlist)
- {
- if (button->get_hasSelection())
- {
- std::string filename = to_utf8(csstrtostr(button->GetComponentInChildren()->get_text()));
- QSoundsConfig::Config.firework_filepath = QSoundsConfig::FireworkSoundPath + filename;
- AudioClips::fireworkSoundLoader.filePath = QSoundsConfig::Config.firework_filepath;
- if (AudioClips::fireworkSoundLoader.audioSource != nullptr) AudioClips::fireworkSoundLoader.audioSource->Stop();
- AudioClips::fireworkSoundLoader.load();
- std::thread PlayAudio([&]() {
- while (!AudioClips::fireworkSoundLoader.loaded && QSoundsConfig::Config.firework_Active) {
- usleep(100);
- }
- if (!QSoundsConfig::Config.firework_Active) {
- return;
- }
- FireworkSelectionChanged = true;
- AudioClips::fireworkSoundLoader.audioSource->set_volume(0.6f);
- return AudioClips::fireworkSoundLoader.audioSource->Play();
- });
- PlayAudio.detach();
- getLogger().debug("Selected filename %s, Sound Path %s", filename.c_str(), QSoundsConfig::Config.firework_filepath.c_str());
- }
- }
- }
-
- void FireworkRefreshList()
- {
- if (FireworkListView->listtxtgroup && FireworkListView->listtxtgroup->m_CachedPtr.m_value) UnityEngine::GameObject::Destroy(FireworkListView->listtxtgroup->get_gameObject());
- for (UnityEngine::UI::Button* button : FireworkQSlist) UnityEngine::Object::Destroy(button->get_transform()->get_parent()->get_gameObject());
- FireworkQSlist = {};
- DIR* sounddir = opendir(QSoundsConfig::FireworkSoundPath.c_str());
- dirent* fileent;
- while ((fileent = readdir(sounddir)) != NULL)
- {
- std::string filename = fileent->d_name;
- for (char& ch : filename) ch = tolower(ch);
-
- if (std::regex_search(filename, std::regex(".ogg|.mp3|.mp2|.wav|.aiff|.aif")))
- {
- UnityEngine::UI::HorizontalLayoutGroup* rowgroup = QuestUI::BeatSaberUI::CreateHorizontalLayoutGroup(FireworkListView->SDlistscroll->get_transform());
- UnityEngine::UI::Button* button = QuestUI::BeatSaberUI::CreateUIButton(rowgroup->get_rectTransform(), fileent->d_name, FireworkSelectSound);
- button->get_gameObject()->GetComponentInChildren()->set_fontStyle(2);
- FireworkQSlist.push_back(button);
- }
- }
- if (FireworkQSlist.size() < 1)
- {
- FireworkListView->listtxtgroup = QuestUI::BeatSaberUI::CreateHorizontalLayoutGroup(FireworkListView->SDlistscroll->get_transform());
- QuestUI::BeatSaberUI::CreateText(FireworkListView->listtxtgroup->get_rectTransform(), "No sound files were found!\nPlease add a sound file into\n" + QSoundsConfig::FireworkSoundPath + "\nto continue.", false)->set_enableWordWrapping(true);
- }
- (void)closedir(sounddir);
- }
-
- void FireworkSdListViewController::DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
- {
- FireworkListView = this;
- if (firstActivation && addedToHierarchy)
- {
- FireworkSelectionChanged = false;
- //FIC = UnityEngine::GameObject::FindObjectOfType();
- UnityEngine::UI::VerticalLayoutGroup* container = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(get_rectTransform());
- container->set_spacing(0.4f);
- container->GetComponent()->set_minWidth(125.0);
-
- // Bool settings
- this->QSconfigcontainer = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(container->get_rectTransform());
- QSconfigcontainer->set_childAlignment(UnityEngine::TextAnchor::UpperCenter);
- QSconfigcontainer->set_childForceExpandHeight(false);
- QSconfigcontainer->set_childControlHeight(true);
-
- // Enable or Disable FireworkSounds
- //QSoundsConfig::QSAddConfigValueToggle(QSconfigcontainer->get_rectTransform(), "Custom FireworkSounds", &QSoundsConfig::Config.firework_Active, this, "Activates or deactivates Custom FireworkSounds");
- auto object = ::QuestUI::BeatSaberUI::CreateToggle(QSconfigcontainer->get_rectTransform(), "Custom Firework Sounds", QSoundsConfig::Config.firework_Active,
- [&](bool value) {
- if (value) FireworkRefreshList();
- QSoundsConfig::Config.firework_Active = value;
- this->SDlistscroll->get_gameObject()->SetActive(value);
- if (AudioClips::fireworkSoundLoader.audioSource != nullptr) AudioClips::fireworkSoundLoader.audioSource->Stop();
- //if (value && AudioClips::fireworkSoundLoader.loaded) {
- // AudioClips::fireworkSoundArr = AudioClips::createAudioClipArray(AudioClips::fireworkSoundLoader);
- // if (FIC != nullptr) {
- // FIC->explosionClips = AudioClips::fireworkSoundArr;
- // FIC->randomAudioPicker->objects = AudioClips::fireworkSoundArr;
- // }
- // else getLogger().warning("Could not set custom FireworkSoundArray");
- //}
- //else {
- // if (FIC != nullptr && AudioClips::origFireworkSoundArr != nullptr) {
- // FIC->explosionClips = AudioClips::origFireworkSoundArr;
- // FIC->randomAudioPicker->objects = AudioClips::origFireworkSoundArr;
- // }
- // else getLogger().warning("Could not set OriginalFireworkSoundArray");
- //}
- });
- ::QuestUI::BeatSaberUI::AddHoverHint(object->get_gameObject(), "Activates or deactivates Custom Firework Sounds");
-
-
- // Sound List (recursively adds buttons as ListView isn't an easy type to deal with)
- this->SDlistscroll = QuestUI::BeatSaberUI::CreateScrollView(container->get_rectTransform());
- SDlistscroll->GetComponent()->Get()->set_minHeight(56.0);
- auto* SDlistcontainer = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(SDlistscroll->get_transform());
- SDlistcontainer->set_childAlignment(UnityEngine::TextAnchor::UpperCenter);
- SDlistcontainer->set_childForceExpandHeight(false);
- SDlistcontainer->set_childControlHeight(true);
-
- this->SDlistscroll->get_gameObject()->SetActive(QSoundsConfig::Config.firework_Active);
- }
- FireworkRefreshList();
- }
-
- void FireworkSdListViewController::DidDeactivate(bool removedFromHierarchy, bool systemScreenDisabling)
- {
- //QSoundsConfig::SaveConfig();
- for (UnityEngine::UI::Button* button : FireworkQSlist) UnityEngine::Object::Destroy(button->get_transform()->get_parent()->get_gameObject());
- FireworkQSlist = {};
- //if (FireworkSelectionChanged && QSoundsConfig::Config.firework_Active && AudioClips::fireworkSoundLoader.loaded) {
- // AudioClips::fireworkSoundArr = AudioClips::createAudioClipArray(AudioClips::fireworkSoundLoader);
- // if (FIC != nullptr) {
- // FIC->explosionClips = AudioClips::fireworkSoundArr;
- // FIC->randomAudioPicker->objects = AudioClips::fireworkSoundArr;
- // }
- // else getLogger().warning("Could not set custom FireworkSoundArray");
- //}
- //else {
- // if (FIC != nullptr && AudioClips::origFireworkSoundArr != nullptr) {
- // FIC->explosionClips = AudioClips::origFireworkSoundArr;
- // FIC->randomAudioPicker->objects = AudioClips::origFireworkSoundArr;
- // }
- // else getLogger().warning("Could not set OriginalFireworkSoundArray");
- //}
- }
-}
\ No newline at end of file
diff --git a/src/UI/ViewControllers/HitSdListViewController.cpp b/src/UI/ViewControllers/HitSdListViewController.cpp
deleted file mode 100644
index a998311..0000000
--- a/src/UI/ViewControllers/HitSdListViewController.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-#include "main.hpp"
-#include "QSoundsConfig.hpp"
-#include "ViewControllers/HitSdListViewController.hpp"
-#include "AudioClips.hpp"
-
-#include
-#include
-#include
-
-#include "questui/shared/BeatSaberUI.hpp"
-#include "questui/shared/CustomTypes/Components/ExternalComponents.hpp"
-
-#include "UnityEngine/Object.hpp"
-#include "UnityEngine/GameObject.hpp"
-#include "UnityEngine/Transform.hpp"
-#include "UnityEngine/RectTransform.hpp"
-#include "UnityEngine/UI/Button.hpp"
-#include "UnityEngine/UI/LayoutElement.hpp"
-#include "UnityEngine/UI/VerticalLayoutGroup.hpp"
-#include "UnityEngine/UI/HorizontalLayoutGroup.hpp"
-#include "UnityEngine/AudioSource.hpp"
-#include "UnityEngine/Events/UnityAction.hpp"
-#include "TMPro/TextMeshProUGUI.hpp"
-
-using namespace QuestSounds;
-
-#ifndef REGISTER_FUNCTION
-DEFINE_TYPE(QuestSounds::ViewControllers, HitSdListViewController);
-#elif defined(DEFINE_TYPE)
-DEFINE_TYPE(QuestSounds::ViewControllers::HitSdListViewController);
-#elif defined(DEFINE_CLASS)
-DEFINE_CLASS(QuestSounds::ViewControllers::HitSdListViewController);
-#endif
-namespace QuestSounds::ViewControllers {
-
- HitSdListViewController* HitListView;
- std::list HitQSlist = {};
-
- void HitSelectSound()
- {
- for (UnityEngine::UI::Button* button : HitQSlist)
- {
- if (button->get_hasSelection())
- {
- std::string filename = to_utf8(csstrtostr(button->GetComponentInChildren()->get_text()));
- QSoundsConfig::Config.hitSound_filepath = QSoundsConfig::HitSoundPath + filename;
- AudioClips::hitSoundLoader.filePath = QSoundsConfig::Config.hitSound_filepath;
- if (AudioClips::hitSoundLoader.audioSource != nullptr) AudioClips::hitSoundLoader.audioSource->Stop();
- AudioClips::hitSoundLoader.load();
- std::thread PlayAudio([&]() {
- while (!AudioClips::hitSoundLoader.loaded && QSoundsConfig::Config.hitSound_Active) {
- usleep(100);
- }
- if (!QSoundsConfig::Config.hitSound_Active) {
- return;
- }
- if (AudioClips::hitSoundLoader.audioSource != nullptr) {
- AudioClips::hitSoundLoader.audioSource->set_volume(0.6f + QSoundsConfig::Config.hitSound_audioVolumeOffset);
- return AudioClips::hitSoundLoader.audioSource->Play();
- }
- });
- PlayAudio.detach();
- getLogger().debug("Selected filename %s, Sound Path %s", filename.c_str(), QSoundsConfig::Config.hitSound_filepath.c_str());
- }
- }
- }
-
- void HitRefreshList()
- {
- if (HitListView->listtxtgroup && HitListView->listtxtgroup->m_CachedPtr.m_value) UnityEngine::GameObject::Destroy(HitListView->listtxtgroup->get_gameObject());
- for (UnityEngine::UI::Button* button : HitQSlist) UnityEngine::Object::Destroy(button->get_transform()->get_parent()->get_gameObject());
- HitQSlist = {};
- DIR* sounddir = opendir(QSoundsConfig::HitSoundPath.c_str());
- dirent* fileent;
- while ((fileent = readdir(sounddir)) != NULL)
- {
- std::string filename = fileent->d_name;
- for (char& ch : filename) ch = tolower(ch);
-
- if (std::regex_search(filename, std::regex(".ogg|.mp3|.mp2|.wav|.aiff|.aif")))
- {
- UnityEngine::UI::HorizontalLayoutGroup* rowgroup = QuestUI::BeatSaberUI::CreateHorizontalLayoutGroup(HitListView->SDlistscroll->get_transform());
- UnityEngine::UI::Button* button = QuestUI::BeatSaberUI::CreateUIButton(rowgroup->get_rectTransform(), fileent->d_name, HitSelectSound);
- button->get_gameObject()->GetComponentInChildren()->set_fontStyle(2);
- HitQSlist.push_back(button);
- }
- }
- if (HitQSlist.size() < 1)
- {
- HitListView->listtxtgroup = QuestUI::BeatSaberUI::CreateHorizontalLayoutGroup(HitListView->SDlistscroll->get_transform());
- QuestUI::BeatSaberUI::CreateText(HitListView->listtxtgroup->get_rectTransform(), "No sound files were found!\nPlease add a sound file into\n" + QSoundsConfig::HitSoundPath + "\nto continue.", false)->set_enableWordWrapping(true);
- }
- (void)closedir(sounddir);
- }
-
- void HitSdListViewController::DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
- {
- HitListView = this;
- if (firstActivation && addedToHierarchy)
- {
- UnityEngine::UI::VerticalLayoutGroup* container = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(get_rectTransform());
- container->set_spacing(0.4f);
- container->GetComponent()->set_minWidth(125.0);
-
- // Bool settings
- this->QSconfigcontainer = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(container->get_rectTransform());
- QSconfigcontainer->set_childAlignment(UnityEngine::TextAnchor::UpperCenter);
- QSconfigcontainer->set_childForceExpandHeight(false);
- QSconfigcontainer->set_childControlHeight(true);
-
- // Enable or Disable HitSounds
- //QSoundsConfig::QSAddConfigValueToggle(QSconfigcontainer->get_rectTransform(), "Custom HitSounds", &QSoundsConfig::Config.hitSound_Active, this, "Activates or deactivates Custom HitSounds");
- auto HSToggle = ::QuestUI::BeatSaberUI::CreateToggle(QSconfigcontainer->get_rectTransform(), "Custom Hit Sounds", QSoundsConfig::Config.hitSound_Active,
- [&](bool value) {
- if (value) HitRefreshList();
- QSoundsConfig::Config.hitSound_Active = value;
- this->SDlistscroll->get_gameObject()->SetActive(value);
- if (AudioClips::hitSoundLoader.audioSource != nullptr) AudioClips::hitSoundLoader.audioSource->Stop();
- });
- QuestUI::BeatSaberUI::AddHoverHint(HSToggle->get_gameObject(), "Activates or deactivates Custom Hit Sounds");
-
- QuestUI::SliderSetting* volumeSlider = ::QuestUI::BeatSaberUI::CreateSliderSetting(QSconfigcontainer->get_rectTransform(), "Volume Offset", 0.01f, QSoundsConfig::Config.hitSound_audioVolumeOffset, -1.0f, 1.0f, 0.5f, [](float volume) {
- // Checks for safety
- QSoundsConfig::Config.hitSound_audioVolumeOffset = volume;
- if (AudioClips::hitSoundLoader.loaded) {
- if (AudioClips::hitSoundLoader.audioSource->get_isPlaying()) AudioClips::hitSoundLoader.audioSource->Stop();
- AudioClips::hitSoundLoader.audioSource->set_volume(0.6f + volume);
- AudioClips::hitSoundLoader.audioSource->Play();
- }
- });
- QuestUI::BeatSaberUI::AddHoverHint(volumeSlider->get_gameObject(), "Lets you select a Volume Offset that is applied to the sound (Preview volume does not necessarily match volume played in-map)");
-
- auto HSOffSet = ::QuestUI::BeatSaberUI::CreateIncrementSetting(QSconfigcontainer->get_rectTransform(), "Hit Sound OffSet (ms)", 3, 0.005f, QSoundsConfig::Config.hitSound_beatOffSet, 0.0f, 0.25f,
- [&](float value) {
- QSoundsConfig::Config.hitSound_beatOffSet = value;
- });
- QuestUI::BeatSaberUI::AddHoverHint(HSOffSet->get_gameObject(), "Sets a custom HitSound beatOffSet (default: 0.185 ms)");
-
-
- // Sound List (recursively adds buttons as ListView isn't an easy type to deal with)
- this->SDlistscroll = QuestUI::BeatSaberUI::CreateScrollView(container->get_rectTransform());
- SDlistscroll->GetComponent()->Get()->set_minHeight(56.0);
- auto* SDlistcontainer = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(SDlistscroll->get_transform());
- SDlistcontainer->set_childAlignment(UnityEngine::TextAnchor::UpperCenter);
- SDlistcontainer->set_childForceExpandHeight(false);
- SDlistcontainer->set_childControlHeight(true);
-
- this->SDlistscroll->get_gameObject()->SetActive(QSoundsConfig::Config.hitSound_Active);
- }
- HitRefreshList();
- }
-
- void HitSdListViewController::DidDeactivate(bool removedFromHierarchy, bool systemScreenDisabling)
- {
- //QSoundsConfig::SaveConfig();
- for (UnityEngine::UI::Button* button : HitQSlist) UnityEngine::Object::Destroy(button->get_transform()->get_parent()->get_gameObject());
- HitQSlist = {};
- if (AudioClips::hitSoundLoader.audioSource != nullptr) AudioClips::hitSoundLoader.audioSource->Stop();
- }
-}
\ No newline at end of file
diff --git a/src/UI/ViewControllers/LevelClearedSdListViewController.cpp b/src/UI/ViewControllers/LevelClearedSdListViewController.cpp
deleted file mode 100644
index a5a7e95..0000000
--- a/src/UI/ViewControllers/LevelClearedSdListViewController.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-#include "main.hpp"
-#include "QSoundsConfig.hpp"
-#include "ViewControllers/LevelClearedSdListViewController.hpp"
-#include "AudioClips.hpp"
-#include "ObjectInstances.hpp"
-
-#include
-#include
-#include
-
-#include "questui/shared/BeatSaberUI.hpp"
-#include "questui/shared/CustomTypes/Components/ExternalComponents.hpp"
-
-#include "UnityEngine/Object.hpp"
-#include "UnityEngine/GameObject.hpp"
-#include "UnityEngine/Transform.hpp"
-#include "UnityEngine/RectTransform.hpp"
-#include "UnityEngine/UI/Button.hpp"
-#include "UnityEngine/UI/LayoutElement.hpp"
-#include "UnityEngine/UI/VerticalLayoutGroup.hpp"
-#include "UnityEngine/UI/HorizontalLayoutGroup.hpp"
-#include "UnityEngine/Events/UnityAction.hpp"
-#include "TMPro/TextMeshProUGUI.hpp"
-
-using namespace QuestSounds;
-
-#ifndef REGISTER_FUNCTION
-DEFINE_TYPE(QuestSounds::ViewControllers, LevelClearedSdListViewController);
-#elif defined(DEFINE_TYPE)
-DEFINE_TYPE(QuestSounds::ViewControllers::LevelClearedSdListViewController);
-#elif defined(DEFINE_CLASS)
-DEFINE_CLASS(QuestSounds::ViewControllers::QSoundsLevelClearedSdListViewController);
-#endif
-
-namespace QuestSounds::ViewControllers {
-
- LevelClearedSdListViewController* LevelClearedListView;
- std::list LevelClearedQSlist = {};
-
- void LevelClearedSelectSound()
- {
- for (UnityEngine::UI::Button* button : LevelClearedQSlist)
- {
- if (button->get_hasSelection())
- {
- std::string filename = to_utf8(csstrtostr(button->GetComponentInChildren()->get_text()));
- QSoundsConfig::Config.levelCleared_filepath = QSoundsConfig::LevelClearedPath + filename;
- QuestSounds::AudioClips::levelClearedLoader.filePath = QSoundsConfig::Config.levelCleared_filepath;
- if (AudioClips::levelClearedLoader.audioSource != nullptr) AudioClips::levelClearedLoader.audioSource->Stop();
- AudioClips::levelClearedLoader.loaded = false;
- AudioClips::levelClearedLoader.load();
- std::thread PlayAudio([&]() {
- while (!AudioClips::levelClearedLoader.loaded && QSoundsConfig::Config.levelCleared_Active) {
- usleep(100);
- }
- if (!QSoundsConfig::Config.levelCleared_Active) {
- return;
- }
- AudioClips::levelClearedLoader.audioSource->Stop(); // TODO: Figure out why this Stop won't work
- AudioClips::levelClearedLoader.audioSource->set_volume(0.6f);
- return AudioClips::levelClearedLoader.audioSource->Play();
- });
- PlayAudio.detach();
- getLogger().debug("Selected filename %s, Sound Path %s", filename.c_str(), QSoundsConfig::Config.levelCleared_filepath.c_str());
- }
- }
- }
-
- void LevelClearedRefreshList()
- {
- if (LevelClearedListView->listtxtgroup && LevelClearedListView->listtxtgroup->m_CachedPtr.m_value) UnityEngine::GameObject::Destroy(LevelClearedListView->listtxtgroup->get_gameObject());
- for (UnityEngine::UI::Button* button : LevelClearedQSlist) UnityEngine::Object::Destroy(button->get_transform()->get_parent()->get_gameObject());
- LevelClearedQSlist = {};
- DIR* sounddir = opendir(QSoundsConfig::LevelClearedPath.c_str());
- dirent* fileent;
- while ((fileent = readdir(sounddir)) != NULL)
- {
- std::string filename = fileent->d_name;
- for (char& ch : filename) ch = tolower(ch);
-
- if (std::regex_search(filename, std::regex(".ogg|.mp3|.mp2|.wav|.aiff|.aif")))
- {
- UnityEngine::UI::HorizontalLayoutGroup* rowgroup = QuestUI::BeatSaberUI::CreateHorizontalLayoutGroup(LevelClearedListView->SDlistscroll->get_transform());
- UnityEngine::UI::Button* button = QuestUI::BeatSaberUI::CreateUIButton(rowgroup->get_rectTransform(), fileent->d_name, LevelClearedSelectSound);
- button->get_gameObject()->GetComponentInChildren()->set_fontStyle(2);
- LevelClearedQSlist.push_back(button);
- }
- }
- if (LevelClearedQSlist.size() < 1)
- {
- LevelClearedListView->listtxtgroup = QuestUI::BeatSaberUI::CreateHorizontalLayoutGroup(LevelClearedListView->SDlistscroll->get_transform());
- QuestUI::BeatSaberUI::CreateText(LevelClearedListView->listtxtgroup->get_rectTransform(), "No sound files were found!\nPlease add a sound file into\n" + QSoundsConfig::LevelClearedPath + "\nto continue.", false)->set_enableWordWrapping(true);
- }
- (void)closedir(sounddir);
- }
-
- void LevelClearedSdListViewController::DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
- {
- LevelClearedListView = this;
- if (firstActivation && addedToHierarchy)
- {
- UnityEngine::UI::VerticalLayoutGroup* container = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(get_rectTransform());
- container->set_spacing(0.4f);
- container->GetComponent()->set_minWidth(125.0);
-
- // Bool settings
- this->QSconfigcontainer = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(container->get_rectTransform());
- QSconfigcontainer->set_childAlignment(UnityEngine::TextAnchor::UpperCenter);
- QSconfigcontainer->set_childForceExpandHeight(false);
- QSconfigcontainer->set_childControlHeight(true);
-
- // Enable or Disable LevelClearedSounds
- //QSoundsConfig::QSAddConfigValueToggle(QSconfigcontainer->get_rectTransform(), "Custom LevelClearedSounds", &QSoundsConfig::Config.levelCleared_Active, this, "Activates or deactivates Custom LevelClearedSounds");
- auto object = ::QuestUI::BeatSaberUI::CreateToggle(QSconfigcontainer->get_rectTransform(), "Custom LevelCleared Sounds", QSoundsConfig::Config.levelCleared_Active,
- [&](bool value) {
- if (value) LevelClearedRefreshList();
- QSoundsConfig::Config.levelCleared_Active = value;
- this->SDlistscroll->get_gameObject()->SetActive(value);
- if (AudioClips::levelClearedLoader.audioSource != nullptr) AudioClips::levelClearedLoader.audioSource->Stop();
- });
- ::QuestUI::BeatSaberUI::AddHoverHint(object->get_gameObject(), "Activates or deactivates Custom LevelCleared Sounds");
-
-
- // Sound List (recursively adds buttons as ListView isn't an easy type to deal with)
- this->SDlistscroll = QuestUI::BeatSaberUI::CreateScrollView(container->get_rectTransform());
- SDlistscroll->GetComponent()->Get()->set_minHeight(56.0);
- auto* SDlistcontainer = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(SDlistscroll->get_transform());
- SDlistcontainer->set_childAlignment(UnityEngine::TextAnchor::UpperCenter);
- SDlistcontainer->set_childForceExpandHeight(false);
- SDlistcontainer->set_childControlHeight(true);
-
- this->SDlistscroll->get_gameObject()->SetActive(QSoundsConfig::Config.levelCleared_Active);
- }
- LevelClearedRefreshList();
- }
-
- void LevelClearedSdListViewController::DidDeactivate(bool removedFromHierarchy, bool systemScreenDisabling)
- {
- //QSoundsConfig::SaveConfig();
- for (UnityEngine::UI::Button* button : LevelClearedQSlist) UnityEngine::Object::Destroy(button->get_transform()->get_parent()->get_gameObject());
- LevelClearedQSlist = {};
- if (AudioClips::levelClearedLoader.audioSource != nullptr) AudioClips::levelClearedLoader.audioSource->Stop();
-
- }
-}
\ No newline at end of file
diff --git a/src/UI/ViewControllers/LevelFailedSdListViewController.cpp b/src/UI/ViewControllers/LevelFailedSdListViewController.cpp
deleted file mode 100644
index 2d48af4..0000000
--- a/src/UI/ViewControllers/LevelFailedSdListViewController.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-#include "main.hpp"
-#include "QSoundsConfig.hpp"
-#include "ViewControllers/LevelFailedSdListViewController.hpp"
-#include "AudioClips.hpp"
-#include "ObjectInstances.hpp"
-
-#include
-#include
-#include
-
-#include "questui/shared/BeatSaberUI.hpp"
-#include "questui/shared/CustomTypes/Components/ExternalComponents.hpp"
-
-#include "UnityEngine/Object.hpp"
-#include "UnityEngine/GameObject.hpp"
-#include "UnityEngine/Transform.hpp"
-#include "UnityEngine/RectTransform.hpp"
-#include "UnityEngine/UI/Button.hpp"
-#include "UnityEngine/UI/LayoutElement.hpp"
-#include "UnityEngine/UI/VerticalLayoutGroup.hpp"
-#include "UnityEngine/UI/HorizontalLayoutGroup.hpp"
-#include "UnityEngine/Events/UnityAction.hpp"
-#include "TMPro/TextMeshProUGUI.hpp"
-
-using namespace QuestSounds;
-
-#ifndef REGISTER_FUNCTION
-DEFINE_TYPE(QuestSounds::ViewControllers, LevelFailedSdListViewController);
-#elif defined(DEFINE_TYPE)
-DEFINE_TYPE(QuestSounds::ViewControllers::LevelFailedSdListViewController);
-#elif defined(DEFINE_CLASS)
-DEFINE_CLASS(QuestSounds::ViewControllers::LevelFailedSdListViewController);
-#endif
-
-namespace QuestSounds::ViewControllers {
-
- LevelFailedSdListViewController* LevelFailedListView;
- std::list LevelFailedQSlist = {};
-
- void SelectSound()
- {
- for (UnityEngine::UI::Button* button : LevelFailedQSlist)
- {
- if (button->get_hasSelection())
- {
- std::string filename = static_cast(button->GetComponentInChildren()->get_text());
- QSoundsConfig::Config.levelFailed_filepath = QSoundsConfig::LevelFailedPath + filename;
- QuestSounds::AudioClips::levelFailedLoader.filePath = QSoundsConfig::Config.levelFailed_filepath;
- if (AudioClips::levelFailedLoader.audioSource != nullptr) AudioClips::levelFailedLoader.audioSource->Stop();
- AudioClips::levelFailedLoader.load();
- std::thread PlayAudio([&]() {
- while (!AudioClips::levelFailedLoader.loaded && QSoundsConfig::Config.levelFailed_Active) {
- usleep(100);
- }
- if (!QSoundsConfig::Config.levelFailed_Active) {
- return;
- }
- AudioClips::levelFailedLoader.audioSource->Stop();
- float defaultVolume = QuestSounds::ObjectInstances::SPP ? QuestSounds::ObjectInstances::SPP->volume * QuestSounds::ObjectInstances::SPP->ambientVolumeScale : 0.6f;
- AudioClips::levelFailedLoader.audioSource->set_volume(defaultVolume + QSoundsConfig::Config.levelFailed_audioVolumeOffset);
- return AudioClips::levelFailedLoader.audioSource->Play();
- });
- PlayAudio.detach();
- getLogger().debug("Selected filename %s, Sound Path %s", filename.c_str(), QSoundsConfig::Config.levelFailed_filepath.c_str());
- }
- }
- }
-
- void LevelFailedRefreshList()
- {
- if (LevelFailedListView->listtxtgroup && LevelFailedListView->listtxtgroup->m_CachedPtr.m_value) UnityEngine::GameObject::Destroy(LevelFailedListView->listtxtgroup->get_gameObject());
- for (UnityEngine::UI::Button* button : LevelFailedQSlist) UnityEngine::Object::Destroy(button->get_transform()->get_parent()->get_gameObject());
- LevelFailedQSlist = {};
- DIR* sounddir = opendir(QSoundsConfig::LevelFailedPath.c_str());
- dirent* fileent;
- while ((fileent = readdir(sounddir)) != NULL)
- {
- std::string filename = fileent->d_name;
- for (char& ch : filename) ch = tolower(ch);
-
- if (std::regex_search(filename, std::regex(".ogg|.mp3|.mp2|.wav|.aiff|.aif")))
- {
- UnityEngine::UI::HorizontalLayoutGroup* rowgroup = QuestUI::BeatSaberUI::CreateHorizontalLayoutGroup(LevelFailedListView->SDlistscroll->get_transform());
- UnityEngine::UI::Button* button = QuestUI::BeatSaberUI::CreateUIButton(rowgroup->get_rectTransform(), fileent->d_name, SelectSound);
- button->get_gameObject()->GetComponentInChildren()->set_fontStyle(2);
- LevelFailedQSlist.push_back(button);
- }
- }
- if (LevelFailedQSlist.size() < 1)
- {
- LevelFailedListView->listtxtgroup = QuestUI::BeatSaberUI::CreateHorizontalLayoutGroup(LevelFailedListView->SDlistscroll->get_transform());
- QuestUI::BeatSaberUI::CreateText(LevelFailedListView->listtxtgroup->get_rectTransform(), "No sound files were found!\nPlease add a sound file into\n"+ QSoundsConfig::LevelFailedPath +"\nto continue.", false)->set_enableWordWrapping(true);
- }
- (void)closedir(sounddir);
- }
-
- void LevelFailedSdListViewController::DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
- {
- LevelFailedListView = this;
- if (firstActivation && addedToHierarchy)
- {
- UnityEngine::UI::VerticalLayoutGroup* container = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(get_rectTransform());
- container->set_spacing(0.4f);
- container->GetComponent()->set_minWidth(125.0);
-
- // Bool settings
- this->QSconfigcontainer = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(container->get_rectTransform());
- QSconfigcontainer->set_childAlignment(UnityEngine::TextAnchor::UpperCenter);
- QSconfigcontainer->set_childForceExpandHeight(false);
- QSconfigcontainer->set_childControlHeight(true);
-
- // Enable or Disable LevelFailedSounds
- //QSoundsConfig::QSAddConfigValueToggle(QSconfigcontainer->get_rectTransform(), "Custom LevelFailedSounds", &QSoundsConfig::Config.levelFailed_Active, this, "Activates or deactivates Custom LevelFailedSounds");
- auto object = ::QuestUI::BeatSaberUI::CreateToggle(QSconfigcontainer->get_rectTransform(), "Custom LevelFailed Sounds", QSoundsConfig::Config.levelFailed_Active,
- [&](bool value) {
- if (value) LevelFailedRefreshList();
- QSoundsConfig::Config.levelFailed_Active = value;
- this->SDlistscroll->get_gameObject()->SetActive(value);
- if (AudioClips::levelFailedLoader.audioSource != nullptr) AudioClips::levelFailedLoader.audioSource->Stop();
- });
- ::QuestUI::BeatSaberUI::AddHoverHint(object->get_gameObject(), "Activates or deactivates Custom LevelFailed Sounds");
-
- QuestUI::SliderSetting* volumeSlider = ::QuestUI::BeatSaberUI::CreateSliderSetting(QSconfigcontainer->get_rectTransform(), "Volume Offset", 0.01f, QSoundsConfig::Config.levelFailed_audioVolumeOffset, -1.0f, 1.0f, 0.5f, [](float volume) {
- // Checks for safety
- QSoundsConfig::Config.levelFailed_audioVolumeOffset = volume;
- if (AudioClips::levelFailedLoader.loaded) {
- if (AudioClips::levelFailedLoader.audioSource->get_isPlaying()) AudioClips::levelFailedLoader.audioSource->Stop();
- float defaultVolume = QuestSounds::ObjectInstances::SPP ? QuestSounds::ObjectInstances::SPP->volume * QuestSounds::ObjectInstances::SPP->ambientVolumeScale : 0.6f;
- AudioClips::levelFailedLoader.audioSource->set_volume(defaultVolume + volume);
- AudioClips::levelFailedLoader.audioSource->Play();
- }
- });
- QuestUI::BeatSaberUI::AddHoverHint(volumeSlider->get_gameObject(), "Lets you select a Volume Offset that is applied to the sound");
-
- // Sound List (recursively adds buttons as ListView isn't an easy type to deal with)
- this->SDlistscroll = QuestUI::BeatSaberUI::CreateScrollView(container->get_rectTransform());
- SDlistscroll->GetComponent()->Get()->set_minHeight(56.0);
- auto* SDlistcontainer = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(SDlistscroll->get_transform());
- SDlistcontainer->set_childAlignment(UnityEngine::TextAnchor::UpperCenter);
- SDlistcontainer->set_childForceExpandHeight(false);
- SDlistcontainer->set_childControlHeight(true);
-
- this->SDlistscroll->get_gameObject()->SetActive(QSoundsConfig::Config.levelFailed_Active);
- }
- LevelFailedRefreshList();
- }
-
- void LevelFailedSdListViewController::DidDeactivate(bool removedFromHierarchy, bool systemScreenDisabling)
- {
- //QSoundsConfig::SaveConfig();
- for (UnityEngine::UI::Button* button : LevelFailedQSlist) UnityEngine::Object::Destroy(button->get_transform()->get_parent()->get_gameObject());
- LevelFailedQSlist = {};
- if (AudioClips::levelFailedLoader.audioSource != nullptr) AudioClips::levelFailedLoader.audioSource->Stop();
-
- }
-
-}
\ No newline at end of file
diff --git a/src/UI/ViewControllers/LobbyMusicSdListViewController.cpp b/src/UI/ViewControllers/LobbyMusicSdListViewController.cpp
deleted file mode 100644
index a57ce16..0000000
--- a/src/UI/ViewControllers/LobbyMusicSdListViewController.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-#include "main.hpp"
-#include "QSoundsConfig.hpp"
-#include "ViewControllers/LobbyMusicSdListViewController.hpp"
-#include "AudioClips.hpp"
-#include "ObjectInstances.hpp"
-
-#include
-#include
-#include
-
-#include "questui/shared/BeatSaberUI.hpp"
-#include "questui/shared/CustomTypes/Components/ExternalComponents.hpp"
-
-#include "UnityEngine/Object.hpp"
-#include "UnityEngine/GameObject.hpp"
-#include "UnityEngine/Transform.hpp"
-#include "UnityEngine/RectTransform.hpp"
-#include "UnityEngine/UI/Button.hpp"
-#include "UnityEngine/UI/LayoutElement.hpp"
-#include "UnityEngine/UI/VerticalLayoutGroup.hpp"
-#include "UnityEngine/UI/HorizontalLayoutGroup.hpp"
-#include "UnityEngine/Events/UnityAction.hpp"
-#include "TMPro/TextMeshProUGUI.hpp"
-
-#include "GlobalNamespace/SongPreviewPlayer.hpp"
-
-using namespace QuestSounds;
-
-#ifndef REGISTER_FUNCTION
-DEFINE_TYPE(QuestSounds::ViewControllers, LobbyMusicSdListViewController);
-#elif defined(DEFINE_TYPE)
-DEFINE_TYPE(QuestSounds::ViewControllers::LobbyMusicSdListViewController);
-#elif defined(DEFINE_CLASS)
-DEFINE_CLASS(QuestSounds::ViewControllers::LobbyMusicSdListViewController);
-#endif
-
-namespace QuestSounds::ViewControllers {
-
- LobbyMusicSdListViewController* LobbyMusicListView;
- std::list LobbyMusicQSlist = {};
-
- void LobbyMusicSelectSound()
- {
- for (UnityEngine::UI::Button* button : LobbyMusicQSlist)
- {
- if (button->get_hasSelection())
- {
- std::string filename = to_utf8(csstrtostr(button->GetComponentInChildren()->get_text()));
- QSoundsConfig::Config.lobbyAmbience_filepath = QSoundsConfig::LobbyMusicPath + filename;
- QuestSounds::AudioClips::lobbyAmbienceLoader.filePath = QSoundsConfig::Config.lobbyAmbience_filepath;
- if (AudioClips::lobbyAmbienceLoader.audioSource != nullptr) AudioClips::lobbyAmbienceLoader.audioSource->Stop();
- AudioClips::lobbyAmbienceLoader.load();
- std::thread PlayAudio([&]() {
- while (!AudioClips::lobbyAmbienceLoader.loaded && QSoundsConfig::Config.lobbyAmbience_Active) {
- usleep(100);
- }
- if (!QSoundsConfig::Config.lobbyAmbience_Active) {
- return;
- }
- AudioClips::lobbyAmbienceLoader.audioSource->set_volume(0.6f);
- return AudioClips::lobbyAmbienceLoader.audioSource->Play();
- });
- PlayAudio.detach();
- getLogger().debug("Selected filename %s, Sound Path %s", filename.c_str(), QSoundsConfig::Config.lobbyAmbience_filepath.c_str());
- }
- }
- }
-
- void LobbyMusicRefreshList()
- {
- if (LobbyMusicListView->listtxtgroup && LobbyMusicListView->listtxtgroup->m_CachedPtr.m_value) UnityEngine::GameObject::Destroy(LobbyMusicListView->listtxtgroup->get_gameObject());
- for (UnityEngine::UI::Button* button : LobbyMusicQSlist) UnityEngine::Object::Destroy(button->get_transform()->get_parent()->get_gameObject());
- LobbyMusicQSlist = {};
- DIR* sounddir = opendir(QSoundsConfig::LobbyMusicPath.c_str());
- dirent* fileent;
- while ((fileent = readdir(sounddir)) != NULL)
- {
- std::string filename = fileent->d_name;
- for (char& ch : filename) ch = tolower(ch);
-
- if (std::regex_search(filename, std::regex(".ogg|.mp3|.mp2|.wav|.aiff|.aif")))
- {
- UnityEngine::UI::HorizontalLayoutGroup* rowgroup = QuestUI::BeatSaberUI::CreateHorizontalLayoutGroup(LobbyMusicListView->SDlistscroll->get_transform());
- UnityEngine::UI::Button* button = QuestUI::BeatSaberUI::CreateUIButton(rowgroup->get_rectTransform(), fileent->d_name, LobbyMusicSelectSound);
- button->get_gameObject()->GetComponentInChildren()->set_fontStyle(2);
- LobbyMusicQSlist.push_back(button);
- }
- }
- if (LobbyMusicQSlist.size() < 1)
- {
- LobbyMusicListView->listtxtgroup = QuestUI::BeatSaberUI::CreateHorizontalLayoutGroup(LobbyMusicListView->SDlistscroll->get_transform());
- QuestUI::BeatSaberUI::CreateText(LobbyMusicListView->listtxtgroup->get_rectTransform(), "No sound files were found!\nPlease add a sound file into\n" + QSoundsConfig::LobbyMusicPath + "\nto continue.", false)->set_enableWordWrapping(true);
- }
- (void)closedir(sounddir);
- }
-
- void LobbyMusicSdListViewController::DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
- {
- LobbyMusicListView = this;
- if (firstActivation && addedToHierarchy)
- {
- //QuestSounds::ObjectInstances::SPP = UnityEngine::GameObject::FindObjectOfType();
- UnityEngine::UI::VerticalLayoutGroup* container = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(get_rectTransform());
- container->set_spacing(0.4f);
- container->GetComponent()->set_minWidth(125.0);
-
- // Bool settings
- this->QSconfigcontainer = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(container->get_rectTransform());
- QSconfigcontainer->set_childAlignment(UnityEngine::TextAnchor::UpperCenter);
- QSconfigcontainer->set_childForceExpandHeight(false);
- QSconfigcontainer->set_childControlHeight(true);
-
- QuestUI::BeatSaberUI::CreateText(QSconfigcontainer->get_rectTransform(), "Menu Music will be Paused here", false);
-
- // Enable or Disable LobbyMusic
- //QSoundsConfig::QSAddConfigValueToggle(QSconfigcontainer->get_rectTransform(), "Custom Lobby Music", &QSoundsConfig::Config.lobbyAmbience_Active, this, "Activates or deactivates Custom Lobby Music");
- auto object = ::QuestUI::BeatSaberUI::CreateToggle(QSconfigcontainer->get_rectTransform(), "Custom Lobby Music", QSoundsConfig::Config.lobbyAmbience_Active,
- [&](bool value) {
- if (value) LobbyMusicRefreshList();
- QSoundsConfig::Config.lobbyAmbience_Active = value;
- this->SDlistscroll->get_gameObject()->SetActive(value);
- if (AudioClips::lobbyAmbienceLoader.audioSource != nullptr) AudioClips::lobbyAmbienceLoader.audioSource->Stop();
- });
- ::QuestUI::BeatSaberUI::AddHoverHint(object->get_gameObject(), "Activates or deactivates Custom Lobby Music");
-
-
- // Sound List (recursively adds buttons as ListView isn't an easy type to deal with)
- this->SDlistscroll = QuestUI::BeatSaberUI::CreateScrollView(container->get_rectTransform());
- SDlistscroll->GetComponent()->Get()->set_minHeight(56.0);
- auto* SDlistcontainer = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(SDlistscroll->get_transform());
- SDlistcontainer->set_childAlignment(UnityEngine::TextAnchor::UpperCenter);
- SDlistcontainer->set_childForceExpandHeight(false);
- SDlistcontainer->set_childControlHeight(true);
-
- this->SDlistscroll->get_gameObject()->SetActive(QSoundsConfig::Config.lobbyAmbience_Active);
- }
- QuestSounds::ObjectInstances::SPP->PauseCurrentChannel();
- LobbyMusicRefreshList();
- }
-
- void LobbyMusicSdListViewController::DidDeactivate(bool removedFromHierarchy, bool systemScreenDisabling)
- {
- QuestSounds::ObjectInstances::SPP->UnPauseCurrentChannel();
- //QSoundsConfig::SaveConfig();
- for (UnityEngine::UI::Button* button : LobbyMusicQSlist) UnityEngine::Object::Destroy(button->get_transform()->get_parent()->get_gameObject());
- LobbyMusicQSlist = {};
- if (AudioClips::lobbyAmbienceLoader.audioSource != nullptr) AudioClips::lobbyAmbienceLoader.audioSource->Stop();
- }
-}
\ No newline at end of file
diff --git a/src/UI/ViewControllers/MenuClickSdListViewController.cpp b/src/UI/ViewControllers/MenuClickSdListViewController.cpp
deleted file mode 100644
index cf30ef5..0000000
--- a/src/UI/ViewControllers/MenuClickSdListViewController.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-#include "main.hpp"
-#include "QSoundsConfig.hpp"
-#include "ViewControllers/MenuClickSdListViewController.hpp"
-#include "AudioClips.hpp"
-
-#include
-#include
-#include
-
-#include "questui/shared/BeatSaberUI.hpp"
-#include "questui/shared/CustomTypes/Components/ExternalComponents.hpp"
-
-#include "UnityEngine/Object.hpp"
-#include "UnityEngine/GameObject.hpp"
-#include "UnityEngine/Transform.hpp"
-#include "UnityEngine/RectTransform.hpp"
-#include "UnityEngine/UI/Button.hpp"
-#include "UnityEngine/UI/LayoutElement.hpp"
-#include "UnityEngine/UI/VerticalLayoutGroup.hpp"
-#include "UnityEngine/UI/HorizontalLayoutGroup.hpp"
-#include "UnityEngine/Events/UnityAction.hpp"
-#include "TMPro/TextMeshProUGUI.hpp"
-using namespace QuestSounds;
-
-#include "GlobalNamespace/BasicUIAudioManager.hpp"
-#include "GlobalNamespace/RandomObjectPicker_1.hpp"
-
-#ifndef REGISTER_FUNCTION
-DEFINE_TYPE(QuestSounds::ViewControllers, MenuClickSdListViewController);
-#elif defined(DEFINE_TYPE)
-DEFINE_TYPE(QuestSounds::ViewControllers::MenuClickSdListViewController);
-#elif defined(DEFINE_CLASS)
-DEFINE_CLASS(QuestSounds::ViewControllers::MenuClickSdListViewController);
-#endif
-
-namespace QuestSounds::ViewControllers {
-
- GlobalNamespace::BasicUIAudioManager* BUIAM;
-
- MenuClickSdListViewController* MenuClickListView;
- std::list MenuClickQSlist = {};
-
- void MenuClickSelectSound()
- {
- for (UnityEngine::UI::Button* button : MenuClickQSlist)
- {
- if (button->get_hasSelection())
- {
- std::string filename = to_utf8(csstrtostr(button->GetComponentInChildren()->get_text()));
- QSoundsConfig::Config.menuClick_filepath = QSoundsConfig::MenuClickPath + filename;
- AudioClips::menuClickLoader.filePath = QSoundsConfig::Config.menuClick_filepath;
- if (AudioClips::menuClickLoader.audioSource != nullptr) AudioClips::menuClickLoader.audioSource->Stop();
- AudioClips::menuClickLoader.load();
- std::thread PlayAudio([&]() {
- while (!AudioClips::menuClickLoader.loaded && QSoundsConfig::Config.menuClick_Active) {
- usleep(100);
- }
- if (!QSoundsConfig::Config.menuClick_Active) {
- return;
- }
- AudioClips::menuClickLoader.audioSource->set_volume(0.6f);
- return AudioClips::menuClickLoader.audioSource->Play();
- });
- PlayAudio.detach();
- getLogger().debug("Selected filename %s, Sound Path %s", filename.c_str(), QSoundsConfig::Config.menuClick_filepath.c_str());
- }
- }
- }
-
- void MenuClickRefreshList()
- {
- if (MenuClickListView->listtxtgroup && MenuClickListView->listtxtgroup->m_CachedPtr.m_value) UnityEngine::GameObject::Destroy(MenuClickListView->listtxtgroup->get_gameObject());
- for (UnityEngine::UI::Button* button : MenuClickQSlist) UnityEngine::Object::Destroy(button->get_transform()->get_parent()->get_gameObject());
- MenuClickQSlist = {};
- DIR* sounddir = opendir(QSoundsConfig::MenuClickPath.c_str());
- dirent* fileent;
- while ((fileent = readdir(sounddir)) != NULL)
- {
- std::string filename = fileent->d_name;
- for (char& ch : filename) ch = tolower(ch);
-
- if (std::regex_search(filename, std::regex(".ogg|.mp3|.mp2|.wav|.aiff|.aif")))
- {
- UnityEngine::UI::HorizontalLayoutGroup* rowgroup = QuestUI::BeatSaberUI::CreateHorizontalLayoutGroup(MenuClickListView->SDlistscroll->get_transform());
- UnityEngine::UI::Button* button = QuestUI::BeatSaberUI::CreateUIButton(rowgroup->get_rectTransform(), fileent->d_name, MenuClickSelectSound);
- button->get_gameObject()->GetComponentInChildren()->set_fontStyle(2);
- MenuClickQSlist.push_back(button);
- }
- }
- if (MenuClickQSlist.size() < 1)
- {
- MenuClickListView->listtxtgroup = QuestUI::BeatSaberUI::CreateHorizontalLayoutGroup(MenuClickListView->SDlistscroll->get_transform());
- QuestUI::BeatSaberUI::CreateText(MenuClickListView->listtxtgroup->get_rectTransform(), "No sound files were found!\nPlease add a sound file into\n" + QSoundsConfig::MenuClickPath + "\nto continue.", false)->set_enableWordWrapping(true);
- }
- (void)closedir(sounddir);
- }
-
- void MenuClickSdListViewController::DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
- {
- MenuClickListView = this;
- if (firstActivation && addedToHierarchy)
- {
- BUIAM = UnityEngine::GameObject::FindObjectOfType();
- UnityEngine::UI::VerticalLayoutGroup* container = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(get_rectTransform());
- container->set_spacing(0.4f);
- container->GetComponent()->set_minWidth(125.0);
-
- // Bool settings
- this->QSconfigcontainer = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(container->get_rectTransform());
- QSconfigcontainer->set_childAlignment(UnityEngine::TextAnchor::UpperCenter);
- QSconfigcontainer->set_childForceExpandHeight(false);
- QSconfigcontainer->set_childControlHeight(true);
-
- // Enable or Disable MenuClickSounds
- //QSoundsConfig::QSAddConfigValueToggle(QSconfigcontainer->get_rectTransform(), "Custom MenuClickSounds", &QSoundsConfig::Config.menuClick_Active, SDlistscroll, "Activates or deactivates Custom MenuClickSounds");
- auto object = ::QuestUI::BeatSaberUI::CreateToggle(QSconfigcontainer->get_rectTransform(), "Custom Menu ClickSounds", QSoundsConfig::Config.menuClick_Active,
- [&](bool value) {
- if (value) MenuClickRefreshList();
- QSoundsConfig::Config.menuClick_Active = value;
- this->SDlistscroll->get_gameObject()->SetActive(value);
- if (AudioClips::menuClickLoader.audioSource) AudioClips::menuClickLoader.audioSource->Stop();
- if (value && AudioClips::menuClickLoader.loaded) {
- AudioClips::menuClickArr = AudioClips::createAudioClipArray(AudioClips::menuClickLoader);
- BUIAM->randomSoundPicker->objects = AudioClips::menuClickArr;
- }
- else {
- AudioClips::origMenuClickArr = AudioClips::createAudioClipArray(AudioClips::menuClickLoader, true);
- BUIAM->randomSoundPicker->objects = AudioClips::origMenuClickArr;
- }
- });
- ::QuestUI::BeatSaberUI::AddHoverHint(object->get_gameObject(), "Activates or deactivates Custom Menu ClickSounds");
-
-
- // Sound List (recursively adds buttons as ListView isn't an easy type to deal with)
- this->SDlistscroll = QuestUI::BeatSaberUI::CreateScrollView(container->get_rectTransform());
- SDlistscroll->GetComponent()->Get()->set_minHeight(56.0);
- auto* SDlistcontainer = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(SDlistscroll->get_transform());
- SDlistcontainer->set_childAlignment(UnityEngine::TextAnchor::UpperCenter);
- SDlistcontainer->set_childForceExpandHeight(false);
- SDlistcontainer->set_childControlHeight(true);
-
- this->SDlistscroll->get_gameObject()->SetActive(QSoundsConfig::Config.menuClick_Active);
- }
- MenuClickRefreshList();
- }
-
- void MenuClickSdListViewController::DidDeactivate(bool removedFromHierarchy, bool systemScreenDisabling)
- {
- //QSoundsConfig::SaveConfig();
- for (UnityEngine::UI::Button* button : MenuClickQSlist) UnityEngine::Object::Destroy(button->get_transform()->get_parent()->get_gameObject());
- MenuClickQSlist = {};
- if (QSoundsConfig::Config.menuClick_Active && AudioClips::menuClickLoader.loaded) {
- AudioClips::menuClickArr = AudioClips::createAudioClipArray(AudioClips::menuClickLoader);
- BUIAM->randomSoundPicker->objects = AudioClips::menuClickArr;
- }
- else {
- AudioClips::origMenuClickArr = AudioClips::createAudioClipArray(AudioClips::menuClickLoader, true);
- BUIAM->randomSoundPicker->objects = AudioClips::origMenuClickArr;
- }
- }
-}
\ No newline at end of file
diff --git a/src/UI/ViewControllers/MenuSdListViewController.cpp b/src/UI/ViewControllers/MenuSdListViewController.cpp
deleted file mode 100644
index fc6f86e..0000000
--- a/src/UI/ViewControllers/MenuSdListViewController.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-#include "main.hpp"
-#include "QSoundsConfig.hpp"
-#include "ViewControllers/MenuSdListViewController.hpp"
-#include "AudioClips.hpp"
-
-#include
-#include
-#include
-#include
-#include
-
-#include "questui/shared/BeatSaberUI.hpp"
-#include "questui/shared/CustomTypes/Components/ExternalComponents.hpp"
-#include "questui/shared/CustomTypes/Components/MainThreadScheduler.hpp"
-
-#include "UnityEngine/Object.hpp"
-#include "UnityEngine/GameObject.hpp"
-#include "UnityEngine/Transform.hpp"
-#include "UnityEngine/RectTransform.hpp"
-#include "UnityEngine/UI/Button.hpp"
-#include "UnityEngine/UI/LayoutElement.hpp"
-#include "UnityEngine/UI/VerticalLayoutGroup.hpp"
-#include "UnityEngine/UI/HorizontalLayoutGroup.hpp"
-#include "UnityEngine/Events/UnityAction.hpp"
-#include "TMPro/TextMeshProUGUI.hpp"
-
-#include "GlobalNamespace/SongPreviewPlayer.hpp"
-
-using namespace QuestSounds;
-
-#ifndef REGISTER_FUNCTION
-DEFINE_TYPE(QuestSounds::ViewControllers, MenuSdListViewController);
-#elif defined(DEFINE_TYPE)
-DEFINE_TYPE(QuestSounds::ViewControllers::MenuSdListViewController);
-#elif defined(DEFINE_CLASS)
-DEFINE_CLASS(QuestSounds::ViewControllers::MenuSdListViewController);
-#endif
-
-namespace QuestSounds::ObjectInstances {
- GlobalNamespace::SongPreviewPlayer* SPP;
-}
-using namespace QuestSounds::ObjectInstances;
-
-namespace QuestSounds::ViewControllers {
-
- MenuSdListViewController* MenuListView;
- std::list MenuQSlist = {};
-
- void MenuSelectSound()
- {
- for (UnityEngine::UI::Button* button : MenuQSlist)
- {
- if (button->get_hasSelection())
- {
- std::string filename = to_utf8(csstrtostr(button->GetComponentInChildren()->get_text()));
- QSoundsConfig::Config.menuMusic_filepath = QSoundsConfig::MenuMusicPath + filename;
- QuestSounds::AudioClips::menuMusicLoader.filePath = QSoundsConfig::Config.menuMusic_filepath;
- AudioClips::menuMusicLoader.loaded = false;
- AudioClips::menuMusicLoader.load();
- std::thread replaceAudio([&]() {
- while (!AudioClips::menuMusicLoader.loaded && QSoundsConfig::Config.menuMusic_Active) {
- usleep(100);
- }
- if (!QSoundsConfig::Config.menuMusic_Active) {
- return;
- }
- if (AudioClips::menuMusicLoader.audioSource != nullptr) {
- return SPP->CrossfadeToNewDefault(AudioClips::menuMusicLoader.getClip());
- }
- });
- replaceAudio.detach();
- getLogger().debug("Selected Sound Path %s", QSoundsConfig::Config.menuMusic_filepath.c_str());
-
- }
- }
- }
-
- void MenuRefreshList()
- {
- if (MenuListView->listtxtgroup && MenuListView->listtxtgroup->m_CachedPtr.m_value) UnityEngine::GameObject::Destroy(MenuListView->listtxtgroup->get_gameObject());
- for (UnityEngine::UI::Button* button : MenuQSlist) UnityEngine::Object::Destroy(button->get_transform()->get_parent()->get_gameObject());
- MenuQSlist = {};
- DIR* sounddir = opendir(QSoundsConfig::MenuMusicPath.c_str());
- dirent* fileent;
- while ((fileent = readdir(sounddir)) != NULL)
- {
- std::string filename = fileent->d_name;
- for (char& ch : filename) ch = tolower(ch);
-
- if (std::regex_search(filename, std::regex(".ogg|.mp3|.mp2|.wav|.aiff|.aif")))
- {
- UnityEngine::UI::HorizontalLayoutGroup* rowgroup = QuestUI::BeatSaberUI::CreateHorizontalLayoutGroup(MenuListView->SDlistscroll->get_transform());
- UnityEngine::UI::Button* button = QuestUI::BeatSaberUI::CreateUIButton(rowgroup->get_rectTransform(), fileent->d_name, MenuSelectSound);
- button->get_gameObject()->GetComponentInChildren()->set_fontStyle(2);
- MenuQSlist.push_back(button);
- }
- }
- if (MenuQSlist.size() < 1)
- {
- MenuListView->listtxtgroup = QuestUI::BeatSaberUI::CreateHorizontalLayoutGroup(MenuListView->SDlistscroll->get_transform());
- QuestUI::BeatSaberUI::CreateText(MenuListView->listtxtgroup->get_rectTransform(), "No sound files were found!\nPlease add a sound file into\n"+ QSoundsConfig::MenuMusicPath +"\nto continue.", false)->set_enableWordWrapping(true);
- }
- (void)closedir(sounddir);
- }
-
- void MenuSdListViewController::DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
- {
- MenuListView = this;
- if (firstActivation && addedToHierarchy)
- {
- SPP = UnityEngine::GameObject::FindObjectOfType();
- UnityEngine::UI::VerticalLayoutGroup* container = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(get_rectTransform());
- container->set_spacing(0.4f);
- container->GetComponent()->set_minWidth(125.0);
-
-
- //Bool settings
- this->QSconfigcontainer = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(container->get_rectTransform());
- QSconfigcontainer->set_childAlignment(UnityEngine::TextAnchor::UpperCenter);
- QSconfigcontainer->set_childForceExpandHeight(false);
- QSconfigcontainer->set_childControlHeight(true);
-
- // Enable or Disable Custom Menu Music
- //QSoundsConfig::QSAddConfigValueToggle(QSconfigcontainer->get_rectTransform(), "Custom Menu Music", &QSoundsConfig::Config.menuMusic_Active, SDlistscroll, "Activates or deactivates Custom Menu Music");
- auto object = ::QuestUI::BeatSaberUI::CreateToggle(QSconfigcontainer->get_rectTransform(), "Custom Menu Music", QSoundsConfig::Config.menuMusic_Active,
- [&](bool value) {
- if (value) MenuRefreshList();
- QSoundsConfig::Config.menuMusic_Active = value;
- this->SDlistscroll->get_gameObject()->SetActive(value);
- if (AudioClips::menuMusicLoader.loaded && value) {
- SPP->CrossfadeToNewDefault(AudioClips::menuMusicLoader.getClip());
- }
- else {
- if (AudioClips::menuMusicLoader.OriginalAudioSource) SPP->CrossfadeToNewDefault(AudioClips::menuMusicLoader.get_OriginalClip());
- }
- });
- ::QuestUI::BeatSaberUI::AddHoverHint(object->get_gameObject(), "Activates or deactivates Custom Menu Music");
-
-
- //if (QSoundsConfig::LegacyConfig) QuestUI::BeatSaberUI::CreateText(settingsLayoutTransform, "Legacy Config Detected,\nplease move your files into the new folders,\nfor selection in-game", false);
- if (QSoundsConfig::LegacyConfig) {
- modal = QuestUI::BeatSaberUI::CreateModal(get_transform(), {40, 35}, nullptr);
-
- auto wrapper = QuestUI::BeatSaberUI::CreateHorizontalLayoutGroup(modal->get_transform());
- auto container = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(wrapper->get_transform());
- container->set_childAlignment(UnityEngine::TextAnchor::MiddleCenter);
-
- QuestUI::BeatSaberUI::CreateText(container->get_transform(), "Legacy Config Detected\nplease move your files\ninto the new folders,\nfor selection in-game\n\n", false)->set_alignment(TMPro::TextAlignmentOptions::Center);
-
- auto horizon = QuestUI::BeatSaberUI::CreateHorizontalLayoutGroup(container->get_transform());
-
- QuestUI::BeatSaberUI::CreateUIButton(horizon->get_transform(), "Close", UnityEngine::Vector2(0, -3), { 10, 7 }, [this]() -> void {
- modal->Hide(true, nullptr);
- });
-
- std::thread showModal([&]() {
- std::this_thread::sleep_for(std::chrono::milliseconds(500));
-
- QuestUI::MainThreadScheduler::Schedule([this]() {
- modal->Show(true, true, nullptr);
- });
- });
- showModal.detach();
- }
-
-
- //QSconfigcontainer->set_childForceExpandHeight(false);
- //QSconfigcontainer->set_childControlHeight(true);
-
- //UnityEngine::UI::Button::Button();
-
- //bool enabled_initval = getConfig().config["enabled"].GetBool();
- //this->masterEnabled = QuestUI::BeatSaberUI::CreateToggle(QSconfigcontainer->get_rectTransform(), "Enable Quest Sounds", enabled_initval, UnityEngine::Vector2(0, 0), OnChangeEnabled);
-
- // Sound List (recursively adds buttons as MenuListView isn't an easy type to deal with)
- this->SDlistscroll = QuestUI::BeatSaberUI::CreateScrollView(container->get_rectTransform());
- SDlistscroll->GetComponent()->Get()->set_minHeight(56.0);
- auto* SDlistcontainer = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(SDlistscroll->get_transform());
- SDlistcontainer->set_childAlignment(UnityEngine::TextAnchor::UpperCenter);
- SDlistcontainer->set_childForceExpandHeight(false);
- SDlistcontainer->set_childControlHeight(true);
-
- //this->SDlistscroll->get_gameObject()->SetActive(enabled_initval);
- this->SDlistscroll->get_gameObject()->SetActive(QSoundsConfig::Config.menuMusic_Active);
- }
- MenuRefreshList();
- }
-
- void MenuSdListViewController::DidDeactivate(bool removedFromHierarchy, bool systemScreenDisabling)
- {
- for (UnityEngine::UI::Button* button : MenuQSlist) UnityEngine::Object::Destroy(button->get_transform()->get_parent()->get_gameObject());
- MenuQSlist = {};
- //if (AudioClips::menuMusicLoader.loaded && QSoundsConfig::Config.menuMusic_Active) {
- // getLogger().debug("Returning custom audioClip");
- // SPP->CrossfadeToNewDefault(AudioClips::menuMusicLoader.getClip());
- //}
- //else {
- // getLogger().debug("Returning default audioClip");
- // SPP->CrossfadeToNewDefault(AudioClips::menuMusicLoader.get_OriginalClip());
- //}
- }
-}
diff --git a/src/UI/ViewControllers/NoteMissedSdListViewController.cpp b/src/UI/ViewControllers/NoteMissedSdListViewController.cpp
deleted file mode 100644
index 6f79085..0000000
--- a/src/UI/ViewControllers/NoteMissedSdListViewController.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-#include "main.hpp"
-#include "QSoundsConfig.hpp"
-#include "ViewControllers/NoteMissedSdListViewController.hpp"
-#include "AudioClips.hpp"
-
-#include
-#include
-#include
-
-#include "questui/shared/BeatSaberUI.hpp"
-#include "questui/shared/CustomTypes/Components/ExternalComponents.hpp"
-
-#include "UnityEngine/Object.hpp"
-#include "UnityEngine/GameObject.hpp"
-#include "UnityEngine/Transform.hpp"
-#include "UnityEngine/RectTransform.hpp"
-#include "UnityEngine/UI/Button.hpp"
-#include "UnityEngine/UI/LayoutElement.hpp"
-#include "UnityEngine/UI/VerticalLayoutGroup.hpp"
-#include "UnityEngine/UI/HorizontalLayoutGroup.hpp"
-#include "UnityEngine/Events/UnityAction.hpp"
-#include "TMPro/TextMeshProUGUI.hpp"
-
-using namespace QuestSounds;
-
-#ifndef REGISTER_FUNCTION
-DEFINE_TYPE(QuestSounds::ViewControllers, NoteMissedSdListViewController);
-#elif defined(DEFINE_TYPE)
-DEFINE_TYPE(QuestSounds::ViewControllers::NoteMissedSdListViewController);
-#elif defined(DEFINE_CLASS)
-DEFINE_CLASS(QuestSounds::ViewControllers::NoteMissedSdListViewController);
-#endif
-
-namespace QuestSounds::ViewControllers {
-
- NoteMissedSdListViewController* NoteMissedListView;
- std::list NoteMissedQSlist = {};
-
- void NoteMissedSelectSound()
- {
- for (UnityEngine::UI::Button* button : NoteMissedQSlist)
- {
- if (button->get_hasSelection())
- {
- std::string filename = static_cast(button->GetComponentInChildren()->get_text());
- QSoundsConfig::Config.noteMissedSound_filepath = QSoundsConfig::NoteMissedSoundPath + filename;
- AudioClips::noteMissedSoundLoader.filePath = QSoundsConfig::Config.noteMissedSound_filepath;
- if (AudioClips::noteMissedSoundLoader.audioSource != nullptr) AudioClips::noteMissedSoundLoader.audioSource->Stop();
- AudioClips::noteMissedSoundLoader.load();
- std::thread PlayAudio([&]() {
- while (!AudioClips::noteMissedSoundLoader.loaded && QSoundsConfig::Config.noteMissedSound_Active) {
- usleep(100);
- }
- if (!QSoundsConfig::Config.noteMissedSound_Active) {
- return;
- }
- if (AudioClips::noteMissedSoundLoader.audioSource != nullptr) {
- AudioClips::noteMissedSoundLoader.audioSource->set_volume(0.5f + QSoundsConfig::Config.noteMissedSound_audioVolumeOffset);
- return AudioClips::noteMissedSoundLoader.audioSource->Play();
- }
- });
- PlayAudio.detach();
- getLogger().debug("Selected Sound Path %s", QSoundsConfig::Config.badHitSound_filepath.c_str());
- }
- }
- }
-
- void NoteMissedRefreshList()
- {
- if (NoteMissedListView->listtxtgroup && NoteMissedListView->listtxtgroup->m_CachedPtr.m_value) UnityEngine::GameObject::Destroy(NoteMissedListView->listtxtgroup->get_gameObject());
- for (UnityEngine::UI::Button* button : NoteMissedQSlist) UnityEngine::Object::Destroy(button->get_transform()->get_parent()->get_gameObject());
- NoteMissedQSlist = {};
- DIR* sounddir = opendir(QSoundsConfig::NoteMissedSoundPath.c_str());
- dirent* fileent;
- while ((fileent = readdir(sounddir)) != NULL)
- {
- std::string filename = fileent->d_name;
- for (char& ch : filename) ch = tolower(ch);
-
- if (std::regex_search(filename, std::regex(".ogg|.mp3|.mp2|.wav|.aiff|.aif")))
- {
- UnityEngine::UI::HorizontalLayoutGroup* rowgroup = QuestUI::BeatSaberUI::CreateHorizontalLayoutGroup(NoteMissedListView->SDlistscroll->get_transform());
- UnityEngine::UI::Button* button = QuestUI::BeatSaberUI::CreateUIButton(rowgroup->get_rectTransform(), fileent->d_name, NoteMissedSelectSound);
- button->get_gameObject()->GetComponentInChildren()->set_fontStyle(2);
- NoteMissedQSlist.push_back(button);
- }
- }
- if (NoteMissedQSlist.size() < 1)
- {
- NoteMissedListView->listtxtgroup = QuestUI::BeatSaberUI::CreateHorizontalLayoutGroup(NoteMissedListView->SDlistscroll->get_transform());
- QuestUI::BeatSaberUI::CreateText(NoteMissedListView->listtxtgroup->get_rectTransform(), "No sound files were found!\nPlease add a sound file into\n"+ QSoundsConfig::NoteMissedSoundPath +"\nto continue.", false)->set_enableWordWrapping(true);
- }
- (void)closedir(sounddir);
- }
-
- void NoteMissedSdListViewController::DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
- {
- NoteMissedListView = this;
- if (firstActivation && addedToHierarchy)
- {
- UnityEngine::UI::VerticalLayoutGroup* container = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(get_rectTransform());
- container->set_spacing(0.4f);
- container->GetComponent()->set_minWidth(125.0);
-
- // Bool settings
- this->QSconfigcontainer = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(container->get_rectTransform());
- QSconfigcontainer->set_childAlignment(UnityEngine::TextAnchor::UpperCenter);
- QSconfigcontainer->set_childForceExpandHeight(false);
- QSconfigcontainer->set_childControlHeight(true);
-
- // Enable or Disable BadHitSounds
- //QSoundsConfig::QSAddConfigValueToggle(QSconfigcontainer->get_rectTransform(), "Custom BadHitSounds", &QSoundsConfig::Config.noteMissedSound_Active, this, "Activates or deactivates Custom BadHitSounds");
- auto object = ::QuestUI::BeatSaberUI::CreateToggle(QSconfigcontainer->get_rectTransform(), "Custom Note Missed Sounds", QSoundsConfig::Config.noteMissedSound_Active,
- [&](bool value) {
- if (value) NoteMissedRefreshList();
- QSoundsConfig::Config.noteMissedSound_Active = value;
- this->SDlistscroll->get_gameObject()->SetActive(value);
- if (AudioClips::noteMissedSoundLoader.audioSource != nullptr) AudioClips::noteMissedSoundLoader.audioSource->Stop();
- });
- ::QuestUI::BeatSaberUI::AddHoverHint(object->get_gameObject(), "Activates or deactivates Custom Note Missed Sounds");
-
- // AudioVolumeOffset Slider
- QuestUI::SliderSetting* volumeSlider = ::QuestUI::BeatSaberUI::CreateSliderSetting(QSconfigcontainer->get_rectTransform(), "Volume Offset", 0.01f, QSoundsConfig::Config.noteMissedSound_audioVolumeOffset, -1.0f, 1.0f, 0.5f, [](float volume) {
- // Checks for safety
- QSoundsConfig::Config.noteMissedSound_audioVolumeOffset = volume;
- if (AudioClips::noteMissedSoundLoader.loaded) {
- if (AudioClips::noteMissedSoundLoader.audioSource->get_isPlaying()) AudioClips::noteMissedSoundLoader.audioSource->Stop();
- AudioClips::noteMissedSoundLoader.audioSource->set_volume(0.5f + volume);
- AudioClips::noteMissedSoundLoader.audioSource->Play();
- }
- //std::thread PlayAudio([&]() {
- // usleep(100);
- //});
- });
- QuestUI::BeatSaberUI::AddHoverHint(volumeSlider->get_gameObject(), "Lets you select a Volume Offset that is applied to the sound");
-
- // Sound List (recursively adds buttons as ListView isn't an easy type to deal with)
- this->SDlistscroll = QuestUI::BeatSaberUI::CreateScrollView(container->get_rectTransform());
- SDlistscroll->GetComponent()->Get()->set_minHeight(56.0);
- auto* SDlistcontainer = QuestUI::BeatSaberUI::CreateVerticalLayoutGroup(SDlistscroll->get_transform());
- SDlistcontainer->set_childAlignment(UnityEngine::TextAnchor::UpperCenter);
- SDlistcontainer->set_childForceExpandHeight(false);
- SDlistcontainer->set_childControlHeight(true);
-
- this->SDlistscroll->get_gameObject()->SetActive(QSoundsConfig::Config.noteMissedSound_Active);
- }
- NoteMissedRefreshList();
- }
-
- void NoteMissedSdListViewController::DidDeactivate(bool removedFromHierarchy, bool systemScreenDisabling)
- {
- //QSoundsConfig::SaveConfig();
- for (UnityEngine::UI::Button* button : NoteMissedQSlist) UnityEngine::Object::Destroy(button->get_transform()->get_parent()->get_gameObject());
- NoteMissedQSlist = {};
- }
-}
diff --git a/src/Utils/AsyncAudioClipLoader.cpp b/src/Utils/AsyncAudioClipLoader.cpp
new file mode 100644
index 0000000..5195704
--- /dev/null
+++ b/src/Utils/AsyncAudioClipLoader.cpp
@@ -0,0 +1,236 @@
+// #include "QSoundsConfig.hpp"
+#include "Utils/AsyncAudioClipLoader.hpp"
+#include "main.hpp"
+#include "logging.hpp"
+#include "Config.hpp"
+#include "ObjectInstances.hpp"
+
+#include
+#include
+
+#include
+
+#include "custom-types/shared/delegate.hpp"
+#include "bsml/shared/BSML/MainThreadScheduler.hpp"
+#include "bsml/shared/BSML/SharedCoroutineStarter.hpp"
+
+#include "UnityEngine/Networking/DownloadHandlerAudioClip.hpp"
+#include "UnityEngine/Networking/UnityWebRequestMultimedia.hpp"
+using namespace UnityEngine::Networking;
+
+#include "System/Threading/Tasks/TaskStatus.hpp"
+#include "System/Threading/Tasks/Task.hpp"
+#include "System/Threading/Tasks/Task_1.hpp"
+#include "System/Action_1.hpp"
+using namespace System;
+
+#include "UnityEngine/AudioType.hpp"
+#include "UnityEngine/AsyncOperation.hpp"
+#include "UnityEngine/GameObject.hpp"
+#include "UnityEngine/WaitForSeconds.hpp"
+using namespace UnityEngine;
+
+int getAudioType(std::string path) {
+ if (path.ends_with(".ogg")) {
+ getLogger().debug("File is OGGVORBIS");
+ return (int)UnityEngine::AudioType::OGGVORBIS;
+ }
+ else if (path.ends_with(".mp3") || path.ends_with(".mp2")) {
+ getLogger().debug("File is MPEG");
+ return (int)UnityEngine::AudioType::MPEG;
+ }
+ else if (path.ends_with(".wav")) {
+ getLogger().debug("File is WAV");
+ return (int)UnityEngine::AudioType::WAV;
+ }
+ else if (path.ends_with(".aiff") || path.ends_with(".aif")) {
+ getLogger().debug("File is AIFF");
+ return (int)UnityEngine::AudioType::AIFF;
+ }
+ return 0;
+}
+
+System::Threading::Tasks::Task_1* audioClipTask;
+//bool NeedReload = false;
+
+bool QuestSounds::Utils::AsyncAudioClipLoader::load()
+{
+ loaded = false;
+ //Stage 0
+ bool fileError;
+ getLogger().info("Starting Stage 0");
+ getLogger().info("FilePath to check is {}", filePath.c_str());
+ if (filePath.starts_with("https://") || filePath.starts_with("http://")) {
+ getLogger().info("Filepath is URL, skipping file checks and try loading it");
+ fileError = true;
+ }
+ else {
+ // Checks if the given File in the config exists and
+ fileError = fileexists(filePath);
+ getLogger().info("Check file no error is {}", fileError);
+ if (!fileError)
+ {
+ getLogger().error("File {} not found", filePath.c_str());
+ getLogger().error("Stage 0 Failed");
+ return false;
+ }
+ else { getLogger().info("Stage 0 Done with {}", filePath.c_str()); }
+ }
+
+ //Stage 1
+ if ((filePath.ends_with(".ogg") || filePath.ends_with(".wav")) && streamAudio) {
+ getLogger().info("Stage 1: Running MediaAsyncLoader for FilePath {}", filePath.c_str());
+ loadPath = filePath;
+ // Ensure MediaAsyncLoader is initialized
+ if (!classof(GlobalNamespace::MediaAsyncLoader*)->initialized) {
+ getLogger().info("MediaAsyncLoader class not initialized, initializing it");
+ il2cpp_functions::Class_Init(classof(GlobalNamespace::MediaAsyncLoader*));
+ }
+ // We always create a new instance of MediaAsyncLoader to avoid audioclip loading issues
+ audioClipTask = GlobalNamespace::MediaAsyncLoader::New_ctor()->LoadAudioClipFromFilePathAsync(loadPath);
+
+ audioClipTask->GetAwaiter().OnCompleted(custom_types::MakeDelegate(std::function([this]()
+ {
+ getLogger().info("Stage 1: Running MediaAsyncLoader for FilePath {} status is {}", filePath, EnumHelper::GetEnumName(audioClipTask->get_Status()));
+ audioClipCompleted(audioClipTask->get_Result());
+ })));
+ }
+ else {
+ getLogger().info("Stage 1: Running UnityWebRequestMultimedia for FilePath {}", filePath);
+ if (filePath.starts_with("https://") || filePath.starts_with("http://")) {
+ loadPath = filePath;
+ }
+ else {
+ // EscapeURL but also replaces spaces with %20 since the UnityWebRequest replaces spaces with + which causes unitys curl call to fail
+ loadPath = "file:///" + UnityEngine::Networking::UnityWebRequest::EscapeURL(std::regex_replace(filePath, std::regex(" "), "%20"));
+ }
+ audioType = getAudioType(filePath);
+
+ BSML::SharedCoroutineStarter::get_instance()->StartCoroutine(custom_types::Helpers::CoroutineHelper::New(LoadAudioClip()));
+ }
+ getLogger().info("Stage 1 done with loadPath {}", loadPath);
+ return true;
+}
+
+custom_types::Helpers::Coroutine QuestSounds::Utils::AsyncAudioClipLoader::LoadAudioClip()
+{
+ if (audioClipRequest && !audioClipRequest->isDone) {
+ getLogger().info("Stage 1: Cancelling previous request for LoadPath {}", loadPath);
+ try {
+ audioClipRequest->Abort();
+ }
+ catch (const std::exception& e) {
+ getLogger().error("Stage 1: Failed to abort previous request for LoadPath {} with error {}", loadPath, e.what());
+ }
+ }
+ getLogger().info("Stage 1: Running UnityWebRequestMultimedia for LoadPath {}", loadPath);
+ audioClipRequest = UnityEngine::Networking::UnityWebRequestMultimedia::GetAudioClip(loadPath, audioType);
+ audioClipAsync = audioClipRequest->SendWebRequest();
+ audioClipAsync->allowSceneActivation = false;
+ getLogger().debug("Stage 1: UnityWebRequestMultimedia for LoadPath {} started", loadPath);
+ co_yield reinterpret_cast(audioClipAsync);
+
+ if (audioClipRequest->GetError() != UnityEngine::Networking::UnityWebRequest::UnityWebRequestError::OK) {
+ getLogger().error("UnityWebRequestMultimedia for path '{}' failed with error {}", loadPath, EnumHelper::GetEnumName(audioClipRequest->GetError()));
+ co_return;
+ }
+ else {
+ auto downloaderHandlerOpt = il2cpp_utils::try_cast(audioClipRequest->downloadHandler);
+ if (!downloaderHandlerOpt.has_value()) {
+ getLogger().error("UnityWebRequestMultimedia for path '{}' failed to get DownloadHandlerAudioClip", loadPath);
+ co_return;
+ }
+ auto downloadHandler = downloaderHandlerOpt.value();
+ while (!audioClipRequest->isDone && audioClipRequest->downloadedBytes < 1024)
+ {
+ // // auto value = audioClipRequest->GetError().value__;
+ // getLogger().info("UnityWebRequestMultimedia for path '{}' downloaded {} bytes error state {}", loadPath, audioClipRequest->downloadedBytes,
+ // EnumHelper::GetEnumName(audioClipRequest->GetError()));
+ // // ((System::Type*)csTypeOf(UnityEngine::Networking::UnityWebRequest::UnityWebRequestError))->GetEnumName((System::Object*)il2cpp_functions::value_box(classof(::UnityEngine::Networking::__UnityWebRequest__UnityWebRequestError), &value)));
+ // co_yield reinterpret_cast(UnityEngine::WaitForSeconds::New_ctor(0.1f));
+ }
+ if (audioClipRequest->get_result() == UnityWebRequest::Result::Success) {
+ getLogger().info("UnityWebRequestMultimedia for path '{}' completed successfully", loadPath);
+
+ // We stream the audio to avoid blocking the main thread
+ downloadHandler->streamAudio = streamAudio;
+ audioClipCompleted(downloadHandler->audioClip);
+ audioClipAsync->allowSceneActivation = true;
+ }
+ else {
+ getLogger().error("UnityWebRequestMultimedia for path '{}' failed with result {}", loadPath, EnumHelper::GetEnumName(audioClipRequest->get_result()));
+ }
+ audioClipRequest->Dispose();
+ audioClipRequest = nullptr;
+ }
+ co_return;
+}
+
+void QuestSounds::Utils::AsyncAudioClipLoader::audioClipCompleted(::UnityW audioClip)
+{
+ // Stage 2
+ getLogger().info("Starting Stage 2");
+
+ if(audioClip)
+ {
+ getLogger().info("audioClip is not nullptr setting it to AudioSource for filepath {}", filePath);
+ if (!this->audioClipGO) {
+ static auto goName = ConstString("QuestSoundsAudioClipGO");
+ audioClipGO = GameObject::New_ctor(goName);
+ audioSource = audioClipGO->AddComponent();
+ UnityEngine::Object::DontDestroyOnLoad(audioClipGO);
+ }
+ audioSource->set_playOnAwake(false);
+ audioSource->set_clip(audioClip);
+ audioSource->set_volume(0.6f);
+ loaded = true;
+ getLogger().info("Stage 2 done for path '{}' with audioClip", filePath);
+ }
+ else {
+ getLogger().error("Stage 2 failed with audioClip being nullptr {} Object path: {}", fmt::ptr(audioClip.convert()), filePath);
+ return;
+ } // Finished
+}
+
+UnityEngine::AudioClip* QuestSounds::Utils::AsyncAudioClipLoader::getClip()
+{
+ if(audioSource != nullptr && loaded)
+ {
+ getLogger().debug("AudioClip returned");
+ return audioSource->get_clip();
+ } else
+ {
+ getLogger().debug("nullptr returned: is AudioSource null: {}, is loaded: {}", fmt::ptr(audioSource), loaded);
+ return nullptr;
+ }
+}
+
+void QuestSounds::Utils::AsyncAudioClipLoader::set_OriginalClip(AudioClip* OriginalAudioClip)
+{
+ // Stage 1
+ if (OriginalAudioClip != nullptr)
+ {
+ static auto goName = ConstString("OrigAudioClipGO");
+ GameObject* audioClipGO = GameObject::New_ctor(goName);
+ OriginalAudioSource = audioClipGO->AddComponent();
+ OriginalAudioSource->set_playOnAwake(false);
+ OriginalAudioSource->set_clip(OriginalAudioClip);
+ UnityEngine::Object::DontDestroyOnLoad(audioClipGO);
+ getLogger().debug("Saved Original AudioClip");
+ }
+ // Finished
+}
+
+UnityEngine::AudioClip* QuestSounds::Utils::AsyncAudioClipLoader::get_OriginalClip()
+{
+ if (OriginalAudioSource != nullptr)
+ {
+ getLogger().debug("OrignalAudioClip returned");
+ return OriginalAudioSource->get_clip();
+ }
+ else
+ {
+ getLogger().debug("nullptr returned: is OriginalAudioSource null: {}", fmt::ptr(OriginalAudioSource));
+ return nullptr;
+ }
+}
\ No newline at end of file
diff --git a/src/Utils/AsyncAudiocliploader.cpp b/src/Utils/AsyncAudiocliploader.cpp
deleted file mode 100644
index e54e2dd..0000000
--- a/src/Utils/AsyncAudiocliploader.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-#include "QSoundsConfig.hpp"
-#include "Utils/AsyncAudiocliploader.hpp"
-#include "main.hpp"
-#include "ObjectInstances.hpp"
-
-#include
-#include
-
-#include
-
-#include "UnityEngine/Networking/DownloadHandlerAudioClip.hpp"
-#include "UnityEngine/Networking/UnityWebRequestMultimedia.hpp"
-using namespace UnityEngine::Networking;
-
-#include "System/Threading/Tasks/TaskStatus.hpp"
-#include "System/Threading/Tasks/Task.hpp"
-#include "System/Threading/Tasks/Task_1.hpp"
-#include "System/Action_1.hpp"
-using namespace System;
-
-#include "UnityEngine/AsyncOperation.hpp"
-#include "UnityEngine/GameObject.hpp"
-using namespace UnityEngine;
-
-int getAudioType(std::string path) {
- if (path.ends_with(".ogg")) {
- getLogger().debug("File is OGGVORBIS");
- return 0xE;
- }
- else if (path.ends_with(".mp3") || path.ends_with(".mp2")) {
- getLogger().debug("File is MPEG");
- return 0xD;
- }
- else if (path.ends_with(".wav")) {
- getLogger().debug("File is WAV");
- return 0x14;
- }
- else if (path.ends_with(".aiff") || path.ends_with(".aif")) {
- getLogger().debug("File is AIFF");
- return 2;
- }
- return 0;
-}
-
-System::Threading::Tasks::Task_1* audioClipTask;
-//bool NeedReload = false;
-
-bool AsyncAudioClipLoader::loader::load()
-{
- loaded = false;
- //Stage 0
- bool fileError;
- getLogger().info("Starting Stage 0");
- getLogger().info("FilePath to check is %s", filePath.c_str());
- Il2CppString* filePathStr;
- if (filePath.starts_with("https://") || filePath.starts_with("http://")) {
- getLogger().info("Filepath is URL, skipping file checks and try loading it");
- fileError = true;
- }
- else {
- // Checks if the given File in the config exists and
- fileError = fileexists(filePath);
- getLogger().info("File error is %d", fileError);
- if (!fileError)
- {
- getLogger().error("File %s not found", filePath.c_str());
- getLogger().error("Stage 0 Failed");
- return false;
- }
- else { getLogger().info("Stage 0 Done with %s", filePath.c_str()); }
- }
-
- //Stage 1
- if (!(filePath == QSoundsConfig::Config.hitSound_filepath) && filePath.ends_with(".ogg")) {
- getLogger().info("Stage 1: Running MediaAsyncLoader for FilePath %s", filePath.c_str());
- UsesUWR = false;
- filePathStr = il2cpp_utils::newcsstr(filePath);
- audioClipTask = GlobalNamespace::MediaAsyncLoader::New_ctor()->LoadAudioClipFromFilePathAsync(filePathStr);
- ////Stage 2
- auto actionMAL = il2cpp_utils::MakeDelegate*>(classof(System::Action_1*), this, audioClipCompleted);
- reinterpret_cast(audioClipTask)->ContinueWith(actionMAL);
- }
- else {
- getLogger().info("Stage 1: Running UnityWebRequestMultimedia for FilePath %s", filePath.c_str());
- UsesUWR = true;
- if (filePath.starts_with("https://") || filePath.starts_with("http://")) {
- filePathStr = il2cpp_utils::newcsstr(filePath);
- }
- else {
- filePathStr = il2cpp_utils::newcsstr("file:///" + filePath);
- }
- audioType = getAudioType(filePath);
-
- auto actionUWRM = il2cpp_utils::MakeDelegate*>(classof(System::Action_1*), this, audioClipCompleted);
-
- audioClipRequest = UnityEngine::Networking::UnityWebRequestMultimedia::GetAudioClip(filePathStr, audioType);
- audioClipAsync = audioClipRequest->SendWebRequest();
- audioClipAsync->set_allowSceneActivation(false);
-
- if (!audioClipRequest->get_isHttpError() || !audioClipRequest->get_isNetworkError()) {
- //Stage 2
- audioClipAsync->add_completed(actionUWRM);
- }
- }
- getLogger().info("Stage 1 done with filepath %s", filePath.c_str());
- return true;
-}
-
-void AsyncAudioClipLoader::loader::audioClipCompleted(loader* obj, Il2CppObject* asyncOp)
-{
- // Stage 1
- UnityEngine::AudioClip* temporaryClip = nullptr;
- if (!obj->UsesUWR) {
- temporaryClip = obj->audioClipTask->get_ResultOnSuccess();
- il2cpp_functions::GC_free(obj->audioClipTask);
- obj->audioClipTask = nullptr;
- }
- else if (obj->UsesUWR) temporaryClip = UnityEngine::Networking::DownloadHandlerAudioClip::GetContent(obj->audioClipRequest); // TODO: This method takes too long
-
- if(temporaryClip != nullptr)
- {
- if (!obj->audioClipGO) {
- static auto goName = il2cpp_utils::newcsstr("AudioClipGO");
- obj->audioClipGO = GameObject::New_ctor(goName);
- obj->audioSource = obj->audioClipGO->AddComponent();
- UnityEngine::Object::DontDestroyOnLoad(obj->audioClipGO);
- }
- obj->audioSource->set_playOnAwake(false);
- obj->audioSource->set_clip(temporaryClip);
- obj->audioSource->set_volume(0.6f);
- obj->loaded = true;
- getLogger().info("Stage 2 done with temporaryClip");
- }
- else {
- getLogger().error("Stage 2 failed with temporaryClip being nullptr %p Object FilePath: %s", temporaryClip, obj->filePath.c_str());
- if (!obj->UsesUWR) getLogger().error("Task Status was %d", (int)obj->audioClipTask->get_Status());
- return;
- } // Finished
-}
-
-UnityEngine::AudioClip* AsyncAudioClipLoader::loader::getClip()
-{
- if(audioSource != nullptr && loaded)
- {
- getLogger().debug("AudioClip returned");
- return audioSource->get_clip();
- } else
- {
- getLogger().debug("nullptr returned: is AudioSource null: %p, is loaded: %d", audioSource, loaded);
- return nullptr;
- }
-}
-
-void AsyncAudioClipLoader::loader::set_OriginalClip(AudioClip* OriginalAudioClip)
-{
- // Stage 1
- if (OriginalAudioClip != nullptr)
- {
- static auto goName = il2cpp_utils::newcsstr("OrigAudioClipGO");
- GameObject* audioClipGO = GameObject::New_ctor(goName);
- OriginalAudioSource = audioClipGO->AddComponent();
- OriginalAudioSource->set_playOnAwake(false);
- OriginalAudioSource->set_clip(OriginalAudioClip);
- UnityEngine::Object::DontDestroyOnLoad(audioClipGO);
- getLogger().debug("Saved Original AudioClip");
- }
- // Finished
-}
-
-UnityEngine::AudioClip* AsyncAudioClipLoader::loader::get_OriginalClip()
-{
- if (OriginalAudioSource != nullptr)
- {
- getLogger().debug("OrignalAudioClip returned");
- return OriginalAudioSource->get_clip();
- }
- else
- {
- getLogger().debug("nullptr returned: is OriginalAudioSource null: %p", OriginalAudioSource);
- return nullptr;
- }
-}
\ No newline at end of file
diff --git a/src/main.cpp b/src/main.cpp
index 771e808..d523645 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,506 +1,281 @@
-#include "main.hpp"
-#include "Utils/AsyncAudiocliploader.hpp"
-#include "QSoundsConfig.hpp"
-using namespace QSoundsConfig;
-#include "AudioClips.hpp"
-using namespace QuestSounds::AudioClips;
-
-#include "GlobalNamespace/ResultsViewController.hpp"
-#include "GlobalNamespace/SongPreviewPlayer.hpp"
-#include "GlobalNamespace/NoteCutSoundEffectManager.hpp"
-#include "GlobalNamespace/NoteCutSoundEffect.hpp"
-#include "GlobalNamespace/NoteController.hpp"
-#include "GlobalNamespace/NoteData.hpp"
-#include "GlobalNamespace/BasicUIAudioManager.hpp"
-#include "GlobalNamespace/FireworkItemController.hpp"
-#include "GlobalNamespace/GameServerLobbyFlowCoordinator.hpp"
-#include "GlobalNamespace/MultiplayerModeSelectionFlowCoordinator.hpp"
-#include "GlobalNamespace/BeatmapObjectManager.hpp"
-#include "GlobalNamespace/PauseMenuManager.hpp"
-
-#include "GlobalNamespace/FileHelpers.hpp"
-
-#include "GlobalNamespace/LevelCompletionResults.hpp"
-#include "GlobalNamespace/SongPreviewPlayer_AudioSourceVolumeController.hpp"
-using namespace GlobalNamespace;
-
-#include "System/Action.hpp"
-
-#include "UnityEngine/SceneManagement/Scene.hpp"
-#include "UnityEngine/SceneManagement/SceneManager.hpp"
-#include "UnityEngine/MonoBehaviour.hpp"
-#include "UnityEngine/WaitForSeconds.hpp"
-#include "UnityEngine/Time.hpp"
-using namespace UnityEngine::SceneManagement;
-
-#include "questui/shared/BeatSaberUI.hpp"
-#include "questui/shared/QuestUI.hpp"
-using namespace QuestUI;
-
-#include "ViewControllers/MenuSdListViewController.hpp"
-#include "ViewControllers/HitSdListViewController.hpp"
-#include "ViewControllers/MenuClickSdListViewController.hpp"
-#include "ViewControllers/BadHitSdListViewController.hpp"
-#include "ViewControllers/FireworkSdListViewController.hpp"
-#include "ViewControllers/LevelClearedSdListViewController.hpp"
-#include "ViewControllers/LobbyMusicSdListViewController.hpp"
-#include "ViewControllers/ConfigViewController.hpp"
-#include "QSoundsFlowCoordinator.hpp"
-using namespace QuestSounds;
-
-#include "custom-types/shared/register.hpp"
-using namespace custom_types;
-
-#if defined(MAKE_HOOK_OFFSETLESS) && !defined(MAKE_HOOK_MATCH)
-#error Incompatible hook macro
-#elif defined(MAKE_HOOK_MATCH)
-#else
-#error No Compatible HOOK macro found
-#endif
-
-#define RAPIDJSON_HAS_STDSTRING 1
-
-ModInfo modInfo;
-
-Configuration& getConfig() {
- static Configuration config(modInfo);
- //config.Load();
- return config;
-}
-
-Logger& getLogger() {
- static auto logger = new Logger(modInfo, LoggerOptions(false, true));
- return *logger;
-}
-
-void makeFolder()
-{
- if (!direxists(MenuMusicPath.c_str()))
- {
- int makePath = mkpath(MenuMusicPath.c_str());
- if (makePath == -1)
- {
- getLogger().error("Failed to make MenuMusic Folder path!");
- }
- }
-
- if (!direxists(HitSoundPath.c_str()))
- {
- int makePath = mkpath(HitSoundPath.c_str());
- if (makePath == -1)
- {
- getLogger().error("Failed to make HitSound Folder path!");
- }
- }
-
- if (!direxists(BadHitSoundPath.c_str()))
- {
- int makePath = mkpath(BadHitSoundPath.c_str());
- if (makePath == -1)
- {
- getLogger().error("Failed to make BadHitSound Folder path!");
- }
- }
-
- if (!direxists(NoteMissedSoundPath.c_str()))
- {
- int makePath = mkpath(NoteMissedSoundPath.c_str());
- if (makePath == -1)
- {
- getLogger().error("Failed to make NoteMissedSound Folder path!");
- }
- }
-
- if (!direxists(MenuClickPath.c_str()))
- {
- int makePath = mkpath(MenuClickPath.c_str());
- if (makePath == -1)
- {
- getLogger().error("Failed to make MenuClick Folder path!");
- }
- }
-
- if (!direxists(FireworkSoundPath.c_str()))
- {
- int makePath = mkpath(FireworkSoundPath.c_str());
- if (makePath == -1)
- {
- getLogger().error("Failed to make FireworkSound Folder path!");
- }
- }
-
- if (!direxists(LevelClearedPath.c_str()))
- {
- int makePath = mkpath(LevelClearedPath.c_str());
- if (makePath == -1)
- {
- getLogger().error("Failed to make LevelCleared Folder path!");
- }
- }
-
- if (!direxists(LevelFailedPath.c_str()))
- {
- int makePath = mkpath(LevelFailedPath.c_str());
- if (makePath == -1)
- {
- getLogger().error("Failed to make LevelFailed Folder path!");
- }
- }
-
-#ifndef BS__1_13_2
- if (!direxists(LobbyMusicPath.c_str()))
- {
- int makePath = mkpath(LobbyMusicPath.c_str());
- if (makePath == -1)
- {
- getLogger().error("Failed to make LobbyMusic Folder path!");
- }
- }
-#endif
-}
-
-
-
-namespace QuestSounds::AudioClips {
-/*audioClipLoader::loader*/
-AsyncAudioClipLoader::loader hitSoundLoader, // hitSound
- badHitSoundLoader, // badHitSound
- noteMissedSoundLoader,
- menuMusicLoader, // menuMusic
- menuClickLoader,
- fireworkSoundLoader,
- levelClearedLoader,
- levelFailedLoader, // For LevelFailed sound
-#ifndef BS__1_13_2
- lobbyAmbienceLoader; // Added for LobbyMusic
-#endif
-Array * hitSoundArr, // hitSoundArray
- * badHitSoundArr, // badHitSoundArray
- * menuClickArr,
- * fireworkSoundArr;
-
-
-Array* origMenuClickArr;
-
- void loadAudioClips()
- {
- hitSoundLoader.filePath = Config.hitSound_filepath;
- badHitSoundLoader.filePath = Config.badHitSound_filepath;
- noteMissedSoundLoader.filePath = Config.noteMissedSound_filepath;
- menuMusicLoader.filePath = Config.menuMusic_filepath;
- menuClickLoader.filePath = Config.menuClick_filepath;
- fireworkSoundLoader.filePath = Config.firework_filepath;
- levelClearedLoader.filePath = Config.levelCleared_filepath;
- levelFailedLoader.filePath = Config.levelFailed_filepath;
- lobbyAmbienceLoader.filePath = Config.lobbyAmbience_filepath; // Added for LobbyMusic
-
- menuMusicLoader.load();
- menuClickLoader.load();
- if (Config.hitSound_Active) hitSoundLoader.load();
- if (Config.badHitSound_Active) badHitSoundLoader.load();
- if (Config.noteMissedSound_Active) noteMissedSoundLoader.load();
- if (Config.firework_Active) fireworkSoundLoader.load();
- if (Config.levelCleared_Active) levelClearedLoader.load();
- if (Config.levelFailed_Active) levelFailedLoader.load();
- if (Config.lobbyAmbience_Active) lobbyAmbienceLoader.load(); // Added for LobbyMusic
- }
- // Creates an Array, of AudioClips
- Array* createAudioClipArray(AsyncAudioClipLoader::loader clipLoader, bool GetOriginalClip)
- {
- UnityEngine::AudioClip* tempClip;
- if (!GetOriginalClip) tempClip = clipLoader.getClip();
- else tempClip = clipLoader.get_OriginalClip();
- auto* temporaryArray = Array::New(tempClip);
- //temporaryArray->values[0] = tempClip;
- return temporaryArray;
- //return ArrayW({ tempClip });
- }
-}
-
-MAKE_HOOK_MATCH(ResultsViewController_DidActivate, &ResultsViewController::DidActivate, void, ResultsViewController* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) {
- if (firstActivation && addedToHierarchy && !levelClearedLoader.OriginalAudioSource) {
- levelClearedLoader.set_OriginalClip(self->levelClearedAudioClip);
- }
- if (self->levelCompletionResults->levelEndStateType == LevelCompletionResults::LevelEndStateType::Failed) {
- self->songPreviewPlayer->StopAllCoroutines();
- if (levelFailedLoader.loaded && addedToHierarchy && QSoundsConfig::Config.levelFailed_Active) {
- UnityEngine::AudioClip* FailedSound = levelFailedLoader.getClip();
- float length = FailedSound->get_length();
- getLogger().debug("Duration of LevelFailed Sound: %f", length);
- if (length > 7.0f) {
- getLogger().info("Long LevelFailedSound");
- self->songPreviewPlayer->CrossfadeTo(FailedSound, -4.0f, 0.0f, length, nullptr);
- }
- else {
- getLogger().info("Short LevelFailedSound");
- self->songPreviewPlayer->FadeOut(0.1f);
- self->songPreviewPlayer->fadeSpeed = self->songPreviewPlayer->fadeInSpeed;
- getLogger().debug("volume: %f", self->songPreviewPlayer->volume);
- getLogger().debug("AmbientVolume: %f", self->songPreviewPlayer->ambientVolumeScale);
- getLogger().debug("Set Volume: %f", self->songPreviewPlayer->volume * self->songPreviewPlayer->ambientVolumeScale);
-
- levelFailedLoader.audioSource->set_volume(self->songPreviewPlayer->volume * self->songPreviewPlayer->ambientVolumeScale);
- self->songPreviewPlayer->StartCoroutine(self->songPreviewPlayer->CrossFadeAfterDelayCoroutine(length - 1.2f));
- levelFailedLoader.audioSource->Play();
- }
- }
- }
- else {
- if (levelClearedLoader.loaded && addedToHierarchy && QSoundsConfig::Config.levelCleared_Active)
- {
- UnityEngine::AudioClip* audioClip = levelClearedLoader.getClip();
- self->levelClearedAudioClip = audioClip;
- }
- else {
- self->levelClearedAudioClip = levelClearedLoader.get_OriginalClip();
- }
- }
- ResultsViewController_DidActivate(self, firstActivation, addedToHierarchy, screenSystemEnabling);
-}
-
-MAKE_HOOK_MATCH(ResultsViewController_RestartButtonPressed, &ResultsViewController::RestartButtonPressed, void, ResultsViewController* self) {
- if (levelFailedLoader.loaded && levelFailedLoader.audioSource->get_isPlaying()) {
- levelFailedLoader.audioSource->Stop();
- }
- ResultsViewController_RestartButtonPressed(self);
-}
-
-MAKE_HOOK_MATCH(SongPreviewPlayer_OnEnable, &SongPreviewPlayer::OnEnable, void, SongPreviewPlayer* self) {
- getLogger().info("is it true: %i", menuMusicLoader.loaded);
-
- if (!menuMusicLoader.OriginalAudioSource) {
- menuMusicLoader.set_OriginalClip(self->defaultAudioClip);
- }
-
- if (menuMusicLoader.loaded && QSoundsConfig::Config.menuMusic_Active)
- {
- UnityEngine::AudioClip* audioClip = menuMusicLoader.getClip();
- if (audioClip != nullptr)
- self->defaultAudioClip = audioClip;
- }
- else {
- self->defaultAudioClip = menuMusicLoader.get_OriginalClip();
- }
- SongPreviewPlayer_OnEnable(self);
-}
-
-#ifndef BS__1_13_2
-MAKE_HOOK_MATCH(GameServerLobbyFlowCoordinator_DidActivate, &GameServerLobbyFlowCoordinator::DidActivate, void, GameServerLobbyFlowCoordinator* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
-{
- getLogger().debug("GameServerLobbyFlowCoordinator_DidActivate");
- if (!lobbyAmbienceLoader.OriginalAudioSource) lobbyAmbienceLoader.set_OriginalClip(self->ambienceAudioClip);
-
- if (lobbyAmbienceLoader.loaded && QSoundsConfig::Config.lobbyAmbience_Active)
- {
- getLogger().debug("Overwriting LobbyAmbience Audio");
- self->ambienceAudioClip = lobbyAmbienceLoader.getClip();
- }
- else {
- self->ambienceAudioClip = lobbyAmbienceLoader.get_OriginalClip();
- }
- GameServerLobbyFlowCoordinator_DidActivate(self, firstActivation, addedToHierarchy, screenSystemEnabling);
-}
-
-MAKE_HOOK_MATCH(GameServerLobbyFlowCoordinator_DidDeactivate, &GameServerLobbyFlowCoordinator::DidDeactivate, void, GameServerLobbyFlowCoordinator* self, bool removedFromHierarchy, bool screenSystemDisabling)
-{
- getLogger().debug("GameServerLobbyFlowCoordinator_DidActivate");
- if (menuMusicLoader.loaded && QSoundsConfig::Config.menuMusic_Active && removedFromHierarchy)
- {
- getLogger().debug("Switching LobbyMusic to MenuMusic Audio");
- self->ambienceAudioClip = menuMusicLoader.getClip();
- }
- else {
- self->ambienceAudioClip = menuMusicLoader.get_OriginalClip();
- }
- GameServerLobbyFlowCoordinator_DidDeactivate(self, removedFromHierarchy, screenSystemDisabling);
-}
-
-MAKE_HOOK_MATCH(MultiplayerModeSelectionFlowCoordinator_DidActivate, &MultiplayerModeSelectionFlowCoordinator::DidActivate, void, MultiplayerModeSelectionFlowCoordinator* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
-{
- getLogger().debug("MultiplayerModeSelectionFlowCoordinator_DidActivate");
- if (menuMusicLoader.loaded && QSoundsConfig::Config.menuMusic_Active)
- {
- getLogger().debug("Switching LobbyMusic to MenuMusic Audio");
- self->ambienceAudioClip = menuMusicLoader.getClip();
- }
- else {
- self->ambienceAudioClip = menuMusicLoader.get_OriginalClip();
- }
- MultiplayerModeSelectionFlowCoordinator_DidActivate(self, firstActivation, addedToHierarchy, screenSystemEnabling); // This has to be ran last, otherwise it will not work correctly
-}
-
-MAKE_HOOK_MATCH(MultiplayerModeSelectionFlowCoordinator_DidDeactivate, &MultiplayerModeSelectionFlowCoordinator::DidDeactivate, void, MultiplayerModeSelectionFlowCoordinator* self, bool removedFromHierarchy, bool screenSystemDisabling)
-{
- getLogger().debug("MultiplayerModeSelectionFlowCoordinator_DidDeactivate");
- if (menuMusicLoader.loaded && QSoundsConfig::Config.menuMusic_Active && removedFromHierarchy)
- {
- self->ambienceAudioClip = menuMusicLoader.getClip();
- }
- else {
- self->ambienceAudioClip = menuMusicLoader.get_OriginalClip();
- }
-
- MultiplayerModeSelectionFlowCoordinator_DidDeactivate(self, removedFromHierarchy, screenSystemDisabling);
-}
-#endif
-
-#ifdef DEBUG
-MAKE_HOOK_MATCH(FileHelpers_GetEscapedURLForFilePath, &FileHelpers::GetEscapedURLForFilePath, StringW, StringW filePath) {
- return il2cpp_utils::newcsstr(std::u16string(u"file://") + std::u16string(csstrtostr(filePath)));
-}
-#endif
-
-MAKE_HOOK_MATCH(NoteCutSoundEffectManager_Start, &NoteCutSoundEffectManager::Start, void, NoteCutSoundEffectManager* self) {
- if(hitSoundLoader.loaded && QSoundsConfig::Config.hitSound_Active)
- {
- hitSoundArr = createAudioClipArray(hitSoundLoader);
- self->longCutEffectsAudioClips = hitSoundArr;
- self->shortCutEffectsAudioClips = hitSoundArr;
- getLogger().debug("NoteCutSoundEffectManager_Start: Loaded hitSoundArray");
- }
- else {
- getLogger().debug("NoteCutSoundEffectManager_Start: Loading normally");
- }
- getLogger().debug("audioSamplesBeatAlignOffset was: %f", self->audioSamplesBeatAlignOffset);
- self->audioSamplesBeatAlignOffset = QSoundsConfig::Config.hitSound_beatOffSet;
- getLogger().debug("audioSamplesBeatAlignOffset changed to: %f", self->audioSamplesBeatAlignOffset);
- NoteCutSoundEffectManager_Start(self);
- getLogger().debug("Beatalign offset is: %f", self->beatAlignOffset);
-}
-
-MAKE_HOOK_MATCH(NoteCutSoundEffect_Awake, &NoteCutSoundEffect::Awake, void, NoteCutSoundEffect* self) {
- if (hitSoundLoader.loaded && QSoundsConfig::Config.hitSound_Active) {
- self->goodCutVolume += QSoundsConfig::Config.hitSound_audioVolumeOffset;
- }
-
- if(badHitSoundLoader.loaded && QSoundsConfig::Config.badHitSound_Active)
- {
- badHitSoundArr = createAudioClipArray(badHitSoundLoader);
- self->badCutSoundEffectAudioClips = badHitSoundArr;
- self->badCutVolume += QSoundsConfig::Config.badHitSound_audioVolumeOffset;
- }
- NoteCutSoundEffect_Awake(self);
-}
-
-MAKE_HOOK_MATCH(BeatmapObjectManager_HandleNoteWasMissed, &BeatmapObjectManager::HandleNoteControllerNoteWasMissed, void, BeatmapObjectManager* self, NoteController* noteController) {
- BeatmapObjectManager_HandleNoteWasMissed(self, noteController);
- if (noteMissedSoundLoader.loaded &&
- QSoundsConfig::Config.noteMissedSound_Active &&
- noteController->get_noteData()->get_scoringType() != NoteData::ScoringType::Ignore &&
- noteController->get_noteData()->get_gameplayType() != NoteData::GameplayType::Bomb) {
- //getLogger().debug("Playing note missed sound");
- noteMissedSoundLoader.audioSource->set_volume(0.5f + QSoundsConfig::Config.noteMissedSound_audioVolumeOffset);
- noteMissedSoundLoader.audioSource->Play();
- //noteMissedSoundLoader.audioSource->PlayOneShot(noteMissedSoundLoader.audioSource->get_clip(), 1.0f + QSoundsConfig::Config.noteMissedSound_audioVolumeOffset);
- }
-}
-
-MAKE_HOOK_MATCH(BasicUIAudioManager_Start, &BasicUIAudioManager::Start, void, BasicUIAudioManager* self) {
- if (!menuClickLoader.OriginalAudioSource) menuClickLoader.set_OriginalClip(self->clickSounds[0]);
-
- if(menuClickLoader.loaded && QSoundsConfig::Config.menuClick_Active)
- {
- menuClickArr = createAudioClipArray(menuClickLoader);
- self->clickSounds = menuClickArr;
- }
- BasicUIAudioManager_Start(self);
-}
-
-//MAKE_HOOK_MATCH(FireworkItemController_Awake, &FireworkItemController::Awake, void, FireworkItemController* self) {
-// if (!origFireworkSoundArr) origFireworkSoundArr = self->explosionClips;
-//
-// if(fireworkSoundLoader.loaded && QSoundsConfig::Config.firework_Active)
-// {
-// getLogger().debug("Setting custom Fireworks Sounds");
-// fireworkSoundArr = createAudioClipArray(fireworkSoundLoader);
-// self->explosionClips = fireworkSoundArr;
-// }
-// else {
-// getLogger().debug("Return default Fireworks Sounds");
-// self->explosionClips = origFireworkSoundArr;
-// }
-// FireworkItemController_Awake(self);
-//}
-
-// Replacing the function here, as replacing the AudioClips proves to be difficult
-MAKE_HOOK_MATCH(FireworkItemController_PlayExplosionSound, &FireworkItemController::PlayExplosionSound, void, FireworkItemController* self) {
- if (fireworkSoundLoader.loaded && QSoundsConfig::Config.firework_Active) {
- self->audioSource->set_clip(fireworkSoundLoader.getClip());
- float pitch = 1.2f + (((float)rand()) / (float)RAND_MAX) * (0.8f - 1.2f);
- self->audioSource->set_pitch(pitch);
- self->audioSource->Play();
- }
- else FireworkItemController_PlayExplosionSound(self);
-}
-
-MAKE_HOOK_MATCH(PauseMenuManager_MenuButtonPressed, &PauseMenuManager::MenuButtonPressed, void, PauseMenuManager* self) {
- if (noteMissedSoundLoader.loaded &&
- QSoundsConfig::Config.noteMissedSound_Active) {
- if (noteMissedSoundLoader.audioSource) noteMissedSoundLoader.audioSource->Stop();
- //noteMissedSoundLoader.audioSource->PlayOneShot(noteMissedSoundLoader.audioSource->get_clip(), 1.0f + QSoundsConfig::Config.noteMissedSound_audioVolumeOffset);
- }
- PauseMenuManager_MenuButtonPressed(self);
-}
-
-MAKE_HOOK_MATCH(SceneManager_Internal_ActiveSceneChanged, &SceneManager::Internal_ActiveSceneChanged, void, Scene previousActiveScene, Scene newActiveScene) {
- SceneManager_Internal_ActiveSceneChanged(previousActiveScene, newActiveScene);
- if (newActiveScene.IsValid()) {
- std::string sceneName = to_utf8(csstrtostr(newActiveScene.get_name()));
- getLogger().info("Scene found: %s", sceneName.data());
-
- std::string questInit = "QuestInit";
- if(sceneName == questInit) QuestSounds::AudioClips::loadAudioClips();
- }
-}
-
-extern "C" void setup(ModInfo &info)
-{
- info.id = MOD_ID;
- info.version = VERSION;
- modInfo = info;
-
- getLogger().info("Modloader name: %s", Modloader::getInfo().name.c_str());
- getLogger().debug("Config Path is: %s", getConfig().getConfigFilePath(modInfo).c_str());
- getLogger().info("Loading Config");
- getConfig();
- getLogger().info("Completed setup!");
-}
-
-extern "C" void load()
-{
- il2cpp_functions::Init();
- QuestUI::Init();
-
- Logger& hkLog = getLogger();
-
- //custom_types::Register::RegisterType();
- custom_types::Register::AutoRegister();
- //QuestUI::Register::RegisterModSettingsFlowCoordinator(modInfo);
- QuestUI::Register::RegisterMainMenuModSettingsFlowCoordinator(modInfo);
-
- if(!LoadConfig()) SaveConfig();
- makeFolder();
- getLogger().debug("Installing QuestSounds!");
- INSTALL_HOOK(hkLog, SceneManager_Internal_ActiveSceneChanged);
- INSTALL_HOOK(hkLog, PauseMenuManager_MenuButtonPressed);
- INSTALL_HOOK(hkLog, SongPreviewPlayer_OnEnable);
- INSTALL_HOOK(hkLog, NoteCutSoundEffectManager_Start);
- INSTALL_HOOK(hkLog, NoteCutSoundEffect_Awake);
- INSTALL_HOOK(hkLog, BeatmapObjectManager_HandleNoteWasMissed);
- INSTALL_HOOK(hkLog, BasicUIAudioManager_Start);
- INSTALL_HOOK(hkLog, ResultsViewController_DidActivate);
- INSTALL_HOOK(hkLog, ResultsViewController_RestartButtonPressed);
- INSTALL_HOOK(hkLog, FireworkItemController_PlayExplosionSound)
- INSTALL_HOOK(hkLog, MultiplayerModeSelectionFlowCoordinator_DidActivate); // Added for switching out MP Lobby Music
- INSTALL_HOOK(hkLog, MultiplayerModeSelectionFlowCoordinator_DidDeactivate); // Added for switching out MP Lobby Music
- INSTALL_HOOK(hkLog, GameServerLobbyFlowCoordinator_DidActivate); // Added for switching out MP Lobby Music
- INSTALL_HOOK(hkLog, GameServerLobbyFlowCoordinator_DidDeactivate); // Added for switching out MP Lobby Music
- #ifdef DEBUG
- auto ModList = Modloader::getMods();
- if (ModList.find("SongLoader") == ModList.end()) {
- getLogger().info("SongLoader missing, installing FilePath check");
- INSTALL_HOOK(hkLog, FileHelpers_GetEscapedURLForFilePath);
- }
- #endif
- getLogger().debug("Installed QuestSounds!");
-}
+#include "main.hpp"
+#include "_config.h"
+#include "hooking.hpp"
+#include "logging.hpp"
+#include "Utils/AsyncAudioClipLoader.hpp"
+#include "Config.hpp"
+#include "AudioClips.hpp"
+using namespace QuestSounds::AudioClips;
+
+#include "GlobalNamespace/SongPreviewPlayer.hpp"
+#include "GlobalNamespace/BasicUIAudioManager.hpp"
+
+#include "GlobalNamespace/FileHelpers.hpp"
+using namespace GlobalNamespace;
+
+#include "System/Action.hpp"
+
+#include "UnityEngine/SceneManagement/Scene.hpp"
+#include "UnityEngine/SceneManagement/SceneManager.hpp"
+using namespace UnityEngine::SceneManagement;
+
+#include "bsml/shared/BSML.hpp"
+
+// TODO BSML
+
+#include "UI/QuestSoundsFlowCoordinator.hpp"
+using namespace QuestSounds;
+
+#define RAPIDJSON_HAS_STDSTRING 1
+
+// TODO: Proper paper logging
+Paper::ConstLoggerContext<12UL>& getLogger() {
+ static auto fastContext = Paper::Logger::WithContext();
+ return fastContext;
+}
+
+void makeFolder()
+{
+ if (!direxists(Config.Sounds.MenuMusic.FolderPath.c_str()))
+ {
+ int makePath = mkpath(Config.Sounds.MenuMusic.FolderPath.c_str());
+ if (makePath == -1)
+ {
+ getLogger().error("Failed to make MenuMusic Folder path!");
+ }
+ }
+
+ if (!direxists(Config.Sounds.HitSound.FolderPath.c_str()))
+ {
+ int makePath = mkpath(Config.Sounds.HitSound.FolderPath.c_str());
+ if (makePath == -1)
+ {
+ getLogger().error("Failed to make HitSound Folder path!");
+ }
+ }
+
+ if (!direxists(Config.Sounds.BadHitSound.FolderPath.c_str()))
+ {
+ int makePath = mkpath(Config.Sounds.BadHitSound.FolderPath.c_str());
+ if (makePath == -1)
+ {
+ getLogger().error("Failed to make BadHitSound Folder path!");
+ }
+ }
+
+ if (!direxists(Config.Sounds.NoteMissedSound.FolderPath.c_str()))
+ {
+ int makePath = mkpath(Config.Sounds.NoteMissedSound.FolderPath.c_str());
+ if (makePath == -1)
+ {
+ getLogger().error("Failed to make NoteMissedSound Folder path!");
+ }
+ }
+
+ if (!direxists(Config.Sounds.BombExplosionSound.FolderPath.c_str()))
+ {
+ int makePath = mkpath(Config.Sounds.BombExplosionSound.FolderPath.c_str());
+ if (makePath == -1)
+ {
+ getLogger().error("Failed to make BombExplosionSound Folder path!");
+ }
+ }
+
+ if (!direxists(Config.Sounds.MenuClick.FolderPath.c_str()))
+ {
+ int makePath = mkpath(Config.Sounds.MenuClick.FolderPath.c_str());
+ if (makePath == -1)
+ {
+ getLogger().error("Failed to make MenuClick Folder path!");
+ }
+ }
+
+ if (!direxists(Config.Sounds.Firework.FolderPath.c_str()))
+ {
+ int makePath = mkpath(Config.Sounds.Firework.FolderPath.c_str());
+ if (makePath == -1)
+ {
+ getLogger().error("Failed to make FireworkSound Folder path!");
+ }
+ }
+
+ if (!direxists(Config.Sounds.LevelCleared.FolderPath.c_str()))
+ {
+ int makePath = mkpath(Config.Sounds.LevelCleared.FolderPath.c_str());
+ if (makePath == -1)
+ {
+ getLogger().error("Failed to make LevelCleared Folder path!");
+ }
+ }
+
+ if (!direxists(Config.Sounds.LevelFailed.FolderPath.c_str()))
+ {
+ int makePath = mkpath(Config.Sounds.LevelFailed.FolderPath.c_str());
+ if (makePath == -1)
+ {
+ getLogger().error("Failed to make LevelFailed Folder path!");
+ }
+ }
+
+ if (!direxists(Config.Sounds.LobbyMusic.FolderPath.c_str()))
+ {
+ int makePath = mkpath(Config.Sounds.LobbyMusic.FolderPath.c_str());
+ if (makePath == -1)
+ {
+ getLogger().error("Failed to make LobbyMusic Folder path!");
+ }
+ }
+}
+
+
+
+namespace QuestSounds::AudioClips {
+/*audioClipLoader::loader*/
+QuestSounds::Utils::AsyncAudioClipLoader hitSoundLoader, // hitSound
+ badHitSoundLoader, // badHitSound
+ noteMissedSoundLoader,
+ bombExplosionSoundLoader,
+ menuMusicLoader, // menuMusic
+ menuClickLoader,
+ fireworkSoundLoader,
+ levelClearedLoader,
+ levelFailedLoader, // For LevelFailed sound
+ lobbyAmbienceLoader; // Added for LobbyMusic
+::ArrayW<::UnityW<::UnityEngine::AudioClip>> hitSoundArr, // hitSoundArray
+ badHitSoundArr, // badHitSoundArray
+ bombExplosionSoundLoaderArr,
+ menuClickArr,
+ fireworkSoundArr;
+
+
+::ArrayW<::UnityW<::UnityEngine::AudioClip>> origMenuClickArr;
+
+ void loadAudioClips()
+ {
+ hitSoundLoader.filePath = Config.Sounds.HitSound.FilePath;
+ hitSoundLoader.streamAudio = false; // Streaming HitSounds breaks them
+ badHitSoundLoader.filePath = Config.Sounds.BadHitSound.FilePath;
+ noteMissedSoundLoader.filePath = Config.Sounds.NoteMissedSound.FilePath;
+ bombExplosionSoundLoader.filePath = Config.Sounds.BombExplosionSound.FilePath;
+ menuMusicLoader.filePath = Config.Sounds.MenuMusic.FilePath;
+ menuClickLoader.filePath = Config.Sounds.MenuClick.FilePath;
+ fireworkSoundLoader.filePath = Config.Sounds.Firework.FilePath;
+ levelClearedLoader.filePath = Config.Sounds.LevelCleared.FilePath;
+ levelFailedLoader.filePath = Config.Sounds.LevelFailed.FilePath;
+ lobbyAmbienceLoader.filePath = Config.Sounds.LobbyMusic.FilePath; // Added for LobbyMusic
+
+ menuMusicLoader.load();
+ menuClickLoader.load();
+ if (Config.Sounds.HitSound.Active) hitSoundLoader.load();
+ if (Config.Sounds.BadHitSound.Active) badHitSoundLoader.load();
+ if (Config.Sounds.NoteMissedSound.Active) noteMissedSoundLoader.load();
+ if (Config.Sounds.BombExplosionSound.Active) bombExplosionSoundLoader.load();
+ if (Config.Sounds.Firework.Active) fireworkSoundLoader.load();
+ if (Config.Sounds.LevelCleared.Active) levelClearedLoader.load();
+ if (Config.Sounds.LevelFailed.Active) levelFailedLoader.load();
+ if (Config.Sounds.LobbyMusic.Active) lobbyAmbienceLoader.load(); // Added for LobbyMusic
+ }
+ // Creates an Array, of AudioClips
+ ::ArrayW<::UnityW<::UnityEngine::AudioClip>> createAudioClipArray(QuestSounds::Utils::AsyncAudioClipLoader clipLoader, bool GetOriginalClip)
+ {
+ UnityEngine::AudioClip* tempClip;
+ if (!GetOriginalClip) tempClip = clipLoader.getClip();
+ else tempClip = clipLoader.get_OriginalClip();
+ auto temporaryArray = ArrayW<::UnityW>({UnityW(tempClip)});
+ return temporaryArray;
+ }
+}
+
+#ifdef DEBUG
+MAKE_HOOK_MATCH(FileHelpers_GetEscapedURLForFilePath, &FileHelpers::GetEscapedURLForFilePath, StringW, StringW filePath) {
+ return StringW("file://" + filePath);
+}
+#endif
+
+
+namespace QuestSounds::ObjectInstances {
+ GlobalNamespace::BasicUIAudioManager* BUIAM;
+}
+
+MAKE_HOOK_MATCH(BasicUIAudioManager_Start, &BasicUIAudioManager::Start, void, BasicUIAudioManager* self) {
+ getLogger().info("BasicUIAudioManager_Start");
+ QuestSounds::ObjectInstances::BUIAM = self;
+ if (!menuClickLoader.OriginalAudioSource) menuClickLoader.set_OriginalClip(self->_clickSounds[0]);
+
+ if(menuClickLoader.loaded && Config.Sounds.MenuClick.Active)
+ {
+ menuClickArr = createAudioClipArray(menuClickLoader);
+ self->_clickSounds = menuClickArr;
+ }
+ BasicUIAudioManager_Start(self);
+}
+
+MAKE_HOOK_MATCH(SceneManager_Internal_ActiveSceneChanged, &SceneManager::Internal_ActiveSceneChanged, void, Scene previousActiveScene, Scene newActiveScene) {
+ SceneManager_Internal_ActiveSceneChanged(previousActiveScene, newActiveScene);
+ if (newActiveScene.IsValid()) {
+ std::string sceneName = newActiveScene.get_name();
+ getLogger().info("Scene found: {}", sceneName.data());
+
+ std::string questInit = "QuestInit";
+ if(sceneName == questInit) {
+ try {
+ QuestSounds::AudioClips::loadAudioClips();
+ }
+ catch (const std::exception& e) {
+ getLogger().error("Failed to load AudioClips: {}", e.what());
+ }
+ }
+ }
+}
+
+QS_EXPORT_FUNC void setup(CModInfo *info) {
+ info->id = MOD_ID;
+ info->version = VERSION;
+
+
+ Paper::Logger::RegisterFileContextId(getLogger().tag);
+
+ getLogger().info("Modloader: {}", modloader::get_modloader_path().c_str());
+
+ auto& configPath = GetConfigPath();
+ getLogger().debug("Config Path is: {}", configPath);
+
+ getLogger().info("Loading Config from file {}", configPath);
+ if(!fileexists(configPath)) {
+ getLogger().info("Config file not found, creating default config");
+ if(!WriteToFile(configPath, Config, true))
+ getLogger().error("Failed to write config file!");
+ }
+
+ try {
+ ReadFromFile(configPath, Config);
+ } catch(const std::exception& e) {
+ getLogger().error("Failed to read config: {}", e.what());
+ }
+
+ getLogger().info("Completed setup!");
+}
+
+QS_EXPORT_FUNC void late_load()
+{
+ il2cpp_functions::Init();
+ BSML::Init();
+ custom_types::Register::AutoRegister();
+ BSML::Register::RegisterMainMenu("QuestSounds", "Let's you customize sounds and music");
+
+ auto& hkLog = getLogger();
+
+ makeFolder();
+ getLogger().debug("Installing QuestSounds!");
+ QuestSounds::Hooking::InstallHooks();
+ INSTALL_HOOK(hkLog, SceneManager_Internal_ActiveSceneChanged);
+ INSTALL_HOOK(hkLog, BasicUIAudioManager_Start);
+ // #ifdef DEBUG
+ // auto ModList = Modloader::getMods();
+ // if (ModList.find("SongLoader") == ModList.end()) {
+ // getLogger().info("SongLoader missing, installing FilePath check");
+ // INSTALL_HOOK(hkLog, FileHelpers_GetEscapedURLForFilePath);
+ // }
+ // #endif
+ getLogger().debug("Installed QuestSounds!");
+}