Conversation
There was a problem hiding this comment.
Pull request overview
该 PR 为谱面预览/练习增加“保持谱面流速不受播放速度影响”的开关,使在慢放学习时屏幕上的 Note 流动速度保持稳定,从而减少慢放导致的画面堆叠、提升可读性。
Changes:
- 在渲染配置中新增
alwaysKeepHiSpeed与playbackSpeed,并在渲染器侧同步更新 - 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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
| return this.context.baseApproachTimeMs / (this.context.hiSpeed / this.context.config.playbackSpeed); | |
| return (this.context.baseApproachTimeMs * this.context.config.playbackSpeed) / this.context.hiSpeed; |
| if (playbackSpeed >= 0.1 && playbackSpeed <= 1.0) { | ||
| this.config.playbackSpeed = playbackSpeed; | ||
| this.updateRenderersContext(); | ||
| } |
There was a problem hiding this comment.
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.
| 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(); |
# Conflicts: # src/pages/public/Chart/components/ChartCanvas/ChartCanvas.tsx # src/pages/public/Chart/components/Controls/Controls.tsx # src/pages/public/Chart/stores/useGameStore.ts
提高慢放学习复杂谱面时的可读性。