2018-09-15 16:34:53 +02:00
|
|
|
class Scoresheet{
|
2018-11-02 11:26:46 +01:00
|
|
|
constructor(controller, results, multiplayer, touchEnabled){
|
2018-09-15 16:34:53 +02:00
|
|
|
this.controller = controller
|
2020-03-06 01:02:07 +01:00
|
|
|
this.resultsObj = results
|
2018-10-03 11:48:18 +02:00
|
|
|
this.results = {}
|
|
|
|
for(var i in results){
|
|
|
|
this.results[i] = results[i].toString()
|
|
|
|
}
|
2018-09-15 16:34:53 +02:00
|
|
|
this.multiplayer = multiplayer
|
2018-11-02 11:26:46 +01:00
|
|
|
this.touchEnabled = touchEnabled
|
2018-10-01 09:33:43 +02:00
|
|
|
|
|
|
|
this.canvas = document.getElementById("canvas")
|
|
|
|
this.ctx = this.canvas.getContext("2d")
|
2019-11-28 07:04:40 +01:00
|
|
|
var resolution = settings.getItem("resolution")
|
|
|
|
var noSmoothing = resolution === "low" || resolution === "lowest"
|
|
|
|
if(noSmoothing){
|
|
|
|
this.ctx.imageSmoothingEnabled = false
|
|
|
|
}
|
|
|
|
if(resolution === "lowest"){
|
|
|
|
this.canvas.style.imageRendering = "pixelated"
|
|
|
|
}
|
2019-01-01 02:16:55 +01:00
|
|
|
this.game = document.getElementById("game")
|
|
|
|
|
|
|
|
this.fadeScreen = document.createElement("div")
|
|
|
|
this.fadeScreen.id = "fade-screen"
|
|
|
|
this.game.appendChild(this.fadeScreen)
|
2018-10-01 09:33:43 +02:00
|
|
|
|
2019-01-21 16:47:22 +01:00
|
|
|
this.font = strings.font
|
2019-01-21 20:08:02 +01:00
|
|
|
this.numbersFont = "TnT, Meiryo, sans-serif"
|
2018-10-01 09:33:43 +02:00
|
|
|
this.state = {
|
|
|
|
screen: "fadeIn",
|
|
|
|
screenMS: this.getMS(),
|
2018-10-01 13:48:25 +02:00
|
|
|
startDelay: 3300,
|
2018-11-02 11:26:46 +01:00
|
|
|
hasPointer: 0,
|
|
|
|
scoreNext: false
|
2018-09-15 16:34:53 +02:00
|
|
|
}
|
2018-10-03 11:48:18 +02:00
|
|
|
this.frame = 1000 / 60
|
|
|
|
this.numbers = "001122334455667788900112233445".split("")
|
|
|
|
|
2019-11-28 07:04:40 +01:00
|
|
|
this.draw = new CanvasDraw(noSmoothing)
|
|
|
|
this.canvasCache = new CanvasCache(noSmoothing)
|
2020-03-13 03:34:54 +01:00
|
|
|
this.nameplateCache = new CanvasCache(noSmoothing)
|
2018-09-15 16:34:53 +02:00
|
|
|
|
2019-04-16 20:06:41 +02:00
|
|
|
this.keyboard = new Keyboard({
|
|
|
|
confirm: ["enter", "space", "esc", "don_l", "don_r"]
|
|
|
|
}, this.keyDown.bind(this))
|
2018-10-01 09:33:43 +02:00
|
|
|
this.gamepad = new Gamepad({
|
2019-04-05 21:53:51 +02:00
|
|
|
confirm: ["a", "b", "start", "ls", "rs"]
|
2019-04-16 20:06:41 +02:00
|
|
|
}, this.keyDown.bind(this))
|
2018-10-01 09:33:43 +02:00
|
|
|
|
2019-01-21 20:08:02 +01:00
|
|
|
this.difficulty = {
|
|
|
|
"easy": 0,
|
|
|
|
"normal": 1,
|
|
|
|
"hard": 2,
|
|
|
|
"oni": 3,
|
|
|
|
"ura": 4
|
|
|
|
}
|
|
|
|
|
2020-03-06 01:02:07 +01:00
|
|
|
this.scoreSaved = false
|
2018-10-01 09:33:43 +02:00
|
|
|
this.redrawRunning = true
|
|
|
|
this.redrawBind = this.redraw.bind(this)
|
|
|
|
this.redraw()
|
|
|
|
|
2019-02-04 10:14:42 +01:00
|
|
|
assets.sounds["v_results"].play()
|
2018-10-01 09:33:43 +02:00
|
|
|
assets.sounds["bgm_result"].playLoop(3, false, 0, 0.847, 17.689)
|
2018-11-01 23:05:18 +01:00
|
|
|
|
2020-03-09 13:36:57 +01:00
|
|
|
this.session = p2.session
|
|
|
|
if(this.session){
|
2018-11-01 23:05:18 +01:00
|
|
|
if(p2.getMessage("songsel")){
|
|
|
|
this.toSongsel(true)
|
|
|
|
}
|
|
|
|
pageEvents.add(p2, "message", response => {
|
2018-11-02 11:26:46 +01:00
|
|
|
if(response.type === "songsel"){
|
2018-11-01 23:05:18 +01:00
|
|
|
this.toSongsel(true)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
Custom scripting, #song=, translations
- A song can be linked directly by adding "#song=<id>" to the url, replace `<id>` with the id in the database, after loading it jumps immediately jumps to the difficulty selection
- Added tutorial translations
- Fixed song preview not playing
- Use text fallback for the logo when there are no vectors
- Increased combo cache by 1 pixel
- A custom javascript file can be loaded from config.json by defining "custom_js" value
- Added lots of events to help writing custom js files: `version-link, title-screen, language-change, song-select, song-select-move, song-select-difficulty, song-select-back, about, about-link, tutorial, import-songs, import-songs-default, session, session-start, session-end, debug, load-song, load-song-player2, load-song-unfocused, load-song-cancel, load-song-error, game-start, key-events, p2-game-end, p2-disconnected, p2-abandoned, pause, unpause, pause-restart, pause-song-select, game-lag, scoresheet, scoresheet-player2`
- Event syntax example:
```js
addEventListener("game-start", event => {
console.log("game-start", event.detail)
})
```
2019-02-14 10:32:45 +01:00
|
|
|
pageEvents.send("scoresheet", {
|
2019-02-14 23:10:34 +01:00
|
|
|
selectedSong: controller.selectedSong,
|
|
|
|
autoPlayEnabled: controller.autoPlayEnabled,
|
|
|
|
multiplayer: multiplayer,
|
|
|
|
touchEnabled: touchEnabled,
|
Custom scripting, #song=, translations
- A song can be linked directly by adding "#song=<id>" to the url, replace `<id>` with the id in the database, after loading it jumps immediately jumps to the difficulty selection
- Added tutorial translations
- Fixed song preview not playing
- Use text fallback for the logo when there are no vectors
- Increased combo cache by 1 pixel
- A custom javascript file can be loaded from config.json by defining "custom_js" value
- Added lots of events to help writing custom js files: `version-link, title-screen, language-change, song-select, song-select-move, song-select-difficulty, song-select-back, about, about-link, tutorial, import-songs, import-songs-default, session, session-start, session-end, debug, load-song, load-song-player2, load-song-unfocused, load-song-cancel, load-song-error, game-start, key-events, p2-game-end, p2-disconnected, p2-abandoned, pause, unpause, pause-restart, pause-song-select, game-lag, scoresheet, scoresheet-player2`
- Event syntax example:
```js
addEventListener("game-start", event => {
console.log("game-start", event.detail)
})
```
2019-02-14 10:32:45 +01:00
|
|
|
results: this.results,
|
2019-02-14 23:10:34 +01:00
|
|
|
p2results: multiplayer ? p2.results : null,
|
|
|
|
keyboardEvents: controller.keyboard.keyboardEvents,
|
|
|
|
gamepadEvents: controller.keyboard.gamepad.gamepadEvents,
|
|
|
|
touchEvents: controller.view.touchEvents
|
Custom scripting, #song=, translations
- A song can be linked directly by adding "#song=<id>" to the url, replace `<id>` with the id in the database, after loading it jumps immediately jumps to the difficulty selection
- Added tutorial translations
- Fixed song preview not playing
- Use text fallback for the logo when there are no vectors
- Increased combo cache by 1 pixel
- A custom javascript file can be loaded from config.json by defining "custom_js" value
- Added lots of events to help writing custom js files: `version-link, title-screen, language-change, song-select, song-select-move, song-select-difficulty, song-select-back, about, about-link, tutorial, import-songs, import-songs-default, session, session-start, session-end, debug, load-song, load-song-player2, load-song-unfocused, load-song-cancel, load-song-error, game-start, key-events, p2-game-end, p2-disconnected, p2-abandoned, pause, unpause, pause-restart, pause-song-select, game-lag, scoresheet, scoresheet-player2`
- Event syntax example:
```js
addEventListener("game-start", event => {
console.log("game-start", event.detail)
})
```
2019-02-14 10:32:45 +01:00
|
|
|
})
|
2015-07-17 10:22:46 +02:00
|
|
|
}
|
2019-04-16 20:06:41 +02:00
|
|
|
keyDown(pressed){
|
|
|
|
if(pressed && this.redrawing){
|
2018-10-01 09:33:43 +02:00
|
|
|
this.toNext()
|
|
|
|
}
|
2018-09-15 16:34:53 +02:00
|
|
|
}
|
2018-10-01 09:33:43 +02:00
|
|
|
mouseDown(event){
|
2018-10-05 19:03:59 +02:00
|
|
|
if(event.type === "touchstart"){
|
|
|
|
event.preventDefault()
|
|
|
|
this.canvas.style.cursor = ""
|
|
|
|
this.state.pointerLocked = true
|
2018-10-06 15:24:23 +02:00
|
|
|
}else{
|
|
|
|
this.state.pointerLocked = false
|
|
|
|
if(event.which !== 1){
|
|
|
|
return
|
|
|
|
}
|
2018-10-01 09:33:43 +02:00
|
|
|
}
|
|
|
|
this.toNext()
|
2018-09-15 16:34:53 +02:00
|
|
|
}
|
2018-10-01 09:33:43 +02:00
|
|
|
toNext(){
|
2018-11-01 23:05:18 +01:00
|
|
|
var elapsed = this.getMS() - this.state.screenMS
|
2018-10-03 11:48:18 +02:00
|
|
|
if(this.state.screen === "fadeIn" && elapsed >= this.state.startDelay){
|
2018-11-02 11:26:46 +01:00
|
|
|
this.toScoresShown()
|
2018-10-03 11:48:18 +02:00
|
|
|
}else if(this.state.screen === "scoresShown" && elapsed >= 1000){
|
2018-11-01 23:05:18 +01:00
|
|
|
this.toSongsel()
|
|
|
|
}
|
|
|
|
}
|
2018-11-02 11:26:46 +01:00
|
|
|
toScoresShown(){
|
|
|
|
if(!p2.session){
|
|
|
|
this.state.screen = "scoresShown"
|
|
|
|
this.state.screenMS = this.getMS()
|
2019-11-28 07:04:40 +01:00
|
|
|
this.controller.playSound("neiro_1_don", 0, true)
|
2018-11-01 23:05:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
toSongsel(fromP2){
|
2018-11-02 11:26:46 +01:00
|
|
|
if(!p2.session || fromP2){
|
2018-10-03 11:48:18 +02:00
|
|
|
snd.musicGain.fadeOut(0.5)
|
|
|
|
this.state.screen = "fadeOut"
|
2018-11-01 23:05:18 +01:00
|
|
|
this.state.screenMS = this.getMS()
|
2018-11-02 11:26:46 +01:00
|
|
|
if(!fromP2){
|
2019-11-28 07:04:40 +01:00
|
|
|
this.controller.playSound("neiro_1_don", 0, true)
|
2018-11-02 11:26:46 +01:00
|
|
|
}
|
2018-10-01 09:33:43 +02:00
|
|
|
}
|
2018-09-15 16:34:53 +02:00
|
|
|
}
|
2018-10-01 09:33:43 +02:00
|
|
|
|
|
|
|
startRedraw(){
|
|
|
|
this.redrawing = true
|
|
|
|
requestAnimationFrame(this.redrawBind)
|
|
|
|
this.winW = null
|
|
|
|
this.winH = null
|
2018-10-05 19:03:59 +02:00
|
|
|
|
2018-10-12 20:04:28 +02:00
|
|
|
pageEvents.add(this.canvas, ["mousedown", "touchstart"], this.mouseDown.bind(this))
|
2019-01-01 02:16:55 +01:00
|
|
|
|
|
|
|
if(!this.multiplayer){
|
|
|
|
this.tetsuoHana = document.createElement("div")
|
|
|
|
this.tetsuoHana.id = "tetsuohana"
|
|
|
|
var flowersBg = "url('" + assets.image["results_flowers"].src + "')"
|
|
|
|
var mikoshiBg = "url('" + assets.image["results_mikoshi"].src + "')"
|
2019-02-12 01:31:20 +01:00
|
|
|
var tetsuoHanaBg = "url('" + assets.image["results_tetsuohana" + (debugObj.state === "closed" ? "" : "2")].src + "')"
|
2019-01-01 02:16:55 +01:00
|
|
|
var id = ["flowers1", "flowers2", "mikoshi", "tetsuo", "hana"]
|
|
|
|
var bg = [flowersBg, flowersBg, mikoshiBg, tetsuoHanaBg, tetsuoHanaBg]
|
|
|
|
for(var i = 0; i < id.length; i++){
|
2019-01-01 05:45:13 +01:00
|
|
|
if(id[i] === "mikoshi"){
|
|
|
|
var divOut = document.createElement("div")
|
|
|
|
divOut.id = id[i] + "-out"
|
|
|
|
this.tetsuoHana.appendChild(divOut)
|
|
|
|
}else{
|
|
|
|
var divOut = this.tetsuoHana
|
|
|
|
}
|
2019-01-01 02:16:55 +01:00
|
|
|
var div = document.createElement("div")
|
|
|
|
div.id = id[i]
|
2019-01-01 05:45:13 +01:00
|
|
|
var divIn = document.createElement("div")
|
|
|
|
divIn.id = id[i] + "-in"
|
|
|
|
divIn.style.backgroundImage = bg[i]
|
|
|
|
div.appendChild(divIn)
|
|
|
|
divOut.appendChild(div)
|
2019-01-01 02:16:55 +01:00
|
|
|
}
|
|
|
|
this.game.appendChild(this.tetsuoHana)
|
|
|
|
}
|
2018-09-15 16:34:53 +02:00
|
|
|
}
|
2018-10-01 09:33:43 +02:00
|
|
|
|
|
|
|
redraw(){
|
|
|
|
if(!this.redrawRunning){
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if(this.redrawing){
|
|
|
|
requestAnimationFrame(this.redrawBind)
|
|
|
|
}
|
|
|
|
var ms = this.getMS()
|
|
|
|
|
|
|
|
if(!this.redrawRunning){
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var ctx = this.ctx
|
|
|
|
ctx.save()
|
|
|
|
|
|
|
|
var winW = innerWidth
|
2018-10-14 13:25:10 +02:00
|
|
|
var winH = lastHeight
|
2018-10-01 09:33:43 +02:00
|
|
|
this.pixelRatio = window.devicePixelRatio || 1
|
2019-04-04 23:21:08 +02:00
|
|
|
var resolution = settings.getItem("resolution")
|
|
|
|
if(resolution === "medium"){
|
|
|
|
this.pixelRatio *= 0.75
|
|
|
|
}else if(resolution === "low"){
|
|
|
|
this.pixelRatio *= 0.5
|
|
|
|
}else if(resolution === "lowest"){
|
|
|
|
this.pixelRatio *= 0.25
|
|
|
|
}
|
2018-10-01 09:33:43 +02:00
|
|
|
winW *= this.pixelRatio
|
|
|
|
winH *= this.pixelRatio
|
|
|
|
var ratioX = winW / 1280
|
|
|
|
var ratioY = winH / 720
|
|
|
|
var ratio = (ratioX < ratioY ? ratioX : ratioY)
|
|
|
|
|
|
|
|
if(this.redrawing){
|
|
|
|
if(this.winW !== winW || this.winH !== winH){
|
|
|
|
this.canvas.width = winW
|
|
|
|
this.canvas.height = winH
|
|
|
|
ctx.scale(ratio, ratio)
|
|
|
|
this.canvas.style.width = (winW / this.pixelRatio) + "px"
|
|
|
|
this.canvas.style.height = (winH / this.pixelRatio) + "px"
|
2018-10-09 15:07:53 +02:00
|
|
|
|
|
|
|
this.canvasCache.resize(winW / ratio, 80 + 1, ratio)
|
2020-03-13 03:34:54 +01:00
|
|
|
this.nameplateCache.resize(274, 134, ratio + 0.2)
|
2019-01-01 02:16:55 +01:00
|
|
|
|
|
|
|
if(!this.multiplayer){
|
2019-01-01 02:57:21 +01:00
|
|
|
this.tetsuoHana.style.setProperty("--scale", ratio / this.pixelRatio)
|
2019-01-01 16:00:00 +01:00
|
|
|
if(this.tetsuoHanaClass === "dance"){
|
|
|
|
this.tetsuoHana.classList.remove("dance", "dance2")
|
|
|
|
setTimeout(()=>{
|
|
|
|
this.tetsuoHana.classList.add("dance2")
|
|
|
|
},50)
|
|
|
|
}else if(this.tetsuoHanaClass === "failed"){
|
|
|
|
this.tetsuoHana.classList.remove("failed")
|
|
|
|
setTimeout(()=>{
|
|
|
|
this.tetsuoHana.classList.add("failed")
|
|
|
|
},50)
|
|
|
|
}
|
2019-01-01 02:16:55 +01:00
|
|
|
}
|
2018-10-03 11:48:18 +02:00
|
|
|
}else if(!document.hasFocus() && this.state.screen === "scoresShown"){
|
2018-10-01 09:33:43 +02:00
|
|
|
return
|
|
|
|
}else{
|
|
|
|
ctx.clearRect(0, 0, winW / ratio, winH / ratio)
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
ctx.scale(ratio, ratio)
|
2018-10-27 20:35:04 +02:00
|
|
|
if(!this.canvasCache.canvas){
|
|
|
|
this.canvasCache.resize(winW / ratio, 80 + 1, ratio)
|
|
|
|
}
|
2020-03-13 03:34:54 +01:00
|
|
|
if(!this.nameplateCache.canvas){
|
|
|
|
this.nameplateCache.resize(274, 67, ratio + 0.2)
|
|
|
|
}
|
2018-10-01 09:33:43 +02:00
|
|
|
}
|
|
|
|
this.winW = winW
|
|
|
|
this.winH = winH
|
|
|
|
this.ratio = ratio
|
|
|
|
winW /= ratio
|
|
|
|
winH /= ratio
|
|
|
|
|
|
|
|
var frameTop = winH / 2 - 720 / 2
|
|
|
|
var frameLeft = winW / 2 - 1280 / 2
|
2018-09-15 16:34:53 +02:00
|
|
|
|
2018-10-01 12:02:28 +02:00
|
|
|
var players = this.multiplayer && p2.results ? 2 : 1
|
2018-10-01 09:33:43 +02:00
|
|
|
var p2Offset = 298
|
|
|
|
|
|
|
|
var bgOffset = 0
|
|
|
|
var elapsed = ms - this.state.screenMS
|
|
|
|
if(this.state.screen === "fadeIn" && elapsed < 1000){
|
2018-10-01 13:48:25 +02:00
|
|
|
bgOffset = Math.min(1, this.draw.easeIn(1 - elapsed / 1000)) * (winH / 2)
|
2018-10-01 09:33:43 +02:00
|
|
|
}
|
2020-03-06 01:02:07 +01:00
|
|
|
if((this.state.screen !== "fadeIn" || elapsed >= 1000) && !this.scoreSaved){
|
|
|
|
this.saveScore()
|
|
|
|
}
|
2018-09-15 16:34:53 +02:00
|
|
|
|
2018-10-01 09:33:43 +02:00
|
|
|
if(bgOffset){
|
|
|
|
ctx.save()
|
|
|
|
ctx.translate(0, -bgOffset)
|
|
|
|
}
|
|
|
|
this.draw.pattern({
|
|
|
|
ctx: ctx,
|
|
|
|
img: assets.image["bg_score_p1"],
|
|
|
|
x: 0,
|
|
|
|
y: 0,
|
|
|
|
w: winW,
|
|
|
|
h: winH / 2,
|
|
|
|
dx: frameLeft - 35,
|
|
|
|
dy: frameTop + 17
|
2018-09-15 16:34:53 +02:00
|
|
|
})
|
2018-10-01 09:33:43 +02:00
|
|
|
ctx.fillStyle = "rgba(127, 28, 12, 0.5)"
|
|
|
|
ctx.fillRect(0, winH / 2 - 12, winW, 12)
|
2018-10-03 11:48:18 +02:00
|
|
|
ctx.fillStyle = "rgba(0, 0, 0, 0.25)"
|
|
|
|
ctx.fillRect(0, winH / 2, winW, 20)
|
|
|
|
if(bgOffset !== 0){
|
|
|
|
ctx.fillStyle = "#000"
|
|
|
|
ctx.fillRect(0, winH / 2 - 2, winW, 2)
|
|
|
|
}
|
2018-10-01 09:33:43 +02:00
|
|
|
ctx.fillStyle = "#fa4529"
|
|
|
|
ctx.fillRect(0, 0, winW, frameTop + 64)
|
|
|
|
ctx.fillStyle = "#bf2900"
|
|
|
|
ctx.fillRect(0, frameTop + 64, winW, 8)
|
|
|
|
|
|
|
|
if(bgOffset){
|
|
|
|
ctx.restore()
|
|
|
|
ctx.save()
|
|
|
|
ctx.translate(0, bgOffset)
|
|
|
|
}
|
|
|
|
|
|
|
|
this.draw.pattern({
|
|
|
|
ctx: ctx,
|
|
|
|
img: assets.image[this.multiplayer ? "bg_score_p2" : "bg_score_p1"],
|
|
|
|
x: 0,
|
|
|
|
y: winH / 2,
|
|
|
|
w: winW,
|
|
|
|
h: winH / 2,
|
|
|
|
dx: frameLeft - 35,
|
|
|
|
dy: frameTop - 17
|
2018-09-15 16:34:53 +02:00
|
|
|
})
|
2018-10-01 09:33:43 +02:00
|
|
|
ctx.fillStyle = this.multiplayer ? "rgba(138, 245, 247, 0.5)" : "rgba(249, 163, 149, 0.5)"
|
|
|
|
ctx.fillRect(0, winH / 2, winW, 12)
|
|
|
|
ctx.fillStyle = "#000"
|
2018-10-03 11:48:18 +02:00
|
|
|
if(bgOffset === 0){
|
|
|
|
ctx.fillRect(0, winH / 2 - 2, winW, 4)
|
|
|
|
}else{
|
|
|
|
ctx.fillRect(0, winH / 2, winW, 2)
|
|
|
|
}
|
2018-10-01 09:33:43 +02:00
|
|
|
ctx.fillStyle = this.multiplayer ? "#6bbec0" : "#fa4529"
|
|
|
|
ctx.fillRect(0, winH - frameTop - 64, winW, frameTop + 64)
|
|
|
|
ctx.fillStyle = this.multiplayer ? "rgba(160, 228, 229, 0.8)" : "rgba(255, 144, 116, 0.8)"
|
|
|
|
ctx.fillRect(0, winH - frameTop - 72, winW, 7)
|
|
|
|
ctx.fillStyle = this.multiplayer ? "#a8e0e0" : "#ff9b7a"
|
|
|
|
ctx.fillRect(0, winH - frameTop - 66, winW, 2)
|
|
|
|
|
|
|
|
if(bgOffset){
|
|
|
|
ctx.restore()
|
|
|
|
}
|
|
|
|
|
2018-10-03 11:48:18 +02:00
|
|
|
if(this.state.screen === "scoresShown" || this.state.screen === "fadeOut"){
|
|
|
|
var elapsed = Infinity
|
2019-01-01 02:16:55 +01:00
|
|
|
}else if(this.redrawing){
|
2018-10-01 09:33:43 +02:00
|
|
|
var elapsed = ms - this.state.screenMS - this.state.startDelay
|
2019-01-01 02:16:55 +01:00
|
|
|
}else{
|
|
|
|
var elapsed = 0
|
|
|
|
}
|
|
|
|
|
2020-03-09 13:36:57 +01:00
|
|
|
var rules = this.controller.game.rules
|
|
|
|
var gaugePercent = rules.gaugePercent(this.results.gauge)
|
|
|
|
var gaugeClear = [rules.gaugeClear]
|
2019-01-01 02:16:55 +01:00
|
|
|
if(players === 2){
|
2020-03-05 16:58:49 +01:00
|
|
|
gaugeClear.push(this.controller.syncWith.game.rules.gaugeClear)
|
|
|
|
}
|
|
|
|
var failedOffset = gaugePercent >= gaugeClear[0] ? 0 : -2000
|
|
|
|
if(players === 2){
|
2020-03-09 13:36:57 +01:00
|
|
|
var gauge2 = this.controller.syncWith.game.rules.gaugePercent(p2.results.gauge)
|
2020-03-05 16:58:49 +01:00
|
|
|
if(gauge2 > gaugePercent && failedOffset !== 0 && gauge2 >= gaugeClear[1]){
|
|
|
|
failedOffset = 0
|
2019-01-01 02:16:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(elapsed >= 3100 + failedOffset){
|
|
|
|
for(var p = 0; p < players; p++){
|
|
|
|
ctx.save()
|
|
|
|
var results = this.results
|
|
|
|
if(p === 1){
|
|
|
|
results = p2.results
|
|
|
|
}
|
2020-03-09 13:36:57 +01:00
|
|
|
var playerRules = p === 0 ? rules : this.controller.syncWith.game.rules
|
|
|
|
var resultGauge = playerRules.gaugePercent(results.gauge)
|
2020-03-05 16:58:49 +01:00
|
|
|
var clear = resultGauge >= gaugeClear[p]
|
2019-01-01 04:04:49 +01:00
|
|
|
if(p === 1 || !this.multiplayer && clear){
|
|
|
|
ctx.translate(0, 290)
|
|
|
|
}
|
2019-01-01 02:16:55 +01:00
|
|
|
if(clear){
|
|
|
|
ctx.globalCompositeOperation = "lighter"
|
|
|
|
}
|
|
|
|
ctx.globalAlpha = Math.min(1, Math.max(0, (elapsed - (3100 + failedOffset)) / 500)) * 0.5
|
2019-01-01 04:04:49 +01:00
|
|
|
var grd = ctx.createLinearGradient(0, frameTop + 72, 0, frameTop + 368)
|
2019-01-01 02:16:55 +01:00
|
|
|
grd.addColorStop(0, "#000")
|
|
|
|
if(clear){
|
|
|
|
grd.addColorStop(1, "#ffffba")
|
|
|
|
}else{
|
|
|
|
grd.addColorStop(1, "transparent")
|
|
|
|
}
|
|
|
|
ctx.fillStyle = grd
|
2019-01-01 04:04:49 +01:00
|
|
|
ctx.fillRect(0, frameTop + 72, winW, 286)
|
2019-01-01 02:16:55 +01:00
|
|
|
ctx.restore()
|
|
|
|
}
|
2018-10-01 09:33:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(elapsed >= 0){
|
2018-10-01 13:48:25 +02:00
|
|
|
if(this.state.hasPointer === 0){
|
|
|
|
this.state.hasPointer = 1
|
2020-03-09 13:36:57 +01:00
|
|
|
if(!this.state.pointerLocked){
|
|
|
|
this.canvas.style.cursor = this.session ? "" : "pointer"
|
2018-10-05 19:03:59 +02:00
|
|
|
}
|
2018-10-01 13:48:25 +02:00
|
|
|
}
|
2018-10-01 09:33:43 +02:00
|
|
|
ctx.save()
|
|
|
|
ctx.setTransform(1, 0, 0, 1, 0, 0)
|
|
|
|
this.draw.alpha(Math.min(1, elapsed / 400), ctx, ctx => {
|
|
|
|
ctx.scale(ratio, ratio)
|
|
|
|
ctx.translate(frameLeft, frameTop)
|
|
|
|
|
2018-10-09 15:07:53 +02:00
|
|
|
this.canvasCache.get({
|
2018-10-01 09:33:43 +02:00
|
|
|
ctx: ctx,
|
2018-10-09 15:07:53 +02:00
|
|
|
x: 0,
|
|
|
|
y: 0,
|
|
|
|
w: winW,
|
|
|
|
h: 80,
|
|
|
|
id: "results"
|
|
|
|
}, ctx => {
|
|
|
|
this.draw.layeredText({
|
|
|
|
ctx: ctx,
|
2019-01-05 08:44:28 +01:00
|
|
|
text: strings.results,
|
2018-10-09 15:07:53 +02:00
|
|
|
fontSize: 48,
|
|
|
|
fontFamily: this.font,
|
|
|
|
x: 23,
|
|
|
|
y: 15,
|
2019-01-22 19:47:09 +01:00
|
|
|
letterSpacing: strings.id === "en" ? 0 : 3,
|
2018-10-09 15:07:53 +02:00
|
|
|
forceShadow: true
|
|
|
|
}, [
|
|
|
|
{x: -2, y: -2, outline: "#000", letterBorder: 22},
|
|
|
|
{},
|
|
|
|
{x: 2, y: 2, shadow: [2, 2, 7]},
|
|
|
|
{x: 2, y: 2, outline: "#ad1516", letterBorder: 10},
|
|
|
|
{x: -2, y: -2, outline: "#ff797b"},
|
|
|
|
{outline: "#f70808"},
|
|
|
|
{fill: "#fff", shadow: [-1, 1, 3, 1.5]}
|
|
|
|
])
|
|
|
|
|
|
|
|
this.draw.layeredText({
|
|
|
|
ctx: ctx,
|
|
|
|
text: this.results.title,
|
|
|
|
fontSize: 40,
|
|
|
|
fontFamily: this.font,
|
|
|
|
x: 1257,
|
|
|
|
y: 20,
|
2019-01-26 19:29:13 +01:00
|
|
|
width: 600,
|
2018-10-09 15:07:53 +02:00
|
|
|
align: "right",
|
|
|
|
forceShadow: true
|
|
|
|
}, [
|
|
|
|
{outline: "#000", letterBorder: 10, shadow: [1, 1, 3]},
|
|
|
|
{fill: "#fff"}
|
|
|
|
])
|
|
|
|
})
|
2018-10-01 09:33:43 +02:00
|
|
|
|
|
|
|
ctx.save()
|
|
|
|
for(var p = 0; p < players; p++){
|
|
|
|
var results = this.results
|
|
|
|
if(p === 1){
|
|
|
|
results = p2.results
|
|
|
|
ctx.translate(0, p2Offset)
|
|
|
|
}
|
|
|
|
|
2019-01-21 20:08:02 +01:00
|
|
|
ctx.drawImage(assets.image["difficulty"],
|
|
|
|
0, 144 * this.difficulty[results.difficulty],
|
|
|
|
168, 143,
|
|
|
|
300, 150, 189, 162
|
2018-10-01 09:33:43 +02:00
|
|
|
)
|
2019-01-22 19:47:09 +01:00
|
|
|
var diff = results.difficulty
|
|
|
|
var text = strings[diff === "ura" ? "oni" : diff]
|
|
|
|
ctx.font = this.draw.bold(this.font) + "28px " + this.font
|
|
|
|
ctx.textAlign = "center"
|
|
|
|
ctx.textBaseline = "bottom"
|
|
|
|
ctx.strokeStyle = "#000"
|
|
|
|
ctx.fillStyle = "#fff"
|
|
|
|
ctx.lineWidth = 9
|
|
|
|
ctx.miterLimit = 1
|
|
|
|
ctx.strokeText(text, 395, 308)
|
|
|
|
ctx.fillText(text, 395, 308)
|
|
|
|
ctx.miterLimit = 10
|
2018-10-01 09:33:43 +02:00
|
|
|
|
2020-03-13 03:34:54 +01:00
|
|
|
if(p === 0){
|
|
|
|
var name = account.loggedIn ? account.displayName : strings.defaultName
|
|
|
|
}else{
|
|
|
|
var name = results.name
|
|
|
|
}
|
|
|
|
this.nameplateCache.get({
|
|
|
|
ctx: ctx,
|
|
|
|
x: 259,
|
|
|
|
y: 92,
|
|
|
|
w: 273,
|
|
|
|
h: 66,
|
|
|
|
id: p.toString() + "p",
|
|
|
|
}, ctx => {
|
|
|
|
this.draw.nameplate({
|
|
|
|
ctx: ctx,
|
|
|
|
x: 3,
|
|
|
|
y: 3,
|
|
|
|
name: name,
|
|
|
|
font: this.font,
|
|
|
|
blue: p === 1
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2018-10-03 16:22:40 +02:00
|
|
|
if(this.controller.autoPlayEnabled){
|
|
|
|
ctx.drawImage(assets.image["badge_auto"],
|
|
|
|
431, 311, 34, 34
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2018-10-01 09:33:43 +02:00
|
|
|
this.draw.roundedRect({
|
|
|
|
ctx: ctx,
|
|
|
|
x: 532,
|
|
|
|
y: 98,
|
|
|
|
w: 728,
|
|
|
|
h: 232,
|
|
|
|
radius: 30,
|
|
|
|
})
|
|
|
|
ctx.fillStyle = p === 1 ? "rgba(195, 228, 229, 0.8)" : "rgba(255, 224, 216, 0.8)"
|
|
|
|
ctx.fill()
|
|
|
|
this.draw.roundedRect({
|
|
|
|
ctx: ctx,
|
|
|
|
x: 556,
|
|
|
|
y: 237,
|
|
|
|
w: 254,
|
|
|
|
h: 70,
|
|
|
|
radius: 15,
|
|
|
|
})
|
|
|
|
ctx.fillStyle = "#000"
|
|
|
|
ctx.fill()
|
|
|
|
this.draw.roundedRect({
|
|
|
|
ctx: ctx,
|
|
|
|
x: 559,
|
|
|
|
y: 240,
|
|
|
|
w: 248,
|
|
|
|
h: 64,
|
|
|
|
radius: 14,
|
|
|
|
})
|
|
|
|
ctx.fillStyle = "#eec954"
|
|
|
|
ctx.fill()
|
|
|
|
this.draw.roundedRect({
|
|
|
|
ctx: ctx,
|
|
|
|
x: 567,
|
|
|
|
y: 248,
|
|
|
|
w: 232,
|
|
|
|
h: 48,
|
|
|
|
radius: 6,
|
|
|
|
})
|
|
|
|
ctx.fillStyle = "#000"
|
|
|
|
ctx.fill()
|
2019-01-21 17:12:30 +01:00
|
|
|
this.draw.layeredText({
|
|
|
|
ctx: ctx,
|
|
|
|
text: strings.points,
|
|
|
|
x: 792,
|
2019-01-21 20:08:02 +01:00
|
|
|
y: strings.id === "ko" ? 260 : 253,
|
2019-01-21 17:12:30 +01:00
|
|
|
fontSize: 36,
|
|
|
|
fontFamily: this.font,
|
|
|
|
align: "right",
|
|
|
|
width: 36
|
|
|
|
}, [
|
|
|
|
{fill: "#fff"},
|
|
|
|
{outline: "#000", letterBorder: 0.5}
|
|
|
|
])
|
2018-10-01 09:33:43 +02:00
|
|
|
|
|
|
|
this.draw.score({
|
|
|
|
ctx: ctx,
|
|
|
|
score: "good",
|
|
|
|
x: 823,
|
2019-01-21 20:08:02 +01:00
|
|
|
y: 192,
|
|
|
|
results: true
|
2018-10-01 09:33:43 +02:00
|
|
|
})
|
|
|
|
this.draw.score({
|
|
|
|
ctx: ctx,
|
|
|
|
score: "ok",
|
|
|
|
x: 823,
|
2019-01-21 20:08:02 +01:00
|
|
|
y: 233,
|
|
|
|
results: true
|
2018-10-01 09:33:43 +02:00
|
|
|
})
|
|
|
|
this.draw.score({
|
|
|
|
ctx: ctx,
|
|
|
|
score: "bad",
|
|
|
|
x: 823,
|
2019-01-21 20:08:02 +01:00
|
|
|
y: 273,
|
|
|
|
results: true
|
2018-10-01 09:33:43 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
ctx.textAlign = "right"
|
|
|
|
var grd = ctx.createLinearGradient(0, 0, 0, 30)
|
|
|
|
grd.addColorStop(0.2, "#ff4900")
|
|
|
|
grd.addColorStop(0.9, "#f7fb00")
|
|
|
|
this.draw.layeredText({
|
|
|
|
ctx: ctx,
|
2019-01-05 08:44:28 +01:00
|
|
|
text: strings.maxCombo,
|
2018-10-03 11:48:18 +02:00
|
|
|
x: 1149,
|
2018-10-01 09:33:43 +02:00
|
|
|
y: 193,
|
|
|
|
fontSize: 29,
|
|
|
|
fontFamily: this.font,
|
|
|
|
align: "right",
|
2019-01-16 13:33:42 +01:00
|
|
|
width: 154,
|
2019-01-21 17:12:30 +01:00
|
|
|
letterSpacing: strings.id === "ja" ? 1 : 0
|
2018-10-01 09:33:43 +02:00
|
|
|
}, [
|
|
|
|
{outline: "#000", letterBorder: 8},
|
|
|
|
{fill: grd}
|
|
|
|
])
|
|
|
|
this.draw.layeredText({
|
|
|
|
ctx: ctx,
|
2019-01-05 08:44:28 +01:00
|
|
|
text: strings.drumroll,
|
2018-10-01 09:33:43 +02:00
|
|
|
x: 1150,
|
|
|
|
y: 233,
|
|
|
|
fontSize: 29,
|
|
|
|
fontFamily: this.font,
|
2019-01-21 17:12:30 +01:00
|
|
|
align: "right",
|
2019-01-21 20:08:02 +01:00
|
|
|
width: 154,
|
|
|
|
letterSpacing: strings.id === "ja" ? 4 : 0
|
2018-10-01 09:33:43 +02:00
|
|
|
}, [
|
|
|
|
{outline: "#000", letterBorder: 8},
|
|
|
|
{fill: "#ffc700"}
|
|
|
|
])
|
|
|
|
}
|
|
|
|
ctx.restore()
|
|
|
|
})
|
|
|
|
ctx.restore()
|
|
|
|
}
|
|
|
|
|
2019-01-01 02:16:55 +01:00
|
|
|
if(!this.multiplayer){
|
|
|
|
if(elapsed >= 400 && elapsed < 3100 + failedOffset){
|
|
|
|
if(this.tetsuoHanaClass !== "fadein"){
|
|
|
|
this.tetsuoHana.classList.add("fadein")
|
|
|
|
this.tetsuoHanaClass = "fadein"
|
|
|
|
}
|
|
|
|
}else if(elapsed >= 3100 + failedOffset){
|
2019-01-01 16:00:00 +01:00
|
|
|
if(this.tetsuoHanaClass !== "dance" && this.tetsuoHanaClass !== "failed"){
|
2019-01-01 02:16:55 +01:00
|
|
|
if(this.tetsuoHanaClass){
|
|
|
|
this.tetsuoHana.classList.remove(this.tetsuoHanaClass)
|
|
|
|
}
|
2020-03-09 13:36:57 +01:00
|
|
|
this.tetsuoHanaClass = rules.clearReached(this.results.gauge) ? "dance" : "failed"
|
2019-01-01 16:00:00 +01:00
|
|
|
this.tetsuoHana.classList.add(this.tetsuoHanaClass)
|
2019-01-01 02:16:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-01 09:33:43 +02:00
|
|
|
if(elapsed >= 800){
|
|
|
|
ctx.save()
|
2018-10-27 20:35:04 +02:00
|
|
|
ctx.setTransform(1, 0, 0, 1, 0, 0)
|
|
|
|
this.draw.alpha(Math.min(1, (elapsed - 800) / 500), ctx, ctx => {
|
|
|
|
ctx.scale(ratio, ratio)
|
|
|
|
ctx.translate(frameLeft, frameTop)
|
|
|
|
|
|
|
|
for(var p = 0; p < players; p++){
|
|
|
|
var results = this.results
|
|
|
|
if(p === 1){
|
|
|
|
results = p2.results
|
|
|
|
ctx.translate(0, p2Offset)
|
|
|
|
}
|
2020-03-09 13:36:57 +01:00
|
|
|
var gaugePercent = rules.gaugePercent(results.gauge)
|
2018-10-27 20:35:04 +02:00
|
|
|
var w = 712
|
|
|
|
this.draw.gauge({
|
|
|
|
ctx: ctx,
|
|
|
|
x: 558 + w,
|
2020-03-09 13:36:57 +01:00
|
|
|
y: p === 1 ? 124 : 116,
|
2020-03-05 16:58:49 +01:00
|
|
|
clear: gaugeClear[p],
|
2018-10-27 20:35:04 +02:00
|
|
|
percentage: gaugePercent,
|
|
|
|
font: this.font,
|
|
|
|
scale: w / 788,
|
2018-11-06 20:26:58 +01:00
|
|
|
scoresheet: true,
|
2020-03-09 13:36:57 +01:00
|
|
|
blue: p === 1,
|
|
|
|
multiplayer: p === 1
|
2018-10-27 20:35:04 +02:00
|
|
|
})
|
2020-03-09 13:36:57 +01:00
|
|
|
var playerRules = p === 0 ? rules : this.controller.syncWith.game.rules
|
2018-10-27 20:35:04 +02:00
|
|
|
this.draw.soul({
|
|
|
|
ctx: ctx,
|
|
|
|
x: 1215,
|
|
|
|
y: 144,
|
|
|
|
scale: 36 / 42,
|
2020-03-09 13:36:57 +01:00
|
|
|
cleared: playerRules.clearReached(results.gauge)
|
2018-10-27 20:35:04 +02:00
|
|
|
})
|
2018-10-01 09:33:43 +02:00
|
|
|
}
|
2018-10-27 20:35:04 +02:00
|
|
|
})
|
2018-10-01 09:33:43 +02:00
|
|
|
ctx.restore()
|
|
|
|
}
|
2018-09-26 22:06:14 +02:00
|
|
|
|
2018-10-01 09:33:43 +02:00
|
|
|
if(elapsed >= 1200){
|
|
|
|
ctx.save()
|
|
|
|
ctx.setTransform(1, 0, 0, 1, 0, 0)
|
2018-10-13 11:08:00 +02:00
|
|
|
var noCrownResultWait = -2000;
|
|
|
|
|
2018-10-01 09:33:43 +02:00
|
|
|
for(var p = 0; p < players; p++){
|
|
|
|
var results = this.results
|
|
|
|
if(p === 1){
|
|
|
|
results = p2.results
|
|
|
|
}
|
|
|
|
var crownType = null
|
2020-03-09 13:36:57 +01:00
|
|
|
var playerRules = p === 0 ? rules : this.controller.syncWith.game.rules
|
|
|
|
if(playerRules.clearReached(results.gauge)){
|
2018-10-25 16:18:41 +02:00
|
|
|
crownType = results.bad === "0" ? "gold" : "silver"
|
2018-10-01 09:33:43 +02:00
|
|
|
}
|
|
|
|
if(crownType !== null){
|
2018-10-13 11:08:00 +02:00
|
|
|
noCrownResultWait = 0;
|
2018-10-01 09:33:43 +02:00
|
|
|
var amount = Math.min(1, (elapsed - 1200) / 450)
|
2018-10-01 14:05:21 +02:00
|
|
|
this.draw.alpha(this.draw.easeIn(amount), ctx, ctx => {
|
2018-10-01 09:33:43 +02:00
|
|
|
ctx.save()
|
|
|
|
ctx.scale(ratio, ratio)
|
|
|
|
ctx.translate(frameLeft, frameTop)
|
|
|
|
if(p === 1){
|
|
|
|
ctx.translate(0, p2Offset)
|
|
|
|
}
|
|
|
|
|
|
|
|
var crownScale = 1
|
|
|
|
var shine = 0
|
|
|
|
if(amount < 1){
|
|
|
|
crownScale = 2.8 * (1 - amount) + 0.9
|
|
|
|
}else if(elapsed < 1850){
|
|
|
|
crownScale = 0.9 + (elapsed - 1650) / 2000
|
|
|
|
}else if(elapsed < 2200){
|
|
|
|
shine = (elapsed - 1850) / 175
|
|
|
|
if(shine > 1){
|
|
|
|
shine = 2 - shine
|
|
|
|
}
|
|
|
|
}
|
2018-10-03 11:48:18 +02:00
|
|
|
if(this.state.screen === "fadeIn" && elapsed >= 1200 && !this.state["fullcomboPlayed" + p]){
|
|
|
|
this.state["fullcomboPlayed" + p] = true
|
2018-10-03 16:22:40 +02:00
|
|
|
if(crownType === "gold"){
|
2019-02-04 10:14:42 +01:00
|
|
|
this.playSound("v_results_fullcombo" + (p === 1 ? "2" : ""), p)
|
2018-10-03 11:48:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(this.state.screen === "fadeIn" && elapsed >= 1650 && !this.state["crownPlayed" + p]){
|
|
|
|
this.state["crownPlayed" + p] = true
|
2019-02-04 10:14:42 +01:00
|
|
|
this.playSound("se_results_crown", p)
|
2018-10-03 11:48:18 +02:00
|
|
|
}
|
2018-10-01 09:33:43 +02:00
|
|
|
this.draw.crown({
|
|
|
|
ctx: ctx,
|
|
|
|
type: crownType,
|
|
|
|
x: 395,
|
|
|
|
y: 218,
|
|
|
|
scale: crownScale,
|
2018-10-09 15:07:53 +02:00
|
|
|
shine: shine,
|
2020-03-06 18:52:22 +01:00
|
|
|
whiteOutline: true,
|
2018-10-09 15:07:53 +02:00
|
|
|
ratio: ratio
|
2018-10-01 09:33:43 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
ctx.restore()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ctx.restore()
|
2018-09-15 16:34:53 +02:00
|
|
|
}
|
2018-10-01 09:33:43 +02:00
|
|
|
|
2018-10-13 11:08:00 +02:00
|
|
|
if(elapsed >= 2400 + noCrownResultWait){
|
2018-10-01 09:33:43 +02:00
|
|
|
ctx.save()
|
|
|
|
ctx.translate(frameLeft, frameTop)
|
|
|
|
|
2018-10-03 11:48:18 +02:00
|
|
|
var printNumbers = ["good", "ok", "bad", "maxCombo", "drumroll"]
|
|
|
|
if(!this.state["countupTime0"]){
|
|
|
|
var times = {}
|
|
|
|
var lastTime = 0
|
|
|
|
for(var p = 0; p < players; p++){
|
|
|
|
var results = p === 0 ? this.results : p2.results
|
2018-10-13 11:08:00 +02:00
|
|
|
var currentTime = 3100 + noCrownResultWait + results.points.length * 30 * this.frame
|
2018-10-03 11:48:18 +02:00
|
|
|
if(currentTime > lastTime){
|
|
|
|
lastTime = currentTime
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for(var i in printNumbers){
|
|
|
|
var largestTime = 0
|
|
|
|
for(var p = 0; p < players; p++){
|
|
|
|
var results = p === 0 ? this.results : p2.results
|
|
|
|
times[printNumbers[i]] = lastTime + 500
|
|
|
|
var currentTime = lastTime + 500 + results[printNumbers[i]].length * 30 * this.frame
|
|
|
|
if(currentTime > largestTime){
|
|
|
|
largestTime = currentTime
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lastTime = largestTime
|
|
|
|
}
|
|
|
|
this.state.fadeInEnd = lastTime
|
|
|
|
for(var p = 0; p < players; p++){
|
|
|
|
this.state["countupTime" + p] = times
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-01 09:33:43 +02:00
|
|
|
for(var p = 0; p < players; p++){
|
|
|
|
var results = this.results
|
|
|
|
if(p === 1){
|
|
|
|
results = p2.results
|
|
|
|
ctx.translate(0, p2Offset)
|
|
|
|
}
|
|
|
|
ctx.save()
|
2018-10-03 11:48:18 +02:00
|
|
|
|
|
|
|
this.state.countupShown = false
|
|
|
|
|
2018-10-13 11:08:00 +02:00
|
|
|
var points = this.getNumber(results.points, 3100 + noCrownResultWait, elapsed)
|
2018-10-01 09:33:43 +02:00
|
|
|
var scale = 1.3
|
2019-01-21 20:08:02 +01:00
|
|
|
ctx.font = "35px " + this.numbersFont
|
2018-10-01 09:33:43 +02:00
|
|
|
ctx.translate(760, 286)
|
|
|
|
ctx.scale(1 / scale, 1 * 1.1)
|
|
|
|
ctx.textAlign = "center"
|
|
|
|
ctx.fillStyle = "#fff"
|
|
|
|
ctx.strokeStyle = "#fff"
|
|
|
|
ctx.lineWidth = 0.5
|
|
|
|
for(var i = 0; i < points.length; i++){
|
2018-10-03 11:48:18 +02:00
|
|
|
ctx.translate(-23.3 * scale, 0)
|
2018-10-01 09:33:43 +02:00
|
|
|
ctx.fillText(points[points.length - i - 1], 0, 0)
|
|
|
|
ctx.strokeText(points[points.length - i - 1], 0, 0)
|
|
|
|
}
|
|
|
|
ctx.restore()
|
|
|
|
|
2018-10-03 11:48:18 +02:00
|
|
|
if(!this.state["countupTime" + p]){
|
|
|
|
var times = {}
|
2018-10-13 11:08:00 +02:00
|
|
|
var lastTime = 3100 + noCrownResultWait + results.points.length * 30 * this.frame + 1000
|
2018-10-03 11:48:18 +02:00
|
|
|
for(var i in printNumbers){
|
|
|
|
times[printNumbers[i]] = lastTime + 500
|
|
|
|
lastTime = lastTime + 500 + results[printNumbers[i]].length * 30 * this.frame
|
|
|
|
}
|
|
|
|
this.state["countupTime" + p] = times
|
|
|
|
}
|
|
|
|
|
2018-10-01 09:33:43 +02:00
|
|
|
for(var i in printNumbers){
|
2018-10-03 11:48:18 +02:00
|
|
|
var start = this.state["countupTime" + p][printNumbers[i]]
|
2018-10-01 09:33:43 +02:00
|
|
|
this.draw.layeredText({
|
|
|
|
ctx: ctx,
|
2018-10-03 11:48:18 +02:00
|
|
|
text: this.getNumber(results[printNumbers[i]], start, elapsed),
|
2018-10-01 09:33:43 +02:00
|
|
|
x: 971 + 270 * Math.floor(i / 3),
|
2018-10-03 11:48:18 +02:00
|
|
|
y: 196 + (40 * (i % 3)),
|
|
|
|
fontSize: 26,
|
2019-01-21 20:08:02 +01:00
|
|
|
fontFamily: this.numbersFont,
|
2018-10-03 11:48:18 +02:00
|
|
|
letterSpacing: 1,
|
2018-10-01 09:33:43 +02:00
|
|
|
align: "right"
|
|
|
|
}, [
|
|
|
|
{outline: "#000", letterBorder: 9},
|
|
|
|
{fill: "#fff"}
|
|
|
|
])
|
|
|
|
}
|
2018-10-03 11:48:18 +02:00
|
|
|
|
|
|
|
if(this.state.countupShown){
|
|
|
|
if(!this.state["countup" + p]){
|
|
|
|
this.state["countup" + p] = true
|
2019-02-04 10:14:42 +01:00
|
|
|
this.loopSound("se_results_countup", p, [0.1, false, 0, 0, 0.07])
|
2018-10-03 11:48:18 +02:00
|
|
|
}
|
|
|
|
}else if(this.state["countup" + p]){
|
|
|
|
this.state["countup" + p] = false
|
2019-02-04 10:14:42 +01:00
|
|
|
this.stopSound("se_results_countup", p)
|
2018-10-03 11:48:18 +02:00
|
|
|
if(this.state.screen === "fadeIn"){
|
2019-02-04 10:14:42 +01:00
|
|
|
this.playSound("neiro_1_don", p)
|
2018-10-03 11:48:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(this.state.screen === "fadeIn" && elapsed >= this.state.fadeInEnd){
|
|
|
|
this.state.screen = "scoresShown"
|
|
|
|
this.state.screenMS = this.getMS()
|
|
|
|
}
|
2018-10-01 09:33:43 +02:00
|
|
|
}
|
|
|
|
ctx.restore()
|
2018-09-26 22:06:14 +02:00
|
|
|
}
|
2018-10-01 09:33:43 +02:00
|
|
|
|
2020-03-09 13:36:57 +01:00
|
|
|
if(this.session && !this.state.scoreNext && this.state.screen === "scoresShown" && ms - this.state.screenMS >= 10000){
|
2018-11-02 11:26:46 +01:00
|
|
|
this.state.scoreNext = true
|
2020-03-09 13:36:57 +01:00
|
|
|
if(p2.session){
|
|
|
|
p2.send("songsel")
|
|
|
|
}else{
|
|
|
|
this.toSongsel(true)
|
|
|
|
}
|
2018-11-02 11:26:46 +01:00
|
|
|
}
|
|
|
|
|
2018-10-01 09:33:43 +02:00
|
|
|
if(this.state.screen === "fadeOut"){
|
2018-10-01 13:48:25 +02:00
|
|
|
if(this.state.hasPointer === 1){
|
|
|
|
this.state.hasPointer = 2
|
|
|
|
this.canvas.style.cursor = ""
|
|
|
|
}
|
2018-10-01 09:33:43 +02:00
|
|
|
|
2019-01-01 02:16:55 +01:00
|
|
|
if(!this.fadeScreenBlack){
|
|
|
|
this.fadeScreenBlack = true
|
|
|
|
this.fadeScreen.style.backgroundColor = "#000"
|
|
|
|
}
|
2018-10-01 09:33:43 +02:00
|
|
|
var elapsed = ms - this.state.screenMS
|
|
|
|
|
|
|
|
if(elapsed >= 1000){
|
|
|
|
this.clean()
|
2019-01-01 14:35:12 +01:00
|
|
|
this.controller.songSelection(true)
|
2018-09-26 22:06:14 +02:00
|
|
|
}
|
|
|
|
}
|
2018-10-01 09:33:43 +02:00
|
|
|
|
|
|
|
ctx.restore()
|
|
|
|
}
|
|
|
|
|
2018-10-03 11:48:18 +02:00
|
|
|
getNumber(score, start, elapsed){
|
|
|
|
var numberPos = Math.floor((elapsed - start) / this.frame)
|
|
|
|
if(numberPos < 0){
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
var output = ""
|
|
|
|
for(var i = 0; i < score.length; i++){
|
|
|
|
if(numberPos < 30 * (i + 1)){
|
|
|
|
this.state.countupShown = true
|
|
|
|
return this.numbers[numberPos % 30] + output
|
|
|
|
}else{
|
|
|
|
output = score[score.length - i - 1] + output
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return output
|
|
|
|
}
|
|
|
|
|
|
|
|
getSound(id, p){
|
|
|
|
return assets.sounds[id + (this.multiplayer ? "_p" + (p + 1) : "")]
|
|
|
|
}
|
|
|
|
playSound(id, p){
|
|
|
|
this.getSound(id, p).play()
|
|
|
|
}
|
|
|
|
loopSound(id, p, args){
|
|
|
|
this.getSound(id, p).playLoop(...args)
|
|
|
|
}
|
|
|
|
stopSound(id, p){
|
|
|
|
this.getSound(id, p).stop()
|
|
|
|
}
|
|
|
|
|
2018-10-01 09:33:43 +02:00
|
|
|
mod(length, index){
|
|
|
|
return ((index % length) + length) % length
|
|
|
|
}
|
|
|
|
|
|
|
|
getMS(){
|
2018-12-13 10:18:52 +01:00
|
|
|
return Date.now()
|
2018-09-26 22:06:14 +02:00
|
|
|
}
|
2018-10-01 09:33:43 +02:00
|
|
|
|
2020-03-06 01:02:07 +01:00
|
|
|
saveScore(){
|
2020-03-09 13:36:57 +01:00
|
|
|
if(this.controller.saveScore){
|
2020-03-07 08:34:01 +01:00
|
|
|
if(this.resultsObj.points < 0){
|
|
|
|
this.resultsObj.points = 0
|
|
|
|
}
|
2020-03-06 01:02:07 +01:00
|
|
|
var title = this.controller.selectedSong.originalTitle
|
2020-03-07 02:48:30 +01:00
|
|
|
var hash = this.controller.selectedSong.hash
|
2020-03-06 01:02:07 +01:00
|
|
|
var difficulty = this.resultsObj.difficulty
|
2020-03-07 02:48:30 +01:00
|
|
|
var oldScore = scoreStorage.get(hash, difficulty, true)
|
2020-03-07 08:34:01 +01:00
|
|
|
var clearReached = this.controller.game.rules.clearReached(this.resultsObj.gauge)
|
|
|
|
var crown = ""
|
|
|
|
if(clearReached){
|
|
|
|
crown = this.resultsObj.bad === 0 ? "gold" : "silver"
|
|
|
|
}
|
2020-03-06 01:02:07 +01:00
|
|
|
if(!oldScore || oldScore.points <= this.resultsObj.points){
|
2020-03-06 18:52:22 +01:00
|
|
|
if(oldScore && (oldScore.crown === "gold" || oldScore.crown === "silver" && !crown)){
|
|
|
|
crown = oldScore.crown
|
|
|
|
}
|
|
|
|
this.resultsObj.crown = crown
|
2020-03-06 01:02:07 +01:00
|
|
|
delete this.resultsObj.title
|
|
|
|
delete this.resultsObj.difficulty
|
|
|
|
delete this.resultsObj.gauge
|
2020-03-07 02:48:30 +01:00
|
|
|
scoreStorage.add(hash, difficulty, this.resultsObj, true, title)
|
2020-03-07 08:34:01 +01:00
|
|
|
}else if(oldScore && (crown === "gold" && oldScore.crown !== "gold" || crown && !oldScore.crown)){
|
|
|
|
oldScore.crown = crown
|
|
|
|
scoreStorage.add(hash, difficulty, oldScore, true, title)
|
2020-03-06 01:02:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
this.scoreSaved = true
|
|
|
|
}
|
|
|
|
|
2018-09-18 00:37:59 +02:00
|
|
|
clean(){
|
2019-04-16 20:06:41 +02:00
|
|
|
this.keyboard.clean()
|
|
|
|
this.gamepad.clean()
|
2018-10-09 15:07:53 +02:00
|
|
|
this.draw.clean()
|
|
|
|
this.canvasCache.clean()
|
2018-09-18 00:37:59 +02:00
|
|
|
assets.sounds["bgm_result"].stop()
|
2019-03-15 22:34:48 +01:00
|
|
|
snd.buffer.loadSettings()
|
2018-10-01 09:33:43 +02:00
|
|
|
this.redrawRunning = false
|
2018-10-12 20:04:28 +02:00
|
|
|
pageEvents.remove(this.canvas, ["mousedown", "touchstart"])
|
2019-01-01 02:16:55 +01:00
|
|
|
if(this.multiplayer !== 2 && this.touchEnabled){
|
|
|
|
pageEvents.remove(document.getElementById("touch-full-btn"), "touchend")
|
|
|
|
}
|
2020-03-09 13:36:57 +01:00
|
|
|
if(this.session){
|
2018-12-15 20:13:16 +01:00
|
|
|
pageEvents.remove(p2, "message")
|
|
|
|
}
|
2019-01-01 02:16:55 +01:00
|
|
|
if(!this.multiplayer){
|
|
|
|
delete this.tetsuoHana
|
|
|
|
}
|
2018-10-01 09:33:43 +02:00
|
|
|
delete this.ctx
|
|
|
|
delete this.canvas
|
2019-01-01 02:16:55 +01:00
|
|
|
delete this.fadeScreen
|
2018-09-18 00:37:59 +02:00
|
|
|
}
|
2018-09-15 16:34:53 +02:00
|
|
|
}
|