Merge pull request #39 from LoveEevee/parsesong-drumroll-timing

Parsesong: Fix drumroll timing again
This commit is contained in:
Bui 2018-09-27 20:47:09 +01:00 committed by GitHub
commit d1efbf0109
2 changed files with 20 additions and 17 deletions

View File

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

View File

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