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
|
2021-05-27 19:23:19 +02:00
|
|
|
db.getItem("customFolder").then(folder => this.customFolder = folder)
|
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.disclaimerText = document.getElementById("title-disclaimer-text")
|
|
|
|
this.disclaimerCopyright = document.getElementById("title-disclaimer-copyright")
|
|
|
|
this.logo = new Logo()
|
|
|
|
}
|
2019-04-06 21:14:44 +02:00
|
|
|
this.setLang(allStrings[settings.getItem("language")])
|
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){
|
2019-02-17 17:26:46 +01:00
|
|
|
if(localStorage.getItem("tutorial") === "true"){
|
|
|
|
new SongSelect(false, false, this.touched, this.songId)
|
|
|
|
}else{
|
2019-04-16 20:06:41 +02:00
|
|
|
new SettingsView(false, true, this.songId)
|
2019-02-17 17:26:46 +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
|
|
|
}else{
|
2019-04-16 20:06:41 +02:00
|
|
|
pageEvents.add(this.titleScreen, ["mousedown", "touchstart"], event => {
|
|
|
|
if(event.type === "touchstart"){
|
|
|
|
event.preventDefault()
|
|
|
|
this.touched = true
|
|
|
|
}else if(event.type === "mousedown" && event.which !== 1){
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.onPressed(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
|
|
|
|
|
|
|
assets.sounds["v_title"].play()
|
2019-04-16 20:06:41 +02:00
|
|
|
this.keyboard = new Keyboard({
|
|
|
|
confirm: ["enter", "space", "don_l", "don_r"]
|
|
|
|
}, this.onPressed.bind(this))
|
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
|
|
|
this.gamepad = new Gamepad({
|
2020-03-12 05:59:28 +01:00
|
|
|
gamepadConfirm: ["a", "b", "x", "y", "start", "ls", "rs"]
|
2019-04-16 20:06:41 +02:00
|
|
|
}, this.onPressed.bind(this))
|
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
|
|
|
|
2019-04-16 20:06:41 +02:00
|
|
|
onPressed(pressed, name){
|
|
|
|
if(pressed){
|
2021-05-27 19:23:19 +02:00
|
|
|
if(name === "gamepadConfirm" && (snd.buffer.context.state === "suspended" || this.customFolder)){
|
2020-03-12 05:59:28 +01:00
|
|
|
return
|
|
|
|
}
|
2019-04-16 20:06:41 +02:00
|
|
|
this.titleScreen.style.cursor = "auto"
|
|
|
|
this.clean()
|
2021-05-28 03:55:53 +02:00
|
|
|
if(!this.customFolder || assets.customSongs){
|
|
|
|
assets.sounds["se_don"].play()
|
|
|
|
}
|
2019-04-16 20:06:41 +02:00
|
|
|
this.goNext()
|
2018-10-06 15:24:23 +02:00
|
|
|
}
|
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")
|
2018-10-06 17:09:57 +02:00
|
|
|
}else{
|
2021-05-27 19:23:19 +02:00
|
|
|
if(fromP2 || this.customFolder || localStorage.getItem("tutorial") === "true"){
|
|
|
|
if(this.touched){
|
|
|
|
localStorage.setItem("tutorial", "true")
|
|
|
|
}
|
|
|
|
pageEvents.remove(p2, "message")
|
|
|
|
if(this.customFolder && !fromP2 && !assets.customSongs){
|
|
|
|
var customSongs = new CustomSongs(this.touched, true)
|
2021-05-28 03:55:53 +02:00
|
|
|
var soundPlayed = false
|
|
|
|
customSongs.walkFilesystem(this.customFolder).then(files => {
|
|
|
|
assets.sounds["se_don"].play()
|
|
|
|
soundPlayed = true
|
|
|
|
return customSongs.importLocal(files)
|
|
|
|
}).catch(() => {
|
|
|
|
localStorage.removeItem("customSelected")
|
2021-05-27 19:23:19 +02:00
|
|
|
db.removeItem("customFolder")
|
2021-05-28 03:55:53 +02:00
|
|
|
if(!soundPlayed){
|
|
|
|
assets.sounds["se_don"].play()
|
|
|
|
}
|
|
|
|
setTimeout(() => {
|
|
|
|
new SongSelect(false, false, this.touched, this.songId)
|
|
|
|
}, 500)
|
2021-05-27 19:23:19 +02:00
|
|
|
})
|
|
|
|
}else{
|
|
|
|
setTimeout(() => {
|
|
|
|
new SongSelect(false, false, this.touched, this.songId)
|
|
|
|
}, 500)
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
setTimeout(() => {
|
|
|
|
new SettingsView(this.touched, true, this.songId)
|
|
|
|
}, 500)
|
|
|
|
}
|
2018-09-18 00:37:59 +02:00
|
|
|
}
|
|
|
|
}
|
2019-04-06 12:19:10 +02:00
|
|
|
setLang(lang, noEvent){
|
2019-04-06 21:14:44 +02:00
|
|
|
settings.setLang(lang, 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.songId){
|
|
|
|
return
|
|
|
|
}
|
2019-01-21 16:47:22 +01:00
|
|
|
this.proceed.innerText = strings.titleProceed
|
|
|
|
this.proceed.setAttribute("alt", strings.titleProceed)
|
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()
|
2019-01-21 16:47:22 +01:00
|
|
|
}
|
2018-09-18 00:37:59 +02:00
|
|
|
clean(){
|
2019-04-16 20:06:41 +02:00
|
|
|
this.keyboard.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-12 20:04:28 +02:00
|
|
|
pageEvents.remove(this.titleScreen, ["mousedown", "touchstart"])
|
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
|
2018-09-18 00:37:59 +02:00
|
|
|
}
|
|
|
|
}
|