Skip to content

Commit b076725

Browse files
committed
Disable fps counter in replays
1 parent afa6a5d commit b076725

5 files changed

Lines changed: 183 additions & 98 deletions

File tree

include/Utils.hpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#pragma once
2+
3+
namespace GraphicsTweaks {
4+
/**
5+
* @brief Checks if the application is currently in a rendering state.
6+
*
7+
* This function uses conditional dependencies to check if the game is in a
8+
* rendering state according to the Replay mod. It retrieves a function pointer
9+
* to the "IsInRender" function from the Replay mod and invokes it if
10+
* available.
11+
*
12+
* @return true if the application is in a replay state, false otherwise.
13+
*/
14+
bool IsInRender();
15+
/**
16+
* @brief Checks if the application is currently in a replay state.
17+
*
18+
* This function uses conditional dependencies to check if the game is in a
19+
* replay state according to the Replay mod. It retrieves a function pointer
20+
* to the "IsInReplay" function from the Replay mod and invokes it if
21+
* available.
22+
*
23+
* @return true if the application is in a replay state, false otherwise.
24+
*/
25+
bool IsInReplay();
26+
}

qpm.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@
9797
"id": "sombrero",
9898
"versionRange": "^0.1.43",
9999
"additionalData": {}
100+
},
101+
{
102+
"id": "conditional-dependencies",
103+
"versionRange": "^0.3.0",
104+
"additionalData": {}
100105
}
101106
]
102107
}

qpm.shared.json

