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)
})
```
This commit is contained in:
LoveEevee
2019-02-14 12:32:45 +03:00
parent ca85bc1b2d
commit adc45cb652
20 changed files with 224 additions and 104 deletions

View File

@@ -25,6 +25,12 @@ class Loader{
var queryString = gameConfig._version.commit_short ? "?" + gameConfig._version.commit_short : ""
if(gameConfig.custom_js){
var script = document.createElement("script")
this.addPromise(pageEvents.load(script))
script.src = gameConfig.custom_js + queryString
document.head.appendChild(script)
}
assets.js.forEach(name => {
var script = document.createElement("script")
this.addPromise(pageEvents.load(script))
@@ -147,8 +153,15 @@ class Loader{
}
}))
var songId
var hashLower = location.hash.toLowerCase()
p2 = new P2Connection()
if(location.hash.length === 6){
if(hashLower.startsWith("#song=")){
var number = parseInt(location.hash.slice(6))
if(number > 0){
songId = number
}
}else if(location.hash.length === 6){
p2.hashLock = true
this.addPromise(new Promise(resolve => {
p2.open()
@@ -182,7 +195,7 @@ class Loader{
perf.load = Date.now() - this.startTime
this.canvasTest.clean()
this.clean()
this.callback()
this.callback(songId)
})
}, this.errorMsg.bind(this))