2018-09-18 06:37:59 +08:00
|
|
|
class Tutorial{
|
2018-09-27 02:30:57 +08:00
|
|
|
constructor(fromSongSel){
|
|
|
|
this.fromSongSel = fromSongSel
|
2019-01-16 20:33:42 +08:00
|
|
|
loader.changePage("tutorial", true)
|
2018-09-18 06:37:59 +08:00
|
|
|
assets.sounds["bgm_setsume"].playLoop(0.1, false, 0, 1.054, 16.054)
|
|
|
|
this.endButton = document.getElementById("tutorial-end-button")
|
2018-10-06 21:24:23 +08:00
|
|
|
|
2019-01-23 02:47:09 +08:00
|
|
|
var tutorialTitle = document.getElementById("tutorial-title")
|
|
|
|
tutorialTitle.innerText = strings.howToPlay
|
|
|
|
tutorialTitle.setAttribute("alt", strings.howToPlay)
|
|
|
|
var tutorialContent = document.getElementById("tutorial-content")
|
|
|
|
var keys = ["F", "J", "D", "K", "Q", "SHIFT", "CTRL"]
|
|
|
|
var keyIndex = 0
|
|
|
|
strings.tutorial.basics.forEach(string => {
|
|
|
|
var par = document.createElement("p")
|
|
|
|
var stringKeys = string.split("%s")
|
|
|
|
stringKeys.forEach((stringKey, i) => {
|
|
|
|
if(i !== 0){
|
|
|
|
this.insertKey(keys[keyIndex++], par)
|
|
|
|
}
|
|
|
|
this.insertText(stringKey, par)
|
|
|
|
})
|
|
|
|
tutorialContent.appendChild(par)
|
|
|
|
})
|
|
|
|
var par = document.createElement("p")
|
|
|
|
var span = document.createElement("span")
|
|
|
|
span.style.fontWeight = "bold"
|
|
|
|
span.innerText = strings.tutorial.otherControls
|
|
|
|
par.appendChild(span)
|
|
|
|
strings.tutorial.otherTutorial.forEach(string => {
|
|
|
|
par.appendChild(document.createElement("br"))
|
|
|
|
var stringKeys = string.split("%s")
|
|
|
|
stringKeys.forEach((stringKey, i) => {
|
|
|
|
if(i !== 0){
|
|
|
|
this.insertKey(keys[keyIndex++], par)
|
|
|
|
}
|
|
|
|
this.insertText(stringKey, par)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
tutorialContent.appendChild(par)
|
|
|
|
this.endButton.innerText = strings.tutorial.ok
|
|
|
|
this.endButton.setAttribute("alt", strings.tutorial.ok)
|
|
|
|
|
2018-10-13 02:04:28 +08:00
|
|
|
pageEvents.once(this.endButton, ["mousedown", "touchstart"]).then(this.onEnd.bind(this))
|
2018-09-27 02:30:57 +08:00
|
|
|
pageEvents.keyOnce(this, 13, "down").then(this.onEnd.bind(this))
|
2018-10-06 21:24:23 +08:00
|
|
|
|
2018-09-27 02:30:57 +08:00
|
|
|
this.gamepad = new Gamepad({
|
2018-10-09 04:32:25 +08:00
|
|
|
"confirm": ["start", "b", "ls", "rs"]
|
2018-09-27 02:30:57 +08:00
|
|
|
}, this.onEnd.bind(this))
|
2018-09-18 06:37:59 +08:00
|
|
|
}
|
2019-01-23 02:47:09 +08:00
|
|
|
insertText(text, parent){
|
|
|
|
parent.appendChild(document.createTextNode(text))
|
|
|
|
}
|
|
|
|
insertKey(key, parent){
|
|
|
|
var kbd = document.createElement("kbd")
|
|
|
|
kbd.innerText = key
|
|
|
|
parent.appendChild(kbd)
|
|
|
|
}
|
2018-10-06 21:24:23 +08:00
|
|
|
onEnd(event){
|
|
|
|
var touched = false
|
|
|
|
if(event && event.type === "touchstart"){
|
|
|
|
event.preventDefault()
|
|
|
|
touched = true
|
|
|
|
}
|
2018-09-18 06:37:59 +08:00
|
|
|
this.clean()
|
|
|
|
assets.sounds["don"].play()
|
|
|
|
localStorage.setItem("tutorial", "true")
|
2018-09-27 02:30:57 +08:00
|
|
|
setTimeout(() => {
|
2018-10-14 16:04:31 +08:00
|
|
|
new SongSelect(this.fromSongSel ? "tutorial" : false, false, touched)
|
2018-09-27 02:30:57 +08:00
|
|
|
}, 500)
|
2018-09-18 06:37:59 +08:00
|
|
|
}
|
|
|
|
clean(){
|
2018-09-27 02:30:57 +08:00
|
|
|
this.gamepad.clean()
|
2018-09-18 06:37:59 +08:00
|
|
|
assets.sounds["bgm_setsume"].stop()
|
2018-10-13 02:04:28 +08:00
|
|
|
pageEvents.remove(this.endButton, ["mousedown", "touchstart"])
|
2018-09-27 02:30:57 +08:00
|
|
|
pageEvents.keyRemove(this, 13)
|
2018-09-18 06:37:59 +08:00
|
|
|
delete this.endButton
|
|
|
|
}
|
|
|
|
}
|