2018-12-13 17:18:52 +08:00
|
|
|
class LoadSong{
|
2018-10-06 01:03:59 +08:00
|
|
|
constructor(selectedSong, autoPlayEnabled, multiplayer, touchEnabled){
|
2018-09-11 06:17:13 +08:00
|
|
|
this.selectedSong = selectedSong
|
|
|
|
this.autoPlayEnabled = autoPlayEnabled
|
2018-10-06 01:03:59 +08:00
|
|
|
this.multiplayer = multiplayer
|
|
|
|
this.touchEnabled = touchEnabled
|
2019-04-05 04:40:11 +08:00
|
|
|
var resolution = settings.getItem("resolution")
|
|
|
|
this.imgScale = 1
|
|
|
|
if(resolution === "medium"){
|
|
|
|
this.imgScale = 0.75
|
|
|
|
}else if(resolution === "low"){
|
|
|
|
this.imgScale = 0.5
|
|
|
|
}else if(resolution === "lowest"){
|
|
|
|
this.imgScale = 0.25
|
|
|
|
}
|
2018-11-26 06:42:24 +08:00
|
|
|
|
2019-01-16 20:33:42 +08:00
|
|
|
loader.changePage("loadsong", true)
|
2019-01-05 15:44:28 +08:00
|
|
|
var loadingText = document.getElementById("loading-text")
|
|
|
|
loadingText.appendChild(document.createTextNode(strings.loading))
|
|
|
|
loadingText.setAttribute("alt", strings.loading)
|
|
|
|
if(multiplayer){
|
|
|
|
var cancel = document.getElementById("p2-cancel-button")
|
|
|
|
cancel.appendChild(document.createTextNode(strings.cancel))
|
|
|
|
cancel.setAttribute("alt", strings.cancel)
|
|
|
|
}
|
2018-09-18 06:37:59 +08:00
|
|
|
this.run()
|
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 17:32:45 +08:00
|
|
|
pageEvents.send("load-song", {
|
|
|
|
selectedSong: selectedSong,
|
|
|
|
autoPlayEnabled: autoPlayEnabled,
|
2019-02-15 06:10:34 +08:00
|
|
|
multiplayer: multiplayer,
|
|
|
|
touchEnabled: touchEnabled
|
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 17:32:45 +08:00
|
|
|
})
|
2018-09-11 06:17:13 +08:00
|
|
|
}
|
|
|
|
run(){
|
2018-11-26 06:42:24 +08:00
|
|
|
var song = this.selectedSong
|
|
|
|
var id = song.folder
|
2020-03-16 21:42:36 +08:00
|
|
|
this.promises = []
|
2019-11-28 14:04:40 +08:00
|
|
|
if(song.folder !== "calibration"){
|
|
|
|
assets.sounds["v_start"].play()
|
|
|
|
var songObj = assets.songs.find(song => song.id === id)
|
|
|
|
}else{
|
|
|
|
var songObj = {
|
|
|
|
"music": "muted",
|
|
|
|
"chart": "blank"
|
|
|
|
}
|
|
|
|
}
|
2015-07-18 10:57:56 +08:00
|
|
|
|
2018-11-26 06:42:24 +08:00
|
|
|
song.songBg = this.randInt(1, 5)
|
|
|
|
song.songStage = this.randInt(1, 3)
|
2018-12-02 23:25:42 +08:00
|
|
|
song.donBg = this.randInt(1, 6)
|
|
|
|
|
2018-11-26 06:42:24 +08:00
|
|
|
if(song.songSkin && song.songSkin.name){
|
|
|
|
var imgLoad = []
|
|
|
|
for(var type in song.songSkin){
|
|
|
|
var value = song.songSkin[type]
|
2019-02-03 20:04:25 +08:00
|
|
|
if(["song", "stage", "don"].indexOf(type) !== -1 && value && value !== "none"){
|
2018-11-26 06:42:24 +08:00
|
|
|
var filename = "bg_" + type + "_" + song.songSkin.name
|
|
|
|
if(value === "static"){
|
|
|
|
imgLoad.push({
|
|
|
|
filename: filename,
|
|
|
|
type: type
|
|
|
|
})
|
|
|
|
}else{
|
|
|
|
imgLoad.push({
|
|
|
|
filename: filename + "_a",
|
|
|
|
type: type
|
|
|
|
})
|
|
|
|
imgLoad.push({
|
|
|
|
filename: filename + "_b",
|
|
|
|
type: type
|
|
|
|
})
|
|
|
|
}
|
2019-01-01 09:16:55 +08:00
|
|
|
if(type === "don"){
|
|
|
|
song.donBg = null
|
2019-04-05 04:40:11 +08:00
|
|
|
}else if(type === "song"){
|
2018-12-02 23:25:42 +08:00
|
|
|
song.songBg = null
|
2019-04-05 04:40:11 +08:00
|
|
|
}else if(type === "stage"){
|
|
|
|
song.songStage = null
|
2018-12-02 23:25:42 +08:00
|
|
|
}
|
2018-11-26 06:42:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
var skinBase = gameConfig.assets_baseurl + "song_skins/"
|
|
|
|
for(var i = 0; i < imgLoad.length; i++){
|
2019-02-03 20:04:25 +08:00
|
|
|
let filename = imgLoad[i].filename
|
|
|
|
let prefix = song.songSkin.prefix || ""
|
|
|
|
if((prefix + filename) in assets.image){
|
|
|
|
continue
|
|
|
|
}
|
2018-11-26 06:42:24 +08:00
|
|
|
let img = document.createElement("img")
|
2019-04-05 04:40:11 +08:00
|
|
|
let force = imgLoad[i].type === "song" && this.touchEnabled
|
|
|
|
if(!songObj.music && (this.imgScale !== 1 || force)){
|
2018-11-30 22:47:53 +08:00
|
|
|
img.crossOrigin = "Anonymous"
|
|
|
|
}
|
2018-11-26 06:42:24 +08:00
|
|
|
let promise = pageEvents.load(img)
|
2020-03-16 21:42:36 +08:00
|
|
|
this.addPromise(promise.then(() => {
|
2019-04-05 04:40:11 +08:00
|
|
|
return this.scaleImg(img, filename, prefix, force)
|
2020-03-16 21:42:36 +08:00
|
|
|
}), songObj.music ? filename + ".png" : skinBase + filename + ".png")
|
2019-02-03 20:04:25 +08:00
|
|
|
if(songObj.music){
|
|
|
|
img.src = URL.createObjectURL(song.songSkin[filename + ".png"])
|
|
|
|
}else{
|
|
|
|
img.src = skinBase + filename + ".png"
|
|
|
|
}
|
2018-11-26 06:42:24 +08:00
|
|
|
}
|
|
|
|
}
|
2020-03-16 21:42:36 +08:00
|
|
|
this.loadSongBg(id)
|
2015-07-17 16:22:46 +08:00
|
|
|
|
2020-03-16 21:42:36 +08:00
|
|
|
var url = gameConfig.songs_baseurl + id + "/main.mp3"
|
|
|
|
this.addPromise(new Promise((resolve, reject) => {
|
2018-09-11 06:17:13 +08:00
|
|
|
if(songObj.sound){
|
|
|
|
songObj.sound.gain = snd.musicGain
|
|
|
|
resolve()
|
2019-03-06 05:48:30 +08:00
|
|
|
}else if(!songObj.music){
|
2020-03-16 21:42:36 +08:00
|
|
|
snd.musicGain.load(url).then(sound => {
|
2018-12-06 04:33:34 +08:00
|
|
|
songObj.sound = sound
|
|
|
|
resolve()
|
|
|
|
}, reject)
|
2019-03-06 05:48:30 +08:00
|
|
|
}else if(songObj.music !== "muted"){
|
|
|
|
snd.musicGain.load(songObj.music, true).then(sound => {
|
2018-09-11 06:17:13 +08:00
|
|
|
songObj.sound = sound
|
|
|
|
resolve()
|
|
|
|
}, reject)
|
2019-03-06 05:48:30 +08:00
|
|
|
}else{
|
|
|
|
resolve()
|
2018-08-29 13:55:16 +08:00
|
|
|
}
|
2020-03-16 21:42:36 +08:00
|
|
|
}), songObj.music ? songObj.music.webkitRelativePath : url)
|
2018-12-06 04:33:34 +08:00
|
|
|
if(songObj.chart){
|
2019-11-28 14:04:40 +08:00
|
|
|
if(songObj.chart === "blank"){
|
|
|
|
this.songData = ""
|
2019-03-16 05:34:48 +08:00
|
|
|
}else{
|
2019-11-28 14:04:40 +08:00
|
|
|
var reader = new FileReader()
|
2020-03-16 21:42:36 +08:00
|
|
|
this.addPromise(pageEvents.load(reader).then(event => {
|
2019-11-28 14:04:40 +08:00
|
|
|
this.songData = event.target.result.replace(/\0/g, "").split("\n")
|
2020-03-16 21:42:36 +08:00
|
|
|
}), songObj.chart.webkitRelativePath)
|
2019-11-28 14:04:40 +08:00
|
|
|
if(song.type === "tja"){
|
|
|
|
reader.readAsText(songObj.chart, "sjis")
|
|
|
|
}else{
|
|
|
|
reader.readAsText(songObj.chart)
|
|
|
|
}
|
2019-03-16 05:34:48 +08:00
|
|
|
}
|
2018-12-06 04:33:34 +08:00
|
|
|
}else{
|
2020-03-16 21:42:36 +08:00
|
|
|
var url = this.getSongPath(song)
|
|
|
|
this.addPromise(loader.ajax(url).then(data => {
|
2018-12-06 04:33:34 +08:00
|
|
|
this.songData = data.replace(/\0/g, "").split("\n")
|
2020-03-16 21:42:36 +08:00
|
|
|
}), url)
|
2018-12-06 04:33:34 +08:00
|
|
|
}
|
2019-04-05 04:40:11 +08:00
|
|
|
if(this.touchEnabled && !assets.image["touch_drum"]){
|
|
|
|
let img = document.createElement("img")
|
|
|
|
if(this.imgScale !== 1){
|
|
|
|
img.crossOrigin = "Anonymous"
|
|
|
|
}
|
2020-03-16 21:42:36 +08:00
|
|
|
var url = gameConfig.assets_baseurl + "img/touch_drum.png"
|
|
|
|
this.addPromise(pageEvents.load(img).then(() => {
|
2019-04-05 04:40:11 +08:00
|
|
|
return this.scaleImg(img, "touch_drum", "")
|
2020-03-16 21:42:36 +08:00
|
|
|
}), url)
|
|
|
|
img.src = url
|
2019-04-05 04:40:11 +08:00
|
|
|
}
|
2020-03-16 21:42:36 +08:00
|
|
|
Promise.all(this.promises).then(() => {
|
|
|
|
if(!this.error){
|
|
|
|
this.setupMultiplayer()
|
2018-12-04 06:23:11 +08:00
|
|
|
}
|
2018-09-11 06:17:13 +08:00
|
|
|
})
|
2015-07-17 16:22:46 +08:00
|
|
|
}
|
2020-03-16 21:42:36 +08:00
|
|
|
addPromise(promise, url){
|
|
|
|
this.promises.push(promise.catch(response => {
|
|
|
|
this.errorMsg(response, url)
|
|
|
|
return Promise.resolve()
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
errorMsg(error, url){
|
|
|
|
if(!this.error){
|
|
|
|
if(url){
|
|
|
|
error = (Array.isArray(error) ? error[0] + ": " : (error ? error + ": " : "")) + url
|
2018-12-02 23:25:42 +08:00
|
|
|
}
|
2020-03-16 21:42:36 +08:00
|
|
|
pageEvents.send("load-song-error", error)
|
|
|
|
errorMessage(new Error(error).stack)
|
|
|
|
var title = this.selectedSong.title
|
|
|
|
if(title !== this.selectedSong.originalTitle){
|
|
|
|
title += " (" + this.selectedSong.originalTitle + ")"
|
2018-12-02 23:25:42 +08:00
|
|
|
}
|
2020-03-16 21:42:36 +08:00
|
|
|
this.clean()
|
|
|
|
new SongSelect(false, false, this.touchEnabled, null, {
|
|
|
|
name: "loadSongError",
|
|
|
|
title: title,
|
|
|
|
id: this.selectedSong.folder,
|
|
|
|
error: error
|
|
|
|
})
|
|
|
|
}
|
|
|
|
this.error = true
|
|
|
|
}
|
|
|
|
loadSongBg(){
|
|
|
|
var filenames = []
|
|
|
|
if(this.selectedSong.songBg !== null){
|
|
|
|
filenames.push("bg_song_" + this.selectedSong.songBg)
|
|
|
|
}
|
|
|
|
if(this.selectedSong.donBg !== null){
|
|
|
|
filenames.push("bg_don_" + this.selectedSong.donBg)
|
|
|
|
if(this.multiplayer){
|
|
|
|
filenames.push("bg_don2_" + this.selectedSong.donBg)
|
2019-04-05 04:40:11 +08:00
|
|
|
}
|
2020-03-16 21:42:36 +08:00
|
|
|
}
|
|
|
|
if(this.selectedSong.songStage !== null){
|
|
|
|
filenames.push("bg_stage_" + this.selectedSong.songStage)
|
|
|
|
}
|
|
|
|
for(var i = 0; i < filenames.length; i++){
|
|
|
|
var filename = filenames[i]
|
|
|
|
var stage = filename.startsWith("bg_stage_")
|
|
|
|
for(var letter = 0; letter < (stage ? 1 : 2); letter++){
|
|
|
|
let filenameAb = filenames[i] + (stage ? "" : (letter === 0 ? "a" : "b"))
|
|
|
|
if(!(filenameAb in assets.image)){
|
|
|
|
let img = document.createElement("img")
|
|
|
|
let force = filenameAb.startsWith("bg_song_") && this.touchEnabled
|
|
|
|
if(this.imgScale !== 1 || force){
|
|
|
|
img.crossOrigin = "Anonymous"
|
2018-11-30 22:47:53 +08:00
|
|
|
}
|
2020-03-16 21:42:36 +08:00
|
|
|
var url = gameConfig.assets_baseurl + "img/" + filenameAb + ".png"
|
|
|
|
this.addPromise(pageEvents.load(img).then(() => {
|
|
|
|
return this.scaleImg(img, filenameAb, "", force)
|
|
|
|
}), url)
|
|
|
|
img.src = url
|
2018-11-24 02:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
2020-03-16 21:42:36 +08:00
|
|
|
}
|
2018-11-24 02:52:24 +08:00
|
|
|
}
|
2019-04-05 04:40:11 +08:00
|
|
|
scaleImg(img, filename, prefix, force){
|
2018-11-26 06:42:24 +08:00
|
|
|
return new Promise((resolve, reject) => {
|
2019-04-05 04:40:11 +08:00
|
|
|
var scale = this.imgScale
|
|
|
|
if(force && scale > 0.5){
|
|
|
|
scale = 0.5
|
|
|
|
}
|
|
|
|
if(scale !== 1){
|
2018-11-26 06:42:24 +08:00
|
|
|
var canvas = document.createElement("canvas")
|
2019-04-05 04:40:11 +08:00
|
|
|
var w = Math.floor(img.width * scale)
|
|
|
|
var h = Math.floor(img.height * scale)
|
2018-11-26 06:42:24 +08:00
|
|
|
canvas.width = w
|
|
|
|
canvas.height = h
|
|
|
|
var ctx = canvas.getContext("2d")
|
|
|
|
ctx.drawImage(img, 0, 0, w, h)
|
2018-11-27 07:05:02 +08:00
|
|
|
var saveScaled = url => {
|
2018-11-26 06:42:24 +08:00
|
|
|
let img2 = document.createElement("img")
|
|
|
|
pageEvents.load(img2).then(() => {
|
2019-02-03 20:04:25 +08:00
|
|
|
assets.image[prefix + filename] = img2
|
2018-11-26 06:42:24 +08:00
|
|
|
resolve()
|
|
|
|
}, reject)
|
2018-11-27 07:05:02 +08:00
|
|
|
img2.src = url
|
|
|
|
}
|
|
|
|
if("toBlob" in canvas){
|
|
|
|
canvas.toBlob(blob => {
|
|
|
|
saveScaled(URL.createObjectURL(blob))
|
|
|
|
})
|
|
|
|
}else{
|
|
|
|
saveScaled(canvas.toDataURL())
|
|
|
|
}
|
2018-11-26 06:42:24 +08:00
|
|
|
}else{
|
2019-02-03 20:04:25 +08:00
|
|
|
assets.image[prefix + filename] = img
|
2018-11-26 06:42:24 +08:00
|
|
|
resolve()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2018-11-24 02:52:24 +08:00
|
|
|
randInt(min, max){
|
|
|
|
return Math.floor(Math.random() * (max - min + 1)) + min
|
|
|
|
}
|
2018-10-11 06:13:24 +08:00
|
|
|
getSongPath(selectedSong){
|
2018-10-28 05:42:28 +08:00
|
|
|
var directory = gameConfig.songs_baseurl + selectedSong.folder + "/"
|
2018-10-11 06:13:24 +08:00
|
|
|
if(selectedSong.type === "tja"){
|
|
|
|
return directory + "main.tja"
|
|
|
|
}else{
|
|
|
|
return directory + selectedSong.difficulty + ".osu"
|
|
|
|
}
|
2018-09-19 01:33:18 +08:00
|
|
|
}
|
2018-09-13 01:10:00 +08:00
|
|
|
setupMultiplayer(){
|
2018-11-26 06:42:24 +08:00
|
|
|
var song = this.selectedSong
|
|
|
|
|
2018-09-13 01:10:00 +08:00
|
|
|
if(this.multiplayer){
|
2018-09-18 06:37:59 +08:00
|
|
|
var loadingText = document.getElementsByClassName("loading-text")[0]
|
2019-01-30 00:10:56 +08:00
|
|
|
loadingText.firstChild.data = strings.waitingForP2
|
|
|
|
loadingText.setAttribute("alt", strings.waitingForP2)
|
2018-09-18 06:37:59 +08:00
|
|
|
|
2018-11-13 12:36:15 +08:00
|
|
|
this.cancelButton = document.getElementById("p2-cancel-button")
|
|
|
|
this.cancelButton.style.display = "inline-block"
|
|
|
|
pageEvents.add(this.cancelButton, ["mousedown", "touchstart"], this.cancelLoad.bind(this))
|
|
|
|
|
2018-09-13 01:10:00 +08:00
|
|
|
this.song2Data = this.songData
|
2018-11-26 06:42:24 +08:00
|
|
|
this.selectedSong2 = song
|
2018-09-18 06:37:59 +08:00
|
|
|
pageEvents.add(p2, "message", event => {
|
|
|
|
if(event.type === "gameload"){
|
2018-11-13 12:36:15 +08:00
|
|
|
this.cancelButton.style.display = ""
|
|
|
|
|
2020-03-14 12:50:04 +08:00
|
|
|
if(event.value.diff === song.difficulty){
|
2018-11-13 12:36:15 +08:00
|
|
|
this.startMultiplayer()
|
2018-09-18 06:37:59 +08:00
|
|
|
}else{
|
2018-12-04 06:23:11 +08:00
|
|
|
this.selectedSong2 = {}
|
|
|
|
for(var i in this.selectedSong){
|
|
|
|
this.selectedSong2[i] = this.selectedSong[i]
|
2018-09-18 06:37:59 +08:00
|
|
|
}
|
2020-03-14 12:50:04 +08:00
|
|
|
this.selectedSong2.difficulty = event.value.diff
|
2018-11-26 06:42:24 +08:00
|
|
|
if(song.type === "tja"){
|
2018-11-13 12:36:15 +08:00
|
|
|
this.startMultiplayer()
|
2018-10-11 08:50:00 +08:00
|
|
|
}else{
|
|
|
|
loader.ajax(this.getSongPath(this.selectedSong2)).then(data => {
|
|
|
|
this.song2Data = data.replace(/\0/g, "").split("\n")
|
2018-11-13 12:36:15 +08:00
|
|
|
this.startMultiplayer()
|
2018-10-11 08:50:00 +08:00
|
|
|
}, () => {
|
2018-11-13 12:36:15 +08:00
|
|
|
this.startMultiplayer()
|
2018-10-11 08:50:00 +08:00
|
|
|
})
|
|
|
|
}
|
2018-09-18 06:37:59 +08:00
|
|
|
}
|
|
|
|
}else if(event.type === "gamestart"){
|
|
|
|
this.clean()
|
2018-11-02 06:05:18 +08:00
|
|
|
p2.clearMessage("songsel")
|
2018-11-26 06:42:24 +08:00
|
|
|
var taikoGame1 = new Controller(song, this.songData, false, 1, this.touchEnabled)
|
2018-10-25 22:18:41 +08:00
|
|
|
var taikoGame2 = new Controller(this.selectedSong2, this.song2Data, true, 2, this.touchEnabled)
|
2018-09-18 06:37:59 +08:00
|
|
|
taikoGame1.run(taikoGame2)
|
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 17:32:45 +08:00
|
|
|
pageEvents.send("load-song-player2", this.selectedSong2)
|
2018-11-13 12:36:15 +08:00
|
|
|
}else if(event.type === "left" || event.type === "gameend"){
|
|
|
|
this.clean()
|
|
|
|
new SongSelect(false, false, this.touchEnabled)
|
2018-09-13 01:10:00 +08:00
|
|
|
}
|
2018-09-18 06:37:59 +08:00
|
|
|
})
|
2018-09-13 01:10:00 +08:00
|
|
|
p2.send("join", {
|
2018-11-26 06:42:24 +08:00
|
|
|
id: song.folder,
|
2020-03-13 10:34:54 +08:00
|
|
|
diff: song.difficulty,
|
|
|
|
name: account.loggedIn ? account.displayName : null
|
2018-09-13 01:10:00 +08:00
|
|
|
})
|
|
|
|
}else{
|
2018-09-18 06:37:59 +08:00
|
|
|
this.clean()
|
2018-11-26 06:42:24 +08:00
|
|
|
var taikoGame = new Controller(song, this.songData, this.autoPlayEnabled, false, this.touchEnabled)
|
2018-09-13 01:10:00 +08:00
|
|
|
taikoGame.run()
|
|
|
|
}
|
|
|
|
}
|
2018-11-13 12:36:15 +08:00
|
|
|
startMultiplayer(repeat){
|
|
|
|
if(document.hasFocus()){
|
|
|
|
p2.send("gamestart")
|
|
|
|
}else{
|
|
|
|
if(!repeat){
|
2019-02-04 17:14:42 +08:00
|
|
|
assets.sounds["v_sanka"].play()
|
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 17:32:45 +08:00
|
|
|
pageEvents.send("load-song-unfocused")
|
2018-11-13 12:36:15 +08:00
|
|
|
}
|
|
|
|
setTimeout(() => {
|
|
|
|
this.startMultiplayer(true)
|
|
|
|
}, 100)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cancelLoad(event){
|
|
|
|
if(event.type === "mousedown"){
|
|
|
|
if(event.which !== 1){
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
event.preventDefault()
|
|
|
|
}
|
|
|
|
p2.send("leave")
|
2019-02-04 17:14:42 +08:00
|
|
|
assets.sounds["se_don"].play()
|
2018-11-13 12:36:15 +08:00
|
|
|
this.cancelButton.style.pointerEvents = "none"
|
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 17:32:45 +08:00
|
|
|
pageEvents.send("load-song-cancel")
|
2018-11-13 12:36:15 +08:00
|
|
|
}
|
2018-09-18 06:37:59 +08:00
|
|
|
clean(){
|
2020-03-16 21:42:36 +08:00
|
|
|
delete this.promises
|
2018-09-18 06:37:59 +08:00
|
|
|
pageEvents.remove(p2, "message")
|
2018-11-13 12:36:15 +08:00
|
|
|
if(this.cancelButton){
|
|
|
|
pageEvents.remove(this.cancelButton, ["mousedown", "touchstart"])
|
|
|
|
delete this.cancelButton
|
|
|
|
}
|
2018-09-18 06:37:59 +08:00
|
|
|
}
|
2018-09-13 01:10:00 +08:00
|
|
|
}
|