diff --git a/.clang-tidy b/.clang-tidy index 6bc4e50..b44da16 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,7 +1,9 @@ Checks: "*,-llvm*, -google-readability-namespace, -llvmlib, + -llvmlibc, -fuchsi, + -fuchsia, -alter, -modernize-use-trailing-return-type, -modernize-use-trailing-return, @@ -12,6 +14,16 @@ Checks: "*,-llvm*, -fuchsia-default-arguments-calls, -altera-unroll-loops, -altera*, + -readability-implicit-bool-conversion, + -cert-err58-cpp, + -cppcoreguidelines-pro-bounds-array-to-pointer-decay, + -hicpp-avoid-c-arrays, + + -bugprone-undefined-memory-manipulation, + -misc-use-anonymous-namespace, + -readability-magic-numbers, + -cppcoreguidelines-pro-type-reinterpret-cast, + -cppcoreguidelines-virtual-class-destructor, -cppcoreguidelines-pro-type-union-access, -cppcoreguidelines-pro-type-vararg, -cppcoreguidelines-pro-type-static-cast-downcast, @@ -22,29 +34,27 @@ Checks: "*,-llvm*, -hicpp-vararg, -cppcoreguidelines-pro-bounds-constant-array-index, -google-build-using-namespace, - -abseil-string-find-str-contains + -abseil-string-find-str-contains, clang-diagnostic-*, - -bugprone-unchecked-optional-access, - clang-analyzer-*, - fuchsia-statically-constructed-objects, - *, - -llvmlibc-callee-namespace, - -readability-identifier-length, - -llvmlibc-implementation-in-namespace, - -llvmlibc-restrict-system-libc-headers, - -llvm-namespace-comment, - -llvm-include-order, - -altera-*, - -fuchsia-*, - -modernize-use-trailing-return-type, - -cppcoreguidelines-avoid-non-const-global-variables, - -llvm-header-guard, - -cppcoreguidelines-macro-usage, - -cppcoreguidelines-pro-type-vararg, - -cppcoreguidelines-avoid-do-while, - -hicpp-vararg, - -concurrency-mt-unsafe, - -abseil-* + clang-analyzer-*, + -bugprone-unchecked-optional-access, + -llvmlibc-callee-namespace, + -readability-identifier-length, + -llvmlibc-implementation-in-namespace, + -llvmlibc-restrict-system-libc-headers, + -llvm-namespace-comment, + -llvm-include-order, + -altera-*, + -fuchsia-*, + -modernize-use-trailing-return-type, + -cppcoreguidelines-avoid-non-const-global-variables, + -llvm-header-guard, + -cppcoreguidelines-macro-usage, + -cppcoreguidelines-pro-type-vararg, + -cppcoreguidelines-avoid-do-while, + -hicpp-vararg, + -concurrency-mt-unsafe, + -abseil-* " FormatStyle: file HeaderFilterRegex: "" diff --git a/.clangd b/.clangd index 9e1f444..c349468 100644 --- a/.clangd +++ b/.clangd @@ -1,3 +1,6 @@ +Diagnostics: + UnusedIncludes: None + If: # Note: This is a regexp, notice '.*' at the end of PathMatch string. PathMatch: ./extern/.* diff --git a/.github/workflows/build-ndk.yml b/.github/workflows/build-ndk.yml index c2b160b..4ada603 100644 --- a/.github/workflows/build-ndk.yml +++ b/.github/workflows/build-ndk.yml @@ -2,7 +2,7 @@ name: NDK build env: module_id: chroma - qmodName: chroma + qmodName: Chroma on: push: @@ -48,13 +48,7 @@ jobs: run: | cd ${GITHUB_WORKSPACE} qpm-rust s build - qpm-rust restore - qpm-rust qmod build - - - - name: Create Qmod - run: | - pwsh -Command ./createqmod.ps1 ${{env.qmodName}} + qpm-rust qmod zip - name: Get Library Name id: libname diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c8d4870..5d1a0cf 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,7 +2,7 @@ name: Publish QPM Package env: module_id: chroma - qmodName: chroma + qmodName: Chroma cache-name: chroma_cache on: @@ -57,21 +57,11 @@ jobs: # Name of qmod in release asset. Assumes exists, same as prior qpm_qmod: ${{env.qmodName}}.qmod - - name: List Post Restore - run: | - echo includes: - ls -la ${GITHUB_WORKSPACE}/extern/includes - echo libs: - ls -la ${GITHUB_WORKSPACE}/extern/libs - echo cache: - ls -la $HOME/.local/share/QPM-Rust/cache - - name: Build run: | cd ${GITHUB_WORKSPACE} qpm-rust s build - qpm-rust restore - qpm-rust qmod build + qpm-rust zip - name: Get Library Name id: libname @@ -85,11 +75,6 @@ jobs: run: | mv ./build/debug/${{ steps.libname.outputs.NAME }} ./build/debug/debug_${{ steps.libname.outputs.NAME }} - - - name: Create Qmod - run: | - pwsh -Command ./createqmod.ps1 ${{env.qmodName}} - - name: Upload to Release id: upload_file_release uses: softprops/action-gh-release@v0.1.15 diff --git a/CMakeLists.txt b/CMakeLists.txt index c11b248..357786d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,9 @@ set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) # compile options used add_compile_options(-frtti -fexceptions) + + + add_compile_options(-O3) # compile definitions used add_compile_definitions(VERSION=\"${MOD_VERSION}\") @@ -74,4 +77,6 @@ add_custom_command(TARGET ${COMPILE_ID} POST_BUILD add_custom_command(TARGET ${COMPILE_ID} POST_BUILD COMMAND ${CMAKE_COMMAND} -E rename stripped_lib${COMPILE_ID}.so lib${COMPILE_ID}.so COMMENT "Rename the stripped lib to regular" - ) \ No newline at end of file + ) + +include(assets_include.cmake) \ No newline at end of file diff --git a/assets/standard_shader.bundle b/assets/standard_shader.bundle new file mode 100644 index 0000000..047c6ba Binary files /dev/null and b/assets/standard_shader.bundle differ diff --git a/assets/ui.bsml b/assets/ui.bsml new file mode 100644 index 0000000..6d2e199 --- /dev/null +++ b/assets/ui.bsml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/assets_include.cmake b/assets_include.cmake new file mode 100644 index 0000000..2ff1cef --- /dev/null +++ b/assets_include.cmake @@ -0,0 +1,111 @@ +# credit goes to https://github.com/Lauriethefish for this +# Directory where our arbitrary asset files are stored +set(ASSETS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/assets) +# Directory to save the object files generated by llvm-objcopy +set(ASSET_BINARIES_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/binaryAssets) +# Directory to save the prepended files to +set(PREPENDED_ASSETS_DIR ${CMAKE_CURRENT_BINARY_DIR}/prependedAssets) +set(ASSET_HEADER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include/assets.hpp") + +# Define a macro which we will use for defining the symbols to access our asset files below +set(ASSET_HEADER_DATA +"#pragma once + +#include +#include \"beatsaber-hook/shared/utils/typedefs.h\" + +struct IncludedAsset { + + IncludedAsset(uint8_t* start, uint8_t* end) : array(reinterpret_cast*>(start)) { + array->klass = nullptr; + array->monitor = nullptr; + array->bounds = nullptr; + array->max_length = end - start - 33; + *(end - 1)= '\\0'; + } + + operator ArrayW() const { + init(); + return array; + } + + operator std::string_view() const { + return { reinterpret_cast(array->_values), array->get_Length() }; + } + + operator std::span() const { + return { array->_values, array->get_Length() }; + } + + void init() const { + if(!array->klass) + array->klass = classof(Array*); + } + + private: + Array* array; + +}; + +#define DECLARE_FILE(name) \\ + extern \"C\" uint8_t _binary_##name##_start[]; \\ + extern \"C\" uint8_t _binary_##name##_end[]; \\ + const IncludedAsset name { _binary_##name##_start, _binary_##name##_end}; + +namespace IncludedAssets { +\n") + +if (EXISTS ${ASSETS_DIRECTORY}) + file(MAKE_DIRECTORY ${ASSET_BINARIES_DIRECTORY}) + file(MAKE_DIRECTORY ${PREPENDED_ASSETS_DIR}) + file(GLOB ASSETS LIST_DIRECTORIES false ${ASSETS_DIRECTORY}/*) + + # Iterate through each file in the assets directory. TODO: This could be recursive + foreach(FILE IN LISTS ASSETS) + message("-- Including asset: ${FILE}") + get_filename_component(ASSET ${FILE} NAME) # Find the asset's file name + + # make a copy of the file with 32 bytes added in the build dir + add_custom_command( + OUTPUT ${PREPENDED_ASSETS_DIR}/${ASSET} + COMMAND ${CMAKE_COMMAND} -E echo_append " " > ${PREPENDED_ASSETS_DIR}/${ASSET} + COMMAND ${CMAKE_COMMAND} -E cat ${ASSETS_DIRECTORY}/${ASSET} >> ${PREPENDED_ASSETS_DIR}/${ASSET} + COMMAND ${CMAKE_COMMAND} -E echo_append " " >> ${PREPENDED_ASSETS_DIR}/${ASSET} + DEPENDS ${ASSETS_DIRECTORY}/${ASSET} + ) + + set(OUTPUT_FILE "${ASSET_BINARIES_DIRECTORY}/${ASSET}.o") # Save our asset in the asset binaries directory + + # Use llvm-objcopy to create an object file that stores our binary asset + # The resulting file contains 3 symbols: _binary__start, _binary__size and _binary__end + # We only use the first two + add_custom_command( + OUTPUT ${OUTPUT_FILE} + COMMAND ${CMAKE_OBJCOPY} ${ASSET} ${OUTPUT_FILE} --input-target binary --output-target elf64-aarch64 --set-section-flags binary=strings + DEPENDS ${PREPENDED_ASSETS_DIR}/${ASSET} + WORKING_DIRECTORY ${PREPENDED_ASSETS_DIR} + ) + list(APPEND BINARY_ASSET_FILES ${OUTPUT_FILE}) + + # Find the correct objcopy symbol name, this is always the file name with any non-alphanumeric characters replaced with _ + string(REGEX REPLACE "[^a-zA-Z0-9]" "_" FIXED_ASSET ${ASSET}) + # Add to our assets header + set(ASSET_HEADER_DATA "${ASSET_HEADER_DATA}\tDECLARE_FILE(${FIXED_ASSET})\n") + endforeach() + set(ASSET_HEADER_DATA "${ASSET_HEADER_DATA}\n}\n") + + # check if at least 1 asset file, otherwise ignore + list(LENGTH BINARY_ASSET_FILES COUNT) + if (${COUNT} GREATER 0) + # Generate the assets header file + file(GENERATE OUTPUT ${ASSET_HEADER_PATH} CONTENT "${ASSET_HEADER_DATA}") + + # Add our assets files to the final SO + add_library(asset_files OBJECT ${BINARY_ASSET_FILES}) + set_target_properties(asset_files PROPERTIES LINKER_LANGUAGE CXX) + target_link_libraries(${COMPILE_ID} PRIVATE asset_files ${BINARY_ASSET_FILES}) + endif() +else() + message("-- Removing '${ASSET_HEADER_PATH}' as no assets have been found in '${ASSETS_DIRECTORY}'") + file(REMOVE ${ASSET_HEADER_PATH}) +endif() \ No newline at end of file diff --git a/copy.ps1 b/copy.ps1 index 916b882..a24c34a 100644 --- a/copy.ps1 +++ b/copy.ps1 @@ -1,6 +1,6 @@ & $PSScriptRoot/build.ps1 if ($?) { - adb push build/libchroma.so /sdcard/Android/data/com.beatgames.beatsaber/files/mods/libchroma.so + adb push build/libchroma.so /sdcard/ModData/com.beatgames.beatsaber/Modloader/mods/libchroma.so if ($?) { adb shell am force-stop com.beatgames.beatsaber adb shell am start com.beatgames.beatsaber/com.unity3d.player.UnityPlayerActivity diff --git a/include/Chroma.hpp b/include/Chroma.hpp index a098c67..53035f5 100644 --- a/include/Chroma.hpp +++ b/include/Chroma.hpp @@ -6,8 +6,6 @@ #include -#define GET_FIND_METHOD(mPtr) il2cpp_utils::il2cpp_type_check::MetadataGetter::get() - template using FPtrWrapper = il2cpp_utils::il2cpp_type_check::FPtrWrapper; inline void PrintJSONValue(rapidjson::Value const& json) { @@ -20,7 +18,7 @@ inline void PrintJSONValue(rapidjson::Value const& json) { PrettyWriter writer(sb); json.Accept(writer); auto str = sb.GetString(); - getLogger().info("%s", str); + ChromaLogger::Logger.info("{}", str); } inline void PrintJSONValue(rapidjson::Value const* json) { @@ -33,21 +31,12 @@ inline void PrintJSONValue(rapidjson::Value const* json) { PrettyWriter writer(sb); json->Accept(writer); auto str = sb.GetString(); - getLogger().info("json %s", str); + ChromaLogger::Logger.info("json {}", str); } namespace Chroma { -namespace ChromaLogger { -inline static char const* ColorLightSwitch = "ColorLightSwitch"; -inline static char const* EnvironmentRemoval = "EnvironmentRemoval"; -inline static char const* LightColorizer = "LightColorizer"; -inline static char const* TrackLaneRings = "TrackLaneRings"; -inline static char const* LegacyLightColor = "LegacyLightColor"; -inline static char const* ObjectDataDeserialize = "ObjectDataDeserialize"; -inline static char const* TrackController = "GameObjectTrackController"; -} // namespace ChromaLogger - -inline static const std::u16string_view REQUIREMENTNAME = u"Chroma"; + +inline static const std::string REQUIREMENTNAME = "Chroma"; namespace NewConstants { using namespace TracksAD::Constants; diff --git a/include/ChromaConfig.hpp b/include/ChromaConfig.hpp index 675413e..d55521d 100644 --- a/include/ChromaConfig.hpp +++ b/include/ChromaConfig.hpp @@ -11,10 +11,4 @@ DECLARE_CONFIG(ChromaConfig, "Controls whether notes will be colored or not"); CONFIG_VALUE(environmentEnhancementsEnabled, bool, "Environment Enhancements", true, "Toggles whether Chroma should modify the environment as specified by a map."); - - CONFIG_INIT_FUNCTION( - - CONFIG_INIT_VALUE(PrintEnvironmentEnhancementDebug); CONFIG_INIT_VALUE(customColorEventsEnabled); - CONFIG_INIT_VALUE(customNoteColors); CONFIG_INIT_VALUE(environmentEnhancementsEnabled); - - )) +) \ No newline at end of file diff --git a/include/ChromaController.hpp b/include/ChromaController.hpp index 70fcff9..11e8dfb 100644 --- a/include/ChromaController.hpp +++ b/include/ChromaController.hpp @@ -49,8 +49,8 @@ class ChromaController { return getChromaConfig().customColorEventsEnabled.GetValue() && (ChromaRequired()); } - static void AddForceDoHooks(ModInfo const& otherModInfo); - static void RemoveForceDoHooks(ModInfo const& otherModInfo); + static void AddForceDoHooks(modloader::ModInfo const& otherModInfo); + static void RemoveForceDoHooks(modloader::ModInfo const& otherModInfo); // Quest internal stuff static void SetChromaLegacy(bool v); @@ -69,6 +69,6 @@ class ChromaController { DelayedStartEnumerator(GlobalNamespace::BeatmapObjectSpawnController* beatmapObjectSpawnController); // Since level data is freed on scene load, we copy it before we load. - inline static std::optional infoDatCopy = std::nullopt; + inline static std::optional> environmentObjectsRemovalV2 = std::nullopt; }; } // namespace Chroma \ No newline at end of file diff --git a/include/ChromaEvents.hpp b/include/ChromaEvents.hpp index d3c4e6e..e442fdd 100644 --- a/include/ChromaEvents.hpp +++ b/include/ChromaEvents.hpp @@ -57,5 +57,5 @@ void deserialize(CustomJSONData::CustomBeatmapData* readOnlyBeatmap); void parseEventData(TracksAD::BeatmapAssociatedData& beatmapAD, CustomJSONData::CustomEventData const* customEventData, bool v2); -void AddEventCallbacks(Logger& logger); +void AddEventCallbacks(); } // namespace ChromaEvents diff --git a/include/ChromaHooks.hpp b/include/ChromaHooks.hpp index cf33f3d..7c9eda0 100644 --- a/include/ChromaHooks.hpp +++ b/include/ChromaHooks.hpp @@ -6,16 +6,16 @@ namespace Chroma { class Hooks { private: - inline static std::vector installFuncs; + inline static std::vector installFuncs; public: - static void AddInstallFunc(void (*installFunc)(Logger& logger)) { + static void AddInstallFunc(void (*installFunc)()) { installFuncs.push_back(installFunc); } - static void InstallHooks(Logger& logger) { + static void InstallHooks() { for (auto installFunc : installFuncs) { - installFunc(logger); + installFunc(); } } }; diff --git a/include/ChromaLogger.hpp b/include/ChromaLogger.hpp new file mode 100644 index 0000000..a7e942c --- /dev/null +++ b/include/ChromaLogger.hpp @@ -0,0 +1,8 @@ +#pragma once +#include "beatsaber-hook/shared/utils/logging.hpp" +#include "custom-json-data/shared/CJDLogger.h" + +class ChromaLogger { +public: + static constexpr auto Logger = Paper::ConstLoggerContext("Chroma"); +}; diff --git a/include/assets.hpp b/include/assets.hpp new file mode 100644 index 0000000..f389cff --- /dev/null +++ b/include/assets.hpp @@ -0,0 +1,49 @@ +#pragma once + +#include +#include "beatsaber-hook/shared/utils/typedefs.h" + +struct IncludedAsset { + + IncludedAsset(uint8_t* start, uint8_t* end) : array(reinterpret_cast*>(start)) { + array->klass = nullptr; + array->monitor = nullptr; + array->bounds = nullptr; + array->max_length = end - start - 33; + *(end - 1)= '\0'; + } + + operator ArrayW() const { + init(); + return array; + } + + operator std::string_view() const { + return { reinterpret_cast(array->_values), array->get_Length() }; + } + + operator std::span() const { + return { array->_values, array->get_Length() }; + } + + void init() const { + if(!array->klass) + array->klass = classof(Array*); + } + + private: + Array* array; + +}; + +#define DECLARE_FILE(name) \ + extern "C" uint8_t _binary_##name##_start[]; \ + extern "C" uint8_t _binary_##name##_end[]; \ + const IncludedAsset name { _binary_##name##_start, _binary_##name##_end}; + +namespace IncludedAssets { + + DECLARE_FILE(standard_shader_bundle) + DECLARE_FILE(ui_bsml) + +} diff --git a/include/colorizer/LightColorizer.hpp b/include/colorizer/LightColorizer.hpp index b88a68d..f5fd7e9 100644 --- a/include/colorizer/LightColorizer.hpp +++ b/include/colorizer/LightColorizer.hpp @@ -137,7 +137,7 @@ class LightColorizer { // extensions inline static LightColorizer* GetLightColorizer(GlobalNamespace::BasicBeatmapEventType BasicBeatmapEventType) { - auto it = Colorizers.find(BasicBeatmapEventType.value); + auto it = Colorizers.find(BasicBeatmapEventType.value__); if (it == Colorizers.end()) { return nullptr; } diff --git a/include/colorizer/NoteColorizer.hpp b/include/colorizer/NoteColorizer.hpp index 22f5f24..36e891e 100644 --- a/include/colorizer/NoteColorizer.hpp +++ b/include/colorizer/NoteColorizer.hpp @@ -32,7 +32,7 @@ class NoteColorizer : public ObjectColorizer { GlobalNamespace::NoteControllerBase* _noteController; GlobalNamespace::ColorNoteVisuals* _colorNoteVisuals; - ArrayW _materialPropertyBlockControllers; + ArrayW> _materialPropertyBlockControllers; NoteColorizer(GlobalNamespace::NoteControllerBase* noteController); diff --git a/include/colorizer/ObjectColorizer.hpp b/include/colorizer/ObjectColorizer.hpp index b94c9f6..17ecfa7 100644 --- a/include/colorizer/ObjectColorizer.hpp +++ b/include/colorizer/ObjectColorizer.hpp @@ -3,25 +3,29 @@ #include #include #include +#include #include "UnityEngine/Color.hpp" #include "sombrero/shared/ColorUtils.hpp" -#include "questui_components/shared/concepts.hpp" namespace Chroma { + +template +concept IsConvertible = std::is_convertible_v; + template concept ObjectColorizerMethods = requires(T t, std::optional const& color) { t.Colorize(color); - { t.getColor() } -> QUC::IsQUCConvertible; - { t.getSelfColor() } -> QUC::IsQUCConvertible>; + { t.getColor() } -> IsConvertible; + { t.getSelfColor() } -> IsConvertible>; }; template concept ObjectColorizerInternalMethods = ObjectColorizerMethods && requires(T t) { t.Refresh(); - { t.GlobalColorGetter() } -> QUC::IsQUCConvertible>; - { t.OriginalColorGetter() } -> QUC::IsQUCConvertible>; - { t.OriginalColor } -> QUC::IsQUCConvertible>; + { t.GlobalColorGetter() } -> IsConvertible>; + { t.OriginalColorGetter() } -> IsConvertible>; + { t.OriginalColor } -> IsConvertible>; }; template class ObjectColorizer { diff --git a/include/colorizer/ObstacleColorizer.hpp b/include/colorizer/ObstacleColorizer.hpp index fecc915..d073237 100644 --- a/include/colorizer/ObstacleColorizer.hpp +++ b/include/colorizer/ObstacleColorizer.hpp @@ -35,7 +35,7 @@ class ObstacleColorizer : public ObjectColorizer { GlobalNamespace::ParametricBoxFakeGlowController* _obstacleFakeGlow; float _addColorMultiplier; float _obstacleCoreLerpToWhiteFactor; - ArrayW _materialPropertyBlockControllers; + ArrayW> _materialPropertyBlockControllers; GlobalNamespace::ObstacleControllerBase* obstacleController; explicit ObstacleColorizer(GlobalNamespace::ObstacleControllerBase* obstacleController); @@ -47,7 +47,8 @@ class ObstacleColorizer : public ObjectColorizer { void Refresh() { Sombrero::FastColor const& color = getColor(); - if (color == Sombrero::FastColor(_obstacleFrame->color)) { + auto frameColor = Sombrero::FastColor(_obstacleFrame->color); + if (color == frameColor) { return; } @@ -71,7 +72,7 @@ class ObstacleColorizer : public ObjectColorizer { FPtrWrapper( &UnityEngine::MaterialPropertyBlock::SetColor)>::get(); - for (auto& materialPropertyBlockController : _materialPropertyBlockControllers) { + for (auto materialPropertyBlockController : _materialPropertyBlockControllers) { if (!materialPropertyBlockController->materialPropertyBlock) { continue; } diff --git a/include/colorizer/ParticleColorizer.hpp b/include/colorizer/ParticleColorizer.hpp index 9cce080..66db1c9 100644 --- a/include/colorizer/ParticleColorizer.hpp +++ b/include/colorizer/ParticleColorizer.hpp @@ -62,7 +62,7 @@ class ParticleColorizer { // extensions inline static std::unordered_set>& GetParticleColorizers(GlobalNamespace::BasicBeatmapEventType BasicBeatmapEventType) { - return Colorizers[BasicBeatmapEventType]; + return Colorizers[BasicBeatmapEventType.value__]; } }; } // namespace Chroma diff --git a/include/environment_enhancements/EnvironmentEnhancementManager.hpp b/include/environment_enhancements/EnvironmentEnhancementManager.hpp index 4ad2197..bc50b6b 100644 --- a/include/environment_enhancements/EnvironmentEnhancementManager.hpp +++ b/include/environment_enhancements/EnvironmentEnhancementManager.hpp @@ -4,6 +4,7 @@ #include #include "UnityEngine/Vector3.hpp" +#include "UnityEngine/SceneManagement/SceneManager.hpp" #include "GlobalNamespace/TrackLaneRing.hpp" #include "GlobalNamespace/BeatmapObjectsAvoidance.hpp" @@ -59,10 +60,10 @@ class Profiler { if (point.showTime) { auto difference = time - before; auto millisElapsed = std::chrono::duration_cast(difference).count(); - getLogger().debug("%s took %lldms", name.c_str(), millisElapsed); + ChromaLogger::Logger.debug("{} took %lldms", name.c_str(), millisElapsed); before = time; } else { - getLogger().debug("%s", name.c_str()); + ChromaLogger::Logger.debug("{}", name.c_str()); } } @@ -70,7 +71,7 @@ class Profiler { auto finishTime = std::chrono::duration_cast(endMark - start).count(); - getLogger().debug("Finished! Took %lldms", finishTime); + ChromaLogger::Logger.debug("Finished! Took %lldms", finishTime); } [[nodiscard]] auto elapsedTimeSinceNow() const { diff --git a/include/environment_enhancements/GeometryFactory.hpp b/include/environment_enhancements/GeometryFactory.hpp index 5e3b53f..9a02b1c 100644 --- a/include/environment_enhancements/GeometryFactory.hpp +++ b/include/environment_enhancements/GeometryFactory.hpp @@ -9,8 +9,8 @@ #include "sombrero/shared/FastColor.hpp" #include "UnityEngine/Material.hpp" -#include "Zenject/IInstantiator.hpp" #include "GlobalNamespace/TubeBloomPrePassLight.hpp" +#include "GlobalNamespace/LightWithIdManager.hpp" #include "MaterialsManager.hpp" namespace Chroma { @@ -28,6 +28,6 @@ class GeometryFactory { private: std::optional _originalTubeBloomPrePassLight = std::nullopt; - SafePtr instantiator; + SafePtrUnity lightWithIDManager; }; } // namespace Chroma diff --git a/include/hooks/LightWithIdManager.hpp b/include/hooks/LightWithIdManager.hpp index d70dcfe..005f091 100644 --- a/include/hooks/LightWithIdManager.hpp +++ b/include/hooks/LightWithIdManager.hpp @@ -34,7 +34,7 @@ struct LightIdRegisterer { static void ForceUnregister(GlobalNamespace::ILightWithId* lightWithId) { int lightId = lightWithId->get_lightId(); - auto lights = VList(lightWithIdManager->lights.get(lightId)); + auto lights = VList(lightWithIdManager->_lights.get(lightId)); int index = -1; for (auto i = 0; i < lights.size(); i++) { diff --git a/include/hooks/SceneTransition/SceneTransitionHelper.hpp b/include/hooks/SceneTransition/SceneTransitionHelper.hpp index 91b8c51..a87dc4f 100644 --- a/include/hooks/SceneTransition/SceneTransitionHelper.hpp +++ b/include/hooks/SceneTransition/SceneTransitionHelper.hpp @@ -1,17 +1,17 @@ #pragma once -#include "GlobalNamespace/IDifficultyBeatmap.hpp" +#include "GlobalNamespace/EnvironmentInfoSO.hpp" +#include "GlobalNamespace/BeatmapKey.hpp" #include "GlobalNamespace/OverrideEnvironmentSettings.hpp" #include "custom-json-data/shared/CustomBeatmapData.h" #include "custom-json-data/shared/CustomBeatmapSaveDatav3.h" +#include "songcore/shared/SongLoader/CustomBeatmapLevel.hpp" namespace Chroma { class SceneTransitionHelper { public: - static void Patch(GlobalNamespace::IDifficultyBeatmap* customBeatmapData); - static void Patch(GlobalNamespace::IDifficultyBeatmap* customBeatmapData, - GlobalNamespace::OverrideEnvironmentSettings*& overrideEnvironmentSettings); - static bool BasicPatch(GlobalNamespace::IDifficultyBeatmap* customBeatmapDifficultyData, - CustomJSONData::v3::CustomBeatmapSaveData* customBeatmapDataCustom); + static void Patch(SongCore::SongLoader::CustomBeatmapLevel* beatmapLevel, GlobalNamespace::BeatmapKey key, GlobalNamespace::EnvironmentInfoSO* environment); + static void Patch(SongCore::SongLoader::CustomBeatmapLevel* beatmapLevel, GlobalNamespace::BeatmapKey key, GlobalNamespace::EnvironmentInfoSO* environment, GlobalNamespace::OverrideEnvironmentSettings*& overrideEnvironmentSettings); + static bool BasicPatch(SongCore::SongLoader::CustomBeatmapLevel* beatmapLevel, GlobalNamespace::BeatmapKey key, GlobalNamespace::EnvironmentInfoSO* environment); }; } // namespace Chroma \ No newline at end of file diff --git a/include/lighting/ChromaLightSwitchEventEffect.hpp b/include/lighting/ChromaLightSwitchEventEffect.hpp index f7e61a1..ef1596d 100644 --- a/include/lighting/ChromaLightSwitchEventEffect.hpp +++ b/include/lighting/ChromaLightSwitchEventEffect.hpp @@ -71,6 +71,5 @@ DECLARE_CLASS_CODEGEN( void CopyValues(LightSwitchEventEffect* lightSwitchEventEffect); public : void RegisterLight(GlobalNamespace::ILightWithId* lightWithId, int id); void UnregisterLight(GlobalNamespace::ILightWithId* lightWithId); - Sombrero::FastColor GetOriginalColor(int beatmapEventValue, bool colorBoost) const; ) diff --git a/include/lighting/ChromaRingsRotationEffect.hpp b/include/lighting/ChromaRingsRotationEffect.hpp index 1d75eb8..27483d8 100644 --- a/include/lighting/ChromaRingsRotationEffect.hpp +++ b/include/lighting/ChromaRingsRotationEffect.hpp @@ -52,23 +52,23 @@ DECLARE_CLASS_CODEGEN(Chroma, ChromaRingsRotationEffect, GlobalNamespace::TrackL public: float GetFirstRingRotationAngleCpp() { static auto GetRotation = FPtrWrapper<&GlobalNamespace::TrackLaneRing::GetRotation>::get(); - if (!trackLaneRingsManager->rings) { - getLogger().warning("Rings is null why! %p ", trackLaneRingsManager); - trackLaneRingsManager->rings = Array::New(); + if (!_trackLaneRingsManager->_rings) { + ChromaLogger::Logger.warn("Rings is null why! {} ", fmt::ptr(_trackLaneRingsManager.ptr())); + _trackLaneRingsManager->_rings = Array::New(); } - return GetRotation(trackLaneRingsManager->rings.get(0)); + return GetRotation(_trackLaneRingsManager->_rings.get(0)); } float GetFirstRingDestinationRotationAngleCpp() { static auto GetDestinationRotation = FPtrWrapper<&GlobalNamespace::TrackLaneRing::GetDestinationRotation>::get(); - if (!trackLaneRingsManager->rings) { - getLogger().warning("Rings is null why! %p ", trackLaneRingsManager); - trackLaneRingsManager->rings = Array::New(); + if (!_trackLaneRingsManager->_rings) { + ChromaLogger::Logger.warn("Rings is null why! {} ", fmt::ptr(_trackLaneRingsManager.ptr())); + _trackLaneRingsManager->_rings = Array::New(); } - return GetDestinationRotation(trackLaneRingsManager->rings.get(0)); + return GetDestinationRotation(_trackLaneRingsManager->_rings.get(0)); } DECLARE_INSTANCE_METHOD(void, AddRingRotationEffectF, float angle, float step, float propagationSpeed, float flexySpeed); diff --git a/include/lighting/ColorTween.hpp b/include/lighting/ColorTween.hpp index 7d9693b..b7adb68 100644 --- a/include/lighting/ColorTween.hpp +++ b/include/lighting/ColorTween.hpp @@ -71,7 +71,7 @@ static void SetColor(GlobalNamespace::ILightWithId* lightWithId, if (!lightWithId->get_isRegistered()) { return; } - lightWithIdManager->didChangeSomeColorsThisFrame = true; + lightWithIdManager->_didChangeSomeColorsThisFrame = true; lightWithId->ColorWasSet(color); } diff --git a/include/lighting/LegacyLightHelper.hpp b/include/lighting/LegacyLightHelper.hpp index 4dcd6da..7920ba9 100644 --- a/include/lighting/LegacyLightHelper.hpp +++ b/include/lighting/LegacyLightHelper.hpp @@ -19,7 +19,7 @@ namespace Chroma { // Please let me delete this whole class class LegacyLightHelper { public: - typedef std::unordered_map>> ColorMap; + typedef std::unordered_map>> ColorMap; // internal inline const static int RGB_INT_OFFSET = 2000000000; diff --git a/include/lighting/LightIDTableManager.hpp b/include/lighting/LightIDTableManager.hpp index f996ba7..89f39a6 100644 --- a/include/lighting/LightIDTableManager.hpp +++ b/include/lighting/LightIDTableManager.hpp @@ -1,6 +1,7 @@ #pragma once #include "main.hpp" +#include "ChromaLogger.hpp" #include #include @@ -37,7 +38,7 @@ class LightIDTableManager { auto typeTableIt = table.find(lightId); if (typeTableIt == table.end()) { - getLogger().warning("Unable to find value for type %d", lightId); + ChromaLogger::Logger.warn("Unable to find value for type {}", lightId); return std::nullopt; } @@ -47,11 +48,11 @@ class LightIDTableManager { if (it != typeTable.end()) { return it->second; } else { - getLogger().warning("Unable to find value for type %d and id %d.", lightId, id); + ChromaLogger::Logger.warn("Unable to find value for type {} and id {}.", lightId, id); } } - getLogger().warning("Return not found"); + ChromaLogger::Logger.warn("Return not found"); return std::nullopt; } @@ -87,7 +88,7 @@ class LightIDTableManager { #define ChromaInstallEnvironment(environment) \ struct __ChromaRegisterEnvironment##environment { \ __ChromaRegisterEnvironment##environment() { \ - __android_log_print(Logging::INFO, "QuestHook[Chroma]", "Creating environment " #environment); \ + ChromaLogger::Logger.info("Creating environment {}", #environment); \ \ Chroma::LightIDTableManager::AddEnvironment({ #environment, environment().getEnvironmentLights() }); \ } \ diff --git a/include/main.hpp b/include/main.hpp index 1e102d8..7a553d5 100644 --- a/include/main.hpp +++ b/include/main.hpp @@ -1,25 +1,25 @@ #pragma once -#include "modloader/shared/modloader.hpp" +#include "scotland2/shared/loader.hpp" #include "beatsaber-hook/shared/config/rapidjson-utils.hpp" #include "beatsaber-hook/shared/utils/logging.hpp" #include "beatsaber-hook/shared/config/config-utils.hpp" #include "beatsaber-hook/shared/utils/il2cpp-functions.hpp" #include "ChromaConfig.hpp" +#include "ChromaLogger.hpp" #include Configuration& getConfig(); -Logger& getLogger(); void setChromaEnv(); #if DEBUGB == 0 -#define debugSpamLog(context, ...) context.debug(__VA_ARGS__) +#define debugSpamLog(...) ChromaLogger::Logger.debug(__VA_ARGS__) #else -#define debugSpamLog(context, ...) ((void)0) +#define debugSpamLog(...) ((void)0) #endif inline const std::string modName = "Chroma"; -static ModInfo modInfo; \ No newline at end of file +static modloader::ModInfo modInfo = {modName, VERSION, 0}; \ No newline at end of file diff --git a/include/ui/ModifierViewController.hpp b/include/ui/ModifierViewController.hpp index 57088b6..25b2bf7 100644 --- a/include/ui/ModifierViewController.hpp +++ b/include/ui/ModifierViewController.hpp @@ -1,12 +1,5 @@ #pragma once -#include "questui_components/shared/context.hpp" -#include "questui_components/shared/RootContainer.hpp" -#include "questui_components/shared/components/ScrollableContainer.hpp" -#include "questui_components/shared/components/settings/ToggleSetting.hpp" -#include "questui_components/shared/components/Text.hpp" -#include "questui_components/shared/components/Image.hpp" -#include "questui_components/shared/components/ModifierButton.hpp" #include "UnityEngine/MonoBehaviour.hpp" #include @@ -20,36 +13,10 @@ namespace Chroma { namespace UIUtils { UnityEngine::Sprite* configToIcon(ConfigUtils::ConfigValue const& configValue); - -template -auto chromaToggleUI(ConfigUtils::ConfigValue& configValue, F&& callable, TArgs&&... args) { - using namespace QUC; - - if constexpr (GameplayModifier) { - QUC::Image image(configToIcon(configValue), { 0, 0 }); - return ConfigUtilsModifierToggleSetting(configValue, std::forward(callable), std::forward(args)..., - image); - } else { - return ConfigUtilsToggleSetting(configValue, callable, std::forward(args)...); - } -} - -template auto buildMainUI() { - using namespace QUC; - - return Container(chromaToggleUI(getChromaConfig().environmentEnhancementsEnabled, nullptr), - chromaToggleUI( - getChromaConfig().customColorEventsEnabled, - [](auto&, bool, UnityEngine::Transform*, QUC::RenderContext&) { setChromaEnv(); }), - chromaToggleUI( - getChromaConfig().customNoteColors, - [](auto&, bool, UnityEngine::Transform*, QUC::RenderContext&) { setChromaEnv(); })); -} } // namespace UIUtils } // namespace Chroma -DECLARE_CLASS_CODEGEN(Chroma, ModifierViewController, UnityEngine::MonoBehaviour, private - : QUC::RenderContext ctx{ nullptr }; +DECLARE_CLASS_CODEGEN(Chroma, ModifierViewController, UnityEngine::MonoBehaviour, DECLARE_INSTANCE_METHOD(void, DidActivate, bool first); diff --git a/include/utils/ChromaUtils.hpp b/include/utils/ChromaUtils.hpp index 69add8f..5de1c3e 100644 --- a/include/utils/ChromaUtils.hpp +++ b/include/utils/ChromaUtils.hpp @@ -16,8 +16,6 @@ #include "UnityEngine/Mesh.hpp" #include "UnityEngine/Transform.hpp" -#define GET_FIND_METHOD(mPtr) il2cpp_utils::il2cpp_type_check::MetadataGetter::get() - namespace ChromaUtils { struct ChromaUtilities { inline static std::optional GetColorFromData(rapidjson::Value const& data, @@ -193,6 +191,9 @@ template inline static constexpr std::optional ptrToOpt(T* t) { /// https://answers.unity.com/questions/1594750/is-there-a-premade-triangle-asset.html /// static UnityEngine::Mesh* CreateTriangleMesh() { + static SafePtrUnity mesh; + if(mesh) return mesh.ptr(); + ArrayW vertices = std::initializer_list({ { -0.5f, -0.5f, 0 }, { 0.5f, -0.5f, 0 }, { 0.0f, 0.5f, 0 } }); @@ -200,15 +201,16 @@ static UnityEngine::Mesh* CreateTriangleMesh() { ArrayW triangles = { 0, 1, 2 }; - UnityEngine::Mesh* mesh = UnityEngine::Mesh::New_ctor(); - mesh->set_vertices(vertices); - mesh->set_uv(uv); + mesh = UnityEngine::Mesh::New_ctor(); + mesh->set_vertices(reinterpret_cast*>(vertices.convert())); + mesh->set_uv(reinterpret_cast*>(uv.convert())); mesh->set_triangles(triangles); mesh->RecalculateBounds(); mesh->RecalculateNormals(); mesh->RecalculateTangents(); - return mesh; + + return mesh.ptr(); } // static bool ColorEquals(Sombrero::FastColor c1, Sombrero::FastColor& c2) { diff --git a/mod.json b/mod.json deleted file mode 100644 index b1350e2..0000000 --- a/mod.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "_QPVersion": "0.1.1", - "name": "Chroma", - "id": "chroma", - "author": "Aeroluna", - "porter": "FernTheDev, nyamimi~", - "version": "2.6.0", - "packageId": "com.beatgames.beatsaber", - "packageVersion": "1.28.0_4124311467", - "description": "Colors!", - "coverImage": "cover.png", - "dependencies": [ - { - "version": "^0.15.0", - "id": "custom-types", - "downloadIfMissing": "https://github.com/sc2ad/Il2CppQuestTypePatching/releases/download/v0.15.23/CustomTypes.qmod" - }, - { - "version": "^0.33.0", - "id": "codegen", - "downloadIfMissing": "https://github.com/sc2ad/BeatSaber-Quest-Codegen/releases/download/v0.33.0/Codegen.qmod" - }, - { - "version": "^0.19.3", - "id": "custom-json-data", - "downloadIfMissing": "https://github.com/StackDoubleFlow/CustomJSONData/releases/download/v0.19.3/custom-json-data.qmod" - }, - { - "version": "^0.17.0", - "id": "questui", - "downloadIfMissing": "https://github.com/darknight1050/QuestUI/releases/download/v0.17.11/QuestUI.qmod" - }, - { - "version": "^0.8.1", - "id": "tracks", - "downloadIfMissing": "https://github.com/StackDoubleFlow/Tracks/releases/download/v0.8.1/tracks" - }, - { - "version": "*", - "id": "pinkcore", - "downloadIfMissing": "https://github.com/BSMGPink/PinkCore/releases/download/v1.8.9/PinkCore.qmod" - }, - { - "version": "^1.0.5", - "id": "paper", - "downloadIfMissing": "https://github.com/Fernthedev/paperlog/releases/download/v1.2.9/paperlog.qmod" - }, - { - "version": "^0.10.0", - "id": "songloader", - "downloadIfMissing": "https://github.com/darknight1050/SongLoader/releases/download/v0.10.15/SongLoader.qmod" - } - ], - "modFiles": [ - "libchroma.so" - ], - "libraryFiles": [ - "libbeatsaber-hook_3_14_0.so" - ], - "fileCopies": [], - "copyExtensions": [] -} \ No newline at end of file diff --git a/mod.template.json b/mod.template.json index d9bb110..42dc3d3 100644 --- a/mod.template.json +++ b/mod.template.json @@ -7,7 +7,7 @@ "porter": "FernTheDev, nyamimi~", "version": "${version}", "packageId": "com.beatgames.beatsaber", - "packageVersion": "1.28.0_4124311467", + "packageVersion": "1.37.0_9064817954", "description": "Colors!", "modFiles": [], "dependencies": [], diff --git a/ndk-stack.ps1 b/ndk-stack.ps1 index 7fdfe07..5bfd118 100644 --- a/ndk-stack.ps1 +++ b/ndk-stack.ps1 @@ -11,4 +11,4 @@ if (-not ($PSVersionTable.PSEdition -eq "Core")) { } -Get-Content ./log.log | & $stackScript -sym ./build/debug/ > log_unstripped.log \ No newline at end of file +Get-Content ./log.txt | & $stackScript -sym ./build/debug/ > log_unstripped.log \ No newline at end of file diff --git a/qpm.json b/qpm.json index 175ab1b..9666219 100644 --- a/qpm.json +++ b/qpm.json @@ -1,4 +1,5 @@ { + "version": "0.1.2", "sharedDir": "shared", "dependenciesDir": "extern", "info": { @@ -11,10 +12,23 @@ "overrideSoName": "libchroma.so" } }, + "workspace": { + "scripts": { + "build": [ + "pwsh ./build.ps1" + ] + }, + "qmodIncludeDirs": [ + "./build", + "./extern/libs" + ], + "qmodIncludeFiles": [], + "qmodOutput": "Chroma.qmod" + }, "dependencies": [ { "id": "beatsaber-hook", - "versionRange": "^3.14.0", + "versionRange": "^5.1.7", "additionalData": { "extraFiles": [ "src/inline-hook" @@ -23,15 +37,15 @@ }, { "id": "custom-types", - "versionRange": "^0.15.0", + "versionRange": "^0.17.0", "additionalData": { "includeQmod": true, "private": true } }, { - "id": "codegen", - "versionRange": "^0.33.0", + "id": "bs-cordl", + "versionRange": "^3700.0.0", "additionalData": { "includeQmod": true, "private": true @@ -39,21 +53,21 @@ }, { "id": "custom-json-data", - "versionRange": "^0.20.0", + "versionRange": "^0.21.0", "additionalData": { "private": true } }, { "id": "config-utils", - "versionRange": "^0.8.0", + "versionRange": "^1.4.0", "additionalData": { "private": true } }, { - "id": "questui", - "versionRange": "^0.17.0", + "id": "bsml", + "versionRange": "^0.4.8", "additionalData": { "includeQmod": true, "private": true @@ -66,27 +80,12 @@ }, { "id": "sombrero", - "versionRange": "^0.1.26", + "versionRange": "^0.1.37", "additionalData": {} }, { "id": "tracks", - "versionRange": "^0.9.0", - "additionalData": { - "private": true - } - }, - { - "id": "pinkcore", - "versionRange": "*", - "additionalData": { - "includeQmod": true, - "private": true - } - }, - { - "id": "questui_components", - "versionRange": "^2.0.1", + "versionRange": "^1.0.0", "additionalData": { "private": true } @@ -99,34 +98,27 @@ } }, { - "id": "modloader", + "id": "scotland2", "versionRange": "*", "additionalData": {} }, { "id": "libil2cpp", - "versionRange": "^0.2.3", + "versionRange": "^0.3.1", "additionalData": {} }, { "id": "paper", - "versionRange": "^1.0.5", + "versionRange": "^3.6.0", "additionalData": {} }, { - "id": "songloader", - "versionRange": "^0.10.0", + "id": "songcore", + "versionRange": "^1.0.0", "additionalData": { "includeQmod": true, "private": true } } - ], - "workspace": { - "scripts": { - "build": [ - "pwsh ./build.ps1" - ] - } - } + ] } \ No newline at end of file diff --git a/qpm.shared.json b/qpm.shared.json index 41c1cf9..49c2ad3 100644 --- a/qpm.shared.json +++ b/qpm.shared.json @@ -1,5 +1,6 @@ { "config": { + "version": "0.1.0", "sharedDir": "shared", "dependenciesDir": "extern", "info": { @@ -17,12 +18,18 @@ "build": [ "pwsh ./build.ps1" ] - } + }, + "qmodIncludeDirs": [ + "./build", + "./extern/libs" + ], + "qmodIncludeFiles": [], + "qmodOutput": "Chroma.qmod" }, "dependencies": [ { "id": "beatsaber-hook", - "versionRange": "^3.14.0", + "versionRange": "^5.1.7", "additionalData": { "extraFiles": [ "src/inline-hook" @@ -31,15 +38,15 @@ }, { "id": "custom-types", - "versionRange": "^0.15.0", + "versionRange": "^0.17.0", "additionalData": { "includeQmod": true, "private": true } }, { - "id": "codegen", - "versionRange": "^0.33.0", + "id": "bs-cordl", + "versionRange": "^3700.0.0", "additionalData": { "includeQmod": true, "private": true @@ -47,21 +54,21 @@ }, { "id": "custom-json-data", - "versionRange": "^0.20.0", + "versionRange": "^0.21.0", "additionalData": { "private": true } }, { "id": "config-utils", - "versionRange": "^0.8.0", + "versionRange": "^1.4.0", "additionalData": { "private": true } }, { - "id": "questui", - "versionRange": "^0.17.0", + "id": "bsml", + "versionRange": "^0.4.8", "additionalData": { "includeQmod": true, "private": true @@ -74,27 +81,12 @@ }, { "id": "sombrero", - "versionRange": "^0.1.26", + "versionRange": "^0.1.37", "additionalData": {} }, { "id": "tracks", - "versionRange": "^0.9.0", - "additionalData": { - "private": true - } - }, - { - "id": "pinkcore", - "versionRange": "*", - "additionalData": { - "includeQmod": true, - "private": true - } - }, - { - "id": "questui_components", - "versionRange": "^2.0.1", + "versionRange": "^1.0.0", "additionalData": { "private": true } @@ -107,23 +99,23 @@ } }, { - "id": "modloader", + "id": "scotland2", "versionRange": "*", "additionalData": {} }, { "id": "libil2cpp", - "versionRange": "^0.2.3", + "versionRange": "^0.3.1", "additionalData": {} }, { "id": "paper", - "versionRange": "^1.0.5", + "versionRange": "^3.6.0", "additionalData": {} }, { - "id": "songloader", - "versionRange": "^0.10.0", + "id": "songcore", + "versionRange": "^1.0.0", "additionalData": { "includeQmod": true, "private": true @@ -132,44 +124,80 @@ ] }, "restoredDependencies": [ + { + "dependency": { + "id": "bsml", + "versionRange": "=0.4.42", + "additionalData": { + "soLink": "https://github.com/RedBrumbler/Quest-BSML/releases/download/v0.4.42/libbsml.so", + "debugSoLink": "https://github.com/RedBrumbler/Quest-BSML/releases/download/v0.4.42/debug_libbsml.so", + "overrideSoName": "libbsml.so", + "modLink": "https://github.com/RedBrumbler/Quest-BSML/releases/download/v0.4.42/BSML.qmod", + "branchName": "version/v0_4_42", + "cmake": true + } + }, + "version": "0.4.42" + }, { "dependency": { "id": "libil2cpp", - "versionRange": "=0.2.3", + "versionRange": "=0.3.2", "additionalData": { - "headersOnly": true + "headersOnly": true, + "cmake": false } }, - "version": "0.2.3" + "version": "0.3.2" }, { "dependency": { "id": "tracks", - "versionRange": "=0.9.0", + "versionRange": "=1.0.1", "additionalData": { + "soLink": "https://github.com/StackDoubleFlow/Tracks/releases/download/v1.0.1/libtracks.so", + "debugSoLink": "https://github.com/StackDoubleFlow/Tracks/releases/download/v1.0.1/debug_libtracks.so", "overrideSoName": "libtracks.so", + "modLink": "https://github.com/StackDoubleFlow/Tracks/releases/download/v1.0.1/Tracks.qmod", + "branchName": "version/v1_0_1", "cmake": true } }, - "version": "0.9.0" + "version": "1.0.1" + }, + { + "dependency": { + "id": "rapidjson-macros", + "versionRange": "=1.2.1", + "additionalData": { + "headersOnly": true, + "branchName": "version/v1_2_1", + "cmake": true + } + }, + "version": "1.2.1" }, { "dependency": { "id": "sombrero", - "versionRange": "=0.1.37", + "versionRange": "=0.1.42", "additionalData": { "headersOnly": true, - "branchName": "version-v0.1.37" + "branchName": "version/v0_1_42" } }, - "version": "0.1.37" + "version": "0.1.42" }, { "dependency": { "id": "custom-json-data", - "versionRange": "=0.20.0", + "versionRange": "=0.21.0", "additionalData": { + "soLink": "https://github.com/StackDoubleFlow/CustomJSONData/releases/download/v0.21.0/libcustom-json-data.so", + "debugSoLink": "https://github.com/StackDoubleFlow/CustomJSONData/releases/download/v0.21.0/debug_libcustom-json-data.so", "overrideSoName": "libcustom-json-data.so", + "modLink": "https://github.com/StackDoubleFlow/CustomJSONData/releases/download/v0.21.0/custom-json-data.qmod", + "branchName": "version/v0_21_0", "compileOptions": { "cppFlags": [ "-DRAPIDJSON_NEON" @@ -178,89 +206,69 @@ "cmake": true } }, - "version": "0.20.0" + "version": "0.21.0" }, { "dependency": { "id": "conditional-dependencies", - "versionRange": "=0.1.0", + "versionRange": "=0.3.0", "additionalData": { - "headersOnly": true + "headersOnly": true, + "branchName": "version/v0_3_0", + "cmake": false } }, - "version": "0.1.0" + "version": "0.3.0" }, { "dependency": { - "id": "pinkcore", - "versionRange": "=1.8.10", + "id": "songcore", + "versionRange": "=1.1.13", "additionalData": { - "soLink": "https://github.com/BSMGPink/PinkCore/releases/download/v1.8.10/libpinkcore.so", - "debugSoLink": "https://github.com/BSMGPink/PinkCore/releases/download/v1.8.10/debug_libpinkcore.so", - "overrideSoName": "libpinkcore.so", - "modLink": "https://github.com/BSMGPink/PinkCore/releases/download/v1.8.10/PinkCore.qmod", - "branchName": "version-v1.8.10" + "soLink": "https://github.com/raineio/Quest-SongCore/releases/download/v1.1.13/libsongcore.so", + "debugSoLink": "https://github.com/raineio/Quest-SongCore/releases/download/v1.1.13/debug_libsongcore.so", + "overrideSoName": "libsongcore.so", + "modLink": "https://github.com/raineio/Quest-SongCore/releases/download/v1.1.13/SongCore.qmod", + "branchName": "version/v1_1_13", + "cmake": true } }, - "version": "1.8.10" + "version": "1.1.13" }, { "dependency": { - "id": "questui_components", - "versionRange": "=2.5.4", + "id": "tinyxml2", + "versionRange": "=10.0.0", "additionalData": { - "headersOnly": true, - "overrideSoName": "libquestui_components.so", - "branchName": "version-v2.5.4", - "compileOptions": { - "systemIncludes": [ - "" - ] - } + "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": "2.5.4" + "version": "10.0.0" }, { "dependency": { - "id": "questui", - "versionRange": "=0.17.12", + "id": "paper", + "versionRange": "=3.6.3", "additionalData": { - "soLink": "https://github.com/darknight1050/QuestUI/releases/download/v0.17.12/libquestui.so", - "debugSoLink": "https://github.com/darknight1050/QuestUI/releases/download/v0.17.12/debug_libquestui.so", - "overrideSoName": "libquestui.so", - "modLink": "https://github.com/darknight1050/QuestUI/releases/download/v0.17.12/QuestUI.qmod", - "branchName": "version-v0.17.12", + "soLink": "https://github.com/Fernthedev/paperlog/releases/download/v3.6.3/libpaperlog.so", + "debugSoLink": "https://github.com/Fernthedev/paperlog/releases/download/v3.6.3/debug_libpaperlog.so", + "overrideSoName": "libpaperlog.so", + "modLink": "https://github.com/Fernthedev/paperlog/releases/download/v3.6.3/paperlog.qmod", + "branchName": "version/v3_6_3", "compileOptions": { "systemIncludes": [ - "shared/cppcodec" + "shared/utfcpp/source" ] - } - } - }, - "version": "0.17.12" - }, - { - "dependency": { - "id": "paper", - "versionRange": "=1.2.16", - "additionalData": { - "overrideSoName": "libpaperlog.so" - } - }, - "version": "1.2.16" - }, - { - "dependency": { - "id": "modloader", - "versionRange": "=1.2.3", - "additionalData": { - "soLink": "https://github.com/sc2ad/QuestLoader/releases/download/v1.2.3/libmodloader64.so", - "overrideSoName": "libmodloader.so", - "branchName": "version-v1.2.3" + }, + "cmake": false } }, - "version": "1.2.3" + "version": "3.6.3" }, { "dependency": { @@ -281,69 +289,85 @@ { "dependency": { "id": "config-utils", - "versionRange": "=0.8.0", + "versionRange": "=1.4.2", "additionalData": { "headersOnly": true, - "soLink": "https://github.com/darknight1050/config-utils/releases/download/v0.8.0/libconfig-utils_test.so", - "debugSoLink": "https://github.com/darknight1050/config-utils/releases/download/v0.8.0/debug_libconfig-utils_test.so", + "soLink": "https://github.com/darknight1050/config-utils/releases/download/v1.4.2/libconfig-utils_test.so", "overrideSoName": "libconfig-utils_test.so", - "branchName": "version-v0.8.0" + "branchName": "version/v1_4_2", + "cmake": true } }, - "version": "0.8.0" + "version": "1.4.2" }, { "dependency": { - "id": "songloader", - "versionRange": "=0.10.17", + "id": "custom-types", + "versionRange": "=0.17.8", "additionalData": { - "soLink": "https://github.com/darknight1050/SongLoader/releases/download/v0.10.17/libsongloader.so", - "debugSoLink": "https://github.com/darknight1050/SongLoader/releases/download/v0.10.17/debug_libsongloader.so", - "overrideSoName": "libsongloader.so", - "modLink": "https://github.com/darknight1050/SongLoader/releases/download/v0.10.17/SongLoader.qmod", - "branchName": "version-v0.10.17" + "soLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.17.8/libcustom-types.so", + "debugSoLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.17.8/debug_libcustom-types.so", + "overrideSoName": "libcustom-types.so", + "modLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.17.8/CustomTypes.qmod", + "branchName": "version/v0_17_8", + "compileOptions": { + "cppFlags": [ + "-Wno-invalid-offsetof" + ] + }, + "cmake": true } }, - "version": "0.10.17" + "version": "0.17.8" }, { "dependency": { - "id": "custom-types", - "versionRange": "=0.15.24", + "id": "bs-cordl", + "versionRange": "=3700.0.0", "additionalData": { - "soLink": "https://github.com/sc2ad/Il2CppQuestTypePatching/releases/download/v0.15.24/libcustom-types.so", - "debugSoLink": "https://github.com/sc2ad/Il2CppQuestTypePatching/releases/download/v0.15.24/debug_libcustom-types.so", - "overrideSoName": "libcustom-types.so", - "modLink": "https://github.com/sc2ad/Il2CppQuestTypePatching/releases/download/v0.15.24/CustomTypes.qmod", - "branchName": "version-v0.15.24" + "headersOnly": true, + "branchName": "version/v3700_0_0", + "compileOptions": { + "includePaths": [ + "include" + ], + "cppFeatures": [], + "cppFlags": [ + "-DNEED_UNSAFE_CSHARP", + "-fdeclspec", + "-DUNITY_2021", + "-DHAS_CODEGEN" + ] + } } }, - "version": "0.15.24" + "version": "3700.0.0" }, { "dependency": { "id": "beatsaber-hook", - "versionRange": "=3.14.0", + "versionRange": "=5.1.8", "additionalData": { - "soLink": "https://github.com/sc2ad/beatsaber-hook/releases/download/v3.14.0/libbeatsaber-hook_3_14_0.so", - "debugSoLink": "https://github.com/sc2ad/beatsaber-hook/releases/download/v3.14.0/debug_libbeatsaber-hook_3_14_0.so", - "branchName": "version-v3.14.0" + "soLink": "https://github.com/QuestPackageManager/beatsaber-hook/releases/download/v5.1.8/libbeatsaber-hook_5_1_8.so", + "debugSoLink": "https://github.com/QuestPackageManager/beatsaber-hook/releases/download/v5.1.8/debug_libbeatsaber-hook_5_1_8.so", + "branchName": "version/v5_1_8", + "cmake": true } }, - "version": "3.14.0" + "version": "5.1.8" }, { "dependency": { - "id": "codegen", - "versionRange": "=0.33.0", + "id": "scotland2", + "versionRange": "=0.1.4", "additionalData": { - "soLink": "https://github.com/sc2ad/BeatSaber-Quest-Codegen/releases/download/v0.33.0/libcodegen.so", - "overrideSoName": "libcodegen.so", - "modLink": "https://github.com/sc2ad/BeatSaber-Quest-Codegen/releases/download/v0.33.0/Codegen.qmod", - "branchName": "version-v0.33.0" + "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.33.0" + "version": "0.1.4" }, { "dependency": { diff --git a/shared/CoreAPI.hpp b/shared/CoreAPI.hpp index a0603f3..0d809fb 100644 --- a/shared/CoreAPI.hpp +++ b/shared/CoreAPI.hpp @@ -1,6 +1,6 @@ #pragma once -#include "modloader/shared/modloader.hpp" +#include "scotland2/shared/loader.hpp" #include "utils.hpp" #include "conditional-dependencies/shared/main.hpp" @@ -8,8 +8,8 @@ namespace Chroma { class CoreAPI { public: // Adds a mod that will force Chroma to enable its hooks (for colorizing), when not in a Chroma map. - static void addForceEnableChromaHooks(ModInfo& modInfo) { - static auto function = CondDeps::Find(CHROMA_ID, "addForceEnableChromaHooks"); + static void addForceEnableChromaHooks(modloader::ModInfo& modInfo) { + static auto function = CondDeps::Find(CHROMA_ID, "addForceEnableChromaHooks"); if (function) { function.value()(modInfo); @@ -18,8 +18,8 @@ class CoreAPI { // Removes a mod so that it will no longer force Chroma to enable its hooks (for colorizing), when not in a Chroma // map. - static void removeForceEnableChromaHooks(ModInfo& modInfo) { - static auto function = CondDeps::Find(CHROMA_ID, "removeForceEnableChromaHooks"); + static void removeForceEnableChromaHooks(modloader::ModInfo& modInfo) { + static auto function = CondDeps::Find(CHROMA_ID, "removeForceEnableChromaHooks"); if (function) { function.value()(modInfo); diff --git a/src/ChromaComponentManager.cpp b/src/ChromaComponentManager.cpp index 489cf3e..ea68185 100644 --- a/src/ChromaComponentManager.cpp +++ b/src/ChromaComponentManager.cpp @@ -79,7 +79,7 @@ void animateTubeBloom(std::string_view propName, std::spancolorAlphaMultiplier = val; + tube->_colorAlphaMultiplier = val; tube->MarkDirty(); }); } diff --git a/src/ChromaConfig.cpp b/src/ChromaConfig.cpp deleted file mode 100644 index d8d3036..0000000 --- a/src/ChromaConfig.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "ChromaConfig.hpp" - -DEFINE_CONFIG(ChromaConfig); diff --git a/src/ChromaController.cpp b/src/ChromaController.cpp index 4d9bf7f..36d9eca 100644 --- a/src/ChromaController.cpp +++ b/src/ChromaController.cpp @@ -1,5 +1,6 @@ #include "main.hpp" #include "ChromaConfig.hpp" +#include "ChromaLogger.hpp" #include "ChromaController.hpp" #include "GlobalNamespace/BeatmapObjectManager.hpp" @@ -48,13 +49,13 @@ ChromaController::DelayedStartEnumerator(GlobalNamespace::BeatmapObjectSpawnCont try { Chroma::ChromaController::BeatmapObjectSpawnController = beatmapObjectSpawnController; auto* coreSetup = - il2cpp_utils::cast(beatmapObjectSpawnController->beatmapCallbacksController); + il2cpp_utils::cast(beatmapObjectSpawnController->_beatmapCallbacksController); Chroma::ChromaController::CallbacksController = coreSetup; - IReadonlyBeatmapData* beatmapData = coreSetup->beatmapData; + IReadonlyBeatmapData* beatmapData = coreSetup->_beatmapData; if (!beatmapData) { - getLogger().debug("Beatmap is null, oh no what will we do now?"); + ChromaLogger::Logger.debug("Beatmap is null, oh no what will we do now?"); co_return; // CRASH_UNLESS(beatmapData); } @@ -79,16 +80,16 @@ ChromaController::DelayedStartEnumerator(GlobalNamespace::BeatmapObjectSpawnCont // please let me kill legacy LegacyLightHelper::Activate(list); } catch (const Il2CppException& e) { - getLogger().error("Unable to run legacy due to exception?"); + ChromaLogger::Logger.error("Unable to run legacy due to exception?"); } } } else { - getLogger().debug( - "Beatmap class %s", + ChromaLogger::Logger.debug( + "Beatmap class {}", il2cpp_utils::ClassStandardName(reinterpret_cast(beatmapData)->klass).c_str()); } } catch (std::exception& e) { - getLogger().debug("Chroma controller failed: %s!", e.what()); + ChromaLogger::Logger.debug("Chroma controller failed: {}!", e.what()); throw; }) @@ -96,7 +97,7 @@ ChromaController::DelayedStartEnumerator(GlobalNamespace::BeatmapObjectSpawnCont } void ChromaController::OnActiveSceneChanged(UnityEngine::SceneManagement::Scene current) { - getLogger().debug("Clear scene"); + ChromaLogger::Logger.debug("Clear scene"); if (current.IsValid() && current.get_name() == "GameCore") { CJDLogger::Logger.fmtLog("Clearing all data"); @@ -115,20 +116,20 @@ void ChromaController::OnActiveSceneChanged(UnityEngine::SceneManagement::Scene } void ChromaController::SetChromaLegacy(bool v) { - getLogger().debug("Set chroma legacy to %s", v ? "true" : "false"); + ChromaLogger::Logger.debug("Set chroma legacy to {}", v ? "true" : "false"); ChromaLegacy = v && getChromaConfig().customColorEventsEnabled.GetValue(); } void ChromaController::setChromaRequired(bool chromaMap) { ChromaMap = chromaMap && getChromaConfig().customColorEventsEnabled.GetValue(); - getLogger().debug("Set chroma required/suggested to %s", ChromaMap ? "true" : "false"); + ChromaLogger::Logger.debug("Set chroma required/suggested to {}", ChromaMap ? "true" : "false"); } -void ChromaController::AddForceDoHooks(ModInfo const& otherModInfo) { - getLogger().info("Adding force do hooks, ID: %s", otherModInfo.id.c_str()); +void ChromaController::AddForceDoHooks(modloader::ModInfo const& otherModInfo) { + ChromaLogger::Logger.info("Adding force do hooks, ID: {}", otherModInfo.id.c_str()); ModsForcingDoHooks.emplace(otherModInfo.id); } -void ChromaController::RemoveForceDoHooks(ModInfo const& otherModInfo) { - getLogger().info("Removing force do hooks, ID: %s", otherModInfo.id.c_str()); +void ChromaController::RemoveForceDoHooks(modloader::ModInfo const& otherModInfo) { + ChromaLogger::Logger.info("Removing force do hooks, ID: {}", otherModInfo.id.c_str()); ModsForcingDoHooks.erase(otherModInfo.id); } diff --git a/src/ChromaEvents.cpp b/src/ChromaEvents.cpp index 8b395ca..1ea3a2d 100644 --- a/src/ChromaEvents.cpp +++ b/src/ChromaEvents.cpp @@ -48,7 +48,7 @@ void ChromaEvents::parseEventData(TracksAD::BeatmapAssociatedData& beatmapAD, auto trackIt = eventData.FindMember((v2 ? Chroma::NewConstants::V2_TRACK : Chroma::NewConstants::TRACK).data()); if (trackIt == eventData.MemberEnd() || trackIt->value.IsNull() || !trackIt->value.IsString()) { - getLogger().debug("Track data is missing for Chroma custom event %f", customEventData->time); + ChromaLogger::Logger.debug("Track data is missing for Chroma custom event {}", customEventData->____time_k__BackingField); return; } @@ -62,7 +62,7 @@ void ChromaEvents::parseEventData(TracksAD::BeatmapAssociatedData& beatmapAD, auto trackIt = eventData.FindMember((v2 ? Chroma::NewConstants::V2_TRACK : Chroma::NewConstants::TRACK).data()); if (trackIt == eventData.MemberEnd() || trackIt->value.IsNull() || !trackIt->value.IsString()) { - getLogger().debug("Track data is missing for Chroma custom event %f", customEventData->time); + ChromaLogger::Logger.debug("Track data is missing for Chroma custom event {}", customEventData->____time_k__BackingField); return; } @@ -158,13 +158,13 @@ void CustomEventCallback(BeatmapCallbacksController* callbackController, // fail safe, idek why this needs to be done smh // CJD you bugger - auto* customBeatmapData = (CustomJSONData::CustomBeatmapData*)callbackController->beatmapData; + auto* customBeatmapData = (CustomJSONData::CustomBeatmapData*)callbackController->_beatmapData; if (!ad.parsed) { TracksAD::BeatmapAssociatedData& beatmapAD = TracksAD::getBeatmapAD(customBeatmapData->customData); ChromaEvents::parseEventData(beatmapAD, customEventData, customBeatmapData->v2orEarlier); } - if (typeHash == jsonNameHash_ASSIGNFOGTRACK && customBeatmapData->v2orEarlier) { + if (typeHash == jsonNameHash_ASSIGNFOGTRACK) { Chroma::ChromaFogController::getInstance()->AssignTrack( std::get(ad.data).track); CJDLogger::Logger.fmtLog("Assigned fog controller to track"); @@ -177,6 +177,6 @@ void CustomEventCallback(BeatmapCallbacksController* callbackController, ) } -void ChromaEvents::AddEventCallbacks(Logger& /*logger*/) { +void ChromaEvents::AddEventCallbacks() { CustomJSONData::CustomEventCallbacks::AddCustomEventCallback(&CustomEventCallback); } diff --git a/src/ChromaObjectData.cpp b/src/ChromaObjectData.cpp index 0021b72..ba18119 100644 --- a/src/ChromaObjectData.cpp +++ b/src/ChromaObjectData.cpp @@ -15,12 +15,10 @@ using namespace GlobalNamespace; void Chroma::ChromaObjectDataManager::deserialize(CustomJSONData::CustomBeatmapData* beatmapData) { ChromaObjectDatas.clear(); - static auto contextLogger = getLogger().WithContext(ChromaLogger::ObjectDataDeserialize); - auto* beatmapDataCast = beatmapData; bool v2 = beatmapDataCast->v2orEarlier; - debugSpamLog(contextLogger, "Array klass: %s", il2cpp_utils::ClassStandardName(beatmapLines->klass).c_str()); + debugSpamLog("Array klass: {}", il2cpp_utils::ClassStandardName(beatmapLines->klass).c_str()); TracksAD::BeatmapAssociatedData& beatmapAD = TracksAD::getBeatmapAD(beatmapDataCast->customData); @@ -39,7 +37,7 @@ void Chroma::ChromaObjectDataManager::deserialize(CustomJSONData::CustomBeatmapD CustomJSONData::JSONWrapper* objectDynData = nullptr; if (ASSIGNMENT_CHECK(CustomNoteDataKlass, beatmapObjectData->klass)) { - debugSpamLog(contextLogger, "Custom note %s", il2cpp_utils::ClassStandardName(beatmapObjectData->klass).c_str()); + debugSpamLog("Custom note {}", il2cpp_utils::ClassStandardName(beatmapObjectData->klass).c_str()); auto* customNoteData = reinterpret_cast(beatmapObjectData); objectDynData = customNoteData->customData; @@ -50,7 +48,7 @@ void Chroma::ChromaObjectDataManager::deserialize(CustomJSONData::CustomBeatmapD .value_or( !getIfExistsOpt(objectDynData->value, NewConstants::V2_DISABLE_SPAWN_EFFECT).value_or(true)); } else if (ASSIGNMENT_CHECK(CustomSliderDataKlass, beatmapObjectData->klass)) { - debugSpamLog(contextLogger, "Custom note %s", il2cpp_utils::ClassStandardName(beatmapObjectData->klass).c_str()); + debugSpamLog("Custom note {}", il2cpp_utils::ClassStandardName(beatmapObjectData->klass).c_str()); auto* customNoteData = reinterpret_cast(beatmapObjectData); objectDynData = customNoteData->customData; @@ -67,7 +65,7 @@ void Chroma::ChromaObjectDataManager::deserialize(CustomJSONData::CustomBeatmapD chromaObjectData.Color = ChromaUtilities::GetColorFromData(objectDynData->value, v2); } // else if (false && ASSIGNMENT_CHECK(CustomWaypointDataKlass,beatmapObjectData->klass)) { - // debugSpamLog(contextLogger, "Custom waypoint"); + // debugSpamLog("Custom waypoint"); // auto *customBeatmapEvent = // il2cpp_utils::cast(beatmapObjectData); // diff --git a/src/api/CoreAPI.cpp b/src/api/CoreAPI.cpp index cc7cbe0..62943df 100644 --- a/src/api/CoreAPI.cpp +++ b/src/api/CoreAPI.cpp @@ -2,11 +2,11 @@ #include "ChromaController.hpp" using namespace Chroma; -EXPOSE_API(addForceEnableChromaHooks, void, ModInfo& modInfo) { +EXPOSE_API(addForceEnableChromaHooks, void, modloader::ModInfo& modInfo) { ChromaController::AddForceDoHooks(modInfo); } -EXPOSE_API(removeForceEnableChromaHooks, void, ModInfo& modInfo) { +EXPOSE_API(removeForceEnableChromaHooks, void, modloader::ModInfo& modInfo) { ChromaController::RemoveForceDoHooks(modInfo); } EXPOSE_API(isChromaRunning, bool) { diff --git a/src/api/LightAPI.cpp b/src/api/LightAPI.cpp index f063303..8794200 100644 --- a/src/api/LightAPI.cpp +++ b/src/api/LightAPI.cpp @@ -62,7 +62,7 @@ EXPOSE_API(setAllLightingColorsSafe, void, bool refresh, std::optional; EXPOSE_API(getLightsSafe, LightMap*, GlobalNamespace::LightSwitchEventEffect* lse) { - auto vectorOrg = VList(LightColorizer::GetLightColorizer(lse->event)->Lights); + auto vectorOrg = VList(LightColorizer::GetLightColorizer(lse->_event)->Lights); auto* vectorPtr = new LightMap(vectorOrg.begin(), vectorOrg.end()); return vectorPtr; @@ -76,7 +76,7 @@ using LightPropMap = std::unordered_map>, // GlobalNamespace::LightSwitchEventEffect *lse) { EXPOSE_API(getLightsPropagationGroupedSafe, LightPropMap*, GlobalNamespace::LightSwitchEventEffect* lse) { - auto mapOrg = LightColorizer::GetLightColorizer(lse->event)->getLightsPropagationGrouped(); + auto mapOrg = LightColorizer::GetLightColorizer(lse->_event)->getLightsPropagationGrouped(); auto* mapPtr = new std::unordered_map>(std::move(mapOrg)); return mapPtr; diff --git a/src/api/NoteAPI.cpp b/src/api/NoteAPI.cpp index d50a199..16edc5e 100644 --- a/src/api/NoteAPI.cpp +++ b/src/api/NoteAPI.cpp @@ -12,7 +12,7 @@ using namespace Sombrero; // TODO: unsure of this EXPOSE_API(getGlobalNoteColorSafe, OptColor, int colorType) { - CRASH_UNLESS(colorType >= ColorType::ColorA && colorType <= ColorType::ColorB); + CRASH_UNLESS(colorType >= ColorType::ColorA.value__ && colorType <= ColorType::ColorB.value__); auto optional = NoteColorizer::GlobalColor[colorType]; if (optional) { diff --git a/src/api/SaberAPI.cpp b/src/api/SaberAPI.cpp index 3a97291..a1bfd7c 100644 --- a/src/api/SaberAPI.cpp +++ b/src/api/SaberAPI.cpp @@ -12,7 +12,7 @@ using namespace UnityEngine; using namespace Sombrero; EXPOSE_API(getGlobalSaberColorSafe, OptColor, int saberType) { - CRASH_UNLESS(saberType >= SaberType::SaberA && saberType <= SaberType::SaberB); + CRASH_UNLESS(saberType >= SaberType::SaberA.value__ && saberType <= SaberType::SaberB.value__); auto optional = SaberColorizer::GlobalColor[saberType]; @@ -51,8 +51,8 @@ EXPOSE_API(setSaberColorSafe, void, GlobalNamespace::SaberModelController* saber } EXPOSE_API(getGlobalSabersColorSafe, SaberAPI::ColorOptPair) { - auto colorA = SaberColorizer::GlobalColor[SaberType::SaberA]; - auto colorB = SaberColorizer::GlobalColor[SaberType::SaberB]; + auto colorA = SaberColorizer::GlobalColor[SaberType::SaberA.value__]; + auto colorB = SaberColorizer::GlobalColor[SaberType::SaberB.value__]; return SaberAPI::ColorOptPair{ OptColorFromColor(colorA), OptColorFromColor(colorB) }; } diff --git a/src/colorizer/LightColorizer.cpp b/src/colorizer/LightColorizer.cpp index 65b5c1b..80aa3cb 100644 --- a/src/colorizer/LightColorizer.cpp +++ b/src/colorizer/LightColorizer.cpp @@ -21,40 +21,39 @@ using namespace Sombrero; using namespace Chroma; LightColorizer::LightColorizer(ChromaLightSwitchEventEffect* lightSwitchEventEffect, LightWithIdManager* lightManager) - : _lightSwitchEventEffect(lightSwitchEventEffect), lightId(lightSwitchEventEffect->lightsID), _colors(COLOR_FIELDS), + : _lightSwitchEventEffect(lightSwitchEventEffect), lightId(lightSwitchEventEffect->_lightsID), _colors(COLOR_FIELDS), _originalColors(), _simpleColorSOs(COLOR_FIELDS) { - static auto contextLogger = getLogger().WithContext(ChromaLogger::LightColorizer); - auto Initialize = [this](ColorSO*& colorSO, int index) { - if (auto mColor = il2cpp_utils::try_cast(colorSO)) { - auto* lightSO = mColor.value()->baseColor; + auto Initialize = [this](UnityW colorSO, int index) { + if (auto mColor = il2cpp_utils::try_cast(colorSO.ptr())) { + auto lightSO = mColor.value()->_baseColor; _originalColors[index] = lightSO->color; - } else if (auto sColor = il2cpp_utils::try_cast(colorSO)) { + } else if (auto sColor = il2cpp_utils::try_cast(colorSO.ptr())) { _originalColors[index] = sColor.value()->color; } }; - Initialize(lightSwitchEventEffect->lightColor0, 0); - Initialize(lightSwitchEventEffect->lightColor1, 1); - Initialize(lightSwitchEventEffect->lightColor0Boost, 2); - Initialize(lightSwitchEventEffect->lightColor1Boost, 3); + Initialize(lightSwitchEventEffect->_lightColor0, 0); + Initialize(lightSwitchEventEffect->_lightColor1, 1); + Initialize(lightSwitchEventEffect->_lightColor0Boost, 2); + Initialize(lightSwitchEventEffect->_lightColor1Boost, 3); // AAAAAA PROPAGATION STUFFF - Lights = lightManager->lights.get(lightSwitchEventEffect->lightsID); + Lights = lightManager->_lights.get(lightSwitchEventEffect->_lightsID); if (Lights == nullptr) { - Lights = lightManager->lights.get(lightSwitchEventEffect->lightsID) = + Lights = lightManager->_lights.get(lightSwitchEventEffect->_lightsID) = System::Collections::Generic::List_1<::GlobalNamespace::ILightWithId*>::New_ctor(10); } - LightsSafePtr.emplace(Lights.getInner()); + LightsSafePtr.emplace(reinterpret_cast*>(Lights.getPtr())); } LightColorizer& LightColorizer::New(ChromaLightSwitchEventEffect* lightSwitchEventEffect, GlobalNamespace::LightWithIdManager* lightManager) { - auto& light = Colorizers.emplace(lightSwitchEventEffect->event, LightColorizer(lightSwitchEventEffect, lightManager)) + auto& light = Colorizers.emplace(lightSwitchEventEffect->_event.value__, LightColorizer(lightSwitchEventEffect, lightManager)) .first->second; - ColorizersByLightID[lightSwitchEventEffect->lightsID] = &light; + ColorizersByLightID[lightSwitchEventEffect->_lightsID] = &light; return light; } @@ -94,7 +93,7 @@ void LightColorizer::InitializeSO(ColorSO*& lightColor0, ColorSO*& /*highlightCo ColorSO*& /*highlightColor1Boost*/) { auto Initialize = [this](ColorSO*& colorSO, int index) { if (auto mColor = il2cpp_utils::try_cast(colorSO)) { - auto* lightSO = mColor.value()->baseColor; + auto lightSO = mColor.value()->_baseColor; _originalColors[index] = lightSO->color; } else if (auto sColor = il2cpp_utils::try_cast(colorSO)) { _originalColors[index] = sColor.value()->color; @@ -182,12 +181,12 @@ void LightColorizer::CreateLightColorizerContractByLightID(int lightId, void LightColorizer::CreateLightColorizerContract(BasicBeatmapEventType type, std::function const& callback) { - auto it = Colorizers.find(type); + auto it = Colorizers.find(type.value__); if (it != Colorizers.end()) { callback(it->second); } else { - _contracts.emplace_back(type, callback); + _contracts.emplace_back(type.value__, callback); } } @@ -195,7 +194,7 @@ void LightColorizer::CompleteContracts(ChromaLightSwitchEventEffect* chromaLight // complete open contracts for (auto it = _contracts.begin(); it != _contracts.end();) { auto const& [type, callback] = *it; - if (type != chromaLightSwitchEventEffect->EventType) { + if (type != chromaLightSwitchEventEffect->EventType.value__) { it++; continue; } @@ -206,7 +205,7 @@ void LightColorizer::CompleteContracts(ChromaLightSwitchEventEffect* chromaLight for (auto it = _contractsByLightID.begin(); it != _contractsByLightID.end();) { auto const& [lightId, callback] = *it; - if (lightId != chromaLightSwitchEventEffect->lightsID) { + if (lightId != chromaLightSwitchEventEffect->_lightsID) { it++; continue; } @@ -242,12 +241,12 @@ LightColorizer::getLightsPropagationGrouped() { auto* ring = (*monoBehaviour)->GetComponentInParent(); if (ring != nullptr) { - TrackLaneRingsManager* mngr = managers.FirstOrDefault([&](TrackLaneRingsManager* it) -> bool { - return (it != nullptr) && std::find(it->rings.begin(), it->rings.end(), ring) != it->rings.end(); + TrackLaneRingsManager* mngr = managers->FirstOrDefault([&](TrackLaneRingsManager* it) -> bool { + return (it != nullptr) && std::find(it->_rings.begin(), it->_rings.end(), UnityW(ring)) != it->_rings.end(); }); if (mngr != nullptr) { - z = 1000 + mngr->rings.IndexOf(ring); + z = 1000 + mngr->_rings->IndexOf(ring); } } diff --git a/src/colorizer/Monobehaviours/ChromaClashEffectController.cpp b/src/colorizer/Monobehaviours/ChromaClashEffectController.cpp index ff9bbe4..7740b6a 100644 --- a/src/colorizer/Monobehaviours/ChromaClashEffectController.cpp +++ b/src/colorizer/Monobehaviours/ChromaClashEffectController.cpp @@ -4,8 +4,7 @@ #include #include "colorizer/SaberColorizer.hpp" -#include "UnityEngine/ParticleSystem_MainModule.hpp" -#include "UnityEngine/ParticleSystem_MinMaxGradient.hpp" +#include "UnityEngine/ParticleSystem.hpp" DEFINE_TYPE(Chroma, ChromaClashEffectController); @@ -38,9 +37,9 @@ void ChromaClashEffectController::OnSaberColorChanged(int saberType, Sombrero::FastColor average = Sombrero::FastColor::Lerp(_colors[0], _colors[1], 0.5F); auto sparkleMain = _sparkleParticleSystem->get_main(); - sparkleMain.set_startColor(ParticleSystem::MinMaxGradient(average)); + sparkleMain.set_startColor(ParticleSystem::MinMaxGradient::op_Implicit___UnityEngine____ParticleSystem__MinMaxGradient(average)); auto glowMain = _glowParticleSystem->get_main(); - glowMain.set_startColor(ParticleSystem::MinMaxGradient(average)); + glowMain.set_startColor(ParticleSystem::MinMaxGradient::op_Implicit___UnityEngine____ParticleSystem__MinMaxGradient(average)); } void ChromaClashEffectController::OnDestroy() { diff --git a/src/colorizer/NoteColorizer.cpp b/src/colorizer/NoteColorizer.cpp index c3ff557..27fb358 100644 --- a/src/colorizer/NoteColorizer.cpp +++ b/src/colorizer/NoteColorizer.cpp @@ -24,7 +24,7 @@ NoteColorizer::NoteColorizer(GlobalNamespace::NoteControllerBase* noteController CRASH_UNLESS(_noteController); CRASH_UNLESS(_colorNoteVisuals); - _materialPropertyBlockControllers = colorNoteVisuals->materialPropertyBlockControllers; + _materialPropertyBlockControllers = colorNoteVisuals->_materialPropertyBlockControllers; } NoteColorizer* NoteColorizer::New(GlobalNamespace::NoteControllerBase* noteControllerBase) { @@ -51,16 +51,16 @@ std::optional NoteColorizer::GlobalColorGetter() { return std::nullopt; } - return GlobalColor[(int)colorType]; + return GlobalColor[colorType.value__]; } std::optional NoteColorizer::OriginalColorGetter() { - return _colorNoteVisuals->colorManager->ColorForType(getColorType()); + return _colorNoteVisuals->_colorManager->ColorForType(getColorType()); } void NoteColorizer::GlobalColorize(std::optional const& color, GlobalNamespace::ColorType const& colorType) { - GlobalColor[(int)colorType] = color; + GlobalColor[colorType.value__] = color; for (auto& [_, colorizer] : Colorizers) { colorizer.Refresh(); } @@ -80,7 +80,7 @@ void NoteColorizer::ColorizeSaber(GlobalNamespace::NoteController* noteControlle if (ChromaController::DoColorizerSabers()) { auto* noteData = noteController->noteData; SaberType saberType = noteCutInfo.saberType; - if ((int)noteData->colorType == (int)saberType) { + if (noteData->colorType.value__ == saberType.value__) { SaberColorizer::ColorizeSaber(saberType, GetNoteColorizer(noteController)->getColor()); } } @@ -91,8 +91,8 @@ void NoteColorizer::Refresh() { return; } - Sombrero::FastColor const& color = getColor().Alpha(_colorNoteVisuals->noteColor.a); - if (color == Sombrero::FastColor(_colorNoteVisuals->noteColor)) { + Sombrero::FastColor const& color = getColor().Alpha(_colorNoteVisuals->_noteColor.a); + if (color == Sombrero::FastColor(_colorNoteVisuals->_noteColor)) { return; } @@ -105,8 +105,8 @@ void NoteColorizer::Refresh() { static auto SetColor = FPtrWrapper( &UnityEngine::MaterialPropertyBlock::SetColor)>::get(); - _colorNoteVisuals->noteColor = color; - for (auto* materialPropertyBlockController : _materialPropertyBlockControllers) { + _colorNoteVisuals->_noteColor = color; + for (auto materialPropertyBlockController : _materialPropertyBlockControllers) { if (materialPropertyBlockController == nullptr) { continue; } diff --git a/src/colorizer/ObstacleColorizer.cpp b/src/colorizer/ObstacleColorizer.cpp index e299538..c6bf38b 100644 --- a/src/colorizer/ObstacleColorizer.cpp +++ b/src/colorizer/ObstacleColorizer.cpp @@ -17,16 +17,16 @@ using namespace Chroma; ObstacleColorizer::ObstacleColorizer(GlobalNamespace::ObstacleControllerBase* obstacleController) : obstacleController(obstacleController) { auto* stretchableObstacle = obstacleController->GetComponent(); - _obstacleFrame = stretchableObstacle->obstacleFrame; - _obstacleFakeGlow = stretchableObstacle->obstacleFakeGlow; - _addColorMultiplier = stretchableObstacle->addColorMultiplier; - _obstacleCoreLerpToWhiteFactor = stretchableObstacle->obstacleCoreLerpToWhiteFactor; - _materialPropertyBlockControllers = stretchableObstacle->materialPropertyBlockControllers; + _obstacleFrame = stretchableObstacle->_obstacleFrame; + _obstacleFakeGlow = stretchableObstacle->_obstacleFakeGlow; + _addColorMultiplier = stretchableObstacle->_addColorMultiplier; + _obstacleCoreLerpToWhiteFactor = stretchableObstacle->_obstacleCoreLerpToWhiteFactor; + _materialPropertyBlockControllers = stretchableObstacle->_materialPropertyBlockControllers; auto trueObstacleControllerCast = il2cpp_utils::try_cast(obstacleController); if (trueObstacleControllerCast) { static auto get_obstaclesColor = FPtrWrapper<&ColorManager::get_obstaclesColor>::get(); - OriginalColor = get_obstaclesColor((*trueObstacleControllerCast)->colorManager); + OriginalColor = get_obstaclesColor((*trueObstacleControllerCast)->_colorManager); } else { static auto white = Sombrero::FastColor::white(); // Fallback diff --git a/src/colorizer/ParticleColorizer.cpp b/src/colorizer/ParticleColorizer.cpp index 155f98f..d6cdd04 100644 --- a/src/colorizer/ParticleColorizer.cpp +++ b/src/colorizer/ParticleColorizer.cpp @@ -35,11 +35,11 @@ void ParticleColorizer::UnsubscribeEvent() { std::unordered_set>& ParticleColorizer::GetOrCreateColorizerList(GlobalNamespace::BasicBeatmapEventType eventType) { - auto it = Colorizers.find(eventType); + auto it = Colorizers.find(eventType.value__); if (it == Colorizers.end()) { - Colorizers[eventType] = std::unordered_set>(); - return Colorizers[eventType]; + Colorizers[eventType.value__] = std::unordered_set>(); + return Colorizers[eventType.value__]; } return it->second; @@ -71,15 +71,15 @@ void ParticleColorizer::OnLightColorChanged(GlobalNamespace::BasicBeatmapEventTy Sombrero::FastColor afterHighlightColor; switch (PreviousValue) { case 0: - particleSystemEventEffect->particleColor = particleSystemEventEffect->offColor; + particleSystemEventEffect->_particleColor = particleSystemEventEffect->_offColor; RefreshParticles(particleSystemEventEffect); break; case 1: case 5: color = (PreviousValue == 1) ? _multipliedColorSOs[0]->get_color() : _multipliedColorSOs[1]->get_color(); - particleSystemEventEffect->particleColor = color; - particleSystemEventEffect->offColor = color.Alpha(0); + particleSystemEventEffect->_particleColor = color; + particleSystemEventEffect->_offColor = color.Alpha(0); RefreshParticles(particleSystemEventEffect); break; @@ -87,14 +87,14 @@ void ParticleColorizer::OnLightColorChanged(GlobalNamespace::BasicBeatmapEventTy case 6: color = (PreviousValue == 2) ? _multipliedHighlightColorSOs[0]->get_color() : _multipliedHighlightColorSOs[1]->get_color(); - particleSystemEventEffect->highlightColor = color; - particleSystemEventEffect->offColor = color.Alpha(0); + particleSystemEventEffect->_highlightColor = color; + particleSystemEventEffect->_offColor = color.Alpha(0); afterHighlightColor = (PreviousValue == 2) ? _multipliedColorSOs[0]->get_color() : _multipliedColorSOs[1]->get_color(); - particleSystemEventEffect->afterHighlightColor = afterHighlightColor; + particleSystemEventEffect->_afterHighlightColor = afterHighlightColor; - particleSystemEventEffect->particleColor = - Sombrero::FastColor::Lerp(afterHighlightColor, color, particleSystemEventEffect->highlightValue); + particleSystemEventEffect->_particleColor = + Sombrero::FastColor::Lerp(afterHighlightColor, color, particleSystemEventEffect->_highlightValue); RefreshParticles(particleSystemEventEffect); break; @@ -103,14 +103,14 @@ void ParticleColorizer::OnLightColorChanged(GlobalNamespace::BasicBeatmapEventTy case -1: color = (PreviousValue == 3) ? _multipliedHighlightColorSOs[0]->get_color() : _multipliedHighlightColorSOs[1]->get_color(); - particleSystemEventEffect->highlightColor = color; - particleSystemEventEffect->offColor = color.Alpha(0); - particleSystemEventEffect->particleColor = color; - afterHighlightColor = particleSystemEventEffect->offColor; - particleSystemEventEffect->afterHighlightColor = afterHighlightColor; - - particleSystemEventEffect->particleColor = - Sombrero::FastColor::Lerp(afterHighlightColor, color, particleSystemEventEffect->highlightValue); + particleSystemEventEffect->_highlightColor = color; + particleSystemEventEffect->_offColor = color.Alpha(0); + particleSystemEventEffect->_particleColor = color; + afterHighlightColor = particleSystemEventEffect->_offColor; + particleSystemEventEffect->_afterHighlightColor = afterHighlightColor; + + particleSystemEventEffect->_particleColor = + Sombrero::FastColor::Lerp(afterHighlightColor, color, particleSystemEventEffect->_highlightValue); RefreshParticles(particleSystemEventEffect); break; } @@ -123,11 +123,11 @@ void ParticleColorizer::InitializeSO(std::string const& id, int index, bool high auto* lightMultSO = il2cpp_utils::cast( CRASH_UNLESS(il2cpp_utils::GetFieldValue(_particleSystemEventEffect, colorSOAcessor))); - Sombrero::FastColor multiplierColor = lightMultSO->multiplierColor; - auto* lightSO = lightMultSO->baseColor; + Sombrero::FastColor multiplierColor = lightMultSO->_multiplierColor; + auto lightSO = lightMultSO->_baseColor; SafePtrUnity mColorSO(ScriptableObject::CreateInstance()); - mColorSO->multiplierColor = multiplierColor; + mColorSO->_multiplierColor = multiplierColor; if (_simpleColorSOs.find(index) == _simpleColorSOs.end()) { SafePtrUnity sColorSO(ScriptableObject::CreateInstance()); @@ -137,7 +137,7 @@ void ParticleColorizer::InitializeSO(std::string const& id, int index, bool high SafePtrUnity& sColorSO = _simpleColorSOs[index]; - mColorSO->baseColor = (SimpleColorSO*)sColorSO; + mColorSO->_baseColor = (SimpleColorSO*)sColorSO; auto* mColorPtr = (MultipliedColorSO*)mColorSO; if (highlight) { diff --git a/src/colorizer/SaberColorizer.cpp b/src/colorizer/SaberColorizer.cpp index c4ec4aa..59c53c1 100644 --- a/src/colorizer/SaberColorizer.cpp +++ b/src/colorizer/SaberColorizer.cpp @@ -8,18 +8,14 @@ #include "GlobalNamespace/SetSaberGlowColor.hpp" #include "GlobalNamespace/SetSaberFakeGlowColor.hpp" #include "GlobalNamespace/TubeBloomPrePassLight.hpp" -#include "GlobalNamespace/SaberModelController_InitData.hpp" #include "GlobalNamespace/SaberTrail.hpp" -#include "GlobalNamespace/SetSaberGlowColor_PropertyTintColorPair.hpp" #include "GlobalNamespace/Parametric3SliceSpriteController.hpp" #include "GlobalNamespace/SaberManager.hpp" #include "GlobalNamespace/SaberBurnMarkSparkles.hpp" #include "GlobalNamespace/ColorManager.hpp" #include "UnityEngine/LineRenderer.hpp" #include "UnityEngine/ParticleSystem.hpp" -#include "UnityEngine/ParticleSystem_MainModule.hpp" #include "UnityEngine/Mathf.hpp" -#include "UnityEngine/ParticleSystem_MinMaxGradient.hpp" #include "UnityEngine/Resources.hpp" #include "hooks/SaberManager.hpp" @@ -40,11 +36,11 @@ SaberColorizer::SaberColorizer(GlobalNamespace::Saber* saber, SaberModelControll : _saberModelController(saberModelController) { _saberType = saber->get_saberType(); - _saberTrail = _saberModelController->saberTrail; - _trailTintColor = _saberModelController->initData->trailTintColor; - _saberLight = _saberModelController->saberLight; + _saberTrail = _saberModelController->_saberTrail; + _trailTintColor = _saberModelController->_initData->trailTintColor; + _saberLight = _saberModelController->_saberLight; - _lastColor = _saberModelController->colorManager->ColorForSaberType(_saberType); + _lastColor = _saberModelController->_colorManager->ColorForSaberType(_saberType); OriginalColor = _lastColor; } @@ -55,12 +51,12 @@ SaberColorizer& SaberColorizer::New(GlobalNamespace::Saber* saber) { } std::optional SaberColorizer::GlobalColorGetter() { - return GlobalColor[(int)_saberType]; + return GlobalColor[_saberType.value__]; } void SaberColorizer::GlobalColorize(GlobalNamespace::SaberType saberType, std::optional const& color) { - GlobalColor[(int)saberType] = color; + GlobalColor[saberType.value__] = color; for (auto const& c : GetColorizerList(saberType)) { c->Refresh(); } @@ -91,25 +87,25 @@ void SaberColorizer::Refresh() { _lastColor = color; if (!IsColorable(_saberModelController)) { - auto _setSaberGlowColors = _saberModelController->setSaberGlowColors; - auto _setSaberFakeGlowColors = _saberModelController->setSaberFakeGlowColors; + auto _setSaberGlowColors = _saberModelController->_setSaberGlowColors; + auto _setSaberFakeGlowColors = _saberModelController->_setSaberFakeGlowColors; auto* saberTrail = _saberTrail; - saberTrail->color = (color * _trailTintColor).Linear(); + saberTrail->_color = (color * _trailTintColor).Linear(); if (_setSaberGlowColors) { - for (auto* setSaberGlowColor : _setSaberGlowColors) { - if (setSaberGlowColor == nullptr) { + for (auto setSaberGlowColor : _setSaberGlowColors) { + if (!setSaberGlowColor) { continue; } - MaterialPropertyBlock* materialPropertyBlock = setSaberGlowColor->materialPropertyBlock; + MaterialPropertyBlock* materialPropertyBlock = setSaberGlowColor->_materialPropertyBlock; if (materialPropertyBlock == nullptr) { - setSaberGlowColor->materialPropertyBlock = MaterialPropertyBlock::New_ctor(); - materialPropertyBlock = setSaberGlowColor->materialPropertyBlock; + setSaberGlowColor->_materialPropertyBlock = MaterialPropertyBlock::New_ctor(); + materialPropertyBlock = setSaberGlowColor->_materialPropertyBlock; } - auto propertyTintColorPairs = setSaberGlowColor->propertyTintColorPairs; + auto propertyTintColorPairs = setSaberGlowColor->_propertyTintColorPairs; if (propertyTintColorPairs) { for (auto& propertyTintColorPair : propertyTintColorPairs) { @@ -120,20 +116,20 @@ void SaberColorizer::Refresh() { } } - if (setSaberGlowColor->meshRenderer != nullptr) { - SetPropertyBlock(setSaberGlowColor->meshRenderer, materialPropertyBlock); + if (setSaberGlowColor->_meshRenderer != nullptr) { + SetPropertyBlock(setSaberGlowColor->_meshRenderer, materialPropertyBlock); } } } if (_setSaberFakeGlowColors) { - for (auto* setSaberFakeGlowColor : _setSaberFakeGlowColors) { - if (setSaberFakeGlowColor == nullptr) { + for (auto setSaberFakeGlowColor : _setSaberFakeGlowColors) { + if (!setSaberFakeGlowColor) { continue; } - auto* parametric3SliceSprite = setSaberFakeGlowColor->parametric3SliceSprite; - parametric3SliceSprite->color = color * setSaberFakeGlowColor->tintColor; + auto parametric3SliceSprite = setSaberFakeGlowColor->_parametric3SliceSprite; + parametric3SliceSprite->color = color * setSaberFakeGlowColor->_tintColor; Refresh(parametric3SliceSprite); } } @@ -145,7 +141,7 @@ void SaberColorizer::Refresh() { ColorColorable(color); } - SaberColorChanged.invoke(_saberType, _saberModelController, color); + SaberColorChanged.invoke(_saberType.value__, _saberModelController, color); } SaberColorizer& SaberColorizer::GetColorizer(GlobalNamespace::SaberModelController* saberModelController) { @@ -160,7 +156,7 @@ std::unordered_set SaberColorizer::GetColorizerList(GlobalNames std::unordered_set colorizers; for (auto& [_, colorizer] : Colorizers) { - if (colorizer._saberType.value == saberType.value) { + if (colorizer._saberType.value__ == saberType.value__) { colorizers.emplace(&colorizer); } } diff --git a/src/colorizer/SliderColorizer.cpp b/src/colorizer/SliderColorizer.cpp index bc853bb..eba8e9c 100644 --- a/src/colorizer/SliderColorizer.cpp +++ b/src/colorizer/SliderColorizer.cpp @@ -37,11 +37,11 @@ GlobalNamespace::ColorType SliderColorizer::getColorType() { } std::optional SliderColorizer::GlobalColorGetter() { - return NoteColorizer::GlobalColor[(int)getColorType()]; + return NoteColorizer::GlobalColor[getColorType().value__]; } std::optional SliderColorizer::OriginalColorGetter() { - return _sliderController->colorManager->ColorForType(getColorType()); + return _sliderController->_colorManager->ColorForType(getColorType()); } void SliderColorizer::Reset() { @@ -50,5 +50,5 @@ void SliderColorizer::Reset() { } void SliderColorizer::Refresh() { - _sliderController->initColor = getColor(); + _sliderController->_initColor = getColor(); } diff --git a/src/environment_enhancements/ComponentInitializer.cpp b/src/environment_enhancements/ComponentInitializer.cpp index aa93d8d..a3900a8 100644 --- a/src/environment_enhancements/ComponentInitializer.cpp +++ b/src/environment_enhancements/ComponentInitializer.cpp @@ -8,7 +8,6 @@ #include "GlobalNamespace/LightWithIdMonoBehaviour.hpp" #include "GlobalNamespace/LightWithIds.hpp" -#include "GlobalNamespace/LightWithIds_LightWithId.hpp" #include "GlobalNamespace/ILightWithId.hpp" #include "GlobalNamespace/TrackLaneRing.hpp" #include "GlobalNamespace/TrackLaneRingsManager.hpp" @@ -53,11 +52,11 @@ requires(std::is_convertible_v>) static void cons ArrayW rootComponents = root->GetComponents(); ArrayW originalComponents = original->GetComponents(); - for (int i = 0; i < rootComponents.Length(); i++) { + for (int i = 0; i < rootComponents.size(); i++) { initializeDelegate(rootComponents.get(i), originalComponents.get(i)); if (getChromaConfig().PrintEnvironmentEnhancementDebug.GetValue()) { - getLogger().info("Initialized %s", il2cpp_utils::ClassStandardName(classof(T*)).c_str()); + ChromaLogger::Logger.info("Initialized {}", il2cpp_utils::ClassStandardName(classof(T*)).c_str()); } } } @@ -70,20 +69,20 @@ Chroma::ComponentInitializer::InitializeComponents(UnityEngine::Transform* root, GetComponentAndOriginal( root, original, [&](LightWithIdMonoBehaviour* rootComponent, LightWithIdMonoBehaviour* originalComponent) { - rootComponent->lightManager = originalComponent->lightManager; - LightIdRegisterer::MarkForTableRegister(rootComponent->i_ILightWithId()); + rootComponent->_lightManager = originalComponent->_lightManager; + LightIdRegisterer::MarkForTableRegister(rootComponent->i___GlobalNamespace__ILightWithId()); }); GetComponentAndOriginal(root, original, [&](LightWithIds* rootComponent, LightWithIds* originalComponent) { - rootComponent->lightManager = originalComponent->lightManager; + rootComponent->_lightManager = originalComponent->_lightManager; // cross fingers no stripping if (rootComponent->lightWithIds != nullptr) { auto* lightsWithIdArray = rootComponent->lightWithIds->GetEnumerator(); - while (lightsWithIdArray->i_IEnumerator()->MoveNext()) { + while (lightsWithIdArray->i___System__Collections__IEnumerator()->MoveNext()) { auto* lightIdData = lightsWithIdArray->get_Current(); - LightIdRegisterer::MarkForTableRegister(lightIdData->i_ILightWithId()); + LightIdRegisterer::MarkForTableRegister(lightIdData->i___GlobalNamespace__ILightWithId()); } // TODO: Handle @@ -99,9 +98,9 @@ Chroma::ComponentInitializer::InitializeComponents(UnityEngine::Transform* root, EnvironmentEnhancementManager::RingRotationOffsets[rootComponent] = ringIt->second; } - rootComponent->transform = root; - rootComponent->positionOffset = originalComponent->positionOffset; - rootComponent->posZ = originalComponent->posZ; + rootComponent->_transform = root; + rootComponent->_positionOffset = originalComponent->_positionOffset; + rootComponent->_posZ = originalComponent->_posZ; TrackLaneRingsManager* managerToAdd = nullptr; for (auto const& manager : Chroma::TrackLaneRingsManagerHolder::RingManagers) { @@ -123,22 +122,22 @@ Chroma::ComponentInitializer::InitializeComponents(UnityEngine::Transform* root, if (componentData) { managerToAdd = (GlobalNamespace::TrackLaneRingsManager*)componentData.value()->NewTrackLaneRingsManager; } else { - auto rings = manager->rings; - if (rings.Contains(originalComponent)) { + auto rings = manager->_rings; + if (rings.contains(originalComponent)) { managerToAdd = manager; } } if (managerToAdd != nullptr) { - auto rings = managerToAdd->rings; + auto rings = managerToAdd->_rings; if (rings) { std::vector newRingList(rings.begin(), rings.end()); newRingList.push_back(rootComponent); - managerToAdd->rings = il2cpp_utils::vectorToArray(newRingList); + managerToAdd->_rings = il2cpp_utils::vectorToArray(newRingList); } else { - managerToAdd->rings = Array::New(rootComponent); + managerToAdd->_rings = Array::New(rootComponent); } break; @@ -164,7 +163,7 @@ Chroma::ComponentInitializer::InitializeComponents(UnityEngine::Transform* root, } if (componentData) { - rootComponent->trackLaneRingsManager = + rootComponent->_trackLaneRingsManager = (GlobalNamespace::TrackLaneRingsManager*)componentData.value()->NewTrackLaneRingsManager; break; @@ -201,32 +200,32 @@ Chroma::ComponentInitializer::InitializeComponents(UnityEngine::Transform* root, root, original, [&](TrackLaneRingsRotationEffectSpawner * rootComponent, TrackLaneRingsRotationEffectSpawner * originalComponent) constexpr { - rootComponent->beatmapCallbacksController = originalComponent->beatmapCallbacksController; - rootComponent->trackLaneRingsRotationEffect = rootComponent->GetComponent(); + rootComponent->_beatmapCallbacksController = originalComponent->_beatmapCallbacksController; + rootComponent->_trackLaneRingsRotationEffect = rootComponent->GetComponent(); }); GetComponentAndOriginal( root, original, [&](Spectrogram * rootComponent, Spectrogram * originalComponent) constexpr { - rootComponent->spectrogramData = originalComponent->spectrogramData; + rootComponent->_spectrogramData = originalComponent->_spectrogramData; }); GetComponentAndOriginal( root, original, [&](LightRotationEventEffect * rootComponent, LightRotationEventEffect * originalComponent) constexpr { - rootComponent->beatmapCallbacksController = originalComponent->beatmapCallbacksController; + rootComponent->_beatmapCallbacksController = originalComponent->_beatmapCallbacksController; }); GetComponentAndOriginal( root, original, [&](LightPairRotationEventEffect * rootComponent, LightPairRotationEventEffect * originalComponent) constexpr { - rootComponent->beatmapCallbacksController = originalComponent->beatmapCallbacksController; - rootComponent->audioTimeSource = originalComponent->audioTimeSource; + rootComponent->_beatmapCallbacksController = originalComponent->_beatmapCallbacksController; + rootComponent->_audioTimeSource = originalComponent->_audioTimeSource; - auto* transformL = originalComponent->transformL; - auto* transformR = originalComponent->transformR; + auto transformL = originalComponent->_transformL; + auto transformR = originalComponent->_transformR; - rootComponent->transformL = root->GetChild(transformL->GetSiblingIndex()); - rootComponent->transformR = root->GetChild(transformR->GetSiblingIndex()); + rootComponent->_transformL = root->GetChild(transformL->GetSiblingIndex()); + rootComponent->_transformR = root->GetChild(transformR->GetSiblingIndex()); // We have to enable the object to tell unity to run Start rootComponent->set_enabled(true); @@ -235,16 +234,16 @@ Chroma::ComponentInitializer::InitializeComponents(UnityEngine::Transform* root, GetComponentAndOriginal( root, original, [&](ParticleSystemEventEffect * rootComponent, ParticleSystemEventEffect * originalComponent) constexpr { - rootComponent->beatmapCallbacksController = originalComponent->beatmapCallbacksController; - rootComponent->particleSystem = root->GetComponent(); + rootComponent->_beatmapCallbacksController = originalComponent->_beatmapCallbacksController; + rootComponent->_particleSystem = root->GetComponent(); rootComponent->set_enabled(true); }); GetComponentAndOriginal( root, original, [&](Mirror * rootComponent, Mirror * originalComponent) constexpr { - rootComponent->mirrorRenderer = UnityEngine::Object::Instantiate(originalComponent->mirrorRenderer); - rootComponent->mirrorMaterial = UnityEngine::Object::Instantiate(originalComponent->mirrorMaterial); + rootComponent->_mirrorRenderer = UnityEngine::Object::Instantiate(originalComponent->_mirrorRenderer); + rootComponent->_mirrorMaterial = UnityEngine::Object::Instantiate(originalComponent->_mirrorMaterial); }); auto const& newGameObject = gameObjectInfos.emplace_back(root->get_gameObject()); @@ -252,7 +251,7 @@ Chroma::ComponentInitializer::InitializeComponents(UnityEngine::Transform* root, auto rootChildCount = root->get_childCount(); for (int i = 0; i < rootChildCount; i++) { - auto* transform = root->GetChild(i); + auto transform = root->GetChild(i); int index = transform->GetSiblingIndex(); InitializeComponents(transform, original->GetChild(index), gameObjectInfos, componentDatas); @@ -274,7 +273,7 @@ void ComponentInitializer::PrefillComponentsData(UnityEngine::Transform* root, componentDatas.reserve(componentDatas.size() + root->get_childCount()); auto rootChildCount = root->get_childCount(); for (int i = 0; i < rootChildCount; i++) { - auto* transform = root->GetChild(i); + auto transform = root->GetChild(i); PrefillComponentsData(transform, componentDatas); } } @@ -304,7 +303,7 @@ void ComponentInitializer::PostfillComponentsData(UnityEngine::Transform* root, auto rootChildCount = root->get_childCount(); for (int i = 0; i < rootChildCount; i++) { - auto* transform = root->GetChild(i); + auto transform = root->GetChild(i); auto index = transform->GetSiblingIndex(); PostfillComponentsData(transform, original->GetChild(index), componentDatas); } @@ -323,7 +322,7 @@ static void InitializeTubeBloomPrePassLights(rapidjson::Value const& data, std:: ChromaUtils::getIfExists(*tubeBloomPrePassLightJSON, Chroma::NewConstants::BLOOM_FOG_INTENSITY_MULTIPLIER); auto SetColorAlphaMultiplier = [](TubeBloomPrePassLight * tubeBloomPrePassLight, float value) constexpr { - tubeBloomPrePassLight->colorAlphaMultiplier = value; + tubeBloomPrePassLight->_colorAlphaMultiplier = value; tubeBloomPrePassLight->MarkDirty(); }; @@ -364,7 +363,7 @@ static void InitializeFog(rapidjson::Value const& data, std::spanfogParams; + auto params = fog->_fogParams; if (attenuation) { params->attenuation = Chroma::fogAttenuationFix(*attenuation); } @@ -420,12 +419,12 @@ static void InitializeLights(rapidjson::Value const& data, std::spani_IDisposable()); - while (enumerator->i_IEnumerator()->MoveNext()) { + while (enumerator->i___System__Collections__IEnumerator()->MoveNext()) { auto* e = enumerator->get_Current(); - lightWithIds.emplace_back(e->i_ILightWithId()); + lightWithIds.emplace_back(e->i___GlobalNamespace__ILightWithId()); } } else if (auto castedMonoLight = il2cpp_utils::try_cast(comp)) { - lightWithIds.emplace_back(castedMonoLight.value()->i_ILightWithId()); + lightWithIds.emplace_back(castedMonoLight.value()->i___GlobalNamespace__ILightWithId()); } } @@ -434,12 +433,12 @@ static void InitializeLights(rapidjson::Value const& data, std::span_lightSwitchEventEffect->lightsID; + int psuedoLightId = LightColorizer::GetLightColorizer(*type)->_lightSwitchEventEffect->_lightsID; auto monoBehaviourCast = il2cpp_utils::try_cast(lightWithId); @@ -449,12 +448,12 @@ static void InitializeLights(rapidjson::Value const& data, std::span(lightWithId); if (lightWithIdsCast) { - lightWithIdsCast.value()->lightId = psuedoLightId; + lightWithIdsCast.value()->_lightId = psuedoLightId; } } }; - auto SetLightID = [&](auto&& lightWithId) constexpr { + auto SetLightID = [&](ILightWithId* const& lightWithId) constexpr { if (lightID) { LightIdRegisterer::SetRequestedId(lightWithId, *lightID); } diff --git a/src/environment_enhancements/EnvironmentEnhancementManager.cpp b/src/environment_enhancements/EnvironmentEnhancementManager.cpp index dc46723..be01a3e 100644 --- a/src/environment_enhancements/EnvironmentEnhancementManager.cpp +++ b/src/environment_enhancements/EnvironmentEnhancementManager.cpp @@ -45,9 +45,9 @@ Chroma::EnvironmentEnhancementManager::LookupId(std::string_view const id, Chrom ret.emplace_back(o); } } catch (std::exception& e) { - getLogger().error("Failed to match (%s) for lookup (%s) with id (%s)", o.FullID.c_str(), lookupMethodStr, + ChromaLogger::Logger.error("Failed to match ({}) for lookup ({}) with id ({})", o.FullID.c_str(), lookupMethodStr, id.data()); - getLogger().error("Error: %s", e.what()); + ChromaLogger::Logger.error("Error: {}", e.what()); } } }; @@ -96,8 +96,8 @@ Chroma::EnvironmentEnhancementManager::LookupId(std::string_view const id, Chrom } } } catch (std::exception const& e) { - getLogger().error("Failed to create match for lookup (%s) with id (%s)", lookupMethodStr.data(), id.data()); - getLogger().error("Error: %s", e.what()); + ChromaLogger::Logger.error("Failed to create match for lookup ({}) with id ({})", lookupMethodStr.data(), id.data()); + ChromaLogger::Logger.error("Error: {}", e.what()); } ret.shrink_to_fit(); @@ -198,10 +198,10 @@ void EnvironmentEnhancementManager::GetAllGameObjects() { auto gameObjectsAll = UnityEngine::Resources::FindObjectsOfTypeAll(); std::vector gameObjectsVec; - gameObjectsVec.reserve(gameObjectsAll.Length()); + gameObjectsVec.reserve(gameObjectsAll.size()); // I'll probably revist this formula for getting objects by only grabbing the root objects and adding all the children - for (int i = 0; i < gameObjectsAll.Length(); i++) { + for (int i = 0; i < gameObjectsAll.size(); i++) { auto* gameObject = gameObjectsAll.get(i); if (gameObject == nullptr) { continue; @@ -228,7 +228,7 @@ void EnvironmentEnhancementManager::GetAllGameObjects() { GetChildRecursive(gameObject->get_transform(), allChildren); for (auto& transform : allChildren) { - auto* childGameObject = transform->get_gameObject(); + auto* childGameObject = transform->get_gameObject().ptr(); if (std::find(gameObjectsVec.begin(), gameObjectsVec.end(), childGameObject) == gameObjectsVec.end()) { gameObjectsVec2.push_back(childGameObject); } @@ -241,13 +241,6 @@ void EnvironmentEnhancementManager::GetAllGameObjects() { } _globalGameObjectInfos.emplace_back(gameObject); - - // // seriously what the fuck beat games - // // GradientBackground permanently yeeted because it looks awful and can ruin multi-colored chroma maps - // if (gameObject->get_name() == "GradientBackground") - // { - // gameObject->SetActive(false); - // } } // Shrink if necessary @@ -268,15 +261,15 @@ void EnvironmentEnhancementManager::GetAllGameObjects() { ss << o.FullID << std::endl; } - getLogger().info("Objects found in environment:\n%s", ss.str().c_str()); + ChromaLogger::Logger.info("Objects found in environment:\n{}", ss.str().c_str()); }).detach(); } } void EnvironmentEnhancementManager::Init(CustomJSONData::CustomBeatmapData* customBeatmapData) { float noteLinesDistance = 0.6F; - getLogger().debug("Custom beat map %p", customBeatmapData); - getLogger().debug("Custom beat map custom data %p", customBeatmapData->customData); + ChromaLogger::Logger.debug("Custom beat map {}", fmt::ptr(customBeatmapData)); + ChromaLogger::Logger.debug("Custom beat map custom data {}", fmt::ptr(customBeatmapData->customData)); auto const& customDynWrapper = customBeatmapData->customData->value; bool v2 = customBeatmapData->v2orEarlier; CJDLogger::Logger.fmtLog("Is environment v2 {}", v2); @@ -288,6 +281,17 @@ void EnvironmentEnhancementManager::Init(CustomJSONData::CustomBeatmapData* cust RingRotationOffsets.clear(); ParametricBoxControllerParameters::TransformParameters.clear(); + if (getChromaConfig().environmentEnhancementsEnabled.GetValue()) + { + // seriously what the fuck beat games + // GradientBackground permanently yeeted because it looks awful and can ruin multi-colored chroma maps + auto gradientBackground = UnityEngine::GameObject::Find("/Environment/GradientBackground"); + if (gradientBackground) + { + gradientBackground->SetActive(false); + } + } + if (!customDynWrapper) { if (v2) { LegacyEnvironmentRemoval::Init(customBeatmapData); @@ -373,7 +377,7 @@ void EnvironmentEnhancementManager::Init(CustomJSONData::CustomBeatmapData* cust << lookupString; if (getChromaConfig().PrintEnvironmentEnhancementDebug.GetValue()) { - getLogger().info("ID [\"%s\"] using method [%s] found:", id.data(), lookupString.c_str()); + ChromaLogger::Logger.info("ID [\"{}\"] using method [{}] found:", id.data(), lookupString.c_str()); } profiler.mark(foundObjectsLog.str()); @@ -396,10 +400,10 @@ void EnvironmentEnhancementManager::Init(CustomJSONData::CustomBeatmapData* cust if (getChromaConfig().PrintEnvironmentEnhancementDebug.GetValue()) { for (auto const& o : foundObjects) { - getLogger().info("%s", o.heldRef.FullID.c_str()); + ChromaLogger::Logger.info("{}", o.heldRef.FullID.c_str()); } - getLogger().info("====================================="); + ChromaLogger::Logger.info("====================================="); } TransformData spawnData(gameObjectDataVal, v2, noteLinesDistance); @@ -441,8 +445,8 @@ void EnvironmentEnhancementManager::Init(CustomJSONData::CustomBeatmapData* cust profiler.mark("Duplicating [" + gameObjectInfo.FullID + "]:", false); } - auto* gameObject = gameObjectInfo.GameObject; - auto* parent = gameObject->get_transform()->get_parent(); + auto gameObject = gameObjectInfo.GameObject; + auto parent = gameObject->get_transform()->get_parent(); auto scene = gameObject->get_scene(); for (int i = 0; i < dupeAmount.value(); i++) { @@ -485,7 +489,7 @@ void EnvironmentEnhancementManager::Init(CustomJSONData::CustomBeatmapData* cust gameObject->SetActive(active.value()); } - auto* transform = gameObject->get_transform(); + auto transform = gameObject->get_transform(); spawnData.Apply(transform, leftHanded); auto const& position = spawnData.position; @@ -504,18 +508,18 @@ void EnvironmentEnhancementManager::Init(CustomJSONData::CustomBeatmapData* cust auto* trackLaneRing = gameObject->GetComponentInChildren(); if (trackLaneRing != nullptr) { if (position || localPosition) { - trackLaneRing->positionOffset = trackLaneRing->get_transform()->get_localPosition(); - trackLaneRing->posZ = 0; + trackLaneRing->_positionOffset = trackLaneRing->get_transform()->get_localPosition(); + trackLaneRing->_posZ = 0; } if (rotation || localRotation) { RingRotationOffsets[trackLaneRing] = trackLaneRing->get_transform()->get_localRotation(); - trackLaneRing->rotZ = 0; + trackLaneRing->_rotZ = 0; } } // Handle ParametricBoxController - auto* parametricBoxController = gameObject->GetComponentInChildren(); + auto parametricBoxController = gameObject->GetComponentInChildren(); if (parametricBoxController != nullptr) { if (position || localPosition) { ParametricBoxControllerParameters::SetTransformPosition( @@ -558,9 +562,9 @@ void EnvironmentEnhancementManager::Init(CustomJSONData::CustomBeatmapData* cust controllerData.RotationUpdate += [=]() { RingRotationOffsets[trackLaneRing] = trackLaneRing->transform->get_localRotation(); }; controllerData.PositionUpdate += - [=]() { trackLaneRing->positionOffset = trackLaneRing->transform->get_localPosition(); }; + [=]() { trackLaneRing->_positionOffset = trackLaneRing->transform->get_localPosition(); }; } else if (parametricBoxController != nullptr) { - auto* parametricBoxControllerTransform = parametricBoxController->get_transform(); + auto parametricBoxControllerTransform = parametricBoxController->get_transform().ptr(); controllerData.ScaleUpdate += [=]() { ParametricBoxControllerParameters::SetTransformScale(parametricBoxController, parametricBoxControllerTransform->get_localScale()); @@ -591,10 +595,10 @@ void EnvironmentEnhancementManager::Init(CustomJSONData::CustomBeatmapData* cust // Log all objects for (auto const& profile : profileData) { profile.printMarks(); - getLogger().info("=====================================\n"); + ChromaLogger::Logger.info("=====================================\n"); } - getLogger().info("Finished environment enhancements took %lldms", millisElapsed); + ChromaLogger::Logger.info("Finished environment enhancements took {}ldms", millisElapsed); }).detach(); /// Handle materials @@ -620,7 +624,7 @@ void EnvironmentEnhancementManager::GetChildRecursive(UnityEngine::Transform* ga children.reserve(children.size() + gameObject->get_childCount()); auto gameObjectChildCount = gameObject->get_childCount(); for (int i = 0; i < gameObjectChildCount; i++) { - auto* child = gameObject->GetChild(i); + auto* child = gameObject->GetChild(i).ptr(); children.push_back(child); GetChildRecursive(child, children); } diff --git a/src/environment_enhancements/EnvironmentMaterialManager.cpp b/src/environment_enhancements/EnvironmentMaterialManager.cpp index ab0cb3a..6e52bba 100644 --- a/src/environment_enhancements/EnvironmentMaterialManager.cpp +++ b/src/environment_enhancements/EnvironmentMaterialManager.cpp @@ -22,7 +22,9 @@ custom_types::Helpers::Coroutine Chroma::EnvironmentMaterialManager::Activate() auto loads = environments | Select([&](std::string_view s) { return Load(s); }); for (auto const& n : loads) { - while (n->get_isDone()) { + if (!n) continue; + + while (!n->get_isDone()) { co_yield nullptr; } } @@ -30,7 +32,7 @@ custom_types::Helpers::Coroutine Chroma::EnvironmentMaterialManager::Activate() auto environmentMaterials = UnityEngine::Resources::FindObjectsOfTypeAll(); auto Save = [&](ShaderType key, std::string_view matName) { - auto* material = environmentMaterials.FirstOrDefault([&](auto const& e) { return e->get_name() == matName; }); + auto* material = environmentMaterials->FirstOrDefault([&](auto const& e) { return e->get_name() == matName; }); if (material != nullptr) { EnvironmentMaterials[key] = material; CJDLogger::Logger.fmtLog("Saving [{}] to [{}].", matName, static_cast(key)); @@ -46,8 +48,10 @@ custom_types::Helpers::Coroutine Chroma::EnvironmentMaterialManager::Activate() Save(ShaderType::InterscopeCar, "Car"); for (auto const& environment : environments) { - UnityEngine::SceneManagement::SceneManager::UnloadSceneAsync(environment); + //UnityEngine::SceneManagement::SceneManager::UnloadSceneAsync(environment); } + + co_return; } std::optional Chroma::EnvironmentMaterialManager::getMaterial(Chroma::ShaderType shaderType) { diff --git a/src/environment_enhancements/GameObjectInfo.cpp b/src/environment_enhancements/GameObjectInfo.cpp index 1d7fb4b..662dffc 100644 --- a/src/environment_enhancements/GameObjectInfo.cpp +++ b/src/environment_enhancements/GameObjectInfo.cpp @@ -20,7 +20,7 @@ Chroma::GameObjectInfo::GameObjectInfo(UnityEngine::GameObject* gameObject) { } else { // Why doesnt GetSiblingIndex work on root objects? auto rootGameObjects = transformGameObject->get_scene().GetRootGameObjects(); - index = rootGameObjects.IndexOf(transformGameObject); + index = rootGameObjects->IndexOf(transformGameObject); } nameList.emplace_back("[" + std::to_string(index) + "]" + static_cast(transform->get_name())); diff --git a/src/environment_enhancements/GeometryFactory.cpp b/src/environment_enhancements/GeometryFactory.cpp index 5d8353c..6f5bc6e 100644 --- a/src/environment_enhancements/GeometryFactory.cpp +++ b/src/environment_enhancements/GeometryFactory.cpp @@ -8,12 +8,14 @@ #include "UnityEngine/MeshCollider.hpp" #include "UnityEngine/MeshFilter.hpp" #include "UnityEngine/Mesh.hpp" +#include "UnityEngine/Resources.hpp" #include "UnityEngine/Rendering/ShadowCastingMode.hpp" #include "GlobalNamespace/TubeBloomPrePassLight.hpp" #include "GlobalNamespace/ParametricBoxController.hpp" #include "GlobalNamespace/SaberModelContainer.hpp" #include "GlobalNamespace/TubeBloomPrePassLightWithId.hpp" +#include "Zenject/DiContainer.hpp" #include "hooks/LightWithIdManager.hpp" using namespace Chroma; @@ -43,20 +45,18 @@ GeometryType geometryTypeFromString(std::string_view str) { return GeometryType::Triangle; } - getLogger().error("Unknown geometry type %s", str.data()); + ChromaLogger::Logger.error("Unknown geometry type {}", str.data()); return Chroma::GeometryType::Cube; } GeometryFactory::GeometryFactory(MaterialsManager& materialsManager, bool v2) : materialsManager(materialsManager), v2(v2) { - auto* tube = CRASH_UNLESS(Resources::FindObjectsOfTypeAll()).FirstOrDefault(); + auto* tube = CRASH_UNLESS(Resources::FindObjectsOfTypeAll())->FirstOrDefault(); if (tube != nullptr) { _originalTubeBloomPrePassLight = tube; } - - instantiator = reinterpret_cast( - Resources::FindObjectsOfTypeAll().FirstOrDefault()->container); + lightWithIDManager = Resources::FindObjectsOfTypeAll()->FirstOrDefault()->_container->Resolve(); } GameObject* Chroma::GeometryFactory::Create(rapidjson::Value const& data) { @@ -103,7 +103,7 @@ GameObject* Chroma::GeometryFactory::Create(rapidjson::Value const& data) { } UnityEngine::GameObject* go = UnityEngine::GameObject::CreatePrimitive(primitiveType); - go->set_name(geometryStr.value_or("") + materialInfo.ShaderTypeStr); + go->set_name(std::string(geometryStr.value_or("")) + materialInfo.ShaderTypeStr); go->set_layer(14); auto* meshRenderer = go->GetComponent(); @@ -147,25 +147,26 @@ GameObject* Chroma::GeometryFactory::Create(rapidjson::Value const& data) { parametricBoxController, parametricBoxController->get_transform()->get_localPosition()); ParametricBoxControllerParameters::SetTransformScale(parametricBoxController, parametricBoxController->get_transform()->get_localScale()); - parametricBoxController->meshRenderer = meshRenderer; + parametricBoxController->_meshRenderer = meshRenderer; if (_originalTubeBloomPrePassLight) { auto* origTube = *_originalTubeBloomPrePassLight; - tubeBloomPrePassLight->mainEffectPostProcessEnabled = origTube->mainEffectPostProcessEnabled; - tubeBloomPrePassLight->lightType = origTube->lightType; - tubeBloomPrePassLight->registeredWithLightType = origTube->registeredWithLightType; + tubeBloomPrePassLight->_mainEffectPostProcessEnabled = origTube->_mainEffectPostProcessEnabled; + tubeBloomPrePassLight->_lightType = origTube->_lightType; + tubeBloomPrePassLight->_registeredWithLightType = origTube->_registeredWithLightType; } else { CJDLogger::Logger.fmtLog("[{{nameof(_originalTubeBloomPrePassLight)}}] was null."); throw std::runtime_error("[{nameof(_originalTubeBloomPrePassLight)}] was null."); } - tubeBloomPrePassLight->parametricBoxController = parametricBoxController; + tubeBloomPrePassLight->_parametricBoxController = parametricBoxController; - auto* tubeBloomPrePassLightWithId = instantiator->InstantiateComponent(go); - tubeBloomPrePassLightWithId->tubeBloomPrePassLight = tubeBloomPrePassLight; + auto* tubeBloomPrePassLightWithId = go->AddComponent(); + tubeBloomPrePassLightWithId->_lightManager = lightWithIDManager.ptr(); + tubeBloomPrePassLightWithId->_tubeBloomPrePassLight = tubeBloomPrePassLight; - LightIdRegisterer::MarkForTableRegister(tubeBloomPrePassLightWithId->i_ILightWithId()); + LightIdRegisterer::MarkForTableRegister(tubeBloomPrePassLightWithId->i___GlobalNamespace__ILightWithId()); go->SetActive(true); diff --git a/src/environment_enhancements/LegacyEnvironmentRemoval.cpp b/src/environment_enhancements/LegacyEnvironmentRemoval.cpp index 13df194..745a22e 100644 --- a/src/environment_enhancements/LegacyEnvironmentRemoval.cpp +++ b/src/environment_enhancements/LegacyEnvironmentRemoval.cpp @@ -10,73 +10,62 @@ using namespace Chroma; void Chroma::LegacyEnvironmentRemoval::Init(CustomJSONData::CustomBeatmapData* /*customBeatmap*/) { - static auto contextLogger = getLogger().WithContext(ChromaLogger::EnvironmentRemoval); - auto& dynDataWrapper = ChromaController::infoDatCopy; + auto const& objectsToKillOpt = ChromaController::environmentObjectsRemovalV2; - getLogger().debug("Environment data: %p", dynDataWrapper ? "true" : "false"); + ChromaLogger::Logger.debug("Environment data: {}", objectsToKillOpt ? "true" : "false"); - if (dynDataWrapper) { - DocumentUTF16& dynData = *dynDataWrapper; - auto objectsToKillIt = dynData.FindMember(Chroma::NewConstants::V2_ENVIRONMENT_REMOVAL.data()); + if (objectsToKillOpt) { + auto const& objectsToKill = *objectsToKillOpt; - if (objectsToKillIt != dynData.MemberEnd()) { + ChromaLogger::Logger.warn("Legacy Environment Removal Detected..."); + ChromaLogger::Logger.warn("Please do not use Legacy Environment Removal for new maps as it is deprecated and its " + "functionality in future versions of Chroma cannot be guaranteed"); - auto objectsToKill = objectsToKillIt->value.GetArray(); - getLogger().warning("Legacy Environment Removal Detected..."); - getLogger().warning("Please do not use Legacy Environment Removal for new maps as it is deprecated and its " - "functionality in future versions of Chroma cannot be guaranteed"); + auto gameObjects = UnityEngine::Resources::FindObjectsOfTypeAll(); - auto gameObjects = UnityEngine::Resources::FindObjectsOfTypeAll(); + for (auto const& s : objectsToKill) { + if (s == "TrackLaneRing" || s == "BigTrackLaneRing") { - for (auto& oValue : objectsToKill) { - std::u16string s = oValue.GetString(); - if (s == u"TrackLaneRing" || s == u"BigTrackLaneRing") { - - for (int i = 0; i < gameObjects.Length(); i++) { - UnityEngine::GameObject* n = gameObjects.get(i); - - if (n == nullptr) { - continue; - } + for (auto const& n : gameObjects) { + if (n == nullptr || UnityW(n) == nullptr) { + continue; + } - auto nName = csstrtostr(n->get_name()); - if (nName.find(s) != std::string::npos) { - if (s == u"TrackLaneRing" && nName.find(u"Big") != std::string::npos) continue; + auto nName = static_cast(n->get_name()); + if (nName.find(s) != std::string::npos) { + if (s == "TrackLaneRing" && nName.find("Big") != std::string::npos) continue; - debugSpamLog(contextLogger, "Setting %s to disabled", nName); - n->SetActive(false); - } + debugSpamLog("Setting {} to disabled", nName); + n->SetActive(false); } + } - } else { - for (int i = 0; i < gameObjects.Length(); i++) { - UnityEngine::GameObject* n = gameObjects.get(i); - - if (n == nullptr) { - continue; - } + } else { + for (auto const& n : gameObjects) { + if (n == nullptr || UnityW(n) == nullptr) { + continue; + } - auto gStrIl2 = n->get_name(); - std::u16string gStr = gStrIl2 != nullptr ? std::u16string(csstrtostr(gStrIl2)) : u""; + auto gStrIl2 = n->get_name(); + std::string gStr = gStrIl2 != nullptr ? static_cast(gStrIl2) : ""; - auto scene = n->get_scene(); + auto scene = n->get_scene(); - if (!scene.IsValid()) { - continue; - } + if (!scene.IsValid()) { + continue; + } - auto sceneNameIl2 = scene.get_name(); - std::string sceneName = sceneNameIl2 != nullptr ? sceneNameIl2 : ""; + auto sceneNameIl2 = scene.get_name(); + std::string sceneName = sceneNameIl2 != nullptr ? sceneNameIl2 : ""; - bool sceneEnvironment = !sceneName.empty() && sceneName.find("Environment") != std::string::npos; + bool sceneEnvironment = !sceneName.empty() && sceneName.find("Environment") != std::string::npos; - bool sceneMenu = !sceneName.empty() && sceneName.find("Menu") != std::string::npos; + bool sceneMenu = !sceneName.empty() && sceneName.find("Menu") != std::string::npos; - if (sceneEnvironment && !sceneMenu && gStr.find(s) != std::string::npos) { - debugSpamLog(contextLogger, "Setting %s to disabled else check", gStr.c_str()); - n->SetActive(false); - } + if (sceneEnvironment && !sceneMenu && gStr.find(s) != std::string::npos) { + debugSpamLog("Setting {} to disabled else check", gStr.c_str()); + n->SetActive(false); } } } diff --git a/src/environment_enhancements/MaterialsManager.cpp b/src/environment_enhancements/MaterialsManager.cpp index f3cda55..6923d06 100644 --- a/src/environment_enhancements/MaterialsManager.cpp +++ b/src/environment_enhancements/MaterialsManager.cpp @@ -1,9 +1,23 @@ #include "environment_enhancements/MaterialsManager.hpp" #include "Chroma.hpp" +#include "ChromaLogger.hpp" +#include "UnityEngine/Resources.hpp" #include "utils/ChromaUtils.hpp" -#include "UnityEngine/MaterialGlobalIlluminationFlags.hpp" #include "environment_enhancements/EnvironmentMaterialManager.hpp" +#include "assets.hpp" +#include "UnityEngine/AssetBundle.hpp" +#include "UnityEngine/Shader.hpp" +#include "UnityEngine/AssetBundleRequest.hpp" +#include "UnityEngine/AsyncOperation.hpp" +#include "UnityEngine/AssetBundleCreateRequest.hpp" +#include "UnityEngine/MaterialGlobalIlluminationFlags.hpp" +#include "UnityEngine/WaitForSeconds.hpp" +#include "UnityEngine/GameObject.hpp" +#include "UnityEngine/MeshRenderer.hpp" +#include "custom-types/shared/coroutine.hpp" +#include "bsml/shared/BSML/SharedCoroutineStarter.hpp" + using namespace Chroma; using namespace UnityEngine; @@ -21,7 +35,7 @@ ShaderType shaderTypeFromString(std::string_view str) { READ_ENUM(InterscopeCar) READ_ENUM(WaterfallMirror) - getLogger().error("Unknown shader type %s", str.data()); + ChromaLogger::Logger.error("Unknown shader type {}", str.data()); return Chroma::ShaderType::Standard; } @@ -77,6 +91,7 @@ UnityEngine::Material* Chroma::MaterialsManager::InstantiateSharedMaterial(Shade { "ENABLE_HEIGHT_FOG", "MULTIPLY_COLOR_WITH_ALPHA", "_ENABLE_MAIN_EFFECT_WHITE_BOOST" })); break; case ShaderType::BaseWater: + // TODO: Fix water shader shaderName = water; shaderKeywords = ArrayW(std::initializer_list( { "FOG", "HEIGHT_FOG", "INVERT_RIMLIGHT", "MASK_RED_IS_ALPHA", "NOISE_DITHERING", "NORMAL_MAP", @@ -85,14 +100,27 @@ UnityEngine::Material* Chroma::MaterialsManager::InstantiateSharedMaterial(Shade "_WHITEBOOSTTYPE_NONE", "_ZWRITE_ON" })); break; } - - auto* shader = Shader::Find(shaderName); - auto* material = Material::New_ctor(shader); + auto shader = + Resources::FindObjectsOfTypeAll().front([&](auto const& e) { return e->get_name() == shaderName; }); + if (!shader) { + ChromaLogger::Logger.error("Unable to find shader {}", shaderName); + // fallback + if (shaderType != ShaderType::Standard) { + return InstantiateSharedMaterial(ShaderType::Standard); + } else { + ChromaLogger::Logger.fmtThrowError("Unable to find shader {}", shaderName); + } + } + auto* material = Material::New_ctor(shader.value()); material->set_globalIlluminationFlags(globalIlluminationFlags); material->set_enableInstancing(true); material->set_color({ 0, 0, 0, 0 }); + if (shaderType == ShaderType::Standard) { + material->SetFloat("_Metallic", 0); + } + if (shaderKeywords) { material->set_shaderKeywords(shaderKeywords); } @@ -100,6 +128,7 @@ UnityEngine::Material* Chroma::MaterialsManager::InstantiateSharedMaterial(Shade return material; } + MaterialInfo Chroma::MaterialsManager::CreateMaterialInfo(rapidjson::Value const& data) { ArrayW shaderKeywords; auto shaderKeywordsIt = diff --git a/src/hooks/BeatEffectSpawner.cpp b/src/hooks/BeatEffectSpawner.cpp index 71eef5d..75adb1a 100644 --- a/src/hooks/BeatEffectSpawner.cpp +++ b/src/hooks/BeatEffectSpawner.cpp @@ -9,12 +9,12 @@ #include "colorizer/BombColorizer.hpp" #include "colorizer/NoteColorizer.hpp" +#include "GlobalNamespace/BeatEffect.hpp" #include "GlobalNamespace/ColorExtensions.hpp" #include "GlobalNamespace/BeatEffectSpawner.hpp" -#include "GlobalNamespace/BeatEffectSpawner_InitData.hpp" #include "GlobalNamespace/MemoryPoolContainer_1.hpp" +#include "GlobalNamespace/ILazyCopyHashSet_1.hpp" #include "GlobalNamespace/LazyCopyHashSet_1.hpp" - #include "GlobalNamespace/AudioTimeSyncController.hpp" #include "custom-json-data/shared/CustomBeatmapData.h" @@ -47,29 +47,29 @@ MAKE_HOOK_MATCH(BeatEffectSpawner_HandleNoteDidStartJump, &BeatEffectSpawner::Ha /// TRANSPILE HERE // if (self->initData->hideNoteSpawnEffect) - if (BeatEffectForce(self->initData->hideNoteSpawnEffect, noteController)) { + if (BeatEffectForce(self->_initData->hideNoteSpawnEffect, noteController)) { return; } if (noteController->hidden) { return; } - if (noteController->noteData->time + 0.1F < self->audioTimeSyncController->songTime) { + if (noteController->noteData->time + 0.1F < self->_audioTimeSyncController->songTime) { return; } ColorType colorType = noteController->noteData->colorType; Sombrero::FastColor a = - (colorType != ColorType::None) ? self->colorManager->ColorForType(colorType) : self->bombColorEffect; - auto* beatEffect = self->beatEffectPoolContainer->Spawn(); - beatEffect->didFinishEvent->Add(self->i_IBeatEffectDidFinishEvent()); + (colorType != ColorType::None) ? self->_colorManager->ColorForType(colorType) : self->_bombColorEffect; + auto beatEffect = self->_beatEffectPoolContainer->Spawn(); + beatEffect->didFinishEvent->Add(self->i___GlobalNamespace__IBeatEffectDidFinishEvent()); beatEffect->get_transform()->SetPositionAndRotation( - noteController->get_worldRotation() * noteController->get_jumpStartPos() - Sombrero::FastVector3(0.F, 0.15F, 0.F), + Sombrero::FastQuaternion(noteController->get_worldRotation()) * noteController->get_jumpStartPos() - Sombrero::FastVector3(0.F, 0.15F, 0.F), Sombrero::FastQuaternion::identity()); - beatEffect->Init(a * 1.F, self->effectDuration, noteController->get_worldRotation()); + beatEffect->Init(a * 1.F, self->_effectDuration, noteController->get_worldRotation()); } -void BeatEffectSpawnerHook(Logger& logger) { +void BeatEffectSpawnerHook() { // TODO: DO TODO ABOVE - INSTALL_HOOK_ORIG(logger, BeatEffectSpawner_HandleNoteDidStartJump); + INSTALL_HOOK_ORIG(ChromaLogger::Logger, BeatEffectSpawner_HandleNoteDidStartJump); } ChromaInstallHooks(BeatEffectSpawnerHook) \ No newline at end of file diff --git a/src/hooks/BeatmapDataTransformHelper.cpp b/src/hooks/BeatmapDataTransformHelper.cpp index a8a9692..c8d5abf 100644 --- a/src/hooks/BeatmapDataTransformHelper.cpp +++ b/src/hooks/BeatmapDataTransformHelper.cpp @@ -4,9 +4,8 @@ #include "GlobalNamespace/BeatmapDataTransformHelper.hpp" #include "GlobalNamespace/IReadonlyBeatmapData.hpp" -#include "GlobalNamespace/IPreviewBeatmapLevel.hpp" +#include "GlobalNamespace/BeatmapLevel.hpp" #include "GlobalNamespace/GameplayModifiers.hpp" -#include "GlobalNamespace/PracticeSettings.hpp" #include "GlobalNamespace/EnvironmentEffectsFilterPreset.hpp" #include "GlobalNamespace/EnvironmentIntensityReductionOptions.hpp" @@ -14,22 +13,19 @@ #include "ChromaEvents.hpp" #include "ChromaObjectData.hpp" -#include "System/Diagnostics/StackTrace.hpp" - using namespace GlobalNamespace; using namespace Chroma; MAKE_HOOK_MATCH(BeatmapDataTransformHelper_CreateTransformedBeatmapData, &BeatmapDataTransformHelper::CreateTransformedBeatmapData, GlobalNamespace::IReadonlyBeatmapData*, - ::GlobalNamespace::IReadonlyBeatmapData* beatmapData, - ::GlobalNamespace::IPreviewBeatmapLevel* beatmapLevel, + ::GlobalNamespace::IReadonlyBeatmapData* beatmapData, ::GlobalNamespace::BeatmapLevel* beatmapLevel, ::GlobalNamespace::GameplayModifiers* gameplayModifiers, bool leftHanded, ::GlobalNamespace::EnvironmentEffectsFilterPreset environmentEffectsFilterPreset, ::GlobalNamespace::EnvironmentIntensityReductionOptions* environmentIntensityReductionOptions, - ::GlobalNamespace::MainSettingsModelSO* mainSettingsModel) { + ::BeatSaber::PerformancePresets::PerformancePreset* performancePreset) { auto* result = BeatmapDataTransformHelper_CreateTransformedBeatmapData( beatmapData, beatmapLevel, gameplayModifiers, leftHanded, environmentEffectsFilterPreset, - environmentIntensityReductionOptions, mainSettingsModel); + environmentIntensityReductionOptions, performancePreset); // Essentially, here we cancel the original method. DO NOT call it IF it's a Chroma map if (!ChromaController::DoChromaHooks() || MultiplayerConnectedPlayerInstallerHookHolder::MultiplayerInvoked) { @@ -50,7 +46,7 @@ MAKE_HOOK_MATCH(BeatmapDataTransformHelper_CreateTransformedBeatmapData, // auto* stackTrace = System::Diagnostics::StackTrace::New_ctor(); // - // getLogger().debug("Frames: %d", stackTrace->frames->Length()); + // ChromaLogger::Logger.debug("Frames: {}", stackTrace->frames->Length()); // if // (!stackTrace->GetFrame(2)->GetMethod()->get_Name()->Contains(il2cpp_utils::newcsstr("MultiplayerConnectedPlayerInstaller"))) @@ -61,8 +57,8 @@ MAKE_HOOK_MATCH(BeatmapDataTransformHelper_CreateTransformedBeatmapData, return result; } -void BeatmapDataTransformHelperHook(Logger& /*logger*/) { - INSTALL_HOOK(getLogger(), BeatmapDataTransformHelper_CreateTransformedBeatmapData); +void BeatmapDataTransformHelperHook() { + INSTALL_HOOK(ChromaLogger::Logger, BeatmapDataTransformHelper_CreateTransformedBeatmapData); } ChromaInstallHooks(BeatmapDataTransformHelperHook) \ No newline at end of file diff --git a/src/hooks/BeatmapObjectCallbackController.cpp b/src/hooks/BeatmapObjectCallbackController.cpp index 5682d31..a8470f6 100644 --- a/src/hooks/BeatmapObjectCallbackController.cpp +++ b/src/hooks/BeatmapObjectCallbackController.cpp @@ -29,7 +29,7 @@ MAKE_HOOK_MATCH(BeatmapObjectCallbackController_Start, &BeatmapCallbacksControll } } -void InstallBeatmapObjectCallbackControllerHooks(Logger& logger) { - INSTALL_HOOK(logger, BeatmapObjectCallbackController_Start); +void InstallBeatmapObjectCallbackControllerHooks() { + INSTALL_HOOK(ChromaLogger::Logger, BeatmapObjectCallbackController_Start); } ChromaInstallHooks(InstallBeatmapObjectCallbackControllerHooks) \ No newline at end of file diff --git a/src/hooks/BeatmapObjectSpawnController.cpp b/src/hooks/BeatmapObjectSpawnController.cpp index 2a43b7f..8d9d632 100644 --- a/src/hooks/BeatmapObjectSpawnController.cpp +++ b/src/hooks/BeatmapObjectSpawnController.cpp @@ -23,8 +23,8 @@ MAKE_HOOK_MATCH(BeatmapObjectSpawnController_Start, &BeatmapObjectSpawnControlle self->StartCoroutine(delayedStartCoro); } -void BeatmapObjectSpawnControllerHook(Logger& logger) { - INSTALL_HOOK(logger, BeatmapObjectSpawnController_Start); +void BeatmapObjectSpawnControllerHook() { + INSTALL_HOOK(ChromaLogger::Logger, BeatmapObjectSpawnController_Start); } ChromaInstallHooks(BeatmapObjectSpawnControllerHook) \ No newline at end of file diff --git a/src/hooks/DefaultEnvironmentEventsFactory.cpp b/src/hooks/DefaultEnvironmentEventsFactory.cpp new file mode 100644 index 0000000..e75613b --- /dev/null +++ b/src/hooks/DefaultEnvironmentEventsFactory.cpp @@ -0,0 +1,38 @@ +#include "Chroma.hpp" +#include "ChromaController.hpp" +#include "hooks/MultiplayerConnectedPlayerInstaller.hpp" + +#include "GlobalNamespace/BeatmapDataTransformHelper.hpp" +#include "GlobalNamespace/IReadonlyBeatmapData.hpp" +#include "GlobalNamespace/BeatmapLevel.hpp" +#include "GlobalNamespace/GameplayModifiers.hpp" +#include "GlobalNamespace/EnvironmentEffectsFilterPreset.hpp" +#include "GlobalNamespace/DefaultEnvironmentEventsFactory.hpp" + +#include "lighting/ChromaEventData.hpp" +#include "ChromaEvents.hpp" +#include "ChromaObjectData.hpp" + +#include "songcore/shared/SongCore.hpp" + +using namespace GlobalNamespace; +using namespace Chroma; + +MAKE_HOOK_MATCH(DefaultEnvironmentEventsFactory_InsertDefaultEvents, + &DefaultEnvironmentEventsFactory::InsertDefaultEvents, void, + ::GlobalNamespace::BeatmapData* beatmapData) { + + // TODO: Check if chroma map before doing this + // I DON'T KNOW WHY THIS EXISTS BUT IT WILL BREAK MAPS + + // This method causes v2 maps to have default lights on + // and that's not good? + + return; +} + +void DefaultEnvironmentEventsFactoryHook() { + INSTALL_HOOK(ChromaLogger::Logger, DefaultEnvironmentEventsFactory_InsertDefaultEvents); +} + +ChromaInstallHooks(DefaultEnvironmentEventsFactoryHook) \ No newline at end of file diff --git a/src/hooks/EnvironmentComponent/BeatmapObjectsAvoidance.cpp b/src/hooks/EnvironmentComponent/BeatmapObjectsAvoidance.cpp index 0d0dfeb..7055f0a 100644 --- a/src/hooks/EnvironmentComponent/BeatmapObjectsAvoidance.cpp +++ b/src/hooks/EnvironmentComponent/BeatmapObjectsAvoidance.cpp @@ -34,8 +34,8 @@ MAKE_HOOK_MATCH(BeatmapObjectsAvoidance_Update, &BeatmapObjectsAvoidance::Update } } -void BeatmapObjectsAvoidanceHook(Logger& logger) { - INSTALL_HOOK(logger, BeatmapObjectsAvoidance_Update); +void BeatmapObjectsAvoidanceHook() { + INSTALL_HOOK(ChromaLogger::Logger, BeatmapObjectsAvoidance_Update); } ChromaInstallHooks(BeatmapObjectsAvoidanceHook) \ No newline at end of file diff --git a/src/hooks/EnvironmentComponent/BloomFogEnvironment.cpp b/src/hooks/EnvironmentComponent/BloomFogEnvironment.cpp index 2045b26..bd94e0e 100644 --- a/src/hooks/EnvironmentComponent/BloomFogEnvironment.cpp +++ b/src/hooks/EnvironmentComponent/BloomFogEnvironment.cpp @@ -14,11 +14,11 @@ MAKE_HOOK_MATCH(BloomFogEnvironment_Awake, &BloomFogEnvironment::OnEnable, void, return; } - self->fogParams = Object::Instantiate(self->fogParams); + self->_fogParams = Object::Instantiate(self->fogParams); } -void BloomFogEnvironmentHook(Logger& logger) { - INSTALL_HOOK(logger, BloomFogEnvironment_Awake); +void BloomFogEnvironmentHook() { + INSTALL_HOOK(ChromaLogger::Logger, BloomFogEnvironment_Awake); } ChromaInstallHooks(BloomFogEnvironmentHook) \ No newline at end of file diff --git a/src/hooks/EnvironmentComponent/LightWithIdManager.cpp b/src/hooks/EnvironmentComponent/LightWithIdManager.cpp index 921b980..58b3833 100644 --- a/src/hooks/EnvironmentComponent/LightWithIdManager.cpp +++ b/src/hooks/EnvironmentComponent/LightWithIdManager.cpp @@ -1,5 +1,6 @@ #include "ChromaController.hpp" +#include "System/Nullable_1.hpp" #include "GlobalNamespace/LightWithIdManager.hpp" #include "colorizer/LightColorizer.hpp" #include "custom-json-data/shared/VList.h" @@ -38,15 +39,15 @@ MAKE_HOOK_MATCH(LightWithIdManager_RegisterLight, &LightWithIdManager::RegisterL } // [] does not bound check, use get() - auto& lights = self->lights.get(lightId); + auto& lights = self->_lights.get(lightId); if (lights == nullptr) { lights = System::Collections::Generic::List_1<::GlobalNamespace::ILightWithId*>::New_ctor(10); } lightWithId->__SetIsRegistered(); - auto* lightWithIdIt = std::find(lights->items.begin(), lights->items.end(), lightWithId); - if (lightWithIdIt != lights->items.end()) { + auto* lightWithIdIt = std::find(lights->_items.begin(), lights->_items.end(), lightWithId); + if (lightWithIdIt != lights->_items.end()) { return; } @@ -117,9 +118,9 @@ MAKE_HOOK_MATCH(LightWithIdManager_SetColorForId, &LightWithIdManager::SetColorF return LightWithIdManager_SetColorForId(self, lightId, color); } - self->colors[lightId] = { color, true }; - self->didChangeSomeColorsThisFrame = true; - auto list = VList(self->lights.get(lightId)); + self->_colors[lightId] = System::Nullable_1( true, color ); + self->_didChangeSomeColorsThisFrame = true; + auto list = VList(self->_lights.get(lightId)); if (list == nullptr) { return; } @@ -130,11 +131,11 @@ MAKE_HOOK_MATCH(LightWithIdManager_SetColorForId, &LightWithIdManager::SetColorF } } -void LightWithIdManagerHook(Logger& logger) { - INSTALL_HOOK(logger, LightWithIdManager_LateUpdate); - INSTALL_HOOK(logger, LightWithIdManager_UnregisterLight); - INSTALL_HOOK(logger, LightWithIdManager_SetColorForId); - INSTALL_HOOK(logger, LightWithIdManager_RegisterLight); +void LightWithIdManagerHook() { + INSTALL_HOOK(ChromaLogger::Logger, LightWithIdManager_LateUpdate); + INSTALL_HOOK(ChromaLogger::Logger, LightWithIdManager_UnregisterLight); + INSTALL_HOOK(ChromaLogger::Logger, LightWithIdManager_SetColorForId); + INSTALL_HOOK(ChromaLogger::Logger, LightWithIdManager_RegisterLight); } ChromaInstallHooks(LightWithIdManagerHook) \ No newline at end of file diff --git a/src/hooks/EnvironmentComponent/ParametricBoxController.cpp b/src/hooks/EnvironmentComponent/ParametricBoxController.cpp index ccb91e5..bab9262 100644 --- a/src/hooks/EnvironmentComponent/ParametricBoxController.cpp +++ b/src/hooks/EnvironmentComponent/ParametricBoxController.cpp @@ -49,7 +49,7 @@ MAKE_HOOK_MATCH(ParametricBoxController_Refresh, &ParametricBoxController::Refre return; } - if (self->meshRenderer == nullptr) { + if (self->____meshRenderer == nullptr) { return; } @@ -63,23 +63,16 @@ MAKE_HOOK_MATCH(ParametricBoxController_Refresh, &ParametricBoxController::Refre pos = GetTransformPosition(pos, it->second); } - static auto const* transformProp = il2cpp_utils::FindProperty(classof(UnityEngine::Component*), "transform"); + auto transform = self->get_transform(); - // auto transform = self->get_transform(); + transform->set_localScale(scale); + transform->set_localPosition(pos); - auto* transform = CRASH_UNLESS(il2cpp_utils::GetPropertyValue(self, transformProp)); - - static auto const* localScaleProp = il2cpp_utils::FindProperty(classof(UnityEngine::Transform*), "localScale"); - static auto const* localPosProp = il2cpp_utils::FindProperty(classof(UnityEngine::Transform*), "localPosition"); - - CRASH_UNLESS(il2cpp_utils::SetPropertyValue(transform, localScaleProp, scale)); - CRASH_UNLESS(il2cpp_utils::SetPropertyValue(transform, localPosProp, pos)); - - static auto* materialPropertyBlock = ParametricBoxController::_get__materialPropertyBlock(); + static auto* materialPropertyBlock = ParametricBoxController::getStaticF__materialPropertyBlock(); if (materialPropertyBlock == nullptr) { materialPropertyBlock = UnityEngine::MaterialPropertyBlock::New_ctor(); - ParametricBoxController::_set__materialPropertyBlock(materialPropertyBlock); + ParametricBoxController::setStaticF__materialPropertyBlock(materialPropertyBlock); } auto color = self->color; @@ -88,11 +81,11 @@ MAKE_HOOK_MATCH(ParametricBoxController_Refresh, &ParametricBoxController::Refre color.a = self->minAlpha; } - static auto colorId = ParametricBoxController::_get__colorID(); - static auto alphaStartID = ParametricBoxController::_get__alphaStartID(); - static auto alphaEndID = ParametricBoxController::_get__alphaEndID(); - static auto widthStartID = ParametricBoxController::_get__widthStartID(); - static auto widthEndID = ParametricBoxController::_get__widthEndID(); + static auto colorId = ParametricBoxController::getStaticF__colorID(); + static auto alphaStartID = ParametricBoxController::getStaticF__alphaStartID(); + static auto alphaEndID = ParametricBoxController::getStaticF__alphaEndID(); + static auto widthStartID = ParametricBoxController::getStaticF__widthStartID(); + static auto widthEndID = ParametricBoxController::getStaticF__widthEndID(); // static auto SetColor = il2cpp_utils::FindMethodUnsafe(materialPropertyBlock, "SetColor", 2); // static auto SetFloat = il2cpp_utils::FindMethodUnsafe(materialPropertyBlock, "SetFloat", 2); @@ -121,7 +114,7 @@ MAKE_HOOK_MATCH(ParametricBoxController_Refresh, &ParametricBoxController::Refre SetFloat(materialPropertyBlock, widthStartID, self->widthStart); SetFloat(materialPropertyBlock, widthEndID, self->widthEnd); - SetPropertyBlock(self->meshRenderer, materialPropertyBlock); + SetPropertyBlock(self->_meshRenderer, materialPropertyBlock); // static auto SetPropertyBlock = il2cpp_utils::FindMethodUnsafe(classof(UnityEngine::MeshRenderer*), // "SetPropertyBlock", 1); @@ -130,8 +123,8 @@ MAKE_HOOK_MATCH(ParametricBoxController_Refresh, &ParametricBoxController::Refre // self->meshRenderer->SetPropertyBlock(materialPropertyBlock); } -void ParametricBoxControllerHook(Logger& logger) { - INSTALL_HOOK_ORIG(logger, ParametricBoxController_Refresh); +void ParametricBoxControllerHook() { + INSTALL_HOOK_ORIG(ChromaLogger::Logger, ParametricBoxController_Refresh); } ChromaInstallHooks(ParametricBoxControllerHook) \ No newline at end of file diff --git a/src/hooks/EnvironmentComponent/TrackLaneRing.cpp b/src/hooks/EnvironmentComponent/TrackLaneRing.cpp index 9efda32..36eed02 100644 --- a/src/hooks/EnvironmentComponent/TrackLaneRing.cpp +++ b/src/hooks/EnvironmentComponent/TrackLaneRing.cpp @@ -22,7 +22,7 @@ MAKE_HOOK_MATCH(TrackLaneRing_Init, &TrackLaneRing::Init, void, GlobalNamespace: return; } - self->posZ = position.z; + self->_posZ = position.z; } MAKE_HOOK_MATCH(TrackLaneRing_FixedUpdateRing, &TrackLaneRing::FixedUpdateRing, void, @@ -33,10 +33,10 @@ MAKE_HOOK_MATCH(TrackLaneRing_FixedUpdateRing, &TrackLaneRing::FixedUpdateRing, return; } - self->prevRotZ = self->rotZ; - self->rotZ = std::lerp(self->rotZ, self->destRotZ, Sombrero::Clamp01(fixedDeltaTime * self->rotationSpeed)); - self->prevPosZ = self->posZ; - self->posZ = std::lerp(self->posZ, self->destPosZ, Sombrero::Clamp01(fixedDeltaTime * self->moveSpeed)); + self->_prevRotZ = self->_rotZ; + self->_rotZ = std::lerp(self->_rotZ, self->_destRotZ, Sombrero::Clamp01(fixedDeltaTime * self->_rotationSpeed)); + self->_prevPosZ = self->_posZ; + self->_posZ = std::lerp(self->_posZ, self->_destPosZ, Sombrero::Clamp01(fixedDeltaTime * self->_moveSpeed)); } MAKE_HOOK_MATCH(TrackLaneRing_LateUpdateRing, &TrackLaneRing::LateUpdateRing, void, @@ -55,11 +55,11 @@ MAKE_HOOK_MATCH(TrackLaneRing_LateUpdateRing, &TrackLaneRing::LateUpdateRing, vo rotation = it2->second; } - float interpolatedZPos = self->prevPosZ + ((self->posZ - self->prevPosZ) * interpolationFactor); + float interpolatedZPos = self->_prevPosZ + ((self->_posZ - self->_prevPosZ) * interpolationFactor); Sombrero::FastVector3 positionZOffset = (rotation * Sombrero::FastVector3::forward()) * interpolatedZPos; - Sombrero::FastVector3 pos = Sombrero::FastVector3(self->positionOffset) + positionZOffset; + Sombrero::FastVector3 pos = Sombrero::FastVector3(self->_positionOffset) + positionZOffset; - float interpolatedZRot = self->prevRotZ + ((self->rotZ - self->prevRotZ) * interpolationFactor); + float interpolatedZRot = self->_prevRotZ + ((self->_rotZ - self->_prevRotZ) * interpolationFactor); static auto AngleAxis = FPtrWrapper<&Sombrero::FastQuaternion::AngleAxis>::get(); @@ -70,10 +70,10 @@ MAKE_HOOK_MATCH(TrackLaneRing_LateUpdateRing, &TrackLaneRing::LateUpdateRing, vo self->transform->set_localPosition(pos); } -void TrackLaneRingHook(Logger& logger) { - INSTALL_HOOK(logger, TrackLaneRing_Init); - INSTALL_HOOK(logger, TrackLaneRing_FixedUpdateRing); - INSTALL_HOOK(logger, TrackLaneRing_LateUpdateRing); +void TrackLaneRingHook() { + INSTALL_HOOK(ChromaLogger::Logger, TrackLaneRing_Init); + INSTALL_HOOK(ChromaLogger::Logger, TrackLaneRing_FixedUpdateRing); + INSTALL_HOOK(ChromaLogger::Logger, TrackLaneRing_LateUpdateRing); } ChromaInstallHooks(TrackLaneRingHook) \ No newline at end of file diff --git a/src/hooks/EnvironmentComponent/TrackLaneRingsManager.cpp b/src/hooks/EnvironmentComponent/TrackLaneRingsManager.cpp index bf4afbd..8246d21 100644 --- a/src/hooks/EnvironmentComponent/TrackLaneRingsManager.cpp +++ b/src/hooks/EnvironmentComponent/TrackLaneRingsManager.cpp @@ -28,14 +28,14 @@ static void FindTrackLaneRingManager(UnityEngine::Transform* transform, std::vec auto childCount = transform->GetChildCount(); for (int i = 0; i < childCount; i++) { - auto* child = transform->GetChild(i); + auto child = transform->GetChild(i); FindTrackLaneRingManager(child, managers); } } static TrackLaneRing* QueueInject(DiContainer* container, TrackLaneRing* prefab) { TrackLaneRing* trackLaneRing = UnityEngine::Object::Instantiate(prefab); - auto injectables = VList(); + auto injectables = VList>::New(); ZenUtilInternal::GetInjectableMonoBehavioursUnderGameObject(trackLaneRing->get_gameObject(), injectables); for (auto const& i : injectables) { @@ -52,40 +52,40 @@ MAKE_HOOK_MATCH(TrackLaneRingsManager_Start, &TrackLaneRingsManager::Start, void return; } - if (self->rings) { + if (self->_rings) { return; } - self->rings = ArrayW(self->ringCount); - auto* transform = self->get_transform(); + self->_rings = ArrayW>(self->_ringCount); + auto transform = self->get_transform(); Sombrero::FastVector3 forward = transform->get_forward(); - if (self->spawnAsChildren) { - for (int i = 0; i < self->rings.size(); i++) { - self->rings[i] = QueueInject(self->container, self->trackLaneRingPrefab); - self->rings[i]->get_transform()->set_parent(transform); + if (self->_spawnAsChildren) { + for (int i = 0; i < self->_rings.size(); i++) { + self->_rings[i] = QueueInject(self->_container, self->_trackLaneRingPrefab); + self->_rings[i]->get_transform()->set_parent(transform); Sombrero::FastVector3 position = { 0.0F, 0.0F, static_cast(i) * self->ringPositionStep }; - self->rings[i]->Init(position, { 0, 0, 0 }); + self->_rings[i]->Init(position, { 0, 0, 0 }); } return; } auto position = transform->get_position(); - for (int j = 0; j < self->rings.size(); j++) { - self->rings[j] = QueueInject(self->container, self->trackLaneRingPrefab); + for (int j = 0; j < self->_rings.size(); j++) { + self->_rings[j] = QueueInject(self->_container, self->_trackLaneRingPrefab); Sombrero::FastVector3 position2 = forward * (static_cast(j) * self->ringPositionStep); - self->rings[j]->Init(position2, position); + self->_rings[j]->Init(position2, position); } } MAKE_HOOK_MATCH(SceneDecoratorContext_InitializeRings, &SceneDecoratorContext::Initialize, void, SceneDecoratorContext* self, Zenject::DiContainer* container) { // Do nothing if Chroma shouldn't run - if (!ChromaController::DoChromaHooks() || self->decoratedContractName != "Environment") { + if (!ChromaController::DoChromaHooks() || self->____decoratedContractName != "Environment") { SceneDecoratorContext_InitializeRings(self, container); return; } std::vector managers; - for (auto const& n : self->get_gameObject()->get_scene().GetRootGameObjects()) { + for (auto n : self->get_gameObject()->get_scene().GetRootGameObjects()) { FindTrackLaneRingManager(n->get_transform(), managers); } @@ -94,16 +94,16 @@ MAKE_HOOK_MATCH(SceneDecoratorContext_InitializeRings, &SceneDecoratorContext::I continue; } - manager->container = container; + manager->_container = container; manager->Start(); } SceneDecoratorContext_InitializeRings(self, container); } -void TrackLaneRingsManagerHook(Logger& logger) { - INSTALL_HOOK(logger, SceneDecoratorContext_InitializeRings); - INSTALL_HOOK(logger, TrackLaneRingsManager_Start); +void TrackLaneRingsManagerHook() { + INSTALL_HOOK(ChromaLogger::Logger, SceneDecoratorContext_InitializeRings); + INSTALL_HOOK(ChromaLogger::Logger, TrackLaneRingsManager_Start); } ChromaInstallHooks(TrackLaneRingsManagerHook) \ No newline at end of file diff --git a/src/hooks/Events/LightPairRotationEventEffect.cpp b/src/hooks/Events/LightPairRotationEventEffect.cpp index 4adb4a6..63f30fb 100644 --- a/src/hooks/Events/LightPairRotationEventEffect.cpp +++ b/src/hooks/Events/LightPairRotationEventEffect.cpp @@ -7,7 +7,6 @@ #include "GlobalNamespace/BeatmapEventData.hpp" #include "GlobalNamespace/BasicBeatmapEventType.hpp" #include "GlobalNamespace/LightPairRotationEventEffect.hpp" -#include "GlobalNamespace/LightPairRotationEventEffect_RotationData.hpp" #include "UnityEngine/Quaternion.hpp" #include "UnityEngine/Transform.hpp" #include "lighting/ChromaEventData.hpp" @@ -29,14 +28,14 @@ MAKE_HOOK_MATCH(LightPairRotationEventEffect_HandleBeatmapObjectCallbackControll return; } - if (beatmapEventData->basicBeatmapEventType == self->eventL || - beatmapEventData->basicBeatmapEventType == self->eventR) { + if (beatmapEventData->basicBeatmapEventType == self->_eventL || + beatmapEventData->basicBeatmapEventType == self->_eventR) { LastLightPairRotationEventEffectData = beatmapEventData; } - // getLogger().debug("Doing lights"); + // ChromaLogger::Logger.debug("Doing lights"); LightPairRotationEventEffect_HandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger(self, beatmapEventData); - // getLogger().debug("Did the custom lights"); + // ChromaLogger::Logger.debug("Did the custom lights"); LastLightPairRotationEventEffectData = nullptr; } @@ -64,10 +63,10 @@ MAKE_HOOK_MATCH(LightPairRotationEventEffect_UpdateRotationData, &LightPairRotat auto const& chromaData = chromaIt->second; - bool isLeftEvent = beatmapEventData->basicBeatmapEventType == self->eventL; + bool isLeftEvent = beatmapEventData->basicBeatmapEventType == self->_eventL; // rotationData LightPairRotationEventEffect::RotationData* customRotationData = - isLeftEvent ? self->rotationDataL : self->rotationDataR; + isLeftEvent ? self->_rotationDataL : self->_rotationDataR; bool lockPosition = chromaData.LockPosition; float precisionSpeed = chromaData.Speed.value_or(beatmapEventData->value); @@ -88,32 +87,32 @@ MAKE_HOOK_MATCH(LightPairRotationEventEffect_UpdateRotationData, &LightPairRotat static auto QuaternionEulerMPtr = FPtrWrapper( &UnityEngine::Quaternion::Euler)>::get(); - // getLogger().debug("The time is: %d", beatmapEventData->time); + // ChromaLogger::Logger.debug("The time is: {}", beatmapEventData->time); if (beatmapEventData->value == 0) { customRotationData->enabled = false; if (!lockPosition) { customRotationData->rotationAngle = customRotationData->startRotationAngle; customRotationData->transform->set_localRotation(Sombrero::QuaternionMultiply( customRotationData->startRotation, QuaternionEulerMPtr(Sombrero::vector3multiply( - self->rotationVector, customRotationData->startRotationAngle)))); + self->_rotationVector, customRotationData->startRotationAngle)))); } } else if (beatmapEventData->value > 0) { customRotationData->enabled = true; customRotationData->rotationSpeed = precisionSpeed * 20.0F * direction; - // getLogger().debug("Doing rotation speed (%d) %d", beatmapEventData->value, customRotationData->rotationSpeed); + // ChromaLogger::Logger.debug("Doing rotation speed ({}) {}", beatmapEventData->value, customRotationData->rotationSpeed); if (!lockPosition) { float rotationAngle = startRotationOffset + customRotationData->startRotationAngle; customRotationData->rotationAngle = rotationAngle; customRotationData->transform->set_localRotation(Sombrero::QuaternionMultiply( customRotationData->startRotation, - QuaternionEulerMPtr(Sombrero::vector3multiply(self->rotationVector, rotationAngle)))); + QuaternionEulerMPtr(Sombrero::vector3multiply(self->_rotationVector, rotationAngle)))); } } } -void LightPairRotationEventEffectHook(Logger& /*logger*/) { - INSTALL_HOOK(getLogger(), LightPairRotationEventEffect_HandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger); - INSTALL_HOOK(getLogger(), LightPairRotationEventEffect_UpdateRotationData); +void LightPairRotationEventEffectHook() { + INSTALL_HOOK(ChromaLogger::Logger, LightPairRotationEventEffect_HandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger); + INSTALL_HOOK(ChromaLogger::Logger, LightPairRotationEventEffect_UpdateRotationData); } ChromaInstallHooks(LightPairRotationEventEffectHook) \ No newline at end of file diff --git a/src/hooks/Events/LightRotationEventEffect.cpp b/src/hooks/Events/LightRotationEventEffect.cpp index fd00fac..90164e4 100644 --- a/src/hooks/Events/LightRotationEventEffect.cpp +++ b/src/hooks/Events/LightRotationEventEffect.cpp @@ -40,7 +40,7 @@ MAKE_HOOK_MATCH(LightRotationEventEffect_HandleBeatmapObjectCallbackControllerBe auto const& chromaData = chromaIt->second; - bool isLeftEvent = self->event == BasicBeatmapEventType::Event12; + bool isLeftEvent = self->_event == BasicBeatmapEventType::Event12; bool lockPosition = chromaData.LockPosition; @@ -65,21 +65,21 @@ MAKE_HOOK_MATCH(LightRotationEventEffect_HandleBeatmapObjectCallbackControllerBe if (beatmapEventData->value == 0) { self->set_enabled(false); if (!lockPosition) { - self->get_transform()->set_localRotation(self->startRotation); + self->get_transform()->set_localRotation(self->_startRotation); } } else if (beatmapEventData->value > 0) { self->set_enabled(true); - self->rotationSpeed = precisionSpeed * 20.0F * direction; + self->_rotationSpeed = precisionSpeed * 20.0F * direction; if (!lockPosition) { - auto* transform = self->get_transform(); - transform->set_localRotation(self->startRotation); - transform->Rotate(self->rotationVector, ChromaController::randomXoshiro(0.0F, 180.0F), Space::Self); + auto transform = self->get_transform(); + transform->set_localRotation(self->_startRotation); + transform->Rotate(self->_rotationVector, ChromaController::randomXoshiro(0.0F, 180.0F), Space::Self); } } } -void LightRotationEventEffectHook(Logger& logger) { - INSTALL_HOOK(logger, LightRotationEventEffect_HandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger); +void LightRotationEventEffectHook() { + INSTALL_HOOK(ChromaLogger::Logger, LightRotationEventEffect_HandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger); } ChromaInstallHooks(LightRotationEventEffectHook) \ No newline at end of file diff --git a/src/hooks/Events/TrackLaneRingsPositionStepEffectSpawner.cpp b/src/hooks/Events/TrackLaneRingsPositionStepEffectSpawner.cpp index f6e649d..4fd06cd 100644 --- a/src/hooks/Events/TrackLaneRingsPositionStepEffectSpawner.cpp +++ b/src/hooks/Events/TrackLaneRingsPositionStepEffectSpawner.cpp @@ -54,24 +54,24 @@ MAKE_HOOK_MATCH(TrackLaneRingsPositionStepEffectSpawner_HandleBeatmapObjectCallb return; } - float num = (beatmapEventData->sameTypeIndex % 2 == 0) ? self->maxPositionStep : self->minPositionStep; + float num = (beatmapEventData->sameTypeIndex % 2 == 0) ? self->_maxPositionStep : self->_minPositionStep; num = GetPrecisionStep(num, beatmapEventData); - auto rings = self->trackLaneRingsManager->rings; + auto rings = self->_trackLaneRingsManager->_rings; for (int i = 0; i < rings.size(); i++) { float destPosZ = static_cast(i) * num; static auto SetPosition = FPtrWrapper<&GlobalNamespace::TrackLaneRing::SetPosition>::get(); - float moveSpeed = GetPrecisionSpeed(self->moveSpeed, beatmapEventData); + float moveSpeed = GetPrecisionSpeed(self->_moveSpeed, beatmapEventData); SetPosition(rings[i], destPosZ, moveSpeed); } } -void TrackLaneRingsPositionStepEffectSpawnerHook(Logger& logger) { - INSTALL_HOOK(logger, +void TrackLaneRingsPositionStepEffectSpawnerHook() { + INSTALL_HOOK(ChromaLogger::Logger, TrackLaneRingsPositionStepEffectSpawner_HandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger); - // INSTALL_HOOK_OFFSETLESS(getLogger(), SaberManager_Finalize, il2cpp_utils::FindMethodUnsafe("System", "Object", + // INSTALL_HOOK_OFFSETLESS(ChromaLogger::Logger, SaberManager_Finalize, il2cpp_utils::FindMethodUnsafe("System", "Object", // "Finalize", 0)); } diff --git a/src/hooks/Events/TrackLaneRingsRotationEffect.cpp b/src/hooks/Events/TrackLaneRingsRotationEffect.cpp index 51a8c2c..2ae4123 100644 --- a/src/hooks/Events/TrackLaneRingsRotationEffect.cpp +++ b/src/hooks/Events/TrackLaneRingsRotationEffect.cpp @@ -58,10 +58,10 @@ MAKE_HOOK_MATCH(TrackLaneRingsRotationEffect_FixedUpdate, &TrackLaneRingsRotatio TrackLaneRingsRotationEffect_FixedUpdate(self); } -void TrackLaneRingsRotationEffectHook(Logger& /*logger*/) { - INSTALL_HOOK_ORIG(getLogger(), TrackLaneRingsRotationEffect_AddRingRotationEffect); - INSTALL_HOOK_ORIG(getLogger(), ChromaRingsRotationEffect_AddRingRotationEffect); - INSTALL_HOOK_ORIG(getLogger(), TrackLaneRingsRotationEffect_FixedUpdate); +void TrackLaneRingsRotationEffectHook() { + INSTALL_HOOK_ORIG(ChromaLogger::Logger, TrackLaneRingsRotationEffect_AddRingRotationEffect); + //INSTALL_HOOK_ORIG(ChromaLogger::Logger, ChromaRingsRotationEffect_AddRingRotationEffect); + INSTALL_HOOK_ORIG(ChromaLogger::Logger, TrackLaneRingsRotationEffect_FixedUpdate); } ChromaInstallHooks(TrackLaneRingsRotationEffectHook) \ No newline at end of file diff --git a/src/hooks/Events/TrackLaneRingsRotationEffectSpawner.cpp b/src/hooks/Events/TrackLaneRingsRotationEffectSpawner.cpp index dfa8abc..cde4d95 100644 --- a/src/hooks/Events/TrackLaneRingsRotationEffectSpawner.cpp +++ b/src/hooks/Events/TrackLaneRingsRotationEffectSpawner.cpp @@ -20,7 +20,6 @@ using namespace ChromaUtils; MAKE_HOOK_MATCH(TrackLaneRingsRotationEffectSpawner_Start, &TrackLaneRingsRotationEffectSpawner::Start, void, GlobalNamespace::TrackLaneRingsRotationEffectSpawner* self) { - static auto contextLogger = getLogger().WithContext(Chroma::ChromaLogger::TrackLaneRings); if (!ChromaController::DoChromaHooks()) { TrackLaneRingsRotationEffectSpawner_Start(self); return; @@ -28,16 +27,16 @@ MAKE_HOOK_MATCH(TrackLaneRingsRotationEffectSpawner_Start, &TrackLaneRingsRotati static auto* TrackLaneRingsRotationEffectKlass = classof(TrackLaneRingsRotationEffect*); - if (self->trackLaneRingsRotationEffect->klass == TrackLaneRingsRotationEffectKlass) { - auto* oldRotationEffect = self->trackLaneRingsRotationEffect; - debugSpamLog(contextLogger, "Adding component"); + if (self->_trackLaneRingsRotationEffect->klass == TrackLaneRingsRotationEffectKlass) { + auto oldRotationEffect = self->_trackLaneRingsRotationEffect; + debugSpamLog("Adding component"); auto* newRotationEffect = oldRotationEffect->get_gameObject()->AddComponent(); - debugSpamLog(contextLogger, "Copyying values now"); + debugSpamLog("Copyying values now"); newRotationEffect->CopyValues(oldRotationEffect); UnityEngine::Object::Destroy(oldRotationEffect); - self->trackLaneRingsRotationEffect = newRotationEffect; + self->_trackLaneRingsRotationEffect = newRotationEffect; } TrackLaneRingsRotationEffectSpawner_Start(self); } @@ -49,8 +48,7 @@ template T getValueOrDefault(rapidjson::Value* val, std::string con void TriggerRotation(TrackLaneRingsRotationEffect* trackLaneRingsRotationEffect, bool rotRight, float rotation, float rotationStep, float rotationPropagationSpeed, float rotationFlexySpeed) { - static auto contextLogger = getLogger().WithContext(Chroma::ChromaLogger::TrackLaneRings); - debugSpamLog(contextLogger, "DOING TRIGGER ROTATION %s", trackLaneRingsRotationEffect->klass->name); + debugSpamLog("DOING TRIGGER ROTATION {}", trackLaneRingsRotationEffect->klass->name); auto* chromaRingRotation = static_cast(trackLaneRingsRotationEffect); @@ -65,40 +63,39 @@ void TriggerRotation(TrackLaneRingsRotationEffect* trackLaneRingsRotationEffect, // as limbo. Hopefully with time we can fix that and use that instead void origHandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger( GlobalNamespace::TrackLaneRingsRotationEffectSpawner* self, BasicBeatmapEventData* beatmapEventData) { - static auto contextLogger = getLogger().WithContext(Chroma::ChromaLogger::TrackLaneRings); - if (beatmapEventData->basicBeatmapEventType != self->beatmapEventType) { + if (beatmapEventData->basicBeatmapEventType != self->_beatmapEventType) { return; } float step = 0.0F; - int originalRotationStepType = (int)self->rotationStepType; + int originalRotationStepType = self->_rotationStepType.value__; - if (originalRotationStepType == TrackLaneRingsRotationEffectSpawner::RotationStepType::Range0ToMax) { - step = ChromaController::randomXoshiro(0.0F, self->rotationStep); - } else if (originalRotationStepType == TrackLaneRingsRotationEffectSpawner::RotationStepType::Range) { - step = ChromaController::randomXoshiro(-self->rotationStep, self->rotationStep); - } else if (originalRotationStepType == TrackLaneRingsRotationEffectSpawner::RotationStepType::MaxOr0) { - step = (ChromaController::randomXoshiro() < 0.5F) ? self->rotationStep : 0.0F; + if (originalRotationStepType == TrackLaneRingsRotationEffectSpawner::RotationStepType::Range0ToMax.value__) { + step = ChromaController::randomXoshiro(0.0F, self->_rotationStep); + } else if (originalRotationStepType == TrackLaneRingsRotationEffectSpawner::RotationStepType::Range.value__) { + step = ChromaController::randomXoshiro(-self->_rotationStep, self->_rotationStep); + } else if (originalRotationStepType == TrackLaneRingsRotationEffectSpawner::RotationStepType::MaxOr0.value__) { + step = (ChromaController::randomXoshiro() < 0.5F) ? self->_rotationStep : 0.0F; } - debugSpamLog(contextLogger, "Track lane klass %s", self->trackLaneRingsRotationEffect->klass->name); + debugSpamLog("Track lane klass {}", self->_trackLaneRingsRotationEffect->klass->name); static auto* ChromaRingsRotationEffectKlass = classof(ChromaRingsRotationEffect*); - auto* rotationEffect = self->trackLaneRingsRotationEffect; + auto rotationEffect = self->_trackLaneRingsRotationEffect; - if (ASSIGNMENT_CHECK(ChromaRingsRotationEffectKlass, self->trackLaneRingsRotationEffect->klass)) { + if (ASSIGNMENT_CHECK(ChromaRingsRotationEffectKlass, rotationEffect->klass)) { - auto* chromaRotation = reinterpret_cast(rotationEffect); + auto* chromaRotation = reinterpret_cast(rotationEffect.ptr()); chromaRotation->AddRingRotationEffectF( chromaRotation->GetFirstRingDestinationRotationAngleCpp() + - self->rotation * static_cast((ChromaController::randomXoshiro() < 0.5F) ? 1 : -1), - step, static_cast(self->rotationPropagationSpeed), self->rotationFlexySpeed); + self->_rotation * static_cast((ChromaController::randomXoshiro() < 0.5F) ? 1 : -1), + step, static_cast(self->_rotationPropagationSpeed), self->_rotationFlexySpeed); } else { rotationEffect->AddRingRotationEffect( rotationEffect->GetFirstRingDestinationRotationAngle() + - self->rotation * static_cast((ChromaController::randomXoshiro() < 0.5F) ? 1 : -1), - step, self->rotationPropagationSpeed, self->rotationFlexySpeed); + self->_rotation * static_cast((ChromaController::randomXoshiro() < 0.5F) ? 1 : -1), + step, self->_rotationPropagationSpeed, self->_rotationFlexySpeed); } } @@ -111,14 +108,13 @@ MAKE_HOOK_MATCH(TrackLaneRingsRotationEffectSpawner_HandleBeatmapObjectCallbackC return; } - // debugSpamLog(contextLogger, "Track lane rotation effect self %d beat %d and customData %d", + // debugSpamLog("Track lane rotation effect self {} beat {} and customData {}", // self->BasicBeatmapEventType.value, // beatmapEventData->type.value, // beatmapEventData->customData != nullptr && beatmapEventData->customData->value != nullptr ? 0 // : 1); - static auto contextLogger = getLogger().WithContext(Chroma::ChromaLogger::TrackLaneRings); - if (beatmapEventData->basicBeatmapEventType == self->beatmapEventType) { + if (beatmapEventData->basicBeatmapEventType == self->_beatmapEventType) { auto chromaIt = ChromaEventDataManager::ChromaEventDatas.find(beatmapEventData); // Not found @@ -129,31 +125,31 @@ MAKE_HOOK_MATCH(TrackLaneRingsRotationEffectSpawner_HandleBeatmapObjectCallbackC auto const& chromaData = chromaIt->second; - debugSpamLog(contextLogger, "Doing stuff with custom Data ring"); + debugSpamLog("Doing stuff with custom Data ring"); float rotationStep = 0.0F; - float originalRotationStep = self->rotationStep; - float originalRotation = self->rotation; - auto originalRotationPropagationSpeed = static_cast(self->rotationPropagationSpeed); - float originalRotationFlexySpeed = self->rotationFlexySpeed; - int originalRotationStepType = (int)self->rotationStepType; + float originalRotationStep = self->_rotationStep; + float originalRotation = self->_rotation; + auto originalRotationPropagationSpeed = static_cast(self->_rotationPropagationSpeed); + float originalRotationFlexySpeed = self->_rotationFlexySpeed; + int originalRotationStepType = self->_rotationStepType.value__; - if (originalRotationStepType == TrackLaneRingsRotationEffectSpawner::RotationStepType::Range0ToMax) { + if (originalRotationStepType == TrackLaneRingsRotationEffectSpawner::RotationStepType::Range0ToMax.value__) { rotationStep = ChromaController::randomXoshiro(0.0F, rotationStep); - } else if (originalRotationStepType == TrackLaneRingsRotationEffectSpawner::RotationStepType::Range) { + } else if (originalRotationStepType == TrackLaneRingsRotationEffectSpawner::RotationStepType::Range.value__) { rotationStep = ChromaController::randomXoshiro(-originalRotationStep, originalRotationStep); - } else if (originalRotationStepType == TrackLaneRingsRotationEffectSpawner::RotationStepType::MaxOr0) { + } else if (originalRotationStepType == TrackLaneRingsRotationEffectSpawner::RotationStepType::MaxOr0.value__) { rotationStep = (ChromaController::randomXoshiro() < 0.5F) ? originalRotationStep : 0.0F; } - debugSpamLog(contextLogger, "Got the data"); + debugSpamLog("Got the data"); std::string selfName = self->get_name(); auto nameFilter = chromaData.NameFilter; // If not equal with ignore case if (nameFilter && stringCompare(selfName, nameFilter.value()) != 0) { - debugSpamLog(contextLogger, "Name filter ignored"); + debugSpamLog("Name filter ignored"); return; } @@ -176,12 +172,12 @@ MAKE_HOOK_MATCH(TrackLaneRingsRotationEffectSpawner_HandleBeatmapObjectCallbackC auto reset = chromaData.Reset; if (reset && reset.value()) { - debugSpamLog(contextLogger, "Reset spawn, returning"); - TriggerRotation(self->trackLaneRingsRotationEffect, rotRight, originalRotation, 0, 50, 50); + debugSpamLog("Reset spawn, returning"); + TriggerRotation(self->_trackLaneRingsRotationEffect, rotRight, originalRotation, 0, 50, 50); return; } - debugSpamLog(contextLogger, "Getting the last values"); + debugSpamLog("Getting the last values"); float step = chromaData.Step.value_or(rotationStep); float prop = chromaData.Prop.value_or(originalRotationPropagationSpeed); @@ -192,23 +188,23 @@ MAKE_HOOK_MATCH(TrackLaneRingsRotationEffectSpawner_HandleBeatmapObjectCallbackC float propMult = chromaData.PropMult; float speedMult = chromaData.SpeedMult; - TriggerRotation(self->trackLaneRingsRotationEffect, rotRight, rotation, step * stepMult, prop * propMult, + TriggerRotation(self->_trackLaneRingsRotationEffect, rotRight, rotation, step * stepMult, prop * propMult, speed * speedMult); - debugSpamLog(contextLogger, "Finished spawn, returning"); + debugSpamLog("Finished spawn, returning"); return; } - debugSpamLog(contextLogger, "Not a custom beat map"); + debugSpamLog("Not a custom beat map"); origHandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger( self, beatmapEventData); // TrackLaneRingsRotationEffectSpawner_HandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger(self, // beatmapEventData); } -void TrackLaneRingsRotationEffectSpawnerHook(Logger& logger) { - INSTALL_HOOK(logger, TrackLaneRingsRotationEffectSpawner_Start); - INSTALL_HOOK(logger, TrackLaneRingsRotationEffectSpawner_HandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger); - // INSTALL_HOOK_OFFSETLESS(getLogger(), SaberManager_Finalize, il2cpp_utils::FindMethodUnsafe("System", "Object", +void TrackLaneRingsRotationEffectSpawnerHook() { + INSTALL_HOOK(ChromaLogger::Logger, TrackLaneRingsRotationEffectSpawner_Start); + INSTALL_HOOK(ChromaLogger::Logger, TrackLaneRingsRotationEffectSpawner_HandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger); + // INSTALL_HOOK_OFFSETLESS(ChromaLogger::Logger, SaberManager_Finalize, il2cpp_utils::FindMethodUnsafe("System", "Object", // "Finalize", 0)); } diff --git a/src/hooks/MainSystemInit.cpp b/src/hooks/MainSystemInit.cpp index f8910bc..d080c8e 100644 --- a/src/hooks/MainSystemInit.cpp +++ b/src/hooks/MainSystemInit.cpp @@ -8,19 +8,20 @@ using namespace GlobalNamespace; using namespace Chroma; -MAKE_HOOK_MATCH(MainSystemInit_Init, &MainSystemInit::Init, void, MainSystemInit* self) { - static bool loaded = true; +MAKE_HOOK_MATCH(MainSystemInit_Init, &MainSystemInit::Init, void, MainSystemInit* self, + ::GlobalNamespace::SettingsApplicatorSO* settingsApplicator) { + static bool loaded = false; if (!loaded) { loaded = true; self->MonoBehaviour::StartCoroutine( custom_types::Helpers::CoroutineHelper::New(EnvironmentMaterialManager::Activate)); } - return MainSystemInit_Init(self); + return MainSystemInit_Init(self, settingsApplicator); } -void MainSystemInitHook(Logger& /*logger*/) { - INSTALL_HOOK(getLogger(), MainSystemInit_Init); +void MainSystemInitHook() { + INSTALL_HOOK(ChromaLogger::Logger, MainSystemInit_Init); } ChromaInstallHooks(MainSystemInitHook) \ No newline at end of file diff --git a/src/hooks/Mirror/MirroredNoteController.cpp b/src/hooks/Mirror/MirroredNoteController.cpp index f79edc2..27f837c 100644 --- a/src/hooks/Mirror/MirroredNoteController.cpp +++ b/src/hooks/Mirror/MirroredNoteController.cpp @@ -20,7 +20,10 @@ using namespace UnityEngine; template <> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter< &GlobalNamespace::MirroredNoteController_1::UpdatePositionAndRotation> { - static MethodInfo const* get() { + static constexpr std::size_t size = 0xFABC; // random garbage + constexpr static std::size_t addrs = 0x260faf4; // random garbage + + static MethodInfo const* methodInfo() { return il2cpp_utils::FindMethod(classof(GlobalNamespace::MirroredNoteController_1*), "UpdatePositionAndRotation"); } @@ -29,7 +32,10 @@ struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter< template <> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter< &GlobalNamespace::MirroredNoteController_1::UpdatePositionAndRotation> { - static MethodInfo const* get() { + static constexpr std::size_t size = 0xFABC; // random garbage + constexpr static std::size_t addrs = 0x260faf4; // random garbage + + static MethodInfo const* methodInfo() { return il2cpp_utils::FindMethod(classof(GlobalNamespace::MirroredNoteController_1*), "UpdatePositionAndRotation"); } @@ -72,12 +78,12 @@ MAKE_HOOK_MATCH(MirroredNoteController_UpdatePositionAndRotationCubeGeneric, UpdateMirror(self, reinterpret_cast(self->followedNote)); } -void MirroredNoteControllerHook(Logger& logger) { +void MirroredNoteControllerHook() { auto* iNoteGeneric = classof(GlobalNamespace::MirroredNoteController_1*); auto* iNoteCubeGeneric = classof(GlobalNamespace::MirroredNoteController_1*); - INSTALL_HOOK(logger, MirroredNoteController_UpdatePositionAndRotationGeneric); - INSTALL_HOOK(logger, MirroredNoteController_UpdatePositionAndRotationCubeGeneric); + INSTALL_HOOK(ChromaLogger::Logger, MirroredNoteController_UpdatePositionAndRotationGeneric); + INSTALL_HOOK(ChromaLogger::Logger, MirroredNoteController_UpdatePositionAndRotationCubeGeneric); } ChromaInstallHooks(MirroredNoteControllerHook) \ No newline at end of file diff --git a/src/hooks/Mirror/MirroredObstacleController.cpp b/src/hooks/Mirror/MirroredObstacleController.cpp index 577f1bb..f0da905 100644 --- a/src/hooks/Mirror/MirroredObstacleController.cpp +++ b/src/hooks/Mirror/MirroredObstacleController.cpp @@ -11,8 +11,6 @@ #include "GlobalNamespace/SaberBurnMarkArea.hpp" #include "UnityEngine/ParticleSystem.hpp" -#include "UnityEngine/ParticleSystem_MainModule.hpp" -#include "UnityEngine/ParticleSystem_MinMaxGradient.hpp" #include "colorizer/ObstacleColorizer.hpp" #include "utils/ChromaUtils.hpp" @@ -30,16 +28,16 @@ MAKE_HOOK_MATCH(MirroredObstacleController_UpdatePositionAndRotation, return; } - if (self->followedObstacle == nullptr) { + if (self->_followedObstacle == nullptr) { return; } ObstacleColorizer::ColorizeObstacle(self, - ObstacleColorizer::GetObstacleColorizer(self->followedObstacle)->getColor()); + ObstacleColorizer::GetObstacleColorizer(self->_followedObstacle)->getColor()); } -void MirroredObstacleControllerHook(Logger& logger) { - INSTALL_HOOK(logger, MirroredObstacleController_UpdatePositionAndRotation); +void MirroredObstacleControllerHook() { + INSTALL_HOOK(ChromaLogger::Logger, MirroredObstacleController_UpdatePositionAndRotation); } ChromaInstallHooks(MirroredObstacleControllerHook) \ No newline at end of file diff --git a/src/hooks/MovementBeatmapEventEffect.cpp b/src/hooks/MovementBeatmapEventEffect.cpp index c511b4a..dc8b412 100644 --- a/src/hooks/MovementBeatmapEventEffect.cpp +++ b/src/hooks/MovementBeatmapEventEffect.cpp @@ -11,7 +11,6 @@ #include "GlobalNamespace/ColorExtensions.hpp" #include "GlobalNamespace/BeatEffectSpawner.hpp" -#include "GlobalNamespace/BeatEffectSpawner_InitData.hpp" #include "GlobalNamespace/MemoryPoolContainer_1.hpp" #include "GlobalNamespace/LazyCopyHashSet_1.hpp" @@ -74,9 +73,9 @@ using namespace GlobalNamespace; // noteController->get_worldRotation()); //} // -// void BeatEffectSpawnerHook(Logger& logger) { +// void BeatEffectSpawnerHook() { // // TODO: DO TODO ABOVE -// INSTALL_HOOK_ORIG(logger, BeatEffectSpawner_HandleNoteDidStartJump); +// INSTALL_HOOK_ORIG(ChromaLogger::Logger, BeatEffectSpawner_HandleNoteDidStartJump); //} // // ChromaInstallHooks(BeatEffectSpawnerHook) \ No newline at end of file diff --git a/src/hooks/MultiplayerConnectedPlayerInstaller.cpp b/src/hooks/MultiplayerConnectedPlayerInstaller.cpp index 4a01a3f..f1ddacd 100644 --- a/src/hooks/MultiplayerConnectedPlayerInstaller.cpp +++ b/src/hooks/MultiplayerConnectedPlayerInstaller.cpp @@ -5,7 +5,6 @@ #include "GlobalNamespace/MultiplayerConnectedPlayerInstaller.hpp" #include "GlobalNamespace/BeatmapDataTransformHelper.hpp" #include "GlobalNamespace/IReadonlyBeatmapData.hpp" -#include "GlobalNamespace/IPreviewBeatmapLevel.hpp" #include "GlobalNamespace/GameplayModifiers.hpp" #include "GlobalNamespace/PracticeSettings.hpp" #include "GlobalNamespace/EnvironmentEffectsFilterPreset.hpp" @@ -27,8 +26,8 @@ MAKE_HOOK_MATCH(MultiplayerConnectedPlayerInstaller_InstallBindings, MultiplayerConnectedPlayerInstallerHookHolder::MultiplayerInvoked = false; } -void MultiplayerConnectedPlayerInstallerHook(Logger& /*logger*/) { - INSTALL_HOOK(getLogger(), MultiplayerConnectedPlayerInstaller_InstallBindings); +void MultiplayerConnectedPlayerInstallerHook() { + INSTALL_HOOK(ChromaLogger::Logger, MultiplayerConnectedPlayerInstaller_InstallBindings); } // ChromaInstallHooks(MultiplayerConnectedPlayerInstallerHook) \ No newline at end of file diff --git a/src/hooks/SceneTransition/MissionLevelScenesTransitionSetupDataSO.cpp b/src/hooks/SceneTransition/MissionLevelScenesTransitionSetupDataSO.cpp index 9ef1cda..7f15bc6 100644 --- a/src/hooks/SceneTransition/MissionLevelScenesTransitionSetupDataSO.cpp +++ b/src/hooks/SceneTransition/MissionLevelScenesTransitionSetupDataSO.cpp @@ -1,17 +1,9 @@ #include "Chroma.hpp" -#include "custom-json-data/shared/CustomBeatmapData.h" #include "GlobalNamespace/MissionLevelScenesTransitionSetupDataSO.hpp" -#include "GlobalNamespace/OverrideEnvironmentSettings.hpp" -#include "GlobalNamespace/ColorScheme.hpp" -#include "GlobalNamespace/GameplayModifiers.hpp" #include "GlobalNamespace/PlayerSpecificSettings.hpp" -#include "GlobalNamespace/IDifficultyBeatmap.hpp" -#include "GlobalNamespace/NoteController.hpp" +#include "GlobalNamespace/EnvironmentsListModel.hpp" #include "GlobalNamespace/BeatmapLevelSO.hpp" -#include "colorizer/NoteColorizer.hpp" -#include "UnityEngine/Space.hpp" -#include "UnityEngine/Transform.hpp" #include "hooks/SceneTransition/SceneTransitionHelper.hpp" @@ -20,22 +12,49 @@ using namespace GlobalNamespace; using namespace UnityEngine; using namespace Chroma; -MAKE_HOOK_MATCH(MissionLevelScenesTransitionSetupDataSO_Init, &MissionLevelScenesTransitionSetupDataSO::Init, void, - MissionLevelScenesTransitionSetupDataSO* self, StringW missionId, - GlobalNamespace::IDifficultyBeatmap* difficultyBeatmap, - GlobalNamespace::IPreviewBeatmapLevel* previewBeatmapLevel, - ::ArrayW missionObjectives, - GlobalNamespace::ColorScheme* overrideColorScheme, - GlobalNamespace::GameplayModifiers* gameplayModifiers, - GlobalNamespace::PlayerSpecificSettings* playerSpecificSettings, StringW backButtonText) { - MissionLevelScenesTransitionSetupDataSO_Init(self, missionId, difficultyBeatmap, previewBeatmapLevel, - missionObjectives, overrideColorScheme, gameplayModifiers, - playerSpecificSettings, backButtonText); - SceneTransitionHelper::Patch(difficultyBeatmap); +MAKE_HOOK_MATCH( + MissionLevelScenesTransitionSetupDataSO_Init, + static_cast, ::GlobalNamespace::BeatmapLevel*, + ::ArrayW<::GlobalNamespace::MissionObjective*, ::Array<::GlobalNamespace::MissionObjective*>*>, + ::GlobalNamespace::ColorScheme*, ::GlobalNamespace::GameplayModifiers*, + ::GlobalNamespace::PlayerSpecificSettings*, ::GlobalNamespace::EnvironmentsListModel*, + ::GlobalNamespace::BeatmapLevelsModel*, ::GlobalNamespace::AudioClipAsyncLoader*, + ::BeatSaber::PerformancePresets::PerformancePreset*, ::GlobalNamespace::BeatmapDataLoader*, ::StringW)>( + &::GlobalNamespace::MissionLevelScenesTransitionSetupDataSO::Init), + void, MissionLevelScenesTransitionSetupDataSO* self, ::StringW missionId, + ByRef<::GlobalNamespace::BeatmapKey> beatmapKey, ::GlobalNamespace::BeatmapLevel* beatmapLevel, + ::ArrayW<::GlobalNamespace::MissionObjective*, ::Array<::GlobalNamespace::MissionObjective*>*> missionObjectives, + ::GlobalNamespace::ColorScheme* overrideColorScheme, ::GlobalNamespace::GameplayModifiers* gameplayModifiers, + ::GlobalNamespace::PlayerSpecificSettings* playerSpecificSettings, + ::GlobalNamespace::EnvironmentsListModel* environmentsListModel, + ::GlobalNamespace::BeatmapLevelsModel* beatmapLevelsModel, + ::GlobalNamespace::AudioClipAsyncLoader* audioClipAsyncLoader, + ::BeatSaber::PerformancePresets::PerformancePreset* performancePreset, + ::GlobalNamespace::BeatmapDataLoader* beatmapDataLoader, ::StringW backButtonText) { + auto customBeatmapLevel = il2cpp_utils::try_cast(beatmapLevel); + if (!customBeatmapLevel) { + MissionLevelScenesTransitionSetupDataSO_Init(self, missionId, beatmapKey, beatmapLevel, missionObjectives, + overrideColorScheme, gameplayModifiers, playerSpecificSettings, + environmentsListModel, beatmapLevelsModel, audioClipAsyncLoader, + performancePreset, beatmapDataLoader, backButtonText); + return; + } + + auto environmentInfoBySerializedNameSafe = environmentsListModel->GetEnvironmentInfoBySerializedNameSafe( + beatmapLevel->GetEnvironmentName(beatmapKey->beatmapCharacteristic, beatmapKey->difficulty)._environmentName); + + // TODO: Fix environment override + SceneTransitionHelper::Patch(customBeatmapLevel.value(), beatmapKey.heldRef, environmentInfoBySerializedNameSafe); + + MissionLevelScenesTransitionSetupDataSO_Init(self, missionId, beatmapKey, beatmapLevel, missionObjectives, + overrideColorScheme, gameplayModifiers, playerSpecificSettings, + environmentsListModel, beatmapLevelsModel, audioClipAsyncLoader, + performancePreset, beatmapDataLoader, backButtonText); } -void MissionLevelScenesTransitionSetupDataSOHook(Logger& logger) { - INSTALL_HOOK(logger, MissionLevelScenesTransitionSetupDataSO_Init); +void MissionLevelScenesTransitionSetupDataSOHook() { + INSTALL_HOOK(ChromaLogger::Logger, MissionLevelScenesTransitionSetupDataSO_Init); } ChromaInstallHooks(MissionLevelScenesTransitionSetupDataSOHook) \ No newline at end of file diff --git a/src/hooks/SceneTransition/MultiplayerLevelScenesTransitionSetupDataSO.cpp b/src/hooks/SceneTransition/MultiplayerLevelScenesTransitionSetupDataSO.cpp index f6557d2..e176956 100644 --- a/src/hooks/SceneTransition/MultiplayerLevelScenesTransitionSetupDataSO.cpp +++ b/src/hooks/SceneTransition/MultiplayerLevelScenesTransitionSetupDataSO.cpp @@ -2,17 +2,7 @@ #include "custom-json-data/shared/CustomBeatmapData.h" #include "GlobalNamespace/MultiplayerLevelScenesTransitionSetupDataSO.hpp" -#include "GlobalNamespace/OverrideEnvironmentSettings.hpp" -#include "GlobalNamespace/ColorScheme.hpp" -#include "GlobalNamespace/GameplayModifiers.hpp" -#include "GlobalNamespace/PlayerSpecificSettings.hpp" -#include "GlobalNamespace/PracticeSettings.hpp" -#include "GlobalNamespace/IDifficultyBeatmap.hpp" -#include "GlobalNamespace/NoteController.hpp" #include "GlobalNamespace/BeatmapLevelSO.hpp" -#include "colorizer/NoteColorizer.hpp" -#include "UnityEngine/Space.hpp" -#include "UnityEngine/Transform.hpp" #include "hooks/SceneTransition/SceneTransitionHelper.hpp" @@ -21,24 +11,24 @@ using namespace GlobalNamespace; using namespace UnityEngine; using namespace Chroma; -MAKE_HOOK_MATCH(MultiplayerLevelScenesTransitionSetupDataSO_Init, &MultiplayerLevelScenesTransitionSetupDataSO::Init, - void, MultiplayerLevelScenesTransitionSetupDataSO* self, StringW gameMode, - GlobalNamespace::IPreviewBeatmapLevel* previewBeatmapLevel, - GlobalNamespace::BeatmapDifficulty beatmapDifficulty, - GlobalNamespace::BeatmapCharacteristicSO* beatmapCharacteristic, - GlobalNamespace::IDifficultyBeatmap* difficultyBeatmap, - GlobalNamespace::ColorScheme* overrideColorScheme, - GlobalNamespace::GameplayModifiers* gameplayModifiers, - GlobalNamespace::PlayerSpecificSettings* playerSpecificSettings, - GlobalNamespace::PracticeSettings* practiceSettings, bool useTestNoteCutSoundEffects) { - MultiplayerLevelScenesTransitionSetupDataSO_Init( - self, gameMode, previewBeatmapLevel, beatmapDifficulty, beatmapCharacteristic, difficultyBeatmap, - overrideColorScheme, gameplayModifiers, playerSpecificSettings, practiceSettings, useTestNoteCutSoundEffects); - SceneTransitionHelper::Patch(difficultyBeatmap); +MAKE_HOOK_MATCH(MultiplayerLevelScenesTransitionSetupDataSO_Init, &MultiplayerLevelScenesTransitionSetupDataSO::InitAndSetupScenes, + void, MultiplayerLevelScenesTransitionSetupDataSO* self) { + + + auto customBeatmapLevel = il2cpp_utils::try_cast(self->get_beatmapLevel()); + if (!customBeatmapLevel) { + MultiplayerLevelScenesTransitionSetupDataSO_Init(self); + return; + } + + // TODO: Fix environment override + SceneTransitionHelper::Patch(customBeatmapLevel.value(), self->beatmapKey, self->GetOrLoadMultiplayerEnvironmentInfo()); + + MultiplayerLevelScenesTransitionSetupDataSO_Init(self); } -void MultiplayerLevelScenesTransitionSetupDataSOHook(Logger& logger) { - INSTALL_HOOK(logger, MultiplayerLevelScenesTransitionSetupDataSO_Init); +void MultiplayerLevelScenesTransitionSetupDataSOHook() { + INSTALL_HOOK(ChromaLogger::Logger, MultiplayerLevelScenesTransitionSetupDataSO_Init); } ChromaInstallHooks(MultiplayerLevelScenesTransitionSetupDataSOHook) \ No newline at end of file diff --git a/src/hooks/SceneTransition/SceneTransitionHelper.cpp b/src/hooks/SceneTransition/SceneTransitionHelper.cpp index 53ce89c..cd1b782 100644 --- a/src/hooks/SceneTransition/SceneTransitionHelper.cpp +++ b/src/hooks/SceneTransition/SceneTransitionHelper.cpp @@ -6,180 +6,133 @@ #include "ChromaController.hpp" #include "lighting/LightIDTableManager.hpp" -#include "GlobalNamespace/BeatmapEnvironmentHelper.hpp" -#include "GlobalNamespace/EnvironmentInfoSO.hpp" -#include "GlobalNamespace/CustomDifficultyBeatmap.hpp" +#include "GlobalNamespace/BeatmapCharacteristicSO.hpp" +#include "GlobalNamespace/BeatmapDifficultySerializedMethods.hpp" #include "utils/ChromaUtils.hpp" +#include "sombrero/shared/linq_functional.hpp" + +#include "paper/shared/string_convert.hpp" + using namespace CustomJSONData; using namespace Chroma; using namespace GlobalNamespace; using namespace UnityEngine; using namespace System::Collections; +using namespace Sombrero::Linq::Functional; -void SceneTransitionHelper::Patch(GlobalNamespace::IDifficultyBeatmap* customBeatmapData) { - if (customBeatmapData == nullptr) { - BasicPatch(nullptr, nullptr); +void SceneTransitionHelper::Patch(SongCore::SongLoader::CustomBeatmapLevel* beatmapLevel, + GlobalNamespace::BeatmapKey key, GlobalNamespace::EnvironmentInfoSO* environment) { + if (beatmapLevel == nullptr) { + BasicPatch(nullptr, key, nullptr); return; } - std::optional customBeatmapDataCustom = - il2cpp_utils::try_cast(customBeatmapData); - if (customBeatmapDataCustom) { - SceneTransitionHelper::BasicPatch(customBeatmapData, il2cpp_utils::cast( - customBeatmapDataCustom.value()->beatmapSaveData)); - } else { - BasicPatch(nullptr, nullptr); - } + BasicPatch(beatmapLevel, key, environment); } -template -static bool CheckIfInArrayOrKey(RValue const& val, const StringValue stringToCheck) { - if (val.IsArray()) { - for (auto& element : val.GetArray()) { - if (element.IsString() && element.GetString() == stringToCheck) { - return true; - } - } - } - - if (val.IsObject()) { - for (auto const& element : val.GetObject()) { - if (element.name.IsString() && element.name.GetString() == stringToCheck) { - return true; - } - } - } - - return false; -} - -template -inline static bool CheckIfInArrayOrKey(std::optional> const val, - const StringValue stringToCheck) { - if (!val) { - return false; - } - - return CheckIfInArrayOrKey(val->get(), stringToCheck); -} - -void SceneTransitionHelper::Patch(GlobalNamespace::IDifficultyBeatmap* customBeatmapData, +void SceneTransitionHelper::Patch(SongCore::SongLoader::CustomBeatmapLevel* beatmapLevel, + GlobalNamespace::BeatmapKey key, GlobalNamespace::EnvironmentInfoSO* environment, OverrideEnvironmentSettings*& overrideEnvironmentSettings) { - if (customBeatmapData == nullptr) { - BasicPatch(nullptr, nullptr); + if (beatmapLevel == nullptr) { + BasicPatch(nullptr, key, nullptr); return; } - std::optional customBeatmapDataCustomOpt = - il2cpp_utils::try_cast(customBeatmapData); - if (customBeatmapDataCustomOpt) { - auto* customBeatmapDataCustom = il2cpp_utils::cast( - customBeatmapDataCustomOpt.value()->beatmapSaveData); - - bool chromaRequirement = SceneTransitionHelper::BasicPatch(customBeatmapData, customBeatmapDataCustom); - if (chromaRequirement && getChromaConfig().environmentEnhancementsEnabled.GetValue()) { - - bool v2 = customBeatmapDataCustom->isV2; - - if (v2 && (overrideEnvironmentSettings != nullptr) && customBeatmapDataCustom->levelCustomData && - CheckIfInArrayOrKey(customBeatmapDataCustom->levelCustomData, Chroma::NewConstants::V2_ENVIRONMENT_REMOVAL)) { - overrideEnvironmentSettings = nullptr; - } - if ((overrideEnvironmentSettings != nullptr) && customBeatmapDataCustom->customData && - CheckIfInArrayOrKey(customBeatmapDataCustom->customData, - v2 ? Chroma::NewConstants::V2_ENVIRONMENT - : Chroma::NewConstants::ENVIRONMENT)) { - overrideEnvironmentSettings = nullptr; - } - - if (overrideEnvironmentSettings == nullptr) { - getLogger().debug("Environment removal!"); - } - } - } else { - CJDLogger::Logger.fmtLog("Not a custom diff"); - BasicPatch(nullptr, nullptr); - } + BasicPatch(beatmapLevel, key, environment); } -bool SceneTransitionHelper::BasicPatch(GlobalNamespace::IDifficultyBeatmap* customBeatmapDifficultyData, - CustomJSONData::v3::CustomBeatmapSaveData* customBeatmapDataCustom) { - CJDLogger::Logger.fmtLog("Custom diff {} save data {}", fmt::ptr(customBeatmapDifficultyData), - fmt::ptr(customBeatmapDataCustom)); +bool SceneTransitionHelper::BasicPatch(SongCore::SongLoader::CustomBeatmapLevel* beatmapLevel, + GlobalNamespace::BeatmapKey key, + GlobalNamespace::EnvironmentInfoSO* environment) { + ChromaLogger::Logger.debug("Basic Patch {}", fmt::ptr(beatmapLevel)); ChromaController::TutorialMode = false; + ChromaController::environmentObjectsRemovalV2 = std::nullopt; - bool chromaRequirement = false; - ChromaController::infoDatCopy = std::nullopt; - - // please let me remove this shit bool legacyOverride = false; - if (customBeatmapDifficultyData != nullptr) { - auto* environmentInfo = BeatmapEnvironmentHelper::GetEnvironmentInfo(customBeatmapDifficultyData); + if (beatmapLevel == nullptr) return false; - LightIDTableManager::SetEnvironment(static_cast(environmentInfo->serializedName)); + ChromaLogger::Logger.debug("Getting Save Data"); - if (customBeatmapDataCustom->levelCustomData) { - auto dynData = customBeatmapDataCustom->levelCustomData; + auto saveData = beatmapLevel->standardLevelInfoSaveDataV2; - getLogger().debug("Level custom data value: %s", dynData ? "true" : "false"); + if (!saveData) return false; - if (dynData && dynData->get().IsObject()) { - ValueUTF16 const& rapidjsonData = *dynData; + auto customSaveInfo = saveData.value()->CustomSaveDataInfo; - // Copy this since it gets freed later on. - DocumentUTF16 doc; - doc.CopyFrom(rapidjsonData, doc.GetAllocator()); + if (!customSaveInfo) return false; - ChromaController::infoDatCopy = std::make_optional(std::move(doc)); + ChromaLogger::Logger.debug("Getting Characteristic and diff"); - auto requirements = rapidjsonData.FindMember(u"_requirements"); + auto diff = customSaveInfo.value().get().TryGetCharacteristicAndDifficulty( + key.beatmapCharacteristic->get_serializedName(), key.difficulty); - if (requirements != rapidjsonData.MemberEnd()) { - chromaRequirement |= CheckIfInArrayOrKey(requirements->value, REQUIREMENTNAME); - } + if (!diff) return false; - auto suggestions = rapidjsonData.FindMember(u"_suggestions"); + ChromaLogger::Logger.debug("Getting Requirements & Suggestions"); - if (suggestions != rapidjsonData.MemberEnd()) { - chromaRequirement |= CheckIfInArrayOrKey(suggestions->value, REQUIREMENTNAME); - } - } - } + auto requirements = diff->get().requirements; + auto suggestions = diff->get().suggestions; - if (customBeatmapDataCustom->isV2) { - auto beatmapEvents = customBeatmapDataCustom->basicBeatmapEvents->items; - auto length = beatmapEvents.Length(); - getLogger().debug("Checking at most %d for ChromaLite notes", static_cast(length)); - for (auto* event : beatmapEvents) { - if (event == nullptr) { - continue; - } - - if (event->get_value() >= LegacyLightHelper::RGB_INT_OFFSET) { - legacyOverride = true; - } - - if (legacyOverride) { - break; - } - } + bool chromaRequirement = false; - if (legacyOverride) { - getLogger().warning("Legacy Chroma Detected..."); - getLogger().warning("Please do not use Legacy Chroma for new maps as it is deprecated and its functionality in " - "future versions of Chroma cannot be guaranteed"); + chromaRequirement |= std::find(requirements.begin(), requirements.end(), REQUIREMENTNAME) != requirements.end(); + chromaRequirement |= std::find(suggestions.begin(), suggestions.end(), REQUIREMENTNAME) != suggestions.end(); + + ChromaLogger::Logger.debug("Setting environment. Chroma Required: {}", chromaRequirement); + + auto diffSaveMap = + saveData.value()->difficultyBeatmapSets | Select([&](auto&& x) { + return x->difficultyBeatmaps | FirstOrDefault([&](auto&& y) { + BeatmapDifficulty mapDifficulty; + GlobalNamespace::BeatmapDifficultySerializedMethods::BeatmapDifficultyFromSerializedName( + y->difficulty, byref(mapDifficulty)); + + return mapDifficulty == key.difficulty && + x->beatmapCharacteristicName == key.beatmapCharacteristic->get_serializedName(); + }); + }) | + First([](auto x) { return x != nullptr; }); + ChromaLogger::Logger.debug("Savemap", fmt::ptr(diffSaveMap.value_or(nullptr))); + auto saveMap = diffSaveMap.value_or(nullptr); + auto customDifficultyBeatmap = + il2cpp_utils::try_cast(saveMap).value_or(nullptr); + + // handle environment v2 removal + if (customDifficultyBeatmap) { + auto customData = customDifficultyBeatmap->customData.value(); + auto objectsToKillIt = customData.get().FindMember(Chroma::NewConstants::V2_ENVIRONMENT_REMOVAL.data()); + + if (objectsToKillIt != customData.get().MemberEnd()) { + ChromaController::environmentObjectsRemovalV2 = std::vector(); + + auto objectsToKill = objectsToKillIt->value.GetArray(); + for (auto const& object : objectsToKill) { + ChromaController::environmentObjectsRemovalV2->emplace_back(Paper::StringConvert::from_utf16(object.GetString())); } } } + + if (environment == nullptr) { + ChromaLogger::Logger.debug("Environment is null, this is not right!", chromaRequirement); + + return false; + } + + LightIDTableManager::SetEnvironment(static_cast(environment->get_serializedName())); + + ChromaLogger::Logger.debug("Environment set"); + + // TODO: Chromalite + ChromaController::SetChromaLegacy(legacyOverride); ChromaController::setChromaRequired(chromaRequirement); - // Reset the randomizer state - // This probably does nothing but whatever ChromaController::randomizerThing = XoshiroCpp::Xoshiro128PlusPlus(); + ChromaLogger::Logger.debug("Scene Patch Finished"); + return ChromaController::ChromaRequired(); } \ No newline at end of file diff --git a/src/hooks/SceneTransition/StandardLevelScenesTransitionSetupDataSO.cpp b/src/hooks/SceneTransition/StandardLevelScenesTransitionSetupDataSO.cpp index 9d91335..b145d0d 100644 --- a/src/hooks/SceneTransition/StandardLevelScenesTransitionSetupDataSO.cpp +++ b/src/hooks/SceneTransition/StandardLevelScenesTransitionSetupDataSO.cpp @@ -7,8 +7,8 @@ #include "GlobalNamespace/GameplayModifiers.hpp" #include "GlobalNamespace/PlayerSpecificSettings.hpp" #include "GlobalNamespace/PracticeSettings.hpp" -#include "GlobalNamespace/IDifficultyBeatmap.hpp" #include "GlobalNamespace/NoteController.hpp" +#include "GlobalNamespace/RecordingToolManager.hpp" #include "GlobalNamespace/BeatmapLevelSO.hpp" #include "colorizer/NoteColorizer.hpp" #include "UnityEngine/Space.hpp" @@ -20,26 +20,27 @@ using namespace CustomJSONData; using namespace GlobalNamespace; using namespace UnityEngine; using namespace Chroma; +using namespace System; -MAKE_HOOK_MATCH(StandardLevelScenesTransitionSetupDataSO_Init, &StandardLevelScenesTransitionSetupDataSO::Init, void, - StandardLevelScenesTransitionSetupDataSO* self, StringW gameMode, - ::GlobalNamespace::IDifficultyBeatmap* difficultyBeatmap, - ::GlobalNamespace::IPreviewBeatmapLevel* previewBeatmapLevel, - ::GlobalNamespace::OverrideEnvironmentSettings* overrideEnvironmentSettings, - ::GlobalNamespace::ColorScheme* overrideColorScheme, - ::GlobalNamespace::GameplayModifiers* gameplayModifiers, - ::GlobalNamespace::PlayerSpecificSettings* playerSpecificSettings, - ::GlobalNamespace::PracticeSettings* practiceSettings, ::StringW backButtonText, - bool useTestNoteCutSoundEffects, bool startPaused, BeatmapDataCache* cache) { - auto* settings = overrideEnvironmentSettings; - SceneTransitionHelper::Patch(difficultyBeatmap, settings); - StandardLevelScenesTransitionSetupDataSO_Init( - self, gameMode, difficultyBeatmap, previewBeatmapLevel, settings, overrideColorScheme, gameplayModifiers, - playerSpecificSettings, practiceSettings, backButtonText, useTestNoteCutSoundEffects, startPaused, cache); +MAKE_HOOK_MATCH(StandardLevelScenesTransitionSetupDataSO_Init, + &StandardLevelScenesTransitionSetupDataSO::InitAndSetupScenes, void, + StandardLevelScenesTransitionSetupDataSO* self, + ::GlobalNamespace::PlayerSpecificSettings* playerSpecificSettings, ::StringW backButtonText, + bool startPaused) { + auto customBeatmapLevel = il2cpp_utils::try_cast(self->get_beatmapLevel()); + if (!customBeatmapLevel) { + StandardLevelScenesTransitionSetupDataSO_Init(self, playerSpecificSettings, backButtonText, startPaused); + return; + } + + // TODO: Fix environment override + SceneTransitionHelper::Patch(customBeatmapLevel.value(), self->beatmapKey, self->environmentInfo); + + StandardLevelScenesTransitionSetupDataSO_Init(self, playerSpecificSettings, backButtonText, startPaused); } -void StandardLevelScenesTransitionSetupDataSOHook(Logger& logger) { - INSTALL_HOOK(logger, StandardLevelScenesTransitionSetupDataSO_Init); +void StandardLevelScenesTransitionSetupDataSOHook() { + INSTALL_HOOK(ChromaLogger::Logger, StandardLevelScenesTransitionSetupDataSO_Init); } ChromaInstallHooks(StandardLevelScenesTransitionSetupDataSOHook) \ No newline at end of file diff --git a/src/hooks/SceneTransition/TutorialScenesTransitionSetupDataSO.cpp b/src/hooks/SceneTransition/TutorialScenesTransitionSetupDataSO.cpp index b5d0b02..31db50d 100644 --- a/src/hooks/SceneTransition/TutorialScenesTransitionSetupDataSO.cpp +++ b/src/hooks/SceneTransition/TutorialScenesTransitionSetupDataSO.cpp @@ -2,12 +2,7 @@ #include "ChromaController.hpp" -#include "custom-json-data/shared/CustomBeatmapData.h" #include "GlobalNamespace/TutorialScenesTransitionSetupDataSO.hpp" -#include "GlobalNamespace/IDifficultyBeatmap.hpp" -#include "colorizer/NoteColorizer.hpp" -#include "UnityEngine/Space.hpp" -#include "UnityEngine/Transform.hpp" using namespace CustomJSONData; using namespace GlobalNamespace; @@ -21,8 +16,8 @@ MAKE_HOOK_MATCH(TutorialScenesTransitionSetupDataSO_Init, &TutorialScenesTransit TutorialScenesTransitionSetupDataSO_Init(self, playerSpecificSettings); } -void TutorialScenesTransitionSetupDataSOHook(Logger& /*logger*/) { - INSTALL_HOOK(getLogger(), TutorialScenesTransitionSetupDataSO_Init); +void TutorialScenesTransitionSetupDataSOHook() { + INSTALL_HOOK(ChromaLogger::Logger, TutorialScenesTransitionSetupDataSO_Init); } ChromaInstallHooks(TutorialScenesTransitionSetupDataSOHook) \ No newline at end of file diff --git a/src/hooks/SceneTransition/UnitySceneChange.cpp b/src/hooks/SceneTransition/UnitySceneChange.cpp index 7b25dbb..c3efc8e 100644 --- a/src/hooks/SceneTransition/UnitySceneChange.cpp +++ b/src/hooks/SceneTransition/UnitySceneChange.cpp @@ -1,11 +1,9 @@ #include "Chroma.hpp" #include "ChromaController.hpp" -#include "GlobalNamespace/GameScenesManager.hpp" #include "UnityEngine/SceneManagement/SceneManager.hpp" #include "UnityEngine/SceneManagement/Scene.hpp" #include "UnityEngine/SceneManagement/LoadSceneMode.hpp" -#include "System/Action.hpp" #include "custom-json-data/shared/CustomBeatmapData.h" using namespace CustomJSONData; @@ -19,8 +17,8 @@ MAKE_HOOK_MATCH(SceneManager_Internal_SceneLoaded, &UnityEngine::SceneManagement SceneManager_Internal_SceneLoaded(scene, mode); } -void SceneManager_Internal(Logger& /*logger*/) { - INSTALL_HOOK(getLogger(), SceneManager_Internal_SceneLoaded); +void SceneManager_Internal() { + INSTALL_HOOK(ChromaLogger::Logger, SceneManager_Internal_SceneLoaded); } ChromaInstallHooks(SceneManager_Internal) \ No newline at end of file diff --git a/src/hooks/colorizer/BeatmapObjectManager.cpp b/src/hooks/colorizer/BeatmapObjectManager.cpp index 6520ff3..950da2f 100644 --- a/src/hooks/colorizer/BeatmapObjectManager.cpp +++ b/src/hooks/colorizer/BeatmapObjectManager.cpp @@ -22,8 +22,8 @@ MAKE_HOOK_MATCH(BeatmapObjectManager_NoteCutEvent, &BeatmapObjectManager::Handle BeatmapObjectManager_NoteCutEvent(self, noteController, noteCutInfo); } -void BeatmapObjectManagerHook(Logger& logger) { - INSTALL_HOOK(logger, BeatmapObjectManager_NoteCutEvent); +void BeatmapObjectManagerHook() { + INSTALL_HOOK(ChromaLogger::Logger, BeatmapObjectManager_NoteCutEvent); } ChromaInstallHooks(BeatmapObjectManagerHook) \ No newline at end of file diff --git a/src/hooks/colorizer/BombNoteController.cpp b/src/hooks/colorizer/BombNoteController.cpp index 645c9f5..59c4d1f 100644 --- a/src/hooks/colorizer/BombNoteController.cpp +++ b/src/hooks/colorizer/BombNoteController.cpp @@ -30,8 +30,8 @@ MAKE_HOOK_MATCH(BombNoteController_Init, &BombNoteController::Init, void, BombNo } } -void BombNoteControllerHook(Logger& logger) { - INSTALL_HOOK(logger, BombNoteController_Init); +void BombNoteControllerHook() { + INSTALL_HOOK(ChromaLogger::Logger, BombNoteController_Init); } ChromaInstallHooks(BombNoteControllerHook) \ No newline at end of file diff --git a/src/hooks/colorizer/BurstSliderController.cpp b/src/hooks/colorizer/BurstSliderController.cpp index ef9c919..ff9e507 100644 --- a/src/hooks/colorizer/BurstSliderController.cpp +++ b/src/hooks/colorizer/BurstSliderController.cpp @@ -66,10 +66,10 @@ MAKE_HOOK_MATCH(BurstSliderGameNoteController_Init, &BurstSliderGameNoteControll NoteColorizer::ColorizeNote(self, color); } } -void BurstSliderControllerHook(Logger& /*logger*/) { - INSTALL_HOOK(getLogger(), BurstSliderGameNoteController_Init); - INSTALL_HOOK(getLogger(), BurstSliderGameNoteController_Awake); - INSTALL_HOOK(getLogger(), BurstSliderGameNoteController_OnDestroy); +void BurstSliderControllerHook() { + INSTALL_HOOK(ChromaLogger::Logger, BurstSliderGameNoteController_Init); + INSTALL_HOOK(ChromaLogger::Logger, BurstSliderGameNoteController_Awake); + INSTALL_HOOK(ChromaLogger::Logger, BurstSliderGameNoteController_OnDestroy); } ChromaInstallHooks(BurstSliderControllerHook) \ No newline at end of file diff --git a/src/hooks/colorizer/ColorNoteVisuals.cpp b/src/hooks/colorizer/ColorNoteVisuals.cpp index c6c6934..d69a720 100644 --- a/src/hooks/colorizer/ColorNoteVisuals.cpp +++ b/src/hooks/colorizer/ColorNoteVisuals.cpp @@ -36,8 +36,8 @@ MAKE_HOOK_MATCH(ColorNoteVisuals_HandleNoteControllerDidInit, &ColorNoteVisuals: } } -void ColorNoteVisualsHook(Logger& logger) { - INSTALL_HOOK(logger, ColorNoteVisuals_HandleNoteControllerDidInit); +void ColorNoteVisualsHook() { + INSTALL_HOOK(ChromaLogger::Logger, ColorNoteVisuals_HandleNoteControllerDidInit); } ChromaInstallHooks(ColorNoteVisualsHook) \ No newline at end of file diff --git a/src/hooks/colorizer/ColorTween.cpp b/src/hooks/colorizer/ColorTween.cpp index 5ee3944..f13e734 100644 --- a/src/hooks/colorizer/ColorTween.cpp +++ b/src/hooks/colorizer/ColorTween.cpp @@ -24,7 +24,7 @@ MAKE_HOOK_MATCH(ColorTween_GetColor, &ColorTween::GetValue, UnityEngine::Color, } // discriminator set in ColorTween.makeTween() - if ((self != nullptr) && self->easeType == Chroma::Tween::ChromaTweenDiscriminator) { + if ((self != nullptr) && self->easeType.value__ == Chroma::Tween::ChromaTweenDiscriminator) { // Set in ChromaLightSwitchEventEffect // fast access Chroma::Tween::ChromaColorTweenData const& tweenData = @@ -35,8 +35,8 @@ MAKE_HOOK_MATCH(ColorTween_GetColor, &ColorTween::GetValue, UnityEngine::Color, return ColorTween_GetColor(self, t); } -void ColorTweenHook(Logger& logger) { - INSTALL_HOOK(logger, ColorTween_GetColor); +void ColorTweenHook() { + INSTALL_HOOK(ChromaLogger::Logger, ColorTween_GetColor); } ChromaInstallHooks(ColorTweenHook) \ No newline at end of file diff --git a/src/hooks/colorizer/Initialize/BaseNoteVisuals.cpp b/src/hooks/colorizer/Initialize/BaseNoteVisuals.cpp index e0d7e2e..97f30ad 100644 --- a/src/hooks/colorizer/Initialize/BaseNoteVisuals.cpp +++ b/src/hooks/colorizer/Initialize/BaseNoteVisuals.cpp @@ -32,10 +32,10 @@ MAKE_HOOK_MATCH(BaseNoteVisuals_Awake, &BaseNoteVisuals::Awake, void, BaseNoteVi return; } - if (IsBombType(self->noteController)) { - BombColorizer::New(self->noteController); + if (IsBombType(self->_noteController)) { + BombColorizer::New(self->_noteController); } else { - NoteColorizer::New(self->noteController); + NoteColorizer::New(self->_noteController); } BaseNoteVisuals_Awake(self); @@ -48,16 +48,16 @@ MAKE_HOOK_MATCH(BaseNoteVisuals_OnDestroy, &BaseNoteVisuals::OnDestroy, void, Ba return; } - if (IsBombType(self->noteController)) { - BombColorizer::Colorizers.erase(self->noteController); + if (IsBombType(self->_noteController)) { + BombColorizer::Colorizers.erase(self->_noteController); } else { - NoteColorizer::Colorizers.erase(self->noteController); + NoteColorizer::Colorizers.erase(self->_noteController); } } -void BaseNoteVisualsHook(Logger& logger) { - INSTALL_HOOK(logger, BaseNoteVisuals_Awake); - INSTALL_HOOK(logger, BaseNoteVisuals_OnDestroy); +void BaseNoteVisualsHook() { + INSTALL_HOOK(ChromaLogger::Logger, BaseNoteVisuals_Awake); + INSTALL_HOOK(ChromaLogger::Logger, BaseNoteVisuals_OnDestroy); } ChromaInstallHooks(BaseNoteVisualsHook) \ No newline at end of file diff --git a/src/hooks/colorizer/Initialize/ObstacleDissolve.cpp b/src/hooks/colorizer/Initialize/ObstacleDissolve.cpp index b1b3577..bd18a1b 100644 --- a/src/hooks/colorizer/Initialize/ObstacleDissolve.cpp +++ b/src/hooks/colorizer/Initialize/ObstacleDissolve.cpp @@ -31,7 +31,7 @@ MAKE_HOOK_MATCH(ObstacleDissolve_Awake, &ObstacleDissolve::Awake, void, Obstacle if (!ChromaController::DoChromaHooks()) { return; } - ObstacleColorizer::New(self->obstacleController); + ObstacleColorizer::New(self->_obstacleController); } MAKE_HOOK_MATCH(ObstacleDissolve_OnDestroy, &ObstacleDissolve::OnDestroy, void, ObstacleDissolve* self) { @@ -42,12 +42,12 @@ MAKE_HOOK_MATCH(ObstacleDissolve_OnDestroy, &ObstacleDissolve::OnDestroy, void, return; } - ObstacleColorizer::Colorizers.erase(self->obstacleController); + ObstacleColorizer::Colorizers.erase(self->_obstacleController); } -void ObstacleDissolveHook(Logger& logger) { - INSTALL_HOOK(logger, ObstacleDissolve_Awake); - INSTALL_HOOK(logger, ObstacleDissolve_OnDestroy); +void ObstacleDissolveHook() { + INSTALL_HOOK(ChromaLogger::Logger, ObstacleDissolve_Awake); + INSTALL_HOOK(ChromaLogger::Logger, ObstacleDissolve_OnDestroy); } ChromaInstallHooks(ObstacleDissolveHook) \ No newline at end of file diff --git a/src/hooks/colorizer/Initialize/ParticleSystemEventEffect.cpp b/src/hooks/colorizer/Initialize/ParticleSystemEventEffect.cpp index 05f05b7..6a297cd 100644 --- a/src/hooks/colorizer/Initialize/ParticleSystemEventEffect.cpp +++ b/src/hooks/colorizer/Initialize/ParticleSystemEventEffect.cpp @@ -42,7 +42,7 @@ MAKE_HOOK_MATCH(ParticleSystemEventEffect_Start, &ParticleSystemEventEffect::Sta UnityEngine::Object::Destroy(oldController); } - auto coro = custom_types::Helpers::CoroutineHelper::New(WaitThenStartParticle(self, self->colorEvent)); + auto coro = custom_types::Helpers::CoroutineHelper::New(WaitThenStartParticle(self, self->_colorEvent)); self->StartCoroutine(coro); } @@ -56,8 +56,8 @@ MAKE_HOOK_MATCH(ParticleSystemEventEffect_HandleBeatmapObjectCallbackControllerB return; } - if (beatmapEventData->basicBeatmapEventType == self->colorEvent) { - for (auto const& colorizer : ParticleColorizer::GetParticleColorizers(self->colorEvent)) { + if (beatmapEventData->basicBeatmapEventType == self->_colorEvent) { + for (auto const& colorizer : ParticleColorizer::GetParticleColorizers(self->_colorEvent)) { colorizer->PreviousValue = beatmapEventData->value; } } @@ -65,9 +65,9 @@ MAKE_HOOK_MATCH(ParticleSystemEventEffect_HandleBeatmapObjectCallbackControllerB ParticleSystemEventEffect_HandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger(self, beatmapEventData); } -void ParticleSystemEventEffectHook(Logger& logger) { - INSTALL_HOOK(logger, ParticleSystemEventEffect_Start); - INSTALL_HOOK(logger, ParticleSystemEventEffect_HandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger); +void ParticleSystemEventEffectHook() { + INSTALL_HOOK(ChromaLogger::Logger, ParticleSystemEventEffect_Start); + INSTALL_HOOK(ChromaLogger::Logger, ParticleSystemEventEffect_HandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger); } ChromaInstallHooks(ParticleSystemEventEffectHook) \ No newline at end of file diff --git a/src/hooks/colorizer/Initialize/SaberModelContainer.cpp b/src/hooks/colorizer/Initialize/SaberModelContainer.cpp index 72238a7..fc0e1dc 100644 --- a/src/hooks/colorizer/Initialize/SaberModelContainer.cpp +++ b/src/hooks/colorizer/Initialize/SaberModelContainer.cpp @@ -22,11 +22,11 @@ MAKE_HOOK_MATCH(SaberModelContainer_Start, &SaberModelContainer::Start, void, Sa return; } - self->get_gameObject()->AddComponent()->Init(self->saber); + self->get_gameObject()->AddComponent()->Init(self->_saber); } -void SaberModelContainerHook(Logger& logger) { - INSTALL_HOOK(logger, SaberModelContainer_Start); +void SaberModelContainerHook() { + INSTALL_HOOK(ChromaLogger::Logger, SaberModelContainer_Start); } ChromaInstallHooks(SaberModelContainerHook) \ No newline at end of file diff --git a/src/hooks/colorizer/Initialize/SliderController.cpp b/src/hooks/colorizer/Initialize/SliderController.cpp index ebd4180..11b8353 100644 --- a/src/hooks/colorizer/Initialize/SliderController.cpp +++ b/src/hooks/colorizer/Initialize/SliderController.cpp @@ -29,9 +29,9 @@ MAKE_HOOK_MATCH(SliderController_OnDestroy, &SliderController::OnDestroy, void, SliderColorizer::Colorizers.erase(self); } -void SliderControllerInitHook(Logger& logger) { - INSTALL_HOOK(logger, SliderController_Awake); - INSTALL_HOOK(logger, SliderController_OnDestroy); +void SliderControllerInitHook() { + INSTALL_HOOK(ChromaLogger::Logger, SliderController_Awake); + INSTALL_HOOK(ChromaLogger::Logger, SliderController_OnDestroy); } ChromaInstallHooks(SliderControllerInitHook) \ No newline at end of file diff --git a/src/hooks/colorizer/LightSwitchEventEffect.cpp b/src/hooks/colorizer/LightSwitchEventEffect.cpp index a536f91..17a2b5f 100644 --- a/src/hooks/colorizer/LightSwitchEventEffect.cpp +++ b/src/hooks/colorizer/LightSwitchEventEffect.cpp @@ -38,21 +38,6 @@ custom_types::Helpers::Coroutine WaitThenStartLight(LightSwitchEventEffect* inst co_return; } -MAKE_HOOK_MATCH(LightSwitchEventEffect_Awake, &LightSwitchEventEffect::Awake, void, LightSwitchEventEffect* self) { - static auto* ChromaLightSwitchEventEffectKlass = classof(ChromaLightSwitchEventEffect*); - - if (self->klass == ChromaLightSwitchEventEffectKlass) { - return; - } - - // Do nothing if Chroma shouldn't run - if (!ChromaController::GetChromaLegacy() && !ChromaController::DoChromaHooks()) { - return LightSwitchEventEffect_Awake(self); - } - - // override method to do nothing -} - MAKE_HOOK_MATCH(LightSwitchEventEffect_Start, &LightSwitchEventEffect::Start, void, LightSwitchEventEffect* self) { static auto* ChromaLightSwitchEventEffectKlass = classof(ChromaLightSwitchEventEffect*); @@ -65,7 +50,7 @@ MAKE_HOOK_MATCH(LightSwitchEventEffect_Start, &LightSwitchEventEffect::Start, vo return LightSwitchEventEffect_Start(self); } - auto coro = custom_types::Helpers::CoroutineHelper::New(WaitThenStartLight(self, self->event)); + auto coro = custom_types::Helpers::CoroutineHelper::New(WaitThenStartLight(self, self->_event)); self->StartCoroutine(coro); } @@ -100,18 +85,17 @@ MAKE_HOOK_MATCH(BeatmapCallbacksController_ManualUpdate, &BeatmapCallbacksContro } }; - self->callbacksInTimes->get_Item(0)->AddCallback(basicEvents); - self->callbacksInTimes->get_Item(0)->AddCallback(boostEvents); + self->_callbacksInTimes->get_Item(0)->AddCallback(basicEvents); + self->_callbacksInTimes->get_Item(0)->AddCallback(boostEvents); } BeatmapCallbacksController_ManualUpdate(self, songTime); } -void LightSwitchEventEffectHook(Logger& logger) { - INSTALL_HOOK(logger, BeatmapCallbacksController_ManualUpdate); +void LightSwitchEventEffectHook() { + INSTALL_HOOK(ChromaLogger::Logger, BeatmapCallbacksController_ManualUpdate); - INSTALL_HOOK(logger, LightSwitchEventEffect_Start); - INSTALL_HOOK(logger, LightSwitchEventEffect_Awake); + INSTALL_HOOK(ChromaLogger::Logger, LightSwitchEventEffect_Start); } ChromaInstallHooks(LightSwitchEventEffectHook) \ No newline at end of file diff --git a/src/hooks/colorizer/Note/ColorManager.cpp b/src/hooks/colorizer/Note/ColorManager.cpp index a264ada..60e5155 100644 --- a/src/hooks/colorizer/Note/ColorManager.cpp +++ b/src/hooks/colorizer/Note/ColorManager.cpp @@ -33,8 +33,8 @@ MAKE_HOOK_MATCH(ColorManager_ColorForType, return *ColorManagerColorForType::_noteColorOverride; } -void ColorManagerHook(Logger& logger) { - INSTALL_HOOK(logger, ColorManager_ColorForType); +void ColorManagerHook() { + INSTALL_HOOK(ChromaLogger::Logger, ColorManager_ColorForType); } ChromaInstallHooks(ColorManagerHook) \ No newline at end of file diff --git a/src/hooks/colorizer/Note/NoteCutEffectSpawner.cpp b/src/hooks/colorizer/Note/NoteCutEffectSpawner.cpp index 6e42fd6..3f62781 100644 --- a/src/hooks/colorizer/Note/NoteCutEffectSpawner.cpp +++ b/src/hooks/colorizer/Note/NoteCutEffectSpawner.cpp @@ -34,8 +34,8 @@ MAKE_HOOK_MATCH(NoteCutEffectSpawner_SpawnNoteCutEffect, &NoteCutCoreEffectsSpaw ColorManagerColorForType::DisableColorOverride(); } -void NoteCutEffectSpawnerHook(Logger& /*logger*/) { - INSTALL_HOOK(getLogger(), NoteCutEffectSpawner_SpawnNoteCutEffect); +void NoteCutEffectSpawnerHook() { + INSTALL_HOOK(ChromaLogger::Logger, NoteCutEffectSpawner_SpawnNoteCutEffect); } ChromaInstallHooks(NoteCutEffectSpawnerHook) \ No newline at end of file diff --git a/src/hooks/colorizer/NoteController.cpp b/src/hooks/colorizer/NoteController.cpp index 68663e3..9e5c640 100644 --- a/src/hooks/colorizer/NoteController.cpp +++ b/src/hooks/colorizer/NoteController.cpp @@ -58,9 +58,9 @@ MAKE_HOOK_MATCH(NoteController_Update, &NoteController::ManualUpdate, void, Note auto const& tracks = chromaData->second.Tracks; auto pathPointDefinition = chromaData->second.LocalPathColor; if (!tracks.empty() || pathPointDefinition) { - NoteJump* noteJump = self->noteMovement->jump; + NoteJump* noteJump = self->_noteMovement->_jump; float jumpDuration = noteJump->jumpDuration; - float elapsedTime = ChromaTimeSourceHelper::getSongTimeChroma(noteJump->audioTimeSyncController) - + float elapsedTime = ChromaTimeSourceHelper::getSongTimeChroma(noteJump->_audioTimeSyncController) - (self->noteData->time - (jumpDuration * 0.5F)); float normalTime = elapsedTime / jumpDuration; @@ -80,9 +80,9 @@ MAKE_HOOK_MATCH(NoteController_Update, &NoteController::ManualUpdate, void, Note } } -void NoteControllerHook(Logger& /*logger*/) { - INSTALL_HOOK(getLogger(), NoteController_Init); - INSTALL_HOOK(getLogger(), NoteController_Update); +void NoteControllerHook() { + INSTALL_HOOK(ChromaLogger::Logger, NoteController_Init); + INSTALL_HOOK(ChromaLogger::Logger, NoteController_Update); } ChromaInstallHooks(NoteControllerHook) \ No newline at end of file diff --git a/src/hooks/colorizer/Obstacle/ObstacleSaberSparklerEffectManager.cpp b/src/hooks/colorizer/Obstacle/ObstacleSaberSparklerEffectManager.cpp index 7d3d178..af4b28b 100644 --- a/src/hooks/colorizer/Obstacle/ObstacleSaberSparklerEffectManager.cpp +++ b/src/hooks/colorizer/Obstacle/ObstacleSaberSparklerEffectManager.cpp @@ -9,12 +9,13 @@ #include "GlobalNamespace/Saber.hpp" #include "GlobalNamespace/SaberType.hpp" #include "GlobalNamespace/SaberTypeExtensions.hpp" -#include "GlobalNamespace/HapticFeedbackController.hpp" +#include "GlobalNamespace/HapticFeedbackManager.hpp" #include "System/Action_1.hpp" #include "UnityEngine/Color.hpp" #include "UnityEngine/XR/XRNode.hpp" +#include "UnityEngine/Pose.hpp" #include "colorizer/ObstacleColorizer.hpp" @@ -40,60 +41,38 @@ MAKE_HOOK_MATCH(ObstacleSaberSparkleEffectManager_Update, &ObstacleSaberSparkleE ObstacleSaberSparkleEffectManager_Update(self); return; } - - self->wasSystemActive.get(0) = self->isSystemActive.get(0); - self->wasSystemActive.get(1) = self->isSystemActive.get(1); - self->isSystemActive.get(0) = false; - self->isSystemActive.get(1) = false; - - auto* obstacleControllers = self->beatmapObjectManager->get_activeObstacleControllers(); - - for (auto const& obstacleController : VList(obstacleControllers)) { - if (obstacleController == nullptr) { - continue; - } - - auto const& bounds = obstacleController->bounds; - for (int i = 0; i < 2; i++) { - Vector3 vector; - if (self->sabers.get(i)->get_isActiveAndEnabled() && - self->GetBurnMarkPos(bounds, obstacleController->get_transform(), self->sabers.get(i)->saberBladeBottomPos, - self->sabers.get(i)->saberBladeTopPos, vector)) { - self->isSystemActive.get(i) = true; - self->burnMarkPositions.get(i) = vector; - self->effects.get(i)->SetPositionAndRotation( - vector, self->GetEffectRotation(vector, obstacleController->get_transform(), bounds)); - - // TRANSPILE IS HERE - SetObstacleSaberSparkleColor(self->effects.get(i), obstacleController); - // TRANSPILE IS HERE - - self->hapticFeedbackController->PlayHapticFeedback( - SaberTypeExtensions::Node(self->sabers.get(i)->get_saberType()), self->rumblePreset); - if (!self->wasSystemActive.get(i)) { - self->effects.get(i)->StartEmission(); - auto* action = self->sparkleEffectDidStartEvent; - if (action != nullptr) { - action->Invoke(self->sabers.get(i)->get_saberType()); - } + auto activeObstacleControllers = self->_beatmapObjectManager->activeObstacleControllers; + Pose identity = Pose::get_identity(); + for (int i = 0; i < 2; i++) { + bool flag = self->_effects[i]->IsEmitting(); + if (ObstacleSaberSparkleEffectManager::IntersectSaberWithObstacles(self->_sabers[i], activeObstacleControllers, + byref(identity))) { + self->_effects[i]->SetPositionAndRotation(identity.position, identity.rotation); + // TRANSPILE IS HERE + // TODO: Reimplement + // SetObstacleSaberSparkleColor(self->_effects.get(i), obstacleController); + // TRANSPILE IS HERE + self->_hapticFeedbackManager->PlayHapticFeedback(SaberTypeExtensions::Node(self->_sabers[i]->saberType), + self->_rumblePreset); + if (!flag) { + self->_effects[i]->StartEmission(); + auto action = self->sparkleEffectDidStartEvent; + if (action != nullptr) { + action->Invoke(self->_sabers[i]->saberType); } } - } - } -#pragma unroll - for (int j = 0; j < 2; j++) { - if (!self->isSystemActive.get(j) && self->wasSystemActive.get(j)) { - self->effects.get(j)->StopEmission(); - auto* action2 = self->sparkleEffectDidEndEvent; + } else if (flag) { + self->_effects[i]->StopEmission(); + auto action2 = self->sparkleEffectDidEndEvent; if (action2 != nullptr) { - action2->Invoke(self->sabers.get(j)->get_saberType()); + action2->Invoke(self->_sabers[i]->saberType); } } } } -void ObstacleSaberSparkleEffectManagerHook(Logger& /*logger*/) { - INSTALL_HOOK_ORIG(getLogger(), ObstacleSaberSparkleEffectManager_Update); +void ObstacleSaberSparkleEffectManagerHook() { + // INSTALL_HOOK_ORIG(ChromaLogger::Logger, ObstacleSaberSparkleEffectManager_Update); } ChromaInstallHooks(ObstacleSaberSparkleEffectManagerHook) \ No newline at end of file diff --git a/src/hooks/colorizer/ObstacleController.cpp b/src/hooks/colorizer/ObstacleController.cpp index 106b81a..89484da 100644 --- a/src/hooks/colorizer/ObstacleController.cpp +++ b/src/hooks/colorizer/ObstacleController.cpp @@ -61,8 +61,8 @@ MAKE_HOOK_MATCH(ObstacleController_ManualUpdate, &ObstacleController::ManualUpda if (!tracks.empty() || pathPointDefinition) { float jumpDuration = self->move2Duration; float elapsedTime = - ChromaTimeSourceHelper::getSongTimeChroma(self->audioTimeSyncController) - self->startTimeOffset; - float normalTime = (elapsedTime - self->move1Duration) / (jumpDuration + self->obstacleDuration); + ChromaTimeSourceHelper::getSongTimeChroma(self->_audioTimeSyncController) - self->_startTimeOffset; + float normalTime = (elapsedTime - self->move1Duration) / (jumpDuration + self->_obstacleDuration); [[maybe_unused]] bool updated = 0; std::optional colorOffset = @@ -75,9 +75,9 @@ MAKE_HOOK_MATCH(ObstacleController_ManualUpdate, &ObstacleController::ManualUpda } } -void ObstacleControllerHook(Logger& /*logger*/) { - INSTALL_HOOK(getLogger(), ObstacleController_Init); - INSTALL_HOOK(getLogger(), ObstacleController_ManualUpdate); +void ObstacleControllerHook() { + INSTALL_HOOK(ChromaLogger::Logger, ObstacleController_Init); + INSTALL_HOOK(ChromaLogger::Logger, ObstacleController_ManualUpdate); } ChromaInstallHooks(ObstacleControllerHook) \ No newline at end of file diff --git a/src/hooks/colorizer/Saber/SaberBurnMarkArea.cpp b/src/hooks/colorizer/Saber/SaberBurnMarkArea.cpp index c75addf..49776a5 100644 --- a/src/hooks/colorizer/Saber/SaberBurnMarkArea.cpp +++ b/src/hooks/colorizer/Saber/SaberBurnMarkArea.cpp @@ -47,9 +47,9 @@ MAKE_HOOK_MATCH(SaberBurnMarkArea_Start, &SaberBurnMarkArea::Start, void, SaberB return; } - if (self->lineRenderers && self->lineRenderers.Length() >= 2) { - lineRenderers[0] = self->lineRenderers.get(0); - lineRenderers[1] = self->lineRenderers.get(1); + if (self->_lineRenderers && self->_lineRenderers.size() >= 2) { + lineRenderers[0] = self->_lineRenderers.get(0); + lineRenderers[1] = self->_lineRenderers.get(1); } if (saberBurnMarkCount == 0) { @@ -72,9 +72,9 @@ MAKE_HOOK_MATCH(SaberBurnMarkArea_OnDestroy, &SaberBurnMarkArea::OnDestroy, void } } -void SaberBurnMarkAreaHook(Logger& logger) { - INSTALL_HOOK(logger, SaberBurnMarkArea_Start); - INSTALL_HOOK(logger, SaberBurnMarkArea_OnDestroy); +void SaberBurnMarkAreaHook() { + INSTALL_HOOK(ChromaLogger::Logger, SaberBurnMarkArea_Start); + INSTALL_HOOK(ChromaLogger::Logger, SaberBurnMarkArea_OnDestroy); } ChromaInstallHooks(SaberBurnMarkAreaHook) \ No newline at end of file diff --git a/src/hooks/colorizer/Saber/SaberBurnMarkSparkles.cpp b/src/hooks/colorizer/Saber/SaberBurnMarkSparkles.cpp index 12fe861..ac3ef9c 100644 --- a/src/hooks/colorizer/Saber/SaberBurnMarkSparkles.cpp +++ b/src/hooks/colorizer/Saber/SaberBurnMarkSparkles.cpp @@ -13,8 +13,6 @@ #include "GlobalNamespace/SaberBurnMarkArea.hpp" #include "UnityEngine/ParticleSystem.hpp" -#include "UnityEngine/ParticleSystem_MainModule.hpp" -#include "UnityEngine/ParticleSystem_MinMaxGradient.hpp" #include "colorizer/SaberColorizer.hpp" #include "utils/ChromaUtils.hpp" @@ -36,7 +34,7 @@ void OnSaberColorChanged(int saberType, GlobalNamespace::SaberModelController* / Sombrero::FastColor::RGBToHSV(color, h, s, _); Sombrero::FastColor effectColor = Sombrero::FastColor::HSVToRGB(h, s, 1); ParticleSystem::MainModule main = burnMarksPS[saberType]->get_main(); - main.set_startColor(effectColor); + main.set_startColor(ParticleSystem::MinMaxGradient::op_Implicit___UnityEngine____ParticleSystem__MinMaxGradient(effectColor)); } MAKE_HOOK_MATCH(SaberBurnMarkSparkles_Start, &SaberBurnMarkSparkles::Start, void, SaberBurnMarkSparkles* self) { @@ -46,9 +44,9 @@ MAKE_HOOK_MATCH(SaberBurnMarkSparkles_Start, &SaberBurnMarkSparkles::Start, void if (!ChromaController::DoChromaHooks() || (self == nullptr)) { return; } - if (self->burnMarksPS && self->burnMarksPS.Length() >= 2) { - burnMarksPS[0] = self->burnMarksPS.get(0); - burnMarksPS[1] = self->burnMarksPS.get(1); + if (self->_burnMarksPS && self->_burnMarksPS.size() >= 2) { + burnMarksPS[0] = self->_burnMarksPS.get(0); + burnMarksPS[1] = self->_burnMarksPS.get(1); } if (subCount == 0) { @@ -71,9 +69,9 @@ MAKE_HOOK_MATCH(SaberBurnMarkSparkles_OnDestroy, &SaberBurnMarkSparkles::OnDestr } } -void SaberBurnMarkSparklesHook(Logger& logger) { - INSTALL_HOOK(logger, SaberBurnMarkSparkles_Start); - INSTALL_HOOK(logger, SaberBurnMarkSparkles_OnDestroy); +void SaberBurnMarkSparklesHook() { + INSTALL_HOOK(ChromaLogger::Logger, SaberBurnMarkSparkles_Start); + INSTALL_HOOK(ChromaLogger::Logger, SaberBurnMarkSparkles_OnDestroy); } ChromaInstallHooks(SaberBurnMarkSparklesHook) \ No newline at end of file diff --git a/src/hooks/colorizer/Saber/SaberClashEffect.cpp b/src/hooks/colorizer/Saber/SaberClashEffect.cpp index 725dc68..c78fbce 100644 --- a/src/hooks/colorizer/Saber/SaberClashEffect.cpp +++ b/src/hooks/colorizer/Saber/SaberClashEffect.cpp @@ -12,8 +12,6 @@ #include "UnityEngine/GameObject.hpp" #include "UnityEngine/ParticleSystem.hpp" -#include "UnityEngine/ParticleSystem_MainModule.hpp" -#include "UnityEngine/ParticleSystem_MinMaxGradient.hpp" #include "colorizer/Monobehaviours/ChromaClashEffectController.hpp" #include "colorizer/SaberColorizer.hpp" @@ -32,9 +30,9 @@ MAKE_HOOK_MATCH(SaberClashEffect_Start, &SaberClashEffect::Start, void, SaberCla } self->get_gameObject()->AddComponent()->Init( - self->sparkleParticleSystem, self->glowParticleSystem, self->colorManager); + self->_sparkleParticleSystem, self->_glowParticleSystem, self->_colorManager); } void SaberClashEffect() { - INSTALL_HOOK(getLogger(), SaberClashEffect_Start); + INSTALL_HOOK(ChromaLogger::Logger, SaberClashEffect_Start); } \ No newline at end of file diff --git a/src/hooks/colorizer/SliderController.cpp b/src/hooks/colorizer/SliderController.cpp index 32d6e31..37f57f7 100644 --- a/src/hooks/colorizer/SliderController.cpp +++ b/src/hooks/colorizer/SliderController.cpp @@ -73,9 +73,9 @@ MAKE_HOOK_MATCH(SliderController_Update, &SliderController::ManualUpdate, void, } } -void SliderControllerHook(Logger& /*logger*/) { - INSTALL_HOOK(getLogger(), SliderController_Init); - INSTALL_HOOK(getLogger(), SliderController_Update); +void SliderControllerHook() { + INSTALL_HOOK(ChromaLogger::Logger, SliderController_Init); + INSTALL_HOOK(ChromaLogger::Logger, SliderController_Update); } ChromaInstallHooks(SliderControllerHook) \ No newline at end of file diff --git a/src/lighting/ChromaEventData.cpp b/src/lighting/ChromaEventData.cpp index dcfa438..e251576 100644 --- a/src/lighting/ChromaEventData.cpp +++ b/src/lighting/ChromaEventData.cpp @@ -10,7 +10,6 @@ using namespace ChromaUtils; void Chroma::ChromaEventDataManager::deserialize(CustomJSONData::CustomBeatmapData* beatmapData) { - static auto contextLogger = getLogger().WithContext(ChromaLogger::ObjectDataDeserialize); ChromaEventDatas.clear(); auto* beatmapDataCast = beatmapData; @@ -18,22 +17,24 @@ void Chroma::ChromaEventDataManager::deserialize(CustomJSONData::CustomBeatmapDa bool v2 = beatmapDataCast->v2orEarlier; - for (auto* beatmapEvent : beatmapDataCast->beatmapEventDatas) { + auto const& beatmapEventDatas = beatmapDataCast->beatmapEventDatas; + + for (auto* beatmapEvent : beatmapEventDatas) { if (beatmapEvent->klass != CustomBasicBeatmapEventDataKlass) { continue; } auto* customBeatmapEvent = reinterpret_cast(beatmapEvent); - + if(!customBeatmapEvent->customData) continue; auto const& optionalDynData = customBeatmapEvent->customData->value; std::optional gradientObject = std::nullopt; - debugSpamLog(contextLogger, "Light gradient"); + debugSpamLog("Light gradient"); // ASSIGN ChromaEventData chromaEventData; - + if (!optionalDynData.has_value()) continue; if (optionalDynData) { rapidjson::Value const& unwrappedData = *optionalDynData; @@ -96,7 +97,7 @@ void Chroma::ChromaEventDataManager::deserialize(CustomJSONData::CustomBeatmapDa propIds.push_back(static_cast(propId)); } } else { - getLogger().error("Prop id type is not array or number!"); + ChromaLogger::Logger.error("Prop id type is not array or number!"); } } @@ -134,7 +135,7 @@ void Chroma::ChromaEventDataManager::deserialize(CustomJSONData::CustomBeatmapDa chromaEventData.LerpType = lerpType; } - debugSpamLog(contextLogger, "Light ID"); + debugSpamLog("Light ID"); auto lightId = unwrappedData.FindMember(v2 ? NewConstants::V2_LIGHT_ID.data() : NewConstants::LIGHT_ID.data()); if (lightId != unwrappedData.MemberEnd()) { @@ -153,7 +154,7 @@ void Chroma::ChromaEventDataManager::deserialize(CustomJSONData::CustomBeatmapDa lightIds.push_back(lightId.GetInt()); } } else { - getLogger().error("Light id type is not array or number!"); + ChromaLogger::Logger.error("Light id type is not array or number!"); } chromaEventData.LightID = lightIds; @@ -197,90 +198,38 @@ void Chroma::ChromaEventDataManager::deserialize(CustomJSONData::CustomBeatmapDa ChromaEventDatas.try_emplace(customBeatmapEvent, std::move(chromaEventData)); } - std::vector allUsedIds; - allUsedIds.reserve(beatmapDataCast->beatmapEventDatas.size()); - - for (auto const& event : beatmapDataCast->beatmapEventDatas) { - auto const& dataIt = ChromaEventDatas.find(event); - if (dataIt == ChromaEventDatas.end()) { - continue; - } - - auto const& d = dataIt->second; - - if (!d.LightID) { - continue; - } - - for (auto const& l : *d.LightID) { - if (std::find(allUsedIds.begin(), allUsedIds.end(), l) == allUsedIds.end()) { - continue; + // Horrible stupid logic to get next same type event per light id + // what am i even doing anymore + std::unordered_map> allNextSameTypes; + for (int i = beatmapEventDatas.size() - 1; i >= 0; i--) { + auto const& beatmapEventData = beatmapEventDatas[i]; + auto const& basicBeatmapEventDataOpt = + il2cpp_utils::try_cast(beatmapEventData); + if (!basicBeatmapEventDataOpt) continue; + auto const& basicBeatmapEventData = *basicBeatmapEventDataOpt; + + auto eventDataIt = ChromaEventDatas.find(beatmapEventData); + if (eventDataIt == ChromaEventDatas.end()) continue; + auto& currentEventData = eventDataIt->second; + + int type = (int)basicBeatmapEventData->basicBeatmapEventType.value__; + auto& nextSameTypes = allNextSameTypes[type]; + + if (currentEventData.NextSameTypeEvent.empty()) { + for (auto const& [k, v] : nextSameTypes) { + currentEventData.NextSameTypeEvent[k] = std::pair(v, &ChromaEventDatas.at(v)); } - allUsedIds.push_back(l); - } - } - - // start at 0 - int i = -1; - auto beatmapEventsLength = beatmapDataCast->beatmapEventDatas.size(); - - for (auto* beatmapEventData : beatmapDataCast->beatmapEventDatas) { - i++; - - auto tryCast = il2cpp_utils::try_cast(beatmapEventData); - if (!tryCast) { - continue; } - auto* basicBeatmapEventData = *tryCast; - auto chromaEventDataIt = ChromaEventDatas.find(basicBeatmapEventData); - - if (chromaEventDataIt == ChromaEventDatas.end()) { - continue; - } - - auto* customBeatmapEvent = static_cast(basicBeatmapEventData); - auto& currentEventData = chromaEventDataIt->second; - // Horrible stupid logic to get next same type event per light id - - auto type = customBeatmapEvent->basicBeatmapEventType; - auto& nextSameTypeEvent = currentEventData.NextSameTypeEvent; - - auto const& ids = currentEventData.LightID.value_or(allUsedIds); - - for (int id : ids) { - if (i >= beatmapEventsLength - 1) { - continue; + auto const& ids = currentEventData.LightID; + if (ids == std::nullopt) { + nextSameTypes[-1] = basicBeatmapEventData; + for (auto [key, _] : nextSameTypes) { + nextSameTypes[key] = basicBeatmapEventData; } - - int nextIndex = FindIndex( - beatmapDataCast->beatmapEventDatas, - [type, id](GlobalNamespace::BeatmapEventData* n) { - auto tryCast = il2cpp_utils::try_cast(n); - if (!tryCast) { - return false; - } - - if (tryCast.value()->basicBeatmapEventType != type) { - return false; - } - - auto it = ChromaEventDatas.find(n); - - if (it == ChromaEventDatas.end()) { - return false; - } - - ChromaEventData const& nextEventData = it->second; - auto const& lightId = nextEventData.LightID; - - return !lightId || std::find(lightId->begin(), lightId->end(), id) != lightId->end(); - }, - i + 1); - - if (nextIndex != -1) { - auto* beatmapEvent = beatmapDataCast->beatmapEventDatas[nextIndex]; - currentEventData.NextSameTypeEvent[id] = { beatmapEvent, &ChromaEventDatas.at(beatmapEvent) }; + } else { + for (auto id : *ids) { + nextSameTypes[id] = basicBeatmapEventData; } } } diff --git a/src/lighting/ChromaFogController.cpp b/src/lighting/ChromaFogController.cpp index 953a140..5966448 100644 --- a/src/lighting/ChromaFogController.cpp +++ b/src/lighting/ChromaFogController.cpp @@ -48,7 +48,7 @@ void ChromaFogController::AssignTrack(Track* track) { void ChromaFogController::Awake() { ArrayW fogs = Resources::FindObjectsOfTypeAll(); - if (fogs && fogs.Length() > 0) { + if (fogs && fogs.size() > 0) { bloomFog = fogs.get(0); } @@ -63,12 +63,12 @@ void ChromaFogController::Awake() { void Chroma::ChromaFogController::Update() { if (_track == nullptr) { - getLogger().error("Track is null"); + ChromaLogger::Logger.error("Track is null"); CJDLogger::Logger.fmtLog("Fog track is null!"); return; } if (_transitionFogParams == nullptr) { - getLogger().error("ChromaFog TransitionFogParams is null"); + ChromaLogger::Logger.error("ChromaFog TransitionFogParams is null"); CJDLogger::Logger.fmtLog("ChromaFog TransitionFogParams is null!"); return; } diff --git a/src/lighting/ChromaGradientController.cpp b/src/lighting/ChromaGradientController.cpp index 4a9b203..78694a3 100644 --- a/src/lighting/ChromaGradientController.cpp +++ b/src/lighting/ChromaGradientController.cpp @@ -51,11 +51,11 @@ void ChromaGradientController::OnDestroy() { } bool Chroma::ChromaGradientController::IsGradientActive(GlobalNamespace::BasicBeatmapEventType eventType) { - return getInstance()->Gradients.contains(eventType); + return getInstance()->Gradients.contains(eventType.value__); } void ChromaGradientController::CancelGradient(GlobalNamespace::BasicBeatmapEventType eventType) { - getInstance()->Gradients.erase(eventType); + getInstance()->Gradients.erase(eventType.value__); } Sombrero::FastColor ChromaGradientController::AddGradient(ChromaEventData::GradientObjectData const& gradientObject, @@ -67,7 +67,7 @@ Sombrero::FastColor ChromaGradientController::AddGradient(ChromaEventData::Gradi Sombrero::FastColor const& endcolor = gradientObject.EndColor; Functions easing = gradientObject.Easing; - auto it = getInstance()->Gradients.try_emplace(id.value, + auto it = getInstance()->Gradients.try_emplace(id.value__, ChromaGradientEvent(initcolor, endcolor, time, duration, id, easing)); // Grab by reference since assignment copies to the map // This way calling interpolate actually modifies the struct itself. diff --git a/src/lighting/ChromaLightSwitchEventEffect.cpp b/src/lighting/ChromaLightSwitchEventEffect.cpp index ce95f36..0327dc6 100644 --- a/src/lighting/ChromaLightSwitchEventEffect.cpp +++ b/src/lighting/ChromaLightSwitchEventEffect.cpp @@ -35,61 +35,67 @@ constexpr static GlobalNamespace::EnvironmentColorType GetLightColorTypeFromEven } Sombrero::FastColor GetNormalColorOld(ChromaLightSwitchEventEffect* l, int beatmapEventValue, bool colorBoost) { - if (colorBoost) { - if (!Chroma::ChromaLightSwitchEventEffect::IsColor0(beatmapEventValue)) { - return l->lightColor1Boost->get_color(); + switch (GetLightColorTypeFromEventDataValue(beatmapEventValue)) { + case EnvironmentColorType::Color0: + if (!colorBoost) { + return l->_lightColor0->color; } - return l->lightColor0Boost->get_color(); - } - if (!Chroma::ChromaLightSwitchEventEffect::IsColor0(beatmapEventValue)) { - return l->lightColor1->get_color(); + return l->_lightColor0Boost->color; + case EnvironmentColorType::Color1: + if (!colorBoost) { + return l->_lightColor1->color; + } + return l->_lightColor1Boost->color; + case EnvironmentColorType::ColorW: + return l->_colorManager->ColorForType(EnvironmentColorType::ColorW, colorBoost); + default: + return l->_lightColor0->color; } - return l->lightColor0->get_color(); } void Chroma::ChromaLightSwitchEventEffect::CopyValues(GlobalNamespace::LightSwitchEventEffect* lightSwitchEventEffect) { - lightColor0 = lightSwitchEventEffect->lightColor0; - lightColor1 = lightSwitchEventEffect->lightColor1; - highlightColor0 = lightSwitchEventEffect->highlightColor0; - highlightColor1 = lightSwitchEventEffect->highlightColor1; - lightColor0Boost = lightSwitchEventEffect->lightColor0Boost; - lightColor1Boost = lightSwitchEventEffect->lightColor1Boost; - highlightColor0Boost = lightSwitchEventEffect->highlightColor0Boost; - highlightColor1Boost = lightSwitchEventEffect->highlightColor1Boost; - - offColorIntensity = lightSwitchEventEffect->offColorIntensity; - lightOnStart = lightSwitchEventEffect->lightOnStart; - this->lightsID = lightSwitchEventEffect->lightsID; - this->event = lightSwitchEventEffect->event; - - this->lightManager = lightSwitchEventEffect->lightManager; - this->beatmapCallbacksController = lightSwitchEventEffect->beatmapCallbacksController; - this->tweeningManager = lightSwitchEventEffect->tweeningManager; - this->colorManager = lightSwitchEventEffect->colorManager; - - _originalLightColor0 = lightColor0; - _originalLightColor0Boost = lightColor0Boost; - _originalLightColor1 = lightColor1; - _originalLightColor1Boost = lightColor1Boost; - - auto Initialize = [](auto&& so, Sombrero::FastColor& color) { - if (auto multi = il2cpp_utils::try_cast(so)) { - color = multi.value()->multiplierColor; + _lightColor0 = lightSwitchEventEffect->_lightColor0; + _lightColor1 = lightSwitchEventEffect->_lightColor1; + _highlightColor0 = lightSwitchEventEffect->_highlightColor0; + _highlightColor1 = lightSwitchEventEffect->_highlightColor1; + _lightColor0Boost = lightSwitchEventEffect->_lightColor0Boost; + _lightColor1Boost = lightSwitchEventEffect->_lightColor1Boost; + _highlightColor0Boost = lightSwitchEventEffect->_highlightColor0Boost; + _highlightColor1Boost = lightSwitchEventEffect->_highlightColor1Boost; + + _offColorIntensity = lightSwitchEventEffect->_offColorIntensity; + _lightOnStart = lightSwitchEventEffect->_lightOnStart; + this->_lightsID = lightSwitchEventEffect->_lightsID; + this->_event = lightSwitchEventEffect->_event; + + this->_lightManager = lightSwitchEventEffect->_lightManager; + this->_beatmapCallbacksController = lightSwitchEventEffect->_beatmapCallbacksController; + this->_tweeningManager = lightSwitchEventEffect->_tweeningManager; + this->_colorManager = lightSwitchEventEffect->_colorManager; + + _originalLightColor0 = _lightColor0; + _originalLightColor0Boost = _lightColor0Boost; + _originalLightColor1 = _lightColor1; + _originalLightColor1Boost = _lightColor1Boost; + + auto Initialize = [](UnityW so, Sombrero::FastColor& color) { + if (auto multi = il2cpp_utils::try_cast(so.ptr())) { + color = multi.value()->_multiplierColor; } else { color = Sombrero::FastColor::white(); } }; - Initialize(lightColor0, _lightColor0Mult); - Initialize(lightColor1, _lightColor1Mult); - Initialize(highlightColor0, _highlightColor0Mult); - Initialize(highlightColor1, _highlightColor1Mult); - Initialize(lightColor0Boost, _lightColor0BoostMult); - Initialize(lightColor1Boost, _lightColor1BoostMult); - Initialize(highlightColor0Boost, _highlightColor0BoostMult); - Initialize(highlightColor1Boost, _highlightColor1BoostMult); + Initialize(_lightColor0, _lightColor0Mult); + Initialize(_lightColor1, _lightColor1Mult); + Initialize(_highlightColor0, _highlightColor0Mult); + Initialize(_highlightColor1, _highlightColor1Mult); + Initialize(_lightColor0Boost, _lightColor0BoostMult); + Initialize(_lightColor1Boost, _lightColor1BoostMult); + Initialize(_highlightColor0Boost, _highlightColor0BoostMult); + Initialize(_highlightColor1Boost, _highlightColor1BoostMult); - this->lightColorizer = &LightColorizer::New(this, lightManager); + this->lightColorizer = &LightColorizer::New(this, _lightManager); LightColorizer::CompleteContracts(this); // Sombrero::FastColor color = lightOnStart ? lightColor0->get_color() : @@ -97,7 +103,7 @@ void Chroma::ChromaLightSwitchEventEffect::CopyValues(GlobalNamespace::LightSwit } void Chroma::ChromaLightSwitchEventEffect::HandleEvent(GlobalNamespace::BasicBeatmapEventData* beatmapEventData) { - if (beatmapEventData->basicBeatmapEventType != event) { + if (beatmapEventData->basicBeatmapEventType != _event) { return; } std::optional> selectLights; @@ -106,8 +112,6 @@ void Chroma::ChromaLightSwitchEventEffect::HandleEvent(GlobalNamespace::BasicBea // fun fun chroma stuff - static auto contextLogger = getLogger().WithContext(ChromaLogger::ColorLightSwitch); - auto chromaIt = ChromaEventDataManager::ChromaEventDatas.find(beatmapEventData); // Aero thinks legacy was a mistake. I think a Quest port was a bigger mistake. @@ -116,7 +120,7 @@ void Chroma::ChromaLightSwitchEventEffect::HandleEvent(GlobalNamespace::BasicBea if (chromaIt == ChromaEventDataManager::ChromaEventDatas.end()) { color = LegacyLightHelper::GetLegacyColor(beatmapEventData); } else { - debugSpamLog(contextLogger, "Color is legacy? %s", color ? "true" : "false"); + debugSpamLog("Color is legacy? {}", color ? "true" : "false"); auto const& chromaData = chromaIt->second; @@ -161,11 +165,11 @@ void Chroma::ChromaLightSwitchEventEffect::HandleEvent(GlobalNamespace::BasicBea } void ChromaLightSwitchEventEffect::HandleBoostEvent(GlobalNamespace::ColorBoostBeatmapEventData* beatmapEventData) { - if (beatmapEventData->boostColorsAreOn == usingBoostColors) { + if (beatmapEventData->boostColorsAreOn == ____usingBoostColors) { return; } - usingBoostColors = beatmapEventData->boostColorsAreOn; + ____usingBoostColors = beatmapEventData->boostColorsAreOn; Refresh(false, std::nullopt); } @@ -176,21 +180,11 @@ void ChromaLightSwitchEventEffect::Awake() { void Chroma::ChromaLightSwitchEventEffect::OnDestroy() { livingLightSwitch.erase(this); static auto const* LightSwitchEventEffect_OnDestroy = - il2cpp_utils::il2cpp_type_check::MetadataGetter<&LightSwitchEventEffect::OnDestroy>::get(); + il2cpp_utils::il2cpp_type_check::MetadataGetter<&LightSwitchEventEffect::OnDestroy>::methodInfo(); il2cpp_utils::RunMethodRethrow(this, LightSwitchEventEffect_OnDestroy); - CRASH_UNLESS(&LightColorizer::Colorizers.at(event) == lightColorizer); - LightColorizer::Colorizers.erase(event); -} - -Sombrero::FastColor Chroma::ChromaLightSwitchEventEffect::GetOriginalColor(int beatmapEventValue, - bool colorBoost) const { - if (colorBoost) { - return !IsColor0(beatmapEventValue) ? _originalLightColor1Boost->get_color() - : _originalLightColor0Boost->get_color(); - } - - return !IsColor0(beatmapEventValue) ? _originalLightColor1->get_color() : _originalLightColor0->get_color(); + CRASH_UNLESS(&LightColorizer::Colorizers.at(_event.value__) == lightColorizer); + LightColorizer::Colorizers.erase(_event.value__); } void ChromaLightSwitchEventEffect::Refresh(bool hard, std::optional> const& selectLights, @@ -211,7 +205,7 @@ void ChromaLightSwitchEventEffect::Refresh(bool hard, std::optionaltween; CRASH_UNLESS(tween.isHandleValid()); @@ -244,10 +238,17 @@ void ChromaLightSwitchEventEffect::Refresh(bool hard, std::optional(previousEvent->nextSameTypeEventData); } else if (nextSameTypesDict->contains(tweenData->id)) { - auto [anextSameTypeEvent, anextEventData] = nextSameTypesDict->at(tweenData->id); - nextSameTypeEvent = il2cpp_utils::try_cast(anextSameTypeEvent).value_or(nullptr); + auto [tempNextSameTypeEvent, tempNextEventData] = nextSameTypesDict->at(tweenData->id); + // optimization, grab early + nextEventData = tempNextEventData; + + nextSameTypeEvent = il2cpp_utils::try_cast(tempNextSameTypeEvent).value_or(nullptr); + + } else if (nextSameTypesDict->contains(-1)) { + auto [tempNextSameTypeEvent, tempNextEventData] = nextSameTypesDict->at(-1); // optimization, grab early - nextEventData = anextEventData; + nextEventData = tempNextEventData; + nextSameTypeEvent = il2cpp_utils::try_cast(tempNextSameTypeEvent).value_or(nullptr); } if ((nextSameTypeEvent == nullptr) || @@ -273,7 +274,7 @@ void ChromaLightSwitchEventEffect::Refresh(bool hard, std::optionaltween->fromValue = prevColor; - tweenData->tween->toValue = nextColor; + tweenData->tween->___fromValue = prevColor; + tweenData->tween->___toValue = nextColor; tweenData->tween->ForceOnUpdate(); if (!hard) { @@ -312,7 +313,7 @@ void ChromaLightSwitchEventEffect::Refresh(bool hard, std::optionaltween->SetStartTimeAndEndTime(previousEvent->time, nextSameTypeEvent->time); tweenData->easing = easing.value_or(Functions::easeLinear); tweenData->lerpType = lerpType.value_or(LerpType::RGB); - tweeningManager->ResumeTween(const_cast(tween.ptr()), this); + _tweeningManager->ResumeTween(const_cast(tween.ptr()), this, false); }; switch (previousValue) { @@ -322,12 +323,12 @@ void ChromaLightSwitchEventEffect::Refresh(bool hard, std::optionalfromValue = color; - tween->toValue = color; - Chroma::Tween::SetColor(tweenData->lightWithId.ptr(), lightManager, color); + tween->___fromValue = color; + tween->___toValue = color; + Chroma::Tween::SetColor(tweenData->lightWithId.ptr(), _lightManager, color); CheckNextEventForFadeBetter(); break; @@ -345,9 +346,9 @@ void ChromaLightSwitchEventEffect::Refresh(bool hard, std::optionalfromValue = color; - tween->toValue = color; - Chroma::Tween::SetColor(tweenData->lightWithId.ptr(), lightManager, color); + tween->___fromValue = color; + tween->___toValue = color; + Chroma::Tween::SetColor(tweenData->lightWithId.ptr(), _lightManager, color); CheckNextEventForFadeBetter(); break; } @@ -359,15 +360,15 @@ void ChromaLightSwitchEventEffect::Refresh(bool hard, std::optionalfromValue = colorFrom; - tween->toValue = colorTo; + tween->___fromValue = colorFrom; + tween->___toValue = colorTo; tween->ForceOnUpdate(); if (hard) { tween->duration = 0.6F; tweenData->easing = easing.value_or(Functions::easeOutCubic); tweenData->lerpType = lerpType.value_or(LerpType::RGB); - tweeningManager->RestartTween(const_cast(tween.ptr()), this); + _tweeningManager->RestartTween(const_cast(tween.ptr()), this, false); } break; @@ -381,16 +382,16 @@ void ChromaLightSwitchEventEffect::Refresh(bool hard, std::optionalfromValue = colorFrom; - tween->toValue = colorTo; + colorTo.a = _offColorIntensity * previousFloatValue; // ColorWithAlpha + tween->___fromValue = colorFrom; + tween->___toValue = colorTo; tween->ForceOnUpdate(); if (hard) { tween->duration = 1.5F; tweenData->easing = easing.value_or(Functions::easeOutExpo); tweenData->lerpType = lerpType.value_or(LerpType::RGB); - tweeningManager->RestartTween(const_cast(tween.ptr()), this); + _tweeningManager->RestartTween(const_cast(tween.ptr()), this, false); } break; @@ -420,7 +421,7 @@ Sombrero::FastColor ChromaLightSwitchEventEffect::GetNormalColor(int beatmapEven return lightColorizer->getColor()[1] * _lightColor1Mult; } case EnvironmentColorType::ColorW: { - return colorManager->ColorForType(EnvironmentColorType::ColorW, colorBoost); + return _colorManager->ColorForType(EnvironmentColorType::ColorW, colorBoost); } } } @@ -440,7 +441,7 @@ Sombrero::FastColor ChromaLightSwitchEventEffect::GetHighlightColor(int beatmapE return lightColorizer->getColor()[1] * _highlightColor1Mult; } case EnvironmentColorType::ColorW: { - return colorManager->ColorForType(EnvironmentColorType::ColorW, colorBoost); + return _colorManager->ColorForType(EnvironmentColorType::ColorW, colorBoost); } } } @@ -470,13 +471,13 @@ void ChromaLightSwitchEventEffect::RegisterLight(GlobalNamespace::ILightWithId* return; } - Sombrero::FastColor color = GetNormalColor(0, usingBoostColors); - if (!lightOnStart) { - color = color.Alpha(offColorIntensity); + Sombrero::FastColor color = GetNormalColor(0, _usingBoostColors); + if (!_lightOnStart) { + color = color.Alpha(_offColorIntensity); } - auto tableId = LightIDTableManager::GetActiveTableValueReverse(lightsID, id).value_or(0); - auto* tween = Chroma::Tween::makeTween(color, color, lightWithId, lightManager); + auto tableId = LightIDTableManager::GetActiveTableValueReverse(_lightsID, id).value_or(0); + auto* tween = Chroma::Tween::makeTween(color, color, lightWithId, _lightManager); auto it = ColorTweens.try_emplace(lightWithId, tableId, tween, lightWithId); ColorTweensMapping[tween] = &it.first->second; diff --git a/src/lighting/ChromaRingsRotationEffect.cpp b/src/lighting/ChromaRingsRotationEffect.cpp index 3708945..718ac24 100644 --- a/src/lighting/ChromaRingsRotationEffect.cpp +++ b/src/lighting/ChromaRingsRotationEffect.cpp @@ -1,6 +1,6 @@ #include "Chroma.hpp" #include "lighting/ChromaRingsRotationEffect.hpp" -#include "GlobalNamespace/TrackLaneRingsRotationEffect_RingRotationEffect.hpp" +#include "GlobalNamespace/TrackLaneRingsRotationEffect.hpp" #include "GlobalNamespace/TrackLaneRing.hpp" using namespace Chroma; @@ -23,16 +23,16 @@ void ChromaRingsRotationEffect::AddRingRotationEffectF(float angle, float step, } void ChromaRingsRotationEffect::SetNewRingManager(GlobalNamespace::TrackLaneRingsManager* trackLaneRingsManager) { - this->trackLaneRingsManager = trackLaneRingsManager; + this->_trackLaneRingsManager = _trackLaneRingsManager; } void ChromaRingsRotationEffect::CopyValues( GlobalNamespace::TrackLaneRingsRotationEffect* trackLaneRingsRotationEffect) { - this->trackLaneRingsManager = trackLaneRingsRotationEffect->trackLaneRingsManager; - this->startupRotationAngle = trackLaneRingsRotationEffect->startupRotationAngle; - this->startupRotationStep = trackLaneRingsRotationEffect->startupRotationStep; - this->startupRotationPropagationSpeed = trackLaneRingsRotationEffect->startupRotationPropagationSpeed; - this->startupRotationFlexySpeed = trackLaneRingsRotationEffect->startupRotationFlexySpeed; + this->_trackLaneRingsManager = trackLaneRingsRotationEffect->_trackLaneRingsManager; + this->_startupRotationAngle = trackLaneRingsRotationEffect->_startupRotationAngle; + this->_startupRotationStep = trackLaneRingsRotationEffect->_startupRotationStep; + this->_startupRotationPropagationSpeed = trackLaneRingsRotationEffect->_startupRotationPropagationSpeed; + this->_startupRotationFlexySpeed = trackLaneRingsRotationEffect->_startupRotationFlexySpeed; } void ChromaRingsRotationEffect::Awake() { @@ -43,17 +43,17 @@ void ChromaRingsRotationEffect::Awake() { } void ChromaRingsRotationEffect::Start() { - AddRingRotationEffectF(startupRotationAngle, startupRotationStep, static_cast(startupRotationPropagationSpeed), - startupRotationFlexySpeed); + AddRingRotationEffectF(_startupRotationAngle, _startupRotationStep, static_cast(_startupRotationPropagationSpeed), + _startupRotationFlexySpeed); } void ChromaRingsRotationEffect::FixedUpdate() { if (!_activeRingRotationEffects.empty()) { - auto rings = trackLaneRingsManager->rings; + auto rings = _trackLaneRingsManager->_rings; if (!rings) { - getLogger().warning("Rings is null why! %p ", trackLaneRingsManager); - rings = trackLaneRingsManager->rings = Array::New(); + ChromaLogger::Logger.warn("Rings is null why! {} ", fmt::ptr(_trackLaneRingsManager.ptr())); + _trackLaneRingsManager->_rings = ArrayW>(); } static auto SetDestRotation = FPtrWrapper<&GlobalNamespace::TrackLaneRing::SetDestRotation>::get(); @@ -64,7 +64,7 @@ void ChromaRingsRotationEffect::FixedUpdate() { auto num = static_cast(ringRotationEffect.ProgressPos); auto progressPos = ringRotationEffect.ProgressPos += ringRotationEffect.RotationPropagationSpeed; - auto length = static_cast(rings.Length()); + auto length = static_cast(rings.size()); while (num < progressPos && num < length) { SetDestRotation(rings.get(num), @@ -73,7 +73,7 @@ void ChromaRingsRotationEffect::FixedUpdate() { num++; } - if (progressPos >= rings.Length()) { + if (progressPos >= rings.size()) { RecycleRingRotationEffect(ringRotationEffect); _activeRingRotationEffects.erase(std::next(it).base()); } diff --git a/src/lighting/LegacyLightHelper.cpp b/src/lighting/LegacyLightHelper.cpp index 7612cf3..1e81016 100644 --- a/src/lighting/LegacyLightHelper.cpp +++ b/src/lighting/LegacyLightHelper.cpp @@ -13,10 +13,8 @@ using namespace System::Collections; LegacyLightHelper::ColorMap LegacyLightHelper::LegacyColorEvents = LegacyLightHelper::ColorMap(); void LegacyLightHelper::Activate(std::span eventData) { - static auto contextLogger = getLogger().WithContext(ChromaLogger::LegacyLightColor); - LegacyColorEvents = LegacyLightHelper::ColorMap(eventData.size()); - debugSpamLog(contextLogger, "Got the events, checking for legacy %d", eventData.size()); + debugSpamLog("Got the events, checking for legacy %zu", eventData.size()); for (auto& d : eventData) { // TODO: Should we do this or find the root of the nullptr and fix that instead? if (d == nullptr) { @@ -24,13 +22,13 @@ void LegacyLightHelper::Activate(std::spanklass)) { - getLogger().debug("Beatmap data: %s not what expected", il2cpp_utils::ClassStandardName(d->klass).c_str()); + ChromaLogger::Logger.debug("Beatmap data: {} not what expected", il2cpp_utils::ClassStandardName(d->klass).c_str()); continue; } - debugSpamLog(contextLogger, "Checking d %d %s", d->value, d->value >= RGB_INT_OFFSET ? "true" : "false"); + debugSpamLog("Checking d {} {}", d->value, d->value >= RGB_INT_OFFSET ? "true" : "false"); if (d->value >= RGB_INT_OFFSET) { - auto& list = LegacyColorEvents.try_emplace(d->basicBeatmapEventType).first->second; + auto& list = LegacyColorEvents.try_emplace(d->basicBeatmapEventType.value__).first->second; list.emplace_back(d->time, ColorFromInt(d->value)); } } @@ -42,12 +40,12 @@ LegacyLightHelper::GetLegacyColor(GlobalNamespace::BasicBeatmapEventData* beatma return std::nullopt; } - auto it = LegacyColorEvents.find(beatmapEventData->basicBeatmapEventType); + auto it = LegacyColorEvents.find(beatmapEventData->basicBeatmapEventType.value__); if (it != LegacyColorEvents.end()) { auto dictionaryID = it->second; - std::vector> colors; + std::vector> colors; - for (pair& n : dictionaryID) { + for (std::pair& n : dictionaryID) { if (n.first <= beatmapEventData->time) { colors.push_back(n); } diff --git a/src/lighting/LightIDTableManager.cpp b/src/lighting/LightIDTableManager.cpp index 4e26be1..f9c1afe 100644 --- a/src/lighting/LightIDTableManager.cpp +++ b/src/lighting/LightIDTableManager.cpp @@ -14,7 +14,7 @@ std::optional LightIDTableManager::activeTable = std::nul void Chroma::LightIDTableManager::InitTable() { for (auto& data : environmentsToInstall) { - getLogger().info("Initializing environment data for %s", data.first.data()); + ChromaLogger::Logger.info("Initializing environment data for {}", data.first.data()); lightIdTable.emplace(data); } installed = true; @@ -24,13 +24,13 @@ void LightIDTableManager::SetEnvironment(std::string_view environmentName) { auto it = lightIdTable.find(environmentName); if (it == lightIdTable.end()) { - getLogger().warning("Table not found for %s", environmentName.data()); + ChromaLogger::Logger.warn("Table not found for {}", environmentName.data()); activeTable = EnvironmentLightDataT(); for (int i = 0; i < 10; i++) { activeTable.value()[i] = {}; } } else { - getLogger().debug("Set the environment as %s", environmentName.data()); + ChromaLogger::Logger.debug("Set the environment as {}", environmentName.data()); auto map = it->second; activeTable = EnvironmentLightDataT(map.begin(), map.end()); } @@ -63,12 +63,12 @@ void LightIDTableManager::RegisterIndex(int lightId, int index, std::optional #include "lighting/LightIDTableManager.hpp" -#include "pinkcore/shared/RequirementAPI.hpp" +#include "songcore/shared/Capabilities.hpp" -#include "questui_components/shared/components/ScrollableContainer.hpp" -#include "questui_components/shared/components/Text.hpp" #include "ui/ModifierViewController.hpp" #include "environment_enhancements/EnvironmentMaterialManager.hpp" -#include "GlobalNamespace/SharedCoroutineStarter.hpp" +#include "bsml/shared/BSML/SharedCoroutineStarter.hpp" -#include "questui/shared/CustomTypes/Components/MainThreadScheduler.hpp" +#include "bsml/shared/BSML/MainThreadScheduler.hpp" using namespace Chroma; -using namespace QuestUI; -using namespace QUC; +//using namespace QuestUI; +//using namespace QUC; Configuration& getConfig() { static Configuration config(modInfo); @@ -34,86 +32,52 @@ Configuration& getConfig() { return config; } -Logger& getLogger() { - static auto* logger = new Logger(modInfo, LoggerOptions(false, true)); - return *logger; -} - void setChromaEnv() { setenv("DisableChromaReq", getChromaConfig().customColorEventsEnabled.GetValue() ? "0" : "1", true); if (getChromaConfig().customColorEventsEnabled.GetValue()) { - PinkCore::RequirementAPI::RegisterInstalled("Chroma"); + SongCore::API::Capabilities::RegisterCapability("Chroma"); } else { - PinkCore::RequirementAPI::RemoveInstalled("Chroma"); + SongCore::API::Capabilities::UnregisterCapability("Chroma"); } - PinkCore::RequirementAPI::RegisterInstalled("Chroma Lighting Events"); + SongCore::API::Capabilities::RegisterCapability("Chroma Lighting Events"); } void DidActivate(HMUI::ViewController* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { - getLogger().info("DidActivate: %p, %d, %d, %d", self, static_cast(firstActivation), + ChromaLogger::Logger.info("DidActivate: {}, {}, {}, {}", fmt::ptr(self), static_cast(firstActivation), static_cast(addedToHierarchy), static_cast(screenSystemEnabling)); - static QUC::RenderContext ctx{ nullptr }; - - static QUC::ScrollableContainer container(Text("Chroma settings."), Text("Settings are saved when changed."), - Text("Not all settings have been tested or implemented."), - Text("Please use with caution."), Chroma::UIUtils::buildMainUI()); - - if (firstActivation) { - ctx.destroyTree(); - ctx = RenderContext(self->get_transform()); - } - - detail::renderSingle(container, ctx); } -extern "C" void setup(ModInfo& info) { - info.id = modName; - info.version = VERSION; - modInfo = info; +extern "C" void setup(CModInfo* info) { + info->id = modName.c_str(); + info->version = VERSION; + info->version_long = 0; getConfig().Load(); - getChromaConfig().Init(info); + getChromaConfig().Init({modName, VERSION, 0}); - getLogger().info("Completed Chroma setup!"); + ChromaLogger::Logger.info("Completed Chroma setup!"); } -extern "C" void load() { +extern "C" void late_load() { il2cpp_functions::Init(); - QuestUI::Init(); - QuestUI::Register::RegisterModSettingsViewController(modInfo, DidActivate); - QuestUI::Register::RegisterGameplaySetupMenu(modInfo, Register::Solo | Register::Online); - -#if DEBUGB == 1 -#warning "Removing debug messages" -#else -#warning "Debug messages hooray" -#endif - - // TODO: This might be redundant now because of the macro, keep it to be safe? - // This disables the useless debug logs on the release build -#if DEBUGB == 1 - getLogger().debug("Disabling annoying loggers in release build"); - getLogger().DisableContext(Chroma::ChromaLogger::LightColorizer); - getLogger().DisableContext(Chroma::ChromaLogger::ColorLightSwitch); - getLogger().DisableContext(Chroma::ChromaLogger::EnvironmentRemoval); - getLogger().DisableContext(Chroma::ChromaLogger::TrackLaneRings); - getLogger().DisableContext(Chroma::ChromaLogger::ColorLightSwitch); - getLogger().DisableContext(Chroma::ChromaLogger::ObjectDataDeserialize); -#endif - - getLogger().info("Installing types..."); + + //QuestUI::Init(); + BSML::Register::RegisterSettingsMenu(modName, DidActivate, false); + //QuestUI::Register::RegisterGameplaySetupMenu(modInfo, Register::Solo | Register::Online); + + ChromaLogger::Logger.info("Installing types..."); custom_types::Register::AutoRegister(); - getLogger().info("Installed types"); + ChromaLogger::Logger.info("Installed types"); - getLogger().info("Installing Chroma hooks..."); - Chroma::Hooks::InstallHooks(getLogger()); - ChromaEvents::AddEventCallbacks(getLogger()); - getLogger().info("Installed Chroma hooks!"); + ChromaLogger::Logger.info("Installing Chroma hooks..."); + Chroma::Hooks::InstallHooks(); + ChromaEvents::AddEventCallbacks(); + ChromaLogger::Logger.info("Installed Chroma hooks!"); LightIDTableManager::InitTable(); diff --git a/src/ui/ModifierViewController.cpp b/src/ui/ModifierViewController.cpp index 081fe60..90c2da5 100644 --- a/src/ui/ModifierViewController.cpp +++ b/src/ui/ModifierViewController.cpp @@ -1,18 +1,12 @@ #include "ui/ModifierViewController.hpp" #include "UnityEngine/RectOffset.hpp" - -#include "questui/shared/CustomTypes/Components/Backgroundable.hpp" - -#include "questui_components/shared/components/Backgroundable.hpp" -#include "questui_components/shared/components/layouts/ModifierContainer.hpp" -#include "questui_components/shared/reference_comp.hpp" +#include "UnityEngine/Resources.hpp" +#include "UnityEngine/Sprite.hpp" #include "main.hpp" using namespace Chroma; -using namespace QUC; -using namespace QuestUI::BeatSaberUI; using namespace UnityEngine::UI; using namespace UnityEngine; @@ -30,8 +24,8 @@ UnityEngine::Sprite* UIUtils::configToIcon(ConfigUtils::ConfigValue const& auto& sprite = spriteMap[name]; - if ((sprite == nullptr) || (sprite->m_CachedPtr.m_value == nullptr)) { - sprite = QuestUI::ArrayUtil::First(Resources::FindObjectsOfTypeAll(), + if (UnityW(sprite) == nullptr) { + sprite = Resources::FindObjectsOfTypeAll()->First( [&name](Sprite* x) { return x->get_name() == name; }); } @@ -40,21 +34,6 @@ UnityEngine::Sprite* UIUtils::configToIcon(ConfigUtils::ConfigValue const& void Chroma::ModifierViewController::DidActivate(bool first) { - static detail::ModifierContainer layout(UIUtils::buildMainUI()); - - static ModifyLayoutElement layoutElement(QUC::detail::refComp(layout)); - - static detail::BackgroundableContainer container( - "round-rect-panel", Backgroundable("round-rect-panel", true, QUC::RefComp(layoutElement))); - if (first) { - this->ctx = RenderContext(get_transform()); - - layout.spacing = 0.75F; - layoutElement.preferredWidth = 55; - - detail::renderSingle(container, ctx); - } else { - detail::renderSingle(container, ctx); } }