Skip to content

[+] 高仿旧框下一曲目随机图片提示功能#111

Open
WUGqnwvMQPzl wants to merge 7 commits intoMuNET-OSS:mainfrom
WUGqnwvMQPzl:finale-next-track
Open

[+] 高仿旧框下一曲目随机图片提示功能#111
WUGqnwvMQPzl wants to merge 7 commits intoMuNET-OSS:mainfrom
WUGqnwvMQPzl:finale-next-track

Conversation

@WUGqnwvMQPzl
Copy link
Copy Markdown
Contributor

No description provided.

@gemini-code-assist
Copy link
Copy Markdown

Note

Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

@WUGqnwvMQPzl
Copy link
Copy Markdown
Contributor Author

fuck github.

@WUGqnwvMQPzl
Copy link
Copy Markdown
Contributor Author

come the fuck on wtf github?

@WUGqnwvMQPzl WUGqnwvMQPzl reopened this Jan 24, 2026
@gemini-code-assist
Copy link
Copy Markdown

你好 @WUGqnwvMQPzl,看起来你可能想使用 Gemini Code Assist 的某个命令。请注意,/gemini 需要后跟一个具体的命令才能执行操作。

你可以尝试以下命令:

  • /gemini review: 对当前拉取请求进行代码审查。
  • /gemini summary: 提供当前拉取请求的摘要。
  • @gemini-code-assist: 当被明确标记时,我会在评论中回复。

如果你想让我审查代码,请使用 /gemini review

@WUGqnwvMQPzl
Copy link
Copy Markdown
Contributor Author

@gemini-code-assist

@gemini-code-assist
Copy link
Copy Markdown

你好 @WUGqnwvMQPzl,你标记了我,但没有提供具体的命令。如果你想让我执行某个操作,请使用 /gemini <command>@gemini-code-assist <command> 的格式。

你可以尝试以下命令:

  • /gemini review: 对当前拉取请求进行代码审查。
  • /gemini summary: 提供当前拉取请求的摘要。

如果你想让我审查代码,请使用 /gemini review

@WUGqnwvMQPzl
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

这个 PR 增加了一个新功能,在下一首曲目开始前显示一张随机提示图片,以模仿旧版游戏的体验。实现方式是使用 Harmony 来 patch 游戏逻辑,这对于这类 mod 来说是合适的。代码整体结构良好,但在正确性、性能和可维护性方面有几个可以改进的地方。

发现的主要问题包括:

  • 随机数生成中存在一个 bug,导致其中一个语音提示永远不会被播放。
  • 存在性能问题,游戏资源在频繁调用的方法中被重复加载,而不是被缓存起来。
  • 针对两个不同游戏进程的 patch 之间存在大量重复代码。
  • 一些硬编码的数值和数组大小使得代码不够健壮,也更难维护。
  • 代码中存在不专业的注释,应该用更具说明性的注释代替。

我已经为以上每一点提供了具体的建议。解决这些问题将使代码更正确、性能更好、更易于维护。

