feat: Add configurable Answer Sound offset and player menu toggle#52
Merged
clansty merged 6 commits intoMuNET-OSS:mainfrom Sep 6, 2025
Merged
Conversation
审阅者指南通过添加新的配置条目并集中菜单注册、日志记录和播放计时中的偏移逻辑,引入了全局机器范围的应答声音偏移和一个可选的游戏内切换功能。 新应答声音偏移配置的实体关系图erDiagram
CONFIGURATION ||--o{ PLAYER : "has"
CONFIGURATION {
bool DisplayInGameConfig
float MoveValue_1P
float MoveValue_2P
}
PLAYER {
float userSettings
}
CONFIGURATION ||--o{ GAME_SETTINGS : "controls"
GAME_SETTINGS {
bool DisplayInGameConfig
}
更新的 MoveAnswerSound 配置和逻辑的类图classDiagram
class MoveAnswerSound {
+static bool DisplayInGameConfig
+static float MoveValue_1P
+static float MoveValue_2P
-static float[] userSettings
-static IPersistentStorage storage
+static float GetCabinSettingsValue(uint monitorIndex)
+static float GetSettingsValue(uint monitorIndex)
+static float GetSettingsValue(int monitorIndex)
+static void OnBeforePatch()
+int Sort
+string Name
+string Description
+void LoadSettings()
+void PreUpdateControl(GameObject ____NoteRoot, GameCtrl __instance)
}
MoveAnswerSound --> IPersistentStorage
MoveAnswerSound --> PlayerPrefsStorage
MoveAnswerSound --> GameSettingsManager
MoveAnswerSound --> UserDataManager
MoveAnswerSound --> MelonLogger
MoveAnswerSound --> NotesManager
MoveAnswerSound --> GameSingleCueCtrl
文件级更改
提示和命令与 Sourcery 互动
自定义您的体验访问您的 仪表板 以:
获取帮助Original review guide in EnglishReviewer's GuideIntroduces a global machine-wide answer sound offset and an optional in-game toggle by adding new config entries and centralizing offset logic across menu registration, logging, and playback timing. Entity relationship diagram for new answer sound offset configurationerDiagram
CONFIGURATION ||--o{ PLAYER : "has"
CONFIGURATION {
bool DisplayInGameConfig
float MoveValue_1P
float MoveValue_2P
}
PLAYER {
float userSettings
}
CONFIGURATION ||--o{ GAME_SETTINGS : "controls"
GAME_SETTINGS {
bool DisplayInGameConfig
}
Class diagram for updated MoveAnswerSound configuration and logicclassDiagram
class MoveAnswerSound {
+static bool DisplayInGameConfig
+static float MoveValue_1P
+static float MoveValue_2P
-static float[] userSettings
-static IPersistentStorage storage
+static float GetCabinSettingsValue(uint monitorIndex)
+static float GetSettingsValue(uint monitorIndex)
+static float GetSettingsValue(int monitorIndex)
+static void OnBeforePatch()
+int Sort
+string Name
+string Description
+void LoadSettings()
+void PreUpdateControl(GameObject ____NoteRoot, GameCtrl __instance)
}
MoveAnswerSound --> IPersistentStorage
MoveAnswerSound --> PlayerPrefsStorage
MoveAnswerSound --> GameSettingsManager
MoveAnswerSound --> UserDataManager
MoveAnswerSound --> MelonLogger
MoveAnswerSound --> NotesManager
MoveAnswerSound --> GameSingleCueCtrl
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
你好 - 我已审查了你的更改,它们看起来很棒!
AI 代理提示
请处理此代码审查中的评论:
## 独立评论
### 评论 1
<location> `AquaMai.Mods/Utils/MoveAnswerSound.cs:51` </location>
<code_context>
+ return DisplayInGameConfig ? userSettings[monitorIndex] + moveValue : moveValue;
+ }
+
+ private static float GetSettingsValue(int monitorIndex) => GetSettingsValue((uint)monitorIndex);
+
#region 设置界面注入
</code_context>
<issue_to_address>
将 int 转换为 uint 可能会掩盖负值。
将负的 monitorIndex 转换为 uint 可能会导致越界访问。在转换之前,请验证 monitorIndex 为非负数。
</issue_to_address>
### 评论 2
<location> `AquaMai.Mods/Utils/MoveAnswerSound.cs:34` </location>
<code_context>
+ [ConfigEntry(
+ en: "Answer sound move value in ms, this value will be combined with user's setting in game. Increase this value to make the answer sound appear later, vice versa.",
+ zh: "正解音偏移量,单位为毫秒,此设定值会与用户游戏内的设置相加。增大这个值将会使正解音出现得更晚,反之则更早。")]
+ private static readonly float MoveValue_1P = 33f;
+
+ [ConfigEntry(
</code_context>
<issue_to_address>
考虑将每个玩家的常量和逻辑整合到一个数组和方法中,以减少代码重复和分支。
以下是将每个玩家的常量和重载合并到一个数组+方法中,并统一日志记录到一个模板的一种方法。这保持了完全相同的行为,但分支/重复大大减少:
```csharp
// replace two fields + GetCabinSettingsValue + int-overload
private static readonly float[] CabinOffsets = { 33f, 33f };
// single entry point
private static float GetSettingsValue(int idx)
{
var cabin = CabinOffsets[idx];
var user = DisplayInGameConfig ? userSettings[idx] : 0f;
return cabin + user;
}
```
然后将你的双分支日志记录器替换为单行:
```csharp
for (uint i = 0; i < 2; i++)
{
// … load userSettings[i] as before …
MelonLogger.Msg(
$"玩家 {i} 的移动正解音设置为 {GetSettingsValue((int)i)} ms "
+ $"(游戏内: {userSettings[i]} ms, 机台: {CabinOffsets[i]} ms)"
+ (DisplayInGameConfig ? "" : ",游戏内设置已禁用"));
}
```
最后,在你的音符播放补丁中,只需调用 `GetSettingsValue(__instance.MonitorIndex)`,而不是重复减法逻辑。这消除了额外的重载、方法和分支,同时保留了所有功能。
</issue_to_address>帮助我更有用!请点击每个评论上的 👍 或 👎,我将使用这些反馈来改进你的评论。
Original comment in English
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `AquaMai.Mods/Utils/MoveAnswerSound.cs:51` </location>
<code_context>
+ return DisplayInGameConfig ? userSettings[monitorIndex] + moveValue : moveValue;
+ }
+
+ private static float GetSettingsValue(int monitorIndex) => GetSettingsValue((uint)monitorIndex);
+
#region 设置界面注入
</code_context>
<issue_to_address>
Casting int to uint may mask negative values.
Casting a negative monitorIndex to uint can lead to out-of-bounds access. Please validate monitorIndex is non-negative before casting.
</issue_to_address>
### Comment 2
<location> `AquaMai.Mods/Utils/MoveAnswerSound.cs:34` </location>
<code_context>
+ [ConfigEntry(
+ en: "Answer sound move value in ms, this value will be combined with user's setting in game. Increase this value to make the answer sound appear later, vice versa.",
+ zh: "正解音偏移量,单位为毫秒,此设定值会与用户游戏内的设置相加。增大这个值将会使正解音出现得更晚,反之则更早。")]
+ private static readonly float MoveValue_1P = 33f;
+
+ [ConfigEntry(
</code_context>
<issue_to_address>
Consider consolidating per-player constants and logic into a single array and method to reduce code duplication and branching.
Here’s one way to collapse the per-player constants and overloads into a single array + method, and unify your logging into one template. This keeps exactly the same behavior but with much less branching/duplication:
```csharp
// replace two fields + GetCabinSettingsValue + int-overload
private static readonly float[] CabinOffsets = { 33f, 33f };
// single entry point
private static float GetSettingsValue(int idx)
{
var cabin = CabinOffsets[idx];
var user = DisplayInGameConfig ? userSettings[idx] : 0f;
return cabin + user;
}
```
Then replace your two-branch logger with a single line:
```csharp
for (uint i = 0; i < 2; i++)
{
// … load userSettings[i] as before …
MelonLogger.Msg(
$"玩家 {i} 的移动正解音设置为 {GetSettingsValue((int)i)} ms "
+ $"(游戏内: {userSettings[i]} ms, 机台: {CabinOffsets[i]} ms)"
+ (DisplayInGameConfig ? "" : ",游戏内设置已禁用"));
}
```
Finally, in your note-playback patch just call `GetSettingsValue(__instance.MonitorIndex)` instead of duplicating the subtraction logic. This removes the extra overloads, methods, and branches while preserving all functionality.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…cs. We should respect its original design.
clansty
approved these changes
Sep 1, 2025
Contributor
Author
|
@clansty 牢大,能帮我 merge 一下吗?我没权限 |
Member
|
忘了,对不起 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
Previously, the Answer Sound offset adjustment could only be performed in-game by players. However, since answer offset issues are often a machine-wide problem rather than a player-specific one, this approach was inconvenient and repetitive.
Changes
New configuration option:
Added a global answer sound offset setting in the configuration file, allowing machine owners to directly adjust the Answer Sound offset for the entire machine.
Menu toggle:
Introduced a switch for the in-game configuration menu that lets the machine owner decide whether players are allowed to access and change the offset setting during gameplay.
Original summary in English
Summary by Sourcery
Introduce a global answer sound offset configuration with optional in-game adjustment and update the timing logic to combine machine-wide and per-user settings.
New Features:
Enhancements: