2018-09-18 00:37:59 +02:00
|
|
|
class Titlescreen{
|
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
|
|
|
constructor(songId){
|
|
|
|
this.songId = songId
|
2019-01-21 16:47:22 +01:00
|
|
|
|
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
|
|
|
if(!songId){
|
|
|
|
loader.changePage("titlescreen", false)
|
|
|
|
|
|
|
|
this.titleScreen = document.getElementById("title-screen")
|
|
|
|
this.proceed = document.getElementById("title-proceed")
|
|
|
|
this.langDropdown = document.getElementById("lang-dropdown")
|
|
|
|
this.langId = document.getElementById("lang-id")
|
|
|
|
this.disclaimerText = document.getElementById("title-disclaimer-text")
|
|
|
|
this.disclaimerCopyright = document.getElementById("title-disclaimer-copyright")
|
|
|
|
document.getElementById("globe-path").setAttribute("d", vectors.globe)
|
|
|
|
this.logo = new Logo()
|
|
|
|
}
|
2019-01-21 16:47:22 +01:00
|
|
|
this.lang = this.getLang()
|
|
|
|
this.setLang(allStrings[this.lang])
|
|
|
|
|
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
|
|
|
if(songId){
|
|
|
|
this.goNext()
|
|
|
|
}else{
|
|
|
|
this.addLangs()
|
|
|
|
|
|
|
|
pageEvents.keyAdd(this, "all", "down", this.keyDown.bind(this))
|
|
|
|
pageEvents.add(this.titleScreen, ["mousedown", "touchstart"], this.onPressed.bind(this))
|
|
|
|
pageEvents.add(this.langDropdown, "change", this.langChange.bind(this))
|
|
|
|
|
|
|
|
assets.sounds["v_title"].play()
|
|
|
|
this.gamepad = new Gamepad({
|
|
|
|
"13": ["a", "b", "x", "y", "start", "ls", "rs"]
|
|
|
|
}, pressed => {
|
|
|
|
if(pressed){
|
|
|
|
this.onPressed()
|
2018-11-01 23:05:18 +01:00
|
|
|
}
|
|
|
|
})
|
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
|
|
|
if(p2.session){
|
|
|
|
pageEvents.add(p2, "message", response => {
|
|
|
|
if(response.type === "songsel"){
|
|
|
|
this.goNext(true)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
pageEvents.send("title-screen")
|
2018-11-01 23:05:18 +01:00
|
|
|
}
|
2015-07-17 10:22:46 +02:00
|
|
|
}
|
2019-01-21 16:47:22 +01:00
|
|
|
|
2018-10-09 08:59:36 +02:00
|
|
|
keyDown(event, code){
|
2019-01-21 16:47:22 +01:00
|
|
|
if(event && event.target === this.langDropdown){
|
|
|
|
return
|
|
|
|
}
|
2018-10-09 08:59:36 +02:00
|
|
|
if(!code){
|
|
|
|
code = event.keyCode
|
|
|
|
}
|
2018-10-23 16:51:55 +02:00
|
|
|
if(code == 13 || code == 32 || code == 70 || code == 74){
|
|
|
|
// Enter, Space, F, J
|
2018-10-09 08:59:36 +02:00
|
|
|
this.onPressed()
|
|
|
|
}
|
|
|
|
}
|
2018-10-06 15:24:23 +02:00
|
|
|
onPressed(event){
|
2018-10-09 08:59:36 +02:00
|
|
|
if(event){
|
|
|
|
if(event.type === "touchstart"){
|
|
|
|
event.preventDefault()
|
|
|
|
this.touched = true
|
|
|
|
}else if(event.type === "mousedown" && event.which !== 1){
|
|
|
|
return
|
|
|
|
}
|
2018-10-06 15:24:23 +02:00
|
|
|
}
|
2018-10-05 19:03:59 +02:00
|
|
|
this.titleScreen.style.cursor = "auto"
|
2018-09-18 00:37:59 +02:00
|
|
|
this.clean()
|
2019-02-04 10:14:42 +01:00
|
|
|
assets.sounds["se_don"].play()
|
2018-11-01 23:05:18 +01:00
|
|
|
this.goNext()
|
2018-09-26 20:30:57 +02:00
|
|
|
}
|
2018-11-01 23:05:18 +01:00
|
|
|
goNext(fromP2){
|
|
|
|
if(p2.session && !fromP2){
|
|
|
|
p2.send("songsel")
|
|
|
|
}else if(fromP2 || this.touched || localStorage.getItem("tutorial") === "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
|
|
|
if(this.touched){
|
|
|
|
localStorage.setItem("tutorial", "true")
|
|
|
|
}
|
2018-11-01 23:05:18 +01:00
|
|
|
pageEvents.remove(p2, "message")
|
|
|
|
setTimeout(() => {
|
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
|
|
|
new SongSelect(false, false, this.touched, this.songId)
|
2018-11-01 23:05:18 +01:00
|
|
|
}, 500)
|
2018-10-06 17:09:57 +02:00
|
|
|
}else{
|
2018-11-01 23:05:18 +01:00
|
|
|
setTimeout(() => {
|
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
|
|
|
new Tutorial(false, this.songId)
|
2018-11-01 23:05:18 +01:00
|
|
|
}, 500)
|
2018-09-18 00:37:59 +02:00
|
|
|
}
|
|
|
|
}
|
2019-01-21 16:47:22 +01:00
|
|
|
|
|
|
|
getLang(){
|
|
|
|
if(localStorage.lang && localStorage.lang in allStrings){
|
|
|
|
return localStorage.lang
|
|
|
|
}
|
|
|
|
if("languages" in navigator){
|
|
|
|
var userLang = navigator.languages.slice()
|
|
|
|
userLang.unshift(navigator.language)
|
|
|
|
for(var i in userLang){
|
|
|
|
for(var j in allStrings){
|
|
|
|
if(allStrings[j].regex.test(userLang[i])){
|
|
|
|
return j
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "ja"
|
|
|
|
}
|
|
|
|
setLang(lang){
|
|
|
|
strings = lang
|
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
|
|
|
|
|
|
|
loader.screen.style.fontFamily = strings.font
|
|
|
|
loader.screen.style.fontWeight = strings.font === "Microsoft YaHei, sans-serif" ? "bold" : ""
|
|
|
|
|
|
|
|
if(failedTests.length !== 0){
|
|
|
|
showUnsupported(strings)
|
|
|
|
}
|
|
|
|
if(this.songId){
|
|
|
|
return
|
|
|
|
}
|
2019-01-21 16:47:22 +01:00
|
|
|
this.proceed.innerText = strings.titleProceed
|
|
|
|
this.proceed.setAttribute("alt", strings.titleProceed)
|
2019-01-21 20:08:02 +01:00
|
|
|
this.langId.innerText = strings.id.toUpperCase()
|
|
|
|
this.langId.setAttribute("alt", strings.id.toUpperCase())
|
2019-01-28 12:43:18 +01:00
|
|
|
|
|
|
|
this.disclaimerText.innerText = strings.titleDisclaimer
|
|
|
|
this.disclaimerText.setAttribute("alt", strings.titleDisclaimer)
|
|
|
|
this.disclaimerCopyright.innerText = strings.titleCopyright
|
|
|
|
this.disclaimerCopyright.setAttribute("alt", strings.titleCopyright)
|
|
|
|
|
2019-01-28 02:57:18 +01:00
|
|
|
this.logo.updateSubtitle()
|
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("language-change", lang.id)
|
2019-01-21 16:47:22 +01:00
|
|
|
}
|
|
|
|
addLangs(){
|
|
|
|
for(var i in allStrings){
|
|
|
|
var option = document.createElement("option")
|
|
|
|
option.value = i
|
|
|
|
if(i === this.lang){
|
|
|
|
option.selected = true
|
|
|
|
}
|
|
|
|
option.appendChild(document.createTextNode(allStrings[i].name))
|
|
|
|
this.langDropdown.appendChild(option)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
langChange(){
|
|
|
|
this.lang = this.langDropdown.value
|
|
|
|
localStorage.lang = this.lang
|
|
|
|
this.setLang(allStrings[this.lang])
|
|
|
|
}
|
|
|
|
|
2018-09-18 00:37:59 +02:00
|
|
|
clean(){
|
2018-09-26 20:30:57 +02:00
|
|
|
this.gamepad.clean()
|
2019-01-28 02:57:18 +01:00
|
|
|
this.logo.clean()
|
2019-02-04 10:14:42 +01:00
|
|
|
assets.sounds["v_title"].stop()
|
2018-10-09 08:59:36 +02:00
|
|
|
pageEvents.keyRemove(this, "all")
|
2018-10-12 20:04:28 +02:00
|
|
|
pageEvents.remove(this.titleScreen, ["mousedown", "touchstart"])
|
2019-01-21 16:47:22 +01:00
|
|
|
pageEvents.remove(this.langDropdown, "change")
|
2018-09-18 00:37:59 +02:00
|
|
|
delete this.titleScreen
|
2019-01-21 16:47:22 +01:00
|
|
|
delete this.proceed
|
2019-01-28 12:50:22 +01:00
|
|
|
delete this.titleDisclaimer
|
|
|
|
delete this.titleCopyright
|
2019-01-21 16:47:22 +01:00
|
|
|
delete this.langDropdown
|
2018-09-18 00:37:59 +02:00
|
|
|
}
|
|
|
|
}
|