From 2618619f01506c0eaaf0386dc471c438b1136110 Mon Sep 17 00:00:00 2001 From: golova Date: Sat, 24 Dec 2022 21:37:03 +0000 Subject: [PATCH] Fixed replays viewing --- include/ModConfig.hpp | 12 +++++++++++- mod.json | 7 ++++++- qpm.json | 7 ++++++- src/CharacteristicsManager.cpp | 1 - src/RthythmGameModifier.cpp | 11 +++++++---- 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/include/ModConfig.hpp b/include/ModConfig.hpp index f244690..9f62967 100644 --- a/include/ModConfig.hpp +++ b/include/ModConfig.hpp @@ -1,5 +1,6 @@ #pragma once #include "config-utils/shared/config-utils.hpp" +#include "bs-utils/shared/utils.hpp" DECLARE_CONFIG(ModConfig, @@ -8,4 +9,13 @@ DECLARE_CONFIG(ModConfig, CONFIG_INIT_FUNCTION( CONFIG_INIT_VALUE(QubeSize); ) -) \ No newline at end of file +) + +inline bool UploadDisabledByReplay() { + for (auto kv : bs_utils::Submission::getDisablingMods()) { + if (kv.id == "Replay") { + return true; + } + } + return false; +} \ No newline at end of file diff --git a/mod.json b/mod.json index 68779fc..54b6373 100644 --- a/mod.json +++ b/mod.json @@ -3,11 +3,16 @@ "name": "BeatLeaderModifiers", "id": "BeatLeaderModifiers", "author": "NSGolova", - "version": "0.1.0", + "version": "0.2.0", "packageId": "com.beatgames.beatsaber", "packageVersion": "1.25.1", "coverImage": "cover.png", "dependencies": [ + { + "version": "^0.7.0", + "id": "bs-utils", + "downloadIfMissing": "https://github.com/sc2ad/QuestBS-Utils/releases/download/v0.7.2/BS-Utils.qmod" + }, { "version": "^0.15.21", "id": "custom-types", diff --git a/qpm.json b/qpm.json index 7ea2026..2c93883 100644 --- a/qpm.json +++ b/qpm.json @@ -4,7 +4,7 @@ "info": { "name": "BeatLeaderModifiers", "id": "BeatLeaderModifiers", - "version": "0.1.0", + "version": "0.2.0", "url": null, "additionalData": { "overrideSoName": "libblmodifiers.so" @@ -44,6 +44,11 @@ "id": "config-utils", "versionRange": "^0.8.0", "additionalData": {} + }, + { + "id": "bs-utils", + "versionRange": "^0.7.0", + "additionalData": {} } ], "additionalData": {} diff --git a/src/CharacteristicsManager.cpp b/src/CharacteristicsManager.cpp index a20fd0d..ef8f92e 100644 --- a/src/CharacteristicsManager.cpp +++ b/src/CharacteristicsManager.cpp @@ -138,7 +138,6 @@ namespace BeatLeaderModifiers { BeatmapDifficulty defaultDifficulty, BeatmapCharacteristicSO* defaultBeatmapCharacteristic, PlayerData* playerData) { - getLogger().info("0"); bool inSolo = il2cpp_utils::try_cast(level->get_beatmapLevelData()) != nullopt; if (inSolo) { diff --git a/src/RthythmGameModifier.cpp b/src/RthythmGameModifier.cpp index ffcf47e..deaf52a 100644 --- a/src/RthythmGameModifier.cpp +++ b/src/RthythmGameModifier.cpp @@ -1,6 +1,7 @@ #include "include/RthythmGameModifier.hpp" #include "include/CharacteristicsManager.hpp" #include "include/InterpolationUtils.hpp" +#include "include/ModConfig.hpp" #include "UnityEngine/Vector3.hpp" #include "UnityEngine/Transform.hpp" @@ -60,7 +61,7 @@ namespace BeatLeaderModifiers { NoteController* self, ByRef noteCutInfo) { - if (customCharacterisitic != CustomCharacterisitic::betterScoring || !noteMovementCache.contains(self)) { + if (UploadDisabledByReplay() || customCharacterisitic != CustomCharacterisitic::betterScoring || !noteMovementCache.contains(self)) { NoteCut(self, noteCutInfo); return; } @@ -122,8 +123,7 @@ namespace BeatLeaderModifiers { } MAKE_HOOK_MATCH(CutScoreBufferRefreshScores, &CutScoreBuffer::RefreshScores, void, CutScoreBuffer* self) { - if (customCharacterisitic == CustomCharacterisitic::betterScoring) { - getLogger().info("%f", self->noteCutInfo.timeDeviation); + if (!UploadDisabledByReplay() && customCharacterisitic == CustomCharacterisitic::betterScoring) { float timingRating = 1 - Mathf::Clamp01((Mathf::Abs(self->noteCutInfo.timeDeviation) - goodTiming) / badTiming); self->saberSwingRatingCounter->afterCutRating = timingRating; self->saberSwingRatingCounter->beforeCutRating = timingRating; @@ -145,6 +145,9 @@ namespace BeatLeaderModifiers { MAKE_HOOK_MATCH(NoteControllerInit, &NoteController::Init, void, NoteController* self, NoteData* noteData, float worldRotation, Vector3 moveStartPos, Vector3 moveEndPos, Vector3 jumpEndPos, float moveDuration, float jumpDuration, float jumpGravity, float endRotation, float uniformScale, bool rotatesTowardsPlayer, bool useRandomRotation) { NoteControllerInit(self, noteData, worldRotation, moveStartPos, moveEndPos, jumpEndPos, moveDuration, jumpDuration, jumpGravity, endRotation, uniformScale, rotatesTowardsPlayer, useRandomRotation); + if (UploadDisabledByReplay()) { + return; + } float colliderScale = 0.58; auto gameNote = il2cpp_utils::try_cast(self); if (gameNote != std::nullopt) { @@ -174,7 +177,7 @@ namespace BeatLeaderModifiers { NoteController* self) { NoteControllerUpdate(self); - if (audioTimeSyncController && self->get_transform()) { + if (!UploadDisabledByReplay() && audioTimeSyncController && self->get_transform()) { if (noteMovementCache2.contains(self)) { noteMovementCache[self] = noteMovementCache2[self]; }