Skip to content

feat: Modify the volume of the music #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wuyu8512
Copy link

@wuyu8512 wuyu8512 commented May 27, 2025

好的,这是翻译成中文的 pull request 总结:

Sourcery 总结

添加了自定义音乐音量控制的支持,通过引入一个新的配置项并通过 Harmony 前缀补丁应用于音乐播放来实现。

新特性:

  • 引入 musicVolume 配置项以调整背景音乐音量。

增强功能:

  • 补丁 SoundManager.Play 以使用配置的 musicVolume 覆盖音乐提示音量。
Original summary in English

Summary by Sourcery

Add support for custom music volume control by introducing a new configuration entry and applying it via a Harmony prefix patch on music playback.

New Features:

  • Introduce a musicVolume config entry to adjust background music volume.

Enhancements:

  • Patch SoundManager.Play to override music cue volume using the configured musicVolume.

Copy link

sourcery-ai bot commented May 27, 2025

## 审查者指南

通过 ConfigEntry 引入可配置的 musicVolume 设置,并在 SoundManager.Play 上的 Harmony 前缀中应用它,以覆盖游戏内的音乐音量,同时进行次要的导入重排序。

#### 通过 Harmony Patch 调整音乐音量的序列图

```mermaid
sequenceDiagram
  participant EC as ExternalCaller
  participant P as Sound.PlayPrefix
  participant SM as SoundManager

  EC->>SM: Play(acbID=Music, playerID=Music, ..., volume)
  activate SM
  SM->>P: PlayPrefix(acbID, playerID, ..., ref volume)
  activate P
  alt acbID == SoundManager.AcbID.Music && playerID == SoundManager.PlayerID.Music
    P-->>P: volume = musicVolume (新配置的值)
  end
  P-->>SM: return (volume 参数已更新)
  deactivate P
  SM-->>SM: 原始 Play 方法执行,带有(可能)修改后的音量
  SM-->>EC: (音乐以新音量播放)
  deactivate SM

Sound 类的更新后的类图

classDiagram
  class Sound {
    -float musicVolume$
    +PlayPrefix(SoundManager.AcbID acbID, SoundManager.PlayerID playerID, int cueID, bool prepare, int target, int startTime, ref float volume) void$
  }
  note for Sound "Sound 类是静态的。"
Loading

文件级别更改

变更 详情 文件
重新排序 using 指令
  • using System 移动到项目导入下方
  • 删除多余的空白导入行
AquaMai.Mods/GameSystem/Sound.cs
添加 'musicVolume' 配置条目
  • 声明静态浮点数 musicVolume,默认值为 1.0
  • 使用 ConfigEntry 属性(英文/中文)注解字段
AquaMai.Mods/GameSystem/Sound.cs
实现 Harmony 前缀以强制执行音乐音量
  • 定义 PlayPrefix 方法,在 SoundManager.Play 上使用 [HarmonyPrefix][HarmonyPatch]
  • 在播放音乐时覆盖 volume 参数
AquaMai.Mods/GameSystem/Sound.cs

提示和命令

与 Sourcery 互动

  • 触发新的审查: 在 pull request 上评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub issue: 通过回复审查评论,要求 Sourcery 从该评论创建一个 issue。您也可以回复审查评论并使用 @sourcery-ai issue 从该评论创建一个 issue。
  • 生成 pull request 标题: 在 pull request 标题中的任何位置写入 @sourcery-ai 以随时生成标题。您也可以在 pull request 上评论 @sourcery-ai title 以随时(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文中的任何位置写入 @sourcery-ai summary 以随时在您想要的位置生成 PR 摘要。您也可以在 pull request 上评论 @sourcery-ai summary 以随时(重新)生成摘要。
  • 生成审查者指南: 在 pull request 上评论 @sourcery-ai guide 以随时(重新)生成审查者指南。
  • 解决所有 Sourcery 评论: 在 pull request 上评论 @sourcery-ai resolve 以解决所有 Sourcery 评论。如果您已经处理了所有评论并且不想再看到它们,这将非常有用。
  • 驳回所有 Sourcery 审查: 在 pull request 上评论 @sourcery-ai dismiss 以驳回所有现有的 Sourcery 审查。如果您想从新的审查开始,这将特别有用 - 不要忘记评论 @sourcery-ai review 以触发新的审查!

自定义您的体验

访问您的 仪表板 以:

  • 启用或禁用审查功能,例如 Sourcery 生成的 pull request 摘要、审查者指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查说明。
  • 调整其他审查设置。

获得帮助

```
Original review guide in English

