|
162 | 162 | cursor: default; |
163 | 163 | pointer-events: auto; |
164 | 164 | border: 1px solid rgba(255, 200, 150, 0.10); |
| 165 | + transition: opacity 0.3s ease; |
| 166 | + } |
| 167 | + .volume-control.disabled { |
| 168 | + pointer-events: none; |
| 169 | + opacity: 0.35; |
165 | 170 | } |
166 | 171 | .volume-control label { |
167 | 172 | color: rgba(255, 210, 160, 0.6); |
|
180 | 185 | outline: none; |
181 | 186 | transition: background 0.2s; |
182 | 187 | } |
| 188 | + .volume-control input[type="range"]:disabled { |
| 189 | + opacity: 0.5; |
| 190 | + } |
183 | 191 | .volume-control input[type="range"]::-webkit-slider-thumb { |
184 | 192 | -webkit-appearance: none; |
185 | 193 | appearance: none; |
|
193 | 201 | .volume-control input[type="range"]::-webkit-slider-thumb:hover { |
194 | 202 | background: rgba(255, 210, 160, 0.9); |
195 | 203 | } |
| 204 | + .volume-control input[type="range"]:disabled::-webkit-slider-thumb { |
| 205 | + cursor: not-allowed; |
| 206 | + background: rgba(255, 210, 160, 0.3); |
| 207 | + } |
196 | 208 | .volume-control input[type="range"]::-moz-range-thumb { |
197 | 209 | width: 16px; |
198 | 210 | height: 16px; |
|
201 | 213 | background: rgba(255, 210, 160, 0.7); |
202 | 214 | cursor: pointer; |
203 | 215 | } |
| 216 | + .volume-control input[type="range"]:disabled::-moz-range-thumb { |
| 217 | + cursor: not-allowed; |
| 218 | + background: rgba(255, 210, 160, 0.3); |
| 219 | + } |
204 | 220 | .volume-control .vol-value { |
205 | 221 | color: rgba(255, 210, 160, 0.5); |
206 | 222 | font-size: 13px; |
|
261 | 277 | /* ============================================================ |
262 | 278 | * 拉伸Tap —— 四列音效 (sl.wav, boom.wav, sla.wav, a.wav) |
263 | 279 | * 自下至上升调 · 仿大狗Tap特效 + 背景音乐 |
264 | | - * 隐藏网格 · 背景音量可调(默认1/4)· 点击遮罩不触发播放 |
| 280 | + * 隐藏网格 · 背景音量可调(默认1/4) |
| 281 | + * 触发后等待节拍播放(量化队列) |
265 | 282 | * ============================================================ */ |
266 | 283 |
|
267 | 284 | // ---------- 常量 ---------- |
|
368 | 385 | master = ctx.createGain(); |
369 | 386 | master.gain.value = MASTER_GAIN; |
370 | 387 | bgmBus = ctx.createGain(); |
371 | | - bgmBus.gain.value = bgmVolume; // 使用用户设定的音量 |
| 388 | + bgmBus.gain.value = bgmVolume; |
372 | 389 | sfxBus = ctx.createGain(); |
373 | 390 | sfxBus.gain.value = 1; |
374 | 391 |
|
|
1265 | 1282 | cell.className = 'cell'; |
1266 | 1283 | cell.dataset.col = c; |
1267 | 1284 | cell.dataset.row = r; |
1268 | | - // 标签已隐藏(display: none) |
1269 | 1285 | gridEl.appendChild(cell); |
1270 | 1286 | cells.push(cell); |
1271 | 1287 | } |
|
1339 | 1355 | function setupVolumeSlider() { |
1340 | 1356 | const slider = document.getElementById('bgm-volume'); |
1341 | 1357 | const display = document.getElementById('vol-value'); |
| 1358 | + const control = document.getElementById('volume-control'); |
| 1359 | + |
1342 | 1360 | slider.addEventListener('input', () => { |
1343 | 1361 | const val = parseFloat(slider.value); |
1344 | 1362 | bgmVolume = val; |
|
1347 | 1365 | bgmBus.gain.setTargetAtTime(val, ctx.currentTime, 0.02); |
1348 | 1366 | } |
1349 | 1367 | }); |
1350 | | - // 阻止滑块事件冒泡到遮罩 |
1351 | | - const control = document.getElementById('volume-control'); |
| 1368 | + |
| 1369 | + // 阻止滑块事件冒泡到遮罩,避免误触发启动 |
1352 | 1370 | control.addEventListener('pointerdown', (e) => e.stopPropagation()); |
1353 | 1371 | control.addEventListener('pointerup', (e) => e.stopPropagation()); |
1354 | 1372 | control.addEventListener('click', (e) => e.stopPropagation()); |
|
1361 | 1379 | overlay.classList.add('hide'); |
1362 | 1380 | document.getElementById('hint').style.opacity = '0'; |
1363 | 1381 |
|
| 1382 | + // 禁用音量控件 |
| 1383 | + const slider = document.getElementById('bgm-volume'); |
| 1384 | + const control = document.getElementById('volume-control'); |
| 1385 | + slider.disabled = true; |
| 1386 | + control.classList.add('disabled'); |
| 1387 | + |
1364 | 1388 | initAudio(); |
1365 | 1389 | if (ctx.state === 'suspended') ctx.resume(); |
1366 | 1390 |
|
|
1399 | 1423 | // 点击遮罩只启动,不触发播放 |
1400 | 1424 | const overlay = document.getElementById('overlay'); |
1401 | 1425 | overlay.addEventListener('click', (e) => { |
1402 | | - // 如果点击的是音量控制区域,不启动 |
1403 | 1426 | if (e.target.closest('.volume-control')) return; |
1404 | 1427 | start(); |
1405 | 1428 | }); |
|
1417 | 1440 | if (!ctx) initAudio(); |
1418 | 1441 | }, { once: true }); |
1419 | 1442 |
|
1420 | | - console.log('拉伸Tap 已加载 (网格隐藏,背景音量可调)'); |
| 1443 | + console.log('拉伸Tap 已加载 (网格隐藏,背景音量可调,触发后量化播放)'); |
1421 | 1444 | } |
1422 | 1445 |
|
1423 | 1446 | if (document.readyState === 'loading') { |
|
0 commit comments