Split language and tutorial, add gamepad settings

This commit is contained in:
LoveEevee
2019-04-16 21:06:41 +03:00
parent a4d938e888
commit f05b2518f3
26 changed files with 1036 additions and 835 deletions

View File

@@ -2,13 +2,13 @@ class Session{
constructor(touchEnabled){
this.touchEnabled = touchEnabled
loader.changePage("session", true)
this.endButton = document.getElementById("tutorial-end-button")
this.endButton = this.getElement("view-end-button")
if(touchEnabled){
document.getElementById("tutorial-outer").classList.add("touch-enabled")
this.getElement("view-outer").classList.add("touch-enabled")
}
this.sessionInvite = document.getElementById("session-invite")
var tutorialTitle = document.getElementById("tutorial-title")
var tutorialTitle = this.getElement("view-title")
tutorialTitle.innerText = strings.session.multiplayerSession
tutorialTitle.setAttribute("alt", strings.session.multiplayerSession)
this.sessionInvite.parentNode.insertBefore(document.createTextNode(strings.session.linkTutorial), this.sessionInvite)
@@ -16,11 +16,12 @@ class Session{
this.endButton.setAttribute("alt", strings.session.cancel)
pageEvents.add(window, ["mousedown", "touchstart"], this.mouseDown.bind(this))
pageEvents.keyOnce(this, 27, "down").then(this.onEnd.bind(this))
this.keyboard = new Keyboard({
confirm: ["esc"]
}, this.keyPress.bind(this))
this.gamepad = new Gamepad({
"confirm": ["start", "b", "ls", "rs"]
}, this.onEnd.bind(this))
confirm: ["start", "b", "ls", "rs"]
}, this.keyPress.bind(this))
p2.hashLock = true
pageEvents.add(p2, "message", response => {
@@ -29,13 +30,16 @@ class Session{
p2.hash(response.value)
}else if(response.type === "songsel"){
p2.clearMessage("users")
this.onEnd(false, true)
this.onEnd(true)
pageEvents.send("session-start", "host")
}
})
p2.send("invite")
pageEvents.send("session")
}
getElement(name){
return loader.screen.getElementsByClassName(name)[0]
}
mouseDown(event){
if(event.type === "mousedown" && event.which !== 1){
return
@@ -50,7 +54,12 @@ class Session{
this.onEnd()
}
}
onEnd(event, fromP2){
keyPress(pressed){
if(pressed){
this.onEnd()
}
}
onEnd(fromP2){
if(!p2.session){
p2.send("leave")
p2.hash("")
@@ -59,9 +68,6 @@ class Session{
}else if(!fromP2){
return p2.send("songsel")
}
if(event && event.type === "keydown"){
event.preventDefault()
}
this.clean()
assets.sounds["se_don"].play()
setTimeout(() => {
@@ -69,9 +75,9 @@ class Session{
}, 500)
}
clean(){
this.keyboard.clean()
this.gamepad.clean()
pageEvents.remove(window, ["mousedown", "touchstart"])
pageEvents.keyRemove(this, 27)
pageEvents.remove(p2, "message")
delete this.endButton
delete this.sessionInvite