Change some events, fix p2 sending gameend twice
- Fixed gameend being sent twice in p2 - Add `ready`, `loader-error`, and `song-select-random` events - Fixed `session-start` not firing when invited, added event detail - Fixed `language-change` being fired at startup - Fixed `version-link` and `about-link` firing twice - "#song=" will fire `song-select-difficulty` - Removed `key-events` and `scoresheet-player2`, merged with `scoresheet` and made it more detailed
This commit is contained in:
parent
adc45cb652
commit
e677f2f032
@ -152,8 +152,10 @@
|
|||||||
return target.getElementsByTagName("a")[0]
|
return target.getElementsByTagName("a")[0]
|
||||||
}
|
}
|
||||||
linkButton(event){
|
linkButton(event){
|
||||||
this.getLink(event.currentTarget).click()
|
if(event.target === event.currentTarget){
|
||||||
pageEvents.send("about-link", event)
|
this.getLink(event.currentTarget).click()
|
||||||
|
pageEvents.send("about-link", event)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
clean(){
|
clean(){
|
||||||
cancelTouch = true
|
cancelTouch = true
|
||||||
|
@ -259,11 +259,5 @@ class Keyboard{
|
|||||||
if(this.controller.multiplayer === 1){
|
if(this.controller.multiplayer === 1){
|
||||||
pageEvents.remove(window, "beforeunload")
|
pageEvents.remove(window, "beforeunload")
|
||||||
}
|
}
|
||||||
if(this.controller.multiplayer !== 2){
|
|
||||||
pageEvents.send("key-events", {
|
|
||||||
keyboard: this.keyboardEvents,
|
|
||||||
gamepad: this.gamepad.gamepadEvents
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,6 +153,7 @@ class Loader{
|
|||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
var readyEvent = "normal"
|
||||||
var songId
|
var songId
|
||||||
var hashLower = location.hash.toLowerCase()
|
var hashLower = location.hash.toLowerCase()
|
||||||
p2 = new P2Connection()
|
p2 = new P2Connection()
|
||||||
@ -160,6 +161,7 @@ class Loader{
|
|||||||
var number = parseInt(location.hash.slice(6))
|
var number = parseInt(location.hash.slice(6))
|
||||||
if(number > 0){
|
if(number > 0){
|
||||||
songId = number
|
songId = number
|
||||||
|
readyEvent = "song-id"
|
||||||
}
|
}
|
||||||
}else if(location.hash.length === 6){
|
}else if(location.hash.length === 6){
|
||||||
p2.hashLock = true
|
p2.hashLock = true
|
||||||
@ -167,10 +169,13 @@ class Loader{
|
|||||||
p2.open()
|
p2.open()
|
||||||
pageEvents.add(p2, "message", response => {
|
pageEvents.add(p2, "message", response => {
|
||||||
if(response.type === "session"){
|
if(response.type === "session"){
|
||||||
|
pageEvents.send("session-start", "invited")
|
||||||
|
readyEvent = "session-start"
|
||||||
resolve()
|
resolve()
|
||||||
}else if(response.type === "gameend"){
|
}else if(response.type === "gameend"){
|
||||||
p2.hash("")
|
p2.hash("")
|
||||||
p2.hashLock = false
|
p2.hashLock = false
|
||||||
|
readyEvent = "session-expired"
|
||||||
resolve()
|
resolve()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -196,6 +201,7 @@ class Loader{
|
|||||||
this.canvasTest.clean()
|
this.canvasTest.clean()
|
||||||
this.clean()
|
this.clean()
|
||||||
this.callback(songId)
|
this.callback(songId)
|
||||||
|
pageEvents.send("ready", readyEvent)
|
||||||
})
|
})
|
||||||
}, this.errorMsg.bind(this))
|
}, this.errorMsg.bind(this))
|
||||||
|
|
||||||
@ -218,6 +224,7 @@ class Loader{
|
|||||||
}
|
}
|
||||||
errorMsg(error){
|
errorMsg(error){
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
pageEvents.send("loader-error", error)
|
||||||
this.error = true
|
this.error = true
|
||||||
this.loaderPercentage.appendChild(document.createElement("br"))
|
this.loaderPercentage.appendChild(document.createElement("br"))
|
||||||
this.loaderPercentage.appendChild(document.createTextNode("An error occurred, please refresh"))
|
this.loaderPercentage.appendChild(document.createTextNode("An error occurred, please refresh"))
|
||||||
|
@ -18,7 +18,8 @@ class LoadSong{
|
|||||||
pageEvents.send("load-song", {
|
pageEvents.send("load-song", {
|
||||||
selectedSong: selectedSong,
|
selectedSong: selectedSong,
|
||||||
autoPlayEnabled: autoPlayEnabled,
|
autoPlayEnabled: autoPlayEnabled,
|
||||||
multiplayer: multiplayer
|
multiplayer: multiplayer,
|
||||||
|
touchEnabled: touchEnabled
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
run(){
|
run(){
|
||||||
|
@ -90,9 +90,11 @@ pageEvents.add(root, ["touchstart", "touchmove", "touchend"], event => {
|
|||||||
})
|
})
|
||||||
var versionDiv = document.getElementById("version")
|
var versionDiv = document.getElementById("version")
|
||||||
var versionLink = document.getElementById("version-link")
|
var versionLink = document.getElementById("version-link")
|
||||||
pageEvents.add(versionDiv, ["click", "touchend"], () => {
|
pageEvents.add(versionDiv, ["click", "touchend"], event => {
|
||||||
versionLink.click()
|
if(event.target === versionDiv){
|
||||||
pageEvents.send("version-link")
|
versionLink.click()
|
||||||
|
pageEvents.send("version-link")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
resizeRoot()
|
resizeRoot()
|
||||||
setInterval(resizeRoot, 100)
|
setInterval(resizeRoot, 100)
|
||||||
|
@ -128,7 +128,6 @@ class P2Connection{
|
|||||||
for(var i in response.value){
|
for(var i in response.value){
|
||||||
this.results[i] = response.value[i].toString()
|
this.results[i] = response.value[i].toString()
|
||||||
}
|
}
|
||||||
pageEvents.send("scoresheet-player2", this.results)
|
|
||||||
break
|
break
|
||||||
case "note":
|
case "note":
|
||||||
this.notes.push(response.value)
|
this.notes.push(response.value)
|
||||||
|
@ -61,8 +61,15 @@ class Scoresheet{
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
pageEvents.send("scoresheet", {
|
pageEvents.send("scoresheet", {
|
||||||
|
selectedSong: controller.selectedSong,
|
||||||
|
autoPlayEnabled: controller.autoPlayEnabled,
|
||||||
|
multiplayer: multiplayer,
|
||||||
|
touchEnabled: touchEnabled,
|
||||||
results: this.results,
|
results: this.results,
|
||||||
multiplayer: multiplayer
|
p2results: multiplayer ? p2.results : null,
|
||||||
|
keyboardEvents: controller.keyboard.keyboardEvents,
|
||||||
|
gamepadEvents: controller.keyboard.gamepad.gamepadEvents,
|
||||||
|
touchEvents: controller.view.touchEvents
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
keyDown(event, code){
|
keyDown(event, code){
|
||||||
|
@ -30,7 +30,7 @@ class Session{
|
|||||||
}else if(response.type === "songsel"){
|
}else if(response.type === "songsel"){
|
||||||
p2.clearMessage("users")
|
p2.clearMessage("users")
|
||||||
this.onEnd(false, true)
|
this.onEnd(false, true)
|
||||||
pageEvents.send("session-start")
|
pageEvents.send("session-start", "host")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
p2.send("invite")
|
p2.send("invite")
|
||||||
|
@ -313,6 +313,9 @@ class SongSelect{
|
|||||||
this.redraw()
|
this.redraw()
|
||||||
pageEvents.send("song-select")
|
pageEvents.send("song-select")
|
||||||
pageEvents.send("song-select-move", this.songs[this.selectedSong])
|
pageEvents.send("song-select-move", this.songs[this.selectedSong])
|
||||||
|
if(songIdIndex !== -1){
|
||||||
|
pageEvents.send("song-select-difficulty", this.songs[this.selectedSong])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
keyDown(event, code){
|
keyDown(event, code){
|
||||||
@ -615,6 +618,7 @@ class SongSelect{
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.moveToSong(moveBy)
|
this.moveToSong(moveBy)
|
||||||
}, 200)
|
}, 200)
|
||||||
|
pageEvents.send("song-select-random")
|
||||||
}else if(currentSong.action === "tutorial"){
|
}else if(currentSong.action === "tutorial"){
|
||||||
this.toTutorial()
|
this.toTutorial()
|
||||||
}else if(currentSong.action === "about"){
|
}else if(currentSong.action === "about"){
|
||||||
|
@ -15,7 +15,7 @@ class Titlescreen{
|
|||||||
this.logo = new Logo()
|
this.logo = new Logo()
|
||||||
}
|
}
|
||||||
this.lang = this.getLang()
|
this.lang = this.getLang()
|
||||||
this.setLang(allStrings[this.lang])
|
this.setLang(allStrings[this.lang], true)
|
||||||
|
|
||||||
if(songId){
|
if(songId){
|
||||||
this.goNext()
|
this.goNext()
|
||||||
@ -106,7 +106,7 @@ class Titlescreen{
|
|||||||
}
|
}
|
||||||
return "ja"
|
return "ja"
|
||||||
}
|
}
|
||||||
setLang(lang){
|
setLang(lang, initial){
|
||||||
strings = lang
|
strings = lang
|
||||||
|
|
||||||
loader.screen.style.fontFamily = strings.font
|
loader.screen.style.fontFamily = strings.font
|
||||||
@ -129,7 +129,9 @@ class Titlescreen{
|
|||||||
this.disclaimerCopyright.setAttribute("alt", strings.titleCopyright)
|
this.disclaimerCopyright.setAttribute("alt", strings.titleCopyright)
|
||||||
|
|
||||||
this.logo.updateSubtitle()
|
this.logo.updateSubtitle()
|
||||||
pageEvents.send("language-change", lang.id)
|
if(!initial){
|
||||||
|
pageEvents.send("language-change", lang.id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
addLangs(){
|
addLangs(){
|
||||||
for(var i in allStrings){
|
for(var i in allStrings){
|
||||||
|
@ -74,6 +74,7 @@
|
|||||||
this.nextBeat = 0
|
this.nextBeat = 0
|
||||||
this.gogoTime = 0
|
this.gogoTime = 0
|
||||||
this.drumroll = []
|
this.drumroll = []
|
||||||
|
this.touchEvents = 0
|
||||||
|
|
||||||
this.beatInterval = this.controller.parsedSongData.beatInfo.beatInterval
|
this.beatInterval = this.controller.parsedSongData.beatInfo.beatInterval
|
||||||
this.font = strings.font
|
this.font = strings.font
|
||||||
@ -1601,6 +1602,7 @@
|
|||||||
this.touchNote("ka_r")
|
this.touchNote("ka_r")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.touchEvents++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,6 +210,7 @@ async def connection(ws, path):
|
|||||||
user["other_user"]["ws"].send(sent_msg1),
|
user["other_user"]["ws"].send(sent_msg1),
|
||||||
user["other_user"]["ws"].send(sent_msg2)
|
user["other_user"]["ws"].send(sent_msg2)
|
||||||
])
|
])
|
||||||
|
del user["other_user"]["other_user"]
|
||||||
del user["other_user"]
|
del user["other_user"]
|
||||||
else:
|
else:
|
||||||
# Other user disconnected
|
# Other user disconnected
|
||||||
@ -304,6 +305,7 @@ async def connection(ws, path):
|
|||||||
user["other_user"]["ws"].send(sent_msg1),
|
user["other_user"]["ws"].send(sent_msg1),
|
||||||
user["other_user"]["ws"].send(sent_msg2)
|
user["other_user"]["ws"].send(sent_msg2)
|
||||||
])
|
])
|
||||||
|
del user["other_user"]["other_user"]
|
||||||
del user["other_user"]
|
del user["other_user"]
|
||||||
else:
|
else:
|
||||||
# Other user disconnected
|
# Other user disconnected
|
||||||
@ -324,6 +326,7 @@ async def connection(ws, path):
|
|||||||
user["other_user"]["ws"].send(msgobj("gameend")),
|
user["other_user"]["ws"].send(msgobj("gameend")),
|
||||||
user["other_user"]["ws"].send(status_event())
|
user["other_user"]["ws"].send(status_event())
|
||||||
])
|
])
|
||||||
|
del user["other_user"]["other_user"]
|
||||||
if user["action"] == "waiting":
|
if user["action"] == "waiting":
|
||||||
del server_status["waiting"][user["gameid"]]
|
del server_status["waiting"][user["gameid"]]
|
||||||
await notify_status()
|
await notify_status()
|
||||||
|
Loading…
Reference in New Issue
Block a user