Lines changed: 115 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -99,30 +99,15 @@
9999
"id": "sombrero",
100100
"versionRange": "^0.1.43",
101101
"additionalData": {}
102+
},
103+
{
104+
"id": "conditional-dependencies",
105+
"versionRange": "^0.3.0",
106+
"additionalData": {}
102107
}
103108
]
104109
},
105110
"restoredDependencies": [
106-
{
107-
"dependency": {
108-
"id": "custom-types",
109-
"versionRange": "=0.18.3",
110-
"additionalData": {
111-
"soLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.18.3/libcustom-types.so",
112-
"debugSoLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.18.3/debug_libcustom-types.so",
113-
"overrideSoName": "libcustom-types.so",
114-
"modLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.18.3/CustomTypes.qmod",
115-
"branchName": "version/v0_18_3",
116-
"compileOptions": {
117-
"cppFlags": [
118-
"-Wno-invalid-offsetof"
119-
]
120-
},
121-
"cmake": true
122-
}
123-
},
124-
"version": "0.18.3"
125-
},
126111
{
127112
"dependency": {
128113
"id": "sombrero",
@@ -158,25 +143,6 @@
158143
},
159144
"version": "4006.0.0"
160145
},
161-
{
162-
"dependency": {
163-
"id": "paper2_scotland2",
164-
"versionRange": "=4.6.4",
165-
"additionalData": {
166-
"soLink": "https://github.com/Fernthedev/paperlog/releases/download/v4.6.4/libpaper2_scotland2.so",
167-
"overrideSoName": "libpaper2_scotland2.so",
168-
"modLink": "https://github.com/Fernthedev/paperlog/releases/download/v4.6.4/paper2_scotland2.qmod",
169-
"branchName": "version/v4_6_4",
170-
"compileOptions": {
171-
"systemIncludes": [
172-
"shared/utfcpp/source"
173-
]
174-
},
175-
"cmake": false
176-
}
177-
},
178-
"version": "4.6.4"
179-
},
180146
{
181147
"dependency": {
182148
"id": "tinyxml2",
@@ -194,129 +160,180 @@
194160
},
195161
{
196162
"dependency": {
197-
"id": "rapidjson-macros",
198-
"versionRange": "=2.1.0",
163+
"id": "fmt",
164+
"versionRange": "=11.0.2",
199165
"additionalData": {
200166
"headersOnly": true,
201-
"branchName": "version/v2_1_0",
202-
"cmake": false
167+
"branchName": "version/v11_0_2",
168+
"compileOptions": {
169+
"systemIncludes": [
170+
"fmt/include/"
171+
],
172+
"cppFlags": [
173+
"-DFMT_HEADER_ONLY"
174+
]
175+
}
203176
}
204177
},
205-
"version": "2.1.0"
178+
"version": "11.0.2"
206179
},
207180
{
208181
"dependency": {
209-
"id": "config-utils",
210-
"versionRange": "=2.0.3",
182+
"id": "scotland2",
183+
"versionRange": "=0.1.6",
211184
"additionalData": {
212-
"headersOnly": true,
213-
"soLink": "https://github.com/darknight1050/config-utils/releases/download/v2.0.3/libconfig-utils_test.so",
214-
"overrideSoName": "libconfig-utils_test.so",
215-
"branchName": "version/v2_0_3",
216-
"cmake": true
185+
"soLink": "https://github.com/sc2ad/scotland2/releases/download/v0.1.6/libsl2.so",
186+
"debugSoLink": "https://github.com/sc2ad/scotland2/releases/download/v0.1.6/debug_libsl2.so",
187+
"overrideSoName": "libsl2.so",
188+
"branchName": "version/v0_1_6"
217189
}
218190
},
219-
"version": "2.0.3"
191+
"version": "0.1.6"
220192
},
221193
{
222194
"dependency": {
223-
"id": "fmt",
224-
"versionRange": "=11.0.2",
195+
"id": "libil2cpp",
196+
"versionRange": "=0.4.0",
225197
"additionalData": {
226198
"headersOnly": true,
227-
"branchName": "version/v11_0_2",
228199
"compileOptions": {
229200
"systemIncludes": [
230-
"fmt/include/"
231-
],
232-
"cppFlags": [
233-
"-DFMT_HEADER_ONLY"
201+
"il2cpp/external/baselib/Include",
202+
"il2cpp/external/baselib/Platforms/Android/Include"
234203
]
235204
}
236205
}
237206
},
238-
"version": "11.0.2"
207+
"version": "0.4.0"
239208
},
240209
{
241210
"dependency": {
242-
"id": "beatsaber-hook",
243-
"versionRange": "=6.4.2",
211+
"id": "kaleb",
212+
"versionRange": "=0.1.9",
244213
"additionalData": {
245-
"soLink": "https://github.com/QuestPackageManager/beatsaber-hook/releases/download/v6.4.2/libbeatsaber-hook.so",
246-
"debugSoLink": "https://github.com/QuestPackageManager/beatsaber-hook/releases/download/v6.4.2/debug_libbeatsaber-hook.so",
247-
"overrideSoName": "libbeatsaber-hook.so",
248-
"modLink": "https://github.com/QuestPackageManager/beatsaber-hook/releases/download/v6.4.2/beatsaber-hook.qmod",
249-
"branchName": "version/v6_4_2",
214+
"headersOnly": true,
215+
"branchName": "version/v0_1_9",
250216
"compileOptions": {
251217
"cppFlags": [
252-
"-Wno-extra-qualification"
218+
"-DKALEB_VERSION=\"0.1.9\""
253219
]
254220
},
255-
"cmake": true
221+
"cmake": false
256222
}
257223
},
258-
"version": "6.4.2"
224+
"version": "0.1.9"
259225
},
260226
{
261227
"dependency": {
262-
"id": "bsml",
263-
"versionRange": "=0.4.53",
228+
"id": "custom-types",
229+
"versionRange": "=0.18.3",
264230
"additionalData": {
265-
"soLink": "https://github.com/bsq-ports/Quest-BSML/releases/download/v0.4.53/libbsml.so",
266-
"debugSoLink": "https://github.com/bsq-ports/Quest-BSML/releases/download/v0.4.53/debug_libbsml.so",
267-
"overrideSoName": "libbsml.so",
268-
"modLink": "https://github.com/bsq-ports/Quest-BSML/releases/download/v0.4.53/BSML.qmod",
269-
"branchName": "version/v0_4_53",
231+
"soLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.18.3/libcustom-types.so",
232+
"debugSoLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.18.3/debug_libcustom-types.so",
233+
"overrideSoName": "libcustom-types.so",
234+
"modLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.18.3/CustomTypes.qmod",
235+
"branchName": "version/v0_18_3",
236+
"compileOptions": {
237+
"cppFlags": [
238+
"-Wno-invalid-offsetof"
239+
]
240+
},
270241
"cmake": true
271242
}
272243
},
273-
"version": "0.4.53"
244+
"version": "0.18.3"
274245
},
275246
{
276247
"dependency": {
277-
"id": "scotland2",
278-
"versionRange": "=0.1.6",
248+
"id": "rapidjson-macros",
249+
"versionRange": "=2.1.0",
279250
"additionalData": {
280-
"soLink": "https://github.com/sc2ad/scotland2/releases/download/v0.1.6/libsl2.so",
281-
"debugSoLink": "https://github.com/sc2ad/scotland2/releases/download/v0.1.6/debug_libsl2.so",
282-
"overrideSoName": "libsl2.so",
283-
"branchName": "version/v0_1_6"
251+
"headersOnly": true,
252+
"branchName": "version/v2_1_0",
253+
"cmake": false
284254
}
285255
},
286-
"version": "0.1.6"
256+
"version": "2.1.0"
287257
},
288258
{
289259
"dependency": {
290-
"id": "libil2cpp",
291-
"versionRange": "=0.4.0",
260+
"id": "paper2_scotland2",
261+
"versionRange": "=4.6.4",
292262
"additionalData": {
293-
"headersOnly": true,
263+
"soLink": "https://github.com/Fernthedev/paperlog/releases/download/v4.6.4/libpaper2_scotland2.so",
264+
"overrideSoName": "libpaper2_scotland2.so",
265+
"modLink": "https://github.com/Fernthedev/paperlog/releases/download/v4.6.4/paper2_scotland2.qmod",
266+
"branchName": "version/v4_6_4",
294267
"compileOptions": {
295268
"systemIncludes": [
296-
"il2cpp/external/baselib/Include",
297-
"il2cpp/external/baselib/Platforms/Android/Include"
269+
"shared/utfcpp/source"
298270
]
299-
}
271+
},
272+
"cmake": false
300273
}
301274
},
302-
"version": "0.4.0"
275+
"version": "4.6.4"
303276
},
304277
{
305278
"dependency": {
306-
"id": "kaleb",
307-
"versionRange": "=0.1.9",
279+
"id": "conditional-dependencies",
280+
"versionRange": "=0.3.0",
308281
"additionalData": {
309282
"headersOnly": true,
310-
"branchName": "version/v0_1_9",
283+
"branchName": "version/v0_3_0",
284+
"cmake": false
285+
}
286+
},
287+
"version": "0.3.0"
288+
},
289+
{
290+
"dependency": {
291+
"id": "config-utils",
292+
"versionRange": "=2.0.3",
293+
"additionalData": {
294+
"headersOnly": true,
295+
"soLink": "https://github.com/darknight1050/config-utils/releases/download/v2.0.3/libconfig-utils_test.so",
296+
"overrideSoName": "libconfig-utils_test.so",
297+
"branchName": "version/v2_0_3",
298+
"cmake": true
299+
}
300+
},
301+
"version": "2.0.3"
302+
},
303+
{
304+
"dependency": {
305+
"id": "beatsaber-hook",
306+
"versionRange": "=6.4.2",
307+
"additionalData": {
308+
"soLink": "https://github.com/QuestPackageManager/beatsaber-hook/releases/download/v6.4.2/libbeatsaber-hook.so",
309+
"debugSoLink": "https://github.com/QuestPackageManager/beatsaber-hook/releases/download/v6.4.2/debug_libbeatsaber-hook.so",
310+
"overrideSoName": "libbeatsaber-hook.so",
311+
"modLink": "https://github.com/QuestPackageManager/beatsaber-hook/releases/download/v6.4.2/beatsaber-hook.qmod",
312+
"branchName": "version/v6_4_2",
311313
"compileOptions": {
312314
"cppFlags": [
313-
"-DKALEB_VERSION=\"0.1.9\""
315+
"-Wno-extra-qualification"
314316
]
315317
},
316-
"cmake": false
318+
"cmake": true
317319
}
318320
},
319-
"version": "0.1.9"
321+
"version": "6.4.2"
322+
},
323+
{
324+
"dependency": {
325+
"id": "bsml",
326+
"versionRange": "=0.4.53",
327+
"additionalData": {
328+
"soLink": "https://github.com/bsq-ports/Quest-BSML/releases/download/v0.4.53/libbsml.so",
329+
"debugSoLink": "https://github.com/bsq-ports/Quest-BSML/releases/download/v0.4.53/debug_libbsml.so",
330+
"overrideSoName": "libbsml.so",
331+
"modLink": "https://github.com/bsq-ports/Quest-BSML/releases/download/v0.4.53/BSML.qmod",
332+
"branchName": "version/v0_4_53",
333+
"cmake": true
334+
}
335+
},
336+
"version": "0.4.53"
320337
}
321338
]
322339
}

