ParseSong: Separate events from notes

This commit is contained in:
LoveEevee 2020-03-15 18:00:23 +03:00
parent 0a578578c5
commit 38f1384f27
5 changed files with 46 additions and 33 deletions

View File

@ -147,8 +147,8 @@ class Debug{
return i === 0 || Math.abs(measure.ms - array[i - 1].ms) > 0.01
})
this.measureNumSlider.setMinMax(0, measures.length - 1)
if(this.measureNum && measures.length > this.measureNum){
var measureMS = measures[this.measureNum].ms
if(this.measureNum > 0 && measures.length >= this.measureNum){
var measureMS = measures[this.measureNum - 1].ms
var game = this.controller.game
game.started = true
var timestamp = Date.now()

View File

@ -5,6 +5,7 @@ class Game{
this.songData = songData
this.elapsedTime = 0
this.currentCircle = -1
this.currentEvent = 0
this.updateCurrentCircle()
this.combo = 0
this.rules = new GameRules(this)
@ -47,13 +48,7 @@ class Game{
}
initTiming(){
// Date when the chrono is started (before the game begins)
var firstCircle
for(var i = 0; i < this.songData.circles.length; i++){
firstCircle = this.songData.circles[i]
if(firstCircle.type !== "event"){
break
}
}
var firstCircle = this.songData.circles[0]
if(this.controller.calibrationMode){
var offsetTime = 0
}else{
@ -238,9 +233,6 @@ class Game{
}
}
skipNote(circle){
if(circle.type === "event"){
return
}
if(circle.section){
this.resetSection()
}
@ -258,9 +250,6 @@ class Game{
checkPlays(){
var circles = this.songData.circles
var circle = circles[this.currentCircle]
if(circle && circle.type === "event"){
this.updateCurrentCircle()
}
if(this.controller.autoPlayEnabled){
while(circle && this.controller.autoPlay(circle)){
@ -469,9 +458,7 @@ class Game{
}
getLastCircle(circles){
for(var i = circles.length; i--;){
if(circles[i].type !== "event"){
return circles[i]
}
return circles[i]
}
}
whenLastCirclePlayed(){
@ -623,7 +610,7 @@ class Game{
var circles = this.songData.circles
do{
var circle = circles[++this.currentCircle]
}while(circle && (circle.branch && !circle.branch.active || circle.type === "event"))
}while(circle && (circle.branch && !circle.branch.active))
}
getCurrentCircle(){
return this.currentCircle

View File

@ -48,6 +48,7 @@ class ParseOsu{
lastBeatInterval: 0,
bpm: 0
}
this.events = []
this.generalInfo = this.parseGeneralInfo()
this.metadata = this.parseMetadata()
this.editor = this.parseEditor()
@ -244,6 +245,18 @@ class ParseOsu{
var circles = []
var circleID = 0
var indexes = this.getStartEndIndexes("HitObjects")
var lastBeatMS = this.beatInfo.beatInterval
var lastGogo = false
var pushCircle = circle => {
circles.push(circle)
if(lastBeatMS !== circle.beatMS || lastGogo !== circle.gogoTime){
lastBeatMS = circle.beatMS
lastGogo = circle.gogoTime
this.events.push(circle)
}
}
for(var i = indexes.start; i <= indexes.end; i++){
circleID++
var values = this.data[i].split(",")
@ -277,7 +290,7 @@ class ParseOsu{
var endTime = parseInt(values[this.osu.ENDTIME])
var hitMultiplier = this.difficultyRange(this.difficulty.overallDifficulty, 3, 5, 7.5) * 1.65
var requiredHits = Math.floor(Math.max(1, (endTime - start) / 1000 * hitMultiplier))
circles.push(new Circle({
pushCircle(new Circle({
id: circleID,
start: start + this.offset,
type: "balloon",
@ -304,7 +317,7 @@ class ParseOsu{
type = "drumroll"
txt = strings.note.drumroll
}
circles.push(new Circle({
pushCircle(new Circle({
id: circleID,
start: start + this.offset,
type: type,
@ -339,7 +352,7 @@ class ParseOsu{
emptyValue = true
}
if(!emptyValue){
circles.push(new Circle({
pushCircle(new Circle({
id: circleID,
start: start + this.offset,
type: type,

View File

@ -43,6 +43,7 @@
this.metadata = this.parseMetadata()
this.measures = []
this.beatInfo = {}
this.events = []
if(!metaOnly){
this.circles = this.parseCircles()
}
@ -248,7 +249,12 @@
lastDrumroll = circleObj
}
circles.push(circleObj)
if(note.event){
this.events.push(circleObj)
}
if(note.type !== "event"){
circles.push(circleObj)
}
} else if (!(currentMeasure.length >= 24 && (!currentMeasure[i + 1] || currentMeasure[i + 1].type))
&& !(currentMeasure.length >= 48 && (!currentMeasure[i + 2] || currentMeasure[i + 2].type || !currentMeasure[i + 3] || currentMeasure[i + 3].type))) {
if (note_chain.length > 1 && currentMeasure.length >= 8) {
@ -266,9 +272,12 @@
}
}
var insertNote = circleObj => {
lastBpm = bpm
lastGogo = gogo
if(circleObj){
if(bpm !== lastBpm || gogo !== lastGogo){
circleObj.event = true
lastBpm = bpm
lastGogo = gogo
}
currentMeasure.push(circleObj)
}
}

View File

@ -1584,17 +1584,21 @@
// Start animation to gauge
circle.animate(ms)
}
if(ms - this.controller.audioLatency >= circle.ms && !circle.beatMSCopied && (!circle.branch || circle.branch.active)){
if(this.beatInterval !== circle.beatMS){
this.changeBeatInterval(circle.beatMS)
}
var game = this.controller.game
for(var i = 0; i < game.songData.events.length; i++){
var event = game.songData.events[i]
if(ms - this.controller.audioLatency >= event.ms && !event.beatMSCopied && (!event.branch || event.branch.active)){
if(this.beatInterval !== event.beatMS){
this.changeBeatInterval(event.beatMS)
}
circle.beatMSCopied = true
event.beatMSCopied = true
}
if(ms - this.controller.audioLatency >= circle.ms && !circle.gogoChecked && (!circle.branch || circle.branch.active)){
if(this.gogoTime != circle.gogoTime){
this.toggleGogoTime(circle)
if(ms - this.controller.audioLatency >= event.ms && !event.gogoChecked && (!event.branch || event.branch.active)){
if(this.gogoTime != event.gogoTime){
this.toggleGogoTime(event)
}
circle.gogoChecked = true
event.gogoChecked = true
}
}
}