mirror of
https://github.com/jiojciojsioe3/a3cjroijsiojiorj.git
synced 2024-11-15 15:31:51 +08:00
ParseSong: Separate events from notes
This commit is contained in:
parent
0a578578c5
commit
38f1384f27
@ -147,8 +147,8 @@ class Debug{
|
|||||||
return i === 0 || Math.abs(measure.ms - array[i - 1].ms) > 0.01
|
return i === 0 || Math.abs(measure.ms - array[i - 1].ms) > 0.01
|
||||||
})
|
})
|
||||||
this.measureNumSlider.setMinMax(0, measures.length - 1)
|
this.measureNumSlider.setMinMax(0, measures.length - 1)
|
||||||
if(this.measureNum && measures.length > this.measureNum){
|
if(this.measureNum > 0 && measures.length >= this.measureNum){
|
||||||
var measureMS = measures[this.measureNum].ms
|
var measureMS = measures[this.measureNum - 1].ms
|
||||||
var game = this.controller.game
|
var game = this.controller.game
|
||||||
game.started = true
|
game.started = true
|
||||||
var timestamp = Date.now()
|
var timestamp = Date.now()
|
||||||
|
@ -5,6 +5,7 @@ class Game{
|
|||||||
this.songData = songData
|
this.songData = songData
|
||||||
this.elapsedTime = 0
|
this.elapsedTime = 0
|
||||||
this.currentCircle = -1
|
this.currentCircle = -1
|
||||||
|
this.currentEvent = 0
|
||||||
this.updateCurrentCircle()
|
this.updateCurrentCircle()
|
||||||
this.combo = 0
|
this.combo = 0
|
||||||
this.rules = new GameRules(this)
|
this.rules = new GameRules(this)
|
||||||
@ -47,13 +48,7 @@ class Game{
|
|||||||
}
|
}
|
||||||
initTiming(){
|
initTiming(){
|
||||||
// Date when the chrono is started (before the game begins)
|
// Date when the chrono is started (before the game begins)
|
||||||
var firstCircle
|
var firstCircle = this.songData.circles[0]
|
||||||
for(var i = 0; i < this.songData.circles.length; i++){
|
|
||||||
firstCircle = this.songData.circles[i]
|
|
||||||
if(firstCircle.type !== "event"){
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(this.controller.calibrationMode){
|
if(this.controller.calibrationMode){
|
||||||
var offsetTime = 0
|
var offsetTime = 0
|
||||||
}else{
|
}else{
|
||||||
@ -238,9 +233,6 @@ class Game{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
skipNote(circle){
|
skipNote(circle){
|
||||||
if(circle.type === "event"){
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if(circle.section){
|
if(circle.section){
|
||||||
this.resetSection()
|
this.resetSection()
|
||||||
}
|
}
|
||||||
@ -258,9 +250,6 @@ class Game{
|
|||||||
checkPlays(){
|
checkPlays(){
|
||||||
var circles = this.songData.circles
|
var circles = this.songData.circles
|
||||||
var circle = circles[this.currentCircle]
|
var circle = circles[this.currentCircle]
|
||||||
if(circle && circle.type === "event"){
|
|
||||||
this.updateCurrentCircle()
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.controller.autoPlayEnabled){
|
if(this.controller.autoPlayEnabled){
|
||||||
while(circle && this.controller.autoPlay(circle)){
|
while(circle && this.controller.autoPlay(circle)){
|
||||||
@ -469,11 +458,9 @@ class Game{
|
|||||||
}
|
}
|
||||||
getLastCircle(circles){
|
getLastCircle(circles){
|
||||||
for(var i = circles.length; i--;){
|
for(var i = circles.length; i--;){
|
||||||
if(circles[i].type !== "event"){
|
|
||||||
return circles[i]
|
return circles[i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
whenLastCirclePlayed(){
|
whenLastCirclePlayed(){
|
||||||
var ms = this.elapsedTime
|
var ms = this.elapsedTime
|
||||||
if(!this.lastCircle){
|
if(!this.lastCircle){
|
||||||
@ -623,7 +610,7 @@ class Game{
|
|||||||
var circles = this.songData.circles
|
var circles = this.songData.circles
|
||||||
do{
|
do{
|
||||||
var circle = circles[++this.currentCircle]
|
var circle = circles[++this.currentCircle]
|
||||||
}while(circle && (circle.branch && !circle.branch.active || circle.type === "event"))
|
}while(circle && (circle.branch && !circle.branch.active))
|
||||||
}
|
}
|
||||||
getCurrentCircle(){
|
getCurrentCircle(){
|
||||||
return this.currentCircle
|
return this.currentCircle
|
||||||
|
@ -48,6 +48,7 @@ class ParseOsu{
|
|||||||
lastBeatInterval: 0,
|
lastBeatInterval: 0,
|
||||||
bpm: 0
|
bpm: 0
|
||||||
}
|
}
|
||||||
|
this.events = []
|
||||||
this.generalInfo = this.parseGeneralInfo()
|
this.generalInfo = this.parseGeneralInfo()
|
||||||
this.metadata = this.parseMetadata()
|
this.metadata = this.parseMetadata()
|
||||||
this.editor = this.parseEditor()
|
this.editor = this.parseEditor()
|
||||||
@ -244,6 +245,18 @@ class ParseOsu{
|
|||||||
var circles = []
|
var circles = []
|
||||||
var circleID = 0
|
var circleID = 0
|
||||||
var indexes = this.getStartEndIndexes("HitObjects")
|
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++){
|
for(var i = indexes.start; i <= indexes.end; i++){
|
||||||
circleID++
|
circleID++
|
||||||
var values = this.data[i].split(",")
|
var values = this.data[i].split(",")
|
||||||
@ -277,7 +290,7 @@ class ParseOsu{
|
|||||||
var endTime = parseInt(values[this.osu.ENDTIME])
|
var endTime = parseInt(values[this.osu.ENDTIME])
|
||||||
var hitMultiplier = this.difficultyRange(this.difficulty.overallDifficulty, 3, 5, 7.5) * 1.65
|
var hitMultiplier = this.difficultyRange(this.difficulty.overallDifficulty, 3, 5, 7.5) * 1.65
|
||||||
var requiredHits = Math.floor(Math.max(1, (endTime - start) / 1000 * hitMultiplier))
|
var requiredHits = Math.floor(Math.max(1, (endTime - start) / 1000 * hitMultiplier))
|
||||||
circles.push(new Circle({
|
pushCircle(new Circle({
|
||||||
id: circleID,
|
id: circleID,
|
||||||
start: start + this.offset,
|
start: start + this.offset,
|
||||||
type: "balloon",
|
type: "balloon",
|
||||||
@ -304,7 +317,7 @@ class ParseOsu{
|
|||||||
type = "drumroll"
|
type = "drumroll"
|
||||||
txt = strings.note.drumroll
|
txt = strings.note.drumroll
|
||||||
}
|
}
|
||||||
circles.push(new Circle({
|
pushCircle(new Circle({
|
||||||
id: circleID,
|
id: circleID,
|
||||||
start: start + this.offset,
|
start: start + this.offset,
|
||||||
type: type,
|
type: type,
|
||||||
@ -339,7 +352,7 @@ class ParseOsu{
|
|||||||
emptyValue = true
|
emptyValue = true
|
||||||
}
|
}
|
||||||
if(!emptyValue){
|
if(!emptyValue){
|
||||||
circles.push(new Circle({
|
pushCircle(new Circle({
|
||||||
id: circleID,
|
id: circleID,
|
||||||
start: start + this.offset,
|
start: start + this.offset,
|
||||||
type: type,
|
type: type,
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
this.metadata = this.parseMetadata()
|
this.metadata = this.parseMetadata()
|
||||||
this.measures = []
|
this.measures = []
|
||||||
this.beatInfo = {}
|
this.beatInfo = {}
|
||||||
|
this.events = []
|
||||||
if(!metaOnly){
|
if(!metaOnly){
|
||||||
this.circles = this.parseCircles()
|
this.circles = this.parseCircles()
|
||||||
}
|
}
|
||||||
@ -248,7 +249,12 @@
|
|||||||
lastDrumroll = circleObj
|
lastDrumroll = circleObj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(note.event){
|
||||||
|
this.events.push(circleObj)
|
||||||
|
}
|
||||||
|
if(note.type !== "event"){
|
||||||
circles.push(circleObj)
|
circles.push(circleObj)
|
||||||
|
}
|
||||||
} else if (!(currentMeasure.length >= 24 && (!currentMeasure[i + 1] || currentMeasure[i + 1].type))
|
} 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))) {
|
&& !(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) {
|
if (note_chain.length > 1 && currentMeasure.length >= 8) {
|
||||||
@ -266,9 +272,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var insertNote = circleObj => {
|
var insertNote = circleObj => {
|
||||||
|
if(circleObj){
|
||||||
|
if(bpm !== lastBpm || gogo !== lastGogo){
|
||||||
|
circleObj.event = true
|
||||||
lastBpm = bpm
|
lastBpm = bpm
|
||||||
lastGogo = gogo
|
lastGogo = gogo
|
||||||
if(circleObj){
|
}
|
||||||
currentMeasure.push(circleObj)
|
currentMeasure.push(circleObj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1584,17 +1584,21 @@
|
|||||||
// Start animation to gauge
|
// Start animation to gauge
|
||||||
circle.animate(ms)
|
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)
|
|
||||||
}
|
}
|
||||||
circle.beatMSCopied = true
|
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)
|
||||||
}
|
}
|
||||||
if(ms - this.controller.audioLatency >= circle.ms && !circle.gogoChecked && (!circle.branch || circle.branch.active)){
|
event.beatMSCopied = true
|
||||||
if(this.gogoTime != circle.gogoTime){
|
|
||||||
this.toggleGogoTime(circle)
|
|
||||||
}
|
}
|
||||||
circle.gogoChecked = true
|
if(ms - this.controller.audioLatency >= event.ms && !event.gogoChecked && (!event.branch || event.branch.active)){
|
||||||
|
if(this.gogoTime != event.gogoTime){
|
||||||
|
this.toggleGogoTime(event)
|
||||||
|
}
|
||||||
|
event.gogoChecked = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user