Parsesong: Fix drumroll timing again

This commit is contained in:
LoveEevee 2018-09-27 21:39:25 +03:00
parent dc01102a72
commit 9cd4bca060
2 changed files with 20 additions and 17 deletions

View File

@ -1,6 +1,5 @@
class ParseSong{ class ParseSong{
constructor(fileContent){ constructor(fileContent){
this.data = fileContent
this.osu = { this.osu = {
OFFSET: 0, OFFSET: 0,
MSPERBEAT: 1, MSPERBEAT: 1,
@ -35,8 +34,16 @@ class ParseSong{
EDGEHITSOUNDS: 3, EDGEHITSOUNDS: 3,
EDGEADDITIONS: 4 EDGEADDITIONS: 4
} }
this.data = []
for(let line of fileContent){
line = line.trim().replace(/\/\/.*/, "")
if(line !== ""){
this.data.push(line)
}
}
this.beatInfo = { this.beatInfo = {
beatInterval: 0, beatInterval: 0,
lastBeatInterval: 0,
bpm: 0 bpm: 0
} }
this.generalInfo = this.parseGeneralInfo() this.generalInfo = this.parseGeneralInfo()
@ -53,7 +60,7 @@ class ParseSong{
end: 0 end: 0
} }
while(indexes.start < this.data.length){ while(indexes.start < this.data.length){
if(this.data[indexes.start].match(type)){ if(this.data[indexes.start] === "[" + type + "]"){
break break
} }
indexes.start++ indexes.start++
@ -61,7 +68,7 @@ class ParseSong{
indexes.start++ indexes.start++
indexes.end = indexes.start indexes.end = indexes.start
while(indexes.end < this.data.length){ while(indexes.end < this.data.length){
if(this.data[indexes.end].match(/^\s*$/)){ if(this.data[indexes.end].match(/^\[\w+\]$/)){
break break
} }
indexes.end++ indexes.end++
@ -122,8 +129,7 @@ class ParseSong{
start: start, start: start,
sliderMultiplier: sliderMultiplier, sliderMultiplier: sliderMultiplier,
measure: parseInt(values[this.osu.METER]), measure: parseInt(values[this.osu.METER]),
gogoTime: parseInt(values[this.osu.KIAIMODE]), gogoTime: parseInt(values[this.osu.KIAIMODE])
beatLength: msOrPercent
}) })
} }
return timingPoints return timingPoints
@ -235,13 +241,13 @@ class ParseSong{
var osuType = parseInt(values[this.osu.TYPE]) var osuType = parseInt(values[this.osu.TYPE])
var hitSound = parseInt(values[this.osu.HITSOUND]) var hitSound = parseInt(values[this.osu.HITSOUND])
var beatLength = speed var beatLength = speed
var lastMultiplier = this.difficulty.lastMultiplier
for(var j = 0; j < this.timingPoints.length; j++){ for(var j = 0; j < this.timingPoints.length; j++){
if(this.timingPoints[j].start > start){ if(this.timingPoints[j].start > start){
break break
} }
speed = this.timingPoints[j].sliderMultiplier speed = this.timingPoints[j].sliderMultiplier
beatLength = this.timingPoints[j].beatLength
gogoTime = this.timingPoints[j].gogoTime gogoTime = this.timingPoints[j].gogoTime
} }
@ -264,13 +270,10 @@ class ParseSong{
}else if(osuType & this.osu.SLIDER){ }else if(osuType & this.osu.SLIDER){
var extras = values.slice(this.osu.EXTRAS) var extras = values.slice(this.osu.EXTRAS)
var distance = parseFloat(extras[this.osu.PIXELLENGTH])
var speedMultiplier = beatLength < 0 ? 100.0 / -beatLength : 1 var distance = parseFloat(extras[this.osu.PIXELLENGTH])
var speedAdjustedBeatLength = this.beatInfo.beatInterval / speedMultiplier var velocity = this.difficulty.sliderMultiplier * speed / 10
var taikoVelocity = 100 * this.difficulty.sliderMultiplier / speedAdjustedBeatLength var endTime = start + distance / velocity
var taikoDuration = distance / taikoVelocity
var endTime = start + taikoDuration
if(hitSound & this.osu.FINISH){ if(hitSound & this.osu.FINISH){
type = "daiDrumroll" type = "daiDrumroll"

View File

@ -83,19 +83,19 @@ class SongSelect{
this.songs.push({ this.songs.push({
id: song.id, id: song.id,
title: song.title, title: song.title,
skin: this.songSkin[song.category || "default"], skin: song.category in this.songSkin ? this.songSkin[song.category] : this.songSkin.default,
stars: song.stars, stars: song.stars,
category: song.category, category: song.category,
preview: song.preview || 0 preview: song.preview || 0
}) })
} }
this.songs.sort((a, b) => { this.songs.sort((a, b) => {
var sortA = this.songSkin[a.category || "default"].sort var catA = a.category in this.songSkin ? this.songSkin[a.category] : this.songSkin.default
var sortB = this.songSkin[b.category || "default"].sort var catB = b.category in this.songSkin ? this.songSkin[b.category] : this.songSkin.default
if(sortA === sortB){ if(catA.sort === catB.sort){
return a.id > b.id ? 1 : -1 return a.id > b.id ? 1 : -1
}else{ }else{
return sortA > sortB ? 1 : -1 return catA.sort > catB.sort ? 1 : -1
} }
}) })
this.songs.push({ this.songs.push({