Skip to content

feat: 保持谱面流速不受播放速度影响#12

Merged
JoinChang merged 6 commits intoLxns-Network:mainfrom
saltcute:main
Mar 4, 2026
Merged

feat: 保持谱面流速不受播放速度影响#12
JoinChang merged 6 commits intoLxns-Network:mainfrom
saltcute:main

Conversation

@saltcute
Copy link
Contributor

提高慢放学习复杂谱面时的可读性。

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

该 PR 为谱面预览/练习增加“保持谱面流速不受播放速度影响”的开关,使在慢放学习时屏幕上的 Note 流动速度保持稳定,从而减少慢放导致的画面堆叠、提升可读性。

Changes:

  • 在渲染配置中新增 alwaysKeepHiSpeedplaybackSpeed,并在渲染器侧同步更新
  • BaseRenderer 的接近时间(approach time)在开启开关时按播放速度进行修正
  • 控制面板新增“保持谱面流速”开关,并接入 Zustand store

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/pages/public/Chart/types/index.ts 扩展 RendererConfig,为渲染侧传递开关与播放速度提供类型支持
src/pages/public/Chart/stores/useGameStore.ts 在游戏状态中加入 alwaysKeepHiSpeed 及其 setter,并提供默认值
src/pages/public/Chart/renderers/MainRenderer.ts 渲染器配置增加新字段,并提供 setter 同步到各子 renderer context
src/pages/public/Chart/renderers/BaseRenderer.ts 根据开关与播放速度调整 approach time 计算逻辑
src/pages/public/Chart/components/Controls/Controls.tsx UI 增加开关并绑定到 store
src/pages/public/Chart/components/ChartCanvas/ChartCanvas.tsx 将 store 中的新配置同步到 renderer,并在变更时触发重绘

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

saltcute and others added 2 commits March 3, 2026 12:39
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


protected getApproachTimeMs(): number {
if (this.context.config.alwaysKeepHiSpeed) {
return this.context.baseApproachTimeMs / (this.context.hiSpeed / this.context.config.playbackSpeed);
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

getApproachTimeMs uses a nested division (baseApproachTimeMs / (hiSpeed / playbackSpeed)). This is mathematically equivalent to (baseApproachTimeMs * playbackSpeed) / hiSpeed and can be rewritten to reduce operations and make the intent (scale approach window by playback speed) clearer.

Suggested change
return this.context.baseApproachTimeMs / (this.context.hiSpeed / this.context.config.playbackSpeed);
return (this.context.baseApproachTimeMs * this.context.config.playbackSpeed) / this.context.hiSpeed;

Copilot uses AI. Check for mistakes.
Comment on lines +175 to +178
if (playbackSpeed >= 0.1 && playbackSpeed <= 1.0) {
this.config.playbackSpeed = playbackSpeed;
this.updateRenderersContext();
}
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

setPlaybackSpeed silently ignores values outside [0.1, 1.0]. For a setter API this can be surprising (caller thinks the value applied when it didn’t). Consider clamping to the valid range (like the store does) or throwing/logging to make invalid inputs explicit.

Suggested change
if (playbackSpeed >= 0.1 && playbackSpeed <= 1.0) {
this.config.playbackSpeed = playbackSpeed;
this.updateRenderersContext();
}
if (playbackSpeed < 0.1 || playbackSpeed > 1.0) {
console.warn(
`MainRenderer.setPlaybackSpeed: playbackSpeed ${playbackSpeed} is out of range [0.1, 1.0]; ignoring value.`,
);
return;
}
this.config.playbackSpeed = playbackSpeed;
this.updateRenderersContext();

Copilot uses AI. Check for mistakes.
# Conflicts:
#	src/pages/public/Chart/components/ChartCanvas/ChartCanvas.tsx
#	src/pages/public/Chart/components/Controls/Controls.tsx
#	src/pages/public/Chart/stores/useGameStore.ts
@JoinChang JoinChang merged commit d7df5c9 into Lxns-Network:main Mar 4, 2026
1 check passed
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.

3 participants