Browse Source

feat: 阶段评测,beatLength传参修改

TIANYONG 1 year ago
parent
commit
1cb86402d8
1 changed files with 12 additions and 2 deletions
  1. 12 2
      src/subpages/colexiu/buttons/evaluating.tsx

+ 12 - 2
src/subpages/colexiu/buttons/evaluating.tsx

@@ -26,6 +26,13 @@ import startingData from './data/starting.json'
 import { unitTestData } from '../unitTest'
 import iconEvaluatingStart from './icons/icon-evaluatingStart.png'
 
+/**
+ * 节拍器时长
+ * 评测模式时,应该传节拍器时长
+ * 阶段评测时,判断是否从第一小节开始,并且曲子本身含有节拍器,需要传节拍器时长,否则传0
+ */
+let actualBeatLength = 0
+
 let backtime = 0
 
 const initBehaviorId = '' + new Date().valueOf()
@@ -53,6 +60,8 @@ const formatPitch = (num?: number): number => {
 }
 let starTime = 0
 const formatTimes = () => {
+  const rate = runtime.speed / detailState.baseSpeed //1
+  actualBeatLength = Math.round(detailState.times[0].fixtime * 1000 / rate)
   const difftime = detailState.times?.[0]?.difftime || 0
   let ListenMode = false
   let dontEvaluatingMode = false
@@ -76,7 +85,8 @@ const formatTimes = () => {
       return index < startIndex
     })
     starTime = times[0].sourceRelativeTime || times[0].relativeTime
-    // console.log("🚀 ~ times", times)
+    actualBeatLength = startIndex == 0 && !detailState.needTick ? actualBeatLength : 0
+    // console.log("🚀 ~ times", times, '开始小节', startIndex, actualBeatLength)
   }
   // 找到阶段评测,开始小节前面最近的是play或者listen的小节
   if (preTimes.length) {
@@ -176,7 +186,7 @@ const connect = async () => {
     speed: runtime.speed,
     heardLevel: SettingState.eva.difficulty,
     // beatLength: Math.round((RuntimeUtils.getFixTime(detailState.times[0].beatSpeed) * 1000) / rate),
-    beatLength: Math.round(detailState.times[0].fixtime * 1000 / rate),
+    beatLength: actualBeatLength,
   }
   // console.log("🚀 ~ content:", content, rate)
   const clientType = useClientType()