Comment thread AquaMai.Mods/Fancy/NextTrackTips.cs
Comment thread AquaMai.Mods/Fancy/NextTrackTips.cs Outdated
Comment thread AquaMai.Mods/Fancy/NextTrackTips.cs Outdated
Comment thread AquaMai.Mods/Fancy/NextTrackTips.cs
Comment thread AquaMai.Mods/Fancy/NextTrackTips.cs Outdated
{
if (CheckNextTrackProcess(____mode) && !_timeCounterChanged)
{
____timeCounter = 5f;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

数值 5f 是一个“魔术数字”。它代表提示图片显示的时长。最好在类的顶部将其定义为一个命名的常量,以提高可读性并使其更易于修改。

建议在类顶部添加一个常量:
private const float TipDisplayDuration = 5f;
然后在这里使用它。

            ____timeCounter = TipDisplayDuration;

Comment thread AquaMai.Mods/Fancy/NextTrackTips.cs
[HarmonyPatch(typeof(KaleidxScopeFadeProcess), "OnStart")]
public static void KS_OnStart_Postfix(ProcessBase ___toProcess, List<KaleidxScopeFadeController> ___mainControllerList)
{
if (___toProcess.GetType() != typeof(MusicSelectProcess) || GameManager.MusicTrackNumber < 2) // WTF SBGA???
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

WTF SBGA??? 这样的注释是不专业的,对未来的维护者没有帮助。最好解释一下为什么这个检查是必要的。例如,描述这段代码是为了解决哪个特定的游戏行为或问题。这个问题在第 204 和 217 行也存在。

@WUGqnwvMQPzl
Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor
Copy link
Copy Markdown

cursor Bot commented Jan 24, 2026

Skipping Bugbot: Unable to authenticate your request. Please make sure Bugbot is properly installed and configured for this repository.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-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.

2 issues found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="AquaMai.Mods/Fancy/NextTrackTips.cs">

<violation number="1" location="AquaMai.Mods/Fancy/NextTrackTips.cs:197">
P2: The window-creation, sound-effect, and voice-line logic is duplicated almost verbatim between `OnStart_Postfix` and `KS_OnStart_Postfix`. This duplication has already caused a subtle divergence (the off-by-one in the final-track voice check). Consider extracting the shared per-player setup into a helper method.</violation>

<violation number="2" location="AquaMai.Mods/Fancy/NextTrackTips.cs:218">
P2: Inconsistent last-track voice condition: `OnStart_Postfix` uses `MusicTrackNumber + 1U == GetMaxTrackCount()` while this KaleidxScopeFade counterpart uses `MusicTrackNumber == GetMaxTrackCount()`. One of these conditions is off-by-one, causing the final-track voice cue to play at the wrong time in one of the two code paths.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

[EnableGameVersion(25000, noWarn: true)]
[HarmonyPostfix]
[HarmonyPatch(typeof(KaleidxScopeFadeProcess), "OnStart")]
public static void KS_OnStart_Postfix(ProcessBase ___toProcess, List<KaleidxScopeFadeController> ___mainControllerList)
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 4, 2026

Choose a reason for hiding this comment

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

P2: The window-creation, sound-effect, and voice-line logic is duplicated almost verbatim between OnStart_Postfix and KS_OnStart_Postfix. This duplication has already caused a subtle divergence (the off-by-one in the final-track voice check). Consider extracting the shared per-player setup into a helper method.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At AquaMai.Mods/Fancy/NextTrackTips.cs, line 197:

<comment>The window-creation, sound-effect, and voice-line logic is duplicated almost verbatim between `OnStart_Postfix` and `KS_OnStart_Postfix`. This duplication has already caused a subtle divergence (the off-by-one in the final-track voice check). Consider extracting the shared per-player setup into a helper method.</comment>

<file context>
@@ -0,0 +1,257 @@
+    [EnableGameVersion(25000, noWarn: true)]
+    [HarmonyPostfix]
+    [HarmonyPatch(typeof(KaleidxScopeFadeProcess), "OnStart")]
+    public static void KS_OnStart_Postfix(ProcessBase ___toProcess, List<KaleidxScopeFadeController> ___mainControllerList)
+    {
+        if (___toProcess.GetType() != typeof(MusicSelectProcess) || GameManager.MusicTrackNumber < 2)  // WTF SBGA???
</file context>
Fix with Cubic


Mai2.Voice_Partner_000001.Cue nextTrackVoice = UnityEngine.Random.Range(0, 2) == 0 ? Mai2.Voice_Partner_000001.Cue.VO_000151 : Mai2.Voice_Partner_000001.Cue.VO_000152;
// WTF SBGA??
if (GameManager.MusicTrackNumber == GameManager.GetMaxTrackCount())
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 4, 2026

Choose a reason for hiding this comment

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

P2: Inconsistent last-track voice condition: OnStart_Postfix uses MusicTrackNumber + 1U == GetMaxTrackCount() while this KaleidxScopeFade counterpart uses MusicTrackNumber == GetMaxTrackCount(). One of these conditions is off-by-one, causing the final-track voice cue to play at the wrong time in one of the two code paths.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At AquaMai.Mods/Fancy/NextTrackTips.cs, line 218:

<comment>Inconsistent last-track voice condition: `OnStart_Postfix` uses `MusicTrackNumber + 1U == GetMaxTrackCount()` while this KaleidxScopeFade counterpart uses `MusicTrackNumber == GetMaxTrackCount()`. One of these conditions is off-by-one, causing the final-track voice cue to play at the wrong time in one of the two code paths.</comment>

<file context>
@@ -0,0 +1,257 @@
+
+            Mai2.Voice_Partner_000001.Cue nextTrackVoice = UnityEngine.Random.Range(0, 2) == 0 ? Mai2.Voice_Partner_000001.Cue.VO_000151 : Mai2.Voice_Partner_000001.Cue.VO_000152;
+            // WTF SBGA??
+            if (GameManager.MusicTrackNumber == GameManager.GetMaxTrackCount())
+                nextTrackVoice = Mai2.Voice_Partner_000001.Cue.VO_000153;
+            SoundManager.PlayPartnerVoice(nextTrackVoice, i);
</file context>
Fix with Cubic

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ask SBGA


#region KaleidxScopeFadeProcess Patch
[EnableGameVersion(25000, noWarn: true)]
[EnableGameVersion(25000, 26499, noWarn: true)]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

据我所知,这里的内容大概会在这个类加载的时候被 jit 解析,让我验证一下这么写到底会不会有问题

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.

2 participants