Fix weird sound on error and long lines not wrapping

This commit is contained in:
LoveEevee 2020-03-16 18:34:18 +03:00
parent 4b37150ee0
commit 8f736b5b23
2 changed files with 33 additions and 4 deletions

View File

@ -927,8 +927,22 @@
} }
} }
} }
var search = () => {
var end = line.length
var dist = end
while(dist){
dist >>= 1
line = words[i].slice(0, end)
lastWidth = ctx.measureText(line).width
end += lastWidth < config.width ? dist : -dist
}
if(line !== words[i]){
words.splice(i + 1, 0, words[i].slice(line.length))
words[i] = line
}
}
for(var i in words){ for(var i = 0; i < words.length; i++){
var skip = words[i].substitute || words[i] === "\n" var skip = words[i].substitute || words[i] === "\n"
if(!skip){ if(!skip){
var currentWidth = ctx.measureText(line + words[i]).width var currentWidth = ctx.measureText(line + words[i]).width
@ -960,8 +974,22 @@
recenter() recenter()
x = 0 x = 0
y += lineHeight y += lineHeight
line = words[i] === "\n" ? "" : words[i] if(words[i] === "\n"){
lastWidth = ctx.measureText(line).width line = ""
lastWidth = 0
}else{
line = words[i]
lastWidth = ctx.measureText(line).width
if(line.length !== 1 && lastWidth > config.width){
search()
}
}
}
}else if(!line){
line = words[i]
lastWidth = ctx.measureText(line).width
if(line.length !== 1 && lastWidth > config.width){
search()
} }
}else{ }else{
line += words[i] line += words[i]

View File

@ -1022,7 +1022,7 @@ class SongSelect{
} }
} }
if(screen === "song" && (this.showWarning || scoreStorage.scoreSaveFailed) && !p2.session){ if(screen === "song" && (this.showWarning && !this.showWarning.shown || scoreStorage.scoreSaveFailed)){
if(!this.showWarning){ if(!this.showWarning){
this.showWarning = {name: "scoreSaveFailed"} this.showWarning = {name: "scoreSaveFailed"}
} }
@ -1032,6 +1032,7 @@ class SongSelect{
if(this.showWarning.name === "scoreSaveFailed"){ if(this.showWarning.name === "scoreSaveFailed"){
scoreStorage.scoreSaveFailed = false scoreStorage.scoreSaveFailed = false
} }
this.showWarning.shown = true
this.state.showWarning = true this.state.showWarning = true
this.state.locked = true this.state.locked = true
this.playSound("se_pause") this.playSound("se_pause")