src/Utils.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "Utils.hpp"
2+
#include <optional>
3+
#include "conditional-dependencies/shared/main.hpp"
4+
5+
6+
namespace GraphicsTweaks {
7+
bool IsInReplay() {
8+
static std::optional<bool (*)()> isInReplayFunc = CondDeps::Find<bool>("replay", "IsInReplay");
9+
10+
if (isInReplayFunc.has_value())
11+
{
12+
return isInReplayFunc.value()();
13+
}
14+
15+
return false;
16+
}
17+
18+
bool IsInRender() {
19+
static std::optional<bool (*)()> isInRenderFunc = CondDeps::Find<bool>("replay", "IsInRender");
20+
21+
if (isInRenderFunc.has_value())
22+
{
23+
return isInRenderFunc.value()();
24+
}
25+
26+
return false;
27+
}
28+
29+
}

src/main.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151

5252
#include "UnityEngine/Graphics.hpp"
5353
#include "PlatformDetector.hpp"
54+
#include "Utils.hpp"
5455

5556
inline modloader::ModInfo modInfo = {
5657
MOD_ID, VERSION, GIT_COMMIT}; // Stores the ID and version of our mod, and
@@ -534,6 +535,13 @@ MAKE_HOOK_MATCH(GameplayCoreInstaller_InstallBindings,
534535

535536
GameplayCoreInstaller_InstallBindings(self);
536537

538+
bool isInRender = GraphicsTweaks::IsInRender();
539+
540+
if (isInRender) {
541+
DEBUG("In render, skipping FPS counter installation");
542+
return;
543+
}
544+
537545
if (getGraphicsTweaksConfig().FpsCounter.GetValue()) {
538546
UnityW<FPSCounterUIController> fpsCounterUIController = Object::Instantiate(
539547
Resources::FindObjectsOfTypeAll<FPSCounterUIController *>()[0]);

0 commit comments

Comments
 (0)