Reviewer's Guide

Introduces a configurable musicVolume setting via ConfigEntry and applies it in a Harmony prefix on SoundManager.Play to override the in-game music volume, alongside a minor import reordering.

Sequence Diagram for Music Volume Adjustment via Harmony Patch

sequenceDiagram
  participant EC as ExternalCaller
  participant P as Sound.PlayPrefix
  participant SM as SoundManager

  EC->>SM: Play(acbID=Music, playerID=Music, ..., volume)
  activate SM
  SM->>P: PlayPrefix(acbID, playerID, ..., ref volume)
  activate P
  alt acbID == SoundManager.AcbID.Music && playerID == SoundManager.PlayerID.Music
    P-->>P: volume = musicVolume (newly configured value)
  end
  P-->>SM: return (volume parameter is updated)
  deactivate P
  SM-->>SM: Original Play method executes with (potentially) modified volume
  SM-->>EC: (Music plays with new volume)
  deactivate SM
Loading

Updated Class Diagram for the Sound Class

classDiagram
  class Sound {
    -float musicVolume$
    +PlayPrefix(SoundManager.AcbID acbID, SoundManager.PlayerID playerID, int cueID, bool prepare, int target, int startTime, ref float volume) void$
  }
  note for Sound "The Sound class is static."
Loading

File-Level Changes

Change Details Files
Reordered using directives
  • Moved using System below project imports
  • Removed redundant blank import line
AquaMai.Mods/GameSystem/Sound.cs
Added 'musicVolume' configuration entry
  • Declared static float musicVolume with default 1.0
  • Annotated field with ConfigEntry attribute (English/Chinese)
AquaMai.Mods/GameSystem/Sound.cs
Implemented Harmony prefix to enforce music volume
  • Defined PlayPrefix method with [HarmonyPrefix] and [HarmonyPatch] on SoundManager.Play
  • Overrode the volume argument when playing music
AquaMai.Mods/GameSystem/Sound.cs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wuyu8512 - 我已经查看了你的更改,它们看起来很棒!

以下是我在审查期间查看的内容
  • 🟡 一般问题:发现 1 个问题
  • 🟢 安全性:一切看起来都很好
  • 🟢 测试:一切看起来都很好
  • 🟢 复杂性:一切看起来都很好
  • 🟢 文档:一切看起来都很好

Sourcery 对开源是免费的 - 如果你喜欢我们的评论,请考虑分享它们✨
帮助我变得更有用!请点击每个评论上的👍或👎,我将使用反馈来改进你的评论。
Original comment in English

Hey @wuyu8512 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +78 to +83
{
if (acbID == SoundManager.AcbID.Music && playerID == SoundManager.PlayerID.Music)
{
volume = musicVolume;
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议: 覆盖音量可能会忽略游戏基础音量

考虑将当前音量按 musicVolume 缩放(例如,volume *= musicVolume),以保留其他音量调整。

Suggested change
{
if (acbID == SoundManager.AcbID.Music && playerID == SoundManager.PlayerID.Music)
{
volume = musicVolume;
}
}
{
if (acbID == SoundManager.AcbID.Music && playerID == SoundManager.PlayerID.Music)
{
volume *= musicVolume;
}
}
Original comment in English

suggestion: Override volume may ignore base game volume

Consider scaling the current volume by musicVolume (e.g., volume *= musicVolume) to preserve other volume adjustments.

Suggested change
{
if (acbID == SoundManager.AcbID.Music && playerID == SoundManager.PlayerID.Music)
{
volume = musicVolume;
}
}
{
if (acbID == SoundManager.AcbID.Music && playerID == SoundManager.PlayerID.Music)
{
volume *= musicVolume;
}
}

@wuyu8512
Copy link
Author

wuyu8512 commented Jul 5, 2025

@clansty 这个不考虑合一下吗,对我来说游戏的正解音即使调到最大还是嫌小,此PR可以让用户调整游戏BGM的音量大小,变相放大正解音

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant