Skip to content

Commit 22bce2d

Browse files
committed
Bring back advanced fps counter
1 parent a58c3a0 commit 22bce2d

5 files changed

Lines changed: 30 additions & 17 deletions

File tree

assets/SettingsView.bsml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<increment-setting id="shockwaveParticlesCountElement" text='Shockwave particles' value="shockwaveParticlesValue" bind-value="true" apply-on-change="true" increment="1" min="0" max="3" hover-hint="Max Shockwave Particles &lt;br> (distortions on impact)" on-change="UpdateGraphicsSettings" />
2121
<bool-setting id="burnMarksSetting" text='Burn marks' value="burnMarksValue" bind-value="true" apply-on-change="true" on-change="UpdateGraphicsSettings" hover-hint="Allows you to see cuts in the platform you stand on" />
2222
<bool-setting text='FPS Counter' value="FPSCounterValue" bind-value="true" apply-on-change="true" on-change="UpdateGraphicsSettings" hover-hint="Minimal FPS counter pinned next to the standing platform" />
23-
<!-- <bool-setting text='Advanced FPS Counter' value="FPSCounterAdvancedValue" bind-value="true" apply-on-change="true" on-change="UpdateGraphicsSettings" hover-hint="FPS counter with more information for debugging frame times. &lt;br> Not recommended to keep it on, as it can cause more crashes and could reduce your overall performance" /> -->
23+
<bool-setting text='Advanced FPS Counter' value="FPSCounterAdvancedValue" bind-value="true" apply-on-change="true" on-change="UpdateGraphicsSettings" hover-hint="FPS counter with more information for debugging frame times. &lt;br> Not recommended to keep it on, as it can cause more crashes and could reduce your overall performance" />
2424
<list-setting value="colorSpaceValue" bind-value="true" apply-on-change="true" text='Color Space' choices="colorSpaceOptions" on-change="UpdateGraphicsSettings" />
2525
<!-- <bool-setting id="screenDistortionSetting" text='Passthrough' value="screenDistortionValue" active="false" bind-value="true" apply-on-change="true" hover-hint="This feature requires patching BeatSaber with passthrough support" on-change="UpdateGraphicsSettings" /> -->
2626
</vertical>

include/GraphicsTweaksConfig.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ DECLARE_CONFIG(GraphicsTweaksConfig) {
1919
CONFIG_VALUE(FpsCounterAdvanced, bool, "FpsCounterAdvanced", false);
2020
CONFIG_VALUE(MenuFoveatedRenderingLevel, int, "MenuFoveatedRenderingLevel", 0);
2121
CONFIG_VALUE(InGameFoveatedRenderingLevel, int, "InGameFoveatedRenderingLevel", 4);
22-
CONFIG_VALUE(ColorSpace, int, "ColorSpace", 6);
22+
CONFIG_VALUE(ColorSpace, int, "ColorSpace", 6); // 0 = Unknown, 1 = Unmanaged, 2 = Rec_2020, 3 = Rec_709, 4 = Rift_CV1, 5 = Rift_S, 6 = Quest, 7 = P3, 8 = Adobe_RGB
2323
CONFIG_VALUE(CpuPerfLevel, int, "CpuPerfLevel", 1); // 0 = Low, 1 = SustainedLow, 2 = SustainedHigh
2424
CONFIG_VALUE(GpuPerfLevel, int, "GpuPerfLevel", 2); // 0 = Low, 1 = SustainedLow, 2 = SustainedHigh
2525
CONFIG_VALUE(Burnmarks, bool, "Burnmarks", false);

scripts/start-logging.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ $command = "adb logcat "
3838

3939
# if ($all -eq $false) {
4040
$loops = 0
41-
while ([string]::IsNullOrEmpty($bspid) -and $loops -lt 3) {
41+
while ([string]::IsNullOrEmpty($bspid) -and $loops -lt 6) {
4242
Start-Sleep -Milliseconds 100
4343
$bspid = adb shell pidof com.beatgames.beatsaber
4444
$loops += 1

src/main.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "GlobalNamespace/SettingsApplicatorSO.hpp"
4949
#include "BeatSaber/Settings/QualitySettings.hpp"
5050
#include "GraphicsTweaksConfig.hpp"
51+
#include "FPSCounter.hpp"
5152

5253
#include "UnityEngine/Graphics.hpp"
5354
#include "PlatformDetector.hpp"
@@ -434,6 +435,12 @@ MAKE_HOOK_MATCH(GameplayCoreInstaller_InstallBindings,
434435

435436
if (isInRender) {
436437
DEBUG("In render, skipping FPS counter installation");
438+
439+
// Disable the Advanced FPS counter if it's enabled
440+
auto counter = GraphicsTweaks::FPSCounter::counter;
441+
if (counter) {
442+
counter->SetActive(false);
443+
}
437444
return;
438445
}
439446

@@ -456,12 +463,18 @@ MAKE_HOOK_MATCH(MainFlowCoordinator_DidActivate,
456463
DEBUG("MainFlowCoordinator_DidActivate");
457464

458465
// Do not load the FPS counter if it's not needed
459-
// if (getGraphicsTweaksConfig().FpsCounterAdvanced.GetValue() &&
460-
// !GraphicsTweaks::FPSCounter::counter) {
461-
// // Load the FPS counter
462-
// self->StartCoroutine(custom_types::Helpers::CoroutineHelper::New(
463-
// GraphicsTweaks::FPSCounter::LoadBund()));
464-
// }
466+
if (getGraphicsTweaksConfig().FpsCounterAdvanced.GetValue() &&
467+
!GraphicsTweaks::FPSCounter::counter) {
468+
// Load the FPS counter
469+
self->StartCoroutine(custom_types::Helpers::CoroutineHelper::New(
470+
GraphicsTweaks::FPSCounter::LoadBund()));
471+
}
472+
473+
// If the FPS counter is loaded, set its active state
474+
if (GraphicsTweaks::FPSCounter::counter) {
475+
GraphicsTweaks::FPSCounter::counter->SetActive(
476+
getGraphicsTweaksConfig().FpsCounterAdvanced.GetValue());
477+
}
465478
}
466479

467480
// Called later on in the game loading - a good time to install function hooks

src/ui/SettingsView.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -507,14 +507,14 @@ void GraphicsTweaks::UI::SettingsView::set_FPSCounterAdvancedValue(bool value) {
507507
getGraphicsTweaksConfig().FpsCounterAdvanced.SetValue(value, instantlySave);
508508

509509
// Load the FPS counter if it's not loaded
510-
// if (value && !FPSCounter::counter) {
511-
// BSML::SharedCoroutineStarter::get_instance()->StartCoroutine(custom_types::Helpers::CoroutineHelper::New(FPSCounter::LoadBund()));
512-
// }
513-
514-
// // If the counter is not loaded, it will set the active state when it's loaded, otherwise set it now
515-
// if (FPSCounter::counter) {
516-
// FPSCounter::counter->SetActive(value);
517-
// }
510+
if (value && !FPSCounter::counter) {
511+
BSML::SharedCoroutineStarter::get_instance()->StartCoroutine(custom_types::Helpers::CoroutineHelper::New(FPSCounter::LoadBund()));
512+
}
513+
514+
// If the counter is not loaded, it will set the active state when it's loaded, otherwise set it now
515+
if (FPSCounter::counter) {
516+
FPSCounter::counter->SetActive(value);
517+
}
518518
}
519519

520520
// colorSpaceValue

0 commit comments

Comments
 (0)