Skip to content

Commit cc2e7df

Browse files
author
3096
committed
feat: HeadphoneVolumeOverride
1 parent f670577 commit cc2e7df

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using HarmonyLib;
2+
3+
using AquaMai.Config.Attributes;
4+
using UnityEngine;
5+
6+
namespace AquaMai.Mods.GameSystem;
7+
8+
[ConfigSection(
9+
name: "耳机音量覆盖",
10+
en: "Override 1P/2P headphone volume to a fixed value, ignoring the user's in-game setting. Set to -1 to disable (use user setting). Range: 0–20.",
11+
zh: "将 1P/2P 耳机音量强制覆盖为固定值,忽略用户的游戏内设置。设为 -1 则禁用(使用用户设置)。范围:0–20。")]
12+
public static class HeadphoneVolumeOverride
13+
{
14+
[ConfigEntry(
15+
name: "1P 音量覆盖",
16+
en: "1P headphone volume override. -1 = use user setting, 0–20 = fixed volume (20 is max).",
17+
zh: "1P 耳机音量覆盖值。-1 = 使用用户设置,0–20 = 固定音量(20 为最大值)。")]
18+
private static readonly float p1 = -1f;
19+
20+
[ConfigEntry(
21+
name: "2P 音量覆盖",
22+
en: "2P headphone volume override. -1 = use user setting, 0–20 = fixed volume (20 is max).",
23+
zh: "2P 耳机音量覆盖值。-1 = 使用用户设置,0–20 = 固定音量(20 为最大值)。")]
24+
private static readonly float p2 = -1f;
25+
26+
[HarmonyPrefix]
27+
[HarmonyPatch(typeof(CriAtomExPlayer), "SetAisacControl", [typeof(uint), typeof(float)])]
28+
public static void PreSetAisacControl(uint controlId, ref float value)
29+
{
30+
if (controlId == 2 && p1 >= 0f)
31+
{
32+
value = Mathf.Clamp(p1 / 20f, 0f, 1f);
33+
}
34+
else if (controlId == 3 && p2 >= 0f)
35+
{
36+
value = Mathf.Clamp(p2 / 20f, 0f, 1f);
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)