Repository navigation
Feat/majview majsimai parser - #93
Merged
Merged
Conversation
Replace the hand-written simai parser with a JavaScript port of MajSimai, the C# interpreter MajdataPlay uses, so a chart reads in the browser the way it reads in the player. parseChart() mirrors SimaiParser.ParseChart in lenient mode: the scanner with its comments, BPM/beat/HS/SV declarations and time signature; note markers and flags; every duration form ([div:beats], [#seconds], [bpm#...], [wait##...]); same-head groups, fake each, touch sensors and the three rules that stop a parse in every mode. compileChart() adapts that model to the renderer: slide segments in chart time, star heads with the spin period of their slide, a chain length spread over the segments by bars, and Slide Code or an undrawable shape skipped with a warning instead of failing the chart. test/fixtures/simai records the model MajSimai 3.0.1 produces for 149 charts (valid ones and malformed ones); pnpm simai:golden re-records it with the .NET package and pnpm test compares the port against it field by field.
paths.json was recorded from an older set of slide prefabs: most shapes sat a few pixels away from where the game draws them, and Star_L_2..5 and Star_pq_7 were missing arrows. Read the current prefabs again (Assets/Prefabs/Game/Slides), composing every child transform with its parent and resolving the nested Just_* prefab for the arrow at the judgment line. - scripts/gen-majview-paths.mjs reads the prefabs and rewrites paths.json; pnpm majview:paths runs it (folder argument or MAJDATAPLAY_SLIDES) - test/majview/geometry.test.ts checks the generated data and resolves every slide mark with slideShape()
The chart f9db9452 uses <HS*-0.5>: a negative note speed scrolls the note backwards, from outside the judgment ring. displayIndex measured the lead with the signed speed, so from > to and the notes never entered the visible window: the section went blank (the first reverse section starts around combo 851). - measure the lead, the touch duration and the slide fade-in with the magnitude of the speed - draw lane notes and hold tails outside the ring, the way the game places them at _outerPos * (distance / 4.8) - add regression tests for a reverse tap, touch and hold
After the reverse-scroll fix the hold head was no longer clamped at the judgment ring, so every hold kept growing outward once its head had passed: the body ran outside the ring. HoldDrop.OnUpdate keeps the body between two distances (ring at 480px, notes appear from 122.5px): - the head stops at 480 once it has passed; - the tail stays at 122.5 until it reaches that radius, and the end point is shown only afterwards. holdSpan() now owns that math, the renderer only consumes it, and the four cases (including a reverse hold with a negative HS) are unit tested.
…p does HoldDrop sizes the sliced body with `distance - holdDistance + 1.4`, centers it at the midpoint and puts the end point at `0.6825 - size / 2`. With a negative HS that difference is negative, so the size is negative too: Unity draws the sprite flipped over |size|, which is shorter than the gap between the ends. The renderer measured `|distance - holdDistance| + 140` instead, so a reverse hold's body stretched past both ends. holdSpan() now returns the signed size, the renderer draws its magnitude, and the end point sits 1.75px inside the tail for either sign.
HoldDrop sizes the sliced body with `distance - holdDistance + 1.4`. A negative HS makes that size negative, and Unity renders a sprite with a negative size flipped on its vertical axis: the top border (the head cap) ends up at the inner end of the body. The renderer only drew |size|, so a reverse hold kept its caps in the normal order and looked like a short normal hold. Swap the caps and mirror the slices when the size is negative; the end point stays at `tail - 1.75px`, which is where HoldDrop puts it for either sign.
A hold with a negative HS is now drawn as if the HS were positive: holdSpan measures the distances with |speed|, so the body scrolls in from the center like any other hold, and the flip, cap swap and signed-size special cases for negative speeds are gone. MajdataPlay's IsEachNote counts only notes whose path is not a mine, marks a mine never as an each, and counts a star head once for its slide. MajSimai's IsEach counts mines too, so a plain slide next to a mine slide at the same timing point turned yellow (the each skin) instead of the normal one; compileChart now applies the game rule when it fills the `each` flags. The AYO WTF?! chart around combo 845 (two mine holds over a mine and a normal slide) renders like the game again.
laneNote measured the appear distance with the signed speed, so a hold with a negative HS started at scale 1 and outside the ring instead of growing from the center, while holdSpan already drew its body forwards. Holds now use |speed| for the distance and the appear scale too, so they fade in at the center like any other hold; taps keep the signed speed and still come from outside.
Port ChartAnalyzer from MajdataPlay: the chart is cut into 64 bars over the seek bar's range, a tap or hold adds one tap, a slide two (the star head adds nothing), a touch one, and every bar is normalized to the busiest one. The player draws the bars as stacked rounded rectangles on a canvas above the range input — tap pink, slide blue, touch orange, in the same order as the game (touch at the bottom, tap on top) — and redraws on resize. The analysis itself lives in src/majview/analyzer.js with unit tests for the counting, bucketing, start offset and normalization.
Draw each bar as a single capsule (radius = half the bar width) and clip the colored slices to it, instead of rounding every slice: the two ends stay semicircular whatever the slices are, and a boundary between two colors is a straight edge. Every slice overlaps the one below by half a pixel, so no background shows through the joint.
Port SimaiVisualizerControl from MajdataEdit-Neo: the current time sits in the middle as a red line with an orange caret, and a window of +-3 seconds rolls past it with the music waveform, one label per BPM change, the beat lines of every BPM section, one tick per comma timing point and one mark per note on its eight lanes. The waveform is coloured by Aurora's three-band mix (RGBMeter from schematicdnb/Aurora): 250Hz / 2kHz crossovers, low -3dB and high +4.5dB, then the band levels of each frame are normalized and the brightest channel is scaled to 255. The analysis runs in a worker at 24kHz so the page keeps its frame rate; the waveform stays plain green until the colours arrive and is drawn at 50% alpha so the note marks stay readable. compileChart now returns the comma timing points, shifted by &first, for the BPM labels and the comma ticks.
- majview 与 SongPage 的耦合度量、模块连线图 - 编辑器布局草案(对齐 MajdataEdit-Neo) - 交互规格 v1:字段映射、六条决策、与上游的差异
MajView 解耦: - 接收 chartUrl / trackUrl / videoUrl,不再自己拼接口地址,src/majview 里 不再有任何 @/ 应用依赖;preload 移到 components/song。 - 新增可选 chartText:给了就直接用内存文本,之后的每次变化只重编译并热换谱面, 不重载音频、不跳播放位置;编译失败保留上一版。 - 新增可选 onTime,把播放时间上报给页面。 编辑器(/editor): - 读取本地谱面文件夹(File System Access,回退 input[webkitdirectory])。 - 七个难度页签常驻,有未保存改动的档位显示 *。 - 难度 / 制谱人 / First 写回 &lv_N / &des_N / &first。 - Monaco 每个难度一个 model,切页签保留各自撤销栈;就地保存。 maidataEdit:字段级读写,其余内容(别的难度、CRLF、BOM)逐字节保留。 测试:maidataEdit 12 项、DifficultyTabs 3 项;全量 402 项通过。
- simaiMirror:只改位置相关字符(数字 1-8、slide 方向符号、触控区编号), 注释 / 拍号 / BPM / 时长括号原样通过。角度映射由 geometry.js 的 laneAngle 推导并验证:镜像两次、旋转八次都回到原样。 - 编辑菜单:水平/垂直/180° 镜像 + 旋转 ±45°,只在编辑器有选区时可用。 - 当前难度没有谱面时显示 MajdataView 默认底图,不再进错误态。 测试:simaiMirror 21 项;全量 423 项通过。
MajView 新增受控 settingsOpen / onSettingsOpenChange;不传时行为与之前完全一致 (song 页仍由播放器自己的齿轮控制),传了则由页面决定开关。
- ChartInfoWindow:改全局 title / artist,以及任意 &k=v(增删改)。 所有编辑作用在草稿文本上,确定才交回页面;谱面正文不在这里编辑。 - 自动保存:停止编辑 5s 落到 IndexedDB(键=文件夹名),每 30s 兜底; 打开文件夹时若草稿比文件新且内容不同,提示恢复上次编辑。 - 保存成功后清掉草稿;自动保存不改变「已保存/未保存」(决策 5)。 - useChartFolder 暴露 maidata.txt 的 lastModified,用于判断草稿新旧。 测试:listFields / shouldOfferRestore 7 项;全量 430 项通过。
- simaiTimeline:按 parseChart 的规则筛出音符格子(纯命令格子和空格子不计), 把每个格子的时间映射到它所在的文本行;注释按空格处理以保持行号对齐。 - 编辑器控制列加「文本跟随」开关;播放时把编辑器滚到当前格子所在行 (只在目标行不可见时滚动,避免抖动)。 测试:buildTimeline / lineAt 11 项,覆盖命令格子、空格子、注释、坏谱面; 全量 441 项通过。
编辑器里所有写死的中文都换成 t('editor/...'),新增 6 个命名空间:
editor/EditorPage、editor/ChartInfoWindow、editor/DifficultyTabs、
editor/EditorWindow、editor/BpmTapWindow、editor/useChartFolder。
四个语言包(en/zh/ja/ko)同步补齐并跑过 i18n:fix 规范化;
i18n:check 通过:69 个命名空间、652 条 key、四语一致。
验证:切到 en 时编辑器显示 Chart editor / Open folder / File·Edit·Settings,
切回 zh 显示 谱面编辑器 / 打开文件夹 / 文件·编辑·设置。
- MajView 新增 controlsHost:给了就用 portal 把控制条挂到页面指定节点, 逻辑和 ref 仍属于播放器;song 页不传,行为完全不变。 - 新增 showAnalysis(默认 false):音符密度条 + 时间轴只在编辑器显示, song 页的播放器只剩进度条和按钮;波形与 FFT 也跟着不跑了。 - 编辑器布局改成「左盘 / 右上:页签+元信息+编辑器 / 右下:控制条」。 验证:编辑器里 analyzer/visualizer/seek 都在 .editor-transport; song 页三者只有 seek,谱面仍正常加载(0/746)。
- MajView 新增 settingsHost:设置面板也用 portal 挂到页面指定节点, song 页不传,仍然画在播放器内部。 - MajViewSettings 新增 hideHeader:挂进外层浮窗时隐藏自己的标题和关闭按钮, 避免和浮窗头部重复。 - EditorWindow 用 ResizeObserver 跟随内容尺寸重新居中(portal 进来的面板 渲染后高度会变),用户拖过之后不再自动居中。 - 浮窗内容区限制高度并可滚动,长内容不会顶出视口。 验证:编辑器里设置面板在浮窗内、只有 1 个标题和 1 个关闭按钮、居中且高度 640 < 视口; 拖动标题栏后窗口按位移移动(533,61 → 633,111)。 song 页齿轮仍在播放器内部打开面板,谱面正常加载 0/746。
- 文件 → 新建:有未保存改动先确认;新建一份空谱面(没有落地文件,保存退化成下载)。 - 编辑 → 查找替换:项目只引了 monaco 的 editor.api(内核),查找控件要单独 import findController 才注册得上,所以 EditorPage chunk 从 12 KB 涨到 102 KB (gzip 26 KB,仍然只在 /editor 懒加载)。 - 时间轴 +/−:MajViewVisualizer 本来就吃 zoom,补两个按钮接到 MajView 的 timelineZoom(0.1–10,默认 4),只有 showAnalysis 时才渲染。 验证:新建后文件夹名显示「未命名谱面」、编辑器为空、预览走默认底图; 查找替换打开 Monaco find widget;点 + 后 visualizer canvas 内容变化。 song 页仍为 0/746 正常,且没有缩放按钮/分析条。
- simaiTimeline 新增 timeAtLine:一行里有多个音符时取该行第一个, 光标在末尾之后停在最后一个;和 lineAt 互为反函数(有测试)。 - MajView 新增 seekTo:编辑器把「光标所在行的时间」发过来,直接用现成的 seek() 跳过去(和评论的 jump 走同一条路)。 - SimaiCodeEditor 新增 onCursorLineChange,随 cursor selection 一起上报。 和上游一致:只有开着「文本跟随」时,移动光标才拖动播放位置。 - 控制条第二个按钮:showAnalysis 为真时先 pause 再回到开头(真·停止, 无障碍标签也换成「停止」);song 页仍然是原来的「从头播放」。 验证:编辑器里点第 28 行 → 时钟 0:00 → 0:36;造一个 WAV 当 track 播起来后 点停止 → 0:05 → 0:00 且按钮回到「播放」,1.2s 后仍未恢复。 song 页按钮仍是「从头播放」、播放中点击不暂停、0/746 正常。
页面级快捷键,拦掉浏览器的「保存网页」。不绑在 Monaco 上是因为这是页面动作。 变换快捷键仍不绑:Ctrl+J 被浏览器保留、其余与 Monaco 默认键位冲突。 顺带把 docs/analysis/editor-interaction-spec.md 的状态更新为「已实现」, 并在 §7 列出实现状态与唯一的偏离。
- MajView 新增 showControls(默认 true)。编辑器传 false,于是不再渲染 密度条 / 时间轴 / 进度条 / 倍速 / 全屏那一整条;控制条与它的 portal 解耦。 - MajView 新增 command(playPause / stop)和 onPlayingChange,编辑器用自己 的 ■ ▶ 按钮驱动播放,并按状态切换 ▶/⏸。 - 音符密度柱状图与时间轴暂时不渲染(showAnalysis 无调用方), prepareTrack 也因此不再算波形和 FFT。 - 圆盘变椭圆:.majview-scene 原来是 flex:1 + aspect-ratio:1,容器窄高时宽度被 max-width 夹住、高度却拉满。改成 .majview-stage 做尺寸容器,判定盘取 min(100cqw, 100cqh) 两边同值,任何窗口形状都是正圆。 验证:编辑器场景 622×622、song 页 469×469(stage 886×469),都是正方; 编辑器无控制条、无柱状图,只有「停止 / 播放」两个键; 播放 0:00 → 0:01 且按钮变「暂停」,停止后回 0:00 并变回「播放」。
把原来一个 showAnalysis 拆成三件事: - showControls:进度条 + 按钮那一条(编辑器关掉) - showTimeline:波形时间轴 + 缩放按钮(编辑器保留) - showAnalyzer:音符密度柱状图(哪里都不显示) 时间轴从控制条里独立成 timelineNode,编辑器用 timelineHost portal 挂到 右侧底部通栏;控制条关掉时它也照样渲染。 波形/FFT 的计算改由 showTimeline || showAnalyzer 触发。 验证:编辑器 .editor-timeline 里 128px 高的 visiualizer、带缩放按钮、 波形正常绘制;无控制条、无密度柱、只有「停止/播放」两个键。 song 页仍是 播放/从头播放/播放速度/设置/全屏,无时间轴无密度柱,0/746 正常。
1. 波形左右拖动:按住拖,按「2×zoom / 宽度」换算秒数,拖动时暂停并 seek; 同时把时间报给页面,页面把文本光标挪到对应行。 2. Ctrl/Cmd + 点击文本:时间跳到光标位置(页面用 timeAtLine 换算)。 顺手把 multiCursorModifier 设成 alt,并在点击后收起选区—— 否则 Monaco 会把 Ctrl+点击当成拖选,留下整段高亮。 3. 时间轴顶部的小黄三角改成跟随「文本光标」的时间,红线仍是播放头; 原先三角是画在中线上跟着播放头走的。 4. 「文本跟随」只做一件事:播放时把文本光标挪到当前行。 光标移动本身不再触发 seek(那是 Ctrl+点击的活)。 5. 编辑器闪烁光标看不见:simai 主题里 editorCursor 是全透明的(原本只读用), 在编辑器作用域内覆盖成青色。 6. 时间轴 +/− 方向反了:数字含义是「中线两侧各显示多少秒」, 所以 + 要减小它(放大内容),已交换。 验证:拖动 0:00→0:02 且光标随之下移;Ctrl+点击第 8 行 → 0:12 且无残留选区; 三角在光标与播放头分离时偏移 467px,重合时回到 0;+ 使同一时间差从 467 增到 533; 播放中开文本跟随,光标 top 30→48 且无选区。
1. 时间轴映射补上列号:Timeline 现在有 columns,位置按 (行, 列) 记录。 新增 positionAt(时间 → 行列)和 timeAtPosition(行列 → 时间), 拖动 / 文本跟随 / Ctrl+点击全部改用它,光标不再是「行首」而是那个音符本身。 timeAtLine 保留,语义等价于 timeAtPosition(line, 1)。 2. 拖动时间轴时编辑器会失焦,Monaco 把 .cursor 设成 visibility: hidden, 光标就看不见了。在编辑器作用域内强制 visible。 3. moveCaret 增加列号钳制(不超过 getLineMaxColumn),避免越界。 验证:拖动后时钟 0:00→0:03,光标 x 从 960(行首)变成 1067, 正好是该行第 3 个音符(第 14 列);拖动过程中 .cursor 的 visibility 一直是 visible。 单测新增 6 条列映射用例(含 positionAt/timeAtPosition 互逆)。
打开 / 新建 - 回到单次目录选择器(不再弹两次)。 - 打开:选文件夹 → 没有 maidata.txt 就报错。 - 新建:选文件夹 → 先查 track.ogg / track.mp3,没有就弹提示让用户重选; 再查 maidata.txt,已存在就提示「请用打开文件夹加载」,不覆盖; 都没有才创建空 maidata.txt 并载入。 - 打开 / 新建前都会先确认未保存改动;已有谱面时再点打开会重新弹选择器。 文本跟随 - 以前 onTime 按整秒节流,光标一秒才动一次,看起来明显滞后。 现在时钟仍按秒刷新,但跟随另外按「音符」去重:行列一变就更新, 3 秒里更新 7 次(180 BPM ≈ 3 音符/秒)。 视频 - 新增 preloadVideo:编辑器在谱面载入后立刻挂上 pv 并 preload="auto", 不再等到点播放。song 页不传,仍然 preload="none"、点播放才拉。 其它 - 拖动时间轴结束后把焦点还给文本编辑器。 - 没打开谱面时禁用「设置」。 - 空难度的页签文字压暗(is-empty)。 - 去掉中栏输入框的 placeholder。 - 有未保存改动时 beforeunload 拦截关闭 / 刷新。 - vite.config: 忽略 *.tmpdir/*.tmp,避免编辑器原子保存让 chokidar 撞上 EBUSY 把 dev server 打挂。 验证:空状态「设置」disabled=true;载入后 5 个空难度页签 rgba(.26)、MASTER 白色; 拖动后 focused=true;编辑器 video src 已挂 + preload=auto 且 paused; song 页 video 无 src、preload=none、0/746 正常。
原来只有一个 window.confirm「继续会丢弃改动?」,没有保存的选项。 现在换成应用内的三选一浮层: - 保存:先写文件,再执行原来的动作(打开 / 新建) - 不保存:直接丢弃并继续 - 取消:什么都不做(Esc 同样取消) requestAction 统一包住 open / createNew,没脏就直接执行,不弹窗。 验证:改脏后点打开,弹窗出现且 showDirectoryPicker 未被调用; 取消 → picker 1 次不变;保存 → 写入 1 次后 picker +1 且胶囊回到「已保存」; 不保存 → 不产生写入,picker 直接 +1。
三处问题,都是「新建后写谱 → view 报错」这条链上的:
1. setField 写空值字段时,值区间会被 trim 到下一行的字段开头,
于是新值落到下一行、把 `&inote_6=` 吞进值里。新建的空模板全是空字段,
所以第一次输入就把 maidata 写坏了。改为写在等号后面。
2. MajView 热更新的 `if (!chartRef.current) return` 是个死胡同:
首次编译失败(编辑器里刚敲了半句话)后 chartRef 恒为 null,
之后再怎么改文本都不会重试,永远停在错误态。现在能编译了就补一次完整加载。
3. 成功渲染之后再改错,热更新只是静默保留上一版,不给任何提示。
现在会报错:画面仍保留上一版,错误显示在文本编辑器底部。
错误提示通过 onTextError 上报给页面,由页面渲染在编辑器下方;
不传的调用方(song 页)仍显示在判定盘上方的浮层里。
验证(真实键盘输入):
- 打开 `(180){4},1,2,3,4,` → 0/4;
- 全选改成 `(` → 编辑器底部出现「谱面有误: The BPM declaration is not closed by ')'」,
预览仍是上一版 0/1;
- 补全成 `(180){4},1,2,3,4` → 提示消失,画面更新为 0/3。
- 首帧就失败(`(` 直接打开)→ 全屏「谱面加载失败」,补全后恢复正常。
以前 EditorPage 用 hasChart 把整个 MajView 挡掉,空难度只剩一张底图, 没法听歌对 BPM。 - MajView 新增 allowEmptyChart:难度字段为空时用一个没有音符的空谱面, 不再抛「This difficulty is empty」。clockTimes / chartStart / chartDuration 本来就能处理空 notes,所以播放、进度条、波形都照常。 - 编辑器不再用 hasChart 做挂载条件,改为始终挂播放器;"这个难度还没有谱面" 变成测试区底部的一条提示(pointer-events: none,不挡操作)。 - 另外修掉 editor.css 里被早前 PowerShell 批量替换搞坏的全部中文注释(乱码)。 验证:全空谱面打开后 MajView 正常挂载、无报错、时间轴画出了波形、 pv 已挂 src 且 preload=auto;点播放 0:00 → 0:02、按钮切成暂停,停止回 0:00。
- 空格:没在播就从当前位置开始播并记下起点;再按一下不是暂停,而是跳回起点并停下。
起点在时间轴底部用红色三角标出。
- Shift+空格:正常输入空格,不触发播放。
- 中栏新增两个开关:
· 显示判定区 —— 改用 MajdataView 的默认底图(带判定区文字),同时隐藏 pv;
按住 Ctrl 临时生效,松开恢复。
· 隐藏所有 note —— 渲染器跳过音符绘制(连击数/物量照常更新);
按住 Shift 临时生效,松开恢复。用 Shift 而不用 Alt,是因为 Alt 会把浏览器焦点
抢到菜单栏。
- Ctrl+方向键:不再被播放器当成逐帧步进(编辑器里的按键交给 Monaco),
改为按逗号跳格 —— 也就是跳到上一个/下一个音符,并让播放位置跟过去。
Monaco 在 EditContext 模式下收不到这个组合键,所以由我们直接改光标位置。
- First 下面新增播放速度下拉框(0.5×–2×),通过 rate 受控传给 MajView。
验证:空格 0:02→0:07 播放、再按回 0:02 且停止;红三角随起点位置移动(偏移 0 → +245px);
Shift+空格插入空格且不播放;显示判定区把 bg.png 换成 Default_Background.png 并移除 video,
Ctrl 按住时同样、松开恢复;隐藏 note 后画布内容变化、松开精确恢复;
Ctrl+→ 连按四次光标跨 4 个音符、时钟 0:00→0:01;2× 下 2 秒走 4 秒。
- Ctrl+空格 = 原来的播放 / 暂停(空格本身仍是「播放 / 回起点」)。
- Ctrl+左键之前不动:lastIndexOf(',', offset-1) 正好命中刚跳过的那个逗号,
target 等于当前 offset。改成从 offset-2 往前找。
- 按住 Ctrl / Shift 的临时效果挪到页面:checkbox 直接绑 judgeArea||holdCtrl、
hideNotes||holdShift,按住时勾选框会跟着勾上,松开取消。
- 播放速度下拉框移到所有 checkbox 上面(First 之后)。
- First 改成 onChange 也提交(滚轮 / 输入立刻生效),不再等失焦。
验证:Ctrl+空格 0:01 播放、再按停在 0:04 且 1.5 秒后仍 0:04(是真的暂停不是回起点);
Ctrl+←连按三次光标后退三格、时钟 0:04→0:03;按住 Ctrl 时「显示判定区」勾上、松开取消,
Shift 同理;控制列顺序为 时钟/难度/制谱人/First/播放速度/三个 checkbox;
First 输入 0.5 后胶囊立刻变「未保存」。
- MajView 不再自己处理键盘(空格/方向键/音量/长按快放全部移除), 手势也改由 gestures 属性控制(默认关)。 - 编辑器页:window 级快捷键,和控件焦点无关—— 空格 = 播放 / 回起点,Ctrl+空格 = 播放/暂停,Shift+空格 = 正常输入空格, Ctrl+左右 = 按逗号移动光标并跳转(从编辑器组件挪到页面,逻辑不变)。 播放器新增 playOrRewind 命令,页面通过 command 驱动。 - song 页:自己实现空格 = 播放/暂停(走 command),行为与以前一致。 - 设置面板里已经无作用的「禁用手势」开关去掉,对应文案一并删除。 验证:焦点在 body 上按空格,编辑器 0:00→0:02 开始播放、Ctrl+空格停在 0:05 且冻结; Ctrl+→ 在编辑器未聚焦时光标仍跳到第 10 列、时钟 0:05→0:00; song 页空格 0:00→0:06 播放、再按停在 0:11 不动; 拖判定盘 200px 时间不变(手势已关)。
上一轮把 MajView 的手势整个关掉,song 页也一起失去了拖盘调进度/音量/亮度。 现在 song 页显式传 gestures,设置面板里的「禁用手势」开关也加回来; 编辑器仍然不传(默认关),快捷键全部由页面接管。 验证:song 页拖判定盘 0:00 → 0:33;勾上「禁用手势」后再拖时间不变; .scene 的 touch-action 在手势开时是 none。
上一轮把 MajView 的键盘操作整个删掉,song 页也丢了逐帧步进、左右快进、 长按右箭头快放和上下键调音量。现在用 shortcuts 属性把这套只给 song 页打开: - MajView:新增 shortcuts(默认 false),里面是原来的键盘 effect 原样; 编辑器仍然不传,快捷键全部由页面接管。 - song 页:传 shortcuts,并去掉上一轮临时加的页面级空格处理(改回播放器内部)。 验证:song 页空格 0:03 开始播、右箭头 0:03 → 0:13(+0:05); 上箭头出现「总音量30%」提示且 localStorage 的 Master 跟着变。
原来顶点朝下(底边在 height-10、尖端落在 height),看起来是倒挂的。 改成底边贴住时间轴下沿、尖端朝上,和顶部光标三角(上宽下尖)对称。 验证:底部色带里红色像素宽度从顶部 1px 递增到底部 15px,即下宽上尖。
- 编辑器顶栏品牌文字 Majdata.Net → Majdata Edit(链接仍然回站点首页)。 - 菜单栏 BPM Tap 后面新增「快捷键」,点开是居中可拖动浮窗,列出九条: 空格、Ctrl+空格、Shift+空格、Ctrl+←/→、Ctrl+点击、Ctrl+S、Ctrl+O、 按住 Ctrl、按住 Shift,每条配 kbd 样式键帽和中文说明。
monaco 的 codicon.css 里写着「glyph 规则由平台主题服务运行时生成」, 所以我们只引 findController 时,图标 class 和 content 都在,但字体没加载, 按钮显示成空白方块。 - vite.config 加别名 monaco-codicon 指向 monaco 的 codicon 目录 (包里的 exports 映射会给 CSS 也补 .js 后缀,子路径引不进来)。 - SimaiCodeEditor 里引 codicon.css,Vite 会把 codicon.ttf 一起打包。 只影响编辑器 chunk。 验证:查找窗里 11 个 .codicon,font-family 为 codicon、fontLoaded=true, 替换开关 / Aa / ab_ / .* / 上下箭头 / 关闭图标都正常显示。
- 曲师下面新增一行「谱师」,读写的当前难度的 &des_{level+1}
(ChartInfoWindow 新增 level 属性,编辑器把 active 传进去)。
- 「其它字段」过滤掉 title / artist / first / first_N / lv_N / des_N 这些
有专门 UI 的结构化字段,只留用户自己加的字段(如 &clock_count)。
- 新增文案 editor/ChartInfoWindow.Designer(四语言)。
验证:打开带 &first / &lv_5 / &des_5 / &clock_count 的谱面,
窗口显示 曲名 InfoTest、曲师 SomeArtist、谱师 Charter Name,
其它字段里只剩 &clock_count。
上一版把谱面信息窗的谱师绑到了 &des_{level+1},和中栏的「制谱人」重复了。
按分工拆开:
- 谱面信息窗:谱师 = 全局 &des(去掉不再需要的 level 属性)
- 中栏「制谱人」:&des_{level+1}(不变)
- 「其它字段」把 des 也一并过滤,避免和谱师一栏重复
验证:谱面同时写 &des=GlobalCharter 与 &des_5=PerDiffCharter 时,
中栏制谱人显示 PerDiffCharter,谱面信息窗谱师显示 GlobalCharter。
时间轴上 tap/hold 是 LightPink、slide 天蓝、touch 深天蓝、break 橙红、 each 金色、BPM/节拍黄色;编辑器原来用的是另一套(tap 灰白、slide 粉、 touch 紫、break 混在 tap 里),两边对不上。 - monacoSimai 的主题规则改成同一套颜色:tap #FFB6C1、hold #FF9EC4、 slide #87CEEB、touch #00BFFF、break #FF4500、each #FFD700、bpm #FFFF00、 measure #FDE047,end/modifier 压成灰,注释保持灰斜体。 - simaiMonarch 新增两个 token:`/` 单独成 each(原来是 delimiter), `1b` 这类 break 单独成 break(原来被 tap 吞掉),测试同步更新。
- simaiMonarch 新增三条 break 滑动规则(顺序在普通 slide 之前): · b 在起点:8b-5 · b 在路径末尾:2bV47b / 1b-4b · b 在时长括号之后:6p3[8:5]b 再加一条单独的 b → break,兜住零散出现的 break 标记; 原来的 [bxfm$]+ 拆成 b(break)和 [xfm$]+(modifier)两条。 - 逗号和反引号的 delimiter 颜色从 #4B5563 提到 #8B98A8,暗底上更清楚。 验证:8b-5 / 6p3[8:5]b / 2bV47b / 1b-4b 都是 #FF4500, 1-2 仍是 #87CEEB,[8:1] 仍是青色,逗号是 #8B98A8。
拿 D:\_Game\maimai谱\contrast 复现:时间轴映射到的行和实际音符行对不上,
注释并不是原因(blankComments 保留换行,行号本身没错)。真正两个问题:
1. 反引号(假 each)会让一个格子产生多个 timing。parseChart 对 `` ` `` 拆段、
每段一个 timing,而 noteCellPositions 一个格子只给一个位置 —— 数量对不上时
buildTimeline 会退化成「按比例估算」,于是整张谱的位置全偏。
现在按同一规则拆段,一段一个位置。
2. 位置取的是格子开头,遇到 `{12}` / `(77)` 这种声明就先指向声明本身。
改成跳过前导空白和 (...) / {...} 之后,再指向音符正文的第一个非空白字符。
验证(真实谱面 339 个 timing / 339 个位置,行号不回退、无格子落在注释行):
#0 t=6.23 -> 5:1 「3h[12:3]/4-6[12:1]」 #1 -> 5:22
#2 -> 6:1 #3 -> 6:22 #8 -> 9:1 ...
新增 3 条回归用例:注释行不移位、反引号每段各有位置、声明不参与定位。
竖屏(手机 / 窄高窗口)原来还是左右两栏,判定盘和编辑器都被挤成细条, 而且早前有一条 max-width:900px 的规则直接把控制列 display:none 掉了。 现在按方向切换: - 竖屏(orientation: portrait 或宽度 ≤820px)改成上下四段: 菜单栏 / 判定盘(32vh,正方形居中) / 页签+编辑器 / 时间轴; 左侧控制列变成一条可横向滚动的工具条(时钟缩小、输入框定宽、播放键并排)。 - 矮横屏(高 ≤460px 且 landscape):时间轴压到 4rem、页签更紧凑, 给判定盘和编辑器腾高度。 - 浮窗 / 确认框加 max-width,避免超出窄屏。 - 删掉那条把控制列藏起来的 max-width:900px 旧规则。 验证:390×844 竖屏 → 判定盘 257×257 居中、控制条 390×52 可横向滚动、 编辑器 390×356、时间轴在底部,页面无横向溢出; 844×390 横屏 → 两栏、时间轴 133→69px、编辑器高度 186→256px; 1280×800 → 原来的两栏布局不变(控制列仍是纵列)。
上一版给 .editor-menubar 加了 overflow-x: auto 想让菜单项横向滚动, 但菜单栏只有一行高,下拉菜单是绝对定位在按钮下方的 —— 直接被裁掉, 看起来就是"点了没反应"。 - 去掉 overflow,改成 flex-wrap: wrap + row-gap(grid 第一行是 auto,会自动变高)。 - 收紧品牌字号和菜单项内边距,390px 宽下仍然是一行(高 31px)。 验证(390×844):overflow 为 visible,点「文件」后菜单 top=32 bottom=140 完整落在视口内,elementFromPoint 命中「新建」,三项都可见可点。
原来这一项跳的是外部文档 docs.majdata.net/majdatax/,现在改成站内路由 /editor(去掉 external),点进去就是刚做的编辑器,导航高亮也走 NavLink。 编辑器本身是 position: fixed; inset: 0,会盖住站点顶栏; 左上角「Majdata Edit」链回首页,所以进得去也出得来。 验证:首页顶栏展开「工具」→「谱面编辑」href=/editor, 点击后 SPA 跳到 /editor 且 .editor-app 渲染;品牌链接 href=/。
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.
本地谱面编辑器 + MajView 引擎重写
这个 PR 做了什么
三件事:
src/majview/simai.js是 MajSimai 3.0.1 的 JS 移植,滑条几何改为从 MajdataPlay 的 prefabs 生成;顺带修了负 HS 的 hold、星头、each 等渲染问题,并新增音符密度分析与波形时间轴。/editor:纯前端读写本地文件夹(File System Access API),不依赖账号、不上传任何文件。songId,改为接收chartUrl / trackUrl / videoUrl;编辑器与 song 页共用同一个播放器,各自按需开启功能。48 commits / 78 files / +8620 −277,无新增运行时依赖。
1. 谱面引擎
src/majview/simai.jssrc/majview/generated/paths.json(pnpm majview:paths从 MajdataPlay prefabs 生成)src/majview/analyzer.jssrc/majview/visualizer.js解析结果由
test/fixtures/simai/里 MajSimai 实机生成的 golden 数据逐项校验。2. 编辑器
/editormaidata.txt与track)、新建(要求目录里已有 track,且不覆盖已有 maidata)、保存(Ctrl+S)、IndexedDB 自动存草稿。*)、Monaco + simai 语法高亮、查找替换、镜像/旋转 5 种变换、谱面信息窗。Ctrl+空格= 播放/暂停,另有倍速下拉。Ctrl/Shift临时切换)、居中可拖动浮窗、快捷键说明窗。3. song 页
shortcuts开启)4. 站点
顶栏「工具 → 谱面编辑」改指站内
/editor;README 增加「谱面解析」一节。测试
461 passed / 59 files;
build/tsc/eslint/i18n(679 keys)全 0。编辑器交互均在浏览器实测(CDP 真实键盘 + 桩化showDirectoryPicker)。已知限制
Ctrl+J被浏览器「下载」占用)/editor的document.title仍是 "Majdata.Net"(站点级 Helmet 竞争,未处理)需要我补充 changelog、把截图内嵌进正文(GitHub 上要先把图传到仓库或用 raw 链接),或者改成分模块的多个 PR,都可以说。